cola Report for recount2:SRP051599

Date: 2019-12-26 00:42:28 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 15454 rows and 60 columns.
#>   Top rows are extracted by 'SD, CV, MAD, ATC' methods.
#>   Subgroups are detected by 'hclust, kmeans, skmeans, pam, mclust, NMF' method.
#>   Number of partitions are tried for k = 2, 3, 4, 5, 6.
#>   Performed in total 30000 partitions by row resampling.
#> 
#> Following methods can be applied to this 'ConsensusPartitionList' object:
#>  [1] "cola_report"           "collect_classes"       "collect_plots"         "collect_stats"        
#>  [5] "colnames"              "functional_enrichment" "get_anno_col"          "get_anno"             
#>  [9] "get_classes"           "get_matrix"            "get_membership"        "get_stats"            
#> [13] "is_best_k"             "is_stable_k"           "ncol"                  "nrow"                 
#> [17] "rownames"              "show"                  "suggest_best_k"        "test_to_known_factors"
#> [21] "top_rows_heatmap"      "top_rows_overlap"     
#> 
#> You can get result for a single method by, e.g. object["SD", "hclust"] or object["SD:hclust"]
#> or a subset of methods by object[c("SD", "CV")], c("hclust", "kmeans")]

The call of run_all_consensus_partition_methods() was:

#> run_all_consensus_partition_methods(data = mat, mc.cores = 4)

Dimension of the input matrix:

mat = get_matrix(res_list)
dim(mat)
#> [1] 15454    60

Density distribution

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

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

plot of chunk density-heatmap

Suggest the best k

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

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

suggest_best_k(res_list)
The best k 1-PAC Mean silhouette Concordance Optional k
SD:kmeans 2 1.000 1.000 1.000 **
SD:pam 6 1.000 0.981 0.993 ** 2,3,4,5
SD:NMF 2 1.000 1.000 1.000 **
CV:hclust 2 1.000 1.000 1.000 **
CV:kmeans 2 1.000 0.995 0.994 **
CV:pam 6 1.000 0.998 0.999 ** 2,3,5
CV:NMF 6 1.000 0.987 0.983 ** 2,5
MAD:kmeans 2 1.000 1.000 1.000 **
MAD:pam 6 1.000 0.982 0.993 ** 2,3,4,5
ATC:kmeans 2 1.000 1.000 1.000 **
ATC:skmeans 2 1.000 1.000 1.000 **
ATC:NMF 2 1.000 1.000 1.000 **
CV:skmeans 6 0.995 0.978 0.961 ** 2,4
MAD:mclust 6 0.968 0.953 0.966 ** 2,3,5
ATC:pam 6 0.946 0.985 0.958 * 2,5
CV:mclust 3 0.944 0.935 0.964 * 2
SD:skmeans 6 0.942 0.955 0.949 * 2
MAD:skmeans 6 0.932 0.959 0.939 * 2
MAD:hclust 6 0.930 0.897 0.960 * 2
MAD:NMF 4 0.924 0.938 0.949 * 2
ATC:hclust 5 0.909 0.520 0.796 * 2,4
SD:hclust 6 0.909 0.889 0.932 * 2
ATC:mclust 6 0.905 0.906 0.936 * 2,4,5
SD:mclust 6 0.904 0.908 0.923 * 2,3,5

**: 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           1.000       1.000          0.489 0.512   0.512
#> CV:NMF      2     1           1.000       1.000          0.489 0.512   0.512
#> MAD:NMF     2     1           1.000       1.000          0.489 0.512   0.512
#> ATC:NMF     2     1           1.000       1.000          0.489 0.512   0.512
#> SD:skmeans  2     1           1.000       1.000          0.489 0.512   0.512
#> CV:skmeans  2     1           1.000       1.000          0.489 0.512   0.512
#> MAD:skmeans 2     1           1.000       1.000          0.489 0.512   0.512
#> ATC:skmeans 2     1           1.000       1.000          0.489 0.512   0.512
#> SD:mclust   2     1           1.000       1.000          0.489 0.512   0.512
#> CV:mclust   2     1           1.000       1.000          0.489 0.512   0.512
#> MAD:mclust  2     1           1.000       1.000          0.489 0.512   0.512
#> ATC:mclust  2     1           1.000       1.000          0.489 0.512   0.512
#> SD:kmeans   2     1           1.000       1.000          0.489 0.512   0.512
#> CV:kmeans   2     1           0.995       0.994          0.487 0.512   0.512
#> MAD:kmeans  2     1           1.000       1.000          0.489 0.512   0.512
#> ATC:kmeans  2     1           1.000       1.000          0.489 0.512   0.512
#> SD:pam      2     1           1.000       1.000          0.489 0.512   0.512
#> CV:pam      2     1           1.000       1.000          0.489 0.512   0.512
#> MAD:pam     2     1           1.000       1.000          0.489 0.512   0.512
#> ATC:pam     2     1           1.000       1.000          0.489 0.512   0.512
#> SD:hclust   2     1           1.000       1.000          0.489 0.512   0.512
#> CV:hclust   2     1           1.000       1.000          0.489 0.512   0.512
#> MAD:hclust  2     1           1.000       1.000          0.489 0.512   0.512
#> ATC:hclust  2     1           1.000       1.000          0.489 0.512   0.512
get_stats(res_list, k = 3)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      3 0.714           0.903       0.863          0.288 0.831   0.670
#> CV:NMF      3 0.741           0.924       0.905          0.301 0.831   0.670
#> MAD:NMF     3 0.675           0.796       0.820          0.302 0.831   0.670
#> ATC:NMF     3 0.818           0.781       0.928          0.130 0.962   0.925
#> SD:skmeans  3 0.898           0.953       0.975          0.350 0.831   0.670
#> CV:skmeans  3 0.898           0.914       0.960          0.352 0.837   0.682
#> MAD:skmeans 3 0.885           0.957       0.977          0.351 0.831   0.670
#> ATC:skmeans 3 0.819           0.837       0.885          0.319 0.831   0.670
#> SD:mclust   3 1.000           0.970       0.985          0.300 0.853   0.713
#> CV:mclust   3 0.944           0.935       0.964          0.323 0.837   0.682
#> MAD:mclust  3 1.000           0.984       0.991          0.300 0.853   0.713
#> ATC:mclust  3 0.793           0.833       0.914          0.330 0.726   0.507
#> SD:kmeans   3 0.706           0.754       0.791          0.258 0.818   0.643
#> CV:kmeans   3 0.706           0.850       0.829          0.269 0.837   0.682
#> MAD:kmeans  3 0.707           0.812       0.796          0.280 0.818   0.643
#> ATC:kmeans  3 0.663           0.842       0.848          0.234 1.000   1.000
#> SD:pam      3 1.000           0.977       0.992          0.339 0.837   0.682
#> CV:pam      3 1.000           0.999       1.000          0.333 0.837   0.682
#> MAD:pam     3 1.000           0.996       0.998          0.344 0.831   0.670
#> ATC:pam     3 0.830           0.943       0.948          0.333 0.831   0.670
#> SD:hclust   3 0.898           0.900       0.954          0.354 0.837   0.682
#> CV:hclust   3 0.898           0.953       0.976          0.349 0.831   0.670
#> MAD:hclust  3 0.793           0.864       0.915          0.308 0.831   0.670
#> ATC:hclust  3 1.000           0.978       0.996          0.046 0.980   0.961
get_stats(res_list, k = 4)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      4 0.877           0.835       0.912         0.1344 0.919   0.773
#> CV:NMF      4 0.838           0.909       0.896         0.1341 0.919   0.773
#> MAD:NMF     4 0.924           0.938       0.949         0.1381 0.899   0.716
#> ATC:NMF     4 0.852           0.958       0.955         0.1760 0.845   0.680
#> SD:skmeans  4 0.835           0.920       0.921         0.0881 0.942   0.832
#> CV:skmeans  4 0.930           0.886       0.919         0.0884 0.939   0.825
#> MAD:skmeans 4 0.880           0.933       0.922         0.0869 0.942   0.832
#> ATC:skmeans 4 0.822           0.910       0.934         0.1104 0.915   0.760
#> SD:mclust   4 0.898           0.967       0.982         0.1344 0.883   0.694
#> CV:mclust   4 0.793           0.882       0.914         0.1215 0.919   0.773
#> MAD:mclust  4 0.898           0.960       0.979         0.1354 0.883   0.694
#> ATC:mclust  4 1.000           0.989       0.995         0.1073 0.956   0.865
#> SD:kmeans   4 0.609           0.756       0.778         0.1237 0.939   0.815
#> CV:kmeans   4 0.665           0.827       0.783         0.1346 0.939   0.825
#> MAD:kmeans  4 0.599           0.812       0.784         0.1031 0.837   0.580
#> ATC:kmeans  4 0.615           0.303       0.721         0.1212 0.885   0.778
#> SD:pam      4 1.000           0.976       0.992         0.0932 0.939   0.825
#> CV:pam      4 0.863           0.969       0.937         0.0960 0.939   0.825
#> MAD:pam     4 1.000           0.995       0.998         0.0928 0.939   0.822
#> ATC:pam     4 0.868           0.900       0.899         0.1052 0.939   0.822
#> SD:hclust   4 0.898           0.894       0.961         0.0139 0.987   0.963
#> CV:hclust   4 0.940           0.947       0.978         0.0207 0.993   0.980
#> MAD:hclust  4 0.793           0.856       0.935         0.0244 0.993   0.980
#> ATC:hclust  4 1.000           0.973       0.992         0.2412 0.868   0.731
get_stats(res_list, k = 5)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      5 0.765           0.868       0.885         0.0883 0.924   0.735
#> CV:NMF      5 0.924           0.973       0.967         0.0886 0.924   0.735
#> MAD:NMF     5 0.742           0.795       0.831         0.0774 0.911   0.675
#> ATC:NMF     5 0.768           0.727       0.872         0.0716 0.993   0.980
#> SD:skmeans  5 0.867           0.923       0.925         0.0793 0.939   0.786
#> CV:skmeans  5 0.855           0.739       0.755         0.0709 0.832   0.519
#> MAD:skmeans 5 0.860           0.943       0.935         0.0789 0.939   0.786
#> ATC:skmeans 5 0.852           0.895       0.876         0.0648 0.939   0.781
#> SD:mclust   5 0.905           0.569       0.826         0.0861 0.932   0.760
#> CV:mclust   5 0.898           0.903       0.923         0.0756 0.942   0.796
#> MAD:mclust  5 0.936           0.929       0.959         0.0927 0.925   0.735
#> ATC:mclust  5 0.969           0.950       0.971         0.0966 0.925   0.735
#> SD:kmeans   5 0.683           0.739       0.785         0.0735 0.898   0.688
#> CV:kmeans   5 0.663           0.555       0.789         0.0604 0.987   0.955
#> MAD:kmeans  5 0.705           0.777       0.743         0.0865 0.942   0.796
#> ATC:kmeans  5 0.591           0.784       0.768         0.0808 0.769   0.461
#> SD:pam      5 1.000           0.947       0.980         0.0935 0.912   0.703
#> CV:pam      5 0.944           0.939       0.953         0.0868 0.923   0.738
#> MAD:pam     5 1.000           0.969       0.987         0.0865 0.942   0.796
#> ATC:pam     5 1.000           1.000       1.000         0.0875 0.915   0.710
#> SD:hclust   5 0.898           0.894       0.961         0.0909 0.939   0.818
#> CV:hclust   5 0.877           0.913       0.919         0.0785 0.939   0.818
#> MAD:hclust  5 0.930           0.897       0.960         0.0665 0.985   0.955
#> ATC:hclust  5 0.909           0.520       0.796         0.0768 0.914   0.771
get_stats(res_list, k = 6)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      6 0.899           0.895       0.904         0.0417 0.944   0.748
#> CV:NMF      6 1.000           0.987       0.983         0.0420 0.969   0.856
#> MAD:NMF     6 0.781           0.757       0.849         0.0316 0.899   0.573
#> ATC:NMF     6 0.767           0.729       0.828         0.0649 0.896   0.691
#> SD:skmeans  6 0.942           0.955       0.949         0.0480 0.948   0.773
#> CV:skmeans  6 0.995           0.978       0.961         0.0572 0.939   0.748
#> MAD:skmeans 6 0.932           0.959       0.939         0.0477 0.959   0.819
#> ATC:skmeans 6 0.852           0.849       0.821         0.0441 0.934   0.716
#> SD:mclust   6 0.904           0.908       0.923         0.0507 0.888   0.546
#> CV:mclust   6 0.884           0.932       0.925         0.0454 0.959   0.819
#> MAD:mclust  6 0.968           0.953       0.966         0.0243 0.983   0.918
#> ATC:mclust  6 0.905           0.906       0.936         0.0266 0.983   0.918
#> SD:kmeans   6 0.717           0.701       0.715         0.0507 0.921   0.724
#> CV:kmeans   6 0.724           0.750       0.753         0.0595 0.933   0.764
#> MAD:kmeans  6 0.704           0.714       0.709         0.0491 0.929   0.721
#> ATC:kmeans  6 0.603           0.736       0.757         0.0623 1.000   1.000
#> SD:pam      6 1.000           0.981       0.993         0.0460 0.945   0.754
#> CV:pam      6 1.000           0.998       0.999         0.0554 0.948   0.773
#> MAD:pam     6 1.000           0.982       0.993         0.0483 0.959   0.819
#> ATC:pam     6 0.946           0.985       0.958         0.0453 0.959   0.813
#> SD:hclust   6 0.909           0.889       0.932         0.0371 0.985   0.945
#> CV:hclust   6 0.895           0.950       0.952         0.0731 0.942   0.791
#> MAD:hclust  6 0.930           0.897       0.960         0.0873 0.939   0.810
#> ATC:hclust  6 0.882           0.912       0.949         0.0753 0.880   0.656

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

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

collect_plots(res)

plot of chunk SD-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4886 0.512   0.512
#> 3 3 0.898           0.900       0.954         0.3540 0.837   0.682
#> 4 4 0.898           0.894       0.961         0.0139 0.987   0.963
#> 5 5 0.898           0.894       0.961         0.0909 0.939   0.818
#> 6 6 0.909           0.889       0.932         0.0371 0.985   0.945

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
#> SRR1736309     2       0          1  0  1
#> SRR1736310     2       0          1  0  1
#> SRR1736312     2       0          1  0  1
#> SRR1736311     2       0          1  0  1
#> SRR1736313     2       0          1  0  1
#> SRR1736314     2       0          1  0  1
#> SRR1736315     2       0          1  0  1
#> SRR1736316     2       0          1  0  1
#> SRR1736317     2       0          1  0  1
#> SRR1736318     2       0          1  0  1
#> SRR1736319     2       0          1  0  1
#> SRR1736320     2       0          1  0  1
#> SRR1736321     2       0          1  0  1
#> SRR1736322     2       0          1  0  1
#> SRR1736323     2       0          1  0  1
#> SRR1736324     2       0          1  0  1
#> SRR1736325     2       0          1  0  1
#> SRR1736326     2       0          1  0  1
#> SRR1736328     2       0          1  0  1
#> SRR1736327     2       0          1  0  1
#> SRR1736329     2       0          1  0  1
#> SRR1736330     2       0          1  0  1
#> SRR1736331     2       0          1  0  1
#> SRR1736332     2       0          1  0  1
#> SRR1736333     1       0          1  1  0
#> SRR1736334     1       0          1  1  0
#> SRR1736335     1       0          1  1  0
#> SRR1736337     1       0          1  1  0
#> SRR1736336     1       0          1  1  0
#> SRR1736338     1       0          1  1  0
#> SRR1736339     1       0          1  1  0
#> SRR1736340     1       0          1  1  0
#> SRR1736341     1       0          1  1  0
#> SRR1736342     1       0          1  1  0
#> SRR1736343     1       0          1  1  0
#> SRR1736344     1       0          1  1  0
#> SRR1736345     1       0          1  1  0
#> SRR1736346     1       0          1  1  0
#> SRR1736348     1       0          1  1  0
#> SRR1736347     1       0          1  1  0
#> SRR1736349     1       0          1  1  0
#> SRR1736350     1       0          1  1  0
#> SRR1736351     1       0          1  1  0
#> SRR1736352     1       0          1  1  0
#> SRR1736353     1       0          1  1  0
#> SRR1736354     1       0          1  1  0
#> SRR1736355     1       0          1  1  0
#> SRR1736356     1       0          1  1  0
#> SRR1736358     1       0          1  1  0
#> SRR1736357     1       0          1  1  0
#> SRR1736359     1       0          1  1  0
#> SRR1736360     1       0          1  1  0
#> SRR1736361     1       0          1  1  0
#> SRR1736362     1       0          1  1  0
#> SRR1736363     1       0          1  1  0
#> SRR1736365     1       0          1  1  0
#> SRR1736364     1       0          1  1  0
#> SRR1736366     1       0          1  1  0
#> SRR1736367     1       0          1  1  0
#> SRR1736368     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
#> SRR1736309     2   0.000      1.000 0.000  1 0.000
#> SRR1736310     2   0.000      1.000 0.000  1 0.000
#> SRR1736312     2   0.000      1.000 0.000  1 0.000
#> SRR1736311     2   0.000      1.000 0.000  1 0.000
#> SRR1736313     2   0.000      1.000 0.000  1 0.000
#> SRR1736314     2   0.000      1.000 0.000  1 0.000
#> SRR1736315     2   0.000      1.000 0.000  1 0.000
#> SRR1736316     2   0.000      1.000 0.000  1 0.000
#> SRR1736317     2   0.000      1.000 0.000  1 0.000
#> SRR1736318     2   0.000      1.000 0.000  1 0.000
#> SRR1736319     2   0.000      1.000 0.000  1 0.000
#> SRR1736320     2   0.000      1.000 0.000  1 0.000
#> SRR1736321     2   0.000      1.000 0.000  1 0.000
#> SRR1736322     2   0.000      1.000 0.000  1 0.000
#> SRR1736323     2   0.000      1.000 0.000  1 0.000
#> SRR1736324     2   0.000      1.000 0.000  1 0.000
#> SRR1736325     2   0.000      1.000 0.000  1 0.000
#> SRR1736326     2   0.000      1.000 0.000  1 0.000
#> SRR1736328     2   0.000      1.000 0.000  1 0.000
#> SRR1736327     2   0.000      1.000 0.000  1 0.000
#> SRR1736329     2   0.000      1.000 0.000  1 0.000
#> SRR1736330     2   0.000      1.000 0.000  1 0.000
#> SRR1736331     2   0.000      1.000 0.000  1 0.000
#> SRR1736332     2   0.000      1.000 0.000  1 0.000
#> SRR1736333     1   0.610      0.492 0.608  0 0.392
#> SRR1736334     1   0.610      0.492 0.608  0 0.392
#> SRR1736335     1   0.610      0.492 0.608  0 0.392
#> SRR1736337     1   0.610      0.492 0.608  0 0.392
#> SRR1736336     1   0.610      0.492 0.608  0 0.392
#> SRR1736338     1   0.610      0.492 0.608  0 0.392
#> SRR1736339     1   0.000      0.867 1.000  0 0.000
#> SRR1736340     1   0.000      0.867 1.000  0 0.000
#> SRR1736341     1   0.000      0.867 1.000  0 0.000
#> SRR1736342     1   0.000      0.867 1.000  0 0.000
#> SRR1736343     1   0.000      0.867 1.000  0 0.000
#> SRR1736344     1   0.000      0.867 1.000  0 0.000
#> SRR1736345     1   0.000      0.867 1.000  0 0.000
#> SRR1736346     1   0.000      0.867 1.000  0 0.000
#> SRR1736348     1   0.000      0.867 1.000  0 0.000
#> SRR1736347     1   0.000      0.867 1.000  0 0.000
#> SRR1736349     1   0.000      0.867 1.000  0 0.000
#> SRR1736350     1   0.000      0.867 1.000  0 0.000
#> SRR1736351     1   0.000      0.867 1.000  0 0.000
#> SRR1736352     1   0.000      0.867 1.000  0 0.000
#> SRR1736353     1   0.000      0.867 1.000  0 0.000
#> SRR1736354     1   0.000      0.867 1.000  0 0.000
#> SRR1736355     1   0.000      0.867 1.000  0 0.000
#> SRR1736356     1   0.613      0.300 0.600  0 0.400
#> SRR1736358     3   0.000      1.000 0.000  0 1.000
#> SRR1736357     3   0.000      1.000 0.000  0 1.000
#> SRR1736359     3   0.000      1.000 0.000  0 1.000
#> SRR1736360     3   0.000      1.000 0.000  0 1.000
#> SRR1736361     3   0.000      1.000 0.000  0 1.000
#> SRR1736362     3   0.000      1.000 0.000  0 1.000
#> SRR1736363     3   0.000      1.000 0.000  0 1.000
#> SRR1736365     3   0.000      1.000 0.000  0 1.000
#> SRR1736364     3   0.000      1.000 0.000  0 1.000
#> SRR1736366     3   0.000      1.000 0.000  0 1.000
#> SRR1736367     3   0.000      1.000 0.000  0 1.000
#> SRR1736368     3   0.000      1.000 0.000  0 1.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1 p2    p3 p4
#> SRR1736309     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736310     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736312     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736311     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736313     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736314     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736315     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736316     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736317     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736318     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736319     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736320     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736321     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736322     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736323     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736324     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736325     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736326     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736328     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736327     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736329     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736330     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736331     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736332     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736333     1   0.483      0.502 0.608  0 0.392  0
#> SRR1736334     1   0.483      0.502 0.608  0 0.392  0
#> SRR1736335     1   0.483      0.502 0.608  0 0.392  0
#> SRR1736337     1   0.483      0.502 0.608  0 0.392  0
#> SRR1736336     1   0.483      0.502 0.608  0 0.392  0
#> SRR1736338     1   0.483      0.502 0.608  0 0.392  0
#> SRR1736339     1   0.000      0.859 1.000  0 0.000  0
#> SRR1736340     1   0.000      0.859 1.000  0 0.000  0
#> SRR1736341     1   0.000      0.859 1.000  0 0.000  0
#> SRR1736342     1   0.000      0.859 1.000  0 0.000  0
#> SRR1736343     1   0.000      0.859 1.000  0 0.000  0
#> SRR1736344     1   0.000      0.859 1.000  0 0.000  0
#> SRR1736345     1   0.000      0.859 1.000  0 0.000  0
#> SRR1736346     1   0.000      0.859 1.000  0 0.000  0
#> SRR1736348     1   0.000      0.859 1.000  0 0.000  0
#> SRR1736347     1   0.000      0.859 1.000  0 0.000  0
#> SRR1736349     1   0.000      0.859 1.000  0 0.000  0
#> SRR1736350     1   0.000      0.859 1.000  0 0.000  0
#> SRR1736351     1   0.000      0.859 1.000  0 0.000  0
#> SRR1736352     1   0.000      0.859 1.000  0 0.000  0
#> SRR1736353     1   0.000      0.859 1.000  0 0.000  0
#> SRR1736354     1   0.000      0.859 1.000  0 0.000  0
#> SRR1736355     1   0.000      0.859 1.000  0 0.000  0
#> SRR1736356     4   0.000      0.000 0.000  0 0.000  1
#> SRR1736358     3   0.000      1.000 0.000  0 1.000  0
#> SRR1736357     3   0.000      1.000 0.000  0 1.000  0
#> SRR1736359     3   0.000      1.000 0.000  0 1.000  0
#> SRR1736360     3   0.000      1.000 0.000  0 1.000  0
#> SRR1736361     3   0.000      1.000 0.000  0 1.000  0
#> SRR1736362     3   0.000      1.000 0.000  0 1.000  0
#> SRR1736363     3   0.000      1.000 0.000  0 1.000  0
#> SRR1736365     3   0.000      1.000 0.000  0 1.000  0
#> SRR1736364     3   0.000      1.000 0.000  0 1.000  0
#> SRR1736366     3   0.000      1.000 0.000  0 1.000  0
#> SRR1736367     3   0.000      1.000 0.000  0 1.000  0
#> SRR1736368     3   0.000      1.000 0.000  0 1.000  0

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1 p2    p3 p4 p5
#> SRR1736309     2   0.000      1.000 0.000  1 0.000  0  0
#> SRR1736310     2   0.000      1.000 0.000  1 0.000  0  0
#> SRR1736312     2   0.000      1.000 0.000  1 0.000  0  0
#> SRR1736311     2   0.000      1.000 0.000  1 0.000  0  0
#> SRR1736313     2   0.000      1.000 0.000  1 0.000  0  0
#> SRR1736314     2   0.000      1.000 0.000  1 0.000  0  0
#> SRR1736315     2   0.000      1.000 0.000  1 0.000  0  0
#> SRR1736316     2   0.000      1.000 0.000  1 0.000  0  0
#> SRR1736317     2   0.000      1.000 0.000  1 0.000  0  0
#> SRR1736318     2   0.000      1.000 0.000  1 0.000  0  0
#> SRR1736319     2   0.000      1.000 0.000  1 0.000  0  0
#> SRR1736320     2   0.000      1.000 0.000  1 0.000  0  0
#> SRR1736321     2   0.000      1.000 0.000  1 0.000  0  0
#> SRR1736322     2   0.000      1.000 0.000  1 0.000  0  0
#> SRR1736323     2   0.000      1.000 0.000  1 0.000  0  0
#> SRR1736324     2   0.000      1.000 0.000  1 0.000  0  0
#> SRR1736325     2   0.000      1.000 0.000  1 0.000  0  0
#> SRR1736326     2   0.000      1.000 0.000  1 0.000  0  0
#> SRR1736328     4   0.000      1.000 0.000  0 0.000  1  0
#> SRR1736327     4   0.000      1.000 0.000  0 0.000  1  0
#> SRR1736329     4   0.000      1.000 0.000  0 0.000  1  0
#> SRR1736330     4   0.000      1.000 0.000  0 0.000  1  0
#> SRR1736331     4   0.000      1.000 0.000  0 0.000  1  0
#> SRR1736332     4   0.000      1.000 0.000  0 0.000  1  0
#> SRR1736333     1   0.416      0.502 0.608  0 0.392  0  0
#> SRR1736334     1   0.416      0.502 0.608  0 0.392  0  0
#> SRR1736335     1   0.416      0.502 0.608  0 0.392  0  0
#> SRR1736337     1   0.416      0.502 0.608  0 0.392  0  0
#> SRR1736336     1   0.416      0.502 0.608  0 0.392  0  0
#> SRR1736338     1   0.416      0.502 0.608  0 0.392  0  0
#> SRR1736339     1   0.000      0.859 1.000  0 0.000  0  0
#> SRR1736340     1   0.000      0.859 1.000  0 0.000  0  0
#> SRR1736341     1   0.000      0.859 1.000  0 0.000  0  0
#> SRR1736342     1   0.000      0.859 1.000  0 0.000  0  0
#> SRR1736343     1   0.000      0.859 1.000  0 0.000  0  0
#> SRR1736344     1   0.000      0.859 1.000  0 0.000  0  0
#> SRR1736345     1   0.000      0.859 1.000  0 0.000  0  0
#> SRR1736346     1   0.000      0.859 1.000  0 0.000  0  0
#> SRR1736348     1   0.000      0.859 1.000  0 0.000  0  0
#> SRR1736347     1   0.000      0.859 1.000  0 0.000  0  0
#> SRR1736349     1   0.000      0.859 1.000  0 0.000  0  0
#> SRR1736350     1   0.000      0.859 1.000  0 0.000  0  0
#> SRR1736351     1   0.000      0.859 1.000  0 0.000  0  0
#> SRR1736352     1   0.000      0.859 1.000  0 0.000  0  0
#> SRR1736353     1   0.000      0.859 1.000  0 0.000  0  0
#> SRR1736354     1   0.000      0.859 1.000  0 0.000  0  0
#> SRR1736355     1   0.000      0.859 1.000  0 0.000  0  0
#> SRR1736356     5   0.000      0.000 0.000  0 0.000  0  1
#> SRR1736358     3   0.000      1.000 0.000  0 1.000  0  0
#> SRR1736357     3   0.000      1.000 0.000  0 1.000  0  0
#> SRR1736359     3   0.000      1.000 0.000  0 1.000  0  0
#> SRR1736360     3   0.000      1.000 0.000  0 1.000  0  0
#> SRR1736361     3   0.000      1.000 0.000  0 1.000  0  0
#> SRR1736362     3   0.000      1.000 0.000  0 1.000  0  0
#> SRR1736363     3   0.000      1.000 0.000  0 1.000  0  0
#> SRR1736365     3   0.000      1.000 0.000  0 1.000  0  0
#> SRR1736364     3   0.000      1.000 0.000  0 1.000  0  0
#> SRR1736366     3   0.000      1.000 0.000  0 1.000  0  0
#> SRR1736367     3   0.000      1.000 0.000  0 1.000  0  0
#> SRR1736368     3   0.000      1.000 0.000  0 1.000  0  0

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1 p2    p3 p4    p5 p6
#> SRR1736309     2  0.0000      1.000 0.000  1 0.000  0 0.000  0
#> SRR1736310     2  0.0000      1.000 0.000  1 0.000  0 0.000  0
#> SRR1736312     2  0.0000      1.000 0.000  1 0.000  0 0.000  0
#> SRR1736311     2  0.0000      1.000 0.000  1 0.000  0 0.000  0
#> SRR1736313     2  0.0000      1.000 0.000  1 0.000  0 0.000  0
#> SRR1736314     2  0.0000      1.000 0.000  1 0.000  0 0.000  0
#> SRR1736315     2  0.0000      1.000 0.000  1 0.000  0 0.000  0
#> SRR1736316     2  0.0000      1.000 0.000  1 0.000  0 0.000  0
#> SRR1736317     2  0.0000      1.000 0.000  1 0.000  0 0.000  0
#> SRR1736318     2  0.0000      1.000 0.000  1 0.000  0 0.000  0
#> SRR1736319     2  0.0000      1.000 0.000  1 0.000  0 0.000  0
#> SRR1736320     2  0.0000      1.000 0.000  1 0.000  0 0.000  0
#> SRR1736321     2  0.0000      1.000 0.000  1 0.000  0 0.000  0
#> SRR1736322     2  0.0000      1.000 0.000  1 0.000  0 0.000  0
#> SRR1736323     2  0.0000      1.000 0.000  1 0.000  0 0.000  0
#> SRR1736324     2  0.0000      1.000 0.000  1 0.000  0 0.000  0
#> SRR1736325     2  0.0000      1.000 0.000  1 0.000  0 0.000  0
#> SRR1736326     2  0.0000      1.000 0.000  1 0.000  0 0.000  0
#> SRR1736328     4  0.0000      1.000 0.000  0 0.000  1 0.000  0
#> SRR1736327     4  0.0000      1.000 0.000  0 0.000  1 0.000  0
#> SRR1736329     4  0.0000      1.000 0.000  0 0.000  1 0.000  0
#> SRR1736330     4  0.0000      1.000 0.000  0 0.000  1 0.000  0
#> SRR1736331     4  0.0000      1.000 0.000  0 0.000  1 0.000  0
#> SRR1736332     4  0.0000      1.000 0.000  0 0.000  1 0.000  0
#> SRR1736333     1  0.3737      0.504 0.608  0 0.000  0 0.392  0
#> SRR1736334     1  0.3737      0.504 0.608  0 0.000  0 0.392  0
#> SRR1736335     1  0.3737      0.504 0.608  0 0.000  0 0.392  0
#> SRR1736337     1  0.3737      0.504 0.608  0 0.000  0 0.392  0
#> SRR1736336     1  0.3737      0.504 0.608  0 0.000  0 0.392  0
#> SRR1736338     1  0.3737      0.504 0.608  0 0.000  0 0.392  0
#> SRR1736339     1  0.0000      0.879 1.000  0 0.000  0 0.000  0
#> SRR1736340     1  0.0000      0.879 1.000  0 0.000  0 0.000  0
#> SRR1736341     1  0.0000      0.879 1.000  0 0.000  0 0.000  0
#> SRR1736342     1  0.0000      0.879 1.000  0 0.000  0 0.000  0
#> SRR1736343     1  0.0000      0.879 1.000  0 0.000  0 0.000  0
#> SRR1736344     1  0.0000      0.879 1.000  0 0.000  0 0.000  0
#> SRR1736345     1  0.0000      0.879 1.000  0 0.000  0 0.000  0
#> SRR1736346     1  0.0000      0.879 1.000  0 0.000  0 0.000  0
#> SRR1736348     1  0.0000      0.879 1.000  0 0.000  0 0.000  0
#> SRR1736347     1  0.0000      0.879 1.000  0 0.000  0 0.000  0
#> SRR1736349     1  0.0000      0.879 1.000  0 0.000  0 0.000  0
#> SRR1736350     1  0.0000      0.879 1.000  0 0.000  0 0.000  0
#> SRR1736351     1  0.0000      0.879 1.000  0 0.000  0 0.000  0
#> SRR1736352     1  0.0000      0.879 1.000  0 0.000  0 0.000  0
#> SRR1736353     1  0.0000      0.879 1.000  0 0.000  0 0.000  0
#> SRR1736354     1  0.0000      0.879 1.000  0 0.000  0 0.000  0
#> SRR1736355     1  0.0000      0.879 1.000  0 0.000  0 0.000  0
#> SRR1736356     6  0.0000      0.000 0.000  0 0.000  0 0.000  1
#> SRR1736358     3  0.1957      0.898 0.000  0 0.888  0 0.112  0
#> SRR1736357     3  0.1957      0.898 0.000  0 0.888  0 0.112  0
#> SRR1736359     3  0.1957      0.898 0.000  0 0.888  0 0.112  0
#> SRR1736360     5  0.1957      1.000 0.000  0 0.112  0 0.888  0
#> SRR1736361     5  0.1957      1.000 0.000  0 0.112  0 0.888  0
#> SRR1736362     5  0.1957      1.000 0.000  0 0.112  0 0.888  0
#> SRR1736363     3  0.0146      0.951 0.000  0 0.996  0 0.004  0
#> SRR1736365     3  0.0146      0.951 0.000  0 0.996  0 0.004  0
#> SRR1736364     3  0.0146      0.951 0.000  0 0.996  0 0.004  0
#> SRR1736366     3  0.0146      0.951 0.000  0 0.996  0 0.004  0
#> SRR1736367     3  0.0146      0.951 0.000  0 0.996  0 0.004  0
#> SRR1736368     3  0.0146      0.951 0.000  0 0.996  0 0.004  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-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 15454 rows and 60 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#>   Subgroups are detected by 'kmeans' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk SD-kmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4886 0.512   0.512
#> 3 3 0.706           0.754       0.791         0.2582 0.818   0.643
#> 4 4 0.609           0.756       0.778         0.1237 0.939   0.815
#> 5 5 0.683           0.739       0.785         0.0735 0.898   0.688
#> 6 6 0.717           0.701       0.715         0.0507 0.921   0.724

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
#> SRR1736309     2       0          1  0  1
#> SRR1736310     2       0          1  0  1
#> SRR1736312     2       0          1  0  1
#> SRR1736311     2       0          1  0  1
#> SRR1736313     2       0          1  0  1
#> SRR1736314     2       0          1  0  1
#> SRR1736315     2       0          1  0  1
#> SRR1736316     2       0          1  0  1
#> SRR1736317     2       0          1  0  1
#> SRR1736318     2       0          1  0  1
#> SRR1736319     2       0          1  0  1
#> SRR1736320     2       0          1  0  1
#> SRR1736321     2       0          1  0  1
#> SRR1736322     2       0          1  0  1
#> SRR1736323     2       0          1  0  1
#> SRR1736324     2       0          1  0  1
#> SRR1736325     2       0          1  0  1
#> SRR1736326     2       0          1  0  1
#> SRR1736328     2       0          1  0  1
#> SRR1736327     2       0          1  0  1
#> SRR1736329     2       0          1  0  1
#> SRR1736330     2       0          1  0  1
#> SRR1736331     2       0          1  0  1
#> SRR1736332     2       0          1  0  1
#> SRR1736333     1       0          1  1  0
#> SRR1736334     1       0          1  1  0
#> SRR1736335     1       0          1  1  0
#> SRR1736337     1       0          1  1  0
#> SRR1736336     1       0          1  1  0
#> SRR1736338     1       0          1  1  0
#> SRR1736339     1       0          1  1  0
#> SRR1736340     1       0          1  1  0
#> SRR1736341     1       0          1  1  0
#> SRR1736342     1       0          1  1  0
#> SRR1736343     1       0          1  1  0
#> SRR1736344     1       0          1  1  0
#> SRR1736345     1       0          1  1  0
#> SRR1736346     1       0          1  1  0
#> SRR1736348     1       0          1  1  0
#> SRR1736347     1       0          1  1  0
#> SRR1736349     1       0          1  1  0
#> SRR1736350     1       0          1  1  0
#> SRR1736351     1       0          1  1  0
#> SRR1736352     1       0          1  1  0
#> SRR1736353     1       0          1  1  0
#> SRR1736354     1       0          1  1  0
#> SRR1736355     1       0          1  1  0
#> SRR1736356     1       0          1  1  0
#> SRR1736358     1       0          1  1  0
#> SRR1736357     1       0          1  1  0
#> SRR1736359     1       0          1  1  0
#> SRR1736360     1       0          1  1  0
#> SRR1736361     1       0          1  1  0
#> SRR1736362     1       0          1  1  0
#> SRR1736363     1       0          1  1  0
#> SRR1736365     1       0          1  1  0
#> SRR1736364     1       0          1  1  0
#> SRR1736366     1       0          1  1  0
#> SRR1736367     1       0          1  1  0
#> SRR1736368     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
#> SRR1736309     2  0.0000      0.919 0.000 1.000 0.000
#> SRR1736310     2  0.0000      0.919 0.000 1.000 0.000
#> SRR1736312     2  0.0000      0.919 0.000 1.000 0.000
#> SRR1736311     2  0.0000      0.919 0.000 1.000 0.000
#> SRR1736313     2  0.0000      0.919 0.000 1.000 0.000
#> SRR1736314     2  0.0000      0.919 0.000 1.000 0.000
#> SRR1736315     2  0.0000      0.919 0.000 1.000 0.000
#> SRR1736316     2  0.0000      0.919 0.000 1.000 0.000
#> SRR1736317     2  0.0000      0.919 0.000 1.000 0.000
#> SRR1736318     2  0.0000      0.919 0.000 1.000 0.000
#> SRR1736319     2  0.0000      0.919 0.000 1.000 0.000
#> SRR1736320     2  0.0000      0.919 0.000 1.000 0.000
#> SRR1736321     2  0.0424      0.916 0.008 0.992 0.000
#> SRR1736322     2  0.0424      0.916 0.008 0.992 0.000
#> SRR1736323     2  0.0424      0.916 0.008 0.992 0.000
#> SRR1736324     2  0.0000      0.919 0.000 1.000 0.000
#> SRR1736325     2  0.0000      0.919 0.000 1.000 0.000
#> SRR1736326     2  0.0000      0.919 0.000 1.000 0.000
#> SRR1736328     2  0.6095      0.732 0.392 0.608 0.000
#> SRR1736327     2  0.6095      0.732 0.392 0.608 0.000
#> SRR1736329     2  0.6095      0.732 0.392 0.608 0.000
#> SRR1736330     2  0.6095      0.732 0.392 0.608 0.000
#> SRR1736331     2  0.6095      0.732 0.392 0.608 0.000
#> SRR1736332     2  0.6095      0.732 0.392 0.608 0.000
#> SRR1736333     3  0.6140     -0.275 0.404 0.000 0.596
#> SRR1736334     3  0.6140     -0.275 0.404 0.000 0.596
#> SRR1736335     3  0.6140     -0.275 0.404 0.000 0.596
#> SRR1736337     3  0.6140     -0.275 0.404 0.000 0.596
#> SRR1736336     3  0.6140     -0.275 0.404 0.000 0.596
#> SRR1736338     3  0.6140     -0.275 0.404 0.000 0.596
#> SRR1736339     1  0.6168      0.990 0.588 0.000 0.412
#> SRR1736340     1  0.6168      0.990 0.588 0.000 0.412
#> SRR1736341     1  0.6168      0.990 0.588 0.000 0.412
#> SRR1736342     1  0.6192      0.989 0.580 0.000 0.420
#> SRR1736343     1  0.6192      0.989 0.580 0.000 0.420
#> SRR1736344     1  0.6192      0.989 0.580 0.000 0.420
#> SRR1736345     1  0.6168      0.990 0.588 0.000 0.412
#> SRR1736346     1  0.6168      0.990 0.588 0.000 0.412
#> SRR1736348     1  0.6192      0.989 0.580 0.000 0.420
#> SRR1736347     1  0.6168      0.990 0.588 0.000 0.412
#> SRR1736349     1  0.6192      0.989 0.580 0.000 0.420
#> SRR1736350     1  0.6192      0.989 0.580 0.000 0.420
#> SRR1736351     1  0.6168      0.990 0.588 0.000 0.412
#> SRR1736352     1  0.6168      0.990 0.588 0.000 0.412
#> SRR1736353     1  0.6168      0.990 0.588 0.000 0.412
#> SRR1736354     1  0.6192      0.989 0.580 0.000 0.420
#> SRR1736355     1  0.6192      0.989 0.580 0.000 0.420
#> SRR1736356     3  0.4796      0.400 0.220 0.000 0.780
#> SRR1736358     3  0.0000      0.732 0.000 0.000 1.000
#> SRR1736357     3  0.0000      0.732 0.000 0.000 1.000
#> SRR1736359     3  0.0000      0.732 0.000 0.000 1.000
#> SRR1736360     3  0.0747      0.724 0.016 0.000 0.984
#> SRR1736361     3  0.0747      0.724 0.016 0.000 0.984
#> SRR1736362     3  0.0747      0.724 0.016 0.000 0.984
#> SRR1736363     3  0.0000      0.732 0.000 0.000 1.000
#> SRR1736365     3  0.0000      0.732 0.000 0.000 1.000
#> SRR1736364     3  0.0000      0.732 0.000 0.000 1.000
#> SRR1736366     3  0.0000      0.732 0.000 0.000 1.000
#> SRR1736367     3  0.0000      0.732 0.000 0.000 1.000
#> SRR1736368     3  0.0000      0.732 0.000 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
#> SRR1736309     2  0.0000     0.9143 0.000 1.000 0.000 0.000
#> SRR1736310     2  0.0000     0.9143 0.000 1.000 0.000 0.000
#> SRR1736312     2  0.0000     0.9143 0.000 1.000 0.000 0.000
#> SRR1736311     2  0.0000     0.9143 0.000 1.000 0.000 0.000
#> SRR1736313     2  0.0000     0.9143 0.000 1.000 0.000 0.000
#> SRR1736314     2  0.0000     0.9143 0.000 1.000 0.000 0.000
#> SRR1736315     2  0.3074     0.8163 0.152 0.848 0.000 0.000
#> SRR1736316     2  0.3074     0.8163 0.152 0.848 0.000 0.000
#> SRR1736317     2  0.3074     0.8163 0.152 0.848 0.000 0.000
#> SRR1736318     2  0.0000     0.9143 0.000 1.000 0.000 0.000
#> SRR1736319     2  0.0000     0.9143 0.000 1.000 0.000 0.000
#> SRR1736320     2  0.0000     0.9143 0.000 1.000 0.000 0.000
#> SRR1736321     2  0.3074     0.8163 0.152 0.848 0.000 0.000
#> SRR1736322     2  0.3074     0.8163 0.152 0.848 0.000 0.000
#> SRR1736323     2  0.3074     0.8163 0.152 0.848 0.000 0.000
#> SRR1736324     2  0.0000     0.9143 0.000 1.000 0.000 0.000
#> SRR1736325     2  0.0000     0.9143 0.000 1.000 0.000 0.000
#> SRR1736326     2  0.0000     0.9143 0.000 1.000 0.000 0.000
#> SRR1736328     4  0.4907     0.9879 0.000 0.420 0.000 0.580
#> SRR1736327     4  0.5800     0.9758 0.032 0.420 0.000 0.548
#> SRR1736329     4  0.5800     0.9758 0.032 0.420 0.000 0.548
#> SRR1736330     4  0.4907     0.9879 0.000 0.420 0.000 0.580
#> SRR1736331     4  0.4907     0.9879 0.000 0.420 0.000 0.580
#> SRR1736332     4  0.4907     0.9879 0.000 0.420 0.000 0.580
#> SRR1736333     3  0.7443     0.0746 0.392 0.000 0.436 0.172
#> SRR1736334     3  0.7443     0.0746 0.392 0.000 0.436 0.172
#> SRR1736335     3  0.7443     0.0746 0.392 0.000 0.436 0.172
#> SRR1736337     3  0.7443     0.0746 0.392 0.000 0.436 0.172
#> SRR1736336     3  0.7443     0.0746 0.392 0.000 0.436 0.172
#> SRR1736338     3  0.7443     0.0746 0.392 0.000 0.436 0.172
#> SRR1736339     1  0.6854     0.8454 0.600 0.000 0.196 0.204
#> SRR1736340     1  0.6854     0.8454 0.600 0.000 0.196 0.204
#> SRR1736341     1  0.6854     0.8454 0.600 0.000 0.196 0.204
#> SRR1736342     1  0.3688     0.8357 0.792 0.000 0.208 0.000
#> SRR1736343     1  0.3688     0.8357 0.792 0.000 0.208 0.000
#> SRR1736344     1  0.3688     0.8357 0.792 0.000 0.208 0.000
#> SRR1736345     1  0.6854     0.8454 0.600 0.000 0.196 0.204
#> SRR1736346     1  0.6854     0.8454 0.600 0.000 0.196 0.204
#> SRR1736348     1  0.4137     0.8302 0.780 0.000 0.208 0.012
#> SRR1736347     1  0.6854     0.8454 0.600 0.000 0.196 0.204
#> SRR1736349     1  0.4137     0.8302 0.780 0.000 0.208 0.012
#> SRR1736350     1  0.4137     0.8302 0.780 0.000 0.208 0.012
#> SRR1736351     1  0.6650     0.8503 0.624 0.000 0.200 0.176
#> SRR1736352     1  0.6650     0.8503 0.624 0.000 0.200 0.176
#> SRR1736353     1  0.6650     0.8503 0.624 0.000 0.200 0.176
#> SRR1736354     1  0.4137     0.8302 0.780 0.000 0.208 0.012
#> SRR1736355     1  0.4137     0.8302 0.780 0.000 0.208 0.012
#> SRR1736356     3  0.7001     0.3522 0.316 0.000 0.544 0.140
#> SRR1736358     3  0.3149     0.6936 0.032 0.000 0.880 0.088
#> SRR1736357     3  0.3149     0.6936 0.032 0.000 0.880 0.088
#> SRR1736359     3  0.3149     0.6936 0.032 0.000 0.880 0.088
#> SRR1736360     3  0.1938     0.7065 0.012 0.000 0.936 0.052
#> SRR1736361     3  0.1938     0.7065 0.012 0.000 0.936 0.052
#> SRR1736362     3  0.1938     0.7065 0.012 0.000 0.936 0.052
#> SRR1736363     3  0.0188     0.7136 0.004 0.000 0.996 0.000
#> SRR1736365     3  0.0188     0.7136 0.004 0.000 0.996 0.000
#> SRR1736364     3  0.0188     0.7136 0.004 0.000 0.996 0.000
#> SRR1736366     3  0.0188     0.7136 0.004 0.000 0.996 0.000
#> SRR1736367     3  0.0188     0.7136 0.004 0.000 0.996 0.000
#> SRR1736368     3  0.0188     0.7136 0.004 0.000 0.996 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
#> SRR1736309     2  0.0609      0.833 0.000 0.980 0.020 0.000 NA
#> SRR1736310     2  0.0000      0.837 0.000 1.000 0.000 0.000 NA
#> SRR1736312     2  0.0000      0.837 0.000 1.000 0.000 0.000 NA
#> SRR1736311     2  0.0000      0.837 0.000 1.000 0.000 0.000 NA
#> SRR1736313     2  0.0609      0.833 0.000 0.980 0.020 0.000 NA
#> SRR1736314     2  0.0000      0.837 0.000 1.000 0.000 0.000 NA
#> SRR1736315     2  0.4465      0.652 0.000 0.672 0.024 0.000 NA
#> SRR1736316     2  0.4465      0.652 0.000 0.672 0.024 0.000 NA
#> SRR1736317     2  0.4465      0.652 0.000 0.672 0.024 0.000 NA
#> SRR1736318     2  0.0510      0.837 0.000 0.984 0.016 0.000 NA
#> SRR1736319     2  0.0510      0.837 0.000 0.984 0.016 0.000 NA
#> SRR1736320     2  0.0963      0.833 0.000 0.964 0.036 0.000 NA
#> SRR1736321     2  0.3932      0.652 0.000 0.672 0.000 0.000 NA
#> SRR1736322     2  0.3932      0.652 0.000 0.672 0.000 0.000 NA
#> SRR1736323     2  0.3932      0.652 0.000 0.672 0.000 0.000 NA
#> SRR1736324     2  0.0510      0.837 0.000 0.984 0.016 0.000 NA
#> SRR1736325     2  0.0510      0.837 0.000 0.984 0.016 0.000 NA
#> SRR1736326     2  0.0510      0.837 0.000 0.984 0.016 0.000 NA
#> SRR1736328     4  0.3752      0.983 0.000 0.292 0.000 0.708 NA
#> SRR1736327     4  0.5130      0.965 0.000 0.292 0.024 0.656 NA
#> SRR1736329     4  0.5130      0.965 0.000 0.292 0.024 0.656 NA
#> SRR1736330     4  0.3752      0.983 0.000 0.292 0.000 0.708 NA
#> SRR1736331     4  0.3752      0.983 0.000 0.292 0.000 0.708 NA
#> SRR1736332     4  0.3752      0.983 0.000 0.292 0.000 0.708 NA
#> SRR1736333     1  0.6622      0.373 0.440 0.000 0.232 0.000 NA
#> SRR1736334     1  0.6622      0.373 0.440 0.000 0.232 0.000 NA
#> SRR1736335     1  0.6622      0.373 0.440 0.000 0.232 0.000 NA
#> SRR1736337     1  0.6622      0.373 0.440 0.000 0.232 0.000 NA
#> SRR1736336     1  0.6622      0.373 0.440 0.000 0.232 0.000 NA
#> SRR1736338     1  0.6622      0.373 0.440 0.000 0.232 0.000 NA
#> SRR1736339     1  0.0000      0.702 1.000 0.000 0.000 0.000 NA
#> SRR1736340     1  0.0000      0.702 1.000 0.000 0.000 0.000 NA
#> SRR1736341     1  0.0000      0.702 1.000 0.000 0.000 0.000 NA
#> SRR1736342     1  0.5500      0.699 0.640 0.000 0.008 0.084 NA
#> SRR1736343     1  0.5500      0.699 0.640 0.000 0.008 0.084 NA
#> SRR1736344     1  0.5500      0.699 0.640 0.000 0.008 0.084 NA
#> SRR1736345     1  0.0000      0.702 1.000 0.000 0.000 0.000 NA
#> SRR1736346     1  0.0000      0.702 1.000 0.000 0.000 0.000 NA
#> SRR1736348     1  0.5500      0.699 0.640 0.000 0.008 0.084 NA
#> SRR1736347     1  0.0000      0.702 1.000 0.000 0.000 0.000 NA
#> SRR1736349     1  0.5500      0.699 0.640 0.000 0.008 0.084 NA
#> SRR1736350     1  0.5500      0.699 0.640 0.000 0.008 0.084 NA
#> SRR1736351     1  0.1300      0.702 0.956 0.000 0.000 0.016 NA
#> SRR1736352     1  0.1300      0.702 0.956 0.000 0.000 0.016 NA
#> SRR1736353     1  0.1300      0.702 0.956 0.000 0.000 0.016 NA
#> SRR1736354     1  0.5500      0.699 0.640 0.000 0.008 0.084 NA
#> SRR1736355     1  0.5500      0.699 0.640 0.000 0.008 0.084 NA
#> SRR1736356     3  0.8490      0.249 0.224 0.000 0.312 0.184 NA
#> SRR1736358     3  0.5505      0.821 0.092 0.000 0.724 0.068 NA
#> SRR1736357     3  0.5505      0.821 0.092 0.000 0.724 0.068 NA
#> SRR1736359     3  0.5505      0.821 0.092 0.000 0.724 0.068 NA
#> SRR1736360     3  0.5594      0.815 0.096 0.000 0.720 0.088 NA
#> SRR1736361     3  0.5594      0.815 0.096 0.000 0.720 0.088 NA
#> SRR1736362     3  0.5594      0.815 0.096 0.000 0.720 0.088 NA
#> SRR1736363     3  0.1908      0.875 0.092 0.000 0.908 0.000 NA
#> SRR1736365     3  0.1908      0.875 0.092 0.000 0.908 0.000 NA
#> SRR1736364     3  0.1908      0.875 0.092 0.000 0.908 0.000 NA
#> SRR1736366     3  0.1908      0.875 0.092 0.000 0.908 0.000 NA
#> SRR1736367     3  0.1908      0.875 0.092 0.000 0.908 0.000 NA
#> SRR1736368     3  0.1908      0.875 0.092 0.000 0.908 0.000 NA

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4 p5    p6
#> SRR1736309     2  0.0858     0.7950 0.000 0.968 0.004 0.000 NA 0.000
#> SRR1736310     2  0.0520     0.7978 0.000 0.984 0.008 0.000 NA 0.000
#> SRR1736312     2  0.0520     0.7978 0.000 0.984 0.008 0.000 NA 0.000
#> SRR1736311     2  0.0520     0.7978 0.000 0.984 0.008 0.000 NA 0.000
#> SRR1736313     2  0.0858     0.7950 0.000 0.968 0.004 0.000 NA 0.000
#> SRR1736314     2  0.0520     0.7978 0.000 0.984 0.008 0.000 NA 0.000
#> SRR1736315     2  0.5230     0.6138 0.000 0.592 0.004 0.000 NA 0.292
#> SRR1736316     2  0.5230     0.6138 0.000 0.592 0.004 0.000 NA 0.292
#> SRR1736317     2  0.5230     0.6138 0.000 0.592 0.004 0.000 NA 0.292
#> SRR1736318     2  0.1327     0.7992 0.000 0.936 0.000 0.000 NA 0.000
#> SRR1736319     2  0.1327     0.7992 0.000 0.936 0.000 0.000 NA 0.000
#> SRR1736320     2  0.1753     0.7958 0.000 0.912 0.004 0.000 NA 0.000
#> SRR1736321     2  0.5034     0.6109 0.000 0.588 0.000 0.004 NA 0.328
#> SRR1736322     2  0.5034     0.6109 0.000 0.588 0.000 0.004 NA 0.328
#> SRR1736323     2  0.5123     0.6110 0.000 0.588 0.004 0.004 NA 0.328
#> SRR1736324     2  0.1327     0.7992 0.000 0.936 0.000 0.000 NA 0.000
#> SRR1736325     2  0.1387     0.7992 0.000 0.932 0.000 0.000 NA 0.000
#> SRR1736326     2  0.1327     0.7992 0.000 0.936 0.000 0.000 NA 0.000
#> SRR1736328     4  0.3163     0.9627 0.000 0.212 0.004 0.780 NA 0.004
#> SRR1736327     4  0.5144     0.9287 0.000 0.212 0.012 0.672 NA 0.012
#> SRR1736329     4  0.5144     0.9287 0.000 0.212 0.012 0.672 NA 0.012
#> SRR1736330     4  0.2883     0.9634 0.000 0.212 0.000 0.788 NA 0.000
#> SRR1736331     4  0.3023     0.9633 0.000 0.212 0.004 0.784 NA 0.000
#> SRR1736332     4  0.2883     0.9634 0.000 0.212 0.000 0.788 NA 0.000
#> SRR1736333     1  0.6828     0.3699 0.388 0.000 0.152 0.000 NA 0.080
#> SRR1736334     1  0.6828     0.3699 0.388 0.000 0.152 0.000 NA 0.080
#> SRR1736335     1  0.6828     0.3699 0.388 0.000 0.152 0.000 NA 0.080
#> SRR1736337     1  0.6828     0.3699 0.388 0.000 0.152 0.000 NA 0.080
#> SRR1736336     1  0.6828     0.3699 0.388 0.000 0.152 0.000 NA 0.080
#> SRR1736338     1  0.6828     0.3699 0.388 0.000 0.152 0.000 NA 0.080
#> SRR1736339     1  0.0000     0.4921 1.000 0.000 0.000 0.000 NA 0.000
#> SRR1736340     1  0.0000     0.4921 1.000 0.000 0.000 0.000 NA 0.000
#> SRR1736341     1  0.0000     0.4921 1.000 0.000 0.000 0.000 NA 0.000
#> SRR1736342     6  0.3989     0.8698 0.468 0.000 0.004 0.000 NA 0.528
#> SRR1736343     6  0.3989     0.8698 0.468 0.000 0.004 0.000 NA 0.528
#> SRR1736344     6  0.3989     0.8698 0.468 0.000 0.004 0.000 NA 0.528
#> SRR1736345     1  0.0000     0.4921 1.000 0.000 0.000 0.000 NA 0.000
#> SRR1736346     1  0.0000     0.4921 1.000 0.000 0.000 0.000 NA 0.000
#> SRR1736348     6  0.3989     0.8698 0.468 0.000 0.004 0.000 NA 0.528
#> SRR1736347     1  0.0000     0.4921 1.000 0.000 0.000 0.000 NA 0.000
#> SRR1736349     6  0.3989     0.8698 0.468 0.000 0.004 0.000 NA 0.528
#> SRR1736350     6  0.3989     0.8698 0.468 0.000 0.004 0.000 NA 0.528
#> SRR1736351     1  0.2313     0.4125 0.904 0.000 0.000 0.036 NA 0.044
#> SRR1736352     1  0.2313     0.4125 0.904 0.000 0.000 0.036 NA 0.044
#> SRR1736353     1  0.2313     0.4125 0.904 0.000 0.000 0.036 NA 0.044
#> SRR1736354     6  0.3989     0.8698 0.468 0.000 0.004 0.000 NA 0.528
#> SRR1736355     6  0.3989     0.8698 0.468 0.000 0.004 0.000 NA 0.528
#> SRR1736356     6  0.8774    -0.0638 0.164 0.000 0.192 0.132 NA 0.296
#> SRR1736358     3  0.5947     0.7494 0.040 0.000 0.648 0.036 NA 0.100
#> SRR1736357     3  0.5947     0.7494 0.040 0.000 0.648 0.036 NA 0.100
#> SRR1736359     3  0.5947     0.7494 0.040 0.000 0.648 0.036 NA 0.100
#> SRR1736360     3  0.5436     0.7786 0.044 0.000 0.692 0.076 NA 0.024
#> SRR1736361     3  0.5436     0.7786 0.044 0.000 0.692 0.076 NA 0.024
#> SRR1736362     3  0.5436     0.7786 0.044 0.000 0.692 0.076 NA 0.024
#> SRR1736363     3  0.0937     0.8654 0.040 0.000 0.960 0.000 NA 0.000
#> SRR1736365     3  0.0937     0.8654 0.040 0.000 0.960 0.000 NA 0.000
#> SRR1736364     3  0.0937     0.8654 0.040 0.000 0.960 0.000 NA 0.000
#> SRR1736366     3  0.0937     0.8654 0.040 0.000 0.960 0.000 NA 0.000
#> SRR1736367     3  0.0937     0.8654 0.040 0.000 0.960 0.000 NA 0.000
#> SRR1736368     3  0.0937     0.8654 0.040 0.000 0.960 0.000 NA 0.000

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

consensus_heatmap(res, k = 2)

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

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

collect_plots(res)

plot of chunk SD-skmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4886 0.512   0.512
#> 3 3 0.898           0.953       0.975         0.3505 0.831   0.670
#> 4 4 0.835           0.920       0.921         0.0881 0.942   0.832
#> 5 5 0.867           0.923       0.925         0.0793 0.939   0.786
#> 6 6 0.942           0.955       0.949         0.0480 0.948   0.773

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

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

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
#> SRR1736309     2       0          1  0  1
#> SRR1736310     2       0          1  0  1
#> SRR1736312     2       0          1  0  1
#> SRR1736311     2       0          1  0  1
#> SRR1736313     2       0          1  0  1
#> SRR1736314     2       0          1  0  1
#> SRR1736315     2       0          1  0  1
#> SRR1736316     2       0          1  0  1
#> SRR1736317     2       0          1  0  1
#> SRR1736318     2       0          1  0  1
#> SRR1736319     2       0          1  0  1
#> SRR1736320     2       0          1  0  1
#> SRR1736321     2       0          1  0  1
#> SRR1736322     2       0          1  0  1
#> SRR1736323     2       0          1  0  1
#> SRR1736324     2       0          1  0  1
#> SRR1736325     2       0          1  0  1
#> SRR1736326     2       0          1  0  1
#> SRR1736328     2       0          1  0  1
#> SRR1736327     2       0          1  0  1
#> SRR1736329     2       0          1  0  1
#> SRR1736330     2       0          1  0  1
#> SRR1736331     2       0          1  0  1
#> SRR1736332     2       0          1  0  1
#> SRR1736333     1       0          1  1  0
#> SRR1736334     1       0          1  1  0
#> SRR1736335     1       0          1  1  0
#> SRR1736337     1       0          1  1  0
#> SRR1736336     1       0          1  1  0
#> SRR1736338     1       0          1  1  0
#> SRR1736339     1       0          1  1  0
#> SRR1736340     1       0          1  1  0
#> SRR1736341     1       0          1  1  0
#> SRR1736342     1       0          1  1  0
#> SRR1736343     1       0          1  1  0
#> SRR1736344     1       0          1  1  0
#> SRR1736345     1       0          1  1  0
#> SRR1736346     1       0          1  1  0
#> SRR1736348     1       0          1  1  0
#> SRR1736347     1       0          1  1  0
#> SRR1736349     1       0          1  1  0
#> SRR1736350     1       0          1  1  0
#> SRR1736351     1       0          1  1  0
#> SRR1736352     1       0          1  1  0
#> SRR1736353     1       0          1  1  0
#> SRR1736354     1       0          1  1  0
#> SRR1736355     1       0          1  1  0
#> SRR1736356     1       0          1  1  0
#> SRR1736358     1       0          1  1  0
#> SRR1736357     1       0          1  1  0
#> SRR1736359     1       0          1  1  0
#> SRR1736360     1       0          1  1  0
#> SRR1736361     1       0          1  1  0
#> SRR1736362     1       0          1  1  0
#> SRR1736363     1       0          1  1  0
#> SRR1736365     1       0          1  1  0
#> SRR1736364     1       0          1  1  0
#> SRR1736366     1       0          1  1  0
#> SRR1736367     1       0          1  1  0
#> SRR1736368     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
#> SRR1736309     2   0.000      1.000 0.000  1 0.000
#> SRR1736310     2   0.000      1.000 0.000  1 0.000
#> SRR1736312     2   0.000      1.000 0.000  1 0.000
#> SRR1736311     2   0.000      1.000 0.000  1 0.000
#> SRR1736313     2   0.000      1.000 0.000  1 0.000
#> SRR1736314     2   0.000      1.000 0.000  1 0.000
#> SRR1736315     2   0.000      1.000 0.000  1 0.000
#> SRR1736316     2   0.000      1.000 0.000  1 0.000
#> SRR1736317     2   0.000      1.000 0.000  1 0.000
#> SRR1736318     2   0.000      1.000 0.000  1 0.000
#> SRR1736319     2   0.000      1.000 0.000  1 0.000
#> SRR1736320     2   0.000      1.000 0.000  1 0.000
#> SRR1736321     2   0.000      1.000 0.000  1 0.000
#> SRR1736322     2   0.000      1.000 0.000  1 0.000
#> SRR1736323     2   0.000      1.000 0.000  1 0.000
#> SRR1736324     2   0.000      1.000 0.000  1 0.000
#> SRR1736325     2   0.000      1.000 0.000  1 0.000
#> SRR1736326     2   0.000      1.000 0.000  1 0.000
#> SRR1736328     2   0.000      1.000 0.000  1 0.000
#> SRR1736327     2   0.000      1.000 0.000  1 0.000
#> SRR1736329     2   0.000      1.000 0.000  1 0.000
#> SRR1736330     2   0.000      1.000 0.000  1 0.000
#> SRR1736331     2   0.000      1.000 0.000  1 0.000
#> SRR1736332     2   0.000      1.000 0.000  1 0.000
#> SRR1736333     1   0.470      0.790 0.788  0 0.212
#> SRR1736334     1   0.470      0.790 0.788  0 0.212
#> SRR1736335     1   0.470      0.790 0.788  0 0.212
#> SRR1736337     1   0.470      0.790 0.788  0 0.212
#> SRR1736336     1   0.470      0.790 0.788  0 0.212
#> SRR1736338     1   0.470      0.790 0.788  0 0.212
#> SRR1736339     1   0.000      0.938 1.000  0 0.000
#> SRR1736340     1   0.000      0.938 1.000  0 0.000
#> SRR1736341     1   0.000      0.938 1.000  0 0.000
#> SRR1736342     1   0.000      0.938 1.000  0 0.000
#> SRR1736343     1   0.000      0.938 1.000  0 0.000
#> SRR1736344     1   0.000      0.938 1.000  0 0.000
#> SRR1736345     1   0.000      0.938 1.000  0 0.000
#> SRR1736346     1   0.000      0.938 1.000  0 0.000
#> SRR1736348     1   0.000      0.938 1.000  0 0.000
#> SRR1736347     1   0.000      0.938 1.000  0 0.000
#> SRR1736349     1   0.000      0.938 1.000  0 0.000
#> SRR1736350     1   0.000      0.938 1.000  0 0.000
#> SRR1736351     1   0.000      0.938 1.000  0 0.000
#> SRR1736352     1   0.000      0.938 1.000  0 0.000
#> SRR1736353     1   0.000      0.938 1.000  0 0.000
#> SRR1736354     1   0.000      0.938 1.000  0 0.000
#> SRR1736355     1   0.000      0.938 1.000  0 0.000
#> SRR1736356     3   0.484      0.715 0.224  0 0.776
#> SRR1736358     3   0.000      0.981 0.000  0 1.000
#> SRR1736357     3   0.000      0.981 0.000  0 1.000
#> SRR1736359     3   0.000      0.981 0.000  0 1.000
#> SRR1736360     3   0.000      0.981 0.000  0 1.000
#> SRR1736361     3   0.000      0.981 0.000  0 1.000
#> SRR1736362     3   0.000      0.981 0.000  0 1.000
#> SRR1736363     3   0.000      0.981 0.000  0 1.000
#> SRR1736365     3   0.000      0.981 0.000  0 1.000
#> SRR1736364     3   0.000      0.981 0.000  0 1.000
#> SRR1736366     3   0.000      0.981 0.000  0 1.000
#> SRR1736367     3   0.000      0.981 0.000  0 1.000
#> SRR1736368     3   0.000      0.981 0.000  0 1.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1736309     2   0.000      0.929 0.000 1.000 0.000 0.000
#> SRR1736310     2   0.000      0.929 0.000 1.000 0.000 0.000
#> SRR1736312     2   0.000      0.929 0.000 1.000 0.000 0.000
#> SRR1736311     2   0.000      0.929 0.000 1.000 0.000 0.000
#> SRR1736313     2   0.000      0.929 0.000 1.000 0.000 0.000
#> SRR1736314     2   0.000      0.929 0.000 1.000 0.000 0.000
#> SRR1736315     2   0.000      0.929 0.000 1.000 0.000 0.000
#> SRR1736316     2   0.000      0.929 0.000 1.000 0.000 0.000
#> SRR1736317     2   0.000      0.929 0.000 1.000 0.000 0.000
#> SRR1736318     2   0.000      0.929 0.000 1.000 0.000 0.000
#> SRR1736319     2   0.000      0.929 0.000 1.000 0.000 0.000
#> SRR1736320     2   0.000      0.929 0.000 1.000 0.000 0.000
#> SRR1736321     2   0.000      0.929 0.000 1.000 0.000 0.000
#> SRR1736322     2   0.000      0.929 0.000 1.000 0.000 0.000
#> SRR1736323     2   0.000      0.929 0.000 1.000 0.000 0.000
#> SRR1736324     2   0.000      0.929 0.000 1.000 0.000 0.000
#> SRR1736325     2   0.000      0.929 0.000 1.000 0.000 0.000
#> SRR1736326     2   0.000      0.929 0.000 1.000 0.000 0.000
#> SRR1736328     2   0.438      0.760 0.000 0.704 0.000 0.296
#> SRR1736327     2   0.438      0.760 0.000 0.704 0.000 0.296
#> SRR1736329     2   0.438      0.760 0.000 0.704 0.000 0.296
#> SRR1736330     2   0.438      0.760 0.000 0.704 0.000 0.296
#> SRR1736331     2   0.438      0.760 0.000 0.704 0.000 0.296
#> SRR1736332     2   0.438      0.760 0.000 0.704 0.000 0.296
#> SRR1736333     4   0.563      1.000 0.224 0.000 0.076 0.700
#> SRR1736334     4   0.563      1.000 0.224 0.000 0.076 0.700
#> SRR1736335     4   0.563      1.000 0.224 0.000 0.076 0.700
#> SRR1736337     4   0.563      1.000 0.224 0.000 0.076 0.700
#> SRR1736336     4   0.563      1.000 0.224 0.000 0.076 0.700
#> SRR1736338     4   0.563      1.000 0.224 0.000 0.076 0.700
#> SRR1736339     1   0.000      0.919 1.000 0.000 0.000 0.000
#> SRR1736340     1   0.000      0.919 1.000 0.000 0.000 0.000
#> SRR1736341     1   0.000      0.919 1.000 0.000 0.000 0.000
#> SRR1736342     1   0.259      0.903 0.884 0.000 0.000 0.116
#> SRR1736343     1   0.259      0.903 0.884 0.000 0.000 0.116
#> SRR1736344     1   0.259      0.903 0.884 0.000 0.000 0.116
#> SRR1736345     1   0.000      0.919 1.000 0.000 0.000 0.000
#> SRR1736346     1   0.000      0.919 1.000 0.000 0.000 0.000
#> SRR1736348     1   0.259      0.903 0.884 0.000 0.000 0.116
#> SRR1736347     1   0.000      0.919 1.000 0.000 0.000 0.000
#> SRR1736349     1   0.259      0.903 0.884 0.000 0.000 0.116
#> SRR1736350     1   0.259      0.903 0.884 0.000 0.000 0.116
#> SRR1736351     1   0.000      0.919 1.000 0.000 0.000 0.000
#> SRR1736352     1   0.000      0.919 1.000 0.000 0.000 0.000
#> SRR1736353     1   0.000      0.919 1.000 0.000 0.000 0.000
#> SRR1736354     1   0.259      0.903 0.884 0.000 0.000 0.116
#> SRR1736355     1   0.259      0.903 0.884 0.000 0.000 0.116
#> SRR1736356     3   0.416      0.686 0.188 0.000 0.792 0.020
#> SRR1736358     3   0.000      0.978 0.000 0.000 1.000 0.000
#> SRR1736357     3   0.000      0.978 0.000 0.000 1.000 0.000
#> SRR1736359     3   0.000      0.978 0.000 0.000 1.000 0.000
#> SRR1736360     3   0.000      0.978 0.000 0.000 1.000 0.000
#> SRR1736361     3   0.000      0.978 0.000 0.000 1.000 0.000
#> SRR1736362     3   0.000      0.978 0.000 0.000 1.000 0.000
#> SRR1736363     3   0.000      0.978 0.000 0.000 1.000 0.000
#> SRR1736365     3   0.000      0.978 0.000 0.000 1.000 0.000
#> SRR1736364     3   0.000      0.978 0.000 0.000 1.000 0.000
#> SRR1736366     3   0.000      0.978 0.000 0.000 1.000 0.000
#> SRR1736367     3   0.000      0.978 0.000 0.000 1.000 0.000
#> SRR1736368     3   0.000      0.978 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
#> SRR1736309     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736310     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736312     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736311     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736313     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736314     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736315     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736316     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736317     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736318     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736319     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736320     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736321     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736322     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736323     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736324     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736325     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736326     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736328     4  0.2813      1.000 0.000 0.168 0.000 0.832 0.000
#> SRR1736327     4  0.2813      1.000 0.000 0.168 0.000 0.832 0.000
#> SRR1736329     4  0.2813      1.000 0.000 0.168 0.000 0.832 0.000
#> SRR1736330     4  0.2813      1.000 0.000 0.168 0.000 0.832 0.000
#> SRR1736331     4  0.2813      1.000 0.000 0.168 0.000 0.832 0.000
#> SRR1736332     4  0.2813      1.000 0.000 0.168 0.000 0.832 0.000
#> SRR1736333     5  0.0794      1.000 0.000 0.000 0.028 0.000 0.972
#> SRR1736334     5  0.0794      1.000 0.000 0.000 0.028 0.000 0.972
#> SRR1736335     5  0.0794      1.000 0.000 0.000 0.028 0.000 0.972
#> SRR1736337     5  0.0794      1.000 0.000 0.000 0.028 0.000 0.972
#> SRR1736336     5  0.0794      1.000 0.000 0.000 0.028 0.000 0.972
#> SRR1736338     5  0.0794      1.000 0.000 0.000 0.028 0.000 0.972
#> SRR1736339     1  0.0162      0.798 0.996 0.000 0.000 0.000 0.004
#> SRR1736340     1  0.0162      0.798 0.996 0.000 0.000 0.000 0.004
#> SRR1736341     1  0.0162      0.798 0.996 0.000 0.000 0.000 0.004
#> SRR1736342     1  0.5707      0.741 0.624 0.000 0.000 0.160 0.216
#> SRR1736343     1  0.5707      0.741 0.624 0.000 0.000 0.160 0.216
#> SRR1736344     1  0.5707      0.741 0.624 0.000 0.000 0.160 0.216
#> SRR1736345     1  0.0162      0.798 0.996 0.000 0.000 0.000 0.004
#> SRR1736346     1  0.0162      0.798 0.996 0.000 0.000 0.000 0.004
#> SRR1736348     1  0.5707      0.741 0.624 0.000 0.000 0.160 0.216
#> SRR1736347     1  0.0162      0.798 0.996 0.000 0.000 0.000 0.004
#> SRR1736349     1  0.5707      0.741 0.624 0.000 0.000 0.160 0.216
#> SRR1736350     1  0.5707      0.741 0.624 0.000 0.000 0.160 0.216
#> SRR1736351     1  0.0162      0.798 0.996 0.000 0.000 0.000 0.004
#> SRR1736352     1  0.0162      0.798 0.996 0.000 0.000 0.000 0.004
#> SRR1736353     1  0.0162      0.798 0.996 0.000 0.000 0.000 0.004
#> SRR1736354     1  0.5707      0.741 0.624 0.000 0.000 0.160 0.216
#> SRR1736355     1  0.5707      0.741 0.624 0.000 0.000 0.160 0.216
#> SRR1736356     3  0.5582      0.623 0.112 0.000 0.716 0.112 0.060
#> SRR1736358     3  0.0162      0.971 0.000 0.000 0.996 0.004 0.000
#> SRR1736357     3  0.0162      0.971 0.000 0.000 0.996 0.004 0.000
#> SRR1736359     3  0.0162      0.971 0.000 0.000 0.996 0.004 0.000
#> SRR1736360     3  0.0162      0.971 0.000 0.000 0.996 0.004 0.000
#> SRR1736361     3  0.0162      0.971 0.000 0.000 0.996 0.004 0.000
#> SRR1736362     3  0.0162      0.971 0.000 0.000 0.996 0.004 0.000
#> SRR1736363     3  0.0000      0.972 0.000 0.000 1.000 0.000 0.000
#> SRR1736365     3  0.0000      0.972 0.000 0.000 1.000 0.000 0.000
#> SRR1736364     3  0.0000      0.972 0.000 0.000 1.000 0.000 0.000
#> SRR1736366     3  0.0000      0.972 0.000 0.000 1.000 0.000 0.000
#> SRR1736367     3  0.0000      0.972 0.000 0.000 1.000 0.000 0.000
#> SRR1736368     3  0.0000      0.972 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
#> SRR1736309     2  0.0000     0.9896 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736310     2  0.0000     0.9896 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736312     2  0.0000     0.9896 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736311     2  0.0000     0.9896 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736313     2  0.0000     0.9896 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736314     2  0.0000     0.9896 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736315     2  0.0858     0.9790 0.028 0.968 0.000 0.000 0.004 0.000
#> SRR1736316     2  0.0858     0.9790 0.028 0.968 0.000 0.000 0.004 0.000
#> SRR1736317     2  0.0858     0.9790 0.028 0.968 0.000 0.000 0.004 0.000
#> SRR1736318     2  0.0000     0.9896 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736319     2  0.0000     0.9896 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736320     2  0.0000     0.9896 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736321     2  0.0858     0.9790 0.028 0.968 0.000 0.000 0.004 0.000
#> SRR1736322     2  0.0858     0.9790 0.028 0.968 0.000 0.000 0.004 0.000
#> SRR1736323     2  0.0858     0.9790 0.028 0.968 0.000 0.000 0.004 0.000
#> SRR1736324     2  0.0000     0.9896 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736325     2  0.0000     0.9896 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736326     2  0.0000     0.9896 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736328     4  0.1141     1.0000 0.000 0.052 0.000 0.948 0.000 0.000
#> SRR1736327     4  0.1141     1.0000 0.000 0.052 0.000 0.948 0.000 0.000
#> SRR1736329     4  0.1141     1.0000 0.000 0.052 0.000 0.948 0.000 0.000
#> SRR1736330     4  0.1141     1.0000 0.000 0.052 0.000 0.948 0.000 0.000
#> SRR1736331     4  0.1141     1.0000 0.000 0.052 0.000 0.948 0.000 0.000
#> SRR1736332     4  0.1141     1.0000 0.000 0.052 0.000 0.948 0.000 0.000
#> SRR1736333     5  0.0547     1.0000 0.000 0.000 0.000 0.000 0.980 0.020
#> SRR1736334     5  0.0547     1.0000 0.000 0.000 0.000 0.000 0.980 0.020
#> SRR1736335     5  0.0547     1.0000 0.000 0.000 0.000 0.000 0.980 0.020
#> SRR1736337     5  0.0547     1.0000 0.000 0.000 0.000 0.000 0.980 0.020
#> SRR1736336     5  0.0547     1.0000 0.000 0.000 0.000 0.000 0.980 0.020
#> SRR1736338     5  0.0547     1.0000 0.000 0.000 0.000 0.000 0.980 0.020
#> SRR1736339     1  0.2562     1.0000 0.828 0.000 0.000 0.000 0.000 0.172
#> SRR1736340     1  0.2562     1.0000 0.828 0.000 0.000 0.000 0.000 0.172
#> SRR1736341     1  0.2562     1.0000 0.828 0.000 0.000 0.000 0.000 0.172
#> SRR1736342     6  0.0000     0.9194 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR1736343     6  0.0000     0.9194 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR1736344     6  0.0000     0.9194 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR1736345     1  0.2562     1.0000 0.828 0.000 0.000 0.000 0.000 0.172
#> SRR1736346     1  0.2562     1.0000 0.828 0.000 0.000 0.000 0.000 0.172
#> SRR1736348     6  0.0000     0.9194 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR1736347     1  0.2562     1.0000 0.828 0.000 0.000 0.000 0.000 0.172
#> SRR1736349     6  0.0000     0.9194 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR1736350     6  0.0000     0.9194 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR1736351     1  0.2562     1.0000 0.828 0.000 0.000 0.000 0.000 0.172
#> SRR1736352     1  0.2562     1.0000 0.828 0.000 0.000 0.000 0.000 0.172
#> SRR1736353     1  0.2562     1.0000 0.828 0.000 0.000 0.000 0.000 0.172
#> SRR1736354     6  0.0000     0.9194 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR1736355     6  0.0000     0.9194 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR1736356     6  0.6084     0.0326 0.092 0.000 0.400 0.032 0.008 0.468
#> SRR1736358     3  0.2615     0.9009 0.088 0.000 0.876 0.028 0.008 0.000
#> SRR1736357     3  0.2615     0.9009 0.088 0.000 0.876 0.028 0.008 0.000
#> SRR1736359     3  0.2615     0.9009 0.088 0.000 0.876 0.028 0.008 0.000
#> SRR1736360     3  0.2022     0.9222 0.052 0.000 0.916 0.024 0.008 0.000
#> SRR1736361     3  0.2022     0.9222 0.052 0.000 0.916 0.024 0.008 0.000
#> SRR1736362     3  0.2022     0.9222 0.052 0.000 0.916 0.024 0.008 0.000
#> SRR1736363     3  0.0000     0.9508 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736365     3  0.0000     0.9508 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736364     3  0.0000     0.9508 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736366     3  0.0000     0.9508 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736367     3  0.0000     0.9508 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736368     3  0.0000     0.9508 0.000 0.000 1.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

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

collect_plots(res)

plot of chunk SD-pam-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2     1           1.000       1.000         0.4886 0.512   0.512
#> 3 3     1           0.977       0.992         0.3386 0.837   0.682
#> 4 4     1           0.976       0.992         0.0932 0.939   0.825
#> 5 5     1           0.947       0.980         0.0935 0.912   0.703
#> 6 6     1           0.981       0.993         0.0460 0.945   0.754

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette p1 p2
#> SRR1736309     2       0          1  0  1
#> SRR1736310     2       0          1  0  1
#> SRR1736312     2       0          1  0  1
#> SRR1736311     2       0          1  0  1
#> SRR1736313     2       0          1  0  1
#> SRR1736314     2       0          1  0  1
#> SRR1736315     2       0          1  0  1
#> SRR1736316     2       0          1  0  1
#> SRR1736317     2       0          1  0  1
#> SRR1736318     2       0          1  0  1
#> SRR1736319     2       0          1  0  1
#> SRR1736320     2       0          1  0  1
#> SRR1736321     2       0          1  0  1
#> SRR1736322     2       0          1  0  1
#> SRR1736323     2       0          1  0  1
#> SRR1736324     2       0          1  0  1
#> SRR1736325     2       0          1  0  1
#> SRR1736326     2       0          1  0  1
#> SRR1736328     2       0          1  0  1
#> SRR1736327     2       0          1  0  1
#> SRR1736329     2       0          1  0  1
#> SRR1736330     2       0          1  0  1
#> SRR1736331     2       0          1  0  1
#> SRR1736332     2       0          1  0  1
#> SRR1736333     1       0          1  1  0
#> SRR1736334     1       0          1  1  0
#> SRR1736335     1       0          1  1  0
#> SRR1736337     1       0          1  1  0
#> SRR1736336     1       0          1  1  0
#> SRR1736338     1       0          1  1  0
#> SRR1736339     1       0          1  1  0
#> SRR1736340     1       0          1  1  0
#> SRR1736341     1       0          1  1  0
#> SRR1736342     1       0          1  1  0
#> SRR1736343     1       0          1  1  0
#> SRR1736344     1       0          1  1  0
#> SRR1736345     1       0          1  1  0
#> SRR1736346     1       0          1  1  0
#> SRR1736348     1       0          1  1  0
#> SRR1736347     1       0          1  1  0
#> SRR1736349     1       0          1  1  0
#> SRR1736350     1       0          1  1  0
#> SRR1736351     1       0          1  1  0
#> SRR1736352     1       0          1  1  0
#> SRR1736353     1       0          1  1  0
#> SRR1736354     1       0          1  1  0
#> SRR1736355     1       0          1  1  0
#> SRR1736356     1       0          1  1  0
#> SRR1736358     1       0          1  1  0
#> SRR1736357     1       0          1  1  0
#> SRR1736359     1       0          1  1  0
#> SRR1736360     1       0          1  1  0
#> SRR1736361     1       0          1  1  0
#> SRR1736362     1       0          1  1  0
#> SRR1736363     1       0          1  1  0
#> SRR1736365     1       0          1  1  0
#> SRR1736364     1       0          1  1  0
#> SRR1736366     1       0          1  1  0
#> SRR1736367     1       0          1  1  0
#> SRR1736368     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
#> SRR1736309     2    0.00      1.000 0.000  1 0.000
#> SRR1736310     2    0.00      1.000 0.000  1 0.000
#> SRR1736312     2    0.00      1.000 0.000  1 0.000
#> SRR1736311     2    0.00      1.000 0.000  1 0.000
#> SRR1736313     2    0.00      1.000 0.000  1 0.000
#> SRR1736314     2    0.00      1.000 0.000  1 0.000
#> SRR1736315     2    0.00      1.000 0.000  1 0.000
#> SRR1736316     2    0.00      1.000 0.000  1 0.000
#> SRR1736317     2    0.00      1.000 0.000  1 0.000
#> SRR1736318     2    0.00      1.000 0.000  1 0.000
#> SRR1736319     2    0.00      1.000 0.000  1 0.000
#> SRR1736320     2    0.00      1.000 0.000  1 0.000
#> SRR1736321     2    0.00      1.000 0.000  1 0.000
#> SRR1736322     2    0.00      1.000 0.000  1 0.000
#> SRR1736323     2    0.00      1.000 0.000  1 0.000
#> SRR1736324     2    0.00      1.000 0.000  1 0.000
#> SRR1736325     2    0.00      1.000 0.000  1 0.000
#> SRR1736326     2    0.00      1.000 0.000  1 0.000
#> SRR1736328     2    0.00      1.000 0.000  1 0.000
#> SRR1736327     2    0.00      1.000 0.000  1 0.000
#> SRR1736329     2    0.00      1.000 0.000  1 0.000
#> SRR1736330     2    0.00      1.000 0.000  1 0.000
#> SRR1736331     2    0.00      1.000 0.000  1 0.000
#> SRR1736332     2    0.00      1.000 0.000  1 0.000
#> SRR1736333     1    0.00      0.979 1.000  0 0.000
#> SRR1736334     1    0.00      0.979 1.000  0 0.000
#> SRR1736335     1    0.00      0.979 1.000  0 0.000
#> SRR1736337     1    0.00      0.979 1.000  0 0.000
#> SRR1736336     1    0.00      0.979 1.000  0 0.000
#> SRR1736338     1    0.00      0.979 1.000  0 0.000
#> SRR1736339     1    0.00      0.979 1.000  0 0.000
#> SRR1736340     1    0.00      0.979 1.000  0 0.000
#> SRR1736341     1    0.00      0.979 1.000  0 0.000
#> SRR1736342     1    0.00      0.979 1.000  0 0.000
#> SRR1736343     1    0.00      0.979 1.000  0 0.000
#> SRR1736344     1    0.00      0.979 1.000  0 0.000
#> SRR1736345     1    0.00      0.979 1.000  0 0.000
#> SRR1736346     1    0.00      0.979 1.000  0 0.000
#> SRR1736348     1    0.00      0.979 1.000  0 0.000
#> SRR1736347     1    0.00      0.979 1.000  0 0.000
#> SRR1736349     1    0.00      0.979 1.000  0 0.000
#> SRR1736350     1    0.00      0.979 1.000  0 0.000
#> SRR1736351     1    0.00      0.979 1.000  0 0.000
#> SRR1736352     1    0.00      0.979 1.000  0 0.000
#> SRR1736353     1    0.00      0.979 1.000  0 0.000
#> SRR1736354     1    0.00      0.979 1.000  0 0.000
#> SRR1736355     1    0.00      0.979 1.000  0 0.000
#> SRR1736356     1    0.63      0.106 0.528  0 0.472
#> SRR1736358     3    0.00      1.000 0.000  0 1.000
#> SRR1736357     3    0.00      1.000 0.000  0 1.000
#> SRR1736359     3    0.00      1.000 0.000  0 1.000
#> SRR1736360     3    0.00      1.000 0.000  0 1.000
#> SRR1736361     3    0.00      1.000 0.000  0 1.000
#> SRR1736362     3    0.00      1.000 0.000  0 1.000
#> SRR1736363     3    0.00      1.000 0.000  0 1.000
#> SRR1736365     3    0.00      1.000 0.000  0 1.000
#> SRR1736364     3    0.00      1.000 0.000  0 1.000
#> SRR1736366     3    0.00      1.000 0.000  0 1.000
#> SRR1736367     3    0.00      1.000 0.000  0 1.000
#> SRR1736368     3    0.00      1.000 0.000  0 1.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1 p2    p3 p4
#> SRR1736309     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736310     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736312     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736311     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736313     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736314     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736315     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736316     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736317     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736318     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736319     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736320     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736321     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736322     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736323     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736324     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736325     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736326     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736328     4   0.000      1.000 0.000  0 0.000  1
#> SRR1736327     4   0.000      1.000 0.000  0 0.000  1
#> SRR1736329     4   0.000      1.000 0.000  0 0.000  1
#> SRR1736330     4   0.000      1.000 0.000  0 0.000  1
#> SRR1736331     4   0.000      1.000 0.000  0 0.000  1
#> SRR1736332     4   0.000      1.000 0.000  0 0.000  1
#> SRR1736333     1   0.000      0.977 1.000  0 0.000  0
#> SRR1736334     1   0.000      0.977 1.000  0 0.000  0
#> SRR1736335     1   0.000      0.977 1.000  0 0.000  0
#> SRR1736337     1   0.000      0.977 1.000  0 0.000  0
#> SRR1736336     1   0.000      0.977 1.000  0 0.000  0
#> SRR1736338     1   0.000      0.977 1.000  0 0.000  0
#> SRR1736339     1   0.000      0.977 1.000  0 0.000  0
#> SRR1736340     1   0.000      0.977 1.000  0 0.000  0
#> SRR1736341     1   0.000      0.977 1.000  0 0.000  0
#> SRR1736342     1   0.000      0.977 1.000  0 0.000  0
#> SRR1736343     1   0.000      0.977 1.000  0 0.000  0
#> SRR1736344     1   0.000      0.977 1.000  0 0.000  0
#> SRR1736345     1   0.000      0.977 1.000  0 0.000  0
#> SRR1736346     1   0.000      0.977 1.000  0 0.000  0
#> SRR1736348     1   0.000      0.977 1.000  0 0.000  0
#> SRR1736347     1   0.000      0.977 1.000  0 0.000  0
#> SRR1736349     1   0.000      0.977 1.000  0 0.000  0
#> SRR1736350     1   0.000      0.977 1.000  0 0.000  0
#> SRR1736351     1   0.000      0.977 1.000  0 0.000  0
#> SRR1736352     1   0.000      0.977 1.000  0 0.000  0
#> SRR1736353     1   0.000      0.977 1.000  0 0.000  0
#> SRR1736354     1   0.000      0.977 1.000  0 0.000  0
#> SRR1736355     1   0.000      0.977 1.000  0 0.000  0
#> SRR1736356     1   0.499      0.106 0.528  0 0.472  0
#> SRR1736358     3   0.000      1.000 0.000  0 1.000  0
#> SRR1736357     3   0.000      1.000 0.000  0 1.000  0
#> SRR1736359     3   0.000      1.000 0.000  0 1.000  0
#> SRR1736360     3   0.000      1.000 0.000  0 1.000  0
#> SRR1736361     3   0.000      1.000 0.000  0 1.000  0
#> SRR1736362     3   0.000      1.000 0.000  0 1.000  0
#> SRR1736363     3   0.000      1.000 0.000  0 1.000  0
#> SRR1736365     3   0.000      1.000 0.000  0 1.000  0
#> SRR1736364     3   0.000      1.000 0.000  0 1.000  0
#> SRR1736366     3   0.000      1.000 0.000  0 1.000  0
#> SRR1736367     3   0.000      1.000 0.000  0 1.000  0
#> SRR1736368     3   0.000      1.000 0.000  0 1.000  0

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1 p2    p3 p4    p5
#> SRR1736309     2   0.000      1.000 0.000  1 0.000  0 0.000
#> SRR1736310     2   0.000      1.000 0.000  1 0.000  0 0.000
#> SRR1736312     2   0.000      1.000 0.000  1 0.000  0 0.000
#> SRR1736311     2   0.000      1.000 0.000  1 0.000  0 0.000
#> SRR1736313     2   0.000      1.000 0.000  1 0.000  0 0.000
#> SRR1736314     2   0.000      1.000 0.000  1 0.000  0 0.000
#> SRR1736315     2   0.000      1.000 0.000  1 0.000  0 0.000
#> SRR1736316     2   0.000      1.000 0.000  1 0.000  0 0.000
#> SRR1736317     2   0.000      1.000 0.000  1 0.000  0 0.000
#> SRR1736318     2   0.000      1.000 0.000  1 0.000  0 0.000
#> SRR1736319     2   0.000      1.000 0.000  1 0.000  0 0.000
#> SRR1736320     2   0.000      1.000 0.000  1 0.000  0 0.000
#> SRR1736321     2   0.000      1.000 0.000  1 0.000  0 0.000
#> SRR1736322     2   0.000      1.000 0.000  1 0.000  0 0.000
#> SRR1736323     2   0.000      1.000 0.000  1 0.000  0 0.000
#> SRR1736324     2   0.000      1.000 0.000  1 0.000  0 0.000
#> SRR1736325     2   0.000      1.000 0.000  1 0.000  0 0.000
#> SRR1736326     2   0.000      1.000 0.000  1 0.000  0 0.000
#> SRR1736328     4   0.000      1.000 0.000  0 0.000  1 0.000
#> SRR1736327     4   0.000      1.000 0.000  0 0.000  1 0.000
#> SRR1736329     4   0.000      1.000 0.000  0 0.000  1 0.000
#> SRR1736330     4   0.000      1.000 0.000  0 0.000  1 0.000
#> SRR1736331     4   0.000      1.000 0.000  0 0.000  1 0.000
#> SRR1736332     4   0.000      1.000 0.000  0 0.000  1 0.000
#> SRR1736333     5   0.000      0.823 0.000  0 0.000  0 1.000
#> SRR1736334     5   0.000      0.823 0.000  0 0.000  0 1.000
#> SRR1736335     5   0.000      0.823 0.000  0 0.000  0 1.000
#> SRR1736337     5   0.000      0.823 0.000  0 0.000  0 1.000
#> SRR1736336     5   0.000      0.823 0.000  0 0.000  0 1.000
#> SRR1736338     5   0.000      0.823 0.000  0 0.000  0 1.000
#> SRR1736339     1   0.000      1.000 1.000  0 0.000  0 0.000
#> SRR1736340     1   0.000      1.000 1.000  0 0.000  0 0.000
#> SRR1736341     1   0.000      1.000 1.000  0 0.000  0 0.000
#> SRR1736342     1   0.000      1.000 1.000  0 0.000  0 0.000
#> SRR1736343     1   0.000      1.000 1.000  0 0.000  0 0.000
#> SRR1736344     1   0.000      1.000 1.000  0 0.000  0 0.000
#> SRR1736345     1   0.000      1.000 1.000  0 0.000  0 0.000
#> SRR1736346     1   0.000      1.000 1.000  0 0.000  0 0.000
#> SRR1736348     1   0.000      1.000 1.000  0 0.000  0 0.000
#> SRR1736347     1   0.000      1.000 1.000  0 0.000  0 0.000
#> SRR1736349     1   0.000      1.000 1.000  0 0.000  0 0.000
#> SRR1736350     1   0.000      1.000 1.000  0 0.000  0 0.000
#> SRR1736351     1   0.000      1.000 1.000  0 0.000  0 0.000
#> SRR1736352     1   0.000      1.000 1.000  0 0.000  0 0.000
#> SRR1736353     1   0.000      1.000 1.000  0 0.000  0 0.000
#> SRR1736354     5   0.426      0.322 0.436  0 0.000  0 0.564
#> SRR1736355     5   0.430      0.191 0.484  0 0.000  0 0.516
#> SRR1736356     3   0.427      0.645 0.036  0 0.732  0 0.232
#> SRR1736358     3   0.000      0.977 0.000  0 1.000  0 0.000
#> SRR1736357     3   0.000      0.977 0.000  0 1.000  0 0.000
#> SRR1736359     3   0.000      0.977 0.000  0 1.000  0 0.000
#> SRR1736360     3   0.000      0.977 0.000  0 1.000  0 0.000
#> SRR1736361     3   0.000      0.977 0.000  0 1.000  0 0.000
#> SRR1736362     3   0.000      0.977 0.000  0 1.000  0 0.000
#> SRR1736363     3   0.000      0.977 0.000  0 1.000  0 0.000
#> SRR1736365     3   0.000      0.977 0.000  0 1.000  0 0.000
#> SRR1736364     3   0.000      0.977 0.000  0 1.000  0 0.000
#> SRR1736366     3   0.000      0.977 0.000  0 1.000  0 0.000
#> SRR1736367     3   0.000      0.977 0.000  0 1.000  0 0.000
#> SRR1736368     3   0.000      0.977 0.000  0 1.000  0 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette p1 p2    p3 p4 p5    p6
#> SRR1736309     2   0.000      1.000  0  1 0.000  0  0 0.000
#> SRR1736310     2   0.000      1.000  0  1 0.000  0  0 0.000
#> SRR1736312     2   0.000      1.000  0  1 0.000  0  0 0.000
#> SRR1736311     2   0.000      1.000  0  1 0.000  0  0 0.000
#> SRR1736313     2   0.000      1.000  0  1 0.000  0  0 0.000
#> SRR1736314     2   0.000      1.000  0  1 0.000  0  0 0.000
#> SRR1736315     2   0.000      1.000  0  1 0.000  0  0 0.000
#> SRR1736316     2   0.000      1.000  0  1 0.000  0  0 0.000
#> SRR1736317     2   0.000      1.000  0  1 0.000  0  0 0.000
#> SRR1736318     2   0.000      1.000  0  1 0.000  0  0 0.000
#> SRR1736319     2   0.000      1.000  0  1 0.000  0  0 0.000
#> SRR1736320     2   0.000      1.000  0  1 0.000  0  0 0.000
#> SRR1736321     2   0.000      1.000  0  1 0.000  0  0 0.000
#> SRR1736322     2   0.000      1.000  0  1 0.000  0  0 0.000
#> SRR1736323     2   0.000      1.000  0  1 0.000  0  0 0.000
#> SRR1736324     2   0.000      1.000  0  1 0.000  0  0 0.000
#> SRR1736325     2   0.000      1.000  0  1 0.000  0  0 0.000
#> SRR1736326     2   0.000      1.000  0  1 0.000  0  0 0.000
#> SRR1736328     4   0.000      1.000  0  0 0.000  1  0 0.000
#> SRR1736327     4   0.000      1.000  0  0 0.000  1  0 0.000
#> SRR1736329     4   0.000      1.000  0  0 0.000  1  0 0.000
#> SRR1736330     4   0.000      1.000  0  0 0.000  1  0 0.000
#> SRR1736331     4   0.000      1.000  0  0 0.000  1  0 0.000
#> SRR1736332     4   0.000      1.000  0  0 0.000  1  0 0.000
#> SRR1736333     5   0.000      1.000  0  0 0.000  0  1 0.000
#> SRR1736334     5   0.000      1.000  0  0 0.000  0  1 0.000
#> SRR1736335     5   0.000      1.000  0  0 0.000  0  1 0.000
#> SRR1736337     5   0.000      1.000  0  0 0.000  0  1 0.000
#> SRR1736336     5   0.000      1.000  0  0 0.000  0  1 0.000
#> SRR1736338     5   0.000      1.000  0  0 0.000  0  1 0.000
#> SRR1736339     1   0.000      1.000  1  0 0.000  0  0 0.000
#> SRR1736340     1   0.000      1.000  1  0 0.000  0  0 0.000
#> SRR1736341     1   0.000      1.000  1  0 0.000  0  0 0.000
#> SRR1736342     6   0.000      0.939  0  0 0.000  0  0 1.000
#> SRR1736343     6   0.000      0.939  0  0 0.000  0  0 1.000
#> SRR1736344     6   0.000      0.939  0  0 0.000  0  0 1.000
#> SRR1736345     1   0.000      1.000  1  0 0.000  0  0 0.000
#> SRR1736346     1   0.000      1.000  1  0 0.000  0  0 0.000
#> SRR1736348     6   0.000      0.939  0  0 0.000  0  0 1.000
#> SRR1736347     1   0.000      1.000  1  0 0.000  0  0 0.000
#> SRR1736349     6   0.000      0.939  0  0 0.000  0  0 1.000
#> SRR1736350     6   0.000      0.939  0  0 0.000  0  0 1.000
#> SRR1736351     1   0.000      1.000  1  0 0.000  0  0 0.000
#> SRR1736352     1   0.000      1.000  1  0 0.000  0  0 0.000
#> SRR1736353     1   0.000      1.000  1  0 0.000  0  0 0.000
#> SRR1736354     6   0.000      0.939  0  0 0.000  0  0 1.000
#> SRR1736355     6   0.000      0.939  0  0 0.000  0  0 1.000
#> SRR1736356     6   0.377      0.322  0  0 0.404  0  0 0.596
#> SRR1736358     3   0.000      1.000  0  0 1.000  0  0 0.000
#> SRR1736357     3   0.000      1.000  0  0 1.000  0  0 0.000
#> SRR1736359     3   0.000      1.000  0  0 1.000  0  0 0.000
#> SRR1736360     3   0.000      1.000  0  0 1.000  0  0 0.000
#> SRR1736361     3   0.000      1.000  0  0 1.000  0  0 0.000
#> SRR1736362     3   0.000      1.000  0  0 1.000  0  0 0.000
#> SRR1736363     3   0.000      1.000  0  0 1.000  0  0 0.000
#> SRR1736365     3   0.000      1.000  0  0 1.000  0  0 0.000
#> SRR1736364     3   0.000      1.000  0  0 1.000  0  0 0.000
#> SRR1736366     3   0.000      1.000  0  0 1.000  0  0 0.000
#> SRR1736367     3   0.000      1.000  0  0 1.000  0  0 0.000
#> SRR1736368     3   0.000      1.000  0  0 1.000  0  0 0.000

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

consensus_heatmap(res, k = 2)

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

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

collect_plots(res)

plot of chunk SD-mclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4886 0.512   0.512
#> 3 3 1.000           0.970       0.985         0.3004 0.853   0.713
#> 4 4 0.898           0.967       0.982         0.1344 0.883   0.694
#> 5 5 0.905           0.569       0.826         0.0861 0.932   0.760
#> 6 6 0.904           0.908       0.923         0.0507 0.888   0.546

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
#> SRR1736309     2       0          1  0  1
#> SRR1736310     2       0          1  0  1
#> SRR1736312     2       0          1  0  1
#> SRR1736311     2       0          1  0  1
#> SRR1736313     2       0          1  0  1
#> SRR1736314     2       0          1  0  1
#> SRR1736315     2       0          1  0  1
#> SRR1736316     2       0          1  0  1
#> SRR1736317     2       0          1  0  1
#> SRR1736318     2       0          1  0  1
#> SRR1736319     2       0          1  0  1
#> SRR1736320     2       0          1  0  1
#> SRR1736321     2       0          1  0  1
#> SRR1736322     2       0          1  0  1
#> SRR1736323     2       0          1  0  1
#> SRR1736324     2       0          1  0  1
#> SRR1736325     2       0          1  0  1
#> SRR1736326     2       0          1  0  1
#> SRR1736328     2       0          1  0  1
#> SRR1736327     2       0          1  0  1
#> SRR1736329     2       0          1  0  1
#> SRR1736330     2       0          1  0  1
#> SRR1736331     2       0          1  0  1
#> SRR1736332     2       0          1  0  1
#> SRR1736333     1       0          1  1  0
#> SRR1736334     1       0          1  1  0
#> SRR1736335     1       0          1  1  0
#> SRR1736337     1       0          1  1  0
#> SRR1736336     1       0          1  1  0
#> SRR1736338     1       0          1  1  0
#> SRR1736339     1       0          1  1  0
#> SRR1736340     1       0          1  1  0
#> SRR1736341     1       0          1  1  0
#> SRR1736342     1       0          1  1  0
#> SRR1736343     1       0          1  1  0
#> SRR1736344     1       0          1  1  0
#> SRR1736345     1       0          1  1  0
#> SRR1736346     1       0          1  1  0
#> SRR1736348     1       0          1  1  0
#> SRR1736347     1       0          1  1  0
#> SRR1736349     1       0          1  1  0
#> SRR1736350     1       0          1  1  0
#> SRR1736351     1       0          1  1  0
#> SRR1736352     1       0          1  1  0
#> SRR1736353     1       0          1  1  0
#> SRR1736354     1       0          1  1  0
#> SRR1736355     1       0          1  1  0
#> SRR1736356     1       0          1  1  0
#> SRR1736358     1       0          1  1  0
#> SRR1736357     1       0          1  1  0
#> SRR1736359     1       0          1  1  0
#> SRR1736360     1       0          1  1  0
#> SRR1736361     1       0          1  1  0
#> SRR1736362     1       0          1  1  0
#> SRR1736363     1       0          1  1  0
#> SRR1736365     1       0          1  1  0
#> SRR1736364     1       0          1  1  0
#> SRR1736366     1       0          1  1  0
#> SRR1736367     1       0          1  1  0
#> SRR1736368     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
#> SRR1736309     2  0.0000      0.977 0.000 1.000 0.000
#> SRR1736310     2  0.0000      0.977 0.000 1.000 0.000
#> SRR1736312     2  0.0000      0.977 0.000 1.000 0.000
#> SRR1736311     2  0.0000      0.977 0.000 1.000 0.000
#> SRR1736313     2  0.0000      0.977 0.000 1.000 0.000
#> SRR1736314     2  0.0000      0.977 0.000 1.000 0.000
#> SRR1736315     2  0.0000      0.977 0.000 1.000 0.000
#> SRR1736316     2  0.0000      0.977 0.000 1.000 0.000
#> SRR1736317     2  0.0000      0.977 0.000 1.000 0.000
#> SRR1736318     2  0.0000      0.977 0.000 1.000 0.000
#> SRR1736319     2  0.0000      0.977 0.000 1.000 0.000
#> SRR1736320     2  0.0000      0.977 0.000 1.000 0.000
#> SRR1736321     2  0.0000      0.977 0.000 1.000 0.000
#> SRR1736322     2  0.0000      0.977 0.000 1.000 0.000
#> SRR1736323     2  0.0000      0.977 0.000 1.000 0.000
#> SRR1736324     2  0.0000      0.977 0.000 1.000 0.000
#> SRR1736325     2  0.0000      0.977 0.000 1.000 0.000
#> SRR1736326     2  0.0000      0.977 0.000 1.000 0.000
#> SRR1736328     2  0.2711      0.925 0.000 0.912 0.088
#> SRR1736327     2  0.2625      0.928 0.000 0.916 0.084
#> SRR1736329     2  0.2711      0.925 0.000 0.912 0.088
#> SRR1736330     2  0.2711      0.925 0.000 0.912 0.088
#> SRR1736331     2  0.2711      0.925 0.000 0.912 0.088
#> SRR1736332     2  0.2711      0.925 0.000 0.912 0.088
#> SRR1736333     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1736334     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1736335     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1736337     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1736336     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1736338     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1736339     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1736340     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1736341     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1736342     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1736343     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1736344     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1736345     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1736346     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1736348     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1736347     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1736349     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1736350     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1736351     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1736352     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1736353     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1736354     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1736355     1  0.0000      0.997 1.000 0.000 0.000
#> SRR1736356     3  0.5733      0.521 0.324 0.000 0.676
#> SRR1736358     3  0.0000      0.961 0.000 0.000 1.000
#> SRR1736357     3  0.0000      0.961 0.000 0.000 1.000
#> SRR1736359     3  0.0000      0.961 0.000 0.000 1.000
#> SRR1736360     1  0.0892      0.980 0.980 0.000 0.020
#> SRR1736361     1  0.0892      0.980 0.980 0.000 0.020
#> SRR1736362     1  0.0892      0.980 0.980 0.000 0.020
#> SRR1736363     3  0.0000      0.961 0.000 0.000 1.000
#> SRR1736365     3  0.0000      0.961 0.000 0.000 1.000
#> SRR1736364     3  0.0000      0.961 0.000 0.000 1.000
#> SRR1736366     3  0.0000      0.961 0.000 0.000 1.000
#> SRR1736367     3  0.0000      0.961 0.000 0.000 1.000
#> SRR1736368     3  0.0000      0.961 0.000 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
#> SRR1736309     2    0.00      1.000 0.00  1 0.00  0
#> SRR1736310     2    0.00      1.000 0.00  1 0.00  0
#> SRR1736312     2    0.00      1.000 0.00  1 0.00  0
#> SRR1736311     2    0.00      1.000 0.00  1 0.00  0
#> SRR1736313     2    0.00      1.000 0.00  1 0.00  0
#> SRR1736314     2    0.00      1.000 0.00  1 0.00  0
#> SRR1736315     2    0.00      1.000 0.00  1 0.00  0
#> SRR1736316     2    0.00      1.000 0.00  1 0.00  0
#> SRR1736317     2    0.00      1.000 0.00  1 0.00  0
#> SRR1736318     2    0.00      1.000 0.00  1 0.00  0
#> SRR1736319     2    0.00      1.000 0.00  1 0.00  0
#> SRR1736320     2    0.00      1.000 0.00  1 0.00  0
#> SRR1736321     2    0.00      1.000 0.00  1 0.00  0
#> SRR1736322     2    0.00      1.000 0.00  1 0.00  0
#> SRR1736323     2    0.00      1.000 0.00  1 0.00  0
#> SRR1736324     2    0.00      1.000 0.00  1 0.00  0
#> SRR1736325     2    0.00      1.000 0.00  1 0.00  0
#> SRR1736326     2    0.00      1.000 0.00  1 0.00  0
#> SRR1736328     4    0.00      1.000 0.00  0 0.00  1
#> SRR1736327     4    0.00      1.000 0.00  0 0.00  1
#> SRR1736329     4    0.00      1.000 0.00  0 0.00  1
#> SRR1736330     4    0.00      1.000 0.00  0 0.00  1
#> SRR1736331     4    0.00      1.000 0.00  0 0.00  1
#> SRR1736332     4    0.00      1.000 0.00  0 0.00  1
#> SRR1736333     1    0.34      0.829 0.82  0 0.18  0
#> SRR1736334     1    0.34      0.829 0.82  0 0.18  0
#> SRR1736335     1    0.34      0.829 0.82  0 0.18  0
#> SRR1736337     1    0.34      0.829 0.82  0 0.18  0
#> SRR1736336     1    0.34      0.829 0.82  0 0.18  0
#> SRR1736338     1    0.34      0.829 0.82  0 0.18  0
#> SRR1736339     1    0.00      0.943 1.00  0 0.00  0
#> SRR1736340     1    0.00      0.943 1.00  0 0.00  0
#> SRR1736341     1    0.00      0.943 1.00  0 0.00  0
#> SRR1736342     1    0.00      0.943 1.00  0 0.00  0
#> SRR1736343     1    0.00      0.943 1.00  0 0.00  0
#> SRR1736344     1    0.00      0.943 1.00  0 0.00  0
#> SRR1736345     1    0.00      0.943 1.00  0 0.00  0
#> SRR1736346     1    0.00      0.943 1.00  0 0.00  0
#> SRR1736348     1    0.00      0.943 1.00  0 0.00  0
#> SRR1736347     1    0.00      0.943 1.00  0 0.00  0
#> SRR1736349     1    0.00      0.943 1.00  0 0.00  0
#> SRR1736350     1    0.00      0.943 1.00  0 0.00  0
#> SRR1736351     1    0.00      0.943 1.00  0 0.00  0
#> SRR1736352     1    0.00      0.943 1.00  0 0.00  0
#> SRR1736353     1    0.00      0.943 1.00  0 0.00  0
#> SRR1736354     1    0.00      0.943 1.00  0 0.00  0
#> SRR1736355     1    0.00      0.943 1.00  0 0.00  0
#> SRR1736356     3    0.00      1.000 0.00  0 1.00  0
#> SRR1736358     3    0.00      1.000 0.00  0 1.00  0
#> SRR1736357     3    0.00      1.000 0.00  0 1.00  0
#> SRR1736359     3    0.00      1.000 0.00  0 1.00  0
#> SRR1736360     3    0.00      1.000 0.00  0 1.00  0
#> SRR1736361     3    0.00      1.000 0.00  0 1.00  0
#> SRR1736362     3    0.00      1.000 0.00  0 1.00  0
#> SRR1736363     3    0.00      1.000 0.00  0 1.00  0
#> SRR1736365     3    0.00      1.000 0.00  0 1.00  0
#> SRR1736364     3    0.00      1.000 0.00  0 1.00  0
#> SRR1736366     3    0.00      1.000 0.00  0 1.00  0
#> SRR1736367     3    0.00      1.000 0.00  0 1.00  0
#> SRR1736368     3    0.00      1.000 0.00  0 1.00  0

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1 p2    p3 p4    p5
#> SRR1736309     2  0.0000     1.0000 0.000  1 0.000  0 0.000
#> SRR1736310     2  0.0000     1.0000 0.000  1 0.000  0 0.000
#> SRR1736312     2  0.0000     1.0000 0.000  1 0.000  0 0.000
#> SRR1736311     2  0.0000     1.0000 0.000  1 0.000  0 0.000
#> SRR1736313     2  0.0000     1.0000 0.000  1 0.000  0 0.000
#> SRR1736314     2  0.0000     1.0000 0.000  1 0.000  0 0.000
#> SRR1736315     2  0.0000     1.0000 0.000  1 0.000  0 0.000
#> SRR1736316     2  0.0000     1.0000 0.000  1 0.000  0 0.000
#> SRR1736317     2  0.0000     1.0000 0.000  1 0.000  0 0.000
#> SRR1736318     2  0.0000     1.0000 0.000  1 0.000  0 0.000
#> SRR1736319     2  0.0000     1.0000 0.000  1 0.000  0 0.000
#> SRR1736320     2  0.0000     1.0000 0.000  1 0.000  0 0.000
#> SRR1736321     2  0.0000     1.0000 0.000  1 0.000  0 0.000
#> SRR1736322     2  0.0000     1.0000 0.000  1 0.000  0 0.000
#> SRR1736323     2  0.0000     1.0000 0.000  1 0.000  0 0.000
#> SRR1736324     2  0.0000     1.0000 0.000  1 0.000  0 0.000
#> SRR1736325     2  0.0000     1.0000 0.000  1 0.000  0 0.000
#> SRR1736326     2  0.0000     1.0000 0.000  1 0.000  0 0.000
#> SRR1736328     4  0.0000     1.0000 0.000  0 0.000  1 0.000
#> SRR1736327     4  0.0000     1.0000 0.000  0 0.000  1 0.000
#> SRR1736329     4  0.0000     1.0000 0.000  0 0.000  1 0.000
#> SRR1736330     4  0.0000     1.0000 0.000  0 0.000  1 0.000
#> SRR1736331     4  0.0000     1.0000 0.000  0 0.000  1 0.000
#> SRR1736332     4  0.0000     1.0000 0.000  0 0.000  1 0.000
#> SRR1736333     5  0.4307    -0.1183 0.500  0 0.000  0 0.500
#> SRR1736334     5  0.4307    -0.1183 0.500  0 0.000  0 0.500
#> SRR1736335     1  0.4307    -0.0738 0.500  0 0.000  0 0.500
#> SRR1736337     1  0.4307    -0.0738 0.500  0 0.000  0 0.500
#> SRR1736336     5  0.4307    -0.1183 0.500  0 0.000  0 0.500
#> SRR1736338     1  0.4307    -0.0738 0.500  0 0.000  0 0.500
#> SRR1736339     1  0.0162     0.3526 0.996  0 0.000  0 0.004
#> SRR1736340     1  0.0162     0.3526 0.996  0 0.000  0 0.004
#> SRR1736341     1  0.0404     0.3511 0.988  0 0.000  0 0.012
#> SRR1736342     5  0.4307     0.0200 0.500  0 0.000  0 0.500
#> SRR1736343     1  0.4307    -0.1997 0.500  0 0.000  0 0.500
#> SRR1736344     5  0.4307     0.0200 0.500  0 0.000  0 0.500
#> SRR1736345     1  0.0290     0.3532 0.992  0 0.000  0 0.008
#> SRR1736346     1  0.0290     0.3532 0.992  0 0.000  0 0.008
#> SRR1736348     5  0.4307     0.0200 0.500  0 0.000  0 0.500
#> SRR1736347     1  0.0290     0.3532 0.992  0 0.000  0 0.008
#> SRR1736349     5  0.4307     0.0200 0.500  0 0.000  0 0.500
#> SRR1736350     1  0.4307    -0.1997 0.500  0 0.000  0 0.500
#> SRR1736351     1  0.4307    -0.1997 0.500  0 0.000  0 0.500
#> SRR1736352     1  0.4307    -0.1997 0.500  0 0.000  0 0.500
#> SRR1736353     5  0.4307     0.0200 0.500  0 0.000  0 0.500
#> SRR1736354     1  0.4307    -0.1997 0.500  0 0.000  0 0.500
#> SRR1736355     1  0.4307    -0.1997 0.500  0 0.000  0 0.500
#> SRR1736356     3  0.0162     0.8512 0.000  0 0.996  0 0.004
#> SRR1736358     3  0.0000     0.8540 0.000  0 1.000  0 0.000
#> SRR1736357     3  0.0000     0.8540 0.000  0 1.000  0 0.000
#> SRR1736359     3  0.0000     0.8540 0.000  0 1.000  0 0.000
#> SRR1736360     3  0.4446     0.3947 0.476  0 0.520  0 0.004
#> SRR1736361     3  0.4446     0.3947 0.476  0 0.520  0 0.004
#> SRR1736362     3  0.4446     0.3947 0.476  0 0.520  0 0.004
#> SRR1736363     3  0.0000     0.8540 0.000  0 1.000  0 0.000
#> SRR1736365     3  0.0000     0.8540 0.000  0 1.000  0 0.000
#> SRR1736364     3  0.0000     0.8540 0.000  0 1.000  0 0.000
#> SRR1736366     3  0.0000     0.8540 0.000  0 1.000  0 0.000
#> SRR1736367     3  0.0000     0.8540 0.000  0 1.000  0 0.000
#> SRR1736368     3  0.0000     0.8540 0.000  0 1.000  0 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3 p4    p5    p6
#> SRR1736309     2  0.0000      1.000 0.000 1.000 0.000  0 0.000 0.000
#> SRR1736310     2  0.0000      1.000 0.000 1.000 0.000  0 0.000 0.000
#> SRR1736312     2  0.0000      1.000 0.000 1.000 0.000  0 0.000 0.000
#> SRR1736311     2  0.0000      1.000 0.000 1.000 0.000  0 0.000 0.000
#> SRR1736313     2  0.0000      1.000 0.000 1.000 0.000  0 0.000 0.000
#> SRR1736314     2  0.0000      1.000 0.000 1.000 0.000  0 0.000 0.000
#> SRR1736315     5  0.2597      1.000 0.000 0.176 0.000  0 0.824 0.000
#> SRR1736316     5  0.2597      1.000 0.000 0.176 0.000  0 0.824 0.000
#> SRR1736317     5  0.2597      1.000 0.000 0.176 0.000  0 0.824 0.000
#> SRR1736318     2  0.0000      1.000 0.000 1.000 0.000  0 0.000 0.000
#> SRR1736319     2  0.0000      1.000 0.000 1.000 0.000  0 0.000 0.000
#> SRR1736320     2  0.0000      1.000 0.000 1.000 0.000  0 0.000 0.000
#> SRR1736321     5  0.2597      1.000 0.000 0.176 0.000  0 0.824 0.000
#> SRR1736322     5  0.2597      1.000 0.000 0.176 0.000  0 0.824 0.000
#> SRR1736323     5  0.2597      1.000 0.000 0.176 0.000  0 0.824 0.000
#> SRR1736324     2  0.0000      1.000 0.000 1.000 0.000  0 0.000 0.000
#> SRR1736325     2  0.0000      1.000 0.000 1.000 0.000  0 0.000 0.000
#> SRR1736326     2  0.0000      1.000 0.000 1.000 0.000  0 0.000 0.000
#> SRR1736328     4  0.0000      1.000 0.000 0.000 0.000  1 0.000 0.000
#> SRR1736327     4  0.0000      1.000 0.000 0.000 0.000  1 0.000 0.000
#> SRR1736329     4  0.0000      1.000 0.000 0.000 0.000  1 0.000 0.000
#> SRR1736330     4  0.0000      1.000 0.000 0.000 0.000  1 0.000 0.000
#> SRR1736331     4  0.0000      1.000 0.000 0.000 0.000  1 0.000 0.000
#> SRR1736332     4  0.0000      1.000 0.000 0.000 0.000  1 0.000 0.000
#> SRR1736333     1  0.4814      0.677 0.532 0.000 0.000  0 0.056 0.412
#> SRR1736334     1  0.4814      0.677 0.532 0.000 0.000  0 0.056 0.412
#> SRR1736335     1  0.4814      0.677 0.532 0.000 0.000  0 0.056 0.412
#> SRR1736337     1  0.4814      0.677 0.532 0.000 0.000  0 0.056 0.412
#> SRR1736336     1  0.4814      0.677 0.532 0.000 0.000  0 0.056 0.412
#> SRR1736338     1  0.4814      0.677 0.532 0.000 0.000  0 0.056 0.412
#> SRR1736339     1  0.0547      0.528 0.980 0.000 0.000  0 0.000 0.020
#> SRR1736340     1  0.0547      0.528 0.980 0.000 0.000  0 0.000 0.020
#> SRR1736341     1  0.1501      0.403 0.924 0.000 0.000  0 0.000 0.076
#> SRR1736342     6  0.3782      1.000 0.412 0.000 0.000  0 0.000 0.588
#> SRR1736343     6  0.3782      1.000 0.412 0.000 0.000  0 0.000 0.588
#> SRR1736344     6  0.3782      1.000 0.412 0.000 0.000  0 0.000 0.588
#> SRR1736345     1  0.0000      0.555 1.000 0.000 0.000  0 0.000 0.000
#> SRR1736346     1  0.0000      0.555 1.000 0.000 0.000  0 0.000 0.000
#> SRR1736348     6  0.3782      1.000 0.412 0.000 0.000  0 0.000 0.588
#> SRR1736347     1  0.0000      0.555 1.000 0.000 0.000  0 0.000 0.000
#> SRR1736349     6  0.3782      1.000 0.412 0.000 0.000  0 0.000 0.588
#> SRR1736350     6  0.3782      1.000 0.412 0.000 0.000  0 0.000 0.588
#> SRR1736351     6  0.3782      1.000 0.412 0.000 0.000  0 0.000 0.588
#> SRR1736352     6  0.3782      1.000 0.412 0.000 0.000  0 0.000 0.588
#> SRR1736353     6  0.3782      1.000 0.412 0.000 0.000  0 0.000 0.588
#> SRR1736354     6  0.3782      1.000 0.412 0.000 0.000  0 0.000 0.588
#> SRR1736355     6  0.3782      1.000 0.412 0.000 0.000  0 0.000 0.588
#> SRR1736356     3  0.0260      0.959 0.000 0.000 0.992  0 0.008 0.000
#> SRR1736358     3  0.0260      0.959 0.000 0.000 0.992  0 0.008 0.000
#> SRR1736357     3  0.0260      0.959 0.000 0.000 0.992  0 0.008 0.000
#> SRR1736359     3  0.0260      0.959 0.000 0.000 0.992  0 0.008 0.000
#> SRR1736360     3  0.2579      0.896 0.040 0.000 0.872  0 0.088 0.000
#> SRR1736361     3  0.2579      0.896 0.040 0.000 0.872  0 0.088 0.000
#> SRR1736362     3  0.2579      0.896 0.040 0.000 0.872  0 0.088 0.000
#> SRR1736363     3  0.0632      0.961 0.000 0.000 0.976  0 0.024 0.000
#> SRR1736365     3  0.0632      0.961 0.000 0.000 0.976  0 0.024 0.000
#> SRR1736364     3  0.0632      0.961 0.000 0.000 0.976  0 0.024 0.000
#> SRR1736366     3  0.0632      0.961 0.000 0.000 0.976  0 0.024 0.000
#> SRR1736367     3  0.0632      0.961 0.000 0.000 0.976  0 0.024 0.000
#> SRR1736368     3  0.0632      0.961 0.000 0.000 0.976  0 0.024 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 15454 rows and 60 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#>   Subgroups are detected by 'NMF' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk SD-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4886 0.512   0.512
#> 3 3 0.714           0.903       0.863         0.2880 0.831   0.670
#> 4 4 0.877           0.835       0.912         0.1344 0.919   0.773
#> 5 5 0.765           0.868       0.885         0.0883 0.924   0.735
#> 6 6 0.899           0.895       0.904         0.0417 0.944   0.748

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
#> SRR1736309     2       0          1  0  1
#> SRR1736310     2       0          1  0  1
#> SRR1736312     2       0          1  0  1
#> SRR1736311     2       0          1  0  1
#> SRR1736313     2       0          1  0  1
#> SRR1736314     2       0          1  0  1
#> SRR1736315     2       0          1  0  1
#> SRR1736316     2       0          1  0  1
#> SRR1736317     2       0          1  0  1
#> SRR1736318     2       0          1  0  1
#> SRR1736319     2       0          1  0  1
#> SRR1736320     2       0          1  0  1
#> SRR1736321     2       0          1  0  1
#> SRR1736322     2       0          1  0  1
#> SRR1736323     2       0          1  0  1
#> SRR1736324     2       0          1  0  1
#> SRR1736325     2       0          1  0  1
#> SRR1736326     2       0          1  0  1
#> SRR1736328     2       0          1  0  1
#> SRR1736327     2       0          1  0  1
#> SRR1736329     2       0          1  0  1
#> SRR1736330     2       0          1  0  1
#> SRR1736331     2       0          1  0  1
#> SRR1736332     2       0          1  0  1
#> SRR1736333     1       0          1  1  0
#> SRR1736334     1       0          1  1  0
#> SRR1736335     1       0          1  1  0
#> SRR1736337     1       0          1  1  0
#> SRR1736336     1       0          1  1  0
#> SRR1736338     1       0          1  1  0
#> SRR1736339     1       0          1  1  0
#> SRR1736340     1       0          1  1  0
#> SRR1736341     1       0          1  1  0
#> SRR1736342     1       0          1  1  0
#> SRR1736343     1       0          1  1  0
#> SRR1736344     1       0          1  1  0
#> SRR1736345     1       0          1  1  0
#> SRR1736346     1       0          1  1  0
#> SRR1736348     1       0          1  1  0
#> SRR1736347     1       0          1  1  0
#> SRR1736349     1       0          1  1  0
#> SRR1736350     1       0          1  1  0
#> SRR1736351     1       0          1  1  0
#> SRR1736352     1       0          1  1  0
#> SRR1736353     1       0          1  1  0
#> SRR1736354     1       0          1  1  0
#> SRR1736355     1       0          1  1  0
#> SRR1736356     1       0          1  1  0
#> SRR1736358     1       0          1  1  0
#> SRR1736357     1       0          1  1  0
#> SRR1736359     1       0          1  1  0
#> SRR1736360     1       0          1  1  0
#> SRR1736361     1       0          1  1  0
#> SRR1736362     1       0          1  1  0
#> SRR1736363     1       0          1  1  0
#> SRR1736365     1       0          1  1  0
#> SRR1736364     1       0          1  1  0
#> SRR1736366     1       0          1  1  0
#> SRR1736367     1       0          1  1  0
#> SRR1736368     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
#> SRR1736309     2  0.2711      0.890 0.000 0.912 0.088
#> SRR1736310     2  0.2625      0.891 0.000 0.916 0.084
#> SRR1736312     2  0.2711      0.890 0.000 0.912 0.088
#> SRR1736311     2  0.2711      0.890 0.000 0.912 0.088
#> SRR1736313     2  0.2711      0.890 0.000 0.912 0.088
#> SRR1736314     2  0.2625      0.891 0.000 0.916 0.084
#> SRR1736315     2  0.4062      0.907 0.000 0.836 0.164
#> SRR1736316     2  0.4062      0.907 0.000 0.836 0.164
#> SRR1736317     2  0.4062      0.907 0.000 0.836 0.164
#> SRR1736318     2  0.1529      0.902 0.000 0.960 0.040
#> SRR1736319     2  0.0424      0.907 0.000 0.992 0.008
#> SRR1736320     2  0.1289      0.904 0.000 0.968 0.032
#> SRR1736321     2  0.4062      0.907 0.000 0.836 0.164
#> SRR1736322     2  0.4002      0.907 0.000 0.840 0.160
#> SRR1736323     2  0.2625      0.910 0.000 0.916 0.084
#> SRR1736324     2  0.1289      0.904 0.000 0.968 0.032
#> SRR1736325     2  0.0237      0.908 0.000 0.996 0.004
#> SRR1736326     2  0.2625      0.891 0.000 0.916 0.084
#> SRR1736328     2  0.4062      0.907 0.000 0.836 0.164
#> SRR1736327     2  0.4062      0.907 0.000 0.836 0.164
#> SRR1736329     2  0.4062      0.907 0.000 0.836 0.164
#> SRR1736330     2  0.4062      0.907 0.000 0.836 0.164
#> SRR1736331     2  0.4062      0.907 0.000 0.836 0.164
#> SRR1736332     2  0.4062      0.907 0.000 0.836 0.164
#> SRR1736333     1  0.4796      0.614 0.780 0.000 0.220
#> SRR1736334     1  0.4121      0.730 0.832 0.000 0.168
#> SRR1736335     3  0.5882      0.917 0.348 0.000 0.652
#> SRR1736337     1  0.4399      0.690 0.812 0.000 0.188
#> SRR1736336     1  0.3551      0.789 0.868 0.000 0.132
#> SRR1736338     1  0.3482      0.796 0.872 0.000 0.128
#> SRR1736339     1  0.0000      0.933 1.000 0.000 0.000
#> SRR1736340     1  0.0000      0.933 1.000 0.000 0.000
#> SRR1736341     1  0.0000      0.933 1.000 0.000 0.000
#> SRR1736342     1  0.0000      0.933 1.000 0.000 0.000
#> SRR1736343     1  0.0000      0.933 1.000 0.000 0.000
#> SRR1736344     1  0.0000      0.933 1.000 0.000 0.000
#> SRR1736345     1  0.0000      0.933 1.000 0.000 0.000
#> SRR1736346     1  0.0000      0.933 1.000 0.000 0.000
#> SRR1736348     1  0.0000      0.933 1.000 0.000 0.000
#> SRR1736347     1  0.0000      0.933 1.000 0.000 0.000
#> SRR1736349     1  0.0000      0.933 1.000 0.000 0.000
#> SRR1736350     1  0.0000      0.933 1.000 0.000 0.000
#> SRR1736351     1  0.0000      0.933 1.000 0.000 0.000
#> SRR1736352     1  0.0000      0.933 1.000 0.000 0.000
#> SRR1736353     1  0.0000      0.933 1.000 0.000 0.000
#> SRR1736354     1  0.0000      0.933 1.000 0.000 0.000
#> SRR1736355     1  0.0000      0.933 1.000 0.000 0.000
#> SRR1736356     1  0.3816      0.730 0.852 0.000 0.148
#> SRR1736358     3  0.5650      0.970 0.312 0.000 0.688
#> SRR1736357     3  0.5650      0.970 0.312 0.000 0.688
#> SRR1736359     3  0.5650      0.970 0.312 0.000 0.688
#> SRR1736360     3  0.6633      0.907 0.260 0.040 0.700
#> SRR1736361     3  0.6939      0.841 0.216 0.072 0.712
#> SRR1736362     3  0.6113      0.958 0.300 0.012 0.688
#> SRR1736363     3  0.5650      0.970 0.312 0.000 0.688
#> SRR1736365     3  0.5650      0.970 0.312 0.000 0.688
#> SRR1736364     3  0.5650      0.970 0.312 0.000 0.688
#> SRR1736366     3  0.5650      0.970 0.312 0.000 0.688
#> SRR1736367     3  0.5650      0.970 0.312 0.000 0.688
#> SRR1736368     3  0.5650      0.970 0.312 0.000 0.688

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1736309     2  0.0000     0.7707 0.000 1.000 0.000 0.000
#> SRR1736310     2  0.0000     0.7707 0.000 1.000 0.000 0.000
#> SRR1736312     2  0.0000     0.7707 0.000 1.000 0.000 0.000
#> SRR1736311     2  0.0000     0.7707 0.000 1.000 0.000 0.000
#> SRR1736313     2  0.0000     0.7707 0.000 1.000 0.000 0.000
#> SRR1736314     2  0.0000     0.7707 0.000 1.000 0.000 0.000
#> SRR1736315     2  0.4999    -0.1390 0.000 0.508 0.000 0.492
#> SRR1736316     2  0.4989    -0.0539 0.000 0.528 0.000 0.472
#> SRR1736317     2  0.5000    -0.1739 0.000 0.500 0.000 0.500
#> SRR1736318     2  0.0817     0.7701 0.000 0.976 0.000 0.024
#> SRR1736319     2  0.1474     0.7605 0.000 0.948 0.000 0.052
#> SRR1736320     2  0.1022     0.7687 0.000 0.968 0.000 0.032
#> SRR1736321     2  0.4981    -0.0210 0.000 0.536 0.000 0.464
#> SRR1736322     2  0.4955     0.0546 0.000 0.556 0.000 0.444
#> SRR1736323     2  0.3726     0.5922 0.000 0.788 0.000 0.212
#> SRR1736324     2  0.1118     0.7676 0.000 0.964 0.000 0.036
#> SRR1736325     2  0.1474     0.7605 0.000 0.948 0.000 0.052
#> SRR1736326     2  0.0000     0.7707 0.000 1.000 0.000 0.000
#> SRR1736328     4  0.3764     1.0000 0.000 0.216 0.000 0.784
#> SRR1736327     4  0.3764     1.0000 0.000 0.216 0.000 0.784
#> SRR1736329     4  0.3764     1.0000 0.000 0.216 0.000 0.784
#> SRR1736330     4  0.3764     1.0000 0.000 0.216 0.000 0.784
#> SRR1736331     4  0.3764     1.0000 0.000 0.216 0.000 0.784
#> SRR1736332     4  0.3764     1.0000 0.000 0.216 0.000 0.784
#> SRR1736333     1  0.1637     0.9423 0.940 0.000 0.060 0.000
#> SRR1736334     1  0.1474     0.9473 0.948 0.000 0.052 0.000
#> SRR1736335     1  0.3610     0.7911 0.800 0.000 0.200 0.000
#> SRR1736337     1  0.1557     0.9449 0.944 0.000 0.056 0.000
#> SRR1736336     1  0.1302     0.9506 0.956 0.000 0.044 0.000
#> SRR1736338     1  0.1211     0.9519 0.960 0.000 0.040 0.000
#> SRR1736339     1  0.0707     0.9583 0.980 0.000 0.000 0.020
#> SRR1736340     1  0.0707     0.9583 0.980 0.000 0.000 0.020
#> SRR1736341     1  0.0707     0.9583 0.980 0.000 0.000 0.020
#> SRR1736342     1  0.1022     0.9583 0.968 0.000 0.000 0.032
#> SRR1736343     1  0.1022     0.9583 0.968 0.000 0.000 0.032
#> SRR1736344     1  0.1022     0.9583 0.968 0.000 0.000 0.032
#> SRR1736345     1  0.0707     0.9583 0.980 0.000 0.000 0.020
#> SRR1736346     1  0.0707     0.9583 0.980 0.000 0.000 0.020
#> SRR1736348     1  0.1022     0.9583 0.968 0.000 0.000 0.032
#> SRR1736347     1  0.0707     0.9583 0.980 0.000 0.000 0.020
#> SRR1736349     1  0.1022     0.9583 0.968 0.000 0.000 0.032
#> SRR1736350     1  0.1022     0.9583 0.968 0.000 0.000 0.032
#> SRR1736351     1  0.0707     0.9583 0.980 0.000 0.000 0.020
#> SRR1736352     1  0.0707     0.9583 0.980 0.000 0.000 0.020
#> SRR1736353     1  0.0707     0.9583 0.980 0.000 0.000 0.020
#> SRR1736354     1  0.1022     0.9583 0.968 0.000 0.000 0.032
#> SRR1736355     1  0.1022     0.9583 0.968 0.000 0.000 0.032
#> SRR1736356     1  0.4290     0.7977 0.800 0.000 0.164 0.036
#> SRR1736358     3  0.0188     0.9971 0.000 0.000 0.996 0.004
#> SRR1736357     3  0.0188     0.9971 0.000 0.000 0.996 0.004
#> SRR1736359     3  0.0188     0.9971 0.000 0.000 0.996 0.004
#> SRR1736360     3  0.0000     0.9990 0.000 0.000 1.000 0.000
#> SRR1736361     3  0.0000     0.9990 0.000 0.000 1.000 0.000
#> SRR1736362     3  0.0000     0.9990 0.000 0.000 1.000 0.000
#> SRR1736363     3  0.0000     0.9990 0.000 0.000 1.000 0.000
#> SRR1736365     3  0.0000     0.9990 0.000 0.000 1.000 0.000
#> SRR1736364     3  0.0000     0.9990 0.000 0.000 1.000 0.000
#> SRR1736366     3  0.0000     0.9990 0.000 0.000 1.000 0.000
#> SRR1736367     3  0.0000     0.9990 0.000 0.000 1.000 0.000
#> SRR1736368     3  0.0000     0.9990 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
#> SRR1736309     2  0.0000      0.898 0.000 1.000 0.000 0.000 0.000
#> SRR1736310     2  0.0000      0.898 0.000 1.000 0.000 0.000 0.000
#> SRR1736312     2  0.0000      0.898 0.000 1.000 0.000 0.000 0.000
#> SRR1736311     2  0.0000      0.898 0.000 1.000 0.000 0.000 0.000
#> SRR1736313     2  0.0000      0.898 0.000 1.000 0.000 0.000 0.000
#> SRR1736314     2  0.0000      0.898 0.000 1.000 0.000 0.000 0.000
#> SRR1736315     2  0.3684      0.664 0.000 0.720 0.000 0.280 0.000
#> SRR1736316     2  0.3395      0.729 0.000 0.764 0.000 0.236 0.000
#> SRR1736317     2  0.3796      0.629 0.000 0.700 0.000 0.300 0.000
#> SRR1736318     2  0.0000      0.898 0.000 1.000 0.000 0.000 0.000
#> SRR1736319     2  0.0290      0.895 0.000 0.992 0.000 0.008 0.000
#> SRR1736320     2  0.0000      0.898 0.000 1.000 0.000 0.000 0.000
#> SRR1736321     2  0.3336      0.739 0.000 0.772 0.000 0.228 0.000
#> SRR1736322     2  0.3336      0.739 0.000 0.772 0.000 0.228 0.000
#> SRR1736323     2  0.2471      0.820 0.000 0.864 0.000 0.136 0.000
#> SRR1736324     2  0.0000      0.898 0.000 1.000 0.000 0.000 0.000
#> SRR1736325     2  0.0609      0.891 0.000 0.980 0.000 0.020 0.000
#> SRR1736326     2  0.0000      0.898 0.000 1.000 0.000 0.000 0.000
#> SRR1736328     4  0.2280      1.000 0.000 0.120 0.000 0.880 0.000
#> SRR1736327     4  0.2280      1.000 0.000 0.120 0.000 0.880 0.000
#> SRR1736329     4  0.2280      1.000 0.000 0.120 0.000 0.880 0.000
#> SRR1736330     4  0.2280      1.000 0.000 0.120 0.000 0.880 0.000
#> SRR1736331     4  0.2280      1.000 0.000 0.120 0.000 0.880 0.000
#> SRR1736332     4  0.2280      1.000 0.000 0.120 0.000 0.880 0.000
#> SRR1736333     5  0.2773      0.769 0.112 0.000 0.020 0.000 0.868
#> SRR1736334     5  0.2864      0.767 0.112 0.000 0.024 0.000 0.864
#> SRR1736335     5  0.2588      0.706 0.060 0.000 0.048 0.000 0.892
#> SRR1736337     5  0.2773      0.769 0.112 0.000 0.020 0.000 0.868
#> SRR1736336     5  0.2921      0.775 0.124 0.000 0.020 0.000 0.856
#> SRR1736338     5  0.2969      0.776 0.128 0.000 0.020 0.000 0.852
#> SRR1736339     1  0.0000      0.996 1.000 0.000 0.000 0.000 0.000
#> SRR1736340     1  0.0000      0.996 1.000 0.000 0.000 0.000 0.000
#> SRR1736341     1  0.0000      0.996 1.000 0.000 0.000 0.000 0.000
#> SRR1736342     5  0.4138      0.770 0.384 0.000 0.000 0.000 0.616
#> SRR1736343     5  0.4114      0.781 0.376 0.000 0.000 0.000 0.624
#> SRR1736344     5  0.4101      0.785 0.372 0.000 0.000 0.000 0.628
#> SRR1736345     1  0.0162      0.994 0.996 0.000 0.004 0.000 0.000
#> SRR1736346     1  0.0162      0.994 0.996 0.000 0.004 0.000 0.000
#> SRR1736348     5  0.4045      0.796 0.356 0.000 0.000 0.000 0.644
#> SRR1736347     1  0.0162      0.994 0.996 0.000 0.004 0.000 0.000
#> SRR1736349     5  0.4045      0.796 0.356 0.000 0.000 0.000 0.644
#> SRR1736350     5  0.4045      0.796 0.356 0.000 0.000 0.000 0.644
#> SRR1736351     1  0.0162      0.994 0.996 0.000 0.000 0.000 0.004
#> SRR1736352     1  0.0162      0.994 0.996 0.000 0.000 0.000 0.004
#> SRR1736353     1  0.0162      0.994 0.996 0.000 0.000 0.000 0.004
#> SRR1736354     5  0.4045      0.796 0.356 0.000 0.000 0.000 0.644
#> SRR1736355     5  0.4015      0.796 0.348 0.000 0.000 0.000 0.652
#> SRR1736356     5  0.5384      0.724 0.196 0.000 0.140 0.000 0.664
#> SRR1736358     3  0.1544      0.888 0.000 0.000 0.932 0.000 0.068
#> SRR1736357     3  0.1544      0.888 0.000 0.000 0.932 0.000 0.068
#> SRR1736359     3  0.1478      0.890 0.000 0.000 0.936 0.000 0.064
#> SRR1736360     3  0.3661      0.767 0.000 0.000 0.724 0.000 0.276
#> SRR1736361     3  0.3684      0.767 0.000 0.000 0.720 0.000 0.280
#> SRR1736362     3  0.3612      0.770 0.000 0.000 0.732 0.000 0.268
#> SRR1736363     3  0.0162      0.908 0.000 0.000 0.996 0.000 0.004
#> SRR1736365     3  0.0000      0.909 0.000 0.000 1.000 0.000 0.000
#> SRR1736364     3  0.0000      0.909 0.000 0.000 1.000 0.000 0.000
#> SRR1736366     3  0.0000      0.909 0.000 0.000 1.000 0.000 0.000
#> SRR1736367     3  0.0000      0.909 0.000 0.000 1.000 0.000 0.000
#> SRR1736368     3  0.0000      0.909 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
#> SRR1736309     2  0.0000      0.957 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736310     2  0.0363      0.954 0.000 0.988 0.000 0.000 0.012 0.000
#> SRR1736312     2  0.0146      0.956 0.000 0.996 0.000 0.000 0.004 0.000
#> SRR1736311     2  0.0363      0.954 0.000 0.988 0.000 0.000 0.012 0.000
#> SRR1736313     2  0.0260      0.955 0.000 0.992 0.000 0.000 0.008 0.000
#> SRR1736314     2  0.0363      0.954 0.000 0.988 0.000 0.000 0.012 0.000
#> SRR1736315     2  0.1958      0.926 0.000 0.896 0.000 0.100 0.004 0.000
#> SRR1736316     2  0.1908      0.929 0.000 0.900 0.000 0.096 0.004 0.000
#> SRR1736317     2  0.2006      0.922 0.000 0.892 0.000 0.104 0.004 0.000
#> SRR1736318     2  0.0547      0.960 0.000 0.980 0.000 0.020 0.000 0.000
#> SRR1736319     2  0.0713      0.959 0.000 0.972 0.000 0.028 0.000 0.000
#> SRR1736320     2  0.0632      0.960 0.000 0.976 0.000 0.024 0.000 0.000
#> SRR1736321     2  0.1806      0.934 0.000 0.908 0.000 0.088 0.004 0.000
#> SRR1736322     2  0.1806      0.934 0.000 0.908 0.000 0.088 0.004 0.000
#> SRR1736323     2  0.1531      0.945 0.000 0.928 0.000 0.068 0.004 0.000
#> SRR1736324     2  0.0547      0.960 0.000 0.980 0.000 0.020 0.000 0.000
#> SRR1736325     2  0.0790      0.959 0.000 0.968 0.000 0.032 0.000 0.000
#> SRR1736326     2  0.0146      0.956 0.000 0.996 0.000 0.000 0.004 0.000
#> SRR1736328     4  0.0937      0.997 0.000 0.040 0.000 0.960 0.000 0.000
#> SRR1736327     4  0.0937      0.997 0.000 0.040 0.000 0.960 0.000 0.000
#> SRR1736329     4  0.0937      0.997 0.000 0.040 0.000 0.960 0.000 0.000
#> SRR1736330     4  0.1007      0.996 0.000 0.044 0.000 0.956 0.000 0.000
#> SRR1736331     4  0.0937      0.995 0.000 0.040 0.000 0.960 0.000 0.000
#> SRR1736332     4  0.1007      0.996 0.000 0.044 0.000 0.956 0.000 0.000
#> SRR1736333     5  0.4153      0.678 0.008 0.000 0.012 0.000 0.640 0.340
#> SRR1736334     5  0.4148      0.669 0.016 0.000 0.004 0.000 0.636 0.344
#> SRR1736335     5  0.3816      0.675 0.000 0.000 0.016 0.000 0.688 0.296
#> SRR1736337     5  0.4153      0.676 0.012 0.000 0.008 0.000 0.640 0.340
#> SRR1736336     5  0.4253      0.644 0.012 0.000 0.008 0.000 0.608 0.372
#> SRR1736338     5  0.4274      0.638 0.008 0.000 0.012 0.000 0.600 0.380
#> SRR1736339     1  0.0458      0.978 0.984 0.000 0.000 0.000 0.000 0.016
#> SRR1736340     1  0.0363      0.978 0.988 0.000 0.000 0.000 0.000 0.012
#> SRR1736341     1  0.0363      0.978 0.988 0.000 0.000 0.000 0.000 0.012
#> SRR1736342     6  0.1765      0.935 0.096 0.000 0.000 0.000 0.000 0.904
#> SRR1736343     6  0.1663      0.943 0.088 0.000 0.000 0.000 0.000 0.912
#> SRR1736344     6  0.1700      0.947 0.080 0.000 0.000 0.000 0.004 0.916
#> SRR1736345     1  0.0000      0.974 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1736346     1  0.0000      0.974 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1736348     6  0.1471      0.951 0.064 0.000 0.000 0.000 0.004 0.932
#> SRR1736347     1  0.0146      0.976 0.996 0.000 0.000 0.000 0.000 0.004
#> SRR1736349     6  0.1471      0.951 0.064 0.000 0.000 0.000 0.004 0.932
#> SRR1736350     6  0.1471      0.951 0.064 0.000 0.000 0.000 0.004 0.932
#> SRR1736351     1  0.1285      0.963 0.944 0.000 0.000 0.000 0.004 0.052
#> SRR1736352     1  0.1285      0.963 0.944 0.000 0.000 0.000 0.004 0.052
#> SRR1736353     1  0.1285      0.963 0.944 0.000 0.000 0.000 0.004 0.052
#> SRR1736354     6  0.1531      0.951 0.068 0.000 0.000 0.000 0.004 0.928
#> SRR1736355     6  0.1584      0.948 0.064 0.000 0.000 0.000 0.008 0.928
#> SRR1736356     6  0.3751      0.712 0.020 0.000 0.080 0.000 0.092 0.808
#> SRR1736358     3  0.1867      0.922 0.000 0.000 0.916 0.000 0.064 0.020
#> SRR1736357     3  0.1779      0.925 0.000 0.000 0.920 0.000 0.064 0.016
#> SRR1736359     3  0.1779      0.925 0.000 0.000 0.920 0.000 0.064 0.016
#> SRR1736360     5  0.4282      0.347 0.000 0.000 0.420 0.000 0.560 0.020
#> SRR1736361     5  0.4453      0.359 0.000 0.000 0.400 0.000 0.568 0.032
#> SRR1736362     5  0.4282      0.347 0.000 0.000 0.420 0.000 0.560 0.020
#> SRR1736363     3  0.0000      0.963 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736365     3  0.0146      0.961 0.000 0.000 0.996 0.000 0.004 0.000
#> SRR1736364     3  0.0000      0.963 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736366     3  0.0000      0.963 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736367     3  0.0000      0.963 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736368     3  0.0000      0.963 0.000 0.000 1.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

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

collect_plots(res)

plot of chunk CV-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.4886 0.512   0.512
#> 3 3 0.898           0.953       0.976         0.3488 0.831   0.670
#> 4 4 0.940           0.947       0.978         0.0207 0.993   0.980
#> 5 5 0.877           0.913       0.919         0.0785 0.939   0.818
#> 6 6 0.895           0.950       0.952         0.0731 0.942   0.791

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
#> SRR1736309     2       0          1  0  1
#> SRR1736310     2       0          1  0  1
#> SRR1736312     2       0          1  0  1
#> SRR1736311     2       0          1  0  1
#> SRR1736313     2       0          1  0  1
#> SRR1736314     2       0          1  0  1
#> SRR1736315     2       0          1  0  1
#> SRR1736316     2       0          1  0  1
#> SRR1736317     2       0          1  0  1
#> SRR1736318     2       0          1  0  1
#> SRR1736319     2       0          1  0  1
#> SRR1736320     2       0          1  0  1
#> SRR1736321     2       0          1  0  1
#> SRR1736322     2       0          1  0  1
#> SRR1736323     2       0          1  0  1
#> SRR1736324     2       0          1  0  1
#> SRR1736325     2       0          1  0  1
#> SRR1736326     2       0          1  0  1
#> SRR1736328     2       0          1  0  1
#> SRR1736327     2       0          1  0  1
#> SRR1736329     2       0          1  0  1
#> SRR1736330     2       0          1  0  1
#> SRR1736331     2       0          1  0  1
#> SRR1736332     2       0          1  0  1
#> SRR1736333     1       0          1  1  0
#> SRR1736334     1       0          1  1  0
#> SRR1736335     1       0          1  1  0
#> SRR1736337     1       0          1  1  0
#> SRR1736336     1       0          1  1  0
#> SRR1736338     1       0          1  1  0
#> SRR1736339     1       0          1  1  0
#> SRR1736340     1       0          1  1  0
#> SRR1736341     1       0          1  1  0
#> SRR1736342     1       0          1  1  0
#> SRR1736343     1       0          1  1  0
#> SRR1736344     1       0          1  1  0
#> SRR1736345     1       0          1  1  0
#> SRR1736346     1       0          1  1  0
#> SRR1736348     1       0          1  1  0
#> SRR1736347     1       0          1  1  0
#> SRR1736349     1       0          1  1  0
#> SRR1736350     1       0          1  1  0
#> SRR1736351     1       0          1  1  0
#> SRR1736352     1       0          1  1  0
#> SRR1736353     1       0          1  1  0
#> SRR1736354     1       0          1  1  0
#> SRR1736355     1       0          1  1  0
#> SRR1736356     1       0          1  1  0
#> SRR1736358     1       0          1  1  0
#> SRR1736357     1       0          1  1  0
#> SRR1736359     1       0          1  1  0
#> SRR1736360     1       0          1  1  0
#> SRR1736361     1       0          1  1  0
#> SRR1736362     1       0          1  1  0
#> SRR1736363     1       0          1  1  0
#> SRR1736365     1       0          1  1  0
#> SRR1736364     1       0          1  1  0
#> SRR1736366     1       0          1  1  0
#> SRR1736367     1       0          1  1  0
#> SRR1736368     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
#> SRR1736309     2   0.000      1.000 0.000  1 0.000
#> SRR1736310     2   0.000      1.000 0.000  1 0.000
#> SRR1736312     2   0.000      1.000 0.000  1 0.000
#> SRR1736311     2   0.000      1.000 0.000  1 0.000
#> SRR1736313     2   0.000      1.000 0.000  1 0.000
#> SRR1736314     2   0.000      1.000 0.000  1 0.000
#> SRR1736315     2   0.000      1.000 0.000  1 0.000
#> SRR1736316     2   0.000      1.000 0.000  1 0.000
#> SRR1736317     2   0.000      1.000 0.000  1 0.000
#> SRR1736318     2   0.000      1.000 0.000  1 0.000
#> SRR1736319     2   0.000      1.000 0.000  1 0.000
#> SRR1736320     2   0.000      1.000 0.000  1 0.000
#> SRR1736321     2   0.000      1.000 0.000  1 0.000
#> SRR1736322     2   0.000      1.000 0.000  1 0.000
#> SRR1736323     2   0.000      1.000 0.000  1 0.000
#> SRR1736324     2   0.000      1.000 0.000  1 0.000
#> SRR1736325     2   0.000      1.000 0.000  1 0.000
#> SRR1736326     2   0.000      1.000 0.000  1 0.000
#> SRR1736328     2   0.000      1.000 0.000  1 0.000
#> SRR1736327     2   0.000      1.000 0.000  1 0.000
#> SRR1736329     2   0.000      1.000 0.000  1 0.000
#> SRR1736330     2   0.000      1.000 0.000  1 0.000
#> SRR1736331     2   0.000      1.000 0.000  1 0.000
#> SRR1736332     2   0.000      1.000 0.000  1 0.000
#> SRR1736333     1   0.435      0.820 0.816  0 0.184
#> SRR1736334     1   0.435      0.820 0.816  0 0.184
#> SRR1736335     1   0.435      0.820 0.816  0 0.184
#> SRR1736337     1   0.435      0.820 0.816  0 0.184
#> SRR1736336     1   0.435      0.820 0.816  0 0.184
#> SRR1736338     1   0.435      0.820 0.816  0 0.184
#> SRR1736339     1   0.000      0.945 1.000  0 0.000
#> SRR1736340     1   0.000      0.945 1.000  0 0.000
#> SRR1736341     1   0.000      0.945 1.000  0 0.000
#> SRR1736342     1   0.000      0.945 1.000  0 0.000
#> SRR1736343     1   0.000      0.945 1.000  0 0.000
#> SRR1736344     1   0.000      0.945 1.000  0 0.000
#> SRR1736345     1   0.000      0.945 1.000  0 0.000
#> SRR1736346     1   0.000      0.945 1.000  0 0.000
#> SRR1736348     1   0.000      0.945 1.000  0 0.000
#> SRR1736347     1   0.000      0.945 1.000  0 0.000
#> SRR1736349     1   0.000      0.945 1.000  0 0.000
#> SRR1736350     1   0.000      0.945 1.000  0 0.000
#> SRR1736351     1   0.000      0.945 1.000  0 0.000
#> SRR1736352     1   0.000      0.945 1.000  0 0.000
#> SRR1736353     1   0.000      0.945 1.000  0 0.000
#> SRR1736354     1   0.000      0.945 1.000  0 0.000
#> SRR1736355     1   0.000      0.945 1.000  0 0.000
#> SRR1736356     3   0.579      0.529 0.332  0 0.668
#> SRR1736358     3   0.000      0.972 0.000  0 1.000
#> SRR1736357     3   0.000      0.972 0.000  0 1.000
#> SRR1736359     3   0.000      0.972 0.000  0 1.000
#> SRR1736360     3   0.000      0.972 0.000  0 1.000
#> SRR1736361     3   0.000      0.972 0.000  0 1.000
#> SRR1736362     3   0.000      0.972 0.000  0 1.000
#> SRR1736363     3   0.000      0.972 0.000  0 1.000
#> SRR1736365     3   0.000      0.972 0.000  0 1.000
#> SRR1736364     3   0.000      0.972 0.000  0 1.000
#> SRR1736366     3   0.000      0.972 0.000  0 1.000
#> SRR1736367     3   0.000      0.972 0.000  0 1.000
#> SRR1736368     3   0.000      0.972 0.000  0 1.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1 p2    p3    p4
#> SRR1736309     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR1736310     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR1736312     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR1736311     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR1736313     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR1736314     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR1736315     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR1736316     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR1736317     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR1736318     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR1736319     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR1736320     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR1736321     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR1736322     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR1736323     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR1736324     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR1736325     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR1736326     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR1736328     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR1736327     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR1736329     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR1736330     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR1736331     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR1736332     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR1736333     1  0.3836      0.814 0.816  0 0.016 0.168
#> SRR1736334     1  0.3836      0.814 0.816  0 0.016 0.168
#> SRR1736335     1  0.3836      0.814 0.816  0 0.016 0.168
#> SRR1736337     1  0.3836      0.814 0.816  0 0.016 0.168
#> SRR1736336     1  0.3836      0.814 0.816  0 0.016 0.168
#> SRR1736338     1  0.3836      0.814 0.816  0 0.016 0.168
#> SRR1736339     1  0.0000      0.938 1.000  0 0.000 0.000
#> SRR1736340     1  0.0000      0.938 1.000  0 0.000 0.000
#> SRR1736341     1  0.0000      0.938 1.000  0 0.000 0.000
#> SRR1736342     1  0.0188      0.937 0.996  0 0.000 0.004
#> SRR1736343     1  0.0188      0.937 0.996  0 0.000 0.004
#> SRR1736344     1  0.0188      0.937 0.996  0 0.000 0.004
#> SRR1736345     1  0.0000      0.938 1.000  0 0.000 0.000
#> SRR1736346     1  0.0000      0.938 1.000  0 0.000 0.000
#> SRR1736348     1  0.0188      0.937 0.996  0 0.000 0.004
#> SRR1736347     1  0.0000      0.938 1.000  0 0.000 0.000
#> SRR1736349     1  0.0188      0.937 0.996  0 0.000 0.004
#> SRR1736350     1  0.0188      0.937 0.996  0 0.000 0.004
#> SRR1736351     1  0.0000      0.938 1.000  0 0.000 0.000
#> SRR1736352     1  0.0000      0.938 1.000  0 0.000 0.000
#> SRR1736353     1  0.0000      0.938 1.000  0 0.000 0.000
#> SRR1736354     1  0.0188      0.937 0.996  0 0.000 0.004
#> SRR1736355     1  0.0188      0.937 0.996  0 0.000 0.004
#> SRR1736356     4  0.3266      0.000 0.168  0 0.000 0.832
#> SRR1736358     3  0.0000      1.000 0.000  0 1.000 0.000
#> SRR1736357     3  0.0000      1.000 0.000  0 1.000 0.000
#> SRR1736359     3  0.0000      1.000 0.000  0 1.000 0.000
#> SRR1736360     3  0.0000      1.000 0.000  0 1.000 0.000
#> SRR1736361     3  0.0000      1.000 0.000  0 1.000 0.000
#> SRR1736362     3  0.0000      1.000 0.000  0 1.000 0.000
#> SRR1736363     3  0.0000      1.000 0.000  0 1.000 0.000
#> SRR1736365     3  0.0000      1.000 0.000  0 1.000 0.000
#> SRR1736364     3  0.0000      1.000 0.000  0 1.000 0.000
#> SRR1736366     3  0.0000      1.000 0.000  0 1.000 0.000
#> SRR1736367     3  0.0000      1.000 0.000  0 1.000 0.000
#> SRR1736368     3  0.0000      1.000 0.000  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
#> SRR1736309     2   0.000      1.000 0.000 1.000  0 0.000 0.00
#> SRR1736310     2   0.000      1.000 0.000 1.000  0 0.000 0.00
#> SRR1736312     2   0.000      1.000 0.000 1.000  0 0.000 0.00
#> SRR1736311     2   0.000      1.000 0.000 1.000  0 0.000 0.00
#> SRR1736313     2   0.000      1.000 0.000 1.000  0 0.000 0.00
#> SRR1736314     2   0.000      1.000 0.000 1.000  0 0.000 0.00
#> SRR1736315     2   0.000      1.000 0.000 1.000  0 0.000 0.00
#> SRR1736316     2   0.000      1.000 0.000 1.000  0 0.000 0.00
#> SRR1736317     2   0.000      1.000 0.000 1.000  0 0.000 0.00
#> SRR1736318     2   0.000      1.000 0.000 1.000  0 0.000 0.00
#> SRR1736319     2   0.000      1.000 0.000 1.000  0 0.000 0.00
#> SRR1736320     2   0.000      1.000 0.000 1.000  0 0.000 0.00
#> SRR1736321     2   0.000      1.000 0.000 1.000  0 0.000 0.00
#> SRR1736322     2   0.000      1.000 0.000 1.000  0 0.000 0.00
#> SRR1736323     2   0.000      1.000 0.000 1.000  0 0.000 0.00
#> SRR1736324     2   0.000      1.000 0.000 1.000  0 0.000 0.00
#> SRR1736325     2   0.000      1.000 0.000 1.000  0 0.000 0.00
#> SRR1736326     2   0.000      1.000 0.000 1.000  0 0.000 0.00
#> SRR1736328     4   0.409      1.000 0.000 0.368  0 0.632 0.00
#> SRR1736327     4   0.409      1.000 0.000 0.368  0 0.632 0.00
#> SRR1736329     4   0.409      1.000 0.000 0.368  0 0.632 0.00
#> SRR1736330     4   0.409      1.000 0.000 0.368  0 0.632 0.00
#> SRR1736331     4   0.409      1.000 0.000 0.368  0 0.632 0.00
#> SRR1736332     4   0.409      1.000 0.000 0.368  0 0.632 0.00
#> SRR1736333     1   0.406      0.650 0.640 0.000  0 0.000 0.36
#> SRR1736334     1   0.406      0.650 0.640 0.000  0 0.000 0.36
#> SRR1736335     1   0.406      0.650 0.640 0.000  0 0.000 0.36
#> SRR1736337     1   0.406      0.650 0.640 0.000  0 0.000 0.36
#> SRR1736336     1   0.406      0.650 0.640 0.000  0 0.000 0.36
#> SRR1736338     1   0.406      0.650 0.640 0.000  0 0.000 0.36
#> SRR1736339     1   0.029      0.877 0.992 0.000  0 0.008 0.00
#> SRR1736340     1   0.029      0.877 0.992 0.000  0 0.008 0.00
#> SRR1736341     1   0.029      0.877 0.992 0.000  0 0.008 0.00
#> SRR1736342     1   0.112      0.876 0.956 0.000  0 0.044 0.00
#> SRR1736343     1   0.112      0.876 0.956 0.000  0 0.044 0.00
#> SRR1736344     1   0.112      0.876 0.956 0.000  0 0.044 0.00
#> SRR1736345     1   0.029      0.877 0.992 0.000  0 0.008 0.00
#> SRR1736346     1   0.029      0.877 0.992 0.000  0 0.008 0.00
#> SRR1736348     1   0.112      0.876 0.956 0.000  0 0.044 0.00
#> SRR1736347     1   0.029      0.877 0.992 0.000  0 0.008 0.00
#> SRR1736349     1   0.112      0.876 0.956 0.000  0 0.044 0.00
#> SRR1736350     1   0.112      0.876 0.956 0.000  0 0.044 0.00
#> SRR1736351     1   0.029      0.877 0.992 0.000  0 0.008 0.00
#> SRR1736352     1   0.029      0.877 0.992 0.000  0 0.008 0.00
#> SRR1736353     1   0.029      0.877 0.992 0.000  0 0.008 0.00
#> SRR1736354     1   0.112      0.876 0.956 0.000  0 0.044 0.00
#> SRR1736355     1   0.112      0.876 0.956 0.000  0 0.044 0.00
#> SRR1736356     5   0.406      0.000 0.000 0.000  0 0.360 0.64
#> SRR1736358     3   0.000      1.000 0.000 0.000  1 0.000 0.00
#> SRR1736357     3   0.000      1.000 0.000 0.000  1 0.000 0.00
#> SRR1736359     3   0.000      1.000 0.000 0.000  1 0.000 0.00
#> SRR1736360     3   0.000      1.000 0.000 0.000  1 0.000 0.00
#> SRR1736361     3   0.000      1.000 0.000 0.000  1 0.000 0.00
#> SRR1736362     3   0.000      1.000 0.000 0.000  1 0.000 0.00
#> SRR1736363     3   0.000      1.000 0.000 0.000  1 0.000 0.00
#> SRR1736365     3   0.000      1.000 0.000 0.000  1 0.000 0.00
#> SRR1736364     3   0.000      1.000 0.000 0.000  1 0.000 0.00
#> SRR1736366     3   0.000      1.000 0.000 0.000  1 0.000 0.00
#> SRR1736367     3   0.000      1.000 0.000 0.000  1 0.000 0.00
#> SRR1736368     3   0.000      1.000 0.000 0.000  1 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
#> SRR1736309     2  0.0000      1.000 0.000 1.0 0.000 0.0 0.000 0.0
#> SRR1736310     2  0.0000      1.000 0.000 1.0 0.000 0.0 0.000 0.0
#> SRR1736312     2  0.0000      1.000 0.000 1.0 0.000 0.0 0.000 0.0
#> SRR1736311     2  0.0000      1.000 0.000 1.0 0.000 0.0 0.000 0.0
#> SRR1736313     2  0.0000      1.000 0.000 1.0 0.000 0.0 0.000 0.0
#> SRR1736314     2  0.0000      1.000 0.000 1.0 0.000 0.0 0.000 0.0
#> SRR1736315     2  0.0000      1.000 0.000 1.0 0.000 0.0 0.000 0.0
#> SRR1736316     2  0.0000      1.000 0.000 1.0 0.000 0.0 0.000 0.0
#> SRR1736317     2  0.0000      1.000 0.000 1.0 0.000 0.0 0.000 0.0
#> SRR1736318     2  0.0000      1.000 0.000 1.0 0.000 0.0 0.000 0.0
#> SRR1736319     2  0.0000      1.000 0.000 1.0 0.000 0.0 0.000 0.0
#> SRR1736320     2  0.0000      1.000 0.000 1.0 0.000 0.0 0.000 0.0
#> SRR1736321     2  0.0000      1.000 0.000 1.0 0.000 0.0 0.000 0.0
#> SRR1736322     2  0.0000      1.000 0.000 1.0 0.000 0.0 0.000 0.0
#> SRR1736323     2  0.0000      1.000 0.000 1.0 0.000 0.0 0.000 0.0
#> SRR1736324     2  0.0000      1.000 0.000 1.0 0.000 0.0 0.000 0.0
#> SRR1736325     2  0.0000      1.000 0.000 1.0 0.000 0.0 0.000 0.0
#> SRR1736326     2  0.0000      1.000 0.000 1.0 0.000 0.0 0.000 0.0
#> SRR1736328     4  0.2793      1.000 0.000 0.2 0.000 0.8 0.000 0.0
#> SRR1736327     4  0.2793      1.000 0.000 0.2 0.000 0.8 0.000 0.0
#> SRR1736329     4  0.2793      1.000 0.000 0.2 0.000 0.8 0.000 0.0
#> SRR1736330     4  0.2793      1.000 0.000 0.2 0.000 0.8 0.000 0.0
#> SRR1736331     4  0.2793      1.000 0.000 0.2 0.000 0.8 0.000 0.0
#> SRR1736332     4  0.2793      1.000 0.000 0.2 0.000 0.8 0.000 0.0
#> SRR1736333     5  0.0146      1.000 0.004 0.0 0.000 0.0 0.996 0.0
#> SRR1736334     5  0.0146      1.000 0.004 0.0 0.000 0.0 0.996 0.0
#> SRR1736335     5  0.0146      1.000 0.004 0.0 0.000 0.0 0.996 0.0
#> SRR1736337     5  0.0146      1.000 0.004 0.0 0.000 0.0 0.996 0.0
#> SRR1736336     5  0.0146      1.000 0.004 0.0 0.000 0.0 0.996 0.0
#> SRR1736338     5  0.0146      1.000 0.004 0.0 0.000 0.0 0.996 0.0
#> SRR1736339     1  0.0000      0.892 1.000 0.0 0.000 0.0 0.000 0.0
#> SRR1736340     1  0.0000      0.892 1.000 0.0 0.000 0.0 0.000 0.0
#> SRR1736341     1  0.0000      0.892 1.000 0.0 0.000 0.0 0.000 0.0
#> SRR1736342     1  0.2933      0.877 0.796 0.0 0.000 0.0 0.004 0.2
#> SRR1736343     1  0.2933      0.877 0.796 0.0 0.000 0.0 0.004 0.2
#> SRR1736344     1  0.2933      0.877 0.796 0.0 0.000 0.0 0.004 0.2
#> SRR1736345     1  0.0000      0.892 1.000 0.0 0.000 0.0 0.000 0.0
#> SRR1736346     1  0.0000      0.892 1.000 0.0 0.000 0.0 0.000 0.0
#> SRR1736348     1  0.2933      0.877 0.796 0.0 0.000 0.0 0.004 0.2
#> SRR1736347     1  0.0000      0.892 1.000 0.0 0.000 0.0 0.000 0.0
#> SRR1736349     1  0.2933      0.877 0.796 0.0 0.000 0.0 0.004 0.2
#> SRR1736350     1  0.2933      0.877 0.796 0.0 0.000 0.0 0.004 0.2
#> SRR1736351     1  0.0000      0.892 1.000 0.0 0.000 0.0 0.000 0.0
#> SRR1736352     1  0.0000      0.892 1.000 0.0 0.000 0.0 0.000 0.0
#> SRR1736353     1  0.0000      0.892 1.000 0.0 0.000 0.0 0.000 0.0
#> SRR1736354     1  0.2933      0.877 0.796 0.0 0.000 0.0 0.004 0.2
#> SRR1736355     1  0.2933      0.877 0.796 0.0 0.000 0.0 0.004 0.2
#> SRR1736356     6  0.2793      0.000 0.000 0.0 0.000 0.2 0.000 0.8
#> SRR1736358     3  0.0000      0.999 0.000 0.0 1.000 0.0 0.000 0.0
#> SRR1736357     3  0.0000      0.999 0.000 0.0 1.000 0.0 0.000 0.0
#> SRR1736359     3  0.0000      0.999 0.000 0.0 1.000 0.0 0.000 0.0
#> SRR1736360     3  0.0146      0.997 0.000 0.0 0.996 0.0 0.004 0.0
#> SRR1736361     3  0.0146      0.997 0.000 0.0 0.996 0.0 0.004 0.0
#> SRR1736362     3  0.0146      0.997 0.000 0.0 0.996 0.0 0.004 0.0
#> SRR1736363     3  0.0000      0.999 0.000 0.0 1.000 0.0 0.000 0.0
#> SRR1736365     3  0.0000      0.999 0.000 0.0 1.000 0.0 0.000 0.0
#> SRR1736364     3  0.0000      0.999 0.000 0.0 1.000 0.0 0.000 0.0
#> SRR1736366     3  0.0000      0.999 0.000 0.0 1.000 0.0 0.000 0.0
#> SRR1736367     3  0.0000      0.999 0.000 0.0 1.000 0.0 0.000 0.0
#> SRR1736368     3  0.0000      0.999 0.000 0.0 1.000 0.0 0.000 0.0

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

consensus_heatmap(res, k = 2)

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

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

collect_plots(res)

plot of chunk CV-kmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.995       0.994         0.4865 0.512   0.512
#> 3 3 0.706           0.850       0.829         0.2686 0.837   0.682
#> 4 4 0.665           0.827       0.783         0.1346 0.939   0.825
#> 5 5 0.663           0.555       0.789         0.0604 0.987   0.955
#> 6 6 0.724           0.750       0.753         0.0595 0.933   0.764

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
#> SRR1736309     2   0.000      1.000 0.000 1.000
#> SRR1736310     2   0.000      1.000 0.000 1.000
#> SRR1736312     2   0.000      1.000 0.000 1.000
#> SRR1736311     2   0.000      1.000 0.000 1.000
#> SRR1736313     2   0.000      1.000 0.000 1.000
#> SRR1736314     2   0.000      1.000 0.000 1.000
#> SRR1736315     2   0.000      1.000 0.000 1.000
#> SRR1736316     2   0.000      1.000 0.000 1.000
#> SRR1736317     2   0.000      1.000 0.000 1.000
#> SRR1736318     2   0.000      1.000 0.000 1.000
#> SRR1736319     2   0.000      1.000 0.000 1.000
#> SRR1736320     2   0.000      1.000 0.000 1.000
#> SRR1736321     2   0.000      1.000 0.000 1.000
#> SRR1736322     2   0.000      1.000 0.000 1.000
#> SRR1736323     2   0.000      1.000 0.000 1.000
#> SRR1736324     2   0.000      1.000 0.000 1.000
#> SRR1736325     2   0.000      1.000 0.000 1.000
#> SRR1736326     2   0.000      1.000 0.000 1.000
#> SRR1736328     2   0.000      1.000 0.000 1.000
#> SRR1736327     2   0.000      1.000 0.000 1.000
#> SRR1736329     2   0.000      1.000 0.000 1.000
#> SRR1736330     2   0.000      1.000 0.000 1.000
#> SRR1736331     2   0.000      1.000 0.000 1.000
#> SRR1736332     2   0.000      1.000 0.000 1.000
#> SRR1736333     1   0.118      0.994 0.984 0.016
#> SRR1736334     1   0.118      0.994 0.984 0.016
#> SRR1736335     1   0.118      0.994 0.984 0.016
#> SRR1736337     1   0.118      0.994 0.984 0.016
#> SRR1736336     1   0.118      0.994 0.984 0.016
#> SRR1736338     1   0.118      0.994 0.984 0.016
#> SRR1736339     1   0.118      0.994 0.984 0.016
#> SRR1736340     1   0.118      0.994 0.984 0.016
#> SRR1736341     1   0.118      0.994 0.984 0.016
#> SRR1736342     1   0.118      0.994 0.984 0.016
#> SRR1736343     1   0.118      0.994 0.984 0.016
#> SRR1736344     1   0.118      0.994 0.984 0.016
#> SRR1736345     1   0.118      0.994 0.984 0.016
#> SRR1736346     1   0.118      0.994 0.984 0.016
#> SRR1736348     1   0.118      0.994 0.984 0.016
#> SRR1736347     1   0.118      0.994 0.984 0.016
#> SRR1736349     1   0.118      0.994 0.984 0.016
#> SRR1736350     1   0.118      0.994 0.984 0.016
#> SRR1736351     1   0.118      0.994 0.984 0.016
#> SRR1736352     1   0.118      0.994 0.984 0.016
#> SRR1736353     1   0.118      0.994 0.984 0.016
#> SRR1736354     1   0.118      0.994 0.984 0.016
#> SRR1736355     1   0.118      0.994 0.984 0.016
#> SRR1736356     1   0.000      0.989 1.000 0.000
#> SRR1736358     1   0.000      0.989 1.000 0.000
#> SRR1736357     1   0.000      0.989 1.000 0.000
#> SRR1736359     1   0.000      0.989 1.000 0.000
#> SRR1736360     1   0.000      0.989 1.000 0.000
#> SRR1736361     1   0.000      0.989 1.000 0.000
#> SRR1736362     1   0.000      0.989 1.000 0.000
#> SRR1736363     1   0.000      0.989 1.000 0.000
#> SRR1736365     1   0.000      0.989 1.000 0.000
#> SRR1736364     1   0.000      0.989 1.000 0.000
#> SRR1736366     1   0.000      0.989 1.000 0.000
#> SRR1736367     1   0.000      0.989 1.000 0.000
#> SRR1736368     1   0.000      0.989 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
#> SRR1736309     2  0.0000      0.920 0.000 1.000 0.000
#> SRR1736310     2  0.0000      0.920 0.000 1.000 0.000
#> SRR1736312     2  0.0000      0.920 0.000 1.000 0.000
#> SRR1736311     2  0.0000      0.920 0.000 1.000 0.000
#> SRR1736313     2  0.0000      0.920 0.000 1.000 0.000
#> SRR1736314     2  0.0000      0.920 0.000 1.000 0.000
#> SRR1736315     2  0.0424      0.918 0.000 0.992 0.008
#> SRR1736316     2  0.0424      0.918 0.000 0.992 0.008
#> SRR1736317     2  0.0424      0.918 0.000 0.992 0.008
#> SRR1736318     2  0.0000      0.920 0.000 1.000 0.000
#> SRR1736319     2  0.0000      0.920 0.000 1.000 0.000
#> SRR1736320     2  0.0000      0.920 0.000 1.000 0.000
#> SRR1736321     2  0.0424      0.918 0.000 0.992 0.008
#> SRR1736322     2  0.0424      0.918 0.000 0.992 0.008
#> SRR1736323     2  0.0424      0.918 0.000 0.992 0.008
#> SRR1736324     2  0.0000      0.920 0.000 1.000 0.000
#> SRR1736325     2  0.0000      0.920 0.000 1.000 0.000
#> SRR1736326     2  0.0000      0.920 0.000 1.000 0.000
#> SRR1736328     2  0.6026      0.738 0.000 0.624 0.376
#> SRR1736327     2  0.6026      0.738 0.000 0.624 0.376
#> SRR1736329     2  0.6026      0.738 0.000 0.624 0.376
#> SRR1736330     2  0.6026      0.738 0.000 0.624 0.376
#> SRR1736331     2  0.6026      0.738 0.000 0.624 0.376
#> SRR1736332     2  0.6026      0.738 0.000 0.624 0.376
#> SRR1736333     1  0.5058      0.474 0.756 0.000 0.244
#> SRR1736334     1  0.5058      0.474 0.756 0.000 0.244
#> SRR1736335     1  0.5058      0.474 0.756 0.000 0.244
#> SRR1736337     1  0.5058      0.474 0.756 0.000 0.244
#> SRR1736336     1  0.5058      0.474 0.756 0.000 0.244
#> SRR1736338     1  0.5058      0.474 0.756 0.000 0.244
#> SRR1736339     1  0.1411      0.852 0.964 0.000 0.036
#> SRR1736340     1  0.1411      0.852 0.964 0.000 0.036
#> SRR1736341     1  0.1411      0.852 0.964 0.000 0.036
#> SRR1736342     1  0.0000      0.852 1.000 0.000 0.000
#> SRR1736343     1  0.0000      0.852 1.000 0.000 0.000
#> SRR1736344     1  0.0000      0.852 1.000 0.000 0.000
#> SRR1736345     1  0.1411      0.852 0.964 0.000 0.036
#> SRR1736346     1  0.1411      0.852 0.964 0.000 0.036
#> SRR1736348     1  0.0000      0.852 1.000 0.000 0.000
#> SRR1736347     1  0.1411      0.852 0.964 0.000 0.036
#> SRR1736349     1  0.0000      0.852 1.000 0.000 0.000
#> SRR1736350     1  0.0000      0.852 1.000 0.000 0.000
#> SRR1736351     1  0.1411      0.852 0.964 0.000 0.036
#> SRR1736352     1  0.1411      0.852 0.964 0.000 0.036
#> SRR1736353     1  0.1411      0.852 0.964 0.000 0.036
#> SRR1736354     1  0.0000      0.852 1.000 0.000 0.000
#> SRR1736355     1  0.0000      0.852 1.000 0.000 0.000
#> SRR1736356     1  0.3038      0.758 0.896 0.000 0.104
#> SRR1736358     3  0.6111      0.998 0.396 0.000 0.604
#> SRR1736357     3  0.6111      0.998 0.396 0.000 0.604
#> SRR1736359     3  0.6111      0.998 0.396 0.000 0.604
#> SRR1736360     3  0.6095      0.993 0.392 0.000 0.608
#> SRR1736361     3  0.6095      0.993 0.392 0.000 0.608
#> SRR1736362     3  0.6095      0.993 0.392 0.000 0.608
#> SRR1736363     3  0.6111      0.998 0.396 0.000 0.604
#> SRR1736365     3  0.6111      0.998 0.396 0.000 0.604
#> SRR1736364     3  0.6111      0.998 0.396 0.000 0.604
#> SRR1736366     3  0.6111      0.998 0.396 0.000 0.604
#> SRR1736367     3  0.6111      0.998 0.396 0.000 0.604
#> SRR1736368     3  0.6111      0.998 0.396 0.000 0.604

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1736309     2   0.000      0.939 0.000 1.000 0.000 0.000
#> SRR1736310     2   0.000      0.939 0.000 1.000 0.000 0.000
#> SRR1736312     2   0.000      0.939 0.000 1.000 0.000 0.000
#> SRR1736311     2   0.000      0.939 0.000 1.000 0.000 0.000
#> SRR1736313     2   0.000      0.939 0.000 1.000 0.000 0.000
#> SRR1736314     2   0.000      0.939 0.000 1.000 0.000 0.000
#> SRR1736315     2   0.240      0.873 0.000 0.904 0.092 0.004
#> SRR1736316     2   0.240      0.873 0.000 0.904 0.092 0.004
#> SRR1736317     2   0.240      0.873 0.000 0.904 0.092 0.004
#> SRR1736318     2   0.000      0.939 0.000 1.000 0.000 0.000
#> SRR1736319     2   0.000      0.939 0.000 1.000 0.000 0.000
#> SRR1736320     2   0.000      0.939 0.000 1.000 0.000 0.000
#> SRR1736321     2   0.240      0.873 0.000 0.904 0.092 0.004
#> SRR1736322     2   0.240      0.873 0.000 0.904 0.092 0.004
#> SRR1736323     2   0.240      0.873 0.000 0.904 0.092 0.004
#> SRR1736324     2   0.000      0.939 0.000 1.000 0.000 0.000
#> SRR1736325     2   0.000      0.939 0.000 1.000 0.000 0.000
#> SRR1736326     2   0.000      0.939 0.000 1.000 0.000 0.000
#> SRR1736328     4   0.517      0.992 0.000 0.492 0.004 0.504
#> SRR1736327     4   0.530      0.990 0.000 0.492 0.008 0.500
#> SRR1736329     4   0.541      0.989 0.000 0.492 0.012 0.496
#> SRR1736330     4   0.500      0.992 0.000 0.492 0.000 0.508
#> SRR1736331     4   0.530      0.990 0.000 0.492 0.008 0.500
#> SRR1736332     4   0.530      0.990 0.000 0.492 0.008 0.500
#> SRR1736333     1   0.755      0.412 0.488 0.000 0.276 0.236
#> SRR1736334     1   0.755      0.412 0.488 0.000 0.276 0.236
#> SRR1736335     1   0.755      0.412 0.488 0.000 0.276 0.236
#> SRR1736337     1   0.755      0.412 0.488 0.000 0.276 0.236
#> SRR1736336     1   0.755      0.412 0.488 0.000 0.276 0.236
#> SRR1736338     1   0.755      0.412 0.488 0.000 0.276 0.236
#> SRR1736339     1   0.121      0.732 0.960 0.000 0.040 0.000
#> SRR1736340     1   0.121      0.732 0.960 0.000 0.040 0.000
#> SRR1736341     1   0.121      0.732 0.960 0.000 0.040 0.000
#> SRR1736342     1   0.407      0.745 0.748 0.000 0.000 0.252
#> SRR1736343     1   0.407      0.745 0.748 0.000 0.000 0.252
#> SRR1736344     1   0.407      0.745 0.748 0.000 0.000 0.252
#> SRR1736345     1   0.121      0.732 0.960 0.000 0.040 0.000
#> SRR1736346     1   0.121      0.732 0.960 0.000 0.040 0.000
#> SRR1736348     1   0.407      0.745 0.748 0.000 0.000 0.252
#> SRR1736347     1   0.121      0.732 0.960 0.000 0.040 0.000
#> SRR1736349     1   0.407      0.745 0.748 0.000 0.000 0.252
#> SRR1736350     1   0.407      0.745 0.748 0.000 0.000 0.252
#> SRR1736351     1   0.180      0.732 0.944 0.000 0.040 0.016
#> SRR1736352     1   0.180      0.732 0.944 0.000 0.040 0.016
#> SRR1736353     1   0.180      0.732 0.944 0.000 0.040 0.016
#> SRR1736354     1   0.407      0.745 0.748 0.000 0.000 0.252
#> SRR1736355     1   0.407      0.745 0.748 0.000 0.000 0.252
#> SRR1736356     1   0.678      0.612 0.572 0.000 0.124 0.304
#> SRR1736358     3   0.462      0.948 0.128 0.000 0.796 0.076
#> SRR1736357     3   0.462      0.948 0.128 0.000 0.796 0.076
#> SRR1736359     3   0.462      0.948 0.128 0.000 0.796 0.076
#> SRR1736360     3   0.362      0.958 0.112 0.000 0.852 0.036
#> SRR1736361     3   0.362      0.958 0.112 0.000 0.852 0.036
#> SRR1736362     3   0.362      0.958 0.112 0.000 0.852 0.036
#> SRR1736363     3   0.276      0.970 0.128 0.000 0.872 0.000
#> SRR1736365     3   0.276      0.970 0.128 0.000 0.872 0.000
#> SRR1736364     3   0.276      0.970 0.128 0.000 0.872 0.000
#> SRR1736366     3   0.276      0.970 0.128 0.000 0.872 0.000
#> SRR1736367     3   0.276      0.970 0.128 0.000 0.872 0.000
#> SRR1736368     3   0.276      0.970 0.128 0.000 0.872 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
#> SRR1736309     2  0.1341     0.8337 0.000 0.944 0.056 0.000 0.000
#> SRR1736310     2  0.1043     0.8383 0.000 0.960 0.040 0.000 0.000
#> SRR1736312     2  0.1043     0.8383 0.000 0.960 0.040 0.000 0.000
#> SRR1736311     2  0.1043     0.8383 0.000 0.960 0.040 0.000 0.000
#> SRR1736313     2  0.1341     0.8337 0.000 0.944 0.056 0.000 0.000
#> SRR1736314     2  0.1043     0.8383 0.000 0.960 0.040 0.000 0.000
#> SRR1736315     2  0.3837     0.6813 0.000 0.692 0.000 0.000 0.308
#> SRR1736316     2  0.3837     0.6813 0.000 0.692 0.000 0.000 0.308
#> SRR1736317     2  0.3837     0.6813 0.000 0.692 0.000 0.000 0.308
#> SRR1736318     2  0.0000     0.8391 0.000 1.000 0.000 0.000 0.000
#> SRR1736319     2  0.0000     0.8391 0.000 1.000 0.000 0.000 0.000
#> SRR1736320     2  0.0000     0.8391 0.000 1.000 0.000 0.000 0.000
#> SRR1736321     2  0.4227     0.6813 0.000 0.692 0.016 0.000 0.292
#> SRR1736322     2  0.4227     0.6813 0.000 0.692 0.016 0.000 0.292
#> SRR1736323     2  0.4227     0.6813 0.000 0.692 0.016 0.000 0.292
#> SRR1736324     2  0.0000     0.8391 0.000 1.000 0.000 0.000 0.000
#> SRR1736325     2  0.0162     0.8390 0.000 0.996 0.004 0.000 0.000
#> SRR1736326     2  0.0162     0.8390 0.000 0.996 0.004 0.000 0.000
#> SRR1736328     4  0.3969     0.9892 0.000 0.304 0.004 0.692 0.000
#> SRR1736327     4  0.4442     0.9850 0.000 0.304 0.004 0.676 0.016
#> SRR1736329     4  0.4560     0.9839 0.000 0.304 0.008 0.672 0.016
#> SRR1736330     4  0.4240     0.9856 0.000 0.304 0.004 0.684 0.008
#> SRR1736331     4  0.3969     0.9892 0.000 0.304 0.000 0.692 0.004
#> SRR1736332     4  0.3969     0.9892 0.000 0.304 0.000 0.692 0.004
#> SRR1736333     1  0.8318     0.0915 0.388 0.000 0.196 0.192 0.224
#> SRR1736334     1  0.8318     0.0915 0.388 0.000 0.196 0.192 0.224
#> SRR1736335     1  0.8318     0.0915 0.388 0.000 0.196 0.192 0.224
#> SRR1736337     1  0.8318     0.0915 0.388 0.000 0.196 0.192 0.224
#> SRR1736336     1  0.8318     0.0915 0.388 0.000 0.196 0.192 0.224
#> SRR1736338     1  0.8318     0.0915 0.388 0.000 0.196 0.192 0.224
#> SRR1736339     1  0.0794     0.2994 0.972 0.000 0.028 0.000 0.000
#> SRR1736340     1  0.0794     0.2994 0.972 0.000 0.028 0.000 0.000
#> SRR1736341     1  0.0794     0.2994 0.972 0.000 0.028 0.000 0.000
#> SRR1736342     1  0.4088    -0.1471 0.632 0.000 0.000 0.000 0.368
#> SRR1736343     1  0.4088    -0.1471 0.632 0.000 0.000 0.000 0.368
#> SRR1736344     1  0.4088    -0.1471 0.632 0.000 0.000 0.000 0.368
#> SRR1736345     1  0.0794     0.2994 0.972 0.000 0.028 0.000 0.000
#> SRR1736346     1  0.0794     0.2994 0.972 0.000 0.028 0.000 0.000
#> SRR1736348     1  0.4088    -0.1471 0.632 0.000 0.000 0.000 0.368
#> SRR1736347     1  0.0794     0.2994 0.972 0.000 0.028 0.000 0.000
#> SRR1736349     1  0.4088    -0.1471 0.632 0.000 0.000 0.000 0.368
#> SRR1736350     1  0.4088    -0.1471 0.632 0.000 0.000 0.000 0.368
#> SRR1736351     1  0.1799     0.2842 0.940 0.000 0.028 0.020 0.012
#> SRR1736352     1  0.1799     0.2842 0.940 0.000 0.028 0.020 0.012
#> SRR1736353     1  0.1799     0.2842 0.940 0.000 0.028 0.020 0.012
#> SRR1736354     1  0.4088    -0.1471 0.632 0.000 0.000 0.000 0.368
#> SRR1736355     1  0.4088    -0.1471 0.632 0.000 0.000 0.000 0.368
#> SRR1736356     5  0.6236     0.0000 0.408 0.000 0.056 0.040 0.496
#> SRR1736358     3  0.4654     0.9028 0.096 0.000 0.784 0.044 0.076
#> SRR1736357     3  0.4654     0.9028 0.096 0.000 0.784 0.044 0.076
#> SRR1736359     3  0.4654     0.9028 0.096 0.000 0.784 0.044 0.076
#> SRR1736360     3  0.3986     0.9273 0.096 0.000 0.824 0.036 0.044
#> SRR1736361     3  0.3986     0.9273 0.096 0.000 0.824 0.036 0.044
#> SRR1736362     3  0.3986     0.9273 0.096 0.000 0.824 0.036 0.044
#> SRR1736363     3  0.1965     0.9494 0.096 0.000 0.904 0.000 0.000
#> SRR1736365     3  0.1965     0.9494 0.096 0.000 0.904 0.000 0.000
#> SRR1736364     3  0.1965     0.9494 0.096 0.000 0.904 0.000 0.000
#> SRR1736366     3  0.1965     0.9494 0.096 0.000 0.904 0.000 0.000
#> SRR1736367     3  0.1965     0.9494 0.096 0.000 0.904 0.000 0.000
#> SRR1736368     3  0.1965     0.9494 0.096 0.000 0.904 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
#> SRR1736309     2  0.1501      0.791 0.000 0.924 0.000 0.000 0.076 NA
#> SRR1736310     2  0.1204      0.794 0.000 0.944 0.000 0.000 0.056 NA
#> SRR1736312     2  0.1327      0.793 0.000 0.936 0.000 0.000 0.064 NA
#> SRR1736311     2  0.1327      0.793 0.000 0.936 0.000 0.000 0.064 NA
#> SRR1736313     2  0.1501      0.791 0.000 0.924 0.000 0.000 0.076 NA
#> SRR1736314     2  0.1204      0.794 0.000 0.944 0.000 0.000 0.056 NA
#> SRR1736315     2  0.4680      0.580 0.000 0.564 0.008 0.000 0.032 NA
#> SRR1736316     2  0.4680      0.580 0.000 0.564 0.008 0.000 0.032 NA
#> SRR1736317     2  0.4680      0.580 0.000 0.564 0.008 0.000 0.032 NA
#> SRR1736318     2  0.0000      0.795 0.000 1.000 0.000 0.000 0.000 NA
#> SRR1736319     2  0.0000      0.795 0.000 1.000 0.000 0.000 0.000 NA
#> SRR1736320     2  0.0000      0.795 0.000 1.000 0.000 0.000 0.000 NA
#> SRR1736321     2  0.3823      0.580 0.000 0.564 0.000 0.000 0.000 NA
#> SRR1736322     2  0.3823      0.580 0.000 0.564 0.000 0.000 0.000 NA
#> SRR1736323     2  0.3823      0.580 0.000 0.564 0.000 0.000 0.000 NA
#> SRR1736324     2  0.0000      0.795 0.000 1.000 0.000 0.000 0.000 NA
#> SRR1736325     2  0.0000      0.795 0.000 1.000 0.000 0.000 0.000 NA
#> SRR1736326     2  0.0000      0.795 0.000 1.000 0.000 0.000 0.000 NA
#> SRR1736328     4  0.3401      0.974 0.000 0.204 0.000 0.776 0.004 NA
#> SRR1736327     4  0.4096      0.965 0.000 0.204 0.000 0.744 0.028 NA
#> SRR1736329     4  0.4242      0.963 0.000 0.204 0.000 0.736 0.028 NA
#> SRR1736330     4  0.3323      0.974 0.000 0.204 0.000 0.780 0.008 NA
#> SRR1736331     4  0.3354      0.974 0.000 0.204 0.004 0.780 0.004 NA
#> SRR1736332     4  0.3354      0.974 0.000 0.204 0.004 0.780 0.004 NA
#> SRR1736333     5  0.6111      0.993 0.312 0.000 0.188 0.016 0.484 NA
#> SRR1736334     5  0.6032      0.992 0.312 0.000 0.188 0.000 0.488 NA
#> SRR1736335     5  0.6075      0.993 0.312 0.000 0.188 0.008 0.488 NA
#> SRR1736337     5  0.6032      0.992 0.312 0.000 0.188 0.000 0.488 NA
#> SRR1736336     5  0.6162      0.993 0.312 0.000 0.188 0.012 0.484 NA
#> SRR1736338     5  0.6111      0.993 0.312 0.000 0.188 0.016 0.484 NA
#> SRR1736339     1  0.6887      0.563 0.424 0.000 0.012 0.104 0.372 NA
#> SRR1736340     1  0.6887      0.563 0.424 0.000 0.012 0.104 0.372 NA
#> SRR1736341     1  0.6887      0.563 0.424 0.000 0.012 0.104 0.372 NA
#> SRR1736342     1  0.0000      0.521 1.000 0.000 0.000 0.000 0.000 NA
#> SRR1736343     1  0.0000      0.521 1.000 0.000 0.000 0.000 0.000 NA
#> SRR1736344     1  0.0000      0.521 1.000 0.000 0.000 0.000 0.000 NA
#> SRR1736345     1  0.6887      0.563 0.424 0.000 0.012 0.104 0.372 NA
#> SRR1736346     1  0.6887      0.563 0.424 0.000 0.012 0.104 0.372 NA
#> SRR1736348     1  0.0363      0.521 0.988 0.000 0.000 0.012 0.000 NA
#> SRR1736347     1  0.6887      0.563 0.424 0.000 0.012 0.104 0.372 NA
#> SRR1736349     1  0.0363      0.521 0.988 0.000 0.000 0.012 0.000 NA
#> SRR1736350     1  0.0363      0.521 0.988 0.000 0.000 0.012 0.000 NA
#> SRR1736351     1  0.7281      0.556 0.436 0.000 0.012 0.136 0.292 NA
#> SRR1736352     1  0.7281      0.556 0.436 0.000 0.012 0.136 0.292 NA
#> SRR1736353     1  0.7281      0.556 0.436 0.000 0.012 0.136 0.292 NA
#> SRR1736354     1  0.0692      0.517 0.976 0.000 0.000 0.004 0.000 NA
#> SRR1736355     1  0.0692      0.517 0.976 0.000 0.000 0.004 0.000 NA
#> SRR1736356     1  0.5463      0.252 0.640 0.000 0.040 0.020 0.044 NA
#> SRR1736358     3  0.3626      0.855 0.020 0.000 0.800 0.000 0.032 NA
#> SRR1736357     3  0.3626      0.855 0.020 0.000 0.800 0.000 0.032 NA
#> SRR1736359     3  0.3626      0.855 0.020 0.000 0.800 0.000 0.032 NA
#> SRR1736360     3  0.3116      0.881 0.012 0.000 0.856 0.008 0.036 NA
#> SRR1736361     3  0.3116      0.881 0.012 0.000 0.856 0.008 0.036 NA
#> SRR1736362     3  0.3116      0.881 0.012 0.000 0.856 0.008 0.036 NA
#> SRR1736363     3  0.0547      0.920 0.020 0.000 0.980 0.000 0.000 NA
#> SRR1736365     3  0.0547      0.920 0.020 0.000 0.980 0.000 0.000 NA
#> SRR1736364     3  0.0547      0.920 0.020 0.000 0.980 0.000 0.000 NA
#> SRR1736366     3  0.0547      0.920 0.020 0.000 0.980 0.000 0.000 NA
#> SRR1736367     3  0.0547      0.920 0.020 0.000 0.980 0.000 0.000 NA
#> SRR1736368     3  0.0547      0.920 0.020 0.000 0.980 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-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 15454 rows and 60 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#>   Subgroups are detected by 'skmeans' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 6.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk CV-skmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4886 0.512   0.512
#> 3 3 0.898           0.914       0.960         0.3520 0.837   0.682
#> 4 4 0.930           0.886       0.919         0.0884 0.939   0.825
#> 5 5 0.855           0.739       0.755         0.0709 0.832   0.519
#> 6 6 0.995           0.978       0.961         0.0572 0.939   0.748

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette p1 p2
#> SRR1736309     2       0          1  0  1
#> SRR1736310     2       0          1  0  1
#> SRR1736312     2       0          1  0  1
#> SRR1736311     2       0          1  0  1
#> SRR1736313     2       0          1  0  1
#> SRR1736314     2       0          1  0  1
#> SRR1736315     2       0          1  0  1
#> SRR1736316     2       0          1  0  1
#> SRR1736317     2       0          1  0  1
#> SRR1736318     2       0          1  0  1
#> SRR1736319     2       0          1  0  1
#> SRR1736320     2       0          1  0  1
#> SRR1736321     2       0          1  0  1
#> SRR1736322     2       0          1  0  1
#> SRR1736323     2       0          1  0  1
#> SRR1736324     2       0          1  0  1
#> SRR1736325     2       0          1  0  1
#> SRR1736326     2       0          1  0  1
#> SRR1736328     2       0          1  0  1
#> SRR1736327     2       0          1  0  1
#> SRR1736329     2       0          1  0  1
#> SRR1736330     2       0          1  0  1
#> SRR1736331     2       0          1  0  1
#> SRR1736332     2       0          1  0  1
#> SRR1736333     1       0          1  1  0
#> SRR1736334     1       0          1  1  0
#> SRR1736335     1       0          1  1  0
#> SRR1736337     1       0          1  1  0
#> SRR1736336     1       0          1  1  0
#> SRR1736338     1       0          1  1  0
#> SRR1736339     1       0          1  1  0
#> SRR1736340     1       0          1  1  0
#> SRR1736341     1       0          1  1  0
#> SRR1736342     1       0          1  1  0
#> SRR1736343     1       0          1  1  0
#> SRR1736344     1       0          1  1  0
#> SRR1736345     1       0          1  1  0
#> SRR1736346     1       0          1  1  0
#> SRR1736348     1       0          1  1  0
#> SRR1736347     1       0          1  1  0
#> SRR1736349     1       0          1  1  0
#> SRR1736350     1       0          1  1  0
#> SRR1736351     1       0          1  1  0
#> SRR1736352     1       0          1  1  0
#> SRR1736353     1       0          1  1  0
#> SRR1736354     1       0          1  1  0
#> SRR1736355     1       0          1  1  0
#> SRR1736356     1       0          1  1  0
#> SRR1736358     1       0          1  1  0
#> SRR1736357     1       0          1  1  0
#> SRR1736359     1       0          1  1  0
#> SRR1736360     1       0          1  1  0
#> SRR1736361     1       0          1  1  0
#> SRR1736362     1       0          1  1  0
#> SRR1736363     1       0          1  1  0
#> SRR1736365     1       0          1  1  0
#> SRR1736364     1       0          1  1  0
#> SRR1736366     1       0          1  1  0
#> SRR1736367     1       0          1  1  0
#> SRR1736368     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
#> SRR1736309     2   0.000      1.000 0.000  1 0.000
#> SRR1736310     2   0.000      1.000 0.000  1 0.000
#> SRR1736312     2   0.000      1.000 0.000  1 0.000
#> SRR1736311     2   0.000      1.000 0.000  1 0.000
#> SRR1736313     2   0.000      1.000 0.000  1 0.000
#> SRR1736314     2   0.000      1.000 0.000  1 0.000
#> SRR1736315     2   0.000      1.000 0.000  1 0.000
#> SRR1736316     2   0.000      1.000 0.000  1 0.000
#> SRR1736317     2   0.000      1.000 0.000  1 0.000
#> SRR1736318     2   0.000      1.000 0.000  1 0.000
#> SRR1736319     2   0.000      1.000 0.000  1 0.000
#> SRR1736320     2   0.000      1.000 0.000  1 0.000
#> SRR1736321     2   0.000      1.000 0.000  1 0.000
#> SRR1736322     2   0.000      1.000 0.000  1 0.000
#> SRR1736323     2   0.000      1.000 0.000  1 0.000
#> SRR1736324     2   0.000      1.000 0.000  1 0.000
#> SRR1736325     2   0.000      1.000 0.000  1 0.000
#> SRR1736326     2   0.000      1.000 0.000  1 0.000
#> SRR1736328     2   0.000      1.000 0.000  1 0.000
#> SRR1736327     2   0.000      1.000 0.000  1 0.000
#> SRR1736329     2   0.000      1.000 0.000  1 0.000
#> SRR1736330     2   0.000      1.000 0.000  1 0.000
#> SRR1736331     2   0.000      1.000 0.000  1 0.000
#> SRR1736332     2   0.000      1.000 0.000  1 0.000
#> SRR1736333     1   0.573      0.617 0.676  0 0.324
#> SRR1736334     1   0.573      0.617 0.676  0 0.324
#> SRR1736335     1   0.573      0.617 0.676  0 0.324
#> SRR1736337     1   0.573      0.617 0.676  0 0.324
#> SRR1736336     1   0.573      0.617 0.676  0 0.324
#> SRR1736338     1   0.573      0.617 0.676  0 0.324
#> SRR1736339     1   0.000      0.885 1.000  0 0.000
#> SRR1736340     1   0.000      0.885 1.000  0 0.000
#> SRR1736341     1   0.000      0.885 1.000  0 0.000
#> SRR1736342     1   0.000      0.885 1.000  0 0.000
#> SRR1736343     1   0.000      0.885 1.000  0 0.000
#> SRR1736344     1   0.000      0.885 1.000  0 0.000
#> SRR1736345     1   0.000      0.885 1.000  0 0.000
#> SRR1736346     1   0.000      0.885 1.000  0 0.000
#> SRR1736348     1   0.000      0.885 1.000  0 0.000
#> SRR1736347     1   0.000      0.885 1.000  0 0.000
#> SRR1736349     1   0.000      0.885 1.000  0 0.000
#> SRR1736350     1   0.000      0.885 1.000  0 0.000
#> SRR1736351     1   0.000      0.885 1.000  0 0.000
#> SRR1736352     1   0.000      0.885 1.000  0 0.000
#> SRR1736353     1   0.000      0.885 1.000  0 0.000
#> SRR1736354     1   0.000      0.885 1.000  0 0.000
#> SRR1736355     1   0.000      0.885 1.000  0 0.000
#> SRR1736356     1   0.629      0.106 0.536  0 0.464
#> SRR1736358     3   0.000      1.000 0.000  0 1.000
#> SRR1736357     3   0.000      1.000 0.000  0 1.000
#> SRR1736359     3   0.000      1.000 0.000  0 1.000
#> SRR1736360     3   0.000      1.000 0.000  0 1.000
#> SRR1736361     3   0.000      1.000 0.000  0 1.000
#> SRR1736362     3   0.000      1.000 0.000  0 1.000
#> SRR1736363     3   0.000      1.000 0.000  0 1.000
#> SRR1736365     3   0.000      1.000 0.000  0 1.000
#> SRR1736364     3   0.000      1.000 0.000  0 1.000
#> SRR1736366     3   0.000      1.000 0.000  0 1.000
#> SRR1736367     3   0.000      1.000 0.000  0 1.000
#> SRR1736368     3   0.000      1.000 0.000  0 1.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1736309     2   0.000      0.981 0.000 1.000 0.000 0.000
#> SRR1736310     2   0.000      0.981 0.000 1.000 0.000 0.000
#> SRR1736312     2   0.000      0.981 0.000 1.000 0.000 0.000
#> SRR1736311     2   0.000      0.981 0.000 1.000 0.000 0.000
#> SRR1736313     2   0.000      0.981 0.000 1.000 0.000 0.000
#> SRR1736314     2   0.000      0.981 0.000 1.000 0.000 0.000
#> SRR1736315     2   0.000      0.981 0.000 1.000 0.000 0.000
#> SRR1736316     2   0.000      0.981 0.000 1.000 0.000 0.000
#> SRR1736317     2   0.000      0.981 0.000 1.000 0.000 0.000
#> SRR1736318     2   0.000      0.981 0.000 1.000 0.000 0.000
#> SRR1736319     2   0.000      0.981 0.000 1.000 0.000 0.000
#> SRR1736320     2   0.000      0.981 0.000 1.000 0.000 0.000
#> SRR1736321     2   0.000      0.981 0.000 1.000 0.000 0.000
#> SRR1736322     2   0.000      0.981 0.000 1.000 0.000 0.000
#> SRR1736323     2   0.000      0.981 0.000 1.000 0.000 0.000
#> SRR1736324     2   0.000      0.981 0.000 1.000 0.000 0.000
#> SRR1736325     2   0.000      0.981 0.000 1.000 0.000 0.000
#> SRR1736326     2   0.000      0.981 0.000 1.000 0.000 0.000
#> SRR1736328     2   0.208      0.940 0.000 0.916 0.000 0.084
#> SRR1736327     2   0.208      0.940 0.000 0.916 0.000 0.084
#> SRR1736329     2   0.208      0.940 0.000 0.916 0.000 0.084
#> SRR1736330     2   0.208      0.940 0.000 0.916 0.000 0.084
#> SRR1736331     2   0.208      0.940 0.000 0.916 0.000 0.084
#> SRR1736332     2   0.208      0.940 0.000 0.916 0.000 0.084
#> SRR1736333     4   0.606      1.000 0.400 0.000 0.048 0.552
#> SRR1736334     4   0.606      1.000 0.400 0.000 0.048 0.552
#> SRR1736335     4   0.606      1.000 0.400 0.000 0.048 0.552
#> SRR1736337     4   0.606      1.000 0.400 0.000 0.048 0.552
#> SRR1736336     4   0.606      1.000 0.400 0.000 0.048 0.552
#> SRR1736338     4   0.606      1.000 0.400 0.000 0.048 0.552
#> SRR1736339     1   0.475      0.739 0.632 0.000 0.000 0.368
#> SRR1736340     1   0.475      0.739 0.632 0.000 0.000 0.368
#> SRR1736341     1   0.475      0.739 0.632 0.000 0.000 0.368
#> SRR1736342     1   0.000      0.635 1.000 0.000 0.000 0.000
#> SRR1736343     1   0.000      0.635 1.000 0.000 0.000 0.000
#> SRR1736344     1   0.000      0.635 1.000 0.000 0.000 0.000
#> SRR1736345     1   0.475      0.739 0.632 0.000 0.000 0.368
#> SRR1736346     1   0.475      0.739 0.632 0.000 0.000 0.368
#> SRR1736348     1   0.000      0.635 1.000 0.000 0.000 0.000
#> SRR1736347     1   0.475      0.739 0.632 0.000 0.000 0.368
#> SRR1736349     1   0.000      0.635 1.000 0.000 0.000 0.000
#> SRR1736350     1   0.000      0.635 1.000 0.000 0.000 0.000
#> SRR1736351     1   0.475      0.739 0.632 0.000 0.000 0.368
#> SRR1736352     1   0.475      0.739 0.632 0.000 0.000 0.368
#> SRR1736353     1   0.475      0.739 0.632 0.000 0.000 0.368
#> SRR1736354     1   0.000      0.635 1.000 0.000 0.000 0.000
#> SRR1736355     1   0.000      0.635 1.000 0.000 0.000 0.000
#> SRR1736356     1   0.483      0.150 0.608 0.000 0.392 0.000
#> SRR1736358     3   0.000      1.000 0.000 0.000 1.000 0.000
#> SRR1736357     3   0.000      1.000 0.000 0.000 1.000 0.000
#> SRR1736359     3   0.000      1.000 0.000 0.000 1.000 0.000
#> SRR1736360     3   0.000      1.000 0.000 0.000 1.000 0.000
#> SRR1736361     3   0.000      1.000 0.000 0.000 1.000 0.000
#> SRR1736362     3   0.000      1.000 0.000 0.000 1.000 0.000
#> SRR1736363     3   0.000      1.000 0.000 0.000 1.000 0.000
#> SRR1736365     3   0.000      1.000 0.000 0.000 1.000 0.000
#> SRR1736364     3   0.000      1.000 0.000 0.000 1.000 0.000
#> SRR1736366     3   0.000      1.000 0.000 0.000 1.000 0.000
#> SRR1736367     3   0.000      1.000 0.000 0.000 1.000 0.000
#> SRR1736368     3   0.000      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
#> SRR1736309     2   0.000     1.0000 0.000 1.000 0.000 0.000 0.000
#> SRR1736310     2   0.000     1.0000 0.000 1.000 0.000 0.000 0.000
#> SRR1736312     2   0.000     1.0000 0.000 1.000 0.000 0.000 0.000
#> SRR1736311     2   0.000     1.0000 0.000 1.000 0.000 0.000 0.000
#> SRR1736313     2   0.000     1.0000 0.000 1.000 0.000 0.000 0.000
#> SRR1736314     2   0.000     1.0000 0.000 1.000 0.000 0.000 0.000
#> SRR1736315     2   0.000     1.0000 0.000 1.000 0.000 0.000 0.000
#> SRR1736316     2   0.000     1.0000 0.000 1.000 0.000 0.000 0.000
#> SRR1736317     2   0.000     1.0000 0.000 1.000 0.000 0.000 0.000
#> SRR1736318     2   0.000     1.0000 0.000 1.000 0.000 0.000 0.000
#> SRR1736319     2   0.000     1.0000 0.000 1.000 0.000 0.000 0.000
#> SRR1736320     2   0.000     1.0000 0.000 1.000 0.000 0.000 0.000
#> SRR1736321     2   0.000     1.0000 0.000 1.000 0.000 0.000 0.000
#> SRR1736322     2   0.000     1.0000 0.000 1.000 0.000 0.000 0.000
#> SRR1736323     2   0.000     1.0000 0.000 1.000 0.000 0.000 0.000
#> SRR1736324     2   0.000     1.0000 0.000 1.000 0.000 0.000 0.000
#> SRR1736325     2   0.000     1.0000 0.000 1.000 0.000 0.000 0.000
#> SRR1736326     2   0.000     1.0000 0.000 1.000 0.000 0.000 0.000
#> SRR1736328     4   0.421     1.0000 0.000 0.412 0.000 0.588 0.000
#> SRR1736327     4   0.421     1.0000 0.000 0.412 0.000 0.588 0.000
#> SRR1736329     4   0.421     1.0000 0.000 0.412 0.000 0.588 0.000
#> SRR1736330     4   0.421     1.0000 0.000 0.412 0.000 0.588 0.000
#> SRR1736331     4   0.421     1.0000 0.000 0.412 0.000 0.588 0.000
#> SRR1736332     4   0.421     1.0000 0.000 0.412 0.000 0.588 0.000
#> SRR1736333     5   0.029     1.0000 0.008 0.000 0.000 0.000 0.992
#> SRR1736334     5   0.029     1.0000 0.008 0.000 0.000 0.000 0.992
#> SRR1736335     5   0.029     1.0000 0.008 0.000 0.000 0.000 0.992
#> SRR1736337     5   0.029     1.0000 0.008 0.000 0.000 0.000 0.992
#> SRR1736336     5   0.029     1.0000 0.008 0.000 0.000 0.000 0.992
#> SRR1736338     5   0.029     1.0000 0.008 0.000 0.000 0.000 0.992
#> SRR1736339     1   0.000     1.0000 1.000 0.000 0.000 0.000 0.000
#> SRR1736340     1   0.000     1.0000 1.000 0.000 0.000 0.000 0.000
#> SRR1736341     1   0.000     1.0000 1.000 0.000 0.000 0.000 0.000
#> SRR1736342     3   0.639    -0.1012 0.396 0.000 0.436 0.000 0.168
#> SRR1736343     3   0.639    -0.1012 0.396 0.000 0.436 0.000 0.168
#> SRR1736344     3   0.639    -0.1012 0.396 0.000 0.436 0.000 0.168
#> SRR1736345     1   0.000     1.0000 1.000 0.000 0.000 0.000 0.000
#> SRR1736346     1   0.000     1.0000 1.000 0.000 0.000 0.000 0.000
#> SRR1736348     3   0.639    -0.1012 0.396 0.000 0.436 0.000 0.168
#> SRR1736347     1   0.000     1.0000 1.000 0.000 0.000 0.000 0.000
#> SRR1736349     3   0.639    -0.1012 0.396 0.000 0.436 0.000 0.168
#> SRR1736350     3   0.639    -0.1012 0.396 0.000 0.436 0.000 0.168
#> SRR1736351     1   0.000     1.0000 1.000 0.000 0.000 0.000 0.000
#> SRR1736352     1   0.000     1.0000 1.000 0.000 0.000 0.000 0.000
#> SRR1736353     1   0.000     1.0000 1.000 0.000 0.000 0.000 0.000
#> SRR1736354     3   0.639    -0.1012 0.396 0.000 0.436 0.000 0.168
#> SRR1736355     3   0.639    -0.1012 0.396 0.000 0.436 0.000 0.168
#> SRR1736356     3   0.512     0.0679 0.224 0.000 0.692 0.008 0.076
#> SRR1736358     3   0.497     0.5054 0.000 0.000 0.560 0.408 0.032
#> SRR1736357     3   0.497     0.5054 0.000 0.000 0.560 0.408 0.032
#> SRR1736359     3   0.497     0.5054 0.000 0.000 0.560 0.408 0.032
#> SRR1736360     3   0.497     0.5054 0.000 0.000 0.560 0.408 0.032
#> SRR1736361     3   0.497     0.5054 0.000 0.000 0.560 0.408 0.032
#> SRR1736362     3   0.497     0.5054 0.000 0.000 0.560 0.408 0.032
#> SRR1736363     3   0.497     0.5061 0.000 0.000 0.564 0.404 0.032
#> SRR1736365     3   0.497     0.5061 0.000 0.000 0.564 0.404 0.032
#> SRR1736364     3   0.497     0.5061 0.000 0.000 0.564 0.404 0.032
#> SRR1736366     3   0.497     0.5061 0.000 0.000 0.564 0.404 0.032
#> SRR1736367     3   0.497     0.5061 0.000 0.000 0.564 0.404 0.032
#> SRR1736368     3   0.497     0.5061 0.000 0.000 0.564 0.404 0.032

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR1736309     2   0.000      0.979 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736310     2   0.000      0.979 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736312     2   0.000      0.979 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736311     2   0.000      0.979 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736313     2   0.000      0.979 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736314     2   0.000      0.979 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736315     2   0.160      0.958 0.000 0.940 0.000 0.012 0.016 0.032
#> SRR1736316     2   0.160      0.958 0.000 0.940 0.000 0.012 0.016 0.032
#> SRR1736317     2   0.160      0.958 0.000 0.940 0.000 0.012 0.016 0.032
#> SRR1736318     2   0.000      0.979 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736319     2   0.000      0.979 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736320     2   0.000      0.979 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736321     2   0.160      0.958 0.000 0.940 0.000 0.012 0.016 0.032
#> SRR1736322     2   0.160      0.958 0.000 0.940 0.000 0.012 0.016 0.032
#> SRR1736323     2   0.160      0.958 0.000 0.940 0.000 0.012 0.016 0.032
#> SRR1736324     2   0.000      0.979 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736325     2   0.000      0.979 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736326     2   0.000      0.979 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736328     4   0.161      1.000 0.000 0.084 0.000 0.916 0.000 0.000
#> SRR1736327     4   0.161      1.000 0.000 0.084 0.000 0.916 0.000 0.000
#> SRR1736329     4   0.161      1.000 0.000 0.084 0.000 0.916 0.000 0.000
#> SRR1736330     4   0.161      1.000 0.000 0.084 0.000 0.916 0.000 0.000
#> SRR1736331     4   0.161      1.000 0.000 0.084 0.000 0.916 0.000 0.000
#> SRR1736332     4   0.161      1.000 0.000 0.084 0.000 0.916 0.000 0.000
#> SRR1736333     5   0.101      1.000 0.000 0.000 0.000 0.000 0.956 0.044
#> SRR1736334     5   0.101      1.000 0.000 0.000 0.000 0.000 0.956 0.044
#> SRR1736335     5   0.101      1.000 0.000 0.000 0.000 0.000 0.956 0.044
#> SRR1736337     5   0.101      1.000 0.000 0.000 0.000 0.000 0.956 0.044
#> SRR1736336     5   0.101      1.000 0.000 0.000 0.000 0.000 0.956 0.044
#> SRR1736338     5   0.101      1.000 0.000 0.000 0.000 0.000 0.956 0.044
#> SRR1736339     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1736340     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1736341     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1736342     6   0.150      0.982 0.076 0.000 0.000 0.000 0.000 0.924
#> SRR1736343     6   0.150      0.982 0.076 0.000 0.000 0.000 0.000 0.924
#> SRR1736344     6   0.150      0.982 0.076 0.000 0.000 0.000 0.000 0.924
#> SRR1736345     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1736346     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1736348     6   0.150      0.982 0.076 0.000 0.000 0.000 0.000 0.924
#> SRR1736347     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1736349     6   0.150      0.982 0.076 0.000 0.000 0.000 0.000 0.924
#> SRR1736350     6   0.150      0.982 0.076 0.000 0.000 0.000 0.000 0.924
#> SRR1736351     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1736352     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1736353     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1736354     6   0.150      0.982 0.076 0.000 0.000 0.000 0.000 0.924
#> SRR1736355     6   0.150      0.982 0.076 0.000 0.000 0.000 0.000 0.924
#> SRR1736356     6   0.291      0.849 0.012 0.000 0.044 0.040 0.024 0.880
#> SRR1736358     3   0.225      0.934 0.000 0.000 0.908 0.044 0.020 0.028
#> SRR1736357     3   0.225      0.934 0.000 0.000 0.908 0.044 0.020 0.028
#> SRR1736359     3   0.225      0.934 0.000 0.000 0.908 0.044 0.020 0.028
#> SRR1736360     3   0.158      0.950 0.000 0.000 0.940 0.036 0.008 0.016
#> SRR1736361     3   0.158      0.950 0.000 0.000 0.940 0.036 0.008 0.016
#> SRR1736362     3   0.158      0.950 0.000 0.000 0.940 0.036 0.008 0.016
#> SRR1736363     3   0.000      0.966 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736365     3   0.000      0.966 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736364     3   0.000      0.966 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736366     3   0.000      0.966 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736367     3   0.000      0.966 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736368     3   0.000      0.966 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 15454 rows and 60 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#>   Subgroups are detected by 'pam' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 6.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk CV-pam-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4886 0.512   0.512
#> 3 3 1.000           0.999       1.000         0.3330 0.837   0.682
#> 4 4 0.863           0.969       0.937         0.0960 0.939   0.825
#> 5 5 0.944           0.939       0.953         0.0868 0.923   0.738
#> 6 6 1.000           0.998       0.999         0.0554 0.948   0.773

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

suggest_best_k(res)
#> [1] 6
#> attr(,"optional")
#> [1] 2 3 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
#> SRR1736309     2       0          1  0  1
#> SRR1736310     2       0          1  0  1
#> SRR1736312     2       0          1  0  1
#> SRR1736311     2       0          1  0  1
#> SRR1736313     2       0          1  0  1
#> SRR1736314     2       0          1  0  1
#> SRR1736315     2       0          1  0  1
#> SRR1736316     2       0          1  0  1
#> SRR1736317     2       0          1  0  1
#> SRR1736318     2       0          1  0  1
#> SRR1736319     2       0          1  0  1
#> SRR1736320     2       0          1  0  1
#> SRR1736321     2       0          1  0  1
#> SRR1736322     2       0          1  0  1
#> SRR1736323     2       0          1  0  1
#> SRR1736324     2       0          1  0  1
#> SRR1736325     2       0          1  0  1
#> SRR1736326     2       0          1  0  1
#> SRR1736328     2       0          1  0  1
#> SRR1736327     2       0          1  0  1
#> SRR1736329     2       0          1  0  1
#> SRR1736330     2       0          1  0  1
#> SRR1736331     2       0          1  0  1
#> SRR1736332     2       0          1  0  1
#> SRR1736333     1       0          1  1  0
#> SRR1736334     1       0          1  1  0
#> SRR1736335     1       0          1  1  0
#> SRR1736337     1       0          1  1  0
#> SRR1736336     1       0          1  1  0
#> SRR1736338     1       0          1  1  0
#> SRR1736339     1       0          1  1  0
#> SRR1736340     1       0          1  1  0
#> SRR1736341     1       0          1  1  0
#> SRR1736342     1       0          1  1  0
#> SRR1736343     1       0          1  1  0
#> SRR1736344     1       0          1  1  0
#> SRR1736345     1       0          1  1  0
#> SRR1736346     1       0          1  1  0
#> SRR1736348     1       0          1  1  0
#> SRR1736347     1       0          1  1  0
#> SRR1736349     1       0          1  1  0
#> SRR1736350     1       0          1  1  0
#> SRR1736351     1       0          1  1  0
#> SRR1736352     1       0          1  1  0
#> SRR1736353     1       0          1  1  0
#> SRR1736354     1       0          1  1  0
#> SRR1736355     1       0          1  1  0
#> SRR1736356     1       0          1  1  0
#> SRR1736358     1       0          1  1  0
#> SRR1736357     1       0          1  1  0
#> SRR1736359     1       0          1  1  0
#> SRR1736360     1       0          1  1  0
#> SRR1736361     1       0          1  1  0
#> SRR1736362     1       0          1  1  0
#> SRR1736363     1       0          1  1  0
#> SRR1736365     1       0          1  1  0
#> SRR1736364     1       0          1  1  0
#> SRR1736366     1       0          1  1  0
#> SRR1736367     1       0          1  1  0
#> SRR1736368     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
#> SRR1736309     2   0.000      1.000 0.000  1 0.000
#> SRR1736310     2   0.000      1.000 0.000  1 0.000
#> SRR1736312     2   0.000      1.000 0.000  1 0.000
#> SRR1736311     2   0.000      1.000 0.000  1 0.000
#> SRR1736313     2   0.000      1.000 0.000  1 0.000
#> SRR1736314     2   0.000      1.000 0.000  1 0.000
#> SRR1736315     2   0.000      1.000 0.000  1 0.000
#> SRR1736316     2   0.000      1.000 0.000  1 0.000
#> SRR1736317     2   0.000      1.000 0.000  1 0.000
#> SRR1736318     2   0.000      1.000 0.000  1 0.000
#> SRR1736319     2   0.000      1.000 0.000  1 0.000
#> SRR1736320     2   0.000      1.000 0.000  1 0.000
#> SRR1736321     2   0.000      1.000 0.000  1 0.000
#> SRR1736322     2   0.000      1.000 0.000  1 0.000
#> SRR1736323     2   0.000      1.000 0.000  1 0.000
#> SRR1736324     2   0.000      1.000 0.000  1 0.000
#> SRR1736325     2   0.000      1.000 0.000  1 0.000
#> SRR1736326     2   0.000      1.000 0.000  1 0.000
#> SRR1736328     2   0.000      1.000 0.000  1 0.000
#> SRR1736327     2   0.000      1.000 0.000  1 0.000
#> SRR1736329     2   0.000      1.000 0.000  1 0.000
#> SRR1736330     2   0.000      1.000 0.000  1 0.000
#> SRR1736331     2   0.000      1.000 0.000  1 0.000
#> SRR1736332     2   0.000      1.000 0.000  1 0.000
#> SRR1736333     1   0.000      0.999 1.000  0 0.000
#> SRR1736334     1   0.000      0.999 1.000  0 0.000
#> SRR1736335     1   0.116      0.971 0.972  0 0.028
#> SRR1736337     1   0.000      0.999 1.000  0 0.000
#> SRR1736336     1   0.000      0.999 1.000  0 0.000
#> SRR1736338     1   0.000      0.999 1.000  0 0.000
#> SRR1736339     1   0.000      0.999 1.000  0 0.000
#> SRR1736340     1   0.000      0.999 1.000  0 0.000
#> SRR1736341     1   0.000      0.999 1.000  0 0.000
#> SRR1736342     1   0.000      0.999 1.000  0 0.000
#> SRR1736343     1   0.000      0.999 1.000  0 0.000
#> SRR1736344     1   0.000      0.999 1.000  0 0.000
#> SRR1736345     1   0.000      0.999 1.000  0 0.000
#> SRR1736346     1   0.000      0.999 1.000  0 0.000
#> SRR1736348     1   0.000      0.999 1.000  0 0.000
#> SRR1736347     1   0.000      0.999 1.000  0 0.000
#> SRR1736349     1   0.000      0.999 1.000  0 0.000
#> SRR1736350     1   0.000      0.999 1.000  0 0.000
#> SRR1736351     1   0.000      0.999 1.000  0 0.000
#> SRR1736352     1   0.000      0.999 1.000  0 0.000
#> SRR1736353     1   0.000      0.999 1.000  0 0.000
#> SRR1736354     1   0.000      0.999 1.000  0 0.000
#> SRR1736355     1   0.000      0.999 1.000  0 0.000
#> SRR1736356     1   0.000      0.999 1.000  0 0.000
#> SRR1736358     3   0.000      1.000 0.000  0 1.000
#> SRR1736357     3   0.000      1.000 0.000  0 1.000
#> SRR1736359     3   0.000      1.000 0.000  0 1.000
#> SRR1736360     3   0.000      1.000 0.000  0 1.000
#> SRR1736361     3   0.000      1.000 0.000  0 1.000
#> SRR1736362     3   0.000      1.000 0.000  0 1.000
#> SRR1736363     3   0.000      1.000 0.000  0 1.000
#> SRR1736365     3   0.000      1.000 0.000  0 1.000
#> SRR1736364     3   0.000      1.000 0.000  0 1.000
#> SRR1736366     3   0.000      1.000 0.000  0 1.000
#> SRR1736367     3   0.000      1.000 0.000  0 1.000
#> SRR1736368     3   0.000      1.000 0.000  0 1.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1  p2 p3    p4
#> SRR1736309     2   0.000      1.000 0.000 1.0  0 0.000
#> SRR1736310     2   0.000      1.000 0.000 1.0  0 0.000
#> SRR1736312     2   0.000      1.000 0.000 1.0  0 0.000
#> SRR1736311     2   0.000      1.000 0.000 1.0  0 0.000
#> SRR1736313     2   0.000      1.000 0.000 1.0  0 0.000
#> SRR1736314     2   0.000      1.000 0.000 1.0  0 0.000
#> SRR1736315     2   0.000      1.000 0.000 1.0  0 0.000
#> SRR1736316     2   0.000      1.000 0.000 1.0  0 0.000
#> SRR1736317     2   0.000      1.000 0.000 1.0  0 0.000
#> SRR1736318     2   0.000      1.000 0.000 1.0  0 0.000
#> SRR1736319     2   0.000      1.000 0.000 1.0  0 0.000
#> SRR1736320     2   0.000      1.000 0.000 1.0  0 0.000
#> SRR1736321     2   0.000      1.000 0.000 1.0  0 0.000
#> SRR1736322     2   0.000      1.000 0.000 1.0  0 0.000
#> SRR1736323     2   0.000      1.000 0.000 1.0  0 0.000
#> SRR1736324     2   0.000      1.000 0.000 1.0  0 0.000
#> SRR1736325     2   0.000      1.000 0.000 1.0  0 0.000
#> SRR1736326     2   0.000      1.000 0.000 1.0  0 0.000
#> SRR1736328     4   0.361      1.000 0.000 0.2  0 0.800
#> SRR1736327     4   0.361      1.000 0.000 0.2  0 0.800
#> SRR1736329     4   0.361      1.000 0.000 0.2  0 0.800
#> SRR1736330     4   0.361      1.000 0.000 0.2  0 0.800
#> SRR1736331     4   0.361      1.000 0.000 0.2  0 0.800
#> SRR1736332     4   0.361      1.000 0.000 0.2  0 0.800
#> SRR1736333     1   0.208      0.909 0.916 0.0  0 0.084
#> SRR1736334     1   0.208      0.909 0.916 0.0  0 0.084
#> SRR1736335     1   0.208      0.909 0.916 0.0  0 0.084
#> SRR1736337     1   0.208      0.909 0.916 0.0  0 0.084
#> SRR1736336     1   0.208      0.909 0.916 0.0  0 0.084
#> SRR1736338     1   0.208      0.909 0.916 0.0  0 0.084
#> SRR1736339     1   0.259      0.917 0.884 0.0  0 0.116
#> SRR1736340     1   0.259      0.917 0.884 0.0  0 0.116
#> SRR1736341     1   0.259      0.917 0.884 0.0  0 0.116
#> SRR1736342     1   0.000      0.937 1.000 0.0  0 0.000
#> SRR1736343     1   0.000      0.937 1.000 0.0  0 0.000
#> SRR1736344     1   0.000      0.937 1.000 0.0  0 0.000
#> SRR1736345     1   0.259      0.917 0.884 0.0  0 0.116
#> SRR1736346     1   0.259      0.917 0.884 0.0  0 0.116
#> SRR1736348     1   0.000      0.937 1.000 0.0  0 0.000
#> SRR1736347     1   0.259      0.917 0.884 0.0  0 0.116
#> SRR1736349     1   0.000      0.937 1.000 0.0  0 0.000
#> SRR1736350     1   0.000      0.937 1.000 0.0  0 0.000
#> SRR1736351     1   0.259      0.917 0.884 0.0  0 0.116
#> SRR1736352     1   0.259      0.917 0.884 0.0  0 0.116
#> SRR1736353     1   0.259      0.917 0.884 0.0  0 0.116
#> SRR1736354     1   0.000      0.937 1.000 0.0  0 0.000
#> SRR1736355     1   0.000      0.937 1.000 0.0  0 0.000
#> SRR1736356     1   0.000      0.937 1.000 0.0  0 0.000
#> SRR1736358     3   0.000      1.000 0.000 0.0  1 0.000
#> SRR1736357     3   0.000      1.000 0.000 0.0  1 0.000
#> SRR1736359     3   0.000      1.000 0.000 0.0  1 0.000
#> SRR1736360     3   0.000      1.000 0.000 0.0  1 0.000
#> SRR1736361     3   0.000      1.000 0.000 0.0  1 0.000
#> SRR1736362     3   0.000      1.000 0.000 0.0  1 0.000
#> SRR1736363     3   0.000      1.000 0.000 0.0  1 0.000
#> SRR1736365     3   0.000      1.000 0.000 0.0  1 0.000
#> SRR1736364     3   0.000      1.000 0.000 0.0  1 0.000
#> SRR1736366     3   0.000      1.000 0.000 0.0  1 0.000
#> SRR1736367     3   0.000      1.000 0.000 0.0  1 0.000
#> SRR1736368     3   0.000      1.000 0.000 0.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
#> SRR1736309     2   0.000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736310     2   0.000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736312     2   0.000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736311     2   0.000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736313     2   0.000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736314     2   0.000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736315     2   0.000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736316     2   0.000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736317     2   0.000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736318     2   0.000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736319     2   0.000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736320     2   0.000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736321     2   0.000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736322     2   0.000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736323     2   0.000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736324     2   0.000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736325     2   0.000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736326     2   0.000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736328     4   0.185      1.000 0.000 0.088 0.000 0.912 0.000
#> SRR1736327     4   0.185      1.000 0.000 0.088 0.000 0.912 0.000
#> SRR1736329     4   0.185      1.000 0.000 0.088 0.000 0.912 0.000
#> SRR1736330     4   0.185      1.000 0.000 0.088 0.000 0.912 0.000
#> SRR1736331     4   0.185      1.000 0.000 0.088 0.000 0.912 0.000
#> SRR1736332     4   0.185      1.000 0.000 0.088 0.000 0.912 0.000
#> SRR1736333     5   0.000      1.000 0.000 0.000 0.000 0.000 1.000
#> SRR1736334     5   0.000      1.000 0.000 0.000 0.000 0.000 1.000
#> SRR1736335     5   0.000      1.000 0.000 0.000 0.000 0.000 1.000
#> SRR1736337     5   0.000      1.000 0.000 0.000 0.000 0.000 1.000
#> SRR1736336     5   0.000      1.000 0.000 0.000 0.000 0.000 1.000
#> SRR1736338     5   0.000      1.000 0.000 0.000 0.000 0.000 1.000
#> SRR1736339     1   0.000      0.886 1.000 0.000 0.000 0.000 0.000
#> SRR1736340     1   0.000      0.886 1.000 0.000 0.000 0.000 0.000
#> SRR1736341     1   0.000      0.886 1.000 0.000 0.000 0.000 0.000
#> SRR1736342     1   0.410      0.859 0.788 0.000 0.000 0.088 0.124
#> SRR1736343     1   0.410      0.859 0.788 0.000 0.000 0.088 0.124
#> SRR1736344     1   0.410      0.859 0.788 0.000 0.000 0.088 0.124
#> SRR1736345     1   0.000      0.886 1.000 0.000 0.000 0.000 0.000
#> SRR1736346     1   0.000      0.886 1.000 0.000 0.000 0.000 0.000
#> SRR1736348     1   0.410      0.859 0.788 0.000 0.000 0.088 0.124
#> SRR1736347     1   0.000      0.886 1.000 0.000 0.000 0.000 0.000
#> SRR1736349     1   0.410      0.859 0.788 0.000 0.000 0.088 0.124
#> SRR1736350     1   0.410      0.859 0.788 0.000 0.000 0.088 0.124
#> SRR1736351     1   0.000      0.886 1.000 0.000 0.000 0.000 0.000
#> SRR1736352     1   0.000      0.886 1.000 0.000 0.000 0.000 0.000
#> SRR1736353     1   0.000      0.886 1.000 0.000 0.000 0.000 0.000
#> SRR1736354     1   0.495      0.770 0.696 0.000 0.000 0.088 0.216
#> SRR1736355     1   0.444      0.834 0.756 0.000 0.000 0.088 0.156
#> SRR1736356     3   0.709      0.157 0.304 0.000 0.508 0.064 0.124
#> SRR1736358     3   0.000      0.953 0.000 0.000 1.000 0.000 0.000
#> SRR1736357     3   0.000      0.953 0.000 0.000 1.000 0.000 0.000
#> SRR1736359     3   0.000      0.953 0.000 0.000 1.000 0.000 0.000
#> SRR1736360     3   0.000      0.953 0.000 0.000 1.000 0.000 0.000
#> SRR1736361     3   0.000      0.953 0.000 0.000 1.000 0.000 0.000
#> SRR1736362     3   0.000      0.953 0.000 0.000 1.000 0.000 0.000
#> SRR1736363     3   0.000      0.953 0.000 0.000 1.000 0.000 0.000
#> SRR1736365     3   0.000      0.953 0.000 0.000 1.000 0.000 0.000
#> SRR1736364     3   0.000      0.953 0.000 0.000 1.000 0.000 0.000
#> SRR1736366     3   0.000      0.953 0.000 0.000 1.000 0.000 0.000
#> SRR1736367     3   0.000      0.953 0.000 0.000 1.000 0.000 0.000
#> SRR1736368     3   0.000      0.953 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
#> SRR1736309     2   0.000      1.000 0.000  1  0  0  0 0.000
#> SRR1736310     2   0.000      1.000 0.000  1  0  0  0 0.000
#> SRR1736312     2   0.000      1.000 0.000  1  0  0  0 0.000
#> SRR1736311     2   0.000      1.000 0.000  1  0  0  0 0.000
#> SRR1736313     2   0.000      1.000 0.000  1  0  0  0 0.000
#> SRR1736314     2   0.000      1.000 0.000  1  0  0  0 0.000
#> SRR1736315     2   0.000      1.000 0.000  1  0  0  0 0.000
#> SRR1736316     2   0.000      1.000 0.000  1  0  0  0 0.000
#> SRR1736317     2   0.000      1.000 0.000  1  0  0  0 0.000
#> SRR1736318     2   0.000      1.000 0.000  1  0  0  0 0.000
#> SRR1736319     2   0.000      1.000 0.000  1  0  0  0 0.000
#> SRR1736320     2   0.000      1.000 0.000  1  0  0  0 0.000
#> SRR1736321     2   0.000      1.000 0.000  1  0  0  0 0.000
#> SRR1736322     2   0.000      1.000 0.000  1  0  0  0 0.000
#> SRR1736323     2   0.000      1.000 0.000  1  0  0  0 0.000
#> SRR1736324     2   0.000      1.000 0.000  1  0  0  0 0.000
#> SRR1736325     2   0.000      1.000 0.000  1  0  0  0 0.000
#> SRR1736326     2   0.000      1.000 0.000  1  0  0  0 0.000
#> SRR1736328     4   0.000      1.000 0.000  0  0  1  0 0.000
#> SRR1736327     4   0.000      1.000 0.000  0  0  1  0 0.000
#> SRR1736329     4   0.000      1.000 0.000  0  0  1  0 0.000
#> SRR1736330     4   0.000      1.000 0.000  0  0  1  0 0.000
#> SRR1736331     4   0.000      1.000 0.000  0  0  1  0 0.000
#> SRR1736332     4   0.000      1.000 0.000  0  0  1  0 0.000
#> SRR1736333     5   0.000      1.000 0.000  0  0  0  1 0.000
#> SRR1736334     5   0.000      1.000 0.000  0  0  0  1 0.000
#> SRR1736335     5   0.000      1.000 0.000  0  0  0  1 0.000
#> SRR1736337     5   0.000      1.000 0.000  0  0  0  1 0.000
#> SRR1736336     5   0.000      1.000 0.000  0  0  0  1 0.000
#> SRR1736338     5   0.000      1.000 0.000  0  0  0  1 0.000
#> SRR1736339     1   0.000      1.000 1.000  0  0  0  0 0.000
#> SRR1736340     1   0.000      1.000 1.000  0  0  0  0 0.000
#> SRR1736341     1   0.000      1.000 1.000  0  0  0  0 0.000
#> SRR1736342     6   0.000      0.994 0.000  0  0  0  0 1.000
#> SRR1736343     6   0.000      0.994 0.000  0  0  0  0 1.000
#> SRR1736344     6   0.000      0.994 0.000  0  0  0  0 1.000
#> SRR1736345     1   0.000      1.000 1.000  0  0  0  0 0.000
#> SRR1736346     1   0.000      1.000 1.000  0  0  0  0 0.000
#> SRR1736348     6   0.000      0.994 0.000  0  0  0  0 1.000
#> SRR1736347     1   0.000      1.000 1.000  0  0  0  0 0.000
#> SRR1736349     6   0.000      0.994 0.000  0  0  0  0 1.000
#> SRR1736350     6   0.000      0.994 0.000  0  0  0  0 1.000
#> SRR1736351     1   0.000      1.000 1.000  0  0  0  0 0.000
#> SRR1736352     1   0.000      1.000 1.000  0  0  0  0 0.000
#> SRR1736353     1   0.000      1.000 1.000  0  0  0  0 0.000
#> SRR1736354     6   0.000      0.994 0.000  0  0  0  0 1.000
#> SRR1736355     6   0.000      0.994 0.000  0  0  0  0 1.000
#> SRR1736356     6   0.101      0.951 0.044  0  0  0  0 0.956
#> SRR1736358     3   0.000      1.000 0.000  0  1  0  0 0.000
#> SRR1736357     3   0.000      1.000 0.000  0  1  0  0 0.000
#> SRR1736359     3   0.000      1.000 0.000  0  1  0  0 0.000
#> SRR1736360     3   0.000      1.000 0.000  0  1  0  0 0.000
#> SRR1736361     3   0.000      1.000 0.000  0  1  0  0 0.000
#> SRR1736362     3   0.000      1.000 0.000  0  1  0  0 0.000
#> SRR1736363     3   0.000      1.000 0.000  0  1  0  0 0.000
#> SRR1736365     3   0.000      1.000 0.000  0  1  0  0 0.000
#> SRR1736364     3   0.000      1.000 0.000  0  1  0  0 0.000
#> SRR1736366     3   0.000      1.000 0.000  0  1  0  0 0.000
#> SRR1736367     3   0.000      1.000 0.000  0  1  0  0 0.000
#> SRR1736368     3   0.000      1.000 0.000  0  1  0  0 0.000

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

consensus_heatmap(res, k = 2)

plot of chunk tab-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 15454 rows and 60 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#>   Subgroups are detected by 'mclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 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-mclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4886 0.512   0.512
#> 3 3 0.944           0.935       0.964         0.3226 0.837   0.682
#> 4 4 0.793           0.882       0.914         0.1215 0.919   0.773
#> 5 5 0.898           0.903       0.923         0.0756 0.942   0.796
#> 6 6 0.884           0.932       0.925         0.0454 0.959   0.819

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
#> SRR1736309     2       0          1  0  1
#> SRR1736310     2       0          1  0  1
#> SRR1736312     2       0          1  0  1
#> SRR1736311     2       0          1  0  1
#> SRR1736313     2       0          1  0  1
#> SRR1736314     2       0          1  0  1
#> SRR1736315     2       0          1  0  1
#> SRR1736316     2       0          1  0  1
#> SRR1736317     2       0          1  0  1
#> SRR1736318     2       0          1  0  1
#> SRR1736319     2       0          1  0  1
#> SRR1736320     2       0          1  0  1
#> SRR1736321     2       0          1  0  1
#> SRR1736322     2       0          1  0  1
#> SRR1736323     2       0          1  0  1
#> SRR1736324     2       0          1  0  1
#> SRR1736325     2       0          1  0  1
#> SRR1736326     2       0          1  0  1
#> SRR1736328     2       0          1  0  1
#> SRR1736327     2       0          1  0  1
#> SRR1736329     2       0          1  0  1
#> SRR1736330     2       0          1  0  1
#> SRR1736331     2       0          1  0  1
#> SRR1736332     2       0          1  0  1
#> SRR1736333     1       0          1  1  0
#> SRR1736334     1       0          1  1  0
#> SRR1736335     1       0          1  1  0
#> SRR1736337     1       0          1  1  0
#> SRR1736336     1       0          1  1  0
#> SRR1736338     1       0          1  1  0
#> SRR1736339     1       0          1  1  0
#> SRR1736340     1       0          1  1  0
#> SRR1736341     1       0          1  1  0
#> SRR1736342     1       0          1  1  0
#> SRR1736343     1       0          1  1  0
#> SRR1736344     1       0          1  1  0
#> SRR1736345     1       0          1  1  0
#> SRR1736346     1       0          1  1  0
#> SRR1736348     1       0          1  1  0
#> SRR1736347     1       0          1  1  0
#> SRR1736349     1       0          1  1  0
#> SRR1736350     1       0          1  1  0
#> SRR1736351     1       0          1  1  0
#> SRR1736352     1       0          1  1  0
#> SRR1736353     1       0          1  1  0
#> SRR1736354     1       0          1  1  0
#> SRR1736355     1       0          1  1  0
#> SRR1736356     1       0          1  1  0
#> SRR1736358     1       0          1  1  0
#> SRR1736357     1       0          1  1  0
#> SRR1736359     1       0          1  1  0
#> SRR1736360     1       0          1  1  0
#> SRR1736361     1       0          1  1  0
#> SRR1736362     1       0          1  1  0
#> SRR1736363     1       0          1  1  0
#> SRR1736365     1       0          1  1  0
#> SRR1736364     1       0          1  1  0
#> SRR1736366     1       0          1  1  0
#> SRR1736367     1       0          1  1  0
#> SRR1736368     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
#> SRR1736309     2   0.000      0.992 0.000 1.000 0.000
#> SRR1736310     2   0.000      0.992 0.000 1.000 0.000
#> SRR1736312     2   0.000      0.992 0.000 1.000 0.000
#> SRR1736311     2   0.000      0.992 0.000 1.000 0.000
#> SRR1736313     2   0.000      0.992 0.000 1.000 0.000
#> SRR1736314     2   0.000      0.992 0.000 1.000 0.000
#> SRR1736315     2   0.000      0.992 0.000 1.000 0.000
#> SRR1736316     2   0.000      0.992 0.000 1.000 0.000
#> SRR1736317     2   0.000      0.992 0.000 1.000 0.000
#> SRR1736318     2   0.000      0.992 0.000 1.000 0.000
#> SRR1736319     2   0.000      0.992 0.000 1.000 0.000
#> SRR1736320     2   0.000      0.992 0.000 1.000 0.000
#> SRR1736321     2   0.000      0.992 0.000 1.000 0.000
#> SRR1736322     2   0.000      0.992 0.000 1.000 0.000
#> SRR1736323     2   0.000      0.992 0.000 1.000 0.000
#> SRR1736324     2   0.000      0.992 0.000 1.000 0.000
#> SRR1736325     2   0.000      0.992 0.000 1.000 0.000
#> SRR1736326     2   0.000      0.992 0.000 1.000 0.000
#> SRR1736328     2   0.103      0.977 0.000 0.976 0.024
#> SRR1736327     2   0.103      0.977 0.000 0.976 0.024
#> SRR1736329     2   0.103      0.977 0.000 0.976 0.024
#> SRR1736330     2   0.103      0.977 0.000 0.976 0.024
#> SRR1736331     2   0.103      0.977 0.000 0.976 0.024
#> SRR1736332     2   0.103      0.977 0.000 0.976 0.024
#> SRR1736333     1   0.288      0.919 0.904 0.000 0.096
#> SRR1736334     1   0.288      0.919 0.904 0.000 0.096
#> SRR1736335     1   0.288      0.919 0.904 0.000 0.096
#> SRR1736337     1   0.288      0.919 0.904 0.000 0.096
#> SRR1736336     1   0.288      0.919 0.904 0.000 0.096
#> SRR1736338     1   0.288      0.919 0.904 0.000 0.096
#> SRR1736339     1   0.000      0.946 1.000 0.000 0.000
#> SRR1736340     1   0.000      0.946 1.000 0.000 0.000
#> SRR1736341     1   0.000      0.946 1.000 0.000 0.000
#> SRR1736342     1   0.129      0.951 0.968 0.000 0.032
#> SRR1736343     1   0.129      0.951 0.968 0.000 0.032
#> SRR1736344     1   0.129      0.951 0.968 0.000 0.032
#> SRR1736345     1   0.000      0.946 1.000 0.000 0.000
#> SRR1736346     1   0.000      0.946 1.000 0.000 0.000
#> SRR1736348     1   0.129      0.951 0.968 0.000 0.032
#> SRR1736347     1   0.000      0.946 1.000 0.000 0.000
#> SRR1736349     1   0.129      0.951 0.968 0.000 0.032
#> SRR1736350     1   0.129      0.951 0.968 0.000 0.032
#> SRR1736351     1   0.000      0.946 1.000 0.000 0.000
#> SRR1736352     1   0.000      0.946 1.000 0.000 0.000
#> SRR1736353     1   0.000      0.946 1.000 0.000 0.000
#> SRR1736354     1   0.153      0.948 0.960 0.000 0.040
#> SRR1736355     1   0.153      0.948 0.960 0.000 0.040
#> SRR1736356     1   0.556      0.591 0.700 0.000 0.300
#> SRR1736358     3   0.000      0.914 0.000 0.000 1.000
#> SRR1736357     3   0.000      0.914 0.000 0.000 1.000
#> SRR1736359     3   0.000      0.914 0.000 0.000 1.000
#> SRR1736360     3   0.540      0.650 0.280 0.000 0.720
#> SRR1736361     3   0.540      0.650 0.280 0.000 0.720
#> SRR1736362     3   0.540      0.650 0.280 0.000 0.720
#> SRR1736363     3   0.000      0.914 0.000 0.000 1.000
#> SRR1736365     3   0.000      0.914 0.000 0.000 1.000
#> SRR1736364     3   0.000      0.914 0.000 0.000 1.000
#> SRR1736366     3   0.000      0.914 0.000 0.000 1.000
#> SRR1736367     3   0.000      0.914 0.000 0.000 1.000
#> SRR1736368     3   0.000      0.914 0.000 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
#> SRR1736309     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR1736310     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR1736312     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR1736311     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR1736313     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR1736314     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR1736315     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR1736316     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR1736317     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR1736318     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR1736319     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR1736320     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR1736321     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR1736322     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR1736323     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR1736324     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR1736325     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR1736326     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR1736328     4  0.3311      1.000 0.000 0.172 0.000 0.828
#> SRR1736327     4  0.3311      1.000 0.000 0.172 0.000 0.828
#> SRR1736329     4  0.3311      1.000 0.000 0.172 0.000 0.828
#> SRR1736330     4  0.3311      1.000 0.000 0.172 0.000 0.828
#> SRR1736331     4  0.3311      1.000 0.000 0.172 0.000 0.828
#> SRR1736332     4  0.3311      1.000 0.000 0.172 0.000 0.828
#> SRR1736333     1  0.7385      0.523 0.484 0.000 0.340 0.176
#> SRR1736334     1  0.7385      0.523 0.484 0.000 0.340 0.176
#> SRR1736335     1  0.7385      0.523 0.484 0.000 0.340 0.176
#> SRR1736337     1  0.7385      0.523 0.484 0.000 0.340 0.176
#> SRR1736336     1  0.7385      0.523 0.484 0.000 0.340 0.176
#> SRR1736338     1  0.7385      0.523 0.484 0.000 0.340 0.176
#> SRR1736339     1  0.0188      0.796 0.996 0.000 0.000 0.004
#> SRR1736340     1  0.0188      0.796 0.996 0.000 0.000 0.004
#> SRR1736341     1  0.0188      0.796 0.996 0.000 0.000 0.004
#> SRR1736342     1  0.3591      0.811 0.824 0.000 0.008 0.168
#> SRR1736343     1  0.3591      0.811 0.824 0.000 0.008 0.168
#> SRR1736344     1  0.3591      0.811 0.824 0.000 0.008 0.168
#> SRR1736345     1  0.0188      0.796 0.996 0.000 0.000 0.004
#> SRR1736346     1  0.0188      0.796 0.996 0.000 0.000 0.004
#> SRR1736348     1  0.3494      0.811 0.824 0.000 0.004 0.172
#> SRR1736347     1  0.0188      0.796 0.996 0.000 0.000 0.004
#> SRR1736349     1  0.3494      0.811 0.824 0.000 0.004 0.172
#> SRR1736350     1  0.3494      0.811 0.824 0.000 0.004 0.172
#> SRR1736351     1  0.0188      0.796 0.996 0.000 0.000 0.004
#> SRR1736352     1  0.0188      0.796 0.996 0.000 0.000 0.004
#> SRR1736353     1  0.0188      0.796 0.996 0.000 0.000 0.004
#> SRR1736354     1  0.3356      0.810 0.824 0.000 0.000 0.176
#> SRR1736355     1  0.3356      0.810 0.824 0.000 0.000 0.176
#> SRR1736356     3  0.6116      0.509 0.220 0.000 0.668 0.112
#> SRR1736358     3  0.0188      0.965 0.000 0.000 0.996 0.004
#> SRR1736357     3  0.0188      0.965 0.000 0.000 0.996 0.004
#> SRR1736359     3  0.0188      0.965 0.000 0.000 0.996 0.004
#> SRR1736360     3  0.0000      0.968 0.000 0.000 1.000 0.000
#> SRR1736361     3  0.0000      0.968 0.000 0.000 1.000 0.000
#> SRR1736362     3  0.0000      0.968 0.000 0.000 1.000 0.000
#> SRR1736363     3  0.0000      0.968 0.000 0.000 1.000 0.000
#> SRR1736365     3  0.0000      0.968 0.000 0.000 1.000 0.000
#> SRR1736364     3  0.0000      0.968 0.000 0.000 1.000 0.000
#> SRR1736366     3  0.0000      0.968 0.000 0.000 1.000 0.000
#> SRR1736367     3  0.0000      0.968 0.000 0.000 1.000 0.000
#> SRR1736368     3  0.0000      0.968 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
#> SRR1736309     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736310     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736312     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736311     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736313     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736314     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736315     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736316     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736317     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736318     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736319     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736320     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736321     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736322     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736323     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736324     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736325     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736326     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736328     4  0.1851      1.000 0.000 0.088 0.000 0.912 0.000
#> SRR1736327     4  0.1851      1.000 0.000 0.088 0.000 0.912 0.000
#> SRR1736329     4  0.1851      1.000 0.000 0.088 0.000 0.912 0.000
#> SRR1736330     4  0.1851      1.000 0.000 0.088 0.000 0.912 0.000
#> SRR1736331     4  0.1851      1.000 0.000 0.088 0.000 0.912 0.000
#> SRR1736332     4  0.1851      1.000 0.000 0.088 0.000 0.912 0.000
#> SRR1736333     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000
#> SRR1736334     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000
#> SRR1736335     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000
#> SRR1736337     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000
#> SRR1736336     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000
#> SRR1736338     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000
#> SRR1736339     1  0.3586      0.640 0.736 0.000 0.000 0.000 0.264
#> SRR1736340     1  0.3586      0.640 0.736 0.000 0.000 0.000 0.264
#> SRR1736341     1  0.3452      0.654 0.756 0.000 0.000 0.000 0.244
#> SRR1736342     1  0.3862      0.781 0.808 0.000 0.000 0.088 0.104
#> SRR1736343     1  0.3862      0.781 0.808 0.000 0.000 0.088 0.104
#> SRR1736344     1  0.3862      0.781 0.808 0.000 0.000 0.088 0.104
#> SRR1736345     1  0.3586      0.640 0.736 0.000 0.000 0.000 0.264
#> SRR1736346     1  0.3586      0.640 0.736 0.000 0.000 0.000 0.264
#> SRR1736348     1  0.3862      0.781 0.808 0.000 0.000 0.088 0.104
#> SRR1736347     1  0.3586      0.640 0.736 0.000 0.000 0.000 0.264
#> SRR1736349     1  0.3862      0.781 0.808 0.000 0.000 0.088 0.104
#> SRR1736350     1  0.3862      0.781 0.808 0.000 0.000 0.088 0.104
#> SRR1736351     1  0.0000      0.765 1.000 0.000 0.000 0.000 0.000
#> SRR1736352     1  0.0000      0.765 1.000 0.000 0.000 0.000 0.000
#> SRR1736353     1  0.0000      0.765 1.000 0.000 0.000 0.000 0.000
#> SRR1736354     1  0.3862      0.781 0.808 0.000 0.000 0.088 0.104
#> SRR1736355     1  0.3862      0.781 0.808 0.000 0.000 0.088 0.104
#> SRR1736356     3  0.6718      0.306 0.264 0.000 0.572 0.084 0.080
#> SRR1736358     3  0.0162      0.956 0.000 0.000 0.996 0.000 0.004
#> SRR1736357     3  0.0162      0.956 0.000 0.000 0.996 0.000 0.004
#> SRR1736359     3  0.0162      0.956 0.000 0.000 0.996 0.000 0.004
#> SRR1736360     3  0.0162      0.956 0.000 0.000 0.996 0.000 0.004
#> SRR1736361     3  0.0162      0.956 0.000 0.000 0.996 0.000 0.004
#> SRR1736362     3  0.0162      0.956 0.000 0.000 0.996 0.000 0.004
#> SRR1736363     3  0.0000      0.957 0.000 0.000 1.000 0.000 0.000
#> SRR1736365     3  0.0000      0.957 0.000 0.000 1.000 0.000 0.000
#> SRR1736364     3  0.0000      0.957 0.000 0.000 1.000 0.000 0.000
#> SRR1736366     3  0.0000      0.957 0.000 0.000 1.000 0.000 0.000
#> SRR1736367     3  0.0000      0.957 0.000 0.000 1.000 0.000 0.000
#> SRR1736368     3  0.0000      0.957 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
#> SRR1736309     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736310     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736312     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736311     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736313     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736314     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736315     6  0.2730      1.000 0.000 0.192 0.000 0.000 0.000 0.808
#> SRR1736316     6  0.2730      1.000 0.000 0.192 0.000 0.000 0.000 0.808
#> SRR1736317     6  0.2730      1.000 0.000 0.192 0.000 0.000 0.000 0.808
#> SRR1736318     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736319     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736320     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736321     6  0.2730      1.000 0.000 0.192 0.000 0.000 0.000 0.808
#> SRR1736322     6  0.2730      1.000 0.000 0.192 0.000 0.000 0.000 0.808
#> SRR1736323     6  0.2730      1.000 0.000 0.192 0.000 0.000 0.000 0.808
#> SRR1736324     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736325     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736326     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736328     4  0.1501      1.000 0.000 0.076 0.000 0.924 0.000 0.000
#> SRR1736327     4  0.1501      1.000 0.000 0.076 0.000 0.924 0.000 0.000
#> SRR1736329     4  0.1501      1.000 0.000 0.076 0.000 0.924 0.000 0.000
#> SRR1736330     4  0.1501      1.000 0.000 0.076 0.000 0.924 0.000 0.000
#> SRR1736331     4  0.1501      1.000 0.000 0.076 0.000 0.924 0.000 0.000
#> SRR1736332     4  0.1501      1.000 0.000 0.076 0.000 0.924 0.000 0.000
#> SRR1736333     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1736334     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1736335     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1736337     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1736336     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1736338     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1736339     1  0.4974      0.777 0.648 0.000 0.000 0.000 0.160 0.192
#> SRR1736340     1  0.4974      0.777 0.648 0.000 0.000 0.000 0.160 0.192
#> SRR1736341     1  0.4942      0.779 0.652 0.000 0.000 0.000 0.156 0.192
#> SRR1736342     1  0.0000      0.841 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1736343     1  0.0000      0.841 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1736344     1  0.0000      0.841 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1736345     1  0.4974      0.777 0.648 0.000 0.000 0.000 0.160 0.192
#> SRR1736346     1  0.4974      0.777 0.648 0.000 0.000 0.000 0.160 0.192
#> SRR1736348     1  0.0000      0.841 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1736347     1  0.4974      0.777 0.648 0.000 0.000 0.000 0.160 0.192
#> SRR1736349     1  0.0000      0.841 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1736350     1  0.0000      0.841 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1736351     1  0.2730      0.834 0.808 0.000 0.000 0.000 0.000 0.192
#> SRR1736352     1  0.2730      0.834 0.808 0.000 0.000 0.000 0.000 0.192
#> SRR1736353     1  0.2730      0.834 0.808 0.000 0.000 0.000 0.000 0.192
#> SRR1736354     1  0.0000      0.841 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1736355     1  0.0000      0.841 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1736356     3  0.5303      0.472 0.296 0.000 0.604 0.076 0.024 0.000
#> SRR1736358     3  0.0291      0.961 0.000 0.000 0.992 0.004 0.004 0.000
#> SRR1736357     3  0.0291      0.961 0.000 0.000 0.992 0.004 0.004 0.000
#> SRR1736359     3  0.0291      0.961 0.000 0.000 0.992 0.004 0.004 0.000
#> SRR1736360     3  0.0000      0.964 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736361     3  0.0000      0.964 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736362     3  0.0000      0.964 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736363     3  0.0000      0.964 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736365     3  0.0000      0.964 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736364     3  0.0000      0.964 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736366     3  0.0000      0.964 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736367     3  0.0000      0.964 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736368     3  0.0000      0.964 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-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 15454 rows and 60 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#>   Subgroups are detected by 'NMF' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 6.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk CV-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4886 0.512   0.512
#> 3 3 0.741           0.924       0.905         0.3014 0.831   0.670
#> 4 4 0.838           0.909       0.896         0.1341 0.919   0.773
#> 5 5 0.924           0.973       0.967         0.0886 0.924   0.735
#> 6 6 1.000           0.987       0.983         0.0420 0.969   0.856

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette p1 p2
#> SRR1736309     2       0          1  0  1
#> SRR1736310     2       0          1  0  1
#> SRR1736312     2       0          1  0  1
#> SRR1736311     2       0          1  0  1
#> SRR1736313     2       0          1  0  1
#> SRR1736314     2       0          1  0  1
#> SRR1736315     2       0          1  0  1
#> SRR1736316     2       0          1  0  1
#> SRR1736317     2       0          1  0  1
#> SRR1736318     2       0          1  0  1
#> SRR1736319     2       0          1  0  1
#> SRR1736320     2       0          1  0  1
#> SRR1736321     2       0          1  0  1
#> SRR1736322     2       0          1  0  1
#> SRR1736323     2       0          1  0  1
#> SRR1736324     2       0          1  0  1
#> SRR1736325     2       0          1  0  1
#> SRR1736326     2       0          1  0  1
#> SRR1736328     2       0          1  0  1
#> SRR1736327     2       0          1  0  1
#> SRR1736329     2       0          1  0  1
#> SRR1736330     2       0          1  0  1
#> SRR1736331     2       0          1  0  1
#> SRR1736332     2       0          1  0  1
#> SRR1736333     1       0          1  1  0
#> SRR1736334     1       0          1  1  0
#> SRR1736335     1       0          1  1  0
#> SRR1736337     1       0          1  1  0
#> SRR1736336     1       0          1  1  0
#> SRR1736338     1       0          1  1  0
#> SRR1736339     1       0          1  1  0
#> SRR1736340     1       0          1  1  0
#> SRR1736341     1       0          1  1  0
#> SRR1736342     1       0          1  1  0
#> SRR1736343     1       0          1  1  0
#> SRR1736344     1       0          1  1  0
#> SRR1736345     1       0          1  1  0
#> SRR1736346     1       0          1  1  0
#> SRR1736348     1       0          1  1  0
#> SRR1736347     1       0          1  1  0
#> SRR1736349     1       0          1  1  0
#> SRR1736350     1       0          1  1  0
#> SRR1736351     1       0          1  1  0
#> SRR1736352     1       0          1  1  0
#> SRR1736353     1       0          1  1  0
#> SRR1736354     1       0          1  1  0
#> SRR1736355     1       0          1  1  0
#> SRR1736356     1       0          1  1  0
#> SRR1736358     1       0          1  1  0
#> SRR1736357     1       0          1  1  0
#> SRR1736359     1       0          1  1  0
#> SRR1736360     1       0          1  1  0
#> SRR1736361     1       0          1  1  0
#> SRR1736362     1       0          1  1  0
#> SRR1736363     1       0          1  1  0
#> SRR1736365     1       0          1  1  0
#> SRR1736364     1       0          1  1  0
#> SRR1736366     1       0          1  1  0
#> SRR1736367     1       0          1  1  0
#> SRR1736368     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
#> SRR1736309     2   0.000      0.943 0.000 1.000 0.000
#> SRR1736310     2   0.000      0.943 0.000 1.000 0.000
#> SRR1736312     2   0.000      0.943 0.000 1.000 0.000
#> SRR1736311     2   0.000      0.943 0.000 1.000 0.000
#> SRR1736313     2   0.000      0.943 0.000 1.000 0.000
#> SRR1736314     2   0.000      0.943 0.000 1.000 0.000
#> SRR1736315     2   0.236      0.934 0.072 0.928 0.000
#> SRR1736316     2   0.216      0.936 0.064 0.936 0.000
#> SRR1736317     2   0.236      0.934 0.072 0.928 0.000
#> SRR1736318     2   0.000      0.943 0.000 1.000 0.000
#> SRR1736319     2   0.000      0.943 0.000 1.000 0.000
#> SRR1736320     2   0.000      0.943 0.000 1.000 0.000
#> SRR1736321     2   0.245      0.933 0.076 0.924 0.000
#> SRR1736322     2   0.196      0.937 0.056 0.944 0.000
#> SRR1736323     2   0.153      0.940 0.040 0.960 0.000
#> SRR1736324     2   0.000      0.943 0.000 1.000 0.000
#> SRR1736325     2   0.000      0.943 0.000 1.000 0.000
#> SRR1736326     2   0.000      0.943 0.000 1.000 0.000
#> SRR1736328     2   0.489      0.871 0.228 0.772 0.000
#> SRR1736327     2   0.489      0.871 0.228 0.772 0.000
#> SRR1736329     2   0.489      0.871 0.228 0.772 0.000
#> SRR1736330     2   0.489      0.871 0.228 0.772 0.000
#> SRR1736331     2   0.489      0.871 0.228 0.772 0.000
#> SRR1736332     2   0.489      0.871 0.228 0.772 0.000
#> SRR1736333     1   0.608      0.773 0.612 0.000 0.388
#> SRR1736334     1   0.608      0.774 0.612 0.000 0.388
#> SRR1736335     3   0.394      0.716 0.156 0.000 0.844
#> SRR1736337     1   0.604      0.785 0.620 0.000 0.380
#> SRR1736336     1   0.608      0.774 0.612 0.000 0.388
#> SRR1736338     1   0.627      0.639 0.544 0.000 0.456
#> SRR1736339     1   0.489      0.947 0.772 0.000 0.228
#> SRR1736340     1   0.489      0.947 0.772 0.000 0.228
#> SRR1736341     1   0.489      0.947 0.772 0.000 0.228
#> SRR1736342     1   0.489      0.947 0.772 0.000 0.228
#> SRR1736343     1   0.489      0.947 0.772 0.000 0.228
#> SRR1736344     1   0.489      0.947 0.772 0.000 0.228
#> SRR1736345     1   0.489      0.947 0.772 0.000 0.228
#> SRR1736346     1   0.489      0.947 0.772 0.000 0.228
#> SRR1736348     1   0.489      0.947 0.772 0.000 0.228
#> SRR1736347     1   0.489      0.947 0.772 0.000 0.228
#> SRR1736349     1   0.489      0.947 0.772 0.000 0.228
#> SRR1736350     1   0.489      0.947 0.772 0.000 0.228
#> SRR1736351     1   0.489      0.947 0.772 0.000 0.228
#> SRR1736352     1   0.489      0.947 0.772 0.000 0.228
#> SRR1736353     1   0.489      0.947 0.772 0.000 0.228
#> SRR1736354     1   0.489      0.947 0.772 0.000 0.228
#> SRR1736355     1   0.489      0.947 0.772 0.000 0.228
#> SRR1736356     1   0.489      0.947 0.772 0.000 0.228
#> SRR1736358     3   0.000      0.981 0.000 0.000 1.000
#> SRR1736357     3   0.000      0.981 0.000 0.000 1.000
#> SRR1736359     3   0.000      0.981 0.000 0.000 1.000
#> SRR1736360     3   0.000      0.981 0.000 0.000 1.000
#> SRR1736361     3   0.000      0.981 0.000 0.000 1.000
#> SRR1736362     3   0.000      0.981 0.000 0.000 1.000
#> SRR1736363     3   0.000      0.981 0.000 0.000 1.000
#> SRR1736365     3   0.000      0.981 0.000 0.000 1.000
#> SRR1736364     3   0.000      0.981 0.000 0.000 1.000
#> SRR1736366     3   0.000      0.981 0.000 0.000 1.000
#> SRR1736367     3   0.000      0.981 0.000 0.000 1.000
#> SRR1736368     3   0.000      0.981 0.000 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
#> SRR1736309     2  0.0000      0.992 0.000 1.000 0.000 0.000
#> SRR1736310     2  0.0000      0.992 0.000 1.000 0.000 0.000
#> SRR1736312     2  0.0000      0.992 0.000 1.000 0.000 0.000
#> SRR1736311     2  0.0000      0.992 0.000 1.000 0.000 0.000
#> SRR1736313     2  0.0000      0.992 0.000 1.000 0.000 0.000
#> SRR1736314     2  0.0000      0.992 0.000 1.000 0.000 0.000
#> SRR1736315     2  0.0592      0.982 0.000 0.984 0.000 0.016
#> SRR1736316     2  0.0469      0.986 0.000 0.988 0.000 0.012
#> SRR1736317     2  0.0592      0.982 0.000 0.984 0.000 0.016
#> SRR1736318     2  0.0000      0.992 0.000 1.000 0.000 0.000
#> SRR1736319     2  0.0000      0.992 0.000 1.000 0.000 0.000
#> SRR1736320     2  0.0000      0.992 0.000 1.000 0.000 0.000
#> SRR1736321     2  0.0817      0.973 0.000 0.976 0.000 0.024
#> SRR1736322     2  0.0469      0.986 0.000 0.988 0.000 0.012
#> SRR1736323     2  0.0469      0.986 0.000 0.988 0.000 0.012
#> SRR1736324     2  0.0000      0.992 0.000 1.000 0.000 0.000
#> SRR1736325     2  0.0000      0.992 0.000 1.000 0.000 0.000
#> SRR1736326     2  0.0000      0.992 0.000 1.000 0.000 0.000
#> SRR1736328     4  0.4454      1.000 0.000 0.308 0.000 0.692
#> SRR1736327     4  0.4454      1.000 0.000 0.308 0.000 0.692
#> SRR1736329     4  0.4454      1.000 0.000 0.308 0.000 0.692
#> SRR1736330     4  0.4454      1.000 0.000 0.308 0.000 0.692
#> SRR1736331     4  0.4454      1.000 0.000 0.308 0.000 0.692
#> SRR1736332     4  0.4454      1.000 0.000 0.308 0.000 0.692
#> SRR1736333     1  0.2408      0.792 0.896 0.000 0.104 0.000
#> SRR1736334     1  0.2647      0.781 0.880 0.000 0.120 0.000
#> SRR1736335     1  0.4817      0.322 0.612 0.000 0.388 0.000
#> SRR1736337     1  0.2149      0.801 0.912 0.000 0.088 0.000
#> SRR1736336     1  0.2281      0.797 0.904 0.000 0.096 0.000
#> SRR1736338     1  0.2760      0.774 0.872 0.000 0.128 0.000
#> SRR1736339     1  0.4454      0.774 0.692 0.000 0.000 0.308
#> SRR1736340     1  0.4454      0.774 0.692 0.000 0.000 0.308
#> SRR1736341     1  0.4454      0.774 0.692 0.000 0.000 0.308
#> SRR1736342     1  0.0000      0.837 1.000 0.000 0.000 0.000
#> SRR1736343     1  0.0000      0.837 1.000 0.000 0.000 0.000
#> SRR1736344     1  0.0000      0.837 1.000 0.000 0.000 0.000
#> SRR1736345     1  0.4454      0.774 0.692 0.000 0.000 0.308
#> SRR1736346     1  0.4454      0.774 0.692 0.000 0.000 0.308
#> SRR1736348     1  0.0000      0.837 1.000 0.000 0.000 0.000
#> SRR1736347     1  0.4454      0.774 0.692 0.000 0.000 0.308
#> SRR1736349     1  0.0000      0.837 1.000 0.000 0.000 0.000
#> SRR1736350     1  0.0000      0.837 1.000 0.000 0.000 0.000
#> SRR1736351     1  0.4454      0.774 0.692 0.000 0.000 0.308
#> SRR1736352     1  0.4454      0.774 0.692 0.000 0.000 0.308
#> SRR1736353     1  0.4454      0.774 0.692 0.000 0.000 0.308
#> SRR1736354     1  0.0000      0.837 1.000 0.000 0.000 0.000
#> SRR1736355     1  0.0000      0.837 1.000 0.000 0.000 0.000
#> SRR1736356     1  0.0000      0.837 1.000 0.000 0.000 0.000
#> SRR1736358     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1736357     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1736359     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1736360     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1736361     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1736362     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1736363     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1736365     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1736364     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1736366     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1736367     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1736368     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
#> SRR1736309     2  0.0000      0.996 0.000 1.000 0.000 0.000 0.000
#> SRR1736310     2  0.0000      0.996 0.000 1.000 0.000 0.000 0.000
#> SRR1736312     2  0.0000      0.996 0.000 1.000 0.000 0.000 0.000
#> SRR1736311     2  0.0000      0.996 0.000 1.000 0.000 0.000 0.000
#> SRR1736313     2  0.0000      0.996 0.000 1.000 0.000 0.000 0.000
#> SRR1736314     2  0.0000      0.996 0.000 1.000 0.000 0.000 0.000
#> SRR1736315     2  0.0451      0.990 0.000 0.988 0.000 0.008 0.004
#> SRR1736316     2  0.0324      0.993 0.000 0.992 0.000 0.004 0.004
#> SRR1736317     2  0.0451      0.990 0.000 0.988 0.000 0.008 0.004
#> SRR1736318     2  0.0000      0.996 0.000 1.000 0.000 0.000 0.000
#> SRR1736319     2  0.0000      0.996 0.000 1.000 0.000 0.000 0.000
#> SRR1736320     2  0.0000      0.996 0.000 1.000 0.000 0.000 0.000
#> SRR1736321     2  0.0865      0.976 0.000 0.972 0.000 0.024 0.004
#> SRR1736322     2  0.0451      0.990 0.000 0.988 0.000 0.008 0.004
#> SRR1736323     2  0.0324      0.993 0.000 0.992 0.000 0.004 0.004
#> SRR1736324     2  0.0000      0.996 0.000 1.000 0.000 0.000 0.000
#> SRR1736325     2  0.0000      0.996 0.000 1.000 0.000 0.000 0.000
#> SRR1736326     2  0.0000      0.996 0.000 1.000 0.000 0.000 0.000
#> SRR1736328     4  0.1410      1.000 0.000 0.060 0.000 0.940 0.000
#> SRR1736327     4  0.1410      1.000 0.000 0.060 0.000 0.940 0.000
#> SRR1736329     4  0.1410      1.000 0.000 0.060 0.000 0.940 0.000
#> SRR1736330     4  0.1410      1.000 0.000 0.060 0.000 0.940 0.000
#> SRR1736331     4  0.1410      1.000 0.000 0.060 0.000 0.940 0.000
#> SRR1736332     4  0.1410      1.000 0.000 0.060 0.000 0.940 0.000
#> SRR1736333     5  0.1571      0.883 0.000 0.000 0.004 0.060 0.936
#> SRR1736334     5  0.1571      0.883 0.000 0.000 0.004 0.060 0.936
#> SRR1736335     5  0.1571      0.883 0.000 0.000 0.004 0.060 0.936
#> SRR1736337     5  0.1571      0.883 0.000 0.000 0.004 0.060 0.936
#> SRR1736336     5  0.1571      0.883 0.000 0.000 0.004 0.060 0.936
#> SRR1736338     5  0.1571      0.883 0.000 0.000 0.004 0.060 0.936
#> SRR1736339     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736340     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736341     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736342     5  0.2280      0.920 0.120 0.000 0.000 0.000 0.880
#> SRR1736343     5  0.2280      0.920 0.120 0.000 0.000 0.000 0.880
#> SRR1736344     5  0.2280      0.920 0.120 0.000 0.000 0.000 0.880
#> SRR1736345     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736346     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736348     5  0.2280      0.920 0.120 0.000 0.000 0.000 0.880
#> SRR1736347     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736349     5  0.2280      0.920 0.120 0.000 0.000 0.000 0.880
#> SRR1736350     5  0.2280      0.920 0.120 0.000 0.000 0.000 0.880
#> SRR1736351     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736352     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736353     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736354     5  0.2280      0.920 0.120 0.000 0.000 0.000 0.880
#> SRR1736355     5  0.2280      0.920 0.120 0.000 0.000 0.000 0.880
#> SRR1736356     5  0.2411      0.917 0.108 0.000 0.008 0.000 0.884
#> SRR1736358     3  0.0162      0.994 0.000 0.000 0.996 0.000 0.004
#> SRR1736357     3  0.0162      0.994 0.000 0.000 0.996 0.000 0.004
#> SRR1736359     3  0.0162      0.994 0.000 0.000 0.996 0.000 0.004
#> SRR1736360     3  0.0404      0.990 0.000 0.000 0.988 0.000 0.012
#> SRR1736361     3  0.0404      0.990 0.000 0.000 0.988 0.000 0.012
#> SRR1736362     3  0.0510      0.987 0.000 0.000 0.984 0.000 0.016
#> SRR1736363     3  0.0000      0.995 0.000 0.000 1.000 0.000 0.000
#> SRR1736365     3  0.0000      0.995 0.000 0.000 1.000 0.000 0.000
#> SRR1736364     3  0.0000      0.995 0.000 0.000 1.000 0.000 0.000
#> SRR1736366     3  0.0000      0.995 0.000 0.000 1.000 0.000 0.000
#> SRR1736367     3  0.0000      0.995 0.000 0.000 1.000 0.000 0.000
#> SRR1736368     3  0.0000      0.995 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
#> SRR1736309     2  0.0000      0.990 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736310     2  0.0000      0.990 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736312     2  0.0000      0.990 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736311     2  0.0000      0.990 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736313     2  0.0000      0.990 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736314     2  0.0000      0.990 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736315     2  0.0790      0.980 0.000 0.968 0.000 0.000 0.032 0.000
#> SRR1736316     2  0.0790      0.980 0.000 0.968 0.000 0.000 0.032 0.000
#> SRR1736317     2  0.0790      0.980 0.000 0.968 0.000 0.000 0.032 0.000
#> SRR1736318     2  0.0000      0.990 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736319     2  0.0000      0.990 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736320     2  0.0000      0.990 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736321     2  0.0790      0.980 0.000 0.968 0.000 0.000 0.032 0.000
#> SRR1736322     2  0.0790      0.980 0.000 0.968 0.000 0.000 0.032 0.000
#> SRR1736323     2  0.0790      0.980 0.000 0.968 0.000 0.000 0.032 0.000
#> SRR1736324     2  0.0000      0.990 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736325     2  0.0000      0.990 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736326     2  0.0000      0.990 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736328     4  0.0547      1.000 0.000 0.020 0.000 0.980 0.000 0.000
#> SRR1736327     4  0.0547      1.000 0.000 0.020 0.000 0.980 0.000 0.000
#> SRR1736329     4  0.0547      1.000 0.000 0.020 0.000 0.980 0.000 0.000
#> SRR1736330     4  0.0547      1.000 0.000 0.020 0.000 0.980 0.000 0.000
#> SRR1736331     4  0.0547      1.000 0.000 0.020 0.000 0.980 0.000 0.000
#> SRR1736332     4  0.0547      1.000 0.000 0.020 0.000 0.980 0.000 0.000
#> SRR1736333     5  0.0937      1.000 0.000 0.000 0.000 0.000 0.960 0.040
#> SRR1736334     5  0.0937      1.000 0.000 0.000 0.000 0.000 0.960 0.040
#> SRR1736335     5  0.0937      1.000 0.000 0.000 0.000 0.000 0.960 0.040
#> SRR1736337     5  0.0937      1.000 0.000 0.000 0.000 0.000 0.960 0.040
#> SRR1736336     5  0.0937      1.000 0.000 0.000 0.000 0.000 0.960 0.040
#> SRR1736338     5  0.0937      1.000 0.000 0.000 0.000 0.000 0.960 0.040
#> SRR1736339     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1736340     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1736341     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1736342     6  0.0363      0.999 0.012 0.000 0.000 0.000 0.000 0.988
#> SRR1736343     6  0.0363      0.999 0.012 0.000 0.000 0.000 0.000 0.988
#> SRR1736344     6  0.0363      0.999 0.012 0.000 0.000 0.000 0.000 0.988
#> SRR1736345     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1736346     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1736348     6  0.0363      0.999 0.012 0.000 0.000 0.000 0.000 0.988
#> SRR1736347     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1736349     6  0.0363      0.999 0.012 0.000 0.000 0.000 0.000 0.988
#> SRR1736350     6  0.0363      0.999 0.012 0.000 0.000 0.000 0.000 0.988
#> SRR1736351     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1736352     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1736353     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1736354     6  0.0363      0.999 0.012 0.000 0.000 0.000 0.000 0.988
#> SRR1736355     6  0.0363      0.999 0.012 0.000 0.000 0.000 0.000 0.988
#> SRR1736356     6  0.0551      0.992 0.008 0.000 0.004 0.004 0.000 0.984
#> SRR1736358     3  0.0603      0.966 0.000 0.000 0.980 0.016 0.004 0.000
#> SRR1736357     3  0.0603      0.966 0.000 0.000 0.980 0.016 0.004 0.000
#> SRR1736359     3  0.0603      0.966 0.000 0.000 0.980 0.016 0.004 0.000
#> SRR1736360     3  0.1913      0.921 0.000 0.000 0.908 0.000 0.080 0.012
#> SRR1736361     3  0.1913      0.921 0.000 0.000 0.908 0.000 0.080 0.012
#> SRR1736362     3  0.1913      0.921 0.000 0.000 0.908 0.000 0.080 0.012
#> SRR1736363     3  0.0000      0.971 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736365     3  0.0000      0.971 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736364     3  0.0000      0.971 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736366     3  0.0000      0.971 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736367     3  0.0000      0.971 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736368     3  0.0000      0.971 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-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 15454 rows and 60 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'hclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 6.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk MAD-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4886 0.512   0.512
#> 3 3 0.793           0.864       0.915         0.3081 0.831   0.670
#> 4 4 0.793           0.856       0.935         0.0244 0.993   0.980
#> 5 5 0.930           0.897       0.960         0.0665 0.985   0.955
#> 6 6 0.930           0.897       0.960         0.0873 0.939   0.810

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
#> SRR1736309     2       0          1  0  1
#> SRR1736310     2       0          1  0  1
#> SRR1736312     2       0          1  0  1
#> SRR1736311     2       0          1  0  1
#> SRR1736313     2       0          1  0  1
#> SRR1736314     2       0          1  0  1
#> SRR1736315     2       0          1  0  1
#> SRR1736316     2       0          1  0  1
#> SRR1736317     2       0          1  0  1
#> SRR1736318     2       0          1  0  1
#> SRR1736319     2       0          1  0  1
#> SRR1736320     2       0          1  0  1
#> SRR1736321     2       0          1  0  1
#> SRR1736322     2       0          1  0  1
#> SRR1736323     2       0          1  0  1
#> SRR1736324     2       0          1  0  1
#> SRR1736325     2       0          1  0  1
#> SRR1736326     2       0          1  0  1
#> SRR1736328     2       0          1  0  1
#> SRR1736327     2       0          1  0  1
#> SRR1736329     2       0          1  0  1
#> SRR1736330     2       0          1  0  1
#> SRR1736331     2       0          1  0  1
#> SRR1736332     2       0          1  0  1
#> SRR1736333     1       0          1  1  0
#> SRR1736334     1       0          1  1  0
#> SRR1736335     1       0          1  1  0
#> SRR1736337     1       0          1  1  0
#> SRR1736336     1       0          1  1  0
#> SRR1736338     1       0          1  1  0
#> SRR1736339     1       0          1  1  0
#> SRR1736340     1       0          1  1  0
#> SRR1736341     1       0          1  1  0
#> SRR1736342     1       0          1  1  0
#> SRR1736343     1       0          1  1  0
#> SRR1736344     1       0          1  1  0
#> SRR1736345     1       0          1  1  0
#> SRR1736346     1       0          1  1  0
#> SRR1736348     1       0          1  1  0
#> SRR1736347     1       0          1  1  0
#> SRR1736349     1       0          1  1  0
#> SRR1736350     1       0          1  1  0
#> SRR1736351     1       0          1  1  0
#> SRR1736352     1       0          1  1  0
#> SRR1736353     1       0          1  1  0
#> SRR1736354     1       0          1  1  0
#> SRR1736355     1       0          1  1  0
#> SRR1736356     1       0          1  1  0
#> SRR1736358     1       0          1  1  0
#> SRR1736357     1       0          1  1  0
#> SRR1736359     1       0          1  1  0
#> SRR1736360     1       0          1  1  0
#> SRR1736361     1       0          1  1  0
#> SRR1736362     1       0          1  1  0
#> SRR1736363     1       0          1  1  0
#> SRR1736365     1       0          1  1  0
#> SRR1736364     1       0          1  1  0
#> SRR1736366     1       0          1  1  0
#> SRR1736367     1       0          1  1  0
#> SRR1736368     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
#> SRR1736309     2   0.000      1.000 0.000  1 0.000
#> SRR1736310     2   0.000      1.000 0.000  1 0.000
#> SRR1736312     2   0.000      1.000 0.000  1 0.000
#> SRR1736311     2   0.000      1.000 0.000  1 0.000
#> SRR1736313     2   0.000      1.000 0.000  1 0.000
#> SRR1736314     2   0.000      1.000 0.000  1 0.000
#> SRR1736315     2   0.000      1.000 0.000  1 0.000
#> SRR1736316     2   0.000      1.000 0.000  1 0.000
#> SRR1736317     2   0.000      1.000 0.000  1 0.000
#> SRR1736318     2   0.000      1.000 0.000  1 0.000
#> SRR1736319     2   0.000      1.000 0.000  1 0.000
#> SRR1736320     2   0.000      1.000 0.000  1 0.000
#> SRR1736321     2   0.000      1.000 0.000  1 0.000
#> SRR1736322     2   0.000      1.000 0.000  1 0.000
#> SRR1736323     2   0.000      1.000 0.000  1 0.000
#> SRR1736324     2   0.000      1.000 0.000  1 0.000
#> SRR1736325     2   0.000      1.000 0.000  1 0.000
#> SRR1736326     2   0.000      1.000 0.000  1 0.000
#> SRR1736328     2   0.000      1.000 0.000  1 0.000
#> SRR1736327     2   0.000      1.000 0.000  1 0.000
#> SRR1736329     2   0.000      1.000 0.000  1 0.000
#> SRR1736330     2   0.000      1.000 0.000  1 0.000
#> SRR1736331     2   0.000      1.000 0.000  1 0.000
#> SRR1736332     2   0.000      1.000 0.000  1 0.000
#> SRR1736333     1   0.590      0.416 0.648  0 0.352
#> SRR1736334     1   0.590      0.416 0.648  0 0.352
#> SRR1736335     1   0.590      0.416 0.648  0 0.352
#> SRR1736337     1   0.590      0.416 0.648  0 0.352
#> SRR1736336     1   0.590      0.416 0.648  0 0.352
#> SRR1736338     1   0.590      0.416 0.648  0 0.352
#> SRR1736339     1   0.000      0.866 1.000  0 0.000
#> SRR1736340     1   0.000      0.866 1.000  0 0.000
#> SRR1736341     1   0.000      0.866 1.000  0 0.000
#> SRR1736342     1   0.000      0.866 1.000  0 0.000
#> SRR1736343     1   0.000      0.866 1.000  0 0.000
#> SRR1736344     1   0.000      0.866 1.000  0 0.000
#> SRR1736345     1   0.000      0.866 1.000  0 0.000
#> SRR1736346     1   0.000      0.866 1.000  0 0.000
#> SRR1736348     1   0.000      0.866 1.000  0 0.000
#> SRR1736347     1   0.000      0.866 1.000  0 0.000
#> SRR1736349     1   0.000      0.866 1.000  0 0.000
#> SRR1736350     1   0.000      0.866 1.000  0 0.000
#> SRR1736351     1   0.000      0.866 1.000  0 0.000
#> SRR1736352     1   0.000      0.866 1.000  0 0.000
#> SRR1736353     1   0.000      0.866 1.000  0 0.000
#> SRR1736354     1   0.000      0.866 1.000  0 0.000
#> SRR1736355     1   0.000      0.866 1.000  0 0.000
#> SRR1736356     3   0.603      0.253 0.376  0 0.624
#> SRR1736358     3   0.470      0.886 0.212  0 0.788
#> SRR1736357     3   0.470      0.886 0.212  0 0.788
#> SRR1736359     3   0.470      0.886 0.212  0 0.788
#> SRR1736360     3   0.186      0.791 0.052  0 0.948
#> SRR1736361     3   0.186      0.791 0.052  0 0.948
#> SRR1736362     3   0.186      0.791 0.052  0 0.948
#> SRR1736363     3   0.470      0.886 0.212  0 0.788
#> SRR1736365     3   0.470      0.886 0.212  0 0.788
#> SRR1736364     3   0.470      0.886 0.212  0 0.788
#> SRR1736366     3   0.470      0.886 0.212  0 0.788
#> SRR1736367     3   0.470      0.886 0.212  0 0.788
#> SRR1736368     3   0.470      0.886 0.212  0 0.788

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1 p2    p3 p4
#> SRR1736309     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736310     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736312     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736311     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736313     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736314     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736315     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736316     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736317     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736318     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736319     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736320     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736321     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736322     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736323     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736324     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736325     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736326     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736328     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736327     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736329     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736330     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736331     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736332     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736333     1   0.485      0.344 0.600  0 0.400  0
#> SRR1736334     1   0.485      0.344 0.600  0 0.400  0
#> SRR1736335     1   0.485      0.344 0.600  0 0.400  0
#> SRR1736337     1   0.485      0.344 0.600  0 0.400  0
#> SRR1736336     1   0.485      0.344 0.600  0 0.400  0
#> SRR1736338     1   0.485      0.344 0.600  0 0.400  0
#> SRR1736339     1   0.000      0.859 1.000  0 0.000  0
#> SRR1736340     1   0.000      0.859 1.000  0 0.000  0
#> SRR1736341     1   0.000      0.859 1.000  0 0.000  0
#> SRR1736342     1   0.000      0.859 1.000  0 0.000  0
#> SRR1736343     1   0.000      0.859 1.000  0 0.000  0
#> SRR1736344     1   0.000      0.859 1.000  0 0.000  0
#> SRR1736345     1   0.000      0.859 1.000  0 0.000  0
#> SRR1736346     1   0.000      0.859 1.000  0 0.000  0
#> SRR1736348     1   0.000      0.859 1.000  0 0.000  0
#> SRR1736347     1   0.000      0.859 1.000  0 0.000  0
#> SRR1736349     1   0.000      0.859 1.000  0 0.000  0
#> SRR1736350     1   0.000      0.859 1.000  0 0.000  0
#> SRR1736351     1   0.000      0.859 1.000  0 0.000  0
#> SRR1736352     1   0.000      0.859 1.000  0 0.000  0
#> SRR1736353     1   0.000      0.859 1.000  0 0.000  0
#> SRR1736354     1   0.000      0.859 1.000  0 0.000  0
#> SRR1736355     1   0.000      0.859 1.000  0 0.000  0
#> SRR1736356     4   0.000      0.000 0.000  0 0.000  1
#> SRR1736358     3   0.322      0.931 0.164  0 0.836  0
#> SRR1736357     3   0.322      0.931 0.164  0 0.836  0
#> SRR1736359     3   0.322      0.931 0.164  0 0.836  0
#> SRR1736360     3   0.000      0.767 0.000  0 1.000  0
#> SRR1736361     3   0.000      0.767 0.000  0 1.000  0
#> SRR1736362     3   0.000      0.767 0.000  0 1.000  0
#> SRR1736363     3   0.322      0.931 0.164  0 0.836  0
#> SRR1736365     3   0.322      0.931 0.164  0 0.836  0
#> SRR1736364     3   0.322      0.931 0.164  0 0.836  0
#> SRR1736366     3   0.322      0.931 0.164  0 0.836  0
#> SRR1736367     3   0.322      0.931 0.164  0 0.836  0
#> SRR1736368     3   0.322      0.931 0.164  0 0.836  0

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette  p1 p2 p3  p4  p5
#> SRR1736309     2   0.000      1.000 0.0  1  0 0.0 0.0
#> SRR1736310     2   0.000      1.000 0.0  1  0 0.0 0.0
#> SRR1736312     2   0.000      1.000 0.0  1  0 0.0 0.0
#> SRR1736311     2   0.000      1.000 0.0  1  0 0.0 0.0
#> SRR1736313     2   0.000      1.000 0.0  1  0 0.0 0.0
#> SRR1736314     2   0.000      1.000 0.0  1  0 0.0 0.0
#> SRR1736315     2   0.000      1.000 0.0  1  0 0.0 0.0
#> SRR1736316     2   0.000      1.000 0.0  1  0 0.0 0.0
#> SRR1736317     2   0.000      1.000 0.0  1  0 0.0 0.0
#> SRR1736318     2   0.000      1.000 0.0  1  0 0.0 0.0
#> SRR1736319     2   0.000      1.000 0.0  1  0 0.0 0.0
#> SRR1736320     2   0.000      1.000 0.0  1  0 0.0 0.0
#> SRR1736321     2   0.000      1.000 0.0  1  0 0.0 0.0
#> SRR1736322     2   0.000      1.000 0.0  1  0 0.0 0.0
#> SRR1736323     2   0.000      1.000 0.0  1  0 0.0 0.0
#> SRR1736324     2   0.000      1.000 0.0  1  0 0.0 0.0
#> SRR1736325     2   0.000      1.000 0.0  1  0 0.0 0.0
#> SRR1736326     2   0.000      1.000 0.0  1  0 0.0 0.0
#> SRR1736328     2   0.000      1.000 0.0  1  0 0.0 0.0
#> SRR1736327     2   0.000      1.000 0.0  1  0 0.0 0.0
#> SRR1736329     2   0.000      1.000 0.0  1  0 0.0 0.0
#> SRR1736330     2   0.000      1.000 0.0  1  0 0.0 0.0
#> SRR1736331     2   0.000      1.000 0.0  1  0 0.0 0.0
#> SRR1736332     2   0.000      1.000 0.0  1  0 0.0 0.0
#> SRR1736333     1   0.418      0.485 0.6  0  0 0.4 0.0
#> SRR1736334     1   0.418      0.485 0.6  0  0 0.4 0.0
#> SRR1736335     1   0.418      0.485 0.6  0  0 0.4 0.0
#> SRR1736337     1   0.418      0.485 0.6  0  0 0.4 0.0
#> SRR1736336     1   0.418      0.485 0.6  0  0 0.4 0.0
#> SRR1736338     1   0.418      0.485 0.6  0  0 0.4 0.0
#> SRR1736339     1   0.000      0.876 1.0  0  0 0.0 0.0
#> SRR1736340     1   0.000      0.876 1.0  0  0 0.0 0.0
#> SRR1736341     1   0.000      0.876 1.0  0  0 0.0 0.0
#> SRR1736342     1   0.000      0.876 1.0  0  0 0.0 0.0
#> SRR1736343     1   0.000      0.876 1.0  0  0 0.0 0.0
#> SRR1736344     1   0.000      0.876 1.0  0  0 0.0 0.0
#> SRR1736345     1   0.000      0.876 1.0  0  0 0.0 0.0
#> SRR1736346     1   0.000      0.876 1.0  0  0 0.0 0.0
#> SRR1736348     1   0.000      0.876 1.0  0  0 0.0 0.0
#> SRR1736347     1   0.000      0.876 1.0  0  0 0.0 0.0
#> SRR1736349     1   0.000      0.876 1.0  0  0 0.0 0.0
#> SRR1736350     1   0.000      0.876 1.0  0  0 0.0 0.0
#> SRR1736351     1   0.000      0.876 1.0  0  0 0.0 0.0
#> SRR1736352     1   0.000      0.876 1.0  0  0 0.0 0.0
#> SRR1736353     1   0.000      0.876 1.0  0  0 0.0 0.0
#> SRR1736354     1   0.000      0.876 1.0  0  0 0.0 0.0
#> SRR1736355     1   0.000      0.876 1.0  0  0 0.0 0.0
#> SRR1736356     4   0.418      0.000 0.0  0  0 0.6 0.4
#> SRR1736358     3   0.000      1.000 0.0  0  1 0.0 0.0
#> SRR1736357     3   0.000      1.000 0.0  0  1 0.0 0.0
#> SRR1736359     3   0.000      1.000 0.0  0  1 0.0 0.0
#> SRR1736360     5   0.418      1.000 0.0  0  0 0.4 0.6
#> SRR1736361     5   0.418      1.000 0.0  0  0 0.4 0.6
#> SRR1736362     5   0.418      1.000 0.0  0  0 0.4 0.6
#> SRR1736363     3   0.000      1.000 0.0  0  1 0.0 0.0
#> SRR1736365     3   0.000      1.000 0.0  0  1 0.0 0.0
#> SRR1736364     3   0.000      1.000 0.0  0  1 0.0 0.0
#> SRR1736366     3   0.000      1.000 0.0  0  1 0.0 0.0
#> SRR1736367     3   0.000      1.000 0.0  0  1 0.0 0.0
#> SRR1736368     3   0.000      1.000 0.0  0  1 0.0 0.0

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette  p1 p2 p3 p4  p5  p6
#> SRR1736309     2   0.000      1.000 0.0  1  0  0 0.0 0.0
#> SRR1736310     2   0.000      1.000 0.0  1  0  0 0.0 0.0
#> SRR1736312     2   0.000      1.000 0.0  1  0  0 0.0 0.0
#> SRR1736311     2   0.000      1.000 0.0  1  0  0 0.0 0.0
#> SRR1736313     2   0.000      1.000 0.0  1  0  0 0.0 0.0
#> SRR1736314     2   0.000      1.000 0.0  1  0  0 0.0 0.0
#> SRR1736315     2   0.000      1.000 0.0  1  0  0 0.0 0.0
#> SRR1736316     2   0.000      1.000 0.0  1  0  0 0.0 0.0
#> SRR1736317     2   0.000      1.000 0.0  1  0  0 0.0 0.0
#> SRR1736318     2   0.000      1.000 0.0  1  0  0 0.0 0.0
#> SRR1736319     2   0.000      1.000 0.0  1  0  0 0.0 0.0
#> SRR1736320     2   0.000      1.000 0.0  1  0  0 0.0 0.0
#> SRR1736321     2   0.000      1.000 0.0  1  0  0 0.0 0.0
#> SRR1736322     2   0.000      1.000 0.0  1  0  0 0.0 0.0
#> SRR1736323     2   0.000      1.000 0.0  1  0  0 0.0 0.0
#> SRR1736324     2   0.000      1.000 0.0  1  0  0 0.0 0.0
#> SRR1736325     2   0.000      1.000 0.0  1  0  0 0.0 0.0
#> SRR1736326     2   0.000      1.000 0.0  1  0  0 0.0 0.0
#> SRR1736328     4   0.000      1.000 0.0  0  0  1 0.0 0.0
#> SRR1736327     4   0.000      1.000 0.0  0  0  1 0.0 0.0
#> SRR1736329     4   0.000      1.000 0.0  0  0  1 0.0 0.0
#> SRR1736330     4   0.000      1.000 0.0  0  0  1 0.0 0.0
#> SRR1736331     4   0.000      1.000 0.0  0  0  1 0.0 0.0
#> SRR1736332     4   0.000      1.000 0.0  0  0  1 0.0 0.0
#> SRR1736333     1   0.376      0.485 0.6  0  0  0 0.0 0.4
#> SRR1736334     1   0.376      0.485 0.6  0  0  0 0.0 0.4
#> SRR1736335     1   0.376      0.485 0.6  0  0  0 0.0 0.4
#> SRR1736337     1   0.376      0.485 0.6  0  0  0 0.0 0.4
#> SRR1736336     1   0.376      0.485 0.6  0  0  0 0.0 0.4
#> SRR1736338     1   0.376      0.485 0.6  0  0  0 0.0 0.4
#> SRR1736339     1   0.000      0.876 1.0  0  0  0 0.0 0.0
#> SRR1736340     1   0.000      0.876 1.0  0  0  0 0.0 0.0
#> SRR1736341     1   0.000      0.876 1.0  0  0  0 0.0 0.0
#> SRR1736342     1   0.000      0.876 1.0  0  0  0 0.0 0.0
#> SRR1736343     1   0.000      0.876 1.0  0  0  0 0.0 0.0
#> SRR1736344     1   0.000      0.876 1.0  0  0  0 0.0 0.0
#> SRR1736345     1   0.000      0.876 1.0  0  0  0 0.0 0.0
#> SRR1736346     1   0.000      0.876 1.0  0  0  0 0.0 0.0
#> SRR1736348     1   0.000      0.876 1.0  0  0  0 0.0 0.0
#> SRR1736347     1   0.000      0.876 1.0  0  0  0 0.0 0.0
#> SRR1736349     1   0.000      0.876 1.0  0  0  0 0.0 0.0
#> SRR1736350     1   0.000      0.876 1.0  0  0  0 0.0 0.0
#> SRR1736351     1   0.000      0.876 1.0  0  0  0 0.0 0.0
#> SRR1736352     1   0.000      0.876 1.0  0  0  0 0.0 0.0
#> SRR1736353     1   0.000      0.876 1.0  0  0  0 0.0 0.0
#> SRR1736354     1   0.000      0.876 1.0  0  0  0 0.0 0.0
#> SRR1736355     1   0.000      0.876 1.0  0  0  0 0.0 0.0
#> SRR1736356     6   0.376      0.000 0.0  0  0  0 0.4 0.6
#> SRR1736358     3   0.000      1.000 0.0  0  1  0 0.0 0.0
#> SRR1736357     3   0.000      1.000 0.0  0  1  0 0.0 0.0
#> SRR1736359     3   0.000      1.000 0.0  0  1  0 0.0 0.0
#> SRR1736360     5   0.376      1.000 0.0  0  0  0 0.6 0.4
#> SRR1736361     5   0.376      1.000 0.0  0  0  0 0.6 0.4
#> SRR1736362     5   0.376      1.000 0.0  0  0  0 0.6 0.4
#> SRR1736363     3   0.000      1.000 0.0  0  1  0 0.0 0.0
#> SRR1736365     3   0.000      1.000 0.0  0  1  0 0.0 0.0
#> SRR1736364     3   0.000      1.000 0.0  0  1  0 0.0 0.0
#> SRR1736366     3   0.000      1.000 0.0  0  1  0 0.0 0.0
#> SRR1736367     3   0.000      1.000 0.0  0  1  0 0.0 0.0
#> SRR1736368     3   0.000      1.000 0.0  0  1  0 0.0 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-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 15454 rows and 60 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'kmeans' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk MAD-kmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4886 0.512   0.512
#> 3 3 0.707           0.812       0.796         0.2800 0.818   0.643
#> 4 4 0.599           0.812       0.784         0.1031 0.837   0.580
#> 5 5 0.705           0.777       0.743         0.0865 0.942   0.796
#> 6 6 0.704           0.714       0.709         0.0491 0.929   0.721

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
#> SRR1736309     2       0          1  0  1
#> SRR1736310     2       0          1  0  1
#> SRR1736312     2       0          1  0  1
#> SRR1736311     2       0          1  0  1
#> SRR1736313     2       0          1  0  1
#> SRR1736314     2       0          1  0  1
#> SRR1736315     2       0          1  0  1
#> SRR1736316     2       0          1  0  1
#> SRR1736317     2       0          1  0  1
#> SRR1736318     2       0          1  0  1
#> SRR1736319     2       0          1  0  1
#> SRR1736320     2       0          1  0  1
#> SRR1736321     2       0          1  0  1
#> SRR1736322     2       0          1  0  1
#> SRR1736323     2       0          1  0  1
#> SRR1736324     2       0          1  0  1
#> SRR1736325     2       0          1  0  1
#> SRR1736326     2       0          1  0  1
#> SRR1736328     2       0          1  0  1
#> SRR1736327     2       0          1  0  1
#> SRR1736329     2       0          1  0  1
#> SRR1736330     2       0          1  0  1
#> SRR1736331     2       0          1  0  1
#> SRR1736332     2       0          1  0  1
#> SRR1736333     1       0          1  1  0
#> SRR1736334     1       0          1  1  0
#> SRR1736335     1       0          1  1  0
#> SRR1736337     1       0          1  1  0
#> SRR1736336     1       0          1  1  0
#> SRR1736338     1       0          1  1  0
#> SRR1736339     1       0          1  1  0
#> SRR1736340     1       0          1  1  0
#> SRR1736341     1       0          1  1  0
#> SRR1736342     1       0          1  1  0
#> SRR1736343     1       0          1  1  0
#> SRR1736344     1       0          1  1  0
#> SRR1736345     1       0          1  1  0
#> SRR1736346     1       0          1  1  0
#> SRR1736348     1       0          1  1  0
#> SRR1736347     1       0          1  1  0
#> SRR1736349     1       0          1  1  0
#> SRR1736350     1       0          1  1  0
#> SRR1736351     1       0          1  1  0
#> SRR1736352     1       0          1  1  0
#> SRR1736353     1       0          1  1  0
#> SRR1736354     1       0          1  1  0
#> SRR1736355     1       0          1  1  0
#> SRR1736356     1       0          1  1  0
#> SRR1736358     1       0          1  1  0
#> SRR1736357     1       0          1  1  0
#> SRR1736359     1       0          1  1  0
#> SRR1736360     1       0          1  1  0
#> SRR1736361     1       0          1  1  0
#> SRR1736362     1       0          1  1  0
#> SRR1736363     1       0          1  1  0
#> SRR1736365     1       0          1  1  0
#> SRR1736364     1       0          1  1  0
#> SRR1736366     1       0          1  1  0
#> SRR1736367     1       0          1  1  0
#> SRR1736368     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
#> SRR1736309     2  0.0000      0.935 0.000 1.000 0.000
#> SRR1736310     2  0.0000      0.935 0.000 1.000 0.000
#> SRR1736312     2  0.0000      0.935 0.000 1.000 0.000
#> SRR1736311     2  0.0000      0.935 0.000 1.000 0.000
#> SRR1736313     2  0.0000      0.935 0.000 1.000 0.000
#> SRR1736314     2  0.0000      0.935 0.000 1.000 0.000
#> SRR1736315     2  0.0000      0.935 0.000 1.000 0.000
#> SRR1736316     2  0.0000      0.935 0.000 1.000 0.000
#> SRR1736317     2  0.0000      0.935 0.000 1.000 0.000
#> SRR1736318     2  0.0000      0.935 0.000 1.000 0.000
#> SRR1736319     2  0.0000      0.935 0.000 1.000 0.000
#> SRR1736320     2  0.0000      0.935 0.000 1.000 0.000
#> SRR1736321     2  0.0000      0.935 0.000 1.000 0.000
#> SRR1736322     2  0.0000      0.935 0.000 1.000 0.000
#> SRR1736323     2  0.0000      0.935 0.000 1.000 0.000
#> SRR1736324     2  0.0000      0.935 0.000 1.000 0.000
#> SRR1736325     2  0.0000      0.935 0.000 1.000 0.000
#> SRR1736326     2  0.0000      0.935 0.000 1.000 0.000
#> SRR1736328     2  0.5678      0.785 0.316 0.684 0.000
#> SRR1736327     2  0.5678      0.785 0.316 0.684 0.000
#> SRR1736329     2  0.5678      0.785 0.316 0.684 0.000
#> SRR1736330     2  0.5678      0.785 0.316 0.684 0.000
#> SRR1736331     2  0.5678      0.785 0.316 0.684 0.000
#> SRR1736332     2  0.5678      0.785 0.316 0.684 0.000
#> SRR1736333     3  0.6026      0.141 0.376 0.000 0.624
#> SRR1736334     3  0.6026      0.141 0.376 0.000 0.624
#> SRR1736335     3  0.6026      0.141 0.376 0.000 0.624
#> SRR1736337     3  0.6026      0.141 0.376 0.000 0.624
#> SRR1736336     3  0.6026      0.141 0.376 0.000 0.624
#> SRR1736338     3  0.6026      0.141 0.376 0.000 0.624
#> SRR1736339     1  0.5760      0.972 0.672 0.000 0.328
#> SRR1736340     1  0.5760      0.972 0.672 0.000 0.328
#> SRR1736341     1  0.5760      0.972 0.672 0.000 0.328
#> SRR1736342     1  0.5859      0.981 0.656 0.000 0.344
#> SRR1736343     1  0.5859      0.981 0.656 0.000 0.344
#> SRR1736344     1  0.5859      0.981 0.656 0.000 0.344
#> SRR1736345     1  0.5760      0.972 0.672 0.000 0.328
#> SRR1736346     1  0.5760      0.972 0.672 0.000 0.328
#> SRR1736348     1  0.5859      0.981 0.656 0.000 0.344
#> SRR1736347     1  0.5760      0.972 0.672 0.000 0.328
#> SRR1736349     1  0.5859      0.981 0.656 0.000 0.344
#> SRR1736350     1  0.5859      0.981 0.656 0.000 0.344
#> SRR1736351     1  0.5859      0.981 0.656 0.000 0.344
#> SRR1736352     1  0.5859      0.981 0.656 0.000 0.344
#> SRR1736353     1  0.5859      0.981 0.656 0.000 0.344
#> SRR1736354     1  0.5859      0.981 0.656 0.000 0.344
#> SRR1736355     1  0.5859      0.981 0.656 0.000 0.344
#> SRR1736356     3  0.3686      0.669 0.140 0.000 0.860
#> SRR1736358     3  0.1964      0.743 0.056 0.000 0.944
#> SRR1736357     3  0.1964      0.743 0.056 0.000 0.944
#> SRR1736359     3  0.1964      0.743 0.056 0.000 0.944
#> SRR1736360     3  0.0892      0.755 0.020 0.000 0.980
#> SRR1736361     3  0.0892      0.755 0.020 0.000 0.980
#> SRR1736362     3  0.0892      0.755 0.020 0.000 0.980
#> SRR1736363     3  0.0424      0.764 0.008 0.000 0.992
#> SRR1736365     3  0.0424      0.764 0.008 0.000 0.992
#> SRR1736364     3  0.0424      0.764 0.008 0.000 0.992
#> SRR1736366     3  0.0424      0.764 0.008 0.000 0.992
#> SRR1736367     3  0.0424      0.764 0.008 0.000 0.992
#> SRR1736368     3  0.0424      0.764 0.008 0.000 0.992

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1736309     2  0.0000      0.905 0.000 1.000 0.000 0.000
#> SRR1736310     2  0.0000      0.905 0.000 1.000 0.000 0.000
#> SRR1736312     2  0.0000      0.905 0.000 1.000 0.000 0.000
#> SRR1736311     2  0.0000      0.905 0.000 1.000 0.000 0.000
#> SRR1736313     2  0.0000      0.905 0.000 1.000 0.000 0.000
#> SRR1736314     2  0.0000      0.905 0.000 1.000 0.000 0.000
#> SRR1736315     2  0.3123      0.794 0.156 0.844 0.000 0.000
#> SRR1736316     2  0.3123      0.794 0.156 0.844 0.000 0.000
#> SRR1736317     2  0.3123      0.794 0.156 0.844 0.000 0.000
#> SRR1736318     2  0.0000      0.905 0.000 1.000 0.000 0.000
#> SRR1736319     2  0.0000      0.905 0.000 1.000 0.000 0.000
#> SRR1736320     2  0.0000      0.905 0.000 1.000 0.000 0.000
#> SRR1736321     2  0.3123      0.794 0.156 0.844 0.000 0.000
#> SRR1736322     2  0.3123      0.794 0.156 0.844 0.000 0.000
#> SRR1736323     2  0.3123      0.794 0.156 0.844 0.000 0.000
#> SRR1736324     2  0.0000      0.905 0.000 1.000 0.000 0.000
#> SRR1736325     2  0.0000      0.905 0.000 1.000 0.000 0.000
#> SRR1736326     2  0.0000      0.905 0.000 1.000 0.000 0.000
#> SRR1736328     4  0.4981      0.993 0.000 0.464 0.000 0.536
#> SRR1736327     4  0.5500      0.987 0.016 0.464 0.000 0.520
#> SRR1736329     4  0.5500      0.987 0.016 0.464 0.000 0.520
#> SRR1736330     4  0.4981      0.993 0.000 0.464 0.000 0.536
#> SRR1736331     4  0.4981      0.993 0.000 0.464 0.000 0.536
#> SRR1736332     4  0.4981      0.993 0.000 0.464 0.000 0.536
#> SRR1736333     1  0.7425      0.491 0.420 0.000 0.412 0.168
#> SRR1736334     1  0.7425      0.491 0.420 0.000 0.412 0.168
#> SRR1736335     1  0.7425      0.491 0.420 0.000 0.412 0.168
#> SRR1736337     1  0.7425      0.491 0.420 0.000 0.412 0.168
#> SRR1736336     1  0.7425      0.491 0.420 0.000 0.412 0.168
#> SRR1736338     1  0.7425      0.491 0.420 0.000 0.412 0.168
#> SRR1736339     1  0.6513      0.788 0.640 0.000 0.180 0.180
#> SRR1736340     1  0.6513      0.788 0.640 0.000 0.180 0.180
#> SRR1736341     1  0.6513      0.788 0.640 0.000 0.180 0.180
#> SRR1736342     1  0.3400      0.784 0.820 0.000 0.180 0.000
#> SRR1736343     1  0.3400      0.784 0.820 0.000 0.180 0.000
#> SRR1736344     1  0.3400      0.784 0.820 0.000 0.180 0.000
#> SRR1736345     1  0.6513      0.788 0.640 0.000 0.180 0.180
#> SRR1736346     1  0.6513      0.788 0.640 0.000 0.180 0.180
#> SRR1736348     1  0.3725      0.783 0.812 0.000 0.180 0.008
#> SRR1736347     1  0.6513      0.788 0.640 0.000 0.180 0.180
#> SRR1736349     1  0.3725      0.783 0.812 0.000 0.180 0.008
#> SRR1736350     1  0.3725      0.783 0.812 0.000 0.180 0.008
#> SRR1736351     1  0.6274      0.787 0.664 0.000 0.184 0.152
#> SRR1736352     1  0.6274      0.787 0.664 0.000 0.184 0.152
#> SRR1736353     1  0.6274      0.787 0.664 0.000 0.184 0.152
#> SRR1736354     1  0.3725      0.783 0.812 0.000 0.180 0.008
#> SRR1736355     1  0.3725      0.783 0.812 0.000 0.180 0.008
#> SRR1736356     3  0.6908      0.600 0.220 0.000 0.592 0.188
#> SRR1736358     3  0.4773      0.799 0.120 0.000 0.788 0.092
#> SRR1736357     3  0.4773      0.799 0.120 0.000 0.788 0.092
#> SRR1736359     3  0.4773      0.799 0.120 0.000 0.788 0.092
#> SRR1736360     3  0.2466      0.844 0.004 0.000 0.900 0.096
#> SRR1736361     3  0.2466      0.844 0.004 0.000 0.900 0.096
#> SRR1736362     3  0.2466      0.844 0.004 0.000 0.900 0.096
#> SRR1736363     3  0.0895      0.887 0.020 0.000 0.976 0.004
#> SRR1736365     3  0.0895      0.887 0.020 0.000 0.976 0.004
#> SRR1736364     3  0.0895      0.887 0.020 0.000 0.976 0.004
#> SRR1736366     3  0.0895      0.887 0.020 0.000 0.976 0.004
#> SRR1736367     3  0.0895      0.887 0.020 0.000 0.976 0.004
#> SRR1736368     3  0.0895      0.887 0.020 0.000 0.976 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
#> SRR1736309     2  0.0404      0.883 0.012 0.988 0.000 0.000 0.000
#> SRR1736310     2  0.0000      0.885 0.000 1.000 0.000 0.000 0.000
#> SRR1736312     2  0.0000      0.885 0.000 1.000 0.000 0.000 0.000
#> SRR1736311     2  0.0000      0.885 0.000 1.000 0.000 0.000 0.000
#> SRR1736313     2  0.0404      0.883 0.012 0.988 0.000 0.000 0.000
#> SRR1736314     2  0.0000      0.885 0.000 1.000 0.000 0.000 0.000
#> SRR1736315     2  0.4164      0.769 0.096 0.784 0.120 0.000 0.000
#> SRR1736316     2  0.4164      0.769 0.096 0.784 0.120 0.000 0.000
#> SRR1736317     2  0.4164      0.769 0.096 0.784 0.120 0.000 0.000
#> SRR1736318     2  0.0510      0.885 0.016 0.984 0.000 0.000 0.000
#> SRR1736319     2  0.0510      0.885 0.016 0.984 0.000 0.000 0.000
#> SRR1736320     2  0.0794      0.883 0.028 0.972 0.000 0.000 0.000
#> SRR1736321     2  0.4169      0.769 0.100 0.784 0.116 0.000 0.000
#> SRR1736322     2  0.4169      0.769 0.100 0.784 0.116 0.000 0.000
#> SRR1736323     2  0.4169      0.769 0.100 0.784 0.116 0.000 0.000
#> SRR1736324     2  0.0510      0.885 0.016 0.984 0.000 0.000 0.000
#> SRR1736325     2  0.0510      0.885 0.016 0.984 0.000 0.000 0.000
#> SRR1736326     2  0.0510      0.885 0.016 0.984 0.000 0.000 0.000
#> SRR1736328     4  0.4015      0.990 0.000 0.348 0.000 0.652 0.000
#> SRR1736327     4  0.4852      0.981 0.016 0.348 0.012 0.624 0.000
#> SRR1736329     4  0.4852      0.981 0.016 0.348 0.012 0.624 0.000
#> SRR1736330     4  0.4015      0.990 0.000 0.348 0.000 0.652 0.000
#> SRR1736331     4  0.4015      0.990 0.000 0.348 0.000 0.652 0.000
#> SRR1736332     4  0.4015      0.990 0.000 0.348 0.000 0.652 0.000
#> SRR1736333     5  0.0404      1.000 0.000 0.000 0.012 0.000 0.988
#> SRR1736334     5  0.0404      1.000 0.000 0.000 0.012 0.000 0.988
#> SRR1736335     5  0.0404      1.000 0.000 0.000 0.012 0.000 0.988
#> SRR1736337     5  0.0404      1.000 0.000 0.000 0.012 0.000 0.988
#> SRR1736336     5  0.0404      1.000 0.000 0.000 0.012 0.000 0.988
#> SRR1736338     5  0.0404      1.000 0.000 0.000 0.012 0.000 0.988
#> SRR1736339     1  0.7430      0.661 0.400 0.000 0.084 0.120 0.396
#> SRR1736340     1  0.7430      0.661 0.400 0.000 0.084 0.120 0.396
#> SRR1736341     1  0.7430      0.661 0.400 0.000 0.084 0.120 0.396
#> SRR1736342     1  0.4045      0.663 0.644 0.000 0.000 0.000 0.356
#> SRR1736343     1  0.4045      0.663 0.644 0.000 0.000 0.000 0.356
#> SRR1736344     1  0.4045      0.663 0.644 0.000 0.000 0.000 0.356
#> SRR1736345     1  0.7430      0.661 0.400 0.000 0.084 0.120 0.396
#> SRR1736346     1  0.7430      0.661 0.400 0.000 0.084 0.120 0.396
#> SRR1736348     1  0.4362      0.657 0.632 0.000 0.004 0.004 0.360
#> SRR1736347     1  0.7430      0.661 0.400 0.000 0.084 0.120 0.396
#> SRR1736349     1  0.4362      0.657 0.632 0.000 0.004 0.004 0.360
#> SRR1736350     1  0.4362      0.657 0.632 0.000 0.004 0.004 0.360
#> SRR1736351     1  0.7334      0.680 0.440 0.000 0.060 0.148 0.352
#> SRR1736352     1  0.7334      0.680 0.440 0.000 0.060 0.148 0.352
#> SRR1736353     1  0.7334      0.680 0.440 0.000 0.060 0.148 0.352
#> SRR1736354     1  0.4478      0.654 0.628 0.000 0.004 0.008 0.360
#> SRR1736355     1  0.4478      0.654 0.628 0.000 0.004 0.008 0.360
#> SRR1736356     3  0.8052      0.370 0.336 0.000 0.368 0.172 0.124
#> SRR1736358     3  0.7137      0.591 0.248 0.000 0.524 0.056 0.172
#> SRR1736357     3  0.7137      0.591 0.248 0.000 0.524 0.056 0.172
#> SRR1736359     3  0.7137      0.591 0.248 0.000 0.524 0.056 0.172
#> SRR1736360     3  0.6774      0.535 0.040 0.000 0.440 0.104 0.416
#> SRR1736361     3  0.6774      0.535 0.040 0.000 0.440 0.104 0.416
#> SRR1736362     3  0.6774      0.535 0.040 0.000 0.440 0.104 0.416
#> SRR1736363     3  0.4090      0.743 0.016 0.000 0.716 0.000 0.268
#> SRR1736365     3  0.4090      0.743 0.016 0.000 0.716 0.000 0.268
#> SRR1736364     3  0.4090      0.743 0.016 0.000 0.716 0.000 0.268
#> SRR1736366     3  0.4090      0.743 0.016 0.000 0.716 0.000 0.268
#> SRR1736367     3  0.4090      0.743 0.016 0.000 0.716 0.000 0.268
#> SRR1736368     3  0.4090      0.743 0.016 0.000 0.716 0.000 0.268

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4 p5    p6
#> SRR1736309     2  0.1346      0.825 0.008 0.952 0.016 0.000 NA 0.024
#> SRR1736310     2  0.0547      0.830 0.000 0.980 0.000 0.000 NA 0.020
#> SRR1736312     2  0.0547      0.830 0.000 0.980 0.000 0.000 NA 0.020
#> SRR1736311     2  0.0547      0.830 0.000 0.980 0.000 0.000 NA 0.020
#> SRR1736313     2  0.1346      0.825 0.008 0.952 0.016 0.000 NA 0.024
#> SRR1736314     2  0.0547      0.830 0.000 0.980 0.000 0.000 NA 0.020
#> SRR1736315     2  0.3737      0.653 0.000 0.608 0.000 0.000 NA 0.000
#> SRR1736316     2  0.3737      0.653 0.000 0.608 0.000 0.000 NA 0.000
#> SRR1736317     2  0.3737      0.653 0.000 0.608 0.000 0.000 NA 0.000
#> SRR1736318     2  0.0622      0.831 0.008 0.980 0.012 0.000 NA 0.000
#> SRR1736319     2  0.0622      0.831 0.008 0.980 0.012 0.000 NA 0.000
#> SRR1736320     2  0.1369      0.827 0.016 0.952 0.016 0.000 NA 0.016
#> SRR1736321     2  0.4650      0.653 0.012 0.608 0.000 0.000 NA 0.032
#> SRR1736322     2  0.4650      0.653 0.012 0.608 0.000 0.000 NA 0.032
#> SRR1736323     2  0.4650      0.653 0.012 0.608 0.000 0.000 NA 0.032
#> SRR1736324     2  0.0622      0.831 0.008 0.980 0.012 0.000 NA 0.000
#> SRR1736325     2  0.0622      0.831 0.008 0.980 0.012 0.000 NA 0.000
#> SRR1736326     2  0.0622      0.831 0.008 0.980 0.012 0.000 NA 0.000
#> SRR1736328     4  0.2884      0.980 0.004 0.164 0.000 0.824 NA 0.008
#> SRR1736327     4  0.4029      0.965 0.004 0.164 0.000 0.772 NA 0.016
#> SRR1736329     4  0.4048      0.965 0.004 0.164 0.000 0.772 NA 0.020
#> SRR1736330     4  0.2491      0.981 0.000 0.164 0.000 0.836 NA 0.000
#> SRR1736331     4  0.2491      0.981 0.000 0.164 0.000 0.836 NA 0.000
#> SRR1736332     4  0.2491      0.981 0.000 0.164 0.000 0.836 NA 0.000
#> SRR1736333     1  0.2219      0.372 0.864 0.000 0.136 0.000 NA 0.000
#> SRR1736334     1  0.2219      0.372 0.864 0.000 0.136 0.000 NA 0.000
#> SRR1736335     1  0.2219      0.372 0.864 0.000 0.136 0.000 NA 0.000
#> SRR1736337     1  0.2219      0.372 0.864 0.000 0.136 0.000 NA 0.000
#> SRR1736336     1  0.2219      0.372 0.864 0.000 0.136 0.000 NA 0.000
#> SRR1736338     1  0.2219      0.372 0.864 0.000 0.136 0.000 NA 0.000
#> SRR1736339     1  0.6010      0.437 0.428 0.000 0.000 0.000 NA 0.312
#> SRR1736340     1  0.6010      0.437 0.428 0.000 0.000 0.000 NA 0.312
#> SRR1736341     1  0.6010      0.437 0.428 0.000 0.000 0.000 NA 0.312
#> SRR1736342     6  0.3531      0.986 0.328 0.000 0.000 0.000 NA 0.672
#> SRR1736343     6  0.3531      0.986 0.328 0.000 0.000 0.000 NA 0.672
#> SRR1736344     6  0.3531      0.986 0.328 0.000 0.000 0.000 NA 0.672
#> SRR1736345     1  0.6010      0.437 0.428 0.000 0.000 0.000 NA 0.312
#> SRR1736346     1  0.6010      0.437 0.428 0.000 0.000 0.000 NA 0.312
#> SRR1736348     6  0.3619      0.987 0.316 0.000 0.000 0.004 NA 0.680
#> SRR1736347     1  0.6010      0.437 0.428 0.000 0.000 0.000 NA 0.312
#> SRR1736349     6  0.3619      0.987 0.316 0.000 0.000 0.004 NA 0.680
#> SRR1736350     6  0.3619      0.987 0.316 0.000 0.000 0.004 NA 0.680
#> SRR1736351     1  0.6589      0.336 0.380 0.000 0.000 0.028 NA 0.344
#> SRR1736352     1  0.6589      0.336 0.380 0.000 0.000 0.028 NA 0.344
#> SRR1736353     1  0.6589      0.336 0.380 0.000 0.000 0.028 NA 0.344
#> SRR1736354     6  0.3636      0.986 0.320 0.000 0.000 0.000 NA 0.676
#> SRR1736355     6  0.3636      0.986 0.320 0.000 0.000 0.000 NA 0.676
#> SRR1736356     3  0.8232      0.475 0.064 0.000 0.332 0.116 NA 0.280
#> SRR1736358     3  0.6208      0.695 0.040 0.000 0.624 0.044 NA 0.184
#> SRR1736357     3  0.6208      0.695 0.040 0.000 0.624 0.044 NA 0.184
#> SRR1736359     3  0.6208      0.695 0.040 0.000 0.624 0.044 NA 0.184
#> SRR1736360     3  0.6224      0.664 0.192 0.000 0.612 0.032 NA 0.040
#> SRR1736361     3  0.6224      0.664 0.192 0.000 0.612 0.032 NA 0.040
#> SRR1736362     3  0.6224      0.664 0.192 0.000 0.612 0.032 NA 0.040
#> SRR1736363     3  0.0972      0.803 0.028 0.000 0.964 0.000 NA 0.008
#> SRR1736365     3  0.0972      0.803 0.028 0.000 0.964 0.000 NA 0.008
#> SRR1736364     3  0.0972      0.803 0.028 0.000 0.964 0.000 NA 0.008
#> SRR1736366     3  0.0972      0.803 0.028 0.000 0.964 0.000 NA 0.008
#> SRR1736367     3  0.0972      0.803 0.028 0.000 0.964 0.000 NA 0.008
#> SRR1736368     3  0.0972      0.803 0.028 0.000 0.964 0.000 NA 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 15454 rows and 60 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'skmeans' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 6.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk MAD-skmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4886 0.512   0.512
#> 3 3 0.885           0.957       0.977         0.3512 0.831   0.670
#> 4 4 0.880           0.933       0.922         0.0869 0.942   0.832
#> 5 5 0.860           0.943       0.935         0.0789 0.939   0.786
#> 6 6 0.932           0.959       0.939         0.0477 0.959   0.819

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
#> SRR1736309     2       0          1  0  1
#> SRR1736310     2       0          1  0  1
#> SRR1736312     2       0          1  0  1
#> SRR1736311     2       0          1  0  1
#> SRR1736313     2       0          1  0  1
#> SRR1736314     2       0          1  0  1
#> SRR1736315     2       0          1  0  1
#> SRR1736316     2       0          1  0  1
#> SRR1736317     2       0          1  0  1
#> SRR1736318     2       0          1  0  1
#> SRR1736319     2       0          1  0  1
#> SRR1736320     2       0          1  0  1
#> SRR1736321     2       0          1  0  1
#> SRR1736322     2       0          1  0  1
#> SRR1736323     2       0          1  0  1
#> SRR1736324     2       0          1  0  1
#> SRR1736325     2       0          1  0  1
#> SRR1736326     2       0          1  0  1
#> SRR1736328     2       0          1  0  1
#> SRR1736327     2       0          1  0  1
#> SRR1736329     2       0          1  0  1
#> SRR1736330     2       0          1  0  1
#> SRR1736331     2       0          1  0  1
#> SRR1736332     2       0          1  0  1
#> SRR1736333     1       0          1  1  0
#> SRR1736334     1       0          1  1  0
#> SRR1736335     1       0          1  1  0
#> SRR1736337     1       0          1  1  0
#> SRR1736336     1       0          1  1  0
#> SRR1736338     1       0          1  1  0
#> SRR1736339     1       0          1  1  0
#> SRR1736340     1       0          1  1  0
#> SRR1736341     1       0          1  1  0
#> SRR1736342     1       0          1  1  0
#> SRR1736343     1       0          1  1  0
#> SRR1736344     1       0          1  1  0
#> SRR1736345     1       0          1  1  0
#> SRR1736346     1       0          1  1  0
#> SRR1736348     1       0          1  1  0
#> SRR1736347     1       0          1  1  0
#> SRR1736349     1       0          1  1  0
#> SRR1736350     1       0          1  1  0
#> SRR1736351     1       0          1  1  0
#> SRR1736352     1       0          1  1  0
#> SRR1736353     1       0          1  1  0
#> SRR1736354     1       0          1  1  0
#> SRR1736355     1       0          1  1  0
#> SRR1736356     1       0          1  1  0
#> SRR1736358     1       0          1  1  0
#> SRR1736357     1       0          1  1  0
#> SRR1736359     1       0          1  1  0
#> SRR1736360     1       0          1  1  0
#> SRR1736361     1       0          1  1  0
#> SRR1736362     1       0          1  1  0
#> SRR1736363     1       0          1  1  0
#> SRR1736365     1       0          1  1  0
#> SRR1736364     1       0          1  1  0
#> SRR1736366     1       0          1  1  0
#> SRR1736367     1       0          1  1  0
#> SRR1736368     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
#> SRR1736309     2   0.000      1.000 0.000  1 0.000
#> SRR1736310     2   0.000      1.000 0.000  1 0.000
#> SRR1736312     2   0.000      1.000 0.000  1 0.000
#> SRR1736311     2   0.000      1.000 0.000  1 0.000
#> SRR1736313     2   0.000      1.000 0.000  1 0.000
#> SRR1736314     2   0.000      1.000 0.000  1 0.000
#> SRR1736315     2   0.000      1.000 0.000  1 0.000
#> SRR1736316     2   0.000      1.000 0.000  1 0.000
#> SRR1736317     2   0.000      1.000 0.000  1 0.000
#> SRR1736318     2   0.000      1.000 0.000  1 0.000
#> SRR1736319     2   0.000      1.000 0.000  1 0.000
#> SRR1736320     2   0.000      1.000 0.000  1 0.000
#> SRR1736321     2   0.000      1.000 0.000  1 0.000
#> SRR1736322     2   0.000      1.000 0.000  1 0.000
#> SRR1736323     2   0.000      1.000 0.000  1 0.000
#> SRR1736324     2   0.000      1.000 0.000  1 0.000
#> SRR1736325     2   0.000      1.000 0.000  1 0.000
#> SRR1736326     2   0.000      1.000 0.000  1 0.000
#> SRR1736328     2   0.000      1.000 0.000  1 0.000
#> SRR1736327     2   0.000      1.000 0.000  1 0.000
#> SRR1736329     2   0.000      1.000 0.000  1 0.000
#> SRR1736330     2   0.000      1.000 0.000  1 0.000
#> SRR1736331     2   0.000      1.000 0.000  1 0.000
#> SRR1736332     2   0.000      1.000 0.000  1 0.000
#> SRR1736333     1   0.460      0.802 0.796  0 0.204
#> SRR1736334     1   0.460      0.802 0.796  0 0.204
#> SRR1736335     1   0.460      0.802 0.796  0 0.204
#> SRR1736337     1   0.460      0.802 0.796  0 0.204
#> SRR1736336     1   0.460      0.802 0.796  0 0.204
#> SRR1736338     1   0.460      0.802 0.796  0 0.204
#> SRR1736339     1   0.000      0.941 1.000  0 0.000
#> SRR1736340     1   0.000      0.941 1.000  0 0.000
#> SRR1736341     1   0.000      0.941 1.000  0 0.000
#> SRR1736342     1   0.000      0.941 1.000  0 0.000
#> SRR1736343     1   0.000      0.941 1.000  0 0.000
#> SRR1736344     1   0.000      0.941 1.000  0 0.000
#> SRR1736345     1   0.000      0.941 1.000  0 0.000
#> SRR1736346     1   0.000      0.941 1.000  0 0.000
#> SRR1736348     1   0.000      0.941 1.000  0 0.000
#> SRR1736347     1   0.000      0.941 1.000  0 0.000
#> SRR1736349     1   0.000      0.941 1.000  0 0.000
#> SRR1736350     1   0.000      0.941 1.000  0 0.000
#> SRR1736351     1   0.000      0.941 1.000  0 0.000
#> SRR1736352     1   0.000      0.941 1.000  0 0.000
#> SRR1736353     1   0.000      0.941 1.000  0 0.000
#> SRR1736354     1   0.000      0.941 1.000  0 0.000
#> SRR1736355     1   0.000      0.941 1.000  0 0.000
#> SRR1736356     3   0.394      0.805 0.156  0 0.844
#> SRR1736358     3   0.000      0.986 0.000  0 1.000
#> SRR1736357     3   0.000      0.986 0.000  0 1.000
#> SRR1736359     3   0.000      0.986 0.000  0 1.000
#> SRR1736360     3   0.000      0.986 0.000  0 1.000
#> SRR1736361     3   0.000      0.986 0.000  0 1.000
#> SRR1736362     3   0.000      0.986 0.000  0 1.000
#> SRR1736363     3   0.000      0.986 0.000  0 1.000
#> SRR1736365     3   0.000      0.986 0.000  0 1.000
#> SRR1736364     3   0.000      0.986 0.000  0 1.000
#> SRR1736366     3   0.000      0.986 0.000  0 1.000
#> SRR1736367     3   0.000      0.986 0.000  0 1.000
#> SRR1736368     3   0.000      0.986 0.000  0 1.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1   p2    p3    p4
#> SRR1736309     2  0.4713      0.913 0.000 0.64 0.000 0.360
#> SRR1736310     2  0.4713      0.913 0.000 0.64 0.000 0.360
#> SRR1736312     2  0.4713      0.913 0.000 0.64 0.000 0.360
#> SRR1736311     2  0.4713      0.913 0.000 0.64 0.000 0.360
#> SRR1736313     2  0.4713      0.913 0.000 0.64 0.000 0.360
#> SRR1736314     2  0.4713      0.913 0.000 0.64 0.000 0.360
#> SRR1736315     2  0.4713      0.913 0.000 0.64 0.000 0.360
#> SRR1736316     2  0.4713      0.913 0.000 0.64 0.000 0.360
#> SRR1736317     2  0.4713      0.913 0.000 0.64 0.000 0.360
#> SRR1736318     2  0.4713      0.913 0.000 0.64 0.000 0.360
#> SRR1736319     2  0.4713      0.913 0.000 0.64 0.000 0.360
#> SRR1736320     2  0.4713      0.913 0.000 0.64 0.000 0.360
#> SRR1736321     2  0.4713      0.913 0.000 0.64 0.000 0.360
#> SRR1736322     2  0.4713      0.913 0.000 0.64 0.000 0.360
#> SRR1736323     2  0.4713      0.913 0.000 0.64 0.000 0.360
#> SRR1736324     2  0.4713      0.913 0.000 0.64 0.000 0.360
#> SRR1736325     2  0.4713      0.913 0.000 0.64 0.000 0.360
#> SRR1736326     2  0.4713      0.913 0.000 0.64 0.000 0.360
#> SRR1736328     2  0.0000      0.699 0.000 1.00 0.000 0.000
#> SRR1736327     2  0.0000      0.699 0.000 1.00 0.000 0.000
#> SRR1736329     2  0.0000      0.699 0.000 1.00 0.000 0.000
#> SRR1736330     2  0.0000      0.699 0.000 1.00 0.000 0.000
#> SRR1736331     2  0.0000      0.699 0.000 1.00 0.000 0.000
#> SRR1736332     2  0.0000      0.699 0.000 1.00 0.000 0.000
#> SRR1736333     4  0.6013      1.000 0.288 0.00 0.072 0.640
#> SRR1736334     4  0.6013      1.000 0.288 0.00 0.072 0.640
#> SRR1736335     4  0.6013      1.000 0.288 0.00 0.072 0.640
#> SRR1736337     4  0.6013      1.000 0.288 0.00 0.072 0.640
#> SRR1736336     4  0.6013      1.000 0.288 0.00 0.072 0.640
#> SRR1736338     4  0.6013      1.000 0.288 0.00 0.072 0.640
#> SRR1736339     1  0.0188      0.981 0.996 0.00 0.000 0.004
#> SRR1736340     1  0.0188      0.981 0.996 0.00 0.000 0.004
#> SRR1736341     1  0.0188      0.981 0.996 0.00 0.000 0.004
#> SRR1736342     1  0.0817      0.980 0.976 0.00 0.000 0.024
#> SRR1736343     1  0.0817      0.980 0.976 0.00 0.000 0.024
#> SRR1736344     1  0.0817      0.980 0.976 0.00 0.000 0.024
#> SRR1736345     1  0.0188      0.981 0.996 0.00 0.000 0.004
#> SRR1736346     1  0.0188      0.981 0.996 0.00 0.000 0.004
#> SRR1736348     1  0.0817      0.980 0.976 0.00 0.000 0.024
#> SRR1736347     1  0.0188      0.981 0.996 0.00 0.000 0.004
#> SRR1736349     1  0.0817      0.980 0.976 0.00 0.000 0.024
#> SRR1736350     1  0.0817      0.980 0.976 0.00 0.000 0.024
#> SRR1736351     1  0.0000      0.981 1.000 0.00 0.000 0.000
#> SRR1736352     1  0.0000      0.981 1.000 0.00 0.000 0.000
#> SRR1736353     1  0.0000      0.981 1.000 0.00 0.000 0.000
#> SRR1736354     1  0.0817      0.980 0.976 0.00 0.000 0.024
#> SRR1736355     1  0.0817      0.980 0.976 0.00 0.000 0.024
#> SRR1736356     3  0.2216      0.867 0.092 0.00 0.908 0.000
#> SRR1736358     3  0.0000      0.985 0.000 0.00 1.000 0.000
#> SRR1736357     3  0.0000      0.985 0.000 0.00 1.000 0.000
#> SRR1736359     3  0.0000      0.985 0.000 0.00 1.000 0.000
#> SRR1736360     3  0.0592      0.977 0.000 0.00 0.984 0.016
#> SRR1736361     3  0.0592      0.977 0.000 0.00 0.984 0.016
#> SRR1736362     3  0.0592      0.977 0.000 0.00 0.984 0.016
#> SRR1736363     3  0.0000      0.985 0.000 0.00 1.000 0.000
#> SRR1736365     3  0.0000      0.985 0.000 0.00 1.000 0.000
#> SRR1736364     3  0.0000      0.985 0.000 0.00 1.000 0.000
#> SRR1736366     3  0.0000      0.985 0.000 0.00 1.000 0.000
#> SRR1736367     3  0.0000      0.985 0.000 0.00 1.000 0.000
#> SRR1736368     3  0.0000      0.985 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
#> SRR1736309     2  0.0000      1.000 0.000 1.00 0.000 0.000 0.000
#> SRR1736310     2  0.0000      1.000 0.000 1.00 0.000 0.000 0.000
#> SRR1736312     2  0.0000      1.000 0.000 1.00 0.000 0.000 0.000
#> SRR1736311     2  0.0000      1.000 0.000 1.00 0.000 0.000 0.000
#> SRR1736313     2  0.0000      1.000 0.000 1.00 0.000 0.000 0.000
#> SRR1736314     2  0.0000      1.000 0.000 1.00 0.000 0.000 0.000
#> SRR1736315     2  0.0000      1.000 0.000 1.00 0.000 0.000 0.000
#> SRR1736316     2  0.0000      1.000 0.000 1.00 0.000 0.000 0.000
#> SRR1736317     2  0.0000      1.000 0.000 1.00 0.000 0.000 0.000
#> SRR1736318     2  0.0000      1.000 0.000 1.00 0.000 0.000 0.000
#> SRR1736319     2  0.0000      1.000 0.000 1.00 0.000 0.000 0.000
#> SRR1736320     2  0.0000      1.000 0.000 1.00 0.000 0.000 0.000
#> SRR1736321     2  0.0000      1.000 0.000 1.00 0.000 0.000 0.000
#> SRR1736322     2  0.0000      1.000 0.000 1.00 0.000 0.000 0.000
#> SRR1736323     2  0.0000      1.000 0.000 1.00 0.000 0.000 0.000
#> SRR1736324     2  0.0000      1.000 0.000 1.00 0.000 0.000 0.000
#> SRR1736325     2  0.0000      1.000 0.000 1.00 0.000 0.000 0.000
#> SRR1736326     2  0.0000      1.000 0.000 1.00 0.000 0.000 0.000
#> SRR1736328     4  0.2929      1.000 0.000 0.18 0.000 0.820 0.000
#> SRR1736327     4  0.2929      1.000 0.000 0.18 0.000 0.820 0.000
#> SRR1736329     4  0.2929      1.000 0.000 0.18 0.000 0.820 0.000
#> SRR1736330     4  0.2929      1.000 0.000 0.18 0.000 0.820 0.000
#> SRR1736331     4  0.2929      1.000 0.000 0.18 0.000 0.820 0.000
#> SRR1736332     4  0.2929      1.000 0.000 0.18 0.000 0.820 0.000
#> SRR1736333     5  0.0404      1.000 0.000 0.00 0.012 0.000 0.988
#> SRR1736334     5  0.0404      1.000 0.000 0.00 0.012 0.000 0.988
#> SRR1736335     5  0.0404      1.000 0.000 0.00 0.012 0.000 0.988
#> SRR1736337     5  0.0404      1.000 0.000 0.00 0.012 0.000 0.988
#> SRR1736336     5  0.0404      1.000 0.000 0.00 0.012 0.000 0.988
#> SRR1736338     5  0.0404      1.000 0.000 0.00 0.012 0.000 0.988
#> SRR1736339     1  0.0510      0.845 0.984 0.00 0.000 0.000 0.016
#> SRR1736340     1  0.0510      0.845 0.984 0.00 0.000 0.000 0.016
#> SRR1736341     1  0.0510      0.845 0.984 0.00 0.000 0.000 0.016
#> SRR1736342     1  0.4959      0.818 0.712 0.00 0.000 0.160 0.128
#> SRR1736343     1  0.4959      0.818 0.712 0.00 0.000 0.160 0.128
#> SRR1736344     1  0.4959      0.818 0.712 0.00 0.000 0.160 0.128
#> SRR1736345     1  0.0510      0.845 0.984 0.00 0.000 0.000 0.016
#> SRR1736346     1  0.0510      0.845 0.984 0.00 0.000 0.000 0.016
#> SRR1736348     1  0.4959      0.818 0.712 0.00 0.000 0.160 0.128
#> SRR1736347     1  0.0510      0.845 0.984 0.00 0.000 0.000 0.016
#> SRR1736349     1  0.4959      0.818 0.712 0.00 0.000 0.160 0.128
#> SRR1736350     1  0.4959      0.818 0.712 0.00 0.000 0.160 0.128
#> SRR1736351     1  0.0290      0.846 0.992 0.00 0.000 0.000 0.008
#> SRR1736352     1  0.0290      0.846 0.992 0.00 0.000 0.000 0.008
#> SRR1736353     1  0.0290      0.846 0.992 0.00 0.000 0.000 0.008
#> SRR1736354     1  0.4959      0.818 0.712 0.00 0.000 0.160 0.128
#> SRR1736355     1  0.4959      0.818 0.712 0.00 0.000 0.160 0.128
#> SRR1736356     3  0.3107      0.858 0.032 0.00 0.868 0.088 0.012
#> SRR1736358     3  0.0693      0.965 0.000 0.00 0.980 0.012 0.008
#> SRR1736357     3  0.0693      0.965 0.000 0.00 0.980 0.012 0.008
#> SRR1736359     3  0.0693      0.965 0.000 0.00 0.980 0.012 0.008
#> SRR1736360     3  0.1522      0.945 0.000 0.00 0.944 0.012 0.044
#> SRR1736361     3  0.1522      0.945 0.000 0.00 0.944 0.012 0.044
#> SRR1736362     3  0.1522      0.945 0.000 0.00 0.944 0.012 0.044
#> SRR1736363     3  0.0000      0.970 0.000 0.00 1.000 0.000 0.000
#> SRR1736365     3  0.0000      0.970 0.000 0.00 1.000 0.000 0.000
#> SRR1736364     3  0.0000      0.970 0.000 0.00 1.000 0.000 0.000
#> SRR1736366     3  0.0000      0.970 0.000 0.00 1.000 0.000 0.000
#> SRR1736367     3  0.0000      0.970 0.000 0.00 1.000 0.000 0.000
#> SRR1736368     3  0.0000      0.970 0.000 0.00 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
#> SRR1736309     2  0.0000      0.995 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736310     2  0.0000      0.995 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736312     2  0.0000      0.995 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736311     2  0.0000      0.995 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736313     2  0.0000      0.995 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736314     2  0.0000      0.995 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736315     2  0.0508      0.990 0.000 0.984 0.000 0.000 0.004 0.012
#> SRR1736316     2  0.0508      0.990 0.000 0.984 0.000 0.000 0.004 0.012
#> SRR1736317     2  0.0508      0.990 0.000 0.984 0.000 0.000 0.004 0.012
#> SRR1736318     2  0.0000      0.995 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736319     2  0.0000      0.995 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736320     2  0.0000      0.995 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736321     2  0.0508      0.990 0.000 0.984 0.000 0.000 0.004 0.012
#> SRR1736322     2  0.0508      0.990 0.000 0.984 0.000 0.000 0.004 0.012
#> SRR1736323     2  0.0508      0.990 0.000 0.984 0.000 0.000 0.004 0.012
#> SRR1736324     2  0.0000      0.995 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736325     2  0.0000      0.995 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736326     2  0.0000      0.995 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736328     4  0.1075      1.000 0.000 0.048 0.000 0.952 0.000 0.000
#> SRR1736327     4  0.1075      1.000 0.000 0.048 0.000 0.952 0.000 0.000
#> SRR1736329     4  0.1075      1.000 0.000 0.048 0.000 0.952 0.000 0.000
#> SRR1736330     4  0.1075      1.000 0.000 0.048 0.000 0.952 0.000 0.000
#> SRR1736331     4  0.1075      1.000 0.000 0.048 0.000 0.952 0.000 0.000
#> SRR1736332     4  0.1075      1.000 0.000 0.048 0.000 0.952 0.000 0.000
#> SRR1736333     5  0.0547      1.000 0.000 0.000 0.000 0.000 0.980 0.020
#> SRR1736334     5  0.0547      1.000 0.000 0.000 0.000 0.000 0.980 0.020
#> SRR1736335     5  0.0547      1.000 0.000 0.000 0.000 0.000 0.980 0.020
#> SRR1736337     5  0.0547      1.000 0.000 0.000 0.000 0.000 0.980 0.020
#> SRR1736336     5  0.0547      1.000 0.000 0.000 0.000 0.000 0.980 0.020
#> SRR1736338     5  0.0547      1.000 0.000 0.000 0.000 0.000 0.980 0.020
#> SRR1736339     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1736340     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1736341     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1736342     6  0.3073      1.000 0.204 0.000 0.000 0.000 0.008 0.788
#> SRR1736343     6  0.3073      1.000 0.204 0.000 0.000 0.000 0.008 0.788
#> SRR1736344     6  0.3073      1.000 0.204 0.000 0.000 0.000 0.008 0.788
#> SRR1736345     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1736346     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1736348     6  0.3073      1.000 0.204 0.000 0.000 0.000 0.008 0.788
#> SRR1736347     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1736349     6  0.3073      1.000 0.204 0.000 0.000 0.000 0.008 0.788
#> SRR1736350     6  0.3073      1.000 0.204 0.000 0.000 0.000 0.008 0.788
#> SRR1736351     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1736352     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1736353     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1736354     6  0.3073      1.000 0.204 0.000 0.000 0.000 0.008 0.788
#> SRR1736355     6  0.3073      1.000 0.204 0.000 0.000 0.000 0.008 0.788
#> SRR1736356     3  0.4152      0.402 0.000 0.000 0.548 0.012 0.000 0.440
#> SRR1736358     3  0.2513      0.839 0.000 0.000 0.852 0.008 0.000 0.140
#> SRR1736357     3  0.2513      0.839 0.000 0.000 0.852 0.008 0.000 0.140
#> SRR1736359     3  0.2513      0.839 0.000 0.000 0.852 0.008 0.000 0.140
#> SRR1736360     3  0.3846      0.802 0.000 0.000 0.804 0.036 0.052 0.108
#> SRR1736361     3  0.3846      0.802 0.000 0.000 0.804 0.036 0.052 0.108
#> SRR1736362     3  0.3846      0.802 0.000 0.000 0.804 0.036 0.052 0.108
#> SRR1736363     3  0.0000      0.886 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736365     3  0.0000      0.886 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736364     3  0.0000      0.886 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736366     3  0.0000      0.886 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736367     3  0.0000      0.886 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736368     3  0.0000      0.886 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 15454 rows and 60 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'pam' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 6.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk MAD-pam-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2     1           1.000       1.000         0.4886 0.512   0.512
#> 3 3     1           0.996       0.998         0.3440 0.831   0.670
#> 4 4     1           0.995       0.998         0.0928 0.939   0.822
#> 5 5     1           0.969       0.987         0.0865 0.942   0.796
#> 6 6     1           0.982       0.993         0.0483 0.959   0.819

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette p1 p2
#> SRR1736309     2       0          1  0  1
#> SRR1736310     2       0          1  0  1
#> SRR1736312     2       0          1  0  1
#> SRR1736311     2       0          1  0  1
#> SRR1736313     2       0          1  0  1
#> SRR1736314     2       0          1  0  1
#> SRR1736315     2       0          1  0  1
#> SRR1736316     2       0          1  0  1
#> SRR1736317     2       0          1  0  1
#> SRR1736318     2       0          1  0  1
#> SRR1736319     2       0          1  0  1
#> SRR1736320     2       0          1  0  1
#> SRR1736321     2       0          1  0  1
#> SRR1736322     2       0          1  0  1
#> SRR1736323     2       0          1  0  1
#> SRR1736324     2       0          1  0  1
#> SRR1736325     2       0          1  0  1
#> SRR1736326     2       0          1  0  1
#> SRR1736328     2       0          1  0  1
#> SRR1736327     2       0          1  0  1
#> SRR1736329     2       0          1  0  1
#> SRR1736330     2       0          1  0  1
#> SRR1736331     2       0          1  0  1
#> SRR1736332     2       0          1  0  1
#> SRR1736333     1       0          1  1  0
#> SRR1736334     1       0          1  1  0
#> SRR1736335     1       0          1  1  0
#> SRR1736337     1       0          1  1  0
#> SRR1736336     1       0          1  1  0
#> SRR1736338     1       0          1  1  0
#> SRR1736339     1       0          1  1  0
#> SRR1736340     1       0          1  1  0
#> SRR1736341     1       0          1  1  0
#> SRR1736342     1       0          1  1  0
#> SRR1736343     1       0          1  1  0
#> SRR1736344     1       0          1  1  0
#> SRR1736345     1       0          1  1  0
#> SRR1736346     1       0          1  1  0
#> SRR1736348     1       0          1  1  0
#> SRR1736347     1       0          1  1  0
#> SRR1736349     1       0          1  1  0
#> SRR1736350     1       0          1  1  0
#> SRR1736351     1       0          1  1  0
#> SRR1736352     1       0          1  1  0
#> SRR1736353     1       0          1  1  0
#> SRR1736354     1       0          1  1  0
#> SRR1736355     1       0          1  1  0
#> SRR1736356     1       0          1  1  0
#> SRR1736358     1       0          1  1  0
#> SRR1736357     1       0          1  1  0
#> SRR1736359     1       0          1  1  0
#> SRR1736360     1       0          1  1  0
#> SRR1736361     1       0          1  1  0
#> SRR1736362     1       0          1  1  0
#> SRR1736363     1       0          1  1  0
#> SRR1736365     1       0          1  1  0
#> SRR1736364     1       0          1  1  0
#> SRR1736366     1       0          1  1  0
#> SRR1736367     1       0          1  1  0
#> SRR1736368     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
#> SRR1736309     2   0.000      1.000 0.000  1 0.000
#> SRR1736310     2   0.000      1.000 0.000  1 0.000
#> SRR1736312     2   0.000      1.000 0.000  1 0.000
#> SRR1736311     2   0.000      1.000 0.000  1 0.000
#> SRR1736313     2   0.000      1.000 0.000  1 0.000
#> SRR1736314     2   0.000      1.000 0.000  1 0.000
#> SRR1736315     2   0.000      1.000 0.000  1 0.000
#> SRR1736316     2   0.000      1.000 0.000  1 0.000
#> SRR1736317     2   0.000      1.000 0.000  1 0.000
#> SRR1736318     2   0.000      1.000 0.000  1 0.000
#> SRR1736319     2   0.000      1.000 0.000  1 0.000
#> SRR1736320     2   0.000      1.000 0.000  1 0.000
#> SRR1736321     2   0.000      1.000 0.000  1 0.000
#> SRR1736322     2   0.000      1.000 0.000  1 0.000
#> SRR1736323     2   0.000      1.000 0.000  1 0.000
#> SRR1736324     2   0.000      1.000 0.000  1 0.000
#> SRR1736325     2   0.000      1.000 0.000  1 0.000
#> SRR1736326     2   0.000      1.000 0.000  1 0.000
#> SRR1736328     2   0.000      1.000 0.000  1 0.000
#> SRR1736327     2   0.000      1.000 0.000  1 0.000
#> SRR1736329     2   0.000      1.000 0.000  1 0.000
#> SRR1736330     2   0.000      1.000 0.000  1 0.000
#> SRR1736331     2   0.000      1.000 0.000  1 0.000
#> SRR1736332     2   0.000      1.000 0.000  1 0.000
#> SRR1736333     1   0.000      1.000 1.000  0 0.000
#> SRR1736334     1   0.000      1.000 1.000  0 0.000
#> SRR1736335     1   0.000      1.000 1.000  0 0.000
#> SRR1736337     1   0.000      1.000 1.000  0 0.000
#> SRR1736336     1   0.000      1.000 1.000  0 0.000
#> SRR1736338     1   0.000      1.000 1.000  0 0.000
#> SRR1736339     1   0.000      1.000 1.000  0 0.000
#> SRR1736340     1   0.000      1.000 1.000  0 0.000
#> SRR1736341     1   0.000      1.000 1.000  0 0.000
#> SRR1736342     1   0.000      1.000 1.000  0 0.000
#> SRR1736343     1   0.000      1.000 1.000  0 0.000
#> SRR1736344     1   0.000      1.000 1.000  0 0.000
#> SRR1736345     1   0.000      1.000 1.000  0 0.000
#> SRR1736346     1   0.000      1.000 1.000  0 0.000
#> SRR1736348     1   0.000      1.000 1.000  0 0.000
#> SRR1736347     1   0.000      1.000 1.000  0 0.000
#> SRR1736349     1   0.000      1.000 1.000  0 0.000
#> SRR1736350     1   0.000      1.000 1.000  0 0.000
#> SRR1736351     1   0.000      1.000 1.000  0 0.000
#> SRR1736352     1   0.000      1.000 1.000  0 0.000
#> SRR1736353     1   0.000      1.000 1.000  0 0.000
#> SRR1736354     1   0.000      1.000 1.000  0 0.000
#> SRR1736355     1   0.000      1.000 1.000  0 0.000
#> SRR1736356     3   0.312      0.879 0.108  0 0.892
#> SRR1736358     3   0.000      0.991 0.000  0 1.000
#> SRR1736357     3   0.000      0.991 0.000  0 1.000
#> SRR1736359     3   0.000      0.991 0.000  0 1.000
#> SRR1736360     3   0.000      0.991 0.000  0 1.000
#> SRR1736361     3   0.000      0.991 0.000  0 1.000
#> SRR1736362     3   0.000      0.991 0.000  0 1.000
#> SRR1736363     3   0.000      0.991 0.000  0 1.000
#> SRR1736365     3   0.000      0.991 0.000  0 1.000
#> SRR1736364     3   0.000      0.991 0.000  0 1.000
#> SRR1736366     3   0.000      0.991 0.000  0 1.000
#> SRR1736367     3   0.000      0.991 0.000  0 1.000
#> SRR1736368     3   0.000      0.991 0.000  0 1.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1 p2    p3 p4
#> SRR1736309     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736310     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736312     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736311     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736313     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736314     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736315     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736316     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736317     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736318     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736319     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736320     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736321     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736322     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736323     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736324     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736325     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736326     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736328     4   0.000      1.000 0.000  0 0.000  1
#> SRR1736327     4   0.000      1.000 0.000  0 0.000  1
#> SRR1736329     4   0.000      1.000 0.000  0 0.000  1
#> SRR1736330     4   0.000      1.000 0.000  0 0.000  1
#> SRR1736331     4   0.000      1.000 0.000  0 0.000  1
#> SRR1736332     4   0.000      1.000 0.000  0 0.000  1
#> SRR1736333     1   0.000      1.000 1.000  0 0.000  0
#> SRR1736334     1   0.000      1.000 1.000  0 0.000  0
#> SRR1736335     1   0.000      1.000 1.000  0 0.000  0
#> SRR1736337     1   0.000      1.000 1.000  0 0.000  0
#> SRR1736336     1   0.000      1.000 1.000  0 0.000  0
#> SRR1736338     1   0.000      1.000 1.000  0 0.000  0
#> SRR1736339     1   0.000      1.000 1.000  0 0.000  0
#> SRR1736340     1   0.000      1.000 1.000  0 0.000  0
#> SRR1736341     1   0.000      1.000 1.000  0 0.000  0
#> SRR1736342     1   0.000      1.000 1.000  0 0.000  0
#> SRR1736343     1   0.000      1.000 1.000  0 0.000  0
#> SRR1736344     1   0.000      1.000 1.000  0 0.000  0
#> SRR1736345     1   0.000      1.000 1.000  0 0.000  0
#> SRR1736346     1   0.000      1.000 1.000  0 0.000  0
#> SRR1736348     1   0.000      1.000 1.000  0 0.000  0
#> SRR1736347     1   0.000      1.000 1.000  0 0.000  0
#> SRR1736349     1   0.000      1.000 1.000  0 0.000  0
#> SRR1736350     1   0.000      1.000 1.000  0 0.000  0
#> SRR1736351     1   0.000      1.000 1.000  0 0.000  0
#> SRR1736352     1   0.000      1.000 1.000  0 0.000  0
#> SRR1736353     1   0.000      1.000 1.000  0 0.000  0
#> SRR1736354     1   0.000      1.000 1.000  0 0.000  0
#> SRR1736355     1   0.000      1.000 1.000  0 0.000  0
#> SRR1736356     3   0.253      0.836 0.112  0 0.888  0
#> SRR1736358     3   0.000      0.987 0.000  0 1.000  0
#> SRR1736357     3   0.000      0.987 0.000  0 1.000  0
#> SRR1736359     3   0.000      0.987 0.000  0 1.000  0
#> SRR1736360     3   0.000      0.987 0.000  0 1.000  0
#> SRR1736361     3   0.000      0.987 0.000  0 1.000  0
#> SRR1736362     3   0.000      0.987 0.000  0 1.000  0
#> SRR1736363     3   0.000      0.987 0.000  0 1.000  0
#> SRR1736365     3   0.000      0.987 0.000  0 1.000  0
#> SRR1736364     3   0.000      0.987 0.000  0 1.000  0
#> SRR1736366     3   0.000      0.987 0.000  0 1.000  0
#> SRR1736367     3   0.000      0.987 0.000  0 1.000  0
#> SRR1736368     3   0.000      0.987 0.000  0 1.000  0

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1 p2    p3 p4    p5
#> SRR1736309     2  0.0000      1.000 0.000  1 0.000  0 0.000
#> SRR1736310     2  0.0000      1.000 0.000  1 0.000  0 0.000
#> SRR1736312     2  0.0000      1.000 0.000  1 0.000  0 0.000
#> SRR1736311     2  0.0000      1.000 0.000  1 0.000  0 0.000
#> SRR1736313     2  0.0000      1.000 0.000  1 0.000  0 0.000
#> SRR1736314     2  0.0000      1.000 0.000  1 0.000  0 0.000
#> SRR1736315     2  0.0000      1.000 0.000  1 0.000  0 0.000
#> SRR1736316     2  0.0000      1.000 0.000  1 0.000  0 0.000
#> SRR1736317     2  0.0000      1.000 0.000  1 0.000  0 0.000
#> SRR1736318     2  0.0000      1.000 0.000  1 0.000  0 0.000
#> SRR1736319     2  0.0000      1.000 0.000  1 0.000  0 0.000
#> SRR1736320     2  0.0000      1.000 0.000  1 0.000  0 0.000
#> SRR1736321     2  0.0000      1.000 0.000  1 0.000  0 0.000
#> SRR1736322     2  0.0000      1.000 0.000  1 0.000  0 0.000
#> SRR1736323     2  0.0000      1.000 0.000  1 0.000  0 0.000
#> SRR1736324     2  0.0000      1.000 0.000  1 0.000  0 0.000
#> SRR1736325     2  0.0000      1.000 0.000  1 0.000  0 0.000
#> SRR1736326     2  0.0000      1.000 0.000  1 0.000  0 0.000
#> SRR1736328     4  0.0000      1.000 0.000  0 0.000  1 0.000
#> SRR1736327     4  0.0000      1.000 0.000  0 0.000  1 0.000
#> SRR1736329     4  0.0000      1.000 0.000  0 0.000  1 0.000
#> SRR1736330     4  0.0000      1.000 0.000  0 0.000  1 0.000
#> SRR1736331     4  0.0000      1.000 0.000  0 0.000  1 0.000
#> SRR1736332     4  0.0000      1.000 0.000  0 0.000  1 0.000
#> SRR1736333     5  0.0000      1.000 0.000  0 0.000  0 1.000
#> SRR1736334     5  0.0000      1.000 0.000  0 0.000  0 1.000
#> SRR1736335     5  0.0000      1.000 0.000  0 0.000  0 1.000
#> SRR1736337     5  0.0000      1.000 0.000  0 0.000  0 1.000
#> SRR1736336     5  0.0000      1.000 0.000  0 0.000  0 1.000
#> SRR1736338     5  0.0000      1.000 0.000  0 0.000  0 1.000
#> SRR1736339     1  0.0000      0.951 1.000  0 0.000  0 0.000
#> SRR1736340     1  0.0000      0.951 1.000  0 0.000  0 0.000
#> SRR1736341     1  0.0000      0.951 1.000  0 0.000  0 0.000
#> SRR1736342     1  0.0000      0.951 1.000  0 0.000  0 0.000
#> SRR1736343     1  0.0000      0.951 1.000  0 0.000  0 0.000
#> SRR1736344     1  0.0000      0.951 1.000  0 0.000  0 0.000
#> SRR1736345     1  0.0000      0.951 1.000  0 0.000  0 0.000
#> SRR1736346     1  0.0000      0.951 1.000  0 0.000  0 0.000
#> SRR1736348     1  0.0000      0.951 1.000  0 0.000  0 0.000
#> SRR1736347     1  0.0000      0.951 1.000  0 0.000  0 0.000
#> SRR1736349     1  0.0000      0.951 1.000  0 0.000  0 0.000
#> SRR1736350     1  0.0000      0.951 1.000  0 0.000  0 0.000
#> SRR1736351     1  0.0000      0.951 1.000  0 0.000  0 0.000
#> SRR1736352     1  0.0000      0.951 1.000  0 0.000  0 0.000
#> SRR1736353     1  0.0000      0.951 1.000  0 0.000  0 0.000
#> SRR1736354     1  0.4074      0.460 0.636  0 0.000  0 0.364
#> SRR1736355     1  0.4138      0.416 0.616  0 0.000  0 0.384
#> SRR1736356     3  0.0451      0.988 0.004  0 0.988  0 0.008
#> SRR1736358     3  0.0000      0.999 0.000  0 1.000  0 0.000
#> SRR1736357     3  0.0000      0.999 0.000  0 1.000  0 0.000
#> SRR1736359     3  0.0000      0.999 0.000  0 1.000  0 0.000
#> SRR1736360     3  0.0000      0.999 0.000  0 1.000  0 0.000
#> SRR1736361     3  0.0000      0.999 0.000  0 1.000  0 0.000
#> SRR1736362     3  0.0000      0.999 0.000  0 1.000  0 0.000
#> SRR1736363     3  0.0000      0.999 0.000  0 1.000  0 0.000
#> SRR1736365     3  0.0000      0.999 0.000  0 1.000  0 0.000
#> SRR1736364     3  0.0000      0.999 0.000  0 1.000  0 0.000
#> SRR1736366     3  0.0000      0.999 0.000  0 1.000  0 0.000
#> SRR1736367     3  0.0000      0.999 0.000  0 1.000  0 0.000
#> SRR1736368     3  0.0000      0.999 0.000  0 1.000  0 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette p1 p2    p3 p4 p5    p6
#> SRR1736309     2   0.000      1.000  0  1 0.000  0  0 0.000
#> SRR1736310     2   0.000      1.000  0  1 0.000  0  0 0.000
#> SRR1736312     2   0.000      1.000  0  1 0.000  0  0 0.000
#> SRR1736311     2   0.000      1.000  0  1 0.000  0  0 0.000
#> SRR1736313     2   0.000      1.000  0  1 0.000  0  0 0.000
#> SRR1736314     2   0.000      1.000  0  1 0.000  0  0 0.000
#> SRR1736315     2   0.000      1.000  0  1 0.000  0  0 0.000
#> SRR1736316     2   0.000      1.000  0  1 0.000  0  0 0.000
#> SRR1736317     2   0.000      1.000  0  1 0.000  0  0 0.000
#> SRR1736318     2   0.000      1.000  0  1 0.000  0  0 0.000
#> SRR1736319     2   0.000      1.000  0  1 0.000  0  0 0.000
#> SRR1736320     2   0.000      1.000  0  1 0.000  0  0 0.000
#> SRR1736321     2   0.000      1.000  0  1 0.000  0  0 0.000
#> SRR1736322     2   0.000      1.000  0  1 0.000  0  0 0.000
#> SRR1736323     2   0.000      1.000  0  1 0.000  0  0 0.000
#> SRR1736324     2   0.000      1.000  0  1 0.000  0  0 0.000
#> SRR1736325     2   0.000      1.000  0  1 0.000  0  0 0.000
#> SRR1736326     2   0.000      1.000  0  1 0.000  0  0 0.000
#> SRR1736328     4   0.000      1.000  0  0 0.000  1  0 0.000
#> SRR1736327     4   0.000      1.000  0  0 0.000  1  0 0.000
#> SRR1736329     4   0.000      1.000  0  0 0.000  1  0 0.000
#> SRR1736330     4   0.000      1.000  0  0 0.000  1  0 0.000
#> SRR1736331     4   0.000      1.000  0  0 0.000  1  0 0.000
#> SRR1736332     4   0.000      1.000  0  0 0.000  1  0 0.000
#> SRR1736333     5   0.000      1.000  0  0 0.000  0  1 0.000
#> SRR1736334     5   0.000      1.000  0  0 0.000  0  1 0.000
#> SRR1736335     5   0.000      1.000  0  0 0.000  0  1 0.000
#> SRR1736337     5   0.000      1.000  0  0 0.000  0  1 0.000
#> SRR1736336     5   0.000      1.000  0  0 0.000  0  1 0.000
#> SRR1736338     5   0.000      1.000  0  0 0.000  0  1 0.000
#> SRR1736339     1   0.000      1.000  1  0 0.000  0  0 0.000
#> SRR1736340     1   0.000      1.000  1  0 0.000  0  0 0.000
#> SRR1736341     1   0.000      1.000  1  0 0.000  0  0 0.000
#> SRR1736342     6   0.000      1.000  0  0 0.000  0  0 1.000
#> SRR1736343     6   0.000      1.000  0  0 0.000  0  0 1.000
#> SRR1736344     6   0.000      1.000  0  0 0.000  0  0 1.000
#> SRR1736345     1   0.000      1.000  1  0 0.000  0  0 0.000
#> SRR1736346     1   0.000      1.000  1  0 0.000  0  0 0.000
#> SRR1736348     6   0.000      1.000  0  0 0.000  0  0 1.000
#> SRR1736347     1   0.000      1.000  1  0 0.000  0  0 0.000
#> SRR1736349     6   0.000      1.000  0  0 0.000  0  0 1.000
#> SRR1736350     6   0.000      1.000  0  0 0.000  0  0 1.000
#> SRR1736351     1   0.000      1.000  1  0 0.000  0  0 0.000
#> SRR1736352     1   0.000      1.000  1  0 0.000  0  0 0.000
#> SRR1736353     1   0.000      1.000  1  0 0.000  0  0 0.000
#> SRR1736354     6   0.000      1.000  0  0 0.000  0  0 1.000
#> SRR1736355     6   0.000      1.000  0  0 0.000  0  0 1.000
#> SRR1736356     3   0.374      0.355  0  0 0.608  0  0 0.392
#> SRR1736358     3   0.000      0.965  0  0 1.000  0  0 0.000
#> SRR1736357     3   0.000      0.965  0  0 1.000  0  0 0.000
#> SRR1736359     3   0.000      0.965  0  0 1.000  0  0 0.000
#> SRR1736360     3   0.000      0.965  0  0 1.000  0  0 0.000
#> SRR1736361     3   0.000      0.965  0  0 1.000  0  0 0.000
#> SRR1736362     3   0.000      0.965  0  0 1.000  0  0 0.000
#> SRR1736363     3   0.000      0.965  0  0 1.000  0  0 0.000
#> SRR1736365     3   0.000      0.965  0  0 1.000  0  0 0.000
#> SRR1736364     3   0.000      0.965  0  0 1.000  0  0 0.000
#> SRR1736366     3   0.000      0.965  0  0 1.000  0  0 0.000
#> SRR1736367     3   0.000      0.965  0  0 1.000  0  0 0.000
#> SRR1736368     3   0.000      0.965  0  0 1.000  0  0 0.000

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

consensus_heatmap(res, k = 2)

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

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

collect_plots(res)

plot of chunk MAD-mclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4886 0.512   0.512
#> 3 3 1.000           0.984       0.991         0.2999 0.853   0.713
#> 4 4 0.898           0.960       0.979         0.1354 0.883   0.694
#> 5 5 0.936           0.929       0.959         0.0927 0.925   0.735
#> 6 6 0.968           0.953       0.966         0.0243 0.983   0.918

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

suggest_best_k(res)
#> [1] 6
#> attr(,"optional")
#> [1] 2 3 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
#> SRR1736309     2       0          1  0  1
#> SRR1736310     2       0          1  0  1
#> SRR1736312     2       0          1  0  1
#> SRR1736311     2       0          1  0  1
#> SRR1736313     2       0          1  0  1
#> SRR1736314     2       0          1  0  1
#> SRR1736315     2       0          1  0  1
#> SRR1736316     2       0          1  0  1
#> SRR1736317     2       0          1  0  1
#> SRR1736318     2       0          1  0  1
#> SRR1736319     2       0          1  0  1
#> SRR1736320     2       0          1  0  1
#> SRR1736321     2       0          1  0  1
#> SRR1736322     2       0          1  0  1
#> SRR1736323     2       0          1  0  1
#> SRR1736324     2       0          1  0  1
#> SRR1736325     2       0          1  0  1
#> SRR1736326     2       0          1  0  1
#> SRR1736328     2       0          1  0  1
#> SRR1736327     2       0          1  0  1
#> SRR1736329     2       0          1  0  1
#> SRR1736330     2       0          1  0  1
#> SRR1736331     2       0          1  0  1
#> SRR1736332     2       0          1  0  1
#> SRR1736333     1       0          1  1  0
#> SRR1736334     1       0          1  1  0
#> SRR1736335     1       0          1  1  0
#> SRR1736337     1       0          1  1  0
#> SRR1736336     1       0          1  1  0
#> SRR1736338     1       0          1  1  0
#> SRR1736339     1       0          1  1  0
#> SRR1736340     1       0          1  1  0
#> SRR1736341     1       0          1  1  0
#> SRR1736342     1       0          1  1  0
#> SRR1736343     1       0          1  1  0
#> SRR1736344     1       0          1  1  0
#> SRR1736345     1       0          1  1  0
#> SRR1736346     1       0          1  1  0
#> SRR1736348     1       0          1  1  0
#> SRR1736347     1       0          1  1  0
#> SRR1736349     1       0          1  1  0
#> SRR1736350     1       0          1  1  0
#> SRR1736351     1       0          1  1  0
#> SRR1736352     1       0          1  1  0
#> SRR1736353     1       0          1  1  0
#> SRR1736354     1       0          1  1  0
#> SRR1736355     1       0          1  1  0
#> SRR1736356     1       0          1  1  0
#> SRR1736358     1       0          1  1  0
#> SRR1736357     1       0          1  1  0
#> SRR1736359     1       0          1  1  0
#> SRR1736360     1       0          1  1  0
#> SRR1736361     1       0          1  1  0
#> SRR1736362     1       0          1  1  0
#> SRR1736363     1       0          1  1  0
#> SRR1736365     1       0          1  1  0
#> SRR1736364     1       0          1  1  0
#> SRR1736366     1       0          1  1  0
#> SRR1736367     1       0          1  1  0
#> SRR1736368     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
#> SRR1736309     2  0.0000      0.986 0.000 1.000 0.000
#> SRR1736310     2  0.0000      0.986 0.000 1.000 0.000
#> SRR1736312     2  0.0000      0.986 0.000 1.000 0.000
#> SRR1736311     2  0.0000      0.986 0.000 1.000 0.000
#> SRR1736313     2  0.0000      0.986 0.000 1.000 0.000
#> SRR1736314     2  0.0000      0.986 0.000 1.000 0.000
#> SRR1736315     2  0.0000      0.986 0.000 1.000 0.000
#> SRR1736316     2  0.0000      0.986 0.000 1.000 0.000
#> SRR1736317     2  0.0000      0.986 0.000 1.000 0.000
#> SRR1736318     2  0.0000      0.986 0.000 1.000 0.000
#> SRR1736319     2  0.0000      0.986 0.000 1.000 0.000
#> SRR1736320     2  0.0000      0.986 0.000 1.000 0.000
#> SRR1736321     2  0.0000      0.986 0.000 1.000 0.000
#> SRR1736322     2  0.0000      0.986 0.000 1.000 0.000
#> SRR1736323     2  0.0000      0.986 0.000 1.000 0.000
#> SRR1736324     2  0.0000      0.986 0.000 1.000 0.000
#> SRR1736325     2  0.0000      0.986 0.000 1.000 0.000
#> SRR1736326     2  0.0000      0.986 0.000 1.000 0.000
#> SRR1736328     2  0.1860      0.957 0.000 0.948 0.052
#> SRR1736327     2  0.1860      0.957 0.000 0.948 0.052
#> SRR1736329     2  0.1860      0.957 0.000 0.948 0.052
#> SRR1736330     2  0.1860      0.957 0.000 0.948 0.052
#> SRR1736331     2  0.1860      0.957 0.000 0.948 0.052
#> SRR1736332     2  0.1860      0.957 0.000 0.948 0.052
#> SRR1736333     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1736334     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1736335     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1736337     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1736336     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1736338     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1736339     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1736340     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1736341     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1736342     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1736343     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1736344     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1736345     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1736346     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1736348     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1736347     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1736349     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1736350     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1736351     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1736352     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1736353     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1736354     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1736355     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1736356     3  0.4452      0.762 0.192 0.000 0.808
#> SRR1736358     3  0.0000      0.977 0.000 0.000 1.000
#> SRR1736357     3  0.0000      0.977 0.000 0.000 1.000
#> SRR1736359     3  0.0000      0.977 0.000 0.000 1.000
#> SRR1736360     1  0.0237      0.996 0.996 0.000 0.004
#> SRR1736361     1  0.0237      0.996 0.996 0.000 0.004
#> SRR1736362     1  0.0237      0.996 0.996 0.000 0.004
#> SRR1736363     3  0.0000      0.977 0.000 0.000 1.000
#> SRR1736365     3  0.0000      0.977 0.000 0.000 1.000
#> SRR1736364     3  0.0000      0.977 0.000 0.000 1.000
#> SRR1736366     3  0.0000      0.977 0.000 0.000 1.000
#> SRR1736367     3  0.0000      0.977 0.000 0.000 1.000
#> SRR1736368     3  0.0000      0.977 0.000 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
#> SRR1736309     2  0.0000      1.000 0.000  1 0.000  0
#> SRR1736310     2  0.0000      1.000 0.000  1 0.000  0
#> SRR1736312     2  0.0000      1.000 0.000  1 0.000  0
#> SRR1736311     2  0.0000      1.000 0.000  1 0.000  0
#> SRR1736313     2  0.0000      1.000 0.000  1 0.000  0
#> SRR1736314     2  0.0000      1.000 0.000  1 0.000  0
#> SRR1736315     2  0.0000      1.000 0.000  1 0.000  0
#> SRR1736316     2  0.0000      1.000 0.000  1 0.000  0
#> SRR1736317     2  0.0000      1.000 0.000  1 0.000  0
#> SRR1736318     2  0.0000      1.000 0.000  1 0.000  0
#> SRR1736319     2  0.0000      1.000 0.000  1 0.000  0
#> SRR1736320     2  0.0000      1.000 0.000  1 0.000  0
#> SRR1736321     2  0.0000      1.000 0.000  1 0.000  0
#> SRR1736322     2  0.0000      1.000 0.000  1 0.000  0
#> SRR1736323     2  0.0000      1.000 0.000  1 0.000  0
#> SRR1736324     2  0.0000      1.000 0.000  1 0.000  0
#> SRR1736325     2  0.0000      1.000 0.000  1 0.000  0
#> SRR1736326     2  0.0000      1.000 0.000  1 0.000  0
#> SRR1736328     4  0.0000      1.000 0.000  0 0.000  1
#> SRR1736327     4  0.0000      1.000 0.000  0 0.000  1
#> SRR1736329     4  0.0000      1.000 0.000  0 0.000  1
#> SRR1736330     4  0.0000      1.000 0.000  0 0.000  1
#> SRR1736331     4  0.0000      1.000 0.000  0 0.000  1
#> SRR1736332     4  0.0000      1.000 0.000  0 0.000  1
#> SRR1736333     1  0.3726      0.793 0.788  0 0.212  0
#> SRR1736334     1  0.3726      0.793 0.788  0 0.212  0
#> SRR1736335     1  0.3726      0.793 0.788  0 0.212  0
#> SRR1736337     1  0.3726      0.793 0.788  0 0.212  0
#> SRR1736336     1  0.3726      0.793 0.788  0 0.212  0
#> SRR1736338     1  0.3726      0.793 0.788  0 0.212  0
#> SRR1736339     1  0.0000      0.933 1.000  0 0.000  0
#> SRR1736340     1  0.0000      0.933 1.000  0 0.000  0
#> SRR1736341     1  0.0000      0.933 1.000  0 0.000  0
#> SRR1736342     1  0.0000      0.933 1.000  0 0.000  0
#> SRR1736343     1  0.0000      0.933 1.000  0 0.000  0
#> SRR1736344     1  0.0000      0.933 1.000  0 0.000  0
#> SRR1736345     1  0.0000      0.933 1.000  0 0.000  0
#> SRR1736346     1  0.0000      0.933 1.000  0 0.000  0
#> SRR1736348     1  0.0000      0.933 1.000  0 0.000  0
#> SRR1736347     1  0.0000      0.933 1.000  0 0.000  0
#> SRR1736349     1  0.0000      0.933 1.000  0 0.000  0
#> SRR1736350     1  0.0000      0.933 1.000  0 0.000  0
#> SRR1736351     1  0.0000      0.933 1.000  0 0.000  0
#> SRR1736352     1  0.0000      0.933 1.000  0 0.000  0
#> SRR1736353     1  0.0000      0.933 1.000  0 0.000  0
#> SRR1736354     1  0.0188      0.931 0.996  0 0.004  0
#> SRR1736355     1  0.0188      0.931 0.996  0 0.004  0
#> SRR1736356     3  0.0188      0.995 0.004  0 0.996  0
#> SRR1736358     3  0.0000      1.000 0.000  0 1.000  0
#> SRR1736357     3  0.0000      1.000 0.000  0 1.000  0
#> SRR1736359     3  0.0000      1.000 0.000  0 1.000  0
#> SRR1736360     3  0.0000      1.000 0.000  0 1.000  0
#> SRR1736361     3  0.0000      1.000 0.000  0 1.000  0
#> SRR1736362     3  0.0000      1.000 0.000  0 1.000  0
#> SRR1736363     3  0.0000      1.000 0.000  0 1.000  0
#> SRR1736365     3  0.0000      1.000 0.000  0 1.000  0
#> SRR1736364     3  0.0000      1.000 0.000  0 1.000  0
#> SRR1736366     3  0.0000      1.000 0.000  0 1.000  0
#> SRR1736367     3  0.0000      1.000 0.000  0 1.000  0
#> SRR1736368     3  0.0000      1.000 0.000  0 1.000  0

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1 p2    p3 p4    p5
#> SRR1736309     2  0.0000      1.000 0.000  1 0.000  0 0.000
#> SRR1736310     2  0.0000      1.000 0.000  1 0.000  0 0.000
#> SRR1736312     2  0.0000      1.000 0.000  1 0.000  0 0.000
#> SRR1736311     2  0.0000      1.000 0.000  1 0.000  0 0.000
#> SRR1736313     2  0.0000      1.000 0.000  1 0.000  0 0.000
#> SRR1736314     2  0.0000      1.000 0.000  1 0.000  0 0.000
#> SRR1736315     2  0.0000      1.000 0.000  1 0.000  0 0.000
#> SRR1736316     2  0.0000      1.000 0.000  1 0.000  0 0.000
#> SRR1736317     2  0.0000      1.000 0.000  1 0.000  0 0.000
#> SRR1736318     2  0.0000      1.000 0.000  1 0.000  0 0.000
#> SRR1736319     2  0.0000      1.000 0.000  1 0.000  0 0.000
#> SRR1736320     2  0.0000      1.000 0.000  1 0.000  0 0.000
#> SRR1736321     2  0.0000      1.000 0.000  1 0.000  0 0.000
#> SRR1736322     2  0.0000      1.000 0.000  1 0.000  0 0.000
#> SRR1736323     2  0.0000      1.000 0.000  1 0.000  0 0.000
#> SRR1736324     2  0.0000      1.000 0.000  1 0.000  0 0.000
#> SRR1736325     2  0.0000      1.000 0.000  1 0.000  0 0.000
#> SRR1736326     2  0.0000      1.000 0.000  1 0.000  0 0.000
#> SRR1736328     4  0.0000      1.000 0.000  0 0.000  1 0.000
#> SRR1736327     4  0.0000      1.000 0.000  0 0.000  1 0.000
#> SRR1736329     4  0.0000      1.000 0.000  0 0.000  1 0.000
#> SRR1736330     4  0.0000      1.000 0.000  0 0.000  1 0.000
#> SRR1736331     4  0.0000      1.000 0.000  0 0.000  1 0.000
#> SRR1736332     4  0.0000      1.000 0.000  0 0.000  1 0.000
#> SRR1736333     5  0.0000      0.857 0.000  0 0.000  0 1.000
#> SRR1736334     5  0.0000      0.857 0.000  0 0.000  0 1.000
#> SRR1736335     5  0.0000      0.857 0.000  0 0.000  0 1.000
#> SRR1736337     5  0.0000      0.857 0.000  0 0.000  0 1.000
#> SRR1736336     5  0.0000      0.857 0.000  0 0.000  0 1.000
#> SRR1736338     5  0.0000      0.857 0.000  0 0.000  0 1.000
#> SRR1736339     5  0.3274      0.849 0.220  0 0.000  0 0.780
#> SRR1736340     5  0.3274      0.849 0.220  0 0.000  0 0.780
#> SRR1736341     5  0.3274      0.849 0.220  0 0.000  0 0.780
#> SRR1736342     1  0.0000      0.998 1.000  0 0.000  0 0.000
#> SRR1736343     1  0.0000      0.998 1.000  0 0.000  0 0.000
#> SRR1736344     1  0.0000      0.998 1.000  0 0.000  0 0.000
#> SRR1736345     5  0.3274      0.849 0.220  0 0.000  0 0.780
#> SRR1736346     5  0.3274      0.849 0.220  0 0.000  0 0.780
#> SRR1736348     1  0.0000      0.998 1.000  0 0.000  0 0.000
#> SRR1736347     5  0.3274      0.849 0.220  0 0.000  0 0.780
#> SRR1736349     1  0.0000      0.998 1.000  0 0.000  0 0.000
#> SRR1736350     1  0.0000      0.998 1.000  0 0.000  0 0.000
#> SRR1736351     1  0.0000      0.998 1.000  0 0.000  0 0.000
#> SRR1736352     1  0.0000      0.998 1.000  0 0.000  0 0.000
#> SRR1736353     1  0.0000      0.998 1.000  0 0.000  0 0.000
#> SRR1736354     1  0.0290      0.990 0.992  0 0.000  0 0.008
#> SRR1736355     1  0.0290      0.990 0.992  0 0.000  0 0.008
#> SRR1736356     3  0.0566      0.891 0.004  0 0.984  0 0.012
#> SRR1736358     3  0.0404      0.892 0.000  0 0.988  0 0.012
#> SRR1736357     3  0.0404      0.892 0.000  0 0.988  0 0.012
#> SRR1736359     3  0.0404      0.892 0.000  0 0.988  0 0.012
#> SRR1736360     3  0.4015      0.546 0.000  0 0.652  0 0.348
#> SRR1736361     3  0.4015      0.546 0.000  0 0.652  0 0.348
#> SRR1736362     3  0.4015      0.546 0.000  0 0.652  0 0.348
#> SRR1736363     3  0.0000      0.893 0.000  0 1.000  0 0.000
#> SRR1736365     3  0.0000      0.893 0.000  0 1.000  0 0.000
#> SRR1736364     3  0.0000      0.893 0.000  0 1.000  0 0.000
#> SRR1736366     3  0.0000      0.893 0.000  0 1.000  0 0.000
#> SRR1736367     3  0.0000      0.893 0.000  0 1.000  0 0.000
#> SRR1736368     3  0.0000      0.893 0.000  0 1.000  0 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3 p4    p5    p6
#> SRR1736309     2  0.0000      0.983 0.000 1.000 0.000  0 0.000 0.000
#> SRR1736310     2  0.0000      0.983 0.000 1.000 0.000  0 0.000 0.000
#> SRR1736312     2  0.0000      0.983 0.000 1.000 0.000  0 0.000 0.000
#> SRR1736311     2  0.0000      0.983 0.000 1.000 0.000  0 0.000 0.000
#> SRR1736313     2  0.0000      0.983 0.000 1.000 0.000  0 0.000 0.000
#> SRR1736314     2  0.0000      0.983 0.000 1.000 0.000  0 0.000 0.000
#> SRR1736315     2  0.1141      0.965 0.000 0.948 0.000  0 0.052 0.000
#> SRR1736316     2  0.1141      0.965 0.000 0.948 0.000  0 0.052 0.000
#> SRR1736317     2  0.1141      0.965 0.000 0.948 0.000  0 0.052 0.000
#> SRR1736318     2  0.0000      0.983 0.000 1.000 0.000  0 0.000 0.000
#> SRR1736319     2  0.0000      0.983 0.000 1.000 0.000  0 0.000 0.000
#> SRR1736320     2  0.0000      0.983 0.000 1.000 0.000  0 0.000 0.000
#> SRR1736321     2  0.1141      0.965 0.000 0.948 0.000  0 0.052 0.000
#> SRR1736322     2  0.1141      0.965 0.000 0.948 0.000  0 0.052 0.000
#> SRR1736323     2  0.1141      0.965 0.000 0.948 0.000  0 0.052 0.000
#> SRR1736324     2  0.0000      0.983 0.000 1.000 0.000  0 0.000 0.000
#> SRR1736325     2  0.0000      0.983 0.000 1.000 0.000  0 0.000 0.000
#> SRR1736326     2  0.0000      0.983 0.000 1.000 0.000  0 0.000 0.000
#> SRR1736328     4  0.0000      1.000 0.000 0.000 0.000  1 0.000 0.000
#> SRR1736327     4  0.0000      1.000 0.000 0.000 0.000  1 0.000 0.000
#> SRR1736329     4  0.0000      1.000 0.000 0.000 0.000  1 0.000 0.000
#> SRR1736330     4  0.0000      1.000 0.000 0.000 0.000  1 0.000 0.000
#> SRR1736331     4  0.0000      1.000 0.000 0.000 0.000  1 0.000 0.000
#> SRR1736332     4  0.0000      1.000 0.000 0.000 0.000  1 0.000 0.000
#> SRR1736333     1  0.0000      0.831 1.000 0.000 0.000  0 0.000 0.000
#> SRR1736334     1  0.0000      0.831 1.000 0.000 0.000  0 0.000 0.000
#> SRR1736335     1  0.0000      0.831 1.000 0.000 0.000  0 0.000 0.000
#> SRR1736337     1  0.0000      0.831 1.000 0.000 0.000  0 0.000 0.000
#> SRR1736336     1  0.0000      0.831 1.000 0.000 0.000  0 0.000 0.000
#> SRR1736338     1  0.0000      0.831 1.000 0.000 0.000  0 0.000 0.000
#> SRR1736339     1  0.3175      0.800 0.744 0.000 0.000  0 0.000 0.256
#> SRR1736340     1  0.3175      0.800 0.744 0.000 0.000  0 0.000 0.256
#> SRR1736341     1  0.3198      0.795 0.740 0.000 0.000  0 0.000 0.260
#> SRR1736342     6  0.0000      0.987 0.000 0.000 0.000  0 0.000 1.000
#> SRR1736343     6  0.0000      0.987 0.000 0.000 0.000  0 0.000 1.000
#> SRR1736344     6  0.0000      0.987 0.000 0.000 0.000  0 0.000 1.000
#> SRR1736345     1  0.2883      0.830 0.788 0.000 0.000  0 0.000 0.212
#> SRR1736346     1  0.2883      0.830 0.788 0.000 0.000  0 0.000 0.212
#> SRR1736348     6  0.0000      0.987 0.000 0.000 0.000  0 0.000 1.000
#> SRR1736347     1  0.2883      0.830 0.788 0.000 0.000  0 0.000 0.212
#> SRR1736349     6  0.0000      0.987 0.000 0.000 0.000  0 0.000 1.000
#> SRR1736350     6  0.0000      0.987 0.000 0.000 0.000  0 0.000 1.000
#> SRR1736351     6  0.0713      0.971 0.028 0.000 0.000  0 0.000 0.972
#> SRR1736352     6  0.0713      0.971 0.028 0.000 0.000  0 0.000 0.972
#> SRR1736353     6  0.0713      0.971 0.028 0.000 0.000  0 0.000 0.972
#> SRR1736354     6  0.0260      0.982 0.000 0.000 0.000  0 0.008 0.992
#> SRR1736355     6  0.0260      0.982 0.000 0.000 0.000  0 0.008 0.992
#> SRR1736356     3  0.0508      0.987 0.000 0.000 0.984  0 0.012 0.004
#> SRR1736358     3  0.0363      0.990 0.000 0.000 0.988  0 0.012 0.000
#> SRR1736357     3  0.0363      0.990 0.000 0.000 0.988  0 0.012 0.000
#> SRR1736359     3  0.0363      0.990 0.000 0.000 0.988  0 0.012 0.000
#> SRR1736360     5  0.1141      1.000 0.000 0.000 0.052  0 0.948 0.000
#> SRR1736361     5  0.1141      1.000 0.000 0.000 0.052  0 0.948 0.000
#> SRR1736362     5  0.1141      1.000 0.000 0.000 0.052  0 0.948 0.000
#> SRR1736363     3  0.0000      0.994 0.000 0.000 1.000  0 0.000 0.000
#> SRR1736365     3  0.0000      0.994 0.000 0.000 1.000  0 0.000 0.000
#> SRR1736364     3  0.0000      0.994 0.000 0.000 1.000  0 0.000 0.000
#> SRR1736366     3  0.0000      0.994 0.000 0.000 1.000  0 0.000 0.000
#> SRR1736367     3  0.0000      0.994 0.000 0.000 1.000  0 0.000 0.000
#> SRR1736368     3  0.0000      0.994 0.000 0.000 1.000  0 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-mclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-mclust-collect-classes

If matrix rows can be associated to genes, consider to use functional_enrichment(res, ...) to perform function enrichment for the signature genes. See this vignette for more detailed explanations.


MAD:NMF*

The object with results only for a single top-value method and a single partition method can be extracted as:

res = res_list["MAD", "NMF"]
# you can also extract it by
# res = res_list["MAD:NMF"]

A summary of res and all the functions that can be applied to it:

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 15454 rows and 60 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'NMF' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 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 1.000           1.000       1.000         0.4886 0.512   0.512
#> 3 3 0.675           0.796       0.820         0.3023 0.831   0.670
#> 4 4 0.924           0.938       0.949         0.1381 0.899   0.716
#> 5 5 0.742           0.795       0.831         0.0774 0.911   0.675
#> 6 6 0.781           0.757       0.849         0.0316 0.899   0.573

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette p1 p2
#> SRR1736309     2       0          1  0  1
#> SRR1736310     2       0          1  0  1
#> SRR1736312     2       0          1  0  1
#> SRR1736311     2       0          1  0  1
#> SRR1736313     2       0          1  0  1
#> SRR1736314     2       0          1  0  1
#> SRR1736315     2       0          1  0  1
#> SRR1736316     2       0          1  0  1
#> SRR1736317     2       0          1  0  1
#> SRR1736318     2       0          1  0  1
#> SRR1736319     2       0          1  0  1
#> SRR1736320     2       0          1  0  1
#> SRR1736321     2       0          1  0  1
#> SRR1736322     2       0          1  0  1
#> SRR1736323     2       0          1  0  1
#> SRR1736324     2       0          1  0  1
#> SRR1736325     2       0          1  0  1
#> SRR1736326     2       0          1  0  1
#> SRR1736328     2       0          1  0  1
#> SRR1736327     2       0          1  0  1
#> SRR1736329     2       0          1  0  1
#> SRR1736330     2       0          1  0  1
#> SRR1736331     2       0          1  0  1
#> SRR1736332     2       0          1  0  1
#> SRR1736333     1       0          1  1  0
#> SRR1736334     1       0          1  1  0
#> SRR1736335     1       0          1  1  0
#> SRR1736337     1       0          1  1  0
#> SRR1736336     1       0          1  1  0
#> SRR1736338     1       0          1  1  0
#> SRR1736339     1       0          1  1  0
#> SRR1736340     1       0          1  1  0
#> SRR1736341     1       0          1  1  0
#> SRR1736342     1       0          1  1  0
#> SRR1736343     1       0          1  1  0
#> SRR1736344     1       0          1  1  0
#> SRR1736345     1       0          1  1  0
#> SRR1736346     1       0          1  1  0
#> SRR1736348     1       0          1  1  0
#> SRR1736347     1       0          1  1  0
#> SRR1736349     1       0          1  1  0
#> SRR1736350     1       0          1  1  0
#> SRR1736351     1       0          1  1  0
#> SRR1736352     1       0          1  1  0
#> SRR1736353     1       0          1  1  0
#> SRR1736354     1       0          1  1  0
#> SRR1736355     1       0          1  1  0
#> SRR1736356     1       0          1  1  0
#> SRR1736358     1       0          1  1  0
#> SRR1736357     1       0          1  1  0
#> SRR1736359     1       0          1  1  0
#> SRR1736360     1       0          1  1  0
#> SRR1736361     1       0          1  1  0
#> SRR1736362     1       0          1  1  0
#> SRR1736363     1       0          1  1  0
#> SRR1736365     1       0          1  1  0
#> SRR1736364     1       0          1  1  0
#> SRR1736366     1       0          1  1  0
#> SRR1736367     1       0          1  1  0
#> SRR1736368     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
#> SRR1736309     2  0.6026      0.833 0.000 0.624 0.376
#> SRR1736310     2  0.6026      0.833 0.000 0.624 0.376
#> SRR1736312     2  0.6026      0.833 0.000 0.624 0.376
#> SRR1736311     2  0.6026      0.833 0.000 0.624 0.376
#> SRR1736313     2  0.6026      0.833 0.000 0.624 0.376
#> SRR1736314     2  0.6026      0.833 0.000 0.624 0.376
#> SRR1736315     2  0.0000      0.824 0.000 1.000 0.000
#> SRR1736316     2  0.0237      0.825 0.000 0.996 0.004
#> SRR1736317     2  0.0000      0.824 0.000 1.000 0.000
#> SRR1736318     2  0.5988      0.835 0.000 0.632 0.368
#> SRR1736319     2  0.5785      0.838 0.000 0.668 0.332
#> SRR1736320     2  0.5968      0.836 0.000 0.636 0.364
#> SRR1736321     2  0.1753      0.832 0.000 0.952 0.048
#> SRR1736322     2  0.1643      0.832 0.000 0.956 0.044
#> SRR1736323     2  0.4121      0.839 0.000 0.832 0.168
#> SRR1736324     2  0.5968      0.836 0.000 0.636 0.364
#> SRR1736325     2  0.5678      0.839 0.000 0.684 0.316
#> SRR1736326     2  0.6026      0.833 0.000 0.624 0.376
#> SRR1736328     2  0.0424      0.822 0.000 0.992 0.008
#> SRR1736327     2  0.0424      0.822 0.000 0.992 0.008
#> SRR1736329     2  0.0424      0.822 0.000 0.992 0.008
#> SRR1736330     2  0.0424      0.822 0.000 0.992 0.008
#> SRR1736331     2  0.0424      0.822 0.000 0.992 0.008
#> SRR1736332     2  0.0424      0.822 0.000 0.992 0.008
#> SRR1736333     1  0.5760      0.195 0.672 0.000 0.328
#> SRR1736334     1  0.5058      0.501 0.756 0.000 0.244
#> SRR1736335     3  0.6095      0.846 0.392 0.000 0.608
#> SRR1736337     1  0.5363      0.404 0.724 0.000 0.276
#> SRR1736336     1  0.4974      0.521 0.764 0.000 0.236
#> SRR1736338     1  0.5016      0.512 0.760 0.000 0.240
#> SRR1736339     1  0.0000      0.880 1.000 0.000 0.000
#> SRR1736340     1  0.0000      0.880 1.000 0.000 0.000
#> SRR1736341     1  0.0000      0.880 1.000 0.000 0.000
#> SRR1736342     1  0.0000      0.880 1.000 0.000 0.000
#> SRR1736343     1  0.0000      0.880 1.000 0.000 0.000
#> SRR1736344     1  0.0000      0.880 1.000 0.000 0.000
#> SRR1736345     1  0.0000      0.880 1.000 0.000 0.000
#> SRR1736346     1  0.0000      0.880 1.000 0.000 0.000
#> SRR1736348     1  0.0000      0.880 1.000 0.000 0.000
#> SRR1736347     1  0.0000      0.880 1.000 0.000 0.000
#> SRR1736349     1  0.0000      0.880 1.000 0.000 0.000
#> SRR1736350     1  0.0000      0.880 1.000 0.000 0.000
#> SRR1736351     1  0.0000      0.880 1.000 0.000 0.000
#> SRR1736352     1  0.0000      0.880 1.000 0.000 0.000
#> SRR1736353     1  0.0000      0.880 1.000 0.000 0.000
#> SRR1736354     1  0.0000      0.880 1.000 0.000 0.000
#> SRR1736355     1  0.0000      0.880 1.000 0.000 0.000
#> SRR1736356     1  0.5431      0.288 0.716 0.000 0.284
#> SRR1736358     3  0.6079      0.855 0.388 0.000 0.612
#> SRR1736357     3  0.6079      0.855 0.388 0.000 0.612
#> SRR1736359     3  0.6079      0.855 0.388 0.000 0.612
#> SRR1736360     3  0.4110      0.636 0.152 0.004 0.844
#> SRR1736361     3  0.3030      0.569 0.092 0.004 0.904
#> SRR1736362     3  0.4521      0.662 0.180 0.004 0.816
#> SRR1736363     3  0.6062      0.858 0.384 0.000 0.616
#> SRR1736365     3  0.6062      0.858 0.384 0.000 0.616
#> SRR1736364     3  0.6062      0.858 0.384 0.000 0.616
#> SRR1736366     3  0.6062      0.858 0.384 0.000 0.616
#> SRR1736367     3  0.6062      0.858 0.384 0.000 0.616
#> SRR1736368     3  0.6062      0.858 0.384 0.000 0.616

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1736309     2  0.0592      0.942 0.000 0.984 0.000 0.016
#> SRR1736310     2  0.0336      0.938 0.000 0.992 0.000 0.008
#> SRR1736312     2  0.0592      0.942 0.000 0.984 0.000 0.016
#> SRR1736311     2  0.0000      0.932 0.000 1.000 0.000 0.000
#> SRR1736313     2  0.0188      0.929 0.000 0.996 0.000 0.004
#> SRR1736314     2  0.0817      0.941 0.000 0.976 0.000 0.024
#> SRR1736315     4  0.3074      0.920 0.000 0.152 0.000 0.848
#> SRR1736316     4  0.3172      0.916 0.000 0.160 0.000 0.840
#> SRR1736317     4  0.3074      0.920 0.000 0.152 0.000 0.848
#> SRR1736318     2  0.2011      0.925 0.000 0.920 0.000 0.080
#> SRR1736319     2  0.2589      0.896 0.000 0.884 0.000 0.116
#> SRR1736320     2  0.2216      0.918 0.000 0.908 0.000 0.092
#> SRR1736321     4  0.3356      0.904 0.000 0.176 0.000 0.824
#> SRR1736322     4  0.3444      0.897 0.000 0.184 0.000 0.816
#> SRR1736323     4  0.4955      0.374 0.000 0.444 0.000 0.556
#> SRR1736324     2  0.2281      0.915 0.000 0.904 0.000 0.096
#> SRR1736325     2  0.3123      0.843 0.000 0.844 0.000 0.156
#> SRR1736326     2  0.0592      0.942 0.000 0.984 0.000 0.016
#> SRR1736328     4  0.2345      0.926 0.000 0.100 0.000 0.900
#> SRR1736327     4  0.2345      0.926 0.000 0.100 0.000 0.900
#> SRR1736329     4  0.2345      0.926 0.000 0.100 0.000 0.900
#> SRR1736330     4  0.2345      0.926 0.000 0.100 0.000 0.900
#> SRR1736331     4  0.2345      0.926 0.000 0.100 0.000 0.900
#> SRR1736332     4  0.2345      0.926 0.000 0.100 0.000 0.900
#> SRR1736333     1  0.0336      0.975 0.992 0.000 0.008 0.000
#> SRR1736334     1  0.0336      0.975 0.992 0.000 0.008 0.000
#> SRR1736335     1  0.1584      0.942 0.952 0.012 0.036 0.000
#> SRR1736337     1  0.0336      0.975 0.992 0.000 0.008 0.000
#> SRR1736336     1  0.0336      0.975 0.992 0.000 0.008 0.000
#> SRR1736338     1  0.0336      0.975 0.992 0.000 0.008 0.000
#> SRR1736339     1  0.0000      0.977 1.000 0.000 0.000 0.000
#> SRR1736340     1  0.0000      0.977 1.000 0.000 0.000 0.000
#> SRR1736341     1  0.0000      0.977 1.000 0.000 0.000 0.000
#> SRR1736342     1  0.0188      0.977 0.996 0.000 0.000 0.004
#> SRR1736343     1  0.0188      0.977 0.996 0.000 0.000 0.004
#> SRR1736344     1  0.0188      0.977 0.996 0.000 0.000 0.004
#> SRR1736345     1  0.0000      0.977 1.000 0.000 0.000 0.000
#> SRR1736346     1  0.0000      0.977 1.000 0.000 0.000 0.000
#> SRR1736348     1  0.0188      0.977 0.996 0.000 0.000 0.004
#> SRR1736347     1  0.0000      0.977 1.000 0.000 0.000 0.000
#> SRR1736349     1  0.0188      0.977 0.996 0.000 0.000 0.004
#> SRR1736350     1  0.0188      0.977 0.996 0.000 0.000 0.004
#> SRR1736351     1  0.0000      0.977 1.000 0.000 0.000 0.000
#> SRR1736352     1  0.0000      0.977 1.000 0.000 0.000 0.000
#> SRR1736353     1  0.0000      0.977 1.000 0.000 0.000 0.000
#> SRR1736354     1  0.0188      0.977 0.996 0.000 0.000 0.004
#> SRR1736355     1  0.0188      0.977 0.996 0.000 0.000 0.004
#> SRR1736356     1  0.5183      0.301 0.584 0.000 0.408 0.008
#> SRR1736358     3  0.0188      0.996 0.000 0.000 0.996 0.004
#> SRR1736357     3  0.0188      0.996 0.000 0.000 0.996 0.004
#> SRR1736359     3  0.0188      0.996 0.000 0.000 0.996 0.004
#> SRR1736360     3  0.0000      0.999 0.000 0.000 1.000 0.000
#> SRR1736361     3  0.0000      0.999 0.000 0.000 1.000 0.000
#> SRR1736362     3  0.0000      0.999 0.000 0.000 1.000 0.000
#> SRR1736363     3  0.0000      0.999 0.000 0.000 1.000 0.000
#> SRR1736365     3  0.0000      0.999 0.000 0.000 1.000 0.000
#> SRR1736364     3  0.0000      0.999 0.000 0.000 1.000 0.000
#> SRR1736366     3  0.0000      0.999 0.000 0.000 1.000 0.000
#> SRR1736367     3  0.0000      0.999 0.000 0.000 1.000 0.000
#> SRR1736368     3  0.0000      0.999 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
#> SRR1736309     2  0.0510      0.886 0.000 0.984 0.000 0.016 0.000
#> SRR1736310     2  0.0000      0.880 0.000 1.000 0.000 0.000 0.000
#> SRR1736312     2  0.0290      0.885 0.000 0.992 0.000 0.008 0.000
#> SRR1736311     2  0.0162      0.877 0.000 0.996 0.000 0.004 0.000
#> SRR1736313     2  0.0404      0.883 0.000 0.988 0.000 0.012 0.000
#> SRR1736314     2  0.0162      0.883 0.000 0.996 0.000 0.004 0.000
#> SRR1736315     4  0.4321      0.563 0.004 0.396 0.000 0.600 0.000
#> SRR1736316     4  0.4331      0.557 0.004 0.400 0.000 0.596 0.000
#> SRR1736317     4  0.4310      0.568 0.004 0.392 0.000 0.604 0.000
#> SRR1736318     2  0.1792      0.867 0.000 0.916 0.000 0.084 0.000
#> SRR1736319     2  0.2329      0.840 0.000 0.876 0.000 0.124 0.000
#> SRR1736320     2  0.2127      0.854 0.000 0.892 0.000 0.108 0.000
#> SRR1736321     4  0.4359      0.534 0.004 0.412 0.000 0.584 0.000
#> SRR1736322     4  0.4403      0.473 0.004 0.436 0.000 0.560 0.000
#> SRR1736323     2  0.4288      0.147 0.004 0.612 0.000 0.384 0.000
#> SRR1736324     2  0.2280      0.844 0.000 0.880 0.000 0.120 0.000
#> SRR1736325     2  0.2690      0.798 0.000 0.844 0.000 0.156 0.000
#> SRR1736326     2  0.0404      0.886 0.000 0.988 0.000 0.012 0.000
#> SRR1736328     4  0.1341      0.760 0.000 0.056 0.000 0.944 0.000
#> SRR1736327     4  0.1341      0.760 0.000 0.056 0.000 0.944 0.000
#> SRR1736329     4  0.1341      0.760 0.000 0.056 0.000 0.944 0.000
#> SRR1736330     4  0.1341      0.760 0.000 0.056 0.000 0.944 0.000
#> SRR1736331     4  0.1341      0.760 0.000 0.056 0.000 0.944 0.000
#> SRR1736332     4  0.1341      0.760 0.000 0.056 0.000 0.944 0.000
#> SRR1736333     5  0.3970      0.739 0.224 0.000 0.024 0.000 0.752
#> SRR1736334     5  0.4000      0.739 0.228 0.000 0.024 0.000 0.748
#> SRR1736335     5  0.4992      0.691 0.244 0.020 0.040 0.000 0.696
#> SRR1736337     5  0.3970      0.739 0.224 0.000 0.024 0.000 0.752
#> SRR1736336     5  0.3877      0.744 0.212 0.000 0.024 0.000 0.764
#> SRR1736338     5  0.3845      0.744 0.208 0.000 0.024 0.000 0.768
#> SRR1736339     1  0.4242      1.000 0.572 0.000 0.000 0.000 0.428
#> SRR1736340     1  0.4242      1.000 0.572 0.000 0.000 0.000 0.428
#> SRR1736341     1  0.4242      1.000 0.572 0.000 0.000 0.000 0.428
#> SRR1736342     5  0.2020      0.590 0.100 0.000 0.000 0.000 0.900
#> SRR1736343     5  0.1544      0.654 0.068 0.000 0.000 0.000 0.932
#> SRR1736344     5  0.1478      0.664 0.064 0.000 0.000 0.000 0.936
#> SRR1736345     1  0.4242      1.000 0.572 0.000 0.000 0.000 0.428
#> SRR1736346     1  0.4242      1.000 0.572 0.000 0.000 0.000 0.428
#> SRR1736348     5  0.0162      0.738 0.004 0.000 0.000 0.000 0.996
#> SRR1736347     1  0.4242      1.000 0.572 0.000 0.000 0.000 0.428
#> SRR1736349     5  0.0162      0.738 0.004 0.000 0.000 0.000 0.996
#> SRR1736350     5  0.0162      0.738 0.004 0.000 0.000 0.000 0.996
#> SRR1736351     1  0.4242      1.000 0.572 0.000 0.000 0.000 0.428
#> SRR1736352     1  0.4242      1.000 0.572 0.000 0.000 0.000 0.428
#> SRR1736353     1  0.4242      1.000 0.572 0.000 0.000 0.000 0.428
#> SRR1736354     5  0.0000      0.736 0.000 0.000 0.000 0.000 1.000
#> SRR1736355     5  0.0162      0.738 0.004 0.000 0.000 0.000 0.996
#> SRR1736356     5  0.5137      0.545 0.096 0.000 0.228 0.000 0.676
#> SRR1736358     3  0.2727      0.846 0.016 0.000 0.868 0.000 0.116
#> SRR1736357     3  0.2677      0.850 0.016 0.000 0.872 0.000 0.112
#> SRR1736359     3  0.2464      0.862 0.016 0.000 0.888 0.000 0.096
#> SRR1736360     3  0.3305      0.803 0.224 0.000 0.776 0.000 0.000
#> SRR1736361     3  0.3395      0.798 0.236 0.000 0.764 0.000 0.000
#> SRR1736362     3  0.3305      0.803 0.224 0.000 0.776 0.000 0.000
#> SRR1736363     3  0.0162      0.905 0.004 0.000 0.996 0.000 0.000
#> SRR1736365     3  0.0000      0.906 0.000 0.000 1.000 0.000 0.000
#> SRR1736364     3  0.0000      0.906 0.000 0.000 1.000 0.000 0.000
#> SRR1736366     3  0.0000      0.906 0.000 0.000 1.000 0.000 0.000
#> SRR1736367     3  0.0000      0.906 0.000 0.000 1.000 0.000 0.000
#> SRR1736368     3  0.0000      0.906 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
#> SRR1736309     2  0.0363      0.878 0.000 0.988 0.000 0.012 0.000 0.000
#> SRR1736310     2  0.0405      0.869 0.000 0.988 0.008 0.000 0.000 0.004
#> SRR1736312     2  0.0000      0.874 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736311     2  0.0405      0.869 0.000 0.988 0.008 0.000 0.000 0.004
#> SRR1736313     2  0.0935      0.873 0.000 0.964 0.004 0.032 0.000 0.000
#> SRR1736314     2  0.0260      0.871 0.000 0.992 0.008 0.000 0.000 0.000
#> SRR1736315     2  0.3383      0.745 0.000 0.728 0.004 0.268 0.000 0.000
#> SRR1736316     2  0.3244      0.748 0.000 0.732 0.000 0.268 0.000 0.000
#> SRR1736317     2  0.3383      0.745 0.000 0.728 0.004 0.268 0.000 0.000
#> SRR1736318     2  0.0937      0.881 0.000 0.960 0.000 0.040 0.000 0.000
#> SRR1736319     2  0.1267      0.881 0.000 0.940 0.000 0.060 0.000 0.000
#> SRR1736320     2  0.1141      0.882 0.000 0.948 0.000 0.052 0.000 0.000
#> SRR1736321     2  0.3198      0.756 0.000 0.740 0.000 0.260 0.000 0.000
#> SRR1736322     2  0.3221      0.753 0.000 0.736 0.000 0.264 0.000 0.000
#> SRR1736323     2  0.2793      0.805 0.000 0.800 0.000 0.200 0.000 0.000
#> SRR1736324     2  0.1204      0.881 0.000 0.944 0.000 0.056 0.000 0.000
#> SRR1736325     2  0.1444      0.877 0.000 0.928 0.000 0.072 0.000 0.000
#> SRR1736326     2  0.0000      0.874 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736328     4  0.1556      1.000 0.000 0.080 0.000 0.920 0.000 0.000
#> SRR1736327     4  0.1556      1.000 0.000 0.080 0.000 0.920 0.000 0.000
#> SRR1736329     4  0.1556      1.000 0.000 0.080 0.000 0.920 0.000 0.000
#> SRR1736330     4  0.1556      1.000 0.000 0.080 0.000 0.920 0.000 0.000
#> SRR1736331     4  0.1556      1.000 0.000 0.080 0.000 0.920 0.000 0.000
#> SRR1736332     4  0.1556      1.000 0.000 0.080 0.000 0.920 0.000 0.000
#> SRR1736333     5  0.5363      0.317 0.032 0.000 0.044 0.000 0.468 0.456
#> SRR1736334     5  0.5363      0.327 0.032 0.000 0.044 0.000 0.472 0.452
#> SRR1736335     5  0.5250      0.386 0.016 0.008 0.044 0.000 0.544 0.388
#> SRR1736337     5  0.5363      0.327 0.032 0.000 0.044 0.000 0.472 0.452
#> SRR1736336     6  0.5329     -0.305 0.032 0.000 0.044 0.000 0.408 0.516
#> SRR1736338     6  0.5290     -0.236 0.032 0.000 0.044 0.000 0.384 0.540
#> SRR1736339     1  0.0146      0.997 0.996 0.000 0.000 0.000 0.000 0.004
#> SRR1736340     1  0.0146      0.997 0.996 0.000 0.000 0.000 0.000 0.004
#> SRR1736341     1  0.0146      0.997 0.996 0.000 0.000 0.000 0.000 0.004
#> SRR1736342     6  0.3266      0.682 0.272 0.000 0.000 0.000 0.000 0.728
#> SRR1736343     6  0.3221      0.688 0.264 0.000 0.000 0.000 0.000 0.736
#> SRR1736344     6  0.3175      0.694 0.256 0.000 0.000 0.000 0.000 0.744
#> SRR1736345     1  0.0000      0.996 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1736346     1  0.0000      0.996 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1736348     6  0.2135      0.731 0.128 0.000 0.000 0.000 0.000 0.872
#> SRR1736347     1  0.0000      0.996 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1736349     6  0.2219      0.734 0.136 0.000 0.000 0.000 0.000 0.864
#> SRR1736350     6  0.2219      0.734 0.136 0.000 0.000 0.000 0.000 0.864
#> SRR1736351     1  0.0291      0.996 0.992 0.000 0.004 0.000 0.000 0.004
#> SRR1736352     1  0.0291      0.996 0.992 0.000 0.004 0.000 0.000 0.004
#> SRR1736353     1  0.0291      0.996 0.992 0.000 0.004 0.000 0.000 0.004
#> SRR1736354     6  0.2402      0.734 0.140 0.000 0.004 0.000 0.000 0.856
#> SRR1736355     6  0.2257      0.721 0.116 0.000 0.008 0.000 0.000 0.876
#> SRR1736356     6  0.4406      0.274 0.008 0.000 0.344 0.000 0.024 0.624
#> SRR1736358     3  0.5256      0.778 0.000 0.000 0.580 0.000 0.288 0.132
#> SRR1736357     3  0.5204      0.788 0.000 0.000 0.584 0.000 0.292 0.124
#> SRR1736359     3  0.5142      0.802 0.000 0.000 0.584 0.000 0.304 0.112
#> SRR1736360     5  0.0713      0.267 0.000 0.000 0.028 0.000 0.972 0.000
#> SRR1736361     5  0.0777      0.277 0.004 0.000 0.024 0.000 0.972 0.000
#> SRR1736362     5  0.0790      0.258 0.000 0.000 0.032 0.000 0.968 0.000
#> SRR1736363     3  0.3833      0.907 0.000 0.000 0.556 0.000 0.444 0.000
#> SRR1736365     3  0.3833      0.907 0.000 0.000 0.556 0.000 0.444 0.000
#> SRR1736364     3  0.3833      0.907 0.000 0.000 0.556 0.000 0.444 0.000
#> SRR1736366     3  0.3833      0.907 0.000 0.000 0.556 0.000 0.444 0.000
#> SRR1736367     3  0.3833      0.907 0.000 0.000 0.556 0.000 0.444 0.000
#> SRR1736368     3  0.3833      0.907 0.000 0.000 0.556 0.000 0.444 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-NMF-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-NMF-collect-classes

If matrix rows can be associated to genes, consider to use functional_enrichment(res, ...) to perform function enrichment for the signature genes. See this vignette for more detailed explanations.


ATC:hclust*

The object with results only for a single top-value method and a single partition method can be extracted as:

res = res_list["ATC", "hclust"]
# you can also extract it by
# res = res_list["ATC:hclust"]

A summary of res and all the functions that can be applied to it:

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

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

collect_plots(res)

plot of chunk ATC-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           1.000       1.000         0.4886 0.512   0.512
#> 3 3 1.000           0.978       0.996         0.0460 0.980   0.961
#> 4 4 1.000           0.973       0.992         0.2412 0.868   0.731
#> 5 5 0.909           0.520       0.796         0.0768 0.914   0.771
#> 6 6 0.882           0.912       0.949         0.0753 0.880   0.656

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette p1 p2
#> SRR1736309     2       0          1  0  1
#> SRR1736310     2       0          1  0  1
#> SRR1736312     2       0          1  0  1
#> SRR1736311     2       0          1  0  1
#> SRR1736313     2       0          1  0  1
#> SRR1736314     2       0          1  0  1
#> SRR1736315     2       0          1  0  1
#> SRR1736316     2       0          1  0  1
#> SRR1736317     2       0          1  0  1
#> SRR1736318     2       0          1  0  1
#> SRR1736319     2       0          1  0  1
#> SRR1736320     2       0          1  0  1
#> SRR1736321     2       0          1  0  1
#> SRR1736322     2       0          1  0  1
#> SRR1736323     2       0          1  0  1
#> SRR1736324     2       0          1  0  1
#> SRR1736325     2       0          1  0  1
#> SRR1736326     2       0          1  0  1
#> SRR1736328     2       0          1  0  1
#> SRR1736327     2       0          1  0  1
#> SRR1736329     2       0          1  0  1
#> SRR1736330     2       0          1  0  1
#> SRR1736331     2       0          1  0  1
#> SRR1736332     2       0          1  0  1
#> SRR1736333     1       0          1  1  0
#> SRR1736334     1       0          1  1  0
#> SRR1736335     1       0          1  1  0
#> SRR1736337     1       0          1  1  0
#> SRR1736336     1       0          1  1  0
#> SRR1736338     1       0          1  1  0
#> SRR1736339     1       0          1  1  0
#> SRR1736340     1       0          1  1  0
#> SRR1736341     1       0          1  1  0
#> SRR1736342     1       0          1  1  0
#> SRR1736343     1       0          1  1  0
#> SRR1736344     1       0          1  1  0
#> SRR1736345     1       0          1  1  0
#> SRR1736346     1       0          1  1  0
#> SRR1736348     1       0          1  1  0
#> SRR1736347     1       0          1  1  0
#> SRR1736349     1       0          1  1  0
#> SRR1736350     1       0          1  1  0
#> SRR1736351     1       0          1  1  0
#> SRR1736352     1       0          1  1  0
#> SRR1736353     1       0          1  1  0
#> SRR1736354     1       0          1  1  0
#> SRR1736355     1       0          1  1  0
#> SRR1736356     1       0          1  1  0
#> SRR1736358     1       0          1  1  0
#> SRR1736357     1       0          1  1  0
#> SRR1736359     1       0          1  1  0
#> SRR1736360     1       0          1  1  0
#> SRR1736361     1       0          1  1  0
#> SRR1736362     1       0          1  1  0
#> SRR1736363     1       0          1  1  0
#> SRR1736365     1       0          1  1  0
#> SRR1736364     1       0          1  1  0
#> SRR1736366     1       0          1  1  0
#> SRR1736367     1       0          1  1  0
#> SRR1736368     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
#> SRR1736309     2   0.000      1.000 0.000  1 0.000
#> SRR1736310     2   0.000      1.000 0.000  1 0.000
#> SRR1736312     2   0.000      1.000 0.000  1 0.000
#> SRR1736311     2   0.000      1.000 0.000  1 0.000
#> SRR1736313     2   0.000      1.000 0.000  1 0.000
#> SRR1736314     2   0.000      1.000 0.000  1 0.000
#> SRR1736315     2   0.000      1.000 0.000  1 0.000
#> SRR1736316     2   0.000      1.000 0.000  1 0.000
#> SRR1736317     2   0.000      1.000 0.000  1 0.000
#> SRR1736318     2   0.000      1.000 0.000  1 0.000
#> SRR1736319     2   0.000      1.000 0.000  1 0.000
#> SRR1736320     2   0.000      1.000 0.000  1 0.000
#> SRR1736321     2   0.000      1.000 0.000  1 0.000
#> SRR1736322     2   0.000      1.000 0.000  1 0.000
#> SRR1736323     2   0.000      1.000 0.000  1 0.000
#> SRR1736324     2   0.000      1.000 0.000  1 0.000
#> SRR1736325     2   0.000      1.000 0.000  1 0.000
#> SRR1736326     2   0.000      1.000 0.000  1 0.000
#> SRR1736328     2   0.000      1.000 0.000  1 0.000
#> SRR1736327     2   0.000      1.000 0.000  1 0.000
#> SRR1736329     2   0.000      1.000 0.000  1 0.000
#> SRR1736330     2   0.000      1.000 0.000  1 0.000
#> SRR1736331     2   0.000      1.000 0.000  1 0.000
#> SRR1736332     2   0.000      1.000 0.000  1 0.000
#> SRR1736333     1   0.103      0.981 0.976  0 0.024
#> SRR1736334     1   0.103      0.981 0.976  0 0.024
#> SRR1736335     1   0.103      0.981 0.976  0 0.024
#> SRR1736337     1   0.103      0.981 0.976  0 0.024
#> SRR1736336     1   0.103      0.981 0.976  0 0.024
#> SRR1736338     1   0.103      0.981 0.976  0 0.024
#> SRR1736339     1   0.000      0.993 1.000  0 0.000
#> SRR1736340     1   0.000      0.993 1.000  0 0.000
#> SRR1736341     1   0.000      0.993 1.000  0 0.000
#> SRR1736342     1   0.000      0.993 1.000  0 0.000
#> SRR1736343     1   0.000      0.993 1.000  0 0.000
#> SRR1736344     1   0.000      0.993 1.000  0 0.000
#> SRR1736345     1   0.000      0.993 1.000  0 0.000
#> SRR1736346     1   0.000      0.993 1.000  0 0.000
#> SRR1736348     1   0.000      0.993 1.000  0 0.000
#> SRR1736347     1   0.000      0.993 1.000  0 0.000
#> SRR1736349     1   0.000      0.993 1.000  0 0.000
#> SRR1736350     1   0.000      0.993 1.000  0 0.000
#> SRR1736351     1   0.000      0.993 1.000  0 0.000
#> SRR1736352     1   0.000      0.993 1.000  0 0.000
#> SRR1736353     1   0.000      0.993 1.000  0 0.000
#> SRR1736354     1   0.000      0.993 1.000  0 0.000
#> SRR1736355     1   0.000      0.993 1.000  0 0.000
#> SRR1736356     3   0.103      0.000 0.024  0 0.976
#> SRR1736358     1   0.000      0.993 1.000  0 0.000
#> SRR1736357     1   0.000      0.993 1.000  0 0.000
#> SRR1736359     1   0.000      0.993 1.000  0 0.000
#> SRR1736360     1   0.103      0.981 0.976  0 0.024
#> SRR1736361     1   0.103      0.981 0.976  0 0.024
#> SRR1736362     1   0.103      0.981 0.976  0 0.024
#> SRR1736363     1   0.000      0.993 1.000  0 0.000
#> SRR1736365     1   0.000      0.993 1.000  0 0.000
#> SRR1736364     1   0.000      0.993 1.000  0 0.000
#> SRR1736366     1   0.000      0.993 1.000  0 0.000
#> SRR1736367     1   0.000      0.993 1.000  0 0.000
#> SRR1736368     1   0.000      0.993 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
#> SRR1736309     2  0.0000      1.000 0.000  1 0.000  0
#> SRR1736310     2  0.0000      1.000 0.000  1 0.000  0
#> SRR1736312     2  0.0000      1.000 0.000  1 0.000  0
#> SRR1736311     2  0.0000      1.000 0.000  1 0.000  0
#> SRR1736313     2  0.0000      1.000 0.000  1 0.000  0
#> SRR1736314     2  0.0000      1.000 0.000  1 0.000  0
#> SRR1736315     2  0.0000      1.000 0.000  1 0.000  0
#> SRR1736316     2  0.0000      1.000 0.000  1 0.000  0
#> SRR1736317     2  0.0000      1.000 0.000  1 0.000  0
#> SRR1736318     2  0.0000      1.000 0.000  1 0.000  0
#> SRR1736319     2  0.0000      1.000 0.000  1 0.000  0
#> SRR1736320     2  0.0000      1.000 0.000  1 0.000  0
#> SRR1736321     2  0.0000      1.000 0.000  1 0.000  0
#> SRR1736322     2  0.0000      1.000 0.000  1 0.000  0
#> SRR1736323     2  0.0000      1.000 0.000  1 0.000  0
#> SRR1736324     2  0.0000      1.000 0.000  1 0.000  0
#> SRR1736325     2  0.0000      1.000 0.000  1 0.000  0
#> SRR1736326     2  0.0000      1.000 0.000  1 0.000  0
#> SRR1736328     2  0.0000      1.000 0.000  1 0.000  0
#> SRR1736327     2  0.0000      1.000 0.000  1 0.000  0
#> SRR1736329     2  0.0000      1.000 0.000  1 0.000  0
#> SRR1736330     2  0.0000      1.000 0.000  1 0.000  0
#> SRR1736331     2  0.0000      1.000 0.000  1 0.000  0
#> SRR1736332     2  0.0000      1.000 0.000  1 0.000  0
#> SRR1736333     3  0.1940      0.950 0.076  0 0.924  0
#> SRR1736334     3  0.1940      0.950 0.076  0 0.924  0
#> SRR1736335     3  0.1940      0.950 0.076  0 0.924  0
#> SRR1736337     3  0.1940      0.950 0.076  0 0.924  0
#> SRR1736336     3  0.1940      0.950 0.076  0 0.924  0
#> SRR1736338     3  0.1940      0.950 0.076  0 0.924  0
#> SRR1736339     1  0.0000      1.000 1.000  0 0.000  0
#> SRR1736340     1  0.0000      1.000 1.000  0 0.000  0
#> SRR1736341     1  0.0000      1.000 1.000  0 0.000  0
#> SRR1736342     1  0.0000      1.000 1.000  0 0.000  0
#> SRR1736343     1  0.0000      1.000 1.000  0 0.000  0
#> SRR1736344     1  0.0000      1.000 1.000  0 0.000  0
#> SRR1736345     1  0.0000      1.000 1.000  0 0.000  0
#> SRR1736346     1  0.0000      1.000 1.000  0 0.000  0
#> SRR1736348     1  0.0000      1.000 1.000  0 0.000  0
#> SRR1736347     1  0.0000      1.000 1.000  0 0.000  0
#> SRR1736349     1  0.0000      1.000 1.000  0 0.000  0
#> SRR1736350     1  0.0000      1.000 1.000  0 0.000  0
#> SRR1736351     1  0.0000      1.000 1.000  0 0.000  0
#> SRR1736352     1  0.0000      1.000 1.000  0 0.000  0
#> SRR1736353     1  0.0000      1.000 1.000  0 0.000  0
#> SRR1736354     1  0.0000      1.000 1.000  0 0.000  0
#> SRR1736355     1  0.0000      1.000 1.000  0 0.000  0
#> SRR1736356     4  0.0000      0.000 0.000  0 0.000  1
#> SRR1736358     1  0.0000      1.000 1.000  0 0.000  0
#> SRR1736357     1  0.0000      1.000 1.000  0 0.000  0
#> SRR1736359     1  0.0000      1.000 1.000  0 0.000  0
#> SRR1736360     3  0.0336      0.899 0.008  0 0.992  0
#> SRR1736361     3  0.0000      0.885 0.000  0 1.000  0
#> SRR1736362     3  0.0336      0.899 0.008  0 0.992  0
#> SRR1736363     1  0.0000      1.000 1.000  0 0.000  0
#> SRR1736365     1  0.0000      1.000 1.000  0 0.000  0
#> SRR1736364     1  0.0000      1.000 1.000  0 0.000  0
#> SRR1736366     1  0.0000      1.000 1.000  0 0.000  0
#> SRR1736367     1  0.0000      1.000 1.000  0 0.000  0
#> SRR1736368     1  0.0000      1.000 1.000  0 0.000  0

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1 p2    p3 p4    p5
#> SRR1736309     2   0.000      1.000 0.000  1 0.000  0 0.000
#> SRR1736310     2   0.000      1.000 0.000  1 0.000  0 0.000
#> SRR1736312     2   0.000      1.000 0.000  1 0.000  0 0.000
#> SRR1736311     2   0.000      1.000 0.000  1 0.000  0 0.000
#> SRR1736313     2   0.000      1.000 0.000  1 0.000  0 0.000
#> SRR1736314     2   0.000      1.000 0.000  1 0.000  0 0.000
#> SRR1736315     2   0.000      1.000 0.000  1 0.000  0 0.000
#> SRR1736316     2   0.000      1.000 0.000  1 0.000  0 0.000
#> SRR1736317     2   0.000      1.000 0.000  1 0.000  0 0.000
#> SRR1736318     2   0.000      1.000 0.000  1 0.000  0 0.000
#> SRR1736319     2   0.000      1.000 0.000  1 0.000  0 0.000
#> SRR1736320     2   0.000      1.000 0.000  1 0.000  0 0.000
#> SRR1736321     2   0.000      1.000 0.000  1 0.000  0 0.000
#> SRR1736322     2   0.000      1.000 0.000  1 0.000  0 0.000
#> SRR1736323     2   0.000      1.000 0.000  1 0.000  0 0.000
#> SRR1736324     2   0.000      1.000 0.000  1 0.000  0 0.000
#> SRR1736325     2   0.000      1.000 0.000  1 0.000  0 0.000
#> SRR1736326     2   0.000      1.000 0.000  1 0.000  0 0.000
#> SRR1736328     2   0.000      1.000 0.000  1 0.000  0 0.000
#> SRR1736327     2   0.000      1.000 0.000  1 0.000  0 0.000
#> SRR1736329     2   0.000      1.000 0.000  1 0.000  0 0.000
#> SRR1736330     2   0.000      1.000 0.000  1 0.000  0 0.000
#> SRR1736331     2   0.000      1.000 0.000  1 0.000  0 0.000
#> SRR1736332     2   0.000      1.000 0.000  1 0.000  0 0.000
#> SRR1736333     5   0.426     -0.675 0.000  0 0.440  0 0.560
#> SRR1736334     5   0.426     -0.675 0.000  0 0.440  0 0.560
#> SRR1736335     5   0.426     -0.675 0.000  0 0.440  0 0.560
#> SRR1736337     5   0.426     -0.675 0.000  0 0.440  0 0.560
#> SRR1736336     5   0.426     -0.675 0.000  0 0.440  0 0.560
#> SRR1736338     5   0.426     -0.675 0.000  0 0.440  0 0.560
#> SRR1736339     1   0.429      0.619 0.536  0 0.000  0 0.464
#> SRR1736340     1   0.429      0.619 0.536  0 0.000  0 0.464
#> SRR1736341     1   0.429      0.619 0.536  0 0.000  0 0.464
#> SRR1736342     1   0.429      0.619 0.536  0 0.000  0 0.464
#> SRR1736343     1   0.429      0.619 0.536  0 0.000  0 0.464
#> SRR1736344     1   0.429      0.619 0.536  0 0.000  0 0.464
#> SRR1736345     1   0.429      0.619 0.536  0 0.000  0 0.464
#> SRR1736346     1   0.429      0.619 0.536  0 0.000  0 0.464
#> SRR1736348     5   0.431     -0.592 0.492  0 0.000  0 0.508
#> SRR1736347     1   0.429      0.619 0.536  0 0.000  0 0.464
#> SRR1736349     5   0.431     -0.592 0.492  0 0.000  0 0.508
#> SRR1736350     5   0.431     -0.592 0.492  0 0.000  0 0.508
#> SRR1736351     1   0.429      0.619 0.536  0 0.000  0 0.464
#> SRR1736352     1   0.429      0.619 0.536  0 0.000  0 0.464
#> SRR1736353     1   0.429      0.619 0.536  0 0.000  0 0.464
#> SRR1736354     5   0.431     -0.592 0.492  0 0.000  0 0.508
#> SRR1736355     5   0.431     -0.592 0.492  0 0.000  0 0.508
#> SRR1736356     4   0.000      0.000 0.000  0 0.000  1 0.000
#> SRR1736358     1   0.127      0.557 0.948  0 0.000  0 0.052
#> SRR1736357     1   0.127      0.557 0.948  0 0.000  0 0.052
#> SRR1736359     1   0.127      0.557 0.948  0 0.000  0 0.052
#> SRR1736360     3   0.431      0.697 0.000  0 0.508  0 0.492
#> SRR1736361     3   0.000      0.230 0.000  0 1.000  0 0.000
#> SRR1736362     3   0.431      0.697 0.000  0 0.508  0 0.492
#> SRR1736363     1   0.029      0.585 0.992  0 0.000  0 0.008
#> SRR1736365     1   0.029      0.585 0.992  0 0.000  0 0.008
#> SRR1736364     1   0.029      0.585 0.992  0 0.000  0 0.008
#> SRR1736366     1   0.029      0.585 0.992  0 0.000  0 0.008
#> SRR1736367     1   0.029      0.585 0.992  0 0.000  0 0.008
#> SRR1736368     1   0.029      0.585 0.992  0 0.000  0 0.008

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5 p6
#> SRR1736309     2  0.0000      0.953 0.000 1.000 0.000 0.000 0.000  0
#> SRR1736310     2  0.0000      0.953 0.000 1.000 0.000 0.000 0.000  0
#> SRR1736312     2  0.0000      0.953 0.000 1.000 0.000 0.000 0.000  0
#> SRR1736311     2  0.0000      0.953 0.000 1.000 0.000 0.000 0.000  0
#> SRR1736313     2  0.0000      0.953 0.000 1.000 0.000 0.000 0.000  0
#> SRR1736314     2  0.0000      0.953 0.000 1.000 0.000 0.000 0.000  0
#> SRR1736315     2  0.0146      0.951 0.000 0.996 0.000 0.004 0.000  0
#> SRR1736316     2  0.0146      0.951 0.000 0.996 0.000 0.004 0.000  0
#> SRR1736317     2  0.0146      0.951 0.000 0.996 0.000 0.004 0.000  0
#> SRR1736318     2  0.0000      0.953 0.000 1.000 0.000 0.000 0.000  0
#> SRR1736319     2  0.0000      0.953 0.000 1.000 0.000 0.000 0.000  0
#> SRR1736320     2  0.0000      0.953 0.000 1.000 0.000 0.000 0.000  0
#> SRR1736321     2  0.0000      0.953 0.000 1.000 0.000 0.000 0.000  0
#> SRR1736322     2  0.0000      0.953 0.000 1.000 0.000 0.000 0.000  0
#> SRR1736323     2  0.0000      0.953 0.000 1.000 0.000 0.000 0.000  0
#> SRR1736324     2  0.0000      0.953 0.000 1.000 0.000 0.000 0.000  0
#> SRR1736325     2  0.0000      0.953 0.000 1.000 0.000 0.000 0.000  0
#> SRR1736326     2  0.0000      0.953 0.000 1.000 0.000 0.000 0.000  0
#> SRR1736328     2  0.3123      0.847 0.000 0.824 0.040 0.136 0.000  0
#> SRR1736327     2  0.3123      0.847 0.000 0.824 0.040 0.136 0.000  0
#> SRR1736329     2  0.3123      0.847 0.000 0.824 0.040 0.136 0.000  0
#> SRR1736330     2  0.3123      0.847 0.000 0.824 0.040 0.136 0.000  0
#> SRR1736331     2  0.3123      0.847 0.000 0.824 0.040 0.136 0.000  0
#> SRR1736332     2  0.3123      0.847 0.000 0.824 0.040 0.136 0.000  0
#> SRR1736333     5  0.1387      0.964 0.068 0.000 0.000 0.000 0.932  0
#> SRR1736334     5  0.1387      0.964 0.068 0.000 0.000 0.000 0.932  0
#> SRR1736335     5  0.1387      0.964 0.068 0.000 0.000 0.000 0.932  0
#> SRR1736337     5  0.1387      0.964 0.068 0.000 0.000 0.000 0.932  0
#> SRR1736336     5  0.1387      0.964 0.068 0.000 0.000 0.000 0.932  0
#> SRR1736338     5  0.1387      0.964 0.068 0.000 0.000 0.000 0.932  0
#> SRR1736339     1  0.0000      0.976 1.000 0.000 0.000 0.000 0.000  0
#> SRR1736340     1  0.0000      0.976 1.000 0.000 0.000 0.000 0.000  0
#> SRR1736341     1  0.0000      0.976 1.000 0.000 0.000 0.000 0.000  0
#> SRR1736342     1  0.0000      0.976 1.000 0.000 0.000 0.000 0.000  0
#> SRR1736343     1  0.0000      0.976 1.000 0.000 0.000 0.000 0.000  0
#> SRR1736344     1  0.0000      0.976 1.000 0.000 0.000 0.000 0.000  0
#> SRR1736345     1  0.0000      0.976 1.000 0.000 0.000 0.000 0.000  0
#> SRR1736346     1  0.0000      0.976 1.000 0.000 0.000 0.000 0.000  0
#> SRR1736348     1  0.1327      0.940 0.936 0.000 0.064 0.000 0.000  0
#> SRR1736347     1  0.0000      0.976 1.000 0.000 0.000 0.000 0.000  0
#> SRR1736349     1  0.1327      0.940 0.936 0.000 0.064 0.000 0.000  0
#> SRR1736350     1  0.1327      0.940 0.936 0.000 0.064 0.000 0.000  0
#> SRR1736351     1  0.0000      0.976 1.000 0.000 0.000 0.000 0.000  0
#> SRR1736352     1  0.0000      0.976 1.000 0.000 0.000 0.000 0.000  0
#> SRR1736353     1  0.0000      0.976 1.000 0.000 0.000 0.000 0.000  0
#> SRR1736354     1  0.1327      0.940 0.936 0.000 0.064 0.000 0.000  0
#> SRR1736355     1  0.1327      0.940 0.936 0.000 0.064 0.000 0.000  0
#> SRR1736356     6  0.0000      0.000 0.000 0.000 0.000 0.000 0.000  1
#> SRR1736358     3  0.0937      0.920 0.040 0.000 0.960 0.000 0.000  0
#> SRR1736357     3  0.0937      0.920 0.040 0.000 0.960 0.000 0.000  0
#> SRR1736359     3  0.0937      0.920 0.040 0.000 0.960 0.000 0.000  0
#> SRR1736360     5  0.0000      0.885 0.000 0.000 0.000 0.000 1.000  0
#> SRR1736361     4  0.2219      0.000 0.000 0.000 0.000 0.864 0.136  0
#> SRR1736362     5  0.0000      0.885 0.000 0.000 0.000 0.000 1.000  0
#> SRR1736363     3  0.1863      0.961 0.104 0.000 0.896 0.000 0.000  0
#> SRR1736365     3  0.1863      0.961 0.104 0.000 0.896 0.000 0.000  0
#> SRR1736364     3  0.1863      0.961 0.104 0.000 0.896 0.000 0.000  0
#> SRR1736366     3  0.1863      0.961 0.104 0.000 0.896 0.000 0.000  0
#> SRR1736367     3  0.1863      0.961 0.104 0.000 0.896 0.000 0.000  0
#> SRR1736368     3  0.1863      0.961 0.104 0.000 0.896 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-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 15454 rows and 60 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#>   Subgroups are detected by 'kmeans' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk ATC-kmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4886 0.512   0.512
#> 3 3 0.663           0.842       0.848         0.2338 1.000   1.000
#> 4 4 0.615           0.303       0.721         0.1212 0.885   0.778
#> 5 5 0.591           0.784       0.768         0.0808 0.769   0.461
#> 6 6 0.603           0.736       0.757         0.0623 1.000   1.000

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

suggest_best_k(res)
#> [1] 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
#> SRR1736309     2       0          1  0  1
#> SRR1736310     2       0          1  0  1
#> SRR1736312     2       0          1  0  1
#> SRR1736311     2       0          1  0  1
#> SRR1736313     2       0          1  0  1
#> SRR1736314     2       0          1  0  1
#> SRR1736315     2       0          1  0  1
#> SRR1736316     2       0          1  0  1
#> SRR1736317     2       0          1  0  1
#> SRR1736318     2       0          1  0  1
#> SRR1736319     2       0          1  0  1
#> SRR1736320     2       0          1  0  1
#> SRR1736321     2       0          1  0  1
#> SRR1736322     2       0          1  0  1
#> SRR1736323     2       0          1  0  1
#> SRR1736324     2       0          1  0  1
#> SRR1736325     2       0          1  0  1
#> SRR1736326     2       0          1  0  1
#> SRR1736328     2       0          1  0  1
#> SRR1736327     2       0          1  0  1
#> SRR1736329     2       0          1  0  1
#> SRR1736330     2       0          1  0  1
#> SRR1736331     2       0          1  0  1
#> SRR1736332     2       0          1  0  1
#> SRR1736333     1       0          1  1  0
#> SRR1736334     1       0          1  1  0
#> SRR1736335     1       0          1  1  0
#> SRR1736337     1       0          1  1  0
#> SRR1736336     1       0          1  1  0
#> SRR1736338     1       0          1  1  0
#> SRR1736339     1       0          1  1  0
#> SRR1736340     1       0          1  1  0
#> SRR1736341     1       0          1  1  0
#> SRR1736342     1       0          1  1  0
#> SRR1736343     1       0          1  1  0
#> SRR1736344     1       0          1  1  0
#> SRR1736345     1       0          1  1  0
#> SRR1736346     1       0          1  1  0
#> SRR1736348     1       0          1  1  0
#> SRR1736347     1       0          1  1  0
#> SRR1736349     1       0          1  1  0
#> SRR1736350     1       0          1  1  0
#> SRR1736351     1       0          1  1  0
#> SRR1736352     1       0          1  1  0
#> SRR1736353     1       0          1  1  0
#> SRR1736354     1       0          1  1  0
#> SRR1736355     1       0          1  1  0
#> SRR1736356     1       0          1  1  0
#> SRR1736358     1       0          1  1  0
#> SRR1736357     1       0          1  1  0
#> SRR1736359     1       0          1  1  0
#> SRR1736360     1       0          1  1  0
#> SRR1736361     1       0          1  1  0
#> SRR1736362     1       0          1  1  0
#> SRR1736363     1       0          1  1  0
#> SRR1736365     1       0          1  1  0
#> SRR1736364     1       0          1  1  0
#> SRR1736366     1       0          1  1  0
#> SRR1736367     1       0          1  1  0
#> SRR1736368     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
#> SRR1736309     2   0.588      0.931 0.000 0.652 NA
#> SRR1736310     2   0.588      0.931 0.000 0.652 NA
#> SRR1736312     2   0.588      0.931 0.000 0.652 NA
#> SRR1736311     2   0.588      0.931 0.000 0.652 NA
#> SRR1736313     2   0.588      0.931 0.000 0.652 NA
#> SRR1736314     2   0.588      0.931 0.000 0.652 NA
#> SRR1736315     2   0.588      0.931 0.000 0.652 NA
#> SRR1736316     2   0.588      0.931 0.000 0.652 NA
#> SRR1736317     2   0.588      0.931 0.000 0.652 NA
#> SRR1736318     2   0.588      0.931 0.000 0.652 NA
#> SRR1736319     2   0.588      0.931 0.000 0.652 NA
#> SRR1736320     2   0.588      0.931 0.000 0.652 NA
#> SRR1736321     2   0.588      0.931 0.000 0.652 NA
#> SRR1736322     2   0.588      0.931 0.000 0.652 NA
#> SRR1736323     2   0.588      0.931 0.000 0.652 NA
#> SRR1736324     2   0.588      0.931 0.000 0.652 NA
#> SRR1736325     2   0.588      0.931 0.000 0.652 NA
#> SRR1736326     2   0.588      0.931 0.000 0.652 NA
#> SRR1736328     2   0.000      0.773 0.000 1.000 NA
#> SRR1736327     2   0.000      0.773 0.000 1.000 NA
#> SRR1736329     2   0.000      0.773 0.000 1.000 NA
#> SRR1736330     2   0.000      0.773 0.000 1.000 NA
#> SRR1736331     2   0.000      0.773 0.000 1.000 NA
#> SRR1736332     2   0.000      0.773 0.000 1.000 NA
#> SRR1736333     1   0.626      0.812 0.552 0.000 NA
#> SRR1736334     1   0.626      0.812 0.552 0.000 NA
#> SRR1736335     1   0.626      0.812 0.552 0.000 NA
#> SRR1736337     1   0.626      0.812 0.552 0.000 NA
#> SRR1736336     1   0.626      0.812 0.552 0.000 NA
#> SRR1736338     1   0.626      0.812 0.552 0.000 NA
#> SRR1736339     1   0.588      0.841 0.652 0.000 NA
#> SRR1736340     1   0.588      0.841 0.652 0.000 NA
#> SRR1736341     1   0.611      0.844 0.604 0.000 NA
#> SRR1736342     1   0.593      0.845 0.644 0.000 NA
#> SRR1736343     1   0.593      0.845 0.644 0.000 NA
#> SRR1736344     1   0.593      0.845 0.644 0.000 NA
#> SRR1736345     1   0.588      0.841 0.652 0.000 NA
#> SRR1736346     1   0.588      0.841 0.652 0.000 NA
#> SRR1736348     1   0.590      0.840 0.648 0.000 NA
#> SRR1736347     1   0.588      0.841 0.652 0.000 NA
#> SRR1736349     1   0.590      0.840 0.648 0.000 NA
#> SRR1736350     1   0.590      0.840 0.648 0.000 NA
#> SRR1736351     1   0.595      0.845 0.640 0.000 NA
#> SRR1736352     1   0.595      0.845 0.640 0.000 NA
#> SRR1736353     1   0.595      0.845 0.640 0.000 NA
#> SRR1736354     1   0.583      0.843 0.660 0.000 NA
#> SRR1736355     1   0.583      0.843 0.660 0.000 NA
#> SRR1736356     1   0.450      0.696 0.804 0.000 NA
#> SRR1736358     1   0.319      0.749 0.888 0.000 NA
#> SRR1736357     1   0.319      0.749 0.888 0.000 NA
#> SRR1736359     1   0.319      0.749 0.888 0.000 NA
#> SRR1736360     1   0.610      0.798 0.608 0.000 NA
#> SRR1736361     1   0.619      0.785 0.580 0.000 NA
#> SRR1736362     1   0.610      0.798 0.608 0.000 NA
#> SRR1736363     1   0.129      0.767 0.968 0.000 NA
#> SRR1736365     1   0.129      0.767 0.968 0.000 NA
#> SRR1736364     1   0.129      0.767 0.968 0.000 NA
#> SRR1736366     1   0.129      0.767 0.968 0.000 NA
#> SRR1736367     1   0.129      0.767 0.968 0.000 NA
#> SRR1736368     1   0.129      0.767 0.968 0.000 NA

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1736309     2  0.0188     0.8440 0.000 0.996 0.004 0.000
#> SRR1736310     2  0.0000     0.8448 0.000 1.000 0.000 0.000
#> SRR1736312     2  0.0000     0.8448 0.000 1.000 0.000 0.000
#> SRR1736311     2  0.0000     0.8448 0.000 1.000 0.000 0.000
#> SRR1736313     2  0.0469     0.8419 0.000 0.988 0.012 0.000
#> SRR1736314     2  0.0000     0.8448 0.000 1.000 0.000 0.000
#> SRR1736315     2  0.3400     0.7851 0.000 0.820 0.180 0.000
#> SRR1736316     2  0.3400     0.7851 0.000 0.820 0.180 0.000
#> SRR1736317     2  0.3400     0.7851 0.000 0.820 0.180 0.000
#> SRR1736318     2  0.0000     0.8448 0.000 1.000 0.000 0.000
#> SRR1736319     2  0.0000     0.8448 0.000 1.000 0.000 0.000
#> SRR1736320     2  0.0469     0.8419 0.000 0.988 0.012 0.000
#> SRR1736321     2  0.3172     0.7927 0.000 0.840 0.160 0.000
#> SRR1736322     2  0.3172     0.7927 0.000 0.840 0.160 0.000
#> SRR1736323     2  0.3172     0.7927 0.000 0.840 0.160 0.000
#> SRR1736324     2  0.0000     0.8448 0.000 1.000 0.000 0.000
#> SRR1736325     2  0.0000     0.8448 0.000 1.000 0.000 0.000
#> SRR1736326     2  0.0000     0.8448 0.000 1.000 0.000 0.000
#> SRR1736328     2  0.7568    -0.0628 0.000 0.404 0.192 0.404
#> SRR1736327     2  0.7665    -0.0502 0.000 0.404 0.212 0.384
#> SRR1736329     2  0.7665    -0.0502 0.000 0.404 0.212 0.384
#> SRR1736330     4  0.7568    -0.1532 0.000 0.404 0.192 0.404
#> SRR1736331     4  0.7568    -0.1532 0.000 0.404 0.192 0.404
#> SRR1736332     4  0.7568    -0.1532 0.000 0.404 0.192 0.404
#> SRR1736333     1  0.5132     0.3502 0.548 0.000 0.004 0.448
#> SRR1736334     1  0.5132     0.3502 0.548 0.000 0.004 0.448
#> SRR1736335     1  0.5132     0.3502 0.548 0.000 0.004 0.448
#> SRR1736337     1  0.5132     0.3502 0.548 0.000 0.004 0.448
#> SRR1736336     1  0.5132     0.3502 0.548 0.000 0.004 0.448
#> SRR1736338     1  0.5132     0.3502 0.548 0.000 0.004 0.448
#> SRR1736339     1  0.3764     0.4762 0.816 0.000 0.012 0.172
#> SRR1736340     1  0.3764     0.4762 0.816 0.000 0.012 0.172
#> SRR1736341     1  0.2867     0.4712 0.884 0.000 0.012 0.104
#> SRR1736342     1  0.1151     0.4429 0.968 0.000 0.024 0.008
#> SRR1736343     1  0.1151     0.4429 0.968 0.000 0.024 0.008
#> SRR1736344     1  0.1151     0.4429 0.968 0.000 0.024 0.008
#> SRR1736345     1  0.3764     0.4762 0.816 0.000 0.012 0.172
#> SRR1736346     1  0.3764     0.4762 0.816 0.000 0.012 0.172
#> SRR1736348     1  0.2611     0.3763 0.896 0.000 0.096 0.008
#> SRR1736347     1  0.3764     0.4762 0.816 0.000 0.012 0.172
#> SRR1736349     1  0.2611     0.3763 0.896 0.000 0.096 0.008
#> SRR1736350     1  0.2611     0.3763 0.896 0.000 0.096 0.008
#> SRR1736351     1  0.0188     0.4534 0.996 0.000 0.000 0.004
#> SRR1736352     1  0.0188     0.4534 0.996 0.000 0.000 0.004
#> SRR1736353     1  0.0188     0.4534 0.996 0.000 0.000 0.004
#> SRR1736354     1  0.2198     0.3996 0.920 0.000 0.072 0.008
#> SRR1736355     1  0.2198     0.3996 0.920 0.000 0.072 0.008
#> SRR1736356     3  0.6222     0.0000 0.412 0.000 0.532 0.056
#> SRR1736358     1  0.5168    -0.7251 0.500 0.000 0.496 0.004
#> SRR1736357     1  0.5168    -0.7251 0.500 0.000 0.496 0.004
#> SRR1736359     1  0.5168    -0.7251 0.500 0.000 0.496 0.004
#> SRR1736360     4  0.7046    -0.2235 0.340 0.000 0.136 0.524
#> SRR1736361     4  0.7120    -0.2103 0.328 0.000 0.148 0.524
#> SRR1736362     4  0.7046    -0.2235 0.340 0.000 0.136 0.524
#> SRR1736363     1  0.7358    -0.4662 0.448 0.000 0.392 0.160
#> SRR1736365     1  0.7358    -0.4662 0.448 0.000 0.392 0.160
#> SRR1736364     1  0.7358    -0.4662 0.448 0.000 0.392 0.160
#> SRR1736366     1  0.7358    -0.4662 0.448 0.000 0.392 0.160
#> SRR1736367     1  0.7358    -0.4662 0.448 0.000 0.392 0.160
#> SRR1736368     1  0.7358    -0.4662 0.448 0.000 0.392 0.160

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4    p5
#> SRR1736309     2  0.0404      0.838 0.000 0.988 0.012 0.000 0.000
#> SRR1736310     2  0.0162      0.841 0.000 0.996 0.004 0.000 0.000
#> SRR1736312     2  0.0000      0.841 0.000 1.000 0.000 0.000 0.000
#> SRR1736311     2  0.0162      0.841 0.000 0.996 0.004 0.000 0.000
#> SRR1736313     2  0.2054      0.808 0.000 0.920 0.028 0.000 0.052
#> SRR1736314     2  0.0162      0.841 0.000 0.996 0.004 0.000 0.000
#> SRR1736315     2  0.5295      0.641 0.000 0.664 0.112 0.000 0.224
#> SRR1736316     2  0.5295      0.641 0.000 0.664 0.112 0.000 0.224
#> SRR1736317     2  0.5295      0.641 0.000 0.664 0.112 0.000 0.224
#> SRR1736318     2  0.0000      0.841 0.000 1.000 0.000 0.000 0.000
#> SRR1736319     2  0.0000      0.841 0.000 1.000 0.000 0.000 0.000
#> SRR1736320     2  0.1750      0.815 0.000 0.936 0.028 0.000 0.036
#> SRR1736321     2  0.5043      0.669 0.000 0.704 0.136 0.000 0.160
#> SRR1736322     2  0.5046      0.670 0.000 0.704 0.140 0.000 0.156
#> SRR1736323     2  0.5043      0.669 0.000 0.704 0.136 0.000 0.160
#> SRR1736324     2  0.0000      0.841 0.000 1.000 0.000 0.000 0.000
#> SRR1736325     2  0.0162      0.841 0.000 0.996 0.004 0.000 0.000
#> SRR1736326     2  0.0000      0.841 0.000 1.000 0.000 0.000 0.000
#> SRR1736328     4  0.3990      0.976 0.000 0.308 0.000 0.688 0.004
#> SRR1736327     4  0.5448      0.954 0.000 0.308 0.052 0.624 0.016
#> SRR1736329     4  0.5448      0.954 0.000 0.308 0.052 0.624 0.016
#> SRR1736330     4  0.3837      0.976 0.000 0.308 0.000 0.692 0.000
#> SRR1736331     4  0.3837      0.976 0.000 0.308 0.000 0.692 0.000
#> SRR1736332     4  0.3837      0.976 0.000 0.308 0.000 0.692 0.000
#> SRR1736333     5  0.4060      0.824 0.360 0.000 0.000 0.000 0.640
#> SRR1736334     5  0.4060      0.824 0.360 0.000 0.000 0.000 0.640
#> SRR1736335     5  0.4060      0.824 0.360 0.000 0.000 0.000 0.640
#> SRR1736337     5  0.4060      0.824 0.360 0.000 0.000 0.000 0.640
#> SRR1736336     5  0.4060      0.824 0.360 0.000 0.000 0.000 0.640
#> SRR1736338     5  0.4060      0.824 0.360 0.000 0.000 0.000 0.640
#> SRR1736339     1  0.3031      0.701 0.852 0.000 0.004 0.016 0.128
#> SRR1736340     1  0.3078      0.696 0.848 0.000 0.004 0.016 0.132
#> SRR1736341     1  0.2568      0.735 0.888 0.000 0.004 0.016 0.092
#> SRR1736342     1  0.2815      0.785 0.892 0.000 0.024 0.056 0.028
#> SRR1736343     1  0.2815      0.785 0.892 0.000 0.024 0.056 0.028
#> SRR1736344     1  0.2815      0.785 0.892 0.000 0.024 0.056 0.028
#> SRR1736345     1  0.3078      0.696 0.848 0.000 0.004 0.016 0.132
#> SRR1736346     1  0.3078      0.696 0.848 0.000 0.004 0.016 0.132
#> SRR1736348     1  0.4785      0.708 0.776 0.000 0.092 0.084 0.048
#> SRR1736347     1  0.3078      0.696 0.848 0.000 0.004 0.016 0.132
#> SRR1736349     1  0.4785      0.708 0.776 0.000 0.092 0.084 0.048
#> SRR1736350     1  0.4785      0.708 0.776 0.000 0.092 0.084 0.048
#> SRR1736351     1  0.0510      0.787 0.984 0.000 0.000 0.000 0.016
#> SRR1736352     1  0.0510      0.787 0.984 0.000 0.000 0.000 0.016
#> SRR1736353     1  0.0510      0.787 0.984 0.000 0.000 0.000 0.016
#> SRR1736354     1  0.4083      0.752 0.824 0.000 0.064 0.064 0.048
#> SRR1736355     1  0.4083      0.752 0.824 0.000 0.064 0.064 0.048
#> SRR1736356     3  0.7577      0.628 0.252 0.000 0.472 0.200 0.076
#> SRR1736358     3  0.6640      0.725 0.324 0.000 0.532 0.100 0.044
#> SRR1736357     3  0.6640      0.725 0.324 0.000 0.532 0.100 0.044
#> SRR1736359     3  0.6640      0.725 0.324 0.000 0.532 0.100 0.044
#> SRR1736360     5  0.6891      0.653 0.204 0.000 0.164 0.060 0.572
#> SRR1736361     5  0.6896      0.649 0.200 0.000 0.168 0.060 0.572
#> SRR1736362     5  0.6891      0.653 0.204 0.000 0.164 0.060 0.572
#> SRR1736363     3  0.5068      0.831 0.300 0.000 0.640 0.000 0.060
#> SRR1736365     3  0.5068      0.831 0.300 0.000 0.640 0.000 0.060
#> SRR1736364     3  0.5068      0.831 0.300 0.000 0.640 0.000 0.060
#> SRR1736366     3  0.5068      0.831 0.300 0.000 0.640 0.000 0.060
#> SRR1736367     3  0.5068      0.831 0.300 0.000 0.640 0.000 0.060
#> SRR1736368     3  0.5068      0.831 0.300 0.000 0.640 0.000 0.060

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5 p6
#> SRR1736309     2  0.1549      0.809 0.000 0.936 0.044 0.000 0.020 NA
#> SRR1736310     2  0.0146      0.828 0.000 0.996 0.000 0.000 0.004 NA
#> SRR1736312     2  0.0000      0.828 0.000 1.000 0.000 0.000 0.000 NA
#> SRR1736311     2  0.0146      0.828 0.000 0.996 0.000 0.000 0.004 NA
#> SRR1736313     2  0.2797      0.787 0.000 0.876 0.064 0.000 0.036 NA
#> SRR1736314     2  0.0146      0.828 0.000 0.996 0.000 0.000 0.004 NA
#> SRR1736315     2  0.5159      0.629 0.000 0.624 0.032 0.000 0.056 NA
#> SRR1736316     2  0.5159      0.629 0.000 0.624 0.032 0.000 0.056 NA
#> SRR1736317     2  0.5159      0.629 0.000 0.624 0.032 0.000 0.056 NA
#> SRR1736318     2  0.0000      0.828 0.000 1.000 0.000 0.000 0.000 NA
#> SRR1736319     2  0.0000      0.828 0.000 1.000 0.000 0.000 0.000 NA
#> SRR1736320     2  0.2724      0.789 0.000 0.880 0.064 0.000 0.032 NA
#> SRR1736321     2  0.3578      0.653 0.000 0.660 0.000 0.000 0.000 NA
#> SRR1736322     2  0.3699      0.654 0.000 0.660 0.000 0.000 0.004 NA
#> SRR1736323     2  0.3578      0.653 0.000 0.660 0.000 0.000 0.000 NA
#> SRR1736324     2  0.0000      0.828 0.000 1.000 0.000 0.000 0.000 NA
#> SRR1736325     2  0.0000      0.828 0.000 1.000 0.000 0.000 0.000 NA
#> SRR1736326     2  0.0000      0.828 0.000 1.000 0.000 0.000 0.000 NA
#> SRR1736328     4  0.3337      0.983 0.000 0.260 0.004 0.736 0.000 NA
#> SRR1736327     4  0.4469      0.969 0.000 0.260 0.012 0.692 0.024 NA
#> SRR1736329     4  0.4469      0.969 0.000 0.260 0.012 0.692 0.024 NA
#> SRR1736330     4  0.3198      0.984 0.000 0.260 0.000 0.740 0.000 NA
#> SRR1736331     4  0.3198      0.984 0.000 0.260 0.000 0.740 0.000 NA
#> SRR1736332     4  0.3198      0.984 0.000 0.260 0.000 0.740 0.000 NA
#> SRR1736333     5  0.2912      0.818 0.216 0.000 0.000 0.000 0.784 NA
#> SRR1736334     5  0.3052      0.817 0.216 0.000 0.000 0.004 0.780 NA
#> SRR1736335     5  0.2912      0.818 0.216 0.000 0.000 0.000 0.784 NA
#> SRR1736337     5  0.3052      0.817 0.216 0.000 0.000 0.004 0.780 NA
#> SRR1736336     5  0.2912      0.818 0.216 0.000 0.000 0.000 0.784 NA
#> SRR1736338     5  0.2912      0.818 0.216 0.000 0.000 0.000 0.784 NA
#> SRR1736339     1  0.6540      0.618 0.604 0.000 0.036 0.144 0.144 NA
#> SRR1736340     1  0.6540      0.618 0.604 0.000 0.036 0.144 0.144 NA
#> SRR1736341     1  0.6296      0.638 0.632 0.000 0.036 0.144 0.116 NA
#> SRR1736342     1  0.1261      0.681 0.952 0.000 0.024 0.000 0.024 NA
#> SRR1736343     1  0.1261      0.681 0.952 0.000 0.024 0.000 0.024 NA
#> SRR1736344     1  0.1261      0.681 0.952 0.000 0.024 0.000 0.024 NA
#> SRR1736345     1  0.6540      0.618 0.604 0.000 0.036 0.144 0.144 NA
#> SRR1736346     1  0.6540      0.618 0.604 0.000 0.036 0.144 0.144 NA
#> SRR1736348     1  0.3564      0.590 0.800 0.000 0.160 0.008 0.024 NA
#> SRR1736347     1  0.6540      0.618 0.604 0.000 0.036 0.144 0.144 NA
#> SRR1736349     1  0.3564      0.590 0.800 0.000 0.160 0.008 0.024 NA
#> SRR1736350     1  0.3564      0.590 0.800 0.000 0.160 0.008 0.024 NA
#> SRR1736351     1  0.4596      0.693 0.772 0.000 0.024 0.104 0.044 NA
#> SRR1736352     1  0.4596      0.693 0.772 0.000 0.024 0.104 0.044 NA
#> SRR1736353     1  0.4596      0.693 0.772 0.000 0.024 0.104 0.044 NA
#> SRR1736354     1  0.2739      0.653 0.876 0.000 0.084 0.008 0.024 NA
#> SRR1736355     1  0.2739      0.653 0.876 0.000 0.084 0.008 0.024 NA
#> SRR1736356     3  0.6714      0.474 0.136 0.000 0.576 0.084 0.028 NA
#> SRR1736358     3  0.2848      0.641 0.176 0.000 0.816 0.000 0.008 NA
#> SRR1736357     3  0.2848      0.641 0.176 0.000 0.816 0.000 0.008 NA
#> SRR1736359     3  0.2848      0.641 0.176 0.000 0.816 0.000 0.008 NA
#> SRR1736360     5  0.6333      0.593 0.092 0.000 0.084 0.028 0.616 NA
#> SRR1736361     5  0.6290      0.590 0.088 0.000 0.084 0.028 0.620 NA
#> SRR1736362     5  0.6333      0.593 0.092 0.000 0.084 0.028 0.616 NA
#> SRR1736363     3  0.6685      0.769 0.136 0.000 0.480 0.000 0.088 NA
#> SRR1736365     3  0.6685      0.769 0.136 0.000 0.480 0.000 0.088 NA
#> SRR1736364     3  0.6804      0.769 0.136 0.000 0.480 0.004 0.088 NA
#> SRR1736366     3  0.6685      0.769 0.136 0.000 0.480 0.000 0.088 NA
#> SRR1736367     3  0.6804      0.769 0.136 0.000 0.480 0.004 0.088 NA
#> SRR1736368     3  0.6804      0.769 0.136 0.000 0.480 0.004 0.088 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-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 15454 rows and 60 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#>   Subgroups are detected by 'skmeans' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk ATC-skmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4886 0.512   0.512
#> 3 3 0.819           0.837       0.885         0.3187 0.831   0.670
#> 4 4 0.822           0.910       0.934         0.1104 0.915   0.760
#> 5 5 0.852           0.895       0.876         0.0648 0.939   0.781
#> 6 6 0.852           0.849       0.821         0.0441 0.934   0.716

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
#> SRR1736309     2       0          1  0  1
#> SRR1736310     2       0          1  0  1
#> SRR1736312     2       0          1  0  1
#> SRR1736311     2       0          1  0  1
#> SRR1736313     2       0          1  0  1
#> SRR1736314     2       0          1  0  1
#> SRR1736315     2       0          1  0  1
#> SRR1736316     2       0          1  0  1
#> SRR1736317     2       0          1  0  1
#> SRR1736318     2       0          1  0  1
#> SRR1736319     2       0          1  0  1
#> SRR1736320     2       0          1  0  1
#> SRR1736321     2       0          1  0  1
#> SRR1736322     2       0          1  0  1
#> SRR1736323     2       0          1  0  1
#> SRR1736324     2       0          1  0  1
#> SRR1736325     2       0          1  0  1
#> SRR1736326     2       0          1  0  1
#> SRR1736328     2       0          1  0  1
#> SRR1736327     2       0          1  0  1
#> SRR1736329     2       0          1  0  1
#> SRR1736330     2       0          1  0  1
#> SRR1736331     2       0          1  0  1
#> SRR1736332     2       0          1  0  1
#> SRR1736333     1       0          1  1  0
#> SRR1736334     1       0          1  1  0
#> SRR1736335     1       0          1  1  0
#> SRR1736337     1       0          1  1  0
#> SRR1736336     1       0          1  1  0
#> SRR1736338     1       0          1  1  0
#> SRR1736339     1       0          1  1  0
#> SRR1736340     1       0          1  1  0
#> SRR1736341     1       0          1  1  0
#> SRR1736342     1       0          1  1  0
#> SRR1736343     1       0          1  1  0
#> SRR1736344     1       0          1  1  0
#> SRR1736345     1       0          1  1  0
#> SRR1736346     1       0          1  1  0
#> SRR1736348     1       0          1  1  0
#> SRR1736347     1       0          1  1  0
#> SRR1736349     1       0          1  1  0
#> SRR1736350     1       0          1  1  0
#> SRR1736351     1       0          1  1  0
#> SRR1736352     1       0          1  1  0
#> SRR1736353     1       0          1  1  0
#> SRR1736354     1       0          1  1  0
#> SRR1736355     1       0          1  1  0
#> SRR1736356     1       0          1  1  0
#> SRR1736358     1       0          1  1  0
#> SRR1736357     1       0          1  1  0
#> SRR1736359     1       0          1  1  0
#> SRR1736360     1       0          1  1  0
#> SRR1736361     1       0          1  1  0
#> SRR1736362     1       0          1  1  0
#> SRR1736363     1       0          1  1  0
#> SRR1736365     1       0          1  1  0
#> SRR1736364     1       0          1  1  0
#> SRR1736366     1       0          1  1  0
#> SRR1736367     1       0          1  1  0
#> SRR1736368     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
#> SRR1736309     2  0.0000      1.000 0.000  1 0.000
#> SRR1736310     2  0.0000      1.000 0.000  1 0.000
#> SRR1736312     2  0.0000      1.000 0.000  1 0.000
#> SRR1736311     2  0.0000      1.000 0.000  1 0.000
#> SRR1736313     2  0.0000      1.000 0.000  1 0.000
#> SRR1736314     2  0.0000      1.000 0.000  1 0.000
#> SRR1736315     2  0.0000      1.000 0.000  1 0.000
#> SRR1736316     2  0.0000      1.000 0.000  1 0.000
#> SRR1736317     2  0.0000      1.000 0.000  1 0.000
#> SRR1736318     2  0.0000      1.000 0.000  1 0.000
#> SRR1736319     2  0.0000      1.000 0.000  1 0.000
#> SRR1736320     2  0.0000      1.000 0.000  1 0.000
#> SRR1736321     2  0.0000      1.000 0.000  1 0.000
#> SRR1736322     2  0.0000      1.000 0.000  1 0.000
#> SRR1736323     2  0.0000      1.000 0.000  1 0.000
#> SRR1736324     2  0.0000      1.000 0.000  1 0.000
#> SRR1736325     2  0.0000      1.000 0.000  1 0.000
#> SRR1736326     2  0.0000      1.000 0.000  1 0.000
#> SRR1736328     2  0.0000      1.000 0.000  1 0.000
#> SRR1736327     2  0.0000      1.000 0.000  1 0.000
#> SRR1736329     2  0.0000      1.000 0.000  1 0.000
#> SRR1736330     2  0.0000      1.000 0.000  1 0.000
#> SRR1736331     2  0.0000      1.000 0.000  1 0.000
#> SRR1736332     2  0.0000      1.000 0.000  1 0.000
#> SRR1736333     1  0.0592      0.481 0.988  0 0.012
#> SRR1736334     1  0.0592      0.481 0.988  0 0.012
#> SRR1736335     1  0.0592      0.481 0.988  0 0.012
#> SRR1736337     1  0.0592      0.481 0.988  0 0.012
#> SRR1736336     1  0.0592      0.481 0.988  0 0.012
#> SRR1736338     1  0.0592      0.481 0.988  0 0.012
#> SRR1736339     1  0.6204      0.805 0.576  0 0.424
#> SRR1736340     1  0.6204      0.805 0.576  0 0.424
#> SRR1736341     1  0.6204      0.805 0.576  0 0.424
#> SRR1736342     1  0.6215      0.806 0.572  0 0.428
#> SRR1736343     1  0.6215      0.806 0.572  0 0.428
#> SRR1736344     1  0.6215      0.806 0.572  0 0.428
#> SRR1736345     1  0.6204      0.805 0.576  0 0.424
#> SRR1736346     1  0.6204      0.805 0.576  0 0.424
#> SRR1736348     1  0.6215      0.806 0.572  0 0.428
#> SRR1736347     1  0.6204      0.805 0.576  0 0.424
#> SRR1736349     1  0.6215      0.806 0.572  0 0.428
#> SRR1736350     1  0.6215      0.806 0.572  0 0.428
#> SRR1736351     1  0.6215      0.806 0.572  0 0.428
#> SRR1736352     1  0.6215      0.806 0.572  0 0.428
#> SRR1736353     1  0.6215      0.806 0.572  0 0.428
#> SRR1736354     1  0.6215      0.806 0.572  0 0.428
#> SRR1736355     1  0.6215      0.806 0.572  0 0.428
#> SRR1736356     3  0.0237      0.811 0.004  0 0.996
#> SRR1736358     3  0.0000      0.817 0.000  0 1.000
#> SRR1736357     3  0.0000      0.817 0.000  0 1.000
#> SRR1736359     3  0.0000      0.817 0.000  0 1.000
#> SRR1736360     3  0.6215      0.495 0.428  0 0.572
#> SRR1736361     3  0.6215      0.495 0.428  0 0.572
#> SRR1736362     3  0.6215      0.495 0.428  0 0.572
#> SRR1736363     3  0.0237      0.820 0.004  0 0.996
#> SRR1736365     3  0.0237      0.820 0.004  0 0.996
#> SRR1736364     3  0.0237      0.820 0.004  0 0.996
#> SRR1736366     3  0.0237      0.820 0.004  0 0.996
#> SRR1736367     3  0.0237      0.820 0.004  0 0.996
#> SRR1736368     3  0.0237      0.820 0.004  0 0.996

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1736309     2  0.0000      0.973 0.000 1.000 0.000 0.000
#> SRR1736310     2  0.0000      0.973 0.000 1.000 0.000 0.000
#> SRR1736312     2  0.0000      0.973 0.000 1.000 0.000 0.000
#> SRR1736311     2  0.0000      0.973 0.000 1.000 0.000 0.000
#> SRR1736313     2  0.0000      0.973 0.000 1.000 0.000 0.000
#> SRR1736314     2  0.0000      0.973 0.000 1.000 0.000 0.000
#> SRR1736315     2  0.0000      0.973 0.000 1.000 0.000 0.000
#> SRR1736316     2  0.0000      0.973 0.000 1.000 0.000 0.000
#> SRR1736317     2  0.0000      0.973 0.000 1.000 0.000 0.000
#> SRR1736318     2  0.0000      0.973 0.000 1.000 0.000 0.000
#> SRR1736319     2  0.0000      0.973 0.000 1.000 0.000 0.000
#> SRR1736320     2  0.0000      0.973 0.000 1.000 0.000 0.000
#> SRR1736321     2  0.0000      0.973 0.000 1.000 0.000 0.000
#> SRR1736322     2  0.0000      0.973 0.000 1.000 0.000 0.000
#> SRR1736323     2  0.0000      0.973 0.000 1.000 0.000 0.000
#> SRR1736324     2  0.0000      0.973 0.000 1.000 0.000 0.000
#> SRR1736325     2  0.0000      0.973 0.000 1.000 0.000 0.000
#> SRR1736326     2  0.0000      0.973 0.000 1.000 0.000 0.000
#> SRR1736328     2  0.3107      0.914 0.000 0.884 0.036 0.080
#> SRR1736327     2  0.3107      0.914 0.000 0.884 0.036 0.080
#> SRR1736329     2  0.3107      0.914 0.000 0.884 0.036 0.080
#> SRR1736330     2  0.3107      0.914 0.000 0.884 0.036 0.080
#> SRR1736331     2  0.3107      0.914 0.000 0.884 0.036 0.080
#> SRR1736332     2  0.3107      0.914 0.000 0.884 0.036 0.080
#> SRR1736333     4  0.2216      0.806 0.092 0.000 0.000 0.908
#> SRR1736334     4  0.2216      0.806 0.092 0.000 0.000 0.908
#> SRR1736335     4  0.2216      0.806 0.092 0.000 0.000 0.908
#> SRR1736337     4  0.2216      0.806 0.092 0.000 0.000 0.908
#> SRR1736336     4  0.2216      0.806 0.092 0.000 0.000 0.908
#> SRR1736338     4  0.2216      0.806 0.092 0.000 0.000 0.908
#> SRR1736339     1  0.1356      0.966 0.960 0.000 0.008 0.032
#> SRR1736340     1  0.1356      0.966 0.960 0.000 0.008 0.032
#> SRR1736341     1  0.1356      0.966 0.960 0.000 0.008 0.032
#> SRR1736342     1  0.0592      0.975 0.984 0.000 0.000 0.016
#> SRR1736343     1  0.0592      0.975 0.984 0.000 0.000 0.016
#> SRR1736344     1  0.0592      0.975 0.984 0.000 0.000 0.016
#> SRR1736345     1  0.1356      0.966 0.960 0.000 0.008 0.032
#> SRR1736346     1  0.1356      0.966 0.960 0.000 0.008 0.032
#> SRR1736348     1  0.0707      0.974 0.980 0.000 0.000 0.020
#> SRR1736347     1  0.1356      0.966 0.960 0.000 0.008 0.032
#> SRR1736349     1  0.0707      0.974 0.980 0.000 0.000 0.020
#> SRR1736350     1  0.0707      0.974 0.980 0.000 0.000 0.020
#> SRR1736351     1  0.0336      0.973 0.992 0.000 0.008 0.000
#> SRR1736352     1  0.0336      0.973 0.992 0.000 0.008 0.000
#> SRR1736353     1  0.0336      0.973 0.992 0.000 0.008 0.000
#> SRR1736354     1  0.0707      0.974 0.980 0.000 0.000 0.020
#> SRR1736355     1  0.0707      0.974 0.980 0.000 0.000 0.020
#> SRR1736356     3  0.3172      0.889 0.160 0.000 0.840 0.000
#> SRR1736358     3  0.3123      0.892 0.156 0.000 0.844 0.000
#> SRR1736357     3  0.3123      0.892 0.156 0.000 0.844 0.000
#> SRR1736359     3  0.3123      0.892 0.156 0.000 0.844 0.000
#> SRR1736360     4  0.4985      0.370 0.000 0.000 0.468 0.532
#> SRR1736361     4  0.4985      0.370 0.000 0.000 0.468 0.532
#> SRR1736362     4  0.4985      0.370 0.000 0.000 0.468 0.532
#> SRR1736363     3  0.1389      0.928 0.048 0.000 0.952 0.000
#> SRR1736365     3  0.1389      0.928 0.048 0.000 0.952 0.000
#> SRR1736364     3  0.1389      0.928 0.048 0.000 0.952 0.000
#> SRR1736366     3  0.1389      0.928 0.048 0.000 0.952 0.000
#> SRR1736367     3  0.1389      0.928 0.048 0.000 0.952 0.000
#> SRR1736368     3  0.1389      0.928 0.048 0.000 0.952 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
#> SRR1736309     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736310     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736312     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736311     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736313     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736314     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736315     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736316     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736317     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736318     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736319     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736320     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736321     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736322     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736323     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736324     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736325     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736326     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736328     4  0.4306      1.000 0.000 0.492 0.000 0.508 0.000
#> SRR1736327     4  0.4306      1.000 0.000 0.492 0.000 0.508 0.000
#> SRR1736329     4  0.4306      1.000 0.000 0.492 0.000 0.508 0.000
#> SRR1736330     4  0.4306      1.000 0.000 0.492 0.000 0.508 0.000
#> SRR1736331     4  0.4306      1.000 0.000 0.492 0.000 0.508 0.000
#> SRR1736332     4  0.4306      1.000 0.000 0.492 0.000 0.508 0.000
#> SRR1736333     5  0.0290      0.797 0.008 0.000 0.000 0.000 0.992
#> SRR1736334     5  0.0290      0.797 0.008 0.000 0.000 0.000 0.992
#> SRR1736335     5  0.0290      0.797 0.008 0.000 0.000 0.000 0.992
#> SRR1736337     5  0.0290      0.797 0.008 0.000 0.000 0.000 0.992
#> SRR1736336     5  0.0290      0.797 0.008 0.000 0.000 0.000 0.992
#> SRR1736338     5  0.0290      0.797 0.008 0.000 0.000 0.000 0.992
#> SRR1736339     1  0.0566      0.878 0.984 0.000 0.004 0.000 0.012
#> SRR1736340     1  0.0566      0.878 0.984 0.000 0.004 0.000 0.012
#> SRR1736341     1  0.0566      0.878 0.984 0.000 0.004 0.000 0.012
#> SRR1736342     1  0.3628      0.865 0.772 0.000 0.000 0.216 0.012
#> SRR1736343     1  0.3628      0.865 0.772 0.000 0.000 0.216 0.012
#> SRR1736344     1  0.3628      0.865 0.772 0.000 0.000 0.216 0.012
#> SRR1736345     1  0.0566      0.878 0.984 0.000 0.004 0.000 0.012
#> SRR1736346     1  0.0566      0.878 0.984 0.000 0.004 0.000 0.012
#> SRR1736348     1  0.3904      0.862 0.764 0.000 0.008 0.216 0.012
#> SRR1736347     1  0.0566      0.878 0.984 0.000 0.004 0.000 0.012
#> SRR1736349     1  0.3904      0.862 0.764 0.000 0.008 0.216 0.012
#> SRR1736350     1  0.3904      0.862 0.764 0.000 0.008 0.216 0.012
#> SRR1736351     1  0.0162      0.880 0.996 0.000 0.004 0.000 0.000
#> SRR1736352     1  0.0162      0.880 0.996 0.000 0.004 0.000 0.000
#> SRR1736353     1  0.0162      0.880 0.996 0.000 0.004 0.000 0.000
#> SRR1736354     1  0.3904      0.862 0.764 0.000 0.008 0.216 0.012
#> SRR1736355     1  0.3904      0.862 0.764 0.000 0.008 0.216 0.012
#> SRR1736356     3  0.3016      0.866 0.020 0.000 0.848 0.132 0.000
#> SRR1736358     3  0.3193      0.862 0.028 0.000 0.840 0.132 0.000
#> SRR1736357     3  0.3193      0.862 0.028 0.000 0.840 0.132 0.000
#> SRR1736359     3  0.3193      0.862 0.028 0.000 0.840 0.132 0.000
#> SRR1736360     5  0.6753      0.394 0.000 0.000 0.340 0.268 0.392
#> SRR1736361     5  0.6753      0.394 0.000 0.000 0.340 0.268 0.392
#> SRR1736362     5  0.6753      0.394 0.000 0.000 0.340 0.268 0.392
#> SRR1736363     3  0.0000      0.910 0.000 0.000 1.000 0.000 0.000
#> SRR1736365     3  0.0000      0.910 0.000 0.000 1.000 0.000 0.000
#> SRR1736364     3  0.0000      0.910 0.000 0.000 1.000 0.000 0.000
#> SRR1736366     3  0.0000      0.910 0.000 0.000 1.000 0.000 0.000
#> SRR1736367     3  0.0000      0.910 0.000 0.000 1.000 0.000 0.000
#> SRR1736368     3  0.0000      0.910 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
#> SRR1736309     2  0.0000      0.995 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736310     2  0.0000      0.995 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736312     2  0.0000      0.995 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736311     2  0.0000      0.995 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736313     2  0.0000      0.995 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736314     2  0.0000      0.995 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736315     2  0.0363      0.990 0.012 0.988 0.000 0.000 0.000 0.000
#> SRR1736316     2  0.0363      0.990 0.012 0.988 0.000 0.000 0.000 0.000
#> SRR1736317     2  0.0363      0.990 0.012 0.988 0.000 0.000 0.000 0.000
#> SRR1736318     2  0.0000      0.995 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736319     2  0.0000      0.995 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736320     2  0.0000      0.995 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736321     2  0.0363      0.990 0.012 0.988 0.000 0.000 0.000 0.000
#> SRR1736322     2  0.0363      0.990 0.012 0.988 0.000 0.000 0.000 0.000
#> SRR1736323     2  0.0363      0.990 0.012 0.988 0.000 0.000 0.000 0.000
#> SRR1736324     2  0.0000      0.995 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736325     2  0.0000      0.995 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736326     2  0.0000      0.995 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1736328     4  0.3371      1.000 0.000 0.292 0.000 0.708 0.000 0.000
#> SRR1736327     4  0.3371      1.000 0.000 0.292 0.000 0.708 0.000 0.000
#> SRR1736329     4  0.3371      1.000 0.000 0.292 0.000 0.708 0.000 0.000
#> SRR1736330     4  0.3371      1.000 0.000 0.292 0.000 0.708 0.000 0.000
#> SRR1736331     4  0.3371      1.000 0.000 0.292 0.000 0.708 0.000 0.000
#> SRR1736332     4  0.3371      1.000 0.000 0.292 0.000 0.708 0.000 0.000
#> SRR1736333     5  0.0260      1.000 0.000 0.000 0.000 0.000 0.992 0.008
#> SRR1736334     5  0.0260      1.000 0.000 0.000 0.000 0.000 0.992 0.008
#> SRR1736335     5  0.0260      1.000 0.000 0.000 0.000 0.000 0.992 0.008
#> SRR1736337     5  0.0260      1.000 0.000 0.000 0.000 0.000 0.992 0.008
#> SRR1736336     5  0.0260      1.000 0.000 0.000 0.000 0.000 0.992 0.008
#> SRR1736338     5  0.0260      1.000 0.000 0.000 0.000 0.000 0.992 0.008
#> SRR1736339     1  0.3862      0.595 0.608 0.000 0.000 0.000 0.004 0.388
#> SRR1736340     1  0.3862      0.595 0.608 0.000 0.000 0.000 0.004 0.388
#> SRR1736341     1  0.3862      0.595 0.608 0.000 0.000 0.000 0.004 0.388
#> SRR1736342     6  0.0000      0.998 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR1736343     6  0.0000      0.998 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR1736344     6  0.0000      0.998 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR1736345     1  0.3862      0.595 0.608 0.000 0.000 0.000 0.004 0.388
#> SRR1736346     1  0.3862      0.595 0.608 0.000 0.000 0.000 0.004 0.388
#> SRR1736348     6  0.0000      0.998 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR1736347     1  0.3862      0.595 0.608 0.000 0.000 0.000 0.004 0.388
#> SRR1736349     6  0.0000      0.998 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR1736350     6  0.0000      0.998 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR1736351     1  0.3774      0.578 0.592 0.000 0.000 0.000 0.000 0.408
#> SRR1736352     1  0.3774      0.578 0.592 0.000 0.000 0.000 0.000 0.408
#> SRR1736353     1  0.3774      0.578 0.592 0.000 0.000 0.000 0.000 0.408
#> SRR1736354     6  0.0146      0.995 0.000 0.000 0.000 0.004 0.000 0.996
#> SRR1736355     6  0.0146      0.995 0.000 0.000 0.000 0.004 0.000 0.996
#> SRR1736356     3  0.4752      0.750 0.024 0.000 0.684 0.056 0.000 0.236
#> SRR1736358     3  0.4411      0.765 0.020 0.000 0.708 0.040 0.000 0.232
#> SRR1736357     3  0.4411      0.765 0.020 0.000 0.708 0.040 0.000 0.232
#> SRR1736359     3  0.4411      0.765 0.020 0.000 0.708 0.040 0.000 0.232
#> SRR1736360     1  0.7530     -0.137 0.356 0.000 0.244 0.236 0.164 0.000
#> SRR1736361     1  0.7512     -0.136 0.360 0.000 0.240 0.240 0.160 0.000
#> SRR1736362     1  0.7530     -0.137 0.356 0.000 0.244 0.236 0.164 0.000
#> SRR1736363     3  0.0000      0.860 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736365     3  0.0000      0.860 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736364     3  0.0000      0.860 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736366     3  0.0000      0.860 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736367     3  0.0000      0.860 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1736368     3  0.0000      0.860 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 15454 rows and 60 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#>   Subgroups are detected by 'pam' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 6.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk ATC-pam-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4886 0.512   0.512
#> 3 3 0.830           0.943       0.948         0.3327 0.831   0.670
#> 4 4 0.868           0.900       0.899         0.1052 0.939   0.822
#> 5 5 1.000           1.000       1.000         0.0875 0.915   0.710
#> 6 6 0.946           0.985       0.958         0.0453 0.959   0.813

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette p1 p2
#> SRR1736309     2       0          1  0  1
#> SRR1736310     2       0          1  0  1
#> SRR1736312     2       0          1  0  1
#> SRR1736311     2       0          1  0  1
#> SRR1736313     2       0          1  0  1
#> SRR1736314     2       0          1  0  1
#> SRR1736315     2       0          1  0  1
#> SRR1736316     2       0          1  0  1
#> SRR1736317     2       0          1  0  1
#> SRR1736318     2       0          1  0  1
#> SRR1736319     2       0          1  0  1
#> SRR1736320     2       0          1  0  1
#> SRR1736321     2       0          1  0  1
#> SRR1736322     2       0          1  0  1
#> SRR1736323     2       0          1  0  1
#> SRR1736324     2       0          1  0  1
#> SRR1736325     2       0          1  0  1
#> SRR1736326     2       0          1  0  1
#> SRR1736328     2       0          1  0  1
#> SRR1736327     2       0          1  0  1
#> SRR1736329     2       0          1  0  1
#> SRR1736330     2       0          1  0  1
#> SRR1736331     2       0          1  0  1
#> SRR1736332     2       0          1  0  1
#> SRR1736333     1       0          1  1  0
#> SRR1736334     1       0          1  1  0
#> SRR1736335     1       0          1  1  0
#> SRR1736337     1       0          1  1  0
#> SRR1736336     1       0          1  1  0
#> SRR1736338     1       0          1  1  0
#> SRR1736339     1       0          1  1  0
#> SRR1736340     1       0          1  1  0
#> SRR1736341     1       0          1  1  0
#> SRR1736342     1       0          1  1  0
#> SRR1736343     1       0          1  1  0
#> SRR1736344     1       0          1  1  0
#> SRR1736345     1       0          1  1  0
#> SRR1736346     1       0          1  1  0
#> SRR1736348     1       0          1  1  0
#> SRR1736347     1       0          1  1  0
#> SRR1736349     1       0          1  1  0
#> SRR1736350     1       0          1  1  0
#> SRR1736351     1       0          1  1  0
#> SRR1736352     1       0          1  1  0
#> SRR1736353     1       0          1  1  0
#> SRR1736354     1       0          1  1  0
#> SRR1736355     1       0          1  1  0
#> SRR1736356     1       0          1  1  0
#> SRR1736358     1       0          1  1  0
#> SRR1736357     1       0          1  1  0
#> SRR1736359     1       0          1  1  0
#> SRR1736360     1       0          1  1  0
#> SRR1736361     1       0          1  1  0
#> SRR1736362     1       0          1  1  0
#> SRR1736363     1       0          1  1  0
#> SRR1736365     1       0          1  1  0
#> SRR1736364     1       0          1  1  0
#> SRR1736366     1       0          1  1  0
#> SRR1736367     1       0          1  1  0
#> SRR1736368     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
#> SRR1736309     2  0.0000      1.000 0.000  1 0.000
#> SRR1736310     2  0.0000      1.000 0.000  1 0.000
#> SRR1736312     2  0.0000      1.000 0.000  1 0.000
#> SRR1736311     2  0.0000      1.000 0.000  1 0.000
#> SRR1736313     2  0.0000      1.000 0.000  1 0.000
#> SRR1736314     2  0.0000      1.000 0.000  1 0.000
#> SRR1736315     2  0.0000      1.000 0.000  1 0.000
#> SRR1736316     2  0.0000      1.000 0.000  1 0.000
#> SRR1736317     2  0.0000      1.000 0.000  1 0.000
#> SRR1736318     2  0.0000      1.000 0.000  1 0.000
#> SRR1736319     2  0.0000      1.000 0.000  1 0.000
#> SRR1736320     2  0.0000      1.000 0.000  1 0.000
#> SRR1736321     2  0.0000      1.000 0.000  1 0.000
#> SRR1736322     2  0.0000      1.000 0.000  1 0.000
#> SRR1736323     2  0.0000      1.000 0.000  1 0.000
#> SRR1736324     2  0.0000      1.000 0.000  1 0.000
#> SRR1736325     2  0.0000      1.000 0.000  1 0.000
#> SRR1736326     2  0.0000      1.000 0.000  1 0.000
#> SRR1736328     2  0.0000      1.000 0.000  1 0.000
#> SRR1736327     2  0.0000      1.000 0.000  1 0.000
#> SRR1736329     2  0.0000      1.000 0.000  1 0.000
#> SRR1736330     2  0.0000      1.000 0.000  1 0.000
#> SRR1736331     2  0.0000      1.000 0.000  1 0.000
#> SRR1736332     2  0.0000      1.000 0.000  1 0.000
#> SRR1736333     1  0.4504      0.812 0.804  0 0.196
#> SRR1736334     1  0.4504      0.812 0.804  0 0.196
#> SRR1736335     1  0.4504      0.812 0.804  0 0.196
#> SRR1736337     1  0.4504      0.812 0.804  0 0.196
#> SRR1736336     1  0.4504      0.812 0.804  0 0.196
#> SRR1736338     1  0.4504      0.812 0.804  0 0.196
#> SRR1736339     1  0.0000      0.934 1.000  0 0.000
#> SRR1736340     1  0.0000      0.934 1.000  0 0.000
#> SRR1736341     1  0.0000      0.934 1.000  0 0.000
#> SRR1736342     1  0.0000      0.934 1.000  0 0.000
#> SRR1736343     1  0.0000      0.934 1.000  0 0.000
#> SRR1736344     1  0.0000      0.934 1.000  0 0.000
#> SRR1736345     1  0.0000      0.934 1.000  0 0.000
#> SRR1736346     1  0.0000      0.934 1.000  0 0.000
#> SRR1736348     1  0.0000      0.934 1.000  0 0.000
#> SRR1736347     1  0.0000      0.934 1.000  0 0.000
#> SRR1736349     1  0.0000      0.934 1.000  0 0.000
#> SRR1736350     1  0.0000      0.934 1.000  0 0.000
#> SRR1736351     1  0.0000      0.934 1.000  0 0.000
#> SRR1736352     1  0.0000      0.934 1.000  0 0.000
#> SRR1736353     1  0.0000      0.934 1.000  0 0.000
#> SRR1736354     1  0.0000      0.934 1.000  0 0.000
#> SRR1736355     1  0.0000      0.934 1.000  0 0.000
#> SRR1736356     3  0.4504      0.939 0.196  0 0.804
#> SRR1736358     3  0.4504      0.939 0.196  0 0.804
#> SRR1736357     3  0.4504      0.939 0.196  0 0.804
#> SRR1736359     3  0.4504      0.939 0.196  0 0.804
#> SRR1736360     3  0.0237      0.803 0.004  0 0.996
#> SRR1736361     3  0.0000      0.804 0.000  0 1.000
#> SRR1736362     3  0.0000      0.804 0.000  0 1.000
#> SRR1736363     3  0.4504      0.939 0.196  0 0.804
#> SRR1736365     3  0.4504      0.939 0.196  0 0.804
#> SRR1736364     3  0.4504      0.939 0.196  0 0.804
#> SRR1736366     3  0.4504      0.939 0.196  0 0.804
#> SRR1736367     3  0.4504      0.939 0.196  0 0.804
#> SRR1736368     3  0.4504      0.939 0.196  0 0.804

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1736309     2   0.000      1.000 0.000 1.000 0.000 0.000
#> SRR1736310     2   0.000      1.000 0.000 1.000 0.000 0.000
#> SRR1736312     2   0.000      1.000 0.000 1.000 0.000 0.000
#> SRR1736311     2   0.000      1.000 0.000 1.000 0.000 0.000
#> SRR1736313     2   0.000      1.000 0.000 1.000 0.000 0.000
#> SRR1736314     2   0.000      1.000 0.000 1.000 0.000 0.000
#> SRR1736315     2   0.000      1.000 0.000 1.000 0.000 0.000
#> SRR1736316     2   0.000      1.000 0.000 1.000 0.000 0.000
#> SRR1736317     2   0.000      1.000 0.000 1.000 0.000 0.000
#> SRR1736318     2   0.000      1.000 0.000 1.000 0.000 0.000
#> SRR1736319     2   0.000      1.000 0.000 1.000 0.000 0.000
#> SRR1736320     2   0.000      1.000 0.000 1.000 0.000 0.000
#> SRR1736321     2   0.000      1.000 0.000 1.000 0.000 0.000
#> SRR1736322     2   0.000      1.000 0.000 1.000 0.000 0.000
#> SRR1736323     2   0.000      1.000 0.000 1.000 0.000 0.000
#> SRR1736324     2   0.000      1.000 0.000 1.000 0.000 0.000
#> SRR1736325     2   0.000      1.000 0.000 1.000 0.000 0.000
#> SRR1736326     2   0.000      1.000 0.000 1.000 0.000 0.000
#> SRR1736328     4   0.487      1.000 0.000 0.404 0.000 0.596
#> SRR1736327     4   0.487      1.000 0.000 0.404 0.000 0.596
#> SRR1736329     4   0.487      1.000 0.000 0.404 0.000 0.596
#> SRR1736330     4   0.487      1.000 0.000 0.404 0.000 0.596
#> SRR1736331     4   0.487      1.000 0.000 0.404 0.000 0.596
#> SRR1736332     4   0.487      1.000 0.000 0.404 0.000 0.596
#> SRR1736333     1   0.000      0.642 1.000 0.000 0.000 0.000
#> SRR1736334     1   0.000      0.642 1.000 0.000 0.000 0.000
#> SRR1736335     1   0.000      0.642 1.000 0.000 0.000 0.000
#> SRR1736337     1   0.000      0.642 1.000 0.000 0.000 0.000
#> SRR1736336     1   0.000      0.642 1.000 0.000 0.000 0.000
#> SRR1736338     1   0.000      0.642 1.000 0.000 0.000 0.000
#> SRR1736339     1   0.487      0.894 0.596 0.000 0.000 0.404
#> SRR1736340     1   0.487      0.894 0.596 0.000 0.000 0.404
#> SRR1736341     1   0.487      0.894 0.596 0.000 0.000 0.404
#> SRR1736342     1   0.487      0.894 0.596 0.000 0.000 0.404
#> SRR1736343     1   0.487      0.894 0.596 0.000 0.000 0.404
#> SRR1736344     1   0.487      0.894 0.596 0.000 0.000 0.404
#> SRR1736345     1   0.487      0.894 0.596 0.000 0.000 0.404
#> SRR1736346     1   0.487      0.894 0.596 0.000 0.000 0.404
#> SRR1736348     1   0.487      0.894 0.596 0.000 0.000 0.404
#> SRR1736347     1   0.487      0.894 0.596 0.000 0.000 0.404
#> SRR1736349     1   0.487      0.894 0.596 0.000 0.000 0.404
#> SRR1736350     1   0.487      0.894 0.596 0.000 0.000 0.404
#> SRR1736351     1   0.487      0.894 0.596 0.000 0.000 0.404
#> SRR1736352     1   0.487      0.894 0.596 0.000 0.000 0.404
#> SRR1736353     1   0.487      0.894 0.596 0.000 0.000 0.404
#> SRR1736354     1   0.487      0.894 0.596 0.000 0.000 0.404
#> SRR1736355     1   0.487      0.894 0.596 0.000 0.000 0.404
#> SRR1736356     3   0.000      0.902 0.000 0.000 1.000 0.000
#> SRR1736358     3   0.000      0.902 0.000 0.000 1.000 0.000
#> SRR1736357     3   0.000      0.902 0.000 0.000 1.000 0.000
#> SRR1736359     3   0.000      0.902 0.000 0.000 1.000 0.000
#> SRR1736360     3   0.487      0.638 0.404 0.000 0.596 0.000
#> SRR1736361     3   0.487      0.638 0.404 0.000 0.596 0.000
#> SRR1736362     3   0.487      0.638 0.404 0.000 0.596 0.000
#> SRR1736363     3   0.000      0.902 0.000 0.000 1.000 0.000
#> SRR1736365     3   0.000      0.902 0.000 0.000 1.000 0.000
#> SRR1736364     3   0.000      0.902 0.000 0.000 1.000 0.000
#> SRR1736366     3   0.000      0.902 0.000 0.000 1.000 0.000
#> SRR1736367     3   0.000      0.902 0.000 0.000 1.000 0.000
#> SRR1736368     3   0.000      0.902 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
#> SRR1736309     2       0          1  0  1  0  0  0
#> SRR1736310     2       0          1  0  1  0  0  0
#> SRR1736312     2       0          1  0  1  0  0  0
#> SRR1736311     2       0          1  0  1  0  0  0
#> SRR1736313     2       0          1  0  1  0  0  0
#> SRR1736314     2       0          1  0  1  0  0  0
#> SRR1736315     2       0          1  0  1  0  0  0
#> SRR1736316     2       0          1  0  1  0  0  0
#> SRR1736317     2       0          1  0  1  0  0  0
#> SRR1736318     2       0          1  0  1  0  0  0
#> SRR1736319     2       0          1  0  1  0  0  0
#> SRR1736320     2       0          1  0  1  0  0  0
#> SRR1736321     2       0          1  0  1  0  0  0
#> SRR1736322     2       0          1  0  1  0  0  0
#> SRR1736323     2       0          1  0  1  0  0  0
#> SRR1736324     2       0          1  0  1  0  0  0
#> SRR1736325     2       0          1  0  1  0  0  0
#> SRR1736326     2       0          1  0  1  0  0  0
#> SRR1736328     4       0          1  0  0  0  1  0
#> SRR1736327     4       0          1  0  0  0  1  0
#> SRR1736329     4       0          1  0  0  0  1  0
#> SRR1736330     4       0          1  0  0  0  1  0
#> SRR1736331     4       0          1  0  0  0  1  0
#> SRR1736332     4       0          1  0  0  0  1  0
#> SRR1736333     5       0          1  0  0  0  0  1
#> SRR1736334     5       0          1  0  0  0  0  1
#> SRR1736335     5       0          1  0  0  0  0  1
#> SRR1736337     5       0          1  0  0  0  0  1
#> SRR1736336     5       0          1  0  0  0  0  1
#> SRR1736338     5       0          1  0  0  0  0  1
#> SRR1736339     1       0          1  1  0  0  0  0
#> SRR1736340     1       0          1  1  0  0  0  0
#> SRR1736341     1       0          1  1  0  0  0  0
#> SRR1736342     1       0          1  1  0  0  0  0
#> SRR1736343     1       0          1  1  0  0  0  0
#> SRR1736344     1       0          1  1  0  0  0  0
#> SRR1736345     1       0          1  1  0  0  0  0
#> SRR1736346     1       0          1  1  0  0  0  0
#> SRR1736348     1       0          1  1  0  0  0  0
#> SRR1736347     1       0          1  1  0  0  0  0
#> SRR1736349     1       0          1  1  0  0  0  0
#> SRR1736350     1       0          1  1  0  0  0  0
#> SRR1736351     1       0          1  1  0  0  0  0
#> SRR1736352     1       0          1  1  0  0  0  0
#> SRR1736353     1       0          1  1  0  0  0  0
#> SRR1736354     1       0          1  1  0  0  0  0
#> SRR1736355     1       0          1  1  0  0  0  0
#> SRR1736356     3       0          1  0  0  1  0  0
#> SRR1736358     3       0          1  0  0  1  0  0
#> SRR1736357     3       0          1  0  0  1  0  0
#> SRR1736359     3       0          1  0  0  1  0  0
#> SRR1736360     5       0          1  0  0  0  0  1
#> SRR1736361     5       0          1  0  0  0  0  1
#> SRR1736362     5       0          1  0  0  0  0  1
#> SRR1736363     3       0          1  0  0  1  0  0
#> SRR1736365     3       0          1  0  0  1  0  0
#> SRR1736364     3       0          1  0  0  1  0  0
#> SRR1736366     3       0          1  0  0  1  0  0
#> SRR1736367     3       0          1  0  0  1  0  0
#> SRR1736368     3       0          1  0  0  1  0  0

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1 p2    p3 p4 p5    p6
#> SRR1736309     2   0.000      1.000 0.000  1 0.000  0  0 0.000
#> SRR1736310     2   0.000      1.000 0.000  1 0.000  0  0 0.000
#> SRR1736312     2   0.000      1.000 0.000  1 0.000  0  0 0.000
#> SRR1736311     2   0.000      1.000 0.000  1 0.000  0  0 0.000
#> SRR1736313     2   0.000      1.000 0.000  1 0.000  0  0 0.000
#> SRR1736314     2   0.000      1.000 0.000  1 0.000  0  0 0.000
#> SRR1736315     2   0.000      1.000 0.000  1 0.000  0  0 0.000
#> SRR1736316     2   0.000      1.000 0.000  1 0.000  0  0 0.000
#> SRR1736317     2   0.000      1.000 0.000  1 0.000  0  0 0.000
#> SRR1736318     2   0.000      1.000 0.000  1 0.000  0  0 0.000
#> SRR1736319     2   0.000      1.000 0.000  1 0.000  0  0 0.000
#> SRR1736320     2   0.000      1.000 0.000  1 0.000  0  0 0.000
#> SRR1736321     2   0.000      1.000 0.000  1 0.000  0  0 0.000
#> SRR1736322     2   0.000      1.000 0.000  1 0.000  0  0 0.000
#> SRR1736323     2   0.000      1.000 0.000  1 0.000  0  0 0.000
#> SRR1736324     2   0.000      1.000 0.000  1 0.000  0  0 0.000
#> SRR1736325     2   0.000      1.000 0.000  1 0.000  0  0 0.000
#> SRR1736326     2   0.000      1.000 0.000  1 0.000  0  0 0.000
#> SRR1736328     4   0.000      1.000 0.000  0 0.000  1  0 0.000
#> SRR1736327     4   0.000      1.000 0.000  0 0.000  1  0 0.000
#> SRR1736329     4   0.000      1.000 0.000  0 0.000  1  0 0.000
#> SRR1736330     4   0.000      1.000 0.000  0 0.000  1  0 0.000
#> SRR1736331     4   0.000      1.000 0.000  0 0.000  1  0 0.000
#> SRR1736332     4   0.000      1.000 0.000  0 0.000  1  0 0.000
#> SRR1736333     5   0.000      1.000 0.000  0 0.000  0  1 0.000
#> SRR1736334     5   0.000      1.000 0.000  0 0.000  0  1 0.000
#> SRR1736335     5   0.000      1.000 0.000  0 0.000  0  1 0.000
#> SRR1736337     5   0.000      1.000 0.000  0 0.000  0  1 0.000
#> SRR1736336     5   0.000      1.000 0.000  0 0.000  0  1 0.000
#> SRR1736338     5   0.000      1.000 0.000  0 0.000  0  1 0.000
#> SRR1736339     1   0.273      0.998 0.808  0 0.000  0  0 0.192
#> SRR1736340     1   0.273      0.998 0.808  0 0.000  0  0 0.192
#> SRR1736341     1   0.273      0.998 0.808  0 0.000  0  0 0.192
#> SRR1736342     6   0.000      1.000 0.000  0 0.000  0  0 1.000
#> SRR1736343     6   0.000      1.000 0.000  0 0.000  0  0 1.000
#> SRR1736344     6   0.000      1.000 0.000  0 0.000  0  0 1.000
#> SRR1736345     1   0.273      0.998 0.808  0 0.000  0  0 0.192
#> SRR1736346     1   0.273      0.998 0.808  0 0.000  0  0 0.192
#> SRR1736348     6   0.000      1.000 0.000  0 0.000  0  0 1.000
#> SRR1736347     1   0.273      0.998 0.808  0 0.000  0  0 0.192
#> SRR1736349     6   0.000      1.000 0.000  0 0.000  0  0 1.000
#> SRR1736350     6   0.000      1.000 0.000  0 0.000  0  0 1.000
#> SRR1736351     1   0.273      0.998 0.808  0 0.000  0  0 0.192
#> SRR1736352     1   0.282      0.985 0.796  0 0.000  0  0 0.204
#> SRR1736353     1   0.273      0.998 0.808  0 0.000  0  0 0.192
#> SRR1736354     6   0.000      1.000 0.000  0 0.000  0  0 1.000
#> SRR1736355     6   0.000      1.000 0.000  0 0.000  0  0 1.000
#> SRR1736356     3   0.273      0.891 0.192  0 0.808  0  0 0.000
#> SRR1736358     3   0.273      0.891 0.192  0 0.808  0  0 0.000
#> SRR1736357     3   0.273      0.891 0.192  0 0.808  0  0 0.000
#> SRR1736359     3   0.273      0.891 0.192  0 0.808  0  0 0.000
#> SRR1736360     5   0.000      1.000 0.000  0 0.000  0  1 0.000
#> SRR1736361     5   0.000      1.000 0.000  0 0.000  0  1 0.000
#> SRR1736362     5   0.000      1.000 0.000  0 0.000  0  1 0.000
#> SRR1736363     3   0.000      0.929 0.000  0 1.000  0  0 0.000
#> SRR1736365     3   0.000      0.929 0.000  0 1.000  0  0 0.000
#> SRR1736364     3   0.000      0.929 0.000  0 1.000  0  0 0.000
#> SRR1736366     3   0.000      0.929 0.000  0 1.000  0  0 0.000
#> SRR1736367     3   0.000      0.929 0.000  0 1.000  0  0 0.000
#> SRR1736368     3   0.000      0.929 0.000  0 1.000  0  0 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-pam-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-pam-collect-classes

If matrix rows can be associated to genes, consider to use functional_enrichment(res, ...) to perform function enrichment for the signature genes. See this vignette for more detailed explanations.


ATC:mclust*

The object with results only for a single top-value method and a single partition method can be extracted as:

res = res_list["ATC", "mclust"]
# you can also extract it by
# res = res_list["ATC:mclust"]

A summary of res and all the functions that can be applied to it:

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

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

collect_plots(res)

plot of chunk ATC-mclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4886 0.512   0.512
#> 3 3 0.793           0.833       0.914         0.3300 0.726   0.507
#> 4 4 1.000           0.989       0.995         0.1073 0.956   0.865
#> 5 5 0.969           0.950       0.971         0.0966 0.925   0.735
#> 6 6 0.905           0.906       0.936         0.0266 0.983   0.918

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette p1 p2
#> SRR1736309     2       0          1  0  1
#> SRR1736310     2       0          1  0  1
#> SRR1736312     2       0          1  0  1
#> SRR1736311     2       0          1  0  1
#> SRR1736313     2       0          1  0  1
#> SRR1736314     2       0          1  0  1
#> SRR1736315     2       0          1  0  1
#> SRR1736316     2       0          1  0  1
#> SRR1736317     2       0          1  0  1
#> SRR1736318     2       0          1  0  1
#> SRR1736319     2       0          1  0  1
#> SRR1736320     2       0          1  0  1
#> SRR1736321     2       0          1  0  1
#> SRR1736322     2       0          1  0  1
#> SRR1736323     2       0          1  0  1
#> SRR1736324     2       0          1  0  1
#> SRR1736325     2       0          1  0  1
#> SRR1736326     2       0          1  0  1
#> SRR1736328     2       0          1  0  1
#> SRR1736327     2       0          1  0  1
#> SRR1736329     2       0          1  0  1
#> SRR1736330     2       0          1  0  1
#> SRR1736331     2       0          1  0  1
#> SRR1736332     2       0          1  0  1
#> SRR1736333     1       0          1  1  0
#> SRR1736334     1       0          1  1  0
#> SRR1736335     1       0          1  1  0
#> SRR1736337     1       0          1  1  0
#> SRR1736336     1       0          1  1  0
#> SRR1736338     1       0          1  1  0
#> SRR1736339     1       0          1  1  0
#> SRR1736340     1       0          1  1  0
#> SRR1736341     1       0          1  1  0
#> SRR1736342     1       0          1  1  0
#> SRR1736343     1       0          1  1  0
#> SRR1736344     1       0          1  1  0
#> SRR1736345     1       0          1  1  0
#> SRR1736346     1       0          1  1  0
#> SRR1736348     1       0          1  1  0
#> SRR1736347     1       0          1  1  0
#> SRR1736349     1       0          1  1  0
#> SRR1736350     1       0          1  1  0
#> SRR1736351     1       0          1  1  0
#> SRR1736352     1       0          1  1  0
#> SRR1736353     1       0          1  1  0
#> SRR1736354     1       0          1  1  0
#> SRR1736355     1       0          1  1  0
#> SRR1736356     1       0          1  1  0
#> SRR1736358     1       0          1  1  0
#> SRR1736357     1       0          1  1  0
#> SRR1736359     1       0          1  1  0
#> SRR1736360     1       0          1  1  0
#> SRR1736361     1       0          1  1  0
#> SRR1736362     1       0          1  1  0
#> SRR1736363     1       0          1  1  0
#> SRR1736365     1       0          1  1  0
#> SRR1736364     1       0          1  1  0
#> SRR1736366     1       0          1  1  0
#> SRR1736367     1       0          1  1  0
#> SRR1736368     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
#> SRR1736309     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1736310     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1736312     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1736311     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1736313     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1736314     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1736315     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1736316     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1736317     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1736318     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1736319     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1736320     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1736321     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1736322     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1736323     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1736324     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1736325     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1736326     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1736328     3  0.6252      0.306 0.000 0.444 0.556
#> SRR1736327     3  0.6252      0.306 0.000 0.444 0.556
#> SRR1736329     3  0.6252      0.306 0.000 0.444 0.556
#> SRR1736330     3  0.6252      0.306 0.000 0.444 0.556
#> SRR1736331     3  0.6252      0.306 0.000 0.444 0.556
#> SRR1736332     3  0.6252      0.306 0.000 0.444 0.556
#> SRR1736333     1  0.0000      0.996 1.000 0.000 0.000
#> SRR1736334     1  0.0000      0.996 1.000 0.000 0.000
#> SRR1736335     1  0.0000      0.996 1.000 0.000 0.000
#> SRR1736337     1  0.0000      0.996 1.000 0.000 0.000
#> SRR1736336     1  0.0000      0.996 1.000 0.000 0.000
#> SRR1736338     1  0.0000      0.996 1.000 0.000 0.000
#> SRR1736339     1  0.0000      0.996 1.000 0.000 0.000
#> SRR1736340     1  0.0000      0.996 1.000 0.000 0.000
#> SRR1736341     1  0.0000      0.996 1.000 0.000 0.000
#> SRR1736342     1  0.0000      0.996 1.000 0.000 0.000
#> SRR1736343     1  0.0000      0.996 1.000 0.000 0.000
#> SRR1736344     1  0.0000      0.996 1.000 0.000 0.000
#> SRR1736345     1  0.0000      0.996 1.000 0.000 0.000
#> SRR1736346     1  0.0000      0.996 1.000 0.000 0.000
#> SRR1736348     1  0.0000      0.996 1.000 0.000 0.000
#> SRR1736347     1  0.0000      0.996 1.000 0.000 0.000
#> SRR1736349     1  0.0000      0.996 1.000 0.000 0.000
#> SRR1736350     1  0.0000      0.996 1.000 0.000 0.000
#> SRR1736351     1  0.0000      0.996 1.000 0.000 0.000
#> SRR1736352     1  0.0000      0.996 1.000 0.000 0.000
#> SRR1736353     1  0.0000      0.996 1.000 0.000 0.000
#> SRR1736354     1  0.1289      0.960 0.968 0.000 0.032
#> SRR1736355     1  0.1289      0.960 0.968 0.000 0.032
#> SRR1736356     3  0.0000      0.680 0.000 0.000 1.000
#> SRR1736358     3  0.0237      0.681 0.004 0.000 0.996
#> SRR1736357     3  0.0237      0.681 0.004 0.000 0.996
#> SRR1736359     3  0.0237      0.681 0.004 0.000 0.996
#> SRR1736360     3  0.6309      0.161 0.500 0.000 0.500
#> SRR1736361     3  0.6309      0.172 0.496 0.000 0.504
#> SRR1736362     3  0.6309      0.161 0.500 0.000 0.500
#> SRR1736363     3  0.3816      0.684 0.148 0.000 0.852
#> SRR1736365     3  0.3816      0.684 0.148 0.000 0.852
#> SRR1736364     3  0.4002      0.679 0.160 0.000 0.840
#> SRR1736366     3  0.3816      0.684 0.148 0.000 0.852
#> SRR1736367     3  0.4002      0.679 0.160 0.000 0.840
#> SRR1736368     3  0.3941      0.681 0.156 0.000 0.844

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1 p2    p3 p4
#> SRR1736309     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736310     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736312     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736311     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736313     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736314     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736315     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736316     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736317     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736318     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736319     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736320     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736321     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736322     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736323     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736324     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736325     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736326     2   0.000      1.000 0.000  1 0.000  0
#> SRR1736328     4   0.000      1.000 0.000  0 0.000  1
#> SRR1736327     4   0.000      1.000 0.000  0 0.000  1
#> SRR1736329     4   0.000      1.000 0.000  0 0.000  1
#> SRR1736330     4   0.000      1.000 0.000  0 0.000  1
#> SRR1736331     4   0.000      1.000 0.000  0 0.000  1
#> SRR1736332     4   0.000      1.000 0.000  0 0.000  1
#> SRR1736333     1   0.000      0.985 1.000  0 0.000  0
#> SRR1736334     1   0.000      0.985 1.000  0 0.000  0
#> SRR1736335     1   0.000      0.985 1.000  0 0.000  0
#> SRR1736337     1   0.000      0.985 1.000  0 0.000  0
#> SRR1736336     1   0.000      0.985 1.000  0 0.000  0
#> SRR1736338     1   0.000      0.985 1.000  0 0.000  0
#> SRR1736339     1   0.000      0.985 1.000  0 0.000  0
#> SRR1736340     1   0.000      0.985 1.000  0 0.000  0
#> SRR1736341     1   0.000      0.985 1.000  0 0.000  0
#> SRR1736342     1   0.000      0.985 1.000  0 0.000  0
#> SRR1736343     1   0.000      0.985 1.000  0 0.000  0
#> SRR1736344     1   0.000      0.985 1.000  0 0.000  0
#> SRR1736345     1   0.000      0.985 1.000  0 0.000  0
#> SRR1736346     1   0.000      0.985 1.000  0 0.000  0
#> SRR1736348     1   0.000      0.985 1.000  0 0.000  0
#> SRR1736347     1   0.000      0.985 1.000  0 0.000  0
#> SRR1736349     1   0.000      0.985 1.000  0 0.000  0
#> SRR1736350     1   0.000      0.985 1.000  0 0.000  0
#> SRR1736351     1   0.000      0.985 1.000  0 0.000  0
#> SRR1736352     1   0.000      0.985 1.000  0 0.000  0
#> SRR1736353     1   0.000      0.985 1.000  0 0.000  0
#> SRR1736354     1   0.297      0.830 0.856  0 0.144  0
#> SRR1736355     1   0.297      0.830 0.856  0 0.144  0
#> SRR1736356     3   0.000      1.000 0.000  0 1.000  0
#> SRR1736358     3   0.000      1.000 0.000  0 1.000  0
#> SRR1736357     3   0.000      1.000 0.000  0 1.000  0
#> SRR1736359     3   0.000      1.000 0.000  0 1.000  0
#> SRR1736360     3   0.000      1.000 0.000  0 1.000  0
#> SRR1736361     3   0.000      1.000 0.000  0 1.000  0
#> SRR1736362     3   0.000      1.000 0.000  0 1.000  0
#> SRR1736363     3   0.000      1.000 0.000  0 1.000  0
#> SRR1736365     3   0.000      1.000 0.000  0 1.000  0
#> SRR1736364     3   0.000      1.000 0.000  0 1.000  0
#> SRR1736366     3   0.000      1.000 0.000  0 1.000  0
#> SRR1736367     3   0.000      1.000 0.000  0 1.000  0
#> SRR1736368     3   0.000      1.000 0.000  0 1.000  0

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1 p2    p3 p4    p5
#> SRR1736309     2  0.0000      1.000 0.000  1 0.000  0 0.000
#> SRR1736310     2  0.0000      1.000 0.000  1 0.000  0 0.000
#> SRR1736312     2  0.0000      1.000 0.000  1 0.000  0 0.000
#> SRR1736311     2  0.0000      1.000 0.000  1 0.000  0 0.000
#> SRR1736313     2  0.0000      1.000 0.000  1 0.000  0 0.000
#> SRR1736314     2  0.0000      1.000 0.000  1 0.000  0 0.000
#> SRR1736315     2  0.0000      1.000 0.000  1 0.000  0 0.000
#> SRR1736316     2  0.0000      1.000 0.000  1 0.000  0 0.000
#> SRR1736317     2  0.0000      1.000 0.000  1 0.000  0 0.000
#> SRR1736318     2  0.0000      1.000 0.000  1 0.000  0 0.000
#> SRR1736319     2  0.0000      1.000 0.000  1 0.000  0 0.000
#> SRR1736320     2  0.0000      1.000 0.000  1 0.000  0 0.000
#> SRR1736321     2  0.0000      1.000 0.000  1 0.000  0 0.000
#> SRR1736322     2  0.0000      1.000 0.000  1 0.000  0 0.000
#> SRR1736323     2  0.0000      1.000 0.000  1 0.000  0 0.000
#> SRR1736324     2  0.0000      1.000 0.000  1 0.000  0 0.000
#> SRR1736325     2  0.0000      1.000 0.000  1 0.000  0 0.000
#> SRR1736326     2  0.0000      1.000 0.000  1 0.000  0 0.000
#> SRR1736328     4  0.0000      1.000 0.000  0 0.000  1 0.000
#> SRR1736327     4  0.0000      1.000 0.000  0 0.000  1 0.000
#> SRR1736329     4  0.0000      1.000 0.000  0 0.000  1 0.000
#> SRR1736330     4  0.0000      1.000 0.000  0 0.000  1 0.000
#> SRR1736331     4  0.0000      1.000 0.000  0 0.000  1 0.000
#> SRR1736332     4  0.0000      1.000 0.000  0 0.000  1 0.000
#> SRR1736333     5  0.0000      0.970 0.000  0 0.000  0 1.000
#> SRR1736334     5  0.0000      0.970 0.000  0 0.000  0 1.000
#> SRR1736335     5  0.0000      0.970 0.000  0 0.000  0 1.000
#> SRR1736337     5  0.0000      0.970 0.000  0 0.000  0 1.000
#> SRR1736336     5  0.0000      0.970 0.000  0 0.000  0 1.000
#> SRR1736338     5  0.0000      0.970 0.000  0 0.000  0 1.000
#> SRR1736339     5  0.1121      0.969 0.044  0 0.000  0 0.956
#> SRR1736340     5  0.1121      0.969 0.044  0 0.000  0 0.956
#> SRR1736341     5  0.1121      0.969 0.044  0 0.000  0 0.956
#> SRR1736342     1  0.0162      0.847 0.996  0 0.000  0 0.004
#> SRR1736343     1  0.0162      0.847 0.996  0 0.000  0 0.004
#> SRR1736344     1  0.0162      0.847 0.996  0 0.000  0 0.004
#> SRR1736345     5  0.1121      0.969 0.044  0 0.000  0 0.956
#> SRR1736346     5  0.1121      0.969 0.044  0 0.000  0 0.956
#> SRR1736348     1  0.0290      0.848 0.992  0 0.000  0 0.008
#> SRR1736347     5  0.1197      0.966 0.048  0 0.000  0 0.952
#> SRR1736349     1  0.0290      0.848 0.992  0 0.000  0 0.008
#> SRR1736350     1  0.0290      0.848 0.992  0 0.000  0 0.008
#> SRR1736351     1  0.3661      0.670 0.724  0 0.000  0 0.276
#> SRR1736352     1  0.3661      0.670 0.724  0 0.000  0 0.276
#> SRR1736353     1  0.3661      0.670 0.724  0 0.000  0 0.276
#> SRR1736354     1  0.4322      0.720 0.768  0 0.144  0 0.088
#> SRR1736355     1  0.4322      0.720 0.768  0 0.144  0 0.088
#> SRR1736356     3  0.0000      0.988 0.000  0 1.000  0 0.000
#> SRR1736358     3  0.0404      0.986 0.012  0 0.988  0 0.000
#> SRR1736357     3  0.0404      0.986 0.012  0 0.988  0 0.000
#> SRR1736359     3  0.0404      0.986 0.012  0 0.988  0 0.000
#> SRR1736360     3  0.0451      0.985 0.004  0 0.988  0 0.008
#> SRR1736361     3  0.0451      0.985 0.004  0 0.988  0 0.008
#> SRR1736362     3  0.0451      0.985 0.004  0 0.988  0 0.008
#> SRR1736363     3  0.0404      0.990 0.012  0 0.988  0 0.000
#> SRR1736365     3  0.0404      0.990 0.012  0 0.988  0 0.000
#> SRR1736364     3  0.0404      0.990 0.012  0 0.988  0 0.000
#> SRR1736366     3  0.0404      0.990 0.012  0 0.988  0 0.000
#> SRR1736367     3  0.0404      0.990 0.012  0 0.988  0 0.000
#> SRR1736368     3  0.0404      0.990 0.012  0 0.988  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
#> SRR1736309     2  0.0000      0.934 0.000 1.000 0.000  0 0.000 0.000
#> SRR1736310     2  0.0000      0.934 0.000 1.000 0.000  0 0.000 0.000
#> SRR1736312     2  0.0000      0.934 0.000 1.000 0.000  0 0.000 0.000
#> SRR1736311     2  0.0000      0.934 0.000 1.000 0.000  0 0.000 0.000
#> SRR1736313     2  0.1267      0.919 0.000 0.940 0.000  0 0.060 0.000
#> SRR1736314     2  0.0000      0.934 0.000 1.000 0.000  0 0.000 0.000
#> SRR1736315     2  0.2697      0.873 0.000 0.812 0.000  0 0.188 0.000
#> SRR1736316     2  0.2697      0.873 0.000 0.812 0.000  0 0.188 0.000
#> SRR1736317     2  0.2697      0.873 0.000 0.812 0.000  0 0.188 0.000
#> SRR1736318     2  0.0000      0.934 0.000 1.000 0.000  0 0.000 0.000
#> SRR1736319     2  0.0000      0.934 0.000 1.000 0.000  0 0.000 0.000
#> SRR1736320     2  0.0363      0.931 0.000 0.988 0.000  0 0.012 0.000
#> SRR1736321     2  0.2697      0.873 0.000 0.812 0.000  0 0.188 0.000
#> SRR1736322     2  0.2697      0.873 0.000 0.812 0.000  0 0.188 0.000
#> SRR1736323     2  0.2697      0.873 0.000 0.812 0.000  0 0.188 0.000
#> SRR1736324     2  0.0000      0.934 0.000 1.000 0.000  0 0.000 0.000
#> SRR1736325     2  0.0000      0.934 0.000 1.000 0.000  0 0.000 0.000
#> SRR1736326     2  0.0000      0.934 0.000 1.000 0.000  0 0.000 0.000
#> SRR1736328     4  0.0000      1.000 0.000 0.000 0.000  1 0.000 0.000
#> SRR1736327     4  0.0000      1.000 0.000 0.000 0.000  1 0.000 0.000
#> SRR1736329     4  0.0000      1.000 0.000 0.000 0.000  1 0.000 0.000
#> SRR1736330     4  0.0000      1.000 0.000 0.000 0.000  1 0.000 0.000
#> SRR1736331     4  0.0000      1.000 0.000 0.000 0.000  1 0.000 0.000
#> SRR1736332     4  0.0000      1.000 0.000 0.000 0.000  1 0.000 0.000
#> SRR1736333     1  0.0000      0.967 1.000 0.000 0.000  0 0.000 0.000
#> SRR1736334     1  0.0000      0.967 1.000 0.000 0.000  0 0.000 0.000
#> SRR1736335     1  0.0000      0.967 1.000 0.000 0.000  0 0.000 0.000
#> SRR1736337     1  0.0000      0.967 1.000 0.000 0.000  0 0.000 0.000
#> SRR1736336     1  0.0000      0.967 1.000 0.000 0.000  0 0.000 0.000
#> SRR1736338     1  0.0000      0.967 1.000 0.000 0.000  0 0.000 0.000
#> SRR1736339     1  0.1075      0.966 0.952 0.000 0.000  0 0.000 0.048
#> SRR1736340     1  0.1075      0.966 0.952 0.000 0.000  0 0.000 0.048
#> SRR1736341     1  0.1075      0.966 0.952 0.000 0.000  0 0.000 0.048
#> SRR1736342     6  0.0000      0.806 0.000 0.000 0.000  0 0.000 1.000
#> SRR1736343     6  0.0000      0.806 0.000 0.000 0.000  0 0.000 1.000
#> SRR1736344     6  0.0000      0.806 0.000 0.000 0.000  0 0.000 1.000
#> SRR1736345     1  0.1075      0.966 0.952 0.000 0.000  0 0.000 0.048
#> SRR1736346     1  0.1075      0.966 0.952 0.000 0.000  0 0.000 0.048
#> SRR1736348     6  0.0000      0.806 0.000 0.000 0.000  0 0.000 1.000
#> SRR1736347     1  0.1141      0.962 0.948 0.000 0.000  0 0.000 0.052
#> SRR1736349     6  0.0000      0.806 0.000 0.000 0.000  0 0.000 1.000
#> SRR1736350     6  0.0000      0.806 0.000 0.000 0.000  0 0.000 1.000
#> SRR1736351     6  0.3499      0.582 0.320 0.000 0.000  0 0.000 0.680
#> SRR1736352     6  0.3499      0.582 0.320 0.000 0.000  0 0.000 0.680
#> SRR1736353     6  0.3499      0.582 0.320 0.000 0.000  0 0.000 0.680
#> SRR1736354     6  0.3834      0.625 0.084 0.000 0.144  0 0.000 0.772
#> SRR1736355     6  0.3834      0.625 0.084 0.000 0.144  0 0.000 0.772
#> SRR1736356     3  0.0865      0.908 0.000 0.000 0.964  0 0.036 0.000
#> SRR1736358     3  0.0260      0.938 0.000 0.000 0.992  0 0.000 0.008
#> SRR1736357     3  0.0260      0.938 0.000 0.000 0.992  0 0.000 0.008
#> SRR1736359     3  0.0260      0.938 0.000 0.000 0.992  0 0.000 0.008
#> SRR1736360     5  0.2697      1.000 0.000 0.000 0.188  0 0.812 0.000
#> SRR1736361     5  0.2697      1.000 0.000 0.000 0.188  0 0.812 0.000
#> SRR1736362     5  0.2697      1.000 0.000 0.000 0.188  0 0.812 0.000
#> SRR1736363     3  0.1204      0.961 0.000 0.000 0.944  0 0.000 0.056
#> SRR1736365     3  0.1204      0.961 0.000 0.000 0.944  0 0.000 0.056
#> SRR1736364     3  0.1204      0.961 0.000 0.000 0.944  0 0.000 0.056
#> SRR1736366     3  0.1204      0.961 0.000 0.000 0.944  0 0.000 0.056
#> SRR1736367     3  0.1204      0.961 0.000 0.000 0.944  0 0.000 0.056
#> SRR1736368     3  0.1204      0.961 0.000 0.000 0.944  0 0.000 0.056

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

consensus_heatmap(res, k = 2)

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

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

collect_plots(res)

plot of chunk ATC-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4886 0.512   0.512
#> 3 3 0.818           0.781       0.928         0.1295 0.962   0.925
#> 4 4 0.852           0.958       0.955         0.1760 0.845   0.680
#> 5 5 0.768           0.727       0.872         0.0716 0.993   0.980
#> 6 6 0.767           0.729       0.828         0.0649 0.896   0.691

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
#> SRR1736309     2       0          1  0  1
#> SRR1736310     2       0          1  0  1
#> SRR1736312     2       0          1  0  1
#> SRR1736311     2       0          1  0  1
#> SRR1736313     2       0          1  0  1
#> SRR1736314     2       0          1  0  1
#> SRR1736315     2       0          1  0  1
#> SRR1736316     2       0          1  0  1
#> SRR1736317     2       0          1  0  1
#> SRR1736318     2       0          1  0  1
#> SRR1736319     2       0          1  0  1
#> SRR1736320     2       0          1  0  1
#> SRR1736321     2       0          1  0  1
#> SRR1736322     2       0          1  0  1
#> SRR1736323     2       0          1  0  1
#> SRR1736324     2       0          1  0  1
#> SRR1736325     2       0          1  0  1
#> SRR1736326     2       0          1  0  1
#> SRR1736328     2       0          1  0  1
#> SRR1736327     2       0          1  0  1
#> SRR1736329     2       0          1  0  1
#> SRR1736330     2       0          1  0  1
#> SRR1736331     2       0          1  0  1
#> SRR1736332     2       0          1  0  1
#> SRR1736333     1       0          1  1  0
#> SRR1736334     1       0          1  1  0
#> SRR1736335     1       0          1  1  0
#> SRR1736337     1       0          1  1  0
#> SRR1736336     1       0          1  1  0
#> SRR1736338     1       0          1  1  0
#> SRR1736339     1       0          1  1  0
#> SRR1736340     1       0          1  1  0
#> SRR1736341     1       0          1  1  0
#> SRR1736342     1       0          1  1  0
#> SRR1736343     1       0          1  1  0
#> SRR1736344     1       0          1  1  0
#> SRR1736345     1       0          1  1  0
#> SRR1736346     1       0          1  1  0
#> SRR1736348     1       0          1  1  0
#> SRR1736347     1       0          1  1  0
#> SRR1736349     1       0          1  1  0
#> SRR1736350     1       0          1  1  0
#> SRR1736351     1       0          1  1  0
#> SRR1736352     1       0          1  1  0
#> SRR1736353     1       0          1  1  0
#> SRR1736354     1       0          1  1  0
#> SRR1736355     1       0          1  1  0
#> SRR1736356     1       0          1  1  0
#> SRR1736358     1       0          1  1  0
#> SRR1736357     1       0          1  1  0
#> SRR1736359     1       0          1  1  0
#> SRR1736360     1       0          1  1  0
#> SRR1736361     1       0          1  1  0
#> SRR1736362     1       0          1  1  0
#> SRR1736363     1       0          1  1  0
#> SRR1736365     1       0          1  1  0
#> SRR1736364     1       0          1  1  0
#> SRR1736366     1       0          1  1  0
#> SRR1736367     1       0          1  1  0
#> SRR1736368     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
#> SRR1736309     2  0.0237      0.995 0.000 0.996 0.004
#> SRR1736310     2  0.0000      0.998 0.000 1.000 0.000
#> SRR1736312     2  0.0000      0.998 0.000 1.000 0.000
#> SRR1736311     2  0.0000      0.998 0.000 1.000 0.000
#> SRR1736313     2  0.1753      0.958 0.000 0.952 0.048
#> SRR1736314     2  0.0000      0.998 0.000 1.000 0.000
#> SRR1736315     2  0.0000      0.998 0.000 1.000 0.000
#> SRR1736316     2  0.0000      0.998 0.000 1.000 0.000
#> SRR1736317     2  0.0000      0.998 0.000 1.000 0.000
#> SRR1736318     2  0.0000      0.998 0.000 1.000 0.000
#> SRR1736319     2  0.0000      0.998 0.000 1.000 0.000
#> SRR1736320     2  0.0000      0.998 0.000 1.000 0.000
#> SRR1736321     2  0.0000      0.998 0.000 1.000 0.000
#> SRR1736322     2  0.0000      0.998 0.000 1.000 0.000
#> SRR1736323     2  0.0000      0.998 0.000 1.000 0.000
#> SRR1736324     2  0.0000      0.998 0.000 1.000 0.000
#> SRR1736325     2  0.0000      0.998 0.000 1.000 0.000
#> SRR1736326     2  0.0000      0.998 0.000 1.000 0.000
#> SRR1736328     2  0.0000      0.998 0.000 1.000 0.000
#> SRR1736327     2  0.0000      0.998 0.000 1.000 0.000
#> SRR1736329     2  0.0000      0.998 0.000 1.000 0.000
#> SRR1736330     2  0.0000      0.998 0.000 1.000 0.000
#> SRR1736331     2  0.0000      0.998 0.000 1.000 0.000
#> SRR1736332     2  0.0000      0.998 0.000 1.000 0.000
#> SRR1736333     1  0.0892      0.781 0.980 0.000 0.020
#> SRR1736334     1  0.1964      0.741 0.944 0.000 0.056
#> SRR1736335     1  0.3038      0.699 0.896 0.000 0.104
#> SRR1736337     1  0.1411      0.767 0.964 0.000 0.036
#> SRR1736336     1  0.0747      0.782 0.984 0.000 0.016
#> SRR1736338     1  0.0892      0.781 0.980 0.000 0.020
#> SRR1736339     1  0.0000      0.785 1.000 0.000 0.000
#> SRR1736340     1  0.0000      0.785 1.000 0.000 0.000
#> SRR1736341     1  0.0424      0.785 0.992 0.000 0.008
#> SRR1736342     1  0.0237      0.783 0.996 0.000 0.004
#> SRR1736343     1  0.0000      0.785 1.000 0.000 0.000
#> SRR1736344     1  0.0237      0.783 0.996 0.000 0.004
#> SRR1736345     1  0.0000      0.785 1.000 0.000 0.000
#> SRR1736346     1  0.0892      0.766 0.980 0.000 0.020
#> SRR1736348     1  0.0237      0.785 0.996 0.000 0.004
#> SRR1736347     1  0.1031      0.761 0.976 0.000 0.024
#> SRR1736349     1  0.0237      0.785 0.996 0.000 0.004
#> SRR1736350     1  0.0237      0.785 0.996 0.000 0.004
#> SRR1736351     1  0.0000      0.785 1.000 0.000 0.000
#> SRR1736352     1  0.0000      0.785 1.000 0.000 0.000
#> SRR1736353     1  0.0000      0.785 1.000 0.000 0.000
#> SRR1736354     1  0.0424      0.785 0.992 0.000 0.008
#> SRR1736355     1  0.0592      0.784 0.988 0.000 0.012
#> SRR1736356     1  0.5291      0.392 0.732 0.000 0.268
#> SRR1736358     1  0.5397      0.369 0.720 0.000 0.280
#> SRR1736357     1  0.5397      0.369 0.720 0.000 0.280
#> SRR1736359     1  0.5397      0.369 0.720 0.000 0.280
#> SRR1736360     3  0.6309      0.619 0.496 0.000 0.504
#> SRR1736361     3  0.5948      0.714 0.360 0.000 0.640
#> SRR1736362     1  0.5835      0.047 0.660 0.000 0.340
#> SRR1736363     1  0.5397      0.369 0.720 0.000 0.280
#> SRR1736365     1  0.5397      0.369 0.720 0.000 0.280
#> SRR1736364     1  0.5397      0.369 0.720 0.000 0.280
#> SRR1736366     1  0.5397      0.369 0.720 0.000 0.280
#> SRR1736367     1  0.5397      0.369 0.720 0.000 0.280
#> SRR1736368     1  0.5397      0.369 0.720 0.000 0.280

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3 p4
#> SRR1736309     2  0.0592      0.986 0.000 0.984 0.000 NA
#> SRR1736310     2  0.0469      0.988 0.000 0.988 0.000 NA
#> SRR1736312     2  0.0592      0.986 0.000 0.984 0.000 NA
#> SRR1736311     2  0.0469      0.988 0.000 0.988 0.000 NA
#> SRR1736313     2  0.1792      0.947 0.000 0.932 0.000 NA
#> SRR1736314     2  0.0000      0.992 0.000 1.000 0.000 NA
#> SRR1736315     2  0.0188      0.991 0.000 0.996 0.000 NA
#> SRR1736316     2  0.0188      0.991 0.000 0.996 0.000 NA
#> SRR1736317     2  0.0188      0.991 0.000 0.996 0.000 NA
#> SRR1736318     2  0.0000      0.992 0.000 1.000 0.000 NA
#> SRR1736319     2  0.0000      0.992 0.000 1.000 0.000 NA
#> SRR1736320     2  0.0000      0.992 0.000 1.000 0.000 NA
#> SRR1736321     2  0.0000      0.992 0.000 1.000 0.000 NA
#> SRR1736322     2  0.0000      0.992 0.000 1.000 0.000 NA
#> SRR1736323     2  0.0000      0.992 0.000 1.000 0.000 NA
#> SRR1736324     2  0.0000      0.992 0.000 1.000 0.000 NA
#> SRR1736325     2  0.0000      0.992 0.000 1.000 0.000 NA
#> SRR1736326     2  0.0469      0.988 0.000 0.988 0.000 NA
#> SRR1736328     2  0.0592      0.988 0.000 0.984 0.000 NA
#> SRR1736327     2  0.0592      0.988 0.000 0.984 0.000 NA
#> SRR1736329     2  0.0592      0.988 0.000 0.984 0.000 NA
#> SRR1736330     2  0.0592      0.988 0.000 0.984 0.000 NA
#> SRR1736331     2  0.0592      0.988 0.000 0.984 0.000 NA
#> SRR1736332     2  0.0592      0.988 0.000 0.984 0.000 NA
#> SRR1736333     1  0.1940      0.940 0.924 0.000 0.076 NA
#> SRR1736334     1  0.1743      0.947 0.940 0.000 0.056 NA
#> SRR1736335     1  0.2334      0.927 0.908 0.000 0.088 NA
#> SRR1736337     1  0.1902      0.944 0.932 0.000 0.064 NA
#> SRR1736336     1  0.1792      0.945 0.932 0.000 0.068 NA
#> SRR1736338     1  0.1792      0.944 0.932 0.000 0.068 NA
#> SRR1736339     1  0.0188      0.970 0.996 0.000 0.004 NA
#> SRR1736340     1  0.0657      0.969 0.984 0.000 0.004 NA
#> SRR1736341     1  0.0000      0.970 1.000 0.000 0.000 NA
#> SRR1736342     1  0.0188      0.970 0.996 0.000 0.000 NA
#> SRR1736343     1  0.0188      0.969 0.996 0.000 0.004 NA
#> SRR1736344     1  0.0000      0.970 1.000 0.000 0.000 NA
#> SRR1736345     1  0.0657      0.969 0.984 0.000 0.012 NA
#> SRR1736346     1  0.1042      0.966 0.972 0.000 0.008 NA
#> SRR1736348     1  0.1042      0.962 0.972 0.000 0.020 NA
#> SRR1736347     1  0.1356      0.959 0.960 0.000 0.008 NA
#> SRR1736349     1  0.0524      0.967 0.988 0.000 0.008 NA
#> SRR1736350     1  0.0524      0.967 0.988 0.000 0.008 NA
#> SRR1736351     1  0.0000      0.970 1.000 0.000 0.000 NA
#> SRR1736352     1  0.0000      0.970 1.000 0.000 0.000 NA
#> SRR1736353     1  0.0000      0.970 1.000 0.000 0.000 NA
#> SRR1736354     1  0.0895      0.964 0.976 0.000 0.020 NA
#> SRR1736355     1  0.1356      0.956 0.960 0.000 0.032 NA
#> SRR1736356     3  0.3972      0.885 0.204 0.000 0.788 NA
#> SRR1736358     3  0.3852      0.899 0.192 0.000 0.800 NA
#> SRR1736357     3  0.3852      0.899 0.192 0.000 0.800 NA
#> SRR1736359     3  0.3852      0.899 0.192 0.000 0.800 NA
#> SRR1736360     3  0.2741      0.837 0.012 0.000 0.892 NA
#> SRR1736361     3  0.2048      0.846 0.008 0.000 0.928 NA
#> SRR1736362     3  0.2521      0.859 0.024 0.000 0.912 NA
#> SRR1736363     3  0.2704      0.927 0.124 0.000 0.876 NA
#> SRR1736365     3  0.2647      0.927 0.120 0.000 0.880 NA
#> SRR1736364     3  0.2704      0.926 0.124 0.000 0.876 NA
#> SRR1736366     3  0.2647      0.927 0.120 0.000 0.880 NA
#> SRR1736367     3  0.2704      0.926 0.124 0.000 0.876 NA
#> SRR1736368     3  0.2647      0.927 0.120 0.000 0.880 NA

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3 p4    p5
#> SRR1736309     2  0.0963      0.888 0.000 0.964 0.000 NA 0.000
#> SRR1736310     2  0.1557      0.880 0.000 0.940 0.000 NA 0.008
#> SRR1736312     2  0.1571      0.878 0.000 0.936 0.000 NA 0.004
#> SRR1736311     2  0.1408      0.884 0.000 0.948 0.000 NA 0.008
#> SRR1736313     2  0.1732      0.864 0.000 0.920 0.000 NA 0.000
#> SRR1736314     2  0.1331      0.885 0.000 0.952 0.000 NA 0.008
#> SRR1736315     2  0.0880      0.887 0.000 0.968 0.000 NA 0.000
#> SRR1736316     2  0.0162      0.893 0.000 0.996 0.000 NA 0.000
#> SRR1736317     2  0.0880      0.887 0.000 0.968 0.000 NA 0.000
#> SRR1736318     2  0.0566      0.892 0.000 0.984 0.000 NA 0.004
#> SRR1736319     2  0.0324      0.893 0.000 0.992 0.000 NA 0.004
#> SRR1736320     2  0.0162      0.894 0.000 0.996 0.000 NA 0.000
#> SRR1736321     2  0.0000      0.893 0.000 1.000 0.000 NA 0.000
#> SRR1736322     2  0.0162      0.894 0.000 0.996 0.000 NA 0.004
#> SRR1736323     2  0.0000      0.893 0.000 1.000 0.000 NA 0.000
#> SRR1736324     2  0.0162      0.893 0.000 0.996 0.000 NA 0.000
#> SRR1736325     2  0.0324      0.893 0.000 0.992 0.000 NA 0.004
#> SRR1736326     2  0.1430      0.882 0.000 0.944 0.000 NA 0.004
#> SRR1736328     2  0.4015      0.695 0.000 0.652 0.000 NA 0.000
#> SRR1736327     2  0.3999      0.698 0.000 0.656 0.000 NA 0.000
#> SRR1736329     2  0.3999      0.698 0.000 0.656 0.000 NA 0.000
#> SRR1736330     2  0.4015      0.695 0.000 0.652 0.000 NA 0.000
#> SRR1736331     2  0.4015      0.695 0.000 0.652 0.000 NA 0.000
#> SRR1736332     2  0.4015      0.695 0.000 0.652 0.000 NA 0.000
#> SRR1736333     1  0.4063      0.770 0.800 0.000 0.084 NA 0.112
#> SRR1736334     1  0.4763      0.683 0.740 0.000 0.104 NA 0.152
#> SRR1736335     1  0.5814      0.500 0.640 0.000 0.180 NA 0.172
#> SRR1736337     1  0.4403      0.729 0.772 0.000 0.092 NA 0.132
#> SRR1736336     1  0.3090      0.821 0.860 0.000 0.088 NA 0.052
#> SRR1736338     1  0.3184      0.819 0.852 0.000 0.100 NA 0.048
#> SRR1736339     1  0.0404      0.883 0.988 0.000 0.000 NA 0.012
#> SRR1736340     1  0.0510      0.882 0.984 0.000 0.000 NA 0.016
#> SRR1736341     1  0.1106      0.882 0.964 0.000 0.012 NA 0.024
#> SRR1736342     1  0.0451      0.884 0.988 0.000 0.004 NA 0.008
#> SRR1736343     1  0.0955      0.881 0.968 0.000 0.004 NA 0.028
#> SRR1736344     1  0.0703      0.882 0.976 0.000 0.000 NA 0.024
#> SRR1736345     1  0.0510      0.882 0.984 0.000 0.000 NA 0.016
#> SRR1736346     1  0.0510      0.882 0.984 0.000 0.000 NA 0.016
#> SRR1736348     1  0.2848      0.819 0.868 0.000 0.028 NA 0.104
#> SRR1736347     1  0.0609      0.881 0.980 0.000 0.000 NA 0.020
#> SRR1736349     1  0.2608      0.840 0.888 0.000 0.020 NA 0.088
#> SRR1736350     1  0.2608      0.840 0.888 0.000 0.020 NA 0.088
#> SRR1736351     1  0.0000      0.884 1.000 0.000 0.000 NA 0.000
#> SRR1736352     1  0.0324      0.884 0.992 0.000 0.004 NA 0.004
#> SRR1736353     1  0.0162      0.885 0.996 0.000 0.004 NA 0.000
#> SRR1736354     1  0.2012      0.859 0.920 0.000 0.020 NA 0.060
#> SRR1736355     1  0.3531      0.752 0.816 0.000 0.036 NA 0.148
#> SRR1736356     5  0.6946      0.000 0.220 0.000 0.348 NA 0.420
#> SRR1736358     3  0.6111     -0.391 0.260 0.000 0.560 NA 0.180
#> SRR1736357     3  0.6111     -0.391 0.260 0.000 0.560 NA 0.180
#> SRR1736359     3  0.6092     -0.382 0.256 0.000 0.564 NA 0.180
#> SRR1736360     3  0.3353      0.551 0.008 0.000 0.796 NA 0.196
#> SRR1736361     3  0.3585      0.531 0.004 0.000 0.772 NA 0.220
#> SRR1736362     3  0.3163      0.573 0.012 0.000 0.824 NA 0.164
#> SRR1736363     3  0.2054      0.638 0.052 0.000 0.920 NA 0.028
#> SRR1736365     3  0.1408      0.659 0.044 0.000 0.948 NA 0.008
#> SRR1736364     3  0.1651      0.660 0.036 0.000 0.944 NA 0.012
#> SRR1736366     3  0.1522      0.657 0.044 0.000 0.944 NA 0.012
#> SRR1736367     3  0.1772      0.657 0.032 0.000 0.940 NA 0.020
#> SRR1736368     3  0.1282      0.661 0.044 0.000 0.952 NA 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
#> SRR1736309     2  0.3789      0.963 0.000 0.584 0.000 0.416 0.000 0.000
#> SRR1736310     2  0.3706      0.933 0.000 0.620 0.000 0.380 0.000 0.000
#> SRR1736312     2  0.3737      0.947 0.000 0.608 0.000 0.392 0.000 0.000
#> SRR1736311     2  0.3727      0.943 0.000 0.612 0.000 0.388 0.000 0.000
#> SRR1736313     2  0.3899      0.957 0.000 0.592 0.000 0.404 0.000 0.004
#> SRR1736314     2  0.3747      0.951 0.000 0.604 0.000 0.396 0.000 0.000
#> SRR1736315     2  0.3843      0.952 0.000 0.548 0.000 0.452 0.000 0.000
#> SRR1736316     2  0.3833      0.960 0.000 0.556 0.000 0.444 0.000 0.000
#> SRR1736317     2  0.3847      0.948 0.000 0.544 0.000 0.456 0.000 0.000
#> SRR1736318     2  0.3797      0.964 0.000 0.580 0.000 0.420 0.000 0.000
#> SRR1736319     2  0.3817      0.965 0.000 0.568 0.000 0.432 0.000 0.000
#> SRR1736320     2  0.3817      0.965 0.000 0.568 0.000 0.432 0.000 0.000
#> SRR1736321     2  0.3838      0.957 0.000 0.552 0.000 0.448 0.000 0.000
#> SRR1736322     2  0.3833      0.960 0.000 0.556 0.000 0.444 0.000 0.000
#> SRR1736323     2  0.3838      0.957 0.000 0.552 0.000 0.448 0.000 0.000
#> SRR1736324     2  0.3817      0.965 0.000 0.568 0.000 0.432 0.000 0.000
#> SRR1736325     2  0.3817      0.965 0.000 0.568 0.000 0.432 0.000 0.000
#> SRR1736326     2  0.3756      0.954 0.000 0.600 0.000 0.400 0.000 0.000
#> SRR1736328     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1736327     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1736329     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1736330     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1736331     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1736332     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1736333     5  0.5639      0.806 0.376 0.000 0.068 0.000 0.520 0.036
#> SRR1736334     5  0.5028      0.820 0.400 0.000 0.056 0.000 0.536 0.008
#> SRR1736335     5  0.5189      0.697 0.248 0.004 0.104 0.000 0.636 0.008
#> SRR1736337     5  0.5153      0.848 0.376 0.000 0.056 0.000 0.552 0.016
#> SRR1736336     1  0.5801     -0.650 0.472 0.000 0.068 0.000 0.416 0.044
#> SRR1736338     1  0.6029     -0.562 0.492 0.000 0.080 0.000 0.372 0.056
#> SRR1736339     1  0.0508      0.816 0.984 0.000 0.000 0.000 0.004 0.012
#> SRR1736340     1  0.0717      0.812 0.976 0.000 0.000 0.000 0.008 0.016
#> SRR1736341     1  0.0405      0.818 0.988 0.000 0.000 0.000 0.004 0.008
#> SRR1736342     1  0.0820      0.817 0.972 0.000 0.000 0.000 0.012 0.016
#> SRR1736343     1  0.0725      0.816 0.976 0.000 0.000 0.000 0.012 0.012
#> SRR1736344     1  0.0725      0.816 0.976 0.000 0.000 0.000 0.012 0.012
#> SRR1736345     1  0.0891      0.807 0.968 0.000 0.000 0.000 0.008 0.024
#> SRR1736346     1  0.0972      0.804 0.964 0.000 0.000 0.000 0.008 0.028
#> SRR1736348     1  0.4423      0.621 0.772 0.004 0.048 0.000 0.104 0.072
#> SRR1736347     1  0.0891      0.807 0.968 0.000 0.000 0.000 0.008 0.024
#> SRR1736349     1  0.3991      0.665 0.800 0.004 0.028 0.000 0.096 0.072
#> SRR1736350     1  0.3962      0.664 0.800 0.004 0.024 0.000 0.100 0.072
#> SRR1736351     1  0.0146      0.819 0.996 0.000 0.000 0.000 0.000 0.004
#> SRR1736352     1  0.0000      0.819 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1736353     1  0.0000      0.819 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1736354     1  0.2485      0.762 0.892 0.000 0.012 0.000 0.040 0.056
#> SRR1736355     1  0.2774      0.747 0.872 0.000 0.012 0.000 0.040 0.076
#> SRR1736356     6  0.3730      0.000 0.076 0.000 0.088 0.000 0.024 0.812
#> SRR1736358     3  0.6633      0.139 0.188 0.000 0.540 0.000 0.124 0.148
#> SRR1736357     3  0.6633      0.139 0.188 0.000 0.540 0.000 0.124 0.148
#> SRR1736359     3  0.6633      0.139 0.188 0.000 0.540 0.000 0.124 0.148
#> SRR1736360     3  0.3976      0.426 0.004 0.000 0.612 0.000 0.380 0.004
#> SRR1736361     3  0.5111      0.303 0.004 0.000 0.492 0.000 0.436 0.068
#> SRR1736362     3  0.4009      0.443 0.004 0.000 0.632 0.000 0.356 0.008
#> SRR1736363     3  0.0779      0.611 0.008 0.000 0.976 0.000 0.008 0.008
#> SRR1736365     3  0.0713      0.631 0.000 0.000 0.972 0.000 0.028 0.000
#> SRR1736364     3  0.1141      0.630 0.000 0.000 0.948 0.000 0.052 0.000
#> SRR1736366     3  0.0291      0.615 0.004 0.000 0.992 0.000 0.004 0.000
#> SRR1736367     3  0.1204      0.629 0.000 0.000 0.944 0.000 0.056 0.000
#> SRR1736368     3  0.0632      0.630 0.000 0.000 0.976 0.000 0.024 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-NMF-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-NMF-collect-classes

If matrix rows can be associated to genes, consider to use functional_enrichment(res, ...) to perform function enrichment for the signature genes. See this vignette for more detailed explanations.

Session info

sessionInfo()
#> R version 3.6.0 (2019-04-26)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: CentOS Linux 7 (Core)
#> 
#> Matrix products: default
#> BLAS:   /usr/lib64/libblas.so.3.4.2
#> LAPACK: /usr/lib64/liblapack.so.3.4.2
#> 
#> locale:
#>  [1] LC_CTYPE=en_GB.UTF-8       LC_NUMERIC=C               LC_TIME=en_GB.UTF-8       
#>  [4] LC_COLLATE=en_GB.UTF-8     LC_MONETARY=en_GB.UTF-8    LC_MESSAGES=en_GB.UTF-8   
#>  [7] LC_PAPER=en_GB.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
#> [10] LC_TELEPHONE=C             LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C       
#> 
#> attached base packages:
#> [1] grid      stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] genefilter_1.66.0    ComplexHeatmap_2.3.1 markdown_1.1         knitr_1.26          
#> [5] GetoptLong_0.1.7     cola_1.3.2          
#> 
#> loaded via a namespace (and not attached):
#>  [1] circlize_0.4.8       shape_1.4.4          xfun_0.11            slam_0.1-46         
#>  [5] lattice_0.20-38      splines_3.6.0        colorspace_1.4-1     vctrs_0.2.0         
#>  [9] stats4_3.6.0         blob_1.2.0           XML_3.98-1.20        survival_2.44-1.1   
#> [13] rlang_0.4.2          pillar_1.4.2         DBI_1.0.0            BiocGenerics_0.30.0 
#> [17] bit64_0.9-7          RColorBrewer_1.1-2   matrixStats_0.55.0   stringr_1.4.0       
#> [21] GlobalOptions_0.1.1  evaluate_0.14        memoise_1.1.0        Biobase_2.44.0      
#> [25] IRanges_2.18.3       parallel_3.6.0       AnnotationDbi_1.46.1 highr_0.8           
#> [29] Rcpp_1.0.3           xtable_1.8-4         backports_1.1.5      S4Vectors_0.22.1    
#> [33] annotate_1.62.0      skmeans_0.2-11       bit_1.1-14           microbenchmark_1.4-7
#> [37] brew_1.0-6           impute_1.58.0        rjson_0.2.20         png_0.1-7           
#> [41] digest_0.6.23        stringi_1.4.3        polyclip_1.10-0      clue_0.3-57         
#> [45] tools_3.6.0          bitops_1.0-6         magrittr_1.5         eulerr_6.0.0        
#> [49] RCurl_1.95-4.12      RSQLite_2.1.4        tibble_2.1.3         cluster_2.1.0       
#> [53] crayon_1.3.4         pkgconfig_2.0.3      zeallot_0.1.0        Matrix_1.2-17       
#> [57] xml2_1.2.2           httr_1.4.1           R6_2.4.1             mclust_5.4.5        
#> [61] compiler_3.6.0