cola Report for recount2:SRP033725

Date: 2019-12-25 23:55:33 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 17931 rows and 61 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] 17931    61

Density distribution

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

library(ComplexHeatmap)
densityHeatmap(mat, ylab = "value", cluster_columns = TRUE, show_column_names = FALSE,
    mc.cores = 4)

plot of chunk density-heatmap

Suggest the best k

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

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

suggest_best_k(res_list)
The best k 1-PAC Mean silhouette Concordance Optional k
SD:hclust 4 1.000 0.999 1.000 ** 2,3
SD:mclust 6 1.000 0.992 0.995 ** 3,4,5
SD:NMF 3 1.000 1.000 1.000 ** 2
CV:hclust 3 1.000 1.000 1.000 ** 2
CV:pam 3 1.000 0.995 0.998 ** 2
CV:NMF 5 1.000 0.985 0.988 ** 3,4
MAD:hclust 3 1.000 0.988 0.994 ** 2
MAD:skmeans 4 1.000 0.991 0.994 **
MAD:pam 2 1.000 1.000 1.000 **
ATC:hclust 2 1.000 0.998 0.999 **
ATC:kmeans 2 1.000 1.000 1.000 **
ATC:pam 2 1.000 1.000 1.000 **
ATC:mclust 2 1.000 1.000 1.000 **
SD:pam 6 0.969 0.930 0.962 ** 2,3,5
CV:skmeans 4 0.959 0.967 0.978 **
SD:skmeans 4 0.932 0.965 0.977 * 3
MAD:mclust 5 0.921 0.907 0.957 *
ATC:skmeans 6 0.902 0.930 0.953 * 2
CV:mclust 4 0.893 0.922 0.961
MAD:NMF 4 0.881 0.888 0.952
MAD:kmeans 4 0.659 0.910 0.895
ATC:NMF 3 0.574 0.834 0.886
SD:kmeans 3 0.509 0.904 0.905
CV:kmeans 4 0.477 0.773 0.820

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

CDF of consensus matrices

Cumulative distribution function curves of consensus matrix for all methods.

collect_plots(res_list, fun = plot_ecdf)

plot of chunk collect-plots

Consensus heatmap

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

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

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

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

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

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

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

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

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

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

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

Membership heatmap

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

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

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

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

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

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

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

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

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

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

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

Signature heatmap

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

Note in following heatmaps, rows are scaled.

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

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

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

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

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

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

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

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

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

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

Statistics table

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

get_stats(res_list, k = 2)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      2 1.000           1.000       1.000          0.154 0.847   0.847
#> CV:NMF      2 0.895           0.964       0.978          0.208 0.820   0.820
#> MAD:NMF     2 0.758           0.935       0.966          0.225 0.820   0.820
#> ATC:NMF     2 0.720           0.819       0.916          0.264 0.744   0.744
#> SD:skmeans  2 0.847           0.899       0.949          0.444 0.531   0.531
#> CV:skmeans  2 0.492           0.904       0.918          0.476 0.531   0.531
#> MAD:skmeans 2 0.515           0.716       0.876          0.506 0.498   0.498
#> ATC:skmeans 2 0.932           0.905       0.964          0.361 0.640   0.640
#> SD:mclust   2 0.716           0.918       0.937          0.335 0.591   0.591
#> CV:mclust   2 0.699           0.972       0.968          0.369 0.591   0.591
#> MAD:mclust  2 0.428           0.860       0.882          0.287 0.793   0.793
#> ATC:mclust  2 1.000           1.000       1.000          0.232 0.768   0.768
#> SD:kmeans   2 0.602           0.944       0.961          0.202 0.820   0.820
#> CV:kmeans   2 0.166           0.584       0.742          0.350 0.820   0.820
#> MAD:kmeans  2 0.163           0.486       0.774          0.354 0.744   0.744
#> ATC:kmeans  2 1.000           1.000       1.000          0.181 0.820   0.820
#> SD:pam      2 1.000           1.000       1.000          0.181 0.820   0.820
#> CV:pam      2 1.000           1.000       1.000          0.181 0.820   0.820
#> MAD:pam     2 1.000           1.000       1.000          0.181 0.820   0.820
#> ATC:pam     2 1.000           1.000       1.000          0.181 0.820   0.820
#> SD:hclust   2 1.000           0.988       0.995          0.163 0.847   0.847
#> CV:hclust   2 1.000           1.000       1.000          0.181 0.820   0.820
#> MAD:hclust  2 1.000           0.977       0.984          0.167 0.847   0.847
#> ATC:hclust  2 1.000           0.998       0.999          0.183 0.820   0.820
get_stats(res_list, k = 3)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      3 1.000           1.000       1.000          1.873 0.711   0.659
#> CV:NMF      3 0.920           0.942       0.975          1.229 0.727   0.669
#> MAD:NMF     3 0.722           0.798       0.917          1.459 0.560   0.476
#> ATC:NMF     3 0.574           0.834       0.886          0.909 0.779   0.710
#> SD:skmeans  3 0.932           0.970       0.971          0.501 0.694   0.475
#> CV:skmeans  3 0.754           0.860       0.929          0.414 0.694   0.475
#> MAD:skmeans 3 0.808           0.940       0.959          0.325 0.785   0.587
#> ATC:skmeans 3 0.859           0.881       0.954          0.762 0.643   0.473
#> SD:mclust   3 1.000           0.994       0.996          0.928 0.762   0.598
#> CV:mclust   3 0.530           0.740       0.777          0.563 0.738   0.556
#> MAD:mclust  3 0.727           0.836       0.921          1.237 0.484   0.379
#> ATC:mclust  3 0.864           0.894       0.943          1.569 0.627   0.515
#> SD:kmeans   3 0.509           0.904       0.905          1.332 0.736   0.677
#> CV:kmeans   3 0.249           0.562       0.676          0.577 0.588   0.497
#> MAD:kmeans  3 0.255           0.577       0.679          0.608 0.578   0.464
#> ATC:kmeans  3 0.478           0.254       0.571          1.796 0.587   0.496
#> SD:pam      3 1.000           1.000       1.000          1.459 0.736   0.677
#> CV:pam      3 1.000           0.995       0.998          1.443 0.727   0.669
#> MAD:pam     3 0.659           0.921       0.948          1.836 0.686   0.617
#> ATC:pam     3 0.505           0.852       0.915          1.803 0.672   0.600
#> SD:hclust   3 1.000           0.999       1.000          0.306 0.941   0.930
#> CV:hclust   3 1.000           1.000       1.000          1.459 0.736   0.677
#> MAD:hclust  3 1.000           0.988       0.994          1.655 0.711   0.659
#> ATC:hclust  3 0.812           0.845       0.937          0.760 0.942   0.929
get_stats(res_list, k = 4)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      4 0.780           0.903       0.953        0.53201 0.762   0.574
#> CV:NMF      4 0.926           0.900       0.963        0.50758 0.732   0.522
#> MAD:NMF     4 0.881           0.888       0.952        0.27196 0.747   0.477
#> ATC:NMF     4 0.569           0.753       0.832        0.35468 0.740   0.535
#> SD:skmeans  4 0.932           0.965       0.977        0.10191 0.896   0.698
#> CV:skmeans  4 0.959           0.967       0.978        0.10594 0.896   0.698
#> MAD:skmeans 4 1.000           0.991       0.994        0.10726 0.896   0.698
#> ATC:skmeans 4 0.811           0.905       0.953        0.08430 0.739   0.441
#> SD:mclust   4 1.000           0.997       0.998        0.05209 0.967   0.907
#> CV:mclust   4 0.893           0.922       0.961        0.19282 0.861   0.647
#> MAD:mclust  4 0.893           0.917       0.958        0.07325 0.967   0.907
#> ATC:mclust  4 0.893           0.906       0.964        0.15602 0.880   0.714
#> SD:kmeans   4 0.622           0.897       0.897        0.41352 0.738   0.528
#> CV:kmeans   4 0.477           0.773       0.820        0.21600 0.795   0.548
#> MAD:kmeans  4 0.659           0.910       0.895        0.21046 0.847   0.642
#> ATC:kmeans  4 0.574           0.735       0.852        0.35853 0.756   0.483
#> SD:pam      4 0.814           0.936       0.963        0.53077 0.770   0.587
#> CV:pam      4 0.669           0.766       0.902        0.53227 0.740   0.535
#> MAD:pam     4 0.841           0.852       0.933        0.35417 0.654   0.396
#> ATC:pam     4 0.725           0.855       0.921        0.36379 0.738   0.511
#> SD:hclust   4 1.000           0.999       1.000        1.13163 0.760   0.695
#> CV:hclust   4 0.694           0.860       0.851        0.30004 0.762   0.572
#> MAD:hclust  4 0.757           0.934       0.948        0.11870 0.989   0.980
#> ATC:hclust  4 0.805           0.828       0.938        0.00802 0.997   0.996
get_stats(res_list, k = 5)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      5 0.738           0.709       0.852         0.1267 0.831   0.532
#> CV:NMF      5 1.000           0.985       0.988         0.1368 0.859   0.559
#> MAD:NMF     5 0.706           0.753       0.858         0.1111 0.790   0.410
#> ATC:NMF     5 0.539           0.617       0.740         0.0925 0.854   0.561
#> SD:skmeans  5 0.836           0.847       0.902         0.0541 0.984   0.936
#> CV:skmeans  5 0.825           0.874       0.881         0.0619 0.959   0.841
#> MAD:skmeans 5 0.852           0.870       0.891         0.0498 0.984   0.936
#> ATC:skmeans 5 0.790           0.820       0.897         0.1002 0.837   0.545
#> SD:mclust   5 1.000           0.993       0.996         0.1500 0.896   0.676
#> CV:mclust   5 0.765           0.772       0.823         0.1218 0.934   0.796
#> MAD:mclust  5 0.921           0.907       0.957         0.1354 0.896   0.676
#> ATC:mclust  5 0.873           0.801       0.904         0.1184 0.902   0.693
#> SD:kmeans   5 0.639           0.790       0.818         0.1166 1.000   1.000
#> CV:kmeans   5 0.632           0.713       0.782         0.0975 1.000   1.000
#> MAD:kmeans  5 0.723           0.811       0.838         0.0932 1.000   1.000
#> ATC:kmeans  5 0.635           0.685       0.794         0.1011 1.000   1.000
#> SD:pam      5 0.949           0.927       0.967         0.1104 0.932   0.790
#> CV:pam      5 0.762           0.805       0.873         0.1115 0.793   0.453
#> MAD:pam     5 0.835           0.833       0.893         0.0795 0.818   0.506
#> ATC:pam     5 0.808           0.772       0.896         0.0943 0.860   0.603
#> SD:hclust   5 0.828           0.957       0.969         0.5588 0.738   0.521
#> CV:hclust   5 0.890           0.929       0.977         0.2144 0.891   0.695
#> MAD:hclust  5 0.893           0.959       0.983         0.4330 0.738   0.521
#> ATC:hclust  5 0.757           0.925       0.971         0.4417 0.784   0.715
get_stats(res_list, k = 6)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      6 0.682           0.689       0.794        0.05111 0.864   0.503
#> CV:NMF      6 0.802           0.632       0.823        0.03862 0.898   0.563
#> MAD:NMF     6 0.742           0.618       0.812        0.04792 0.987   0.936
#> ATC:NMF     6 0.558           0.583       0.709        0.06532 0.940   0.759
#> SD:skmeans  6 0.820           0.833       0.889        0.05751 0.959   0.830
#> CV:skmeans  6 0.842           0.813       0.868        0.04219 0.932   0.703
#> MAD:skmeans 6 0.831           0.866       0.882        0.04903 0.907   0.635
#> ATC:skmeans 6 0.902           0.930       0.953        0.06096 0.905   0.643
#> SD:mclust   6 1.000           0.992       0.995        0.02444 0.981   0.912
#> CV:mclust   6 0.825           0.829       0.880        0.07143 0.883   0.563
#> MAD:mclust  6 0.883           0.856       0.919        0.04875 0.907   0.620
#> ATC:mclust  6 0.892           0.804       0.869        0.02760 0.942   0.771
#> SD:kmeans   6 0.691           0.680       0.769        0.06725 0.923   0.739
#> CV:kmeans   6 0.664           0.616       0.722        0.06012 0.844   0.534
#> MAD:kmeans  6 0.728           0.594       0.679        0.05602 0.885   0.613
#> ATC:kmeans  6 0.693           0.702       0.730        0.05513 0.866   0.563
#> SD:pam      6 0.969           0.930       0.962        0.03493 0.975   0.904
#> CV:pam      6 0.797           0.686       0.862        0.04814 0.879   0.593
#> MAD:pam     6 0.832           0.805       0.876        0.05989 0.936   0.755
#> ATC:pam     6 0.820           0.821       0.879        0.03321 0.959   0.841
#> SD:hclust   6 0.816           0.918       0.970        0.00597 0.999   0.998
#> CV:hclust   6 0.886           0.898       0.960        0.02557 0.987   0.955
#> MAD:hclust  6 0.893           0.959       0.983        0.01599 0.989   0.960
#> ATC:hclust  6 0.658           0.731       0.819        0.43631 0.762   0.562

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

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

collect_plots(res)

plot of chunk SD-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.988       0.995        0.16270 0.847   0.847
#> 3 3 1.000           0.999       1.000        0.30600 0.941   0.930
#> 4 4 1.000           0.999       1.000        1.13163 0.760   0.695
#> 5 5 0.828           0.957       0.969        0.55879 0.738   0.521
#> 6 6 0.816           0.918       0.970        0.00597 0.999   0.998

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
#> SRR1047813     1   0.000      0.994 1.000 0.000
#> SRR1047814     1   0.000      0.994 1.000 0.000
#> SRR1047815     1   0.000      0.994 1.000 0.000
#> SRR1047816     1   0.000      0.994 1.000 0.000
#> SRR1047817     1   0.000      0.994 1.000 0.000
#> SRR1047818     1   0.000      0.994 1.000 0.000
#> SRR1047819     1   0.000      0.994 1.000 0.000
#> SRR1047820     1   0.000      0.994 1.000 0.000
#> SRR1047821     1   0.000      0.994 1.000 0.000
#> SRR1047822     1   0.000      0.994 1.000 0.000
#> SRR1047823     1   0.000      0.994 1.000 0.000
#> SRR1047824     1   0.000      0.994 1.000 0.000
#> SRR1047825     1   0.000      0.994 1.000 0.000
#> SRR1047826     1   0.000      0.994 1.000 0.000
#> SRR1047827     1   0.000      0.994 1.000 0.000
#> SRR1047828     1   0.000      0.994 1.000 0.000
#> SRR1047829     1   0.000      0.994 1.000 0.000
#> SRR1047830     1   0.000      0.994 1.000 0.000
#> SRR1047831     1   0.000      0.994 1.000 0.000
#> SRR1047832     1   0.000      0.994 1.000 0.000
#> SRR1047833     2   0.000      1.000 0.000 1.000
#> SRR1047834     2   0.000      1.000 0.000 1.000
#> SRR1047835     2   0.000      1.000 0.000 1.000
#> SRR1047836     2   0.000      1.000 0.000 1.000
#> SRR1047837     2   0.000      1.000 0.000 1.000
#> SRR1047838     1   0.000      0.994 1.000 0.000
#> SRR1047839     1   0.000      0.994 1.000 0.000
#> SRR1047840     1   0.000      0.994 1.000 0.000
#> SRR1047841     1   0.000      0.994 1.000 0.000
#> SRR1047842     1   0.000      0.994 1.000 0.000
#> SRR1047843     1   0.000      0.994 1.000 0.000
#> SRR1047844     1   0.000      0.994 1.000 0.000
#> SRR1047845     1   0.000      0.994 1.000 0.000
#> SRR1047846     1   0.000      0.994 1.000 0.000
#> SRR1047847     1   0.000      0.994 1.000 0.000
#> SRR1047848     1   0.000      0.994 1.000 0.000
#> SRR1047849     1   0.000      0.994 1.000 0.000
#> SRR1047850     1   0.000      0.994 1.000 0.000
#> SRR1047851     1   0.000      0.994 1.000 0.000
#> SRR1047852     1   0.000      0.994 1.000 0.000
#> SRR1047853     1   0.000      0.994 1.000 0.000
#> SRR1047854     1   0.000      0.994 1.000 0.000
#> SRR1047855     1   0.000      0.994 1.000 0.000
#> SRR1047856     1   0.000      0.994 1.000 0.000
#> SRR1047857     1   0.000      0.994 1.000 0.000
#> SRR1047858     1   0.000      0.994 1.000 0.000
#> SRR1047859     1   0.000      0.994 1.000 0.000
#> SRR1047860     1   0.000      0.994 1.000 0.000
#> SRR1047861     1   0.000      0.994 1.000 0.000
#> SRR1047863     1   0.000      0.994 1.000 0.000
#> SRR1047864     1   0.634      0.813 0.840 0.160
#> SRR1047865     1   0.000      0.994 1.000 0.000
#> SRR1047866     1   0.000      0.994 1.000 0.000
#> SRR1047867     1   0.662      0.796 0.828 0.172
#> SRR1047868     1   0.000      0.994 1.000 0.000
#> SRR1047869     1   0.000      0.994 1.000 0.000
#> SRR1047870     1   0.000      0.994 1.000 0.000
#> SRR1047871     1   0.000      0.994 1.000 0.000
#> SRR1047872     1   0.000      0.994 1.000 0.000
#> SRR1047873     1   0.000      0.994 1.000 0.000
#> SRR1047874     1   0.000      0.994 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1 p2    p3
#> SRR1047813     1  0.0000      1.000 1.000  0 0.000
#> SRR1047814     1  0.0000      1.000 1.000  0 0.000
#> SRR1047815     1  0.0000      1.000 1.000  0 0.000
#> SRR1047816     1  0.0000      1.000 1.000  0 0.000
#> SRR1047817     1  0.0000      1.000 1.000  0 0.000
#> SRR1047818     1  0.0000      1.000 1.000  0 0.000
#> SRR1047819     1  0.0000      1.000 1.000  0 0.000
#> SRR1047820     1  0.0000      1.000 1.000  0 0.000
#> SRR1047821     1  0.0000      1.000 1.000  0 0.000
#> SRR1047822     1  0.0000      1.000 1.000  0 0.000
#> SRR1047823     1  0.0000      1.000 1.000  0 0.000
#> SRR1047824     1  0.0000      1.000 1.000  0 0.000
#> SRR1047825     1  0.0000      1.000 1.000  0 0.000
#> SRR1047826     1  0.0000      1.000 1.000  0 0.000
#> SRR1047827     1  0.0000      1.000 1.000  0 0.000
#> SRR1047828     1  0.0000      1.000 1.000  0 0.000
#> SRR1047829     1  0.0000      1.000 1.000  0 0.000
#> SRR1047830     1  0.0000      1.000 1.000  0 0.000
#> SRR1047831     1  0.0000      1.000 1.000  0 0.000
#> SRR1047832     1  0.0000      1.000 1.000  0 0.000
#> SRR1047833     2  0.0000      1.000 0.000  1 0.000
#> SRR1047834     2  0.0000      1.000 0.000  1 0.000
#> SRR1047835     2  0.0000      1.000 0.000  1 0.000
#> SRR1047836     2  0.0000      1.000 0.000  1 0.000
#> SRR1047837     2  0.0000      1.000 0.000  1 0.000
#> SRR1047838     1  0.0000      1.000 1.000  0 0.000
#> SRR1047839     1  0.0000      1.000 1.000  0 0.000
#> SRR1047840     1  0.0000      1.000 1.000  0 0.000
#> SRR1047841     1  0.0000      1.000 1.000  0 0.000
#> SRR1047842     1  0.0000      1.000 1.000  0 0.000
#> SRR1047843     1  0.0000      1.000 1.000  0 0.000
#> SRR1047844     1  0.0000      1.000 1.000  0 0.000
#> SRR1047845     1  0.0000      1.000 1.000  0 0.000
#> SRR1047846     1  0.0000      1.000 1.000  0 0.000
#> SRR1047847     1  0.0000      1.000 1.000  0 0.000
#> SRR1047848     1  0.0000      1.000 1.000  0 0.000
#> SRR1047849     1  0.0000      1.000 1.000  0 0.000
#> SRR1047850     1  0.0000      1.000 1.000  0 0.000
#> SRR1047851     1  0.0000      1.000 1.000  0 0.000
#> SRR1047852     1  0.0000      1.000 1.000  0 0.000
#> SRR1047853     1  0.0000      1.000 1.000  0 0.000
#> SRR1047854     1  0.0000      1.000 1.000  0 0.000
#> SRR1047855     1  0.0000      1.000 1.000  0 0.000
#> SRR1047856     1  0.0000      1.000 1.000  0 0.000
#> SRR1047857     1  0.0000      1.000 1.000  0 0.000
#> SRR1047858     1  0.0000      1.000 1.000  0 0.000
#> SRR1047859     1  0.0000      1.000 1.000  0 0.000
#> SRR1047860     1  0.0000      1.000 1.000  0 0.000
#> SRR1047861     1  0.0000      1.000 1.000  0 0.000
#> SRR1047863     1  0.0000      1.000 1.000  0 0.000
#> SRR1047864     3  0.0592      0.966 0.012  0 0.988
#> SRR1047865     1  0.0000      1.000 1.000  0 0.000
#> SRR1047866     1  0.0000      1.000 1.000  0 0.000
#> SRR1047867     3  0.0000      0.966 0.000  0 1.000
#> SRR1047868     1  0.0000      1.000 1.000  0 0.000
#> SRR1047869     1  0.0000      1.000 1.000  0 0.000
#> SRR1047870     1  0.0000      1.000 1.000  0 0.000
#> SRR1047871     1  0.0000      1.000 1.000  0 0.000
#> SRR1047872     1  0.0000      1.000 1.000  0 0.000
#> SRR1047873     1  0.0000      1.000 1.000  0 0.000
#> SRR1047874     1  0.0000      1.000 1.000  0 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette p1 p2    p3    p4
#> SRR1047813     1  0.0000      1.000  1  0 0.000 0.000
#> SRR1047814     1  0.0000      1.000  1  0 0.000 0.000
#> SRR1047815     1  0.0000      1.000  1  0 0.000 0.000
#> SRR1047816     1  0.0000      1.000  1  0 0.000 0.000
#> SRR1047817     1  0.0000      1.000  1  0 0.000 0.000
#> SRR1047818     1  0.0000      1.000  1  0 0.000 0.000
#> SRR1047819     1  0.0000      1.000  1  0 0.000 0.000
#> SRR1047820     1  0.0000      1.000  1  0 0.000 0.000
#> SRR1047821     1  0.0000      1.000  1  0 0.000 0.000
#> SRR1047822     1  0.0000      1.000  1  0 0.000 0.000
#> SRR1047823     1  0.0000      1.000  1  0 0.000 0.000
#> SRR1047824     1  0.0000      1.000  1  0 0.000 0.000
#> SRR1047825     1  0.0000      1.000  1  0 0.000 0.000
#> SRR1047826     1  0.0000      1.000  1  0 0.000 0.000
#> SRR1047827     1  0.0000      1.000  1  0 0.000 0.000
#> SRR1047828     1  0.0000      1.000  1  0 0.000 0.000
#> SRR1047829     1  0.0000      1.000  1  0 0.000 0.000
#> SRR1047830     1  0.0000      1.000  1  0 0.000 0.000
#> SRR1047831     1  0.0000      1.000  1  0 0.000 0.000
#> SRR1047832     1  0.0000      1.000  1  0 0.000 0.000
#> SRR1047833     2  0.0000      1.000  0  1 0.000 0.000
#> SRR1047834     2  0.0000      1.000  0  1 0.000 0.000
#> SRR1047835     2  0.0000      1.000  0  1 0.000 0.000
#> SRR1047836     2  0.0000      1.000  0  1 0.000 0.000
#> SRR1047837     2  0.0000      1.000  0  1 0.000 0.000
#> SRR1047838     1  0.0000      1.000  1  0 0.000 0.000
#> SRR1047839     1  0.0000      1.000  1  0 0.000 0.000
#> SRR1047840     1  0.0000      1.000  1  0 0.000 0.000
#> SRR1047841     1  0.0000      1.000  1  0 0.000 0.000
#> SRR1047842     1  0.0000      1.000  1  0 0.000 0.000
#> SRR1047843     1  0.0000      1.000  1  0 0.000 0.000
#> SRR1047844     1  0.0000      1.000  1  0 0.000 0.000
#> SRR1047845     1  0.0000      1.000  1  0 0.000 0.000
#> SRR1047846     1  0.0000      1.000  1  0 0.000 0.000
#> SRR1047847     1  0.0000      1.000  1  0 0.000 0.000
#> SRR1047848     1  0.0000      1.000  1  0 0.000 0.000
#> SRR1047849     1  0.0000      1.000  1  0 0.000 0.000
#> SRR1047850     1  0.0000      1.000  1  0 0.000 0.000
#> SRR1047851     1  0.0000      1.000  1  0 0.000 0.000
#> SRR1047852     1  0.0000      1.000  1  0 0.000 0.000
#> SRR1047853     1  0.0000      1.000  1  0 0.000 0.000
#> SRR1047854     1  0.0000      1.000  1  0 0.000 0.000
#> SRR1047855     1  0.0000      1.000  1  0 0.000 0.000
#> SRR1047856     1  0.0000      1.000  1  0 0.000 0.000
#> SRR1047857     1  0.0000      1.000  1  0 0.000 0.000
#> SRR1047858     1  0.0000      1.000  1  0 0.000 0.000
#> SRR1047859     1  0.0000      1.000  1  0 0.000 0.000
#> SRR1047860     1  0.0000      1.000  1  0 0.000 0.000
#> SRR1047861     1  0.0000      1.000  1  0 0.000 0.000
#> SRR1047863     3  0.0000      1.000  0  0 1.000 0.000
#> SRR1047864     4  0.0469      0.984  0  0 0.012 0.988
#> SRR1047865     3  0.0000      1.000  0  0 1.000 0.000
#> SRR1047866     3  0.0000      1.000  0  0 1.000 0.000
#> SRR1047867     4  0.0000      0.984  0  0 0.000 1.000
#> SRR1047868     3  0.0000      1.000  0  0 1.000 0.000
#> SRR1047869     3  0.0000      1.000  0  0 1.000 0.000
#> SRR1047870     3  0.0000      1.000  0  0 1.000 0.000
#> SRR1047871     3  0.0000      1.000  0  0 1.000 0.000
#> SRR1047872     3  0.0000      1.000  0  0 1.000 0.000
#> SRR1047873     3  0.0000      1.000  0  0 1.000 0.000
#> SRR1047874     3  0.0000      1.000  0  0 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1 p2    p3    p4   p5
#> SRR1047813     1  0.0000      0.923 1.000  0 0.000 0.000 0.00
#> SRR1047814     1  0.0000      0.923 1.000  0 0.000 0.000 0.00
#> SRR1047815     1  0.0000      0.923 1.000  0 0.000 0.000 0.00
#> SRR1047816     1  0.0000      0.923 1.000  0 0.000 0.000 0.00
#> SRR1047817     1  0.0000      0.923 1.000  0 0.000 0.000 0.00
#> SRR1047818     4  0.0404      0.982 0.012  0 0.000 0.988 0.00
#> SRR1047819     4  0.0404      0.982 0.012  0 0.000 0.988 0.00
#> SRR1047820     4  0.0404      0.982 0.012  0 0.000 0.988 0.00
#> SRR1047821     4  0.0404      0.982 0.012  0 0.000 0.988 0.00
#> SRR1047822     4  0.0404      0.982 0.012  0 0.000 0.988 0.00
#> SRR1047823     4  0.0404      0.982 0.012  0 0.000 0.988 0.00
#> SRR1047824     4  0.0404      0.982 0.012  0 0.000 0.988 0.00
#> SRR1047825     4  0.0404      0.982 0.012  0 0.000 0.988 0.00
#> SRR1047826     4  0.0404      0.982 0.012  0 0.000 0.988 0.00
#> SRR1047827     4  0.0404      0.982 0.012  0 0.000 0.988 0.00
#> SRR1047828     1  0.0000      0.923 1.000  0 0.000 0.000 0.00
#> SRR1047829     1  0.0000      0.923 1.000  0 0.000 0.000 0.00
#> SRR1047830     1  0.0000      0.923 1.000  0 0.000 0.000 0.00
#> SRR1047831     1  0.0000      0.923 1.000  0 0.000 0.000 0.00
#> SRR1047832     1  0.0000      0.923 1.000  0 0.000 0.000 0.00
#> SRR1047833     2  0.0000      1.000 0.000  1 0.000 0.000 0.00
#> SRR1047834     2  0.0000      1.000 0.000  1 0.000 0.000 0.00
#> SRR1047835     2  0.0000      1.000 0.000  1 0.000 0.000 0.00
#> SRR1047836     2  0.0000      1.000 0.000  1 0.000 0.000 0.00
#> SRR1047837     2  0.0000      1.000 0.000  1 0.000 0.000 0.00
#> SRR1047838     4  0.0963      0.982 0.036  0 0.000 0.964 0.00
#> SRR1047839     4  0.0963      0.982 0.036  0 0.000 0.964 0.00
#> SRR1047840     4  0.0963      0.982 0.036  0 0.000 0.964 0.00
#> SRR1047841     4  0.0963      0.982 0.036  0 0.000 0.964 0.00
#> SRR1047842     4  0.0963      0.982 0.036  0 0.000 0.964 0.00
#> SRR1047843     1  0.2516      0.878 0.860  0 0.000 0.140 0.00
#> SRR1047844     1  0.2516      0.878 0.860  0 0.000 0.140 0.00
#> SRR1047845     1  0.2516      0.878 0.860  0 0.000 0.140 0.00
#> SRR1047846     1  0.2516      0.878 0.860  0 0.000 0.140 0.00
#> SRR1047847     1  0.2516      0.878 0.860  0 0.000 0.140 0.00
#> SRR1047848     1  0.0404      0.924 0.988  0 0.000 0.012 0.00
#> SRR1047849     1  0.0404      0.924 0.988  0 0.000 0.012 0.00
#> SRR1047850     1  0.0404      0.924 0.988  0 0.000 0.012 0.00
#> SRR1047851     1  0.0404      0.924 0.988  0 0.000 0.012 0.00
#> SRR1047852     1  0.0404      0.924 0.988  0 0.000 0.012 0.00
#> SRR1047853     4  0.0963      0.982 0.036  0 0.000 0.964 0.00
#> SRR1047854     4  0.0963      0.982 0.036  0 0.000 0.964 0.00
#> SRR1047855     4  0.0963      0.982 0.036  0 0.000 0.964 0.00
#> SRR1047856     4  0.0963      0.982 0.036  0 0.000 0.964 0.00
#> SRR1047857     4  0.0963      0.982 0.036  0 0.000 0.964 0.00
#> SRR1047858     1  0.2516      0.878 0.860  0 0.000 0.140 0.00
#> SRR1047859     1  0.2516      0.878 0.860  0 0.000 0.140 0.00
#> SRR1047860     1  0.2516      0.878 0.860  0 0.000 0.140 0.00
#> SRR1047861     1  0.2516      0.878 0.860  0 0.000 0.140 0.00
#> SRR1047863     3  0.0000      1.000 0.000  0 1.000 0.000 0.00
#> SRR1047864     5  0.0693      0.986 0.000  0 0.008 0.012 0.98
#> SRR1047865     3  0.0000      1.000 0.000  0 1.000 0.000 0.00
#> SRR1047866     3  0.0000      1.000 0.000  0 1.000 0.000 0.00
#> SRR1047867     5  0.0000      0.986 0.000  0 0.000 0.000 1.00
#> SRR1047868     3  0.0000      1.000 0.000  0 1.000 0.000 0.00
#> SRR1047869     3  0.0000      1.000 0.000  0 1.000 0.000 0.00
#> SRR1047870     3  0.0000      1.000 0.000  0 1.000 0.000 0.00
#> SRR1047871     3  0.0000      1.000 0.000  0 1.000 0.000 0.00
#> SRR1047872     3  0.0000      1.000 0.000  0 1.000 0.000 0.00
#> SRR1047873     3  0.0000      1.000 0.000  0 1.000 0.000 0.00
#> SRR1047874     3  0.0000      1.000 0.000  0 1.000 0.000 0.00

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1 p2   p3    p4   p5   p6
#> SRR1047813     1  0.0000      0.919 1.000  0 0.00 0.000 0.00 0.00
#> SRR1047814     1  0.0000      0.919 1.000  0 0.00 0.000 0.00 0.00
#> SRR1047815     1  0.0000      0.919 1.000  0 0.00 0.000 0.00 0.00
#> SRR1047816     1  0.0000      0.919 1.000  0 0.00 0.000 0.00 0.00
#> SRR1047817     1  0.0000      0.919 1.000  0 0.00 0.000 0.00 0.00
#> SRR1047818     4  0.0000      0.982 0.000  0 0.00 1.000 0.00 0.00
#> SRR1047819     4  0.0000      0.982 0.000  0 0.00 1.000 0.00 0.00
#> SRR1047820     4  0.0000      0.982 0.000  0 0.00 1.000 0.00 0.00
#> SRR1047821     4  0.0000      0.982 0.000  0 0.00 1.000 0.00 0.00
#> SRR1047822     4  0.0000      0.982 0.000  0 0.00 1.000 0.00 0.00
#> SRR1047823     4  0.0000      0.982 0.000  0 0.00 1.000 0.00 0.00
#> SRR1047824     4  0.0000      0.982 0.000  0 0.00 1.000 0.00 0.00
#> SRR1047825     4  0.0000      0.982 0.000  0 0.00 1.000 0.00 0.00
#> SRR1047826     4  0.0000      0.982 0.000  0 0.00 1.000 0.00 0.00
#> SRR1047827     4  0.0000      0.982 0.000  0 0.00 1.000 0.00 0.00
#> SRR1047828     1  0.0000      0.919 1.000  0 0.00 0.000 0.00 0.00
#> SRR1047829     1  0.0000      0.919 1.000  0 0.00 0.000 0.00 0.00
#> SRR1047830     1  0.0000      0.919 1.000  0 0.00 0.000 0.00 0.00
#> SRR1047831     1  0.0000      0.919 1.000  0 0.00 0.000 0.00 0.00
#> SRR1047832     1  0.0000      0.919 1.000  0 0.00 0.000 0.00 0.00
#> SRR1047833     2  0.0000      1.000 0.000  1 0.00 0.000 0.00 0.00
#> SRR1047834     2  0.0000      1.000 0.000  1 0.00 0.000 0.00 0.00
#> SRR1047835     2  0.0000      1.000 0.000  1 0.00 0.000 0.00 0.00
#> SRR1047836     2  0.0000      1.000 0.000  1 0.00 0.000 0.00 0.00
#> SRR1047837     2  0.0000      1.000 0.000  1 0.00 0.000 0.00 0.00
#> SRR1047838     4  0.0632      0.982 0.024  0 0.00 0.976 0.00 0.00
#> SRR1047839     4  0.0632      0.982 0.024  0 0.00 0.976 0.00 0.00
#> SRR1047840     4  0.0632      0.982 0.024  0 0.00 0.976 0.00 0.00
#> SRR1047841     4  0.0632      0.982 0.024  0 0.00 0.976 0.00 0.00
#> SRR1047842     4  0.0632      0.982 0.024  0 0.00 0.976 0.00 0.00
#> SRR1047843     1  0.2300      0.871 0.856  0 0.00 0.144 0.00 0.00
#> SRR1047844     1  0.2300      0.871 0.856  0 0.00 0.144 0.00 0.00
#> SRR1047845     1  0.2300      0.871 0.856  0 0.00 0.144 0.00 0.00
#> SRR1047846     1  0.2300      0.871 0.856  0 0.00 0.144 0.00 0.00
#> SRR1047847     1  0.2300      0.871 0.856  0 0.00 0.144 0.00 0.00
#> SRR1047848     1  0.0363      0.921 0.988  0 0.00 0.012 0.00 0.00
#> SRR1047849     1  0.0363      0.921 0.988  0 0.00 0.012 0.00 0.00
#> SRR1047850     1  0.0363      0.921 0.988  0 0.00 0.012 0.00 0.00
#> SRR1047851     1  0.0363      0.921 0.988  0 0.00 0.012 0.00 0.00
#> SRR1047852     1  0.0363      0.921 0.988  0 0.00 0.012 0.00 0.00
#> SRR1047853     4  0.0632      0.982 0.024  0 0.00 0.976 0.00 0.00
#> SRR1047854     4  0.0632      0.982 0.024  0 0.00 0.976 0.00 0.00
#> SRR1047855     4  0.0632      0.982 0.024  0 0.00 0.976 0.00 0.00
#> SRR1047856     4  0.0632      0.982 0.024  0 0.00 0.976 0.00 0.00
#> SRR1047857     4  0.0632      0.982 0.024  0 0.00 0.976 0.00 0.00
#> SRR1047858     1  0.2300      0.871 0.856  0 0.00 0.144 0.00 0.00
#> SRR1047859     1  0.2300      0.871 0.856  0 0.00 0.144 0.00 0.00
#> SRR1047860     1  0.2300      0.871 0.856  0 0.00 0.144 0.00 0.00
#> SRR1047861     1  0.2300      0.871 0.856  0 0.00 0.144 0.00 0.00
#> SRR1047863     3  0.0000      0.981 0.000  0 1.00 0.000 0.00 0.00
#> SRR1047864     5  0.1267      0.000 0.000  0 0.00 0.000 0.94 0.06
#> SRR1047865     3  0.1267      0.954 0.000  0 0.94 0.000 0.06 0.00
#> SRR1047866     3  0.1267      0.954 0.000  0 0.94 0.000 0.06 0.00
#> SRR1047867     6  0.0000      0.000 0.000  0 0.00 0.000 0.00 1.00
#> SRR1047868     3  0.0000      0.981 0.000  0 1.00 0.000 0.00 0.00
#> SRR1047869     3  0.1267      0.954 0.000  0 0.94 0.000 0.06 0.00
#> SRR1047870     3  0.0000      0.981 0.000  0 1.00 0.000 0.00 0.00
#> SRR1047871     3  0.0000      0.981 0.000  0 1.00 0.000 0.00 0.00
#> SRR1047872     3  0.0000      0.981 0.000  0 1.00 0.000 0.00 0.00
#> SRR1047873     3  0.0000      0.981 0.000  0 1.00 0.000 0.00 0.00
#> SRR1047874     3  0.0000      0.981 0.000  0 1.00 0.000 0.00 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-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 17931 rows and 61 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 3.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk SD-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.602           0.944       0.961         0.2023 0.820   0.820
#> 3 3 0.509           0.904       0.905         1.3317 0.736   0.677
#> 4 4 0.622           0.897       0.897         0.4135 0.738   0.528
#> 5 5 0.639           0.790       0.818         0.1166 1.000   1.000
#> 6 6 0.691           0.680       0.769         0.0673 0.923   0.739

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
#> SRR1047813     1  0.0376      0.965 0.996 0.004
#> SRR1047814     1  0.0376      0.965 0.996 0.004
#> SRR1047815     1  0.0376      0.965 0.996 0.004
#> SRR1047816     1  0.0376      0.965 0.996 0.004
#> SRR1047817     1  0.0376      0.965 0.996 0.004
#> SRR1047818     1  0.0000      0.965 1.000 0.000
#> SRR1047819     1  0.0000      0.965 1.000 0.000
#> SRR1047820     1  0.0000      0.965 1.000 0.000
#> SRR1047821     1  0.0000      0.965 1.000 0.000
#> SRR1047822     1  0.0000      0.965 1.000 0.000
#> SRR1047823     1  0.0376      0.965 0.996 0.004
#> SRR1047824     1  0.0376      0.965 0.996 0.004
#> SRR1047825     1  0.0376      0.965 0.996 0.004
#> SRR1047826     1  0.0376      0.965 0.996 0.004
#> SRR1047827     1  0.0376      0.965 0.996 0.004
#> SRR1047828     1  0.0376      0.965 0.996 0.004
#> SRR1047829     1  0.0376      0.965 0.996 0.004
#> SRR1047830     1  0.0376      0.965 0.996 0.004
#> SRR1047831     1  0.0376      0.965 0.996 0.004
#> SRR1047832     1  0.0376      0.965 0.996 0.004
#> SRR1047833     2  0.5842      0.969 0.140 0.860
#> SRR1047834     2  0.5842      0.969 0.140 0.860
#> SRR1047835     2  0.5842      0.969 0.140 0.860
#> SRR1047836     2  0.5842      0.969 0.140 0.860
#> SRR1047837     2  0.5842      0.969 0.140 0.860
#> SRR1047838     1  0.0000      0.965 1.000 0.000
#> SRR1047839     1  0.0000      0.965 1.000 0.000
#> SRR1047840     1  0.0000      0.965 1.000 0.000
#> SRR1047841     1  0.0000      0.965 1.000 0.000
#> SRR1047842     1  0.0000      0.965 1.000 0.000
#> SRR1047843     1  0.0672      0.961 0.992 0.008
#> SRR1047844     1  0.0672      0.961 0.992 0.008
#> SRR1047845     1  0.0672      0.961 0.992 0.008
#> SRR1047846     1  0.0672      0.961 0.992 0.008
#> SRR1047847     1  0.0672      0.961 0.992 0.008
#> SRR1047848     1  0.0376      0.965 0.996 0.004
#> SRR1047849     1  0.0376      0.965 0.996 0.004
#> SRR1047850     1  0.0376      0.965 0.996 0.004
#> SRR1047851     1  0.0376      0.965 0.996 0.004
#> SRR1047852     1  0.0376      0.965 0.996 0.004
#> SRR1047853     1  0.0000      0.965 1.000 0.000
#> SRR1047854     1  0.0000      0.965 1.000 0.000
#> SRR1047855     1  0.0000      0.965 1.000 0.000
#> SRR1047856     1  0.0000      0.965 1.000 0.000
#> SRR1047857     1  0.0000      0.965 1.000 0.000
#> SRR1047858     1  0.0000      0.965 1.000 0.000
#> SRR1047859     1  0.0000      0.965 1.000 0.000
#> SRR1047860     1  0.0000      0.965 1.000 0.000
#> SRR1047861     1  0.0000      0.965 1.000 0.000
#> SRR1047863     1  0.5842      0.861 0.860 0.140
#> SRR1047864     1  0.5842      0.861 0.860 0.140
#> SRR1047865     1  0.5842      0.861 0.860 0.140
#> SRR1047866     1  0.5842      0.861 0.860 0.140
#> SRR1047867     2  0.0672      0.855 0.008 0.992
#> SRR1047868     1  0.5842      0.861 0.860 0.140
#> SRR1047869     1  0.5842      0.861 0.860 0.140
#> SRR1047870     1  0.5842      0.861 0.860 0.140
#> SRR1047871     1  0.5842      0.861 0.860 0.140
#> SRR1047872     1  0.5842      0.861 0.860 0.140
#> SRR1047873     1  0.5842      0.861 0.860 0.140
#> SRR1047874     1  0.5842      0.861 0.860 0.140

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1 p2    p3
#> SRR1047813     1  0.0892      0.884 0.980  0 0.020
#> SRR1047814     1  0.0892      0.884 0.980  0 0.020
#> SRR1047815     1  0.0892      0.884 0.980  0 0.020
#> SRR1047816     1  0.0892      0.884 0.980  0 0.020
#> SRR1047817     1  0.0892      0.884 0.980  0 0.020
#> SRR1047818     1  0.4887      0.859 0.772  0 0.228
#> SRR1047819     1  0.4887      0.859 0.772  0 0.228
#> SRR1047820     1  0.4887      0.859 0.772  0 0.228
#> SRR1047821     1  0.4887      0.859 0.772  0 0.228
#> SRR1047822     1  0.4887      0.859 0.772  0 0.228
#> SRR1047823     1  0.4399      0.870 0.812  0 0.188
#> SRR1047824     1  0.4399      0.870 0.812  0 0.188
#> SRR1047825     1  0.4399      0.870 0.812  0 0.188
#> SRR1047826     1  0.4399      0.870 0.812  0 0.188
#> SRR1047827     1  0.4399      0.870 0.812  0 0.188
#> SRR1047828     1  0.2165      0.895 0.936  0 0.064
#> SRR1047829     1  0.2165      0.895 0.936  0 0.064
#> SRR1047830     1  0.2165      0.895 0.936  0 0.064
#> SRR1047831     1  0.2165      0.895 0.936  0 0.064
#> SRR1047832     1  0.2165      0.895 0.936  0 0.064
#> SRR1047833     2  0.0000      1.000 0.000  1 0.000
#> SRR1047834     2  0.0000      1.000 0.000  1 0.000
#> SRR1047835     2  0.0000      1.000 0.000  1 0.000
#> SRR1047836     2  0.0000      1.000 0.000  1 0.000
#> SRR1047837     2  0.0000      1.000 0.000  1 0.000
#> SRR1047838     1  0.4887      0.859 0.772  0 0.228
#> SRR1047839     1  0.4887      0.859 0.772  0 0.228
#> SRR1047840     1  0.4887      0.859 0.772  0 0.228
#> SRR1047841     1  0.4887      0.859 0.772  0 0.228
#> SRR1047842     1  0.4887      0.859 0.772  0 0.228
#> SRR1047843     1  0.0747      0.892 0.984  0 0.016
#> SRR1047844     1  0.1529      0.889 0.960  0 0.040
#> SRR1047845     1  0.0747      0.892 0.984  0 0.016
#> SRR1047846     1  0.0747      0.892 0.984  0 0.016
#> SRR1047847     1  0.1529      0.889 0.960  0 0.040
#> SRR1047848     1  0.0747      0.885 0.984  0 0.016
#> SRR1047849     1  0.0747      0.885 0.984  0 0.016
#> SRR1047850     1  0.0747      0.885 0.984  0 0.016
#> SRR1047851     1  0.0747      0.885 0.984  0 0.016
#> SRR1047852     1  0.0747      0.885 0.984  0 0.016
#> SRR1047853     1  0.4002      0.873 0.840  0 0.160
#> SRR1047854     1  0.4002      0.873 0.840  0 0.160
#> SRR1047855     1  0.4002      0.873 0.840  0 0.160
#> SRR1047856     1  0.4002      0.873 0.840  0 0.160
#> SRR1047857     1  0.4002      0.873 0.840  0 0.160
#> SRR1047858     1  0.0747      0.892 0.984  0 0.016
#> SRR1047859     1  0.0747      0.892 0.984  0 0.016
#> SRR1047860     1  0.0747      0.892 0.984  0 0.016
#> SRR1047861     1  0.0747      0.892 0.984  0 0.016
#> SRR1047863     3  0.2878      0.968 0.096  0 0.904
#> SRR1047864     3  0.2625      0.958 0.084  0 0.916
#> SRR1047865     3  0.3879      0.922 0.152  0 0.848
#> SRR1047866     3  0.3686      0.909 0.140  0 0.860
#> SRR1047867     2  0.0000      1.000 0.000  1 0.000
#> SRR1047868     3  0.2878      0.968 0.096  0 0.904
#> SRR1047869     3  0.3879      0.922 0.152  0 0.848
#> SRR1047870     3  0.2878      0.968 0.096  0 0.904
#> SRR1047871     3  0.2878      0.968 0.096  0 0.904
#> SRR1047872     3  0.2878      0.968 0.096  0 0.904
#> SRR1047873     3  0.2878      0.968 0.096  0 0.904
#> SRR1047874     3  0.2878      0.968 0.096  0 0.904

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1047813     1  0.3674      0.884 0.848 0.000 0.036 0.116
#> SRR1047814     1  0.3674      0.884 0.848 0.000 0.036 0.116
#> SRR1047815     1  0.3674      0.884 0.848 0.000 0.036 0.116
#> SRR1047816     1  0.3674      0.884 0.848 0.000 0.036 0.116
#> SRR1047817     1  0.3674      0.884 0.848 0.000 0.036 0.116
#> SRR1047818     4  0.0376      0.932 0.004 0.000 0.004 0.992
#> SRR1047819     4  0.0376      0.932 0.004 0.000 0.004 0.992
#> SRR1047820     4  0.0376      0.932 0.004 0.000 0.004 0.992
#> SRR1047821     4  0.0376      0.932 0.004 0.000 0.004 0.992
#> SRR1047822     4  0.0376      0.932 0.004 0.000 0.004 0.992
#> SRR1047823     4  0.1452      0.920 0.036 0.000 0.008 0.956
#> SRR1047824     4  0.1452      0.920 0.036 0.000 0.008 0.956
#> SRR1047825     4  0.1452      0.920 0.036 0.000 0.008 0.956
#> SRR1047826     4  0.1452      0.920 0.036 0.000 0.008 0.956
#> SRR1047827     4  0.1452      0.920 0.036 0.000 0.008 0.956
#> SRR1047828     1  0.5339      0.678 0.624 0.000 0.020 0.356
#> SRR1047829     1  0.5339      0.678 0.624 0.000 0.020 0.356
#> SRR1047830     1  0.5339      0.678 0.624 0.000 0.020 0.356
#> SRR1047831     1  0.5339      0.678 0.624 0.000 0.020 0.356
#> SRR1047832     1  0.5339      0.678 0.624 0.000 0.020 0.356
#> SRR1047833     2  0.0000      0.985 0.000 1.000 0.000 0.000
#> SRR1047834     2  0.0000      0.985 0.000 1.000 0.000 0.000
#> SRR1047835     2  0.0000      0.985 0.000 1.000 0.000 0.000
#> SRR1047836     2  0.0000      0.985 0.000 1.000 0.000 0.000
#> SRR1047837     2  0.0000      0.985 0.000 1.000 0.000 0.000
#> SRR1047838     4  0.0000      0.931 0.000 0.000 0.000 1.000
#> SRR1047839     4  0.0000      0.931 0.000 0.000 0.000 1.000
#> SRR1047840     4  0.0000      0.931 0.000 0.000 0.000 1.000
#> SRR1047841     4  0.0000      0.931 0.000 0.000 0.000 1.000
#> SRR1047842     4  0.0000      0.931 0.000 0.000 0.000 1.000
#> SRR1047843     1  0.3831      0.886 0.792 0.000 0.004 0.204
#> SRR1047844     1  0.3831      0.886 0.792 0.000 0.004 0.204
#> SRR1047845     1  0.3831      0.886 0.792 0.000 0.004 0.204
#> SRR1047846     1  0.3831      0.886 0.792 0.000 0.004 0.204
#> SRR1047847     1  0.3831      0.886 0.792 0.000 0.004 0.204
#> SRR1047848     1  0.2814      0.895 0.868 0.000 0.000 0.132
#> SRR1047849     1  0.2814      0.895 0.868 0.000 0.000 0.132
#> SRR1047850     1  0.2814      0.895 0.868 0.000 0.000 0.132
#> SRR1047851     1  0.2814      0.895 0.868 0.000 0.000 0.132
#> SRR1047852     1  0.2814      0.895 0.868 0.000 0.000 0.132
#> SRR1047853     4  0.3024      0.807 0.148 0.000 0.000 0.852
#> SRR1047854     4  0.3024      0.807 0.148 0.000 0.000 0.852
#> SRR1047855     4  0.3024      0.807 0.148 0.000 0.000 0.852
#> SRR1047856     4  0.3024      0.807 0.148 0.000 0.000 0.852
#> SRR1047857     4  0.3024      0.807 0.148 0.000 0.000 0.852
#> SRR1047858     1  0.3356      0.893 0.824 0.000 0.000 0.176
#> SRR1047859     1  0.3356      0.893 0.824 0.000 0.000 0.176
#> SRR1047860     1  0.3356      0.893 0.824 0.000 0.000 0.176
#> SRR1047861     1  0.3356      0.893 0.824 0.000 0.000 0.176
#> SRR1047863     3  0.1584      0.978 0.012 0.000 0.952 0.036
#> SRR1047864     3  0.3552      0.886 0.128 0.000 0.848 0.024
#> SRR1047865     3  0.1488      0.961 0.032 0.000 0.956 0.012
#> SRR1047866     3  0.1174      0.963 0.020 0.000 0.968 0.012
#> SRR1047867     2  0.2589      0.921 0.116 0.884 0.000 0.000
#> SRR1047868     3  0.1584      0.978 0.012 0.000 0.952 0.036
#> SRR1047869     3  0.1488      0.961 0.032 0.000 0.956 0.012
#> SRR1047870     3  0.1584      0.978 0.012 0.000 0.952 0.036
#> SRR1047871     3  0.1584      0.978 0.012 0.000 0.952 0.036
#> SRR1047872     3  0.1584      0.978 0.012 0.000 0.952 0.036
#> SRR1047873     3  0.1584      0.978 0.012 0.000 0.952 0.036
#> SRR1047874     3  0.1584      0.978 0.012 0.000 0.952 0.036

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4 p5
#> SRR1047813     1  0.4397      0.689 0.564 0.000 0.004 0.000 NA
#> SRR1047814     1  0.4397      0.689 0.564 0.000 0.004 0.000 NA
#> SRR1047815     1  0.4397      0.689 0.564 0.000 0.004 0.000 NA
#> SRR1047816     1  0.4397      0.689 0.564 0.000 0.004 0.000 NA
#> SRR1047817     1  0.4397      0.689 0.564 0.000 0.004 0.000 NA
#> SRR1047818     4  0.1992      0.846 0.032 0.000 0.000 0.924 NA
#> SRR1047819     4  0.1992      0.846 0.032 0.000 0.000 0.924 NA
#> SRR1047820     4  0.1992      0.846 0.032 0.000 0.000 0.924 NA
#> SRR1047821     4  0.1992      0.846 0.032 0.000 0.000 0.924 NA
#> SRR1047822     4  0.1992      0.846 0.032 0.000 0.000 0.924 NA
#> SRR1047823     4  0.4739      0.753 0.056 0.000 0.008 0.724 NA
#> SRR1047824     4  0.4739      0.753 0.056 0.000 0.008 0.724 NA
#> SRR1047825     4  0.4739      0.753 0.056 0.000 0.008 0.724 NA
#> SRR1047826     4  0.4739      0.753 0.056 0.000 0.008 0.724 NA
#> SRR1047827     4  0.4739      0.753 0.056 0.000 0.008 0.724 NA
#> SRR1047828     1  0.6553      0.548 0.432 0.000 0.000 0.204 NA
#> SRR1047829     1  0.6553      0.548 0.432 0.000 0.000 0.204 NA
#> SRR1047830     1  0.6553      0.548 0.432 0.000 0.000 0.204 NA
#> SRR1047831     1  0.6553      0.548 0.432 0.000 0.000 0.204 NA
#> SRR1047832     1  0.6553      0.548 0.432 0.000 0.000 0.204 NA
#> SRR1047833     2  0.0162      0.964 0.000 0.996 0.000 0.004 NA
#> SRR1047834     2  0.0000      0.965 0.000 1.000 0.000 0.000 NA
#> SRR1047835     2  0.0000      0.965 0.000 1.000 0.000 0.000 NA
#> SRR1047836     2  0.0000      0.965 0.000 1.000 0.000 0.000 NA
#> SRR1047837     2  0.0000      0.965 0.000 1.000 0.000 0.000 NA
#> SRR1047838     4  0.2011      0.848 0.088 0.000 0.004 0.908 NA
#> SRR1047839     4  0.2011      0.848 0.088 0.000 0.004 0.908 NA
#> SRR1047840     4  0.2011      0.848 0.088 0.000 0.004 0.908 NA
#> SRR1047841     4  0.2011      0.848 0.088 0.000 0.004 0.908 NA
#> SRR1047842     4  0.2011      0.848 0.088 0.000 0.004 0.908 NA
#> SRR1047843     1  0.3427      0.689 0.844 0.000 0.004 0.096 NA
#> SRR1047844     1  0.3494      0.687 0.840 0.000 0.004 0.096 NA
#> SRR1047845     1  0.3427      0.689 0.844 0.000 0.004 0.096 NA
#> SRR1047846     1  0.3427      0.689 0.844 0.000 0.004 0.096 NA
#> SRR1047847     1  0.3494      0.687 0.840 0.000 0.004 0.096 NA
#> SRR1047848     1  0.3596      0.740 0.776 0.000 0.000 0.012 NA
#> SRR1047849     1  0.3596      0.740 0.776 0.000 0.000 0.012 NA
#> SRR1047850     1  0.3596      0.740 0.776 0.000 0.000 0.012 NA
#> SRR1047851     1  0.3596      0.740 0.776 0.000 0.000 0.012 NA
#> SRR1047852     1  0.3596      0.740 0.776 0.000 0.000 0.012 NA
#> SRR1047853     4  0.4272      0.755 0.196 0.000 0.000 0.752 NA
#> SRR1047854     4  0.4272      0.755 0.196 0.000 0.000 0.752 NA
#> SRR1047855     4  0.4272      0.755 0.196 0.000 0.000 0.752 NA
#> SRR1047856     4  0.4272      0.755 0.196 0.000 0.000 0.752 NA
#> SRR1047857     4  0.4272      0.755 0.196 0.000 0.000 0.752 NA
#> SRR1047858     1  0.1124      0.713 0.960 0.000 0.000 0.036 NA
#> SRR1047859     1  0.1124      0.713 0.960 0.000 0.000 0.036 NA
#> SRR1047860     1  0.1124      0.713 0.960 0.000 0.000 0.036 NA
#> SRR1047861     1  0.1124      0.713 0.960 0.000 0.000 0.036 NA
#> SRR1047863     3  0.0566      0.968 0.004 0.000 0.984 0.012 NA
#> SRR1047864     3  0.4070      0.744 0.004 0.000 0.728 0.012 NA
#> SRR1047865     3  0.1106      0.956 0.012 0.000 0.964 0.024 NA
#> SRR1047866     3  0.1106      0.956 0.012 0.000 0.964 0.024 NA
#> SRR1047867     2  0.3534      0.814 0.000 0.744 0.000 0.000 NA
#> SRR1047868     3  0.0566      0.968 0.004 0.000 0.984 0.012 NA
#> SRR1047869     3  0.1106      0.956 0.012 0.000 0.964 0.024 NA
#> SRR1047870     3  0.0566      0.968 0.004 0.000 0.984 0.012 NA
#> SRR1047871     3  0.0451      0.965 0.004 0.000 0.988 0.008 NA
#> SRR1047872     3  0.0566      0.968 0.004 0.000 0.984 0.012 NA
#> SRR1047873     3  0.0566      0.968 0.004 0.000 0.984 0.012 NA
#> SRR1047874     3  0.0566      0.968 0.004 0.000 0.984 0.012 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
#> SRR1047813     5  0.3489      0.425 0.288 0.000 0.000 0.004 0.708 NA
#> SRR1047814     5  0.3489      0.425 0.288 0.000 0.000 0.004 0.708 NA
#> SRR1047815     5  0.3489      0.425 0.288 0.000 0.000 0.004 0.708 NA
#> SRR1047816     5  0.3489      0.425 0.288 0.000 0.000 0.004 0.708 NA
#> SRR1047817     5  0.3489      0.425 0.288 0.000 0.000 0.004 0.708 NA
#> SRR1047818     4  0.2860      0.725 0.000 0.000 0.000 0.852 0.048 NA
#> SRR1047819     4  0.2860      0.725 0.000 0.000 0.000 0.852 0.048 NA
#> SRR1047820     4  0.2860      0.725 0.000 0.000 0.000 0.852 0.048 NA
#> SRR1047821     4  0.2860      0.725 0.000 0.000 0.000 0.852 0.048 NA
#> SRR1047822     4  0.2860      0.725 0.000 0.000 0.000 0.852 0.048 NA
#> SRR1047823     4  0.4402      0.599 0.020 0.000 0.000 0.564 0.004 NA
#> SRR1047824     4  0.4402      0.599 0.020 0.000 0.000 0.564 0.004 NA
#> SRR1047825     4  0.4402      0.599 0.020 0.000 0.000 0.564 0.004 NA
#> SRR1047826     4  0.4402      0.599 0.020 0.000 0.000 0.564 0.004 NA
#> SRR1047827     4  0.4402      0.599 0.020 0.000 0.000 0.564 0.004 NA
#> SRR1047828     5  0.7194      0.571 0.168 0.000 0.000 0.164 0.448 NA
#> SRR1047829     5  0.7194      0.571 0.168 0.000 0.000 0.164 0.448 NA
#> SRR1047830     5  0.7194      0.571 0.168 0.000 0.000 0.164 0.448 NA
#> SRR1047831     5  0.7194      0.571 0.168 0.000 0.000 0.164 0.448 NA
#> SRR1047832     5  0.7194      0.571 0.168 0.000 0.000 0.164 0.448 NA
#> SRR1047833     2  0.0260      0.947 0.000 0.992 0.000 0.000 0.008 NA
#> SRR1047834     2  0.0000      0.950 0.000 1.000 0.000 0.000 0.000 NA
#> SRR1047835     2  0.0000      0.950 0.000 1.000 0.000 0.000 0.000 NA
#> SRR1047836     2  0.0000      0.950 0.000 1.000 0.000 0.000 0.000 NA
#> SRR1047837     2  0.0000      0.950 0.000 1.000 0.000 0.000 0.000 NA
#> SRR1047838     4  0.2123      0.739 0.064 0.000 0.000 0.908 0.008 NA
#> SRR1047839     4  0.2036      0.738 0.064 0.000 0.000 0.912 0.008 NA
#> SRR1047840     4  0.2123      0.739 0.064 0.000 0.000 0.908 0.008 NA
#> SRR1047841     4  0.2123      0.739 0.064 0.000 0.000 0.908 0.008 NA
#> SRR1047842     4  0.2123      0.739 0.064 0.000 0.000 0.908 0.008 NA
#> SRR1047843     1  0.3013      0.604 0.864 0.000 0.000 0.064 0.028 NA
#> SRR1047844     1  0.3013      0.604 0.864 0.000 0.000 0.064 0.028 NA
#> SRR1047845     1  0.3013      0.604 0.864 0.000 0.000 0.064 0.028 NA
#> SRR1047846     1  0.3013      0.604 0.864 0.000 0.000 0.064 0.028 NA
#> SRR1047847     1  0.3013      0.604 0.864 0.000 0.000 0.064 0.028 NA
#> SRR1047848     1  0.4870      0.383 0.584 0.000 0.000 0.004 0.352 NA
#> SRR1047849     1  0.4870      0.383 0.584 0.000 0.000 0.004 0.352 NA
#> SRR1047850     1  0.4870      0.383 0.584 0.000 0.000 0.004 0.352 NA
#> SRR1047851     1  0.4870      0.383 0.584 0.000 0.000 0.004 0.352 NA
#> SRR1047852     1  0.4870      0.383 0.584 0.000 0.000 0.004 0.352 NA
#> SRR1047853     4  0.5218      0.597 0.212 0.000 0.000 0.668 0.052 NA
#> SRR1047854     4  0.5218      0.597 0.212 0.000 0.000 0.668 0.052 NA
#> SRR1047855     4  0.5218      0.597 0.212 0.000 0.000 0.668 0.052 NA
#> SRR1047856     4  0.5218      0.597 0.212 0.000 0.000 0.668 0.052 NA
#> SRR1047857     4  0.5218      0.597 0.212 0.000 0.000 0.668 0.052 NA
#> SRR1047858     1  0.2797      0.648 0.872 0.000 0.000 0.016 0.076 NA
#> SRR1047859     1  0.2797      0.648 0.872 0.000 0.000 0.016 0.076 NA
#> SRR1047860     1  0.2797      0.648 0.872 0.000 0.000 0.016 0.076 NA
#> SRR1047861     1  0.2797      0.648 0.872 0.000 0.000 0.016 0.076 NA
#> SRR1047863     3  0.0692      0.955 0.004 0.000 0.976 0.000 0.020 NA
#> SRR1047864     3  0.4886      0.642 0.004 0.000 0.652 0.000 0.100 NA
#> SRR1047865     3  0.0547      0.956 0.000 0.000 0.980 0.000 0.020 NA
#> SRR1047866     3  0.1075      0.948 0.000 0.000 0.952 0.000 0.048 NA
#> SRR1047867     2  0.4713      0.728 0.004 0.652 0.000 0.000 0.072 NA
#> SRR1047868     3  0.0000      0.960 0.000 0.000 1.000 0.000 0.000 NA
#> SRR1047869     3  0.0547      0.956 0.000 0.000 0.980 0.000 0.020 NA
#> SRR1047870     3  0.0692      0.955 0.004 0.000 0.976 0.000 0.020 NA
#> SRR1047871     3  0.0000      0.960 0.000 0.000 1.000 0.000 0.000 NA
#> SRR1047872     3  0.0000      0.960 0.000 0.000 1.000 0.000 0.000 NA
#> SRR1047873     3  0.0000      0.960 0.000 0.000 1.000 0.000 0.000 NA
#> SRR1047874     3  0.0000      0.960 0.000 0.000 1.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 17931 rows and 61 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#>   Subgroups are detected by 'skmeans' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 4.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk SD-skmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.847           0.899       0.949         0.4442 0.531   0.531
#> 3 3 0.932           0.970       0.971         0.5009 0.694   0.475
#> 4 4 0.932           0.965       0.977         0.1019 0.896   0.698
#> 5 5 0.836           0.847       0.902         0.0541 0.984   0.936
#> 6 6 0.820           0.833       0.889         0.0575 0.959   0.830

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette    p1    p2
#> SRR1047813     1  0.1633      0.976 0.976 0.024
#> SRR1047814     1  0.1633      0.976 0.976 0.024
#> SRR1047815     1  0.1633      0.976 0.976 0.024
#> SRR1047816     1  0.1633      0.976 0.976 0.024
#> SRR1047817     1  0.1633      0.976 0.976 0.024
#> SRR1047818     1  0.1184      0.984 0.984 0.016
#> SRR1047819     1  0.1184      0.984 0.984 0.016
#> SRR1047820     1  0.1184      0.984 0.984 0.016
#> SRR1047821     1  0.1184      0.984 0.984 0.016
#> SRR1047822     1  0.1414      0.981 0.980 0.020
#> SRR1047823     1  0.0938      0.983 0.988 0.012
#> SRR1047824     1  0.0938      0.983 0.988 0.012
#> SRR1047825     1  0.0938      0.983 0.988 0.012
#> SRR1047826     1  0.0938      0.983 0.988 0.012
#> SRR1047827     1  0.0938      0.983 0.988 0.012
#> SRR1047828     2  0.9954      0.293 0.460 0.540
#> SRR1047829     2  0.9635      0.449 0.388 0.612
#> SRR1047830     2  0.9954      0.293 0.460 0.540
#> SRR1047831     2  0.9954      0.293 0.460 0.540
#> SRR1047832     2  0.9954      0.293 0.460 0.540
#> SRR1047833     2  0.0672      0.872 0.008 0.992
#> SRR1047834     2  0.0672      0.872 0.008 0.992
#> SRR1047835     2  0.0672      0.872 0.008 0.992
#> SRR1047836     2  0.0672      0.872 0.008 0.992
#> SRR1047837     2  0.0672      0.872 0.008 0.992
#> SRR1047838     1  0.0672      0.986 0.992 0.008
#> SRR1047839     1  0.0672      0.986 0.992 0.008
#> SRR1047840     1  0.0672      0.986 0.992 0.008
#> SRR1047841     1  0.0672      0.986 0.992 0.008
#> SRR1047842     1  0.0672      0.986 0.992 0.008
#> SRR1047843     1  0.0672      0.986 0.992 0.008
#> SRR1047844     1  0.0672      0.986 0.992 0.008
#> SRR1047845     1  0.0672      0.986 0.992 0.008
#> SRR1047846     1  0.0672      0.986 0.992 0.008
#> SRR1047847     1  0.0672      0.986 0.992 0.008
#> SRR1047848     1  0.1633      0.976 0.976 0.024
#> SRR1047849     1  0.1633      0.976 0.976 0.024
#> SRR1047850     1  0.1633      0.976 0.976 0.024
#> SRR1047851     1  0.1633      0.976 0.976 0.024
#> SRR1047852     1  0.1633      0.976 0.976 0.024
#> SRR1047853     1  0.0672      0.986 0.992 0.008
#> SRR1047854     1  0.0672      0.986 0.992 0.008
#> SRR1047855     1  0.0672      0.986 0.992 0.008
#> SRR1047856     1  0.0672      0.986 0.992 0.008
#> SRR1047857     1  0.0672      0.986 0.992 0.008
#> SRR1047858     1  0.0000      0.986 1.000 0.000
#> SRR1047859     1  0.0000      0.986 1.000 0.000
#> SRR1047860     1  0.0000      0.986 1.000 0.000
#> SRR1047861     1  0.0000      0.986 1.000 0.000
#> SRR1047863     2  0.1843      0.877 0.028 0.972
#> SRR1047864     2  0.0672      0.875 0.008 0.992
#> SRR1047865     2  0.1843      0.877 0.028 0.972
#> SRR1047866     2  0.0938      0.875 0.012 0.988
#> SRR1047867     2  0.0000      0.874 0.000 1.000
#> SRR1047868     2  0.1843      0.877 0.028 0.972
#> SRR1047869     2  0.1843      0.877 0.028 0.972
#> SRR1047870     2  0.1633      0.876 0.024 0.976
#> SRR1047871     2  0.1843      0.877 0.028 0.972
#> SRR1047872     2  0.1843      0.877 0.028 0.972
#> SRR1047873     2  0.1843      0.877 0.028 0.972
#> SRR1047874     2  0.1843      0.877 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
#> SRR1047813     1  0.1163      0.977 0.972 0.028 0.000
#> SRR1047814     1  0.1163      0.977 0.972 0.028 0.000
#> SRR1047815     1  0.1163      0.977 0.972 0.028 0.000
#> SRR1047816     1  0.1163      0.977 0.972 0.028 0.000
#> SRR1047817     1  0.1163      0.977 0.972 0.028 0.000
#> SRR1047818     2  0.0000      0.993 0.000 1.000 0.000
#> SRR1047819     2  0.0000      0.993 0.000 1.000 0.000
#> SRR1047820     2  0.0000      0.993 0.000 1.000 0.000
#> SRR1047821     2  0.0000      0.993 0.000 1.000 0.000
#> SRR1047822     2  0.0000      0.993 0.000 1.000 0.000
#> SRR1047823     2  0.0892      0.982 0.020 0.980 0.000
#> SRR1047824     2  0.0892      0.982 0.020 0.980 0.000
#> SRR1047825     2  0.0892      0.982 0.020 0.980 0.000
#> SRR1047826     2  0.0892      0.982 0.020 0.980 0.000
#> SRR1047827     2  0.0892      0.982 0.020 0.980 0.000
#> SRR1047828     1  0.2537      0.909 0.920 0.000 0.080
#> SRR1047829     1  0.2537      0.909 0.920 0.000 0.080
#> SRR1047830     1  0.2537      0.909 0.920 0.000 0.080
#> SRR1047831     1  0.2537      0.909 0.920 0.000 0.080
#> SRR1047832     1  0.2537      0.909 0.920 0.000 0.080
#> SRR1047833     3  0.1163      0.956 0.028 0.000 0.972
#> SRR1047834     3  0.1163      0.956 0.028 0.000 0.972
#> SRR1047835     3  0.1163      0.956 0.028 0.000 0.972
#> SRR1047836     3  0.1163      0.956 0.028 0.000 0.972
#> SRR1047837     3  0.1163      0.956 0.028 0.000 0.972
#> SRR1047838     2  0.0000      0.993 0.000 1.000 0.000
#> SRR1047839     2  0.0000      0.993 0.000 1.000 0.000
#> SRR1047840     2  0.0000      0.993 0.000 1.000 0.000
#> SRR1047841     2  0.0000      0.993 0.000 1.000 0.000
#> SRR1047842     2  0.0000      0.993 0.000 1.000 0.000
#> SRR1047843     1  0.1163      0.977 0.972 0.028 0.000
#> SRR1047844     1  0.1163      0.977 0.972 0.028 0.000
#> SRR1047845     1  0.1163      0.977 0.972 0.028 0.000
#> SRR1047846     1  0.1163      0.977 0.972 0.028 0.000
#> SRR1047847     1  0.1163      0.977 0.972 0.028 0.000
#> SRR1047848     1  0.1163      0.977 0.972 0.028 0.000
#> SRR1047849     1  0.1163      0.977 0.972 0.028 0.000
#> SRR1047850     1  0.1163      0.977 0.972 0.028 0.000
#> SRR1047851     1  0.1163      0.977 0.972 0.028 0.000
#> SRR1047852     1  0.1163      0.977 0.972 0.028 0.000
#> SRR1047853     2  0.0237      0.991 0.004 0.996 0.000
#> SRR1047854     2  0.0237      0.991 0.004 0.996 0.000
#> SRR1047855     2  0.0237      0.991 0.004 0.996 0.000
#> SRR1047856     2  0.0237      0.991 0.004 0.996 0.000
#> SRR1047857     2  0.0237      0.991 0.004 0.996 0.000
#> SRR1047858     1  0.1163      0.977 0.972 0.028 0.000
#> SRR1047859     1  0.1163      0.977 0.972 0.028 0.000
#> SRR1047860     1  0.1163      0.977 0.972 0.028 0.000
#> SRR1047861     1  0.1163      0.977 0.972 0.028 0.000
#> SRR1047863     3  0.0892      0.961 0.000 0.020 0.980
#> SRR1047864     3  0.0000      0.960 0.000 0.000 1.000
#> SRR1047865     3  0.2636      0.955 0.048 0.020 0.932
#> SRR1047866     3  0.1529      0.958 0.040 0.000 0.960
#> SRR1047867     3  0.1163      0.956 0.028 0.000 0.972
#> SRR1047868     3  0.2689      0.957 0.036 0.032 0.932
#> SRR1047869     3  0.2636      0.955 0.048 0.020 0.932
#> SRR1047870     3  0.0892      0.961 0.000 0.020 0.980
#> SRR1047871     3  0.2663      0.956 0.044 0.024 0.932
#> SRR1047872     3  0.2689      0.957 0.036 0.032 0.932
#> SRR1047873     3  0.2689      0.957 0.036 0.032 0.932
#> SRR1047874     3  0.2689      0.957 0.036 0.032 0.932

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1047813     1  0.0188      0.998 0.996 0.004 0.000 0.000
#> SRR1047814     1  0.0188      0.998 0.996 0.004 0.000 0.000
#> SRR1047815     1  0.0188      0.998 0.996 0.004 0.000 0.000
#> SRR1047816     1  0.0188      0.998 0.996 0.004 0.000 0.000
#> SRR1047817     1  0.0188      0.998 0.996 0.004 0.000 0.000
#> SRR1047818     4  0.0000      0.989 0.000 0.000 0.000 1.000
#> SRR1047819     4  0.0000      0.989 0.000 0.000 0.000 1.000
#> SRR1047820     4  0.0000      0.989 0.000 0.000 0.000 1.000
#> SRR1047821     4  0.0000      0.989 0.000 0.000 0.000 1.000
#> SRR1047822     4  0.0000      0.989 0.000 0.000 0.000 1.000
#> SRR1047823     4  0.0000      0.989 0.000 0.000 0.000 1.000
#> SRR1047824     4  0.0000      0.989 0.000 0.000 0.000 1.000
#> SRR1047825     4  0.0000      0.989 0.000 0.000 0.000 1.000
#> SRR1047826     4  0.0000      0.989 0.000 0.000 0.000 1.000
#> SRR1047827     4  0.0000      0.989 0.000 0.000 0.000 1.000
#> SRR1047828     2  0.3837      0.824 0.224 0.776 0.000 0.000
#> SRR1047829     2  0.3837      0.824 0.224 0.776 0.000 0.000
#> SRR1047830     2  0.3837      0.824 0.224 0.776 0.000 0.000
#> SRR1047831     2  0.3837      0.824 0.224 0.776 0.000 0.000
#> SRR1047832     2  0.3837      0.824 0.224 0.776 0.000 0.000
#> SRR1047833     2  0.0188      0.860 0.000 0.996 0.004 0.000
#> SRR1047834     2  0.0188      0.860 0.000 0.996 0.004 0.000
#> SRR1047835     2  0.0188      0.860 0.000 0.996 0.004 0.000
#> SRR1047836     2  0.0188      0.860 0.000 0.996 0.004 0.000
#> SRR1047837     2  0.0188      0.860 0.000 0.996 0.004 0.000
#> SRR1047838     4  0.0000      0.989 0.000 0.000 0.000 1.000
#> SRR1047839     4  0.0000      0.989 0.000 0.000 0.000 1.000
#> SRR1047840     4  0.0000      0.989 0.000 0.000 0.000 1.000
#> SRR1047841     4  0.0000      0.989 0.000 0.000 0.000 1.000
#> SRR1047842     4  0.0000      0.989 0.000 0.000 0.000 1.000
#> SRR1047843     1  0.0000      0.997 1.000 0.000 0.000 0.000
#> SRR1047844     1  0.0000      0.997 1.000 0.000 0.000 0.000
#> SRR1047845     1  0.0000      0.997 1.000 0.000 0.000 0.000
#> SRR1047846     1  0.0000      0.997 1.000 0.000 0.000 0.000
#> SRR1047847     1  0.0000      0.997 1.000 0.000 0.000 0.000
#> SRR1047848     1  0.0188      0.998 0.996 0.004 0.000 0.000
#> SRR1047849     1  0.0188      0.998 0.996 0.004 0.000 0.000
#> SRR1047850     1  0.0188      0.998 0.996 0.004 0.000 0.000
#> SRR1047851     1  0.0188      0.998 0.996 0.004 0.000 0.000
#> SRR1047852     1  0.0188      0.998 0.996 0.004 0.000 0.000
#> SRR1047853     4  0.1118      0.967 0.036 0.000 0.000 0.964
#> SRR1047854     4  0.1118      0.967 0.036 0.000 0.000 0.964
#> SRR1047855     4  0.1118      0.967 0.036 0.000 0.000 0.964
#> SRR1047856     4  0.1118      0.967 0.036 0.000 0.000 0.964
#> SRR1047857     4  0.1118      0.967 0.036 0.000 0.000 0.964
#> SRR1047858     1  0.0000      0.997 1.000 0.000 0.000 0.000
#> SRR1047859     1  0.0000      0.997 1.000 0.000 0.000 0.000
#> SRR1047860     1  0.0000      0.997 1.000 0.000 0.000 0.000
#> SRR1047861     1  0.0000      0.997 1.000 0.000 0.000 0.000
#> SRR1047863     3  0.0000      0.998 0.000 0.000 1.000 0.000
#> SRR1047864     3  0.0707      0.981 0.000 0.020 0.980 0.000
#> SRR1047865     3  0.0000      0.998 0.000 0.000 1.000 0.000
#> SRR1047866     3  0.0000      0.998 0.000 0.000 1.000 0.000
#> SRR1047867     2  0.0188      0.860 0.000 0.996 0.004 0.000
#> SRR1047868     3  0.0000      0.998 0.000 0.000 1.000 0.000
#> SRR1047869     3  0.0000      0.998 0.000 0.000 1.000 0.000
#> SRR1047870     3  0.0000      0.998 0.000 0.000 1.000 0.000
#> SRR1047871     3  0.0000      0.998 0.000 0.000 1.000 0.000
#> SRR1047872     3  0.0000      0.998 0.000 0.000 1.000 0.000
#> SRR1047873     3  0.0000      0.998 0.000 0.000 1.000 0.000
#> SRR1047874     3  0.0000      0.998 0.000 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4    p5
#> SRR1047813     1  0.4201      0.615 0.592 0.000 0.000 0.000 0.408
#> SRR1047814     1  0.4201      0.615 0.592 0.000 0.000 0.000 0.408
#> SRR1047815     1  0.4201      0.615 0.592 0.000 0.000 0.000 0.408
#> SRR1047816     1  0.4201      0.615 0.592 0.000 0.000 0.000 0.408
#> SRR1047817     1  0.4201      0.615 0.592 0.000 0.000 0.000 0.408
#> SRR1047818     4  0.0000      0.893 0.000 0.000 0.000 1.000 0.000
#> SRR1047819     4  0.0000      0.893 0.000 0.000 0.000 1.000 0.000
#> SRR1047820     4  0.0000      0.893 0.000 0.000 0.000 1.000 0.000
#> SRR1047821     4  0.0000      0.893 0.000 0.000 0.000 1.000 0.000
#> SRR1047822     4  0.0000      0.893 0.000 0.000 0.000 1.000 0.000
#> SRR1047823     4  0.0162      0.893 0.000 0.000 0.000 0.996 0.004
#> SRR1047824     4  0.0162      0.893 0.000 0.000 0.000 0.996 0.004
#> SRR1047825     4  0.0162      0.893 0.000 0.000 0.000 0.996 0.004
#> SRR1047826     4  0.0162      0.893 0.000 0.000 0.000 0.996 0.004
#> SRR1047827     4  0.0162      0.893 0.000 0.000 0.000 0.996 0.004
#> SRR1047828     5  0.1502      1.000 0.004 0.056 0.000 0.000 0.940
#> SRR1047829     5  0.1502      1.000 0.004 0.056 0.000 0.000 0.940
#> SRR1047830     5  0.1502      1.000 0.004 0.056 0.000 0.000 0.940
#> SRR1047831     5  0.1502      1.000 0.004 0.056 0.000 0.000 0.940
#> SRR1047832     5  0.1502      1.000 0.004 0.056 0.000 0.000 0.940
#> SRR1047833     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1047834     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1047835     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1047836     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1047837     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1047838     4  0.0404      0.892 0.000 0.000 0.000 0.988 0.012
#> SRR1047839     4  0.0404      0.892 0.000 0.000 0.000 0.988 0.012
#> SRR1047840     4  0.0404      0.892 0.000 0.000 0.000 0.988 0.012
#> SRR1047841     4  0.0404      0.892 0.000 0.000 0.000 0.988 0.012
#> SRR1047842     4  0.0404      0.892 0.000 0.000 0.000 0.988 0.012
#> SRR1047843     1  0.0510      0.745 0.984 0.000 0.000 0.000 0.016
#> SRR1047844     1  0.0510      0.745 0.984 0.000 0.000 0.000 0.016
#> SRR1047845     1  0.0510      0.745 0.984 0.000 0.000 0.000 0.016
#> SRR1047846     1  0.0510      0.745 0.984 0.000 0.000 0.000 0.016
#> SRR1047847     1  0.0510      0.745 0.984 0.000 0.000 0.000 0.016
#> SRR1047848     1  0.3752      0.716 0.708 0.000 0.000 0.000 0.292
#> SRR1047849     1  0.3752      0.716 0.708 0.000 0.000 0.000 0.292
#> SRR1047850     1  0.3752      0.716 0.708 0.000 0.000 0.000 0.292
#> SRR1047851     1  0.3752      0.716 0.708 0.000 0.000 0.000 0.292
#> SRR1047852     1  0.3752      0.716 0.708 0.000 0.000 0.000 0.292
#> SRR1047853     4  0.4840      0.653 0.320 0.000 0.000 0.640 0.040
#> SRR1047854     4  0.4840      0.653 0.320 0.000 0.000 0.640 0.040
#> SRR1047855     4  0.4840      0.653 0.320 0.000 0.000 0.640 0.040
#> SRR1047856     4  0.4840      0.653 0.320 0.000 0.000 0.640 0.040
#> SRR1047857     4  0.4840      0.653 0.320 0.000 0.000 0.640 0.040
#> SRR1047858     1  0.0290      0.752 0.992 0.000 0.000 0.000 0.008
#> SRR1047859     1  0.0290      0.752 0.992 0.000 0.000 0.000 0.008
#> SRR1047860     1  0.0290      0.752 0.992 0.000 0.000 0.000 0.008
#> SRR1047861     1  0.0290      0.752 0.992 0.000 0.000 0.000 0.008
#> SRR1047863     3  0.0000      0.983 0.000 0.000 1.000 0.000 0.000
#> SRR1047864     3  0.2813      0.798 0.000 0.168 0.832 0.000 0.000
#> SRR1047865     3  0.0000      0.983 0.000 0.000 1.000 0.000 0.000
#> SRR1047866     3  0.0000      0.983 0.000 0.000 1.000 0.000 0.000
#> SRR1047867     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1047868     3  0.0000      0.983 0.000 0.000 1.000 0.000 0.000
#> SRR1047869     3  0.0000      0.983 0.000 0.000 1.000 0.000 0.000
#> SRR1047870     3  0.0000      0.983 0.000 0.000 1.000 0.000 0.000
#> SRR1047871     3  0.0000      0.983 0.000 0.000 1.000 0.000 0.000
#> SRR1047872     3  0.0000      0.983 0.000 0.000 1.000 0.000 0.000
#> SRR1047873     3  0.0000      0.983 0.000 0.000 1.000 0.000 0.000
#> SRR1047874     3  0.0000      0.983 0.000 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2   p3    p4    p5    p6
#> SRR1047813     1  0.3190      0.634 0.772 0.000 0.00 0.000 0.220 0.008
#> SRR1047814     1  0.3190      0.634 0.772 0.000 0.00 0.000 0.220 0.008
#> SRR1047815     1  0.3190      0.634 0.772 0.000 0.00 0.000 0.220 0.008
#> SRR1047816     1  0.3190      0.634 0.772 0.000 0.00 0.000 0.220 0.008
#> SRR1047817     1  0.3190      0.634 0.772 0.000 0.00 0.000 0.220 0.008
#> SRR1047818     4  0.0405      0.883 0.000 0.000 0.00 0.988 0.008 0.004
#> SRR1047819     4  0.0405      0.883 0.000 0.000 0.00 0.988 0.008 0.004
#> SRR1047820     4  0.0405      0.883 0.000 0.000 0.00 0.988 0.008 0.004
#> SRR1047821     4  0.0405      0.883 0.000 0.000 0.00 0.988 0.008 0.004
#> SRR1047822     4  0.0405      0.883 0.000 0.000 0.00 0.988 0.008 0.004
#> SRR1047823     4  0.2009      0.862 0.008 0.000 0.00 0.904 0.004 0.084
#> SRR1047824     4  0.2009      0.862 0.008 0.000 0.00 0.904 0.004 0.084
#> SRR1047825     4  0.2009      0.862 0.008 0.000 0.00 0.904 0.004 0.084
#> SRR1047826     4  0.2009      0.862 0.008 0.000 0.00 0.904 0.004 0.084
#> SRR1047827     4  0.2009      0.862 0.008 0.000 0.00 0.904 0.004 0.084
#> SRR1047828     5  0.0520      1.000 0.008 0.008 0.00 0.000 0.984 0.000
#> SRR1047829     5  0.0520      1.000 0.008 0.008 0.00 0.000 0.984 0.000
#> SRR1047830     5  0.0520      1.000 0.008 0.008 0.00 0.000 0.984 0.000
#> SRR1047831     5  0.0520      1.000 0.008 0.008 0.00 0.000 0.984 0.000
#> SRR1047832     5  0.0520      1.000 0.008 0.008 0.00 0.000 0.984 0.000
#> SRR1047833     2  0.0000      1.000 0.000 1.000 0.00 0.000 0.000 0.000
#> SRR1047834     2  0.0000      1.000 0.000 1.000 0.00 0.000 0.000 0.000
#> SRR1047835     2  0.0000      1.000 0.000 1.000 0.00 0.000 0.000 0.000
#> SRR1047836     2  0.0000      1.000 0.000 1.000 0.00 0.000 0.000 0.000
#> SRR1047837     2  0.0000      1.000 0.000 1.000 0.00 0.000 0.000 0.000
#> SRR1047838     4  0.2597      0.803 0.000 0.000 0.00 0.824 0.000 0.176
#> SRR1047839     4  0.2597      0.803 0.000 0.000 0.00 0.824 0.000 0.176
#> SRR1047840     4  0.2597      0.803 0.000 0.000 0.00 0.824 0.000 0.176
#> SRR1047841     4  0.2597      0.803 0.000 0.000 0.00 0.824 0.000 0.176
#> SRR1047842     4  0.2597      0.803 0.000 0.000 0.00 0.824 0.000 0.176
#> SRR1047843     1  0.3997      0.359 0.508 0.000 0.00 0.000 0.004 0.488
#> SRR1047844     1  0.3999      0.342 0.500 0.000 0.00 0.000 0.004 0.496
#> SRR1047845     1  0.3997      0.359 0.508 0.000 0.00 0.000 0.004 0.488
#> SRR1047846     1  0.3997      0.359 0.508 0.000 0.00 0.000 0.004 0.488
#> SRR1047847     1  0.3999      0.342 0.500 0.000 0.00 0.000 0.004 0.496
#> SRR1047848     1  0.0547      0.737 0.980 0.000 0.00 0.000 0.020 0.000
#> SRR1047849     1  0.0547      0.737 0.980 0.000 0.00 0.000 0.020 0.000
#> SRR1047850     1  0.0547      0.737 0.980 0.000 0.00 0.000 0.020 0.000
#> SRR1047851     1  0.0547      0.737 0.980 0.000 0.00 0.000 0.020 0.000
#> SRR1047852     1  0.0547      0.737 0.980 0.000 0.00 0.000 0.020 0.000
#> SRR1047853     6  0.2003      1.000 0.000 0.000 0.00 0.116 0.000 0.884
#> SRR1047854     6  0.2003      1.000 0.000 0.000 0.00 0.116 0.000 0.884
#> SRR1047855     6  0.2003      1.000 0.000 0.000 0.00 0.116 0.000 0.884
#> SRR1047856     6  0.2003      1.000 0.000 0.000 0.00 0.116 0.000 0.884
#> SRR1047857     6  0.2003      1.000 0.000 0.000 0.00 0.116 0.000 0.884
#> SRR1047858     1  0.2320      0.717 0.864 0.000 0.00 0.000 0.004 0.132
#> SRR1047859     1  0.2320      0.717 0.864 0.000 0.00 0.000 0.004 0.132
#> SRR1047860     1  0.2320      0.717 0.864 0.000 0.00 0.000 0.004 0.132
#> SRR1047861     1  0.2320      0.717 0.864 0.000 0.00 0.000 0.004 0.132
#> SRR1047863     3  0.0000      0.981 0.000 0.000 1.00 0.000 0.000 0.000
#> SRR1047864     3  0.2631      0.780 0.000 0.180 0.82 0.000 0.000 0.000
#> SRR1047865     3  0.0000      0.981 0.000 0.000 1.00 0.000 0.000 0.000
#> SRR1047866     3  0.0000      0.981 0.000 0.000 1.00 0.000 0.000 0.000
#> SRR1047867     2  0.0000      1.000 0.000 1.000 0.00 0.000 0.000 0.000
#> SRR1047868     3  0.0000      0.981 0.000 0.000 1.00 0.000 0.000 0.000
#> SRR1047869     3  0.0000      0.981 0.000 0.000 1.00 0.000 0.000 0.000
#> SRR1047870     3  0.0000      0.981 0.000 0.000 1.00 0.000 0.000 0.000
#> SRR1047871     3  0.0000      0.981 0.000 0.000 1.00 0.000 0.000 0.000
#> SRR1047872     3  0.0000      0.981 0.000 0.000 1.00 0.000 0.000 0.000
#> SRR1047873     3  0.0000      0.981 0.000 0.000 1.00 0.000 0.000 0.000
#> SRR1047874     3  0.0000      0.981 0.000 0.000 1.00 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 17931 rows and 61 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#>   Subgroups are detected by 'pam' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 6.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk SD-pam-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.1811 0.820   0.820
#> 3 3 1.000           1.000       1.000         1.4586 0.736   0.677
#> 4 4 0.814           0.936       0.963         0.5308 0.770   0.587
#> 5 5 0.949           0.927       0.967         0.1104 0.932   0.790
#> 6 6 0.969           0.930       0.962         0.0349 0.975   0.904

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette p1 p2
#> SRR1047813     1       0          1  1  0
#> SRR1047814     1       0          1  1  0
#> SRR1047815     1       0          1  1  0
#> SRR1047816     1       0          1  1  0
#> SRR1047817     1       0          1  1  0
#> SRR1047818     1       0          1  1  0
#> SRR1047819     1       0          1  1  0
#> SRR1047820     1       0          1  1  0
#> SRR1047821     1       0          1  1  0
#> SRR1047822     1       0          1  1  0
#> SRR1047823     1       0          1  1  0
#> SRR1047824     1       0          1  1  0
#> SRR1047825     1       0          1  1  0
#> SRR1047826     1       0          1  1  0
#> SRR1047827     1       0          1  1  0
#> SRR1047828     1       0          1  1  0
#> SRR1047829     1       0          1  1  0
#> SRR1047830     1       0          1  1  0
#> SRR1047831     1       0          1  1  0
#> SRR1047832     1       0          1  1  0
#> SRR1047833     2       0          1  0  1
#> SRR1047834     2       0          1  0  1
#> SRR1047835     2       0          1  0  1
#> SRR1047836     2       0          1  0  1
#> SRR1047837     2       0          1  0  1
#> SRR1047838     1       0          1  1  0
#> SRR1047839     1       0          1  1  0
#> SRR1047840     1       0          1  1  0
#> SRR1047841     1       0          1  1  0
#> SRR1047842     1       0          1  1  0
#> SRR1047843     1       0          1  1  0
#> SRR1047844     1       0          1  1  0
#> SRR1047845     1       0          1  1  0
#> SRR1047846     1       0          1  1  0
#> SRR1047847     1       0          1  1  0
#> SRR1047848     1       0          1  1  0
#> SRR1047849     1       0          1  1  0
#> SRR1047850     1       0          1  1  0
#> SRR1047851     1       0          1  1  0
#> SRR1047852     1       0          1  1  0
#> SRR1047853     1       0          1  1  0
#> SRR1047854     1       0          1  1  0
#> SRR1047855     1       0          1  1  0
#> SRR1047856     1       0          1  1  0
#> SRR1047857     1       0          1  1  0
#> SRR1047858     1       0          1  1  0
#> SRR1047859     1       0          1  1  0
#> SRR1047860     1       0          1  1  0
#> SRR1047861     1       0          1  1  0
#> SRR1047863     1       0          1  1  0
#> SRR1047864     1       0          1  1  0
#> SRR1047865     1       0          1  1  0
#> SRR1047866     1       0          1  1  0
#> SRR1047867     2       0          1  0  1
#> SRR1047868     1       0          1  1  0
#> SRR1047869     1       0          1  1  0
#> SRR1047870     1       0          1  1  0
#> SRR1047871     1       0          1  1  0
#> SRR1047872     1       0          1  1  0
#> SRR1047873     1       0          1  1  0
#> SRR1047874     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette p1 p2 p3
#> SRR1047813     1       0          1  1  0  0
#> SRR1047814     1       0          1  1  0  0
#> SRR1047815     1       0          1  1  0  0
#> SRR1047816     1       0          1  1  0  0
#> SRR1047817     1       0          1  1  0  0
#> SRR1047818     1       0          1  1  0  0
#> SRR1047819     1       0          1  1  0  0
#> SRR1047820     1       0          1  1  0  0
#> SRR1047821     1       0          1  1  0  0
#> SRR1047822     1       0          1  1  0  0
#> SRR1047823     1       0          1  1  0  0
#> SRR1047824     1       0          1  1  0  0
#> SRR1047825     1       0          1  1  0  0
#> SRR1047826     1       0          1  1  0  0
#> SRR1047827     1       0          1  1  0  0
#> SRR1047828     1       0          1  1  0  0
#> SRR1047829     1       0          1  1  0  0
#> SRR1047830     1       0          1  1  0  0
#> SRR1047831     1       0          1  1  0  0
#> SRR1047832     1       0          1  1  0  0
#> SRR1047833     2       0          1  0  1  0
#> SRR1047834     2       0          1  0  1  0
#> SRR1047835     2       0          1  0  1  0
#> SRR1047836     2       0          1  0  1  0
#> SRR1047837     2       0          1  0  1  0
#> SRR1047838     1       0          1  1  0  0
#> SRR1047839     1       0          1  1  0  0
#> SRR1047840     1       0          1  1  0  0
#> SRR1047841     1       0          1  1  0  0
#> SRR1047842     1       0          1  1  0  0
#> SRR1047843     1       0          1  1  0  0
#> SRR1047844     1       0          1  1  0  0
#> SRR1047845     1       0          1  1  0  0
#> SRR1047846     1       0          1  1  0  0
#> SRR1047847     1       0          1  1  0  0
#> SRR1047848     1       0          1  1  0  0
#> SRR1047849     1       0          1  1  0  0
#> SRR1047850     1       0          1  1  0  0
#> SRR1047851     1       0          1  1  0  0
#> SRR1047852     1       0          1  1  0  0
#> SRR1047853     1       0          1  1  0  0
#> SRR1047854     1       0          1  1  0  0
#> SRR1047855     1       0          1  1  0  0
#> SRR1047856     1       0          1  1  0  0
#> SRR1047857     1       0          1  1  0  0
#> SRR1047858     1       0          1  1  0  0
#> SRR1047859     1       0          1  1  0  0
#> SRR1047860     1       0          1  1  0  0
#> SRR1047861     1       0          1  1  0  0
#> SRR1047863     3       0          1  0  0  1
#> SRR1047864     3       0          1  0  0  1
#> SRR1047865     3       0          1  0  0  1
#> SRR1047866     3       0          1  0  0  1
#> SRR1047867     2       0          1  0  1  0
#> SRR1047868     3       0          1  0  0  1
#> SRR1047869     3       0          1  0  0  1
#> SRR1047870     3       0          1  0  0  1
#> SRR1047871     3       0          1  0  0  1
#> SRR1047872     3       0          1  0  0  1
#> SRR1047873     3       0          1  0  0  1
#> SRR1047874     3       0          1  0  0  1

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1 p2 p3    p4
#> SRR1047813     1   0.000      0.995 1.000  0  0 0.000
#> SRR1047814     1   0.000      0.995 1.000  0  0 0.000
#> SRR1047815     1   0.000      0.995 1.000  0  0 0.000
#> SRR1047816     1   0.000      0.995 1.000  0  0 0.000
#> SRR1047817     1   0.130      0.934 0.956  0  0 0.044
#> SRR1047818     4   0.000      0.911 0.000  0  0 1.000
#> SRR1047819     4   0.000      0.911 0.000  0  0 1.000
#> SRR1047820     4   0.000      0.911 0.000  0  0 1.000
#> SRR1047821     4   0.000      0.911 0.000  0  0 1.000
#> SRR1047822     4   0.000      0.911 0.000  0  0 1.000
#> SRR1047823     4   0.000      0.911 0.000  0  0 1.000
#> SRR1047824     4   0.000      0.911 0.000  0  0 1.000
#> SRR1047825     4   0.000      0.911 0.000  0  0 1.000
#> SRR1047826     4   0.000      0.911 0.000  0  0 1.000
#> SRR1047827     4   0.000      0.911 0.000  0  0 1.000
#> SRR1047828     4   0.387      0.794 0.228  0  0 0.772
#> SRR1047829     4   0.387      0.794 0.228  0  0 0.772
#> SRR1047830     4   0.387      0.794 0.228  0  0 0.772
#> SRR1047831     4   0.387      0.794 0.228  0  0 0.772
#> SRR1047832     4   0.387      0.794 0.228  0  0 0.772
#> SRR1047833     2   0.000      1.000 0.000  1  0 0.000
#> SRR1047834     2   0.000      1.000 0.000  1  0 0.000
#> SRR1047835     2   0.000      1.000 0.000  1  0 0.000
#> SRR1047836     2   0.000      1.000 0.000  1  0 0.000
#> SRR1047837     2   0.000      1.000 0.000  1  0 0.000
#> SRR1047838     4   0.000      0.911 0.000  0  0 1.000
#> SRR1047839     4   0.000      0.911 0.000  0  0 1.000
#> SRR1047840     4   0.000      0.911 0.000  0  0 1.000
#> SRR1047841     4   0.000      0.911 0.000  0  0 1.000
#> SRR1047842     4   0.000      0.911 0.000  0  0 1.000
#> SRR1047843     4   0.387      0.794 0.228  0  0 0.772
#> SRR1047844     4   0.353      0.820 0.192  0  0 0.808
#> SRR1047845     4   0.387      0.794 0.228  0  0 0.772
#> SRR1047846     4   0.387      0.794 0.228  0  0 0.772
#> SRR1047847     4   0.361      0.814 0.200  0  0 0.800
#> SRR1047848     1   0.000      0.995 1.000  0  0 0.000
#> SRR1047849     1   0.000      0.995 1.000  0  0 0.000
#> SRR1047850     1   0.000      0.995 1.000  0  0 0.000
#> SRR1047851     1   0.000      0.995 1.000  0  0 0.000
#> SRR1047852     1   0.000      0.995 1.000  0  0 0.000
#> SRR1047853     4   0.000      0.911 0.000  0  0 1.000
#> SRR1047854     4   0.000      0.911 0.000  0  0 1.000
#> SRR1047855     4   0.000      0.911 0.000  0  0 1.000
#> SRR1047856     4   0.000      0.911 0.000  0  0 1.000
#> SRR1047857     4   0.000      0.911 0.000  0  0 1.000
#> SRR1047858     1   0.000      0.995 1.000  0  0 0.000
#> SRR1047859     1   0.000      0.995 1.000  0  0 0.000
#> SRR1047860     1   0.000      0.995 1.000  0  0 0.000
#> SRR1047861     1   0.000      0.995 1.000  0  0 0.000
#> SRR1047863     3   0.000      1.000 0.000  0  1 0.000
#> SRR1047864     3   0.000      1.000 0.000  0  1 0.000
#> SRR1047865     3   0.000      1.000 0.000  0  1 0.000
#> SRR1047866     3   0.000      1.000 0.000  0  1 0.000
#> SRR1047867     2   0.000      1.000 0.000  1  0 0.000
#> SRR1047868     3   0.000      1.000 0.000  0  1 0.000
#> SRR1047869     3   0.000      1.000 0.000  0  1 0.000
#> SRR1047870     3   0.000      1.000 0.000  0  1 0.000
#> SRR1047871     3   0.000      1.000 0.000  0  1 0.000
#> SRR1047872     3   0.000      1.000 0.000  0  1 0.000
#> SRR1047873     3   0.000      1.000 0.000  0  1 0.000
#> SRR1047874     3   0.000      1.000 0.000  0  1 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
#> SRR1047813     1  0.0000      0.984 1.000  0  0 0.000 0.000
#> SRR1047814     1  0.0000      0.984 1.000  0  0 0.000 0.000
#> SRR1047815     1  0.0000      0.984 1.000  0  0 0.000 0.000
#> SRR1047816     1  0.0000      0.984 1.000  0  0 0.000 0.000
#> SRR1047817     1  0.2732      0.769 0.840  0  0 0.160 0.000
#> SRR1047818     4  0.4114      0.487 0.000  0  0 0.624 0.376
#> SRR1047819     4  0.4171      0.448 0.000  0  0 0.604 0.396
#> SRR1047820     4  0.4171      0.448 0.000  0  0 0.604 0.396
#> SRR1047821     4  0.4101      0.495 0.000  0  0 0.628 0.372
#> SRR1047822     4  0.3109      0.740 0.000  0  0 0.800 0.200
#> SRR1047823     5  0.0162      1.000 0.000  0  0 0.004 0.996
#> SRR1047824     5  0.0162      1.000 0.000  0  0 0.004 0.996
#> SRR1047825     5  0.0162      1.000 0.000  0  0 0.004 0.996
#> SRR1047826     5  0.0162      1.000 0.000  0  0 0.004 0.996
#> SRR1047827     5  0.0162      1.000 0.000  0  0 0.004 0.996
#> SRR1047828     4  0.0162      0.919 0.000  0  0 0.996 0.004
#> SRR1047829     4  0.0162      0.919 0.000  0  0 0.996 0.004
#> SRR1047830     4  0.0162      0.919 0.000  0  0 0.996 0.004
#> SRR1047831     4  0.0162      0.919 0.000  0  0 0.996 0.004
#> SRR1047832     4  0.0162      0.919 0.000  0  0 0.996 0.004
#> SRR1047833     2  0.0000      1.000 0.000  1  0 0.000 0.000
#> SRR1047834     2  0.0000      1.000 0.000  1  0 0.000 0.000
#> SRR1047835     2  0.0000      1.000 0.000  1  0 0.000 0.000
#> SRR1047836     2  0.0000      1.000 0.000  1  0 0.000 0.000
#> SRR1047837     2  0.0000      1.000 0.000  1  0 0.000 0.000
#> SRR1047838     4  0.0162      0.919 0.000  0  0 0.996 0.004
#> SRR1047839     4  0.0162      0.919 0.000  0  0 0.996 0.004
#> SRR1047840     4  0.0162      0.919 0.000  0  0 0.996 0.004
#> SRR1047841     4  0.0162      0.919 0.000  0  0 0.996 0.004
#> SRR1047842     4  0.0162      0.919 0.000  0  0 0.996 0.004
#> SRR1047843     4  0.0162      0.919 0.004  0  0 0.996 0.000
#> SRR1047844     4  0.0162      0.919 0.004  0  0 0.996 0.000
#> SRR1047845     4  0.0162      0.919 0.004  0  0 0.996 0.000
#> SRR1047846     4  0.0162      0.919 0.004  0  0 0.996 0.000
#> SRR1047847     4  0.0162      0.919 0.004  0  0 0.996 0.000
#> SRR1047848     1  0.0000      0.984 1.000  0  0 0.000 0.000
#> SRR1047849     1  0.0000      0.984 1.000  0  0 0.000 0.000
#> SRR1047850     1  0.0000      0.984 1.000  0  0 0.000 0.000
#> SRR1047851     1  0.0000      0.984 1.000  0  0 0.000 0.000
#> SRR1047852     1  0.0000      0.984 1.000  0  0 0.000 0.000
#> SRR1047853     4  0.0000      0.920 0.000  0  0 1.000 0.000
#> SRR1047854     4  0.0000      0.920 0.000  0  0 1.000 0.000
#> SRR1047855     4  0.0000      0.920 0.000  0  0 1.000 0.000
#> SRR1047856     4  0.0000      0.920 0.000  0  0 1.000 0.000
#> SRR1047857     4  0.0000      0.920 0.000  0  0 1.000 0.000
#> SRR1047858     1  0.0000      0.984 1.000  0  0 0.000 0.000
#> SRR1047859     1  0.0000      0.984 1.000  0  0 0.000 0.000
#> SRR1047860     1  0.0000      0.984 1.000  0  0 0.000 0.000
#> SRR1047861     1  0.0000      0.984 1.000  0  0 0.000 0.000
#> SRR1047863     3  0.0000      1.000 0.000  0  1 0.000 0.000
#> SRR1047864     3  0.0000      1.000 0.000  0  1 0.000 0.000
#> SRR1047865     3  0.0000      1.000 0.000  0  1 0.000 0.000
#> SRR1047866     3  0.0000      1.000 0.000  0  1 0.000 0.000
#> SRR1047867     2  0.0000      1.000 0.000  1  0 0.000 0.000
#> SRR1047868     3  0.0000      1.000 0.000  0  1 0.000 0.000
#> SRR1047869     3  0.0000      1.000 0.000  0  1 0.000 0.000
#> SRR1047870     3  0.0000      1.000 0.000  0  1 0.000 0.000
#> SRR1047871     3  0.0000      1.000 0.000  0  1 0.000 0.000
#> SRR1047872     3  0.0000      1.000 0.000  0  1 0.000 0.000
#> SRR1047873     3  0.0000      1.000 0.000  0  1 0.000 0.000
#> SRR1047874     3  0.0000      1.000 0.000  0  1 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
#> SRR1047813     6  0.1075      0.998 0.048  0 0.000 0.000 0.000 0.952
#> SRR1047814     6  0.1075      0.998 0.048  0 0.000 0.000 0.000 0.952
#> SRR1047815     6  0.1075      0.998 0.048  0 0.000 0.000 0.000 0.952
#> SRR1047816     6  0.1075      0.998 0.048  0 0.000 0.000 0.000 0.952
#> SRR1047817     6  0.1152      0.993 0.044  0 0.000 0.004 0.000 0.952
#> SRR1047818     4  0.3695      0.495 0.000  0 0.000 0.624 0.376 0.000
#> SRR1047819     4  0.3747      0.457 0.000  0 0.000 0.604 0.396 0.000
#> SRR1047820     4  0.3747      0.457 0.000  0 0.000 0.604 0.396 0.000
#> SRR1047821     4  0.3684      0.501 0.000  0 0.000 0.628 0.372 0.000
#> SRR1047822     4  0.2793      0.741 0.000  0 0.000 0.800 0.200 0.000
#> SRR1047823     5  0.0146      1.000 0.000  0 0.000 0.004 0.996 0.000
#> SRR1047824     5  0.0146      1.000 0.000  0 0.000 0.004 0.996 0.000
#> SRR1047825     5  0.0146      1.000 0.000  0 0.000 0.004 0.996 0.000
#> SRR1047826     5  0.0146      1.000 0.000  0 0.000 0.004 0.996 0.000
#> SRR1047827     5  0.0146      1.000 0.000  0 0.000 0.004 0.996 0.000
#> SRR1047828     4  0.1219      0.893 0.000  0 0.000 0.948 0.004 0.048
#> SRR1047829     4  0.1219      0.893 0.000  0 0.000 0.948 0.004 0.048
#> SRR1047830     4  0.1219      0.893 0.000  0 0.000 0.948 0.004 0.048
#> SRR1047831     4  0.1219      0.893 0.000  0 0.000 0.948 0.004 0.048
#> SRR1047832     4  0.1219      0.893 0.000  0 0.000 0.948 0.004 0.048
#> SRR1047833     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> SRR1047834     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> SRR1047835     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> SRR1047836     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> SRR1047837     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> SRR1047838     4  0.0146      0.910 0.000  0 0.000 0.996 0.004 0.000
#> SRR1047839     4  0.0146      0.910 0.000  0 0.000 0.996 0.004 0.000
#> SRR1047840     4  0.0146      0.910 0.000  0 0.000 0.996 0.004 0.000
#> SRR1047841     4  0.0146      0.910 0.000  0 0.000 0.996 0.004 0.000
#> SRR1047842     4  0.0146      0.910 0.000  0 0.000 0.996 0.004 0.000
#> SRR1047843     4  0.0146      0.910 0.004  0 0.000 0.996 0.000 0.000
#> SRR1047844     4  0.0146      0.910 0.004  0 0.000 0.996 0.000 0.000
#> SRR1047845     4  0.0146      0.910 0.004  0 0.000 0.996 0.000 0.000
#> SRR1047846     4  0.0146      0.910 0.004  0 0.000 0.996 0.000 0.000
#> SRR1047847     4  0.0146      0.910 0.004  0 0.000 0.996 0.000 0.000
#> SRR1047848     1  0.0000      1.000 1.000  0 0.000 0.000 0.000 0.000
#> SRR1047849     1  0.0000      1.000 1.000  0 0.000 0.000 0.000 0.000
#> SRR1047850     1  0.0000      1.000 1.000  0 0.000 0.000 0.000 0.000
#> SRR1047851     1  0.0000      1.000 1.000  0 0.000 0.000 0.000 0.000
#> SRR1047852     1  0.0000      1.000 1.000  0 0.000 0.000 0.000 0.000
#> SRR1047853     4  0.0000      0.911 0.000  0 0.000 1.000 0.000 0.000
#> SRR1047854     4  0.0000      0.911 0.000  0 0.000 1.000 0.000 0.000
#> SRR1047855     4  0.0000      0.911 0.000  0 0.000 1.000 0.000 0.000
#> SRR1047856     4  0.0000      0.911 0.000  0 0.000 1.000 0.000 0.000
#> SRR1047857     4  0.0000      0.911 0.000  0 0.000 1.000 0.000 0.000
#> SRR1047858     1  0.0000      1.000 1.000  0 0.000 0.000 0.000 0.000
#> SRR1047859     1  0.0000      1.000 1.000  0 0.000 0.000 0.000 0.000
#> SRR1047860     1  0.0000      1.000 1.000  0 0.000 0.000 0.000 0.000
#> SRR1047861     1  0.0000      1.000 1.000  0 0.000 0.000 0.000 0.000
#> SRR1047863     3  0.0000      1.000 0.000  0 1.000 0.000 0.000 0.000
#> SRR1047864     3  0.0146      0.996 0.000  0 0.996 0.000 0.000 0.004
#> SRR1047865     3  0.0000      1.000 0.000  0 1.000 0.000 0.000 0.000
#> SRR1047866     3  0.0000      1.000 0.000  0 1.000 0.000 0.000 0.000
#> SRR1047867     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> SRR1047868     3  0.0000      1.000 0.000  0 1.000 0.000 0.000 0.000
#> SRR1047869     3  0.0000      1.000 0.000  0 1.000 0.000 0.000 0.000
#> SRR1047870     3  0.0000      1.000 0.000  0 1.000 0.000 0.000 0.000
#> SRR1047871     3  0.0000      1.000 0.000  0 1.000 0.000 0.000 0.000
#> SRR1047872     3  0.0000      1.000 0.000  0 1.000 0.000 0.000 0.000
#> SRR1047873     3  0.0000      1.000 0.000  0 1.000 0.000 0.000 0.000
#> SRR1047874     3  0.0000      1.000 0.000  0 1.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-pam-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-pam-collect-classes

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

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

collect_plots(res)

plot of chunk SD-mclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.716           0.918       0.937         0.3352 0.591   0.591
#> 3 3 1.000           0.994       0.996         0.9282 0.762   0.598
#> 4 4 1.000           0.997       0.998         0.0521 0.967   0.907
#> 5 5 1.000           0.993       0.996         0.1500 0.896   0.676
#> 6 6 1.000           0.992       0.995         0.0244 0.981   0.912

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette    p1    p2
#> SRR1047813     1  0.0000      0.999 1.000 0.000
#> SRR1047814     1  0.0000      0.999 1.000 0.000
#> SRR1047815     1  0.0000      0.999 1.000 0.000
#> SRR1047816     1  0.0000      0.999 1.000 0.000
#> SRR1047817     1  0.0000      0.999 1.000 0.000
#> SRR1047818     1  0.0000      0.999 1.000 0.000
#> SRR1047819     1  0.0000      0.999 1.000 0.000
#> SRR1047820     1  0.0000      0.999 1.000 0.000
#> SRR1047821     1  0.0000      0.999 1.000 0.000
#> SRR1047822     1  0.0000      0.999 1.000 0.000
#> SRR1047823     1  0.0000      0.999 1.000 0.000
#> SRR1047824     1  0.0000      0.999 1.000 0.000
#> SRR1047825     1  0.0000      0.999 1.000 0.000
#> SRR1047826     1  0.0000      0.999 1.000 0.000
#> SRR1047827     1  0.0000      0.999 1.000 0.000
#> SRR1047828     1  0.0000      0.999 1.000 0.000
#> SRR1047829     1  0.0376      0.994 0.996 0.004
#> SRR1047830     1  0.0938      0.984 0.988 0.012
#> SRR1047831     1  0.1184      0.979 0.984 0.016
#> SRR1047832     1  0.1184      0.979 0.984 0.016
#> SRR1047833     2  0.0000      0.746 0.000 1.000
#> SRR1047834     2  0.0000      0.746 0.000 1.000
#> SRR1047835     2  0.0000      0.746 0.000 1.000
#> SRR1047836     2  0.0000      0.746 0.000 1.000
#> SRR1047837     2  0.0000      0.746 0.000 1.000
#> SRR1047838     1  0.0000      0.999 1.000 0.000
#> SRR1047839     1  0.0000      0.999 1.000 0.000
#> SRR1047840     1  0.0000      0.999 1.000 0.000
#> SRR1047841     1  0.0000      0.999 1.000 0.000
#> SRR1047842     1  0.0000      0.999 1.000 0.000
#> SRR1047843     1  0.0000      0.999 1.000 0.000
#> SRR1047844     1  0.0000      0.999 1.000 0.000
#> SRR1047845     1  0.0000      0.999 1.000 0.000
#> SRR1047846     1  0.0000      0.999 1.000 0.000
#> SRR1047847     1  0.0000      0.999 1.000 0.000
#> SRR1047848     1  0.0000      0.999 1.000 0.000
#> SRR1047849     1  0.0000      0.999 1.000 0.000
#> SRR1047850     1  0.0000      0.999 1.000 0.000
#> SRR1047851     1  0.0000      0.999 1.000 0.000
#> SRR1047852     1  0.0000      0.999 1.000 0.000
#> SRR1047853     1  0.0000      0.999 1.000 0.000
#> SRR1047854     1  0.0000      0.999 1.000 0.000
#> SRR1047855     1  0.0000      0.999 1.000 0.000
#> SRR1047856     1  0.0000      0.999 1.000 0.000
#> SRR1047857     1  0.0000      0.999 1.000 0.000
#> SRR1047858     1  0.0000      0.999 1.000 0.000
#> SRR1047859     1  0.0000      0.999 1.000 0.000
#> SRR1047860     1  0.0000      0.999 1.000 0.000
#> SRR1047861     1  0.0000      0.999 1.000 0.000
#> SRR1047863     2  0.9732      0.681 0.404 0.596
#> SRR1047864     2  0.0000      0.746 0.000 1.000
#> SRR1047865     2  0.6887      0.738 0.184 0.816
#> SRR1047866     2  0.9732      0.681 0.404 0.596
#> SRR1047867     2  0.0000      0.746 0.000 1.000
#> SRR1047868     2  0.9732      0.681 0.404 0.596
#> SRR1047869     2  0.9491      0.697 0.368 0.632
#> SRR1047870     2  0.9732      0.681 0.404 0.596
#> SRR1047871     2  0.9732      0.681 0.404 0.596
#> SRR1047872     2  0.9732      0.681 0.404 0.596
#> SRR1047873     2  0.9732      0.681 0.404 0.596
#> SRR1047874     2  0.9732      0.681 0.404 0.596

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette   p1   p2   p3
#> SRR1047813     1  0.0000      0.996 1.00 0.00 0.00
#> SRR1047814     1  0.0000      0.996 1.00 0.00 0.00
#> SRR1047815     1  0.0000      0.996 1.00 0.00 0.00
#> SRR1047816     1  0.0000      0.996 1.00 0.00 0.00
#> SRR1047817     1  0.0000      0.996 1.00 0.00 0.00
#> SRR1047818     2  0.0000      1.000 0.00 1.00 0.00
#> SRR1047819     2  0.0000      1.000 0.00 1.00 0.00
#> SRR1047820     2  0.0000      1.000 0.00 1.00 0.00
#> SRR1047821     2  0.0000      1.000 0.00 1.00 0.00
#> SRR1047822     2  0.0000      1.000 0.00 1.00 0.00
#> SRR1047823     2  0.0000      1.000 0.00 1.00 0.00
#> SRR1047824     2  0.0000      1.000 0.00 1.00 0.00
#> SRR1047825     2  0.0000      1.000 0.00 1.00 0.00
#> SRR1047826     2  0.0000      1.000 0.00 1.00 0.00
#> SRR1047827     2  0.0000      1.000 0.00 1.00 0.00
#> SRR1047828     1  0.0000      0.996 1.00 0.00 0.00
#> SRR1047829     1  0.0000      0.996 1.00 0.00 0.00
#> SRR1047830     1  0.0000      0.996 1.00 0.00 0.00
#> SRR1047831     1  0.0000      0.996 1.00 0.00 0.00
#> SRR1047832     1  0.0000      0.996 1.00 0.00 0.00
#> SRR1047833     3  0.0000      0.989 0.00 0.00 1.00
#> SRR1047834     3  0.0000      0.989 0.00 0.00 1.00
#> SRR1047835     3  0.0000      0.989 0.00 0.00 1.00
#> SRR1047836     3  0.0000      0.989 0.00 0.00 1.00
#> SRR1047837     3  0.0000      0.989 0.00 0.00 1.00
#> SRR1047838     2  0.0000      1.000 0.00 1.00 0.00
#> SRR1047839     2  0.0000      1.000 0.00 1.00 0.00
#> SRR1047840     2  0.0000      1.000 0.00 1.00 0.00
#> SRR1047841     2  0.0000      1.000 0.00 1.00 0.00
#> SRR1047842     2  0.0000      1.000 0.00 1.00 0.00
#> SRR1047843     1  0.0000      0.996 1.00 0.00 0.00
#> SRR1047844     1  0.0000      0.996 1.00 0.00 0.00
#> SRR1047845     1  0.0000      0.996 1.00 0.00 0.00
#> SRR1047846     1  0.0000      0.996 1.00 0.00 0.00
#> SRR1047847     1  0.0000      0.996 1.00 0.00 0.00
#> SRR1047848     1  0.0000      0.996 1.00 0.00 0.00
#> SRR1047849     1  0.0000      0.996 1.00 0.00 0.00
#> SRR1047850     1  0.0000      0.996 1.00 0.00 0.00
#> SRR1047851     1  0.0000      0.996 1.00 0.00 0.00
#> SRR1047852     1  0.0000      0.996 1.00 0.00 0.00
#> SRR1047853     1  0.0892      0.981 0.98 0.02 0.00
#> SRR1047854     1  0.0892      0.981 0.98 0.02 0.00
#> SRR1047855     1  0.0892      0.981 0.98 0.02 0.00
#> SRR1047856     1  0.0892      0.981 0.98 0.02 0.00
#> SRR1047857     1  0.0892      0.981 0.98 0.02 0.00
#> SRR1047858     1  0.0000      0.996 1.00 0.00 0.00
#> SRR1047859     1  0.0000      0.996 1.00 0.00 0.00
#> SRR1047860     1  0.0000      0.996 1.00 0.00 0.00
#> SRR1047861     1  0.0000      0.996 1.00 0.00 0.00
#> SRR1047863     3  0.0892      0.988 0.00 0.02 0.98
#> SRR1047864     3  0.0000      0.989 0.00 0.00 1.00
#> SRR1047865     3  0.0000      0.989 0.00 0.00 1.00
#> SRR1047866     3  0.0000      0.989 0.00 0.00 1.00
#> SRR1047867     3  0.0000      0.989 0.00 0.00 1.00
#> SRR1047868     3  0.0892      0.988 0.00 0.02 0.98
#> SRR1047869     3  0.0892      0.988 0.00 0.02 0.98
#> SRR1047870     3  0.0892      0.988 0.00 0.02 0.98
#> SRR1047871     3  0.0892      0.988 0.00 0.02 0.98
#> SRR1047872     3  0.0892      0.988 0.00 0.02 0.98
#> SRR1047873     3  0.0892      0.988 0.00 0.02 0.98
#> SRR1047874     3  0.0892      0.988 0.00 0.02 0.98

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette   p1 p2 p3   p4
#> SRR1047813     1  0.0000      0.996 1.00  0  0 0.00
#> SRR1047814     1  0.0000      0.996 1.00  0  0 0.00
#> SRR1047815     1  0.0000      0.996 1.00  0  0 0.00
#> SRR1047816     1  0.0000      0.996 1.00  0  0 0.00
#> SRR1047817     1  0.0000      0.996 1.00  0  0 0.00
#> SRR1047818     4  0.0000      1.000 0.00  0  0 1.00
#> SRR1047819     4  0.0000      1.000 0.00  0  0 1.00
#> SRR1047820     4  0.0000      1.000 0.00  0  0 1.00
#> SRR1047821     4  0.0000      1.000 0.00  0  0 1.00
#> SRR1047822     4  0.0000      1.000 0.00  0  0 1.00
#> SRR1047823     4  0.0000      1.000 0.00  0  0 1.00
#> SRR1047824     4  0.0000      1.000 0.00  0  0 1.00
#> SRR1047825     4  0.0000      1.000 0.00  0  0 1.00
#> SRR1047826     4  0.0000      1.000 0.00  0  0 1.00
#> SRR1047827     4  0.0000      1.000 0.00  0  0 1.00
#> SRR1047828     1  0.0000      0.996 1.00  0  0 0.00
#> SRR1047829     1  0.0000      0.996 1.00  0  0 0.00
#> SRR1047830     1  0.0000      0.996 1.00  0  0 0.00
#> SRR1047831     1  0.0000      0.996 1.00  0  0 0.00
#> SRR1047832     1  0.0000      0.996 1.00  0  0 0.00
#> SRR1047833     2  0.0000      1.000 0.00  1  0 0.00
#> SRR1047834     2  0.0000      1.000 0.00  1  0 0.00
#> SRR1047835     2  0.0000      1.000 0.00  1  0 0.00
#> SRR1047836     2  0.0000      1.000 0.00  1  0 0.00
#> SRR1047837     2  0.0000      1.000 0.00  1  0 0.00
#> SRR1047838     4  0.0000      1.000 0.00  0  0 1.00
#> SRR1047839     4  0.0000      1.000 0.00  0  0 1.00
#> SRR1047840     4  0.0000      1.000 0.00  0  0 1.00
#> SRR1047841     4  0.0000      1.000 0.00  0  0 1.00
#> SRR1047842     4  0.0000      1.000 0.00  0  0 1.00
#> SRR1047843     1  0.0000      0.996 1.00  0  0 0.00
#> SRR1047844     1  0.0000      0.996 1.00  0  0 0.00
#> SRR1047845     1  0.0000      0.996 1.00  0  0 0.00
#> SRR1047846     1  0.0000      0.996 1.00  0  0 0.00
#> SRR1047847     1  0.0000      0.996 1.00  0  0 0.00
#> SRR1047848     1  0.0000      0.996 1.00  0  0 0.00
#> SRR1047849     1  0.0000      0.996 1.00  0  0 0.00
#> SRR1047850     1  0.0000      0.996 1.00  0  0 0.00
#> SRR1047851     1  0.0000      0.996 1.00  0  0 0.00
#> SRR1047852     1  0.0000      0.996 1.00  0  0 0.00
#> SRR1047853     1  0.0707      0.980 0.98  0  0 0.02
#> SRR1047854     1  0.0707      0.980 0.98  0  0 0.02
#> SRR1047855     1  0.0707      0.980 0.98  0  0 0.02
#> SRR1047856     1  0.0707      0.980 0.98  0  0 0.02
#> SRR1047857     1  0.0707      0.980 0.98  0  0 0.02
#> SRR1047858     1  0.0000      0.996 1.00  0  0 0.00
#> SRR1047859     1  0.0000      0.996 1.00  0  0 0.00
#> SRR1047860     1  0.0000      0.996 1.00  0  0 0.00
#> SRR1047861     1  0.0000      0.996 1.00  0  0 0.00
#> SRR1047863     3  0.0000      1.000 0.00  0  1 0.00
#> SRR1047864     3  0.0000      1.000 0.00  0  1 0.00
#> SRR1047865     3  0.0000      1.000 0.00  0  1 0.00
#> SRR1047866     3  0.0000      1.000 0.00  0  1 0.00
#> SRR1047867     3  0.0000      1.000 0.00  0  1 0.00
#> SRR1047868     3  0.0000      1.000 0.00  0  1 0.00
#> SRR1047869     3  0.0000      1.000 0.00  0  1 0.00
#> SRR1047870     3  0.0000      1.000 0.00  0  1 0.00
#> SRR1047871     3  0.0000      1.000 0.00  0  1 0.00
#> SRR1047872     3  0.0000      1.000 0.00  0  1 0.00
#> SRR1047873     3  0.0000      1.000 0.00  0  1 0.00
#> SRR1047874     3  0.0000      1.000 0.00  0  1 0.00

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1 p2 p3   p4    p5
#> SRR1047813     1  0.0000      0.975 1.000  0  0 0.00 0.000
#> SRR1047814     1  0.0000      0.975 1.000  0  0 0.00 0.000
#> SRR1047815     1  0.0000      0.975 1.000  0  0 0.00 0.000
#> SRR1047816     1  0.0000      0.975 1.000  0  0 0.00 0.000
#> SRR1047817     1  0.0000      0.975 1.000  0  0 0.00 0.000
#> SRR1047818     4  0.0000      1.000 0.000  0  0 1.00 0.000
#> SRR1047819     4  0.0000      1.000 0.000  0  0 1.00 0.000
#> SRR1047820     4  0.0000      1.000 0.000  0  0 1.00 0.000
#> SRR1047821     4  0.0000      1.000 0.000  0  0 1.00 0.000
#> SRR1047822     4  0.0000      1.000 0.000  0  0 1.00 0.000
#> SRR1047823     4  0.0000      1.000 0.000  0  0 1.00 0.000
#> SRR1047824     4  0.0000      1.000 0.000  0  0 1.00 0.000
#> SRR1047825     4  0.0000      1.000 0.000  0  0 1.00 0.000
#> SRR1047826     4  0.0000      1.000 0.000  0  0 1.00 0.000
#> SRR1047827     4  0.0000      1.000 0.000  0  0 1.00 0.000
#> SRR1047828     5  0.0000      0.993 0.000  0  0 0.00 1.000
#> SRR1047829     5  0.0000      0.993 0.000  0  0 0.00 1.000
#> SRR1047830     5  0.0000      0.993 0.000  0  0 0.00 1.000
#> SRR1047831     5  0.0000      0.993 0.000  0  0 0.00 1.000
#> SRR1047832     5  0.0000      0.993 0.000  0  0 0.00 1.000
#> SRR1047833     2  0.0000      1.000 0.000  1  0 0.00 0.000
#> SRR1047834     2  0.0000      1.000 0.000  1  0 0.00 0.000
#> SRR1047835     2  0.0000      1.000 0.000  1  0 0.00 0.000
#> SRR1047836     2  0.0000      1.000 0.000  1  0 0.00 0.000
#> SRR1047837     2  0.0000      1.000 0.000  1  0 0.00 0.000
#> SRR1047838     4  0.0000      1.000 0.000  0  0 1.00 0.000
#> SRR1047839     4  0.0000      1.000 0.000  0  0 1.00 0.000
#> SRR1047840     4  0.0000      1.000 0.000  0  0 1.00 0.000
#> SRR1047841     4  0.0000      1.000 0.000  0  0 1.00 0.000
#> SRR1047842     4  0.0000      1.000 0.000  0  0 1.00 0.000
#> SRR1047843     5  0.0000      0.993 0.000  0  0 0.00 1.000
#> SRR1047844     5  0.0000      0.993 0.000  0  0 0.00 1.000
#> SRR1047845     5  0.0000      0.993 0.000  0  0 0.00 1.000
#> SRR1047846     5  0.0000      0.993 0.000  0  0 0.00 1.000
#> SRR1047847     5  0.0000      0.993 0.000  0  0 0.00 1.000
#> SRR1047848     1  0.0880      0.975 0.968  0  0 0.00 0.032
#> SRR1047849     1  0.0880      0.975 0.968  0  0 0.00 0.032
#> SRR1047850     1  0.0880      0.975 0.968  0  0 0.00 0.032
#> SRR1047851     1  0.0880      0.975 0.968  0  0 0.00 0.032
#> SRR1047852     1  0.0880      0.975 0.968  0  0 0.00 0.032
#> SRR1047853     5  0.0609      0.981 0.000  0  0 0.02 0.980
#> SRR1047854     5  0.0609      0.981 0.000  0  0 0.02 0.980
#> SRR1047855     5  0.0609      0.981 0.000  0  0 0.02 0.980
#> SRR1047856     5  0.0609      0.981 0.000  0  0 0.02 0.980
#> SRR1047857     5  0.0609      0.981 0.000  0  0 0.02 0.980
#> SRR1047858     5  0.0000      0.993 0.000  0  0 0.00 1.000
#> SRR1047859     5  0.0000      0.993 0.000  0  0 0.00 1.000
#> SRR1047860     5  0.0000      0.993 0.000  0  0 0.00 1.000
#> SRR1047861     5  0.0000      0.993 0.000  0  0 0.00 1.000
#> SRR1047863     3  0.0000      1.000 0.000  0  1 0.00 0.000
#> SRR1047864     3  0.0000      1.000 0.000  0  1 0.00 0.000
#> SRR1047865     3  0.0000      1.000 0.000  0  1 0.00 0.000
#> SRR1047866     3  0.0000      1.000 0.000  0  1 0.00 0.000
#> SRR1047867     3  0.0000      1.000 0.000  0  1 0.00 0.000
#> SRR1047868     3  0.0000      1.000 0.000  0  1 0.00 0.000
#> SRR1047869     3  0.0000      1.000 0.000  0  1 0.00 0.000
#> SRR1047870     3  0.0000      1.000 0.000  0  1 0.00 0.000
#> SRR1047871     3  0.0000      1.000 0.000  0  1 0.00 0.000
#> SRR1047872     3  0.0000      1.000 0.000  0  1 0.00 0.000
#> SRR1047873     3  0.0000      1.000 0.000  0  1 0.00 0.000
#> SRR1047874     3  0.0000      1.000 0.000  0  1 0.00 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
#> SRR1047813     1  0.0000      0.975 1.000  0 0.000 0.00 0.000 0.000
#> SRR1047814     1  0.0000      0.975 1.000  0 0.000 0.00 0.000 0.000
#> SRR1047815     1  0.0000      0.975 1.000  0 0.000 0.00 0.000 0.000
#> SRR1047816     1  0.0000      0.975 1.000  0 0.000 0.00 0.000 0.000
#> SRR1047817     1  0.0000      0.975 1.000  0 0.000 0.00 0.000 0.000
#> SRR1047818     4  0.0000      1.000 0.000  0 0.000 1.00 0.000 0.000
#> SRR1047819     4  0.0000      1.000 0.000  0 0.000 1.00 0.000 0.000
#> SRR1047820     4  0.0000      1.000 0.000  0 0.000 1.00 0.000 0.000
#> SRR1047821     4  0.0000      1.000 0.000  0 0.000 1.00 0.000 0.000
#> SRR1047822     4  0.0000      1.000 0.000  0 0.000 1.00 0.000 0.000
#> SRR1047823     4  0.0000      1.000 0.000  0 0.000 1.00 0.000 0.000
#> SRR1047824     4  0.0000      1.000 0.000  0 0.000 1.00 0.000 0.000
#> SRR1047825     4  0.0000      1.000 0.000  0 0.000 1.00 0.000 0.000
#> SRR1047826     4  0.0000      1.000 0.000  0 0.000 1.00 0.000 0.000
#> SRR1047827     4  0.0000      1.000 0.000  0 0.000 1.00 0.000 0.000
#> SRR1047828     5  0.0000      0.993 0.000  0 0.000 0.00 1.000 0.000
#> SRR1047829     5  0.0000      0.993 0.000  0 0.000 0.00 1.000 0.000
#> SRR1047830     5  0.0000      0.993 0.000  0 0.000 0.00 1.000 0.000
#> SRR1047831     5  0.0000      0.993 0.000  0 0.000 0.00 1.000 0.000
#> SRR1047832     5  0.0000      0.993 0.000  0 0.000 0.00 1.000 0.000
#> SRR1047833     2  0.0000      1.000 0.000  1 0.000 0.00 0.000 0.000
#> SRR1047834     2  0.0000      1.000 0.000  1 0.000 0.00 0.000 0.000
#> SRR1047835     2  0.0000      1.000 0.000  1 0.000 0.00 0.000 0.000
#> SRR1047836     2  0.0000      1.000 0.000  1 0.000 0.00 0.000 0.000
#> SRR1047837     2  0.0000      1.000 0.000  1 0.000 0.00 0.000 0.000
#> SRR1047838     4  0.0000      1.000 0.000  0 0.000 1.00 0.000 0.000
#> SRR1047839     4  0.0000      1.000 0.000  0 0.000 1.00 0.000 0.000
#> SRR1047840     4  0.0000      1.000 0.000  0 0.000 1.00 0.000 0.000
#> SRR1047841     4  0.0000      1.000 0.000  0 0.000 1.00 0.000 0.000
#> SRR1047842     4  0.0000      1.000 0.000  0 0.000 1.00 0.000 0.000
#> SRR1047843     5  0.0000      0.993 0.000  0 0.000 0.00 1.000 0.000
#> SRR1047844     5  0.0000      0.993 0.000  0 0.000 0.00 1.000 0.000
#> SRR1047845     5  0.0000      0.993 0.000  0 0.000 0.00 1.000 0.000
#> SRR1047846     5  0.0000      0.993 0.000  0 0.000 0.00 1.000 0.000
#> SRR1047847     5  0.0000      0.993 0.000  0 0.000 0.00 1.000 0.000
#> SRR1047848     1  0.0790      0.975 0.968  0 0.000 0.00 0.032 0.000
#> SRR1047849     1  0.0790      0.975 0.968  0 0.000 0.00 0.032 0.000
#> SRR1047850     1  0.0790      0.975 0.968  0 0.000 0.00 0.032 0.000
#> SRR1047851     1  0.0790      0.975 0.968  0 0.000 0.00 0.032 0.000
#> SRR1047852     1  0.0790      0.975 0.968  0 0.000 0.00 0.032 0.000
#> SRR1047853     5  0.0547      0.981 0.000  0 0.000 0.02 0.980 0.000
#> SRR1047854     5  0.0547      0.981 0.000  0 0.000 0.02 0.980 0.000
#> SRR1047855     5  0.0547      0.981 0.000  0 0.000 0.02 0.980 0.000
#> SRR1047856     5  0.0547      0.981 0.000  0 0.000 0.02 0.980 0.000
#> SRR1047857     5  0.0547      0.981 0.000  0 0.000 0.02 0.980 0.000
#> SRR1047858     5  0.0000      0.993 0.000  0 0.000 0.00 1.000 0.000
#> SRR1047859     5  0.0000      0.993 0.000  0 0.000 0.00 1.000 0.000
#> SRR1047860     5  0.0000      0.993 0.000  0 0.000 0.00 1.000 0.000
#> SRR1047861     5  0.0000      0.993 0.000  0 0.000 0.00 1.000 0.000
#> SRR1047863     3  0.0146      0.995 0.000  0 0.996 0.00 0.000 0.004
#> SRR1047864     6  0.0000      1.000 0.000  0 0.000 0.00 0.000 1.000
#> SRR1047865     6  0.0000      1.000 0.000  0 0.000 0.00 0.000 1.000
#> SRR1047866     6  0.0000      1.000 0.000  0 0.000 0.00 0.000 1.000
#> SRR1047867     6  0.0000      1.000 0.000  0 0.000 0.00 0.000 1.000
#> SRR1047868     3  0.0000      0.997 0.000  0 1.000 0.00 0.000 0.000
#> SRR1047869     6  0.0000      1.000 0.000  0 0.000 0.00 0.000 1.000
#> SRR1047870     3  0.0000      0.997 0.000  0 1.000 0.00 0.000 0.000
#> SRR1047871     3  0.0458      0.985 0.000  0 0.984 0.00 0.000 0.016
#> SRR1047872     3  0.0000      0.997 0.000  0 1.000 0.00 0.000 0.000
#> SRR1047873     3  0.0000      0.997 0.000  0 1.000 0.00 0.000 0.000
#> SRR1047874     3  0.0000      0.997 0.000  0 1.000 0.00 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-mclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-mclust-collect-classes

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

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

collect_plots(res)

plot of chunk SD-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.1539 0.847   0.847
#> 3 3 1.000           1.000       1.000         1.8734 0.711   0.659
#> 4 4 0.780           0.903       0.953         0.5320 0.762   0.574
#> 5 5 0.738           0.709       0.852         0.1267 0.831   0.532
#> 6 6 0.682           0.689       0.794         0.0511 0.864   0.503

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette p1 p2
#> SRR1047813     1       0          1  1  0
#> SRR1047814     1       0          1  1  0
#> SRR1047815     1       0          1  1  0
#> SRR1047816     1       0          1  1  0
#> SRR1047817     1       0          1  1  0
#> SRR1047818     1       0          1  1  0
#> SRR1047819     1       0          1  1  0
#> SRR1047820     1       0          1  1  0
#> SRR1047821     1       0          1  1  0
#> SRR1047822     1       0          1  1  0
#> SRR1047823     1       0          1  1  0
#> SRR1047824     1       0          1  1  0
#> SRR1047825     1       0          1  1  0
#> SRR1047826     1       0          1  1  0
#> SRR1047827     1       0          1  1  0
#> SRR1047828     1       0          1  1  0
#> SRR1047829     1       0          1  1  0
#> SRR1047830     1       0          1  1  0
#> SRR1047831     1       0          1  1  0
#> SRR1047832     1       0          1  1  0
#> SRR1047833     2       0          1  0  1
#> SRR1047834     2       0          1  0  1
#> SRR1047835     2       0          1  0  1
#> SRR1047836     2       0          1  0  1
#> SRR1047837     2       0          1  0  1
#> SRR1047838     1       0          1  1  0
#> SRR1047839     1       0          1  1  0
#> SRR1047840     1       0          1  1  0
#> SRR1047841     1       0          1  1  0
#> SRR1047842     1       0          1  1  0
#> SRR1047843     1       0          1  1  0
#> SRR1047844     1       0          1  1  0
#> SRR1047845     1       0          1  1  0
#> SRR1047846     1       0          1  1  0
#> SRR1047847     1       0          1  1  0
#> SRR1047848     1       0          1  1  0
#> SRR1047849     1       0          1  1  0
#> SRR1047850     1       0          1  1  0
#> SRR1047851     1       0          1  1  0
#> SRR1047852     1       0          1  1  0
#> SRR1047853     1       0          1  1  0
#> SRR1047854     1       0          1  1  0
#> SRR1047855     1       0          1  1  0
#> SRR1047856     1       0          1  1  0
#> SRR1047857     1       0          1  1  0
#> SRR1047858     1       0          1  1  0
#> SRR1047859     1       0          1  1  0
#> SRR1047860     1       0          1  1  0
#> SRR1047861     1       0          1  1  0
#> SRR1047863     1       0          1  1  0
#> SRR1047864     1       0          1  1  0
#> SRR1047865     1       0          1  1  0
#> SRR1047866     1       0          1  1  0
#> SRR1047867     1       0          1  1  0
#> SRR1047868     1       0          1  1  0
#> SRR1047869     1       0          1  1  0
#> SRR1047870     1       0          1  1  0
#> SRR1047871     1       0          1  1  0
#> SRR1047872     1       0          1  1  0
#> SRR1047873     1       0          1  1  0
#> SRR1047874     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette p1 p2 p3
#> SRR1047813     1       0          1  1  0  0
#> SRR1047814     1       0          1  1  0  0
#> SRR1047815     1       0          1  1  0  0
#> SRR1047816     1       0          1  1  0  0
#> SRR1047817     1       0          1  1  0  0
#> SRR1047818     1       0          1  1  0  0
#> SRR1047819     1       0          1  1  0  0
#> SRR1047820     1       0          1  1  0  0
#> SRR1047821     1       0          1  1  0  0
#> SRR1047822     1       0          1  1  0  0
#> SRR1047823     1       0          1  1  0  0
#> SRR1047824     1       0          1  1  0  0
#> SRR1047825     1       0          1  1  0  0
#> SRR1047826     1       0          1  1  0  0
#> SRR1047827     1       0          1  1  0  0
#> SRR1047828     1       0          1  1  0  0
#> SRR1047829     1       0          1  1  0  0
#> SRR1047830     1       0          1  1  0  0
#> SRR1047831     1       0          1  1  0  0
#> SRR1047832     1       0          1  1  0  0
#> SRR1047833     2       0          1  0  1  0
#> SRR1047834     2       0          1  0  1  0
#> SRR1047835     2       0          1  0  1  0
#> SRR1047836     2       0          1  0  1  0
#> SRR1047837     2       0          1  0  1  0
#> SRR1047838     1       0          1  1  0  0
#> SRR1047839     1       0          1  1  0  0
#> SRR1047840     1       0          1  1  0  0
#> SRR1047841     1       0          1  1  0  0
#> SRR1047842     1       0          1  1  0  0
#> SRR1047843     1       0          1  1  0  0
#> SRR1047844     1       0          1  1  0  0
#> SRR1047845     1       0          1  1  0  0
#> SRR1047846     1       0          1  1  0  0
#> SRR1047847     1       0          1  1  0  0
#> SRR1047848     1       0          1  1  0  0
#> SRR1047849     1       0          1  1  0  0
#> SRR1047850     1       0          1  1  0  0
#> SRR1047851     1       0          1  1  0  0
#> SRR1047852     1       0          1  1  0  0
#> SRR1047853     1       0          1  1  0  0
#> SRR1047854     1       0          1  1  0  0
#> SRR1047855     1       0          1  1  0  0
#> SRR1047856     1       0          1  1  0  0
#> SRR1047857     1       0          1  1  0  0
#> SRR1047858     1       0          1  1  0  0
#> SRR1047859     1       0          1  1  0  0
#> SRR1047860     1       0          1  1  0  0
#> SRR1047861     1       0          1  1  0  0
#> SRR1047863     3       0          1  0  0  1
#> SRR1047864     3       0          1  0  0  1
#> SRR1047865     3       0          1  0  0  1
#> SRR1047866     3       0          1  0  0  1
#> SRR1047867     3       0          1  0  0  1
#> SRR1047868     3       0          1  0  0  1
#> SRR1047869     3       0          1  0  0  1
#> SRR1047870     3       0          1  0  0  1
#> SRR1047871     3       0          1  0  0  1
#> SRR1047872     3       0          1  0  0  1
#> SRR1047873     3       0          1  0  0  1
#> SRR1047874     3       0          1  0  0  1

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1 p2 p3    p4
#> SRR1047813     1   0.000      0.921 1.000  0  0 0.000
#> SRR1047814     1   0.000      0.921 1.000  0  0 0.000
#> SRR1047815     1   0.000      0.921 1.000  0  0 0.000
#> SRR1047816     1   0.000      0.921 1.000  0  0 0.000
#> SRR1047817     1   0.000      0.921 1.000  0  0 0.000
#> SRR1047818     4   0.000      0.902 0.000  0  0 1.000
#> SRR1047819     4   0.000      0.902 0.000  0  0 1.000
#> SRR1047820     4   0.000      0.902 0.000  0  0 1.000
#> SRR1047821     4   0.000      0.902 0.000  0  0 1.000
#> SRR1047822     4   0.000      0.902 0.000  0  0 1.000
#> SRR1047823     4   0.349      0.765 0.188  0  0 0.812
#> SRR1047824     4   0.241      0.842 0.104  0  0 0.896
#> SRR1047825     4   0.407      0.686 0.252  0  0 0.748
#> SRR1047826     4   0.410      0.678 0.256  0  0 0.744
#> SRR1047827     4   0.265      0.830 0.120  0  0 0.880
#> SRR1047828     1   0.000      0.921 1.000  0  0 0.000
#> SRR1047829     1   0.000      0.921 1.000  0  0 0.000
#> SRR1047830     1   0.000      0.921 1.000  0  0 0.000
#> SRR1047831     1   0.000      0.921 1.000  0  0 0.000
#> SRR1047832     1   0.000      0.921 1.000  0  0 0.000
#> SRR1047833     2   0.000      1.000 0.000  1  0 0.000
#> SRR1047834     2   0.000      1.000 0.000  1  0 0.000
#> SRR1047835     2   0.000      1.000 0.000  1  0 0.000
#> SRR1047836     2   0.000      1.000 0.000  1  0 0.000
#> SRR1047837     2   0.000      1.000 0.000  1  0 0.000
#> SRR1047838     4   0.000      0.902 0.000  0  0 1.000
#> SRR1047839     4   0.000      0.902 0.000  0  0 1.000
#> SRR1047840     4   0.000      0.902 0.000  0  0 1.000
#> SRR1047841     4   0.000      0.902 0.000  0  0 1.000
#> SRR1047842     4   0.000      0.902 0.000  0  0 1.000
#> SRR1047843     1   0.000      0.921 1.000  0  0 0.000
#> SRR1047844     1   0.000      0.921 1.000  0  0 0.000
#> SRR1047845     1   0.000      0.921 1.000  0  0 0.000
#> SRR1047846     1   0.000      0.921 1.000  0  0 0.000
#> SRR1047847     1   0.000      0.921 1.000  0  0 0.000
#> SRR1047848     1   0.000      0.921 1.000  0  0 0.000
#> SRR1047849     1   0.000      0.921 1.000  0  0 0.000
#> SRR1047850     1   0.000      0.921 1.000  0  0 0.000
#> SRR1047851     1   0.000      0.921 1.000  0  0 0.000
#> SRR1047852     1   0.000      0.921 1.000  0  0 0.000
#> SRR1047853     1   0.349      0.795 0.812  0  0 0.188
#> SRR1047854     1   0.302      0.829 0.852  0  0 0.148
#> SRR1047855     1   0.281      0.841 0.868  0  0 0.132
#> SRR1047856     1   0.361      0.783 0.800  0  0 0.200
#> SRR1047857     1   0.413      0.706 0.740  0  0 0.260
#> SRR1047858     1   0.401      0.731 0.756  0  0 0.244
#> SRR1047859     1   0.410      0.714 0.744  0  0 0.256
#> SRR1047860     1   0.407      0.720 0.748  0  0 0.252
#> SRR1047861     1   0.407      0.720 0.748  0  0 0.252
#> SRR1047863     3   0.000      1.000 0.000  0  1 0.000
#> SRR1047864     3   0.000      1.000 0.000  0  1 0.000
#> SRR1047865     3   0.000      1.000 0.000  0  1 0.000
#> SRR1047866     3   0.000      1.000 0.000  0  1 0.000
#> SRR1047867     3   0.000      1.000 0.000  0  1 0.000
#> SRR1047868     3   0.000      1.000 0.000  0  1 0.000
#> SRR1047869     3   0.000      1.000 0.000  0  1 0.000
#> SRR1047870     3   0.000      1.000 0.000  0  1 0.000
#> SRR1047871     3   0.000      1.000 0.000  0  1 0.000
#> SRR1047872     3   0.000      1.000 0.000  0  1 0.000
#> SRR1047873     3   0.000      1.000 0.000  0  1 0.000
#> SRR1047874     3   0.000      1.000 0.000  0  1 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
#> SRR1047813     5  0.4251     0.7661 0.316  0 0.000 0.012 0.672
#> SRR1047814     5  0.4270     0.7598 0.320  0 0.000 0.012 0.668
#> SRR1047815     5  0.4251     0.7661 0.316  0 0.000 0.012 0.672
#> SRR1047816     5  0.4251     0.7661 0.316  0 0.000 0.012 0.672
#> SRR1047817     5  0.4152     0.7739 0.296  0 0.000 0.012 0.692
#> SRR1047818     4  0.1341     0.9036 0.000  0 0.000 0.944 0.056
#> SRR1047819     4  0.1341     0.9020 0.000  0 0.000 0.944 0.056
#> SRR1047820     4  0.1197     0.9038 0.000  0 0.000 0.952 0.048
#> SRR1047821     4  0.1270     0.9032 0.000  0 0.000 0.948 0.052
#> SRR1047822     4  0.1341     0.8981 0.000  0 0.000 0.944 0.056
#> SRR1047823     1  0.5680     0.0200 0.492  0 0.000 0.428 0.080
#> SRR1047824     4  0.5399     0.0595 0.448  0 0.000 0.496 0.056
#> SRR1047825     1  0.5697     0.2077 0.548  0 0.000 0.360 0.092
#> SRR1047826     1  0.5663     0.2008 0.548  0 0.000 0.364 0.088
#> SRR1047827     1  0.5604    -0.0836 0.468  0 0.000 0.460 0.072
#> SRR1047828     1  0.4045     0.2657 0.644  0 0.000 0.000 0.356
#> SRR1047829     1  0.4455     0.1745 0.588  0 0.008 0.000 0.404
#> SRR1047830     1  0.4074     0.2782 0.636  0 0.000 0.000 0.364
#> SRR1047831     1  0.4074     0.2782 0.636  0 0.000 0.000 0.364
#> SRR1047832     1  0.4138     0.2392 0.616  0 0.000 0.000 0.384
#> SRR1047833     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000
#> SRR1047834     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000
#> SRR1047835     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000
#> SRR1047836     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000
#> SRR1047837     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000
#> SRR1047838     4  0.1661     0.9000 0.024  0 0.000 0.940 0.036
#> SRR1047839     4  0.1638     0.8685 0.004  0 0.000 0.932 0.064
#> SRR1047840     4  0.1082     0.8929 0.028  0 0.000 0.964 0.008
#> SRR1047841     4  0.0912     0.8963 0.016  0 0.000 0.972 0.012
#> SRR1047842     4  0.1195     0.9021 0.012  0 0.000 0.960 0.028
#> SRR1047843     1  0.2966     0.5758 0.816  0 0.000 0.000 0.184
#> SRR1047844     1  0.5808     0.3417 0.576  0 0.100 0.004 0.320
#> SRR1047845     1  0.3242     0.5626 0.784  0 0.000 0.000 0.216
#> SRR1047846     1  0.3305     0.5576 0.776  0 0.000 0.000 0.224
#> SRR1047847     1  0.5203     0.3984 0.620  0 0.052 0.004 0.324
#> SRR1047848     1  0.0671     0.6561 0.980  0 0.000 0.004 0.016
#> SRR1047849     1  0.0671     0.6561 0.980  0 0.000 0.004 0.016
#> SRR1047850     1  0.0671     0.6561 0.980  0 0.000 0.004 0.016
#> SRR1047851     1  0.0671     0.6561 0.980  0 0.000 0.004 0.016
#> SRR1047852     1  0.0671     0.6561 0.980  0 0.000 0.004 0.016
#> SRR1047853     5  0.2423     0.7959 0.080  0 0.000 0.024 0.896
#> SRR1047854     5  0.2248     0.8015 0.088  0 0.000 0.012 0.900
#> SRR1047855     5  0.2361     0.8034 0.096  0 0.000 0.012 0.892
#> SRR1047856     5  0.2390     0.7964 0.084  0 0.000 0.020 0.896
#> SRR1047857     5  0.2423     0.7929 0.080  0 0.000 0.024 0.896
#> SRR1047858     1  0.0771     0.6574 0.976  0 0.000 0.004 0.020
#> SRR1047859     1  0.1205     0.6548 0.956  0 0.000 0.004 0.040
#> SRR1047860     1  0.1041     0.6565 0.964  0 0.000 0.004 0.032
#> SRR1047861     1  0.1124     0.6559 0.960  0 0.000 0.004 0.036
#> SRR1047863     3  0.0000     0.9693 0.000  0 1.000 0.000 0.000
#> SRR1047864     3  0.0000     0.9693 0.000  0 1.000 0.000 0.000
#> SRR1047865     3  0.1041     0.9524 0.004  0 0.964 0.000 0.032
#> SRR1047866     3  0.0000     0.9693 0.000  0 1.000 0.000 0.000
#> SRR1047867     3  0.0290     0.9672 0.000  0 0.992 0.000 0.008
#> SRR1047868     3  0.0162     0.9692 0.000  0 0.996 0.000 0.004
#> SRR1047869     3  0.2574     0.8881 0.012  0 0.876 0.000 0.112
#> SRR1047870     3  0.0000     0.9693 0.000  0 1.000 0.000 0.000
#> SRR1047871     3  0.0162     0.9692 0.000  0 0.996 0.000 0.004
#> SRR1047872     3  0.0566     0.9649 0.000  0 0.984 0.012 0.004
#> SRR1047873     3  0.1628     0.9416 0.000  0 0.936 0.008 0.056
#> SRR1047874     3  0.1956     0.9263 0.000  0 0.916 0.008 0.076

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1 p2    p3    p4    p5    p6
#> SRR1047813     5  0.3050      0.737 0.136  0 0.000 0.028 0.832 0.004
#> SRR1047814     5  0.3240      0.735 0.144  0 0.000 0.028 0.820 0.008
#> SRR1047815     5  0.3130      0.736 0.144  0 0.000 0.028 0.824 0.004
#> SRR1047816     5  0.3090      0.736 0.140  0 0.000 0.028 0.828 0.004
#> SRR1047817     5  0.2666      0.732 0.092  0 0.000 0.028 0.872 0.008
#> SRR1047818     4  0.2182      0.802 0.020  0 0.000 0.904 0.068 0.008
#> SRR1047819     4  0.1982      0.803 0.016  0 0.000 0.912 0.068 0.004
#> SRR1047820     4  0.2036      0.805 0.016  0 0.000 0.912 0.064 0.008
#> SRR1047821     4  0.1863      0.804 0.016  0 0.000 0.920 0.060 0.004
#> SRR1047822     4  0.1196      0.794 0.000  0 0.000 0.952 0.040 0.008
#> SRR1047823     4  0.5942      0.200 0.424  0 0.000 0.444 0.100 0.032
#> SRR1047824     4  0.5596      0.431 0.336  0 0.000 0.552 0.084 0.028
#> SRR1047825     1  0.5935     -0.223 0.460  0 0.000 0.408 0.100 0.032
#> SRR1047826     1  0.5937     -0.232 0.456  0 0.000 0.412 0.100 0.032
#> SRR1047827     4  0.5831      0.344 0.372  0 0.000 0.500 0.100 0.028
#> SRR1047828     5  0.5498      0.440 0.400  0 0.004 0.000 0.484 0.112
#> SRR1047829     5  0.6282      0.425 0.336  0 0.024 0.000 0.456 0.184
#> SRR1047830     5  0.5963      0.452 0.372  0 0.016 0.000 0.468 0.144
#> SRR1047831     5  0.5952      0.462 0.364  0 0.016 0.000 0.476 0.144
#> SRR1047832     5  0.6041      0.453 0.356  0 0.016 0.000 0.468 0.160
#> SRR1047833     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> SRR1047834     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> SRR1047835     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> SRR1047836     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> SRR1047837     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> SRR1047838     4  0.2209      0.801 0.072  0 0.000 0.900 0.024 0.004
#> SRR1047839     4  0.3488      0.688 0.032  0 0.000 0.804 0.012 0.152
#> SRR1047840     4  0.1728      0.801 0.064  0 0.000 0.924 0.004 0.008
#> SRR1047841     4  0.1951      0.797 0.060  0 0.000 0.916 0.004 0.020
#> SRR1047842     4  0.2002      0.799 0.056  0 0.000 0.916 0.008 0.020
#> SRR1047843     6  0.5710      0.749 0.372  0 0.000 0.012 0.120 0.496
#> SRR1047844     6  0.5977      0.841 0.228  0 0.036 0.020 0.104 0.612
#> SRR1047845     6  0.5435      0.865 0.316  0 0.000 0.012 0.104 0.568
#> SRR1047846     6  0.5491      0.868 0.308  0 0.000 0.016 0.104 0.572
#> SRR1047847     6  0.6035      0.839 0.224  0 0.032 0.028 0.104 0.612
#> SRR1047848     1  0.1218      0.658 0.956  0 0.000 0.004 0.028 0.012
#> SRR1047849     1  0.0508      0.671 0.984  0 0.000 0.004 0.012 0.000
#> SRR1047850     1  0.0653      0.669 0.980  0 0.000 0.004 0.012 0.004
#> SRR1047851     1  0.0508      0.671 0.984  0 0.000 0.004 0.012 0.000
#> SRR1047852     1  0.0508      0.671 0.984  0 0.000 0.004 0.012 0.000
#> SRR1047853     5  0.2854      0.690 0.024  0 0.000 0.068 0.872 0.036
#> SRR1047854     5  0.2701      0.710 0.044  0 0.000 0.044 0.884 0.028
#> SRR1047855     5  0.2701      0.710 0.044  0 0.000 0.044 0.884 0.028
#> SRR1047856     5  0.2883      0.683 0.020  0 0.000 0.076 0.868 0.036
#> SRR1047857     5  0.3139      0.657 0.012  0 0.000 0.084 0.848 0.056
#> SRR1047858     1  0.3477      0.597 0.808  0 0.000 0.004 0.132 0.056
#> SRR1047859     1  0.4493      0.474 0.720  0 0.000 0.004 0.144 0.132
#> SRR1047860     1  0.3576      0.592 0.800  0 0.000 0.004 0.136 0.060
#> SRR1047861     1  0.3795      0.577 0.784  0 0.000 0.004 0.136 0.076
#> SRR1047863     3  0.0865      0.866 0.000  0 0.964 0.000 0.000 0.036
#> SRR1047864     3  0.1387      0.842 0.000  0 0.932 0.000 0.000 0.068
#> SRR1047865     3  0.2810      0.813 0.004  0 0.832 0.000 0.008 0.156
#> SRR1047866     3  0.0508      0.860 0.004  0 0.984 0.000 0.000 0.012
#> SRR1047867     3  0.1556      0.837 0.000  0 0.920 0.000 0.000 0.080
#> SRR1047868     3  0.1204      0.863 0.000  0 0.944 0.000 0.000 0.056
#> SRR1047869     3  0.4670      0.460 0.004  0 0.548 0.000 0.036 0.412
#> SRR1047870     3  0.0937      0.852 0.000  0 0.960 0.000 0.000 0.040
#> SRR1047871     3  0.0790      0.866 0.000  0 0.968 0.000 0.000 0.032
#> SRR1047872     3  0.1542      0.864 0.000  0 0.936 0.008 0.004 0.052
#> SRR1047873     3  0.4318      0.709 0.004  0 0.700 0.012 0.028 0.256
#> SRR1047874     3  0.4495      0.681 0.004  0 0.676 0.012 0.032 0.276

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

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

collect_plots(res)

plot of chunk CV-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.1811 0.820   0.820
#> 3 3 1.000           1.000       1.000         1.4586 0.736   0.677
#> 4 4 0.694           0.860       0.851         0.3000 0.762   0.572
#> 5 5 0.890           0.929       0.977         0.2144 0.891   0.695
#> 6 6 0.886           0.898       0.960         0.0256 0.987   0.955

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette p1 p2
#> SRR1047813     1       0          1  1  0
#> SRR1047814     1       0          1  1  0
#> SRR1047815     1       0          1  1  0
#> SRR1047816     1       0          1  1  0
#> SRR1047817     1       0          1  1  0
#> SRR1047818     1       0          1  1  0
#> SRR1047819     1       0          1  1  0
#> SRR1047820     1       0          1  1  0
#> SRR1047821     1       0          1  1  0
#> SRR1047822     1       0          1  1  0
#> SRR1047823     1       0          1  1  0
#> SRR1047824     1       0          1  1  0
#> SRR1047825     1       0          1  1  0
#> SRR1047826     1       0          1  1  0
#> SRR1047827     1       0          1  1  0
#> SRR1047828     1       0          1  1  0
#> SRR1047829     1       0          1  1  0
#> SRR1047830     1       0          1  1  0
#> SRR1047831     1       0          1  1  0
#> SRR1047832     1       0          1  1  0
#> SRR1047833     2       0          1  0  1
#> SRR1047834     2       0          1  0  1
#> SRR1047835     2       0          1  0  1
#> SRR1047836     2       0          1  0  1
#> SRR1047837     2       0          1  0  1
#> SRR1047838     1       0          1  1  0
#> SRR1047839     1       0          1  1  0
#> SRR1047840     1       0          1  1  0
#> SRR1047841     1       0          1  1  0
#> SRR1047842     1       0          1  1  0
#> SRR1047843     1       0          1  1  0
#> SRR1047844     1       0          1  1  0
#> SRR1047845     1       0          1  1  0
#> SRR1047846     1       0          1  1  0
#> SRR1047847     1       0          1  1  0
#> SRR1047848     1       0          1  1  0
#> SRR1047849     1       0          1  1  0
#> SRR1047850     1       0          1  1  0
#> SRR1047851     1       0          1  1  0
#> SRR1047852     1       0          1  1  0
#> SRR1047853     1       0          1  1  0
#> SRR1047854     1       0          1  1  0
#> SRR1047855     1       0          1  1  0
#> SRR1047856     1       0          1  1  0
#> SRR1047857     1       0          1  1  0
#> SRR1047858     1       0          1  1  0
#> SRR1047859     1       0          1  1  0
#> SRR1047860     1       0          1  1  0
#> SRR1047861     1       0          1  1  0
#> SRR1047863     1       0          1  1  0
#> SRR1047864     1       0          1  1  0
#> SRR1047865     1       0          1  1  0
#> SRR1047866     1       0          1  1  0
#> SRR1047867     2       0          1  0  1
#> SRR1047868     1       0          1  1  0
#> SRR1047869     1       0          1  1  0
#> SRR1047870     1       0          1  1  0
#> SRR1047871     1       0          1  1  0
#> SRR1047872     1       0          1  1  0
#> SRR1047873     1       0          1  1  0
#> SRR1047874     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette p1 p2 p3
#> SRR1047813     1       0          1  1  0  0
#> SRR1047814     1       0          1  1  0  0
#> SRR1047815     1       0          1  1  0  0
#> SRR1047816     1       0          1  1  0  0
#> SRR1047817     1       0          1  1  0  0
#> SRR1047818     1       0          1  1  0  0
#> SRR1047819     1       0          1  1  0  0
#> SRR1047820     1       0          1  1  0  0
#> SRR1047821     1       0          1  1  0  0
#> SRR1047822     1       0          1  1  0  0
#> SRR1047823     1       0          1  1  0  0
#> SRR1047824     1       0          1  1  0  0
#> SRR1047825     1       0          1  1  0  0
#> SRR1047826     1       0          1  1  0  0
#> SRR1047827     1       0          1  1  0  0
#> SRR1047828     1       0          1  1  0  0
#> SRR1047829     1       0          1  1  0  0
#> SRR1047830     1       0          1  1  0  0
#> SRR1047831     1       0          1  1  0  0
#> SRR1047832     1       0          1  1  0  0
#> SRR1047833     2       0          1  0  1  0
#> SRR1047834     2       0          1  0  1  0
#> SRR1047835     2       0          1  0  1  0
#> SRR1047836     2       0          1  0  1  0
#> SRR1047837     2       0          1  0  1  0
#> SRR1047838     1       0          1  1  0  0
#> SRR1047839     1       0          1  1  0  0
#> SRR1047840     1       0          1  1  0  0
#> SRR1047841     1       0          1  1  0  0
#> SRR1047842     1       0          1  1  0  0
#> SRR1047843     1       0          1  1  0  0
#> SRR1047844     1       0          1  1  0  0
#> SRR1047845     1       0          1  1  0  0
#> SRR1047846     1       0          1  1  0  0
#> SRR1047847     1       0          1  1  0  0
#> SRR1047848     1       0          1  1  0  0
#> SRR1047849     1       0          1  1  0  0
#> SRR1047850     1       0          1  1  0  0
#> SRR1047851     1       0          1  1  0  0
#> SRR1047852     1       0          1  1  0  0
#> SRR1047853     1       0          1  1  0  0
#> SRR1047854     1       0          1  1  0  0
#> SRR1047855     1       0          1  1  0  0
#> SRR1047856     1       0          1  1  0  0
#> SRR1047857     1       0          1  1  0  0
#> SRR1047858     1       0          1  1  0  0
#> SRR1047859     1       0          1  1  0  0
#> SRR1047860     1       0          1  1  0  0
#> SRR1047861     1       0          1  1  0  0
#> SRR1047863     3       0          1  0  0  1
#> SRR1047864     3       0          1  0  0  1
#> SRR1047865     3       0          1  0  0  1
#> SRR1047866     3       0          1  0  0  1
#> SRR1047867     2       0          1  0  1  0
#> SRR1047868     3       0          1  0  0  1
#> SRR1047869     3       0          1  0  0  1
#> SRR1047870     3       0          1  0  0  1
#> SRR1047871     3       0          1  0  0  1
#> SRR1047872     3       0          1  0  0  1
#> SRR1047873     3       0          1  0  0  1
#> SRR1047874     3       0          1  0  0  1

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2 p3    p4
#> SRR1047813     1  0.0000    0.88898 1.000 0.000  0 0.000
#> SRR1047814     1  0.0000    0.88898 1.000 0.000  0 0.000
#> SRR1047815     1  0.0000    0.88898 1.000 0.000  0 0.000
#> SRR1047816     1  0.0000    0.88898 1.000 0.000  0 0.000
#> SRR1047817     1  0.0000    0.88898 1.000 0.000  0 0.000
#> SRR1047818     4  0.4985    0.99043 0.468 0.000  0 0.532
#> SRR1047819     4  0.4985    0.99043 0.468 0.000  0 0.532
#> SRR1047820     4  0.4985    0.99043 0.468 0.000  0 0.532
#> SRR1047821     4  0.4985    0.99043 0.468 0.000  0 0.532
#> SRR1047822     4  0.4985    0.99043 0.468 0.000  0 0.532
#> SRR1047823     4  0.4985    0.99043 0.468 0.000  0 0.532
#> SRR1047824     4  0.4985    0.99043 0.468 0.000  0 0.532
#> SRR1047825     4  0.4985    0.99043 0.468 0.000  0 0.532
#> SRR1047826     4  0.4985    0.99043 0.468 0.000  0 0.532
#> SRR1047827     4  0.4985    0.99043 0.468 0.000  0 0.532
#> SRR1047828     1  0.0000    0.88898 1.000 0.000  0 0.000
#> SRR1047829     1  0.0000    0.88898 1.000 0.000  0 0.000
#> SRR1047830     1  0.0000    0.88898 1.000 0.000  0 0.000
#> SRR1047831     1  0.0000    0.88898 1.000 0.000  0 0.000
#> SRR1047832     1  0.0000    0.88898 1.000 0.000  0 0.000
#> SRR1047833     2  0.0000    0.94318 0.000 1.000  0 0.000
#> SRR1047834     2  0.0000    0.94318 0.000 1.000  0 0.000
#> SRR1047835     2  0.0000    0.94318 0.000 1.000  0 0.000
#> SRR1047836     2  0.0000    0.94318 0.000 1.000  0 0.000
#> SRR1047837     2  0.0000    0.94318 0.000 1.000  0 0.000
#> SRR1047838     4  0.4994    0.98049 0.480 0.000  0 0.520
#> SRR1047839     4  0.4994    0.98049 0.480 0.000  0 0.520
#> SRR1047840     4  0.4994    0.98049 0.480 0.000  0 0.520
#> SRR1047841     4  0.4994    0.98049 0.480 0.000  0 0.520
#> SRR1047842     4  0.4994    0.98049 0.480 0.000  0 0.520
#> SRR1047843     1  0.0469    0.88490 0.988 0.000  0 0.012
#> SRR1047844     1  0.0469    0.88490 0.988 0.000  0 0.012
#> SRR1047845     1  0.0469    0.88490 0.988 0.000  0 0.012
#> SRR1047846     1  0.0469    0.88490 0.988 0.000  0 0.012
#> SRR1047847     1  0.0469    0.88490 0.988 0.000  0 0.012
#> SRR1047848     1  0.0000    0.88898 1.000 0.000  0 0.000
#> SRR1047849     1  0.0000    0.88898 1.000 0.000  0 0.000
#> SRR1047850     1  0.0000    0.88898 1.000 0.000  0 0.000
#> SRR1047851     1  0.0000    0.88898 1.000 0.000  0 0.000
#> SRR1047852     1  0.0000    0.88898 1.000 0.000  0 0.000
#> SRR1047853     1  0.4331   -0.00914 0.712 0.000  0 0.288
#> SRR1047854     1  0.4331   -0.00914 0.712 0.000  0 0.288
#> SRR1047855     1  0.4331   -0.00914 0.712 0.000  0 0.288
#> SRR1047856     1  0.4331   -0.00914 0.712 0.000  0 0.288
#> SRR1047857     1  0.4331   -0.00914 0.712 0.000  0 0.288
#> SRR1047858     1  0.0469    0.88490 0.988 0.000  0 0.012
#> SRR1047859     1  0.0469    0.88490 0.988 0.000  0 0.012
#> SRR1047860     1  0.0469    0.88490 0.988 0.000  0 0.012
#> SRR1047861     1  0.0469    0.88490 0.988 0.000  0 0.012
#> SRR1047863     3  0.0000    1.00000 0.000 0.000  1 0.000
#> SRR1047864     3  0.0000    1.00000 0.000 0.000  1 0.000
#> SRR1047865     3  0.0000    1.00000 0.000 0.000  1 0.000
#> SRR1047866     3  0.0000    1.00000 0.000 0.000  1 0.000
#> SRR1047867     2  0.4985    0.68701 0.000 0.532  0 0.468
#> SRR1047868     3  0.0000    1.00000 0.000 0.000  1 0.000
#> SRR1047869     3  0.0000    1.00000 0.000 0.000  1 0.000
#> SRR1047870     3  0.0000    1.00000 0.000 0.000  1 0.000
#> SRR1047871     3  0.0000    1.00000 0.000 0.000  1 0.000
#> SRR1047872     3  0.0000    1.00000 0.000 0.000  1 0.000
#> SRR1047873     3  0.0000    1.00000 0.000 0.000  1 0.000
#> SRR1047874     3  0.0000    1.00000 0.000 0.000  1 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
#> SRR1047813     1  0.0000      0.994 1.000  0  0 0.000  0
#> SRR1047814     1  0.0000      0.994 1.000  0  0 0.000  0
#> SRR1047815     1  0.0000      0.994 1.000  0  0 0.000  0
#> SRR1047816     1  0.0000      0.994 1.000  0  0 0.000  0
#> SRR1047817     1  0.0000      0.994 1.000  0  0 0.000  0
#> SRR1047818     4  0.0000      0.896 0.000  0  0 1.000  0
#> SRR1047819     4  0.0000      0.896 0.000  0  0 1.000  0
#> SRR1047820     4  0.0000      0.896 0.000  0  0 1.000  0
#> SRR1047821     4  0.0000      0.896 0.000  0  0 1.000  0
#> SRR1047822     4  0.0000      0.896 0.000  0  0 1.000  0
#> SRR1047823     4  0.0000      0.896 0.000  0  0 1.000  0
#> SRR1047824     4  0.0000      0.896 0.000  0  0 1.000  0
#> SRR1047825     4  0.0000      0.896 0.000  0  0 1.000  0
#> SRR1047826     4  0.0000      0.896 0.000  0  0 1.000  0
#> SRR1047827     4  0.0000      0.896 0.000  0  0 1.000  0
#> SRR1047828     1  0.0000      0.994 1.000  0  0 0.000  0
#> SRR1047829     1  0.0000      0.994 1.000  0  0 0.000  0
#> SRR1047830     1  0.0000      0.994 1.000  0  0 0.000  0
#> SRR1047831     1  0.0000      0.994 1.000  0  0 0.000  0
#> SRR1047832     1  0.0000      0.994 1.000  0  0 0.000  0
#> SRR1047833     2  0.0000      1.000 0.000  1  0 0.000  0
#> SRR1047834     2  0.0000      1.000 0.000  1  0 0.000  0
#> SRR1047835     2  0.0000      1.000 0.000  1  0 0.000  0
#> SRR1047836     2  0.0000      1.000 0.000  1  0 0.000  0
#> SRR1047837     2  0.0000      1.000 0.000  1  0 0.000  0
#> SRR1047838     4  0.0404      0.895 0.012  0  0 0.988  0
#> SRR1047839     4  0.0404      0.895 0.012  0  0 0.988  0
#> SRR1047840     4  0.0404      0.895 0.012  0  0 0.988  0
#> SRR1047841     4  0.0404      0.895 0.012  0  0 0.988  0
#> SRR1047842     4  0.0404      0.895 0.012  0  0 0.988  0
#> SRR1047843     1  0.0404      0.990 0.988  0  0 0.012  0
#> SRR1047844     1  0.0404      0.990 0.988  0  0 0.012  0
#> SRR1047845     1  0.0404      0.990 0.988  0  0 0.012  0
#> SRR1047846     1  0.0404      0.990 0.988  0  0 0.012  0
#> SRR1047847     1  0.0404      0.990 0.988  0  0 0.012  0
#> SRR1047848     1  0.0000      0.994 1.000  0  0 0.000  0
#> SRR1047849     1  0.0000      0.994 1.000  0  0 0.000  0
#> SRR1047850     1  0.0000      0.994 1.000  0  0 0.000  0
#> SRR1047851     1  0.0000      0.994 1.000  0  0 0.000  0
#> SRR1047852     1  0.0000      0.994 1.000  0  0 0.000  0
#> SRR1047853     4  0.3480      0.684 0.248  0  0 0.752  0
#> SRR1047854     4  0.3480      0.684 0.248  0  0 0.752  0
#> SRR1047855     4  0.3480      0.684 0.248  0  0 0.752  0
#> SRR1047856     4  0.3480      0.684 0.248  0  0 0.752  0
#> SRR1047857     4  0.3480      0.684 0.248  0  0 0.752  0
#> SRR1047858     1  0.0404      0.990 0.988  0  0 0.012  0
#> SRR1047859     1  0.0404      0.990 0.988  0  0 0.012  0
#> SRR1047860     1  0.0404      0.990 0.988  0  0 0.012  0
#> SRR1047861     1  0.0404      0.990 0.988  0  0 0.012  0
#> SRR1047863     3  0.0000      1.000 0.000  0  1 0.000  0
#> SRR1047864     3  0.0000      1.000 0.000  0  1 0.000  0
#> SRR1047865     3  0.0000      1.000 0.000  0  1 0.000  0
#> SRR1047866     3  0.0000      1.000 0.000  0  1 0.000  0
#> SRR1047867     5  0.0000      0.000 0.000  0  0 0.000  1
#> SRR1047868     3  0.0000      1.000 0.000  0  1 0.000  0
#> SRR1047869     3  0.0000      1.000 0.000  0  1 0.000  0
#> SRR1047870     3  0.0000      1.000 0.000  0  1 0.000  0
#> SRR1047871     3  0.0000      1.000 0.000  0  1 0.000  0
#> SRR1047872     3  0.0000      1.000 0.000  0  1 0.000  0
#> SRR1047873     3  0.0000      1.000 0.000  0  1 0.000  0
#> SRR1047874     3  0.0000      1.000 0.000  0  1 0.000  0

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1 p2    p3    p4    p5 p6
#> SRR1047813     1  0.0547   9.82e-01 0.980  0 0.000 0.000 0.020  0
#> SRR1047814     1  0.0547   9.82e-01 0.980  0 0.000 0.000 0.020  0
#> SRR1047815     1  0.0547   9.82e-01 0.980  0 0.000 0.000 0.020  0
#> SRR1047816     1  0.0547   9.82e-01 0.980  0 0.000 0.000 0.020  0
#> SRR1047817     1  0.0547   9.82e-01 0.980  0 0.000 0.000 0.020  0
#> SRR1047818     4  0.0000   8.92e-01 0.000  0 0.000 1.000 0.000  0
#> SRR1047819     4  0.0000   8.92e-01 0.000  0 0.000 1.000 0.000  0
#> SRR1047820     4  0.0000   8.92e-01 0.000  0 0.000 1.000 0.000  0
#> SRR1047821     4  0.0000   8.92e-01 0.000  0 0.000 1.000 0.000  0
#> SRR1047822     4  0.0000   8.92e-01 0.000  0 0.000 1.000 0.000  0
#> SRR1047823     4  0.0000   8.92e-01 0.000  0 0.000 1.000 0.000  0
#> SRR1047824     4  0.0000   8.92e-01 0.000  0 0.000 1.000 0.000  0
#> SRR1047825     4  0.0000   8.92e-01 0.000  0 0.000 1.000 0.000  0
#> SRR1047826     4  0.0000   8.92e-01 0.000  0 0.000 1.000 0.000  0
#> SRR1047827     4  0.0000   8.92e-01 0.000  0 0.000 1.000 0.000  0
#> SRR1047828     1  0.0363   9.82e-01 0.988  0 0.000 0.000 0.012  0
#> SRR1047829     1  0.0363   9.82e-01 0.988  0 0.000 0.000 0.012  0
#> SRR1047830     1  0.0363   9.82e-01 0.988  0 0.000 0.000 0.012  0
#> SRR1047831     1  0.0363   9.82e-01 0.988  0 0.000 0.000 0.012  0
#> SRR1047832     1  0.0363   9.82e-01 0.988  0 0.000 0.000 0.012  0
#> SRR1047833     2  0.0000   1.00e+00 0.000  1 0.000 0.000 0.000  0
#> SRR1047834     2  0.0000   1.00e+00 0.000  1 0.000 0.000 0.000  0
#> SRR1047835     2  0.0000   1.00e+00 0.000  1 0.000 0.000 0.000  0
#> SRR1047836     2  0.0000   1.00e+00 0.000  1 0.000 0.000 0.000  0
#> SRR1047837     2  0.0000   1.00e+00 0.000  1 0.000 0.000 0.000  0
#> SRR1047838     4  0.0725   8.89e-01 0.012  0 0.000 0.976 0.012  0
#> SRR1047839     4  0.0725   8.89e-01 0.012  0 0.000 0.976 0.012  0
#> SRR1047840     4  0.0725   8.89e-01 0.012  0 0.000 0.976 0.012  0
#> SRR1047841     4  0.0725   8.89e-01 0.012  0 0.000 0.976 0.012  0
#> SRR1047842     4  0.0725   8.89e-01 0.012  0 0.000 0.976 0.012  0
#> SRR1047843     1  0.0458   9.80e-01 0.984  0 0.000 0.000 0.016  0
#> SRR1047844     1  0.0458   9.80e-01 0.984  0 0.000 0.000 0.016  0
#> SRR1047845     1  0.0458   9.80e-01 0.984  0 0.000 0.000 0.016  0
#> SRR1047846     1  0.0458   9.80e-01 0.984  0 0.000 0.000 0.016  0
#> SRR1047847     1  0.0458   9.80e-01 0.984  0 0.000 0.000 0.016  0
#> SRR1047848     1  0.0547   9.80e-01 0.980  0 0.000 0.000 0.020  0
#> SRR1047849     1  0.0547   9.80e-01 0.980  0 0.000 0.000 0.020  0
#> SRR1047850     1  0.0547   9.80e-01 0.980  0 0.000 0.000 0.020  0
#> SRR1047851     1  0.0547   9.80e-01 0.980  0 0.000 0.000 0.020  0
#> SRR1047852     1  0.0547   9.80e-01 0.980  0 0.000 0.000 0.020  0
#> SRR1047853     4  0.3534   6.82e-01 0.244  0 0.000 0.740 0.016  0
#> SRR1047854     4  0.3534   6.82e-01 0.244  0 0.000 0.740 0.016  0
#> SRR1047855     4  0.3534   6.82e-01 0.244  0 0.000 0.740 0.016  0
#> SRR1047856     4  0.3534   6.82e-01 0.244  0 0.000 0.740 0.016  0
#> SRR1047857     4  0.3534   6.82e-01 0.244  0 0.000 0.740 0.016  0
#> SRR1047858     1  0.0363   9.81e-01 0.988  0 0.000 0.000 0.012  0
#> SRR1047859     1  0.0363   9.81e-01 0.988  0 0.000 0.000 0.012  0
#> SRR1047860     1  0.0363   9.81e-01 0.988  0 0.000 0.000 0.012  0
#> SRR1047861     1  0.0363   9.81e-01 0.988  0 0.000 0.000 0.012  0
#> SRR1047863     3  0.0000   9.22e-01 0.000  0 1.000 0.000 0.000  0
#> SRR1047864     3  0.3862  -1.71e-08 0.000  0 0.524 0.000 0.476  0
#> SRR1047865     5  0.1075   1.00e+00 0.000  0 0.048 0.000 0.952  0
#> SRR1047866     5  0.1075   1.00e+00 0.000  0 0.048 0.000 0.952  0
#> SRR1047867     6  0.0000   0.00e+00 0.000  0 0.000 0.000 0.000  1
#> SRR1047868     3  0.0000   9.22e-01 0.000  0 1.000 0.000 0.000  0
#> SRR1047869     5  0.1075   1.00e+00 0.000  0 0.048 0.000 0.952  0
#> SRR1047870     3  0.0000   9.22e-01 0.000  0 1.000 0.000 0.000  0
#> SRR1047871     3  0.0000   9.22e-01 0.000  0 1.000 0.000 0.000  0
#> SRR1047872     3  0.0000   9.22e-01 0.000  0 1.000 0.000 0.000  0
#> SRR1047873     3  0.0000   9.22e-01 0.000  0 1.000 0.000 0.000  0
#> SRR1047874     3  0.0000   9.22e-01 0.000  0 1.000 0.000 0.000  0

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

consensus_heatmap(res, k = 2)

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

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

collect_plots(res)

plot of chunk CV-kmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.166           0.584       0.742         0.3499 0.820   0.820
#> 3 3 0.249           0.562       0.676         0.5773 0.588   0.497
#> 4 4 0.477           0.773       0.820         0.2160 0.795   0.548
#> 5 5 0.632           0.713       0.782         0.0975 1.000   1.000
#> 6 6 0.664           0.616       0.722         0.0601 0.844   0.534

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

suggest_best_k(res)
#> [1] 4

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette    p1    p2
#> SRR1047813     1  0.5737      0.615 0.864 0.136
#> SRR1047814     1  0.5737      0.615 0.864 0.136
#> SRR1047815     1  0.5737      0.615 0.864 0.136
#> SRR1047816     1  0.5737      0.615 0.864 0.136
#> SRR1047817     1  0.5737      0.615 0.864 0.136
#> SRR1047818     1  0.9087      0.474 0.676 0.324
#> SRR1047819     1  0.9087      0.474 0.676 0.324
#> SRR1047820     1  0.9087      0.474 0.676 0.324
#> SRR1047821     1  0.9087      0.474 0.676 0.324
#> SRR1047822     1  0.9087      0.474 0.676 0.324
#> SRR1047823     1  0.9580      0.422 0.620 0.380
#> SRR1047824     1  0.9580      0.422 0.620 0.380
#> SRR1047825     1  0.9580      0.422 0.620 0.380
#> SRR1047826     1  0.9580      0.422 0.620 0.380
#> SRR1047827     1  0.9580      0.422 0.620 0.380
#> SRR1047828     1  0.7139      0.630 0.804 0.196
#> SRR1047829     1  0.7139      0.630 0.804 0.196
#> SRR1047830     1  0.7139      0.630 0.804 0.196
#> SRR1047831     1  0.7139      0.630 0.804 0.196
#> SRR1047832     1  0.7139      0.630 0.804 0.196
#> SRR1047833     2  0.8016      0.904 0.244 0.756
#> SRR1047834     2  0.8016      0.904 0.244 0.756
#> SRR1047835     2  0.8016      0.904 0.244 0.756
#> SRR1047836     2  0.8016      0.904 0.244 0.756
#> SRR1047837     2  0.8016      0.904 0.244 0.756
#> SRR1047838     1  0.7299      0.632 0.796 0.204
#> SRR1047839     1  0.7299      0.632 0.796 0.204
#> SRR1047840     1  0.7299      0.632 0.796 0.204
#> SRR1047841     1  0.7299      0.632 0.796 0.204
#> SRR1047842     1  0.7299      0.632 0.796 0.204
#> SRR1047843     1  0.0376      0.678 0.996 0.004
#> SRR1047844     1  0.0376      0.678 0.996 0.004
#> SRR1047845     1  0.0376      0.678 0.996 0.004
#> SRR1047846     1  0.0376      0.678 0.996 0.004
#> SRR1047847     1  0.0376      0.678 0.996 0.004
#> SRR1047848     1  0.4431      0.642 0.908 0.092
#> SRR1047849     1  0.4431      0.642 0.908 0.092
#> SRR1047850     1  0.4431      0.642 0.908 0.092
#> SRR1047851     1  0.4431      0.642 0.908 0.092
#> SRR1047852     1  0.4431      0.642 0.908 0.092
#> SRR1047853     1  0.5842      0.663 0.860 0.140
#> SRR1047854     1  0.5842      0.663 0.860 0.140
#> SRR1047855     1  0.5842      0.663 0.860 0.140
#> SRR1047856     1  0.5842      0.663 0.860 0.140
#> SRR1047857     1  0.5842      0.663 0.860 0.140
#> SRR1047858     1  0.1184      0.677 0.984 0.016
#> SRR1047859     1  0.1184      0.677 0.984 0.016
#> SRR1047860     1  0.1184      0.677 0.984 0.016
#> SRR1047861     1  0.1184      0.677 0.984 0.016
#> SRR1047863     1  0.9922      0.351 0.552 0.448
#> SRR1047864     1  0.9933      0.346 0.548 0.452
#> SRR1047865     1  0.9323      0.383 0.652 0.348
#> SRR1047866     1  0.9323      0.383 0.652 0.348
#> SRR1047867     2  0.3114      0.608 0.056 0.944
#> SRR1047868     1  0.9922      0.351 0.552 0.448
#> SRR1047869     1  0.9323      0.383 0.652 0.348
#> SRR1047870     1  0.9922      0.351 0.552 0.448
#> SRR1047871     1  0.9922      0.351 0.552 0.448
#> SRR1047872     1  0.9850      0.373 0.572 0.428
#> SRR1047873     1  0.9850      0.373 0.572 0.428
#> SRR1047874     1  0.9833      0.375 0.576 0.424

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1047813     1   0.285     0.7617 0.924 0.056 0.020
#> SRR1047814     1   0.285     0.7617 0.924 0.056 0.020
#> SRR1047815     1   0.285     0.7617 0.924 0.056 0.020
#> SRR1047816     1   0.285     0.7617 0.924 0.056 0.020
#> SRR1047817     1   0.285     0.7617 0.924 0.056 0.020
#> SRR1047818     3   0.973     0.4912 0.292 0.260 0.448
#> SRR1047819     3   0.973     0.4912 0.292 0.260 0.448
#> SRR1047820     3   0.973     0.4912 0.292 0.260 0.448
#> SRR1047821     3   0.973     0.4912 0.292 0.260 0.448
#> SRR1047822     3   0.973     0.4912 0.292 0.260 0.448
#> SRR1047823     3   0.987     0.4611 0.324 0.268 0.408
#> SRR1047824     3   0.987     0.4611 0.324 0.268 0.408
#> SRR1047825     3   0.987     0.4611 0.324 0.268 0.408
#> SRR1047826     3   0.987     0.4611 0.324 0.268 0.408
#> SRR1047827     3   0.987     0.4611 0.324 0.268 0.408
#> SRR1047828     1   0.641     0.6844 0.764 0.144 0.092
#> SRR1047829     1   0.641     0.6844 0.764 0.144 0.092
#> SRR1047830     1   0.641     0.6844 0.764 0.144 0.092
#> SRR1047831     1   0.641     0.6844 0.764 0.144 0.092
#> SRR1047832     1   0.641     0.6844 0.764 0.144 0.092
#> SRR1047833     2   0.456     0.9127 0.064 0.860 0.076
#> SRR1047834     2   0.456     0.9127 0.064 0.860 0.076
#> SRR1047835     2   0.456     0.9127 0.064 0.860 0.076
#> SRR1047836     2   0.456     0.9127 0.064 0.860 0.076
#> SRR1047837     2   0.456     0.9127 0.064 0.860 0.076
#> SRR1047838     3   0.955     0.4337 0.352 0.200 0.448
#> SRR1047839     3   0.955     0.4337 0.352 0.200 0.448
#> SRR1047840     3   0.955     0.4337 0.352 0.200 0.448
#> SRR1047841     3   0.955     0.4337 0.352 0.200 0.448
#> SRR1047842     3   0.955     0.4337 0.352 0.200 0.448
#> SRR1047843     1   0.271     0.7632 0.912 0.000 0.088
#> SRR1047844     1   0.271     0.7632 0.912 0.000 0.088
#> SRR1047845     1   0.271     0.7632 0.912 0.000 0.088
#> SRR1047846     1   0.271     0.7632 0.912 0.000 0.088
#> SRR1047847     1   0.271     0.7632 0.912 0.000 0.088
#> SRR1047848     1   0.148     0.7805 0.968 0.012 0.020
#> SRR1047849     1   0.148     0.7805 0.968 0.012 0.020
#> SRR1047850     1   0.148     0.7805 0.968 0.012 0.020
#> SRR1047851     1   0.148     0.7805 0.968 0.012 0.020
#> SRR1047852     1   0.148     0.7805 0.968 0.012 0.020
#> SRR1047853     1   0.856     0.0452 0.528 0.104 0.368
#> SRR1047854     1   0.856     0.0452 0.528 0.104 0.368
#> SRR1047855     1   0.856     0.0452 0.528 0.104 0.368
#> SRR1047856     1   0.856     0.0452 0.528 0.104 0.368
#> SRR1047857     1   0.856     0.0452 0.528 0.104 0.368
#> SRR1047858     1   0.116     0.7815 0.972 0.000 0.028
#> SRR1047859     1   0.116     0.7815 0.972 0.000 0.028
#> SRR1047860     1   0.116     0.7815 0.972 0.000 0.028
#> SRR1047861     1   0.116     0.7815 0.972 0.000 0.028
#> SRR1047863     3   0.434     0.3654 0.136 0.016 0.848
#> SRR1047864     3   0.434     0.3654 0.136 0.016 0.848
#> SRR1047865     3   0.531     0.3275 0.192 0.020 0.788
#> SRR1047866     3   0.544     0.3200 0.192 0.024 0.784
#> SRR1047867     2   0.704     0.5413 0.020 0.536 0.444
#> SRR1047868     3   0.434     0.3654 0.136 0.016 0.848
#> SRR1047869     3   0.501     0.3280 0.204 0.008 0.788
#> SRR1047870     3   0.434     0.3654 0.136 0.016 0.848
#> SRR1047871     3   0.434     0.3654 0.136 0.016 0.848
#> SRR1047872     3   0.398     0.3788 0.144 0.004 0.852
#> SRR1047873     3   0.398     0.3788 0.144 0.004 0.852
#> SRR1047874     3   0.398     0.3788 0.144 0.004 0.852

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1047813     1   0.456     0.7728 0.820 0.084 0.084 0.012
#> SRR1047814     1   0.456     0.7728 0.820 0.084 0.084 0.012
#> SRR1047815     1   0.456     0.7728 0.820 0.084 0.084 0.012
#> SRR1047816     1   0.456     0.7728 0.820 0.084 0.084 0.012
#> SRR1047817     1   0.456     0.7728 0.820 0.084 0.084 0.012
#> SRR1047818     4   0.255     0.7755 0.056 0.004 0.024 0.916
#> SRR1047819     4   0.255     0.7755 0.056 0.004 0.024 0.916
#> SRR1047820     4   0.255     0.7755 0.056 0.004 0.024 0.916
#> SRR1047821     4   0.255     0.7755 0.056 0.004 0.024 0.916
#> SRR1047822     4   0.255     0.7755 0.056 0.004 0.024 0.916
#> SRR1047823     4   0.251     0.7417 0.052 0.020 0.008 0.920
#> SRR1047824     4   0.251     0.7417 0.052 0.020 0.008 0.920
#> SRR1047825     4   0.251     0.7417 0.052 0.020 0.008 0.920
#> SRR1047826     4   0.251     0.7417 0.052 0.020 0.008 0.920
#> SRR1047827     4   0.251     0.7417 0.052 0.020 0.008 0.920
#> SRR1047828     1   0.700     0.7043 0.668 0.064 0.092 0.176
#> SRR1047829     1   0.700     0.7043 0.668 0.064 0.092 0.176
#> SRR1047830     1   0.700     0.7043 0.668 0.064 0.092 0.176
#> SRR1047831     1   0.700     0.7043 0.668 0.064 0.092 0.176
#> SRR1047832     1   0.700     0.7043 0.668 0.064 0.092 0.176
#> SRR1047833     2   0.356     1.0000 0.016 0.864 0.016 0.104
#> SRR1047834     2   0.356     1.0000 0.016 0.864 0.016 0.104
#> SRR1047835     2   0.356     1.0000 0.016 0.864 0.016 0.104
#> SRR1047836     2   0.356     1.0000 0.016 0.864 0.016 0.104
#> SRR1047837     2   0.356     1.0000 0.016 0.864 0.016 0.104
#> SRR1047838     4   0.451     0.7699 0.176 0.004 0.032 0.788
#> SRR1047839     4   0.451     0.7699 0.176 0.004 0.032 0.788
#> SRR1047840     4   0.451     0.7699 0.176 0.004 0.032 0.788
#> SRR1047841     4   0.451     0.7699 0.176 0.004 0.032 0.788
#> SRR1047842     4   0.451     0.7699 0.176 0.004 0.032 0.788
#> SRR1047843     1   0.444     0.7728 0.808 0.004 0.048 0.140
#> SRR1047844     1   0.444     0.7728 0.808 0.004 0.048 0.140
#> SRR1047845     1   0.444     0.7728 0.808 0.004 0.048 0.140
#> SRR1047846     1   0.444     0.7728 0.808 0.004 0.048 0.140
#> SRR1047847     1   0.444     0.7728 0.808 0.004 0.048 0.140
#> SRR1047848     1   0.274     0.8123 0.908 0.020 0.008 0.064
#> SRR1047849     1   0.274     0.8123 0.908 0.020 0.008 0.064
#> SRR1047850     1   0.274     0.8123 0.908 0.020 0.008 0.064
#> SRR1047851     1   0.274     0.8123 0.908 0.020 0.008 0.064
#> SRR1047852     1   0.274     0.8123 0.908 0.020 0.008 0.064
#> SRR1047853     4   0.668     0.3941 0.404 0.004 0.076 0.516
#> SRR1047854     4   0.668     0.3941 0.404 0.004 0.076 0.516
#> SRR1047855     4   0.668     0.3941 0.404 0.004 0.076 0.516
#> SRR1047856     4   0.668     0.3941 0.404 0.004 0.076 0.516
#> SRR1047857     4   0.668     0.3941 0.404 0.004 0.076 0.516
#> SRR1047858     1   0.236     0.8193 0.920 0.012 0.004 0.064
#> SRR1047859     1   0.236     0.8193 0.920 0.012 0.004 0.064
#> SRR1047860     1   0.236     0.8193 0.920 0.012 0.004 0.064
#> SRR1047861     1   0.236     0.8193 0.920 0.012 0.004 0.064
#> SRR1047863     3   0.256     0.9268 0.020 0.000 0.908 0.072
#> SRR1047864     3   0.278     0.9235 0.016 0.008 0.904 0.072
#> SRR1047865     3   0.326     0.8965 0.056 0.008 0.888 0.048
#> SRR1047866     3   0.317     0.8947 0.052 0.008 0.892 0.048
#> SRR1047867     3   0.585     0.0564 0.000 0.456 0.512 0.032
#> SRR1047868     3   0.249     0.9270 0.020 0.000 0.912 0.068
#> SRR1047869     3   0.347     0.8974 0.056 0.012 0.880 0.052
#> SRR1047870     3   0.289     0.9251 0.020 0.008 0.900 0.072
#> SRR1047871     3   0.249     0.9270 0.020 0.000 0.912 0.068
#> SRR1047872     3   0.271     0.9243 0.016 0.004 0.904 0.076
#> SRR1047873     3   0.271     0.9243 0.016 0.004 0.904 0.076
#> SRR1047874     3   0.271     0.9243 0.016 0.004 0.904 0.076

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4 p5
#> SRR1047813     1  0.4600    0.65441 0.632 0.008 0.004 0.004 NA
#> SRR1047814     1  0.4600    0.65441 0.632 0.008 0.004 0.004 NA
#> SRR1047815     1  0.4600    0.65441 0.632 0.008 0.004 0.004 NA
#> SRR1047816     1  0.4600    0.65441 0.632 0.008 0.004 0.004 NA
#> SRR1047817     1  0.4600    0.65441 0.632 0.008 0.004 0.004 NA
#> SRR1047818     4  0.2607    0.73322 0.024 0.004 0.032 0.908 NA
#> SRR1047819     4  0.2607    0.73322 0.024 0.004 0.032 0.908 NA
#> SRR1047820     4  0.2607    0.73322 0.024 0.004 0.032 0.908 NA
#> SRR1047821     4  0.2607    0.73322 0.024 0.004 0.032 0.908 NA
#> SRR1047822     4  0.2607    0.73322 0.024 0.004 0.032 0.908 NA
#> SRR1047823     4  0.3512    0.67003 0.024 0.004 0.004 0.828 NA
#> SRR1047824     4  0.3512    0.67003 0.024 0.004 0.004 0.828 NA
#> SRR1047825     4  0.3512    0.67003 0.024 0.004 0.004 0.828 NA
#> SRR1047826     4  0.3512    0.67003 0.024 0.004 0.004 0.828 NA
#> SRR1047827     4  0.3512    0.67003 0.024 0.004 0.004 0.828 NA
#> SRR1047828     1  0.6958    0.61657 0.540 0.044 0.020 0.084 NA
#> SRR1047829     1  0.6958    0.61657 0.540 0.044 0.020 0.084 NA
#> SRR1047830     1  0.6958    0.61657 0.540 0.044 0.020 0.084 NA
#> SRR1047831     1  0.6958    0.61657 0.540 0.044 0.020 0.084 NA
#> SRR1047832     1  0.6958    0.61657 0.540 0.044 0.020 0.084 NA
#> SRR1047833     2  0.0703    0.99760 0.000 0.976 0.000 0.024 NA
#> SRR1047834     2  0.0609    0.99940 0.000 0.980 0.000 0.020 NA
#> SRR1047835     2  0.0609    0.99940 0.000 0.980 0.000 0.020 NA
#> SRR1047836     2  0.0609    0.99940 0.000 0.980 0.000 0.020 NA
#> SRR1047837     2  0.0609    0.99940 0.000 0.980 0.000 0.020 NA
#> SRR1047838     4  0.4769    0.72690 0.124 0.000 0.032 0.768 NA
#> SRR1047839     4  0.4769    0.72690 0.124 0.000 0.032 0.768 NA
#> SRR1047840     4  0.4769    0.72690 0.124 0.000 0.032 0.768 NA
#> SRR1047841     4  0.4769    0.72690 0.124 0.000 0.032 0.768 NA
#> SRR1047842     4  0.4769    0.72690 0.124 0.000 0.032 0.768 NA
#> SRR1047843     1  0.4711    0.63787 0.772 0.000 0.032 0.124 NA
#> SRR1047844     1  0.4711    0.63787 0.772 0.000 0.032 0.124 NA
#> SRR1047845     1  0.4711    0.63787 0.772 0.000 0.032 0.124 NA
#> SRR1047846     1  0.4711    0.63787 0.772 0.000 0.032 0.124 NA
#> SRR1047847     1  0.4711    0.63787 0.772 0.000 0.032 0.124 NA
#> SRR1047848     1  0.3814    0.69380 0.832 0.012 0.008 0.040 NA
#> SRR1047849     1  0.3814    0.69380 0.832 0.012 0.008 0.040 NA
#> SRR1047850     1  0.3814    0.69380 0.832 0.012 0.008 0.040 NA
#> SRR1047851     1  0.3814    0.69380 0.832 0.012 0.008 0.040 NA
#> SRR1047852     1  0.3814    0.69380 0.832 0.012 0.008 0.040 NA
#> SRR1047853     4  0.7107    0.38232 0.364 0.000 0.060 0.460 NA
#> SRR1047854     4  0.7107    0.38232 0.364 0.000 0.060 0.460 NA
#> SRR1047855     4  0.7107    0.38232 0.364 0.000 0.060 0.460 NA
#> SRR1047856     4  0.7107    0.38232 0.364 0.000 0.060 0.460 NA
#> SRR1047857     4  0.7107    0.38232 0.364 0.000 0.060 0.460 NA
#> SRR1047858     1  0.2838    0.69843 0.884 0.000 0.008 0.072 NA
#> SRR1047859     1  0.2838    0.69843 0.884 0.000 0.008 0.072 NA
#> SRR1047860     1  0.2838    0.69843 0.884 0.000 0.008 0.072 NA
#> SRR1047861     1  0.2838    0.69843 0.884 0.000 0.008 0.072 NA
#> SRR1047863     3  0.0727    0.92349 0.004 0.000 0.980 0.004 NA
#> SRR1047864     3  0.2330    0.88607 0.004 0.004 0.900 0.004 NA
#> SRR1047865     3  0.1369    0.92027 0.008 0.000 0.956 0.008 NA
#> SRR1047866     3  0.1186    0.92090 0.008 0.000 0.964 0.008 NA
#> SRR1047867     3  0.6495    0.00655 0.000 0.388 0.424 0.000 NA
#> SRR1047868     3  0.0486    0.92454 0.004 0.000 0.988 0.004 NA
#> SRR1047869     3  0.1369    0.92027 0.008 0.000 0.956 0.008 NA
#> SRR1047870     3  0.1604    0.91039 0.004 0.004 0.944 0.004 NA
#> SRR1047871     3  0.0486    0.92454 0.004 0.000 0.988 0.004 NA
#> SRR1047872     3  0.1314    0.92173 0.004 0.004 0.960 0.008 NA
#> SRR1047873     3  0.1314    0.92173 0.004 0.004 0.960 0.008 NA
#> SRR1047874     3  0.1314    0.92173 0.004 0.004 0.960 0.008 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
#> SRR1047813     5  0.3489     0.6986 0.288 0.000 0.000 0.004 0.708 NA
#> SRR1047814     5  0.3489     0.6986 0.288 0.000 0.000 0.004 0.708 NA
#> SRR1047815     5  0.3489     0.6986 0.288 0.000 0.000 0.004 0.708 NA
#> SRR1047816     5  0.3489     0.6986 0.288 0.000 0.000 0.004 0.708 NA
#> SRR1047817     5  0.3489     0.6986 0.288 0.000 0.000 0.004 0.708 NA
#> SRR1047818     4  0.2201     0.7579 0.016 0.000 0.008 0.916 0.036 NA
#> SRR1047819     4  0.2201     0.7579 0.016 0.000 0.008 0.916 0.036 NA
#> SRR1047820     4  0.2201     0.7579 0.016 0.000 0.008 0.916 0.036 NA
#> SRR1047821     4  0.2201     0.7579 0.016 0.000 0.008 0.916 0.036 NA
#> SRR1047822     4  0.2201     0.7579 0.016 0.000 0.008 0.916 0.036 NA
#> SRR1047823     4  0.3740     0.7164 0.012 0.000 0.000 0.728 0.008 NA
#> SRR1047824     4  0.3740     0.7164 0.012 0.000 0.000 0.728 0.008 NA
#> SRR1047825     4  0.3740     0.7164 0.012 0.000 0.000 0.728 0.008 NA
#> SRR1047826     4  0.3740     0.7164 0.012 0.000 0.000 0.728 0.008 NA
#> SRR1047827     4  0.3740     0.7164 0.012 0.000 0.000 0.728 0.008 NA
#> SRR1047828     5  0.7412     0.6863 0.348 0.020 0.024 0.072 0.428 NA
#> SRR1047829     5  0.7412     0.6863 0.348 0.020 0.024 0.072 0.428 NA
#> SRR1047830     5  0.7412     0.6863 0.348 0.020 0.024 0.072 0.428 NA
#> SRR1047831     5  0.7412     0.6863 0.348 0.020 0.024 0.072 0.428 NA
#> SRR1047832     5  0.7412     0.6863 0.348 0.020 0.024 0.072 0.428 NA
#> SRR1047833     2  0.0622     0.9957 0.000 0.980 0.000 0.012 0.008 NA
#> SRR1047834     2  0.0363     0.9983 0.000 0.988 0.000 0.012 0.000 NA
#> SRR1047835     2  0.0458     0.9974 0.000 0.984 0.000 0.016 0.000 NA
#> SRR1047836     2  0.0363     0.9983 0.000 0.988 0.000 0.012 0.000 NA
#> SRR1047837     2  0.0363     0.9983 0.000 0.988 0.000 0.012 0.000 NA
#> SRR1047838     4  0.5191     0.6313 0.188 0.000 0.008 0.692 0.052 NA
#> SRR1047839     4  0.5191     0.6313 0.188 0.000 0.008 0.692 0.052 NA
#> SRR1047840     4  0.5191     0.6313 0.188 0.000 0.008 0.692 0.052 NA
#> SRR1047841     4  0.5191     0.6313 0.188 0.000 0.008 0.692 0.052 NA
#> SRR1047842     4  0.5191     0.6313 0.188 0.000 0.008 0.692 0.052 NA
#> SRR1047843     1  0.3149     0.3924 0.856 0.000 0.008 0.080 0.044 NA
#> SRR1047844     1  0.3149     0.3924 0.856 0.000 0.008 0.080 0.044 NA
#> SRR1047845     1  0.3149     0.3924 0.856 0.000 0.008 0.080 0.044 NA
#> SRR1047846     1  0.3149     0.3924 0.856 0.000 0.008 0.080 0.044 NA
#> SRR1047847     1  0.3149     0.3924 0.856 0.000 0.008 0.080 0.044 NA
#> SRR1047848     1  0.6000     0.2820 0.552 0.000 0.000 0.024 0.208 NA
#> SRR1047849     1  0.6000     0.2820 0.552 0.000 0.000 0.024 0.208 NA
#> SRR1047850     1  0.6000     0.2820 0.552 0.000 0.000 0.024 0.208 NA
#> SRR1047851     1  0.6000     0.2820 0.552 0.000 0.000 0.024 0.208 NA
#> SRR1047852     1  0.6000     0.2820 0.552 0.000 0.000 0.024 0.208 NA
#> SRR1047853     1  0.6668     0.0632 0.416 0.000 0.020 0.412 0.096 NA
#> SRR1047854     1  0.6668     0.0632 0.416 0.000 0.020 0.412 0.096 NA
#> SRR1047855     1  0.6668     0.0632 0.416 0.000 0.020 0.412 0.096 NA
#> SRR1047856     1  0.6668     0.0632 0.416 0.000 0.020 0.412 0.096 NA
#> SRR1047857     1  0.6668     0.0632 0.416 0.000 0.020 0.412 0.096 NA
#> SRR1047858     1  0.3543     0.3895 0.812 0.000 0.000 0.012 0.124 NA
#> SRR1047859     1  0.3543     0.3895 0.812 0.000 0.000 0.012 0.124 NA
#> SRR1047860     1  0.3543     0.3895 0.812 0.000 0.000 0.012 0.124 NA
#> SRR1047861     1  0.3543     0.3895 0.812 0.000 0.000 0.012 0.124 NA
#> SRR1047863     3  0.0603     0.9005 0.000 0.000 0.980 0.000 0.004 NA
#> SRR1047864     3  0.2664     0.8418 0.000 0.000 0.848 0.000 0.016 NA
#> SRR1047865     3  0.2074     0.8866 0.004 0.000 0.912 0.000 0.048 NA
#> SRR1047866     3  0.1863     0.8872 0.000 0.000 0.920 0.000 0.044 NA
#> SRR1047867     3  0.6684     0.0831 0.000 0.292 0.380 0.000 0.032 NA
#> SRR1047868     3  0.0291     0.9017 0.000 0.000 0.992 0.000 0.004 NA
#> SRR1047869     3  0.2138     0.8861 0.004 0.000 0.908 0.000 0.052 NA
#> SRR1047870     3  0.1643     0.8826 0.000 0.000 0.924 0.000 0.008 NA
#> SRR1047871     3  0.0291     0.9017 0.000 0.000 0.992 0.000 0.004 NA
#> SRR1047872     3  0.1519     0.8978 0.004 0.008 0.948 0.004 0.028 NA
#> SRR1047873     3  0.1519     0.8978 0.004 0.008 0.948 0.004 0.028 NA
#> SRR1047874     3  0.1519     0.8978 0.004 0.008 0.948 0.004 0.028 NA

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-kmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-kmeans-collect-classes

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 17931 rows and 61 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 0.492           0.904       0.918         0.4757 0.531   0.531
#> 3 3 0.754           0.860       0.929         0.4140 0.694   0.475
#> 4 4 0.959           0.967       0.978         0.1059 0.896   0.698
#> 5 5 0.825           0.874       0.881         0.0619 0.959   0.841
#> 6 6 0.842           0.813       0.868         0.0422 0.932   0.703

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

suggest_best_k(res)
#> [1] 4

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette    p1    p2
#> SRR1047813     1   0.184      0.898 0.972 0.028
#> SRR1047814     1   0.184      0.898 0.972 0.028
#> SRR1047815     1   0.184      0.898 0.972 0.028
#> SRR1047816     1   0.184      0.898 0.972 0.028
#> SRR1047817     1   0.184      0.898 0.972 0.028
#> SRR1047818     1   0.634      0.901 0.840 0.160
#> SRR1047819     1   0.634      0.901 0.840 0.160
#> SRR1047820     1   0.634      0.901 0.840 0.160
#> SRR1047821     1   0.634      0.901 0.840 0.160
#> SRR1047822     1   0.634      0.901 0.840 0.160
#> SRR1047823     1   0.295      0.903 0.948 0.052
#> SRR1047824     1   0.295      0.903 0.948 0.052
#> SRR1047825     1   0.295      0.903 0.948 0.052
#> SRR1047826     1   0.295      0.903 0.948 0.052
#> SRR1047827     1   0.295      0.903 0.948 0.052
#> SRR1047828     2   0.634      0.885 0.160 0.840
#> SRR1047829     2   0.634      0.885 0.160 0.840
#> SRR1047830     2   0.634      0.885 0.160 0.840
#> SRR1047831     2   0.634      0.885 0.160 0.840
#> SRR1047832     2   0.634      0.885 0.160 0.840
#> SRR1047833     2   0.506      0.902 0.112 0.888
#> SRR1047834     2   0.506      0.902 0.112 0.888
#> SRR1047835     2   0.506      0.902 0.112 0.888
#> SRR1047836     2   0.506      0.902 0.112 0.888
#> SRR1047837     2   0.506      0.902 0.112 0.888
#> SRR1047838     1   0.605      0.908 0.852 0.148
#> SRR1047839     1   0.605      0.908 0.852 0.148
#> SRR1047840     1   0.605      0.908 0.852 0.148
#> SRR1047841     1   0.605      0.908 0.852 0.148
#> SRR1047842     1   0.605      0.908 0.852 0.148
#> SRR1047843     1   0.506      0.908 0.888 0.112
#> SRR1047844     1   0.506      0.908 0.888 0.112
#> SRR1047845     1   0.506      0.908 0.888 0.112
#> SRR1047846     1   0.506      0.908 0.888 0.112
#> SRR1047847     1   0.506      0.908 0.888 0.112
#> SRR1047848     1   0.141      0.900 0.980 0.020
#> SRR1047849     1   0.141      0.900 0.980 0.020
#> SRR1047850     1   0.141      0.900 0.980 0.020
#> SRR1047851     1   0.141      0.900 0.980 0.020
#> SRR1047852     1   0.141      0.900 0.980 0.020
#> SRR1047853     1   0.605      0.908 0.852 0.148
#> SRR1047854     1   0.605      0.908 0.852 0.148
#> SRR1047855     1   0.605      0.908 0.852 0.148
#> SRR1047856     1   0.605      0.908 0.852 0.148
#> SRR1047857     1   0.605      0.908 0.852 0.148
#> SRR1047858     1   0.000      0.907 1.000 0.000
#> SRR1047859     1   0.000      0.907 1.000 0.000
#> SRR1047860     1   0.000      0.907 1.000 0.000
#> SRR1047861     1   0.000      0.907 1.000 0.000
#> SRR1047863     2   0.141      0.913 0.020 0.980
#> SRR1047864     2   0.141      0.913 0.020 0.980
#> SRR1047865     2   0.295      0.910 0.052 0.948
#> SRR1047866     2   0.295      0.910 0.052 0.948
#> SRR1047867     2   0.000      0.914 0.000 1.000
#> SRR1047868     2   0.141      0.913 0.020 0.980
#> SRR1047869     2   0.295      0.910 0.052 0.948
#> SRR1047870     2   0.141      0.913 0.020 0.980
#> SRR1047871     2   0.141      0.913 0.020 0.980
#> SRR1047872     2   0.141      0.913 0.020 0.980
#> SRR1047873     2   0.141      0.913 0.020 0.980
#> SRR1047874     2   0.141      0.913 0.020 0.980

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1047813     1  0.0237      0.883 0.996 0.000 0.004
#> SRR1047814     1  0.0237      0.883 0.996 0.000 0.004
#> SRR1047815     1  0.0237      0.883 0.996 0.000 0.004
#> SRR1047816     1  0.0237      0.883 0.996 0.000 0.004
#> SRR1047817     1  0.0237      0.883 0.996 0.000 0.004
#> SRR1047818     2  0.0000      0.954 0.000 1.000 0.000
#> SRR1047819     2  0.0000      0.954 0.000 1.000 0.000
#> SRR1047820     2  0.0000      0.954 0.000 1.000 0.000
#> SRR1047821     2  0.0000      0.954 0.000 1.000 0.000
#> SRR1047822     2  0.0000      0.954 0.000 1.000 0.000
#> SRR1047823     2  0.0000      0.954 0.000 1.000 0.000
#> SRR1047824     2  0.0000      0.954 0.000 1.000 0.000
#> SRR1047825     2  0.0000      0.954 0.000 1.000 0.000
#> SRR1047826     2  0.0000      0.954 0.000 1.000 0.000
#> SRR1047827     2  0.0000      0.954 0.000 1.000 0.000
#> SRR1047828     1  0.6410      0.351 0.576 0.004 0.420
#> SRR1047829     1  0.6410      0.351 0.576 0.004 0.420
#> SRR1047830     1  0.6410      0.351 0.576 0.004 0.420
#> SRR1047831     1  0.6410      0.351 0.576 0.004 0.420
#> SRR1047832     1  0.6410      0.351 0.576 0.004 0.420
#> SRR1047833     3  0.5467      0.827 0.032 0.176 0.792
#> SRR1047834     3  0.5467      0.827 0.032 0.176 0.792
#> SRR1047835     3  0.5467      0.827 0.032 0.176 0.792
#> SRR1047836     3  0.5467      0.827 0.032 0.176 0.792
#> SRR1047837     3  0.5467      0.827 0.032 0.176 0.792
#> SRR1047838     2  0.0237      0.953 0.004 0.996 0.000
#> SRR1047839     2  0.0237      0.953 0.004 0.996 0.000
#> SRR1047840     2  0.0237      0.953 0.004 0.996 0.000
#> SRR1047841     2  0.0237      0.953 0.004 0.996 0.000
#> SRR1047842     2  0.0237      0.953 0.004 0.996 0.000
#> SRR1047843     1  0.1453      0.879 0.968 0.008 0.024
#> SRR1047844     1  0.1453      0.879 0.968 0.008 0.024
#> SRR1047845     1  0.1453      0.879 0.968 0.008 0.024
#> SRR1047846     1  0.1453      0.879 0.968 0.008 0.024
#> SRR1047847     1  0.1453      0.879 0.968 0.008 0.024
#> SRR1047848     1  0.0592      0.887 0.988 0.012 0.000
#> SRR1047849     1  0.0592      0.887 0.988 0.012 0.000
#> SRR1047850     1  0.0592      0.887 0.988 0.012 0.000
#> SRR1047851     1  0.0592      0.887 0.988 0.012 0.000
#> SRR1047852     1  0.0592      0.887 0.988 0.012 0.000
#> SRR1047853     2  0.4390      0.854 0.012 0.840 0.148
#> SRR1047854     2  0.4390      0.854 0.012 0.840 0.148
#> SRR1047855     2  0.4390      0.854 0.012 0.840 0.148
#> SRR1047856     2  0.4390      0.854 0.012 0.840 0.148
#> SRR1047857     2  0.4390      0.854 0.012 0.840 0.148
#> SRR1047858     1  0.0592      0.887 0.988 0.012 0.000
#> SRR1047859     1  0.0592      0.887 0.988 0.012 0.000
#> SRR1047860     1  0.0592      0.887 0.988 0.012 0.000
#> SRR1047861     1  0.0592      0.887 0.988 0.012 0.000
#> SRR1047863     3  0.0237      0.932 0.004 0.000 0.996
#> SRR1047864     3  0.0237      0.932 0.004 0.000 0.996
#> SRR1047865     3  0.0237      0.932 0.004 0.000 0.996
#> SRR1047866     3  0.0237      0.932 0.004 0.000 0.996
#> SRR1047867     3  0.0237      0.928 0.004 0.000 0.996
#> SRR1047868     3  0.0237      0.932 0.004 0.000 0.996
#> SRR1047869     3  0.0237      0.932 0.004 0.000 0.996
#> SRR1047870     3  0.0237      0.932 0.004 0.000 0.996
#> SRR1047871     3  0.0237      0.932 0.004 0.000 0.996
#> SRR1047872     3  0.0237      0.932 0.004 0.000 0.996
#> SRR1047873     3  0.0237      0.932 0.004 0.000 0.996
#> SRR1047874     3  0.0237      0.932 0.004 0.000 0.996

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1047813     1  0.1792      0.945 0.932 0.068 0.000 0.000
#> SRR1047814     1  0.1792      0.945 0.932 0.068 0.000 0.000
#> SRR1047815     1  0.1792      0.945 0.932 0.068 0.000 0.000
#> SRR1047816     1  0.1792      0.945 0.932 0.068 0.000 0.000
#> SRR1047817     1  0.1792      0.945 0.932 0.068 0.000 0.000
#> SRR1047818     4  0.0188      0.963 0.000 0.004 0.000 0.996
#> SRR1047819     4  0.0188      0.963 0.000 0.004 0.000 0.996
#> SRR1047820     4  0.0188      0.963 0.000 0.004 0.000 0.996
#> SRR1047821     4  0.0188      0.963 0.000 0.004 0.000 0.996
#> SRR1047822     4  0.0188      0.963 0.000 0.004 0.000 0.996
#> SRR1047823     4  0.0188      0.963 0.000 0.004 0.000 0.996
#> SRR1047824     4  0.0188      0.963 0.000 0.004 0.000 0.996
#> SRR1047825     4  0.0188      0.963 0.000 0.004 0.000 0.996
#> SRR1047826     4  0.0188      0.963 0.000 0.004 0.000 0.996
#> SRR1047827     4  0.0188      0.963 0.000 0.004 0.000 0.996
#> SRR1047828     2  0.0707      0.978 0.020 0.980 0.000 0.000
#> SRR1047829     2  0.0707      0.978 0.020 0.980 0.000 0.000
#> SRR1047830     2  0.0707      0.978 0.020 0.980 0.000 0.000
#> SRR1047831     2  0.0707      0.978 0.020 0.980 0.000 0.000
#> SRR1047832     2  0.0707      0.978 0.020 0.980 0.000 0.000
#> SRR1047833     2  0.0188      0.979 0.000 0.996 0.000 0.004
#> SRR1047834     2  0.0188      0.979 0.000 0.996 0.000 0.004
#> SRR1047835     2  0.0188      0.979 0.000 0.996 0.000 0.004
#> SRR1047836     2  0.0188      0.979 0.000 0.996 0.000 0.004
#> SRR1047837     2  0.0188      0.979 0.000 0.996 0.000 0.004
#> SRR1047838     4  0.0000      0.963 0.000 0.000 0.000 1.000
#> SRR1047839     4  0.0000      0.963 0.000 0.000 0.000 1.000
#> SRR1047840     4  0.0000      0.963 0.000 0.000 0.000 1.000
#> SRR1047841     4  0.0000      0.963 0.000 0.000 0.000 1.000
#> SRR1047842     4  0.0000      0.963 0.000 0.000 0.000 1.000
#> SRR1047843     1  0.0188      0.978 0.996 0.000 0.000 0.004
#> SRR1047844     1  0.0188      0.978 0.996 0.000 0.000 0.004
#> SRR1047845     1  0.0188      0.978 0.996 0.000 0.000 0.004
#> SRR1047846     1  0.0188      0.978 0.996 0.000 0.000 0.004
#> SRR1047847     1  0.0188      0.978 0.996 0.000 0.000 0.004
#> SRR1047848     1  0.0188      0.979 0.996 0.004 0.000 0.000
#> SRR1047849     1  0.0188      0.979 0.996 0.004 0.000 0.000
#> SRR1047850     1  0.0188      0.979 0.996 0.004 0.000 0.000
#> SRR1047851     1  0.0188      0.979 0.996 0.004 0.000 0.000
#> SRR1047852     1  0.0188      0.979 0.996 0.004 0.000 0.000
#> SRR1047853     4  0.3670      0.884 0.044 0.004 0.092 0.860
#> SRR1047854     4  0.3670      0.884 0.044 0.004 0.092 0.860
#> SRR1047855     4  0.3670      0.884 0.044 0.004 0.092 0.860
#> SRR1047856     4  0.3670      0.884 0.044 0.004 0.092 0.860
#> SRR1047857     4  0.3670      0.884 0.044 0.004 0.092 0.860
#> SRR1047858     1  0.0000      0.979 1.000 0.000 0.000 0.000
#> SRR1047859     1  0.0000      0.979 1.000 0.000 0.000 0.000
#> SRR1047860     1  0.0000      0.979 1.000 0.000 0.000 0.000
#> SRR1047861     1  0.0000      0.979 1.000 0.000 0.000 0.000
#> SRR1047863     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1047864     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1047865     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1047866     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1047867     2  0.1867      0.912 0.000 0.928 0.072 0.000
#> SRR1047868     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1047869     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1047870     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1047871     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1047872     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1047873     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1047874     3  0.0000      1.000 0.000 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4    p5
#> SRR1047813     1  0.4232      0.676 0.676 0.012 0.000 0.000 0.312
#> SRR1047814     1  0.4232      0.676 0.676 0.012 0.000 0.000 0.312
#> SRR1047815     1  0.4232      0.676 0.676 0.012 0.000 0.000 0.312
#> SRR1047816     1  0.4232      0.676 0.676 0.012 0.000 0.000 0.312
#> SRR1047817     1  0.4232      0.676 0.676 0.012 0.000 0.000 0.312
#> SRR1047818     4  0.0000      0.924 0.000 0.000 0.000 1.000 0.000
#> SRR1047819     4  0.0000      0.924 0.000 0.000 0.000 1.000 0.000
#> SRR1047820     4  0.0000      0.924 0.000 0.000 0.000 1.000 0.000
#> SRR1047821     4  0.0000      0.924 0.000 0.000 0.000 1.000 0.000
#> SRR1047822     4  0.0000      0.924 0.000 0.000 0.000 1.000 0.000
#> SRR1047823     4  0.0671      0.918 0.000 0.004 0.000 0.980 0.016
#> SRR1047824     4  0.0671      0.918 0.000 0.004 0.000 0.980 0.016
#> SRR1047825     4  0.0671      0.918 0.000 0.004 0.000 0.980 0.016
#> SRR1047826     4  0.0671      0.918 0.000 0.004 0.000 0.980 0.016
#> SRR1047827     4  0.0671      0.918 0.000 0.004 0.000 0.980 0.016
#> SRR1047828     2  0.4360      0.810 0.020 0.680 0.000 0.000 0.300
#> SRR1047829     2  0.4360      0.810 0.020 0.680 0.000 0.000 0.300
#> SRR1047830     2  0.4360      0.810 0.020 0.680 0.000 0.000 0.300
#> SRR1047831     2  0.4360      0.810 0.020 0.680 0.000 0.000 0.300
#> SRR1047832     2  0.4360      0.810 0.020 0.680 0.000 0.000 0.300
#> SRR1047833     2  0.0324      0.842 0.000 0.992 0.004 0.004 0.000
#> SRR1047834     2  0.0324      0.842 0.000 0.992 0.004 0.004 0.000
#> SRR1047835     2  0.0324      0.842 0.000 0.992 0.004 0.004 0.000
#> SRR1047836     2  0.0324      0.842 0.000 0.992 0.004 0.004 0.000
#> SRR1047837     2  0.0324      0.842 0.000 0.992 0.004 0.004 0.000
#> SRR1047838     4  0.2230      0.848 0.000 0.000 0.000 0.884 0.116
#> SRR1047839     4  0.2230      0.848 0.000 0.000 0.000 0.884 0.116
#> SRR1047840     4  0.2230      0.848 0.000 0.000 0.000 0.884 0.116
#> SRR1047841     4  0.2230      0.848 0.000 0.000 0.000 0.884 0.116
#> SRR1047842     4  0.2230      0.848 0.000 0.000 0.000 0.884 0.116
#> SRR1047843     1  0.3109      0.771 0.800 0.000 0.000 0.000 0.200
#> SRR1047844     1  0.3109      0.771 0.800 0.000 0.000 0.000 0.200
#> SRR1047845     1  0.3109      0.771 0.800 0.000 0.000 0.000 0.200
#> SRR1047846     1  0.3109      0.771 0.800 0.000 0.000 0.000 0.200
#> SRR1047847     1  0.3109      0.771 0.800 0.000 0.000 0.000 0.200
#> SRR1047848     1  0.0162      0.842 0.996 0.000 0.000 0.000 0.004
#> SRR1047849     1  0.0162      0.842 0.996 0.000 0.000 0.000 0.004
#> SRR1047850     1  0.0162      0.842 0.996 0.000 0.000 0.000 0.004
#> SRR1047851     1  0.0162      0.842 0.996 0.000 0.000 0.000 0.004
#> SRR1047852     1  0.0162      0.842 0.996 0.000 0.000 0.000 0.004
#> SRR1047853     5  0.5124      1.000 0.004 0.000 0.048 0.320 0.628
#> SRR1047854     5  0.5124      1.000 0.004 0.000 0.048 0.320 0.628
#> SRR1047855     5  0.5124      1.000 0.004 0.000 0.048 0.320 0.628
#> SRR1047856     5  0.5124      1.000 0.004 0.000 0.048 0.320 0.628
#> SRR1047857     5  0.5124      1.000 0.004 0.000 0.048 0.320 0.628
#> SRR1047858     1  0.0963      0.841 0.964 0.000 0.000 0.000 0.036
#> SRR1047859     1  0.0963      0.841 0.964 0.000 0.000 0.000 0.036
#> SRR1047860     1  0.0963      0.841 0.964 0.000 0.000 0.000 0.036
#> SRR1047861     1  0.0963      0.841 0.964 0.000 0.000 0.000 0.036
#> SRR1047863     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1047864     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1047865     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1047866     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1047867     2  0.0510      0.836 0.000 0.984 0.016 0.000 0.000
#> SRR1047868     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1047869     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1047870     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1047871     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1047872     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1047873     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1047874     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR1047813     5  0.4697      0.396 0.404 0.000 0.000 0.000 0.548 0.048
#> SRR1047814     5  0.4697      0.396 0.404 0.000 0.000 0.000 0.548 0.048
#> SRR1047815     5  0.4697      0.396 0.404 0.000 0.000 0.000 0.548 0.048
#> SRR1047816     5  0.4697      0.396 0.404 0.000 0.000 0.000 0.548 0.048
#> SRR1047817     5  0.4697      0.396 0.404 0.000 0.000 0.000 0.548 0.048
#> SRR1047818     4  0.1333      0.887 0.000 0.000 0.000 0.944 0.008 0.048
#> SRR1047819     4  0.1333      0.887 0.000 0.000 0.000 0.944 0.008 0.048
#> SRR1047820     4  0.1333      0.887 0.000 0.000 0.000 0.944 0.008 0.048
#> SRR1047821     4  0.1333      0.887 0.000 0.000 0.000 0.944 0.008 0.048
#> SRR1047822     4  0.1333      0.887 0.000 0.000 0.000 0.944 0.008 0.048
#> SRR1047823     4  0.0692      0.880 0.000 0.000 0.000 0.976 0.020 0.004
#> SRR1047824     4  0.0692      0.880 0.000 0.000 0.000 0.976 0.020 0.004
#> SRR1047825     4  0.0692      0.880 0.000 0.000 0.000 0.976 0.020 0.004
#> SRR1047826     4  0.0692      0.880 0.000 0.000 0.000 0.976 0.020 0.004
#> SRR1047827     4  0.0692      0.880 0.000 0.000 0.000 0.976 0.020 0.004
#> SRR1047828     5  0.3607      0.371 0.000 0.348 0.000 0.000 0.652 0.000
#> SRR1047829     5  0.3607      0.371 0.000 0.348 0.000 0.000 0.652 0.000
#> SRR1047830     5  0.3607      0.371 0.000 0.348 0.000 0.000 0.652 0.000
#> SRR1047831     5  0.3607      0.371 0.000 0.348 0.000 0.000 0.652 0.000
#> SRR1047832     5  0.3607      0.371 0.000 0.348 0.000 0.000 0.652 0.000
#> SRR1047833     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1047834     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1047835     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1047836     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1047837     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1047838     4  0.3572      0.794 0.000 0.000 0.000 0.764 0.032 0.204
#> SRR1047839     4  0.3572      0.794 0.000 0.000 0.000 0.764 0.032 0.204
#> SRR1047840     4  0.3572      0.794 0.000 0.000 0.000 0.764 0.032 0.204
#> SRR1047841     4  0.3572      0.794 0.000 0.000 0.000 0.764 0.032 0.204
#> SRR1047842     4  0.3572      0.794 0.000 0.000 0.000 0.764 0.032 0.204
#> SRR1047843     1  0.4226      0.741 0.736 0.000 0.000 0.000 0.112 0.152
#> SRR1047844     1  0.4261      0.737 0.732 0.000 0.000 0.000 0.112 0.156
#> SRR1047845     1  0.4226      0.741 0.736 0.000 0.000 0.000 0.112 0.152
#> SRR1047846     1  0.4226      0.741 0.736 0.000 0.000 0.000 0.112 0.152
#> SRR1047847     1  0.4261      0.737 0.732 0.000 0.000 0.000 0.112 0.156
#> SRR1047848     1  0.2051      0.799 0.896 0.000 0.000 0.004 0.096 0.004
#> SRR1047849     1  0.2051      0.799 0.896 0.000 0.000 0.004 0.096 0.004
#> SRR1047850     1  0.2051      0.799 0.896 0.000 0.000 0.004 0.096 0.004
#> SRR1047851     1  0.2051      0.799 0.896 0.000 0.000 0.004 0.096 0.004
#> SRR1047852     1  0.2051      0.799 0.896 0.000 0.000 0.004 0.096 0.004
#> SRR1047853     6  0.0858      1.000 0.000 0.000 0.004 0.028 0.000 0.968
#> SRR1047854     6  0.0858      1.000 0.000 0.000 0.004 0.028 0.000 0.968
#> SRR1047855     6  0.0858      1.000 0.000 0.000 0.004 0.028 0.000 0.968
#> SRR1047856     6  0.0858      1.000 0.000 0.000 0.004 0.028 0.000 0.968
#> SRR1047857     6  0.0858      1.000 0.000 0.000 0.004 0.028 0.000 0.968
#> SRR1047858     1  0.0363      0.820 0.988 0.000 0.000 0.000 0.012 0.000
#> SRR1047859     1  0.0363      0.820 0.988 0.000 0.000 0.000 0.012 0.000
#> SRR1047860     1  0.0363      0.820 0.988 0.000 0.000 0.000 0.012 0.000
#> SRR1047861     1  0.0363      0.820 0.988 0.000 0.000 0.000 0.012 0.000
#> SRR1047863     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1047864     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1047865     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1047866     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1047867     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1047868     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1047869     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1047870     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1047871     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1047872     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1047873     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1047874     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

plot of chunk tab-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 17931 rows and 61 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 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-pam-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.1811 0.820   0.820
#> 3 3 1.000           0.995       0.998         1.4432 0.727   0.669
#> 4 4 0.669           0.766       0.902         0.5323 0.740   0.535
#> 5 5 0.762           0.805       0.873         0.1115 0.793   0.453
#> 6 6 0.797           0.686       0.862         0.0481 0.879   0.593

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette p1 p2
#> SRR1047813     1       0          1  1  0
#> SRR1047814     1       0          1  1  0
#> SRR1047815     1       0          1  1  0
#> SRR1047816     1       0          1  1  0
#> SRR1047817     1       0          1  1  0
#> SRR1047818     1       0          1  1  0
#> SRR1047819     1       0          1  1  0
#> SRR1047820     1       0          1  1  0
#> SRR1047821     1       0          1  1  0
#> SRR1047822     1       0          1  1  0
#> SRR1047823     1       0          1  1  0
#> SRR1047824     1       0          1  1  0
#> SRR1047825     1       0          1  1  0
#> SRR1047826     1       0          1  1  0
#> SRR1047827     1       0          1  1  0
#> SRR1047828     1       0          1  1  0
#> SRR1047829     1       0          1  1  0
#> SRR1047830     1       0          1  1  0
#> SRR1047831     1       0          1  1  0
#> SRR1047832     1       0          1  1  0
#> SRR1047833     2       0          1  0  1
#> SRR1047834     2       0          1  0  1
#> SRR1047835     2       0          1  0  1
#> SRR1047836     2       0          1  0  1
#> SRR1047837     2       0          1  0  1
#> SRR1047838     1       0          1  1  0
#> SRR1047839     1       0          1  1  0
#> SRR1047840     1       0          1  1  0
#> SRR1047841     1       0          1  1  0
#> SRR1047842     1       0          1  1  0
#> SRR1047843     1       0          1  1  0
#> SRR1047844     1       0          1  1  0
#> SRR1047845     1       0          1  1  0
#> SRR1047846     1       0          1  1  0
#> SRR1047847     1       0          1  1  0
#> SRR1047848     1       0          1  1  0
#> SRR1047849     1       0          1  1  0
#> SRR1047850     1       0          1  1  0
#> SRR1047851     1       0          1  1  0
#> SRR1047852     1       0          1  1  0
#> SRR1047853     1       0          1  1  0
#> SRR1047854     1       0          1  1  0
#> SRR1047855     1       0          1  1  0
#> SRR1047856     1       0          1  1  0
#> SRR1047857     1       0          1  1  0
#> SRR1047858     1       0          1  1  0
#> SRR1047859     1       0          1  1  0
#> SRR1047860     1       0          1  1  0
#> SRR1047861     1       0          1  1  0
#> SRR1047863     1       0          1  1  0
#> SRR1047864     1       0          1  1  0
#> SRR1047865     1       0          1  1  0
#> SRR1047866     1       0          1  1  0
#> SRR1047867     2       0          1  0  1
#> SRR1047868     1       0          1  1  0
#> SRR1047869     1       0          1  1  0
#> SRR1047870     1       0          1  1  0
#> SRR1047871     1       0          1  1  0
#> SRR1047872     1       0          1  1  0
#> SRR1047873     1       0          1  1  0
#> SRR1047874     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette p1    p2    p3
#> SRR1047813     1   0.000      1.000  1 0.000 0.000
#> SRR1047814     1   0.000      1.000  1 0.000 0.000
#> SRR1047815     1   0.000      1.000  1 0.000 0.000
#> SRR1047816     1   0.000      1.000  1 0.000 0.000
#> SRR1047817     1   0.000      1.000  1 0.000 0.000
#> SRR1047818     1   0.000      1.000  1 0.000 0.000
#> SRR1047819     1   0.000      1.000  1 0.000 0.000
#> SRR1047820     1   0.000      1.000  1 0.000 0.000
#> SRR1047821     1   0.000      1.000  1 0.000 0.000
#> SRR1047822     1   0.000      1.000  1 0.000 0.000
#> SRR1047823     1   0.000      1.000  1 0.000 0.000
#> SRR1047824     1   0.000      1.000  1 0.000 0.000
#> SRR1047825     1   0.000      1.000  1 0.000 0.000
#> SRR1047826     1   0.000      1.000  1 0.000 0.000
#> SRR1047827     1   0.000      1.000  1 0.000 0.000
#> SRR1047828     1   0.000      1.000  1 0.000 0.000
#> SRR1047829     1   0.000      1.000  1 0.000 0.000
#> SRR1047830     1   0.000      1.000  1 0.000 0.000
#> SRR1047831     1   0.000      1.000  1 0.000 0.000
#> SRR1047832     1   0.000      1.000  1 0.000 0.000
#> SRR1047833     2   0.000      1.000  0 1.000 0.000
#> SRR1047834     2   0.000      1.000  0 1.000 0.000
#> SRR1047835     2   0.000      1.000  0 1.000 0.000
#> SRR1047836     2   0.000      1.000  0 1.000 0.000
#> SRR1047837     2   0.000      1.000  0 1.000 0.000
#> SRR1047838     1   0.000      1.000  1 0.000 0.000
#> SRR1047839     1   0.000      1.000  1 0.000 0.000
#> SRR1047840     1   0.000      1.000  1 0.000 0.000
#> SRR1047841     1   0.000      1.000  1 0.000 0.000
#> SRR1047842     1   0.000      1.000  1 0.000 0.000
#> SRR1047843     1   0.000      1.000  1 0.000 0.000
#> SRR1047844     1   0.000      1.000  1 0.000 0.000
#> SRR1047845     1   0.000      1.000  1 0.000 0.000
#> SRR1047846     1   0.000      1.000  1 0.000 0.000
#> SRR1047847     1   0.000      1.000  1 0.000 0.000
#> SRR1047848     1   0.000      1.000  1 0.000 0.000
#> SRR1047849     1   0.000      1.000  1 0.000 0.000
#> SRR1047850     1   0.000      1.000  1 0.000 0.000
#> SRR1047851     1   0.000      1.000  1 0.000 0.000
#> SRR1047852     1   0.000      1.000  1 0.000 0.000
#> SRR1047853     1   0.000      1.000  1 0.000 0.000
#> SRR1047854     1   0.000      1.000  1 0.000 0.000
#> SRR1047855     1   0.000      1.000  1 0.000 0.000
#> SRR1047856     1   0.000      1.000  1 0.000 0.000
#> SRR1047857     1   0.000      1.000  1 0.000 0.000
#> SRR1047858     1   0.000      1.000  1 0.000 0.000
#> SRR1047859     1   0.000      1.000  1 0.000 0.000
#> SRR1047860     1   0.000      1.000  1 0.000 0.000
#> SRR1047861     1   0.000      1.000  1 0.000 0.000
#> SRR1047863     3   0.000      0.986  0 0.000 1.000
#> SRR1047864     3   0.000      0.986  0 0.000 1.000
#> SRR1047865     3   0.000      0.986  0 0.000 1.000
#> SRR1047866     3   0.000      0.986  0 0.000 1.000
#> SRR1047867     3   0.388      0.821  0 0.152 0.848
#> SRR1047868     3   0.000      0.986  0 0.000 1.000
#> SRR1047869     3   0.000      0.986  0 0.000 1.000
#> SRR1047870     3   0.000      0.986  0 0.000 1.000
#> SRR1047871     3   0.000      0.986  0 0.000 1.000
#> SRR1047872     3   0.000      0.986  0 0.000 1.000
#> SRR1047873     3   0.000      0.986  0 0.000 1.000
#> SRR1047874     3   0.000      0.986  0 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1047813     1  0.2921     0.7911 0.860 0.000 0.000 0.140
#> SRR1047814     1  0.2973     0.7913 0.856 0.000 0.000 0.144
#> SRR1047815     1  0.3024     0.7910 0.852 0.000 0.000 0.148
#> SRR1047816     1  0.3024     0.7911 0.852 0.000 0.000 0.148
#> SRR1047817     1  0.3688     0.7695 0.792 0.000 0.000 0.208
#> SRR1047818     4  0.0000     0.8535 0.000 0.000 0.000 1.000
#> SRR1047819     4  0.0000     0.8535 0.000 0.000 0.000 1.000
#> SRR1047820     4  0.0000     0.8535 0.000 0.000 0.000 1.000
#> SRR1047821     4  0.0000     0.8535 0.000 0.000 0.000 1.000
#> SRR1047822     4  0.0000     0.8535 0.000 0.000 0.000 1.000
#> SRR1047823     4  0.0000     0.8535 0.000 0.000 0.000 1.000
#> SRR1047824     4  0.0000     0.8535 0.000 0.000 0.000 1.000
#> SRR1047825     4  0.0000     0.8535 0.000 0.000 0.000 1.000
#> SRR1047826     4  0.0000     0.8535 0.000 0.000 0.000 1.000
#> SRR1047827     4  0.0000     0.8535 0.000 0.000 0.000 1.000
#> SRR1047828     1  0.3688     0.7695 0.792 0.000 0.000 0.208
#> SRR1047829     1  0.3688     0.7695 0.792 0.000 0.000 0.208
#> SRR1047830     1  0.3688     0.7695 0.792 0.000 0.000 0.208
#> SRR1047831     1  0.3688     0.7695 0.792 0.000 0.000 0.208
#> SRR1047832     1  0.3688     0.7695 0.792 0.000 0.000 0.208
#> SRR1047833     2  0.0000     1.0000 0.000 1.000 0.000 0.000
#> SRR1047834     2  0.0000     1.0000 0.000 1.000 0.000 0.000
#> SRR1047835     2  0.0000     1.0000 0.000 1.000 0.000 0.000
#> SRR1047836     2  0.0000     1.0000 0.000 1.000 0.000 0.000
#> SRR1047837     2  0.0000     1.0000 0.000 1.000 0.000 0.000
#> SRR1047838     4  0.0000     0.8535 0.000 0.000 0.000 1.000
#> SRR1047839     4  0.0000     0.8535 0.000 0.000 0.000 1.000
#> SRR1047840     4  0.0000     0.8535 0.000 0.000 0.000 1.000
#> SRR1047841     4  0.0000     0.8535 0.000 0.000 0.000 1.000
#> SRR1047842     4  0.0000     0.8535 0.000 0.000 0.000 1.000
#> SRR1047843     4  0.4948     0.0534 0.440 0.000 0.000 0.560
#> SRR1047844     4  0.4925     0.0837 0.428 0.000 0.000 0.572
#> SRR1047845     4  0.4925     0.0837 0.428 0.000 0.000 0.572
#> SRR1047846     4  0.4925     0.0837 0.428 0.000 0.000 0.572
#> SRR1047847     4  0.4925     0.0837 0.428 0.000 0.000 0.572
#> SRR1047848     1  0.0188     0.7282 0.996 0.000 0.000 0.004
#> SRR1047849     1  0.0707     0.7345 0.980 0.000 0.000 0.020
#> SRR1047850     1  0.0469     0.7326 0.988 0.000 0.000 0.012
#> SRR1047851     1  0.0336     0.7310 0.992 0.000 0.000 0.008
#> SRR1047852     1  0.0336     0.7310 0.992 0.000 0.000 0.008
#> SRR1047853     4  0.0469     0.8472 0.012 0.000 0.000 0.988
#> SRR1047854     4  0.2760     0.7428 0.128 0.000 0.000 0.872
#> SRR1047855     4  0.1867     0.8047 0.072 0.000 0.000 0.928
#> SRR1047856     4  0.1389     0.8242 0.048 0.000 0.000 0.952
#> SRR1047857     4  0.2149     0.7887 0.088 0.000 0.000 0.912
#> SRR1047858     1  0.4730     0.3644 0.636 0.000 0.000 0.364
#> SRR1047859     1  0.4790     0.3423 0.620 0.000 0.000 0.380
#> SRR1047860     1  0.4730     0.3644 0.636 0.000 0.000 0.364
#> SRR1047861     1  0.4730     0.3644 0.636 0.000 0.000 0.364
#> SRR1047863     3  0.0000     0.9860 0.000 0.000 1.000 0.000
#> SRR1047864     3  0.0000     0.9860 0.000 0.000 1.000 0.000
#> SRR1047865     3  0.0000     0.9860 0.000 0.000 1.000 0.000
#> SRR1047866     3  0.0000     0.9860 0.000 0.000 1.000 0.000
#> SRR1047867     3  0.3074     0.8208 0.000 0.152 0.848 0.000
#> SRR1047868     3  0.0000     0.9860 0.000 0.000 1.000 0.000
#> SRR1047869     3  0.0000     0.9860 0.000 0.000 1.000 0.000
#> SRR1047870     3  0.0000     0.9860 0.000 0.000 1.000 0.000
#> SRR1047871     3  0.0000     0.9860 0.000 0.000 1.000 0.000
#> SRR1047872     3  0.0000     0.9860 0.000 0.000 1.000 0.000
#> SRR1047873     3  0.0000     0.9860 0.000 0.000 1.000 0.000
#> SRR1047874     3  0.0000     0.9860 0.000 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4    p5
#> SRR1047813     5  0.4307   -0.05088 0.496 0.000 0.000 0.000 0.504
#> SRR1047814     1  0.4304   -0.04688 0.516 0.000 0.000 0.000 0.484
#> SRR1047815     5  0.4306    0.00767 0.492 0.000 0.000 0.000 0.508
#> SRR1047816     5  0.4307   -0.02529 0.500 0.000 0.000 0.000 0.500
#> SRR1047817     5  0.2813    0.70631 0.168 0.000 0.000 0.000 0.832
#> SRR1047818     4  0.1908    0.90396 0.000 0.000 0.000 0.908 0.092
#> SRR1047819     4  0.1410    0.93370 0.000 0.000 0.000 0.940 0.060
#> SRR1047820     4  0.1410    0.93370 0.000 0.000 0.000 0.940 0.060
#> SRR1047821     4  0.1908    0.90302 0.000 0.000 0.000 0.908 0.092
#> SRR1047822     5  0.3913    0.67656 0.000 0.000 0.000 0.324 0.676
#> SRR1047823     4  0.0000    0.94600 0.000 0.000 0.000 1.000 0.000
#> SRR1047824     4  0.0000    0.94600 0.000 0.000 0.000 1.000 0.000
#> SRR1047825     4  0.0000    0.94600 0.000 0.000 0.000 1.000 0.000
#> SRR1047826     4  0.0000    0.94600 0.000 0.000 0.000 1.000 0.000
#> SRR1047827     4  0.0000    0.94600 0.000 0.000 0.000 1.000 0.000
#> SRR1047828     5  0.0000    0.70722 0.000 0.000 0.000 0.000 1.000
#> SRR1047829     5  0.0000    0.70722 0.000 0.000 0.000 0.000 1.000
#> SRR1047830     5  0.0000    0.70722 0.000 0.000 0.000 0.000 1.000
#> SRR1047831     5  0.0290    0.70967 0.008 0.000 0.000 0.000 0.992
#> SRR1047832     5  0.0000    0.70722 0.000 0.000 0.000 0.000 1.000
#> SRR1047833     2  0.0000    1.00000 0.000 1.000 0.000 0.000 0.000
#> SRR1047834     2  0.0000    1.00000 0.000 1.000 0.000 0.000 0.000
#> SRR1047835     2  0.0000    1.00000 0.000 1.000 0.000 0.000 0.000
#> SRR1047836     2  0.0000    1.00000 0.000 1.000 0.000 0.000 0.000
#> SRR1047837     2  0.0000    1.00000 0.000 1.000 0.000 0.000 0.000
#> SRR1047838     5  0.3774    0.71009 0.000 0.000 0.000 0.296 0.704
#> SRR1047839     5  0.3774    0.71009 0.000 0.000 0.000 0.296 0.704
#> SRR1047840     5  0.3774    0.71009 0.000 0.000 0.000 0.296 0.704
#> SRR1047841     5  0.3774    0.71009 0.000 0.000 0.000 0.296 0.704
#> SRR1047842     5  0.3774    0.71009 0.000 0.000 0.000 0.296 0.704
#> SRR1047843     5  0.4953    0.74290 0.216 0.000 0.000 0.088 0.696
#> SRR1047844     5  0.4893    0.74792 0.208 0.000 0.000 0.088 0.704
#> SRR1047845     5  0.4893    0.74792 0.208 0.000 0.000 0.088 0.704
#> SRR1047846     5  0.4871    0.74575 0.212 0.000 0.000 0.084 0.704
#> SRR1047847     5  0.4893    0.74792 0.208 0.000 0.000 0.088 0.704
#> SRR1047848     1  0.0000    0.92151 1.000 0.000 0.000 0.000 0.000
#> SRR1047849     1  0.0000    0.92151 1.000 0.000 0.000 0.000 0.000
#> SRR1047850     1  0.0000    0.92151 1.000 0.000 0.000 0.000 0.000
#> SRR1047851     1  0.0000    0.92151 1.000 0.000 0.000 0.000 0.000
#> SRR1047852     1  0.0000    0.92151 1.000 0.000 0.000 0.000 0.000
#> SRR1047853     5  0.4086    0.71892 0.012 0.000 0.000 0.284 0.704
#> SRR1047854     5  0.5038    0.76127 0.132 0.000 0.000 0.164 0.704
#> SRR1047855     5  0.4822    0.75181 0.076 0.000 0.000 0.220 0.704
#> SRR1047856     5  0.4629    0.74126 0.052 0.000 0.000 0.244 0.704
#> SRR1047857     5  0.4933    0.75718 0.096 0.000 0.000 0.200 0.704
#> SRR1047858     1  0.0000    0.92151 1.000 0.000 0.000 0.000 0.000
#> SRR1047859     1  0.1485    0.87208 0.948 0.000 0.000 0.020 0.032
#> SRR1047860     1  0.0162    0.91836 0.996 0.000 0.000 0.004 0.000
#> SRR1047861     1  0.0000    0.92151 1.000 0.000 0.000 0.000 0.000
#> SRR1047863     3  0.0000    0.98597 0.000 0.000 1.000 0.000 0.000
#> SRR1047864     3  0.0000    0.98597 0.000 0.000 1.000 0.000 0.000
#> SRR1047865     3  0.0000    0.98597 0.000 0.000 1.000 0.000 0.000
#> SRR1047866     3  0.0000    0.98597 0.000 0.000 1.000 0.000 0.000
#> SRR1047867     3  0.2648    0.82075 0.000 0.152 0.848 0.000 0.000
#> SRR1047868     3  0.0000    0.98597 0.000 0.000 1.000 0.000 0.000
#> SRR1047869     3  0.0000    0.98597 0.000 0.000 1.000 0.000 0.000
#> SRR1047870     3  0.0000    0.98597 0.000 0.000 1.000 0.000 0.000
#> SRR1047871     3  0.0000    0.98597 0.000 0.000 1.000 0.000 0.000
#> SRR1047872     3  0.0000    0.98597 0.000 0.000 1.000 0.000 0.000
#> SRR1047873     3  0.0000    0.98597 0.000 0.000 1.000 0.000 0.000
#> SRR1047874     3  0.0000    0.98597 0.000 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR1047813     6  0.0146      1.000 0.004 0.000 0.000 0.000 0.000 0.996
#> SRR1047814     6  0.0146      1.000 0.004 0.000 0.000 0.000 0.000 0.996
#> SRR1047815     6  0.0146      1.000 0.004 0.000 0.000 0.000 0.000 0.996
#> SRR1047816     6  0.0146      1.000 0.004 0.000 0.000 0.000 0.000 0.996
#> SRR1047817     6  0.0146      1.000 0.004 0.000 0.000 0.000 0.000 0.996
#> SRR1047818     4  0.3843     -0.588 0.000 0.000 0.000 0.548 0.452 0.000
#> SRR1047819     4  0.3862     -0.636 0.000 0.000 0.000 0.524 0.476 0.000
#> SRR1047820     4  0.3854     -0.613 0.000 0.000 0.000 0.536 0.464 0.000
#> SRR1047821     4  0.3817     -0.545 0.000 0.000 0.000 0.568 0.432 0.000
#> SRR1047822     4  0.0363      0.568 0.000 0.000 0.000 0.988 0.012 0.000
#> SRR1047823     5  0.3828      0.745 0.000 0.000 0.000 0.440 0.560 0.000
#> SRR1047824     5  0.3828      0.745 0.000 0.000 0.000 0.440 0.560 0.000
#> SRR1047825     5  0.3828      0.745 0.000 0.000 0.000 0.440 0.560 0.000
#> SRR1047826     5  0.3828      0.745 0.000 0.000 0.000 0.440 0.560 0.000
#> SRR1047827     5  0.3828      0.745 0.000 0.000 0.000 0.440 0.560 0.000
#> SRR1047828     5  0.5722     -0.333 0.000 0.000 0.000 0.404 0.432 0.164
#> SRR1047829     4  0.4504      0.331 0.000 0.000 0.000 0.536 0.432 0.032
#> SRR1047830     4  0.4978      0.294 0.000 0.000 0.000 0.500 0.432 0.068
#> SRR1047831     4  0.4439      0.335 0.000 0.000 0.000 0.540 0.432 0.028
#> SRR1047832     4  0.4565      0.328 0.000 0.000 0.000 0.532 0.432 0.036
#> SRR1047833     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1047834     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1047835     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1047836     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1047837     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1047838     4  0.0000      0.579 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1047839     4  0.0000      0.579 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1047840     4  0.0000      0.579 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1047841     4  0.0000      0.579 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1047842     4  0.0000      0.579 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1047843     4  0.3323      0.546 0.240 0.000 0.000 0.752 0.008 0.000
#> SRR1047844     4  0.3133      0.562 0.212 0.000 0.000 0.780 0.008 0.000
#> SRR1047845     4  0.3271      0.551 0.232 0.000 0.000 0.760 0.008 0.000
#> SRR1047846     4  0.3398      0.536 0.252 0.000 0.000 0.740 0.008 0.000
#> SRR1047847     4  0.3161      0.560 0.216 0.000 0.000 0.776 0.008 0.000
#> SRR1047848     1  0.0000      0.979 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1047849     1  0.0000      0.979 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1047850     1  0.0000      0.979 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1047851     1  0.0000      0.979 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1047852     1  0.0000      0.979 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1047853     4  0.0363      0.585 0.012 0.000 0.000 0.988 0.000 0.000
#> SRR1047854     4  0.2135      0.592 0.128 0.000 0.000 0.872 0.000 0.000
#> SRR1047855     4  0.1387      0.599 0.068 0.000 0.000 0.932 0.000 0.000
#> SRR1047856     4  0.1141      0.597 0.052 0.000 0.000 0.948 0.000 0.000
#> SRR1047857     4  0.1714      0.598 0.092 0.000 0.000 0.908 0.000 0.000
#> SRR1047858     1  0.0260      0.977 0.992 0.000 0.000 0.000 0.008 0.000
#> SRR1047859     1  0.1970      0.860 0.900 0.000 0.000 0.092 0.008 0.000
#> SRR1047860     1  0.0405      0.975 0.988 0.000 0.000 0.004 0.008 0.000
#> SRR1047861     1  0.0260      0.977 0.992 0.000 0.000 0.000 0.008 0.000
#> SRR1047863     3  0.0000      0.986 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1047864     3  0.0000      0.986 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1047865     3  0.0000      0.986 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1047866     3  0.0000      0.986 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1047867     3  0.2378      0.821 0.000 0.152 0.848 0.000 0.000 0.000
#> SRR1047868     3  0.0000      0.986 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1047869     3  0.0000      0.986 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1047870     3  0.0000      0.986 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1047871     3  0.0000      0.986 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1047872     3  0.0000      0.986 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1047873     3  0.0000      0.986 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1047874     3  0.0000      0.986 0.000 0.000 1.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

plot of chunk tab-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 17931 rows and 61 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 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-mclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.699           0.972       0.968         0.3685 0.591   0.591
#> 3 3 0.530           0.740       0.777         0.5634 0.738   0.556
#> 4 4 0.893           0.922       0.961         0.1928 0.861   0.647
#> 5 5 0.765           0.772       0.823         0.1218 0.934   0.796
#> 6 6 0.825           0.829       0.880         0.0714 0.883   0.563

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

suggest_best_k(res)
#> [1] 4

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette    p1    p2
#> SRR1047813     1   0.000      1.000 1.000 0.000
#> SRR1047814     1   0.000      1.000 1.000 0.000
#> SRR1047815     1   0.000      1.000 1.000 0.000
#> SRR1047816     1   0.000      1.000 1.000 0.000
#> SRR1047817     1   0.000      1.000 1.000 0.000
#> SRR1047818     1   0.000      1.000 1.000 0.000
#> SRR1047819     1   0.000      1.000 1.000 0.000
#> SRR1047820     1   0.000      1.000 1.000 0.000
#> SRR1047821     1   0.000      1.000 1.000 0.000
#> SRR1047822     1   0.000      1.000 1.000 0.000
#> SRR1047823     1   0.000      1.000 1.000 0.000
#> SRR1047824     1   0.000      1.000 1.000 0.000
#> SRR1047825     1   0.000      1.000 1.000 0.000
#> SRR1047826     1   0.000      1.000 1.000 0.000
#> SRR1047827     1   0.000      1.000 1.000 0.000
#> SRR1047828     1   0.000      1.000 1.000 0.000
#> SRR1047829     1   0.000      1.000 1.000 0.000
#> SRR1047830     1   0.000      1.000 1.000 0.000
#> SRR1047831     1   0.000      1.000 1.000 0.000
#> SRR1047832     1   0.000      1.000 1.000 0.000
#> SRR1047833     2   0.000      0.869 0.000 1.000
#> SRR1047834     2   0.000      0.869 0.000 1.000
#> SRR1047835     2   0.000      0.869 0.000 1.000
#> SRR1047836     2   0.000      0.869 0.000 1.000
#> SRR1047837     2   0.000      0.869 0.000 1.000
#> SRR1047838     1   0.000      1.000 1.000 0.000
#> SRR1047839     1   0.000      1.000 1.000 0.000
#> SRR1047840     1   0.000      1.000 1.000 0.000
#> SRR1047841     1   0.000      1.000 1.000 0.000
#> SRR1047842     1   0.000      1.000 1.000 0.000
#> SRR1047843     1   0.000      1.000 1.000 0.000
#> SRR1047844     1   0.000      1.000 1.000 0.000
#> SRR1047845     1   0.000      1.000 1.000 0.000
#> SRR1047846     1   0.000      1.000 1.000 0.000
#> SRR1047847     1   0.000      1.000 1.000 0.000
#> SRR1047848     1   0.000      1.000 1.000 0.000
#> SRR1047849     1   0.000      1.000 1.000 0.000
#> SRR1047850     1   0.000      1.000 1.000 0.000
#> SRR1047851     1   0.000      1.000 1.000 0.000
#> SRR1047852     1   0.000      1.000 1.000 0.000
#> SRR1047853     1   0.000      1.000 1.000 0.000
#> SRR1047854     1   0.000      1.000 1.000 0.000
#> SRR1047855     1   0.000      1.000 1.000 0.000
#> SRR1047856     1   0.000      1.000 1.000 0.000
#> SRR1047857     1   0.000      1.000 1.000 0.000
#> SRR1047858     1   0.000      1.000 1.000 0.000
#> SRR1047859     1   0.000      1.000 1.000 0.000
#> SRR1047860     1   0.000      1.000 1.000 0.000
#> SRR1047861     1   0.000      1.000 1.000 0.000
#> SRR1047863     2   0.680      0.917 0.180 0.820
#> SRR1047864     2   0.671      0.917 0.176 0.824
#> SRR1047865     2   0.680      0.917 0.180 0.820
#> SRR1047866     2   0.680      0.917 0.180 0.820
#> SRR1047867     2   0.000      0.869 0.000 1.000
#> SRR1047868     2   0.680      0.917 0.180 0.820
#> SRR1047869     2   0.680      0.917 0.180 0.820
#> SRR1047870     2   0.680      0.917 0.180 0.820
#> SRR1047871     2   0.680      0.917 0.180 0.820
#> SRR1047872     2   0.680      0.917 0.180 0.820
#> SRR1047873     2   0.680      0.917 0.180 0.820
#> SRR1047874     2   0.680      0.917 0.180 0.820

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1047813     1  0.5678      0.924 0.684 0.316 0.000
#> SRR1047814     1  0.5678      0.924 0.684 0.316 0.000
#> SRR1047815     1  0.5678      0.924 0.684 0.316 0.000
#> SRR1047816     1  0.5678      0.924 0.684 0.316 0.000
#> SRR1047817     1  0.5678      0.924 0.684 0.316 0.000
#> SRR1047818     2  0.0000      0.800 0.000 1.000 0.000
#> SRR1047819     2  0.0000      0.800 0.000 1.000 0.000
#> SRR1047820     2  0.0000      0.800 0.000 1.000 0.000
#> SRR1047821     2  0.0000      0.800 0.000 1.000 0.000
#> SRR1047822     2  0.0000      0.800 0.000 1.000 0.000
#> SRR1047823     2  0.0000      0.800 0.000 1.000 0.000
#> SRR1047824     2  0.0000      0.800 0.000 1.000 0.000
#> SRR1047825     2  0.0000      0.800 0.000 1.000 0.000
#> SRR1047826     2  0.0000      0.800 0.000 1.000 0.000
#> SRR1047827     2  0.0000      0.800 0.000 1.000 0.000
#> SRR1047828     1  0.5678      0.924 0.684 0.316 0.000
#> SRR1047829     1  0.5678      0.924 0.684 0.316 0.000
#> SRR1047830     1  0.5678      0.924 0.684 0.316 0.000
#> SRR1047831     1  0.5678      0.924 0.684 0.316 0.000
#> SRR1047832     1  0.5678      0.924 0.684 0.316 0.000
#> SRR1047833     3  0.0000      0.785 0.000 0.000 1.000
#> SRR1047834     3  0.0000      0.785 0.000 0.000 1.000
#> SRR1047835     3  0.0000      0.785 0.000 0.000 1.000
#> SRR1047836     3  0.0000      0.785 0.000 0.000 1.000
#> SRR1047837     3  0.0000      0.785 0.000 0.000 1.000
#> SRR1047838     2  0.0000      0.800 0.000 1.000 0.000
#> SRR1047839     2  0.0000      0.800 0.000 1.000 0.000
#> SRR1047840     2  0.0000      0.800 0.000 1.000 0.000
#> SRR1047841     2  0.0000      0.800 0.000 1.000 0.000
#> SRR1047842     2  0.0000      0.800 0.000 1.000 0.000
#> SRR1047843     1  0.6140      0.895 0.596 0.404 0.000
#> SRR1047844     1  0.6140      0.895 0.596 0.404 0.000
#> SRR1047845     1  0.6140      0.895 0.596 0.404 0.000
#> SRR1047846     1  0.6140      0.895 0.596 0.404 0.000
#> SRR1047847     1  0.6140      0.895 0.596 0.404 0.000
#> SRR1047848     1  0.5859      0.929 0.656 0.344 0.000
#> SRR1047849     1  0.5859      0.929 0.656 0.344 0.000
#> SRR1047850     1  0.5859      0.929 0.656 0.344 0.000
#> SRR1047851     1  0.5859      0.929 0.656 0.344 0.000
#> SRR1047852     1  0.5859      0.929 0.656 0.344 0.000
#> SRR1047853     2  0.6267     -0.474 0.452 0.548 0.000
#> SRR1047854     2  0.6267     -0.474 0.452 0.548 0.000
#> SRR1047855     2  0.6267     -0.474 0.452 0.548 0.000
#> SRR1047856     2  0.6267     -0.474 0.452 0.548 0.000
#> SRR1047857     2  0.6267     -0.474 0.452 0.548 0.000
#> SRR1047858     1  0.6140      0.895 0.596 0.404 0.000
#> SRR1047859     1  0.6140      0.895 0.596 0.404 0.000
#> SRR1047860     1  0.6140      0.895 0.596 0.404 0.000
#> SRR1047861     1  0.6140      0.895 0.596 0.404 0.000
#> SRR1047863     3  0.6786      0.816 0.448 0.012 0.540
#> SRR1047864     3  0.5678      0.828 0.316 0.000 0.684
#> SRR1047865     3  0.8882      0.777 0.316 0.144 0.540
#> SRR1047866     3  0.5678      0.828 0.316 0.000 0.684
#> SRR1047867     3  0.0237      0.784 0.004 0.000 0.996
#> SRR1047868     3  0.6280      0.814 0.460 0.000 0.540
#> SRR1047869     3  0.8930      0.775 0.316 0.148 0.536
#> SRR1047870     3  0.6280      0.814 0.460 0.000 0.540
#> SRR1047871     3  0.8720      0.790 0.336 0.124 0.540
#> SRR1047872     3  0.6495      0.813 0.460 0.004 0.536
#> SRR1047873     3  0.6495      0.813 0.460 0.004 0.536
#> SRR1047874     3  0.6495      0.813 0.460 0.004 0.536

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1 p2 p3    p4
#> SRR1047813     1   0.000      0.901 1.000  0  0 0.000
#> SRR1047814     1   0.000      0.901 1.000  0  0 0.000
#> SRR1047815     1   0.000      0.901 1.000  0  0 0.000
#> SRR1047816     1   0.000      0.901 1.000  0  0 0.000
#> SRR1047817     1   0.000      0.901 1.000  0  0 0.000
#> SRR1047818     4   0.000      1.000 0.000  0  0 1.000
#> SRR1047819     4   0.000      1.000 0.000  0  0 1.000
#> SRR1047820     4   0.000      1.000 0.000  0  0 1.000
#> SRR1047821     4   0.000      1.000 0.000  0  0 1.000
#> SRR1047822     4   0.000      1.000 0.000  0  0 1.000
#> SRR1047823     4   0.000      1.000 0.000  0  0 1.000
#> SRR1047824     4   0.000      1.000 0.000  0  0 1.000
#> SRR1047825     4   0.000      1.000 0.000  0  0 1.000
#> SRR1047826     4   0.000      1.000 0.000  0  0 1.000
#> SRR1047827     4   0.000      1.000 0.000  0  0 1.000
#> SRR1047828     1   0.000      0.901 1.000  0  0 0.000
#> SRR1047829     1   0.000      0.901 1.000  0  0 0.000
#> SRR1047830     1   0.000      0.901 1.000  0  0 0.000
#> SRR1047831     1   0.000      0.901 1.000  0  0 0.000
#> SRR1047832     1   0.000      0.901 1.000  0  0 0.000
#> SRR1047833     2   0.000      1.000 0.000  1  0 0.000
#> SRR1047834     2   0.000      1.000 0.000  1  0 0.000
#> SRR1047835     2   0.000      1.000 0.000  1  0 0.000
#> SRR1047836     2   0.000      1.000 0.000  1  0 0.000
#> SRR1047837     2   0.000      1.000 0.000  1  0 0.000
#> SRR1047838     4   0.000      1.000 0.000  0  0 1.000
#> SRR1047839     4   0.000      1.000 0.000  0  0 1.000
#> SRR1047840     4   0.000      1.000 0.000  0  0 1.000
#> SRR1047841     4   0.000      1.000 0.000  0  0 1.000
#> SRR1047842     4   0.000      1.000 0.000  0  0 1.000
#> SRR1047843     1   0.164      0.893 0.940  0  0 0.060
#> SRR1047844     1   0.164      0.893 0.940  0  0 0.060
#> SRR1047845     1   0.164      0.893 0.940  0  0 0.060
#> SRR1047846     1   0.164      0.893 0.940  0  0 0.060
#> SRR1047847     1   0.164      0.893 0.940  0  0 0.060
#> SRR1047848     1   0.000      0.901 1.000  0  0 0.000
#> SRR1047849     1   0.000      0.901 1.000  0  0 0.000
#> SRR1047850     1   0.000      0.901 1.000  0  0 0.000
#> SRR1047851     1   0.000      0.901 1.000  0  0 0.000
#> SRR1047852     1   0.000      0.901 1.000  0  0 0.000
#> SRR1047853     1   0.476      0.541 0.628  0  0 0.372
#> SRR1047854     1   0.476      0.541 0.628  0  0 0.372
#> SRR1047855     1   0.476      0.541 0.628  0  0 0.372
#> SRR1047856     1   0.476      0.541 0.628  0  0 0.372
#> SRR1047857     1   0.476      0.541 0.628  0  0 0.372
#> SRR1047858     1   0.164      0.893 0.940  0  0 0.060
#> SRR1047859     1   0.164      0.893 0.940  0  0 0.060
#> SRR1047860     1   0.164      0.893 0.940  0  0 0.060
#> SRR1047861     1   0.164      0.893 0.940  0  0 0.060
#> SRR1047863     3   0.000      1.000 0.000  0  1 0.000
#> SRR1047864     3   0.000      1.000 0.000  0  1 0.000
#> SRR1047865     3   0.000      1.000 0.000  0  1 0.000
#> SRR1047866     3   0.000      1.000 0.000  0  1 0.000
#> SRR1047867     3   0.000      1.000 0.000  0  1 0.000
#> SRR1047868     3   0.000      1.000 0.000  0  1 0.000
#> SRR1047869     3   0.000      1.000 0.000  0  1 0.000
#> SRR1047870     3   0.000      1.000 0.000  0  1 0.000
#> SRR1047871     3   0.000      1.000 0.000  0  1 0.000
#> SRR1047872     3   0.000      1.000 0.000  0  1 0.000
#> SRR1047873     3   0.000      1.000 0.000  0  1 0.000
#> SRR1047874     3   0.000      1.000 0.000  0  1 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
#> SRR1047813     1   0.416      0.552 0.608  0 0.000 0.000 0.392
#> SRR1047814     1   0.416      0.552 0.608  0 0.000 0.000 0.392
#> SRR1047815     1   0.416      0.552 0.608  0 0.000 0.000 0.392
#> SRR1047816     1   0.416      0.552 0.608  0 0.000 0.000 0.392
#> SRR1047817     1   0.416      0.552 0.608  0 0.000 0.000 0.392
#> SRR1047818     4   0.000      0.821 0.000  0 0.000 1.000 0.000
#> SRR1047819     4   0.000      0.821 0.000  0 0.000 1.000 0.000
#> SRR1047820     4   0.000      0.821 0.000  0 0.000 1.000 0.000
#> SRR1047821     4   0.000      0.821 0.000  0 0.000 1.000 0.000
#> SRR1047822     4   0.000      0.821 0.000  0 0.000 1.000 0.000
#> SRR1047823     4   0.000      0.821 0.000  0 0.000 1.000 0.000
#> SRR1047824     4   0.000      0.821 0.000  0 0.000 1.000 0.000
#> SRR1047825     4   0.000      0.821 0.000  0 0.000 1.000 0.000
#> SRR1047826     4   0.000      0.821 0.000  0 0.000 1.000 0.000
#> SRR1047827     4   0.000      0.821 0.000  0 0.000 1.000 0.000
#> SRR1047828     1   0.491      0.617 0.588  0 0.032 0.000 0.380
#> SRR1047829     1   0.491      0.617 0.588  0 0.032 0.000 0.380
#> SRR1047830     1   0.491      0.617 0.588  0 0.032 0.000 0.380
#> SRR1047831     1   0.491      0.617 0.588  0 0.032 0.000 0.380
#> SRR1047832     1   0.491      0.617 0.588  0 0.032 0.000 0.380
#> SRR1047833     2   0.000      1.000 0.000  1 0.000 0.000 0.000
#> SRR1047834     2   0.000      1.000 0.000  1 0.000 0.000 0.000
#> SRR1047835     2   0.000      1.000 0.000  1 0.000 0.000 0.000
#> SRR1047836     2   0.000      1.000 0.000  1 0.000 0.000 0.000
#> SRR1047837     2   0.000      1.000 0.000  1 0.000 0.000 0.000
#> SRR1047838     4   0.417      0.481 0.000  0 0.000 0.604 0.396
#> SRR1047839     4   0.417      0.481 0.000  0 0.000 0.604 0.396
#> SRR1047840     4   0.417      0.481 0.000  0 0.000 0.604 0.396
#> SRR1047841     4   0.417      0.481 0.000  0 0.000 0.604 0.396
#> SRR1047842     4   0.417      0.481 0.000  0 0.000 0.604 0.396
#> SRR1047843     1   0.321      0.623 0.788  0 0.000 0.000 0.212
#> SRR1047844     1   0.321      0.623 0.788  0 0.000 0.000 0.212
#> SRR1047845     1   0.321      0.623 0.788  0 0.000 0.000 0.212
#> SRR1047846     1   0.321      0.623 0.788  0 0.000 0.000 0.212
#> SRR1047847     1   0.321      0.623 0.788  0 0.000 0.000 0.212
#> SRR1047848     1   0.247      0.603 0.864  0 0.000 0.000 0.136
#> SRR1047849     1   0.247      0.603 0.864  0 0.000 0.000 0.136
#> SRR1047850     1   0.247      0.603 0.864  0 0.000 0.000 0.136
#> SRR1047851     1   0.247      0.603 0.864  0 0.000 0.000 0.136
#> SRR1047852     1   0.247      0.603 0.864  0 0.000 0.000 0.136
#> SRR1047853     5   0.583      1.000 0.220  0 0.000 0.172 0.608
#> SRR1047854     5   0.583      1.000 0.220  0 0.000 0.172 0.608
#> SRR1047855     5   0.583      1.000 0.220  0 0.000 0.172 0.608
#> SRR1047856     5   0.583      1.000 0.220  0 0.000 0.172 0.608
#> SRR1047857     5   0.583      1.000 0.220  0 0.000 0.172 0.608
#> SRR1047858     1   0.314      0.627 0.796  0 0.000 0.000 0.204
#> SRR1047859     1   0.314      0.627 0.796  0 0.000 0.000 0.204
#> SRR1047860     1   0.314      0.627 0.796  0 0.000 0.000 0.204
#> SRR1047861     1   0.314      0.627 0.796  0 0.000 0.000 0.204
#> SRR1047863     3   0.000      1.000 0.000  0 1.000 0.000 0.000
#> SRR1047864     3   0.000      1.000 0.000  0 1.000 0.000 0.000
#> SRR1047865     3   0.000      1.000 0.000  0 1.000 0.000 0.000
#> SRR1047866     3   0.000      1.000 0.000  0 1.000 0.000 0.000
#> SRR1047867     3   0.000      1.000 0.000  0 1.000 0.000 0.000
#> SRR1047868     3   0.000      1.000 0.000  0 1.000 0.000 0.000
#> SRR1047869     3   0.000      1.000 0.000  0 1.000 0.000 0.000
#> SRR1047870     3   0.000      1.000 0.000  0 1.000 0.000 0.000
#> SRR1047871     3   0.000      1.000 0.000  0 1.000 0.000 0.000
#> SRR1047872     3   0.000      1.000 0.000  0 1.000 0.000 0.000
#> SRR1047873     3   0.000      1.000 0.000  0 1.000 0.000 0.000
#> SRR1047874     3   0.000      1.000 0.000  0 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1 p2    p3    p4    p5    p6
#> SRR1047813     1   0.000      0.792 1.000  0 0.000 0.000 0.000 0.000
#> SRR1047814     1   0.000      0.792 1.000  0 0.000 0.000 0.000 0.000
#> SRR1047815     1   0.000      0.792 1.000  0 0.000 0.000 0.000 0.000
#> SRR1047816     1   0.000      0.792 1.000  0 0.000 0.000 0.000 0.000
#> SRR1047817     1   0.000      0.792 1.000  0 0.000 0.000 0.000 0.000
#> SRR1047818     4   0.000      1.000 0.000  0 0.000 1.000 0.000 0.000
#> SRR1047819     4   0.000      1.000 0.000  0 0.000 1.000 0.000 0.000
#> SRR1047820     4   0.000      1.000 0.000  0 0.000 1.000 0.000 0.000
#> SRR1047821     4   0.000      1.000 0.000  0 0.000 1.000 0.000 0.000
#> SRR1047822     4   0.000      1.000 0.000  0 0.000 1.000 0.000 0.000
#> SRR1047823     4   0.000      1.000 0.000  0 0.000 1.000 0.000 0.000
#> SRR1047824     4   0.000      1.000 0.000  0 0.000 1.000 0.000 0.000
#> SRR1047825     4   0.000      1.000 0.000  0 0.000 1.000 0.000 0.000
#> SRR1047826     4   0.000      1.000 0.000  0 0.000 1.000 0.000 0.000
#> SRR1047827     4   0.000      1.000 0.000  0 0.000 1.000 0.000 0.000
#> SRR1047828     5   0.543      0.647 0.188  0 0.000 0.000 0.576 0.236
#> SRR1047829     5   0.543      0.647 0.188  0 0.000 0.000 0.576 0.236
#> SRR1047830     5   0.543      0.647 0.188  0 0.000 0.000 0.576 0.236
#> SRR1047831     5   0.543      0.647 0.188  0 0.000 0.000 0.576 0.236
#> SRR1047832     5   0.543      0.647 0.188  0 0.000 0.000 0.576 0.236
#> SRR1047833     2   0.000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> SRR1047834     2   0.000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> SRR1047835     2   0.000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> SRR1047836     2   0.000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> SRR1047837     2   0.000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> SRR1047838     6   0.382      0.531 0.000  0 0.000 0.436 0.000 0.564
#> SRR1047839     6   0.382      0.531 0.000  0 0.000 0.436 0.000 0.564
#> SRR1047840     6   0.382      0.531 0.000  0 0.000 0.436 0.000 0.564
#> SRR1047841     6   0.382      0.531 0.000  0 0.000 0.436 0.000 0.564
#> SRR1047842     6   0.382      0.531 0.000  0 0.000 0.436 0.000 0.564
#> SRR1047843     5   0.000      0.816 0.000  0 0.000 0.000 1.000 0.000
#> SRR1047844     5   0.000      0.816 0.000  0 0.000 0.000 1.000 0.000
#> SRR1047845     5   0.000      0.816 0.000  0 0.000 0.000 1.000 0.000
#> SRR1047846     5   0.000      0.816 0.000  0 0.000 0.000 1.000 0.000
#> SRR1047847     5   0.000      0.816 0.000  0 0.000 0.000 1.000 0.000
#> SRR1047848     1   0.339      0.777 0.704  0 0.000 0.000 0.296 0.000
#> SRR1047849     1   0.339      0.777 0.704  0 0.000 0.000 0.296 0.000
#> SRR1047850     1   0.339      0.777 0.704  0 0.000 0.000 0.296 0.000
#> SRR1047851     1   0.339      0.777 0.704  0 0.000 0.000 0.296 0.000
#> SRR1047852     1   0.339      0.777 0.704  0 0.000 0.000 0.296 0.000
#> SRR1047853     6   0.276      0.630 0.000  0 0.000 0.000 0.196 0.804
#> SRR1047854     6   0.276      0.630 0.000  0 0.000 0.000 0.196 0.804
#> SRR1047855     6   0.276      0.630 0.000  0 0.000 0.000 0.196 0.804
#> SRR1047856     6   0.276      0.630 0.000  0 0.000 0.000 0.196 0.804
#> SRR1047857     6   0.276      0.630 0.000  0 0.000 0.000 0.196 0.804
#> SRR1047858     5   0.000      0.816 0.000  0 0.000 0.000 1.000 0.000
#> SRR1047859     5   0.000      0.816 0.000  0 0.000 0.000 1.000 0.000
#> SRR1047860     5   0.000      0.816 0.000  0 0.000 0.000 1.000 0.000
#> SRR1047861     5   0.000      0.816 0.000  0 0.000 0.000 1.000 0.000
#> SRR1047863     3   0.000      0.954 0.000  0 1.000 0.000 0.000 0.000
#> SRR1047864     3   0.200      0.935 0.000  0 0.884 0.000 0.000 0.116
#> SRR1047865     3   0.200      0.935 0.000  0 0.884 0.000 0.000 0.116
#> SRR1047866     3   0.200      0.935 0.000  0 0.884 0.000 0.000 0.116
#> SRR1047867     3   0.200      0.935 0.000  0 0.884 0.000 0.000 0.116
#> SRR1047868     3   0.000      0.954 0.000  0 1.000 0.000 0.000 0.000
#> SRR1047869     3   0.200      0.935 0.000  0 0.884 0.000 0.000 0.116
#> SRR1047870     3   0.000      0.954 0.000  0 1.000 0.000 0.000 0.000
#> SRR1047871     3   0.000      0.954 0.000  0 1.000 0.000 0.000 0.000
#> SRR1047872     3   0.000      0.954 0.000  0 1.000 0.000 0.000 0.000
#> SRR1047873     3   0.000      0.954 0.000  0 1.000 0.000 0.000 0.000
#> SRR1047874     3   0.000      0.954 0.000  0 1.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

plot of chunk tab-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 17931 rows and 61 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 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-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.895           0.964       0.978         0.2084 0.820   0.820
#> 3 3 0.920           0.942       0.975         1.2291 0.727   0.669
#> 4 4 0.926           0.900       0.963         0.5076 0.732   0.522
#> 5 5 1.000           0.985       0.988         0.1368 0.859   0.559
#> 6 6 0.802           0.632       0.823         0.0386 0.898   0.563

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
#> SRR1047813     1  0.0000      0.976 1.000 0.000
#> SRR1047814     1  0.0000      0.976 1.000 0.000
#> SRR1047815     1  0.0000      0.976 1.000 0.000
#> SRR1047816     1  0.0000      0.976 1.000 0.000
#> SRR1047817     1  0.0000      0.976 1.000 0.000
#> SRR1047818     1  0.0000      0.976 1.000 0.000
#> SRR1047819     1  0.0000      0.976 1.000 0.000
#> SRR1047820     1  0.0000      0.976 1.000 0.000
#> SRR1047821     1  0.0000      0.976 1.000 0.000
#> SRR1047822     1  0.0000      0.976 1.000 0.000
#> SRR1047823     1  0.0000      0.976 1.000 0.000
#> SRR1047824     1  0.0000      0.976 1.000 0.000
#> SRR1047825     1  0.0000      0.976 1.000 0.000
#> SRR1047826     1  0.0000      0.976 1.000 0.000
#> SRR1047827     1  0.0000      0.976 1.000 0.000
#> SRR1047828     1  0.2778      0.948 0.952 0.048
#> SRR1047829     1  0.6148      0.857 0.848 0.152
#> SRR1047830     1  0.5519      0.883 0.872 0.128
#> SRR1047831     1  0.4690      0.910 0.900 0.100
#> SRR1047832     1  0.5946      0.866 0.856 0.144
#> SRR1047833     2  0.0376      0.999 0.004 0.996
#> SRR1047834     2  0.0376      0.999 0.004 0.996
#> SRR1047835     2  0.0376      0.999 0.004 0.996
#> SRR1047836     2  0.0376      0.999 0.004 0.996
#> SRR1047837     2  0.0376      0.999 0.004 0.996
#> SRR1047838     1  0.0000      0.976 1.000 0.000
#> SRR1047839     1  0.0000      0.976 1.000 0.000
#> SRR1047840     1  0.0000      0.976 1.000 0.000
#> SRR1047841     1  0.0000      0.976 1.000 0.000
#> SRR1047842     1  0.0000      0.976 1.000 0.000
#> SRR1047843     1  0.0000      0.976 1.000 0.000
#> SRR1047844     1  0.0000      0.976 1.000 0.000
#> SRR1047845     1  0.0000      0.976 1.000 0.000
#> SRR1047846     1  0.0000      0.976 1.000 0.000
#> SRR1047847     1  0.0000      0.976 1.000 0.000
#> SRR1047848     1  0.0000      0.976 1.000 0.000
#> SRR1047849     1  0.0000      0.976 1.000 0.000
#> SRR1047850     1  0.0000      0.976 1.000 0.000
#> SRR1047851     1  0.0000      0.976 1.000 0.000
#> SRR1047852     1  0.0000      0.976 1.000 0.000
#> SRR1047853     1  0.0000      0.976 1.000 0.000
#> SRR1047854     1  0.0000      0.976 1.000 0.000
#> SRR1047855     1  0.0000      0.976 1.000 0.000
#> SRR1047856     1  0.0000      0.976 1.000 0.000
#> SRR1047857     1  0.0000      0.976 1.000 0.000
#> SRR1047858     1  0.0000      0.976 1.000 0.000
#> SRR1047859     1  0.0000      0.976 1.000 0.000
#> SRR1047860     1  0.0000      0.976 1.000 0.000
#> SRR1047861     1  0.0000      0.976 1.000 0.000
#> SRR1047863     1  0.4690      0.911 0.900 0.100
#> SRR1047864     1  0.4690      0.911 0.900 0.100
#> SRR1047865     1  0.4562      0.914 0.904 0.096
#> SRR1047866     1  0.4562      0.914 0.904 0.096
#> SRR1047867     2  0.0000      0.996 0.000 1.000
#> SRR1047868     1  0.4562      0.914 0.904 0.096
#> SRR1047869     1  0.0376      0.974 0.996 0.004
#> SRR1047870     1  0.4939      0.904 0.892 0.108
#> SRR1047871     1  0.4562      0.914 0.904 0.096
#> SRR1047872     1  0.1633      0.964 0.976 0.024
#> SRR1047873     1  0.0376      0.974 0.996 0.004
#> SRR1047874     1  0.1184      0.968 0.984 0.016

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2   p3
#> SRR1047813     1   0.000      0.972 1.000 0.000 0.00
#> SRR1047814     1   0.000      0.972 1.000 0.000 0.00
#> SRR1047815     1   0.000      0.972 1.000 0.000 0.00
#> SRR1047816     1   0.000      0.972 1.000 0.000 0.00
#> SRR1047817     1   0.000      0.972 1.000 0.000 0.00
#> SRR1047818     1   0.000      0.972 1.000 0.000 0.00
#> SRR1047819     1   0.000      0.972 1.000 0.000 0.00
#> SRR1047820     1   0.000      0.972 1.000 0.000 0.00
#> SRR1047821     1   0.000      0.972 1.000 0.000 0.00
#> SRR1047822     1   0.000      0.972 1.000 0.000 0.00
#> SRR1047823     1   0.000      0.972 1.000 0.000 0.00
#> SRR1047824     1   0.000      0.972 1.000 0.000 0.00
#> SRR1047825     1   0.000      0.972 1.000 0.000 0.00
#> SRR1047826     1   0.000      0.972 1.000 0.000 0.00
#> SRR1047827     1   0.000      0.972 1.000 0.000 0.00
#> SRR1047828     1   0.429      0.790 0.820 0.180 0.00
#> SRR1047829     1   0.571      0.571 0.680 0.320 0.00
#> SRR1047830     1   0.489      0.727 0.772 0.228 0.00
#> SRR1047831     1   0.455      0.765 0.800 0.200 0.00
#> SRR1047832     1   0.493      0.721 0.768 0.232 0.00
#> SRR1047833     2   0.000      1.000 0.000 1.000 0.00
#> SRR1047834     2   0.000      1.000 0.000 1.000 0.00
#> SRR1047835     2   0.000      1.000 0.000 1.000 0.00
#> SRR1047836     2   0.000      1.000 0.000 1.000 0.00
#> SRR1047837     2   0.000      1.000 0.000 1.000 0.00
#> SRR1047838     1   0.000      0.972 1.000 0.000 0.00
#> SRR1047839     1   0.000      0.972 1.000 0.000 0.00
#> SRR1047840     1   0.000      0.972 1.000 0.000 0.00
#> SRR1047841     1   0.000      0.972 1.000 0.000 0.00
#> SRR1047842     1   0.000      0.972 1.000 0.000 0.00
#> SRR1047843     1   0.000      0.972 1.000 0.000 0.00
#> SRR1047844     1   0.000      0.972 1.000 0.000 0.00
#> SRR1047845     1   0.000      0.972 1.000 0.000 0.00
#> SRR1047846     1   0.000      0.972 1.000 0.000 0.00
#> SRR1047847     1   0.000      0.972 1.000 0.000 0.00
#> SRR1047848     1   0.000      0.972 1.000 0.000 0.00
#> SRR1047849     1   0.000      0.972 1.000 0.000 0.00
#> SRR1047850     1   0.000      0.972 1.000 0.000 0.00
#> SRR1047851     1   0.000      0.972 1.000 0.000 0.00
#> SRR1047852     1   0.000      0.972 1.000 0.000 0.00
#> SRR1047853     1   0.000      0.972 1.000 0.000 0.00
#> SRR1047854     1   0.000      0.972 1.000 0.000 0.00
#> SRR1047855     1   0.000      0.972 1.000 0.000 0.00
#> SRR1047856     1   0.000      0.972 1.000 0.000 0.00
#> SRR1047857     1   0.000      0.972 1.000 0.000 0.00
#> SRR1047858     1   0.000      0.972 1.000 0.000 0.00
#> SRR1047859     1   0.000      0.972 1.000 0.000 0.00
#> SRR1047860     1   0.000      0.972 1.000 0.000 0.00
#> SRR1047861     1   0.000      0.972 1.000 0.000 0.00
#> SRR1047863     3   0.000      0.963 0.000 0.000 1.00
#> SRR1047864     3   0.000      0.963 0.000 0.000 1.00
#> SRR1047865     3   0.000      0.963 0.000 0.000 1.00
#> SRR1047866     3   0.000      0.963 0.000 0.000 1.00
#> SRR1047867     3   0.604      0.363 0.000 0.380 0.62
#> SRR1047868     3   0.000      0.963 0.000 0.000 1.00
#> SRR1047869     3   0.000      0.963 0.000 0.000 1.00
#> SRR1047870     3   0.000      0.963 0.000 0.000 1.00
#> SRR1047871     3   0.000      0.963 0.000 0.000 1.00
#> SRR1047872     3   0.000      0.963 0.000 0.000 1.00
#> SRR1047873     3   0.000      0.963 0.000 0.000 1.00
#> SRR1047874     3   0.000      0.963 0.000 0.000 1.00

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1047813     1  0.0000      0.968 1.000 0.000 0.000 0.000
#> SRR1047814     1  0.0000      0.968 1.000 0.000 0.000 0.000
#> SRR1047815     1  0.0000      0.968 1.000 0.000 0.000 0.000
#> SRR1047816     1  0.0000      0.968 1.000 0.000 0.000 0.000
#> SRR1047817     1  0.0000      0.968 1.000 0.000 0.000 0.000
#> SRR1047818     4  0.0000      0.898 0.000 0.000 0.000 1.000
#> SRR1047819     4  0.0000      0.898 0.000 0.000 0.000 1.000
#> SRR1047820     4  0.0000      0.898 0.000 0.000 0.000 1.000
#> SRR1047821     4  0.0000      0.898 0.000 0.000 0.000 1.000
#> SRR1047822     4  0.0000      0.898 0.000 0.000 0.000 1.000
#> SRR1047823     4  0.0000      0.898 0.000 0.000 0.000 1.000
#> SRR1047824     4  0.0000      0.898 0.000 0.000 0.000 1.000
#> SRR1047825     4  0.0000      0.898 0.000 0.000 0.000 1.000
#> SRR1047826     4  0.0000      0.898 0.000 0.000 0.000 1.000
#> SRR1047827     4  0.0000      0.898 0.000 0.000 0.000 1.000
#> SRR1047828     1  0.0000      0.968 1.000 0.000 0.000 0.000
#> SRR1047829     1  0.2589      0.857 0.884 0.116 0.000 0.000
#> SRR1047830     1  0.1118      0.940 0.964 0.036 0.000 0.000
#> SRR1047831     1  0.0336      0.963 0.992 0.008 0.000 0.000
#> SRR1047832     1  0.1716      0.914 0.936 0.064 0.000 0.000
#> SRR1047833     2  0.0000      0.945 0.000 1.000 0.000 0.000
#> SRR1047834     2  0.0000      0.945 0.000 1.000 0.000 0.000
#> SRR1047835     2  0.0000      0.945 0.000 1.000 0.000 0.000
#> SRR1047836     2  0.0000      0.945 0.000 1.000 0.000 0.000
#> SRR1047837     2  0.0000      0.945 0.000 1.000 0.000 0.000
#> SRR1047838     4  0.0000      0.898 0.000 0.000 0.000 1.000
#> SRR1047839     4  0.0000      0.898 0.000 0.000 0.000 1.000
#> SRR1047840     4  0.0000      0.898 0.000 0.000 0.000 1.000
#> SRR1047841     4  0.0000      0.898 0.000 0.000 0.000 1.000
#> SRR1047842     4  0.0000      0.898 0.000 0.000 0.000 1.000
#> SRR1047843     1  0.0000      0.968 1.000 0.000 0.000 0.000
#> SRR1047844     1  0.0000      0.968 1.000 0.000 0.000 0.000
#> SRR1047845     1  0.0000      0.968 1.000 0.000 0.000 0.000
#> SRR1047846     1  0.0000      0.968 1.000 0.000 0.000 0.000
#> SRR1047847     1  0.0000      0.968 1.000 0.000 0.000 0.000
#> SRR1047848     1  0.0000      0.968 1.000 0.000 0.000 0.000
#> SRR1047849     1  0.0000      0.968 1.000 0.000 0.000 0.000
#> SRR1047850     1  0.0000      0.968 1.000 0.000 0.000 0.000
#> SRR1047851     1  0.0000      0.968 1.000 0.000 0.000 0.000
#> SRR1047852     1  0.0000      0.968 1.000 0.000 0.000 0.000
#> SRR1047853     4  0.4730      0.484 0.364 0.000 0.000 0.636
#> SRR1047854     4  0.4985      0.198 0.468 0.000 0.000 0.532
#> SRR1047855     1  0.4925      0.122 0.572 0.000 0.000 0.428
#> SRR1047856     4  0.3486      0.718 0.188 0.000 0.000 0.812
#> SRR1047857     4  0.4564      0.551 0.328 0.000 0.000 0.672
#> SRR1047858     1  0.0188      0.966 0.996 0.000 0.000 0.004
#> SRR1047859     1  0.0188      0.966 0.996 0.000 0.000 0.004
#> SRR1047860     1  0.0188      0.966 0.996 0.000 0.000 0.004
#> SRR1047861     1  0.0188      0.966 0.996 0.000 0.000 0.004
#> SRR1047863     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1047864     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1047865     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1047866     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1047867     2  0.4193      0.634 0.000 0.732 0.268 0.000
#> SRR1047868     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1047869     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1047870     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1047871     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1047872     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1047873     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1047874     3  0.0000      1.000 0.000 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4    p5
#> SRR1047813     5  0.0703      0.968 0.024 0.000 0.000 0.000 0.976
#> SRR1047814     5  0.0703      0.968 0.024 0.000 0.000 0.000 0.976
#> SRR1047815     5  0.0703      0.968 0.024 0.000 0.000 0.000 0.976
#> SRR1047816     5  0.0703      0.968 0.024 0.000 0.000 0.000 0.976
#> SRR1047817     5  0.0703      0.968 0.024 0.000 0.000 0.000 0.976
#> SRR1047818     4  0.0000      0.994 0.000 0.000 0.000 1.000 0.000
#> SRR1047819     4  0.0000      0.994 0.000 0.000 0.000 1.000 0.000
#> SRR1047820     4  0.0000      0.994 0.000 0.000 0.000 1.000 0.000
#> SRR1047821     4  0.0000      0.994 0.000 0.000 0.000 1.000 0.000
#> SRR1047822     4  0.0000      0.994 0.000 0.000 0.000 1.000 0.000
#> SRR1047823     4  0.0324      0.991 0.004 0.000 0.000 0.992 0.004
#> SRR1047824     4  0.0162      0.993 0.000 0.000 0.000 0.996 0.004
#> SRR1047825     4  0.0162      0.993 0.000 0.000 0.000 0.996 0.004
#> SRR1047826     4  0.0000      0.994 0.000 0.000 0.000 1.000 0.000
#> SRR1047827     4  0.0000      0.994 0.000 0.000 0.000 1.000 0.000
#> SRR1047828     5  0.1205      0.961 0.040 0.004 0.000 0.000 0.956
#> SRR1047829     5  0.1399      0.961 0.028 0.020 0.000 0.000 0.952
#> SRR1047830     5  0.1485      0.959 0.032 0.020 0.000 0.000 0.948
#> SRR1047831     5  0.1281      0.962 0.032 0.012 0.000 0.000 0.956
#> SRR1047832     5  0.1661      0.955 0.036 0.024 0.000 0.000 0.940
#> SRR1047833     2  0.0000      0.997 0.000 1.000 0.000 0.000 0.000
#> SRR1047834     2  0.0000      0.997 0.000 1.000 0.000 0.000 0.000
#> SRR1047835     2  0.0000      0.997 0.000 1.000 0.000 0.000 0.000
#> SRR1047836     2  0.0000      0.997 0.000 1.000 0.000 0.000 0.000
#> SRR1047837     2  0.0000      0.997 0.000 1.000 0.000 0.000 0.000
#> SRR1047838     4  0.0865      0.973 0.024 0.000 0.000 0.972 0.004
#> SRR1047839     4  0.0324      0.992 0.004 0.000 0.000 0.992 0.004
#> SRR1047840     4  0.0324      0.992 0.004 0.000 0.000 0.992 0.004
#> SRR1047841     4  0.0324      0.992 0.004 0.000 0.000 0.992 0.004
#> SRR1047842     4  0.0324      0.992 0.004 0.000 0.000 0.992 0.004
#> SRR1047843     1  0.0000      0.995 1.000 0.000 0.000 0.000 0.000
#> SRR1047844     1  0.0000      0.995 1.000 0.000 0.000 0.000 0.000
#> SRR1047845     1  0.0000      0.995 1.000 0.000 0.000 0.000 0.000
#> SRR1047846     1  0.0000      0.995 1.000 0.000 0.000 0.000 0.000
#> SRR1047847     1  0.0000      0.995 1.000 0.000 0.000 0.000 0.000
#> SRR1047848     1  0.0290      0.993 0.992 0.000 0.000 0.000 0.008
#> SRR1047849     1  0.0290      0.993 0.992 0.000 0.000 0.000 0.008
#> SRR1047850     1  0.0290      0.993 0.992 0.000 0.000 0.000 0.008
#> SRR1047851     1  0.0290      0.993 0.992 0.000 0.000 0.000 0.008
#> SRR1047852     1  0.0290      0.993 0.992 0.000 0.000 0.000 0.008
#> SRR1047853     5  0.0807      0.959 0.012 0.000 0.000 0.012 0.976
#> SRR1047854     5  0.0693      0.958 0.008 0.000 0.000 0.012 0.980
#> SRR1047855     5  0.0693      0.960 0.012 0.000 0.000 0.008 0.980
#> SRR1047856     5  0.2358      0.869 0.008 0.000 0.000 0.104 0.888
#> SRR1047857     5  0.1168      0.947 0.008 0.000 0.000 0.032 0.960
#> SRR1047858     1  0.0162      0.994 0.996 0.000 0.000 0.000 0.004
#> SRR1047859     1  0.0162      0.994 0.996 0.000 0.000 0.000 0.004
#> SRR1047860     1  0.0162      0.994 0.996 0.000 0.000 0.000 0.004
#> SRR1047861     1  0.0162      0.994 0.996 0.000 0.000 0.000 0.004
#> SRR1047863     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1047864     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1047865     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1047866     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1047867     2  0.0510      0.984 0.000 0.984 0.016 0.000 0.000
#> SRR1047868     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1047869     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1047870     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1047871     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1047872     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1047873     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1047874     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR1047813     5  0.1007     0.7689 0.000 0.000 0.000 0.000 0.956 0.044
#> SRR1047814     5  0.1007     0.7689 0.000 0.000 0.000 0.000 0.956 0.044
#> SRR1047815     5  0.1007     0.7689 0.000 0.000 0.000 0.000 0.956 0.044
#> SRR1047816     5  0.1007     0.7689 0.000 0.000 0.000 0.000 0.956 0.044
#> SRR1047817     5  0.1007     0.7689 0.000 0.000 0.000 0.000 0.956 0.044
#> SRR1047818     4  0.2300     0.8931 0.000 0.000 0.000 0.856 0.000 0.144
#> SRR1047819     4  0.2178     0.8993 0.000 0.000 0.000 0.868 0.000 0.132
#> SRR1047820     4  0.2219     0.8978 0.000 0.000 0.000 0.864 0.000 0.136
#> SRR1047821     4  0.2178     0.8993 0.000 0.000 0.000 0.868 0.000 0.132
#> SRR1047822     4  0.2454     0.8793 0.000 0.000 0.000 0.840 0.000 0.160
#> SRR1047823     4  0.1307     0.8909 0.032 0.000 0.000 0.952 0.008 0.008
#> SRR1047824     4  0.0748     0.9009 0.016 0.000 0.000 0.976 0.004 0.004
#> SRR1047825     4  0.1116     0.8963 0.028 0.000 0.000 0.960 0.004 0.008
#> SRR1047826     4  0.1003     0.8986 0.028 0.000 0.000 0.964 0.004 0.004
#> SRR1047827     4  0.0951     0.8996 0.020 0.000 0.000 0.968 0.004 0.008
#> SRR1047828     5  0.4381     0.7416 0.036 0.000 0.000 0.072 0.760 0.132
#> SRR1047829     5  0.4088     0.7469 0.004 0.004 0.004 0.080 0.776 0.132
#> SRR1047830     5  0.4276     0.7469 0.020 0.004 0.000 0.076 0.768 0.132
#> SRR1047831     5  0.4114     0.7467 0.012 0.004 0.000 0.080 0.776 0.128
#> SRR1047832     5  0.4514     0.7422 0.032 0.004 0.000 0.080 0.756 0.128
#> SRR1047833     2  0.0000     0.9956 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1047834     2  0.0000     0.9956 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1047835     2  0.0000     0.9956 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1047836     2  0.0000     0.9956 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1047837     2  0.0000     0.9956 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1047838     6  0.4028     0.3655 0.024 0.000 0.000 0.308 0.000 0.668
#> SRR1047839     6  0.3547     0.3691 0.004 0.000 0.000 0.300 0.000 0.696
#> SRR1047840     6  0.3584     0.3583 0.004 0.000 0.000 0.308 0.000 0.688
#> SRR1047841     6  0.3448     0.3990 0.004 0.000 0.000 0.280 0.000 0.716
#> SRR1047842     6  0.3426     0.3986 0.004 0.000 0.000 0.276 0.000 0.720
#> SRR1047843     1  0.4109     0.3904 0.576 0.000 0.000 0.000 0.012 0.412
#> SRR1047844     6  0.4468    -0.3436 0.484 0.000 0.004 0.000 0.020 0.492
#> SRR1047845     1  0.4234     0.3404 0.544 0.000 0.000 0.000 0.016 0.440
#> SRR1047846     1  0.4076     0.4139 0.592 0.000 0.000 0.000 0.012 0.396
#> SRR1047847     1  0.4338     0.2167 0.492 0.000 0.000 0.000 0.020 0.488
#> SRR1047848     1  0.0000     0.6836 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1047849     1  0.0146     0.6832 0.996 0.000 0.000 0.000 0.000 0.004
#> SRR1047850     1  0.0000     0.6836 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1047851     1  0.0000     0.6836 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1047852     1  0.0146     0.6832 0.996 0.000 0.000 0.000 0.000 0.004
#> SRR1047853     6  0.4179    -0.0943 0.000 0.000 0.000 0.012 0.472 0.516
#> SRR1047854     5  0.3997     0.0808 0.000 0.000 0.000 0.004 0.508 0.488
#> SRR1047855     5  0.3996     0.0874 0.000 0.000 0.000 0.004 0.512 0.484
#> SRR1047856     6  0.4466     0.2179 0.000 0.000 0.000 0.044 0.336 0.620
#> SRR1047857     6  0.4026     0.1514 0.000 0.000 0.000 0.012 0.376 0.612
#> SRR1047858     6  0.4338    -0.2709 0.484 0.000 0.000 0.000 0.020 0.496
#> SRR1047859     6  0.4335    -0.2515 0.472 0.000 0.000 0.000 0.020 0.508
#> SRR1047860     6  0.4336    -0.2562 0.476 0.000 0.000 0.000 0.020 0.504
#> SRR1047861     6  0.4336    -0.2562 0.476 0.000 0.000 0.000 0.020 0.504
#> SRR1047863     3  0.0000     0.9644 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1047864     3  0.0000     0.9644 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1047865     3  0.0000     0.9644 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1047866     3  0.0000     0.9644 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1047867     2  0.0547     0.9779 0.000 0.980 0.020 0.000 0.000 0.000
#> SRR1047868     3  0.0000     0.9644 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1047869     3  0.0000     0.9644 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1047870     3  0.0000     0.9644 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1047871     3  0.0000     0.9644 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1047872     3  0.2823     0.7835 0.000 0.000 0.796 0.000 0.000 0.204
#> SRR1047873     3  0.2092     0.8687 0.000 0.000 0.876 0.000 0.000 0.124
#> SRR1047874     3  0.0363     0.9576 0.000 0.000 0.988 0.000 0.000 0.012

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

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

collect_plots(res)

plot of chunk MAD-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.977       0.984          0.167 0.847   0.847
#> 3 3 1.000           0.988       0.994          1.655 0.711   0.659
#> 4 4 0.757           0.934       0.948          0.119 0.989   0.980
#> 5 5 0.893           0.959       0.983          0.433 0.738   0.521
#> 6 6 0.893           0.959       0.983          0.016 0.989   0.960

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette    p1    p2
#> SRR1047813     1   0.000      0.986 1.000 0.000
#> SRR1047814     1   0.000      0.986 1.000 0.000
#> SRR1047815     1   0.000      0.986 1.000 0.000
#> SRR1047816     1   0.000      0.986 1.000 0.000
#> SRR1047817     1   0.000      0.986 1.000 0.000
#> SRR1047818     1   0.000      0.986 1.000 0.000
#> SRR1047819     1   0.000      0.986 1.000 0.000
#> SRR1047820     1   0.000      0.986 1.000 0.000
#> SRR1047821     1   0.000      0.986 1.000 0.000
#> SRR1047822     1   0.000      0.986 1.000 0.000
#> SRR1047823     1   0.000      0.986 1.000 0.000
#> SRR1047824     1   0.000      0.986 1.000 0.000
#> SRR1047825     1   0.000      0.986 1.000 0.000
#> SRR1047826     1   0.000      0.986 1.000 0.000
#> SRR1047827     1   0.000      0.986 1.000 0.000
#> SRR1047828     1   0.000      0.986 1.000 0.000
#> SRR1047829     1   0.000      0.986 1.000 0.000
#> SRR1047830     1   0.000      0.986 1.000 0.000
#> SRR1047831     1   0.000      0.986 1.000 0.000
#> SRR1047832     1   0.000      0.986 1.000 0.000
#> SRR1047833     2   0.260      1.000 0.044 0.956
#> SRR1047834     2   0.260      1.000 0.044 0.956
#> SRR1047835     2   0.260      1.000 0.044 0.956
#> SRR1047836     2   0.260      1.000 0.044 0.956
#> SRR1047837     2   0.260      1.000 0.044 0.956
#> SRR1047838     1   0.000      0.986 1.000 0.000
#> SRR1047839     1   0.000      0.986 1.000 0.000
#> SRR1047840     1   0.000      0.986 1.000 0.000
#> SRR1047841     1   0.000      0.986 1.000 0.000
#> SRR1047842     1   0.000      0.986 1.000 0.000
#> SRR1047843     1   0.000      0.986 1.000 0.000
#> SRR1047844     1   0.000      0.986 1.000 0.000
#> SRR1047845     1   0.000      0.986 1.000 0.000
#> SRR1047846     1   0.000      0.986 1.000 0.000
#> SRR1047847     1   0.000      0.986 1.000 0.000
#> SRR1047848     1   0.000      0.986 1.000 0.000
#> SRR1047849     1   0.000      0.986 1.000 0.000
#> SRR1047850     1   0.000      0.986 1.000 0.000
#> SRR1047851     1   0.000      0.986 1.000 0.000
#> SRR1047852     1   0.000      0.986 1.000 0.000
#> SRR1047853     1   0.000      0.986 1.000 0.000
#> SRR1047854     1   0.000      0.986 1.000 0.000
#> SRR1047855     1   0.000      0.986 1.000 0.000
#> SRR1047856     1   0.000      0.986 1.000 0.000
#> SRR1047857     1   0.000      0.986 1.000 0.000
#> SRR1047858     1   0.000      0.986 1.000 0.000
#> SRR1047859     1   0.000      0.986 1.000 0.000
#> SRR1047860     1   0.000      0.986 1.000 0.000
#> SRR1047861     1   0.000      0.986 1.000 0.000
#> SRR1047863     1   0.260      0.957 0.956 0.044
#> SRR1047864     1   0.595      0.832 0.856 0.144
#> SRR1047865     1   0.260      0.957 0.956 0.044
#> SRR1047866     1   0.260      0.957 0.956 0.044
#> SRR1047867     1   0.595      0.832 0.856 0.144
#> SRR1047868     1   0.260      0.957 0.956 0.044
#> SRR1047869     1   0.260      0.957 0.956 0.044
#> SRR1047870     1   0.260      0.957 0.956 0.044
#> SRR1047871     1   0.260      0.957 0.956 0.044
#> SRR1047872     1   0.260      0.957 0.956 0.044
#> SRR1047873     1   0.260      0.957 0.956 0.044
#> SRR1047874     1   0.260      0.957 0.956 0.044

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette p1   p2   p3
#> SRR1047813     1   0.000      1.000  1 0.00 0.00
#> SRR1047814     1   0.000      1.000  1 0.00 0.00
#> SRR1047815     1   0.000      1.000  1 0.00 0.00
#> SRR1047816     1   0.000      1.000  1 0.00 0.00
#> SRR1047817     1   0.000      1.000  1 0.00 0.00
#> SRR1047818     1   0.000      1.000  1 0.00 0.00
#> SRR1047819     1   0.000      1.000  1 0.00 0.00
#> SRR1047820     1   0.000      1.000  1 0.00 0.00
#> SRR1047821     1   0.000      1.000  1 0.00 0.00
#> SRR1047822     1   0.000      1.000  1 0.00 0.00
#> SRR1047823     1   0.000      1.000  1 0.00 0.00
#> SRR1047824     1   0.000      1.000  1 0.00 0.00
#> SRR1047825     1   0.000      1.000  1 0.00 0.00
#> SRR1047826     1   0.000      1.000  1 0.00 0.00
#> SRR1047827     1   0.000      1.000  1 0.00 0.00
#> SRR1047828     1   0.000      1.000  1 0.00 0.00
#> SRR1047829     1   0.000      1.000  1 0.00 0.00
#> SRR1047830     1   0.000      1.000  1 0.00 0.00
#> SRR1047831     1   0.000      1.000  1 0.00 0.00
#> SRR1047832     1   0.000      1.000  1 0.00 0.00
#> SRR1047833     2   0.000      1.000  0 1.00 0.00
#> SRR1047834     2   0.000      1.000  0 1.00 0.00
#> SRR1047835     2   0.000      1.000  0 1.00 0.00
#> SRR1047836     2   0.000      1.000  0 1.00 0.00
#> SRR1047837     2   0.000      1.000  0 1.00 0.00
#> SRR1047838     1   0.000      1.000  1 0.00 0.00
#> SRR1047839     1   0.000      1.000  1 0.00 0.00
#> SRR1047840     1   0.000      1.000  1 0.00 0.00
#> SRR1047841     1   0.000      1.000  1 0.00 0.00
#> SRR1047842     1   0.000      1.000  1 0.00 0.00
#> SRR1047843     1   0.000      1.000  1 0.00 0.00
#> SRR1047844     1   0.000      1.000  1 0.00 0.00
#> SRR1047845     1   0.000      1.000  1 0.00 0.00
#> SRR1047846     1   0.000      1.000  1 0.00 0.00
#> SRR1047847     1   0.000      1.000  1 0.00 0.00
#> SRR1047848     1   0.000      1.000  1 0.00 0.00
#> SRR1047849     1   0.000      1.000  1 0.00 0.00
#> SRR1047850     1   0.000      1.000  1 0.00 0.00
#> SRR1047851     1   0.000      1.000  1 0.00 0.00
#> SRR1047852     1   0.000      1.000  1 0.00 0.00
#> SRR1047853     1   0.000      1.000  1 0.00 0.00
#> SRR1047854     1   0.000      1.000  1 0.00 0.00
#> SRR1047855     1   0.000      1.000  1 0.00 0.00
#> SRR1047856     1   0.000      1.000  1 0.00 0.00
#> SRR1047857     1   0.000      1.000  1 0.00 0.00
#> SRR1047858     1   0.000      1.000  1 0.00 0.00
#> SRR1047859     1   0.000      1.000  1 0.00 0.00
#> SRR1047860     1   0.000      1.000  1 0.00 0.00
#> SRR1047861     1   0.000      1.000  1 0.00 0.00
#> SRR1047863     3   0.000      0.966  0 0.00 1.00
#> SRR1047864     3   0.429      0.800  0 0.18 0.82
#> SRR1047865     3   0.000      0.966  0 0.00 1.00
#> SRR1047866     3   0.000      0.966  0 0.00 1.00
#> SRR1047867     3   0.429      0.800  0 0.18 0.82
#> SRR1047868     3   0.000      0.966  0 0.00 1.00
#> SRR1047869     3   0.000      0.966  0 0.00 1.00
#> SRR1047870     3   0.000      0.966  0 0.00 1.00
#> SRR1047871     3   0.000      0.966  0 0.00 1.00
#> SRR1047872     3   0.000      0.966  0 0.00 1.00
#> SRR1047873     3   0.000      0.966  0 0.00 1.00
#> SRR1047874     3   0.000      0.966  0 0.00 1.00

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1   p2    p3    p4
#> SRR1047813     1  0.0000      0.934 1.000 0.00 0.000 0.000
#> SRR1047814     1  0.0000      0.934 1.000 0.00 0.000 0.000
#> SRR1047815     1  0.0000      0.934 1.000 0.00 0.000 0.000
#> SRR1047816     1  0.0000      0.934 1.000 0.00 0.000 0.000
#> SRR1047817     1  0.0000      0.934 1.000 0.00 0.000 0.000
#> SRR1047818     1  0.3583      0.864 0.816 0.18 0.000 0.004
#> SRR1047819     1  0.3583      0.864 0.816 0.18 0.000 0.004
#> SRR1047820     1  0.3583      0.864 0.816 0.18 0.000 0.004
#> SRR1047821     1  0.3583      0.864 0.816 0.18 0.000 0.004
#> SRR1047822     1  0.3583      0.864 0.816 0.18 0.000 0.004
#> SRR1047823     1  0.3583      0.864 0.816 0.18 0.000 0.004
#> SRR1047824     1  0.3583      0.864 0.816 0.18 0.000 0.004
#> SRR1047825     1  0.3583      0.864 0.816 0.18 0.000 0.004
#> SRR1047826     1  0.3583      0.864 0.816 0.18 0.000 0.004
#> SRR1047827     1  0.3583      0.864 0.816 0.18 0.000 0.004
#> SRR1047828     1  0.0000      0.934 1.000 0.00 0.000 0.000
#> SRR1047829     1  0.0000      0.934 1.000 0.00 0.000 0.000
#> SRR1047830     1  0.0000      0.934 1.000 0.00 0.000 0.000
#> SRR1047831     1  0.0000      0.934 1.000 0.00 0.000 0.000
#> SRR1047832     1  0.0000      0.934 1.000 0.00 0.000 0.000
#> SRR1047833     2  0.3400      1.000 0.000 0.82 0.000 0.180
#> SRR1047834     2  0.3400      1.000 0.000 0.82 0.000 0.180
#> SRR1047835     2  0.3400      1.000 0.000 0.82 0.000 0.180
#> SRR1047836     2  0.3400      1.000 0.000 0.82 0.000 0.180
#> SRR1047837     2  0.3400      1.000 0.000 0.82 0.000 0.180
#> SRR1047838     1  0.3583      0.864 0.816 0.18 0.000 0.004
#> SRR1047839     1  0.3583      0.864 0.816 0.18 0.000 0.004
#> SRR1047840     1  0.3583      0.864 0.816 0.18 0.000 0.004
#> SRR1047841     1  0.3583      0.864 0.816 0.18 0.000 0.004
#> SRR1047842     1  0.3583      0.864 0.816 0.18 0.000 0.004
#> SRR1047843     1  0.0000      0.934 1.000 0.00 0.000 0.000
#> SRR1047844     1  0.0000      0.934 1.000 0.00 0.000 0.000
#> SRR1047845     1  0.0000      0.934 1.000 0.00 0.000 0.000
#> SRR1047846     1  0.0000      0.934 1.000 0.00 0.000 0.000
#> SRR1047847     1  0.0000      0.934 1.000 0.00 0.000 0.000
#> SRR1047848     1  0.0000      0.934 1.000 0.00 0.000 0.000
#> SRR1047849     1  0.0000      0.934 1.000 0.00 0.000 0.000
#> SRR1047850     1  0.0000      0.934 1.000 0.00 0.000 0.000
#> SRR1047851     1  0.0000      0.934 1.000 0.00 0.000 0.000
#> SRR1047852     1  0.0000      0.934 1.000 0.00 0.000 0.000
#> SRR1047853     1  0.0000      0.934 1.000 0.00 0.000 0.000
#> SRR1047854     1  0.0000      0.934 1.000 0.00 0.000 0.000
#> SRR1047855     1  0.0000      0.934 1.000 0.00 0.000 0.000
#> SRR1047856     1  0.0000      0.934 1.000 0.00 0.000 0.000
#> SRR1047857     1  0.0000      0.934 1.000 0.00 0.000 0.000
#> SRR1047858     1  0.0000      0.934 1.000 0.00 0.000 0.000
#> SRR1047859     1  0.0000      0.934 1.000 0.00 0.000 0.000
#> SRR1047860     1  0.0000      0.934 1.000 0.00 0.000 0.000
#> SRR1047861     1  0.0000      0.934 1.000 0.00 0.000 0.000
#> SRR1047863     3  0.0592      0.987 0.000 0.00 0.984 0.016
#> SRR1047864     4  0.0188      1.000 0.000 0.00 0.004 0.996
#> SRR1047865     3  0.0000      0.995 0.000 0.00 1.000 0.000
#> SRR1047866     3  0.0000      0.995 0.000 0.00 1.000 0.000
#> SRR1047867     4  0.0188      1.000 0.000 0.00 0.004 0.996
#> SRR1047868     3  0.0000      0.995 0.000 0.00 1.000 0.000
#> SRR1047869     3  0.0000      0.995 0.000 0.00 1.000 0.000
#> SRR1047870     3  0.0592      0.987 0.000 0.00 0.984 0.016
#> SRR1047871     3  0.0592      0.987 0.000 0.00 0.984 0.016
#> SRR1047872     3  0.0000      0.995 0.000 0.00 1.000 0.000
#> SRR1047873     3  0.0000      0.995 0.000 0.00 1.000 0.000
#> SRR1047874     3  0.0000      0.995 0.000 0.00 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette  p1 p2    p3  p4    p5
#> SRR1047813     1  0.0000      1.000 1.0  0 0.000 0.0 0.000
#> SRR1047814     1  0.0000      1.000 1.0  0 0.000 0.0 0.000
#> SRR1047815     1  0.0000      1.000 1.0  0 0.000 0.0 0.000
#> SRR1047816     1  0.0000      1.000 1.0  0 0.000 0.0 0.000
#> SRR1047817     1  0.0000      1.000 1.0  0 0.000 0.0 0.000
#> SRR1047818     4  0.0000      0.922 0.0  0 0.000 1.0 0.000
#> SRR1047819     4  0.0000      0.922 0.0  0 0.000 1.0 0.000
#> SRR1047820     4  0.0000      0.922 0.0  0 0.000 1.0 0.000
#> SRR1047821     4  0.0000      0.922 0.0  0 0.000 1.0 0.000
#> SRR1047822     4  0.0000      0.922 0.0  0 0.000 1.0 0.000
#> SRR1047823     4  0.0000      0.922 0.0  0 0.000 1.0 0.000
#> SRR1047824     4  0.0000      0.922 0.0  0 0.000 1.0 0.000
#> SRR1047825     4  0.0000      0.922 0.0  0 0.000 1.0 0.000
#> SRR1047826     4  0.0000      0.922 0.0  0 0.000 1.0 0.000
#> SRR1047827     4  0.0000      0.922 0.0  0 0.000 1.0 0.000
#> SRR1047828     1  0.0000      1.000 1.0  0 0.000 0.0 0.000
#> SRR1047829     1  0.0000      1.000 1.0  0 0.000 0.0 0.000
#> SRR1047830     1  0.0000      1.000 1.0  0 0.000 0.0 0.000
#> SRR1047831     1  0.0000      1.000 1.0  0 0.000 0.0 0.000
#> SRR1047832     1  0.0000      1.000 1.0  0 0.000 0.0 0.000
#> SRR1047833     2  0.0000      1.000 0.0  1 0.000 0.0 0.000
#> SRR1047834     2  0.0000      1.000 0.0  1 0.000 0.0 0.000
#> SRR1047835     2  0.0000      1.000 0.0  1 0.000 0.0 0.000
#> SRR1047836     2  0.0000      1.000 0.0  1 0.000 0.0 0.000
#> SRR1047837     2  0.0000      1.000 0.0  1 0.000 0.0 0.000
#> SRR1047838     4  0.0000      0.922 0.0  0 0.000 1.0 0.000
#> SRR1047839     4  0.0000      0.922 0.0  0 0.000 1.0 0.000
#> SRR1047840     4  0.0000      0.922 0.0  0 0.000 1.0 0.000
#> SRR1047841     4  0.0000      0.922 0.0  0 0.000 1.0 0.000
#> SRR1047842     4  0.0000      0.922 0.0  0 0.000 1.0 0.000
#> SRR1047843     1  0.0000      1.000 1.0  0 0.000 0.0 0.000
#> SRR1047844     1  0.0000      1.000 1.0  0 0.000 0.0 0.000
#> SRR1047845     1  0.0000      1.000 1.0  0 0.000 0.0 0.000
#> SRR1047846     1  0.0000      1.000 1.0  0 0.000 0.0 0.000
#> SRR1047847     1  0.0000      1.000 1.0  0 0.000 0.0 0.000
#> SRR1047848     1  0.0000      1.000 1.0  0 0.000 0.0 0.000
#> SRR1047849     1  0.0000      1.000 1.0  0 0.000 0.0 0.000
#> SRR1047850     1  0.0000      1.000 1.0  0 0.000 0.0 0.000
#> SRR1047851     1  0.0000      1.000 1.0  0 0.000 0.0 0.000
#> SRR1047852     1  0.0000      1.000 1.0  0 0.000 0.0 0.000
#> SRR1047853     4  0.3109      0.750 0.2  0 0.000 0.8 0.000
#> SRR1047854     4  0.3109      0.750 0.2  0 0.000 0.8 0.000
#> SRR1047855     4  0.3109      0.750 0.2  0 0.000 0.8 0.000
#> SRR1047856     4  0.3109      0.750 0.2  0 0.000 0.8 0.000
#> SRR1047857     4  0.3109      0.750 0.2  0 0.000 0.8 0.000
#> SRR1047858     1  0.0000      1.000 1.0  0 0.000 0.0 0.000
#> SRR1047859     1  0.0000      1.000 1.0  0 0.000 0.0 0.000
#> SRR1047860     1  0.0000      1.000 1.0  0 0.000 0.0 0.000
#> SRR1047861     1  0.0000      1.000 1.0  0 0.000 0.0 0.000
#> SRR1047863     3  0.0510      0.987 0.0  0 0.984 0.0 0.016
#> SRR1047864     5  0.0000      1.000 0.0  0 0.000 0.0 1.000
#> SRR1047865     3  0.0162      0.993 0.0  0 0.996 0.0 0.004
#> SRR1047866     3  0.0162      0.993 0.0  0 0.996 0.0 0.004
#> SRR1047867     5  0.0000      1.000 0.0  0 0.000 0.0 1.000
#> SRR1047868     3  0.0000      0.993 0.0  0 1.000 0.0 0.000
#> SRR1047869     3  0.0162      0.993 0.0  0 0.996 0.0 0.004
#> SRR1047870     3  0.0510      0.987 0.0  0 0.984 0.0 0.016
#> SRR1047871     3  0.0510      0.987 0.0  0 0.984 0.0 0.016
#> SRR1047872     3  0.0000      0.993 0.0  0 1.000 0.0 0.000
#> SRR1047873     3  0.0000      0.993 0.0  0 1.000 0.0 0.000
#> SRR1047874     3  0.0000      0.993 0.0  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
#> SRR1047813     1  0.0000      1.000 1.0  0 0.000 0.0 0.000  0
#> SRR1047814     1  0.0000      1.000 1.0  0 0.000 0.0 0.000  0
#> SRR1047815     1  0.0000      1.000 1.0  0 0.000 0.0 0.000  0
#> SRR1047816     1  0.0000      1.000 1.0  0 0.000 0.0 0.000  0
#> SRR1047817     1  0.0000      1.000 1.0  0 0.000 0.0 0.000  0
#> SRR1047818     4  0.0000      0.922 0.0  0 0.000 1.0 0.000  0
#> SRR1047819     4  0.0000      0.922 0.0  0 0.000 1.0 0.000  0
#> SRR1047820     4  0.0000      0.922 0.0  0 0.000 1.0 0.000  0
#> SRR1047821     4  0.0000      0.922 0.0  0 0.000 1.0 0.000  0
#> SRR1047822     4  0.0000      0.922 0.0  0 0.000 1.0 0.000  0
#> SRR1047823     4  0.0000      0.922 0.0  0 0.000 1.0 0.000  0
#> SRR1047824     4  0.0000      0.922 0.0  0 0.000 1.0 0.000  0
#> SRR1047825     4  0.0000      0.922 0.0  0 0.000 1.0 0.000  0
#> SRR1047826     4  0.0000      0.922 0.0  0 0.000 1.0 0.000  0
#> SRR1047827     4  0.0000      0.922 0.0  0 0.000 1.0 0.000  0
#> SRR1047828     1  0.0000      1.000 1.0  0 0.000 0.0 0.000  0
#> SRR1047829     1  0.0000      1.000 1.0  0 0.000 0.0 0.000  0
#> SRR1047830     1  0.0000      1.000 1.0  0 0.000 0.0 0.000  0
#> SRR1047831     1  0.0000      1.000 1.0  0 0.000 0.0 0.000  0
#> SRR1047832     1  0.0000      1.000 1.0  0 0.000 0.0 0.000  0
#> SRR1047833     2  0.0000      1.000 0.0  1 0.000 0.0 0.000  0
#> SRR1047834     2  0.0000      1.000 0.0  1 0.000 0.0 0.000  0
#> SRR1047835     2  0.0000      1.000 0.0  1 0.000 0.0 0.000  0
#> SRR1047836     2  0.0000      1.000 0.0  1 0.000 0.0 0.000  0
#> SRR1047837     2  0.0000      1.000 0.0  1 0.000 0.0 0.000  0
#> SRR1047838     4  0.0000      0.922 0.0  0 0.000 1.0 0.000  0
#> SRR1047839     4  0.0000      0.922 0.0  0 0.000 1.0 0.000  0
#> SRR1047840     4  0.0000      0.922 0.0  0 0.000 1.0 0.000  0
#> SRR1047841     4  0.0000      0.922 0.0  0 0.000 1.0 0.000  0
#> SRR1047842     4  0.0000      0.922 0.0  0 0.000 1.0 0.000  0
#> SRR1047843     1  0.0000      1.000 1.0  0 0.000 0.0 0.000  0
#> SRR1047844     1  0.0000      1.000 1.0  0 0.000 0.0 0.000  0
#> SRR1047845     1  0.0000      1.000 1.0  0 0.000 0.0 0.000  0
#> SRR1047846     1  0.0000      1.000 1.0  0 0.000 0.0 0.000  0
#> SRR1047847     1  0.0000      1.000 1.0  0 0.000 0.0 0.000  0
#> SRR1047848     1  0.0000      1.000 1.0  0 0.000 0.0 0.000  0
#> SRR1047849     1  0.0000      1.000 1.0  0 0.000 0.0 0.000  0
#> SRR1047850     1  0.0000      1.000 1.0  0 0.000 0.0 0.000  0
#> SRR1047851     1  0.0000      1.000 1.0  0 0.000 0.0 0.000  0
#> SRR1047852     1  0.0000      1.000 1.0  0 0.000 0.0 0.000  0
#> SRR1047853     4  0.2793      0.750 0.2  0 0.000 0.8 0.000  0
#> SRR1047854     4  0.2793      0.750 0.2  0 0.000 0.8 0.000  0
#> SRR1047855     4  0.2793      0.750 0.2  0 0.000 0.8 0.000  0
#> SRR1047856     4  0.2793      0.750 0.2  0 0.000 0.8 0.000  0
#> SRR1047857     4  0.2793      0.750 0.2  0 0.000 0.8 0.000  0
#> SRR1047858     1  0.0000      1.000 1.0  0 0.000 0.0 0.000  0
#> SRR1047859     1  0.0000      1.000 1.0  0 0.000 0.0 0.000  0
#> SRR1047860     1  0.0000      1.000 1.0  0 0.000 0.0 0.000  0
#> SRR1047861     1  0.0000      1.000 1.0  0 0.000 0.0 0.000  0
#> SRR1047863     3  0.0458      0.989 0.0  0 0.984 0.0 0.016  0
#> SRR1047864     5  0.0000      1.000 0.0  0 0.000 0.0 1.000  0
#> SRR1047865     6  0.0000      1.000 0.0  0 0.000 0.0 0.000  1
#> SRR1047866     6  0.0000      1.000 0.0  0 0.000 0.0 0.000  1
#> SRR1047867     5  0.0000      1.000 0.0  0 0.000 0.0 1.000  0
#> SRR1047868     3  0.0000      0.992 0.0  0 1.000 0.0 0.000  0
#> SRR1047869     6  0.0000      1.000 0.0  0 0.000 0.0 0.000  1
#> SRR1047870     3  0.0458      0.989 0.0  0 0.984 0.0 0.016  0
#> SRR1047871     3  0.0458      0.989 0.0  0 0.984 0.0 0.016  0
#> SRR1047872     3  0.0000      0.992 0.0  0 1.000 0.0 0.000  0
#> SRR1047873     3  0.0000      0.992 0.0  0 1.000 0.0 0.000  0
#> SRR1047874     3  0.0000      0.992 0.0  0 1.000 0.0 0.000  0

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

consensus_heatmap(res, k = 2)

plot of chunk tab-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 17931 rows and 61 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 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-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.163           0.486       0.774         0.3537 0.744   0.744
#> 3 3 0.255           0.577       0.679         0.6079 0.578   0.464
#> 4 4 0.659           0.910       0.895         0.2105 0.847   0.642
#> 5 5 0.723           0.811       0.838         0.0932 1.000   1.000
#> 6 6 0.728           0.594       0.679         0.0560 0.885   0.613

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

suggest_best_k(res)
#> [1] 4

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette    p1    p2
#> SRR1047813     1   0.469     0.5847 0.900 0.100
#> SRR1047814     1   0.469     0.5847 0.900 0.100
#> SRR1047815     1   0.469     0.5847 0.900 0.100
#> SRR1047816     1   0.469     0.5847 0.900 0.100
#> SRR1047817     1   0.469     0.5847 0.900 0.100
#> SRR1047818     1   0.936     0.5170 0.648 0.352
#> SRR1047819     1   0.936     0.5170 0.648 0.352
#> SRR1047820     1   0.936     0.5170 0.648 0.352
#> SRR1047821     1   0.936     0.5170 0.648 0.352
#> SRR1047822     1   0.936     0.5170 0.648 0.352
#> SRR1047823     1   0.895     0.5450 0.688 0.312
#> SRR1047824     1   0.895     0.5450 0.688 0.312
#> SRR1047825     1   0.895     0.5450 0.688 0.312
#> SRR1047826     1   0.895     0.5450 0.688 0.312
#> SRR1047827     1   0.895     0.5450 0.688 0.312
#> SRR1047828     1   0.634     0.6134 0.840 0.160
#> SRR1047829     1   0.634     0.6134 0.840 0.160
#> SRR1047830     1   0.634     0.6134 0.840 0.160
#> SRR1047831     1   0.634     0.6134 0.840 0.160
#> SRR1047832     1   0.634     0.6134 0.840 0.160
#> SRR1047833     2   0.827     0.6622 0.260 0.740
#> SRR1047834     2   0.827     0.6622 0.260 0.740
#> SRR1047835     2   0.827     0.6622 0.260 0.740
#> SRR1047836     2   0.827     0.6622 0.260 0.740
#> SRR1047837     2   0.827     0.6622 0.260 0.740
#> SRR1047838     1   0.866     0.5832 0.712 0.288
#> SRR1047839     1   0.866     0.5832 0.712 0.288
#> SRR1047840     1   0.866     0.5832 0.712 0.288
#> SRR1047841     1   0.866     0.5832 0.712 0.288
#> SRR1047842     1   0.866     0.5832 0.712 0.288
#> SRR1047843     1   0.278     0.6360 0.952 0.048
#> SRR1047844     1   0.295     0.6348 0.948 0.052
#> SRR1047845     1   0.278     0.6360 0.952 0.048
#> SRR1047846     1   0.278     0.6360 0.952 0.048
#> SRR1047847     1   0.295     0.6348 0.948 0.052
#> SRR1047848     1   0.388     0.6071 0.924 0.076
#> SRR1047849     1   0.388     0.6071 0.924 0.076
#> SRR1047850     1   0.388     0.6071 0.924 0.076
#> SRR1047851     1   0.388     0.6071 0.924 0.076
#> SRR1047852     1   0.388     0.6071 0.924 0.076
#> SRR1047853     1   0.745     0.6099 0.788 0.212
#> SRR1047854     1   0.745     0.6099 0.788 0.212
#> SRR1047855     1   0.745     0.6099 0.788 0.212
#> SRR1047856     1   0.745     0.6099 0.788 0.212
#> SRR1047857     1   0.745     0.6099 0.788 0.212
#> SRR1047858     1   0.000     0.6417 1.000 0.000
#> SRR1047859     1   0.000     0.6417 1.000 0.000
#> SRR1047860     1   0.000     0.6417 1.000 0.000
#> SRR1047861     1   0.000     0.6417 1.000 0.000
#> SRR1047863     1   1.000    -0.0895 0.508 0.492
#> SRR1047864     2   0.999     0.0379 0.480 0.520
#> SRR1047865     1   0.949     0.0689 0.632 0.368
#> SRR1047866     1   0.952     0.0641 0.628 0.372
#> SRR1047867     2   0.456     0.5579 0.096 0.904
#> SRR1047868     1   1.000    -0.0868 0.508 0.492
#> SRR1047869     1   0.949     0.0689 0.632 0.368
#> SRR1047870     2   1.000    -0.0301 0.496 0.504
#> SRR1047871     1   0.998    -0.0670 0.524 0.476
#> SRR1047872     2   1.000    -0.0350 0.500 0.500
#> SRR1047873     1   1.000    -0.0868 0.508 0.492
#> SRR1047874     1   1.000    -0.0868 0.508 0.492

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1047813     1  0.6742     0.7455 0.708 0.052 0.240
#> SRR1047814     1  0.6742     0.7455 0.708 0.052 0.240
#> SRR1047815     1  0.6742     0.7455 0.708 0.052 0.240
#> SRR1047816     1  0.6742     0.7455 0.708 0.052 0.240
#> SRR1047817     1  0.6742     0.7455 0.708 0.052 0.240
#> SRR1047818     3  0.0237     0.6718 0.000 0.004 0.996
#> SRR1047819     3  0.0237     0.6718 0.000 0.004 0.996
#> SRR1047820     3  0.0237     0.6718 0.000 0.004 0.996
#> SRR1047821     3  0.0237     0.6718 0.000 0.004 0.996
#> SRR1047822     3  0.0237     0.6718 0.000 0.004 0.996
#> SRR1047823     3  0.3845     0.5447 0.116 0.012 0.872
#> SRR1047824     3  0.3845     0.5447 0.116 0.012 0.872
#> SRR1047825     3  0.3845     0.5447 0.116 0.012 0.872
#> SRR1047826     3  0.3845     0.5447 0.116 0.012 0.872
#> SRR1047827     3  0.3845     0.5447 0.116 0.012 0.872
#> SRR1047828     1  0.7600     0.6885 0.600 0.056 0.344
#> SRR1047829     1  0.7600     0.6885 0.600 0.056 0.344
#> SRR1047830     1  0.7600     0.6885 0.600 0.056 0.344
#> SRR1047831     1  0.7600     0.6885 0.600 0.056 0.344
#> SRR1047832     1  0.7600     0.6885 0.600 0.056 0.344
#> SRR1047833     2  0.7319     0.8899 0.128 0.708 0.164
#> SRR1047834     2  0.7319     0.8899 0.128 0.708 0.164
#> SRR1047835     2  0.7319     0.8899 0.128 0.708 0.164
#> SRR1047836     2  0.7319     0.8899 0.128 0.708 0.164
#> SRR1047837     2  0.7319     0.8899 0.128 0.708 0.164
#> SRR1047838     3  0.0237     0.6704 0.004 0.000 0.996
#> SRR1047839     3  0.0000     0.6715 0.000 0.000 1.000
#> SRR1047840     3  0.0237     0.6704 0.004 0.000 0.996
#> SRR1047841     3  0.0237     0.6704 0.004 0.000 0.996
#> SRR1047842     3  0.0237     0.6704 0.004 0.000 0.996
#> SRR1047843     1  0.5835     0.7016 0.660 0.000 0.340
#> SRR1047844     1  0.6215     0.5876 0.572 0.000 0.428
#> SRR1047845     1  0.5835     0.7016 0.660 0.000 0.340
#> SRR1047846     1  0.5835     0.7016 0.660 0.000 0.340
#> SRR1047847     1  0.6215     0.5876 0.572 0.000 0.428
#> SRR1047848     1  0.6335     0.7482 0.724 0.036 0.240
#> SRR1047849     1  0.6335     0.7482 0.724 0.036 0.240
#> SRR1047850     1  0.6335     0.7482 0.724 0.036 0.240
#> SRR1047851     1  0.6335     0.7482 0.724 0.036 0.240
#> SRR1047852     1  0.6335     0.7482 0.724 0.036 0.240
#> SRR1047853     3  0.3918     0.5860 0.120 0.012 0.868
#> SRR1047854     3  0.3989     0.5831 0.124 0.012 0.864
#> SRR1047855     3  0.3989     0.5831 0.124 0.012 0.864
#> SRR1047856     3  0.3918     0.5860 0.120 0.012 0.868
#> SRR1047857     3  0.3918     0.5860 0.120 0.012 0.868
#> SRR1047858     1  0.5902     0.7146 0.680 0.004 0.316
#> SRR1047859     1  0.5902     0.7146 0.680 0.004 0.316
#> SRR1047860     1  0.5902     0.7146 0.680 0.004 0.316
#> SRR1047861     1  0.5902     0.7146 0.680 0.004 0.316
#> SRR1047863     3  0.9991     0.1934 0.332 0.316 0.352
#> SRR1047864     1  0.9736    -0.2149 0.436 0.324 0.240
#> SRR1047865     1  0.9248    -0.1044 0.516 0.296 0.188
#> SRR1047866     1  0.8776    -0.0523 0.560 0.296 0.144
#> SRR1047867     2  0.5659     0.4459 0.248 0.740 0.012
#> SRR1047868     3  0.9989     0.1969 0.328 0.316 0.356
#> SRR1047869     1  0.9248    -0.1044 0.516 0.296 0.188
#> SRR1047870     3  0.9986     0.1947 0.320 0.320 0.360
#> SRR1047871     3  0.9991     0.1934 0.332 0.316 0.352
#> SRR1047872     3  0.9989     0.1969 0.328 0.316 0.356
#> SRR1047873     3  0.9989     0.1969 0.328 0.316 0.356
#> SRR1047874     3  0.9989     0.1969 0.328 0.316 0.356

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1047813     1  0.2844      0.886 0.900 0.048 0.052 0.000
#> SRR1047814     1  0.2844      0.886 0.900 0.048 0.052 0.000
#> SRR1047815     1  0.2844      0.886 0.900 0.048 0.052 0.000
#> SRR1047816     1  0.2844      0.886 0.900 0.048 0.052 0.000
#> SRR1047817     1  0.2844      0.886 0.900 0.048 0.052 0.000
#> SRR1047818     4  0.1767      0.937 0.044 0.012 0.000 0.944
#> SRR1047819     4  0.1767      0.937 0.044 0.012 0.000 0.944
#> SRR1047820     4  0.1767      0.937 0.044 0.012 0.000 0.944
#> SRR1047821     4  0.1767      0.937 0.044 0.012 0.000 0.944
#> SRR1047822     4  0.1767      0.937 0.044 0.012 0.000 0.944
#> SRR1047823     4  0.4105      0.902 0.056 0.040 0.048 0.856
#> SRR1047824     4  0.4105      0.902 0.056 0.040 0.048 0.856
#> SRR1047825     4  0.4105      0.902 0.056 0.040 0.048 0.856
#> SRR1047826     4  0.4105      0.902 0.056 0.040 0.048 0.856
#> SRR1047827     4  0.4105      0.902 0.056 0.040 0.048 0.856
#> SRR1047828     1  0.4840      0.848 0.808 0.024 0.060 0.108
#> SRR1047829     1  0.4840      0.848 0.808 0.024 0.060 0.108
#> SRR1047830     1  0.4840      0.848 0.808 0.024 0.060 0.108
#> SRR1047831     1  0.4840      0.848 0.808 0.024 0.060 0.108
#> SRR1047832     1  0.4840      0.848 0.808 0.024 0.060 0.108
#> SRR1047833     2  0.3761      1.000 0.020 0.868 0.044 0.068
#> SRR1047834     2  0.3761      1.000 0.020 0.868 0.044 0.068
#> SRR1047835     2  0.3761      1.000 0.020 0.868 0.044 0.068
#> SRR1047836     2  0.3761      1.000 0.020 0.868 0.044 0.068
#> SRR1047837     2  0.3761      1.000 0.020 0.868 0.044 0.068
#> SRR1047838     4  0.1302      0.938 0.044 0.000 0.000 0.956
#> SRR1047839     4  0.1302      0.938 0.044 0.000 0.000 0.956
#> SRR1047840     4  0.1302      0.938 0.044 0.000 0.000 0.956
#> SRR1047841     4  0.1302      0.938 0.044 0.000 0.000 0.956
#> SRR1047842     4  0.1302      0.938 0.044 0.000 0.000 0.956
#> SRR1047843     1  0.3574      0.893 0.876 0.044 0.016 0.064
#> SRR1047844     1  0.3722      0.888 0.868 0.044 0.016 0.072
#> SRR1047845     1  0.3574      0.893 0.876 0.044 0.016 0.064
#> SRR1047846     1  0.3574      0.893 0.876 0.044 0.016 0.064
#> SRR1047847     1  0.3722      0.888 0.868 0.044 0.016 0.072
#> SRR1047848     1  0.0657      0.903 0.984 0.004 0.012 0.000
#> SRR1047849     1  0.0657      0.903 0.984 0.004 0.012 0.000
#> SRR1047850     1  0.0657      0.903 0.984 0.004 0.012 0.000
#> SRR1047851     1  0.0657      0.903 0.984 0.004 0.012 0.000
#> SRR1047852     1  0.0657      0.903 0.984 0.004 0.012 0.000
#> SRR1047853     4  0.3404      0.891 0.104 0.000 0.032 0.864
#> SRR1047854     4  0.3404      0.891 0.104 0.000 0.032 0.864
#> SRR1047855     4  0.3404      0.891 0.104 0.000 0.032 0.864
#> SRR1047856     4  0.3404      0.891 0.104 0.000 0.032 0.864
#> SRR1047857     4  0.3404      0.891 0.104 0.000 0.032 0.864
#> SRR1047858     1  0.2310      0.901 0.932 0.032 0.020 0.016
#> SRR1047859     1  0.2310      0.901 0.932 0.032 0.020 0.016
#> SRR1047860     1  0.2310      0.901 0.932 0.032 0.020 0.016
#> SRR1047861     1  0.2310      0.901 0.932 0.032 0.020 0.016
#> SRR1047863     3  0.2281      0.937 0.000 0.000 0.904 0.096
#> SRR1047864     3  0.3505      0.909 0.012 0.016 0.864 0.108
#> SRR1047865     3  0.3761      0.893 0.068 0.020 0.868 0.044
#> SRR1047866     3  0.4448      0.870 0.076 0.020 0.832 0.072
#> SRR1047867     3  0.3974      0.830 0.008 0.108 0.844 0.040
#> SRR1047868     3  0.2345      0.937 0.000 0.000 0.900 0.100
#> SRR1047869     3  0.3761      0.893 0.068 0.020 0.868 0.044
#> SRR1047870     3  0.2530      0.934 0.004 0.000 0.896 0.100
#> SRR1047871     3  0.2401      0.937 0.004 0.000 0.904 0.092
#> SRR1047872     3  0.2345      0.937 0.000 0.000 0.900 0.100
#> SRR1047873     3  0.2345      0.937 0.000 0.000 0.900 0.100
#> SRR1047874     3  0.2345      0.937 0.000 0.000 0.900 0.100

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4    p5
#> SRR1047813     1  0.4039      0.693 0.720 0.008 0.000 0.004 0.268
#> SRR1047814     1  0.4039      0.693 0.720 0.008 0.000 0.004 0.268
#> SRR1047815     1  0.4039      0.693 0.720 0.008 0.000 0.004 0.268
#> SRR1047816     1  0.4039      0.693 0.720 0.008 0.000 0.004 0.268
#> SRR1047817     1  0.4039      0.693 0.720 0.008 0.000 0.004 0.268
#> SRR1047818     4  0.1628      0.865 0.000 0.000 0.008 0.936 0.056
#> SRR1047819     4  0.1628      0.865 0.000 0.000 0.008 0.936 0.056
#> SRR1047820     4  0.1628      0.865 0.000 0.000 0.008 0.936 0.056
#> SRR1047821     4  0.1628      0.865 0.000 0.000 0.008 0.936 0.056
#> SRR1047822     4  0.1628      0.865 0.000 0.000 0.008 0.936 0.056
#> SRR1047823     4  0.3918      0.762 0.008 0.000 0.008 0.752 0.232
#> SRR1047824     4  0.3918      0.762 0.008 0.000 0.008 0.752 0.232
#> SRR1047825     4  0.3918      0.762 0.008 0.000 0.008 0.752 0.232
#> SRR1047826     4  0.3918      0.762 0.008 0.000 0.008 0.752 0.232
#> SRR1047827     4  0.3918      0.762 0.008 0.000 0.008 0.752 0.232
#> SRR1047828     1  0.6691      0.631 0.500 0.000 0.020 0.152 0.328
#> SRR1047829     1  0.6691      0.631 0.500 0.000 0.020 0.152 0.328
#> SRR1047830     1  0.6691      0.631 0.500 0.000 0.020 0.152 0.328
#> SRR1047831     1  0.6691      0.631 0.500 0.000 0.020 0.152 0.328
#> SRR1047832     1  0.6691      0.631 0.500 0.000 0.020 0.152 0.328
#> SRR1047833     2  0.0963      1.000 0.000 0.964 0.000 0.036 0.000
#> SRR1047834     2  0.0963      1.000 0.000 0.964 0.000 0.036 0.000
#> SRR1047835     2  0.0963      1.000 0.000 0.964 0.000 0.036 0.000
#> SRR1047836     2  0.0963      1.000 0.000 0.964 0.000 0.036 0.000
#> SRR1047837     2  0.0963      1.000 0.000 0.964 0.000 0.036 0.000
#> SRR1047838     4  0.0290      0.871 0.000 0.000 0.008 0.992 0.000
#> SRR1047839     4  0.0290      0.871 0.000 0.000 0.008 0.992 0.000
#> SRR1047840     4  0.0290      0.871 0.000 0.000 0.008 0.992 0.000
#> SRR1047841     4  0.0290      0.871 0.000 0.000 0.008 0.992 0.000
#> SRR1047842     4  0.0290      0.871 0.000 0.000 0.008 0.992 0.000
#> SRR1047843     1  0.5336      0.698 0.632 0.000 0.012 0.052 0.304
#> SRR1047844     1  0.5397      0.696 0.628 0.000 0.012 0.056 0.304
#> SRR1047845     1  0.5336      0.698 0.632 0.000 0.012 0.052 0.304
#> SRR1047846     1  0.5336      0.698 0.632 0.000 0.012 0.052 0.304
#> SRR1047847     1  0.5397      0.696 0.628 0.000 0.012 0.056 0.304
#> SRR1047848     1  0.0693      0.747 0.980 0.012 0.000 0.008 0.000
#> SRR1047849     1  0.0693      0.747 0.980 0.012 0.000 0.008 0.000
#> SRR1047850     1  0.0693      0.747 0.980 0.012 0.000 0.008 0.000
#> SRR1047851     1  0.0693      0.747 0.980 0.012 0.000 0.008 0.000
#> SRR1047852     1  0.0693      0.747 0.980 0.012 0.000 0.008 0.000
#> SRR1047853     4  0.3753      0.807 0.020 0.000 0.036 0.828 0.116
#> SRR1047854     4  0.3753      0.807 0.020 0.000 0.036 0.828 0.116
#> SRR1047855     4  0.3753      0.807 0.020 0.000 0.036 0.828 0.116
#> SRR1047856     4  0.3753      0.807 0.020 0.000 0.036 0.828 0.116
#> SRR1047857     4  0.3753      0.807 0.020 0.000 0.036 0.828 0.116
#> SRR1047858     1  0.3004      0.736 0.860 0.004 0.008 0.008 0.120
#> SRR1047859     1  0.3004      0.736 0.860 0.004 0.008 0.008 0.120
#> SRR1047860     1  0.3004      0.736 0.860 0.004 0.008 0.008 0.120
#> SRR1047861     1  0.3004      0.736 0.860 0.004 0.008 0.008 0.120
#> SRR1047863     3  0.0404      0.948 0.000 0.000 0.988 0.012 0.000
#> SRR1047864     3  0.2956      0.891 0.000 0.004 0.848 0.008 0.140
#> SRR1047865     3  0.2043      0.926 0.008 0.012 0.928 0.004 0.048
#> SRR1047866     3  0.3519      0.878 0.008 0.012 0.820 0.004 0.156
#> SRR1047867     3  0.3238      0.878 0.000 0.028 0.836 0.000 0.136
#> SRR1047868     3  0.0609      0.949 0.000 0.000 0.980 0.020 0.000
#> SRR1047869     3  0.2043      0.926 0.008 0.012 0.928 0.004 0.048
#> SRR1047870     3  0.0609      0.949 0.000 0.000 0.980 0.020 0.000
#> SRR1047871     3  0.0404      0.948 0.000 0.000 0.988 0.012 0.000
#> SRR1047872     3  0.0609      0.949 0.000 0.000 0.980 0.020 0.000
#> SRR1047873     3  0.0609      0.949 0.000 0.000 0.980 0.020 0.000
#> SRR1047874     3  0.0609      0.949 0.000 0.000 0.980 0.020 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
#> SRR1047813     5  0.4342     0.1066 0.308 0.008 0.000 0.000 0.656 0.028
#> SRR1047814     5  0.4342     0.1066 0.308 0.008 0.000 0.000 0.656 0.028
#> SRR1047815     5  0.4342     0.1066 0.308 0.008 0.000 0.000 0.656 0.028
#> SRR1047816     5  0.4342     0.1066 0.308 0.008 0.000 0.000 0.656 0.028
#> SRR1047817     5  0.4342     0.1066 0.308 0.008 0.000 0.000 0.656 0.028
#> SRR1047818     4  0.4693     0.4619 0.028 0.004 0.000 0.540 0.004 0.424
#> SRR1047819     4  0.4693     0.4619 0.028 0.004 0.000 0.540 0.004 0.424
#> SRR1047820     4  0.4693     0.4619 0.028 0.004 0.000 0.540 0.004 0.424
#> SRR1047821     4  0.4693     0.4619 0.028 0.004 0.000 0.540 0.004 0.424
#> SRR1047822     4  0.4693     0.4619 0.028 0.004 0.000 0.540 0.004 0.424
#> SRR1047823     4  0.0725     0.4180 0.012 0.000 0.000 0.976 0.012 0.000
#> SRR1047824     4  0.0260     0.4213 0.000 0.000 0.000 0.992 0.008 0.000
#> SRR1047825     4  0.0260     0.4213 0.000 0.000 0.000 0.992 0.008 0.000
#> SRR1047826     4  0.0260     0.4213 0.000 0.000 0.000 0.992 0.008 0.000
#> SRR1047827     4  0.0260     0.4213 0.000 0.000 0.000 0.992 0.008 0.000
#> SRR1047828     5  0.3488     0.4268 0.000 0.000 0.028 0.076 0.832 0.064
#> SRR1047829     5  0.3488     0.4268 0.000 0.000 0.028 0.076 0.832 0.064
#> SRR1047830     5  0.3488     0.4268 0.000 0.000 0.028 0.076 0.832 0.064
#> SRR1047831     5  0.3488     0.4268 0.000 0.000 0.028 0.076 0.832 0.064
#> SRR1047832     5  0.3488     0.4268 0.000 0.000 0.028 0.076 0.832 0.064
#> SRR1047833     2  0.0972     0.9976 0.000 0.964 0.000 0.028 0.008 0.000
#> SRR1047834     2  0.0858     0.9994 0.000 0.968 0.000 0.028 0.004 0.000
#> SRR1047835     2  0.0858     0.9994 0.000 0.968 0.000 0.028 0.004 0.000
#> SRR1047836     2  0.0858     0.9994 0.000 0.968 0.000 0.028 0.004 0.000
#> SRR1047837     2  0.0858     0.9994 0.000 0.968 0.000 0.028 0.004 0.000
#> SRR1047838     4  0.3937     0.4142 0.004 0.000 0.000 0.572 0.000 0.424
#> SRR1047839     4  0.3944     0.4076 0.004 0.000 0.000 0.568 0.000 0.428
#> SRR1047840     4  0.3937     0.4142 0.004 0.000 0.000 0.572 0.000 0.424
#> SRR1047841     4  0.3937     0.4142 0.004 0.000 0.000 0.572 0.000 0.424
#> SRR1047842     4  0.3937     0.4142 0.004 0.000 0.000 0.572 0.000 0.424
#> SRR1047843     5  0.6488     0.0821 0.352 0.000 0.000 0.020 0.372 0.256
#> SRR1047844     5  0.6488     0.0821 0.352 0.000 0.000 0.020 0.372 0.256
#> SRR1047845     5  0.6488     0.0821 0.352 0.000 0.000 0.020 0.372 0.256
#> SRR1047846     5  0.6488     0.0821 0.352 0.000 0.000 0.020 0.372 0.256
#> SRR1047847     5  0.6488     0.0821 0.352 0.000 0.000 0.020 0.372 0.256
#> SRR1047848     1  0.3707     0.7454 0.680 0.000 0.000 0.008 0.312 0.000
#> SRR1047849     1  0.3707     0.7454 0.680 0.000 0.000 0.008 0.312 0.000
#> SRR1047850     1  0.3707     0.7454 0.680 0.000 0.000 0.008 0.312 0.000
#> SRR1047851     1  0.3707     0.7454 0.680 0.000 0.000 0.008 0.312 0.000
#> SRR1047852     1  0.3707     0.7454 0.680 0.000 0.000 0.008 0.312 0.000
#> SRR1047853     6  0.6830     1.0000 0.024 0.000 0.032 0.356 0.160 0.428
#> SRR1047854     6  0.6830     1.0000 0.024 0.000 0.032 0.356 0.160 0.428
#> SRR1047855     6  0.6830     1.0000 0.024 0.000 0.032 0.356 0.160 0.428
#> SRR1047856     6  0.6830     1.0000 0.024 0.000 0.032 0.356 0.160 0.428
#> SRR1047857     6  0.6830     1.0000 0.024 0.000 0.032 0.356 0.160 0.428
#> SRR1047858     1  0.5572     0.6764 0.588 0.016 0.000 0.004 0.284 0.108
#> SRR1047859     1  0.5572     0.6764 0.588 0.016 0.000 0.004 0.284 0.108
#> SRR1047860     1  0.5572     0.6764 0.588 0.016 0.000 0.004 0.284 0.108
#> SRR1047861     1  0.5572     0.6764 0.588 0.016 0.000 0.004 0.284 0.108
#> SRR1047863     3  0.0405     0.8967 0.004 0.000 0.988 0.000 0.000 0.008
#> SRR1047864     3  0.5002     0.7672 0.076 0.000 0.692 0.000 0.040 0.192
#> SRR1047865     3  0.3506     0.8464 0.088 0.004 0.828 0.000 0.012 0.068
#> SRR1047866     3  0.5304     0.7585 0.136 0.004 0.656 0.000 0.016 0.188
#> SRR1047867     3  0.5002     0.7672 0.076 0.000 0.692 0.000 0.040 0.192
#> SRR1047868     3  0.0520     0.8976 0.008 0.000 0.984 0.000 0.000 0.008
#> SRR1047869     3  0.3506     0.8464 0.088 0.004 0.828 0.000 0.012 0.068
#> SRR1047870     3  0.0820     0.8958 0.012 0.000 0.972 0.000 0.000 0.016
#> SRR1047871     3  0.0000     0.8976 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1047872     3  0.0520     0.8976 0.008 0.000 0.984 0.000 0.000 0.008
#> SRR1047873     3  0.0520     0.8976 0.008 0.000 0.984 0.000 0.000 0.008
#> SRR1047874     3  0.0520     0.8976 0.008 0.000 0.984 0.000 0.000 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-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 17931 rows and 61 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 0.515           0.716       0.876         0.5059 0.498   0.498
#> 3 3 0.808           0.940       0.959         0.3245 0.785   0.587
#> 4 4 1.000           0.991       0.994         0.1073 0.896   0.698
#> 5 5 0.852           0.870       0.891         0.0498 0.984   0.936
#> 6 6 0.831           0.866       0.882         0.0490 0.907   0.635

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

suggest_best_k(res)
#> [1] 4

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette    p1    p2
#> SRR1047813     1   0.000      0.864 1.000 0.000
#> SRR1047814     1   0.000      0.864 1.000 0.000
#> SRR1047815     1   0.000      0.864 1.000 0.000
#> SRR1047816     1   0.000      0.864 1.000 0.000
#> SRR1047817     1   0.000      0.864 1.000 0.000
#> SRR1047818     2   0.000      0.815 0.000 1.000
#> SRR1047819     2   0.000      0.815 0.000 1.000
#> SRR1047820     2   0.000      0.815 0.000 1.000
#> SRR1047821     2   0.000      0.815 0.000 1.000
#> SRR1047822     2   0.000      0.815 0.000 1.000
#> SRR1047823     2   0.992      0.401 0.448 0.552
#> SRR1047824     2   0.992      0.401 0.448 0.552
#> SRR1047825     2   0.992      0.401 0.448 0.552
#> SRR1047826     2   0.992      0.401 0.448 0.552
#> SRR1047827     2   0.992      0.401 0.448 0.552
#> SRR1047828     1   0.000      0.864 1.000 0.000
#> SRR1047829     1   0.000      0.864 1.000 0.000
#> SRR1047830     1   0.000      0.864 1.000 0.000
#> SRR1047831     1   0.000      0.864 1.000 0.000
#> SRR1047832     1   0.000      0.864 1.000 0.000
#> SRR1047833     2   0.969      0.487 0.396 0.604
#> SRR1047834     2   0.969      0.487 0.396 0.604
#> SRR1047835     2   0.969      0.487 0.396 0.604
#> SRR1047836     2   0.969      0.487 0.396 0.604
#> SRR1047837     2   0.969      0.487 0.396 0.604
#> SRR1047838     2   0.000      0.815 0.000 1.000
#> SRR1047839     2   0.000      0.815 0.000 1.000
#> SRR1047840     2   0.000      0.815 0.000 1.000
#> SRR1047841     2   0.000      0.815 0.000 1.000
#> SRR1047842     2   0.000      0.815 0.000 1.000
#> SRR1047843     1   0.689      0.717 0.816 0.184
#> SRR1047844     1   0.969      0.420 0.604 0.396
#> SRR1047845     1   0.689      0.717 0.816 0.184
#> SRR1047846     1   0.689      0.717 0.816 0.184
#> SRR1047847     1   0.969      0.420 0.604 0.396
#> SRR1047848     1   0.000      0.864 1.000 0.000
#> SRR1047849     1   0.000      0.864 1.000 0.000
#> SRR1047850     1   0.000      0.864 1.000 0.000
#> SRR1047851     1   0.000      0.864 1.000 0.000
#> SRR1047852     1   0.000      0.864 1.000 0.000
#> SRR1047853     2   0.000      0.815 0.000 1.000
#> SRR1047854     2   0.000      0.815 0.000 1.000
#> SRR1047855     2   0.000      0.815 0.000 1.000
#> SRR1047856     2   0.000      0.815 0.000 1.000
#> SRR1047857     2   0.000      0.815 0.000 1.000
#> SRR1047858     1   0.000      0.864 1.000 0.000
#> SRR1047859     1   0.000      0.864 1.000 0.000
#> SRR1047860     1   0.000      0.864 1.000 0.000
#> SRR1047861     1   0.000      0.864 1.000 0.000
#> SRR1047863     2   0.184      0.795 0.028 0.972
#> SRR1047864     2   0.767      0.567 0.224 0.776
#> SRR1047865     1   0.993      0.313 0.548 0.452
#> SRR1047866     1   0.992      0.320 0.552 0.448
#> SRR1047867     2   0.714      0.612 0.196 0.804
#> SRR1047868     2   0.000      0.815 0.000 1.000
#> SRR1047869     1   0.993      0.313 0.548 0.452
#> SRR1047870     2   0.000      0.815 0.000 1.000
#> SRR1047871     2   0.706      0.616 0.192 0.808
#> SRR1047872     2   0.000      0.815 0.000 1.000
#> SRR1047873     2   0.000      0.815 0.000 1.000
#> SRR1047874     2   0.000      0.815 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
#> SRR1047813     1  0.0000      0.958 1.000 0.000 0.000
#> SRR1047814     1  0.0000      0.958 1.000 0.000 0.000
#> SRR1047815     1  0.0000      0.958 1.000 0.000 0.000
#> SRR1047816     1  0.0000      0.958 1.000 0.000 0.000
#> SRR1047817     1  0.0000      0.958 1.000 0.000 0.000
#> SRR1047818     2  0.0000      0.986 0.000 1.000 0.000
#> SRR1047819     2  0.0000      0.986 0.000 1.000 0.000
#> SRR1047820     2  0.0000      0.986 0.000 1.000 0.000
#> SRR1047821     2  0.0000      0.986 0.000 1.000 0.000
#> SRR1047822     2  0.0000      0.986 0.000 1.000 0.000
#> SRR1047823     2  0.1411      0.964 0.036 0.964 0.000
#> SRR1047824     2  0.1411      0.964 0.036 0.964 0.000
#> SRR1047825     2  0.1411      0.964 0.036 0.964 0.000
#> SRR1047826     2  0.1411      0.964 0.036 0.964 0.000
#> SRR1047827     2  0.1411      0.964 0.036 0.964 0.000
#> SRR1047828     1  0.3619      0.875 0.864 0.000 0.136
#> SRR1047829     1  0.3619      0.875 0.864 0.000 0.136
#> SRR1047830     1  0.3619      0.875 0.864 0.000 0.136
#> SRR1047831     1  0.3619      0.875 0.864 0.000 0.136
#> SRR1047832     1  0.3619      0.875 0.864 0.000 0.136
#> SRR1047833     3  0.2339      0.907 0.048 0.012 0.940
#> SRR1047834     3  0.2339      0.907 0.048 0.012 0.940
#> SRR1047835     3  0.2339      0.907 0.048 0.012 0.940
#> SRR1047836     3  0.2339      0.907 0.048 0.012 0.940
#> SRR1047837     3  0.2339      0.907 0.048 0.012 0.940
#> SRR1047838     2  0.0000      0.986 0.000 1.000 0.000
#> SRR1047839     2  0.0000      0.986 0.000 1.000 0.000
#> SRR1047840     2  0.0000      0.986 0.000 1.000 0.000
#> SRR1047841     2  0.0000      0.986 0.000 1.000 0.000
#> SRR1047842     2  0.0000      0.986 0.000 1.000 0.000
#> SRR1047843     1  0.1753      0.934 0.952 0.000 0.048
#> SRR1047844     1  0.1989      0.932 0.948 0.004 0.048
#> SRR1047845     1  0.1753      0.934 0.952 0.000 0.048
#> SRR1047846     1  0.1753      0.934 0.952 0.000 0.048
#> SRR1047847     1  0.1989      0.932 0.948 0.004 0.048
#> SRR1047848     1  0.0000      0.958 1.000 0.000 0.000
#> SRR1047849     1  0.0000      0.958 1.000 0.000 0.000
#> SRR1047850     1  0.0000      0.958 1.000 0.000 0.000
#> SRR1047851     1  0.0000      0.958 1.000 0.000 0.000
#> SRR1047852     1  0.0000      0.958 1.000 0.000 0.000
#> SRR1047853     2  0.0424      0.983 0.000 0.992 0.008
#> SRR1047854     2  0.0424      0.983 0.000 0.992 0.008
#> SRR1047855     2  0.0424      0.983 0.000 0.992 0.008
#> SRR1047856     2  0.0424      0.983 0.000 0.992 0.008
#> SRR1047857     2  0.0424      0.983 0.000 0.992 0.008
#> SRR1047858     1  0.0000      0.958 1.000 0.000 0.000
#> SRR1047859     1  0.0000      0.958 1.000 0.000 0.000
#> SRR1047860     1  0.0000      0.958 1.000 0.000 0.000
#> SRR1047861     1  0.0000      0.958 1.000 0.000 0.000
#> SRR1047863     3  0.1643      0.920 0.000 0.044 0.956
#> SRR1047864     3  0.0000      0.916 0.000 0.000 1.000
#> SRR1047865     3  0.4335      0.882 0.100 0.036 0.864
#> SRR1047866     3  0.2959      0.883 0.100 0.000 0.900
#> SRR1047867     3  0.0000      0.916 0.000 0.000 1.000
#> SRR1047868     3  0.3619      0.877 0.000 0.136 0.864
#> SRR1047869     3  0.4335      0.882 0.100 0.036 0.864
#> SRR1047870     3  0.1643      0.920 0.000 0.044 0.956
#> SRR1047871     3  0.1643      0.920 0.000 0.044 0.956
#> SRR1047872     3  0.3619      0.877 0.000 0.136 0.864
#> SRR1047873     3  0.3619      0.877 0.000 0.136 0.864
#> SRR1047874     3  0.3619      0.877 0.000 0.136 0.864

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1047813     1  0.0336      0.991 0.992 0.008 0.000 0.000
#> SRR1047814     1  0.0336      0.991 0.992 0.008 0.000 0.000
#> SRR1047815     1  0.0336      0.991 0.992 0.008 0.000 0.000
#> SRR1047816     1  0.0336      0.991 0.992 0.008 0.000 0.000
#> SRR1047817     1  0.0336      0.991 0.992 0.008 0.000 0.000
#> SRR1047818     4  0.0000      0.998 0.000 0.000 0.000 1.000
#> SRR1047819     4  0.0000      0.998 0.000 0.000 0.000 1.000
#> SRR1047820     4  0.0000      0.998 0.000 0.000 0.000 1.000
#> SRR1047821     4  0.0000      0.998 0.000 0.000 0.000 1.000
#> SRR1047822     4  0.0000      0.998 0.000 0.000 0.000 1.000
#> SRR1047823     4  0.0000      0.998 0.000 0.000 0.000 1.000
#> SRR1047824     4  0.0000      0.998 0.000 0.000 0.000 1.000
#> SRR1047825     4  0.0000      0.998 0.000 0.000 0.000 1.000
#> SRR1047826     4  0.0000      0.998 0.000 0.000 0.000 1.000
#> SRR1047827     4  0.0000      0.998 0.000 0.000 0.000 1.000
#> SRR1047828     2  0.1211      0.972 0.040 0.960 0.000 0.000
#> SRR1047829     2  0.1211      0.972 0.040 0.960 0.000 0.000
#> SRR1047830     2  0.1211      0.972 0.040 0.960 0.000 0.000
#> SRR1047831     2  0.1211      0.972 0.040 0.960 0.000 0.000
#> SRR1047832     2  0.1211      0.972 0.040 0.960 0.000 0.000
#> SRR1047833     2  0.0000      0.976 0.000 1.000 0.000 0.000
#> SRR1047834     2  0.0000      0.976 0.000 1.000 0.000 0.000
#> SRR1047835     2  0.0000      0.976 0.000 1.000 0.000 0.000
#> SRR1047836     2  0.0000      0.976 0.000 1.000 0.000 0.000
#> SRR1047837     2  0.0000      0.976 0.000 1.000 0.000 0.000
#> SRR1047838     4  0.0000      0.998 0.000 0.000 0.000 1.000
#> SRR1047839     4  0.0000      0.998 0.000 0.000 0.000 1.000
#> SRR1047840     4  0.0000      0.998 0.000 0.000 0.000 1.000
#> SRR1047841     4  0.0000      0.998 0.000 0.000 0.000 1.000
#> SRR1047842     4  0.0000      0.998 0.000 0.000 0.000 1.000
#> SRR1047843     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> SRR1047844     1  0.1118      0.961 0.964 0.000 0.036 0.000
#> SRR1047845     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> SRR1047846     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> SRR1047847     1  0.1118      0.961 0.964 0.000 0.036 0.000
#> SRR1047848     1  0.0188      0.993 0.996 0.004 0.000 0.000
#> SRR1047849     1  0.0188      0.993 0.996 0.004 0.000 0.000
#> SRR1047850     1  0.0188      0.993 0.996 0.004 0.000 0.000
#> SRR1047851     1  0.0188      0.993 0.996 0.004 0.000 0.000
#> SRR1047852     1  0.0188      0.993 0.996 0.004 0.000 0.000
#> SRR1047853     4  0.0376      0.994 0.004 0.000 0.004 0.992
#> SRR1047854     4  0.0188      0.996 0.004 0.000 0.000 0.996
#> SRR1047855     4  0.0188      0.996 0.004 0.000 0.000 0.996
#> SRR1047856     4  0.0376      0.994 0.004 0.000 0.004 0.992
#> SRR1047857     4  0.0376      0.994 0.004 0.000 0.004 0.992
#> SRR1047858     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> SRR1047859     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> SRR1047860     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> SRR1047861     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> SRR1047863     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1047864     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1047865     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1047866     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1047867     2  0.0469      0.968 0.000 0.988 0.012 0.000
#> SRR1047868     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1047869     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1047870     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1047871     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1047872     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1047873     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1047874     3  0.0000      1.000 0.000 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4    p5
#> SRR1047813     1  0.4294      0.424 0.532 0.000 0.000 0.000 0.468
#> SRR1047814     1  0.4294      0.424 0.532 0.000 0.000 0.000 0.468
#> SRR1047815     1  0.4294      0.424 0.532 0.000 0.000 0.000 0.468
#> SRR1047816     1  0.4294      0.424 0.532 0.000 0.000 0.000 0.468
#> SRR1047817     1  0.4294      0.424 0.532 0.000 0.000 0.000 0.468
#> SRR1047818     4  0.0000      0.928 0.000 0.000 0.000 1.000 0.000
#> SRR1047819     4  0.0000      0.928 0.000 0.000 0.000 1.000 0.000
#> SRR1047820     4  0.0000      0.928 0.000 0.000 0.000 1.000 0.000
#> SRR1047821     4  0.0000      0.928 0.000 0.000 0.000 1.000 0.000
#> SRR1047822     4  0.0000      0.928 0.000 0.000 0.000 1.000 0.000
#> SRR1047823     4  0.0963      0.917 0.000 0.000 0.000 0.964 0.036
#> SRR1047824     4  0.0963      0.917 0.000 0.000 0.000 0.964 0.036
#> SRR1047825     4  0.0963      0.917 0.000 0.000 0.000 0.964 0.036
#> SRR1047826     4  0.0963      0.917 0.000 0.000 0.000 0.964 0.036
#> SRR1047827     4  0.0963      0.917 0.000 0.000 0.000 0.964 0.036
#> SRR1047828     5  0.4270      1.000 0.012 0.320 0.000 0.000 0.668
#> SRR1047829     5  0.4270      1.000 0.012 0.320 0.000 0.000 0.668
#> SRR1047830     5  0.4270      1.000 0.012 0.320 0.000 0.000 0.668
#> SRR1047831     5  0.4270      1.000 0.012 0.320 0.000 0.000 0.668
#> SRR1047832     5  0.4270      1.000 0.012 0.320 0.000 0.000 0.668
#> SRR1047833     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1047834     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1047835     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1047836     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1047837     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1047838     4  0.0000      0.928 0.000 0.000 0.000 1.000 0.000
#> SRR1047839     4  0.0000      0.928 0.000 0.000 0.000 1.000 0.000
#> SRR1047840     4  0.0000      0.928 0.000 0.000 0.000 1.000 0.000
#> SRR1047841     4  0.0000      0.928 0.000 0.000 0.000 1.000 0.000
#> SRR1047842     4  0.0000      0.928 0.000 0.000 0.000 1.000 0.000
#> SRR1047843     1  0.1341      0.795 0.944 0.000 0.000 0.000 0.056
#> SRR1047844     1  0.1341      0.795 0.944 0.000 0.000 0.000 0.056
#> SRR1047845     1  0.1341      0.795 0.944 0.000 0.000 0.000 0.056
#> SRR1047846     1  0.1341      0.795 0.944 0.000 0.000 0.000 0.056
#> SRR1047847     1  0.1341      0.795 0.944 0.000 0.000 0.000 0.056
#> SRR1047848     1  0.2127      0.798 0.892 0.000 0.000 0.000 0.108
#> SRR1047849     1  0.2127      0.798 0.892 0.000 0.000 0.000 0.108
#> SRR1047850     1  0.2127      0.798 0.892 0.000 0.000 0.000 0.108
#> SRR1047851     1  0.2127      0.798 0.892 0.000 0.000 0.000 0.108
#> SRR1047852     1  0.2127      0.798 0.892 0.000 0.000 0.000 0.108
#> SRR1047853     4  0.3715      0.787 0.000 0.000 0.004 0.736 0.260
#> SRR1047854     4  0.3715      0.787 0.000 0.000 0.004 0.736 0.260
#> SRR1047855     4  0.3715      0.787 0.000 0.000 0.004 0.736 0.260
#> SRR1047856     4  0.3715      0.787 0.000 0.000 0.004 0.736 0.260
#> SRR1047857     4  0.3715      0.787 0.000 0.000 0.004 0.736 0.260
#> SRR1047858     1  0.0000      0.808 1.000 0.000 0.000 0.000 0.000
#> SRR1047859     1  0.0000      0.808 1.000 0.000 0.000 0.000 0.000
#> SRR1047860     1  0.0000      0.808 1.000 0.000 0.000 0.000 0.000
#> SRR1047861     1  0.0000      0.808 1.000 0.000 0.000 0.000 0.000
#> SRR1047863     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000
#> SRR1047864     3  0.0162      0.995 0.000 0.004 0.996 0.000 0.000
#> SRR1047865     3  0.0162      0.997 0.000 0.000 0.996 0.000 0.004
#> SRR1047866     3  0.0162      0.997 0.000 0.000 0.996 0.000 0.004
#> SRR1047867     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1047868     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000
#> SRR1047869     3  0.0162      0.997 0.000 0.000 0.996 0.000 0.004
#> SRR1047870     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000
#> SRR1047871     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000
#> SRR1047872     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000
#> SRR1047873     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000
#> SRR1047874     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR1047813     5  0.4493      0.628 0.344 0.000 0.000 0.000 0.612 0.044
#> SRR1047814     5  0.4493      0.628 0.344 0.000 0.000 0.000 0.612 0.044
#> SRR1047815     5  0.4493      0.628 0.344 0.000 0.000 0.000 0.612 0.044
#> SRR1047816     5  0.4493      0.628 0.344 0.000 0.000 0.000 0.612 0.044
#> SRR1047817     5  0.4493      0.628 0.344 0.000 0.000 0.000 0.612 0.044
#> SRR1047818     4  0.0777      0.904 0.000 0.000 0.000 0.972 0.004 0.024
#> SRR1047819     4  0.0777      0.904 0.000 0.000 0.000 0.972 0.004 0.024
#> SRR1047820     4  0.0777      0.904 0.000 0.000 0.000 0.972 0.004 0.024
#> SRR1047821     4  0.0777      0.904 0.000 0.000 0.000 0.972 0.004 0.024
#> SRR1047822     4  0.0777      0.904 0.000 0.000 0.000 0.972 0.004 0.024
#> SRR1047823     4  0.2623      0.848 0.000 0.000 0.000 0.852 0.016 0.132
#> SRR1047824     4  0.2623      0.848 0.000 0.000 0.000 0.852 0.016 0.132
#> SRR1047825     4  0.2623      0.848 0.000 0.000 0.000 0.852 0.016 0.132
#> SRR1047826     4  0.2623      0.848 0.000 0.000 0.000 0.852 0.016 0.132
#> SRR1047827     4  0.2623      0.848 0.000 0.000 0.000 0.852 0.016 0.132
#> SRR1047828     5  0.1471      0.705 0.004 0.064 0.000 0.000 0.932 0.000
#> SRR1047829     5  0.1471      0.705 0.004 0.064 0.000 0.000 0.932 0.000
#> SRR1047830     5  0.1471      0.705 0.004 0.064 0.000 0.000 0.932 0.000
#> SRR1047831     5  0.1471      0.705 0.004 0.064 0.000 0.000 0.932 0.000
#> SRR1047832     5  0.1471      0.705 0.004 0.064 0.000 0.000 0.932 0.000
#> SRR1047833     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1047834     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1047835     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1047836     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1047837     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1047838     4  0.0146      0.912 0.000 0.000 0.000 0.996 0.000 0.004
#> SRR1047839     4  0.0146      0.912 0.000 0.000 0.000 0.996 0.000 0.004
#> SRR1047840     4  0.0146      0.912 0.000 0.000 0.000 0.996 0.000 0.004
#> SRR1047841     4  0.0146      0.912 0.000 0.000 0.000 0.996 0.000 0.004
#> SRR1047842     4  0.0146      0.912 0.000 0.000 0.000 0.996 0.000 0.004
#> SRR1047843     1  0.3168      0.775 0.804 0.000 0.000 0.000 0.024 0.172
#> SRR1047844     1  0.3168      0.775 0.804 0.000 0.000 0.000 0.024 0.172
#> SRR1047845     1  0.3168      0.775 0.804 0.000 0.000 0.000 0.024 0.172
#> SRR1047846     1  0.3168      0.775 0.804 0.000 0.000 0.000 0.024 0.172
#> SRR1047847     1  0.3168      0.775 0.804 0.000 0.000 0.000 0.024 0.172
#> SRR1047848     1  0.2909      0.744 0.836 0.000 0.000 0.000 0.136 0.028
#> SRR1047849     1  0.2909      0.744 0.836 0.000 0.000 0.000 0.136 0.028
#> SRR1047850     1  0.2909      0.744 0.836 0.000 0.000 0.000 0.136 0.028
#> SRR1047851     1  0.2909      0.744 0.836 0.000 0.000 0.000 0.136 0.028
#> SRR1047852     1  0.2909      0.744 0.836 0.000 0.000 0.000 0.136 0.028
#> SRR1047853     6  0.3426      1.000 0.000 0.000 0.004 0.276 0.000 0.720
#> SRR1047854     6  0.3426      1.000 0.000 0.000 0.004 0.276 0.000 0.720
#> SRR1047855     6  0.3426      1.000 0.000 0.000 0.004 0.276 0.000 0.720
#> SRR1047856     6  0.3426      1.000 0.000 0.000 0.004 0.276 0.000 0.720
#> SRR1047857     6  0.3426      1.000 0.000 0.000 0.004 0.276 0.000 0.720
#> SRR1047858     1  0.0146      0.819 0.996 0.000 0.000 0.000 0.004 0.000
#> SRR1047859     1  0.0146      0.819 0.996 0.000 0.000 0.000 0.004 0.000
#> SRR1047860     1  0.0146      0.819 0.996 0.000 0.000 0.000 0.004 0.000
#> SRR1047861     1  0.0146      0.819 0.996 0.000 0.000 0.000 0.004 0.000
#> SRR1047863     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1047864     3  0.0146      0.996 0.000 0.004 0.996 0.000 0.000 0.000
#> SRR1047865     3  0.0146      0.997 0.000 0.000 0.996 0.000 0.000 0.004
#> SRR1047866     3  0.0146      0.997 0.000 0.000 0.996 0.000 0.000 0.004
#> SRR1047867     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1047868     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1047869     3  0.0146      0.997 0.000 0.000 0.996 0.000 0.000 0.004
#> SRR1047870     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1047871     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1047872     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1047873     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1047874     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

plot of chunk tab-MAD-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 17931 rows and 61 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 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-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.1811 0.820   0.820
#> 3 3 0.659           0.921       0.948         1.8355 0.686   0.617
#> 4 4 0.841           0.852       0.933         0.3542 0.654   0.396
#> 5 5 0.835           0.833       0.893         0.0795 0.818   0.506
#> 6 6 0.832           0.805       0.876         0.0599 0.936   0.755

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
#> SRR1047813     1       0          1  1  0
#> SRR1047814     1       0          1  1  0
#> SRR1047815     1       0          1  1  0
#> SRR1047816     1       0          1  1  0
#> SRR1047817     1       0          1  1  0
#> SRR1047818     1       0          1  1  0
#> SRR1047819     1       0          1  1  0
#> SRR1047820     1       0          1  1  0
#> SRR1047821     1       0          1  1  0
#> SRR1047822     1       0          1  1  0
#> SRR1047823     1       0          1  1  0
#> SRR1047824     1       0          1  1  0
#> SRR1047825     1       0          1  1  0
#> SRR1047826     1       0          1  1  0
#> SRR1047827     1       0          1  1  0
#> SRR1047828     1       0          1  1  0
#> SRR1047829     1       0          1  1  0
#> SRR1047830     1       0          1  1  0
#> SRR1047831     1       0          1  1  0
#> SRR1047832     1       0          1  1  0
#> SRR1047833     2       0          1  0  1
#> SRR1047834     2       0          1  0  1
#> SRR1047835     2       0          1  0  1
#> SRR1047836     2       0          1  0  1
#> SRR1047837     2       0          1  0  1
#> SRR1047838     1       0          1  1  0
#> SRR1047839     1       0          1  1  0
#> SRR1047840     1       0          1  1  0
#> SRR1047841     1       0          1  1  0
#> SRR1047842     1       0          1  1  0
#> SRR1047843     1       0          1  1  0
#> SRR1047844     1       0          1  1  0
#> SRR1047845     1       0          1  1  0
#> SRR1047846     1       0          1  1  0
#> SRR1047847     1       0          1  1  0
#> SRR1047848     1       0          1  1  0
#> SRR1047849     1       0          1  1  0
#> SRR1047850     1       0          1  1  0
#> SRR1047851     1       0          1  1  0
#> SRR1047852     1       0          1  1  0
#> SRR1047853     1       0          1  1  0
#> SRR1047854     1       0          1  1  0
#> SRR1047855     1       0          1  1  0
#> SRR1047856     1       0          1  1  0
#> SRR1047857     1       0          1  1  0
#> SRR1047858     1       0          1  1  0
#> SRR1047859     1       0          1  1  0
#> SRR1047860     1       0          1  1  0
#> SRR1047861     1       0          1  1  0
#> SRR1047863     1       0          1  1  0
#> SRR1047864     1       0          1  1  0
#> SRR1047865     1       0          1  1  0
#> SRR1047866     1       0          1  1  0
#> SRR1047867     2       0          1  0  1
#> SRR1047868     1       0          1  1  0
#> SRR1047869     1       0          1  1  0
#> SRR1047870     1       0          1  1  0
#> SRR1047871     1       0          1  1  0
#> SRR1047872     1       0          1  1  0
#> SRR1047873     1       0          1  1  0
#> SRR1047874     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette  p1 p2  p3
#> SRR1047813     3   0.000      1.000 0.0  0 1.0
#> SRR1047814     3   0.000      1.000 0.0  0 1.0
#> SRR1047815     3   0.000      1.000 0.0  0 1.0
#> SRR1047816     3   0.000      1.000 0.0  0 1.0
#> SRR1047817     3   0.000      1.000 0.0  0 1.0
#> SRR1047818     1   0.000      0.908 1.0  0 0.0
#> SRR1047819     1   0.000      0.908 1.0  0 0.0
#> SRR1047820     1   0.000      0.908 1.0  0 0.0
#> SRR1047821     1   0.000      0.908 1.0  0 0.0
#> SRR1047822     1   0.000      0.908 1.0  0 0.0
#> SRR1047823     1   0.000      0.908 1.0  0 0.0
#> SRR1047824     1   0.000      0.908 1.0  0 0.0
#> SRR1047825     1   0.000      0.908 1.0  0 0.0
#> SRR1047826     1   0.000      0.908 1.0  0 0.0
#> SRR1047827     1   0.000      0.908 1.0  0 0.0
#> SRR1047828     1   0.455      0.844 0.8  0 0.2
#> SRR1047829     1   0.455      0.844 0.8  0 0.2
#> SRR1047830     1   0.455      0.844 0.8  0 0.2
#> SRR1047831     1   0.455      0.844 0.8  0 0.2
#> SRR1047832     1   0.455      0.844 0.8  0 0.2
#> SRR1047833     2   0.000      1.000 0.0  1 0.0
#> SRR1047834     2   0.000      1.000 0.0  1 0.0
#> SRR1047835     2   0.000      1.000 0.0  1 0.0
#> SRR1047836     2   0.000      1.000 0.0  1 0.0
#> SRR1047837     2   0.000      1.000 0.0  1 0.0
#> SRR1047838     1   0.000      0.908 1.0  0 0.0
#> SRR1047839     1   0.000      0.908 1.0  0 0.0
#> SRR1047840     1   0.000      0.908 1.0  0 0.0
#> SRR1047841     1   0.000      0.908 1.0  0 0.0
#> SRR1047842     1   0.000      0.908 1.0  0 0.0
#> SRR1047843     1   0.455      0.844 0.8  0 0.2
#> SRR1047844     1   0.455      0.844 0.8  0 0.2
#> SRR1047845     1   0.455      0.844 0.8  0 0.2
#> SRR1047846     1   0.455      0.844 0.8  0 0.2
#> SRR1047847     1   0.455      0.844 0.8  0 0.2
#> SRR1047848     3   0.000      1.000 0.0  0 1.0
#> SRR1047849     3   0.000      1.000 0.0  0 1.0
#> SRR1047850     3   0.000      1.000 0.0  0 1.0
#> SRR1047851     3   0.000      1.000 0.0  0 1.0
#> SRR1047852     3   0.000      1.000 0.0  0 1.0
#> SRR1047853     1   0.000      0.908 1.0  0 0.0
#> SRR1047854     1   0.000      0.908 1.0  0 0.0
#> SRR1047855     1   0.000      0.908 1.0  0 0.0
#> SRR1047856     1   0.000      0.908 1.0  0 0.0
#> SRR1047857     1   0.000      0.908 1.0  0 0.0
#> SRR1047858     3   0.000      1.000 0.0  0 1.0
#> SRR1047859     3   0.000      1.000 0.0  0 1.0
#> SRR1047860     3   0.000      1.000 0.0  0 1.0
#> SRR1047861     3   0.000      1.000 0.0  0 1.0
#> SRR1047863     1   0.455      0.844 0.8  0 0.2
#> SRR1047864     1   0.455      0.844 0.8  0 0.2
#> SRR1047865     1   0.455      0.844 0.8  0 0.2
#> SRR1047866     1   0.455      0.844 0.8  0 0.2
#> SRR1047867     2   0.000      1.000 0.0  1 0.0
#> SRR1047868     1   0.000      0.908 1.0  0 0.0
#> SRR1047869     1   0.455      0.844 0.8  0 0.2
#> SRR1047870     1   0.000      0.908 1.0  0 0.0
#> SRR1047871     1   0.455      0.844 0.8  0 0.2
#> SRR1047872     1   0.000      0.908 1.0  0 0.0
#> SRR1047873     1   0.000      0.908 1.0  0 0.0
#> SRR1047874     1   0.000      0.908 1.0  0 0.0

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette   p1 p2    p3    p4
#> SRR1047813     1   0.000      0.796 1.00  0 0.000 0.000
#> SRR1047814     1   0.000      0.796 1.00  0 0.000 0.000
#> SRR1047815     1   0.000      0.796 1.00  0 0.000 0.000
#> SRR1047816     1   0.000      0.796 1.00  0 0.000 0.000
#> SRR1047817     1   0.000      0.796 1.00  0 0.000 0.000
#> SRR1047818     4   0.000      0.946 0.00  0 0.000 1.000
#> SRR1047819     4   0.000      0.946 0.00  0 0.000 1.000
#> SRR1047820     4   0.000      0.946 0.00  0 0.000 1.000
#> SRR1047821     4   0.000      0.946 0.00  0 0.000 1.000
#> SRR1047822     4   0.000      0.946 0.00  0 0.000 1.000
#> SRR1047823     4   0.000      0.946 0.00  0 0.000 1.000
#> SRR1047824     4   0.000      0.946 0.00  0 0.000 1.000
#> SRR1047825     4   0.000      0.946 0.00  0 0.000 1.000
#> SRR1047826     4   0.000      0.946 0.00  0 0.000 1.000
#> SRR1047827     4   0.000      0.946 0.00  0 0.000 1.000
#> SRR1047828     1   0.479      0.566 0.62  0 0.000 0.380
#> SRR1047829     1   0.479      0.566 0.62  0 0.000 0.380
#> SRR1047830     1   0.479      0.566 0.62  0 0.000 0.380
#> SRR1047831     1   0.479      0.566 0.62  0 0.000 0.380
#> SRR1047832     1   0.479      0.566 0.62  0 0.000 0.380
#> SRR1047833     2   0.000      1.000 0.00  1 0.000 0.000
#> SRR1047834     2   0.000      1.000 0.00  1 0.000 0.000
#> SRR1047835     2   0.000      1.000 0.00  1 0.000 0.000
#> SRR1047836     2   0.000      1.000 0.00  1 0.000 0.000
#> SRR1047837     2   0.000      1.000 0.00  1 0.000 0.000
#> SRR1047838     4   0.000      0.946 0.00  0 0.000 1.000
#> SRR1047839     4   0.000      0.946 0.00  0 0.000 1.000
#> SRR1047840     4   0.000      0.946 0.00  0 0.000 1.000
#> SRR1047841     4   0.000      0.946 0.00  0 0.000 1.000
#> SRR1047842     4   0.000      0.946 0.00  0 0.000 1.000
#> SRR1047843     1   0.479      0.566 0.62  0 0.000 0.380
#> SRR1047844     4   0.760      0.116 0.20  0 0.376 0.424
#> SRR1047845     1   0.479      0.566 0.62  0 0.000 0.380
#> SRR1047846     1   0.479      0.566 0.62  0 0.000 0.380
#> SRR1047847     4   0.740      0.245 0.20  0 0.292 0.508
#> SRR1047848     1   0.000      0.796 1.00  0 0.000 0.000
#> SRR1047849     1   0.000      0.796 1.00  0 0.000 0.000
#> SRR1047850     1   0.000      0.796 1.00  0 0.000 0.000
#> SRR1047851     1   0.000      0.796 1.00  0 0.000 0.000
#> SRR1047852     1   0.000      0.796 1.00  0 0.000 0.000
#> SRR1047853     4   0.000      0.946 0.00  0 0.000 1.000
#> SRR1047854     4   0.000      0.946 0.00  0 0.000 1.000
#> SRR1047855     4   0.000      0.946 0.00  0 0.000 1.000
#> SRR1047856     4   0.000      0.946 0.00  0 0.000 1.000
#> SRR1047857     4   0.000      0.946 0.00  0 0.000 1.000
#> SRR1047858     1   0.000      0.796 1.00  0 0.000 0.000
#> SRR1047859     1   0.000      0.796 1.00  0 0.000 0.000
#> SRR1047860     1   0.000      0.796 1.00  0 0.000 0.000
#> SRR1047861     1   0.000      0.796 1.00  0 0.000 0.000
#> SRR1047863     3   0.000      1.000 0.00  0 1.000 0.000
#> SRR1047864     3   0.000      1.000 0.00  0 1.000 0.000
#> SRR1047865     3   0.000      1.000 0.00  0 1.000 0.000
#> SRR1047866     3   0.000      1.000 0.00  0 1.000 0.000
#> SRR1047867     3   0.000      1.000 0.00  0 1.000 0.000
#> SRR1047868     3   0.000      1.000 0.00  0 1.000 0.000
#> SRR1047869     3   0.000      1.000 0.00  0 1.000 0.000
#> SRR1047870     3   0.000      1.000 0.00  0 1.000 0.000
#> SRR1047871     3   0.000      1.000 0.00  0 1.000 0.000
#> SRR1047872     3   0.000      1.000 0.00  0 1.000 0.000
#> SRR1047873     3   0.000      1.000 0.00  0 1.000 0.000
#> SRR1047874     3   0.000      1.000 0.00  0 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1 p2    p3    p4    p5
#> SRR1047813     1  0.2377      0.842 0.872  0 0.000 0.000 0.128
#> SRR1047814     1  0.0703      0.941 0.976  0 0.000 0.000 0.024
#> SRR1047815     1  0.0703      0.941 0.976  0 0.000 0.000 0.024
#> SRR1047816     1  0.0609      0.943 0.980  0 0.000 0.000 0.020
#> SRR1047817     1  0.4161      0.496 0.608  0 0.000 0.000 0.392
#> SRR1047818     4  0.0000      0.730 0.000  0 0.000 1.000 0.000
#> SRR1047819     4  0.0000      0.730 0.000  0 0.000 1.000 0.000
#> SRR1047820     4  0.0000      0.730 0.000  0 0.000 1.000 0.000
#> SRR1047821     4  0.0000      0.730 0.000  0 0.000 1.000 0.000
#> SRR1047822     4  0.0000      0.730 0.000  0 0.000 1.000 0.000
#> SRR1047823     5  0.4171      1.000 0.000  0 0.000 0.396 0.604
#> SRR1047824     5  0.4171      1.000 0.000  0 0.000 0.396 0.604
#> SRR1047825     5  0.4171      1.000 0.000  0 0.000 0.396 0.604
#> SRR1047826     5  0.4171      1.000 0.000  0 0.000 0.396 0.604
#> SRR1047827     5  0.4171      1.000 0.000  0 0.000 0.396 0.604
#> SRR1047828     4  0.4171      0.546 0.000  0 0.000 0.604 0.396
#> SRR1047829     4  0.4171      0.546 0.000  0 0.000 0.604 0.396
#> SRR1047830     4  0.4171      0.546 0.000  0 0.000 0.604 0.396
#> SRR1047831     4  0.4171      0.546 0.000  0 0.000 0.604 0.396
#> SRR1047832     4  0.4171      0.546 0.000  0 0.000 0.604 0.396
#> SRR1047833     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> SRR1047834     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> SRR1047835     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> SRR1047836     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> SRR1047837     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> SRR1047838     4  0.0000      0.730 0.000  0 0.000 1.000 0.000
#> SRR1047839     4  0.0000      0.730 0.000  0 0.000 1.000 0.000
#> SRR1047840     4  0.0000      0.730 0.000  0 0.000 1.000 0.000
#> SRR1047841     4  0.0000      0.730 0.000  0 0.000 1.000 0.000
#> SRR1047842     4  0.0000      0.730 0.000  0 0.000 1.000 0.000
#> SRR1047843     4  0.4171      0.474 0.396  0 0.000 0.604 0.000
#> SRR1047844     4  0.5998      0.498 0.200  0 0.192 0.604 0.004
#> SRR1047845     4  0.4171      0.474 0.396  0 0.000 0.604 0.000
#> SRR1047846     4  0.4171      0.474 0.396  0 0.000 0.604 0.000
#> SRR1047847     4  0.6084      0.499 0.200  0 0.188 0.604 0.008
#> SRR1047848     1  0.0000      0.951 1.000  0 0.000 0.000 0.000
#> SRR1047849     1  0.0000      0.951 1.000  0 0.000 0.000 0.000
#> SRR1047850     1  0.0000      0.951 1.000  0 0.000 0.000 0.000
#> SRR1047851     1  0.0000      0.951 1.000  0 0.000 0.000 0.000
#> SRR1047852     1  0.0000      0.951 1.000  0 0.000 0.000 0.000
#> SRR1047853     4  0.0000      0.730 0.000  0 0.000 1.000 0.000
#> SRR1047854     4  0.0000      0.730 0.000  0 0.000 1.000 0.000
#> SRR1047855     4  0.0000      0.730 0.000  0 0.000 1.000 0.000
#> SRR1047856     4  0.0000      0.730 0.000  0 0.000 1.000 0.000
#> SRR1047857     4  0.0000      0.730 0.000  0 0.000 1.000 0.000
#> SRR1047858     1  0.0000      0.951 1.000  0 0.000 0.000 0.000
#> SRR1047859     1  0.0000      0.951 1.000  0 0.000 0.000 0.000
#> SRR1047860     1  0.0000      0.951 1.000  0 0.000 0.000 0.000
#> SRR1047861     1  0.0000      0.951 1.000  0 0.000 0.000 0.000
#> SRR1047863     3  0.0000      0.999 0.000  0 1.000 0.000 0.000
#> SRR1047864     3  0.0000      0.999 0.000  0 1.000 0.000 0.000
#> SRR1047865     3  0.0000      0.999 0.000  0 1.000 0.000 0.000
#> SRR1047866     3  0.0000      0.999 0.000  0 1.000 0.000 0.000
#> SRR1047867     3  0.0404      0.987 0.000  0 0.988 0.000 0.012
#> SRR1047868     3  0.0000      0.999 0.000  0 1.000 0.000 0.000
#> SRR1047869     3  0.0000      0.999 0.000  0 1.000 0.000 0.000
#> SRR1047870     3  0.0000      0.999 0.000  0 1.000 0.000 0.000
#> SRR1047871     3  0.0000      0.999 0.000  0 1.000 0.000 0.000
#> SRR1047872     3  0.0000      0.999 0.000  0 1.000 0.000 0.000
#> SRR1047873     3  0.0000      0.999 0.000  0 1.000 0.000 0.000
#> SRR1047874     3  0.0000      0.999 0.000  0 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR1047813     1   0.521      0.593 0.556 0.336 0.000 0.000 0.108 0.000
#> SRR1047814     1   0.521      0.593 0.556 0.336 0.000 0.000 0.108 0.000
#> SRR1047815     1   0.521      0.593 0.556 0.336 0.000 0.000 0.108 0.000
#> SRR1047816     1   0.521      0.593 0.556 0.336 0.000 0.000 0.108 0.000
#> SRR1047817     5   0.356      0.486 0.000 0.336 0.000 0.000 0.664 0.000
#> SRR1047818     4   0.000      0.737 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1047819     4   0.000      0.737 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1047820     4   0.000      0.737 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1047821     4   0.000      0.737 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1047822     4   0.000      0.737 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1047823     6   0.381      1.000 0.000 0.000 0.000 0.428 0.000 0.572
#> SRR1047824     6   0.381      1.000 0.000 0.000 0.000 0.428 0.000 0.572
#> SRR1047825     6   0.381      1.000 0.000 0.000 0.000 0.428 0.000 0.572
#> SRR1047826     6   0.381      1.000 0.000 0.000 0.000 0.428 0.000 0.572
#> SRR1047827     6   0.381      1.000 0.000 0.000 0.000 0.428 0.000 0.572
#> SRR1047828     5   0.191      0.909 0.000 0.000 0.000 0.108 0.892 0.000
#> SRR1047829     5   0.191      0.909 0.000 0.000 0.000 0.108 0.892 0.000
#> SRR1047830     5   0.191      0.909 0.000 0.000 0.000 0.108 0.892 0.000
#> SRR1047831     5   0.191      0.909 0.000 0.000 0.000 0.108 0.892 0.000
#> SRR1047832     5   0.191      0.909 0.000 0.000 0.000 0.108 0.892 0.000
#> SRR1047833     2   0.356      1.000 0.000 0.664 0.000 0.000 0.000 0.336
#> SRR1047834     2   0.356      1.000 0.000 0.664 0.000 0.000 0.000 0.336
#> SRR1047835     2   0.356      1.000 0.000 0.664 0.000 0.000 0.000 0.336
#> SRR1047836     2   0.356      1.000 0.000 0.664 0.000 0.000 0.000 0.336
#> SRR1047837     2   0.356      1.000 0.000 0.664 0.000 0.000 0.000 0.336
#> SRR1047838     4   0.000      0.737 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1047839     4   0.000      0.737 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1047840     4   0.000      0.737 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1047841     4   0.000      0.737 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1047842     4   0.000      0.737 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1047843     4   0.618      0.175 0.424 0.000 0.000 0.428 0.056 0.092
#> SRR1047844     4   0.744      0.278 0.200 0.000 0.184 0.484 0.040 0.092
#> SRR1047845     4   0.618      0.175 0.424 0.000 0.000 0.428 0.056 0.092
#> SRR1047846     4   0.618      0.175 0.424 0.000 0.000 0.428 0.056 0.092
#> SRR1047847     4   0.752      0.288 0.200 0.000 0.148 0.496 0.064 0.092
#> SRR1047848     1   0.000      0.845 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1047849     1   0.000      0.845 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1047850     1   0.000      0.845 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1047851     1   0.000      0.845 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1047852     1   0.000      0.845 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1047853     4   0.000      0.737 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1047854     4   0.000      0.737 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1047855     4   0.000      0.737 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1047856     4   0.000      0.737 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1047857     4   0.000      0.737 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1047858     1   0.000      0.845 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1047859     1   0.079      0.821 0.968 0.000 0.000 0.000 0.000 0.032
#> SRR1047860     1   0.000      0.845 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1047861     1   0.000      0.845 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1047863     3   0.000      0.999 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1047864     3   0.000      0.999 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1047865     3   0.000      0.999 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1047866     3   0.000      0.999 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1047867     3   0.026      0.992 0.000 0.000 0.992 0.000 0.008 0.000
#> SRR1047868     3   0.000      0.999 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1047869     3   0.000      0.999 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1047870     3   0.000      0.999 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1047871     3   0.000      0.999 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1047872     3   0.000      0.999 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1047873     3   0.000      0.999 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1047874     3   0.000      0.999 0.000 0.000 1.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-pam-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-pam-collect-classes

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 17931 rows and 61 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 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-mclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.428           0.860       0.882         0.2867 0.793   0.793
#> 3 3 0.727           0.836       0.921         1.2366 0.484   0.379
#> 4 4 0.893           0.917       0.958         0.0732 0.967   0.907
#> 5 5 0.921           0.907       0.957         0.1354 0.896   0.676
#> 6 6 0.883           0.856       0.919         0.0487 0.907   0.620

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

suggest_best_k(res)
#> [1] 5

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette    p1    p2
#> SRR1047813     1  0.0938      0.847 0.988 0.012
#> SRR1047814     1  0.0938      0.847 0.988 0.012
#> SRR1047815     1  0.0938      0.847 0.988 0.012
#> SRR1047816     1  0.0938      0.847 0.988 0.012
#> SRR1047817     1  0.0938      0.847 0.988 0.012
#> SRR1047818     1  0.7299      0.860 0.796 0.204
#> SRR1047819     1  0.7299      0.860 0.796 0.204
#> SRR1047820     1  0.7299      0.860 0.796 0.204
#> SRR1047821     1  0.7299      0.860 0.796 0.204
#> SRR1047822     1  0.7299      0.860 0.796 0.204
#> SRR1047823     1  0.7299      0.860 0.796 0.204
#> SRR1047824     1  0.7299      0.860 0.796 0.204
#> SRR1047825     1  0.7299      0.860 0.796 0.204
#> SRR1047826     1  0.7299      0.860 0.796 0.204
#> SRR1047827     1  0.7299      0.860 0.796 0.204
#> SRR1047828     1  0.4161      0.865 0.916 0.084
#> SRR1047829     1  0.9248      0.505 0.660 0.340
#> SRR1047830     1  0.4161      0.865 0.916 0.084
#> SRR1047831     1  0.4161      0.865 0.916 0.084
#> SRR1047832     1  0.5178      0.853 0.884 0.116
#> SRR1047833     2  0.0938      0.999 0.012 0.988
#> SRR1047834     2  0.0938      0.999 0.012 0.988
#> SRR1047835     2  0.0938      0.999 0.012 0.988
#> SRR1047836     2  0.0938      0.999 0.012 0.988
#> SRR1047837     2  0.0938      0.999 0.012 0.988
#> SRR1047838     1  0.7299      0.860 0.796 0.204
#> SRR1047839     1  0.7299      0.860 0.796 0.204
#> SRR1047840     1  0.7299      0.860 0.796 0.204
#> SRR1047841     1  0.7299      0.860 0.796 0.204
#> SRR1047842     1  0.7299      0.860 0.796 0.204
#> SRR1047843     1  0.2043      0.839 0.968 0.032
#> SRR1047844     1  0.0000      0.851 1.000 0.000
#> SRR1047845     1  0.1184      0.847 0.984 0.016
#> SRR1047846     1  0.0938      0.849 0.988 0.012
#> SRR1047847     1  0.0000      0.851 1.000 0.000
#> SRR1047848     1  0.0938      0.847 0.988 0.012
#> SRR1047849     1  0.0938      0.847 0.988 0.012
#> SRR1047850     1  0.0938      0.847 0.988 0.012
#> SRR1047851     1  0.0938      0.847 0.988 0.012
#> SRR1047852     1  0.0938      0.847 0.988 0.012
#> SRR1047853     1  0.4562      0.870 0.904 0.096
#> SRR1047854     1  0.5408      0.870 0.876 0.124
#> SRR1047855     1  0.4690      0.870 0.900 0.100
#> SRR1047856     1  0.4298      0.869 0.912 0.088
#> SRR1047857     1  0.4431      0.869 0.908 0.092
#> SRR1047858     1  0.1184      0.847 0.984 0.016
#> SRR1047859     1  0.1184      0.847 0.984 0.016
#> SRR1047860     1  0.1184      0.847 0.984 0.016
#> SRR1047861     1  0.1184      0.847 0.984 0.016
#> SRR1047863     1  0.8144      0.830 0.748 0.252
#> SRR1047864     2  0.1184      0.995 0.016 0.984
#> SRR1047865     1  0.8144      0.830 0.748 0.252
#> SRR1047866     1  0.8144      0.830 0.748 0.252
#> SRR1047867     2  0.0938      0.999 0.012 0.988
#> SRR1047868     1  0.8144      0.830 0.748 0.252
#> SRR1047869     1  0.9323      0.722 0.652 0.348
#> SRR1047870     1  0.8144      0.830 0.748 0.252
#> SRR1047871     1  0.8144      0.830 0.748 0.252
#> SRR1047872     1  0.8144      0.830 0.748 0.252
#> SRR1047873     1  0.8144      0.830 0.748 0.252
#> SRR1047874     1  0.8144      0.830 0.748 0.252

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1047813     1   0.000      0.909 1.000 0.000 0.000
#> SRR1047814     1   0.000      0.909 1.000 0.000 0.000
#> SRR1047815     1   0.000      0.909 1.000 0.000 0.000
#> SRR1047816     1   0.000      0.909 1.000 0.000 0.000
#> SRR1047817     1   0.000      0.909 1.000 0.000 0.000
#> SRR1047818     2   0.000      1.000 0.000 1.000 0.000
#> SRR1047819     2   0.000      1.000 0.000 1.000 0.000
#> SRR1047820     2   0.000      1.000 0.000 1.000 0.000
#> SRR1047821     2   0.000      1.000 0.000 1.000 0.000
#> SRR1047822     2   0.000      1.000 0.000 1.000 0.000
#> SRR1047823     2   0.000      1.000 0.000 1.000 0.000
#> SRR1047824     2   0.000      1.000 0.000 1.000 0.000
#> SRR1047825     2   0.000      1.000 0.000 1.000 0.000
#> SRR1047826     2   0.000      1.000 0.000 1.000 0.000
#> SRR1047827     2   0.000      1.000 0.000 1.000 0.000
#> SRR1047828     1   0.000      0.909 1.000 0.000 0.000
#> SRR1047829     1   0.000      0.909 1.000 0.000 0.000
#> SRR1047830     1   0.000      0.909 1.000 0.000 0.000
#> SRR1047831     1   0.000      0.909 1.000 0.000 0.000
#> SRR1047832     1   0.000      0.909 1.000 0.000 0.000
#> SRR1047833     3   0.000      0.823 0.000 0.000 1.000
#> SRR1047834     3   0.000      0.823 0.000 0.000 1.000
#> SRR1047835     3   0.000      0.823 0.000 0.000 1.000
#> SRR1047836     3   0.000      0.823 0.000 0.000 1.000
#> SRR1047837     3   0.000      0.823 0.000 0.000 1.000
#> SRR1047838     2   0.000      1.000 0.000 1.000 0.000
#> SRR1047839     2   0.000      1.000 0.000 1.000 0.000
#> SRR1047840     2   0.000      1.000 0.000 1.000 0.000
#> SRR1047841     2   0.000      1.000 0.000 1.000 0.000
#> SRR1047842     2   0.000      1.000 0.000 1.000 0.000
#> SRR1047843     1   0.000      0.909 1.000 0.000 0.000
#> SRR1047844     1   0.000      0.909 1.000 0.000 0.000
#> SRR1047845     1   0.000      0.909 1.000 0.000 0.000
#> SRR1047846     1   0.000      0.909 1.000 0.000 0.000
#> SRR1047847     1   0.000      0.909 1.000 0.000 0.000
#> SRR1047848     1   0.000      0.909 1.000 0.000 0.000
#> SRR1047849     1   0.000      0.909 1.000 0.000 0.000
#> SRR1047850     1   0.000      0.909 1.000 0.000 0.000
#> SRR1047851     1   0.000      0.909 1.000 0.000 0.000
#> SRR1047852     1   0.000      0.909 1.000 0.000 0.000
#> SRR1047853     1   0.618      0.372 0.584 0.416 0.000
#> SRR1047854     1   0.618      0.372 0.584 0.416 0.000
#> SRR1047855     1   0.618      0.372 0.584 0.416 0.000
#> SRR1047856     1   0.618      0.372 0.584 0.416 0.000
#> SRR1047857     1   0.618      0.372 0.584 0.416 0.000
#> SRR1047858     1   0.000      0.909 1.000 0.000 0.000
#> SRR1047859     1   0.000      0.909 1.000 0.000 0.000
#> SRR1047860     1   0.000      0.909 1.000 0.000 0.000
#> SRR1047861     1   0.000      0.909 1.000 0.000 0.000
#> SRR1047863     3   0.550      0.572 0.000 0.292 0.708
#> SRR1047864     3   0.000      0.823 0.000 0.000 1.000
#> SRR1047865     3   0.141      0.811 0.000 0.036 0.964
#> SRR1047866     3   0.000      0.823 0.000 0.000 1.000
#> SRR1047867     3   0.000      0.823 0.000 0.000 1.000
#> SRR1047868     3   0.852      0.630 0.280 0.132 0.588
#> SRR1047869     3   0.141      0.811 0.000 0.036 0.964
#> SRR1047870     3   0.569      0.654 0.288 0.004 0.708
#> SRR1047871     3   0.617      0.363 0.000 0.412 0.588
#> SRR1047872     3   0.846      0.626 0.288 0.124 0.588
#> SRR1047873     3   0.846      0.626 0.288 0.124 0.588
#> SRR1047874     3   0.846      0.626 0.288 0.124 0.588

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1 p2    p3   p4
#> SRR1047813     1   0.000      0.896 1.000  0 0.000 0.00
#> SRR1047814     1   0.000      0.896 1.000  0 0.000 0.00
#> SRR1047815     1   0.000      0.896 1.000  0 0.000 0.00
#> SRR1047816     1   0.000      0.896 1.000  0 0.000 0.00
#> SRR1047817     1   0.000      0.896 1.000  0 0.000 0.00
#> SRR1047818     4   0.000      1.000 0.000  0 0.000 1.00
#> SRR1047819     4   0.000      1.000 0.000  0 0.000 1.00
#> SRR1047820     4   0.000      1.000 0.000  0 0.000 1.00
#> SRR1047821     4   0.000      1.000 0.000  0 0.000 1.00
#> SRR1047822     4   0.000      1.000 0.000  0 0.000 1.00
#> SRR1047823     4   0.000      1.000 0.000  0 0.000 1.00
#> SRR1047824     4   0.000      1.000 0.000  0 0.000 1.00
#> SRR1047825     4   0.000      1.000 0.000  0 0.000 1.00
#> SRR1047826     4   0.000      1.000 0.000  0 0.000 1.00
#> SRR1047827     4   0.000      1.000 0.000  0 0.000 1.00
#> SRR1047828     1   0.112      0.903 0.964  0 0.036 0.00
#> SRR1047829     1   0.112      0.903 0.964  0 0.036 0.00
#> SRR1047830     1   0.112      0.903 0.964  0 0.036 0.00
#> SRR1047831     1   0.112      0.903 0.964  0 0.036 0.00
#> SRR1047832     1   0.112      0.903 0.964  0 0.036 0.00
#> SRR1047833     2   0.000      1.000 0.000  1 0.000 0.00
#> SRR1047834     2   0.000      1.000 0.000  1 0.000 0.00
#> SRR1047835     2   0.000      1.000 0.000  1 0.000 0.00
#> SRR1047836     2   0.000      1.000 0.000  1 0.000 0.00
#> SRR1047837     2   0.000      1.000 0.000  1 0.000 0.00
#> SRR1047838     4   0.000      1.000 0.000  0 0.000 1.00
#> SRR1047839     4   0.000      1.000 0.000  0 0.000 1.00
#> SRR1047840     4   0.000      1.000 0.000  0 0.000 1.00
#> SRR1047841     4   0.000      1.000 0.000  0 0.000 1.00
#> SRR1047842     4   0.000      1.000 0.000  0 0.000 1.00
#> SRR1047843     1   0.112      0.903 0.964  0 0.036 0.00
#> SRR1047844     1   0.112      0.903 0.964  0 0.036 0.00
#> SRR1047845     1   0.112      0.903 0.964  0 0.036 0.00
#> SRR1047846     1   0.112      0.903 0.964  0 0.036 0.00
#> SRR1047847     1   0.112      0.903 0.964  0 0.036 0.00
#> SRR1047848     1   0.000      0.896 1.000  0 0.000 0.00
#> SRR1047849     1   0.000      0.896 1.000  0 0.000 0.00
#> SRR1047850     1   0.000      0.896 1.000  0 0.000 0.00
#> SRR1047851     1   0.000      0.896 1.000  0 0.000 0.00
#> SRR1047852     1   0.000      0.896 1.000  0 0.000 0.00
#> SRR1047853     1   0.578      0.467 0.584  0 0.036 0.38
#> SRR1047854     1   0.578      0.467 0.584  0 0.036 0.38
#> SRR1047855     1   0.578      0.467 0.584  0 0.036 0.38
#> SRR1047856     1   0.578      0.467 0.584  0 0.036 0.38
#> SRR1047857     1   0.578      0.467 0.584  0 0.036 0.38
#> SRR1047858     1   0.112      0.903 0.964  0 0.036 0.00
#> SRR1047859     1   0.112      0.903 0.964  0 0.036 0.00
#> SRR1047860     1   0.112      0.903 0.964  0 0.036 0.00
#> SRR1047861     1   0.112      0.903 0.964  0 0.036 0.00
#> SRR1047863     3   0.000      1.000 0.000  0 1.000 0.00
#> SRR1047864     3   0.000      1.000 0.000  0 1.000 0.00
#> SRR1047865     3   0.000      1.000 0.000  0 1.000 0.00
#> SRR1047866     3   0.000      1.000 0.000  0 1.000 0.00
#> SRR1047867     3   0.000      1.000 0.000  0 1.000 0.00
#> SRR1047868     3   0.000      1.000 0.000  0 1.000 0.00
#> SRR1047869     3   0.000      1.000 0.000  0 1.000 0.00
#> SRR1047870     3   0.000      1.000 0.000  0 1.000 0.00
#> SRR1047871     3   0.000      1.000 0.000  0 1.000 0.00
#> SRR1047872     3   0.000      1.000 0.000  0 1.000 0.00
#> SRR1047873     3   0.000      1.000 0.000  0 1.000 0.00
#> SRR1047874     3   0.000      1.000 0.000  0 1.000 0.00

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette   p1 p2   p3    p4    p5
#> SRR1047813     1   0.000      1.000 1.00  0 0.00 0.000 0.000
#> SRR1047814     1   0.000      1.000 1.00  0 0.00 0.000 0.000
#> SRR1047815     1   0.000      1.000 1.00  0 0.00 0.000 0.000
#> SRR1047816     1   0.000      1.000 1.00  0 0.00 0.000 0.000
#> SRR1047817     1   0.000      1.000 1.00  0 0.00 0.000 0.000
#> SRR1047818     4   0.000      1.000 0.00  0 0.00 1.000 0.000
#> SRR1047819     4   0.000      1.000 0.00  0 0.00 1.000 0.000
#> SRR1047820     4   0.000      1.000 0.00  0 0.00 1.000 0.000
#> SRR1047821     4   0.000      1.000 0.00  0 0.00 1.000 0.000
#> SRR1047822     4   0.000      1.000 0.00  0 0.00 1.000 0.000
#> SRR1047823     4   0.000      1.000 0.00  0 0.00 1.000 0.000
#> SRR1047824     4   0.000      1.000 0.00  0 0.00 1.000 0.000
#> SRR1047825     4   0.000      1.000 0.00  0 0.00 1.000 0.000
#> SRR1047826     4   0.000      1.000 0.00  0 0.00 1.000 0.000
#> SRR1047827     4   0.000      1.000 0.00  0 0.00 1.000 0.000
#> SRR1047828     5   0.000      0.823 0.00  0 0.00 0.000 1.000
#> SRR1047829     5   0.000      0.823 0.00  0 0.00 0.000 1.000
#> SRR1047830     5   0.000      0.823 0.00  0 0.00 0.000 1.000
#> SRR1047831     5   0.000      0.823 0.00  0 0.00 0.000 1.000
#> SRR1047832     5   0.000      0.823 0.00  0 0.00 0.000 1.000
#> SRR1047833     2   0.000      1.000 0.00  1 0.00 0.000 0.000
#> SRR1047834     2   0.000      1.000 0.00  1 0.00 0.000 0.000
#> SRR1047835     2   0.000      1.000 0.00  1 0.00 0.000 0.000
#> SRR1047836     2   0.000      1.000 0.00  1 0.00 0.000 0.000
#> SRR1047837     2   0.000      1.000 0.00  1 0.00 0.000 0.000
#> SRR1047838     4   0.000      1.000 0.00  0 0.00 1.000 0.000
#> SRR1047839     4   0.000      1.000 0.00  0 0.00 1.000 0.000
#> SRR1047840     4   0.000      1.000 0.00  0 0.00 1.000 0.000
#> SRR1047841     4   0.000      1.000 0.00  0 0.00 1.000 0.000
#> SRR1047842     4   0.000      1.000 0.00  0 0.00 1.000 0.000
#> SRR1047843     5   0.104      0.831 0.04  0 0.00 0.000 0.960
#> SRR1047844     5   0.104      0.831 0.04  0 0.00 0.000 0.960
#> SRR1047845     5   0.104      0.831 0.04  0 0.00 0.000 0.960
#> SRR1047846     5   0.104      0.831 0.04  0 0.00 0.000 0.960
#> SRR1047847     5   0.104      0.831 0.04  0 0.00 0.000 0.960
#> SRR1047848     1   0.000      1.000 1.00  0 0.00 0.000 0.000
#> SRR1047849     1   0.000      1.000 1.00  0 0.00 0.000 0.000
#> SRR1047850     1   0.000      1.000 1.00  0 0.00 0.000 0.000
#> SRR1047851     1   0.000      1.000 1.00  0 0.00 0.000 0.000
#> SRR1047852     1   0.000      1.000 1.00  0 0.00 0.000 0.000
#> SRR1047853     5   0.422      0.425 0.00  0 0.00 0.416 0.584
#> SRR1047854     5   0.422      0.425 0.00  0 0.00 0.416 0.584
#> SRR1047855     5   0.422      0.425 0.00  0 0.00 0.416 0.584
#> SRR1047856     5   0.422      0.425 0.00  0 0.00 0.416 0.584
#> SRR1047857     5   0.422      0.425 0.00  0 0.00 0.416 0.584
#> SRR1047858     5   0.104      0.831 0.04  0 0.00 0.000 0.960
#> SRR1047859     5   0.104      0.831 0.04  0 0.00 0.000 0.960
#> SRR1047860     5   0.104      0.831 0.04  0 0.00 0.000 0.960
#> SRR1047861     5   0.104      0.831 0.04  0 0.00 0.000 0.960
#> SRR1047863     3   0.104      0.957 0.00  0 0.96 0.000 0.040
#> SRR1047864     3   0.000      0.978 0.00  0 1.00 0.000 0.000
#> SRR1047865     3   0.104      0.956 0.04  0 0.96 0.000 0.000
#> SRR1047866     3   0.104      0.956 0.04  0 0.96 0.000 0.000
#> SRR1047867     3   0.000      0.978 0.00  0 1.00 0.000 0.000
#> SRR1047868     3   0.104      0.957 0.00  0 0.96 0.000 0.040
#> SRR1047869     3   0.104      0.956 0.04  0 0.96 0.000 0.000
#> SRR1047870     3   0.000      0.978 0.00  0 1.00 0.000 0.000
#> SRR1047871     3   0.000      0.978 0.00  0 1.00 0.000 0.000
#> SRR1047872     3   0.000      0.978 0.00  0 1.00 0.000 0.000
#> SRR1047873     3   0.000      0.978 0.00  0 1.00 0.000 0.000
#> SRR1047874     3   0.000      0.978 0.00  0 1.00 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
#> SRR1047813     1   0.000      1.000  1  0  0 0.000 0.000 0.0
#> SRR1047814     1   0.000      1.000  1  0  0 0.000 0.000 0.0
#> SRR1047815     1   0.000      1.000  1  0  0 0.000 0.000 0.0
#> SRR1047816     1   0.000      1.000  1  0  0 0.000 0.000 0.0
#> SRR1047817     1   0.000      1.000  1  0  0 0.000 0.000 0.0
#> SRR1047818     4   0.000      0.681  0  0  0 1.000 0.000 0.0
#> SRR1047819     4   0.000      0.681  0  0  0 1.000 0.000 0.0
#> SRR1047820     4   0.000      0.681  0  0  0 1.000 0.000 0.0
#> SRR1047821     4   0.000      0.681  0  0  0 1.000 0.000 0.0
#> SRR1047822     4   0.000      0.681  0  0  0 1.000 0.000 0.0
#> SRR1047823     6   0.279      1.000  0  0  0 0.200 0.000 0.8
#> SRR1047824     6   0.279      1.000  0  0  0 0.200 0.000 0.8
#> SRR1047825     6   0.279      1.000  0  0  0 0.200 0.000 0.8
#> SRR1047826     6   0.279      1.000  0  0  0 0.200 0.000 0.8
#> SRR1047827     6   0.279      1.000  0  0  0 0.200 0.000 0.8
#> SRR1047828     5   0.279      0.842  0  0  0 0.000 0.800 0.2
#> SRR1047829     5   0.279      0.842  0  0  0 0.000 0.800 0.2
#> SRR1047830     5   0.279      0.842  0  0  0 0.000 0.800 0.2
#> SRR1047831     5   0.279      0.842  0  0  0 0.000 0.800 0.2
#> SRR1047832     5   0.279      0.842  0  0  0 0.000 0.800 0.2
#> SRR1047833     2   0.000      1.000  0  1  0 0.000 0.000 0.0
#> SRR1047834     2   0.000      1.000  0  1  0 0.000 0.000 0.0
#> SRR1047835     2   0.000      1.000  0  1  0 0.000 0.000 0.0
#> SRR1047836     2   0.000      1.000  0  1  0 0.000 0.000 0.0
#> SRR1047837     2   0.000      1.000  0  1  0 0.000 0.000 0.0
#> SRR1047838     4   0.000      0.681  0  0  0 1.000 0.000 0.0
#> SRR1047839     4   0.000      0.681  0  0  0 1.000 0.000 0.0
#> SRR1047840     4   0.000      0.681  0  0  0 1.000 0.000 0.0
#> SRR1047841     4   0.000      0.681  0  0  0 1.000 0.000 0.0
#> SRR1047842     4   0.000      0.681  0  0  0 1.000 0.000 0.0
#> SRR1047843     5   0.000      0.917  0  0  0 0.000 1.000 0.0
#> SRR1047844     5   0.000      0.917  0  0  0 0.000 1.000 0.0
#> SRR1047845     5   0.000      0.917  0  0  0 0.000 1.000 0.0
#> SRR1047846     5   0.000      0.917  0  0  0 0.000 1.000 0.0
#> SRR1047847     5   0.000      0.917  0  0  0 0.000 1.000 0.0
#> SRR1047848     1   0.000      1.000  1  0  0 0.000 0.000 0.0
#> SRR1047849     1   0.000      1.000  1  0  0 0.000 0.000 0.0
#> SRR1047850     1   0.000      1.000  1  0  0 0.000 0.000 0.0
#> SRR1047851     1   0.000      1.000  1  0  0 0.000 0.000 0.0
#> SRR1047852     1   0.000      1.000  1  0  0 0.000 0.000 0.0
#> SRR1047853     4   0.588      0.186  0  0  0 0.416 0.384 0.2
#> SRR1047854     4   0.588      0.186  0  0  0 0.416 0.384 0.2
#> SRR1047855     4   0.588      0.186  0  0  0 0.416 0.384 0.2
#> SRR1047856     4   0.588      0.186  0  0  0 0.416 0.384 0.2
#> SRR1047857     4   0.588      0.186  0  0  0 0.416 0.384 0.2
#> SRR1047858     5   0.000      0.917  0  0  0 0.000 1.000 0.0
#> SRR1047859     5   0.000      0.917  0  0  0 0.000 1.000 0.0
#> SRR1047860     5   0.000      0.917  0  0  0 0.000 1.000 0.0
#> SRR1047861     5   0.000      0.917  0  0  0 0.000 1.000 0.0
#> SRR1047863     3   0.000      1.000  0  0  1 0.000 0.000 0.0
#> SRR1047864     3   0.000      1.000  0  0  1 0.000 0.000 0.0
#> SRR1047865     3   0.000      1.000  0  0  1 0.000 0.000 0.0
#> SRR1047866     3   0.000      1.000  0  0  1 0.000 0.000 0.0
#> SRR1047867     3   0.000      1.000  0  0  1 0.000 0.000 0.0
#> SRR1047868     3   0.000      1.000  0  0  1 0.000 0.000 0.0
#> SRR1047869     3   0.000      1.000  0  0  1 0.000 0.000 0.0
#> SRR1047870     3   0.000      1.000  0  0  1 0.000 0.000 0.0
#> SRR1047871     3   0.000      1.000  0  0  1 0.000 0.000 0.0
#> SRR1047872     3   0.000      1.000  0  0  1 0.000 0.000 0.0
#> SRR1047873     3   0.000      1.000  0  0  1 0.000 0.000 0.0
#> SRR1047874     3   0.000      1.000  0  0  1 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-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 17931 rows and 61 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 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-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.758           0.935       0.966         0.2247 0.820   0.820
#> 3 3 0.722           0.798       0.917         1.4593 0.560   0.476
#> 4 4 0.881           0.888       0.952         0.2720 0.747   0.477
#> 5 5 0.706           0.753       0.858         0.1111 0.790   0.410
#> 6 6 0.742           0.618       0.812         0.0479 0.987   0.936

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

suggest_best_k(res)
#> [1] 4

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette    p1    p2
#> SRR1047813     1  0.0000      0.959 1.000 0.000
#> SRR1047814     1  0.0000      0.959 1.000 0.000
#> SRR1047815     1  0.0000      0.959 1.000 0.000
#> SRR1047816     1  0.0000      0.959 1.000 0.000
#> SRR1047817     1  0.0000      0.959 1.000 0.000
#> SRR1047818     1  0.7219      0.795 0.800 0.200
#> SRR1047819     1  0.7299      0.791 0.796 0.204
#> SRR1047820     1  0.7219      0.795 0.800 0.200
#> SRR1047821     1  0.7299      0.791 0.796 0.204
#> SRR1047822     1  0.7376      0.786 0.792 0.208
#> SRR1047823     1  0.7056      0.804 0.808 0.192
#> SRR1047824     1  0.7056      0.804 0.808 0.192
#> SRR1047825     1  0.7056      0.804 0.808 0.192
#> SRR1047826     1  0.7056      0.804 0.808 0.192
#> SRR1047827     1  0.7056      0.804 0.808 0.192
#> SRR1047828     1  0.0000      0.959 1.000 0.000
#> SRR1047829     1  0.0000      0.959 1.000 0.000
#> SRR1047830     1  0.0000      0.959 1.000 0.000
#> SRR1047831     1  0.0000      0.959 1.000 0.000
#> SRR1047832     1  0.0000      0.959 1.000 0.000
#> SRR1047833     2  0.0000      0.998 0.000 1.000
#> SRR1047834     2  0.0000      0.998 0.000 1.000
#> SRR1047835     2  0.0000      0.998 0.000 1.000
#> SRR1047836     2  0.0000      0.998 0.000 1.000
#> SRR1047837     2  0.0000      0.998 0.000 1.000
#> SRR1047838     1  0.0000      0.959 1.000 0.000
#> SRR1047839     1  0.0000      0.959 1.000 0.000
#> SRR1047840     1  0.0000      0.959 1.000 0.000
#> SRR1047841     1  0.0000      0.959 1.000 0.000
#> SRR1047842     1  0.0000      0.959 1.000 0.000
#> SRR1047843     1  0.0000      0.959 1.000 0.000
#> SRR1047844     1  0.0000      0.959 1.000 0.000
#> SRR1047845     1  0.0000      0.959 1.000 0.000
#> SRR1047846     1  0.0000      0.959 1.000 0.000
#> SRR1047847     1  0.0000      0.959 1.000 0.000
#> SRR1047848     1  0.0000      0.959 1.000 0.000
#> SRR1047849     1  0.0000      0.959 1.000 0.000
#> SRR1047850     1  0.0000      0.959 1.000 0.000
#> SRR1047851     1  0.0000      0.959 1.000 0.000
#> SRR1047852     1  0.0000      0.959 1.000 0.000
#> SRR1047853     1  0.0000      0.959 1.000 0.000
#> SRR1047854     1  0.0000      0.959 1.000 0.000
#> SRR1047855     1  0.0000      0.959 1.000 0.000
#> SRR1047856     1  0.0000      0.959 1.000 0.000
#> SRR1047857     1  0.0000      0.959 1.000 0.000
#> SRR1047858     1  0.0000      0.959 1.000 0.000
#> SRR1047859     1  0.0000      0.959 1.000 0.000
#> SRR1047860     1  0.0000      0.959 1.000 0.000
#> SRR1047861     1  0.0000      0.959 1.000 0.000
#> SRR1047863     1  0.0000      0.959 1.000 0.000
#> SRR1047864     1  0.0000      0.959 1.000 0.000
#> SRR1047865     1  0.0000      0.959 1.000 0.000
#> SRR1047866     1  0.0000      0.959 1.000 0.000
#> SRR1047867     2  0.0672      0.991 0.008 0.992
#> SRR1047868     1  0.0000      0.959 1.000 0.000
#> SRR1047869     1  0.0000      0.959 1.000 0.000
#> SRR1047870     1  0.5059      0.876 0.888 0.112
#> SRR1047871     1  0.0000      0.959 1.000 0.000
#> SRR1047872     1  0.0000      0.959 1.000 0.000
#> SRR1047873     1  0.0000      0.959 1.000 0.000
#> SRR1047874     1  0.0000      0.959 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1047813     1  0.0000     0.9655 1.000 0.000 0.000
#> SRR1047814     1  0.0000     0.9655 1.000 0.000 0.000
#> SRR1047815     1  0.0000     0.9655 1.000 0.000 0.000
#> SRR1047816     1  0.0000     0.9655 1.000 0.000 0.000
#> SRR1047817     1  0.0000     0.9655 1.000 0.000 0.000
#> SRR1047818     2  0.8470     0.3574 0.104 0.552 0.344
#> SRR1047819     2  0.7741     0.4365 0.376 0.568 0.056
#> SRR1047820     2  0.8087     0.4571 0.364 0.560 0.076
#> SRR1047821     2  0.8421     0.4310 0.116 0.584 0.300
#> SRR1047822     3  0.6126     0.1689 0.000 0.400 0.600
#> SRR1047823     1  0.1989     0.9323 0.948 0.048 0.004
#> SRR1047824     1  0.2496     0.9146 0.928 0.068 0.004
#> SRR1047825     1  0.1129     0.9523 0.976 0.020 0.004
#> SRR1047826     1  0.1399     0.9470 0.968 0.028 0.004
#> SRR1047827     1  0.2096     0.9291 0.944 0.052 0.004
#> SRR1047828     1  0.0000     0.9655 1.000 0.000 0.000
#> SRR1047829     1  0.0000     0.9655 1.000 0.000 0.000
#> SRR1047830     1  0.0000     0.9655 1.000 0.000 0.000
#> SRR1047831     1  0.0000     0.9655 1.000 0.000 0.000
#> SRR1047832     1  0.0000     0.9655 1.000 0.000 0.000
#> SRR1047833     2  0.0000     0.7269 0.000 1.000 0.000
#> SRR1047834     2  0.0000     0.7269 0.000 1.000 0.000
#> SRR1047835     2  0.0000     0.7269 0.000 1.000 0.000
#> SRR1047836     2  0.0000     0.7269 0.000 1.000 0.000
#> SRR1047837     2  0.0000     0.7269 0.000 1.000 0.000
#> SRR1047838     1  0.3918     0.8506 0.868 0.120 0.012
#> SRR1047839     3  0.8979     0.0836 0.420 0.128 0.452
#> SRR1047840     1  0.3695     0.8654 0.880 0.108 0.012
#> SRR1047841     1  0.4209     0.8359 0.856 0.128 0.016
#> SRR1047842     1  0.4277     0.8302 0.852 0.132 0.016
#> SRR1047843     1  0.0000     0.9655 1.000 0.000 0.000
#> SRR1047844     1  0.2878     0.8661 0.904 0.000 0.096
#> SRR1047845     1  0.0000     0.9655 1.000 0.000 0.000
#> SRR1047846     1  0.0000     0.9655 1.000 0.000 0.000
#> SRR1047847     1  0.2711     0.8766 0.912 0.000 0.088
#> SRR1047848     1  0.0000     0.9655 1.000 0.000 0.000
#> SRR1047849     1  0.0000     0.9655 1.000 0.000 0.000
#> SRR1047850     1  0.0000     0.9655 1.000 0.000 0.000
#> SRR1047851     1  0.0000     0.9655 1.000 0.000 0.000
#> SRR1047852     1  0.0000     0.9655 1.000 0.000 0.000
#> SRR1047853     3  0.6305     0.1808 0.484 0.000 0.516
#> SRR1047854     1  0.0424     0.9604 0.992 0.000 0.008
#> SRR1047855     1  0.0424     0.9604 0.992 0.000 0.008
#> SRR1047856     3  0.6140     0.3182 0.404 0.000 0.596
#> SRR1047857     3  0.5216     0.5052 0.260 0.000 0.740
#> SRR1047858     1  0.0000     0.9655 1.000 0.000 0.000
#> SRR1047859     1  0.0000     0.9655 1.000 0.000 0.000
#> SRR1047860     1  0.0000     0.9655 1.000 0.000 0.000
#> SRR1047861     1  0.0000     0.9655 1.000 0.000 0.000
#> SRR1047863     3  0.0237     0.7792 0.004 0.000 0.996
#> SRR1047864     3  0.0237     0.7792 0.004 0.000 0.996
#> SRR1047865     3  0.0237     0.7792 0.004 0.000 0.996
#> SRR1047866     3  0.0237     0.7792 0.004 0.000 0.996
#> SRR1047867     3  0.4702     0.5586 0.000 0.212 0.788
#> SRR1047868     3  0.0000     0.7774 0.000 0.000 1.000
#> SRR1047869     3  0.0237     0.7792 0.004 0.000 0.996
#> SRR1047870     3  0.0000     0.7774 0.000 0.000 1.000
#> SRR1047871     3  0.0237     0.7792 0.004 0.000 0.996
#> SRR1047872     3  0.0000     0.7774 0.000 0.000 1.000
#> SRR1047873     3  0.0000     0.7774 0.000 0.000 1.000
#> SRR1047874     3  0.0237     0.7792 0.004 0.000 0.996

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1047813     1  0.0000      0.930 1.000 0.000 0.000 0.000
#> SRR1047814     1  0.0000      0.930 1.000 0.000 0.000 0.000
#> SRR1047815     1  0.0000      0.930 1.000 0.000 0.000 0.000
#> SRR1047816     1  0.0000      0.930 1.000 0.000 0.000 0.000
#> SRR1047817     1  0.0000      0.930 1.000 0.000 0.000 0.000
#> SRR1047818     4  0.0000      0.910 0.000 0.000 0.000 1.000
#> SRR1047819     4  0.0000      0.910 0.000 0.000 0.000 1.000
#> SRR1047820     4  0.0000      0.910 0.000 0.000 0.000 1.000
#> SRR1047821     4  0.0000      0.910 0.000 0.000 0.000 1.000
#> SRR1047822     4  0.0188      0.908 0.000 0.000 0.004 0.996
#> SRR1047823     4  0.0707      0.905 0.020 0.000 0.000 0.980
#> SRR1047824     4  0.0592      0.907 0.016 0.000 0.000 0.984
#> SRR1047825     4  0.0921      0.901 0.028 0.000 0.000 0.972
#> SRR1047826     4  0.0921      0.901 0.028 0.000 0.000 0.972
#> SRR1047827     4  0.0592      0.907 0.016 0.000 0.000 0.984
#> SRR1047828     1  0.0336      0.927 0.992 0.008 0.000 0.000
#> SRR1047829     1  0.1022      0.913 0.968 0.032 0.000 0.000
#> SRR1047830     1  0.0336      0.927 0.992 0.008 0.000 0.000
#> SRR1047831     1  0.0336      0.927 0.992 0.008 0.000 0.000
#> SRR1047832     1  0.0592      0.922 0.984 0.016 0.000 0.000
#> SRR1047833     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR1047834     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR1047835     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR1047836     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR1047837     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR1047838     4  0.0000      0.910 0.000 0.000 0.000 1.000
#> SRR1047839     4  0.0000      0.910 0.000 0.000 0.000 1.000
#> SRR1047840     4  0.0000      0.910 0.000 0.000 0.000 1.000
#> SRR1047841     4  0.0000      0.910 0.000 0.000 0.000 1.000
#> SRR1047842     4  0.0000      0.910 0.000 0.000 0.000 1.000
#> SRR1047843     1  0.0188      0.930 0.996 0.000 0.000 0.004
#> SRR1047844     1  0.2281      0.857 0.904 0.000 0.096 0.000
#> SRR1047845     1  0.0188      0.930 0.996 0.000 0.000 0.004
#> SRR1047846     1  0.0188      0.930 0.996 0.000 0.000 0.004
#> SRR1047847     1  0.2216      0.861 0.908 0.000 0.092 0.000
#> SRR1047848     1  0.0188      0.930 0.996 0.000 0.000 0.004
#> SRR1047849     1  0.0188      0.930 0.996 0.000 0.000 0.004
#> SRR1047850     1  0.0188      0.930 0.996 0.000 0.000 0.004
#> SRR1047851     1  0.0188      0.930 0.996 0.000 0.000 0.004
#> SRR1047852     1  0.0188      0.930 0.996 0.000 0.000 0.004
#> SRR1047853     4  0.4241      0.790 0.036 0.012 0.124 0.828
#> SRR1047854     4  0.5097      0.246 0.428 0.000 0.004 0.568
#> SRR1047855     4  0.5328      0.102 0.472 0.004 0.004 0.520
#> SRR1047856     4  0.3850      0.809 0.032 0.008 0.112 0.848
#> SRR1047857     4  0.1938      0.878 0.012 0.000 0.052 0.936
#> SRR1047858     1  0.4134      0.672 0.740 0.000 0.000 0.260
#> SRR1047859     1  0.4250      0.646 0.724 0.000 0.000 0.276
#> SRR1047860     1  0.4164      0.666 0.736 0.000 0.000 0.264
#> SRR1047861     1  0.4164      0.666 0.736 0.000 0.000 0.264
#> SRR1047863     3  0.0000      0.983 0.000 0.000 1.000 0.000
#> SRR1047864     3  0.0000      0.983 0.000 0.000 1.000 0.000
#> SRR1047865     3  0.0000      0.983 0.000 0.000 1.000 0.000
#> SRR1047866     3  0.0000      0.983 0.000 0.000 1.000 0.000
#> SRR1047867     3  0.2530      0.877 0.000 0.112 0.888 0.000
#> SRR1047868     3  0.0000      0.983 0.000 0.000 1.000 0.000
#> SRR1047869     3  0.0000      0.983 0.000 0.000 1.000 0.000
#> SRR1047870     3  0.0000      0.983 0.000 0.000 1.000 0.000
#> SRR1047871     3  0.0000      0.983 0.000 0.000 1.000 0.000
#> SRR1047872     3  0.1557      0.918 0.000 0.000 0.944 0.056
#> SRR1047873     3  0.0000      0.983 0.000 0.000 1.000 0.000
#> SRR1047874     3  0.0000      0.983 0.000 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4    p5
#> SRR1047813     5  0.3508     0.7564 0.252 0.000 0.000 0.000 0.748
#> SRR1047814     5  0.3508     0.7564 0.252 0.000 0.000 0.000 0.748
#> SRR1047815     5  0.3508     0.7564 0.252 0.000 0.000 0.000 0.748
#> SRR1047816     5  0.3508     0.7564 0.252 0.000 0.000 0.000 0.748
#> SRR1047817     5  0.3480     0.7570 0.248 0.000 0.000 0.000 0.752
#> SRR1047818     4  0.0404     0.8853 0.000 0.000 0.000 0.988 0.012
#> SRR1047819     4  0.0162     0.8847 0.000 0.000 0.000 0.996 0.004
#> SRR1047820     4  0.0000     0.8866 0.000 0.000 0.000 1.000 0.000
#> SRR1047821     4  0.0290     0.8870 0.000 0.000 0.000 0.992 0.008
#> SRR1047822     4  0.0703     0.8757 0.000 0.000 0.000 0.976 0.024
#> SRR1047823     1  0.5264     0.0323 0.500 0.016 0.000 0.464 0.020
#> SRR1047824     4  0.5181     0.1939 0.400 0.016 0.000 0.564 0.020
#> SRR1047825     1  0.5225     0.2750 0.576 0.016 0.000 0.384 0.024
#> SRR1047826     1  0.5292     0.1908 0.544 0.016 0.000 0.416 0.024
#> SRR1047827     4  0.5254     0.0278 0.448 0.016 0.000 0.516 0.020
#> SRR1047828     5  0.6452     0.6418 0.284 0.220 0.000 0.000 0.496
#> SRR1047829     5  0.6873     0.6134 0.228 0.268 0.016 0.000 0.488
#> SRR1047830     5  0.6467     0.6403 0.272 0.232 0.000 0.000 0.496
#> SRR1047831     5  0.6387     0.6549 0.272 0.216 0.000 0.000 0.512
#> SRR1047832     5  0.6477     0.6307 0.248 0.256 0.000 0.000 0.496
#> SRR1047833     2  0.0000     1.0000 0.000 1.000 0.000 0.000 0.000
#> SRR1047834     2  0.0000     1.0000 0.000 1.000 0.000 0.000 0.000
#> SRR1047835     2  0.0000     1.0000 0.000 1.000 0.000 0.000 0.000
#> SRR1047836     2  0.0000     1.0000 0.000 1.000 0.000 0.000 0.000
#> SRR1047837     2  0.0000     1.0000 0.000 1.000 0.000 0.000 0.000
#> SRR1047838     4  0.0162     0.8878 0.000 0.000 0.000 0.996 0.004
#> SRR1047839     4  0.1121     0.8603 0.000 0.000 0.000 0.956 0.044
#> SRR1047840     4  0.0404     0.8789 0.000 0.000 0.000 0.988 0.012
#> SRR1047841     4  0.0162     0.8878 0.000 0.000 0.000 0.996 0.004
#> SRR1047842     4  0.0162     0.8878 0.000 0.000 0.000 0.996 0.004
#> SRR1047843     1  0.3165     0.7521 0.848 0.000 0.000 0.036 0.116
#> SRR1047844     3  0.5631     0.6126 0.200 0.000 0.684 0.040 0.076
#> SRR1047845     1  0.3099     0.7503 0.848 0.000 0.000 0.028 0.124
#> SRR1047846     1  0.2879     0.7666 0.868 0.000 0.000 0.032 0.100
#> SRR1047847     3  0.5715     0.6046 0.204 0.000 0.676 0.040 0.080
#> SRR1047848     1  0.0000     0.8277 1.000 0.000 0.000 0.000 0.000
#> SRR1047849     1  0.0000     0.8277 1.000 0.000 0.000 0.000 0.000
#> SRR1047850     1  0.0000     0.8277 1.000 0.000 0.000 0.000 0.000
#> SRR1047851     1  0.0000     0.8277 1.000 0.000 0.000 0.000 0.000
#> SRR1047852     1  0.0000     0.8277 1.000 0.000 0.000 0.000 0.000
#> SRR1047853     5  0.2929     0.6739 0.000 0.000 0.000 0.180 0.820
#> SRR1047854     5  0.3039     0.6899 0.012 0.000 0.000 0.152 0.836
#> SRR1047855     5  0.3098     0.6924 0.016 0.000 0.000 0.148 0.836
#> SRR1047856     5  0.3086     0.6738 0.000 0.000 0.004 0.180 0.816
#> SRR1047857     5  0.3305     0.6310 0.000 0.000 0.000 0.224 0.776
#> SRR1047858     1  0.0000     0.8277 1.000 0.000 0.000 0.000 0.000
#> SRR1047859     1  0.0798     0.8212 0.976 0.000 0.000 0.008 0.016
#> SRR1047860     1  0.0162     0.8272 0.996 0.000 0.000 0.000 0.004
#> SRR1047861     1  0.0324     0.8269 0.992 0.000 0.000 0.004 0.004
#> SRR1047863     3  0.0000     0.8973 0.000 0.000 1.000 0.000 0.000
#> SRR1047864     3  0.0162     0.8959 0.000 0.000 0.996 0.000 0.004
#> SRR1047865     3  0.0000     0.8973 0.000 0.000 1.000 0.000 0.000
#> SRR1047866     3  0.0000     0.8973 0.000 0.000 1.000 0.000 0.000
#> SRR1047867     3  0.4367     0.3755 0.000 0.372 0.620 0.000 0.008
#> SRR1047868     3  0.0000     0.8973 0.000 0.000 1.000 0.000 0.000
#> SRR1047869     3  0.0000     0.8973 0.000 0.000 1.000 0.000 0.000
#> SRR1047870     3  0.0000     0.8973 0.000 0.000 1.000 0.000 0.000
#> SRR1047871     3  0.0000     0.8973 0.000 0.000 1.000 0.000 0.000
#> SRR1047872     3  0.2561     0.7823 0.000 0.000 0.856 0.144 0.000
#> SRR1047873     3  0.0703     0.8845 0.000 0.000 0.976 0.024 0.000
#> SRR1047874     3  0.0162     0.8958 0.000 0.000 0.996 0.004 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR1047813     5  0.0777    0.74523 0.024 0.000 0.000 0.000 0.972 0.004
#> SRR1047814     5  0.0891    0.74473 0.024 0.000 0.000 0.000 0.968 0.008
#> SRR1047815     5  0.0891    0.74473 0.024 0.000 0.000 0.000 0.968 0.008
#> SRR1047816     5  0.0632    0.74440 0.024 0.000 0.000 0.000 0.976 0.000
#> SRR1047817     5  0.1261    0.74060 0.024 0.000 0.000 0.000 0.952 0.024
#> SRR1047818     4  0.0405    0.86537 0.000 0.000 0.000 0.988 0.004 0.008
#> SRR1047819     4  0.0508    0.86456 0.000 0.000 0.000 0.984 0.004 0.012
#> SRR1047820     4  0.0508    0.86456 0.000 0.000 0.000 0.984 0.004 0.012
#> SRR1047821     4  0.0405    0.86537 0.000 0.000 0.000 0.988 0.004 0.008
#> SRR1047822     4  0.0858    0.86175 0.000 0.000 0.000 0.968 0.004 0.028
#> SRR1047823     1  0.6040   -0.00972 0.448 0.004 0.000 0.416 0.028 0.104
#> SRR1047824     4  0.5671    0.13443 0.372 0.004 0.000 0.512 0.012 0.100
#> SRR1047825     1  0.6036    0.09932 0.484 0.004 0.000 0.376 0.028 0.108
#> SRR1047826     1  0.6022    0.05948 0.472 0.004 0.000 0.392 0.028 0.104
#> SRR1047827     4  0.5834    0.00160 0.412 0.004 0.000 0.464 0.016 0.104
#> SRR1047828     5  0.6018    0.62055 0.108 0.124 0.000 0.000 0.620 0.148
#> SRR1047829     5  0.6373    0.60836 0.044 0.140 0.052 0.000 0.620 0.144
#> SRR1047830     5  0.5861    0.63143 0.084 0.124 0.000 0.000 0.632 0.160
#> SRR1047831     5  0.5693    0.64143 0.076 0.116 0.000 0.000 0.648 0.160
#> SRR1047832     5  0.6052    0.63329 0.068 0.120 0.016 0.000 0.636 0.160
#> SRR1047833     2  0.0000    1.00000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1047834     2  0.0000    1.00000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1047835     2  0.0000    1.00000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1047836     2  0.0000    1.00000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1047837     2  0.0000    1.00000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1047838     4  0.0935    0.86372 0.004 0.000 0.000 0.964 0.000 0.032
#> SRR1047839     4  0.1843    0.82549 0.004 0.000 0.000 0.912 0.004 0.080
#> SRR1047840     4  0.0717    0.86531 0.008 0.000 0.000 0.976 0.000 0.016
#> SRR1047841     4  0.0937    0.86110 0.000 0.000 0.000 0.960 0.000 0.040
#> SRR1047842     4  0.0937    0.86110 0.000 0.000 0.000 0.960 0.000 0.040
#> SRR1047843     1  0.5104   -0.65251 0.496 0.000 0.004 0.004 0.056 0.440
#> SRR1047844     6  0.6518    0.96403 0.360 0.000 0.116 0.016 0.040 0.468
#> SRR1047845     1  0.5384   -0.68284 0.480 0.000 0.012 0.004 0.064 0.440
#> SRR1047846     1  0.5338   -0.67599 0.484 0.000 0.012 0.004 0.060 0.440
#> SRR1047847     6  0.6471    0.96351 0.368 0.000 0.100 0.020 0.040 0.472
#> SRR1047848     1  0.1092    0.45395 0.960 0.000 0.000 0.000 0.020 0.020
#> SRR1047849     1  0.0547    0.45962 0.980 0.000 0.000 0.000 0.020 0.000
#> SRR1047850     1  0.0547    0.45962 0.980 0.000 0.000 0.000 0.020 0.000
#> SRR1047851     1  0.0547    0.45962 0.980 0.000 0.000 0.000 0.020 0.000
#> SRR1047852     1  0.0547    0.45962 0.980 0.000 0.000 0.000 0.020 0.000
#> SRR1047853     5  0.4952    0.58983 0.008 0.000 0.000 0.132 0.672 0.188
#> SRR1047854     5  0.3635    0.68568 0.008 0.000 0.000 0.068 0.804 0.120
#> SRR1047855     5  0.3419    0.69341 0.008 0.000 0.000 0.056 0.820 0.116
#> SRR1047856     5  0.5156    0.56375 0.008 0.000 0.000 0.140 0.644 0.208
#> SRR1047857     5  0.5768    0.41228 0.008 0.000 0.000 0.168 0.532 0.292
#> SRR1047858     1  0.3736    0.40952 0.776 0.000 0.000 0.000 0.156 0.068
#> SRR1047859     1  0.4131    0.38488 0.744 0.000 0.000 0.000 0.156 0.100
#> SRR1047860     1  0.3842    0.40606 0.768 0.000 0.000 0.000 0.156 0.076
#> SRR1047861     1  0.3893    0.40309 0.764 0.000 0.000 0.000 0.156 0.080
#> SRR1047863     3  0.1714    0.88347 0.000 0.000 0.908 0.000 0.000 0.092
#> SRR1047864     3  0.1556    0.88379 0.000 0.000 0.920 0.000 0.000 0.080
#> SRR1047865     3  0.0146    0.90446 0.000 0.000 0.996 0.000 0.000 0.004
#> SRR1047866     3  0.0146    0.90446 0.000 0.000 0.996 0.000 0.000 0.004
#> SRR1047867     3  0.5480    0.49761 0.000 0.252 0.580 0.000 0.004 0.164
#> SRR1047868     3  0.0000    0.90431 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1047869     3  0.1007    0.88945 0.000 0.000 0.956 0.000 0.000 0.044
#> SRR1047870     3  0.1610    0.88243 0.000 0.000 0.916 0.000 0.000 0.084
#> SRR1047871     3  0.0146    0.90442 0.000 0.000 0.996 0.000 0.000 0.004
#> SRR1047872     3  0.3154    0.74137 0.000 0.000 0.800 0.184 0.004 0.012
#> SRR1047873     3  0.1225    0.89114 0.000 0.000 0.952 0.036 0.000 0.012
#> SRR1047874     3  0.1575    0.88625 0.000 0.000 0.936 0.032 0.000 0.032

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

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

collect_plots(res)

plot of chunk ATC-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.998       0.999        0.18291 0.820   0.820
#> 3 3 0.812           0.845       0.937        0.75977 0.942   0.929
#> 4 4 0.805           0.828       0.938        0.00802 0.997   0.996
#> 5 5 0.757           0.925       0.971        0.44169 0.784   0.715
#> 6 6 0.658           0.731       0.819        0.43631 0.762   0.562

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
#> SRR1047813     1   0.000      0.999 1.000 0.000
#> SRR1047814     1   0.000      0.999 1.000 0.000
#> SRR1047815     1   0.000      0.999 1.000 0.000
#> SRR1047816     1   0.000      0.999 1.000 0.000
#> SRR1047817     1   0.000      0.999 1.000 0.000
#> SRR1047818     1   0.000      0.999 1.000 0.000
#> SRR1047819     1   0.000      0.999 1.000 0.000
#> SRR1047820     1   0.000      0.999 1.000 0.000
#> SRR1047821     1   0.000      0.999 1.000 0.000
#> SRR1047822     1   0.000      0.999 1.000 0.000
#> SRR1047823     1   0.000      0.999 1.000 0.000
#> SRR1047824     1   0.000      0.999 1.000 0.000
#> SRR1047825     1   0.000      0.999 1.000 0.000
#> SRR1047826     1   0.000      0.999 1.000 0.000
#> SRR1047827     1   0.000      0.999 1.000 0.000
#> SRR1047828     1   0.000      0.999 1.000 0.000
#> SRR1047829     1   0.000      0.999 1.000 0.000
#> SRR1047830     1   0.000      0.999 1.000 0.000
#> SRR1047831     1   0.000      0.999 1.000 0.000
#> SRR1047832     1   0.000      0.999 1.000 0.000
#> SRR1047833     2   0.000      1.000 0.000 1.000
#> SRR1047834     2   0.000      1.000 0.000 1.000
#> SRR1047835     2   0.000      1.000 0.000 1.000
#> SRR1047836     2   0.000      1.000 0.000 1.000
#> SRR1047837     2   0.000      1.000 0.000 1.000
#> SRR1047838     1   0.000      0.999 1.000 0.000
#> SRR1047839     1   0.000      0.999 1.000 0.000
#> SRR1047840     1   0.000      0.999 1.000 0.000
#> SRR1047841     1   0.000      0.999 1.000 0.000
#> SRR1047842     1   0.000      0.999 1.000 0.000
#> SRR1047843     1   0.000      0.999 1.000 0.000
#> SRR1047844     1   0.000      0.999 1.000 0.000
#> SRR1047845     1   0.000      0.999 1.000 0.000
#> SRR1047846     1   0.000      0.999 1.000 0.000
#> SRR1047847     1   0.000      0.999 1.000 0.000
#> SRR1047848     1   0.000      0.999 1.000 0.000
#> SRR1047849     1   0.000      0.999 1.000 0.000
#> SRR1047850     1   0.000      0.999 1.000 0.000
#> SRR1047851     1   0.000      0.999 1.000 0.000
#> SRR1047852     1   0.000      0.999 1.000 0.000
#> SRR1047853     1   0.000      0.999 1.000 0.000
#> SRR1047854     1   0.000      0.999 1.000 0.000
#> SRR1047855     1   0.000      0.999 1.000 0.000
#> SRR1047856     1   0.000      0.999 1.000 0.000
#> SRR1047857     1   0.000      0.999 1.000 0.000
#> SRR1047858     1   0.000      0.999 1.000 0.000
#> SRR1047859     1   0.000      0.999 1.000 0.000
#> SRR1047860     1   0.000      0.999 1.000 0.000
#> SRR1047861     1   0.000      0.999 1.000 0.000
#> SRR1047863     1   0.000      0.999 1.000 0.000
#> SRR1047864     1   0.358      0.927 0.932 0.068
#> SRR1047865     1   0.000      0.999 1.000 0.000
#> SRR1047866     1   0.000      0.999 1.000 0.000
#> SRR1047867     2   0.000      1.000 0.000 1.000
#> SRR1047868     1   0.000      0.999 1.000 0.000
#> SRR1047869     1   0.000      0.999 1.000 0.000
#> SRR1047870     1   0.000      0.999 1.000 0.000
#> SRR1047871     1   0.000      0.999 1.000 0.000
#> SRR1047872     1   0.000      0.999 1.000 0.000
#> SRR1047873     1   0.000      0.999 1.000 0.000
#> SRR1047874     1   0.000      0.999 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1047813     1  0.0000      0.920 1.000 0.000 0.000
#> SRR1047814     1  0.0000      0.920 1.000 0.000 0.000
#> SRR1047815     1  0.0000      0.920 1.000 0.000 0.000
#> SRR1047816     1  0.0000      0.920 1.000 0.000 0.000
#> SRR1047817     1  0.0000      0.920 1.000 0.000 0.000
#> SRR1047818     1  0.0892      0.907 0.980 0.000 0.020
#> SRR1047819     1  0.0892      0.907 0.980 0.000 0.020
#> SRR1047820     1  0.0892      0.907 0.980 0.000 0.020
#> SRR1047821     1  0.0892      0.907 0.980 0.000 0.020
#> SRR1047822     1  0.0892      0.907 0.980 0.000 0.020
#> SRR1047823     1  0.0000      0.920 1.000 0.000 0.000
#> SRR1047824     1  0.0000      0.920 1.000 0.000 0.000
#> SRR1047825     1  0.0000      0.920 1.000 0.000 0.000
#> SRR1047826     1  0.0000      0.920 1.000 0.000 0.000
#> SRR1047827     1  0.0000      0.920 1.000 0.000 0.000
#> SRR1047828     1  0.0000      0.920 1.000 0.000 0.000
#> SRR1047829     1  0.0000      0.920 1.000 0.000 0.000
#> SRR1047830     1  0.0000      0.920 1.000 0.000 0.000
#> SRR1047831     1  0.0000      0.920 1.000 0.000 0.000
#> SRR1047832     1  0.0000      0.920 1.000 0.000 0.000
#> SRR1047833     2  0.0000      0.988 0.000 1.000 0.000
#> SRR1047834     2  0.0000      0.988 0.000 1.000 0.000
#> SRR1047835     2  0.0000      0.988 0.000 1.000 0.000
#> SRR1047836     2  0.0000      0.988 0.000 1.000 0.000
#> SRR1047837     2  0.0000      0.988 0.000 1.000 0.000
#> SRR1047838     1  0.0000      0.920 1.000 0.000 0.000
#> SRR1047839     1  0.0000      0.920 1.000 0.000 0.000
#> SRR1047840     1  0.0000      0.920 1.000 0.000 0.000
#> SRR1047841     1  0.0000      0.920 1.000 0.000 0.000
#> SRR1047842     1  0.0000      0.920 1.000 0.000 0.000
#> SRR1047843     1  0.0000      0.920 1.000 0.000 0.000
#> SRR1047844     1  0.0000      0.920 1.000 0.000 0.000
#> SRR1047845     1  0.0000      0.920 1.000 0.000 0.000
#> SRR1047846     1  0.0000      0.920 1.000 0.000 0.000
#> SRR1047847     1  0.0000      0.920 1.000 0.000 0.000
#> SRR1047848     1  0.0000      0.920 1.000 0.000 0.000
#> SRR1047849     1  0.0000      0.920 1.000 0.000 0.000
#> SRR1047850     1  0.0000      0.920 1.000 0.000 0.000
#> SRR1047851     1  0.0000      0.920 1.000 0.000 0.000
#> SRR1047852     1  0.0000      0.920 1.000 0.000 0.000
#> SRR1047853     1  0.0000      0.920 1.000 0.000 0.000
#> SRR1047854     1  0.0000      0.920 1.000 0.000 0.000
#> SRR1047855     1  0.0000      0.920 1.000 0.000 0.000
#> SRR1047856     1  0.0000      0.920 1.000 0.000 0.000
#> SRR1047857     1  0.0000      0.920 1.000 0.000 0.000
#> SRR1047858     1  0.0000      0.920 1.000 0.000 0.000
#> SRR1047859     1  0.0000      0.920 1.000 0.000 0.000
#> SRR1047860     1  0.0000      0.920 1.000 0.000 0.000
#> SRR1047861     1  0.0000      0.920 1.000 0.000 0.000
#> SRR1047863     1  0.6168      0.379 0.588 0.000 0.412
#> SRR1047864     3  0.0000      0.830 0.000 0.000 1.000
#> SRR1047865     1  0.6154      0.389 0.592 0.000 0.408
#> SRR1047866     3  0.2261      0.838 0.068 0.000 0.932
#> SRR1047867     2  0.2261      0.940 0.000 0.932 0.068
#> SRR1047868     1  0.6111      0.415 0.604 0.000 0.396
#> SRR1047869     1  0.6126      0.406 0.600 0.000 0.400
#> SRR1047870     1  0.6168      0.379 0.588 0.000 0.412
#> SRR1047871     1  0.6111      0.415 0.604 0.000 0.396
#> SRR1047872     1  0.6154      0.389 0.592 0.000 0.408
#> SRR1047873     1  0.6111      0.415 0.604 0.000 0.396
#> SRR1047874     1  0.6111      0.415 0.604 0.000 0.396

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1 p2    p3    p4
#> SRR1047813     1  0.0000      0.920 1.000  0 0.000 0.000
#> SRR1047814     1  0.0000      0.920 1.000  0 0.000 0.000
#> SRR1047815     1  0.0000      0.920 1.000  0 0.000 0.000
#> SRR1047816     1  0.0000      0.920 1.000  0 0.000 0.000
#> SRR1047817     1  0.0000      0.920 1.000  0 0.000 0.000
#> SRR1047818     1  0.0707      0.907 0.980  0 0.000 0.020
#> SRR1047819     1  0.0707      0.907 0.980  0 0.000 0.020
#> SRR1047820     1  0.0707      0.907 0.980  0 0.000 0.020
#> SRR1047821     1  0.0707      0.907 0.980  0 0.000 0.020
#> SRR1047822     1  0.0707      0.907 0.980  0 0.000 0.020
#> SRR1047823     1  0.0000      0.920 1.000  0 0.000 0.000
#> SRR1047824     1  0.0000      0.920 1.000  0 0.000 0.000
#> SRR1047825     1  0.0000      0.920 1.000  0 0.000 0.000
#> SRR1047826     1  0.0000      0.920 1.000  0 0.000 0.000
#> SRR1047827     1  0.0000      0.920 1.000  0 0.000 0.000
#> SRR1047828     1  0.0000      0.920 1.000  0 0.000 0.000
#> SRR1047829     1  0.0000      0.920 1.000  0 0.000 0.000
#> SRR1047830     1  0.0000      0.920 1.000  0 0.000 0.000
#> SRR1047831     1  0.0000      0.920 1.000  0 0.000 0.000
#> SRR1047832     1  0.0000      0.920 1.000  0 0.000 0.000
#> SRR1047833     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR1047834     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR1047835     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR1047836     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR1047837     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR1047838     1  0.0000      0.920 1.000  0 0.000 0.000
#> SRR1047839     1  0.0000      0.920 1.000  0 0.000 0.000
#> SRR1047840     1  0.0000      0.920 1.000  0 0.000 0.000
#> SRR1047841     1  0.0000      0.920 1.000  0 0.000 0.000
#> SRR1047842     1  0.0000      0.920 1.000  0 0.000 0.000
#> SRR1047843     1  0.0000      0.920 1.000  0 0.000 0.000
#> SRR1047844     1  0.0000      0.920 1.000  0 0.000 0.000
#> SRR1047845     1  0.0000      0.920 1.000  0 0.000 0.000
#> SRR1047846     1  0.0000      0.920 1.000  0 0.000 0.000
#> SRR1047847     1  0.0000      0.920 1.000  0 0.000 0.000
#> SRR1047848     1  0.0000      0.920 1.000  0 0.000 0.000
#> SRR1047849     1  0.0000      0.920 1.000  0 0.000 0.000
#> SRR1047850     1  0.0000      0.920 1.000  0 0.000 0.000
#> SRR1047851     1  0.0000      0.920 1.000  0 0.000 0.000
#> SRR1047852     1  0.0000      0.920 1.000  0 0.000 0.000
#> SRR1047853     1  0.0000      0.920 1.000  0 0.000 0.000
#> SRR1047854     1  0.0000      0.920 1.000  0 0.000 0.000
#> SRR1047855     1  0.0000      0.920 1.000  0 0.000 0.000
#> SRR1047856     1  0.0000      0.920 1.000  0 0.000 0.000
#> SRR1047857     1  0.0000      0.920 1.000  0 0.000 0.000
#> SRR1047858     1  0.0000      0.920 1.000  0 0.000 0.000
#> SRR1047859     1  0.0000      0.920 1.000  0 0.000 0.000
#> SRR1047860     1  0.0000      0.920 1.000  0 0.000 0.000
#> SRR1047861     1  0.0000      0.920 1.000  0 0.000 0.000
#> SRR1047863     1  0.4888      0.379 0.588  0 0.000 0.412
#> SRR1047864     3  0.4888      0.758 0.000  0 0.588 0.412
#> SRR1047865     1  0.4877      0.389 0.592  0 0.000 0.408
#> SRR1047866     3  0.6407      0.776 0.068  0 0.520 0.412
#> SRR1047867     4  0.4888      0.000 0.000  0 0.412 0.588
#> SRR1047868     1  0.4843      0.415 0.604  0 0.000 0.396
#> SRR1047869     1  0.4855      0.406 0.600  0 0.000 0.400
#> SRR1047870     1  0.4888      0.379 0.588  0 0.000 0.412
#> SRR1047871     1  0.4843      0.415 0.604  0 0.000 0.396
#> SRR1047872     1  0.4877      0.389 0.592  0 0.000 0.408
#> SRR1047873     1  0.4843      0.415 0.604  0 0.000 0.396
#> SRR1047874     1  0.4843      0.415 0.604  0 0.000 0.396

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette   p1 p2    p3    p4 p5
#> SRR1047813     4  0.0000      0.966 0.00  0 0.000 1.000  0
#> SRR1047814     4  0.0000      0.966 0.00  0 0.000 1.000  0
#> SRR1047815     4  0.0000      0.966 0.00  0 0.000 1.000  0
#> SRR1047816     4  0.0000      0.966 0.00  0 0.000 1.000  0
#> SRR1047817     4  0.0000      0.966 0.00  0 0.000 1.000  0
#> SRR1047818     4  0.2605      0.854 0.00  0 0.148 0.852  0
#> SRR1047819     4  0.2605      0.854 0.00  0 0.148 0.852  0
#> SRR1047820     4  0.2605      0.854 0.00  0 0.148 0.852  0
#> SRR1047821     4  0.2605      0.854 0.00  0 0.148 0.852  0
#> SRR1047822     4  0.2605      0.854 0.00  0 0.148 0.852  0
#> SRR1047823     4  0.0000      0.966 0.00  0 0.000 1.000  0
#> SRR1047824     4  0.0000      0.966 0.00  0 0.000 1.000  0
#> SRR1047825     4  0.0000      0.966 0.00  0 0.000 1.000  0
#> SRR1047826     4  0.0000      0.966 0.00  0 0.000 1.000  0
#> SRR1047827     4  0.0000      0.966 0.00  0 0.000 1.000  0
#> SRR1047828     4  0.2230      0.885 0.00  0 0.116 0.884  0
#> SRR1047829     4  0.2230      0.885 0.00  0 0.116 0.884  0
#> SRR1047830     4  0.2230      0.885 0.00  0 0.116 0.884  0
#> SRR1047831     4  0.2230      0.885 0.00  0 0.116 0.884  0
#> SRR1047832     4  0.2230      0.885 0.00  0 0.116 0.884  0
#> SRR1047833     2  0.0000      1.000 0.00  1 0.000 0.000  0
#> SRR1047834     2  0.0000      1.000 0.00  1 0.000 0.000  0
#> SRR1047835     2  0.0000      1.000 0.00  1 0.000 0.000  0
#> SRR1047836     2  0.0000      1.000 0.00  1 0.000 0.000  0
#> SRR1047837     2  0.0000      1.000 0.00  1 0.000 0.000  0
#> SRR1047838     4  0.0000      0.966 0.00  0 0.000 1.000  0
#> SRR1047839     4  0.0000      0.966 0.00  0 0.000 1.000  0
#> SRR1047840     4  0.0000      0.966 0.00  0 0.000 1.000  0
#> SRR1047841     4  0.0000      0.966 0.00  0 0.000 1.000  0
#> SRR1047842     4  0.0000      0.966 0.00  0 0.000 1.000  0
#> SRR1047843     4  0.0000      0.966 0.00  0 0.000 1.000  0
#> SRR1047844     4  0.0000      0.966 0.00  0 0.000 1.000  0
#> SRR1047845     4  0.0000      0.966 0.00  0 0.000 1.000  0
#> SRR1047846     4  0.0000      0.966 0.00  0 0.000 1.000  0
#> SRR1047847     4  0.0000      0.966 0.00  0 0.000 1.000  0
#> SRR1047848     4  0.0000      0.966 0.00  0 0.000 1.000  0
#> SRR1047849     4  0.0000      0.966 0.00  0 0.000 1.000  0
#> SRR1047850     4  0.0000      0.966 0.00  0 0.000 1.000  0
#> SRR1047851     4  0.0000      0.966 0.00  0 0.000 1.000  0
#> SRR1047852     4  0.0000      0.966 0.00  0 0.000 1.000  0
#> SRR1047853     4  0.0000      0.966 0.00  0 0.000 1.000  0
#> SRR1047854     4  0.0000      0.966 0.00  0 0.000 1.000  0
#> SRR1047855     4  0.0000      0.966 0.00  0 0.000 1.000  0
#> SRR1047856     4  0.0000      0.966 0.00  0 0.000 1.000  0
#> SRR1047857     4  0.0000      0.966 0.00  0 0.000 1.000  0
#> SRR1047858     4  0.0000      0.966 0.00  0 0.000 1.000  0
#> SRR1047859     4  0.0000      0.966 0.00  0 0.000 1.000  0
#> SRR1047860     4  0.0000      0.966 0.00  0 0.000 1.000  0
#> SRR1047861     4  0.0000      0.966 0.00  0 0.000 1.000  0
#> SRR1047863     3  0.0000      0.886 0.00  0 1.000 0.000  0
#> SRR1047864     1  0.0000      0.884 1.00  0 0.000 0.000  0
#> SRR1047865     3  0.0162      0.892 0.00  0 0.996 0.004  0
#> SRR1047866     1  0.1732      0.885 0.92  0 0.080 0.000  0
#> SRR1047867     5  0.0000      0.000 0.00  0 0.000 0.000  1
#> SRR1047868     3  0.1671      0.914 0.00  0 0.924 0.076  0
#> SRR1047869     3  0.1608      0.914 0.00  0 0.928 0.072  0
#> SRR1047870     3  0.0000      0.886 0.00  0 1.000 0.000  0
#> SRR1047871     3  0.1671      0.914 0.00  0 0.924 0.076  0
#> SRR1047872     3  0.0162      0.892 0.00  0 0.996 0.004  0
#> SRR1047873     3  0.1671      0.914 0.00  0 0.924 0.076  0
#> SRR1047874     3  0.1671      0.914 0.00  0 0.924 0.076  0

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1 p2    p3    p4    p5 p6
#> SRR1047813     1  0.3747      1.000 0.604  0 0.000 0.396 0.000  0
#> SRR1047814     1  0.3747      1.000 0.604  0 0.000 0.396 0.000  0
#> SRR1047815     1  0.3747      1.000 0.604  0 0.000 0.396 0.000  0
#> SRR1047816     1  0.3747      1.000 0.604  0 0.000 0.396 0.000  0
#> SRR1047817     1  0.3747      1.000 0.604  0 0.000 0.396 0.000  0
#> SRR1047818     4  0.5391      0.501 0.244  0 0.176 0.580 0.000  0
#> SRR1047819     4  0.5391      0.501 0.244  0 0.176 0.580 0.000  0
#> SRR1047820     4  0.5391      0.501 0.244  0 0.176 0.580 0.000  0
#> SRR1047821     4  0.5391      0.501 0.244  0 0.176 0.580 0.000  0
#> SRR1047822     4  0.5391      0.501 0.244  0 0.176 0.580 0.000  0
#> SRR1047823     1  0.3747      1.000 0.604  0 0.000 0.396 0.000  0
#> SRR1047824     1  0.3747      1.000 0.604  0 0.000 0.396 0.000  0
#> SRR1047825     1  0.3747      1.000 0.604  0 0.000 0.396 0.000  0
#> SRR1047826     1  0.3747      1.000 0.604  0 0.000 0.396 0.000  0
#> SRR1047827     1  0.3747      1.000 0.604  0 0.000 0.396 0.000  0
#> SRR1047828     4  0.5186      0.538 0.232  0 0.156 0.612 0.000  0
#> SRR1047829     4  0.5186      0.538 0.232  0 0.156 0.612 0.000  0
#> SRR1047830     4  0.5186      0.538 0.232  0 0.156 0.612 0.000  0
#> SRR1047831     4  0.5186      0.538 0.232  0 0.156 0.612 0.000  0
#> SRR1047832     4  0.5186      0.538 0.232  0 0.156 0.612 0.000  0
#> SRR1047833     2  0.0000      1.000 0.000  1 0.000 0.000 0.000  0
#> SRR1047834     2  0.0000      1.000 0.000  1 0.000 0.000 0.000  0
#> SRR1047835     2  0.0000      1.000 0.000  1 0.000 0.000 0.000  0
#> SRR1047836     2  0.0000      1.000 0.000  1 0.000 0.000 0.000  0
#> SRR1047837     2  0.0000      1.000 0.000  1 0.000 0.000 0.000  0
#> SRR1047838     4  0.0000      0.677 0.000  0 0.000 1.000 0.000  0
#> SRR1047839     4  0.0000      0.677 0.000  0 0.000 1.000 0.000  0
#> SRR1047840     4  0.0000      0.677 0.000  0 0.000 1.000 0.000  0
#> SRR1047841     4  0.0000      0.677 0.000  0 0.000 1.000 0.000  0
#> SRR1047842     4  0.0000      0.677 0.000  0 0.000 1.000 0.000  0
#> SRR1047843     4  0.0000      0.677 0.000  0 0.000 1.000 0.000  0
#> SRR1047844     4  0.0000      0.677 0.000  0 0.000 1.000 0.000  0
#> SRR1047845     4  0.0000      0.677 0.000  0 0.000 1.000 0.000  0
#> SRR1047846     4  0.0000      0.677 0.000  0 0.000 1.000 0.000  0
#> SRR1047847     4  0.0000      0.677 0.000  0 0.000 1.000 0.000  0
#> SRR1047848     1  0.3747      1.000 0.604  0 0.000 0.396 0.000  0
#> SRR1047849     1  0.3747      1.000 0.604  0 0.000 0.396 0.000  0
#> SRR1047850     1  0.3747      1.000 0.604  0 0.000 0.396 0.000  0
#> SRR1047851     1  0.3747      1.000 0.604  0 0.000 0.396 0.000  0
#> SRR1047852     1  0.3747      1.000 0.604  0 0.000 0.396 0.000  0
#> SRR1047853     4  0.0000      0.677 0.000  0 0.000 1.000 0.000  0
#> SRR1047854     4  0.0000      0.677 0.000  0 0.000 1.000 0.000  0
#> SRR1047855     4  0.0000      0.677 0.000  0 0.000 1.000 0.000  0
#> SRR1047856     4  0.0000      0.677 0.000  0 0.000 1.000 0.000  0
#> SRR1047857     4  0.0000      0.677 0.000  0 0.000 1.000 0.000  0
#> SRR1047858     4  0.3428     -0.198 0.304  0 0.000 0.696 0.000  0
#> SRR1047859     4  0.3428     -0.198 0.304  0 0.000 0.696 0.000  0
#> SRR1047860     4  0.3428     -0.198 0.304  0 0.000 0.696 0.000  0
#> SRR1047861     4  0.3428     -0.198 0.304  0 0.000 0.696 0.000  0
#> SRR1047863     3  0.1152      0.927 0.044  0 0.952 0.000 0.004  0
#> SRR1047864     5  0.2092      0.805 0.124  0 0.000 0.000 0.876  0
#> SRR1047865     3  0.1007      0.930 0.044  0 0.956 0.000 0.000  0
#> SRR1047866     5  0.1765      0.806 0.052  0 0.024 0.000 0.924  0
#> SRR1047867     6  0.0000      0.000 0.000  0 0.000 0.000 0.000  1
#> SRR1047868     3  0.1257      0.939 0.020  0 0.952 0.028 0.000  0
#> SRR1047869     3  0.0632      0.939 0.000  0 0.976 0.024 0.000  0
#> SRR1047870     3  0.1152      0.927 0.044  0 0.952 0.000 0.004  0
#> SRR1047871     3  0.1257      0.939 0.020  0 0.952 0.028 0.000  0
#> SRR1047872     3  0.1007      0.930 0.044  0 0.956 0.000 0.000  0
#> SRR1047873     3  0.1257      0.939 0.020  0 0.952 0.028 0.000  0
#> SRR1047874     3  0.1257      0.939 0.020  0 0.952 0.028 0.000  0

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-hclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-hclust-collect-classes

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

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

collect_plots(res)

plot of chunk ATC-kmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.1811 0.820   0.820
#> 3 3 0.478           0.254       0.571         1.7964 0.587   0.496
#> 4 4 0.574           0.735       0.852         0.3585 0.756   0.483
#> 5 5 0.635           0.685       0.794         0.1011 1.000   1.000
#> 6 6 0.693           0.702       0.730         0.0551 0.866   0.563

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
#> SRR1047813     1       0          1  1  0
#> SRR1047814     1       0          1  1  0
#> SRR1047815     1       0          1  1  0
#> SRR1047816     1       0          1  1  0
#> SRR1047817     1       0          1  1  0
#> SRR1047818     1       0          1  1  0
#> SRR1047819     1       0          1  1  0
#> SRR1047820     1       0          1  1  0
#> SRR1047821     1       0          1  1  0
#> SRR1047822     1       0          1  1  0
#> SRR1047823     1       0          1  1  0
#> SRR1047824     1       0          1  1  0
#> SRR1047825     1       0          1  1  0
#> SRR1047826     1       0          1  1  0
#> SRR1047827     1       0          1  1  0
#> SRR1047828     1       0          1  1  0
#> SRR1047829     1       0          1  1  0
#> SRR1047830     1       0          1  1  0
#> SRR1047831     1       0          1  1  0
#> SRR1047832     1       0          1  1  0
#> SRR1047833     2       0          1  0  1
#> SRR1047834     2       0          1  0  1
#> SRR1047835     2       0          1  0  1
#> SRR1047836     2       0          1  0  1
#> SRR1047837     2       0          1  0  1
#> SRR1047838     1       0          1  1  0
#> SRR1047839     1       0          1  1  0
#> SRR1047840     1       0          1  1  0
#> SRR1047841     1       0          1  1  0
#> SRR1047842     1       0          1  1  0
#> SRR1047843     1       0          1  1  0
#> SRR1047844     1       0          1  1  0
#> SRR1047845     1       0          1  1  0
#> SRR1047846     1       0          1  1  0
#> SRR1047847     1       0          1  1  0
#> SRR1047848     1       0          1  1  0
#> SRR1047849     1       0          1  1  0
#> SRR1047850     1       0          1  1  0
#> SRR1047851     1       0          1  1  0
#> SRR1047852     1       0          1  1  0
#> SRR1047853     1       0          1  1  0
#> SRR1047854     1       0          1  1  0
#> SRR1047855     1       0          1  1  0
#> SRR1047856     1       0          1  1  0
#> SRR1047857     1       0          1  1  0
#> SRR1047858     1       0          1  1  0
#> SRR1047859     1       0          1  1  0
#> SRR1047860     1       0          1  1  0
#> SRR1047861     1       0          1  1  0
#> SRR1047863     1       0          1  1  0
#> SRR1047864     1       0          1  1  0
#> SRR1047865     1       0          1  1  0
#> SRR1047866     1       0          1  1  0
#> SRR1047867     2       0          1  0  1
#> SRR1047868     1       0          1  1  0
#> SRR1047869     1       0          1  1  0
#> SRR1047870     1       0          1  1  0
#> SRR1047871     1       0          1  1  0
#> SRR1047872     1       0          1  1  0
#> SRR1047873     1       0          1  1  0
#> SRR1047874     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1047813     1   0.622     0.1894 0.568 0.000 0.432
#> SRR1047814     1   0.622     0.1894 0.568 0.000 0.432
#> SRR1047815     1   0.622     0.1894 0.568 0.000 0.432
#> SRR1047816     1   0.622     0.1894 0.568 0.000 0.432
#> SRR1047817     1   0.627     0.1120 0.544 0.000 0.456
#> SRR1047818     1   0.319     0.2840 0.888 0.000 0.112
#> SRR1047819     1   0.319     0.2840 0.888 0.000 0.112
#> SRR1047820     1   0.319     0.2840 0.888 0.000 0.112
#> SRR1047821     1   0.319     0.2840 0.888 0.000 0.112
#> SRR1047822     1   0.312     0.2825 0.892 0.000 0.108
#> SRR1047823     1   0.622     0.1894 0.568 0.000 0.432
#> SRR1047824     1   0.622     0.1894 0.568 0.000 0.432
#> SRR1047825     1   0.622     0.1894 0.568 0.000 0.432
#> SRR1047826     1   0.622     0.1894 0.568 0.000 0.432
#> SRR1047827     1   0.622     0.1894 0.568 0.000 0.432
#> SRR1047828     1   0.000     0.3147 1.000 0.000 0.000
#> SRR1047829     1   0.000     0.3147 1.000 0.000 0.000
#> SRR1047830     1   0.000     0.3147 1.000 0.000 0.000
#> SRR1047831     1   0.000     0.3147 1.000 0.000 0.000
#> SRR1047832     1   0.000     0.3147 1.000 0.000 0.000
#> SRR1047833     2   0.000     0.9969 0.000 1.000 0.000
#> SRR1047834     2   0.000     0.9969 0.000 1.000 0.000
#> SRR1047835     2   0.000     0.9969 0.000 1.000 0.000
#> SRR1047836     2   0.000     0.9969 0.000 1.000 0.000
#> SRR1047837     2   0.000     0.9969 0.000 1.000 0.000
#> SRR1047838     3   0.627     0.2019 0.452 0.000 0.548
#> SRR1047839     3   0.627     0.2019 0.452 0.000 0.548
#> SRR1047840     3   0.627     0.2019 0.452 0.000 0.548
#> SRR1047841     3   0.627     0.2019 0.452 0.000 0.548
#> SRR1047842     3   0.627     0.2019 0.452 0.000 0.548
#> SRR1047843     3   0.627     0.2019 0.452 0.000 0.548
#> SRR1047844     3   0.627     0.2019 0.452 0.000 0.548
#> SRR1047845     3   0.627     0.2019 0.452 0.000 0.548
#> SRR1047846     3   0.627     0.2019 0.452 0.000 0.548
#> SRR1047847     3   0.627     0.2019 0.452 0.000 0.548
#> SRR1047848     1   0.621     0.1921 0.572 0.000 0.428
#> SRR1047849     1   0.621     0.1921 0.572 0.000 0.428
#> SRR1047850     1   0.621     0.1921 0.572 0.000 0.428
#> SRR1047851     1   0.621     0.1921 0.572 0.000 0.428
#> SRR1047852     1   0.621     0.1921 0.572 0.000 0.428
#> SRR1047853     3   0.627     0.2019 0.452 0.000 0.548
#> SRR1047854     3   0.627     0.2019 0.452 0.000 0.548
#> SRR1047855     3   0.627     0.2019 0.452 0.000 0.548
#> SRR1047856     3   0.627     0.2019 0.452 0.000 0.548
#> SRR1047857     3   0.627     0.2019 0.452 0.000 0.548
#> SRR1047858     3   0.627     0.2019 0.452 0.000 0.548
#> SRR1047859     3   0.627     0.2019 0.452 0.000 0.548
#> SRR1047860     3   0.627     0.2019 0.452 0.000 0.548
#> SRR1047861     3   0.627     0.2019 0.452 0.000 0.548
#> SRR1047863     3   0.631     0.0169 0.488 0.000 0.512
#> SRR1047864     1   0.627    -0.0783 0.548 0.000 0.452
#> SRR1047865     3   0.631     0.0169 0.488 0.000 0.512
#> SRR1047866     1   0.623    -0.0506 0.564 0.000 0.436
#> SRR1047867     2   0.129     0.9846 0.000 0.968 0.032
#> SRR1047868     3   0.631     0.0169 0.488 0.000 0.512
#> SRR1047869     3   0.630     0.0163 0.480 0.000 0.520
#> SRR1047870     1   0.630    -0.0656 0.516 0.000 0.484
#> SRR1047871     3   0.630     0.0163 0.480 0.000 0.520
#> SRR1047872     3   0.631     0.0169 0.488 0.000 0.512
#> SRR1047873     3   0.627     0.0184 0.456 0.000 0.544
#> SRR1047874     3   0.622     0.0128 0.432 0.000 0.568

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1  p2    p3    p4
#> SRR1047813     1  0.3356      0.749 0.824 0.0 0.000 0.176
#> SRR1047814     1  0.3356      0.749 0.824 0.0 0.000 0.176
#> SRR1047815     1  0.3356      0.749 0.824 0.0 0.000 0.176
#> SRR1047816     1  0.3356      0.749 0.824 0.0 0.000 0.176
#> SRR1047817     1  0.3356      0.749 0.824 0.0 0.000 0.176
#> SRR1047818     4  0.6465      0.329 0.080 0.0 0.364 0.556
#> SRR1047819     4  0.6465      0.329 0.080 0.0 0.364 0.556
#> SRR1047820     4  0.6465      0.329 0.080 0.0 0.364 0.556
#> SRR1047821     4  0.6465      0.329 0.080 0.0 0.364 0.556
#> SRR1047822     4  0.6465      0.329 0.080 0.0 0.364 0.556
#> SRR1047823     1  0.4866      0.507 0.596 0.0 0.000 0.404
#> SRR1047824     1  0.4866      0.507 0.596 0.0 0.000 0.404
#> SRR1047825     1  0.4866      0.507 0.596 0.0 0.000 0.404
#> SRR1047826     1  0.4866      0.507 0.596 0.0 0.000 0.404
#> SRR1047827     1  0.4866      0.507 0.596 0.0 0.000 0.404
#> SRR1047828     1  0.6015      0.513 0.652 0.0 0.268 0.080
#> SRR1047829     1  0.6280      0.426 0.604 0.0 0.316 0.080
#> SRR1047830     1  0.6015      0.513 0.652 0.0 0.268 0.080
#> SRR1047831     1  0.6015      0.513 0.652 0.0 0.268 0.080
#> SRR1047832     1  0.6015      0.513 0.652 0.0 0.268 0.080
#> SRR1047833     2  0.0000      0.987 0.000 1.0 0.000 0.000
#> SRR1047834     2  0.0000      0.987 0.000 1.0 0.000 0.000
#> SRR1047835     2  0.0000      0.987 0.000 1.0 0.000 0.000
#> SRR1047836     2  0.0000      0.987 0.000 1.0 0.000 0.000
#> SRR1047837     2  0.0000      0.987 0.000 1.0 0.000 0.000
#> SRR1047838     4  0.0817      0.827 0.024 0.0 0.000 0.976
#> SRR1047839     4  0.0188      0.829 0.004 0.0 0.000 0.996
#> SRR1047840     4  0.0817      0.827 0.024 0.0 0.000 0.976
#> SRR1047841     4  0.0817      0.827 0.024 0.0 0.000 0.976
#> SRR1047842     4  0.0817      0.827 0.024 0.0 0.000 0.976
#> SRR1047843     4  0.0921      0.825 0.028 0.0 0.000 0.972
#> SRR1047844     4  0.0188      0.829 0.004 0.0 0.000 0.996
#> SRR1047845     4  0.0921      0.825 0.028 0.0 0.000 0.972
#> SRR1047846     4  0.0921      0.825 0.028 0.0 0.000 0.972
#> SRR1047847     4  0.0188      0.829 0.004 0.0 0.000 0.996
#> SRR1047848     1  0.2216      0.750 0.908 0.0 0.000 0.092
#> SRR1047849     1  0.2216      0.750 0.908 0.0 0.000 0.092
#> SRR1047850     1  0.2216      0.750 0.908 0.0 0.000 0.092
#> SRR1047851     1  0.2216      0.750 0.908 0.0 0.000 0.092
#> SRR1047852     1  0.2216      0.750 0.908 0.0 0.000 0.092
#> SRR1047853     4  0.0336      0.825 0.000 0.0 0.008 0.992
#> SRR1047854     4  0.0000      0.828 0.000 0.0 0.000 1.000
#> SRR1047855     4  0.0000      0.828 0.000 0.0 0.000 1.000
#> SRR1047856     4  0.0336      0.825 0.000 0.0 0.008 0.992
#> SRR1047857     4  0.0336      0.825 0.000 0.0 0.008 0.992
#> SRR1047858     4  0.3123      0.685 0.156 0.0 0.000 0.844
#> SRR1047859     4  0.1867      0.786 0.072 0.0 0.000 0.928
#> SRR1047860     4  0.3123      0.685 0.156 0.0 0.000 0.844
#> SRR1047861     4  0.3123      0.685 0.156 0.0 0.000 0.844
#> SRR1047863     3  0.0707      0.918 0.000 0.0 0.980 0.020
#> SRR1047864     3  0.2345      0.842 0.100 0.0 0.900 0.000
#> SRR1047865     3  0.0707      0.918 0.000 0.0 0.980 0.020
#> SRR1047866     3  0.0817      0.892 0.024 0.0 0.976 0.000
#> SRR1047867     2  0.2706      0.932 0.080 0.9 0.020 0.000
#> SRR1047868     3  0.1118      0.916 0.000 0.0 0.964 0.036
#> SRR1047869     3  0.1118      0.916 0.000 0.0 0.964 0.036
#> SRR1047870     3  0.0707      0.918 0.000 0.0 0.980 0.020
#> SRR1047871     3  0.1211      0.915 0.000 0.0 0.960 0.040
#> SRR1047872     3  0.0707      0.918 0.000 0.0 0.980 0.020
#> SRR1047873     3  0.3837      0.730 0.000 0.0 0.776 0.224
#> SRR1047874     3  0.3975      0.710 0.000 0.0 0.760 0.240

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4 p5
#> SRR1047813     1  0.2209      0.689 0.912 0.000 0.000 0.032 NA
#> SRR1047814     1  0.2209      0.689 0.912 0.000 0.000 0.032 NA
#> SRR1047815     1  0.2209      0.689 0.912 0.000 0.000 0.032 NA
#> SRR1047816     1  0.2209      0.689 0.912 0.000 0.000 0.032 NA
#> SRR1047817     1  0.2209      0.689 0.912 0.000 0.000 0.032 NA
#> SRR1047818     4  0.7283      0.229 0.024 0.000 0.304 0.400 NA
#> SRR1047819     4  0.7283      0.229 0.024 0.000 0.304 0.400 NA
#> SRR1047820     4  0.7283      0.229 0.024 0.000 0.304 0.400 NA
#> SRR1047821     4  0.7283      0.229 0.024 0.000 0.304 0.400 NA
#> SRR1047822     4  0.7217      0.224 0.020 0.000 0.308 0.400 NA
#> SRR1047823     1  0.5854      0.502 0.600 0.000 0.000 0.240 NA
#> SRR1047824     1  0.5854      0.502 0.600 0.000 0.000 0.240 NA
#> SRR1047825     1  0.5854      0.502 0.600 0.000 0.000 0.240 NA
#> SRR1047826     1  0.5854      0.502 0.600 0.000 0.000 0.240 NA
#> SRR1047827     1  0.5854      0.502 0.600 0.000 0.000 0.240 NA
#> SRR1047828     1  0.6082      0.481 0.464 0.000 0.076 0.016 NA
#> SRR1047829     1  0.6250      0.456 0.448 0.000 0.092 0.016 NA
#> SRR1047830     1  0.6082      0.481 0.464 0.000 0.076 0.016 NA
#> SRR1047831     1  0.6082      0.481 0.464 0.000 0.076 0.016 NA
#> SRR1047832     1  0.6082      0.481 0.464 0.000 0.076 0.016 NA
#> SRR1047833     2  0.0000      0.974 0.000 1.000 0.000 0.000 NA
#> SRR1047834     2  0.0000      0.974 0.000 1.000 0.000 0.000 NA
#> SRR1047835     2  0.0000      0.974 0.000 1.000 0.000 0.000 NA
#> SRR1047836     2  0.0000      0.974 0.000 1.000 0.000 0.000 NA
#> SRR1047837     2  0.0000      0.974 0.000 1.000 0.000 0.000 NA
#> SRR1047838     4  0.0290      0.772 0.008 0.000 0.000 0.992 NA
#> SRR1047839     4  0.0609      0.772 0.000 0.000 0.000 0.980 NA
#> SRR1047840     4  0.0290      0.772 0.008 0.000 0.000 0.992 NA
#> SRR1047841     4  0.0290      0.772 0.008 0.000 0.000 0.992 NA
#> SRR1047842     4  0.0290      0.772 0.008 0.000 0.000 0.992 NA
#> SRR1047843     4  0.1774      0.763 0.016 0.000 0.000 0.932 NA
#> SRR1047844     4  0.1357      0.769 0.004 0.000 0.000 0.948 NA
#> SRR1047845     4  0.1774      0.763 0.016 0.000 0.000 0.932 NA
#> SRR1047846     4  0.1774      0.763 0.016 0.000 0.000 0.932 NA
#> SRR1047847     4  0.1357      0.769 0.004 0.000 0.000 0.948 NA
#> SRR1047848     1  0.2522      0.698 0.880 0.000 0.000 0.012 NA
#> SRR1047849     1  0.2522      0.698 0.880 0.000 0.000 0.012 NA
#> SRR1047850     1  0.2522      0.698 0.880 0.000 0.000 0.012 NA
#> SRR1047851     1  0.2522      0.698 0.880 0.000 0.000 0.012 NA
#> SRR1047852     1  0.2522      0.698 0.880 0.000 0.000 0.012 NA
#> SRR1047853     4  0.3339      0.744 0.000 0.000 0.048 0.840 NA
#> SRR1047854     4  0.3216      0.747 0.000 0.000 0.044 0.848 NA
#> SRR1047855     4  0.3216      0.747 0.000 0.000 0.044 0.848 NA
#> SRR1047856     4  0.3339      0.744 0.000 0.000 0.048 0.840 NA
#> SRR1047857     4  0.3339      0.744 0.000 0.000 0.048 0.840 NA
#> SRR1047858     4  0.4309      0.613 0.148 0.000 0.000 0.768 NA
#> SRR1047859     4  0.3536      0.684 0.084 0.000 0.000 0.832 NA
#> SRR1047860     4  0.4309      0.613 0.148 0.000 0.000 0.768 NA
#> SRR1047861     4  0.4309      0.613 0.148 0.000 0.000 0.768 NA
#> SRR1047863     3  0.1197      0.876 0.000 0.000 0.952 0.000 NA
#> SRR1047864     3  0.4276      0.631 0.004 0.000 0.616 0.000 NA
#> SRR1047865     3  0.1197      0.876 0.000 0.000 0.952 0.000 NA
#> SRR1047866     3  0.3177      0.772 0.000 0.000 0.792 0.000 NA
#> SRR1047867     2  0.3242      0.864 0.012 0.816 0.000 0.000 NA
#> SRR1047868     3  0.1357      0.873 0.000 0.000 0.948 0.004 NA
#> SRR1047869     3  0.1408      0.873 0.000 0.000 0.948 0.008 NA
#> SRR1047870     3  0.1478      0.872 0.000 0.000 0.936 0.000 NA
#> SRR1047871     3  0.1704      0.865 0.000 0.000 0.928 0.004 NA
#> SRR1047872     3  0.1043      0.878 0.000 0.000 0.960 0.000 NA
#> SRR1047873     3  0.3056      0.827 0.000 0.000 0.864 0.068 NA
#> SRR1047874     3  0.3517      0.795 0.000 0.000 0.832 0.100 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
#> SRR1047813     1  0.0547      0.698 0.980 0.000 0.000 0.020 0.000 0.000
#> SRR1047814     1  0.0547      0.698 0.980 0.000 0.000 0.020 0.000 0.000
#> SRR1047815     1  0.0547      0.698 0.980 0.000 0.000 0.020 0.000 0.000
#> SRR1047816     1  0.0547      0.698 0.980 0.000 0.000 0.020 0.000 0.000
#> SRR1047817     1  0.0547      0.698 0.980 0.000 0.000 0.020 0.000 0.000
#> SRR1047818     5  0.7621      0.441 0.004 0.000 0.220 0.268 0.352 0.156
#> SRR1047819     5  0.7621      0.441 0.004 0.000 0.220 0.268 0.352 0.156
#> SRR1047820     5  0.7621      0.441 0.004 0.000 0.220 0.268 0.352 0.156
#> SRR1047821     5  0.7621      0.441 0.004 0.000 0.220 0.268 0.352 0.156
#> SRR1047822     5  0.7621      0.441 0.004 0.000 0.220 0.268 0.352 0.156
#> SRR1047823     6  0.5935      1.000 0.424 0.000 0.000 0.124 0.020 0.432
#> SRR1047824     6  0.5935      1.000 0.424 0.000 0.000 0.124 0.020 0.432
#> SRR1047825     6  0.5935      1.000 0.424 0.000 0.000 0.124 0.020 0.432
#> SRR1047826     6  0.5935      1.000 0.424 0.000 0.000 0.124 0.020 0.432
#> SRR1047827     6  0.5935      1.000 0.424 0.000 0.000 0.124 0.020 0.432
#> SRR1047828     5  0.4308      0.259 0.300 0.000 0.028 0.008 0.664 0.000
#> SRR1047829     5  0.4359      0.263 0.296 0.000 0.032 0.008 0.664 0.000
#> SRR1047830     5  0.4308      0.259 0.300 0.000 0.028 0.008 0.664 0.000
#> SRR1047831     5  0.4308      0.259 0.300 0.000 0.028 0.008 0.664 0.000
#> SRR1047832     5  0.4308      0.259 0.300 0.000 0.028 0.008 0.664 0.000
#> SRR1047833     2  0.0405      0.949 0.004 0.988 0.000 0.000 0.008 0.000
#> SRR1047834     2  0.0260      0.950 0.000 0.992 0.000 0.000 0.008 0.000
#> SRR1047835     2  0.0146      0.951 0.000 0.996 0.000 0.000 0.004 0.000
#> SRR1047836     2  0.0146      0.951 0.000 0.996 0.004 0.000 0.000 0.000
#> SRR1047837     2  0.0146      0.950 0.000 0.996 0.000 0.000 0.004 0.000
#> SRR1047838     4  0.0291      0.776 0.004 0.000 0.000 0.992 0.000 0.004
#> SRR1047839     4  0.0891      0.766 0.000 0.000 0.000 0.968 0.008 0.024
#> SRR1047840     4  0.0291      0.776 0.004 0.000 0.000 0.992 0.000 0.004
#> SRR1047841     4  0.0291      0.776 0.004 0.000 0.000 0.992 0.000 0.004
#> SRR1047842     4  0.0291      0.776 0.004 0.000 0.000 0.992 0.000 0.004
#> SRR1047843     4  0.3633      0.742 0.020 0.000 0.000 0.812 0.052 0.116
#> SRR1047844     4  0.3112      0.754 0.004 0.000 0.000 0.840 0.052 0.104
#> SRR1047845     4  0.3633      0.742 0.020 0.000 0.000 0.812 0.052 0.116
#> SRR1047846     4  0.3633      0.742 0.020 0.000 0.000 0.812 0.052 0.116
#> SRR1047847     4  0.3112      0.754 0.004 0.000 0.000 0.840 0.052 0.104
#> SRR1047848     1  0.4338      0.727 0.716 0.000 0.000 0.004 0.208 0.072
#> SRR1047849     1  0.4444      0.729 0.700 0.000 0.000 0.004 0.224 0.072
#> SRR1047850     1  0.4444      0.729 0.700 0.000 0.000 0.004 0.224 0.072
#> SRR1047851     1  0.4444      0.729 0.700 0.000 0.000 0.004 0.224 0.072
#> SRR1047852     1  0.4444      0.729 0.700 0.000 0.000 0.004 0.224 0.072
#> SRR1047853     4  0.4709      0.627 0.000 0.000 0.060 0.744 0.104 0.092
#> SRR1047854     4  0.4709      0.627 0.000 0.000 0.060 0.744 0.104 0.092
#> SRR1047855     4  0.4709      0.627 0.000 0.000 0.060 0.744 0.104 0.092
#> SRR1047856     4  0.4709      0.627 0.000 0.000 0.060 0.744 0.104 0.092
#> SRR1047857     4  0.4709      0.627 0.000 0.000 0.060 0.744 0.104 0.092
#> SRR1047858     4  0.5167      0.526 0.096 0.000 0.000 0.664 0.028 0.212
#> SRR1047859     4  0.4674      0.589 0.056 0.000 0.000 0.704 0.028 0.212
#> SRR1047860     4  0.5167      0.526 0.096 0.000 0.000 0.664 0.028 0.212
#> SRR1047861     4  0.5167      0.526 0.096 0.000 0.000 0.664 0.028 0.212
#> SRR1047863     3  0.1924      0.859 0.000 0.000 0.920 0.004 0.048 0.028
#> SRR1047864     3  0.5940      0.433 0.000 0.000 0.456 0.000 0.296 0.248
#> SRR1047865     3  0.1924      0.859 0.000 0.000 0.920 0.004 0.048 0.028
#> SRR1047866     3  0.3833      0.713 0.000 0.000 0.736 0.004 0.232 0.028
#> SRR1047867     2  0.4503      0.752 0.000 0.684 0.000 0.000 0.084 0.232
#> SRR1047868     3  0.0922      0.856 0.000 0.000 0.968 0.004 0.024 0.004
#> SRR1047869     3  0.0806      0.858 0.000 0.000 0.972 0.008 0.020 0.000
#> SRR1047870     3  0.2113      0.854 0.000 0.000 0.908 0.004 0.060 0.028
#> SRR1047871     3  0.1116      0.853 0.000 0.000 0.960 0.004 0.028 0.008
#> SRR1047872     3  0.1636      0.861 0.000 0.000 0.936 0.004 0.036 0.024
#> SRR1047873     3  0.2085      0.822 0.000 0.000 0.912 0.056 0.024 0.008
#> SRR1047874     3  0.2377      0.803 0.000 0.000 0.892 0.076 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 17931 rows and 61 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 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-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 0.932           0.905       0.964         0.3610 0.640   0.640
#> 3 3 0.859           0.881       0.954         0.7619 0.643   0.473
#> 4 4 0.811           0.905       0.953         0.0843 0.739   0.441
#> 5 5 0.790           0.820       0.897         0.1002 0.837   0.545
#> 6 6 0.902           0.930       0.953         0.0610 0.905   0.643

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette    p1    p2
#> SRR1047813     1   0.000      0.971 1.000 0.000
#> SRR1047814     1   0.000      0.971 1.000 0.000
#> SRR1047815     1   0.000      0.971 1.000 0.000
#> SRR1047816     1   0.000      0.971 1.000 0.000
#> SRR1047817     1   0.000      0.971 1.000 0.000
#> SRR1047818     1   0.000      0.971 1.000 0.000
#> SRR1047819     1   0.000      0.971 1.000 0.000
#> SRR1047820     1   0.000      0.971 1.000 0.000
#> SRR1047821     1   0.000      0.971 1.000 0.000
#> SRR1047822     1   0.000      0.971 1.000 0.000
#> SRR1047823     1   0.000      0.971 1.000 0.000
#> SRR1047824     1   0.000      0.971 1.000 0.000
#> SRR1047825     1   0.000      0.971 1.000 0.000
#> SRR1047826     1   0.000      0.971 1.000 0.000
#> SRR1047827     1   0.000      0.971 1.000 0.000
#> SRR1047828     1   0.000      0.971 1.000 0.000
#> SRR1047829     1   0.000      0.971 1.000 0.000
#> SRR1047830     1   0.000      0.971 1.000 0.000
#> SRR1047831     1   0.000      0.971 1.000 0.000
#> SRR1047832     1   0.000      0.971 1.000 0.000
#> SRR1047833     2   0.000      0.921 0.000 1.000
#> SRR1047834     2   0.000      0.921 0.000 1.000
#> SRR1047835     2   0.000      0.921 0.000 1.000
#> SRR1047836     2   0.000      0.921 0.000 1.000
#> SRR1047837     2   0.000      0.921 0.000 1.000
#> SRR1047838     1   0.000      0.971 1.000 0.000
#> SRR1047839     1   0.000      0.971 1.000 0.000
#> SRR1047840     1   0.000      0.971 1.000 0.000
#> SRR1047841     1   0.000      0.971 1.000 0.000
#> SRR1047842     1   0.000      0.971 1.000 0.000
#> SRR1047843     1   0.000      0.971 1.000 0.000
#> SRR1047844     1   0.000      0.971 1.000 0.000
#> SRR1047845     1   0.000      0.971 1.000 0.000
#> SRR1047846     1   0.000      0.971 1.000 0.000
#> SRR1047847     1   0.000      0.971 1.000 0.000
#> SRR1047848     1   0.000      0.971 1.000 0.000
#> SRR1047849     1   0.000      0.971 1.000 0.000
#> SRR1047850     1   0.000      0.971 1.000 0.000
#> SRR1047851     1   0.000      0.971 1.000 0.000
#> SRR1047852     1   0.000      0.971 1.000 0.000
#> SRR1047853     1   0.000      0.971 1.000 0.000
#> SRR1047854     1   0.000      0.971 1.000 0.000
#> SRR1047855     1   0.000      0.971 1.000 0.000
#> SRR1047856     1   0.000      0.971 1.000 0.000
#> SRR1047857     1   0.000      0.971 1.000 0.000
#> SRR1047858     1   0.000      0.971 1.000 0.000
#> SRR1047859     1   0.000      0.971 1.000 0.000
#> SRR1047860     1   0.000      0.971 1.000 0.000
#> SRR1047861     1   0.000      0.971 1.000 0.000
#> SRR1047863     2   0.000      0.921 0.000 1.000
#> SRR1047864     2   0.000      0.921 0.000 1.000
#> SRR1047865     2   0.416      0.868 0.084 0.916
#> SRR1047866     2   0.000      0.921 0.000 1.000
#> SRR1047867     2   0.000      0.921 0.000 1.000
#> SRR1047868     2   0.971      0.372 0.400 0.600
#> SRR1047869     2   0.971      0.372 0.400 0.600
#> SRR1047870     2   0.000      0.921 0.000 1.000
#> SRR1047871     1   0.971      0.264 0.600 0.400
#> SRR1047872     2   0.416      0.868 0.084 0.916
#> SRR1047873     1   0.971      0.264 0.600 0.400
#> SRR1047874     1   0.971      0.264 0.600 0.400

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1047813     1  0.0000      0.903 1.000 0.000 0.000
#> SRR1047814     1  0.0000      0.903 1.000 0.000 0.000
#> SRR1047815     1  0.0000      0.903 1.000 0.000 0.000
#> SRR1047816     1  0.0000      0.903 1.000 0.000 0.000
#> SRR1047817     1  0.0000      0.903 1.000 0.000 0.000
#> SRR1047818     3  0.0000      0.973 0.000 0.000 1.000
#> SRR1047819     3  0.0000      0.973 0.000 0.000 1.000
#> SRR1047820     3  0.0000      0.973 0.000 0.000 1.000
#> SRR1047821     3  0.0000      0.973 0.000 0.000 1.000
#> SRR1047822     3  0.0000      0.973 0.000 0.000 1.000
#> SRR1047823     1  0.0592      0.898 0.988 0.000 0.012
#> SRR1047824     1  0.0592      0.898 0.988 0.000 0.012
#> SRR1047825     1  0.0592      0.898 0.988 0.000 0.012
#> SRR1047826     1  0.0592      0.898 0.988 0.000 0.012
#> SRR1047827     1  0.0592      0.898 0.988 0.000 0.012
#> SRR1047828     1  0.0000      0.903 1.000 0.000 0.000
#> SRR1047829     1  0.0000      0.903 1.000 0.000 0.000
#> SRR1047830     1  0.0000      0.903 1.000 0.000 0.000
#> SRR1047831     1  0.0000      0.903 1.000 0.000 0.000
#> SRR1047832     1  0.0000      0.903 1.000 0.000 0.000
#> SRR1047833     2  0.0000      0.954 0.000 1.000 0.000
#> SRR1047834     2  0.0000      0.954 0.000 1.000 0.000
#> SRR1047835     2  0.0000      0.954 0.000 1.000 0.000
#> SRR1047836     2  0.0000      0.954 0.000 1.000 0.000
#> SRR1047837     2  0.0000      0.954 0.000 1.000 0.000
#> SRR1047838     3  0.0000      0.973 0.000 0.000 1.000
#> SRR1047839     3  0.0000      0.973 0.000 0.000 1.000
#> SRR1047840     3  0.0000      0.973 0.000 0.000 1.000
#> SRR1047841     3  0.0000      0.973 0.000 0.000 1.000
#> SRR1047842     3  0.0000      0.973 0.000 0.000 1.000
#> SRR1047843     3  0.0000      0.973 0.000 0.000 1.000
#> SRR1047844     3  0.0000      0.973 0.000 0.000 1.000
#> SRR1047845     3  0.0000      0.973 0.000 0.000 1.000
#> SRR1047846     3  0.0000      0.973 0.000 0.000 1.000
#> SRR1047847     3  0.0000      0.973 0.000 0.000 1.000
#> SRR1047848     1  0.0000      0.903 1.000 0.000 0.000
#> SRR1047849     1  0.0000      0.903 1.000 0.000 0.000
#> SRR1047850     1  0.0000      0.903 1.000 0.000 0.000
#> SRR1047851     1  0.0000      0.903 1.000 0.000 0.000
#> SRR1047852     1  0.0000      0.903 1.000 0.000 0.000
#> SRR1047853     3  0.0000      0.973 0.000 0.000 1.000
#> SRR1047854     3  0.0000      0.973 0.000 0.000 1.000
#> SRR1047855     3  0.0000      0.973 0.000 0.000 1.000
#> SRR1047856     3  0.0000      0.973 0.000 0.000 1.000
#> SRR1047857     3  0.0000      0.973 0.000 0.000 1.000
#> SRR1047858     1  0.6204      0.346 0.576 0.000 0.424
#> SRR1047859     1  0.6260      0.281 0.552 0.000 0.448
#> SRR1047860     1  0.6204      0.346 0.576 0.000 0.424
#> SRR1047861     1  0.6204      0.346 0.576 0.000 0.424
#> SRR1047863     2  0.4555      0.751 0.000 0.800 0.200
#> SRR1047864     2  0.0000      0.954 0.000 1.000 0.000
#> SRR1047865     2  0.4555      0.751 0.000 0.800 0.200
#> SRR1047866     2  0.0000      0.954 0.000 1.000 0.000
#> SRR1047867     2  0.0000      0.954 0.000 1.000 0.000
#> SRR1047868     3  0.0237      0.970 0.000 0.004 0.996
#> SRR1047869     3  0.4555      0.734 0.000 0.200 0.800
#> SRR1047870     2  0.0000      0.954 0.000 1.000 0.000
#> SRR1047871     3  0.0237      0.970 0.000 0.004 0.996
#> SRR1047872     3  0.6215      0.230 0.000 0.428 0.572
#> SRR1047873     3  0.0237      0.970 0.000 0.004 0.996
#> SRR1047874     3  0.0237      0.970 0.000 0.004 0.996

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1047813     1  0.1389      0.959 0.952 0.000 0.000 0.048
#> SRR1047814     1  0.1389      0.959 0.952 0.000 0.000 0.048
#> SRR1047815     1  0.1389      0.959 0.952 0.000 0.000 0.048
#> SRR1047816     1  0.1389      0.959 0.952 0.000 0.000 0.048
#> SRR1047817     1  0.2868      0.845 0.864 0.000 0.000 0.136
#> SRR1047818     4  0.1022      0.903 0.000 0.000 0.032 0.968
#> SRR1047819     4  0.1022      0.903 0.000 0.000 0.032 0.968
#> SRR1047820     4  0.1022      0.903 0.000 0.000 0.032 0.968
#> SRR1047821     4  0.1022      0.903 0.000 0.000 0.032 0.968
#> SRR1047822     4  0.1118      0.900 0.000 0.000 0.036 0.964
#> SRR1047823     4  0.4356      0.652 0.292 0.000 0.000 0.708
#> SRR1047824     4  0.4356      0.652 0.292 0.000 0.000 0.708
#> SRR1047825     4  0.4356      0.652 0.292 0.000 0.000 0.708
#> SRR1047826     4  0.4356      0.652 0.292 0.000 0.000 0.708
#> SRR1047827     4  0.4356      0.652 0.292 0.000 0.000 0.708
#> SRR1047828     1  0.0188      0.955 0.996 0.000 0.004 0.000
#> SRR1047829     1  0.0188      0.955 0.996 0.000 0.004 0.000
#> SRR1047830     1  0.0188      0.955 0.996 0.000 0.004 0.000
#> SRR1047831     1  0.0188      0.955 0.996 0.000 0.004 0.000
#> SRR1047832     1  0.0188      0.955 0.996 0.000 0.004 0.000
#> SRR1047833     2  0.0000      0.940 0.000 1.000 0.000 0.000
#> SRR1047834     2  0.0000      0.940 0.000 1.000 0.000 0.000
#> SRR1047835     2  0.0000      0.940 0.000 1.000 0.000 0.000
#> SRR1047836     2  0.0000      0.940 0.000 1.000 0.000 0.000
#> SRR1047837     2  0.0000      0.940 0.000 1.000 0.000 0.000
#> SRR1047838     4  0.0000      0.921 0.000 0.000 0.000 1.000
#> SRR1047839     4  0.0000      0.921 0.000 0.000 0.000 1.000
#> SRR1047840     4  0.0000      0.921 0.000 0.000 0.000 1.000
#> SRR1047841     4  0.0000      0.921 0.000 0.000 0.000 1.000
#> SRR1047842     4  0.0000      0.921 0.000 0.000 0.000 1.000
#> SRR1047843     4  0.0000      0.921 0.000 0.000 0.000 1.000
#> SRR1047844     4  0.0000      0.921 0.000 0.000 0.000 1.000
#> SRR1047845     4  0.0000      0.921 0.000 0.000 0.000 1.000
#> SRR1047846     4  0.0000      0.921 0.000 0.000 0.000 1.000
#> SRR1047847     4  0.0000      0.921 0.000 0.000 0.000 1.000
#> SRR1047848     1  0.0921      0.967 0.972 0.000 0.000 0.028
#> SRR1047849     1  0.0921      0.967 0.972 0.000 0.000 0.028
#> SRR1047850     1  0.0921      0.967 0.972 0.000 0.000 0.028
#> SRR1047851     1  0.0921      0.967 0.972 0.000 0.000 0.028
#> SRR1047852     1  0.0921      0.967 0.972 0.000 0.000 0.028
#> SRR1047853     4  0.0000      0.921 0.000 0.000 0.000 1.000
#> SRR1047854     4  0.0000      0.921 0.000 0.000 0.000 1.000
#> SRR1047855     4  0.0000      0.921 0.000 0.000 0.000 1.000
#> SRR1047856     4  0.0000      0.921 0.000 0.000 0.000 1.000
#> SRR1047857     4  0.0000      0.921 0.000 0.000 0.000 1.000
#> SRR1047858     4  0.2469      0.859 0.108 0.000 0.000 0.892
#> SRR1047859     4  0.0188      0.919 0.004 0.000 0.000 0.996
#> SRR1047860     4  0.2469      0.859 0.108 0.000 0.000 0.892
#> SRR1047861     4  0.2469      0.859 0.108 0.000 0.000 0.892
#> SRR1047863     3  0.0188      0.995 0.000 0.004 0.996 0.000
#> SRR1047864     2  0.0000      0.940 0.000 1.000 0.000 0.000
#> SRR1047865     3  0.0188      0.995 0.000 0.004 0.996 0.000
#> SRR1047866     2  0.4877      0.309 0.000 0.592 0.408 0.000
#> SRR1047867     2  0.0000      0.940 0.000 1.000 0.000 0.000
#> SRR1047868     3  0.0188      0.998 0.000 0.000 0.996 0.004
#> SRR1047869     3  0.0188      0.998 0.000 0.000 0.996 0.004
#> SRR1047870     3  0.0188      0.995 0.000 0.004 0.996 0.000
#> SRR1047871     3  0.0188      0.998 0.000 0.000 0.996 0.004
#> SRR1047872     3  0.0188      0.998 0.000 0.000 0.996 0.004
#> SRR1047873     3  0.0188      0.998 0.000 0.000 0.996 0.004
#> SRR1047874     3  0.0188      0.998 0.000 0.000 0.996 0.004

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4    p5
#> SRR1047813     1  0.0510     0.7398 0.984 0.000 0.000 0.016 0.000
#> SRR1047814     1  0.0510     0.7398 0.984 0.000 0.000 0.016 0.000
#> SRR1047815     1  0.0510     0.7398 0.984 0.000 0.000 0.016 0.000
#> SRR1047816     1  0.0510     0.7398 0.984 0.000 0.000 0.016 0.000
#> SRR1047817     1  0.1478     0.7465 0.936 0.000 0.000 0.064 0.000
#> SRR1047818     4  0.3430     0.7823 0.000 0.000 0.004 0.776 0.220
#> SRR1047819     4  0.3430     0.7823 0.000 0.000 0.004 0.776 0.220
#> SRR1047820     4  0.3430     0.7823 0.000 0.000 0.004 0.776 0.220
#> SRR1047821     4  0.3430     0.7823 0.000 0.000 0.004 0.776 0.220
#> SRR1047822     4  0.3430     0.7823 0.000 0.000 0.004 0.776 0.220
#> SRR1047823     1  0.3586     0.7340 0.792 0.000 0.000 0.188 0.020
#> SRR1047824     1  0.3586     0.7340 0.792 0.000 0.000 0.188 0.020
#> SRR1047825     1  0.3586     0.7340 0.792 0.000 0.000 0.188 0.020
#> SRR1047826     1  0.3586     0.7340 0.792 0.000 0.000 0.188 0.020
#> SRR1047827     1  0.3586     0.7340 0.792 0.000 0.000 0.188 0.020
#> SRR1047828     5  0.3424     1.0000 0.240 0.000 0.000 0.000 0.760
#> SRR1047829     5  0.3424     1.0000 0.240 0.000 0.000 0.000 0.760
#> SRR1047830     5  0.3424     1.0000 0.240 0.000 0.000 0.000 0.760
#> SRR1047831     5  0.3424     1.0000 0.240 0.000 0.000 0.000 0.760
#> SRR1047832     5  0.3424     1.0000 0.240 0.000 0.000 0.000 0.760
#> SRR1047833     2  0.0000     0.9334 0.000 1.000 0.000 0.000 0.000
#> SRR1047834     2  0.0000     0.9334 0.000 1.000 0.000 0.000 0.000
#> SRR1047835     2  0.0000     0.9334 0.000 1.000 0.000 0.000 0.000
#> SRR1047836     2  0.0000     0.9334 0.000 1.000 0.000 0.000 0.000
#> SRR1047837     2  0.0000     0.9334 0.000 1.000 0.000 0.000 0.000
#> SRR1047838     4  0.0451     0.8991 0.008 0.000 0.000 0.988 0.004
#> SRR1047839     4  0.0798     0.9000 0.008 0.000 0.000 0.976 0.016
#> SRR1047840     4  0.0451     0.8991 0.008 0.000 0.000 0.988 0.004
#> SRR1047841     4  0.0451     0.8991 0.008 0.000 0.000 0.988 0.004
#> SRR1047842     4  0.0451     0.8991 0.008 0.000 0.000 0.988 0.004
#> SRR1047843     4  0.0451     0.8991 0.008 0.000 0.000 0.988 0.004
#> SRR1047844     4  0.0290     0.8997 0.008 0.000 0.000 0.992 0.000
#> SRR1047845     4  0.0451     0.8991 0.008 0.000 0.000 0.988 0.004
#> SRR1047846     4  0.0451     0.8991 0.008 0.000 0.000 0.988 0.004
#> SRR1047847     4  0.0290     0.8997 0.008 0.000 0.000 0.992 0.000
#> SRR1047848     1  0.1341     0.6950 0.944 0.000 0.000 0.000 0.056
#> SRR1047849     1  0.1341     0.6950 0.944 0.000 0.000 0.000 0.056
#> SRR1047850     1  0.1341     0.6950 0.944 0.000 0.000 0.000 0.056
#> SRR1047851     1  0.1341     0.6950 0.944 0.000 0.000 0.000 0.056
#> SRR1047852     1  0.1341     0.6950 0.944 0.000 0.000 0.000 0.056
#> SRR1047853     4  0.1251     0.8985 0.008 0.000 0.000 0.956 0.036
#> SRR1047854     4  0.1251     0.8985 0.008 0.000 0.000 0.956 0.036
#> SRR1047855     4  0.1251     0.8985 0.008 0.000 0.000 0.956 0.036
#> SRR1047856     4  0.1251     0.8985 0.008 0.000 0.000 0.956 0.036
#> SRR1047857     4  0.1251     0.8985 0.008 0.000 0.000 0.956 0.036
#> SRR1047858     1  0.4824     0.3429 0.512 0.000 0.000 0.468 0.020
#> SRR1047859     4  0.4752    -0.0735 0.412 0.000 0.000 0.568 0.020
#> SRR1047860     1  0.4824     0.3429 0.512 0.000 0.000 0.468 0.020
#> SRR1047861     1  0.4824     0.3429 0.512 0.000 0.000 0.468 0.020
#> SRR1047863     3  0.0162     0.9955 0.000 0.004 0.996 0.000 0.000
#> SRR1047864     2  0.0000     0.9334 0.000 1.000 0.000 0.000 0.000
#> SRR1047865     3  0.0162     0.9955 0.000 0.004 0.996 0.000 0.000
#> SRR1047866     2  0.4201     0.3082 0.000 0.592 0.408 0.000 0.000
#> SRR1047867     2  0.0000     0.9334 0.000 1.000 0.000 0.000 0.000
#> SRR1047868     3  0.0162     0.9978 0.000 0.000 0.996 0.004 0.000
#> SRR1047869     3  0.0162     0.9978 0.000 0.000 0.996 0.004 0.000
#> SRR1047870     3  0.0162     0.9955 0.000 0.004 0.996 0.000 0.000
#> SRR1047871     3  0.0162     0.9978 0.000 0.000 0.996 0.004 0.000
#> SRR1047872     3  0.0162     0.9978 0.000 0.000 0.996 0.004 0.000
#> SRR1047873     3  0.0162     0.9978 0.000 0.000 0.996 0.004 0.000
#> SRR1047874     3  0.0162     0.9978 0.000 0.000 0.996 0.004 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR1047813     1  0.1152      0.921 0.952 0.000 0.000 0.000 0.044 0.004
#> SRR1047814     1  0.1152      0.921 0.952 0.000 0.000 0.000 0.044 0.004
#> SRR1047815     1  0.1152      0.921 0.952 0.000 0.000 0.000 0.044 0.004
#> SRR1047816     1  0.1152      0.921 0.952 0.000 0.000 0.000 0.044 0.004
#> SRR1047817     1  0.1152      0.921 0.952 0.000 0.000 0.000 0.044 0.004
#> SRR1047818     6  0.1501      1.000 0.000 0.000 0.000 0.076 0.000 0.924
#> SRR1047819     6  0.1501      1.000 0.000 0.000 0.000 0.076 0.000 0.924
#> SRR1047820     6  0.1501      1.000 0.000 0.000 0.000 0.076 0.000 0.924
#> SRR1047821     6  0.1501      1.000 0.000 0.000 0.000 0.076 0.000 0.924
#> SRR1047822     6  0.1501      1.000 0.000 0.000 0.000 0.076 0.000 0.924
#> SRR1047823     1  0.1713      0.889 0.928 0.000 0.000 0.028 0.000 0.044
#> SRR1047824     1  0.1713      0.889 0.928 0.000 0.000 0.028 0.000 0.044
#> SRR1047825     1  0.1713      0.889 0.928 0.000 0.000 0.028 0.000 0.044
#> SRR1047826     1  0.1713      0.889 0.928 0.000 0.000 0.028 0.000 0.044
#> SRR1047827     1  0.1713      0.889 0.928 0.000 0.000 0.028 0.000 0.044
#> SRR1047828     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1047829     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1047830     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1047831     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1047832     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1047833     2  0.0000      0.931 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1047834     2  0.0000      0.931 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1047835     2  0.0000      0.931 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1047836     2  0.0000      0.931 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1047837     2  0.0000      0.931 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1047838     4  0.0000      0.948 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1047839     4  0.0000      0.948 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1047840     4  0.0000      0.948 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1047841     4  0.0000      0.948 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1047842     4  0.0000      0.948 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1047843     4  0.0000      0.948 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1047844     4  0.0000      0.948 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1047845     4  0.0000      0.948 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1047846     4  0.0000      0.948 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1047847     4  0.0000      0.948 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1047848     1  0.2527      0.895 0.868 0.000 0.000 0.000 0.108 0.024
#> SRR1047849     1  0.2527      0.895 0.868 0.000 0.000 0.000 0.108 0.024
#> SRR1047850     1  0.2527      0.895 0.868 0.000 0.000 0.000 0.108 0.024
#> SRR1047851     1  0.2527      0.895 0.868 0.000 0.000 0.000 0.108 0.024
#> SRR1047852     1  0.2527      0.895 0.868 0.000 0.000 0.000 0.108 0.024
#> SRR1047853     4  0.0632      0.939 0.000 0.000 0.000 0.976 0.000 0.024
#> SRR1047854     4  0.0547      0.941 0.000 0.000 0.000 0.980 0.000 0.020
#> SRR1047855     4  0.0547      0.941 0.000 0.000 0.000 0.980 0.000 0.020
#> SRR1047856     4  0.0632      0.939 0.000 0.000 0.000 0.976 0.000 0.024
#> SRR1047857     4  0.0632      0.939 0.000 0.000 0.000 0.976 0.000 0.024
#> SRR1047858     4  0.3284      0.783 0.168 0.000 0.000 0.800 0.000 0.032
#> SRR1047859     4  0.2164      0.878 0.068 0.000 0.000 0.900 0.000 0.032
#> SRR1047860     4  0.3284      0.783 0.168 0.000 0.000 0.800 0.000 0.032
#> SRR1047861     4  0.3284      0.783 0.168 0.000 0.000 0.800 0.000 0.032
#> SRR1047863     3  0.0146      0.997 0.000 0.000 0.996 0.000 0.000 0.004
#> SRR1047864     2  0.0000      0.931 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1047865     3  0.0000      0.999 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1047866     2  0.3915      0.292 0.000 0.584 0.412 0.000 0.000 0.004
#> SRR1047867     2  0.0000      0.931 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1047868     3  0.0000      0.999 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1047869     3  0.0000      0.999 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1047870     3  0.0146      0.997 0.000 0.000 0.996 0.000 0.000 0.004
#> SRR1047871     3  0.0000      0.999 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1047872     3  0.0000      0.999 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1047873     3  0.0000      0.999 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1047874     3  0.0000      0.999 0.000 0.000 1.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

plot of chunk tab-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 17931 rows and 61 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 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-pam-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.1811 0.820   0.820
#> 3 3 0.505           0.852       0.915         1.8028 0.672   0.600
#> 4 4 0.725           0.855       0.921         0.3638 0.738   0.511
#> 5 5 0.808           0.772       0.896         0.0943 0.860   0.603
#> 6 6 0.820           0.821       0.879         0.0332 0.959   0.841

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
#> SRR1047813     1       0          1  1  0
#> SRR1047814     1       0          1  1  0
#> SRR1047815     1       0          1  1  0
#> SRR1047816     1       0          1  1  0
#> SRR1047817     1       0          1  1  0
#> SRR1047818     1       0          1  1  0
#> SRR1047819     1       0          1  1  0
#> SRR1047820     1       0          1  1  0
#> SRR1047821     1       0          1  1  0
#> SRR1047822     1       0          1  1  0
#> SRR1047823     1       0          1  1  0
#> SRR1047824     1       0          1  1  0
#> SRR1047825     1       0          1  1  0
#> SRR1047826     1       0          1  1  0
#> SRR1047827     1       0          1  1  0
#> SRR1047828     1       0          1  1  0
#> SRR1047829     1       0          1  1  0
#> SRR1047830     1       0          1  1  0
#> SRR1047831     1       0          1  1  0
#> SRR1047832     1       0          1  1  0
#> SRR1047833     2       0          1  0  1
#> SRR1047834     2       0          1  0  1
#> SRR1047835     2       0          1  0  1
#> SRR1047836     2       0          1  0  1
#> SRR1047837     2       0          1  0  1
#> SRR1047838     1       0          1  1  0
#> SRR1047839     1       0          1  1  0
#> SRR1047840     1       0          1  1  0
#> SRR1047841     1       0          1  1  0
#> SRR1047842     1       0          1  1  0
#> SRR1047843     1       0          1  1  0
#> SRR1047844     1       0          1  1  0
#> SRR1047845     1       0          1  1  0
#> SRR1047846     1       0          1  1  0
#> SRR1047847     1       0          1  1  0
#> SRR1047848     1       0          1  1  0
#> SRR1047849     1       0          1  1  0
#> SRR1047850     1       0          1  1  0
#> SRR1047851     1       0          1  1  0
#> SRR1047852     1       0          1  1  0
#> SRR1047853     1       0          1  1  0
#> SRR1047854     1       0          1  1  0
#> SRR1047855     1       0          1  1  0
#> SRR1047856     1       0          1  1  0
#> SRR1047857     1       0          1  1  0
#> SRR1047858     1       0          1  1  0
#> SRR1047859     1       0          1  1  0
#> SRR1047860     1       0          1  1  0
#> SRR1047861     1       0          1  1  0
#> SRR1047863     1       0          1  1  0
#> SRR1047864     1       0          1  1  0
#> SRR1047865     1       0          1  1  0
#> SRR1047866     1       0          1  1  0
#> SRR1047867     2       0          1  0  1
#> SRR1047868     1       0          1  1  0
#> SRR1047869     1       0          1  1  0
#> SRR1047870     1       0          1  1  0
#> SRR1047871     1       0          1  1  0
#> SRR1047872     1       0          1  1  0
#> SRR1047873     1       0          1  1  0
#> SRR1047874     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1 p2    p3
#> SRR1047813     1   0.400      0.786 0.840  0 0.160
#> SRR1047814     1   0.400      0.786 0.840  0 0.160
#> SRR1047815     1   0.400      0.786 0.840  0 0.160
#> SRR1047816     1   0.400      0.786 0.840  0 0.160
#> SRR1047817     1   0.000      0.908 1.000  0 0.000
#> SRR1047818     1   0.103      0.896 0.976  0 0.024
#> SRR1047819     1   0.103      0.896 0.976  0 0.024
#> SRR1047820     1   0.103      0.896 0.976  0 0.024
#> SRR1047821     1   0.103      0.896 0.976  0 0.024
#> SRR1047822     1   0.103      0.896 0.976  0 0.024
#> SRR1047823     1   0.375      0.803 0.856  0 0.144
#> SRR1047824     1   0.375      0.803 0.856  0 0.144
#> SRR1047825     1   0.375      0.803 0.856  0 0.144
#> SRR1047826     1   0.375      0.803 0.856  0 0.144
#> SRR1047827     1   0.375      0.803 0.856  0 0.144
#> SRR1047828     3   0.455      0.866 0.200  0 0.800
#> SRR1047829     3   0.455      0.866 0.200  0 0.800
#> SRR1047830     3   0.455      0.866 0.200  0 0.800
#> SRR1047831     3   0.455      0.866 0.200  0 0.800
#> SRR1047832     3   0.455      0.866 0.200  0 0.800
#> SRR1047833     2   0.000      1.000 0.000  1 0.000
#> SRR1047834     2   0.000      1.000 0.000  1 0.000
#> SRR1047835     2   0.000      1.000 0.000  1 0.000
#> SRR1047836     2   0.000      1.000 0.000  1 0.000
#> SRR1047837     2   0.000      1.000 0.000  1 0.000
#> SRR1047838     1   0.000      0.908 1.000  0 0.000
#> SRR1047839     1   0.000      0.908 1.000  0 0.000
#> SRR1047840     1   0.000      0.908 1.000  0 0.000
#> SRR1047841     1   0.000      0.908 1.000  0 0.000
#> SRR1047842     1   0.000      0.908 1.000  0 0.000
#> SRR1047843     1   0.000      0.908 1.000  0 0.000
#> SRR1047844     1   0.000      0.908 1.000  0 0.000
#> SRR1047845     1   0.000      0.908 1.000  0 0.000
#> SRR1047846     1   0.000      0.908 1.000  0 0.000
#> SRR1047847     1   0.000      0.908 1.000  0 0.000
#> SRR1047848     3   0.455      0.866 0.200  0 0.800
#> SRR1047849     3   0.455      0.866 0.200  0 0.800
#> SRR1047850     3   0.455      0.866 0.200  0 0.800
#> SRR1047851     3   0.455      0.866 0.200  0 0.800
#> SRR1047852     3   0.455      0.866 0.200  0 0.800
#> SRR1047853     1   0.000      0.908 1.000  0 0.000
#> SRR1047854     1   0.000      0.908 1.000  0 0.000
#> SRR1047855     1   0.000      0.908 1.000  0 0.000
#> SRR1047856     1   0.000      0.908 1.000  0 0.000
#> SRR1047857     1   0.000      0.908 1.000  0 0.000
#> SRR1047858     1   0.000      0.908 1.000  0 0.000
#> SRR1047859     1   0.000      0.908 1.000  0 0.000
#> SRR1047860     1   0.000      0.908 1.000  0 0.000
#> SRR1047861     1   0.000      0.908 1.000  0 0.000
#> SRR1047863     3   0.400      0.619 0.160  0 0.840
#> SRR1047864     3   0.000      0.687 0.000  0 1.000
#> SRR1047865     3   0.375      0.631 0.144  0 0.856
#> SRR1047866     3   0.000      0.687 0.000  0 1.000
#> SRR1047867     2   0.000      1.000 0.000  1 0.000
#> SRR1047868     1   0.460      0.725 0.796  0 0.204
#> SRR1047869     1   0.455      0.727 0.800  0 0.200
#> SRR1047870     3   0.375      0.631 0.144  0 0.856
#> SRR1047871     1   0.460      0.725 0.796  0 0.204
#> SRR1047872     1   0.536      0.643 0.724  0 0.276
#> SRR1047873     1   0.455      0.727 0.800  0 0.200
#> SRR1047874     1   0.455      0.727 0.800  0 0.200

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1 p2    p3    p4
#> SRR1047813     1  0.0188      0.887 0.996  0 0.000 0.004
#> SRR1047814     1  0.0188      0.887 0.996  0 0.000 0.004
#> SRR1047815     1  0.0188      0.887 0.996  0 0.000 0.004
#> SRR1047816     1  0.0188      0.887 0.996  0 0.000 0.004
#> SRR1047817     1  0.4040      0.646 0.752  0 0.000 0.248
#> SRR1047818     4  0.4290      0.777 0.036  0 0.164 0.800
#> SRR1047819     4  0.4568      0.799 0.124  0 0.076 0.800
#> SRR1047820     4  0.4591      0.798 0.116  0 0.084 0.800
#> SRR1047821     4  0.4139      0.771 0.024  0 0.176 0.800
#> SRR1047822     4  0.4746      0.509 0.000  0 0.368 0.632
#> SRR1047823     4  0.4040      0.744 0.248  0 0.000 0.752
#> SRR1047824     4  0.3942      0.756 0.236  0 0.000 0.764
#> SRR1047825     4  0.4866      0.497 0.404  0 0.000 0.596
#> SRR1047826     4  0.4454      0.670 0.308  0 0.000 0.692
#> SRR1047827     4  0.4008      0.748 0.244  0 0.000 0.756
#> SRR1047828     1  0.3569      0.824 0.804  0 0.196 0.000
#> SRR1047829     1  0.3764      0.802 0.784  0 0.216 0.000
#> SRR1047830     1  0.3569      0.824 0.804  0 0.196 0.000
#> SRR1047831     1  0.3569      0.824 0.804  0 0.196 0.000
#> SRR1047832     1  0.3569      0.824 0.804  0 0.196 0.000
#> SRR1047833     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR1047834     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR1047835     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR1047836     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR1047837     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR1047838     4  0.0000      0.900 0.000  0 0.000 1.000
#> SRR1047839     4  0.0000      0.900 0.000  0 0.000 1.000
#> SRR1047840     4  0.0000      0.900 0.000  0 0.000 1.000
#> SRR1047841     4  0.0000      0.900 0.000  0 0.000 1.000
#> SRR1047842     4  0.0000      0.900 0.000  0 0.000 1.000
#> SRR1047843     4  0.0000      0.900 0.000  0 0.000 1.000
#> SRR1047844     4  0.0000      0.900 0.000  0 0.000 1.000
#> SRR1047845     4  0.0000      0.900 0.000  0 0.000 1.000
#> SRR1047846     4  0.0000      0.900 0.000  0 0.000 1.000
#> SRR1047847     4  0.0000      0.900 0.000  0 0.000 1.000
#> SRR1047848     1  0.0000      0.887 1.000  0 0.000 0.000
#> SRR1047849     1  0.0592      0.891 0.984  0 0.016 0.000
#> SRR1047850     1  0.0592      0.891 0.984  0 0.016 0.000
#> SRR1047851     1  0.0592      0.891 0.984  0 0.016 0.000
#> SRR1047852     1  0.0592      0.891 0.984  0 0.016 0.000
#> SRR1047853     4  0.0000      0.900 0.000  0 0.000 1.000
#> SRR1047854     4  0.0000      0.900 0.000  0 0.000 1.000
#> SRR1047855     4  0.0000      0.900 0.000  0 0.000 1.000
#> SRR1047856     4  0.0000      0.900 0.000  0 0.000 1.000
#> SRR1047857     4  0.0000      0.900 0.000  0 0.000 1.000
#> SRR1047858     4  0.0000      0.900 0.000  0 0.000 1.000
#> SRR1047859     4  0.0000      0.900 0.000  0 0.000 1.000
#> SRR1047860     4  0.0000      0.900 0.000  0 0.000 1.000
#> SRR1047861     4  0.0000      0.900 0.000  0 0.000 1.000
#> SRR1047863     3  0.0000      0.865 0.000  0 1.000 0.000
#> SRR1047864     3  0.0188      0.863 0.004  0 0.996 0.000
#> SRR1047865     3  0.0000      0.865 0.000  0 1.000 0.000
#> SRR1047866     3  0.0188      0.863 0.004  0 0.996 0.000
#> SRR1047867     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR1047868     3  0.2647      0.849 0.000  0 0.880 0.120
#> SRR1047869     3  0.3172      0.831 0.000  0 0.840 0.160
#> SRR1047870     3  0.0000      0.865 0.000  0 1.000 0.000
#> SRR1047871     3  0.3172      0.831 0.000  0 0.840 0.160
#> SRR1047872     3  0.0707      0.865 0.000  0 0.980 0.020
#> SRR1047873     3  0.3801      0.771 0.000  0 0.780 0.220
#> SRR1047874     3  0.3837      0.768 0.000  0 0.776 0.224

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1 p2    p3    p4    p5
#> SRR1047813     1  0.4182      0.429 0.600  0 0.000 0.000 0.400
#> SRR1047814     1  0.4182      0.429 0.600  0 0.000 0.000 0.400
#> SRR1047815     1  0.4182      0.429 0.600  0 0.000 0.000 0.400
#> SRR1047816     1  0.4182      0.429 0.600  0 0.000 0.000 0.400
#> SRR1047817     4  0.2127      0.833 0.108  0 0.000 0.892 0.000
#> SRR1047818     4  0.6012      0.632 0.040  0 0.124 0.660 0.176
#> SRR1047819     4  0.6176      0.621 0.100  0 0.080 0.664 0.156
#> SRR1047820     4  0.6300      0.603 0.096  0 0.080 0.648 0.176
#> SRR1047821     4  0.6024      0.615 0.032  0 0.124 0.648 0.196
#> SRR1047822     4  0.4166      0.536 0.000  0 0.348 0.648 0.004
#> SRR1047823     1  0.1732      0.702 0.920  0 0.000 0.080 0.000
#> SRR1047824     1  0.1732      0.702 0.920  0 0.000 0.080 0.000
#> SRR1047825     1  0.1732      0.702 0.920  0 0.000 0.080 0.000
#> SRR1047826     1  0.1732      0.702 0.920  0 0.000 0.080 0.000
#> SRR1047827     1  0.1732      0.702 0.920  0 0.000 0.080 0.000
#> SRR1047828     5  0.0000      0.721 0.000  0 0.000 0.000 1.000
#> SRR1047829     5  0.0510      0.710 0.000  0 0.000 0.016 0.984
#> SRR1047830     5  0.0000      0.721 0.000  0 0.000 0.000 1.000
#> SRR1047831     5  0.0000      0.721 0.000  0 0.000 0.000 1.000
#> SRR1047832     5  0.0000      0.721 0.000  0 0.000 0.000 1.000
#> SRR1047833     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> SRR1047834     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> SRR1047835     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> SRR1047836     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> SRR1047837     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> SRR1047838     4  0.0000      0.906 0.000  0 0.000 1.000 0.000
#> SRR1047839     4  0.0000      0.906 0.000  0 0.000 1.000 0.000
#> SRR1047840     4  0.0000      0.906 0.000  0 0.000 1.000 0.000
#> SRR1047841     4  0.0000      0.906 0.000  0 0.000 1.000 0.000
#> SRR1047842     4  0.0000      0.906 0.000  0 0.000 1.000 0.000
#> SRR1047843     4  0.0000      0.906 0.000  0 0.000 1.000 0.000
#> SRR1047844     4  0.0000      0.906 0.000  0 0.000 1.000 0.000
#> SRR1047845     4  0.0000      0.906 0.000  0 0.000 1.000 0.000
#> SRR1047846     4  0.0000      0.906 0.000  0 0.000 1.000 0.000
#> SRR1047847     4  0.0000      0.906 0.000  0 0.000 1.000 0.000
#> SRR1047848     5  0.4171      0.185 0.396  0 0.000 0.000 0.604
#> SRR1047849     5  0.3003      0.636 0.188  0 0.000 0.000 0.812
#> SRR1047850     5  0.3109      0.626 0.200  0 0.000 0.000 0.800
#> SRR1047851     5  0.3109      0.626 0.200  0 0.000 0.000 0.800
#> SRR1047852     5  0.3109      0.626 0.200  0 0.000 0.000 0.800
#> SRR1047853     4  0.0000      0.906 0.000  0 0.000 1.000 0.000
#> SRR1047854     4  0.0000      0.906 0.000  0 0.000 1.000 0.000
#> SRR1047855     4  0.0000      0.906 0.000  0 0.000 1.000 0.000
#> SRR1047856     4  0.0000      0.906 0.000  0 0.000 1.000 0.000
#> SRR1047857     4  0.0000      0.906 0.000  0 0.000 1.000 0.000
#> SRR1047858     4  0.3932      0.480 0.328  0 0.000 0.672 0.000
#> SRR1047859     4  0.0000      0.906 0.000  0 0.000 1.000 0.000
#> SRR1047860     4  0.0290      0.900 0.008  0 0.000 0.992 0.000
#> SRR1047861     4  0.0000      0.906 0.000  0 0.000 1.000 0.000
#> SRR1047863     3  0.0000      0.968 0.000  0 1.000 0.000 0.000
#> SRR1047864     5  0.4182      0.197 0.000  0 0.400 0.000 0.600
#> SRR1047865     3  0.0000      0.968 0.000  0 1.000 0.000 0.000
#> SRR1047866     5  0.4182      0.197 0.000  0 0.400 0.000 0.600
#> SRR1047867     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> SRR1047868     3  0.0000      0.968 0.000  0 1.000 0.000 0.000
#> SRR1047869     3  0.0404      0.961 0.000  0 0.988 0.012 0.000
#> SRR1047870     3  0.0162      0.966 0.000  0 0.996 0.000 0.004
#> SRR1047871     3  0.0000      0.968 0.000  0 1.000 0.000 0.000
#> SRR1047872     3  0.0000      0.968 0.000  0 1.000 0.000 0.000
#> SRR1047873     3  0.1732      0.896 0.000  0 0.920 0.080 0.000
#> SRR1047874     3  0.1732      0.896 0.000  0 0.920 0.080 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
#> SRR1047813     1  0.0000      0.639 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1047814     1  0.0000      0.639 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1047815     1  0.0000      0.639 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1047816     1  0.0000      0.639 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1047817     4  0.3528      0.574 0.296 0.000 0.004 0.700 0.000 0.000
#> SRR1047818     4  0.6011      0.524 0.024 0.000 0.088 0.564 0.024 0.300
#> SRR1047819     4  0.5992      0.517 0.056 0.000 0.072 0.564 0.008 0.300
#> SRR1047820     4  0.5992      0.517 0.056 0.000 0.072 0.564 0.008 0.300
#> SRR1047821     4  0.6008      0.525 0.020 0.000 0.088 0.564 0.028 0.300
#> SRR1047822     4  0.5466      0.518 0.000 0.000 0.136 0.560 0.004 0.300
#> SRR1047823     6  0.5160      1.000 0.332 0.000 0.000 0.104 0.000 0.564
#> SRR1047824     6  0.5160      1.000 0.332 0.000 0.000 0.104 0.000 0.564
#> SRR1047825     6  0.5160      1.000 0.332 0.000 0.000 0.104 0.000 0.564
#> SRR1047826     6  0.5160      1.000 0.332 0.000 0.000 0.104 0.000 0.564
#> SRR1047827     6  0.5160      1.000 0.332 0.000 0.000 0.104 0.000 0.564
#> SRR1047828     5  0.0000      0.896 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1047829     5  0.0000      0.896 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1047830     5  0.0000      0.896 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1047831     5  0.0000      0.896 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1047832     5  0.0000      0.896 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1047833     2  0.0000      0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1047834     2  0.0000      0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1047835     2  0.0000      0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1047836     2  0.0000      0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1047837     2  0.0000      0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1047838     4  0.0000      0.874 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1047839     4  0.0146      0.874 0.000 0.000 0.004 0.996 0.000 0.000
#> SRR1047840     4  0.0000      0.874 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1047841     4  0.0146      0.874 0.000 0.000 0.004 0.996 0.000 0.000
#> SRR1047842     4  0.0146      0.874 0.000 0.000 0.004 0.996 0.000 0.000
#> SRR1047843     4  0.0146      0.874 0.000 0.000 0.000 0.996 0.000 0.004
#> SRR1047844     4  0.0146      0.874 0.000 0.000 0.000 0.996 0.000 0.004
#> SRR1047845     4  0.0146      0.874 0.000 0.000 0.000 0.996 0.000 0.004
#> SRR1047846     4  0.0146      0.874 0.000 0.000 0.000 0.996 0.000 0.004
#> SRR1047847     4  0.0146      0.874 0.000 0.000 0.000 0.996 0.000 0.004
#> SRR1047848     1  0.1075      0.653 0.952 0.000 0.000 0.000 0.048 0.000
#> SRR1047849     1  0.3797      0.545 0.580 0.000 0.000 0.000 0.420 0.000
#> SRR1047850     1  0.3765      0.577 0.596 0.000 0.000 0.000 0.404 0.000
#> SRR1047851     1  0.3765      0.577 0.596 0.000 0.000 0.000 0.404 0.000
#> SRR1047852     1  0.3765      0.577 0.596 0.000 0.000 0.000 0.404 0.000
#> SRR1047853     4  0.0146      0.874 0.000 0.000 0.004 0.996 0.000 0.000
#> SRR1047854     4  0.0146      0.874 0.000 0.000 0.004 0.996 0.000 0.000
#> SRR1047855     4  0.0146      0.874 0.000 0.000 0.004 0.996 0.000 0.000
#> SRR1047856     4  0.0146      0.874 0.000 0.000 0.004 0.996 0.000 0.000
#> SRR1047857     4  0.0146      0.874 0.000 0.000 0.004 0.996 0.000 0.000
#> SRR1047858     4  0.3050      0.593 0.000 0.000 0.000 0.764 0.000 0.236
#> SRR1047859     4  0.0146      0.874 0.000 0.000 0.000 0.996 0.000 0.004
#> SRR1047860     4  0.0632      0.860 0.000 0.000 0.000 0.976 0.000 0.024
#> SRR1047861     4  0.0146      0.874 0.000 0.000 0.000 0.996 0.000 0.004
#> SRR1047863     3  0.0146      0.968 0.000 0.000 0.996 0.000 0.004 0.000
#> SRR1047864     5  0.1327      0.847 0.000 0.000 0.064 0.000 0.936 0.000
#> SRR1047865     3  0.0146      0.968 0.000 0.000 0.996 0.000 0.004 0.000
#> SRR1047866     5  0.3747      0.381 0.000 0.000 0.396 0.000 0.604 0.000
#> SRR1047867     2  0.2178      0.901 0.000 0.868 0.000 0.000 0.000 0.132
#> SRR1047868     3  0.0000      0.968 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1047869     3  0.0363      0.964 0.000 0.000 0.988 0.012 0.000 0.000
#> SRR1047870     3  0.0260      0.966 0.000 0.000 0.992 0.000 0.008 0.000
#> SRR1047871     3  0.0146      0.968 0.000 0.000 0.996 0.004 0.000 0.000
#> SRR1047872     3  0.0000      0.968 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1047873     3  0.1387      0.909 0.000 0.000 0.932 0.068 0.000 0.000
#> SRR1047874     3  0.1387      0.909 0.000 0.000 0.932 0.068 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-pam-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-pam-collect-classes

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

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

collect_plots(res)

plot of chunk ATC-mclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.2325 0.768   0.768
#> 3 3 0.864           0.894       0.943         1.5693 0.627   0.515
#> 4 4 0.893           0.906       0.964         0.1560 0.880   0.714
#> 5 5 0.873           0.801       0.904         0.1184 0.902   0.693
#> 6 6 0.892           0.804       0.869         0.0276 0.942   0.771

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
#> SRR1047813     1       0          1  1  0
#> SRR1047814     1       0          1  1  0
#> SRR1047815     1       0          1  1  0
#> SRR1047816     1       0          1  1  0
#> SRR1047817     1       0          1  1  0
#> SRR1047818     1       0          1  1  0
#> SRR1047819     1       0          1  1  0
#> SRR1047820     1       0          1  1  0
#> SRR1047821     1       0          1  1  0
#> SRR1047822     1       0          1  1  0
#> SRR1047823     1       0          1  1  0
#> SRR1047824     1       0          1  1  0
#> SRR1047825     1       0          1  1  0
#> SRR1047826     1       0          1  1  0
#> SRR1047827     1       0          1  1  0
#> SRR1047828     1       0          1  1  0
#> SRR1047829     1       0          1  1  0
#> SRR1047830     1       0          1  1  0
#> SRR1047831     1       0          1  1  0
#> SRR1047832     1       0          1  1  0
#> SRR1047833     2       0          1  0  1
#> SRR1047834     2       0          1  0  1
#> SRR1047835     2       0          1  0  1
#> SRR1047836     2       0          1  0  1
#> SRR1047837     2       0          1  0  1
#> SRR1047838     1       0          1  1  0
#> SRR1047839     1       0          1  1  0
#> SRR1047840     1       0          1  1  0
#> SRR1047841     1       0          1  1  0
#> SRR1047842     1       0          1  1  0
#> SRR1047843     1       0          1  1  0
#> SRR1047844     1       0          1  1  0
#> SRR1047845     1       0          1  1  0
#> SRR1047846     1       0          1  1  0
#> SRR1047847     1       0          1  1  0
#> SRR1047848     1       0          1  1  0
#> SRR1047849     1       0          1  1  0
#> SRR1047850     1       0          1  1  0
#> SRR1047851     1       0          1  1  0
#> SRR1047852     1       0          1  1  0
#> SRR1047853     1       0          1  1  0
#> SRR1047854     1       0          1  1  0
#> SRR1047855     1       0          1  1  0
#> SRR1047856     1       0          1  1  0
#> SRR1047857     1       0          1  1  0
#> SRR1047858     1       0          1  1  0
#> SRR1047859     1       0          1  1  0
#> SRR1047860     1       0          1  1  0
#> SRR1047861     1       0          1  1  0
#> SRR1047863     1       0          1  1  0
#> SRR1047864     2       0          1  0  1
#> SRR1047865     1       0          1  1  0
#> SRR1047866     2       0          1  0  1
#> SRR1047867     2       0          1  0  1
#> SRR1047868     1       0          1  1  0
#> SRR1047869     1       0          1  1  0
#> SRR1047870     1       0          1  1  0
#> SRR1047871     1       0          1  1  0
#> SRR1047872     1       0          1  1  0
#> SRR1047873     1       0          1  1  0
#> SRR1047874     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1047813     3  0.0000      0.897 0.000 0.000 1.000
#> SRR1047814     3  0.0000      0.897 0.000 0.000 1.000
#> SRR1047815     3  0.0000      0.897 0.000 0.000 1.000
#> SRR1047816     3  0.0000      0.897 0.000 0.000 1.000
#> SRR1047817     3  0.0000      0.897 0.000 0.000 1.000
#> SRR1047818     1  0.0892      0.939 0.980 0.000 0.020
#> SRR1047819     1  0.0892      0.939 0.980 0.000 0.020
#> SRR1047820     1  0.0892      0.939 0.980 0.000 0.020
#> SRR1047821     1  0.0892      0.939 0.980 0.000 0.020
#> SRR1047822     1  0.0892      0.939 0.980 0.000 0.020
#> SRR1047823     1  0.1289      0.935 0.968 0.000 0.032
#> SRR1047824     1  0.1289      0.935 0.968 0.000 0.032
#> SRR1047825     1  0.1289      0.935 0.968 0.000 0.032
#> SRR1047826     1  0.1289      0.935 0.968 0.000 0.032
#> SRR1047827     1  0.1289      0.935 0.968 0.000 0.032
#> SRR1047828     3  0.0000      0.897 0.000 0.000 1.000
#> SRR1047829     3  0.0000      0.897 0.000 0.000 1.000
#> SRR1047830     3  0.0000      0.897 0.000 0.000 1.000
#> SRR1047831     3  0.0000      0.897 0.000 0.000 1.000
#> SRR1047832     3  0.0000      0.897 0.000 0.000 1.000
#> SRR1047833     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1047834     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1047835     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1047836     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1047837     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1047838     1  0.1289      0.953 0.968 0.000 0.032
#> SRR1047839     1  0.1529      0.950 0.960 0.000 0.040
#> SRR1047840     1  0.1289      0.953 0.968 0.000 0.032
#> SRR1047841     1  0.1289      0.953 0.968 0.000 0.032
#> SRR1047842     1  0.1289      0.953 0.968 0.000 0.032
#> SRR1047843     1  0.1411      0.952 0.964 0.000 0.036
#> SRR1047844     1  0.1411      0.952 0.964 0.000 0.036
#> SRR1047845     1  0.1411      0.952 0.964 0.000 0.036
#> SRR1047846     1  0.1411      0.952 0.964 0.000 0.036
#> SRR1047847     1  0.1411      0.952 0.964 0.000 0.036
#> SRR1047848     3  0.0000      0.897 0.000 0.000 1.000
#> SRR1047849     3  0.0000      0.897 0.000 0.000 1.000
#> SRR1047850     3  0.0000      0.897 0.000 0.000 1.000
#> SRR1047851     3  0.0000      0.897 0.000 0.000 1.000
#> SRR1047852     3  0.0000      0.897 0.000 0.000 1.000
#> SRR1047853     1  0.1289      0.953 0.968 0.000 0.032
#> SRR1047854     1  0.1289      0.953 0.968 0.000 0.032
#> SRR1047855     1  0.1289      0.953 0.968 0.000 0.032
#> SRR1047856     1  0.1289      0.953 0.968 0.000 0.032
#> SRR1047857     1  0.1289      0.953 0.968 0.000 0.032
#> SRR1047858     1  0.1643      0.949 0.956 0.000 0.044
#> SRR1047859     1  0.1643      0.949 0.956 0.000 0.044
#> SRR1047860     1  0.1643      0.949 0.956 0.000 0.044
#> SRR1047861     1  0.1643      0.949 0.956 0.000 0.044
#> SRR1047863     3  0.5325      0.748 0.248 0.004 0.748
#> SRR1047864     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1047865     3  0.2860      0.856 0.084 0.004 0.912
#> SRR1047866     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1047867     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1047868     3  0.6505      0.274 0.468 0.004 0.528
#> SRR1047869     3  0.5325      0.748 0.248 0.004 0.748
#> SRR1047870     3  0.5325      0.748 0.248 0.004 0.748
#> SRR1047871     3  0.5325      0.748 0.248 0.004 0.748
#> SRR1047872     3  0.5325      0.748 0.248 0.004 0.748
#> SRR1047873     1  0.6008      0.390 0.664 0.004 0.332
#> SRR1047874     1  0.6104      0.343 0.648 0.004 0.348

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1 p2 p3    p4
#> SRR1047813     1   0.000      1.000 1.000  0  0 0.000
#> SRR1047814     1   0.000      1.000 1.000  0  0 0.000
#> SRR1047815     1   0.000      1.000 1.000  0  0 0.000
#> SRR1047816     1   0.000      1.000 1.000  0  0 0.000
#> SRR1047817     1   0.000      1.000 1.000  0  0 0.000
#> SRR1047818     4   0.000      0.905 0.000  0  0 1.000
#> SRR1047819     4   0.000      0.905 0.000  0  0 1.000
#> SRR1047820     4   0.000      0.905 0.000  0  0 1.000
#> SRR1047821     4   0.000      0.905 0.000  0  0 1.000
#> SRR1047822     4   0.000      0.905 0.000  0  0 1.000
#> SRR1047823     4   0.495      0.316 0.444  0  0 0.556
#> SRR1047824     4   0.495      0.316 0.444  0  0 0.556
#> SRR1047825     4   0.495      0.316 0.444  0  0 0.556
#> SRR1047826     4   0.495      0.316 0.444  0  0 0.556
#> SRR1047827     4   0.495      0.316 0.444  0  0 0.556
#> SRR1047828     1   0.000      1.000 1.000  0  0 0.000
#> SRR1047829     1   0.000      1.000 1.000  0  0 0.000
#> SRR1047830     1   0.000      1.000 1.000  0  0 0.000
#> SRR1047831     1   0.000      1.000 1.000  0  0 0.000
#> SRR1047832     1   0.000      1.000 1.000  0  0 0.000
#> SRR1047833     2   0.000      1.000 0.000  1  0 0.000
#> SRR1047834     2   0.000      1.000 0.000  1  0 0.000
#> SRR1047835     2   0.000      1.000 0.000  1  0 0.000
#> SRR1047836     2   0.000      1.000 0.000  1  0 0.000
#> SRR1047837     2   0.000      1.000 0.000  1  0 0.000
#> SRR1047838     4   0.000      0.905 0.000  0  0 1.000
#> SRR1047839     4   0.000      0.905 0.000  0  0 1.000
#> SRR1047840     4   0.000      0.905 0.000  0  0 1.000
#> SRR1047841     4   0.000      0.905 0.000  0  0 1.000
#> SRR1047842     4   0.000      0.905 0.000  0  0 1.000
#> SRR1047843     4   0.000      0.905 0.000  0  0 1.000
#> SRR1047844     4   0.000      0.905 0.000  0  0 1.000
#> SRR1047845     4   0.000      0.905 0.000  0  0 1.000
#> SRR1047846     4   0.000      0.905 0.000  0  0 1.000
#> SRR1047847     4   0.000      0.905 0.000  0  0 1.000
#> SRR1047848     1   0.000      1.000 1.000  0  0 0.000
#> SRR1047849     1   0.000      1.000 1.000  0  0 0.000
#> SRR1047850     1   0.000      1.000 1.000  0  0 0.000
#> SRR1047851     1   0.000      1.000 1.000  0  0 0.000
#> SRR1047852     1   0.000      1.000 1.000  0  0 0.000
#> SRR1047853     4   0.000      0.905 0.000  0  0 1.000
#> SRR1047854     4   0.000      0.905 0.000  0  0 1.000
#> SRR1047855     4   0.000      0.905 0.000  0  0 1.000
#> SRR1047856     4   0.000      0.905 0.000  0  0 1.000
#> SRR1047857     4   0.000      0.905 0.000  0  0 1.000
#> SRR1047858     4   0.000      0.905 0.000  0  0 1.000
#> SRR1047859     4   0.000      0.905 0.000  0  0 1.000
#> SRR1047860     4   0.000      0.905 0.000  0  0 1.000
#> SRR1047861     4   0.000      0.905 0.000  0  0 1.000
#> SRR1047863     3   0.000      1.000 0.000  0  1 0.000
#> SRR1047864     3   0.000      1.000 0.000  0  1 0.000
#> SRR1047865     3   0.000      1.000 0.000  0  1 0.000
#> SRR1047866     3   0.000      1.000 0.000  0  1 0.000
#> SRR1047867     3   0.000      1.000 0.000  0  1 0.000
#> SRR1047868     3   0.000      1.000 0.000  0  1 0.000
#> SRR1047869     3   0.000      1.000 0.000  0  1 0.000
#> SRR1047870     3   0.000      1.000 0.000  0  1 0.000
#> SRR1047871     3   0.000      1.000 0.000  0  1 0.000
#> SRR1047872     3   0.000      1.000 0.000  0  1 0.000
#> SRR1047873     3   0.000      1.000 0.000  0  1 0.000
#> SRR1047874     3   0.000      1.000 0.000  0  1 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
#> SRR1047813     1   0.000      0.790 1.00  0  0 0.000 0.000
#> SRR1047814     1   0.000      0.790 1.00  0  0 0.000 0.000
#> SRR1047815     1   0.000      0.790 1.00  0  0 0.000 0.000
#> SRR1047816     1   0.000      0.790 1.00  0  0 0.000 0.000
#> SRR1047817     1   0.477      0.629 0.56  0  0 0.020 0.420
#> SRR1047818     4   0.000      0.894 0.00  0  0 1.000 0.000
#> SRR1047819     4   0.000      0.894 0.00  0  0 1.000 0.000
#> SRR1047820     4   0.000      0.894 0.00  0  0 1.000 0.000
#> SRR1047821     4   0.000      0.894 0.00  0  0 1.000 0.000
#> SRR1047822     4   0.000      0.894 0.00  0  0 1.000 0.000
#> SRR1047823     5   0.000      0.652 0.00  0  0 0.000 1.000
#> SRR1047824     5   0.000      0.652 0.00  0  0 0.000 1.000
#> SRR1047825     5   0.000      0.652 0.00  0  0 0.000 1.000
#> SRR1047826     5   0.000      0.652 0.00  0  0 0.000 1.000
#> SRR1047827     5   0.000      0.652 0.00  0  0 0.000 1.000
#> SRR1047828     1   0.477      0.629 0.56  0  0 0.020 0.420
#> SRR1047829     1   0.477      0.629 0.56  0  0 0.020 0.420
#> SRR1047830     1   0.477      0.629 0.56  0  0 0.020 0.420
#> SRR1047831     1   0.477      0.629 0.56  0  0 0.020 0.420
#> SRR1047832     1   0.477      0.629 0.56  0  0 0.020 0.420
#> SRR1047833     2   0.000      1.000 0.00  1  0 0.000 0.000
#> SRR1047834     2   0.000      1.000 0.00  1  0 0.000 0.000
#> SRR1047835     2   0.000      1.000 0.00  1  0 0.000 0.000
#> SRR1047836     2   0.000      1.000 0.00  1  0 0.000 0.000
#> SRR1047837     2   0.000      1.000 0.00  1  0 0.000 0.000
#> SRR1047838     4   0.154      0.882 0.00  0  0 0.932 0.068
#> SRR1047839     4   0.148      0.884 0.00  0  0 0.936 0.064
#> SRR1047840     4   0.154      0.882 0.00  0  0 0.932 0.068
#> SRR1047841     4   0.154      0.882 0.00  0  0 0.932 0.068
#> SRR1047842     4   0.154      0.882 0.00  0  0 0.932 0.068
#> SRR1047843     4   0.402      0.399 0.00  0  0 0.652 0.348
#> SRR1047844     4   0.148      0.884 0.00  0  0 0.936 0.064
#> SRR1047845     4   0.402      0.399 0.00  0  0 0.652 0.348
#> SRR1047846     4   0.402      0.399 0.00  0  0 0.652 0.348
#> SRR1047847     4   0.148      0.884 0.00  0  0 0.936 0.064
#> SRR1047848     1   0.000      0.790 1.00  0  0 0.000 0.000
#> SRR1047849     1   0.000      0.790 1.00  0  0 0.000 0.000
#> SRR1047850     1   0.000      0.790 1.00  0  0 0.000 0.000
#> SRR1047851     1   0.000      0.790 1.00  0  0 0.000 0.000
#> SRR1047852     1   0.000      0.790 1.00  0  0 0.000 0.000
#> SRR1047853     4   0.000      0.894 0.00  0  0 1.000 0.000
#> SRR1047854     4   0.000      0.894 0.00  0  0 1.000 0.000
#> SRR1047855     4   0.000      0.894 0.00  0  0 1.000 0.000
#> SRR1047856     4   0.000      0.894 0.00  0  0 1.000 0.000
#> SRR1047857     4   0.000      0.894 0.00  0  0 1.000 0.000
#> SRR1047858     5   0.420      0.398 0.00  0  0 0.408 0.592
#> SRR1047859     5   0.430      0.192 0.00  0  0 0.476 0.524
#> SRR1047860     5   0.420      0.398 0.00  0  0 0.408 0.592
#> SRR1047861     5   0.420      0.398 0.00  0  0 0.408 0.592
#> SRR1047863     3   0.000      1.000 0.00  0  1 0.000 0.000
#> SRR1047864     3   0.000      1.000 0.00  0  1 0.000 0.000
#> SRR1047865     3   0.000      1.000 0.00  0  1 0.000 0.000
#> SRR1047866     3   0.000      1.000 0.00  0  1 0.000 0.000
#> SRR1047867     3   0.000      1.000 0.00  0  1 0.000 0.000
#> SRR1047868     3   0.000      1.000 0.00  0  1 0.000 0.000
#> SRR1047869     3   0.000      1.000 0.00  0  1 0.000 0.000
#> SRR1047870     3   0.000      1.000 0.00  0  1 0.000 0.000
#> SRR1047871     3   0.000      1.000 0.00  0  1 0.000 0.000
#> SRR1047872     3   0.000      1.000 0.00  0  1 0.000 0.000
#> SRR1047873     3   0.000      1.000 0.00  0  1 0.000 0.000
#> SRR1047874     3   0.000      1.000 0.00  0  1 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
#> SRR1047813     1   0.380      0.627 0.58  0 0.42 0.000 0.00 0.000
#> SRR1047814     1   0.380      0.627 0.58  0 0.42 0.000 0.00 0.000
#> SRR1047815     1   0.380      0.627 0.58  0 0.42 0.000 0.00 0.000
#> SRR1047816     1   0.380      0.627 0.58  0 0.42 0.000 0.00 0.000
#> SRR1047817     1   0.000      0.586 1.00  0 0.00 0.000 0.00 0.000
#> SRR1047818     4   0.000      0.963 0.00  0 0.00 1.000 0.00 0.000
#> SRR1047819     4   0.000      0.963 0.00  0 0.00 1.000 0.00 0.000
#> SRR1047820     4   0.000      0.963 0.00  0 0.00 1.000 0.00 0.000
#> SRR1047821     4   0.000      0.963 0.00  0 0.00 1.000 0.00 0.000
#> SRR1047822     4   0.000      0.963 0.00  0 0.00 1.000 0.00 0.000
#> SRR1047823     6   0.000      1.000 0.00  0 0.00 0.000 0.00 1.000
#> SRR1047824     6   0.000      1.000 0.00  0 0.00 0.000 0.00 1.000
#> SRR1047825     6   0.000      1.000 0.00  0 0.00 0.000 0.00 1.000
#> SRR1047826     6   0.000      1.000 0.00  0 0.00 0.000 0.00 1.000
#> SRR1047827     6   0.000      1.000 0.00  0 0.00 0.000 0.00 1.000
#> SRR1047828     1   0.000      0.586 1.00  0 0.00 0.000 0.00 0.000
#> SRR1047829     1   0.000      0.586 1.00  0 0.00 0.000 0.00 0.000
#> SRR1047830     1   0.000      0.586 1.00  0 0.00 0.000 0.00 0.000
#> SRR1047831     1   0.000      0.586 1.00  0 0.00 0.000 0.00 0.000
#> SRR1047832     1   0.000      0.586 1.00  0 0.00 0.000 0.00 0.000
#> SRR1047833     2   0.000      1.000 0.00  1 0.00 0.000 0.00 0.000
#> SRR1047834     2   0.000      1.000 0.00  1 0.00 0.000 0.00 0.000
#> SRR1047835     2   0.000      1.000 0.00  1 0.00 0.000 0.00 0.000
#> SRR1047836     2   0.000      1.000 0.00  1 0.00 0.000 0.00 0.000
#> SRR1047837     2   0.000      1.000 0.00  1 0.00 0.000 0.00 0.000
#> SRR1047838     4   0.000      0.963 0.00  0 0.00 1.000 0.00 0.000
#> SRR1047839     4   0.000      0.963 0.00  0 0.00 1.000 0.00 0.000
#> SRR1047840     4   0.000      0.963 0.00  0 0.00 1.000 0.00 0.000
#> SRR1047841     4   0.000      0.963 0.00  0 0.00 1.000 0.00 0.000
#> SRR1047842     4   0.000      0.963 0.00  0 0.00 1.000 0.00 0.000
#> SRR1047843     4   0.285      0.747 0.00  0 0.00 0.792 0.00 0.208
#> SRR1047844     4   0.000      0.963 0.00  0 0.00 1.000 0.00 0.000
#> SRR1047845     4   0.285      0.747 0.00  0 0.00 0.792 0.00 0.208
#> SRR1047846     4   0.285      0.747 0.00  0 0.00 0.792 0.00 0.208
#> SRR1047847     4   0.000      0.963 0.00  0 0.00 1.000 0.00 0.000
#> SRR1047848     1   0.380      0.627 0.58  0 0.42 0.000 0.00 0.000
#> SRR1047849     1   0.380      0.627 0.58  0 0.42 0.000 0.00 0.000
#> SRR1047850     1   0.380      0.627 0.58  0 0.42 0.000 0.00 0.000
#> SRR1047851     1   0.380      0.627 0.58  0 0.42 0.000 0.00 0.000
#> SRR1047852     1   0.380      0.627 0.58  0 0.42 0.000 0.00 0.000
#> SRR1047853     4   0.000      0.963 0.00  0 0.00 1.000 0.00 0.000
#> SRR1047854     4   0.000      0.963 0.00  0 0.00 1.000 0.00 0.000
#> SRR1047855     4   0.000      0.963 0.00  0 0.00 1.000 0.00 0.000
#> SRR1047856     4   0.000      0.963 0.00  0 0.00 1.000 0.00 0.000
#> SRR1047857     4   0.000      0.963 0.00  0 0.00 1.000 0.00 0.000
#> SRR1047858     1   0.591     -0.196 0.42  0 0.00 0.208 0.00 0.372
#> SRR1047859     1   0.599     -0.175 0.42  0 0.00 0.240 0.00 0.340
#> SRR1047860     1   0.591     -0.196 0.42  0 0.00 0.208 0.00 0.372
#> SRR1047861     1   0.591     -0.196 0.42  0 0.00 0.208 0.00 0.372
#> SRR1047863     3   0.380      1.000 0.00  0 0.58 0.000 0.42 0.000
#> SRR1047864     5   0.000      1.000 0.00  0 0.00 0.000 1.00 0.000
#> SRR1047865     3   0.380      1.000 0.00  0 0.58 0.000 0.42 0.000
#> SRR1047866     5   0.000      1.000 0.00  0 0.00 0.000 1.00 0.000
#> SRR1047867     5   0.000      1.000 0.00  0 0.00 0.000 1.00 0.000
#> SRR1047868     3   0.380      1.000 0.00  0 0.58 0.000 0.42 0.000
#> SRR1047869     3   0.380      1.000 0.00  0 0.58 0.000 0.42 0.000
#> SRR1047870     3   0.380      1.000 0.00  0 0.58 0.000 0.42 0.000
#> SRR1047871     3   0.380      1.000 0.00  0 0.58 0.000 0.42 0.000
#> SRR1047872     3   0.380      1.000 0.00  0 0.58 0.000 0.42 0.000
#> SRR1047873     3   0.380      1.000 0.00  0 0.58 0.000 0.42 0.000
#> SRR1047874     3   0.380      1.000 0.00  0 0.58 0.000 0.42 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-mclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-mclust-collect-classes

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

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

collect_plots(res)

plot of chunk ATC-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.720           0.819       0.916         0.2641 0.744   0.744
#> 3 3 0.574           0.834       0.886         0.9092 0.779   0.710
#> 4 4 0.569           0.753       0.832         0.3547 0.740   0.535
#> 5 5 0.539           0.617       0.740         0.0925 0.854   0.561
#> 6 6 0.558           0.583       0.709         0.0653 0.940   0.759

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
#> SRR1047813     1  0.3431     0.9022 0.936 0.064
#> SRR1047814     1  0.3431     0.9022 0.936 0.064
#> SRR1047815     1  0.3431     0.9022 0.936 0.064
#> SRR1047816     1  0.3431     0.9022 0.936 0.064
#> SRR1047817     1  0.2236     0.9157 0.964 0.036
#> SRR1047818     1  0.0672     0.9192 0.992 0.008
#> SRR1047819     1  0.0376     0.9205 0.996 0.004
#> SRR1047820     1  0.0376     0.9205 0.996 0.004
#> SRR1047821     1  0.0376     0.9205 0.996 0.004
#> SRR1047822     1  0.1184     0.9149 0.984 0.016
#> SRR1047823     1  0.3431     0.9022 0.936 0.064
#> SRR1047824     1  0.3274     0.9047 0.940 0.060
#> SRR1047825     1  0.3431     0.9022 0.936 0.064
#> SRR1047826     1  0.3431     0.9022 0.936 0.064
#> SRR1047827     1  0.3431     0.9022 0.936 0.064
#> SRR1047828     1  0.1414     0.9200 0.980 0.020
#> SRR1047829     1  0.0376     0.9205 0.996 0.004
#> SRR1047830     1  0.1414     0.9200 0.980 0.020
#> SRR1047831     1  0.0376     0.9213 0.996 0.004
#> SRR1047832     1  0.0376     0.9213 0.996 0.004
#> SRR1047833     2  0.0938     0.7399 0.012 0.988
#> SRR1047834     2  0.0938     0.7399 0.012 0.988
#> SRR1047835     2  0.0938     0.7399 0.012 0.988
#> SRR1047836     2  0.0938     0.7399 0.012 0.988
#> SRR1047837     2  0.0938     0.7399 0.012 0.988
#> SRR1047838     1  0.0000     0.9211 1.000 0.000
#> SRR1047839     1  0.0672     0.9192 0.992 0.008
#> SRR1047840     1  0.1184     0.9206 0.984 0.016
#> SRR1047841     1  0.0000     0.9211 1.000 0.000
#> SRR1047842     1  0.0000     0.9211 1.000 0.000
#> SRR1047843     1  0.0000     0.9211 1.000 0.000
#> SRR1047844     1  0.0672     0.9192 0.992 0.008
#> SRR1047845     1  0.0000     0.9211 1.000 0.000
#> SRR1047846     1  0.0000     0.9211 1.000 0.000
#> SRR1047847     1  0.0672     0.9192 0.992 0.008
#> SRR1047848     1  0.3431     0.9022 0.936 0.064
#> SRR1047849     1  0.3114     0.9070 0.944 0.056
#> SRR1047850     1  0.3114     0.9070 0.944 0.056
#> SRR1047851     1  0.3114     0.9070 0.944 0.056
#> SRR1047852     1  0.3114     0.9070 0.944 0.056
#> SRR1047853     1  0.1184     0.9149 0.984 0.016
#> SRR1047854     1  0.0672     0.9192 0.992 0.008
#> SRR1047855     1  0.0672     0.9192 0.992 0.008
#> SRR1047856     1  0.1184     0.9149 0.984 0.016
#> SRR1047857     1  0.1184     0.9149 0.984 0.016
#> SRR1047858     1  0.2043     0.9171 0.968 0.032
#> SRR1047859     1  0.1414     0.9200 0.980 0.020
#> SRR1047860     1  0.2043     0.9171 0.968 0.032
#> SRR1047861     1  0.2043     0.9171 0.968 0.032
#> SRR1047863     2  0.9998     0.3285 0.492 0.508
#> SRR1047864     2  0.9954     0.4090 0.460 0.540
#> SRR1047865     1  0.9815    -0.0587 0.580 0.420
#> SRR1047866     2  0.9998     0.3285 0.492 0.508
#> SRR1047867     2  0.9909     0.4375 0.444 0.556
#> SRR1047868     1  0.7376     0.6616 0.792 0.208
#> SRR1047869     1  0.6887     0.7072 0.816 0.184
#> SRR1047870     1  0.9087     0.3559 0.676 0.324
#> SRR1047871     1  0.5842     0.7792 0.860 0.140
#> SRR1047872     1  0.8207     0.5541 0.744 0.256
#> SRR1047873     1  0.5842     0.7792 0.860 0.140
#> SRR1047874     1  0.5842     0.7792 0.860 0.140

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1047813     1  0.1289      0.850 0.968 0.032 0.000
#> SRR1047814     1  0.1289      0.850 0.968 0.032 0.000
#> SRR1047815     1  0.1289      0.850 0.968 0.032 0.000
#> SRR1047816     1  0.1289      0.850 0.968 0.032 0.000
#> SRR1047817     1  0.1031      0.852 0.976 0.024 0.000
#> SRR1047818     1  0.6597      0.714 0.696 0.036 0.268
#> SRR1047819     1  0.4744      0.828 0.836 0.028 0.136
#> SRR1047820     1  0.5180      0.814 0.812 0.032 0.156
#> SRR1047821     1  0.6375      0.742 0.720 0.036 0.244
#> SRR1047822     1  0.7987      0.348 0.492 0.060 0.448
#> SRR1047823     1  0.0237      0.856 0.996 0.004 0.000
#> SRR1047824     1  0.0237      0.856 0.996 0.004 0.000
#> SRR1047825     1  0.0237      0.856 0.996 0.004 0.000
#> SRR1047826     1  0.0237      0.856 0.996 0.004 0.000
#> SRR1047827     1  0.0237      0.856 0.996 0.004 0.000
#> SRR1047828     1  0.3028      0.856 0.920 0.032 0.048
#> SRR1047829     1  0.5687      0.775 0.756 0.020 0.224
#> SRR1047830     1  0.3141      0.856 0.912 0.020 0.068
#> SRR1047831     1  0.3528      0.853 0.892 0.016 0.092
#> SRR1047832     1  0.3610      0.852 0.888 0.016 0.096
#> SRR1047833     2  0.1620      0.995 0.012 0.964 0.024
#> SRR1047834     2  0.1453      0.996 0.008 0.968 0.024
#> SRR1047835     2  0.1620      0.995 0.012 0.964 0.024
#> SRR1047836     2  0.1453      0.996 0.008 0.968 0.024
#> SRR1047837     2  0.1453      0.996 0.008 0.968 0.024
#> SRR1047838     1  0.3590      0.853 0.896 0.028 0.076
#> SRR1047839     1  0.6662      0.745 0.716 0.052 0.232
#> SRR1047840     1  0.3181      0.856 0.912 0.024 0.064
#> SRR1047841     1  0.3678      0.852 0.892 0.028 0.080
#> SRR1047842     1  0.3678      0.852 0.892 0.028 0.080
#> SRR1047843     1  0.3690      0.850 0.884 0.016 0.100
#> SRR1047844     1  0.7192      0.556 0.588 0.032 0.380
#> SRR1047845     1  0.3769      0.847 0.880 0.016 0.104
#> SRR1047846     1  0.3921      0.845 0.872 0.016 0.112
#> SRR1047847     1  0.7061      0.627 0.632 0.036 0.332
#> SRR1047848     1  0.1163      0.851 0.972 0.028 0.000
#> SRR1047849     1  0.1163      0.851 0.972 0.028 0.000
#> SRR1047850     1  0.0892      0.853 0.980 0.020 0.000
#> SRR1047851     1  0.1163      0.851 0.972 0.028 0.000
#> SRR1047852     1  0.1163      0.851 0.972 0.028 0.000
#> SRR1047853     1  0.7274      0.418 0.520 0.028 0.452
#> SRR1047854     1  0.6066      0.748 0.728 0.024 0.248
#> SRR1047855     1  0.5986      0.756 0.736 0.024 0.240
#> SRR1047856     1  0.7248      0.455 0.536 0.028 0.436
#> SRR1047857     1  0.7430      0.467 0.540 0.036 0.424
#> SRR1047858     1  0.0000      0.856 1.000 0.000 0.000
#> SRR1047859     1  0.1453      0.859 0.968 0.008 0.024
#> SRR1047860     1  0.0237      0.857 0.996 0.004 0.000
#> SRR1047861     1  0.0237      0.857 0.996 0.004 0.000
#> SRR1047863     3  0.2796      0.924 0.000 0.092 0.908
#> SRR1047864     3  0.2356      0.936 0.000 0.072 0.928
#> SRR1047865     3  0.1289      0.951 0.000 0.032 0.968
#> SRR1047866     3  0.2066      0.941 0.000 0.060 0.940
#> SRR1047867     3  0.2261      0.938 0.000 0.068 0.932
#> SRR1047868     3  0.1860      0.936 0.000 0.052 0.948
#> SRR1047869     3  0.0892      0.956 0.000 0.020 0.980
#> SRR1047870     3  0.1163      0.957 0.000 0.028 0.972
#> SRR1047871     3  0.0592      0.955 0.000 0.012 0.988
#> SRR1047872     3  0.1031      0.957 0.000 0.024 0.976
#> SRR1047873     3  0.2384      0.927 0.008 0.056 0.936
#> SRR1047874     3  0.1525      0.941 0.004 0.032 0.964

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1047813     1  0.1004     0.8257 0.972 0.000 0.024 0.004
#> SRR1047814     1  0.0779     0.8286 0.980 0.000 0.016 0.004
#> SRR1047815     1  0.0927     0.8282 0.976 0.000 0.016 0.008
#> SRR1047816     1  0.0927     0.8282 0.976 0.000 0.016 0.008
#> SRR1047817     1  0.1004     0.8277 0.972 0.000 0.004 0.024
#> SRR1047818     4  0.2075     0.7972 0.016 0.004 0.044 0.936
#> SRR1047819     4  0.1888     0.8038 0.044 0.000 0.016 0.940
#> SRR1047820     4  0.2007     0.8054 0.036 0.004 0.020 0.940
#> SRR1047821     4  0.1863     0.7961 0.012 0.004 0.040 0.944
#> SRR1047822     4  0.2597     0.7512 0.004 0.008 0.084 0.904
#> SRR1047823     1  0.4824     0.7276 0.744 0.004 0.024 0.228
#> SRR1047824     1  0.5243     0.6805 0.704 0.008 0.024 0.264
#> SRR1047825     1  0.4824     0.7276 0.744 0.004 0.024 0.228
#> SRR1047826     1  0.4824     0.7276 0.744 0.004 0.024 0.228
#> SRR1047827     1  0.4986     0.7050 0.724 0.004 0.024 0.248
#> SRR1047828     1  0.2988     0.7820 0.876 0.012 0.112 0.000
#> SRR1047829     1  0.4647     0.7441 0.796 0.012 0.156 0.036
#> SRR1047830     1  0.2928     0.7853 0.880 0.012 0.108 0.000
#> SRR1047831     1  0.2988     0.7831 0.876 0.012 0.112 0.000
#> SRR1047832     1  0.3289     0.7773 0.864 0.012 0.120 0.004
#> SRR1047833     2  0.0376     0.9954 0.004 0.992 0.000 0.004
#> SRR1047834     2  0.0188     0.9969 0.000 0.996 0.000 0.004
#> SRR1047835     2  0.0188     0.9969 0.000 0.996 0.000 0.004
#> SRR1047836     2  0.0376     0.9954 0.004 0.992 0.000 0.004
#> SRR1047837     2  0.0188     0.9969 0.000 0.996 0.000 0.004
#> SRR1047838     4  0.3157     0.7622 0.144 0.000 0.004 0.852
#> SRR1047839     4  0.1639     0.7960 0.008 0.004 0.036 0.952
#> SRR1047840     4  0.4319     0.6481 0.228 0.000 0.012 0.760
#> SRR1047841     4  0.2589     0.7844 0.116 0.000 0.000 0.884
#> SRR1047842     4  0.2647     0.7821 0.120 0.000 0.000 0.880
#> SRR1047843     1  0.5392     0.1992 0.528 0.000 0.012 0.460
#> SRR1047844     4  0.3256     0.7947 0.044 0.004 0.068 0.884
#> SRR1047845     4  0.5163    -0.0630 0.480 0.000 0.004 0.516
#> SRR1047846     4  0.5126     0.0973 0.444 0.000 0.004 0.552
#> SRR1047847     4  0.2549     0.7967 0.024 0.004 0.056 0.916
#> SRR1047848     1  0.1629     0.8211 0.952 0.024 0.024 0.000
#> SRR1047849     1  0.1297     0.8235 0.964 0.016 0.020 0.000
#> SRR1047850     1  0.0967     0.8278 0.976 0.016 0.004 0.004
#> SRR1047851     1  0.1059     0.8256 0.972 0.016 0.012 0.000
#> SRR1047852     1  0.1059     0.8256 0.972 0.016 0.012 0.000
#> SRR1047853     4  0.2926     0.7536 0.012 0.004 0.096 0.888
#> SRR1047854     4  0.3800     0.7939 0.112 0.004 0.036 0.848
#> SRR1047855     4  0.3706     0.7915 0.112 0.000 0.040 0.848
#> SRR1047856     4  0.2796     0.7497 0.008 0.004 0.096 0.892
#> SRR1047857     4  0.2715     0.7404 0.004 0.004 0.100 0.892
#> SRR1047858     1  0.3895     0.7626 0.804 0.000 0.012 0.184
#> SRR1047859     1  0.5026     0.6050 0.672 0.000 0.016 0.312
#> SRR1047860     1  0.4019     0.7560 0.792 0.000 0.012 0.196
#> SRR1047861     1  0.4253     0.7455 0.776 0.000 0.016 0.208
#> SRR1047863     3  0.5003     0.7726 0.000 0.016 0.676 0.308
#> SRR1047864     3  0.3312     0.6539 0.068 0.040 0.884 0.008
#> SRR1047865     3  0.2773     0.7957 0.004 0.000 0.880 0.116
#> SRR1047866     3  0.3238     0.6427 0.092 0.020 0.880 0.008
#> SRR1047867     3  0.3538     0.6645 0.024 0.096 0.868 0.012
#> SRR1047868     3  0.4836     0.7637 0.000 0.008 0.672 0.320
#> SRR1047869     3  0.3208     0.8167 0.004 0.000 0.848 0.148
#> SRR1047870     3  0.4086     0.8251 0.000 0.008 0.776 0.216
#> SRR1047871     3  0.3631     0.8239 0.004 0.004 0.824 0.168
#> SRR1047872     3  0.4089     0.8258 0.004 0.004 0.780 0.212
#> SRR1047873     3  0.5085     0.6913 0.000 0.008 0.616 0.376
#> SRR1047874     3  0.4917     0.7508 0.004 0.004 0.664 0.328

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4    p5
#> SRR1047813     1  0.5316     0.0227 0.520 0.004 0.032 0.004 0.440
#> SRR1047814     1  0.5396     0.0996 0.540 0.004 0.032 0.008 0.416
#> SRR1047815     1  0.5396     0.0956 0.540 0.004 0.032 0.008 0.416
#> SRR1047816     1  0.5419     0.0389 0.524 0.004 0.032 0.008 0.432
#> SRR1047817     1  0.5657     0.0666 0.516 0.008 0.024 0.020 0.432
#> SRR1047818     4  0.2707     0.7520 0.080 0.000 0.024 0.888 0.008
#> SRR1047819     4  0.3792     0.7402 0.180 0.000 0.020 0.792 0.008
#> SRR1047820     4  0.3678     0.7444 0.168 0.000 0.020 0.804 0.008
#> SRR1047821     4  0.2881     0.7519 0.092 0.000 0.024 0.876 0.008
#> SRR1047822     4  0.1787     0.7265 0.016 0.000 0.032 0.940 0.012
#> SRR1047823     1  0.1924     0.6215 0.924 0.000 0.004 0.064 0.008
#> SRR1047824     1  0.2237     0.6159 0.904 0.000 0.004 0.084 0.008
#> SRR1047825     1  0.2103     0.6201 0.920 0.000 0.004 0.056 0.020
#> SRR1047826     1  0.2005     0.6205 0.924 0.000 0.004 0.056 0.016
#> SRR1047827     1  0.1956     0.6196 0.916 0.000 0.000 0.076 0.008
#> SRR1047828     5  0.4445     0.8294 0.272 0.000 0.024 0.004 0.700
#> SRR1047829     5  0.4863     0.7331 0.176 0.000 0.064 0.020 0.740
#> SRR1047830     5  0.4260     0.8340 0.256 0.000 0.020 0.004 0.720
#> SRR1047831     5  0.4125     0.8258 0.236 0.000 0.020 0.004 0.740
#> SRR1047832     5  0.4155     0.8195 0.228 0.000 0.024 0.004 0.744
#> SRR1047833     2  0.0000     0.9944 0.000 1.000 0.000 0.000 0.000
#> SRR1047834     2  0.0162     0.9951 0.000 0.996 0.000 0.004 0.000
#> SRR1047835     2  0.0162     0.9953 0.000 0.996 0.004 0.000 0.000
#> SRR1047836     2  0.0162     0.9953 0.000 0.996 0.004 0.000 0.000
#> SRR1047837     2  0.0162     0.9951 0.000 0.996 0.000 0.004 0.000
#> SRR1047838     4  0.4387     0.5663 0.336 0.000 0.004 0.652 0.008
#> SRR1047839     4  0.0960     0.7330 0.008 0.000 0.016 0.972 0.004
#> SRR1047840     4  0.4658     0.1876 0.484 0.000 0.000 0.504 0.012
#> SRR1047841     4  0.3521     0.7063 0.232 0.000 0.000 0.764 0.004
#> SRR1047842     4  0.3671     0.6971 0.236 0.000 0.000 0.756 0.008
#> SRR1047843     1  0.5078     0.5310 0.692 0.000 0.024 0.244 0.040
#> SRR1047844     4  0.2256     0.7260 0.032 0.000 0.032 0.920 0.016
#> SRR1047845     1  0.5161     0.3413 0.620 0.000 0.020 0.336 0.024
#> SRR1047846     1  0.5322     0.2970 0.592 0.000 0.020 0.360 0.028
#> SRR1047847     4  0.2170     0.7202 0.020 0.000 0.036 0.924 0.020
#> SRR1047848     5  0.4252     0.7955 0.340 0.000 0.008 0.000 0.652
#> SRR1047849     5  0.4122     0.8377 0.304 0.000 0.004 0.004 0.688
#> SRR1047850     5  0.4299     0.8348 0.316 0.000 0.008 0.004 0.672
#> SRR1047851     5  0.4236     0.8279 0.328 0.000 0.004 0.004 0.664
#> SRR1047852     5  0.4218     0.8285 0.324 0.000 0.004 0.004 0.668
#> SRR1047853     4  0.2313     0.7367 0.032 0.000 0.040 0.916 0.012
#> SRR1047854     4  0.5190     0.6872 0.236 0.004 0.032 0.696 0.032
#> SRR1047855     4  0.5087     0.6825 0.244 0.004 0.028 0.696 0.028
#> SRR1047856     4  0.2140     0.7341 0.024 0.000 0.040 0.924 0.012
#> SRR1047857     4  0.1617     0.7366 0.020 0.000 0.020 0.948 0.012
#> SRR1047858     1  0.4295     0.5107 0.760 0.000 0.012 0.032 0.196
#> SRR1047859     1  0.4823     0.5766 0.744 0.000 0.008 0.120 0.128
#> SRR1047860     1  0.4220     0.5095 0.760 0.000 0.008 0.032 0.200
#> SRR1047861     1  0.4087     0.5459 0.784 0.000 0.008 0.040 0.168
#> SRR1047863     3  0.5235     0.4482 0.008 0.008 0.524 0.444 0.016
#> SRR1047864     3  0.4352     0.5833 0.020 0.012 0.732 0.000 0.236
#> SRR1047865     3  0.5317     0.7204 0.004 0.004 0.700 0.148 0.144
#> SRR1047866     3  0.5020     0.4409 0.016 0.012 0.564 0.000 0.408
#> SRR1047867     3  0.4583     0.5765 0.036 0.052 0.788 0.004 0.120
#> SRR1047868     3  0.4510     0.4625 0.000 0.008 0.560 0.432 0.000
#> SRR1047869     3  0.4855     0.7265 0.004 0.000 0.716 0.204 0.076
#> SRR1047870     3  0.4193     0.7355 0.012 0.008 0.784 0.172 0.024
#> SRR1047871     3  0.3995     0.7366 0.012 0.008 0.804 0.152 0.024
#> SRR1047872     3  0.4527     0.6849 0.000 0.004 0.696 0.272 0.028
#> SRR1047873     4  0.4876     0.1059 0.008 0.004 0.320 0.648 0.020
#> SRR1047874     4  0.4854    -0.1151 0.004 0.004 0.404 0.576 0.012

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5 p6
#> SRR1047813     5  0.6461     0.4092 0.240 0.000 0.008 0.016 0.464 NA
#> SRR1047814     5  0.6439     0.4166 0.228 0.000 0.008 0.016 0.468 NA
#> SRR1047815     5  0.6427     0.4188 0.228 0.000 0.008 0.016 0.472 NA
#> SRR1047816     5  0.6478     0.4196 0.220 0.000 0.008 0.020 0.472 NA
#> SRR1047817     5  0.7064     0.3640 0.180 0.000 0.008 0.072 0.420 NA
#> SRR1047818     4  0.3940     0.6326 0.104 0.000 0.016 0.804 0.012 NA
#> SRR1047819     4  0.4668     0.6276 0.152 0.000 0.012 0.740 0.020 NA
#> SRR1047820     4  0.4469     0.6283 0.136 0.000 0.012 0.760 0.020 NA
#> SRR1047821     4  0.4095     0.6299 0.108 0.000 0.012 0.792 0.016 NA
#> SRR1047822     4  0.3378     0.6221 0.056 0.000 0.024 0.848 0.008 NA
#> SRR1047823     1  0.1332     0.7323 0.952 0.000 0.000 0.008 0.028 NA
#> SRR1047824     1  0.1950     0.7272 0.924 0.000 0.000 0.032 0.028 NA
#> SRR1047825     1  0.1577     0.7314 0.940 0.000 0.000 0.008 0.036 NA
#> SRR1047826     1  0.1503     0.7321 0.944 0.000 0.000 0.008 0.032 NA
#> SRR1047827     1  0.1710     0.7325 0.936 0.000 0.000 0.020 0.028 NA
#> SRR1047828     5  0.3462     0.6013 0.120 0.000 0.012 0.020 0.828 NA
#> SRR1047829     5  0.4769     0.5440 0.084 0.000 0.016 0.076 0.760 NA
#> SRR1047830     5  0.3149     0.6001 0.100 0.000 0.012 0.020 0.852 NA
#> SRR1047831     5  0.3039     0.5973 0.100 0.000 0.012 0.024 0.856 NA
#> SRR1047832     5  0.3316     0.5901 0.100 0.000 0.012 0.020 0.844 NA
#> SRR1047833     2  0.0146     0.9938 0.000 0.996 0.000 0.000 0.004 NA
#> SRR1047834     2  0.0146     0.9969 0.000 0.996 0.000 0.004 0.000 NA
#> SRR1047835     2  0.0000     0.9942 0.000 1.000 0.000 0.000 0.000 NA
#> SRR1047836     2  0.0146     0.9969 0.000 0.996 0.000 0.004 0.000 NA
#> SRR1047837     2  0.0146     0.9969 0.000 0.996 0.000 0.004 0.000 NA
#> SRR1047838     4  0.5817     0.4747 0.280 0.004 0.004 0.568 0.012 NA
#> SRR1047839     4  0.3080     0.6163 0.036 0.000 0.036 0.860 0.000 NA
#> SRR1047840     4  0.6389     0.2170 0.372 0.004 0.004 0.440 0.020 NA
#> SRR1047841     4  0.5270     0.5895 0.208 0.004 0.016 0.664 0.004 NA
#> SRR1047842     4  0.5298     0.5956 0.200 0.004 0.020 0.668 0.004 NA
#> SRR1047843     1  0.5286     0.6114 0.680 0.000 0.004 0.184 0.044 NA
#> SRR1047844     4  0.4839     0.5514 0.048 0.000 0.060 0.724 0.004 NA
#> SRR1047845     1  0.5863     0.4494 0.592 0.000 0.008 0.264 0.036 NA
#> SRR1047846     1  0.5858     0.4176 0.572 0.000 0.004 0.284 0.032 NA
#> SRR1047847     4  0.4612     0.5639 0.040 0.000 0.048 0.744 0.008 NA
#> SRR1047848     5  0.4939     0.3935 0.380 0.000 0.004 0.000 0.556 NA
#> SRR1047849     5  0.4635     0.4778 0.336 0.000 0.000 0.000 0.608 NA
#> SRR1047850     5  0.4648     0.4756 0.340 0.000 0.000 0.000 0.604 NA
#> SRR1047851     5  0.4648     0.4756 0.340 0.000 0.000 0.000 0.604 NA
#> SRR1047852     5  0.4621     0.4793 0.332 0.000 0.000 0.000 0.612 NA
#> SRR1047853     4  0.5322     0.5886 0.032 0.000 0.040 0.696 0.052 NA
#> SRR1047854     4  0.7086     0.4493 0.144 0.004 0.016 0.484 0.076 NA
#> SRR1047855     4  0.7125     0.4411 0.148 0.004 0.016 0.476 0.076 NA
#> SRR1047856     4  0.5042     0.5952 0.036 0.000 0.032 0.720 0.044 NA
#> SRR1047857     4  0.4595     0.6070 0.028 0.000 0.036 0.760 0.036 NA
#> SRR1047858     1  0.4477     0.6357 0.740 0.000 0.000 0.016 0.124 NA
#> SRR1047859     1  0.4865     0.6843 0.732 0.000 0.000 0.068 0.100 NA
#> SRR1047860     1  0.4391     0.6408 0.748 0.000 0.000 0.016 0.128 NA
#> SRR1047861     1  0.4507     0.6562 0.748 0.000 0.000 0.028 0.116 NA
#> SRR1047863     3  0.4881     0.5707 0.000 0.000 0.604 0.324 0.004 NA
#> SRR1047864     3  0.3907     0.6073 0.000 0.000 0.764 0.000 0.152 NA
#> SRR1047865     3  0.5661     0.6963 0.004 0.000 0.660 0.104 0.072 NA
#> SRR1047866     3  0.6059     0.3072 0.004 0.000 0.464 0.012 0.368 NA
#> SRR1047867     3  0.4038     0.5673 0.008 0.020 0.764 0.000 0.024 NA
#> SRR1047868     3  0.4844     0.5600 0.000 0.000 0.608 0.312 0.000 NA
#> SRR1047869     3  0.5396     0.6918 0.004 0.000 0.664 0.152 0.028 NA
#> SRR1047870     3  0.3815     0.7108 0.000 0.004 0.800 0.132 0.020 NA
#> SRR1047871     3  0.2686     0.7165 0.000 0.000 0.868 0.100 0.008 NA
#> SRR1047872     3  0.5047     0.6729 0.004 0.000 0.672 0.208 0.012 NA
#> SRR1047873     4  0.5807     0.0218 0.004 0.000 0.284 0.516 0.000 NA
#> SRR1047874     4  0.5843     0.0330 0.008 0.000 0.308 0.512 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-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