cola Report for recount2:SRP002079

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

The call of run_all_consensus_partition_methods() was:

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

Dimension of the input matrix:

mat = get_matrix(res_list)
dim(mat)
#> [1] 15332    62

Density distribution

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

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

plot of chunk density-heatmap

Suggest the best k

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

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

suggest_best_k(res_list)
The best k 1-PAC Mean silhouette Concordance Optional k
CV:pam 6 1.000 1.000 1.000 ** 3,4,5
MAD:pam 6 1.000 0.998 0.998 ** 3,4,5
ATC:kmeans 2 1.000 1.000 1.000 **
ATC:pam 2 1.000 0.949 0.980 **
SD:skmeans 6 0.955 0.948 0.890 ** 2,3,4,5
SD:mclust 6 0.954 0.959 0.950 ** 2,3
MAD:skmeans 6 0.954 0.937 0.943 ** 2,3,5
ATC:mclust 6 0.951 0.911 0.956 ** 2,3,4
ATC:hclust 6 0.949 0.903 0.922 *
CV:hclust 6 0.943 0.948 0.966 * 4,5
SD:NMF 5 0.935 0.934 0.903 * 2,3,4
MAD:mclust 6 0.933 0.940 0.954 * 4
MAD:NMF 6 0.932 0.857 0.934 * 4
SD:pam 6 0.931 0.963 0.950 * 3,4,5
CV:mclust 5 0.922 0.962 0.894 *
CV:NMF 5 0.914 0.958 0.891 * 3
CV:skmeans 6 0.908 0.769 0.785 * 2,3,4,5
ATC:skmeans 3 0.905 0.934 0.936 * 2
MAD:hclust 4 0.847 0.889 0.886
CV:kmeans 4 0.813 0.943 0.836
ATC:NMF 2 0.747 0.904 0.948
SD:hclust 2 0.712 0.874 0.947
SD:kmeans 3 0.705 0.936 0.905
MAD:kmeans 3 0.622 0.877 0.887

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

CDF of consensus matrices

Cumulative distribution function curves of consensus matrix for all methods.

collect_plots(res_list, fun = plot_ecdf)

plot of chunk collect-plots

Consensus heatmap

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

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

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

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

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

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

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

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

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

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

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

Membership heatmap

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

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

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

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

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

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

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

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

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

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

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

Signature heatmap

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

Note in following heatmaps, rows are scaled.

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

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

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

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

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

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

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

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

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

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

Statistics table

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

get_stats(res_list, k = 2)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      2 1.000           0.997       0.998          0.358 0.645   0.645
#> CV:NMF      2 0.566           0.662       0.810          0.435 0.500   0.500
#> MAD:NMF     2 0.688           0.837       0.933          0.484 0.511   0.511
#> ATC:NMF     2 0.747           0.904       0.948          0.466 0.505   0.505
#> SD:skmeans  2 1.000           0.983       0.987          0.500 0.500   0.500
#> CV:skmeans  2 1.000           1.000       1.000          0.500 0.500   0.500
#> MAD:skmeans 2 1.000           0.970       0.979          0.500 0.500   0.500
#> ATC:skmeans 2 1.000           1.000       1.000          0.507 0.494   0.494
#> SD:mclust   2 1.000           0.999       0.999          0.356 0.645   0.645
#> CV:mclust   2 0.405           0.748       0.848          0.424 0.645   0.645
#> MAD:mclust  2 0.500           0.957       0.956          0.366 0.645   0.645
#> ATC:mclust  2 1.000           0.994       0.997          0.359 0.645   0.645
#> SD:kmeans   2 0.545           0.798       0.867          0.408 0.645   0.645
#> CV:kmeans   2 0.419           0.683       0.779          0.420 0.645   0.645
#> MAD:kmeans  2 0.409           0.617       0.773          0.447 0.545   0.545
#> ATC:kmeans  2 1.000           1.000       1.000          0.507 0.494   0.494
#> SD:pam      2 0.545           0.775       0.864          0.414 0.645   0.645
#> CV:pam      2 0.898           0.849       0.949          0.504 0.492   0.492
#> MAD:pam     2 0.530           0.719       0.839          0.452 0.581   0.581
#> ATC:pam     2 1.000           0.949       0.980          0.500 0.500   0.500
#> SD:hclust   2 0.712           0.874       0.947          0.432 0.581   0.581
#> CV:hclust   2 0.524           0.831       0.903          0.412 0.645   0.645
#> MAD:hclust  2 0.414           0.827       0.877          0.477 0.505   0.505
#> ATC:hclust  2 0.458           0.818       0.877          0.442 0.526   0.526
get_stats(res_list, k = 3)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      3 1.000           0.982       0.990          0.832 0.700   0.535
#> CV:NMF      3 1.000           1.000       1.000          0.507 0.845   0.689
#> MAD:NMF     3 0.731           0.876       0.925          0.363 0.718   0.504
#> ATC:NMF     3 0.584           0.598       0.784          0.343 0.879   0.765
#> SD:skmeans  3 1.000           1.000       1.000          0.312 0.845   0.689
#> CV:skmeans  3 1.000           1.000       1.000          0.310 0.845   0.689
#> MAD:skmeans 3 1.000           0.999       0.999          0.311 0.845   0.689
#> ATC:skmeans 3 0.905           0.934       0.936          0.231 0.866   0.733
#> SD:mclust   3 1.000           0.995       0.996          0.836 0.700   0.535
#> CV:mclust   3 0.816           0.881       0.923          0.549 0.700   0.535
#> MAD:mclust  3 0.848           0.981       0.989          0.779 0.700   0.535
#> ATC:mclust  3 1.000           0.988       0.987          0.808 0.700   0.535
#> SD:kmeans   3 0.705           0.936       0.905          0.551 0.700   0.535
#> CV:kmeans   3 0.535           0.937       0.881          0.471 0.700   0.535
#> MAD:kmeans  3 0.622           0.877       0.887          0.442 0.696   0.491
#> ATC:kmeans  3 0.466           0.531       0.728          0.274 0.737   0.513
#> SD:pam      3 1.000           1.000       1.000          0.584 0.700   0.535
#> CV:pam      3 1.000           1.000       1.000          0.302 0.811   0.631
#> MAD:pam     3 1.000           0.988       0.994          0.453 0.666   0.470
#> ATC:pam     3 0.654           0.733       0.823          0.244 0.860   0.727
#> SD:hclust   3 0.667           0.514       0.742          0.224 0.856   0.760
#> CV:hclust   3 0.709           0.897       0.928          0.552 0.700   0.535
#> MAD:hclust  3 0.613           0.844       0.882          0.181 0.911   0.824
#> ATC:hclust  3 0.746           0.869       0.938          0.438 0.821   0.660
get_stats(res_list, k = 4)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      4 0.901           0.936       0.947         0.1235 0.910   0.739
#> CV:NMF      4 0.879           0.980       0.934         0.1223 0.905   0.724
#> MAD:NMF     4 0.930           0.910       0.948         0.1226 0.926   0.785
#> ATC:NMF     4 0.592           0.807       0.846         0.1937 0.776   0.487
#> SD:skmeans  4 1.000           0.980       0.984         0.1448 0.905   0.724
#> CV:skmeans  4 1.000           1.000       0.999         0.1447 0.905   0.724
#> MAD:skmeans 4 0.867           0.846       0.914         0.1448 0.867   0.634
#> ATC:skmeans 4 0.795           0.934       0.929         0.1889 0.867   0.644
#> SD:mclust   4 0.759           0.733       0.869         0.1274 0.895   0.704
#> CV:mclust   4 0.866           0.959       0.968         0.1403 0.905   0.724
#> MAD:mclust  4 0.907           0.910       0.943         0.1491 0.859   0.617
#> ATC:mclust  4 1.000           0.958       0.976         0.1356 0.885   0.679
#> SD:kmeans   4 0.789           0.891       0.865         0.1521 0.905   0.724
#> CV:kmeans   4 0.813           0.943       0.836         0.1510 0.905   0.724
#> MAD:kmeans  4 0.779           0.718       0.835         0.1393 0.926   0.785
#> ATC:kmeans  4 0.537           0.502       0.682         0.1400 0.825   0.533
#> SD:pam      4 1.000           1.000       1.000         0.0395 0.974   0.925
#> CV:pam      4 1.000           1.000       1.000         0.0395 0.974   0.925
#> MAD:pam     4 0.902           0.913       0.885         0.0741 0.974   0.925
#> ATC:pam     4 0.750           0.787       0.899         0.2131 0.863   0.642
#> SD:hclust   4 0.859           0.878       0.932         0.3765 0.702   0.441
#> CV:hclust   4 0.926           0.968       0.977         0.1685 0.905   0.724
#> MAD:hclust  4 0.847           0.889       0.886         0.3007 0.833   0.600
#> ATC:hclust  4 0.770           0.835       0.889         0.1377 0.930   0.799
get_stats(res_list, k = 5)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      5 0.935           0.934       0.903         0.0522 0.960   0.848
#> CV:NMF      5 0.914           0.958       0.891         0.0563 0.974   0.896
#> MAD:NMF     5 0.865           0.752       0.868         0.0549 0.932   0.763
#> ATC:NMF     5 0.713           0.736       0.825         0.0465 0.887   0.610
#> SD:skmeans  5 0.929           0.986       0.958         0.0630 0.948   0.792
#> CV:skmeans  5 0.903           0.958       0.915         0.0375 0.974   0.896
#> MAD:skmeans 5 1.000           0.995       0.992         0.0680 0.904   0.646
#> ATC:skmeans 5 0.781           0.818       0.853         0.0570 0.966   0.857
#> SD:mclust   5 0.838           0.808       0.859         0.0747 0.841   0.483
#> CV:mclust   5 0.922           0.962       0.894         0.0615 0.948   0.792
#> MAD:mclust  5 0.780           0.516       0.728         0.0530 0.909   0.682
#> ATC:mclust  5 0.852           0.827       0.857         0.0701 1.000   1.000
#> SD:kmeans   5 0.765           0.823       0.824         0.0694 1.000   1.000
#> CV:kmeans   5 0.772           0.863       0.808         0.0671 1.000   1.000
#> MAD:kmeans  5 0.766           0.804       0.775         0.0688 0.894   0.634
#> ATC:kmeans  5 0.612           0.655       0.685         0.0677 0.867   0.549
#> SD:pam      5 1.000           0.993       0.996         0.1324 0.910   0.718
#> CV:pam      5 1.000           0.981       0.992         0.1339 0.910   0.718
#> MAD:pam     5 0.912           0.865       0.930         0.0976 0.910   0.718
#> ATC:pam     5 0.790           0.585       0.811         0.0481 0.861   0.545
#> SD:hclust   5 0.856           0.877       0.926         0.0352 0.974   0.912
#> CV:hclust   5 0.904           0.917       0.919         0.0293 0.981   0.924
#> MAD:hclust  5 0.836           0.844       0.874         0.0447 0.974   0.896
#> ATC:hclust  5 0.876           0.746       0.870         0.0709 0.920   0.730
get_stats(res_list, k = 6)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      6 0.969           0.937       0.964         0.0177 0.992   0.965
#> CV:NMF      6 0.894           0.930       0.874         0.0324 0.981   0.915
#> MAD:NMF     6 0.932           0.857       0.934         0.0254 0.963   0.842
#> ATC:NMF     6 0.770           0.684       0.816         0.0226 0.934   0.738
#> SD:skmeans  6 0.955           0.948       0.890         0.0317 0.981   0.904
#> CV:skmeans  6 0.908           0.769       0.785         0.0437 0.911   0.639
#> MAD:skmeans 6 0.954           0.937       0.943         0.0305 0.981   0.904
#> ATC:skmeans 6 0.762           0.729       0.802         0.0397 0.937   0.723
#> SD:mclust   6 0.954           0.959       0.950         0.0343 0.985   0.924
#> CV:mclust   6 0.873           0.844       0.851         0.0421 1.000   1.000
#> MAD:mclust  6 0.933           0.940       0.954         0.0406 0.858   0.491
#> ATC:mclust  6 0.951           0.911       0.956         0.0335 0.922   0.698
#> SD:kmeans   6 0.809           0.647       0.725         0.0450 0.986   0.943
#> CV:kmeans   6 0.731           0.684       0.739         0.0567 0.983   0.930
#> MAD:kmeans  6 0.757           0.770       0.789         0.0416 0.989   0.948
#> ATC:kmeans  6 0.723           0.689       0.709         0.0463 0.931   0.688
#> SD:pam      6 0.931           0.963       0.950         0.0589 0.948   0.774
#> CV:pam      6 1.000           1.000       1.000         0.0296 0.967   0.859
#> MAD:pam     6 1.000           0.998       0.998         0.0639 0.948   0.774
#> ATC:pam     6 0.863           0.740       0.869         0.0432 0.888   0.569
#> SD:hclust   6 0.864           0.876       0.926         0.0721 0.937   0.765
#> CV:hclust   6 0.943           0.948       0.966         0.0316 0.974   0.888
#> MAD:hclust  6 0.840           0.890       0.867         0.0615 0.945   0.754
#> ATC:hclust  6 0.949           0.903       0.922         0.0256 0.960   0.834

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 15332 rows and 62 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#>   Subgroups are detected by 'hclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 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-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.712           0.874       0.947         0.4319 0.581   0.581
#> 3 3 0.667           0.514       0.742         0.2237 0.856   0.760
#> 4 4 0.859           0.878       0.932         0.3765 0.702   0.441
#> 5 5 0.856           0.877       0.926         0.0352 0.974   0.912
#> 6 6 0.864           0.876       0.926         0.0721 0.937   0.765

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
#> SRR037165     2  0.0376      0.934 0.004 0.996
#> SRR037166     2  0.0376      0.934 0.004 0.996
#> SRR037167     2  0.0376      0.934 0.004 0.996
#> SRR037168     1  0.7219      0.766 0.800 0.200
#> SRR037169     1  0.7219      0.766 0.800 0.200
#> SRR037170     1  0.7219      0.766 0.800 0.200
#> SRR037171     2  0.0000      0.935 0.000 1.000
#> SRR037172     2  0.0000      0.935 0.000 1.000
#> SRR037173     2  0.0000      0.935 0.000 1.000
#> SRR037174     2  0.0000      0.935 0.000 1.000
#> SRR037175     2  0.0000      0.935 0.000 1.000
#> SRR037176     2  0.0000      0.935 0.000 1.000
#> SRR037177     2  0.0376      0.934 0.004 0.996
#> SRR037182     2  0.9580      0.419 0.380 0.620
#> SRR037183     2  0.9580      0.419 0.380 0.620
#> SRR037184     2  0.0376      0.934 0.004 0.996
#> SRR037185     2  0.0376      0.934 0.004 0.996
#> SRR037186     2  0.0376      0.934 0.004 0.996
#> SRR037187     2  0.0376      0.934 0.004 0.996
#> SRR037188     2  0.9580      0.419 0.380 0.620
#> SRR037178     2  0.0000      0.935 0.000 1.000
#> SRR037179     2  0.0000      0.935 0.000 1.000
#> SRR037180     2  0.0000      0.935 0.000 1.000
#> SRR037181     2  0.0000      0.935 0.000 1.000
#> SRR037189     2  0.0376      0.934 0.004 0.996
#> SRR037190     2  0.0000      0.935 0.000 1.000
#> SRR037191     2  0.0000      0.935 0.000 1.000
#> SRR037192     2  0.0376      0.934 0.004 0.996
#> SRR037193     2  0.0376      0.934 0.004 0.996
#> SRR037194     2  0.0376      0.934 0.004 0.996
#> SRR037195     2  0.0376      0.934 0.004 0.996
#> SRR037196     2  0.4431      0.859 0.092 0.908
#> SRR037197     1  0.7219      0.766 0.800 0.200
#> SRR037198     2  0.4431      0.859 0.092 0.908
#> SRR037199     1  0.0000      0.946 1.000 0.000
#> SRR037200     1  0.0000      0.946 1.000 0.000
#> SRR037201     1  0.0000      0.946 1.000 0.000
#> SRR037202     1  0.0000      0.946 1.000 0.000
#> SRR037203     1  0.0000      0.946 1.000 0.000
#> SRR037204     1  0.0000      0.946 1.000 0.000
#> SRR037205     1  0.0000      0.946 1.000 0.000
#> SRR037206     2  0.0000      0.935 0.000 1.000
#> SRR037207     2  0.0000      0.935 0.000 1.000
#> SRR037208     2  0.0000      0.935 0.000 1.000
#> SRR037209     2  0.0000      0.935 0.000 1.000
#> SRR037210     2  0.0000      0.935 0.000 1.000
#> SRR037211     2  0.0000      0.935 0.000 1.000
#> SRR037212     2  0.9580      0.419 0.380 0.620
#> SRR037213     2  0.9580      0.419 0.380 0.620
#> SRR037219     2  0.9580      0.419 0.380 0.620
#> SRR037214     2  0.0000      0.935 0.000 1.000
#> SRR037215     2  0.0000      0.935 0.000 1.000
#> SRR037216     2  0.0000      0.935 0.000 1.000
#> SRR037217     2  0.0000      0.935 0.000 1.000
#> SRR037218     2  0.0000      0.935 0.000 1.000
#> SRR037220     1  0.0000      0.946 1.000 0.000
#> SRR037221     1  0.0000      0.946 1.000 0.000
#> SRR037222     1  0.0000      0.946 1.000 0.000
#> SRR037223     1  0.0000      0.946 1.000 0.000
#> SRR037224     1  0.0000      0.946 1.000 0.000
#> SRR037225     1  0.0000      0.946 1.000 0.000
#> SRR037226     1  0.0000      0.946 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
#> SRR037165     2  0.2772     0.8455 0.080 0.916 0.004
#> SRR037166     2  0.2772     0.8455 0.080 0.916 0.004
#> SRR037167     2  0.2772     0.8455 0.080 0.916 0.004
#> SRR037168     1  0.8817     0.2825 0.500 0.120 0.380
#> SRR037169     1  0.8817     0.2825 0.500 0.120 0.380
#> SRR037170     1  0.8817     0.2825 0.500 0.120 0.380
#> SRR037171     2  0.0000     0.8903 0.000 1.000 0.000
#> SRR037172     2  0.0000     0.8903 0.000 1.000 0.000
#> SRR037173     2  0.0000     0.8903 0.000 1.000 0.000
#> SRR037174     2  0.0000     0.8903 0.000 1.000 0.000
#> SRR037175     2  0.0000     0.8903 0.000 1.000 0.000
#> SRR037176     2  0.0000     0.8903 0.000 1.000 0.000
#> SRR037177     2  0.0475     0.8890 0.004 0.992 0.004
#> SRR037182     2  0.6309     0.2989 0.000 0.500 0.500
#> SRR037183     3  0.6309    -0.3734 0.000 0.500 0.500
#> SRR037184     2  0.0475     0.8890 0.004 0.992 0.004
#> SRR037185     2  0.0475     0.8890 0.004 0.992 0.004
#> SRR037186     2  0.0475     0.8890 0.004 0.992 0.004
#> SRR037187     2  0.0475     0.8890 0.004 0.992 0.004
#> SRR037188     3  0.6309    -0.3734 0.000 0.500 0.500
#> SRR037178     2  0.3340     0.8698 0.000 0.880 0.120
#> SRR037179     2  0.3340     0.8698 0.000 0.880 0.120
#> SRR037180     2  0.3340     0.8698 0.000 0.880 0.120
#> SRR037181     2  0.3340     0.8698 0.000 0.880 0.120
#> SRR037189     2  0.0475     0.8890 0.004 0.992 0.004
#> SRR037190     2  0.0000     0.8903 0.000 1.000 0.000
#> SRR037191     2  0.0000     0.8903 0.000 1.000 0.000
#> SRR037192     2  0.0475     0.8890 0.004 0.992 0.004
#> SRR037193     2  0.2772     0.8455 0.080 0.916 0.004
#> SRR037194     2  0.2772     0.8455 0.080 0.916 0.004
#> SRR037195     2  0.2772     0.8455 0.080 0.916 0.004
#> SRR037196     2  0.5263     0.7733 0.088 0.828 0.084
#> SRR037197     1  0.8817     0.2825 0.500 0.120 0.380
#> SRR037198     2  0.5263     0.7733 0.088 0.828 0.084
#> SRR037199     1  0.6309    -0.0447 0.500 0.000 0.500
#> SRR037200     3  0.6309    -0.1364 0.500 0.000 0.500
#> SRR037201     1  0.6309    -0.0447 0.500 0.000 0.500
#> SRR037202     1  0.6309    -0.0447 0.500 0.000 0.500
#> SRR037203     3  0.6309    -0.1364 0.500 0.000 0.500
#> SRR037204     3  0.6309    -0.1364 0.500 0.000 0.500
#> SRR037205     3  0.6309    -0.1364 0.500 0.000 0.500
#> SRR037206     2  0.3340     0.8698 0.000 0.880 0.120
#> SRR037207     2  0.3340     0.8698 0.000 0.880 0.120
#> SRR037208     2  0.3340     0.8698 0.000 0.880 0.120
#> SRR037209     2  0.3340     0.8698 0.000 0.880 0.120
#> SRR037210     2  0.3340     0.8698 0.000 0.880 0.120
#> SRR037211     2  0.3340     0.8698 0.000 0.880 0.120
#> SRR037212     3  0.6309    -0.3734 0.000 0.500 0.500
#> SRR037213     2  0.6309     0.2989 0.000 0.500 0.500
#> SRR037219     3  0.6309    -0.3734 0.000 0.500 0.500
#> SRR037214     2  0.3340     0.8698 0.000 0.880 0.120
#> SRR037215     2  0.3340     0.8698 0.000 0.880 0.120
#> SRR037216     2  0.3340     0.8698 0.000 0.880 0.120
#> SRR037217     2  0.3340     0.8698 0.000 0.880 0.120
#> SRR037218     2  0.3340     0.8698 0.000 0.880 0.120
#> SRR037220     3  0.6309    -0.1364 0.500 0.000 0.500
#> SRR037221     3  0.6309    -0.1364 0.500 0.000 0.500
#> SRR037222     1  0.6309    -0.0447 0.500 0.000 0.500
#> SRR037223     3  0.6309    -0.1364 0.500 0.000 0.500
#> SRR037224     3  0.6309    -0.1364 0.500 0.000 0.500
#> SRR037225     1  0.6309    -0.0447 0.500 0.000 0.500
#> SRR037226     1  0.6309    -0.0447 0.500 0.000 0.500

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette p1    p2   p3    p4
#> SRR037165     2  0.3649      0.826  0 0.796 0.00 0.204
#> SRR037166     2  0.3649      0.826  0 0.796 0.00 0.204
#> SRR037167     2  0.3649      0.826  0 0.796 0.00 0.204
#> SRR037168     4  0.0000      1.000  0 0.000 0.00 1.000
#> SRR037169     4  0.0000      1.000  0 0.000 0.00 1.000
#> SRR037170     4  0.0000      1.000  0 0.000 0.00 1.000
#> SRR037171     2  0.0000      0.909  0 1.000 0.00 0.000
#> SRR037172     2  0.0000      0.909  0 1.000 0.00 0.000
#> SRR037173     2  0.0000      0.909  0 1.000 0.00 0.000
#> SRR037174     2  0.0000      0.909  0 1.000 0.00 0.000
#> SRR037175     2  0.0000      0.909  0 1.000 0.00 0.000
#> SRR037176     2  0.0000      0.909  0 1.000 0.00 0.000
#> SRR037177     2  0.0592      0.911  0 0.984 0.00 0.016
#> SRR037182     3  0.4790      0.547  0 0.000 0.62 0.380
#> SRR037183     3  0.4790      0.547  0 0.000 0.62 0.380
#> SRR037184     2  0.0592      0.911  0 0.984 0.00 0.016
#> SRR037185     2  0.0592      0.911  0 0.984 0.00 0.016
#> SRR037186     2  0.0592      0.911  0 0.984 0.00 0.016
#> SRR037187     2  0.0592      0.911  0 0.984 0.00 0.016
#> SRR037188     3  0.4790      0.547  0 0.000 0.62 0.380
#> SRR037178     3  0.0000      0.872  0 0.000 1.00 0.000
#> SRR037179     3  0.0000      0.872  0 0.000 1.00 0.000
#> SRR037180     3  0.0000      0.872  0 0.000 1.00 0.000
#> SRR037181     3  0.0000      0.872  0 0.000 1.00 0.000
#> SRR037189     2  0.0592      0.911  0 0.984 0.00 0.016
#> SRR037190     2  0.0000      0.909  0 1.000 0.00 0.000
#> SRR037191     2  0.0000      0.909  0 1.000 0.00 0.000
#> SRR037192     2  0.0592      0.911  0 0.984 0.00 0.016
#> SRR037193     2  0.3649      0.826  0 0.796 0.00 0.204
#> SRR037194     2  0.3649      0.826  0 0.796 0.00 0.204
#> SRR037195     2  0.3649      0.826  0 0.796 0.00 0.204
#> SRR037196     2  0.4356      0.723  0 0.708 0.00 0.292
#> SRR037197     4  0.0000      1.000  0 0.000 0.00 1.000
#> SRR037198     2  0.4356      0.723  0 0.708 0.00 0.292
#> SRR037199     1  0.0000      1.000  1 0.000 0.00 0.000
#> SRR037200     1  0.0000      1.000  1 0.000 0.00 0.000
#> SRR037201     1  0.0000      1.000  1 0.000 0.00 0.000
#> SRR037202     1  0.0000      1.000  1 0.000 0.00 0.000
#> SRR037203     1  0.0000      1.000  1 0.000 0.00 0.000
#> SRR037204     1  0.0000      1.000  1 0.000 0.00 0.000
#> SRR037205     1  0.0000      1.000  1 0.000 0.00 0.000
#> SRR037206     3  0.0000      0.872  0 0.000 1.00 0.000
#> SRR037207     3  0.0000      0.872  0 0.000 1.00 0.000
#> SRR037208     3  0.0000      0.872  0 0.000 1.00 0.000
#> SRR037209     3  0.0000      0.872  0 0.000 1.00 0.000
#> SRR037210     3  0.0000      0.872  0 0.000 1.00 0.000
#> SRR037211     3  0.0000      0.872  0 0.000 1.00 0.000
#> SRR037212     3  0.4790      0.547  0 0.000 0.62 0.380
#> SRR037213     3  0.4790      0.547  0 0.000 0.62 0.380
#> SRR037219     3  0.4790      0.547  0 0.000 0.62 0.380
#> SRR037214     3  0.0000      0.872  0 0.000 1.00 0.000
#> SRR037215     3  0.0000      0.872  0 0.000 1.00 0.000
#> SRR037216     3  0.0000      0.872  0 0.000 1.00 0.000
#> SRR037217     3  0.0000      0.872  0 0.000 1.00 0.000
#> SRR037218     3  0.0000      0.872  0 0.000 1.00 0.000
#> SRR037220     1  0.0000      1.000  1 0.000 0.00 0.000
#> SRR037221     1  0.0000      1.000  1 0.000 0.00 0.000
#> SRR037222     1  0.0000      1.000  1 0.000 0.00 0.000
#> SRR037223     1  0.0000      1.000  1 0.000 0.00 0.000
#> SRR037224     1  0.0000      1.000  1 0.000 0.00 0.000
#> SRR037225     1  0.0000      1.000  1 0.000 0.00 0.000
#> SRR037226     1  0.0000      1.000  1 0.000 0.00 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
#> SRR037165     2  0.3109      0.829 0.000 0.800 0.00 0.200 0.000
#> SRR037166     2  0.3109      0.829 0.000 0.800 0.00 0.200 0.000
#> SRR037167     2  0.3109      0.829 0.000 0.800 0.00 0.200 0.000
#> SRR037168     4  0.0000      0.983 0.000 0.000 0.00 1.000 0.000
#> SRR037169     4  0.0000      0.983 0.000 0.000 0.00 1.000 0.000
#> SRR037170     4  0.0000      0.983 0.000 0.000 0.00 1.000 0.000
#> SRR037171     2  0.0162      0.913 0.000 0.996 0.00 0.000 0.004
#> SRR037172     2  0.0162      0.913 0.000 0.996 0.00 0.000 0.004
#> SRR037173     2  0.0162      0.913 0.000 0.996 0.00 0.000 0.004
#> SRR037174     2  0.0162      0.913 0.000 0.996 0.00 0.000 0.004
#> SRR037175     2  0.0162      0.913 0.000 0.996 0.00 0.000 0.004
#> SRR037176     2  0.0162      0.913 0.000 0.996 0.00 0.000 0.004
#> SRR037177     2  0.0404      0.915 0.000 0.988 0.00 0.012 0.000
#> SRR037182     3  0.4126      0.543 0.000 0.000 0.62 0.380 0.000
#> SRR037183     3  0.4126      0.543 0.000 0.000 0.62 0.380 0.000
#> SRR037184     2  0.0404      0.915 0.000 0.988 0.00 0.012 0.000
#> SRR037185     2  0.0404      0.915 0.000 0.988 0.00 0.012 0.000
#> SRR037186     2  0.0404      0.915 0.000 0.988 0.00 0.012 0.000
#> SRR037187     2  0.0404      0.915 0.000 0.988 0.00 0.012 0.000
#> SRR037188     3  0.4126      0.543 0.000 0.000 0.62 0.380 0.000
#> SRR037178     3  0.0000      0.871 0.000 0.000 1.00 0.000 0.000
#> SRR037179     3  0.0000      0.871 0.000 0.000 1.00 0.000 0.000
#> SRR037180     3  0.0000      0.871 0.000 0.000 1.00 0.000 0.000
#> SRR037181     3  0.0000      0.871 0.000 0.000 1.00 0.000 0.000
#> SRR037189     2  0.0404      0.915 0.000 0.988 0.00 0.012 0.000
#> SRR037190     2  0.0162      0.913 0.000 0.996 0.00 0.000 0.004
#> SRR037191     2  0.0162      0.913 0.000 0.996 0.00 0.000 0.004
#> SRR037192     2  0.0404      0.915 0.000 0.988 0.00 0.012 0.000
#> SRR037193     2  0.3794      0.831 0.000 0.800 0.00 0.152 0.048
#> SRR037194     2  0.3794      0.831 0.000 0.800 0.00 0.152 0.048
#> SRR037195     2  0.3794      0.831 0.000 0.800 0.00 0.152 0.048
#> SRR037196     2  0.4536      0.732 0.000 0.712 0.00 0.240 0.048
#> SRR037197     4  0.1357      0.950 0.000 0.004 0.00 0.948 0.048
#> SRR037198     2  0.4536      0.732 0.000 0.712 0.00 0.240 0.048
#> SRR037199     1  0.0000      1.000 1.000 0.000 0.00 0.000 0.000
#> SRR037200     1  0.0000      1.000 1.000 0.000 0.00 0.000 0.000
#> SRR037201     1  0.0000      1.000 1.000 0.000 0.00 0.000 0.000
#> SRR037202     1  0.0000      1.000 1.000 0.000 0.00 0.000 0.000
#> SRR037203     1  0.0000      1.000 1.000 0.000 0.00 0.000 0.000
#> SRR037204     1  0.0000      1.000 1.000 0.000 0.00 0.000 0.000
#> SRR037205     1  0.0000      1.000 1.000 0.000 0.00 0.000 0.000
#> SRR037206     3  0.0000      0.871 0.000 0.000 1.00 0.000 0.000
#> SRR037207     3  0.0000      0.871 0.000 0.000 1.00 0.000 0.000
#> SRR037208     3  0.0000      0.871 0.000 0.000 1.00 0.000 0.000
#> SRR037209     3  0.0000      0.871 0.000 0.000 1.00 0.000 0.000
#> SRR037210     3  0.0000      0.871 0.000 0.000 1.00 0.000 0.000
#> SRR037211     3  0.0000      0.871 0.000 0.000 1.00 0.000 0.000
#> SRR037212     3  0.4126      0.543 0.000 0.000 0.62 0.380 0.000
#> SRR037213     3  0.4126      0.543 0.000 0.000 0.62 0.380 0.000
#> SRR037219     3  0.4126      0.543 0.000 0.000 0.62 0.380 0.000
#> SRR037214     3  0.0000      0.871 0.000 0.000 1.00 0.000 0.000
#> SRR037215     3  0.0000      0.871 0.000 0.000 1.00 0.000 0.000
#> SRR037216     3  0.0000      0.871 0.000 0.000 1.00 0.000 0.000
#> SRR037217     3  0.0000      0.871 0.000 0.000 1.00 0.000 0.000
#> SRR037218     3  0.0000      0.871 0.000 0.000 1.00 0.000 0.000
#> SRR037220     5  0.1270      1.000 0.052 0.000 0.00 0.000 0.948
#> SRR037221     5  0.1270      1.000 0.052 0.000 0.00 0.000 0.948
#> SRR037222     5  0.1270      1.000 0.052 0.000 0.00 0.000 0.948
#> SRR037223     5  0.1270      1.000 0.052 0.000 0.00 0.000 0.948
#> SRR037224     5  0.1270      1.000 0.052 0.000 0.00 0.000 0.948
#> SRR037225     5  0.1270      1.000 0.052 0.000 0.00 0.000 0.948
#> SRR037226     5  0.1270      1.000 0.052 0.000 0.00 0.000 0.948

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette p1    p2   p3    p4 p5    p6
#> SRR037165     4  0.2697      0.805  0 0.000 0.00 0.812  0 0.188
#> SRR037166     4  0.2697      0.805  0 0.000 0.00 0.812  0 0.188
#> SRR037167     4  0.2697      0.805  0 0.000 0.00 0.812  0 0.188
#> SRR037168     6  0.0146      0.933  0 0.000 0.00 0.004  0 0.996
#> SRR037169     6  0.0146      0.933  0 0.000 0.00 0.004  0 0.996
#> SRR037170     6  0.0146      0.933  0 0.000 0.00 0.004  0 0.996
#> SRR037171     2  0.0000      1.000  0 1.000 0.00 0.000  0 0.000
#> SRR037172     2  0.0000      1.000  0 1.000 0.00 0.000  0 0.000
#> SRR037173     2  0.0000      1.000  0 1.000 0.00 0.000  0 0.000
#> SRR037174     2  0.0000      1.000  0 1.000 0.00 0.000  0 0.000
#> SRR037175     2  0.0000      1.000  0 1.000 0.00 0.000  0 0.000
#> SRR037176     2  0.0000      1.000  0 1.000 0.00 0.000  0 0.000
#> SRR037177     4  0.2697      0.863  0 0.188 0.00 0.812  0 0.000
#> SRR037182     3  0.3706      0.536  0 0.000 0.62 0.000  0 0.380
#> SRR037183     3  0.3706      0.536  0 0.000 0.62 0.000  0 0.380
#> SRR037184     4  0.2697      0.863  0 0.188 0.00 0.812  0 0.000
#> SRR037185     4  0.2697      0.863  0 0.188 0.00 0.812  0 0.000
#> SRR037186     4  0.2697      0.863  0 0.188 0.00 0.812  0 0.000
#> SRR037187     4  0.2697      0.863  0 0.188 0.00 0.812  0 0.000
#> SRR037188     3  0.3706      0.536  0 0.000 0.62 0.000  0 0.380
#> SRR037178     3  0.0000      0.869  0 0.000 1.00 0.000  0 0.000
#> SRR037179     3  0.0000      0.869  0 0.000 1.00 0.000  0 0.000
#> SRR037180     3  0.0000      0.869  0 0.000 1.00 0.000  0 0.000
#> SRR037181     3  0.0000      0.869  0 0.000 1.00 0.000  0 0.000
#> SRR037189     4  0.2697      0.863  0 0.188 0.00 0.812  0 0.000
#> SRR037190     2  0.0000      1.000  0 1.000 0.00 0.000  0 0.000
#> SRR037191     2  0.0000      1.000  0 1.000 0.00 0.000  0 0.000
#> SRR037192     4  0.2697      0.863  0 0.188 0.00 0.812  0 0.000
#> SRR037193     4  0.0146      0.827  0 0.000 0.00 0.996  0 0.004
#> SRR037194     4  0.0146      0.827  0 0.000 0.00 0.996  0 0.004
#> SRR037195     4  0.0146      0.827  0 0.000 0.00 0.996  0 0.004
#> SRR037196     4  0.1714      0.760  0 0.000 0.00 0.908  0 0.092
#> SRR037197     6  0.2793      0.793  0 0.000 0.00 0.200  0 0.800
#> SRR037198     4  0.1714      0.760  0 0.000 0.00 0.908  0 0.092
#> SRR037199     1  0.0000      1.000  1 0.000 0.00 0.000  0 0.000
#> SRR037200     1  0.0000      1.000  1 0.000 0.00 0.000  0 0.000
#> SRR037201     1  0.0000      1.000  1 0.000 0.00 0.000  0 0.000
#> SRR037202     1  0.0000      1.000  1 0.000 0.00 0.000  0 0.000
#> SRR037203     1  0.0000      1.000  1 0.000 0.00 0.000  0 0.000
#> SRR037204     1  0.0000      1.000  1 0.000 0.00 0.000  0 0.000
#> SRR037205     1  0.0000      1.000  1 0.000 0.00 0.000  0 0.000
#> SRR037206     3  0.0000      0.869  0 0.000 1.00 0.000  0 0.000
#> SRR037207     3  0.0000      0.869  0 0.000 1.00 0.000  0 0.000
#> SRR037208     3  0.0000      0.869  0 0.000 1.00 0.000  0 0.000
#> SRR037209     3  0.0000      0.869  0 0.000 1.00 0.000  0 0.000
#> SRR037210     3  0.0000      0.869  0 0.000 1.00 0.000  0 0.000
#> SRR037211     3  0.0000      0.869  0 0.000 1.00 0.000  0 0.000
#> SRR037212     3  0.3706      0.536  0 0.000 0.62 0.000  0 0.380
#> SRR037213     3  0.3706      0.536  0 0.000 0.62 0.000  0 0.380
#> SRR037219     3  0.3706      0.536  0 0.000 0.62 0.000  0 0.380
#> SRR037214     3  0.0000      0.869  0 0.000 1.00 0.000  0 0.000
#> SRR037215     3  0.0000      0.869  0 0.000 1.00 0.000  0 0.000
#> SRR037216     3  0.0000      0.869  0 0.000 1.00 0.000  0 0.000
#> SRR037217     3  0.0000      0.869  0 0.000 1.00 0.000  0 0.000
#> SRR037218     3  0.0000      0.869  0 0.000 1.00 0.000  0 0.000
#> SRR037220     5  0.0000      1.000  0 0.000 0.00 0.000  1 0.000
#> SRR037221     5  0.0000      1.000  0 0.000 0.00 0.000  1 0.000
#> SRR037222     5  0.0000      1.000  0 0.000 0.00 0.000  1 0.000
#> SRR037223     5  0.0000      1.000  0 0.000 0.00 0.000  1 0.000
#> SRR037224     5  0.0000      1.000  0 0.000 0.00 0.000  1 0.000
#> SRR037225     5  0.0000      1.000  0 0.000 0.00 0.000  1 0.000
#> SRR037226     5  0.0000      1.000  0 0.000 0.00 0.000  1 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-hclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-hclust-collect-classes

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


SD:kmeans

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

res = res_list["SD", "kmeans"]
# you can also extract it by
# res = res_list["SD:kmeans"]

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

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

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

collect_plots(res)

plot of chunk SD-kmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.545           0.798       0.867         0.4082 0.645   0.645
#> 3 3 0.705           0.936       0.905         0.5505 0.700   0.535
#> 4 4 0.789           0.891       0.865         0.1521 0.905   0.724
#> 5 5 0.765           0.823       0.824         0.0694 1.000   1.000
#> 6 6 0.809           0.647       0.725         0.0450 0.986   0.943

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

suggest_best_k(res)
#> [1] 3

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> SRR037165     2   0.000      0.805 0.000 1.000
#> SRR037166     2   0.000      0.805 0.000 1.000
#> SRR037167     2   0.000      0.805 0.000 1.000
#> SRR037168     2   0.000      0.805 0.000 1.000
#> SRR037169     2   0.000      0.805 0.000 1.000
#> SRR037170     2   0.000      0.805 0.000 1.000
#> SRR037171     2   0.000      0.805 0.000 1.000
#> SRR037172     2   0.000      0.805 0.000 1.000
#> SRR037173     2   0.000      0.805 0.000 1.000
#> SRR037174     2   0.000      0.805 0.000 1.000
#> SRR037175     2   0.000      0.805 0.000 1.000
#> SRR037176     2   0.000      0.805 0.000 1.000
#> SRR037177     2   0.000      0.805 0.000 1.000
#> SRR037182     2   0.943      0.692 0.360 0.640
#> SRR037183     2   0.943      0.692 0.360 0.640
#> SRR037184     2   0.000      0.805 0.000 1.000
#> SRR037185     2   0.000      0.805 0.000 1.000
#> SRR037186     2   0.000      0.805 0.000 1.000
#> SRR037187     2   0.000      0.805 0.000 1.000
#> SRR037188     2   0.943      0.692 0.360 0.640
#> SRR037178     2   0.943      0.692 0.360 0.640
#> SRR037179     2   0.943      0.692 0.360 0.640
#> SRR037180     2   0.943      0.692 0.360 0.640
#> SRR037181     2   0.943      0.692 0.360 0.640
#> SRR037189     2   0.000      0.805 0.000 1.000
#> SRR037190     2   0.000      0.805 0.000 1.000
#> SRR037191     2   0.000      0.805 0.000 1.000
#> SRR037192     2   0.000      0.805 0.000 1.000
#> SRR037193     2   0.000      0.805 0.000 1.000
#> SRR037194     2   0.000      0.805 0.000 1.000
#> SRR037195     2   0.000      0.805 0.000 1.000
#> SRR037196     2   0.000      0.805 0.000 1.000
#> SRR037197     2   0.000      0.805 0.000 1.000
#> SRR037198     2   0.000      0.805 0.000 1.000
#> SRR037199     1   0.118      0.947 0.984 0.016
#> SRR037200     1   0.118      0.947 0.984 0.016
#> SRR037201     1   0.118      0.947 0.984 0.016
#> SRR037202     1   0.118      0.947 0.984 0.016
#> SRR037203     1   0.118      0.947 0.984 0.016
#> SRR037204     1   0.118      0.947 0.984 0.016
#> SRR037205     1   0.118      0.947 0.984 0.016
#> SRR037206     2   0.946      0.689 0.364 0.636
#> SRR037207     2   0.946      0.689 0.364 0.636
#> SRR037208     2   0.946      0.689 0.364 0.636
#> SRR037209     2   0.946      0.689 0.364 0.636
#> SRR037210     2   0.946      0.689 0.364 0.636
#> SRR037211     2   0.946      0.689 0.364 0.636
#> SRR037212     2   0.946      0.689 0.364 0.636
#> SRR037213     2   0.946      0.689 0.364 0.636
#> SRR037219     2   0.946      0.689 0.364 0.636
#> SRR037214     2   0.946      0.689 0.364 0.636
#> SRR037215     2   0.946      0.689 0.364 0.636
#> SRR037216     2   0.946      0.689 0.364 0.636
#> SRR037217     2   0.946      0.689 0.364 0.636
#> SRR037218     2   0.946      0.689 0.364 0.636
#> SRR037220     1   0.430      0.946 0.912 0.088
#> SRR037221     1   0.430      0.946 0.912 0.088
#> SRR037222     1   0.430      0.946 0.912 0.088
#> SRR037223     1   0.430      0.946 0.912 0.088
#> SRR037224     1   0.430      0.946 0.912 0.088
#> SRR037225     1   0.430      0.946 0.912 0.088
#> SRR037226     1   0.430      0.946 0.912 0.088

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> SRR037165     2  0.1170      0.921 0.008 0.976 0.016
#> SRR037166     2  0.1170      0.921 0.008 0.976 0.016
#> SRR037167     2  0.0848      0.919 0.008 0.984 0.008
#> SRR037168     2  0.1015      0.914 0.008 0.980 0.012
#> SRR037169     2  0.1015      0.914 0.008 0.980 0.012
#> SRR037170     2  0.1015      0.914 0.008 0.980 0.012
#> SRR037171     2  0.5576      0.894 0.084 0.812 0.104
#> SRR037172     2  0.5576      0.894 0.084 0.812 0.104
#> SRR037173     2  0.5576      0.894 0.084 0.812 0.104
#> SRR037174     2  0.5576      0.894 0.084 0.812 0.104
#> SRR037175     2  0.5576      0.894 0.084 0.812 0.104
#> SRR037176     2  0.5576      0.894 0.084 0.812 0.104
#> SRR037177     2  0.3120      0.926 0.080 0.908 0.012
#> SRR037182     3  0.3879      0.902 0.000 0.152 0.848
#> SRR037183     3  0.3879      0.902 0.000 0.152 0.848
#> SRR037184     2  0.3359      0.926 0.084 0.900 0.016
#> SRR037185     2  0.3120      0.926 0.080 0.908 0.012
#> SRR037186     2  0.3359      0.926 0.084 0.900 0.016
#> SRR037187     2  0.3359      0.926 0.084 0.900 0.016
#> SRR037188     3  0.3879      0.902 0.000 0.152 0.848
#> SRR037178     3  0.2261      0.957 0.000 0.068 0.932
#> SRR037179     3  0.2261      0.957 0.000 0.068 0.932
#> SRR037180     3  0.2261      0.957 0.000 0.068 0.932
#> SRR037181     3  0.2261      0.957 0.000 0.068 0.932
#> SRR037189     2  0.3359      0.926 0.084 0.900 0.016
#> SRR037190     2  0.5576      0.894 0.084 0.812 0.104
#> SRR037191     2  0.5576      0.894 0.084 0.812 0.104
#> SRR037192     2  0.3359      0.926 0.084 0.900 0.016
#> SRR037193     2  0.1964      0.919 0.000 0.944 0.056
#> SRR037194     2  0.0892      0.923 0.000 0.980 0.020
#> SRR037195     2  0.0892      0.923 0.000 0.980 0.020
#> SRR037196     2  0.0892      0.919 0.000 0.980 0.020
#> SRR037197     2  0.1015      0.914 0.008 0.980 0.012
#> SRR037198     2  0.0892      0.919 0.000 0.980 0.020
#> SRR037199     1  0.3941      0.973 0.844 0.000 0.156
#> SRR037200     1  0.3941      0.973 0.844 0.000 0.156
#> SRR037201     1  0.3941      0.973 0.844 0.000 0.156
#> SRR037202     1  0.3941      0.973 0.844 0.000 0.156
#> SRR037203     1  0.3941      0.973 0.844 0.000 0.156
#> SRR037204     1  0.3941      0.973 0.844 0.000 0.156
#> SRR037205     1  0.3941      0.973 0.844 0.000 0.156
#> SRR037206     3  0.2261      0.957 0.000 0.068 0.932
#> SRR037207     3  0.2261      0.957 0.000 0.068 0.932
#> SRR037208     3  0.2165      0.958 0.000 0.064 0.936
#> SRR037209     3  0.2165      0.958 0.000 0.064 0.936
#> SRR037210     3  0.2261      0.957 0.000 0.068 0.932
#> SRR037211     3  0.2261      0.957 0.000 0.068 0.932
#> SRR037212     3  0.3879      0.902 0.000 0.152 0.848
#> SRR037213     3  0.3879      0.902 0.000 0.152 0.848
#> SRR037219     3  0.3879      0.902 0.000 0.152 0.848
#> SRR037214     3  0.2165      0.949 0.000 0.064 0.936
#> SRR037215     3  0.2165      0.958 0.000 0.064 0.936
#> SRR037216     3  0.2261      0.957 0.000 0.068 0.932
#> SRR037217     3  0.2165      0.958 0.000 0.064 0.936
#> SRR037218     3  0.2165      0.958 0.000 0.064 0.936
#> SRR037220     1  0.3030      0.973 0.904 0.004 0.092
#> SRR037221     1  0.3030      0.973 0.904 0.004 0.092
#> SRR037222     1  0.3030      0.973 0.904 0.004 0.092
#> SRR037223     1  0.3030      0.973 0.904 0.004 0.092
#> SRR037224     1  0.3030      0.973 0.904 0.004 0.092
#> SRR037225     1  0.3030      0.973 0.904 0.004 0.092
#> SRR037226     1  0.3030      0.973 0.904 0.004 0.092

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> SRR037165     4  0.3390      0.806 0.000 0.132 0.016 0.852
#> SRR037166     4  0.3390      0.806 0.000 0.132 0.016 0.852
#> SRR037167     4  0.0672      0.906 0.000 0.008 0.008 0.984
#> SRR037168     4  0.0524      0.905 0.000 0.004 0.008 0.988
#> SRR037169     4  0.0524      0.905 0.000 0.004 0.008 0.988
#> SRR037170     4  0.0524      0.905 0.000 0.004 0.008 0.988
#> SRR037171     2  0.5267      0.923 0.000 0.712 0.048 0.240
#> SRR037172     2  0.5267      0.923 0.000 0.712 0.048 0.240
#> SRR037173     2  0.5298      0.924 0.000 0.708 0.048 0.244
#> SRR037174     2  0.5298      0.924 0.000 0.708 0.048 0.244
#> SRR037175     2  0.5267      0.923 0.000 0.712 0.048 0.240
#> SRR037176     2  0.5267      0.923 0.000 0.712 0.048 0.240
#> SRR037177     2  0.5756      0.681 0.012 0.552 0.012 0.424
#> SRR037182     3  0.4332      0.814 0.000 0.032 0.792 0.176
#> SRR037183     3  0.4332      0.814 0.000 0.032 0.792 0.176
#> SRR037184     2  0.5348      0.910 0.012 0.692 0.020 0.276
#> SRR037185     2  0.5756      0.681 0.012 0.552 0.012 0.424
#> SRR037186     2  0.5348      0.910 0.012 0.692 0.020 0.276
#> SRR037187     2  0.5348      0.910 0.012 0.692 0.020 0.276
#> SRR037188     3  0.4332      0.814 0.000 0.032 0.792 0.176
#> SRR037178     3  0.0469      0.915 0.000 0.012 0.988 0.000
#> SRR037179     3  0.0469      0.915 0.000 0.012 0.988 0.000
#> SRR037180     3  0.0469      0.915 0.000 0.012 0.988 0.000
#> SRR037181     3  0.0469      0.915 0.000 0.012 0.988 0.000
#> SRR037189     2  0.5348      0.910 0.012 0.692 0.020 0.276
#> SRR037190     2  0.5298      0.924 0.000 0.708 0.048 0.244
#> SRR037191     2  0.5267      0.923 0.000 0.712 0.048 0.240
#> SRR037192     2  0.5348      0.910 0.012 0.692 0.020 0.276
#> SRR037193     4  0.3824      0.842 0.008 0.104 0.036 0.852
#> SRR037194     4  0.3238      0.869 0.008 0.092 0.020 0.880
#> SRR037195     4  0.3238      0.869 0.008 0.092 0.020 0.880
#> SRR037196     4  0.1394      0.902 0.008 0.016 0.012 0.964
#> SRR037197     4  0.1486      0.880 0.008 0.024 0.008 0.960
#> SRR037198     4  0.1394      0.902 0.008 0.016 0.012 0.964
#> SRR037199     1  0.0895      0.919 0.976 0.004 0.020 0.000
#> SRR037200     1  0.0895      0.919 0.976 0.004 0.020 0.000
#> SRR037201     1  0.0895      0.919 0.976 0.004 0.020 0.000
#> SRR037202     1  0.0707      0.919 0.980 0.000 0.020 0.000
#> SRR037203     1  0.0707      0.919 0.980 0.000 0.020 0.000
#> SRR037204     1  0.0707      0.919 0.980 0.000 0.020 0.000
#> SRR037205     1  0.0707      0.919 0.980 0.000 0.020 0.000
#> SRR037206     3  0.1867      0.910 0.000 0.072 0.928 0.000
#> SRR037207     3  0.1867      0.910 0.000 0.072 0.928 0.000
#> SRR037208     3  0.1716      0.912 0.000 0.064 0.936 0.000
#> SRR037209     3  0.1716      0.912 0.000 0.064 0.936 0.000
#> SRR037210     3  0.1867      0.910 0.000 0.072 0.928 0.000
#> SRR037211     3  0.1867      0.910 0.000 0.072 0.928 0.000
#> SRR037212     3  0.4105      0.829 0.000 0.032 0.812 0.156
#> SRR037213     3  0.4105      0.829 0.000 0.032 0.812 0.156
#> SRR037219     3  0.4332      0.814 0.000 0.032 0.792 0.176
#> SRR037214     3  0.1356      0.904 0.000 0.032 0.960 0.008
#> SRR037215     3  0.1716      0.912 0.000 0.064 0.936 0.000
#> SRR037216     3  0.1867      0.910 0.000 0.072 0.928 0.000
#> SRR037217     3  0.0188      0.914 0.000 0.004 0.996 0.000
#> SRR037218     3  0.0188      0.914 0.000 0.004 0.996 0.000
#> SRR037220     1  0.4284      0.918 0.780 0.200 0.020 0.000
#> SRR037221     1  0.4284      0.918 0.780 0.200 0.020 0.000
#> SRR037222     1  0.4284      0.918 0.780 0.200 0.020 0.000
#> SRR037223     1  0.4486      0.918 0.784 0.188 0.020 0.008
#> SRR037224     1  0.4486      0.918 0.784 0.188 0.020 0.008
#> SRR037225     1  0.4284      0.918 0.780 0.200 0.020 0.000
#> SRR037226     1  0.4486      0.918 0.784 0.188 0.020 0.008

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> SRR037165     4  0.4519      0.818 0.000 0.148 0.000 0.752 0.100
#> SRR037166     4  0.4519      0.818 0.000 0.148 0.000 0.752 0.100
#> SRR037167     4  0.3992      0.844 0.000 0.080 0.000 0.796 0.124
#> SRR037168     4  0.5081      0.837 0.000 0.080 0.032 0.740 0.148
#> SRR037169     4  0.5081      0.837 0.000 0.080 0.032 0.740 0.148
#> SRR037170     4  0.5081      0.837 0.000 0.080 0.032 0.740 0.148
#> SRR037171     2  0.0404      0.918 0.000 0.988 0.012 0.000 0.000
#> SRR037172     2  0.0404      0.918 0.000 0.988 0.012 0.000 0.000
#> SRR037173     2  0.0404      0.918 0.000 0.988 0.012 0.000 0.000
#> SRR037174     2  0.0404      0.918 0.000 0.988 0.012 0.000 0.000
#> SRR037175     2  0.0404      0.918 0.000 0.988 0.012 0.000 0.000
#> SRR037176     2  0.0404      0.918 0.000 0.988 0.012 0.000 0.000
#> SRR037177     2  0.4911      0.768 0.012 0.744 0.004 0.160 0.080
#> SRR037182     3  0.2237      0.643 0.008 0.004 0.904 0.084 0.000
#> SRR037183     3  0.2237      0.643 0.008 0.004 0.904 0.084 0.000
#> SRR037184     2  0.3089      0.898 0.012 0.872 0.000 0.040 0.076
#> SRR037185     2  0.4911      0.768 0.012 0.744 0.004 0.160 0.080
#> SRR037186     2  0.3089      0.898 0.012 0.872 0.000 0.040 0.076
#> SRR037187     2  0.3089      0.898 0.012 0.872 0.000 0.040 0.076
#> SRR037188     3  0.2237      0.643 0.008 0.004 0.904 0.084 0.000
#> SRR037178     3  0.3707      0.816 0.000 0.000 0.716 0.000 0.284
#> SRR037179     3  0.3707      0.816 0.000 0.000 0.716 0.000 0.284
#> SRR037180     3  0.3707      0.816 0.000 0.000 0.716 0.000 0.284
#> SRR037181     3  0.3707      0.816 0.000 0.000 0.716 0.000 0.284
#> SRR037189     2  0.3089      0.898 0.012 0.872 0.000 0.040 0.076
#> SRR037190     2  0.0404      0.918 0.000 0.988 0.012 0.000 0.000
#> SRR037191     2  0.0404      0.918 0.000 0.988 0.012 0.000 0.000
#> SRR037192     2  0.3089      0.898 0.012 0.872 0.000 0.040 0.076
#> SRR037193     4  0.5029      0.821 0.000 0.156 0.104 0.728 0.012
#> SRR037194     4  0.4902      0.828 0.000 0.148 0.100 0.740 0.012
#> SRR037195     4  0.4902      0.828 0.000 0.148 0.100 0.740 0.012
#> SRR037196     4  0.4351      0.842 0.000 0.104 0.104 0.784 0.008
#> SRR037197     4  0.5174      0.830 0.000 0.076 0.128 0.744 0.052
#> SRR037198     4  0.4351      0.842 0.000 0.104 0.104 0.784 0.008
#> SRR037199     1  0.1356      0.837 0.956 0.004 0.012 0.028 0.000
#> SRR037200     1  0.1356      0.837 0.956 0.004 0.012 0.028 0.000
#> SRR037201     1  0.1356      0.837 0.956 0.004 0.012 0.028 0.000
#> SRR037202     1  0.0404      0.837 0.988 0.000 0.012 0.000 0.000
#> SRR037203     1  0.0404      0.837 0.988 0.000 0.012 0.000 0.000
#> SRR037204     1  0.0404      0.837 0.988 0.000 0.012 0.000 0.000
#> SRR037205     1  0.0404      0.837 0.988 0.000 0.012 0.000 0.000
#> SRR037206     3  0.4283      0.798 0.000 0.000 0.544 0.000 0.456
#> SRR037207     3  0.4283      0.798 0.000 0.000 0.544 0.000 0.456
#> SRR037208     3  0.4268      0.799 0.000 0.000 0.556 0.000 0.444
#> SRR037209     3  0.4268      0.799 0.000 0.000 0.556 0.000 0.444
#> SRR037210     3  0.4283      0.798 0.000 0.000 0.544 0.000 0.456
#> SRR037211     3  0.4283      0.798 0.000 0.000 0.544 0.000 0.456
#> SRR037212     3  0.2054      0.655 0.008 0.004 0.916 0.072 0.000
#> SRR037213     3  0.2054      0.655 0.008 0.004 0.916 0.072 0.000
#> SRR037219     3  0.2237      0.643 0.008 0.004 0.904 0.084 0.000
#> SRR037214     3  0.2068      0.753 0.000 0.004 0.904 0.000 0.092
#> SRR037215     3  0.4268      0.799 0.000 0.000 0.556 0.000 0.444
#> SRR037216     3  0.4283      0.798 0.000 0.000 0.544 0.000 0.456
#> SRR037217     3  0.3612      0.814 0.000 0.000 0.732 0.000 0.268
#> SRR037218     3  0.3612      0.814 0.000 0.000 0.732 0.000 0.268
#> SRR037220     1  0.4992      0.840 0.640 0.000 0.012 0.028 0.320
#> SRR037221     1  0.4992      0.840 0.640 0.000 0.012 0.028 0.320
#> SRR037222     1  0.4992      0.840 0.640 0.000 0.012 0.028 0.320
#> SRR037223     1  0.5340      0.839 0.640 0.004 0.012 0.044 0.300
#> SRR037224     1  0.5340      0.839 0.640 0.004 0.012 0.044 0.300
#> SRR037225     1  0.4992      0.840 0.640 0.000 0.012 0.028 0.320
#> SRR037226     1  0.5340      0.839 0.640 0.004 0.012 0.044 0.300

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5 p6
#> SRR037165     4  0.3089      0.504 0.000 0.080 0.000 0.856 0.040 NA
#> SRR037166     4  0.3089      0.504 0.000 0.080 0.000 0.856 0.040 NA
#> SRR037167     4  0.1635      0.558 0.000 0.020 0.000 0.940 0.020 NA
#> SRR037168     4  0.1275      0.571 0.000 0.016 0.000 0.956 0.016 NA
#> SRR037169     4  0.1275      0.571 0.000 0.016 0.000 0.956 0.016 NA
#> SRR037170     4  0.1275      0.571 0.000 0.016 0.000 0.956 0.016 NA
#> SRR037171     2  0.3748      0.834 0.000 0.688 0.012 0.000 0.000 NA
#> SRR037172     2  0.3748      0.834 0.000 0.688 0.012 0.000 0.000 NA
#> SRR037173     2  0.3748      0.834 0.000 0.688 0.012 0.000 0.000 NA
#> SRR037174     2  0.3748      0.834 0.000 0.688 0.012 0.000 0.000 NA
#> SRR037175     2  0.3748      0.834 0.000 0.688 0.012 0.000 0.000 NA
#> SRR037176     2  0.4029      0.832 0.000 0.688 0.012 0.000 0.012 NA
#> SRR037177     2  0.2062      0.717 0.000 0.900 0.000 0.088 0.008 NA
#> SRR037182     3  0.4949      0.486 0.000 0.004 0.488 0.036 0.464 NA
#> SRR037183     3  0.4949      0.486 0.000 0.004 0.488 0.036 0.464 NA
#> SRR037184     2  0.0508      0.793 0.000 0.984 0.000 0.012 0.004 NA
#> SRR037185     2  0.2062      0.717 0.000 0.900 0.000 0.088 0.008 NA
#> SRR037186     2  0.0508      0.793 0.000 0.984 0.000 0.012 0.004 NA
#> SRR037187     2  0.0508      0.793 0.000 0.984 0.000 0.012 0.004 NA
#> SRR037188     3  0.4949      0.486 0.000 0.004 0.488 0.036 0.464 NA
#> SRR037178     3  0.0862      0.706 0.000 0.000 0.972 0.004 0.008 NA
#> SRR037179     3  0.0862      0.706 0.000 0.000 0.972 0.004 0.008 NA
#> SRR037180     3  0.0862      0.706 0.000 0.000 0.972 0.004 0.008 NA
#> SRR037181     3  0.0862      0.706 0.000 0.000 0.972 0.004 0.008 NA
#> SRR037189     2  0.0508      0.793 0.000 0.984 0.000 0.012 0.004 NA
#> SRR037190     2  0.3748      0.834 0.000 0.688 0.012 0.000 0.000 NA
#> SRR037191     2  0.3748      0.834 0.000 0.688 0.012 0.000 0.000 NA
#> SRR037192     2  0.0508      0.793 0.000 0.984 0.000 0.012 0.004 NA
#> SRR037193     5  0.6680      0.960 0.000 0.096 0.008 0.396 0.420 NA
#> SRR037194     5  0.6460      0.980 0.000 0.096 0.000 0.404 0.420 NA
#> SRR037195     5  0.6460      0.980 0.000 0.096 0.000 0.404 0.420 NA
#> SRR037196     4  0.6239     -0.867 0.000 0.068 0.000 0.440 0.408 NA
#> SRR037197     4  0.5651     -0.554 0.000 0.020 0.000 0.516 0.368 NA
#> SRR037198     4  0.6239     -0.867 0.000 0.068 0.000 0.440 0.408 NA
#> SRR037199     1  0.4897      0.789 0.588 0.004 0.000 0.000 0.064 NA
#> SRR037200     1  0.4812      0.789 0.588 0.000 0.000 0.000 0.068 NA
#> SRR037201     1  0.4812      0.789 0.588 0.000 0.000 0.000 0.068 NA
#> SRR037202     1  0.4500      0.790 0.572 0.000 0.000 0.000 0.036 NA
#> SRR037203     1  0.4500      0.790 0.572 0.000 0.000 0.000 0.036 NA
#> SRR037204     1  0.4500      0.790 0.572 0.000 0.000 0.000 0.036 NA
#> SRR037205     1  0.4500      0.790 0.572 0.000 0.000 0.000 0.036 NA
#> SRR037206     3  0.4619      0.670 0.000 0.004 0.704 0.000 0.124 NA
#> SRR037207     3  0.4619      0.670 0.000 0.004 0.704 0.000 0.124 NA
#> SRR037208     3  0.3918      0.678 0.000 0.000 0.768 0.000 0.124 NA
#> SRR037209     3  0.3918      0.678 0.000 0.000 0.768 0.000 0.124 NA
#> SRR037210     3  0.4619      0.670 0.000 0.004 0.704 0.000 0.124 NA
#> SRR037211     3  0.4619      0.670 0.000 0.004 0.704 0.000 0.124 NA
#> SRR037212     3  0.4792      0.491 0.000 0.004 0.492 0.032 0.468 NA
#> SRR037213     3  0.4792      0.491 0.000 0.004 0.492 0.032 0.468 NA
#> SRR037219     3  0.4852      0.487 0.000 0.004 0.488 0.036 0.468 NA
#> SRR037214     3  0.3830      0.576 0.000 0.004 0.620 0.000 0.376 NA
#> SRR037215     3  0.3918      0.678 0.000 0.000 0.768 0.000 0.124 NA
#> SRR037216     3  0.4619      0.670 0.000 0.004 0.704 0.000 0.124 NA
#> SRR037217     3  0.1075      0.704 0.000 0.000 0.952 0.000 0.048 NA
#> SRR037218     3  0.1075      0.704 0.000 0.000 0.952 0.000 0.048 NA
#> SRR037220     1  0.0000      0.788 1.000 0.000 0.000 0.000 0.000 NA
#> SRR037221     1  0.0000      0.788 1.000 0.000 0.000 0.000 0.000 NA
#> SRR037222     1  0.0000      0.788 1.000 0.000 0.000 0.000 0.000 NA
#> SRR037223     1  0.1729      0.787 0.936 0.004 0.000 0.012 0.036 NA
#> SRR037224     1  0.1729      0.787 0.936 0.004 0.000 0.012 0.036 NA
#> SRR037225     1  0.0000      0.788 1.000 0.000 0.000 0.000 0.000 NA
#> SRR037226     1  0.1729      0.787 0.936 0.004 0.000 0.012 0.036 NA

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-kmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-kmeans-collect-classes

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


SD:skmeans**

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

res = res_list["SD", "skmeans"]
# you can also extract it by
# res = res_list["SD:skmeans"]

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

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 15332 rows and 62 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#>   Subgroups are detected by 'skmeans' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 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           0.983       0.987         0.4997 0.500   0.500
#> 3 3 1.000           1.000       1.000         0.3118 0.845   0.689
#> 4 4 1.000           0.980       0.984         0.1448 0.905   0.724
#> 5 5 0.929           0.986       0.958         0.0630 0.948   0.792
#> 6 6 0.955           0.948       0.890         0.0317 0.981   0.904

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

suggest_best_k(res)
#> [1] 6
#> attr(,"optional")
#> [1] 2 3 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
#> SRR037165     2  0.0000      0.991 0.000 1.000
#> SRR037166     2  0.0000      0.991 0.000 1.000
#> SRR037167     2  0.0000      0.991 0.000 1.000
#> SRR037168     2  0.2236      0.970 0.036 0.964
#> SRR037169     2  0.2236      0.970 0.036 0.964
#> SRR037170     2  0.2236      0.970 0.036 0.964
#> SRR037171     2  0.0000      0.991 0.000 1.000
#> SRR037172     2  0.0000      0.991 0.000 1.000
#> SRR037173     2  0.0000      0.991 0.000 1.000
#> SRR037174     2  0.0000      0.991 0.000 1.000
#> SRR037175     2  0.0000      0.991 0.000 1.000
#> SRR037176     2  0.0000      0.991 0.000 1.000
#> SRR037177     2  0.0000      0.991 0.000 1.000
#> SRR037182     1  0.0376      0.983 0.996 0.004
#> SRR037183     1  0.0376      0.983 0.996 0.004
#> SRR037184     2  0.0000      0.991 0.000 1.000
#> SRR037185     2  0.0000      0.991 0.000 1.000
#> SRR037186     2  0.0000      0.991 0.000 1.000
#> SRR037187     2  0.0000      0.991 0.000 1.000
#> SRR037188     1  0.0376      0.983 0.996 0.004
#> SRR037178     1  0.2423      0.976 0.960 0.040
#> SRR037179     1  0.2423      0.976 0.960 0.040
#> SRR037180     1  0.2423      0.976 0.960 0.040
#> SRR037181     1  0.2423      0.976 0.960 0.040
#> SRR037189     2  0.0000      0.991 0.000 1.000
#> SRR037190     2  0.0000      0.991 0.000 1.000
#> SRR037191     2  0.0000      0.991 0.000 1.000
#> SRR037192     2  0.0000      0.991 0.000 1.000
#> SRR037193     2  0.0000      0.991 0.000 1.000
#> SRR037194     2  0.0000      0.991 0.000 1.000
#> SRR037195     2  0.0000      0.991 0.000 1.000
#> SRR037196     2  0.2236      0.970 0.036 0.964
#> SRR037197     2  0.2236      0.970 0.036 0.964
#> SRR037198     2  0.2236      0.970 0.036 0.964
#> SRR037199     1  0.0000      0.983 1.000 0.000
#> SRR037200     1  0.0000      0.983 1.000 0.000
#> SRR037201     1  0.0000      0.983 1.000 0.000
#> SRR037202     1  0.0000      0.983 1.000 0.000
#> SRR037203     1  0.0000      0.983 1.000 0.000
#> SRR037204     1  0.0000      0.983 1.000 0.000
#> SRR037205     1  0.0000      0.983 1.000 0.000
#> SRR037206     1  0.2423      0.976 0.960 0.040
#> SRR037207     1  0.2423      0.976 0.960 0.040
#> SRR037208     1  0.2423      0.976 0.960 0.040
#> SRR037209     1  0.2423      0.976 0.960 0.040
#> SRR037210     1  0.2423      0.976 0.960 0.040
#> SRR037211     1  0.2423      0.976 0.960 0.040
#> SRR037212     1  0.0376      0.983 0.996 0.004
#> SRR037213     1  0.0376      0.983 0.996 0.004
#> SRR037219     1  0.0376      0.983 0.996 0.004
#> SRR037214     1  0.0376      0.983 0.996 0.004
#> SRR037215     1  0.2423      0.976 0.960 0.040
#> SRR037216     1  0.2423      0.976 0.960 0.040
#> SRR037217     1  0.2423      0.976 0.960 0.040
#> SRR037218     1  0.2423      0.976 0.960 0.040
#> SRR037220     1  0.0000      0.983 1.000 0.000
#> SRR037221     1  0.0000      0.983 1.000 0.000
#> SRR037222     1  0.0000      0.983 1.000 0.000
#> SRR037223     1  0.0000      0.983 1.000 0.000
#> SRR037224     1  0.0000      0.983 1.000 0.000
#> SRR037225     1  0.0000      0.983 1.000 0.000
#> SRR037226     1  0.0000      0.983 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
#> SRR037165     2       0          1  0  1  0
#> SRR037166     2       0          1  0  1  0
#> SRR037167     2       0          1  0  1  0
#> SRR037168     2       0          1  0  1  0
#> SRR037169     2       0          1  0  1  0
#> SRR037170     2       0          1  0  1  0
#> SRR037171     2       0          1  0  1  0
#> SRR037172     2       0          1  0  1  0
#> SRR037173     2       0          1  0  1  0
#> SRR037174     2       0          1  0  1  0
#> SRR037175     2       0          1  0  1  0
#> SRR037176     2       0          1  0  1  0
#> SRR037177     2       0          1  0  1  0
#> SRR037182     3       0          1  0  0  1
#> SRR037183     3       0          1  0  0  1
#> SRR037184     2       0          1  0  1  0
#> SRR037185     2       0          1  0  1  0
#> SRR037186     2       0          1  0  1  0
#> SRR037187     2       0          1  0  1  0
#> SRR037188     3       0          1  0  0  1
#> SRR037178     3       0          1  0  0  1
#> SRR037179     3       0          1  0  0  1
#> SRR037180     3       0          1  0  0  1
#> SRR037181     3       0          1  0  0  1
#> SRR037189     2       0          1  0  1  0
#> SRR037190     2       0          1  0  1  0
#> SRR037191     2       0          1  0  1  0
#> SRR037192     2       0          1  0  1  0
#> SRR037193     2       0          1  0  1  0
#> SRR037194     2       0          1  0  1  0
#> SRR037195     2       0          1  0  1  0
#> SRR037196     2       0          1  0  1  0
#> SRR037197     2       0          1  0  1  0
#> SRR037198     2       0          1  0  1  0
#> SRR037199     1       0          1  1  0  0
#> SRR037200     1       0          1  1  0  0
#> SRR037201     1       0          1  1  0  0
#> SRR037202     1       0          1  1  0  0
#> SRR037203     1       0          1  1  0  0
#> SRR037204     1       0          1  1  0  0
#> SRR037205     1       0          1  1  0  0
#> SRR037206     3       0          1  0  0  1
#> SRR037207     3       0          1  0  0  1
#> SRR037208     3       0          1  0  0  1
#> SRR037209     3       0          1  0  0  1
#> SRR037210     3       0          1  0  0  1
#> SRR037211     3       0          1  0  0  1
#> SRR037212     3       0          1  0  0  1
#> SRR037213     3       0          1  0  0  1
#> SRR037219     3       0          1  0  0  1
#> SRR037214     3       0          1  0  0  1
#> SRR037215     3       0          1  0  0  1
#> SRR037216     3       0          1  0  0  1
#> SRR037217     3       0          1  0  0  1
#> SRR037218     3       0          1  0  0  1
#> SRR037220     1       0          1  1  0  0
#> SRR037221     1       0          1  1  0  0
#> SRR037222     1       0          1  1  0  0
#> SRR037223     1       0          1  1  0  0
#> SRR037224     1       0          1  1  0  0
#> SRR037225     1       0          1  1  0  0
#> SRR037226     1       0          1  1  0  0

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette p1    p2   p3    p4
#> SRR037165     4  0.2011      0.950  0 0.080 0.00 0.920
#> SRR037166     4  0.2011      0.950  0 0.080 0.00 0.920
#> SRR037167     4  0.2011      0.950  0 0.080 0.00 0.920
#> SRR037168     4  0.0188      0.953  0 0.004 0.00 0.996
#> SRR037169     4  0.0188      0.953  0 0.004 0.00 0.996
#> SRR037170     4  0.0188      0.953  0 0.004 0.00 0.996
#> SRR037171     2  0.0000      1.000  0 1.000 0.00 0.000
#> SRR037172     2  0.0000      1.000  0 1.000 0.00 0.000
#> SRR037173     2  0.0000      1.000  0 1.000 0.00 0.000
#> SRR037174     2  0.0000      1.000  0 1.000 0.00 0.000
#> SRR037175     2  0.0000      1.000  0 1.000 0.00 0.000
#> SRR037176     2  0.0000      1.000  0 1.000 0.00 0.000
#> SRR037177     2  0.0000      1.000  0 1.000 0.00 0.000
#> SRR037182     3  0.2011      0.942  0 0.000 0.92 0.080
#> SRR037183     3  0.2011      0.942  0 0.000 0.92 0.080
#> SRR037184     2  0.0000      1.000  0 1.000 0.00 0.000
#> SRR037185     2  0.0000      1.000  0 1.000 0.00 0.000
#> SRR037186     2  0.0000      1.000  0 1.000 0.00 0.000
#> SRR037187     2  0.0000      1.000  0 1.000 0.00 0.000
#> SRR037188     3  0.2011      0.942  0 0.000 0.92 0.080
#> SRR037178     3  0.0000      0.978  0 0.000 1.00 0.000
#> SRR037179     3  0.0000      0.978  0 0.000 1.00 0.000
#> SRR037180     3  0.0000      0.978  0 0.000 1.00 0.000
#> SRR037181     3  0.0000      0.978  0 0.000 1.00 0.000
#> SRR037189     2  0.0000      1.000  0 1.000 0.00 0.000
#> SRR037190     2  0.0000      1.000  0 1.000 0.00 0.000
#> SRR037191     2  0.0000      1.000  0 1.000 0.00 0.000
#> SRR037192     2  0.0000      1.000  0 1.000 0.00 0.000
#> SRR037193     4  0.2011      0.950  0 0.080 0.00 0.920
#> SRR037194     4  0.2011      0.950  0 0.080 0.00 0.920
#> SRR037195     4  0.2011      0.950  0 0.080 0.00 0.920
#> SRR037196     4  0.0188      0.953  0 0.004 0.00 0.996
#> SRR037197     4  0.0188      0.953  0 0.004 0.00 0.996
#> SRR037198     4  0.0188      0.953  0 0.004 0.00 0.996
#> SRR037199     1  0.0000      1.000  1 0.000 0.00 0.000
#> SRR037200     1  0.0000      1.000  1 0.000 0.00 0.000
#> SRR037201     1  0.0000      1.000  1 0.000 0.00 0.000
#> SRR037202     1  0.0000      1.000  1 0.000 0.00 0.000
#> SRR037203     1  0.0000      1.000  1 0.000 0.00 0.000
#> SRR037204     1  0.0000      1.000  1 0.000 0.00 0.000
#> SRR037205     1  0.0000      1.000  1 0.000 0.00 0.000
#> SRR037206     3  0.0000      0.978  0 0.000 1.00 0.000
#> SRR037207     3  0.0000      0.978  0 0.000 1.00 0.000
#> SRR037208     3  0.0000      0.978  0 0.000 1.00 0.000
#> SRR037209     3  0.0000      0.978  0 0.000 1.00 0.000
#> SRR037210     3  0.0000      0.978  0 0.000 1.00 0.000
#> SRR037211     3  0.0000      0.978  0 0.000 1.00 0.000
#> SRR037212     3  0.2011      0.942  0 0.000 0.92 0.080
#> SRR037213     3  0.2011      0.942  0 0.000 0.92 0.080
#> SRR037219     3  0.2011      0.942  0 0.000 0.92 0.080
#> SRR037214     3  0.0000      0.978  0 0.000 1.00 0.000
#> SRR037215     3  0.0000      0.978  0 0.000 1.00 0.000
#> SRR037216     3  0.0000      0.978  0 0.000 1.00 0.000
#> SRR037217     3  0.0000      0.978  0 0.000 1.00 0.000
#> SRR037218     3  0.0000      0.978  0 0.000 1.00 0.000
#> SRR037220     1  0.0000      1.000  1 0.000 0.00 0.000
#> SRR037221     1  0.0000      1.000  1 0.000 0.00 0.000
#> SRR037222     1  0.0000      1.000  1 0.000 0.00 0.000
#> SRR037223     1  0.0000      1.000  1 0.000 0.00 0.000
#> SRR037224     1  0.0000      1.000  1 0.000 0.00 0.000
#> SRR037225     1  0.0000      1.000  1 0.000 0.00 0.000
#> SRR037226     1  0.0000      1.000  1 0.000 0.00 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
#> SRR037165     4  0.2280      0.946 0.000  0 0.000 0.88 0.120
#> SRR037166     4  0.2280      0.946 0.000  0 0.000 0.88 0.120
#> SRR037167     4  0.2280      0.946 0.000  0 0.000 0.88 0.120
#> SRR037168     4  0.2280      0.946 0.000  0 0.000 0.88 0.120
#> SRR037169     4  0.2280      0.946 0.000  0 0.000 0.88 0.120
#> SRR037170     4  0.2280      0.946 0.000  0 0.000 0.88 0.120
#> SRR037171     2  0.0000      1.000 0.000  1 0.000 0.00 0.000
#> SRR037172     2  0.0000      1.000 0.000  1 0.000 0.00 0.000
#> SRR037173     2  0.0000      1.000 0.000  1 0.000 0.00 0.000
#> SRR037174     2  0.0000      1.000 0.000  1 0.000 0.00 0.000
#> SRR037175     2  0.0000      1.000 0.000  1 0.000 0.00 0.000
#> SRR037176     2  0.0000      1.000 0.000  1 0.000 0.00 0.000
#> SRR037177     2  0.0000      1.000 0.000  1 0.000 0.00 0.000
#> SRR037182     5  0.2561      0.995 0.000  0 0.144 0.00 0.856
#> SRR037183     5  0.2561      0.995 0.000  0 0.144 0.00 0.856
#> SRR037184     2  0.0000      1.000 0.000  1 0.000 0.00 0.000
#> SRR037185     2  0.0000      1.000 0.000  1 0.000 0.00 0.000
#> SRR037186     2  0.0000      1.000 0.000  1 0.000 0.00 0.000
#> SRR037187     2  0.0000      1.000 0.000  1 0.000 0.00 0.000
#> SRR037188     5  0.2561      0.995 0.000  0 0.144 0.00 0.856
#> SRR037178     3  0.0000      1.000 0.000  0 1.000 0.00 0.000
#> SRR037179     3  0.0000      1.000 0.000  0 1.000 0.00 0.000
#> SRR037180     3  0.0000      1.000 0.000  0 1.000 0.00 0.000
#> SRR037181     3  0.0000      1.000 0.000  0 1.000 0.00 0.000
#> SRR037189     2  0.0000      1.000 0.000  1 0.000 0.00 0.000
#> SRR037190     2  0.0000      1.000 0.000  1 0.000 0.00 0.000
#> SRR037191     2  0.0000      1.000 0.000  1 0.000 0.00 0.000
#> SRR037192     2  0.0000      1.000 0.000  1 0.000 0.00 0.000
#> SRR037193     4  0.0000      0.946 0.000  0 0.000 1.00 0.000
#> SRR037194     4  0.0000      0.946 0.000  0 0.000 1.00 0.000
#> SRR037195     4  0.0000      0.946 0.000  0 0.000 1.00 0.000
#> SRR037196     4  0.0000      0.946 0.000  0 0.000 1.00 0.000
#> SRR037197     4  0.0000      0.946 0.000  0 0.000 1.00 0.000
#> SRR037198     4  0.0000      0.946 0.000  0 0.000 1.00 0.000
#> SRR037199     1  0.0703      0.989 0.976  0 0.000 0.00 0.024
#> SRR037200     1  0.0703      0.989 0.976  0 0.000 0.00 0.024
#> SRR037201     1  0.0703      0.989 0.976  0 0.000 0.00 0.024
#> SRR037202     1  0.0703      0.989 0.976  0 0.000 0.00 0.024
#> SRR037203     1  0.0703      0.989 0.976  0 0.000 0.00 0.024
#> SRR037204     1  0.0703      0.989 0.976  0 0.000 0.00 0.024
#> SRR037205     1  0.0703      0.989 0.976  0 0.000 0.00 0.024
#> SRR037206     3  0.0000      1.000 0.000  0 1.000 0.00 0.000
#> SRR037207     3  0.0000      1.000 0.000  0 1.000 0.00 0.000
#> SRR037208     3  0.0000      1.000 0.000  0 1.000 0.00 0.000
#> SRR037209     3  0.0000      1.000 0.000  0 1.000 0.00 0.000
#> SRR037210     3  0.0000      1.000 0.000  0 1.000 0.00 0.000
#> SRR037211     3  0.0000      1.000 0.000  0 1.000 0.00 0.000
#> SRR037212     5  0.2561      0.995 0.000  0 0.144 0.00 0.856
#> SRR037213     5  0.2561      0.995 0.000  0 0.144 0.00 0.856
#> SRR037219     5  0.2561      0.995 0.000  0 0.144 0.00 0.856
#> SRR037214     5  0.2813      0.971 0.000  0 0.168 0.00 0.832
#> SRR037215     3  0.0000      1.000 0.000  0 1.000 0.00 0.000
#> SRR037216     3  0.0000      1.000 0.000  0 1.000 0.00 0.000
#> SRR037217     3  0.0000      1.000 0.000  0 1.000 0.00 0.000
#> SRR037218     3  0.0000      1.000 0.000  0 1.000 0.00 0.000
#> SRR037220     1  0.0000      0.989 1.000  0 0.000 0.00 0.000
#> SRR037221     1  0.0000      0.989 1.000  0 0.000 0.00 0.000
#> SRR037222     1  0.0000      0.989 1.000  0 0.000 0.00 0.000
#> SRR037223     1  0.0000      0.989 1.000  0 0.000 0.00 0.000
#> SRR037224     1  0.0000      0.989 1.000  0 0.000 0.00 0.000
#> SRR037225     1  0.0000      0.989 1.000  0 0.000 0.00 0.000
#> SRR037226     1  0.0000      0.989 1.000  0 0.000 0.00 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR037165     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR037166     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR037167     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR037168     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR037169     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR037170     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR037171     2  0.0000      0.988 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR037172     2  0.0000      0.988 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR037173     2  0.0000      0.988 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR037174     2  0.0000      0.988 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR037175     2  0.0000      0.988 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR037176     2  0.0000      0.988 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR037177     2  0.1409      0.965 0.000 0.948 0.000 0.032 0.012 0.008
#> SRR037182     6  0.4583      0.989 0.000 0.000 0.044 0.000 0.376 0.580
#> SRR037183     6  0.4583      0.989 0.000 0.000 0.044 0.000 0.376 0.580
#> SRR037184     2  0.0622      0.986 0.000 0.980 0.000 0.000 0.012 0.008
#> SRR037185     2  0.1409      0.965 0.000 0.948 0.000 0.032 0.012 0.008
#> SRR037186     2  0.0622      0.986 0.000 0.980 0.000 0.000 0.012 0.008
#> SRR037187     2  0.0622      0.986 0.000 0.980 0.000 0.000 0.012 0.008
#> SRR037188     6  0.4583      0.989 0.000 0.000 0.044 0.000 0.376 0.580
#> SRR037178     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR037179     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR037180     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR037181     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR037189     2  0.0622      0.986 0.000 0.980 0.000 0.000 0.012 0.008
#> SRR037190     2  0.0000      0.988 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR037191     2  0.0000      0.988 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR037192     2  0.0622      0.986 0.000 0.980 0.000 0.000 0.012 0.008
#> SRR037193     5  0.3727      1.000 0.000 0.000 0.000 0.388 0.612 0.000
#> SRR037194     5  0.3727      1.000 0.000 0.000 0.000 0.388 0.612 0.000
#> SRR037195     5  0.3727      1.000 0.000 0.000 0.000 0.388 0.612 0.000
#> SRR037196     5  0.3727      1.000 0.000 0.000 0.000 0.388 0.612 0.000
#> SRR037197     5  0.3727      1.000 0.000 0.000 0.000 0.388 0.612 0.000
#> SRR037198     5  0.3727      1.000 0.000 0.000 0.000 0.388 0.612 0.000
#> SRR037199     1  0.3782      0.794 0.588 0.000 0.000 0.000 0.000 0.412
#> SRR037200     1  0.3782      0.794 0.588 0.000 0.000 0.000 0.000 0.412
#> SRR037201     1  0.3782      0.794 0.588 0.000 0.000 0.000 0.000 0.412
#> SRR037202     1  0.3782      0.794 0.588 0.000 0.000 0.000 0.000 0.412
#> SRR037203     1  0.3782      0.794 0.588 0.000 0.000 0.000 0.000 0.412
#> SRR037204     1  0.3782      0.794 0.588 0.000 0.000 0.000 0.000 0.412
#> SRR037205     1  0.3782      0.794 0.588 0.000 0.000 0.000 0.000 0.412
#> SRR037206     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR037207     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR037208     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR037209     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR037210     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR037211     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR037212     6  0.4583      0.989 0.000 0.000 0.044 0.000 0.376 0.580
#> SRR037213     6  0.4583      0.989 0.000 0.000 0.044 0.000 0.376 0.580
#> SRR037219     6  0.4583      0.989 0.000 0.000 0.044 0.000 0.376 0.580
#> SRR037214     6  0.5157      0.935 0.000 0.000 0.096 0.000 0.360 0.544
#> SRR037215     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR037216     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR037217     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR037218     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR037220     1  0.0000      0.794 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR037221     1  0.0000      0.794 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR037222     1  0.0000      0.794 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR037223     1  0.0000      0.794 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR037224     1  0.0000      0.794 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR037225     1  0.0000      0.794 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR037226     1  0.0000      0.794 1.000 0.000 0.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-skmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-skmeans-collect-classes

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


SD:pam*

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

res = res_list["SD", "pam"]
# you can also extract it by
# res = res_list["SD:pam"]

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

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

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

collect_plots(res)

plot of chunk SD-pam-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.545           0.775       0.864         0.4138 0.645   0.645
#> 3 3 1.000           1.000       1.000         0.5842 0.700   0.535
#> 4 4 1.000           1.000       1.000         0.0395 0.974   0.925
#> 5 5 1.000           0.993       0.996         0.1324 0.910   0.718
#> 6 6 0.931           0.963       0.950         0.0589 0.948   0.774

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> SRR037165     2  0.0000      0.782 0.000 1.000
#> SRR037166     2  0.0000      0.782 0.000 1.000
#> SRR037167     2  0.0000      0.782 0.000 1.000
#> SRR037168     2  0.0000      0.782 0.000 1.000
#> SRR037169     2  0.0938      0.773 0.012 0.988
#> SRR037170     2  0.0000      0.782 0.000 1.000
#> SRR037171     2  0.0000      0.782 0.000 1.000
#> SRR037172     2  0.0000      0.782 0.000 1.000
#> SRR037173     2  0.0000      0.782 0.000 1.000
#> SRR037174     2  0.0000      0.782 0.000 1.000
#> SRR037175     2  0.0000      0.782 0.000 1.000
#> SRR037176     2  0.0000      0.782 0.000 1.000
#> SRR037177     2  0.0000      0.782 0.000 1.000
#> SRR037182     2  0.9710      0.617 0.400 0.600
#> SRR037183     2  0.9710      0.617 0.400 0.600
#> SRR037184     2  0.0000      0.782 0.000 1.000
#> SRR037185     2  0.0000      0.782 0.000 1.000
#> SRR037186     2  0.0000      0.782 0.000 1.000
#> SRR037187     2  0.0000      0.782 0.000 1.000
#> SRR037188     2  0.9710      0.617 0.400 0.600
#> SRR037178     2  0.9710      0.617 0.400 0.600
#> SRR037179     2  0.9710      0.617 0.400 0.600
#> SRR037180     2  0.9710      0.617 0.400 0.600
#> SRR037181     2  0.9710      0.617 0.400 0.600
#> SRR037189     2  0.0000      0.782 0.000 1.000
#> SRR037190     2  0.0000      0.782 0.000 1.000
#> SRR037191     2  0.0000      0.782 0.000 1.000
#> SRR037192     2  0.0000      0.782 0.000 1.000
#> SRR037193     2  0.0000      0.782 0.000 1.000
#> SRR037194     2  0.0000      0.782 0.000 1.000
#> SRR037195     2  0.0000      0.782 0.000 1.000
#> SRR037196     2  0.0000      0.782 0.000 1.000
#> SRR037197     2  0.0000      0.782 0.000 1.000
#> SRR037198     2  0.0000      0.782 0.000 1.000
#> SRR037199     1  0.0376      0.994 0.996 0.004
#> SRR037200     1  0.0000      1.000 1.000 0.000
#> SRR037201     1  0.0000      1.000 1.000 0.000
#> SRR037202     1  0.0000      1.000 1.000 0.000
#> SRR037203     1  0.0000      1.000 1.000 0.000
#> SRR037204     1  0.0000      1.000 1.000 0.000
#> SRR037205     1  0.0000      1.000 1.000 0.000
#> SRR037206     2  0.9710      0.617 0.400 0.600
#> SRR037207     2  0.9710      0.617 0.400 0.600
#> SRR037208     2  0.9710      0.617 0.400 0.600
#> SRR037209     2  0.9710      0.617 0.400 0.600
#> SRR037210     2  0.9710      0.617 0.400 0.600
#> SRR037211     2  0.9710      0.617 0.400 0.600
#> SRR037212     2  0.9710      0.617 0.400 0.600
#> SRR037213     2  0.9710      0.617 0.400 0.600
#> SRR037219     2  0.9710      0.617 0.400 0.600
#> SRR037214     2  0.9710      0.617 0.400 0.600
#> SRR037215     2  0.9710      0.617 0.400 0.600
#> SRR037216     2  0.9710      0.617 0.400 0.600
#> SRR037217     2  0.9710      0.617 0.400 0.600
#> SRR037218     2  0.9710      0.617 0.400 0.600
#> SRR037220     1  0.0000      1.000 1.000 0.000
#> SRR037221     1  0.0000      1.000 1.000 0.000
#> SRR037222     1  0.0000      1.000 1.000 0.000
#> SRR037223     1  0.0000      1.000 1.000 0.000
#> SRR037224     1  0.0000      1.000 1.000 0.000
#> SRR037225     1  0.0000      1.000 1.000 0.000
#> SRR037226     1  0.0000      1.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette p1 p2 p3
#> SRR037165     2       0          1  0  1  0
#> SRR037166     2       0          1  0  1  0
#> SRR037167     2       0          1  0  1  0
#> SRR037168     2       0          1  0  1  0
#> SRR037169     2       0          1  0  1  0
#> SRR037170     2       0          1  0  1  0
#> SRR037171     2       0          1  0  1  0
#> SRR037172     2       0          1  0  1  0
#> SRR037173     2       0          1  0  1  0
#> SRR037174     2       0          1  0  1  0
#> SRR037175     2       0          1  0  1  0
#> SRR037176     2       0          1  0  1  0
#> SRR037177     2       0          1  0  1  0
#> SRR037182     3       0          1  0  0  1
#> SRR037183     3       0          1  0  0  1
#> SRR037184     2       0          1  0  1  0
#> SRR037185     2       0          1  0  1  0
#> SRR037186     2       0          1  0  1  0
#> SRR037187     2       0          1  0  1  0
#> SRR037188     3       0          1  0  0  1
#> SRR037178     3       0          1  0  0  1
#> SRR037179     3       0          1  0  0  1
#> SRR037180     3       0          1  0  0  1
#> SRR037181     3       0          1  0  0  1
#> SRR037189     2       0          1  0  1  0
#> SRR037190     2       0          1  0  1  0
#> SRR037191     2       0          1  0  1  0
#> SRR037192     2       0          1  0  1  0
#> SRR037193     2       0          1  0  1  0
#> SRR037194     2       0          1  0  1  0
#> SRR037195     2       0          1  0  1  0
#> SRR037196     2       0          1  0  1  0
#> SRR037197     2       0          1  0  1  0
#> SRR037198     2       0          1  0  1  0
#> SRR037199     1       0          1  1  0  0
#> SRR037200     1       0          1  1  0  0
#> SRR037201     1       0          1  1  0  0
#> SRR037202     1       0          1  1  0  0
#> SRR037203     1       0          1  1  0  0
#> SRR037204     1       0          1  1  0  0
#> SRR037205     1       0          1  1  0  0
#> SRR037206     3       0          1  0  0  1
#> SRR037207     3       0          1  0  0  1
#> SRR037208     3       0          1  0  0  1
#> SRR037209     3       0          1  0  0  1
#> SRR037210     3       0          1  0  0  1
#> SRR037211     3       0          1  0  0  1
#> SRR037212     3       0          1  0  0  1
#> SRR037213     3       0          1  0  0  1
#> SRR037219     3       0          1  0  0  1
#> SRR037214     3       0          1  0  0  1
#> SRR037215     3       0          1  0  0  1
#> SRR037216     3       0          1  0  0  1
#> SRR037217     3       0          1  0  0  1
#> SRR037218     3       0          1  0  0  1
#> SRR037220     1       0          1  1  0  0
#> SRR037221     1       0          1  1  0  0
#> SRR037222     1       0          1  1  0  0
#> SRR037223     1       0          1  1  0  0
#> SRR037224     1       0          1  1  0  0
#> SRR037225     1       0          1  1  0  0
#> SRR037226     1       0          1  1  0  0

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette p1 p2 p3 p4
#> SRR037165     2       0          1  0  1  0  0
#> SRR037166     2       0          1  0  1  0  0
#> SRR037167     2       0          1  0  1  0  0
#> SRR037168     2       0          1  0  1  0  0
#> SRR037169     2       0          1  0  1  0  0
#> SRR037170     2       0          1  0  1  0  0
#> SRR037171     2       0          1  0  1  0  0
#> SRR037172     2       0          1  0  1  0  0
#> SRR037173     2       0          1  0  1  0  0
#> SRR037174     2       0          1  0  1  0  0
#> SRR037175     2       0          1  0  1  0  0
#> SRR037176     2       0          1  0  1  0  0
#> SRR037177     2       0          1  0  1  0  0
#> SRR037182     3       0          1  0  0  1  0
#> SRR037183     3       0          1  0  0  1  0
#> SRR037184     2       0          1  0  1  0  0
#> SRR037185     2       0          1  0  1  0  0
#> SRR037186     2       0          1  0  1  0  0
#> SRR037187     2       0          1  0  1  0  0
#> SRR037188     3       0          1  0  0  1  0
#> SRR037178     3       0          1  0  0  1  0
#> SRR037179     3       0          1  0  0  1  0
#> SRR037180     3       0          1  0  0  1  0
#> SRR037181     3       0          1  0  0  1  0
#> SRR037189     2       0          1  0  1  0  0
#> SRR037190     2       0          1  0  1  0  0
#> SRR037191     2       0          1  0  1  0  0
#> SRR037192     2       0          1  0  1  0  0
#> SRR037193     2       0          1  0  1  0  0
#> SRR037194     2       0          1  0  1  0  0
#> SRR037195     2       0          1  0  1  0  0
#> SRR037196     2       0          1  0  1  0  0
#> SRR037197     2       0          1  0  1  0  0
#> SRR037198     2       0          1  0  1  0  0
#> SRR037199     4       0          1  0  0  0  1
#> SRR037200     4       0          1  0  0  0  1
#> SRR037201     4       0          1  0  0  0  1
#> SRR037202     4       0          1  0  0  0  1
#> SRR037203     4       0          1  0  0  0  1
#> SRR037204     4       0          1  0  0  0  1
#> SRR037205     4       0          1  0  0  0  1
#> SRR037206     3       0          1  0  0  1  0
#> SRR037207     3       0          1  0  0  1  0
#> SRR037208     3       0          1  0  0  1  0
#> SRR037209     3       0          1  0  0  1  0
#> SRR037210     3       0          1  0  0  1  0
#> SRR037211     3       0          1  0  0  1  0
#> SRR037212     3       0          1  0  0  1  0
#> SRR037213     3       0          1  0  0  1  0
#> SRR037219     3       0          1  0  0  1  0
#> SRR037214     3       0          1  0  0  1  0
#> SRR037215     3       0          1  0  0  1  0
#> SRR037216     3       0          1  0  0  1  0
#> SRR037217     3       0          1  0  0  1  0
#> SRR037218     3       0          1  0  0  1  0
#> SRR037220     1       0          1  1  0  0  0
#> SRR037221     1       0          1  1  0  0  0
#> SRR037222     1       0          1  1  0  0  0
#> SRR037223     1       0          1  1  0  0  0
#> SRR037224     1       0          1  1  0  0  0
#> SRR037225     1       0          1  1  0  0  0
#> SRR037226     1       0          1  1  0  0  0

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette p1    p2    p3    p4 p5
#> SRR037165     2  0.0000      0.992  0 1.000 0.000 0.000  0
#> SRR037166     2  0.2280      0.862  0 0.880 0.000 0.120  0
#> SRR037167     4  0.0404      0.989  0 0.012 0.000 0.988  0
#> SRR037168     4  0.0000      0.993  0 0.000 0.000 1.000  0
#> SRR037169     4  0.0000      0.993  0 0.000 0.000 1.000  0
#> SRR037170     4  0.0000      0.993  0 0.000 0.000 1.000  0
#> SRR037171     2  0.0000      0.992  0 1.000 0.000 0.000  0
#> SRR037172     2  0.0000      0.992  0 1.000 0.000 0.000  0
#> SRR037173     2  0.0000      0.992  0 1.000 0.000 0.000  0
#> SRR037174     2  0.0000      0.992  0 1.000 0.000 0.000  0
#> SRR037175     2  0.0000      0.992  0 1.000 0.000 0.000  0
#> SRR037176     2  0.0000      0.992  0 1.000 0.000 0.000  0
#> SRR037177     2  0.0000      0.992  0 1.000 0.000 0.000  0
#> SRR037182     3  0.0404      0.991  0 0.000 0.988 0.012  0
#> SRR037183     3  0.0404      0.991  0 0.000 0.988 0.012  0
#> SRR037184     2  0.0000      0.992  0 1.000 0.000 0.000  0
#> SRR037185     2  0.0000      0.992  0 1.000 0.000 0.000  0
#> SRR037186     2  0.0000      0.992  0 1.000 0.000 0.000  0
#> SRR037187     2  0.0000      0.992  0 1.000 0.000 0.000  0
#> SRR037188     3  0.0404      0.991  0 0.000 0.988 0.012  0
#> SRR037178     3  0.0000      0.996  0 0.000 1.000 0.000  0
#> SRR037179     3  0.0000      0.996  0 0.000 1.000 0.000  0
#> SRR037180     3  0.0000      0.996  0 0.000 1.000 0.000  0
#> SRR037181     3  0.0000      0.996  0 0.000 1.000 0.000  0
#> SRR037189     2  0.0000      0.992  0 1.000 0.000 0.000  0
#> SRR037190     2  0.0000      0.992  0 1.000 0.000 0.000  0
#> SRR037191     2  0.0000      0.992  0 1.000 0.000 0.000  0
#> SRR037192     2  0.0000      0.992  0 1.000 0.000 0.000  0
#> SRR037193     4  0.0404      0.989  0 0.012 0.000 0.988  0
#> SRR037194     4  0.0404      0.989  0 0.012 0.000 0.988  0
#> SRR037195     4  0.0404      0.989  0 0.012 0.000 0.988  0
#> SRR037196     4  0.0000      0.993  0 0.000 0.000 1.000  0
#> SRR037197     4  0.0000      0.993  0 0.000 0.000 1.000  0
#> SRR037198     4  0.0000      0.993  0 0.000 0.000 1.000  0
#> SRR037199     5  0.0000      1.000  0 0.000 0.000 0.000  1
#> SRR037200     5  0.0000      1.000  0 0.000 0.000 0.000  1
#> SRR037201     5  0.0000      1.000  0 0.000 0.000 0.000  1
#> SRR037202     5  0.0000      1.000  0 0.000 0.000 0.000  1
#> SRR037203     5  0.0000      1.000  0 0.000 0.000 0.000  1
#> SRR037204     5  0.0000      1.000  0 0.000 0.000 0.000  1
#> SRR037205     5  0.0000      1.000  0 0.000 0.000 0.000  1
#> SRR037206     3  0.0000      0.996  0 0.000 1.000 0.000  0
#> SRR037207     3  0.0000      0.996  0 0.000 1.000 0.000  0
#> SRR037208     3  0.0000      0.996  0 0.000 1.000 0.000  0
#> SRR037209     3  0.0000      0.996  0 0.000 1.000 0.000  0
#> SRR037210     3  0.0000      0.996  0 0.000 1.000 0.000  0
#> SRR037211     3  0.0000      0.996  0 0.000 1.000 0.000  0
#> SRR037212     3  0.0404      0.991  0 0.000 0.988 0.012  0
#> SRR037213     3  0.0404      0.991  0 0.000 0.988 0.012  0
#> SRR037219     3  0.0404      0.991  0 0.000 0.988 0.012  0
#> SRR037214     3  0.0000      0.996  0 0.000 1.000 0.000  0
#> SRR037215     3  0.0000      0.996  0 0.000 1.000 0.000  0
#> SRR037216     3  0.0000      0.996  0 0.000 1.000 0.000  0
#> SRR037217     3  0.0000      0.996  0 0.000 1.000 0.000  0
#> SRR037218     3  0.0000      0.996  0 0.000 1.000 0.000  0
#> SRR037220     1  0.0000      1.000  1 0.000 0.000 0.000  0
#> SRR037221     1  0.0000      1.000  1 0.000 0.000 0.000  0
#> SRR037222     1  0.0000      1.000  1 0.000 0.000 0.000  0
#> SRR037223     1  0.0000      1.000  1 0.000 0.000 0.000  0
#> SRR037224     1  0.0000      1.000  1 0.000 0.000 0.000  0
#> SRR037225     1  0.0000      1.000  1 0.000 0.000 0.000  0
#> SRR037226     1  0.0000      1.000  1 0.000 0.000 0.000  0

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette p1    p2    p3    p4 p5    p6
#> SRR037165     2   0.300      0.752  0 0.772 0.000 0.228  0 0.000
#> SRR037166     2   0.362      0.561  0 0.648 0.000 0.352  0 0.000
#> SRR037167     4   0.000      0.863  0 0.000 0.000 1.000  0 0.000
#> SRR037168     4   0.000      0.863  0 0.000 0.000 1.000  0 0.000
#> SRR037169     4   0.000      0.863  0 0.000 0.000 1.000  0 0.000
#> SRR037170     4   0.000      0.863  0 0.000 0.000 1.000  0 0.000
#> SRR037171     2   0.000      0.965  0 1.000 0.000 0.000  0 0.000
#> SRR037172     2   0.000      0.965  0 1.000 0.000 0.000  0 0.000
#> SRR037173     2   0.000      0.965  0 1.000 0.000 0.000  0 0.000
#> SRR037174     2   0.000      0.965  0 1.000 0.000 0.000  0 0.000
#> SRR037175     2   0.000      0.965  0 1.000 0.000 0.000  0 0.000
#> SRR037176     2   0.000      0.965  0 1.000 0.000 0.000  0 0.000
#> SRR037177     2   0.000      0.965  0 1.000 0.000 0.000  0 0.000
#> SRR037182     6   0.000      1.000  0 0.000 0.000 0.000  0 1.000
#> SRR037183     6   0.000      1.000  0 0.000 0.000 0.000  0 1.000
#> SRR037184     2   0.000      0.965  0 1.000 0.000 0.000  0 0.000
#> SRR037185     2   0.000      0.965  0 1.000 0.000 0.000  0 0.000
#> SRR037186     2   0.000      0.965  0 1.000 0.000 0.000  0 0.000
#> SRR037187     2   0.000      0.965  0 1.000 0.000 0.000  0 0.000
#> SRR037188     6   0.000      1.000  0 0.000 0.000 0.000  0 1.000
#> SRR037178     3   0.300      1.000  0 0.000 0.772 0.000  0 0.228
#> SRR037179     3   0.300      1.000  0 0.000 0.772 0.000  0 0.228
#> SRR037180     3   0.300      1.000  0 0.000 0.772 0.000  0 0.228
#> SRR037181     3   0.300      1.000  0 0.000 0.772 0.000  0 0.228
#> SRR037189     2   0.000      0.965  0 1.000 0.000 0.000  0 0.000
#> SRR037190     2   0.000      0.965  0 1.000 0.000 0.000  0 0.000
#> SRR037191     2   0.000      0.965  0 1.000 0.000 0.000  0 0.000
#> SRR037192     2   0.000      0.965  0 1.000 0.000 0.000  0 0.000
#> SRR037193     4   0.300      0.911  0 0.000 0.228 0.772  0 0.000
#> SRR037194     4   0.300      0.911  0 0.000 0.228 0.772  0 0.000
#> SRR037195     4   0.300      0.911  0 0.000 0.228 0.772  0 0.000
#> SRR037196     4   0.300      0.911  0 0.000 0.228 0.772  0 0.000
#> SRR037197     4   0.300      0.911  0 0.000 0.228 0.772  0 0.000
#> SRR037198     4   0.300      0.911  0 0.000 0.228 0.772  0 0.000
#> SRR037199     1   0.000      1.000  1 0.000 0.000 0.000  0 0.000
#> SRR037200     1   0.000      1.000  1 0.000 0.000 0.000  0 0.000
#> SRR037201     1   0.000      1.000  1 0.000 0.000 0.000  0 0.000
#> SRR037202     1   0.000      1.000  1 0.000 0.000 0.000  0 0.000
#> SRR037203     1   0.000      1.000  1 0.000 0.000 0.000  0 0.000
#> SRR037204     1   0.000      1.000  1 0.000 0.000 0.000  0 0.000
#> SRR037205     1   0.000      1.000  1 0.000 0.000 0.000  0 0.000
#> SRR037206     3   0.300      1.000  0 0.000 0.772 0.000  0 0.228
#> SRR037207     3   0.300      1.000  0 0.000 0.772 0.000  0 0.228
#> SRR037208     3   0.300      1.000  0 0.000 0.772 0.000  0 0.228
#> SRR037209     3   0.300      1.000  0 0.000 0.772 0.000  0 0.228
#> SRR037210     3   0.300      1.000  0 0.000 0.772 0.000  0 0.228
#> SRR037211     3   0.300      1.000  0 0.000 0.772 0.000  0 0.228
#> SRR037212     6   0.000      1.000  0 0.000 0.000 0.000  0 1.000
#> SRR037213     6   0.000      1.000  0 0.000 0.000 0.000  0 1.000
#> SRR037219     6   0.000      1.000  0 0.000 0.000 0.000  0 1.000
#> SRR037214     6   0.000      1.000  0 0.000 0.000 0.000  0 1.000
#> SRR037215     3   0.300      1.000  0 0.000 0.772 0.000  0 0.228
#> SRR037216     3   0.300      1.000  0 0.000 0.772 0.000  0 0.228
#> SRR037217     3   0.300      1.000  0 0.000 0.772 0.000  0 0.228
#> SRR037218     3   0.300      1.000  0 0.000 0.772 0.000  0 0.228
#> SRR037220     5   0.000      1.000  0 0.000 0.000 0.000  1 0.000
#> SRR037221     5   0.000      1.000  0 0.000 0.000 0.000  1 0.000
#> SRR037222     5   0.000      1.000  0 0.000 0.000 0.000  1 0.000
#> SRR037223     5   0.000      1.000  0 0.000 0.000 0.000  1 0.000
#> SRR037224     5   0.000      1.000  0 0.000 0.000 0.000  1 0.000
#> SRR037225     5   0.000      1.000  0 0.000 0.000 0.000  1 0.000
#> SRR037226     5   0.000      1.000  0 0.000 0.000 0.000  1 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 15332 rows and 62 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#>   Subgroups are detected by 'mclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 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           0.999       0.999         0.3564 0.645   0.645
#> 3 3 1.000           0.995       0.996         0.8362 0.700   0.535
#> 4 4 0.759           0.733       0.869         0.1274 0.895   0.704
#> 5 5 0.838           0.808       0.859         0.0747 0.841   0.483
#> 6 6 0.954           0.959       0.950         0.0343 0.985   0.924

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> SRR037165     2  0.0000      0.999 0.000 1.000
#> SRR037166     2  0.0000      0.999 0.000 1.000
#> SRR037167     2  0.0000      0.999 0.000 1.000
#> SRR037168     2  0.0000      0.999 0.000 1.000
#> SRR037169     2  0.0000      0.999 0.000 1.000
#> SRR037170     2  0.0000      0.999 0.000 1.000
#> SRR037171     2  0.0376      0.997 0.004 0.996
#> SRR037172     2  0.0376      0.997 0.004 0.996
#> SRR037173     2  0.0376      0.997 0.004 0.996
#> SRR037174     2  0.0376      0.997 0.004 0.996
#> SRR037175     2  0.0376      0.997 0.004 0.996
#> SRR037176     2  0.0376      0.997 0.004 0.996
#> SRR037177     2  0.0000      0.999 0.000 1.000
#> SRR037182     2  0.0000      0.999 0.000 1.000
#> SRR037183     2  0.0000      0.999 0.000 1.000
#> SRR037184     2  0.0376      0.997 0.004 0.996
#> SRR037185     2  0.0000      0.999 0.000 1.000
#> SRR037186     2  0.0376      0.997 0.004 0.996
#> SRR037187     2  0.0376      0.997 0.004 0.996
#> SRR037188     2  0.0000      0.999 0.000 1.000
#> SRR037178     2  0.0000      0.999 0.000 1.000
#> SRR037179     2  0.0000      0.999 0.000 1.000
#> SRR037180     2  0.0000      0.999 0.000 1.000
#> SRR037181     2  0.0000      0.999 0.000 1.000
#> SRR037189     2  0.0376      0.997 0.004 0.996
#> SRR037190     2  0.0376      0.997 0.004 0.996
#> SRR037191     2  0.0376      0.997 0.004 0.996
#> SRR037192     2  0.0376      0.997 0.004 0.996
#> SRR037193     2  0.0000      0.999 0.000 1.000
#> SRR037194     2  0.0000      0.999 0.000 1.000
#> SRR037195     2  0.0000      0.999 0.000 1.000
#> SRR037196     2  0.0000      0.999 0.000 1.000
#> SRR037197     2  0.0000      0.999 0.000 1.000
#> SRR037198     2  0.0000      0.999 0.000 1.000
#> SRR037199     1  0.0000      1.000 1.000 0.000
#> SRR037200     1  0.0000      1.000 1.000 0.000
#> SRR037201     1  0.0000      1.000 1.000 0.000
#> SRR037202     1  0.0000      1.000 1.000 0.000
#> SRR037203     1  0.0000      1.000 1.000 0.000
#> SRR037204     1  0.0000      1.000 1.000 0.000
#> SRR037205     1  0.0000      1.000 1.000 0.000
#> SRR037206     2  0.0000      0.999 0.000 1.000
#> SRR037207     2  0.0000      0.999 0.000 1.000
#> SRR037208     2  0.0000      0.999 0.000 1.000
#> SRR037209     2  0.0000      0.999 0.000 1.000
#> SRR037210     2  0.0000      0.999 0.000 1.000
#> SRR037211     2  0.0000      0.999 0.000 1.000
#> SRR037212     2  0.0000      0.999 0.000 1.000
#> SRR037213     2  0.0000      0.999 0.000 1.000
#> SRR037219     2  0.0000      0.999 0.000 1.000
#> SRR037214     2  0.0000      0.999 0.000 1.000
#> SRR037215     2  0.0000      0.999 0.000 1.000
#> SRR037216     2  0.0000      0.999 0.000 1.000
#> SRR037217     2  0.0000      0.999 0.000 1.000
#> SRR037218     2  0.0000      0.999 0.000 1.000
#> SRR037220     1  0.0000      1.000 1.000 0.000
#> SRR037221     1  0.0000      1.000 1.000 0.000
#> SRR037222     1  0.0000      1.000 1.000 0.000
#> SRR037223     1  0.0000      1.000 1.000 0.000
#> SRR037224     1  0.0000      1.000 1.000 0.000
#> SRR037225     1  0.0000      1.000 1.000 0.000
#> SRR037226     1  0.0000      1.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette p1    p2    p3
#> SRR037165     2  0.0747      0.990  0 0.984 0.016
#> SRR037166     2  0.0747      0.990  0 0.984 0.016
#> SRR037167     2  0.0747      0.990  0 0.984 0.016
#> SRR037168     2  0.0747      0.990  0 0.984 0.016
#> SRR037169     2  0.0747      0.990  0 0.984 0.016
#> SRR037170     2  0.0747      0.990  0 0.984 0.016
#> SRR037171     2  0.0000      0.992  0 1.000 0.000
#> SRR037172     2  0.0000      0.992  0 1.000 0.000
#> SRR037173     2  0.0000      0.992  0 1.000 0.000
#> SRR037174     2  0.0000      0.992  0 1.000 0.000
#> SRR037175     2  0.0000      0.992  0 1.000 0.000
#> SRR037176     2  0.0000      0.992  0 1.000 0.000
#> SRR037177     2  0.0000      0.992  0 1.000 0.000
#> SRR037182     3  0.0424      0.994  0 0.008 0.992
#> SRR037183     3  0.0424      0.994  0 0.008 0.992
#> SRR037184     2  0.0000      0.992  0 1.000 0.000
#> SRR037185     2  0.0000      0.992  0 1.000 0.000
#> SRR037186     2  0.0000      0.992  0 1.000 0.000
#> SRR037187     2  0.0000      0.992  0 1.000 0.000
#> SRR037188     3  0.0424      0.994  0 0.008 0.992
#> SRR037178     3  0.0000      0.996  0 0.000 1.000
#> SRR037179     3  0.0000      0.996  0 0.000 1.000
#> SRR037180     3  0.0000      0.996  0 0.000 1.000
#> SRR037181     3  0.0000      0.996  0 0.000 1.000
#> SRR037189     2  0.0000      0.992  0 1.000 0.000
#> SRR037190     2  0.0000      0.992  0 1.000 0.000
#> SRR037191     2  0.0000      0.992  0 1.000 0.000
#> SRR037192     2  0.0000      0.992  0 1.000 0.000
#> SRR037193     2  0.0747      0.990  0 0.984 0.016
#> SRR037194     2  0.0747      0.990  0 0.984 0.016
#> SRR037195     2  0.0747      0.990  0 0.984 0.016
#> SRR037196     2  0.0747      0.990  0 0.984 0.016
#> SRR037197     2  0.0747      0.990  0 0.984 0.016
#> SRR037198     2  0.0747      0.990  0 0.984 0.016
#> SRR037199     1  0.0000      1.000  1 0.000 0.000
#> SRR037200     1  0.0000      1.000  1 0.000 0.000
#> SRR037201     1  0.0000      1.000  1 0.000 0.000
#> SRR037202     1  0.0000      1.000  1 0.000 0.000
#> SRR037203     1  0.0000      1.000  1 0.000 0.000
#> SRR037204     1  0.0000      1.000  1 0.000 0.000
#> SRR037205     1  0.0000      1.000  1 0.000 0.000
#> SRR037206     3  0.0000      0.996  0 0.000 1.000
#> SRR037207     3  0.0000      0.996  0 0.000 1.000
#> SRR037208     3  0.0000      0.996  0 0.000 1.000
#> SRR037209     3  0.0000      0.996  0 0.000 1.000
#> SRR037210     3  0.0000      0.996  0 0.000 1.000
#> SRR037211     3  0.0000      0.996  0 0.000 1.000
#> SRR037212     3  0.0424      0.994  0 0.008 0.992
#> SRR037213     3  0.0424      0.994  0 0.008 0.992
#> SRR037219     3  0.0424      0.994  0 0.008 0.992
#> SRR037214     3  0.0424      0.994  0 0.008 0.992
#> SRR037215     3  0.0424      0.994  0 0.008 0.992
#> SRR037216     3  0.0000      0.996  0 0.000 1.000
#> SRR037217     3  0.0000      0.996  0 0.000 1.000
#> SRR037218     3  0.0000      0.996  0 0.000 1.000
#> SRR037220     1  0.0000      1.000  1 0.000 0.000
#> SRR037221     1  0.0000      1.000  1 0.000 0.000
#> SRR037222     1  0.0000      1.000  1 0.000 0.000
#> SRR037223     1  0.0000      1.000  1 0.000 0.000
#> SRR037224     1  0.0000      1.000  1 0.000 0.000
#> SRR037225     1  0.0000      1.000  1 0.000 0.000
#> SRR037226     1  0.0000      1.000  1 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette p1    p2    p3    p4
#> SRR037165     2  0.2589      0.695  0 0.884 0.000 0.116
#> SRR037166     2  0.2589      0.695  0 0.884 0.000 0.116
#> SRR037167     2  0.2589      0.695  0 0.884 0.000 0.116
#> SRR037168     2  0.4134      0.510  0 0.740 0.000 0.260
#> SRR037169     2  0.4804      0.170  0 0.616 0.000 0.384
#> SRR037170     2  0.3942      0.551  0 0.764 0.000 0.236
#> SRR037171     2  0.3873      0.751  0 0.772 0.000 0.228
#> SRR037172     2  0.3873      0.751  0 0.772 0.000 0.228
#> SRR037173     2  0.3873      0.751  0 0.772 0.000 0.228
#> SRR037174     2  0.3873      0.751  0 0.772 0.000 0.228
#> SRR037175     2  0.3873      0.751  0 0.772 0.000 0.228
#> SRR037176     2  0.3873      0.751  0 0.772 0.000 0.228
#> SRR037177     2  0.0817      0.769  0 0.976 0.000 0.024
#> SRR037182     4  0.7497      0.587  0 0.224 0.280 0.496
#> SRR037183     4  0.7497      0.587  0 0.224 0.280 0.496
#> SRR037184     2  0.0188      0.777  0 0.996 0.000 0.004
#> SRR037185     2  0.0921      0.768  0 0.972 0.000 0.028
#> SRR037186     2  0.0336      0.777  0 0.992 0.000 0.008
#> SRR037187     2  0.0336      0.777  0 0.992 0.000 0.008
#> SRR037188     4  0.7497      0.587  0 0.224 0.280 0.496
#> SRR037178     3  0.2868      0.720  0 0.000 0.864 0.136
#> SRR037179     3  0.2868      0.720  0 0.000 0.864 0.136
#> SRR037180     3  0.2868      0.720  0 0.000 0.864 0.136
#> SRR037181     3  0.2868      0.720  0 0.000 0.864 0.136
#> SRR037189     2  0.0336      0.777  0 0.992 0.000 0.008
#> SRR037190     2  0.3873      0.751  0 0.772 0.000 0.228
#> SRR037191     2  0.3873      0.751  0 0.772 0.000 0.228
#> SRR037192     2  0.0000      0.777  0 1.000 0.000 0.000
#> SRR037193     4  0.4193      0.825  0 0.268 0.000 0.732
#> SRR037194     4  0.4164      0.829  0 0.264 0.000 0.736
#> SRR037195     4  0.4164      0.829  0 0.264 0.000 0.736
#> SRR037196     4  0.3942      0.833  0 0.236 0.000 0.764
#> SRR037197     4  0.3873      0.830  0 0.228 0.000 0.772
#> SRR037198     4  0.3942      0.833  0 0.236 0.000 0.764
#> SRR037199     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR037200     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR037201     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR037202     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR037203     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR037204     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR037205     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR037206     3  0.0000      0.778  0 0.000 1.000 0.000
#> SRR037207     3  0.0000      0.778  0 0.000 1.000 0.000
#> SRR037208     3  0.1474      0.778  0 0.000 0.948 0.052
#> SRR037209     3  0.1474      0.778  0 0.000 0.948 0.052
#> SRR037210     3  0.0000      0.778  0 0.000 1.000 0.000
#> SRR037211     3  0.0000      0.778  0 0.000 1.000 0.000
#> SRR037212     3  0.7674     -0.321  0 0.224 0.436 0.340
#> SRR037213     3  0.7674     -0.321  0 0.224 0.436 0.340
#> SRR037219     3  0.7674     -0.321  0 0.224 0.436 0.340
#> SRR037214     3  0.6435      0.269  0 0.224 0.640 0.136
#> SRR037215     3  0.2179      0.763  0 0.012 0.924 0.064
#> SRR037216     3  0.0000      0.778  0 0.000 1.000 0.000
#> SRR037217     3  0.1474      0.778  0 0.000 0.948 0.052
#> SRR037218     3  0.1474      0.778  0 0.000 0.948 0.052
#> SRR037220     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR037221     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR037222     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR037223     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR037224     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR037225     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR037226     1  0.0000      1.000  1 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette p1    p2    p3    p4    p5
#> SRR037165     4  0.4836      0.680  0 0.356 0.000 0.612 0.032
#> SRR037166     4  0.4836      0.680  0 0.356 0.000 0.612 0.032
#> SRR037167     4  0.5043      0.674  0 0.356 0.000 0.600 0.044
#> SRR037168     5  0.6084      0.285  0 0.360 0.000 0.132 0.508
#> SRR037169     5  0.6155      0.458  0 0.148 0.000 0.336 0.516
#> SRR037170     5  0.5976      0.259  0 0.376 0.000 0.116 0.508
#> SRR037171     2  0.0000      0.999  0 1.000 0.000 0.000 0.000
#> SRR037172     2  0.0000      0.999  0 1.000 0.000 0.000 0.000
#> SRR037173     2  0.0000      0.999  0 1.000 0.000 0.000 0.000
#> SRR037174     2  0.0000      0.999  0 1.000 0.000 0.000 0.000
#> SRR037175     2  0.0000      0.999  0 1.000 0.000 0.000 0.000
#> SRR037176     2  0.0000      0.999  0 1.000 0.000 0.000 0.000
#> SRR037177     4  0.4249      0.665  0 0.432 0.000 0.568 0.000
#> SRR037182     5  0.0162      0.715  0 0.000 0.000 0.004 0.996
#> SRR037183     5  0.0162      0.715  0 0.000 0.000 0.004 0.996
#> SRR037184     4  0.4249      0.665  0 0.432 0.000 0.568 0.000
#> SRR037185     4  0.4249      0.665  0 0.432 0.000 0.568 0.000
#> SRR037186     4  0.4249      0.665  0 0.432 0.000 0.568 0.000
#> SRR037187     4  0.4249      0.665  0 0.432 0.000 0.568 0.000
#> SRR037188     5  0.0162      0.715  0 0.000 0.000 0.004 0.996
#> SRR037178     3  0.2929      0.830  0 0.000 0.820 0.000 0.180
#> SRR037179     3  0.2929      0.830  0 0.000 0.820 0.000 0.180
#> SRR037180     3  0.2929      0.830  0 0.000 0.820 0.000 0.180
#> SRR037181     3  0.2929      0.830  0 0.000 0.820 0.000 0.180
#> SRR037189     4  0.4242      0.666  0 0.428 0.000 0.572 0.000
#> SRR037190     2  0.0162      0.995  0 0.996 0.000 0.004 0.000
#> SRR037191     2  0.0000      0.999  0 1.000 0.000 0.000 0.000
#> SRR037192     4  0.4249      0.665  0 0.432 0.000 0.568 0.000
#> SRR037193     4  0.1121      0.547  0 0.000 0.000 0.956 0.044
#> SRR037194     4  0.1121      0.547  0 0.000 0.000 0.956 0.044
#> SRR037195     4  0.1121      0.547  0 0.000 0.000 0.956 0.044
#> SRR037196     4  0.1121      0.547  0 0.000 0.000 0.956 0.044
#> SRR037197     5  0.4304      0.461  0 0.000 0.000 0.484 0.516
#> SRR037198     4  0.1121      0.547  0 0.000 0.000 0.956 0.044
#> SRR037199     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR037200     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR037201     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR037202     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR037203     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR037204     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR037205     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR037206     3  0.0000      0.907  0 0.000 1.000 0.000 0.000
#> SRR037207     3  0.0000      0.907  0 0.000 1.000 0.000 0.000
#> SRR037208     3  0.1043      0.896  0 0.000 0.960 0.000 0.040
#> SRR037209     3  0.1043      0.896  0 0.000 0.960 0.000 0.040
#> SRR037210     3  0.0000      0.907  0 0.000 1.000 0.000 0.000
#> SRR037211     3  0.0000      0.907  0 0.000 1.000 0.000 0.000
#> SRR037212     5  0.2929      0.707  0 0.000 0.180 0.000 0.820
#> SRR037213     5  0.2891      0.709  0 0.000 0.176 0.000 0.824
#> SRR037219     5  0.2852      0.710  0 0.000 0.172 0.000 0.828
#> SRR037214     5  0.3003      0.704  0 0.000 0.188 0.000 0.812
#> SRR037215     3  0.2605      0.799  0 0.000 0.852 0.000 0.148
#> SRR037216     3  0.0000      0.907  0 0.000 1.000 0.000 0.000
#> SRR037217     3  0.1410      0.896  0 0.000 0.940 0.000 0.060
#> SRR037218     3  0.1410      0.896  0 0.000 0.940 0.000 0.060
#> SRR037220     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR037221     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR037222     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR037223     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR037224     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR037225     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR037226     1  0.0000      1.000  1 0.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette p1    p2    p3    p4    p5    p6
#> SRR037165     4  0.1866      0.888  0 0.008 0.000 0.908 0.084 0.000
#> SRR037166     4  0.1866      0.888  0 0.008 0.000 0.908 0.084 0.000
#> SRR037167     4  0.2346      0.876  0 0.008 0.000 0.868 0.124 0.000
#> SRR037168     5  0.0000      0.994  0 0.000 0.000 0.000 1.000 0.000
#> SRR037169     5  0.0146      0.992  0 0.004 0.000 0.000 0.996 0.000
#> SRR037170     5  0.0000      0.994  0 0.000 0.000 0.000 1.000 0.000
#> SRR037171     2  0.0000      0.983  0 1.000 0.000 0.000 0.000 0.000
#> SRR037172     2  0.0000      0.983  0 1.000 0.000 0.000 0.000 0.000
#> SRR037173     2  0.0000      0.983  0 1.000 0.000 0.000 0.000 0.000
#> SRR037174     2  0.0713      0.960  0 0.972 0.000 0.028 0.000 0.000
#> SRR037175     2  0.0000      0.983  0 1.000 0.000 0.000 0.000 0.000
#> SRR037176     2  0.0000      0.983  0 1.000 0.000 0.000 0.000 0.000
#> SRR037177     4  0.2020      0.889  0 0.096 0.000 0.896 0.008 0.000
#> SRR037182     6  0.0146      0.970  0 0.000 0.000 0.000 0.004 0.996
#> SRR037183     6  0.0000      0.971  0 0.000 0.000 0.000 0.000 1.000
#> SRR037184     4  0.1814      0.887  0 0.100 0.000 0.900 0.000 0.000
#> SRR037185     4  0.2020      0.889  0 0.096 0.000 0.896 0.008 0.000
#> SRR037186     4  0.1814      0.887  0 0.100 0.000 0.900 0.000 0.000
#> SRR037187     4  0.1814      0.887  0 0.100 0.000 0.900 0.000 0.000
#> SRR037188     6  0.0000      0.971  0 0.000 0.000 0.000 0.000 1.000
#> SRR037178     3  0.0632      0.974  0 0.000 0.976 0.000 0.000 0.024
#> SRR037179     3  0.0632      0.974  0 0.000 0.976 0.000 0.000 0.024
#> SRR037180     3  0.0632      0.974  0 0.000 0.976 0.000 0.000 0.024
#> SRR037181     3  0.0632      0.974  0 0.000 0.976 0.000 0.000 0.024
#> SRR037189     4  0.1814      0.887  0 0.100 0.000 0.900 0.000 0.000
#> SRR037190     2  0.1327      0.920  0 0.936 0.000 0.064 0.000 0.000
#> SRR037191     2  0.0000      0.983  0 1.000 0.000 0.000 0.000 0.000
#> SRR037192     4  0.1814      0.887  0 0.100 0.000 0.900 0.000 0.000
#> SRR037193     4  0.1951      0.884  0 0.000 0.000 0.908 0.076 0.016
#> SRR037194     4  0.1951      0.884  0 0.000 0.000 0.908 0.076 0.016
#> SRR037195     4  0.1951      0.884  0 0.000 0.000 0.908 0.076 0.016
#> SRR037196     4  0.2783      0.860  0 0.000 0.000 0.836 0.148 0.016
#> SRR037197     5  0.0405      0.987  0 0.000 0.000 0.008 0.988 0.004
#> SRR037198     4  0.2783      0.860  0 0.000 0.000 0.836 0.148 0.016
#> SRR037199     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR037200     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR037201     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR037202     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR037203     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR037204     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR037205     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR037206     3  0.0000      0.982  0 0.000 1.000 0.000 0.000 0.000
#> SRR037207     3  0.0000      0.982  0 0.000 1.000 0.000 0.000 0.000
#> SRR037208     3  0.0458      0.978  0 0.000 0.984 0.000 0.000 0.016
#> SRR037209     3  0.0458      0.978  0 0.000 0.984 0.000 0.000 0.016
#> SRR037210     3  0.0000      0.982  0 0.000 1.000 0.000 0.000 0.000
#> SRR037211     3  0.0000      0.982  0 0.000 1.000 0.000 0.000 0.000
#> SRR037212     6  0.0632      0.975  0 0.000 0.024 0.000 0.000 0.976
#> SRR037213     6  0.0632      0.975  0 0.000 0.024 0.000 0.000 0.976
#> SRR037219     6  0.0632      0.975  0 0.000 0.024 0.000 0.000 0.976
#> SRR037214     6  0.1411      0.939  0 0.000 0.060 0.000 0.004 0.936
#> SRR037215     3  0.0937      0.963  0 0.000 0.960 0.000 0.000 0.040
#> SRR037216     3  0.0000      0.982  0 0.000 1.000 0.000 0.000 0.000
#> SRR037217     3  0.0777      0.973  0 0.000 0.972 0.000 0.004 0.024
#> SRR037218     3  0.0777      0.973  0 0.000 0.972 0.000 0.004 0.024
#> SRR037220     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR037221     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR037222     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR037223     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR037224     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR037225     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR037226     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

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

collect_plots(res)

plot of chunk SD-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.997       0.998         0.3577 0.645   0.645
#> 3 3 1.000           0.982       0.990         0.8323 0.700   0.535
#> 4 4 0.901           0.936       0.947         0.1235 0.910   0.739
#> 5 5 0.935           0.934       0.903         0.0522 0.960   0.848
#> 6 6 0.969           0.937       0.964         0.0177 0.992   0.965

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> SRR037165     2  0.0000      0.998 0.000 1.000
#> SRR037166     2  0.0000      0.998 0.000 1.000
#> SRR037167     2  0.0000      0.998 0.000 1.000
#> SRR037168     2  0.0000      0.998 0.000 1.000
#> SRR037169     2  0.0000      0.998 0.000 1.000
#> SRR037170     2  0.0000      0.998 0.000 1.000
#> SRR037171     2  0.0000      0.998 0.000 1.000
#> SRR037172     2  0.0000      0.998 0.000 1.000
#> SRR037173     2  0.0000      0.998 0.000 1.000
#> SRR037174     2  0.0000      0.998 0.000 1.000
#> SRR037175     2  0.0000      0.998 0.000 1.000
#> SRR037176     2  0.0000      0.998 0.000 1.000
#> SRR037177     2  0.0000      0.998 0.000 1.000
#> SRR037182     2  0.0000      0.998 0.000 1.000
#> SRR037183     2  0.0000      0.998 0.000 1.000
#> SRR037184     2  0.0000      0.998 0.000 1.000
#> SRR037185     2  0.0000      0.998 0.000 1.000
#> SRR037186     2  0.0000      0.998 0.000 1.000
#> SRR037187     2  0.0000      0.998 0.000 1.000
#> SRR037188     2  0.0000      0.998 0.000 1.000
#> SRR037178     2  0.0000      0.998 0.000 1.000
#> SRR037179     2  0.0000      0.998 0.000 1.000
#> SRR037180     2  0.0000      0.998 0.000 1.000
#> SRR037181     2  0.0000      0.998 0.000 1.000
#> SRR037189     2  0.0000      0.998 0.000 1.000
#> SRR037190     2  0.0000      0.998 0.000 1.000
#> SRR037191     2  0.0000      0.998 0.000 1.000
#> SRR037192     2  0.0000      0.998 0.000 1.000
#> SRR037193     2  0.0000      0.998 0.000 1.000
#> SRR037194     2  0.0000      0.998 0.000 1.000
#> SRR037195     2  0.0000      0.998 0.000 1.000
#> SRR037196     2  0.0000      0.998 0.000 1.000
#> SRR037197     2  0.0000      0.998 0.000 1.000
#> SRR037198     2  0.0000      0.998 0.000 1.000
#> SRR037199     1  0.0000      1.000 1.000 0.000
#> SRR037200     1  0.0000      1.000 1.000 0.000
#> SRR037201     1  0.0000      1.000 1.000 0.000
#> SRR037202     1  0.0000      1.000 1.000 0.000
#> SRR037203     1  0.0000      1.000 1.000 0.000
#> SRR037204     1  0.0000      1.000 1.000 0.000
#> SRR037205     1  0.0000      1.000 1.000 0.000
#> SRR037206     2  0.0000      0.998 0.000 1.000
#> SRR037207     2  0.0000      0.998 0.000 1.000
#> SRR037208     2  0.0000      0.998 0.000 1.000
#> SRR037209     2  0.0000      0.998 0.000 1.000
#> SRR037210     2  0.0000      0.998 0.000 1.000
#> SRR037211     2  0.0000      0.998 0.000 1.000
#> SRR037212     2  0.0376      0.994 0.004 0.996
#> SRR037213     2  0.0376      0.994 0.004 0.996
#> SRR037219     2  0.4431      0.899 0.092 0.908
#> SRR037214     2  0.0376      0.994 0.004 0.996
#> SRR037215     2  0.0000      0.998 0.000 1.000
#> SRR037216     2  0.0000      0.998 0.000 1.000
#> SRR037217     2  0.0000      0.998 0.000 1.000
#> SRR037218     2  0.0000      0.998 0.000 1.000
#> SRR037220     1  0.0000      1.000 1.000 0.000
#> SRR037221     1  0.0000      1.000 1.000 0.000
#> SRR037222     1  0.0000      1.000 1.000 0.000
#> SRR037223     1  0.0000      1.000 1.000 0.000
#> SRR037224     1  0.0000      1.000 1.000 0.000
#> SRR037225     1  0.0000      1.000 1.000 0.000
#> SRR037226     1  0.0000      1.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> SRR037165     2  0.0000      0.977 0.000 1.000 0.000
#> SRR037166     2  0.0000      0.977 0.000 1.000 0.000
#> SRR037167     2  0.0000      0.977 0.000 1.000 0.000
#> SRR037168     2  0.0000      0.977 0.000 1.000 0.000
#> SRR037169     2  0.0000      0.977 0.000 1.000 0.000
#> SRR037170     2  0.0000      0.977 0.000 1.000 0.000
#> SRR037171     2  0.2625      0.930 0.000 0.916 0.084
#> SRR037172     2  0.2625      0.930 0.000 0.916 0.084
#> SRR037173     2  0.0892      0.969 0.000 0.980 0.020
#> SRR037174     2  0.0592      0.973 0.000 0.988 0.012
#> SRR037175     2  0.2625      0.930 0.000 0.916 0.084
#> SRR037176     2  0.2625      0.930 0.000 0.916 0.084
#> SRR037177     2  0.0000      0.977 0.000 1.000 0.000
#> SRR037182     3  0.0592      0.985 0.000 0.012 0.988
#> SRR037183     3  0.1753      0.945 0.000 0.048 0.952
#> SRR037184     2  0.0000      0.977 0.000 1.000 0.000
#> SRR037185     2  0.0000      0.977 0.000 1.000 0.000
#> SRR037186     2  0.0000      0.977 0.000 1.000 0.000
#> SRR037187     2  0.0000      0.977 0.000 1.000 0.000
#> SRR037188     3  0.0000      0.996 0.000 0.000 1.000
#> SRR037178     3  0.0000      0.996 0.000 0.000 1.000
#> SRR037179     3  0.0000      0.996 0.000 0.000 1.000
#> SRR037180     3  0.0000      0.996 0.000 0.000 1.000
#> SRR037181     3  0.0000      0.996 0.000 0.000 1.000
#> SRR037189     2  0.0000      0.977 0.000 1.000 0.000
#> SRR037190     2  0.0237      0.976 0.000 0.996 0.004
#> SRR037191     2  0.2625      0.930 0.000 0.916 0.084
#> SRR037192     2  0.0000      0.977 0.000 1.000 0.000
#> SRR037193     2  0.2625      0.930 0.000 0.916 0.084
#> SRR037194     2  0.1163      0.965 0.000 0.972 0.028
#> SRR037195     2  0.0424      0.974 0.000 0.992 0.008
#> SRR037196     2  0.0000      0.977 0.000 1.000 0.000
#> SRR037197     2  0.0000      0.977 0.000 1.000 0.000
#> SRR037198     2  0.0000      0.977 0.000 1.000 0.000
#> SRR037199     1  0.0000      1.000 1.000 0.000 0.000
#> SRR037200     1  0.0000      1.000 1.000 0.000 0.000
#> SRR037201     1  0.0000      1.000 1.000 0.000 0.000
#> SRR037202     1  0.0000      1.000 1.000 0.000 0.000
#> SRR037203     1  0.0000      1.000 1.000 0.000 0.000
#> SRR037204     1  0.0000      1.000 1.000 0.000 0.000
#> SRR037205     1  0.0000      1.000 1.000 0.000 0.000
#> SRR037206     3  0.0000      0.996 0.000 0.000 1.000
#> SRR037207     3  0.0000      0.996 0.000 0.000 1.000
#> SRR037208     3  0.0000      0.996 0.000 0.000 1.000
#> SRR037209     3  0.0000      0.996 0.000 0.000 1.000
#> SRR037210     3  0.0000      0.996 0.000 0.000 1.000
#> SRR037211     3  0.0000      0.996 0.000 0.000 1.000
#> SRR037212     3  0.0000      0.996 0.000 0.000 1.000
#> SRR037213     3  0.0000      0.996 0.000 0.000 1.000
#> SRR037219     3  0.0592      0.985 0.012 0.000 0.988
#> SRR037214     3  0.0000      0.996 0.000 0.000 1.000
#> SRR037215     3  0.0000      0.996 0.000 0.000 1.000
#> SRR037216     3  0.0000      0.996 0.000 0.000 1.000
#> SRR037217     3  0.0000      0.996 0.000 0.000 1.000
#> SRR037218     3  0.0000      0.996 0.000 0.000 1.000
#> SRR037220     1  0.0000      1.000 1.000 0.000 0.000
#> SRR037221     1  0.0000      1.000 1.000 0.000 0.000
#> SRR037222     1  0.0000      1.000 1.000 0.000 0.000
#> SRR037223     1  0.0000      1.000 1.000 0.000 0.000
#> SRR037224     1  0.0000      1.000 1.000 0.000 0.000
#> SRR037225     1  0.0000      1.000 1.000 0.000 0.000
#> SRR037226     1  0.0000      1.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette   p1    p2    p3    p4
#> SRR037165     4  0.4898      0.522 0.00 0.416 0.000 0.584
#> SRR037166     4  0.4072      0.814 0.00 0.252 0.000 0.748
#> SRR037167     4  0.2647      0.917 0.00 0.120 0.000 0.880
#> SRR037168     4  0.2647      0.917 0.00 0.120 0.000 0.880
#> SRR037169     4  0.2647      0.917 0.00 0.120 0.000 0.880
#> SRR037170     4  0.2647      0.917 0.00 0.120 0.000 0.880
#> SRR037171     2  0.0000      0.951 0.00 1.000 0.000 0.000
#> SRR037172     2  0.0000      0.951 0.00 1.000 0.000 0.000
#> SRR037173     2  0.0000      0.951 0.00 1.000 0.000 0.000
#> SRR037174     2  0.0000      0.951 0.00 1.000 0.000 0.000
#> SRR037175     2  0.0000      0.951 0.00 1.000 0.000 0.000
#> SRR037176     2  0.0000      0.951 0.00 1.000 0.000 0.000
#> SRR037177     2  0.2149      0.871 0.00 0.912 0.000 0.088
#> SRR037182     3  0.0000      1.000 0.00 0.000 1.000 0.000
#> SRR037183     3  0.0336      0.992 0.00 0.000 0.992 0.008
#> SRR037184     2  0.0000      0.951 0.00 1.000 0.000 0.000
#> SRR037185     2  0.2081      0.876 0.00 0.916 0.000 0.084
#> SRR037186     2  0.0188      0.949 0.00 0.996 0.000 0.004
#> SRR037187     2  0.0000      0.951 0.00 1.000 0.000 0.000
#> SRR037188     3  0.0000      1.000 0.00 0.000 1.000 0.000
#> SRR037178     3  0.0000      1.000 0.00 0.000 1.000 0.000
#> SRR037179     3  0.0000      1.000 0.00 0.000 1.000 0.000
#> SRR037180     3  0.0000      1.000 0.00 0.000 1.000 0.000
#> SRR037181     3  0.0000      1.000 0.00 0.000 1.000 0.000
#> SRR037189     2  0.0188      0.949 0.00 0.996 0.000 0.004
#> SRR037190     2  0.0000      0.951 0.00 1.000 0.000 0.000
#> SRR037191     2  0.0000      0.951 0.00 1.000 0.000 0.000
#> SRR037192     2  0.0000      0.951 0.00 1.000 0.000 0.000
#> SRR037193     2  0.2149      0.861 0.00 0.912 0.000 0.088
#> SRR037194     2  0.4643      0.287 0.00 0.656 0.000 0.344
#> SRR037195     4  0.4382      0.760 0.00 0.296 0.000 0.704
#> SRR037196     4  0.2647      0.917 0.00 0.120 0.000 0.880
#> SRR037197     4  0.2647      0.917 0.00 0.120 0.000 0.880
#> SRR037198     4  0.2647      0.917 0.00 0.120 0.000 0.880
#> SRR037199     1  0.2647      0.948 0.88 0.000 0.000 0.120
#> SRR037200     1  0.2647      0.948 0.88 0.000 0.000 0.120
#> SRR037201     1  0.2647      0.948 0.88 0.000 0.000 0.120
#> SRR037202     1  0.2647      0.948 0.88 0.000 0.000 0.120
#> SRR037203     1  0.2647      0.948 0.88 0.000 0.000 0.120
#> SRR037204     1  0.2647      0.948 0.88 0.000 0.000 0.120
#> SRR037205     1  0.2647      0.948 0.88 0.000 0.000 0.120
#> SRR037206     3  0.0000      1.000 0.00 0.000 1.000 0.000
#> SRR037207     3  0.0000      1.000 0.00 0.000 1.000 0.000
#> SRR037208     3  0.0000      1.000 0.00 0.000 1.000 0.000
#> SRR037209     3  0.0000      1.000 0.00 0.000 1.000 0.000
#> SRR037210     3  0.0000      1.000 0.00 0.000 1.000 0.000
#> SRR037211     3  0.0000      1.000 0.00 0.000 1.000 0.000
#> SRR037212     3  0.0000      1.000 0.00 0.000 1.000 0.000
#> SRR037213     3  0.0000      1.000 0.00 0.000 1.000 0.000
#> SRR037219     3  0.0000      1.000 0.00 0.000 1.000 0.000
#> SRR037214     3  0.0000      1.000 0.00 0.000 1.000 0.000
#> SRR037215     3  0.0000      1.000 0.00 0.000 1.000 0.000
#> SRR037216     3  0.0000      1.000 0.00 0.000 1.000 0.000
#> SRR037217     3  0.0000      1.000 0.00 0.000 1.000 0.000
#> SRR037218     3  0.0000      1.000 0.00 0.000 1.000 0.000
#> SRR037220     1  0.0000      0.948 1.00 0.000 0.000 0.000
#> SRR037221     1  0.0000      0.948 1.00 0.000 0.000 0.000
#> SRR037222     1  0.0000      0.948 1.00 0.000 0.000 0.000
#> SRR037223     1  0.0000      0.948 1.00 0.000 0.000 0.000
#> SRR037224     1  0.0000      0.948 1.00 0.000 0.000 0.000
#> SRR037225     1  0.0000      0.948 1.00 0.000 0.000 0.000
#> SRR037226     1  0.0000      0.948 1.00 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette   p1    p2    p3    p4    p5
#> SRR037165     4  0.1965      0.879 0.00 0.096 0.000 0.904 0.000
#> SRR037166     4  0.0794      0.932 0.00 0.028 0.000 0.972 0.000
#> SRR037167     4  0.0000      0.938 0.00 0.000 0.000 1.000 0.000
#> SRR037168     4  0.0290      0.938 0.00 0.000 0.000 0.992 0.008
#> SRR037169     4  0.0290      0.938 0.00 0.000 0.000 0.992 0.008
#> SRR037170     4  0.0290      0.938 0.00 0.000 0.000 0.992 0.008
#> SRR037171     2  0.0000      0.959 0.00 1.000 0.000 0.000 0.000
#> SRR037172     2  0.0000      0.959 0.00 1.000 0.000 0.000 0.000
#> SRR037173     2  0.0000      0.959 0.00 1.000 0.000 0.000 0.000
#> SRR037174     2  0.0000      0.959 0.00 1.000 0.000 0.000 0.000
#> SRR037175     2  0.0000      0.959 0.00 1.000 0.000 0.000 0.000
#> SRR037176     2  0.0000      0.959 0.00 1.000 0.000 0.000 0.000
#> SRR037177     2  0.1952      0.887 0.00 0.912 0.000 0.084 0.004
#> SRR037182     3  0.1043      0.939 0.00 0.000 0.960 0.000 0.040
#> SRR037183     3  0.1341      0.931 0.00 0.000 0.944 0.000 0.056
#> SRR037184     2  0.0000      0.959 0.00 1.000 0.000 0.000 0.000
#> SRR037185     2  0.1544      0.904 0.00 0.932 0.000 0.068 0.000
#> SRR037186     2  0.0000      0.959 0.00 1.000 0.000 0.000 0.000
#> SRR037187     2  0.0000      0.959 0.00 1.000 0.000 0.000 0.000
#> SRR037188     3  0.0794      0.944 0.00 0.000 0.972 0.000 0.028
#> SRR037178     3  0.0000      0.950 0.00 0.000 1.000 0.000 0.000
#> SRR037179     3  0.0000      0.950 0.00 0.000 1.000 0.000 0.000
#> SRR037180     3  0.0000      0.950 0.00 0.000 1.000 0.000 0.000
#> SRR037181     3  0.0000      0.950 0.00 0.000 1.000 0.000 0.000
#> SRR037189     2  0.0000      0.959 0.00 1.000 0.000 0.000 0.000
#> SRR037190     2  0.0000      0.959 0.00 1.000 0.000 0.000 0.000
#> SRR037191     2  0.0000      0.959 0.00 1.000 0.000 0.000 0.000
#> SRR037192     2  0.0000      0.959 0.00 1.000 0.000 0.000 0.000
#> SRR037193     2  0.6566      0.314 0.00 0.512 0.008 0.192 0.288
#> SRR037194     4  0.4800      0.614 0.00 0.272 0.000 0.676 0.052
#> SRR037195     4  0.1753      0.926 0.00 0.032 0.000 0.936 0.032
#> SRR037196     4  0.0794      0.938 0.00 0.000 0.000 0.972 0.028
#> SRR037197     4  0.0794      0.938 0.00 0.000 0.000 0.972 0.028
#> SRR037198     4  0.0794      0.938 0.00 0.000 0.000 0.972 0.028
#> SRR037199     5  0.4227      1.000 0.42 0.000 0.000 0.000 0.580
#> SRR037200     5  0.4227      1.000 0.42 0.000 0.000 0.000 0.580
#> SRR037201     5  0.4227      1.000 0.42 0.000 0.000 0.000 0.580
#> SRR037202     5  0.4227      1.000 0.42 0.000 0.000 0.000 0.580
#> SRR037203     5  0.4227      1.000 0.42 0.000 0.000 0.000 0.580
#> SRR037204     5  0.4227      1.000 0.42 0.000 0.000 0.000 0.580
#> SRR037205     5  0.4227      1.000 0.42 0.000 0.000 0.000 0.580
#> SRR037206     3  0.2852      0.865 0.00 0.000 0.828 0.000 0.172
#> SRR037207     3  0.3109      0.845 0.00 0.000 0.800 0.000 0.200
#> SRR037208     3  0.0162      0.950 0.00 0.000 0.996 0.000 0.004
#> SRR037209     3  0.0162      0.950 0.00 0.000 0.996 0.000 0.004
#> SRR037210     3  0.2773      0.870 0.00 0.000 0.836 0.000 0.164
#> SRR037211     3  0.3336      0.822 0.00 0.000 0.772 0.000 0.228
#> SRR037212     3  0.0794      0.944 0.00 0.000 0.972 0.000 0.028
#> SRR037213     3  0.0794      0.944 0.00 0.000 0.972 0.000 0.028
#> SRR037219     3  0.0794      0.944 0.00 0.000 0.972 0.000 0.028
#> SRR037214     3  0.0000      0.950 0.00 0.000 1.000 0.000 0.000
#> SRR037215     3  0.0162      0.950 0.00 0.000 0.996 0.000 0.004
#> SRR037216     3  0.2773      0.870 0.00 0.000 0.836 0.000 0.164
#> SRR037217     3  0.0000      0.950 0.00 0.000 1.000 0.000 0.000
#> SRR037218     3  0.0000      0.950 0.00 0.000 1.000 0.000 0.000
#> SRR037220     1  0.0000      1.000 1.00 0.000 0.000 0.000 0.000
#> SRR037221     1  0.0000      1.000 1.00 0.000 0.000 0.000 0.000
#> SRR037222     1  0.0000      1.000 1.00 0.000 0.000 0.000 0.000
#> SRR037223     1  0.0000      1.000 1.00 0.000 0.000 0.000 0.000
#> SRR037224     1  0.0000      1.000 1.00 0.000 0.000 0.000 0.000
#> SRR037225     1  0.0000      1.000 1.00 0.000 0.000 0.000 0.000
#> SRR037226     1  0.0000      1.000 1.00 0.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1   p2    p3    p4    p5    p6
#> SRR037165     4  0.0000      0.892 0.000 0.00 0.000 1.000 0.000 0.000
#> SRR037166     4  0.0146      0.892 0.000 0.00 0.000 0.996 0.000 0.004
#> SRR037167     4  0.0458      0.889 0.000 0.00 0.000 0.984 0.000 0.016
#> SRR037168     4  0.0547      0.887 0.000 0.00 0.000 0.980 0.000 0.020
#> SRR037169     4  0.0547      0.887 0.000 0.00 0.000 0.980 0.000 0.020
#> SRR037170     4  0.0547      0.887 0.000 0.00 0.000 0.980 0.000 0.020
#> SRR037171     2  0.0000      0.997 0.000 1.00 0.000 0.000 0.000 0.000
#> SRR037172     2  0.0000      0.997 0.000 1.00 0.000 0.000 0.000 0.000
#> SRR037173     2  0.0000      0.997 0.000 1.00 0.000 0.000 0.000 0.000
#> SRR037174     2  0.0000      0.997 0.000 1.00 0.000 0.000 0.000 0.000
#> SRR037175     2  0.0000      0.997 0.000 1.00 0.000 0.000 0.000 0.000
#> SRR037176     2  0.0000      0.997 0.000 1.00 0.000 0.000 0.000 0.000
#> SRR037177     2  0.0603      0.981 0.000 0.98 0.000 0.004 0.000 0.016
#> SRR037182     3  0.0713      0.952 0.000 0.00 0.972 0.000 0.000 0.028
#> SRR037183     3  0.1531      0.923 0.000 0.00 0.928 0.000 0.004 0.068
#> SRR037184     2  0.0000      0.997 0.000 1.00 0.000 0.000 0.000 0.000
#> SRR037185     2  0.0603      0.981 0.000 0.98 0.000 0.004 0.000 0.016
#> SRR037186     2  0.0000      0.997 0.000 1.00 0.000 0.000 0.000 0.000
#> SRR037187     2  0.0000      0.997 0.000 1.00 0.000 0.000 0.000 0.000
#> SRR037188     3  0.0713      0.952 0.000 0.00 0.972 0.000 0.000 0.028
#> SRR037178     3  0.0000      0.961 0.000 0.00 1.000 0.000 0.000 0.000
#> SRR037179     3  0.0000      0.961 0.000 0.00 1.000 0.000 0.000 0.000
#> SRR037180     3  0.0000      0.961 0.000 0.00 1.000 0.000 0.000 0.000
#> SRR037181     3  0.0000      0.961 0.000 0.00 1.000 0.000 0.000 0.000
#> SRR037189     2  0.0000      0.997 0.000 1.00 0.000 0.000 0.000 0.000
#> SRR037190     2  0.0000      0.997 0.000 1.00 0.000 0.000 0.000 0.000
#> SRR037191     2  0.0000      0.997 0.000 1.00 0.000 0.000 0.000 0.000
#> SRR037192     2  0.0000      0.997 0.000 1.00 0.000 0.000 0.000 0.000
#> SRR037193     6  0.3584      0.000 0.000 0.00 0.004 0.308 0.000 0.688
#> SRR037194     4  0.2664      0.748 0.000 0.00 0.000 0.816 0.000 0.184
#> SRR037195     4  0.2527      0.775 0.000 0.00 0.000 0.832 0.000 0.168
#> SRR037196     4  0.1714      0.867 0.000 0.00 0.000 0.908 0.000 0.092
#> SRR037197     4  0.1663      0.869 0.000 0.00 0.000 0.912 0.000 0.088
#> SRR037198     4  0.1714      0.867 0.000 0.00 0.000 0.908 0.000 0.092
#> SRR037199     1  0.0000      1.000 1.000 0.00 0.000 0.000 0.000 0.000
#> SRR037200     1  0.0000      1.000 1.000 0.00 0.000 0.000 0.000 0.000
#> SRR037201     1  0.0000      1.000 1.000 0.00 0.000 0.000 0.000 0.000
#> SRR037202     1  0.0000      1.000 1.000 0.00 0.000 0.000 0.000 0.000
#> SRR037203     1  0.0000      1.000 1.000 0.00 0.000 0.000 0.000 0.000
#> SRR037204     1  0.0000      1.000 1.000 0.00 0.000 0.000 0.000 0.000
#> SRR037205     1  0.0000      1.000 1.000 0.00 0.000 0.000 0.000 0.000
#> SRR037206     3  0.1957      0.895 0.000 0.00 0.888 0.000 0.000 0.112
#> SRR037207     3  0.2260      0.870 0.000 0.00 0.860 0.000 0.000 0.140
#> SRR037208     3  0.0146      0.960 0.000 0.00 0.996 0.000 0.000 0.004
#> SRR037209     3  0.0000      0.961 0.000 0.00 1.000 0.000 0.000 0.000
#> SRR037210     3  0.1501      0.922 0.000 0.00 0.924 0.000 0.000 0.076
#> SRR037211     3  0.2996      0.768 0.000 0.00 0.772 0.000 0.000 0.228
#> SRR037212     3  0.0363      0.958 0.000 0.00 0.988 0.000 0.000 0.012
#> SRR037213     3  0.0363      0.958 0.000 0.00 0.988 0.000 0.000 0.012
#> SRR037219     3  0.0547      0.956 0.000 0.00 0.980 0.000 0.000 0.020
#> SRR037214     3  0.0000      0.961 0.000 0.00 1.000 0.000 0.000 0.000
#> SRR037215     3  0.0000      0.961 0.000 0.00 1.000 0.000 0.000 0.000
#> SRR037216     3  0.1556      0.919 0.000 0.00 0.920 0.000 0.000 0.080
#> SRR037217     3  0.0000      0.961 0.000 0.00 1.000 0.000 0.000 0.000
#> SRR037218     3  0.0000      0.961 0.000 0.00 1.000 0.000 0.000 0.000
#> SRR037220     5  0.1007      1.000 0.044 0.00 0.000 0.000 0.956 0.000
#> SRR037221     5  0.1007      1.000 0.044 0.00 0.000 0.000 0.956 0.000
#> SRR037222     5  0.1007      1.000 0.044 0.00 0.000 0.000 0.956 0.000
#> SRR037223     5  0.1007      1.000 0.044 0.00 0.000 0.000 0.956 0.000
#> SRR037224     5  0.1007      1.000 0.044 0.00 0.000 0.000 0.956 0.000
#> SRR037225     5  0.1007      1.000 0.044 0.00 0.000 0.000 0.956 0.000
#> SRR037226     5  0.1007      1.000 0.044 0.00 0.000 0.000 0.956 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 15332 rows and 62 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#>   Subgroups are detected by 'hclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 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-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.524           0.831       0.903         0.4121 0.645   0.645
#> 3 3 0.709           0.897       0.928         0.5523 0.700   0.535
#> 4 4 0.926           0.968       0.977         0.1685 0.905   0.724
#> 5 5 0.904           0.917       0.919         0.0293 0.981   0.924
#> 6 6 0.943           0.948       0.966         0.0316 0.974   0.888

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> SRR037165     2  0.9580      0.591 0.380 0.620
#> SRR037166     2  0.9580      0.591 0.380 0.620
#> SRR037167     2  0.9580      0.591 0.380 0.620
#> SRR037168     2  0.9580      0.591 0.380 0.620
#> SRR037169     2  0.9580      0.591 0.380 0.620
#> SRR037170     2  0.9580      0.591 0.380 0.620
#> SRR037171     2  0.0000      0.858 0.000 1.000
#> SRR037172     2  0.0000      0.858 0.000 1.000
#> SRR037173     2  0.0000      0.858 0.000 1.000
#> SRR037174     2  0.0000      0.858 0.000 1.000
#> SRR037175     2  0.0000      0.858 0.000 1.000
#> SRR037176     2  0.0000      0.858 0.000 1.000
#> SRR037177     2  0.6801      0.783 0.180 0.820
#> SRR037182     2  0.0672      0.860 0.008 0.992
#> SRR037183     2  0.0672      0.860 0.008 0.992
#> SRR037184     2  0.6801      0.783 0.180 0.820
#> SRR037185     2  0.6801      0.783 0.180 0.820
#> SRR037186     2  0.6801      0.783 0.180 0.820
#> SRR037187     2  0.6801      0.783 0.180 0.820
#> SRR037188     2  0.0672      0.860 0.008 0.992
#> SRR037178     2  0.0672      0.860 0.008 0.992
#> SRR037179     2  0.0672      0.860 0.008 0.992
#> SRR037180     2  0.0672      0.860 0.008 0.992
#> SRR037181     2  0.0672      0.860 0.008 0.992
#> SRR037189     2  0.6801      0.783 0.180 0.820
#> SRR037190     2  0.0000      0.858 0.000 1.000
#> SRR037191     2  0.0000      0.858 0.000 1.000
#> SRR037192     2  0.6801      0.783 0.180 0.820
#> SRR037193     2  0.9580      0.591 0.380 0.620
#> SRR037194     2  0.9580      0.591 0.380 0.620
#> SRR037195     2  0.9580      0.591 0.380 0.620
#> SRR037196     2  0.9580      0.591 0.380 0.620
#> SRR037197     2  0.9580      0.591 0.380 0.620
#> SRR037198     2  0.9580      0.591 0.380 0.620
#> SRR037199     1  0.0000      1.000 1.000 0.000
#> SRR037200     1  0.0000      1.000 1.000 0.000
#> SRR037201     1  0.0000      1.000 1.000 0.000
#> SRR037202     1  0.0000      1.000 1.000 0.000
#> SRR037203     1  0.0000      1.000 1.000 0.000
#> SRR037204     1  0.0000      1.000 1.000 0.000
#> SRR037205     1  0.0000      1.000 1.000 0.000
#> SRR037206     2  0.0672      0.860 0.008 0.992
#> SRR037207     2  0.0672      0.860 0.008 0.992
#> SRR037208     2  0.0672      0.860 0.008 0.992
#> SRR037209     2  0.0672      0.860 0.008 0.992
#> SRR037210     2  0.0672      0.860 0.008 0.992
#> SRR037211     2  0.0672      0.860 0.008 0.992
#> SRR037212     2  0.0672      0.860 0.008 0.992
#> SRR037213     2  0.0672      0.860 0.008 0.992
#> SRR037219     2  0.0672      0.860 0.008 0.992
#> SRR037214     2  0.0672      0.860 0.008 0.992
#> SRR037215     2  0.0672      0.860 0.008 0.992
#> SRR037216     2  0.0672      0.860 0.008 0.992
#> SRR037217     2  0.0672      0.860 0.008 0.992
#> SRR037218     2  0.0672      0.860 0.008 0.992
#> SRR037220     1  0.0000      1.000 1.000 0.000
#> SRR037221     1  0.0000      1.000 1.000 0.000
#> SRR037222     1  0.0000      1.000 1.000 0.000
#> SRR037223     1  0.0000      1.000 1.000 0.000
#> SRR037224     1  0.0000      1.000 1.000 0.000
#> SRR037225     1  0.0000      1.000 1.000 0.000
#> SRR037226     1  0.0000      1.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette p1   p2   p3
#> SRR037165     2   0.000      0.806  0 1.00 0.00
#> SRR037166     2   0.000      0.806  0 1.00 0.00
#> SRR037167     2   0.000      0.806  0 1.00 0.00
#> SRR037168     2   0.000      0.806  0 1.00 0.00
#> SRR037169     2   0.000      0.806  0 1.00 0.00
#> SRR037170     2   0.000      0.806  0 1.00 0.00
#> SRR037171     2   0.604      0.660  0 0.62 0.38
#> SRR037172     2   0.604      0.660  0 0.62 0.38
#> SRR037173     2   0.604      0.660  0 0.62 0.38
#> SRR037174     2   0.604      0.660  0 0.62 0.38
#> SRR037175     2   0.604      0.660  0 0.62 0.38
#> SRR037176     2   0.604      0.660  0 0.62 0.38
#> SRR037177     2   0.455      0.804  0 0.80 0.20
#> SRR037182     3   0.000      1.000  0 0.00 1.00
#> SRR037183     3   0.000      1.000  0 0.00 1.00
#> SRR037184     2   0.455      0.804  0 0.80 0.20
#> SRR037185     2   0.455      0.804  0 0.80 0.20
#> SRR037186     2   0.455      0.804  0 0.80 0.20
#> SRR037187     2   0.455      0.804  0 0.80 0.20
#> SRR037188     3   0.000      1.000  0 0.00 1.00
#> SRR037178     3   0.000      1.000  0 0.00 1.00
#> SRR037179     3   0.000      1.000  0 0.00 1.00
#> SRR037180     3   0.000      1.000  0 0.00 1.00
#> SRR037181     3   0.000      1.000  0 0.00 1.00
#> SRR037189     2   0.455      0.804  0 0.80 0.20
#> SRR037190     2   0.604      0.660  0 0.62 0.38
#> SRR037191     2   0.604      0.660  0 0.62 0.38
#> SRR037192     2   0.455      0.804  0 0.80 0.20
#> SRR037193     2   0.000      0.806  0 1.00 0.00
#> SRR037194     2   0.000      0.806  0 1.00 0.00
#> SRR037195     2   0.000      0.806  0 1.00 0.00
#> SRR037196     2   0.000      0.806  0 1.00 0.00
#> SRR037197     2   0.000      0.806  0 1.00 0.00
#> SRR037198     2   0.000      0.806  0 1.00 0.00
#> SRR037199     1   0.000      1.000  1 0.00 0.00
#> SRR037200     1   0.000      1.000  1 0.00 0.00
#> SRR037201     1   0.000      1.000  1 0.00 0.00
#> SRR037202     1   0.000      1.000  1 0.00 0.00
#> SRR037203     1   0.000      1.000  1 0.00 0.00
#> SRR037204     1   0.000      1.000  1 0.00 0.00
#> SRR037205     1   0.000      1.000  1 0.00 0.00
#> SRR037206     3   0.000      1.000  0 0.00 1.00
#> SRR037207     3   0.000      1.000  0 0.00 1.00
#> SRR037208     3   0.000      1.000  0 0.00 1.00
#> SRR037209     3   0.000      1.000  0 0.00 1.00
#> SRR037210     3   0.000      1.000  0 0.00 1.00
#> SRR037211     3   0.000      1.000  0 0.00 1.00
#> SRR037212     3   0.000      1.000  0 0.00 1.00
#> SRR037213     3   0.000      1.000  0 0.00 1.00
#> SRR037219     3   0.000      1.000  0 0.00 1.00
#> SRR037214     3   0.000      1.000  0 0.00 1.00
#> SRR037215     3   0.000      1.000  0 0.00 1.00
#> SRR037216     3   0.000      1.000  0 0.00 1.00
#> SRR037217     3   0.000      1.000  0 0.00 1.00
#> SRR037218     3   0.000      1.000  0 0.00 1.00
#> SRR037220     1   0.000      1.000  1 0.00 0.00
#> SRR037221     1   0.000      1.000  1 0.00 0.00
#> SRR037222     1   0.000      1.000  1 0.00 0.00
#> SRR037223     1   0.000      1.000  1 0.00 0.00
#> SRR037224     1   0.000      1.000  1 0.00 0.00
#> SRR037225     1   0.000      1.000  1 0.00 0.00
#> SRR037226     1   0.000      1.000  1 0.00 0.00

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette p1    p2 p3    p4
#> SRR037165     4   0.000      1.000  0 0.000  0 1.000
#> SRR037166     4   0.000      1.000  0 0.000  0 1.000
#> SRR037167     4   0.000      1.000  0 0.000  0 1.000
#> SRR037168     4   0.000      1.000  0 0.000  0 1.000
#> SRR037169     4   0.000      1.000  0 0.000  0 1.000
#> SRR037170     4   0.000      1.000  0 0.000  0 1.000
#> SRR037171     2   0.000      0.886  0 1.000  0 0.000
#> SRR037172     2   0.000      0.886  0 1.000  0 0.000
#> SRR037173     2   0.000      0.886  0 1.000  0 0.000
#> SRR037174     2   0.000      0.886  0 1.000  0 0.000
#> SRR037175     2   0.000      0.886  0 1.000  0 0.000
#> SRR037176     2   0.000      0.886  0 1.000  0 0.000
#> SRR037177     2   0.369      0.850  0 0.792  0 0.208
#> SRR037182     3   0.000      1.000  0 0.000  1 0.000
#> SRR037183     3   0.000      1.000  0 0.000  1 0.000
#> SRR037184     2   0.369      0.850  0 0.792  0 0.208
#> SRR037185     2   0.369      0.850  0 0.792  0 0.208
#> SRR037186     2   0.369      0.850  0 0.792  0 0.208
#> SRR037187     2   0.369      0.850  0 0.792  0 0.208
#> SRR037188     3   0.000      1.000  0 0.000  1 0.000
#> SRR037178     3   0.000      1.000  0 0.000  1 0.000
#> SRR037179     3   0.000      1.000  0 0.000  1 0.000
#> SRR037180     3   0.000      1.000  0 0.000  1 0.000
#> SRR037181     3   0.000      1.000  0 0.000  1 0.000
#> SRR037189     2   0.369      0.850  0 0.792  0 0.208
#> SRR037190     2   0.000      0.886  0 1.000  0 0.000
#> SRR037191     2   0.000      0.886  0 1.000  0 0.000
#> SRR037192     2   0.369      0.850  0 0.792  0 0.208
#> SRR037193     4   0.000      1.000  0 0.000  0 1.000
#> SRR037194     4   0.000      1.000  0 0.000  0 1.000
#> SRR037195     4   0.000      1.000  0 0.000  0 1.000
#> SRR037196     4   0.000      1.000  0 0.000  0 1.000
#> SRR037197     4   0.000      1.000  0 0.000  0 1.000
#> SRR037198     4   0.000      1.000  0 0.000  0 1.000
#> SRR037199     1   0.000      1.000  1 0.000  0 0.000
#> SRR037200     1   0.000      1.000  1 0.000  0 0.000
#> SRR037201     1   0.000      1.000  1 0.000  0 0.000
#> SRR037202     1   0.000      1.000  1 0.000  0 0.000
#> SRR037203     1   0.000      1.000  1 0.000  0 0.000
#> SRR037204     1   0.000      1.000  1 0.000  0 0.000
#> SRR037205     1   0.000      1.000  1 0.000  0 0.000
#> SRR037206     3   0.000      1.000  0 0.000  1 0.000
#> SRR037207     3   0.000      1.000  0 0.000  1 0.000
#> SRR037208     3   0.000      1.000  0 0.000  1 0.000
#> SRR037209     3   0.000      1.000  0 0.000  1 0.000
#> SRR037210     3   0.000      1.000  0 0.000  1 0.000
#> SRR037211     3   0.000      1.000  0 0.000  1 0.000
#> SRR037212     3   0.000      1.000  0 0.000  1 0.000
#> SRR037213     3   0.000      1.000  0 0.000  1 0.000
#> SRR037219     3   0.000      1.000  0 0.000  1 0.000
#> SRR037214     3   0.000      1.000  0 0.000  1 0.000
#> SRR037215     3   0.000      1.000  0 0.000  1 0.000
#> SRR037216     3   0.000      1.000  0 0.000  1 0.000
#> SRR037217     3   0.000      1.000  0 0.000  1 0.000
#> SRR037218     3   0.000      1.000  0 0.000  1 0.000
#> SRR037220     1   0.000      1.000  1 0.000  0 0.000
#> SRR037221     1   0.000      1.000  1 0.000  0 0.000
#> SRR037222     1   0.000      1.000  1 0.000  0 0.000
#> SRR037223     1   0.000      1.000  1 0.000  0 0.000
#> SRR037224     1   0.000      1.000  1 0.000  0 0.000
#> SRR037225     1   0.000      1.000  1 0.000  0 0.000
#> SRR037226     1   0.000      1.000  1 0.000  0 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2 p3    p4    p5
#> SRR037165     4   0.000      0.729 0.000 0.000  0 1.000 0.000
#> SRR037166     4   0.000      0.729 0.000 0.000  0 1.000 0.000
#> SRR037167     4   0.000      0.729 0.000 0.000  0 1.000 0.000
#> SRR037168     4   0.314      0.783 0.000 0.000  0 0.796 0.204
#> SRR037169     4   0.314      0.783 0.000 0.000  0 0.796 0.204
#> SRR037170     4   0.314      0.783 0.000 0.000  0 0.796 0.204
#> SRR037171     2   0.000      0.876 0.000 1.000  0 0.000 0.000
#> SRR037172     2   0.000      0.876 0.000 1.000  0 0.000 0.000
#> SRR037173     2   0.000      0.876 0.000 1.000  0 0.000 0.000
#> SRR037174     2   0.000      0.876 0.000 1.000  0 0.000 0.000
#> SRR037175     2   0.000      0.876 0.000 1.000  0 0.000 0.000
#> SRR037176     2   0.000      0.876 0.000 1.000  0 0.000 0.000
#> SRR037177     2   0.318      0.841 0.000 0.792  0 0.208 0.000
#> SRR037182     3   0.000      1.000 0.000 0.000  1 0.000 0.000
#> SRR037183     3   0.000      1.000 0.000 0.000  1 0.000 0.000
#> SRR037184     2   0.318      0.841 0.000 0.792  0 0.208 0.000
#> SRR037185     2   0.318      0.841 0.000 0.792  0 0.208 0.000
#> SRR037186     2   0.318      0.841 0.000 0.792  0 0.208 0.000
#> SRR037187     2   0.318      0.841 0.000 0.792  0 0.208 0.000
#> SRR037188     3   0.000      1.000 0.000 0.000  1 0.000 0.000
#> SRR037178     3   0.000      1.000 0.000 0.000  1 0.000 0.000
#> SRR037179     3   0.000      1.000 0.000 0.000  1 0.000 0.000
#> SRR037180     3   0.000      1.000 0.000 0.000  1 0.000 0.000
#> SRR037181     3   0.000      1.000 0.000 0.000  1 0.000 0.000
#> SRR037189     2   0.318      0.841 0.000 0.792  0 0.208 0.000
#> SRR037190     2   0.000      0.876 0.000 1.000  0 0.000 0.000
#> SRR037191     2   0.000      0.876 0.000 1.000  0 0.000 0.000
#> SRR037192     2   0.318      0.841 0.000 0.792  0 0.208 0.000
#> SRR037193     5   0.425      1.000 0.000 0.000  0 0.432 0.568
#> SRR037194     5   0.425      1.000 0.000 0.000  0 0.432 0.568
#> SRR037195     5   0.425      1.000 0.000 0.000  0 0.432 0.568
#> SRR037196     5   0.425      1.000 0.000 0.000  0 0.432 0.568
#> SRR037197     5   0.425      1.000 0.000 0.000  0 0.432 0.568
#> SRR037198     5   0.425      1.000 0.000 0.000  0 0.432 0.568
#> SRR037199     1   0.000      0.888 1.000 0.000  0 0.000 0.000
#> SRR037200     1   0.000      0.888 1.000 0.000  0 0.000 0.000
#> SRR037201     1   0.000      0.888 1.000 0.000  0 0.000 0.000
#> SRR037202     1   0.000      0.888 1.000 0.000  0 0.000 0.000
#> SRR037203     1   0.000      0.888 1.000 0.000  0 0.000 0.000
#> SRR037204     1   0.000      0.888 1.000 0.000  0 0.000 0.000
#> SRR037205     1   0.000      0.888 1.000 0.000  0 0.000 0.000
#> SRR037206     3   0.000      1.000 0.000 0.000  1 0.000 0.000
#> SRR037207     3   0.000      1.000 0.000 0.000  1 0.000 0.000
#> SRR037208     3   0.000      1.000 0.000 0.000  1 0.000 0.000
#> SRR037209     3   0.000      1.000 0.000 0.000  1 0.000 0.000
#> SRR037210     3   0.000      1.000 0.000 0.000  1 0.000 0.000
#> SRR037211     3   0.000      1.000 0.000 0.000  1 0.000 0.000
#> SRR037212     3   0.000      1.000 0.000 0.000  1 0.000 0.000
#> SRR037213     3   0.000      1.000 0.000 0.000  1 0.000 0.000
#> SRR037219     3   0.000      1.000 0.000 0.000  1 0.000 0.000
#> SRR037214     3   0.000      1.000 0.000 0.000  1 0.000 0.000
#> SRR037215     3   0.000      1.000 0.000 0.000  1 0.000 0.000
#> SRR037216     3   0.000      1.000 0.000 0.000  1 0.000 0.000
#> SRR037217     3   0.000      1.000 0.000 0.000  1 0.000 0.000
#> SRR037218     3   0.000      1.000 0.000 0.000  1 0.000 0.000
#> SRR037220     1   0.334      0.888 0.772 0.000  0 0.000 0.228
#> SRR037221     1   0.334      0.888 0.772 0.000  0 0.000 0.228
#> SRR037222     1   0.334      0.888 0.772 0.000  0 0.000 0.228
#> SRR037223     1   0.334      0.888 0.772 0.000  0 0.000 0.228
#> SRR037224     1   0.334      0.888 0.772 0.000  0 0.000 0.228
#> SRR037225     1   0.334      0.888 0.772 0.000  0 0.000 0.228
#> SRR037226     1   0.334      0.888 0.772 0.000  0 0.000 0.228

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette p1    p2 p3    p4 p5    p6
#> SRR037165     4   0.285      0.802  0 0.000  0 0.792  0 0.208
#> SRR037166     4   0.285      0.802  0 0.000  0 0.792  0 0.208
#> SRR037167     4   0.285      0.802  0 0.000  0 0.792  0 0.208
#> SRR037168     4   0.000      0.831  0 0.000  0 1.000  0 0.000
#> SRR037169     4   0.000      0.831  0 0.000  0 1.000  0 0.000
#> SRR037170     4   0.000      0.831  0 0.000  0 1.000  0 0.000
#> SRR037171     2   0.000      0.874  0 1.000  0 0.000  0 0.000
#> SRR037172     2   0.000      0.874  0 1.000  0 0.000  0 0.000
#> SRR037173     2   0.000      0.874  0 1.000  0 0.000  0 0.000
#> SRR037174     2   0.000      0.874  0 1.000  0 0.000  0 0.000
#> SRR037175     2   0.000      0.874  0 1.000  0 0.000  0 0.000
#> SRR037176     2   0.000      0.874  0 1.000  0 0.000  0 0.000
#> SRR037177     2   0.285      0.840  0 0.792  0 0.000  0 0.208
#> SRR037182     3   0.000      1.000  0 0.000  1 0.000  0 0.000
#> SRR037183     3   0.000      1.000  0 0.000  1 0.000  0 0.000
#> SRR037184     2   0.285      0.840  0 0.792  0 0.000  0 0.208
#> SRR037185     2   0.285      0.840  0 0.792  0 0.000  0 0.208
#> SRR037186     2   0.285      0.840  0 0.792  0 0.000  0 0.208
#> SRR037187     2   0.285      0.840  0 0.792  0 0.000  0 0.208
#> SRR037188     3   0.000      1.000  0 0.000  1 0.000  0 0.000
#> SRR037178     3   0.000      1.000  0 0.000  1 0.000  0 0.000
#> SRR037179     3   0.000      1.000  0 0.000  1 0.000  0 0.000
#> SRR037180     3   0.000      1.000  0 0.000  1 0.000  0 0.000
#> SRR037181     3   0.000      1.000  0 0.000  1 0.000  0 0.000
#> SRR037189     2   0.285      0.840  0 0.792  0 0.000  0 0.208
#> SRR037190     2   0.000      0.874  0 1.000  0 0.000  0 0.000
#> SRR037191     2   0.000      0.874  0 1.000  0 0.000  0 0.000
#> SRR037192     2   0.285      0.840  0 0.792  0 0.000  0 0.208
#> SRR037193     6   0.000      1.000  0 0.000  0 0.000  0 1.000
#> SRR037194     6   0.000      1.000  0 0.000  0 0.000  0 1.000
#> SRR037195     6   0.000      1.000  0 0.000  0 0.000  0 1.000
#> SRR037196     6   0.000      1.000  0 0.000  0 0.000  0 1.000
#> SRR037197     6   0.000      1.000  0 0.000  0 0.000  0 1.000
#> SRR037198     6   0.000      1.000  0 0.000  0 0.000  0 1.000
#> SRR037199     1   0.000      1.000  1 0.000  0 0.000  0 0.000
#> SRR037200     1   0.000      1.000  1 0.000  0 0.000  0 0.000
#> SRR037201     1   0.000      1.000  1 0.000  0 0.000  0 0.000
#> SRR037202     1   0.000      1.000  1 0.000  0 0.000  0 0.000
#> SRR037203     1   0.000      1.000  1 0.000  0 0.000  0 0.000
#> SRR037204     1   0.000      1.000  1 0.000  0 0.000  0 0.000
#> SRR037205     1   0.000      1.000  1 0.000  0 0.000  0 0.000
#> SRR037206     3   0.000      1.000  0 0.000  1 0.000  0 0.000
#> SRR037207     3   0.000      1.000  0 0.000  1 0.000  0 0.000
#> SRR037208     3   0.000      1.000  0 0.000  1 0.000  0 0.000
#> SRR037209     3   0.000      1.000  0 0.000  1 0.000  0 0.000
#> SRR037210     3   0.000      1.000  0 0.000  1 0.000  0 0.000
#> SRR037211     3   0.000      1.000  0 0.000  1 0.000  0 0.000
#> SRR037212     3   0.000      1.000  0 0.000  1 0.000  0 0.000
#> SRR037213     3   0.000      1.000  0 0.000  1 0.000  0 0.000
#> SRR037219     3   0.000      1.000  0 0.000  1 0.000  0 0.000
#> SRR037214     3   0.000      1.000  0 0.000  1 0.000  0 0.000
#> SRR037215     3   0.000      1.000  0 0.000  1 0.000  0 0.000
#> SRR037216     3   0.000      1.000  0 0.000  1 0.000  0 0.000
#> SRR037217     3   0.000      1.000  0 0.000  1 0.000  0 0.000
#> SRR037218     3   0.000      1.000  0 0.000  1 0.000  0 0.000
#> SRR037220     5   0.000      1.000  0 0.000  0 0.000  1 0.000
#> SRR037221     5   0.000      1.000  0 0.000  0 0.000  1 0.000
#> SRR037222     5   0.000      1.000  0 0.000  0 0.000  1 0.000
#> SRR037223     5   0.000      1.000  0 0.000  0 0.000  1 0.000
#> SRR037224     5   0.000      1.000  0 0.000  0 0.000  1 0.000
#> SRR037225     5   0.000      1.000  0 0.000  0 0.000  1 0.000
#> SRR037226     5   0.000      1.000  0 0.000  0 0.000  1 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-hclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-hclust-collect-classes

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


CV:kmeans

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

res = res_list["CV", "kmeans"]
# you can also extract it by
# res = res_list["CV:kmeans"]

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

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

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

collect_plots(res)

plot of chunk CV-kmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.419           0.683       0.779         0.4196 0.645   0.645
#> 3 3 0.535           0.937       0.881         0.4712 0.700   0.535
#> 4 4 0.813           0.943       0.836         0.1510 0.905   0.724
#> 5 5 0.772           0.863       0.808         0.0671 1.000   1.000
#> 6 6 0.731           0.684       0.739         0.0567 0.983   0.930

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

suggest_best_k(res)
#> [1] 4

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> SRR037165     2   1.000      0.696 0.496 0.504
#> SRR037166     2   1.000      0.696 0.496 0.504
#> SRR037167     2   1.000      0.696 0.496 0.504
#> SRR037168     2   1.000      0.696 0.496 0.504
#> SRR037169     2   1.000      0.696 0.496 0.504
#> SRR037170     2   1.000      0.696 0.496 0.504
#> SRR037171     2   0.999      0.707 0.480 0.520
#> SRR037172     2   0.999      0.707 0.480 0.520
#> SRR037173     2   0.999      0.707 0.480 0.520
#> SRR037174     2   0.999      0.707 0.480 0.520
#> SRR037175     2   0.999      0.707 0.480 0.520
#> SRR037176     2   0.999      0.707 0.480 0.520
#> SRR037177     2   0.999      0.707 0.480 0.520
#> SRR037182     2   0.000      0.526 0.000 1.000
#> SRR037183     2   0.000      0.526 0.000 1.000
#> SRR037184     2   0.999      0.707 0.480 0.520
#> SRR037185     2   0.999      0.707 0.480 0.520
#> SRR037186     2   0.999      0.707 0.480 0.520
#> SRR037187     2   0.999      0.707 0.480 0.520
#> SRR037188     2   0.000      0.526 0.000 1.000
#> SRR037178     2   0.000      0.526 0.000 1.000
#> SRR037179     2   0.000      0.526 0.000 1.000
#> SRR037180     2   0.000      0.526 0.000 1.000
#> SRR037181     2   0.000      0.526 0.000 1.000
#> SRR037189     2   0.999      0.707 0.480 0.520
#> SRR037190     2   0.999      0.707 0.480 0.520
#> SRR037191     2   0.999      0.707 0.480 0.520
#> SRR037192     2   0.999      0.707 0.480 0.520
#> SRR037193     2   0.999      0.707 0.480 0.520
#> SRR037194     2   0.999      0.707 0.480 0.520
#> SRR037195     2   0.999      0.707 0.480 0.520
#> SRR037196     2   0.999      0.707 0.480 0.520
#> SRR037197     2   0.999      0.707 0.480 0.520
#> SRR037198     2   0.999      0.707 0.480 0.520
#> SRR037199     1   0.981      0.879 0.580 0.420
#> SRR037200     1   0.981      0.879 0.580 0.420
#> SRR037201     1   0.981      0.879 0.580 0.420
#> SRR037202     1   0.981      0.879 0.580 0.420
#> SRR037203     1   0.981      0.879 0.580 0.420
#> SRR037204     1   0.981      0.879 0.580 0.420
#> SRR037205     1   0.981      0.879 0.580 0.420
#> SRR037206     2   0.000      0.526 0.000 1.000
#> SRR037207     2   0.000      0.526 0.000 1.000
#> SRR037208     2   0.000      0.526 0.000 1.000
#> SRR037209     2   0.000      0.526 0.000 1.000
#> SRR037210     2   0.000      0.526 0.000 1.000
#> SRR037211     2   0.000      0.526 0.000 1.000
#> SRR037212     2   0.000      0.526 0.000 1.000
#> SRR037213     2   0.000      0.526 0.000 1.000
#> SRR037219     2   0.000      0.526 0.000 1.000
#> SRR037214     2   0.000      0.526 0.000 1.000
#> SRR037215     2   0.000      0.526 0.000 1.000
#> SRR037216     2   0.000      0.526 0.000 1.000
#> SRR037217     2   0.000      0.526 0.000 1.000
#> SRR037218     2   0.000      0.526 0.000 1.000
#> SRR037220     1   0.855      0.874 0.720 0.280
#> SRR037221     1   0.855      0.874 0.720 0.280
#> SRR037222     1   0.855      0.874 0.720 0.280
#> SRR037223     1   0.855      0.874 0.720 0.280
#> SRR037224     1   0.855      0.874 0.720 0.280
#> SRR037225     1   0.855      0.874 0.720 0.280
#> SRR037226     1   0.855      0.874 0.720 0.280

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> SRR037165     2   0.341      0.860 0.124 0.876 0.000
#> SRR037166     2   0.341      0.860 0.124 0.876 0.000
#> SRR037167     2   0.341      0.860 0.124 0.876 0.000
#> SRR037168     2   0.341      0.860 0.124 0.876 0.000
#> SRR037169     2   0.341      0.860 0.124 0.876 0.000
#> SRR037170     2   0.341      0.860 0.124 0.876 0.000
#> SRR037171     2   0.369      0.894 0.012 0.880 0.108
#> SRR037172     2   0.369      0.894 0.012 0.880 0.108
#> SRR037173     2   0.369      0.894 0.012 0.880 0.108
#> SRR037174     2   0.369      0.894 0.012 0.880 0.108
#> SRR037175     2   0.369      0.894 0.012 0.880 0.108
#> SRR037176     2   0.369      0.894 0.012 0.880 0.108
#> SRR037177     2   0.369      0.894 0.012 0.880 0.108
#> SRR037182     3   0.277      0.997 0.004 0.080 0.916
#> SRR037183     3   0.277      0.997 0.004 0.080 0.916
#> SRR037184     2   0.369      0.894 0.012 0.880 0.108
#> SRR037185     2   0.369      0.894 0.012 0.880 0.108
#> SRR037186     2   0.369      0.894 0.012 0.880 0.108
#> SRR037187     2   0.369      0.894 0.012 0.880 0.108
#> SRR037188     3   0.277      0.997 0.004 0.080 0.916
#> SRR037178     3   0.277      0.997 0.004 0.080 0.916
#> SRR037179     3   0.277      0.997 0.004 0.080 0.916
#> SRR037180     3   0.277      0.997 0.004 0.080 0.916
#> SRR037181     3   0.277      0.997 0.004 0.080 0.916
#> SRR037189     2   0.369      0.894 0.012 0.880 0.108
#> SRR037190     2   0.369      0.894 0.012 0.880 0.108
#> SRR037191     2   0.369      0.894 0.012 0.880 0.108
#> SRR037192     2   0.369      0.894 0.012 0.880 0.108
#> SRR037193     2   0.392      0.871 0.112 0.872 0.016
#> SRR037194     2   0.392      0.871 0.112 0.872 0.016
#> SRR037195     2   0.392      0.871 0.112 0.872 0.016
#> SRR037196     2   0.392      0.871 0.112 0.872 0.016
#> SRR037197     2   0.392      0.871 0.112 0.872 0.016
#> SRR037198     2   0.392      0.871 0.112 0.872 0.016
#> SRR037199     1   0.498      0.952 0.780 0.004 0.216
#> SRR037200     1   0.498      0.952 0.780 0.004 0.216
#> SRR037201     1   0.498      0.952 0.780 0.004 0.216
#> SRR037202     1   0.498      0.952 0.780 0.004 0.216
#> SRR037203     1   0.498      0.952 0.780 0.004 0.216
#> SRR037204     1   0.498      0.952 0.780 0.004 0.216
#> SRR037205     1   0.498      0.952 0.780 0.004 0.216
#> SRR037206     3   0.254      0.998 0.000 0.080 0.920
#> SRR037207     3   0.254      0.998 0.000 0.080 0.920
#> SRR037208     3   0.254      0.998 0.000 0.080 0.920
#> SRR037209     3   0.254      0.998 0.000 0.080 0.920
#> SRR037210     3   0.254      0.998 0.000 0.080 0.920
#> SRR037211     3   0.254      0.998 0.000 0.080 0.920
#> SRR037212     3   0.254      0.998 0.000 0.080 0.920
#> SRR037213     3   0.254      0.998 0.000 0.080 0.920
#> SRR037219     3   0.254      0.998 0.000 0.080 0.920
#> SRR037214     3   0.254      0.998 0.000 0.080 0.920
#> SRR037215     3   0.254      0.998 0.000 0.080 0.920
#> SRR037216     3   0.254      0.998 0.000 0.080 0.920
#> SRR037217     3   0.254      0.998 0.000 0.080 0.920
#> SRR037218     3   0.254      0.998 0.000 0.080 0.920
#> SRR037220     1   0.377      0.953 0.880 0.016 0.104
#> SRR037221     1   0.377      0.953 0.880 0.016 0.104
#> SRR037222     1   0.377      0.953 0.880 0.016 0.104
#> SRR037223     1   0.377      0.953 0.880 0.016 0.104
#> SRR037224     1   0.377      0.953 0.880 0.016 0.104
#> SRR037225     1   0.377      0.953 0.880 0.016 0.104
#> SRR037226     1   0.377      0.953 0.880 0.016 0.104

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> SRR037165     4  0.4977      0.959 0.000 0.460 0.000 0.540
#> SRR037166     4  0.4977      0.959 0.000 0.460 0.000 0.540
#> SRR037167     4  0.4977      0.959 0.000 0.460 0.000 0.540
#> SRR037168     4  0.4977      0.959 0.000 0.460 0.000 0.540
#> SRR037169     4  0.4977      0.959 0.000 0.460 0.000 0.540
#> SRR037170     4  0.4977      0.959 0.000 0.460 0.000 0.540
#> SRR037171     2  0.1118      1.000 0.000 0.964 0.036 0.000
#> SRR037172     2  0.1118      1.000 0.000 0.964 0.036 0.000
#> SRR037173     2  0.1118      1.000 0.000 0.964 0.036 0.000
#> SRR037174     2  0.1118      1.000 0.000 0.964 0.036 0.000
#> SRR037175     2  0.1118      1.000 0.000 0.964 0.036 0.000
#> SRR037176     2  0.1118      1.000 0.000 0.964 0.036 0.000
#> SRR037177     2  0.1118      1.000 0.000 0.964 0.036 0.000
#> SRR037182     3  0.2845      0.919 0.000 0.028 0.896 0.076
#> SRR037183     3  0.2845      0.919 0.000 0.028 0.896 0.076
#> SRR037184     2  0.1118      1.000 0.000 0.964 0.036 0.000
#> SRR037185     2  0.1118      1.000 0.000 0.964 0.036 0.000
#> SRR037186     2  0.1118      1.000 0.000 0.964 0.036 0.000
#> SRR037187     2  0.1118      1.000 0.000 0.964 0.036 0.000
#> SRR037188     3  0.2845      0.919 0.000 0.028 0.896 0.076
#> SRR037178     3  0.1109      0.934 0.000 0.028 0.968 0.004
#> SRR037179     3  0.1109      0.934 0.000 0.028 0.968 0.004
#> SRR037180     3  0.1109      0.934 0.000 0.028 0.968 0.004
#> SRR037181     3  0.1109      0.934 0.000 0.028 0.968 0.004
#> SRR037189     2  0.1118      1.000 0.000 0.964 0.036 0.000
#> SRR037190     2  0.1118      1.000 0.000 0.964 0.036 0.000
#> SRR037191     2  0.1118      1.000 0.000 0.964 0.036 0.000
#> SRR037192     2  0.1118      1.000 0.000 0.964 0.036 0.000
#> SRR037193     4  0.5510      0.958 0.016 0.480 0.000 0.504
#> SRR037194     4  0.5510      0.958 0.016 0.480 0.000 0.504
#> SRR037195     4  0.5510      0.958 0.016 0.480 0.000 0.504
#> SRR037196     4  0.5510      0.958 0.016 0.480 0.000 0.504
#> SRR037197     4  0.5510      0.958 0.016 0.480 0.000 0.504
#> SRR037198     4  0.5510      0.958 0.016 0.480 0.000 0.504
#> SRR037199     1  0.1004      0.900 0.972 0.004 0.024 0.000
#> SRR037200     1  0.1004      0.900 0.972 0.004 0.024 0.000
#> SRR037201     1  0.1004      0.900 0.972 0.004 0.024 0.000
#> SRR037202     1  0.1109      0.899 0.968 0.004 0.028 0.000
#> SRR037203     1  0.1109      0.899 0.968 0.004 0.028 0.000
#> SRR037204     1  0.0779      0.900 0.980 0.004 0.016 0.000
#> SRR037205     1  0.0779      0.900 0.980 0.004 0.016 0.000
#> SRR037206     3  0.3781      0.916 0.004 0.028 0.844 0.124
#> SRR037207     3  0.3653      0.916 0.000 0.028 0.844 0.128
#> SRR037208     3  0.3653      0.916 0.000 0.028 0.844 0.128
#> SRR037209     3  0.3653      0.916 0.000 0.028 0.844 0.128
#> SRR037210     3  0.3653      0.916 0.000 0.028 0.844 0.128
#> SRR037211     3  0.3781      0.916 0.004 0.028 0.844 0.124
#> SRR037212     3  0.2845      0.919 0.000 0.028 0.896 0.076
#> SRR037213     3  0.2845      0.919 0.000 0.028 0.896 0.076
#> SRR037219     3  0.2845      0.919 0.000 0.028 0.896 0.076
#> SRR037214     3  0.3182      0.927 0.000 0.028 0.876 0.096
#> SRR037215     3  0.3653      0.916 0.000 0.028 0.844 0.128
#> SRR037216     3  0.3653      0.916 0.000 0.028 0.844 0.128
#> SRR037217     3  0.1109      0.934 0.000 0.028 0.968 0.004
#> SRR037218     3  0.1109      0.934 0.000 0.028 0.968 0.004
#> SRR037220     1  0.4778      0.901 0.732 0.004 0.016 0.248
#> SRR037221     1  0.4778      0.901 0.732 0.004 0.016 0.248
#> SRR037222     1  0.4778      0.901 0.732 0.004 0.016 0.248
#> SRR037223     1  0.4923      0.900 0.732 0.004 0.024 0.240
#> SRR037224     1  0.4923      0.900 0.732 0.004 0.024 0.240
#> SRR037225     1  0.4778      0.901 0.732 0.004 0.016 0.248
#> SRR037226     1  0.4923      0.900 0.732 0.004 0.024 0.240

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4 p5
#> SRR037165     4  0.3437      0.877 0.000 0.012 0.004 0.808 NA
#> SRR037166     4  0.3437      0.877 0.000 0.012 0.004 0.808 NA
#> SRR037167     4  0.3437      0.877 0.000 0.012 0.004 0.808 NA
#> SRR037168     4  0.3437      0.877 0.000 0.012 0.004 0.808 NA
#> SRR037169     4  0.3437      0.877 0.000 0.012 0.004 0.808 NA
#> SRR037170     4  0.3437      0.877 0.000 0.012 0.004 0.808 NA
#> SRR037171     2  0.4398      0.964 0.000 0.720 0.040 0.240 NA
#> SRR037172     2  0.4398      0.964 0.000 0.720 0.040 0.240 NA
#> SRR037173     2  0.4398      0.964 0.000 0.720 0.040 0.240 NA
#> SRR037174     2  0.4398      0.964 0.000 0.720 0.040 0.240 NA
#> SRR037175     2  0.4398      0.964 0.000 0.720 0.040 0.240 NA
#> SRR037176     2  0.5028      0.956 0.004 0.700 0.040 0.240 NA
#> SRR037177     2  0.5833      0.959 0.004 0.656 0.040 0.240 NA
#> SRR037182     3  0.4182      0.833 0.000 0.000 0.600 0.000 NA
#> SRR037183     3  0.4182      0.833 0.000 0.000 0.600 0.000 NA
#> SRR037184     2  0.5833      0.959 0.004 0.656 0.040 0.240 NA
#> SRR037185     2  0.5833      0.959 0.004 0.656 0.040 0.240 NA
#> SRR037186     2  0.5833      0.959 0.004 0.656 0.040 0.240 NA
#> SRR037187     2  0.5833      0.959 0.004 0.656 0.040 0.240 NA
#> SRR037188     3  0.4182      0.833 0.000 0.000 0.600 0.000 NA
#> SRR037178     3  0.4138      0.855 0.000 0.016 0.708 0.000 NA
#> SRR037179     3  0.4138      0.855 0.000 0.016 0.708 0.000 NA
#> SRR037180     3  0.4138      0.855 0.000 0.016 0.708 0.000 NA
#> SRR037181     3  0.4138      0.855 0.000 0.016 0.708 0.000 NA
#> SRR037189     2  0.5579      0.961 0.004 0.672 0.040 0.240 NA
#> SRR037190     2  0.4398      0.964 0.000 0.720 0.040 0.240 NA
#> SRR037191     2  0.4874      0.956 0.000 0.704 0.040 0.240 NA
#> SRR037192     2  0.5833      0.959 0.004 0.656 0.040 0.240 NA
#> SRR037193     4  0.1356      0.873 0.000 0.028 0.012 0.956 NA
#> SRR037194     4  0.1356      0.873 0.000 0.028 0.012 0.956 NA
#> SRR037195     4  0.1356      0.873 0.000 0.028 0.012 0.956 NA
#> SRR037196     4  0.1356      0.873 0.000 0.028 0.012 0.956 NA
#> SRR037197     4  0.1356      0.873 0.000 0.028 0.012 0.956 NA
#> SRR037198     4  0.1356      0.873 0.000 0.028 0.012 0.956 NA
#> SRR037199     1  0.6148      0.801 0.552 0.124 0.008 0.000 NA
#> SRR037200     1  0.6124      0.801 0.552 0.120 0.008 0.000 NA
#> SRR037201     1  0.6124      0.801 0.552 0.120 0.008 0.000 NA
#> SRR037202     1  0.6046      0.801 0.552 0.108 0.008 0.000 NA
#> SRR037203     1  0.6208      0.801 0.552 0.112 0.008 0.004 NA
#> SRR037204     1  0.5957      0.801 0.552 0.096 0.008 0.000 NA
#> SRR037205     1  0.5957      0.801 0.552 0.096 0.008 0.000 NA
#> SRR037206     3  0.0609      0.803 0.000 0.020 0.980 0.000 NA
#> SRR037207     3  0.0703      0.804 0.000 0.024 0.976 0.000 NA
#> SRR037208     3  0.0162      0.805 0.000 0.004 0.996 0.000 NA
#> SRR037209     3  0.0162      0.805 0.000 0.004 0.996 0.000 NA
#> SRR037210     3  0.0404      0.803 0.000 0.012 0.988 0.000 NA
#> SRR037211     3  0.0794      0.803 0.000 0.028 0.972 0.000 NA
#> SRR037212     3  0.4321      0.832 0.000 0.004 0.600 0.000 NA
#> SRR037213     3  0.4321      0.832 0.000 0.004 0.600 0.000 NA
#> SRR037219     3  0.4321      0.832 0.000 0.004 0.600 0.000 NA
#> SRR037214     3  0.4108      0.841 0.000 0.008 0.684 0.000 NA
#> SRR037215     3  0.0162      0.805 0.000 0.004 0.996 0.000 NA
#> SRR037216     3  0.0404      0.803 0.000 0.012 0.988 0.000 NA
#> SRR037217     3  0.3934      0.856 0.000 0.008 0.716 0.000 NA
#> SRR037218     3  0.3934      0.856 0.000 0.008 0.716 0.000 NA
#> SRR037220     1  0.0579      0.795 0.984 0.000 0.008 0.008 NA
#> SRR037221     1  0.0579      0.795 0.984 0.000 0.008 0.008 NA
#> SRR037222     1  0.0579      0.795 0.984 0.000 0.008 0.008 NA
#> SRR037223     1  0.2050      0.793 0.920 0.064 0.008 0.008 NA
#> SRR037224     1  0.2050      0.793 0.920 0.064 0.008 0.008 NA
#> SRR037225     1  0.0579      0.795 0.984 0.000 0.008 0.008 NA
#> SRR037226     1  0.2050      0.793 0.920 0.064 0.008 0.008 NA

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4 p5    p6
#> SRR037165     4  0.2527      0.778 0.000 0.108 0.000 0.868 NA 0.024
#> SRR037166     4  0.2527      0.778 0.000 0.108 0.000 0.868 NA 0.024
#> SRR037167     4  0.2527      0.778 0.000 0.108 0.000 0.868 NA 0.024
#> SRR037168     4  0.2053      0.778 0.000 0.108 0.000 0.888 NA 0.004
#> SRR037169     4  0.2053      0.778 0.000 0.108 0.000 0.888 NA 0.004
#> SRR037170     4  0.1910      0.778 0.000 0.108 0.000 0.892 NA 0.000
#> SRR037171     2  0.0000      0.907 0.000 1.000 0.000 0.000 NA 0.000
#> SRR037172     2  0.0000      0.907 0.000 1.000 0.000 0.000 NA 0.000
#> SRR037173     2  0.0000      0.907 0.000 1.000 0.000 0.000 NA 0.000
#> SRR037174     2  0.0000      0.907 0.000 1.000 0.000 0.000 NA 0.000
#> SRR037175     2  0.0000      0.907 0.000 1.000 0.000 0.000 NA 0.000
#> SRR037176     2  0.1498      0.885 0.000 0.940 0.000 0.000 NA 0.028
#> SRR037177     2  0.3139      0.893 0.000 0.816 0.000 0.000 NA 0.152
#> SRR037182     3  0.4278      0.722 0.000 0.000 0.712 0.000 NA 0.076
#> SRR037183     3  0.4278      0.722 0.000 0.000 0.712 0.000 NA 0.076
#> SRR037184     2  0.3139      0.893 0.000 0.816 0.000 0.000 NA 0.152
#> SRR037185     2  0.3139      0.893 0.000 0.816 0.000 0.000 NA 0.152
#> SRR037186     2  0.3139      0.893 0.000 0.816 0.000 0.000 NA 0.152
#> SRR037187     2  0.3139      0.893 0.000 0.816 0.000 0.000 NA 0.152
#> SRR037188     3  0.4278      0.722 0.000 0.000 0.712 0.000 NA 0.076
#> SRR037178     3  0.1173      0.785 0.000 0.000 0.960 0.016 NA 0.016
#> SRR037179     3  0.1173      0.785 0.000 0.000 0.960 0.016 NA 0.016
#> SRR037180     3  0.1173      0.785 0.000 0.000 0.960 0.016 NA 0.016
#> SRR037181     3  0.1173      0.785 0.000 0.000 0.960 0.016 NA 0.016
#> SRR037189     2  0.2581      0.899 0.000 0.860 0.000 0.000 NA 0.120
#> SRR037190     2  0.0000      0.907 0.000 1.000 0.000 0.000 NA 0.000
#> SRR037191     2  0.1074      0.887 0.000 0.960 0.000 0.000 NA 0.028
#> SRR037192     2  0.3139      0.893 0.000 0.816 0.000 0.000 NA 0.152
#> SRR037193     4  0.5583      0.777 0.000 0.140 0.000 0.448 NA 0.000
#> SRR037194     4  0.5583      0.777 0.000 0.140 0.000 0.448 NA 0.000
#> SRR037195     4  0.5583      0.777 0.000 0.140 0.000 0.448 NA 0.000
#> SRR037196     4  0.5583      0.777 0.000 0.140 0.000 0.448 NA 0.000
#> SRR037197     4  0.5583      0.777 0.000 0.140 0.000 0.448 NA 0.000
#> SRR037198     4  0.5583      0.777 0.000 0.140 0.000 0.448 NA 0.000
#> SRR037199     1  0.0508      0.578 0.984 0.000 0.000 0.012 NA 0.000
#> SRR037200     1  0.0508      0.578 0.984 0.000 0.000 0.012 NA 0.000
#> SRR037201     1  0.0508      0.578 0.984 0.000 0.000 0.012 NA 0.000
#> SRR037202     1  0.0717      0.570 0.976 0.000 0.000 0.008 NA 0.000
#> SRR037203     1  0.1257      0.557 0.952 0.000 0.000 0.020 NA 0.000
#> SRR037204     1  0.0000      0.578 1.000 0.000 0.000 0.000 NA 0.000
#> SRR037205     1  0.0000      0.578 1.000 0.000 0.000 0.000 NA 0.000
#> SRR037206     3  0.5393      0.737 0.000 0.000 0.656 0.032 NA 0.156
#> SRR037207     3  0.5345      0.738 0.000 0.000 0.656 0.028 NA 0.140
#> SRR037208     3  0.4952      0.743 0.000 0.000 0.684 0.016 NA 0.116
#> SRR037209     3  0.4952      0.743 0.000 0.000 0.684 0.016 NA 0.116
#> SRR037210     3  0.5307      0.737 0.000 0.000 0.656 0.024 NA 0.144
#> SRR037211     3  0.5393      0.737 0.000 0.000 0.656 0.032 NA 0.156
#> SRR037212     3  0.4172      0.725 0.000 0.000 0.724 0.000 NA 0.072
#> SRR037213     3  0.4172      0.725 0.000 0.000 0.724 0.000 NA 0.072
#> SRR037219     3  0.4172      0.725 0.000 0.000 0.724 0.000 NA 0.072
#> SRR037214     3  0.4546      0.746 0.000 0.000 0.692 0.000 NA 0.104
#> SRR037215     3  0.4962      0.743 0.000 0.000 0.684 0.016 NA 0.120
#> SRR037216     3  0.5307      0.737 0.000 0.000 0.656 0.024 NA 0.144
#> SRR037217     3  0.0146      0.788 0.000 0.000 0.996 0.000 NA 0.004
#> SRR037218     3  0.0146      0.788 0.000 0.000 0.996 0.000 NA 0.004
#> SRR037220     1  0.5317     -0.787 0.464 0.000 0.000 0.004 NA 0.444
#> SRR037221     1  0.5226     -0.784 0.464 0.000 0.000 0.000 NA 0.444
#> SRR037222     1  0.5226     -0.784 0.464 0.000 0.000 0.000 NA 0.444
#> SRR037223     6  0.4256      1.000 0.464 0.000 0.000 0.016 NA 0.520
#> SRR037224     6  0.4256      1.000 0.464 0.000 0.000 0.016 NA 0.520
#> SRR037225     1  0.5226     -0.784 0.464 0.000 0.000 0.000 NA 0.444
#> SRR037226     6  0.4256      1.000 0.464 0.000 0.000 0.016 NA 0.520

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

consensus_heatmap(res, k = 2)

plot of chunk tab-CV-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 15332 rows and 62 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#>   Subgroups are detected by 'skmeans' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 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.5002 0.500   0.500
#> 3 3 1.000           1.000       1.000         0.3105 0.845   0.689
#> 4 4 1.000           1.000       0.999         0.1447 0.905   0.724
#> 5 5 0.903           0.958       0.915         0.0375 0.974   0.896
#> 6 6 0.908           0.769       0.785         0.0437 0.911   0.639

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
#> SRR037165     2       0          1  0  1
#> SRR037166     2       0          1  0  1
#> SRR037167     2       0          1  0  1
#> SRR037168     2       0          1  0  1
#> SRR037169     2       0          1  0  1
#> SRR037170     2       0          1  0  1
#> SRR037171     2       0          1  0  1
#> SRR037172     2       0          1  0  1
#> SRR037173     2       0          1  0  1
#> SRR037174     2       0          1  0  1
#> SRR037175     2       0          1  0  1
#> SRR037176     2       0          1  0  1
#> SRR037177     2       0          1  0  1
#> SRR037182     1       0          1  1  0
#> SRR037183     1       0          1  1  0
#> SRR037184     2       0          1  0  1
#> SRR037185     2       0          1  0  1
#> SRR037186     2       0          1  0  1
#> SRR037187     2       0          1  0  1
#> SRR037188     1       0          1  1  0
#> SRR037178     1       0          1  1  0
#> SRR037179     1       0          1  1  0
#> SRR037180     1       0          1  1  0
#> SRR037181     1       0          1  1  0
#> SRR037189     2       0          1  0  1
#> SRR037190     2       0          1  0  1
#> SRR037191     2       0          1  0  1
#> SRR037192     2       0          1  0  1
#> SRR037193     2       0          1  0  1
#> SRR037194     2       0          1  0  1
#> SRR037195     2       0          1  0  1
#> SRR037196     2       0          1  0  1
#> SRR037197     2       0          1  0  1
#> SRR037198     2       0          1  0  1
#> SRR037199     1       0          1  1  0
#> SRR037200     1       0          1  1  0
#> SRR037201     1       0          1  1  0
#> SRR037202     1       0          1  1  0
#> SRR037203     1       0          1  1  0
#> SRR037204     1       0          1  1  0
#> SRR037205     1       0          1  1  0
#> SRR037206     1       0          1  1  0
#> SRR037207     1       0          1  1  0
#> SRR037208     1       0          1  1  0
#> SRR037209     1       0          1  1  0
#> SRR037210     1       0          1  1  0
#> SRR037211     1       0          1  1  0
#> SRR037212     1       0          1  1  0
#> SRR037213     1       0          1  1  0
#> SRR037219     1       0          1  1  0
#> SRR037214     1       0          1  1  0
#> SRR037215     1       0          1  1  0
#> SRR037216     1       0          1  1  0
#> SRR037217     1       0          1  1  0
#> SRR037218     1       0          1  1  0
#> SRR037220     1       0          1  1  0
#> SRR037221     1       0          1  1  0
#> SRR037222     1       0          1  1  0
#> SRR037223     1       0          1  1  0
#> SRR037224     1       0          1  1  0
#> SRR037225     1       0          1  1  0
#> SRR037226     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
#> SRR037165     2       0          1  0  1  0
#> SRR037166     2       0          1  0  1  0
#> SRR037167     2       0          1  0  1  0
#> SRR037168     2       0          1  0  1  0
#> SRR037169     2       0          1  0  1  0
#> SRR037170     2       0          1  0  1  0
#> SRR037171     2       0          1  0  1  0
#> SRR037172     2       0          1  0  1  0
#> SRR037173     2       0          1  0  1  0
#> SRR037174     2       0          1  0  1  0
#> SRR037175     2       0          1  0  1  0
#> SRR037176     2       0          1  0  1  0
#> SRR037177     2       0          1  0  1  0
#> SRR037182     3       0          1  0  0  1
#> SRR037183     3       0          1  0  0  1
#> SRR037184     2       0          1  0  1  0
#> SRR037185     2       0          1  0  1  0
#> SRR037186     2       0          1  0  1  0
#> SRR037187     2       0          1  0  1  0
#> SRR037188     3       0          1  0  0  1
#> SRR037178     3       0          1  0  0  1
#> SRR037179     3       0          1  0  0  1
#> SRR037180     3       0          1  0  0  1
#> SRR037181     3       0          1  0  0  1
#> SRR037189     2       0          1  0  1  0
#> SRR037190     2       0          1  0  1  0
#> SRR037191     2       0          1  0  1  0
#> SRR037192     2       0          1  0  1  0
#> SRR037193     2       0          1  0  1  0
#> SRR037194     2       0          1  0  1  0
#> SRR037195     2       0          1  0  1  0
#> SRR037196     2       0          1  0  1  0
#> SRR037197     2       0          1  0  1  0
#> SRR037198     2       0          1  0  1  0
#> SRR037199     1       0          1  1  0  0
#> SRR037200     1       0          1  1  0  0
#> SRR037201     1       0          1  1  0  0
#> SRR037202     1       0          1  1  0  0
#> SRR037203     1       0          1  1  0  0
#> SRR037204     1       0          1  1  0  0
#> SRR037205     1       0          1  1  0  0
#> SRR037206     3       0          1  0  0  1
#> SRR037207     3       0          1  0  0  1
#> SRR037208     3       0          1  0  0  1
#> SRR037209     3       0          1  0  0  1
#> SRR037210     3       0          1  0  0  1
#> SRR037211     3       0          1  0  0  1
#> SRR037212     3       0          1  0  0  1
#> SRR037213     3       0          1  0  0  1
#> SRR037219     3       0          1  0  0  1
#> SRR037214     3       0          1  0  0  1
#> SRR037215     3       0          1  0  0  1
#> SRR037216     3       0          1  0  0  1
#> SRR037217     3       0          1  0  0  1
#> SRR037218     3       0          1  0  0  1
#> SRR037220     1       0          1  1  0  0
#> SRR037221     1       0          1  1  0  0
#> SRR037222     1       0          1  1  0  0
#> SRR037223     1       0          1  1  0  0
#> SRR037224     1       0          1  1  0  0
#> SRR037225     1       0          1  1  0  0
#> SRR037226     1       0          1  1  0  0

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2 p3    p4
#> SRR037165     4  0.0188      1.000 0.000 0.004  0 0.996
#> SRR037166     4  0.0188      1.000 0.000 0.004  0 0.996
#> SRR037167     4  0.0188      1.000 0.000 0.004  0 0.996
#> SRR037168     4  0.0188      1.000 0.000 0.004  0 0.996
#> SRR037169     4  0.0188      1.000 0.000 0.004  0 0.996
#> SRR037170     4  0.0188      1.000 0.000 0.004  0 0.996
#> SRR037171     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR037172     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR037173     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR037174     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR037175     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR037176     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR037177     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR037182     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR037183     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR037184     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR037185     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR037186     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR037187     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR037188     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR037178     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR037179     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR037180     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR037181     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR037189     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR037190     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR037191     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR037192     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR037193     4  0.0188      1.000 0.000 0.004  0 0.996
#> SRR037194     4  0.0188      1.000 0.000 0.004  0 0.996
#> SRR037195     4  0.0188      1.000 0.000 0.004  0 0.996
#> SRR037196     4  0.0188      1.000 0.000 0.004  0 0.996
#> SRR037197     4  0.0188      1.000 0.000 0.004  0 0.996
#> SRR037198     4  0.0188      1.000 0.000 0.004  0 0.996
#> SRR037199     1  0.0000      0.998 1.000 0.000  0 0.000
#> SRR037200     1  0.0000      0.998 1.000 0.000  0 0.000
#> SRR037201     1  0.0000      0.998 1.000 0.000  0 0.000
#> SRR037202     1  0.0000      0.998 1.000 0.000  0 0.000
#> SRR037203     1  0.0000      0.998 1.000 0.000  0 0.000
#> SRR037204     1  0.0000      0.998 1.000 0.000  0 0.000
#> SRR037205     1  0.0000      0.998 1.000 0.000  0 0.000
#> SRR037206     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR037207     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR037208     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR037209     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR037210     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR037211     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR037212     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR037213     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR037219     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR037214     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR037215     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR037216     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR037217     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR037218     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR037220     1  0.0188      0.998 0.996 0.000  0 0.004
#> SRR037221     1  0.0188      0.998 0.996 0.000  0 0.004
#> SRR037222     1  0.0188      0.998 0.996 0.000  0 0.004
#> SRR037223     1  0.0188      0.998 0.996 0.000  0 0.004
#> SRR037224     1  0.0188      0.998 0.996 0.000  0 0.004
#> SRR037225     1  0.0188      0.998 0.996 0.000  0 0.004
#> SRR037226     1  0.0188      0.998 0.996 0.000  0 0.004

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1 p2    p3    p4    p5
#> SRR037165     4  0.3480      0.888 0.000  0 0.000 0.752 0.248
#> SRR037166     4  0.3480      0.888 0.000  0 0.000 0.752 0.248
#> SRR037167     4  0.3480      0.888 0.000  0 0.000 0.752 0.248
#> SRR037168     4  0.3480      0.888 0.000  0 0.000 0.752 0.248
#> SRR037169     4  0.3480      0.888 0.000  0 0.000 0.752 0.248
#> SRR037170     4  0.3480      0.888 0.000  0 0.000 0.752 0.248
#> SRR037171     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> SRR037172     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> SRR037173     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> SRR037174     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> SRR037175     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> SRR037176     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> SRR037177     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> SRR037182     3  0.2471      0.911 0.000  0 0.864 0.000 0.136
#> SRR037183     3  0.2471      0.911 0.000  0 0.864 0.000 0.136
#> SRR037184     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> SRR037185     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> SRR037186     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> SRR037187     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> SRR037188     3  0.2471      0.911 0.000  0 0.864 0.000 0.136
#> SRR037178     3  0.0000      0.955 0.000  0 1.000 0.000 0.000
#> SRR037179     3  0.0000      0.955 0.000  0 1.000 0.000 0.000
#> SRR037180     3  0.0000      0.955 0.000  0 1.000 0.000 0.000
#> SRR037181     3  0.0000      0.955 0.000  0 1.000 0.000 0.000
#> SRR037189     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> SRR037190     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> SRR037191     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> SRR037192     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> SRR037193     4  0.0000      0.888 0.000  0 0.000 1.000 0.000
#> SRR037194     4  0.0000      0.888 0.000  0 0.000 1.000 0.000
#> SRR037195     4  0.0000      0.888 0.000  0 0.000 1.000 0.000
#> SRR037196     4  0.0000      0.888 0.000  0 0.000 1.000 0.000
#> SRR037197     4  0.0000      0.888 0.000  0 0.000 1.000 0.000
#> SRR037198     4  0.0000      0.888 0.000  0 0.000 1.000 0.000
#> SRR037199     1  0.0000      1.000 1.000  0 0.000 0.000 0.000
#> SRR037200     1  0.0000      1.000 1.000  0 0.000 0.000 0.000
#> SRR037201     1  0.0000      1.000 1.000  0 0.000 0.000 0.000
#> SRR037202     1  0.0000      1.000 1.000  0 0.000 0.000 0.000
#> SRR037203     1  0.0000      1.000 1.000  0 0.000 0.000 0.000
#> SRR037204     1  0.0000      1.000 1.000  0 0.000 0.000 0.000
#> SRR037205     1  0.0000      1.000 1.000  0 0.000 0.000 0.000
#> SRR037206     3  0.0404      0.955 0.000  0 0.988 0.000 0.012
#> SRR037207     3  0.0404      0.955 0.000  0 0.988 0.000 0.012
#> SRR037208     3  0.0404      0.955 0.000  0 0.988 0.000 0.012
#> SRR037209     3  0.0404      0.955 0.000  0 0.988 0.000 0.012
#> SRR037210     3  0.0404      0.955 0.000  0 0.988 0.000 0.012
#> SRR037211     3  0.0404      0.955 0.000  0 0.988 0.000 0.012
#> SRR037212     3  0.2471      0.911 0.000  0 0.864 0.000 0.136
#> SRR037213     3  0.2471      0.911 0.000  0 0.864 0.000 0.136
#> SRR037219     3  0.2471      0.911 0.000  0 0.864 0.000 0.136
#> SRR037214     3  0.2377      0.920 0.000  0 0.872 0.000 0.128
#> SRR037215     3  0.0404      0.955 0.000  0 0.988 0.000 0.012
#> SRR037216     3  0.0404      0.955 0.000  0 0.988 0.000 0.012
#> SRR037217     3  0.0000      0.955 0.000  0 1.000 0.000 0.000
#> SRR037218     3  0.0000      0.955 0.000  0 1.000 0.000 0.000
#> SRR037220     5  0.4171      1.000 0.396  0 0.000 0.000 0.604
#> SRR037221     5  0.4171      1.000 0.396  0 0.000 0.000 0.604
#> SRR037222     5  0.4171      1.000 0.396  0 0.000 0.000 0.604
#> SRR037223     5  0.4171      1.000 0.396  0 0.000 0.000 0.604
#> SRR037224     5  0.4171      1.000 0.396  0 0.000 0.000 0.604
#> SRR037225     5  0.4171      1.000 0.396  0 0.000 0.000 0.604
#> SRR037226     5  0.4171      1.000 0.396  0 0.000 0.000 0.604

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR037165     4  0.3684    1.00000 0.000 0.000 0.000 0.628 0.372 0.000
#> SRR037166     4  0.3684    1.00000 0.000 0.000 0.000 0.628 0.372 0.000
#> SRR037167     4  0.3684    1.00000 0.000 0.000 0.000 0.628 0.372 0.000
#> SRR037168     4  0.3684    1.00000 0.000 0.000 0.000 0.628 0.372 0.000
#> SRR037169     4  0.3684    1.00000 0.000 0.000 0.000 0.628 0.372 0.000
#> SRR037170     4  0.3684    1.00000 0.000 0.000 0.000 0.628 0.372 0.000
#> SRR037171     2  0.0000    0.98870 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR037172     2  0.0000    0.98870 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR037173     2  0.0000    0.98870 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR037174     2  0.0000    0.98870 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR037175     2  0.0000    0.98870 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR037176     2  0.0000    0.98870 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR037177     2  0.0777    0.98658 0.000 0.972 0.000 0.004 0.000 0.024
#> SRR037182     6  0.3838    1.00000 0.000 0.000 0.448 0.000 0.000 0.552
#> SRR037183     6  0.3838    1.00000 0.000 0.000 0.448 0.000 0.000 0.552
#> SRR037184     2  0.0777    0.98658 0.000 0.972 0.000 0.004 0.000 0.024
#> SRR037185     2  0.0777    0.98658 0.000 0.972 0.000 0.004 0.000 0.024
#> SRR037186     2  0.0777    0.98658 0.000 0.972 0.000 0.004 0.000 0.024
#> SRR037187     2  0.0777    0.98658 0.000 0.972 0.000 0.004 0.000 0.024
#> SRR037188     6  0.3838    1.00000 0.000 0.000 0.448 0.000 0.000 0.552
#> SRR037178     3  0.1610    0.83798 0.000 0.000 0.916 0.000 0.000 0.084
#> SRR037179     3  0.1610    0.83798 0.000 0.000 0.916 0.000 0.000 0.084
#> SRR037180     3  0.1610    0.83798 0.000 0.000 0.916 0.000 0.000 0.084
#> SRR037181     3  0.1610    0.83798 0.000 0.000 0.916 0.000 0.000 0.084
#> SRR037189     2  0.0692    0.98708 0.000 0.976 0.000 0.004 0.000 0.020
#> SRR037190     2  0.0000    0.98870 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR037191     2  0.0000    0.98870 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR037192     2  0.0777    0.98658 0.000 0.972 0.000 0.004 0.000 0.024
#> SRR037193     5  0.3804   -0.00799 0.000 0.000 0.000 0.000 0.576 0.424
#> SRR037194     5  0.3804   -0.00799 0.000 0.000 0.000 0.000 0.576 0.424
#> SRR037195     5  0.3804   -0.00799 0.000 0.000 0.000 0.000 0.576 0.424
#> SRR037196     5  0.3804   -0.00799 0.000 0.000 0.000 0.000 0.576 0.424
#> SRR037197     5  0.3804   -0.00799 0.000 0.000 0.000 0.000 0.576 0.424
#> SRR037198     5  0.3804   -0.00799 0.000 0.000 0.000 0.000 0.576 0.424
#> SRR037199     1  0.0000    1.00000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR037200     1  0.0000    1.00000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR037201     1  0.0000    1.00000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR037202     1  0.0000    1.00000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR037203     1  0.0000    1.00000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR037204     1  0.0000    1.00000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR037205     1  0.0000    1.00000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR037206     3  0.0000    0.87249 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR037207     3  0.0000    0.87249 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR037208     3  0.0000    0.87249 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR037209     3  0.0000    0.87249 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR037210     3  0.0000    0.87249 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR037211     3  0.0000    0.87249 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR037212     6  0.3838    1.00000 0.000 0.000 0.448 0.000 0.000 0.552
#> SRR037213     6  0.3838    1.00000 0.000 0.000 0.448 0.000 0.000 0.552
#> SRR037219     6  0.3838    1.00000 0.000 0.000 0.448 0.000 0.000 0.552
#> SRR037214     3  0.3737   -0.64606 0.000 0.000 0.608 0.000 0.000 0.392
#> SRR037215     3  0.0000    0.87249 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR037216     3  0.0000    0.87249 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR037217     3  0.1610    0.83778 0.000 0.000 0.916 0.000 0.000 0.084
#> SRR037218     3  0.1610    0.83778 0.000 0.000 0.916 0.000 0.000 0.084
#> SRR037220     5  0.5906    0.36569 0.208 0.000 0.000 0.368 0.424 0.000
#> SRR037221     5  0.5906    0.36569 0.208 0.000 0.000 0.368 0.424 0.000
#> SRR037222     5  0.5906    0.36569 0.208 0.000 0.000 0.368 0.424 0.000
#> SRR037223     5  0.5906    0.36569 0.208 0.000 0.000 0.368 0.424 0.000
#> SRR037224     5  0.5906    0.36569 0.208 0.000 0.000 0.368 0.424 0.000
#> SRR037225     5  0.5906    0.36569 0.208 0.000 0.000 0.368 0.424 0.000
#> SRR037226     5  0.5906    0.36569 0.208 0.000 0.000 0.368 0.424 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 15332 rows and 62 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#>   Subgroups are detected by 'pam' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 6.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk CV-pam-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.898           0.849       0.949         0.5035 0.492   0.492
#> 3 3 1.000           1.000       1.000         0.3019 0.811   0.631
#> 4 4 1.000           1.000       1.000         0.0395 0.974   0.925
#> 5 5 1.000           0.981       0.992         0.1339 0.910   0.718
#> 6 6 1.000           1.000       1.000         0.0296 0.967   0.859

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> SRR037165     2   0.000    0.93785 0.000 1.000
#> SRR037166     2   0.000    0.93785 0.000 1.000
#> SRR037167     2   0.000    0.93785 0.000 1.000
#> SRR037168     2   0.000    0.93785 0.000 1.000
#> SRR037169     2   0.000    0.93785 0.000 1.000
#> SRR037170     2   0.000    0.93785 0.000 1.000
#> SRR037171     2   0.000    0.93785 0.000 1.000
#> SRR037172     2   0.000    0.93785 0.000 1.000
#> SRR037173     2   0.000    0.93785 0.000 1.000
#> SRR037174     2   0.000    0.93785 0.000 1.000
#> SRR037175     2   0.000    0.93785 0.000 1.000
#> SRR037176     2   0.000    0.93785 0.000 1.000
#> SRR037177     2   0.000    0.93785 0.000 1.000
#> SRR037182     1   0.000    0.94551 1.000 0.000
#> SRR037183     1   0.000    0.94551 1.000 0.000
#> SRR037184     2   0.000    0.93785 0.000 1.000
#> SRR037185     2   0.000    0.93785 0.000 1.000
#> SRR037186     2   0.000    0.93785 0.000 1.000
#> SRR037187     2   0.000    0.93785 0.000 1.000
#> SRR037188     1   0.000    0.94551 1.000 0.000
#> SRR037178     1   0.000    0.94551 1.000 0.000
#> SRR037179     1   0.000    0.94551 1.000 0.000
#> SRR037180     1   0.000    0.94551 1.000 0.000
#> SRR037181     1   0.000    0.94551 1.000 0.000
#> SRR037189     2   0.000    0.93785 0.000 1.000
#> SRR037190     2   0.000    0.93785 0.000 1.000
#> SRR037191     2   0.000    0.93785 0.000 1.000
#> SRR037192     2   0.000    0.93785 0.000 1.000
#> SRR037193     2   0.000    0.93785 0.000 1.000
#> SRR037194     2   0.000    0.93785 0.000 1.000
#> SRR037195     2   0.000    0.93785 0.000 1.000
#> SRR037196     2   0.000    0.93785 0.000 1.000
#> SRR037197     2   0.000    0.93785 0.000 1.000
#> SRR037198     2   0.000    0.93785 0.000 1.000
#> SRR037199     1   0.000    0.94551 1.000 0.000
#> SRR037200     1   0.000    0.94551 1.000 0.000
#> SRR037201     1   0.000    0.94551 1.000 0.000
#> SRR037202     1   0.000    0.94551 1.000 0.000
#> SRR037203     1   0.000    0.94551 1.000 0.000
#> SRR037204     1   0.000    0.94551 1.000 0.000
#> SRR037205     1   0.000    0.94551 1.000 0.000
#> SRR037206     1   0.000    0.94551 1.000 0.000
#> SRR037207     1   0.000    0.94551 1.000 0.000
#> SRR037208     1   0.000    0.94551 1.000 0.000
#> SRR037209     1   0.000    0.94551 1.000 0.000
#> SRR037210     1   0.000    0.94551 1.000 0.000
#> SRR037211     1   0.000    0.94551 1.000 0.000
#> SRR037212     1   0.000    0.94551 1.000 0.000
#> SRR037213     1   0.000    0.94551 1.000 0.000
#> SRR037219     1   0.000    0.94551 1.000 0.000
#> SRR037214     1   0.000    0.94551 1.000 0.000
#> SRR037215     1   0.000    0.94551 1.000 0.000
#> SRR037216     1   0.000    0.94551 1.000 0.000
#> SRR037217     1   0.000    0.94551 1.000 0.000
#> SRR037218     1   0.000    0.94551 1.000 0.000
#> SRR037220     2   0.921    0.47477 0.336 0.664
#> SRR037221     2   1.000    0.03256 0.492 0.508
#> SRR037222     2   0.988    0.22462 0.436 0.564
#> SRR037223     2   0.991    0.19655 0.444 0.556
#> SRR037224     1   0.999    0.00314 0.516 0.484
#> SRR037225     1   1.000   -0.02720 0.508 0.492
#> SRR037226     1   1.000   -0.04260 0.504 0.496

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette p1 p2 p3
#> SRR037165     2       0          1  0  1  0
#> SRR037166     2       0          1  0  1  0
#> SRR037167     2       0          1  0  1  0
#> SRR037168     2       0          1  0  1  0
#> SRR037169     2       0          1  0  1  0
#> SRR037170     2       0          1  0  1  0
#> SRR037171     2       0          1  0  1  0
#> SRR037172     2       0          1  0  1  0
#> SRR037173     2       0          1  0  1  0
#> SRR037174     2       0          1  0  1  0
#> SRR037175     2       0          1  0  1  0
#> SRR037176     2       0          1  0  1  0
#> SRR037177     2       0          1  0  1  0
#> SRR037182     3       0          1  0  0  1
#> SRR037183     3       0          1  0  0  1
#> SRR037184     2       0          1  0  1  0
#> SRR037185     2       0          1  0  1  0
#> SRR037186     2       0          1  0  1  0
#> SRR037187     2       0          1  0  1  0
#> SRR037188     3       0          1  0  0  1
#> SRR037178     3       0          1  0  0  1
#> SRR037179     3       0          1  0  0  1
#> SRR037180     3       0          1  0  0  1
#> SRR037181     3       0          1  0  0  1
#> SRR037189     2       0          1  0  1  0
#> SRR037190     2       0          1  0  1  0
#> SRR037191     2       0          1  0  1  0
#> SRR037192     2       0          1  0  1  0
#> SRR037193     2       0          1  0  1  0
#> SRR037194     2       0          1  0  1  0
#> SRR037195     2       0          1  0  1  0
#> SRR037196     2       0          1  0  1  0
#> SRR037197     2       0          1  0  1  0
#> SRR037198     2       0          1  0  1  0
#> SRR037199     1       0          1  1  0  0
#> SRR037200     1       0          1  1  0  0
#> SRR037201     1       0          1  1  0  0
#> SRR037202     1       0          1  1  0  0
#> SRR037203     1       0          1  1  0  0
#> SRR037204     1       0          1  1  0  0
#> SRR037205     1       0          1  1  0  0
#> SRR037206     3       0          1  0  0  1
#> SRR037207     3       0          1  0  0  1
#> SRR037208     3       0          1  0  0  1
#> SRR037209     3       0          1  0  0  1
#> SRR037210     3       0          1  0  0  1
#> SRR037211     3       0          1  0  0  1
#> SRR037212     3       0          1  0  0  1
#> SRR037213     3       0          1  0  0  1
#> SRR037219     3       0          1  0  0  1
#> SRR037214     3       0          1  0  0  1
#> SRR037215     3       0          1  0  0  1
#> SRR037216     3       0          1  0  0  1
#> SRR037217     3       0          1  0  0  1
#> SRR037218     3       0          1  0  0  1
#> SRR037220     1       0          1  1  0  0
#> SRR037221     1       0          1  1  0  0
#> SRR037222     1       0          1  1  0  0
#> SRR037223     1       0          1  1  0  0
#> SRR037224     1       0          1  1  0  0
#> SRR037225     1       0          1  1  0  0
#> SRR037226     1       0          1  1  0  0

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette p1 p2 p3 p4
#> SRR037165     2       0          1  0  1  0  0
#> SRR037166     2       0          1  0  1  0  0
#> SRR037167     2       0          1  0  1  0  0
#> SRR037168     2       0          1  0  1  0  0
#> SRR037169     2       0          1  0  1  0  0
#> SRR037170     2       0          1  0  1  0  0
#> SRR037171     2       0          1  0  1  0  0
#> SRR037172     2       0          1  0  1  0  0
#> SRR037173     2       0          1  0  1  0  0
#> SRR037174     2       0          1  0  1  0  0
#> SRR037175     2       0          1  0  1  0  0
#> SRR037176     2       0          1  0  1  0  0
#> SRR037177     2       0          1  0  1  0  0
#> SRR037182     3       0          1  0  0  1  0
#> SRR037183     3       0          1  0  0  1  0
#> SRR037184     2       0          1  0  1  0  0
#> SRR037185     2       0          1  0  1  0  0
#> SRR037186     2       0          1  0  1  0  0
#> SRR037187     2       0          1  0  1  0  0
#> SRR037188     3       0          1  0  0  1  0
#> SRR037178     3       0          1  0  0  1  0
#> SRR037179     3       0          1  0  0  1  0
#> SRR037180     3       0          1  0  0  1  0
#> SRR037181     3       0          1  0  0  1  0
#> SRR037189     2       0          1  0  1  0  0
#> SRR037190     2       0          1  0  1  0  0
#> SRR037191     2       0          1  0  1  0  0
#> SRR037192     2       0          1  0  1  0  0
#> SRR037193     2       0          1  0  1  0  0
#> SRR037194     2       0          1  0  1  0  0
#> SRR037195     2       0          1  0  1  0  0
#> SRR037196     2       0          1  0  1  0  0
#> SRR037197     2       0          1  0  1  0  0
#> SRR037198     2       0          1  0  1  0  0
#> SRR037199     1       0          1  1  0  0  0
#> SRR037200     1       0          1  1  0  0  0
#> SRR037201     1       0          1  1  0  0  0
#> SRR037202     1       0          1  1  0  0  0
#> SRR037203     1       0          1  1  0  0  0
#> SRR037204     1       0          1  1  0  0  0
#> SRR037205     1       0          1  1  0  0  0
#> SRR037206     3       0          1  0  0  1  0
#> SRR037207     3       0          1  0  0  1  0
#> SRR037208     3       0          1  0  0  1  0
#> SRR037209     3       0          1  0  0  1  0
#> SRR037210     3       0          1  0  0  1  0
#> SRR037211     3       0          1  0  0  1  0
#> SRR037212     3       0          1  0  0  1  0
#> SRR037213     3       0          1  0  0  1  0
#> SRR037219     3       0          1  0  0  1  0
#> SRR037214     3       0          1  0  0  1  0
#> SRR037215     3       0          1  0  0  1  0
#> SRR037216     3       0          1  0  0  1  0
#> SRR037217     3       0          1  0  0  1  0
#> SRR037218     3       0          1  0  0  1  0
#> SRR037220     4       0          1  0  0  0  1
#> SRR037221     4       0          1  0  0  0  1
#> SRR037222     4       0          1  0  0  0  1
#> SRR037223     4       0          1  0  0  0  1
#> SRR037224     4       0          1  0  0  0  1
#> SRR037225     4       0          1  0  0  0  1
#> SRR037226     4       0          1  0  0  0  1

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette p1    p2 p3    p4 p5
#> SRR037165     2  0.2690      0.810  0 0.844  0 0.156  0
#> SRR037166     2  0.3999      0.499  0 0.656  0 0.344  0
#> SRR037167     4  0.0162      0.995  0 0.004  0 0.996  0
#> SRR037168     4  0.0000      0.999  0 0.000  0 1.000  0
#> SRR037169     4  0.0000      0.999  0 0.000  0 1.000  0
#> SRR037170     4  0.0000      0.999  0 0.000  0 1.000  0
#> SRR037171     2  0.0000      0.967  0 1.000  0 0.000  0
#> SRR037172     2  0.0000      0.967  0 1.000  0 0.000  0
#> SRR037173     2  0.0000      0.967  0 1.000  0 0.000  0
#> SRR037174     2  0.0000      0.967  0 1.000  0 0.000  0
#> SRR037175     2  0.0000      0.967  0 1.000  0 0.000  0
#> SRR037176     2  0.0000      0.967  0 1.000  0 0.000  0
#> SRR037177     2  0.0000      0.967  0 1.000  0 0.000  0
#> SRR037182     3  0.0000      1.000  0 0.000  1 0.000  0
#> SRR037183     3  0.0000      1.000  0 0.000  1 0.000  0
#> SRR037184     2  0.0000      0.967  0 1.000  0 0.000  0
#> SRR037185     2  0.0000      0.967  0 1.000  0 0.000  0
#> SRR037186     2  0.0000      0.967  0 1.000  0 0.000  0
#> SRR037187     2  0.0000      0.967  0 1.000  0 0.000  0
#> SRR037188     3  0.0000      1.000  0 0.000  1 0.000  0
#> SRR037178     3  0.0000      1.000  0 0.000  1 0.000  0
#> SRR037179     3  0.0000      1.000  0 0.000  1 0.000  0
#> SRR037180     3  0.0000      1.000  0 0.000  1 0.000  0
#> SRR037181     3  0.0000      1.000  0 0.000  1 0.000  0
#> SRR037189     2  0.0000      0.967  0 1.000  0 0.000  0
#> SRR037190     2  0.0000      0.967  0 1.000  0 0.000  0
#> SRR037191     2  0.0000      0.967  0 1.000  0 0.000  0
#> SRR037192     2  0.0000      0.967  0 1.000  0 0.000  0
#> SRR037193     4  0.0000      0.999  0 0.000  0 1.000  0
#> SRR037194     4  0.0000      0.999  0 0.000  0 1.000  0
#> SRR037195     4  0.0000      0.999  0 0.000  0 1.000  0
#> SRR037196     4  0.0000      0.999  0 0.000  0 1.000  0
#> SRR037197     4  0.0000      0.999  0 0.000  0 1.000  0
#> SRR037198     4  0.0000      0.999  0 0.000  0 1.000  0
#> SRR037199     5  0.0000      1.000  0 0.000  0 0.000  1
#> SRR037200     5  0.0000      1.000  0 0.000  0 0.000  1
#> SRR037201     5  0.0000      1.000  0 0.000  0 0.000  1
#> SRR037202     5  0.0000      1.000  0 0.000  0 0.000  1
#> SRR037203     5  0.0000      1.000  0 0.000  0 0.000  1
#> SRR037204     5  0.0000      1.000  0 0.000  0 0.000  1
#> SRR037205     5  0.0000      1.000  0 0.000  0 0.000  1
#> SRR037206     3  0.0000      1.000  0 0.000  1 0.000  0
#> SRR037207     3  0.0000      1.000  0 0.000  1 0.000  0
#> SRR037208     3  0.0000      1.000  0 0.000  1 0.000  0
#> SRR037209     3  0.0000      1.000  0 0.000  1 0.000  0
#> SRR037210     3  0.0000      1.000  0 0.000  1 0.000  0
#> SRR037211     3  0.0000      1.000  0 0.000  1 0.000  0
#> SRR037212     3  0.0000      1.000  0 0.000  1 0.000  0
#> SRR037213     3  0.0000      1.000  0 0.000  1 0.000  0
#> SRR037219     3  0.0000      1.000  0 0.000  1 0.000  0
#> SRR037214     3  0.0000      1.000  0 0.000  1 0.000  0
#> SRR037215     3  0.0000      1.000  0 0.000  1 0.000  0
#> SRR037216     3  0.0000      1.000  0 0.000  1 0.000  0
#> SRR037217     3  0.0000      1.000  0 0.000  1 0.000  0
#> SRR037218     3  0.0000      1.000  0 0.000  1 0.000  0
#> SRR037220     1  0.0000      1.000  1 0.000  0 0.000  0
#> SRR037221     1  0.0000      1.000  1 0.000  0 0.000  0
#> SRR037222     1  0.0000      1.000  1 0.000  0 0.000  0
#> SRR037223     1  0.0000      1.000  1 0.000  0 0.000  0
#> SRR037224     1  0.0000      1.000  1 0.000  0 0.000  0
#> SRR037225     1  0.0000      1.000  1 0.000  0 0.000  0
#> SRR037226     1  0.0000      1.000  1 0.000  0 0.000  0

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR037165     4       0          1  0  0  0  1  0  0
#> SRR037166     4       0          1  0  0  0  1  0  0
#> SRR037167     4       0          1  0  0  0  1  0  0
#> SRR037168     4       0          1  0  0  0  1  0  0
#> SRR037169     4       0          1  0  0  0  1  0  0
#> SRR037170     4       0          1  0  0  0  1  0  0
#> SRR037171     2       0          1  0  1  0  0  0  0
#> SRR037172     2       0          1  0  1  0  0  0  0
#> SRR037173     2       0          1  0  1  0  0  0  0
#> SRR037174     2       0          1  0  1  0  0  0  0
#> SRR037175     2       0          1  0  1  0  0  0  0
#> SRR037176     2       0          1  0  1  0  0  0  0
#> SRR037177     2       0          1  0  1  0  0  0  0
#> SRR037182     3       0          1  0  0  1  0  0  0
#> SRR037183     3       0          1  0  0  1  0  0  0
#> SRR037184     2       0          1  0  1  0  0  0  0
#> SRR037185     2       0          1  0  1  0  0  0  0
#> SRR037186     2       0          1  0  1  0  0  0  0
#> SRR037187     2       0          1  0  1  0  0  0  0
#> SRR037188     3       0          1  0  0  1  0  0  0
#> SRR037178     3       0          1  0  0  1  0  0  0
#> SRR037179     3       0          1  0  0  1  0  0  0
#> SRR037180     3       0          1  0  0  1  0  0  0
#> SRR037181     3       0          1  0  0  1  0  0  0
#> SRR037189     2       0          1  0  1  0  0  0  0
#> SRR037190     2       0          1  0  1  0  0  0  0
#> SRR037191     2       0          1  0  1  0  0  0  0
#> SRR037192     2       0          1  0  1  0  0  0  0
#> SRR037193     6       0          1  0  0  0  0  0  1
#> SRR037194     6       0          1  0  0  0  0  0  1
#> SRR037195     6       0          1  0  0  0  0  0  1
#> SRR037196     6       0          1  0  0  0  0  0  1
#> SRR037197     6       0          1  0  0  0  0  0  1
#> SRR037198     6       0          1  0  0  0  0  0  1
#> SRR037199     1       0          1  1  0  0  0  0  0
#> SRR037200     1       0          1  1  0  0  0  0  0
#> SRR037201     1       0          1  1  0  0  0  0  0
#> SRR037202     1       0          1  1  0  0  0  0  0
#> SRR037203     1       0          1  1  0  0  0  0  0
#> SRR037204     1       0          1  1  0  0  0  0  0
#> SRR037205     1       0          1  1  0  0  0  0  0
#> SRR037206     3       0          1  0  0  1  0  0  0
#> SRR037207     3       0          1  0  0  1  0  0  0
#> SRR037208     3       0          1  0  0  1  0  0  0
#> SRR037209     3       0          1  0  0  1  0  0  0
#> SRR037210     3       0          1  0  0  1  0  0  0
#> SRR037211     3       0          1  0  0  1  0  0  0
#> SRR037212     3       0          1  0  0  1  0  0  0
#> SRR037213     3       0          1  0  0  1  0  0  0
#> SRR037219     3       0          1  0  0  1  0  0  0
#> SRR037214     3       0          1  0  0  1  0  0  0
#> SRR037215     3       0          1  0  0  1  0  0  0
#> SRR037216     3       0          1  0  0  1  0  0  0
#> SRR037217     3       0          1  0  0  1  0  0  0
#> SRR037218     3       0          1  0  0  1  0  0  0
#> SRR037220     5       0          1  0  0  0  0  1  0
#> SRR037221     5       0          1  0  0  0  0  1  0
#> SRR037222     5       0          1  0  0  0  0  1  0
#> SRR037223     5       0          1  0  0  0  0  1  0
#> SRR037224     5       0          1  0  0  0  0  1  0
#> SRR037225     5       0          1  0  0  0  0  1  0
#> SRR037226     5       0          1  0  0  0  0  1  0

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-pam-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-pam-collect-classes

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


CV:mclust*

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

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

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

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

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

collect_plots(res)

plot of chunk CV-mclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.405           0.748       0.848         0.4237 0.645   0.645
#> 3 3 0.816           0.881       0.923         0.5492 0.700   0.535
#> 4 4 0.866           0.959       0.968         0.1403 0.905   0.724
#> 5 5 0.922           0.962       0.894         0.0615 0.948   0.792
#> 6 6 0.873           0.844       0.851         0.0421 1.000   1.000

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

suggest_best_k(res)
#> [1] 5

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
#> SRR037165     2   0.936      0.746 0.352 0.648
#> SRR037166     2   0.936      0.746 0.352 0.648
#> SRR037167     2   0.936      0.746 0.352 0.648
#> SRR037168     2   0.936      0.746 0.352 0.648
#> SRR037169     2   0.936      0.746 0.352 0.648
#> SRR037170     2   0.936      0.746 0.352 0.648
#> SRR037171     2   0.000      0.482 0.000 1.000
#> SRR037172     2   0.000      0.482 0.000 1.000
#> SRR037173     2   0.000      0.482 0.000 1.000
#> SRR037174     2   0.000      0.482 0.000 1.000
#> SRR037175     2   0.000      0.482 0.000 1.000
#> SRR037176     2   0.000      0.482 0.000 1.000
#> SRR037177     2   0.000      0.482 0.000 1.000
#> SRR037182     2   0.997      0.772 0.468 0.532
#> SRR037183     2   0.997      0.772 0.468 0.532
#> SRR037184     2   0.000      0.482 0.000 1.000
#> SRR037185     2   0.000      0.482 0.000 1.000
#> SRR037186     2   0.000      0.482 0.000 1.000
#> SRR037187     2   0.000      0.482 0.000 1.000
#> SRR037188     2   0.997      0.772 0.468 0.532
#> SRR037178     2   0.997      0.772 0.468 0.532
#> SRR037179     2   0.997      0.772 0.468 0.532
#> SRR037180     2   0.997      0.772 0.468 0.532
#> SRR037181     2   0.997      0.772 0.468 0.532
#> SRR037189     2   0.000      0.482 0.000 1.000
#> SRR037190     2   0.000      0.482 0.000 1.000
#> SRR037191     2   0.000      0.482 0.000 1.000
#> SRR037192     2   0.000      0.482 0.000 1.000
#> SRR037193     2   0.936      0.746 0.352 0.648
#> SRR037194     2   0.936      0.746 0.352 0.648
#> SRR037195     2   0.936      0.746 0.352 0.648
#> SRR037196     2   0.936      0.746 0.352 0.648
#> SRR037197     2   0.936      0.746 0.352 0.648
#> SRR037198     2   0.936      0.746 0.352 0.648
#> SRR037199     1   0.996      1.000 0.536 0.464
#> SRR037200     1   0.996      1.000 0.536 0.464
#> SRR037201     1   0.996      1.000 0.536 0.464
#> SRR037202     1   0.996      1.000 0.536 0.464
#> SRR037203     1   0.996      1.000 0.536 0.464
#> SRR037204     1   0.996      1.000 0.536 0.464
#> SRR037205     1   0.996      1.000 0.536 0.464
#> SRR037206     2   0.997      0.772 0.468 0.532
#> SRR037207     2   0.997      0.772 0.468 0.532
#> SRR037208     2   0.997      0.772 0.468 0.532
#> SRR037209     2   0.997      0.772 0.468 0.532
#> SRR037210     2   0.997      0.772 0.468 0.532
#> SRR037211     2   0.997      0.772 0.468 0.532
#> SRR037212     2   0.997      0.772 0.468 0.532
#> SRR037213     2   0.997      0.772 0.468 0.532
#> SRR037219     2   0.997      0.772 0.468 0.532
#> SRR037214     2   0.997      0.772 0.468 0.532
#> SRR037215     2   0.997      0.772 0.468 0.532
#> SRR037216     2   0.997      0.772 0.468 0.532
#> SRR037217     2   0.997      0.772 0.468 0.532
#> SRR037218     2   0.997      0.772 0.468 0.532
#> SRR037220     1   0.996      1.000 0.536 0.464
#> SRR037221     1   0.996      1.000 0.536 0.464
#> SRR037222     1   0.996      1.000 0.536 0.464
#> SRR037223     1   0.996      1.000 0.536 0.464
#> SRR037224     1   0.996      1.000 0.536 0.464
#> SRR037225     1   0.996      1.000 0.536 0.464
#> SRR037226     1   0.996      1.000 0.536 0.464

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> SRR037165     2   0.729      0.647 0.356 0.604 0.040
#> SRR037166     2   0.729      0.647 0.356 0.604 0.040
#> SRR037167     2   0.729      0.647 0.356 0.604 0.040
#> SRR037168     2   0.729      0.647 0.356 0.604 0.040
#> SRR037169     2   0.729      0.647 0.356 0.604 0.040
#> SRR037170     2   0.729      0.647 0.356 0.604 0.040
#> SRR037171     2   0.000      0.791 0.000 1.000 0.000
#> SRR037172     2   0.000      0.791 0.000 1.000 0.000
#> SRR037173     2   0.000      0.791 0.000 1.000 0.000
#> SRR037174     2   0.000      0.791 0.000 1.000 0.000
#> SRR037175     2   0.000      0.791 0.000 1.000 0.000
#> SRR037176     2   0.000      0.791 0.000 1.000 0.000
#> SRR037177     2   0.000      0.791 0.000 1.000 0.000
#> SRR037182     3   0.000      1.000 0.000 0.000 1.000
#> SRR037183     3   0.000      1.000 0.000 0.000 1.000
#> SRR037184     2   0.000      0.791 0.000 1.000 0.000
#> SRR037185     2   0.000      0.791 0.000 1.000 0.000
#> SRR037186     2   0.000      0.791 0.000 1.000 0.000
#> SRR037187     2   0.000      0.791 0.000 1.000 0.000
#> SRR037188     3   0.000      1.000 0.000 0.000 1.000
#> SRR037178     3   0.000      1.000 0.000 0.000 1.000
#> SRR037179     3   0.000      1.000 0.000 0.000 1.000
#> SRR037180     3   0.000      1.000 0.000 0.000 1.000
#> SRR037181     3   0.000      1.000 0.000 0.000 1.000
#> SRR037189     2   0.000      0.791 0.000 1.000 0.000
#> SRR037190     2   0.000      0.791 0.000 1.000 0.000
#> SRR037191     2   0.000      0.791 0.000 1.000 0.000
#> SRR037192     2   0.000      0.791 0.000 1.000 0.000
#> SRR037193     2   0.739      0.644 0.356 0.600 0.044
#> SRR037194     2   0.739      0.644 0.356 0.600 0.044
#> SRR037195     2   0.739      0.644 0.356 0.600 0.044
#> SRR037196     2   0.739      0.644 0.356 0.600 0.044
#> SRR037197     2   0.739      0.644 0.356 0.600 0.044
#> SRR037198     2   0.739      0.644 0.356 0.600 0.044
#> SRR037199     1   0.000      1.000 1.000 0.000 0.000
#> SRR037200     1   0.000      1.000 1.000 0.000 0.000
#> SRR037201     1   0.000      1.000 1.000 0.000 0.000
#> SRR037202     1   0.000      1.000 1.000 0.000 0.000
#> SRR037203     1   0.000      1.000 1.000 0.000 0.000
#> SRR037204     1   0.000      1.000 1.000 0.000 0.000
#> SRR037205     1   0.000      1.000 1.000 0.000 0.000
#> SRR037206     3   0.000      1.000 0.000 0.000 1.000
#> SRR037207     3   0.000      1.000 0.000 0.000 1.000
#> SRR037208     3   0.000      1.000 0.000 0.000 1.000
#> SRR037209     3   0.000      1.000 0.000 0.000 1.000
#> SRR037210     3   0.000      1.000 0.000 0.000 1.000
#> SRR037211     3   0.000      1.000 0.000 0.000 1.000
#> SRR037212     3   0.000      1.000 0.000 0.000 1.000
#> SRR037213     3   0.000      1.000 0.000 0.000 1.000
#> SRR037219     3   0.000      1.000 0.000 0.000 1.000
#> SRR037214     3   0.000      1.000 0.000 0.000 1.000
#> SRR037215     3   0.000      1.000 0.000 0.000 1.000
#> SRR037216     3   0.000      1.000 0.000 0.000 1.000
#> SRR037217     3   0.000      1.000 0.000 0.000 1.000
#> SRR037218     3   0.000      1.000 0.000 0.000 1.000
#> SRR037220     1   0.000      1.000 1.000 0.000 0.000
#> SRR037221     1   0.000      1.000 1.000 0.000 0.000
#> SRR037222     1   0.000      1.000 1.000 0.000 0.000
#> SRR037223     1   0.000      1.000 1.000 0.000 0.000
#> SRR037224     1   0.000      1.000 1.000 0.000 0.000
#> SRR037225     1   0.000      1.000 1.000 0.000 0.000
#> SRR037226     1   0.000      1.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> SRR037165     4  0.1022      0.979 0.000 0.032 0.000 0.968
#> SRR037166     4  0.1022      0.979 0.000 0.032 0.000 0.968
#> SRR037167     4  0.1022      0.979 0.000 0.032 0.000 0.968
#> SRR037168     4  0.0921      0.981 0.000 0.028 0.000 0.972
#> SRR037169     4  0.0817      0.982 0.000 0.024 0.000 0.976
#> SRR037170     4  0.1022      0.979 0.000 0.032 0.000 0.968
#> SRR037171     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> SRR037172     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> SRR037173     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> SRR037174     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> SRR037175     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> SRR037176     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> SRR037177     2  0.0188      0.998 0.000 0.996 0.000 0.004
#> SRR037182     3  0.2469      0.918 0.000 0.000 0.892 0.108
#> SRR037183     3  0.2469      0.918 0.000 0.000 0.892 0.108
#> SRR037184     2  0.0188      0.998 0.000 0.996 0.000 0.004
#> SRR037185     2  0.0188      0.998 0.000 0.996 0.000 0.004
#> SRR037186     2  0.0188      0.998 0.000 0.996 0.000 0.004
#> SRR037187     2  0.0188      0.998 0.000 0.996 0.000 0.004
#> SRR037188     3  0.2469      0.918 0.000 0.000 0.892 0.108
#> SRR037178     3  0.0000      0.964 0.000 0.000 1.000 0.000
#> SRR037179     3  0.0000      0.964 0.000 0.000 1.000 0.000
#> SRR037180     3  0.0000      0.964 0.000 0.000 1.000 0.000
#> SRR037181     3  0.0000      0.964 0.000 0.000 1.000 0.000
#> SRR037189     2  0.0188      0.998 0.000 0.996 0.000 0.004
#> SRR037190     2  0.0188      0.998 0.000 0.996 0.000 0.004
#> SRR037191     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> SRR037192     2  0.0188      0.998 0.000 0.996 0.000 0.004
#> SRR037193     4  0.0188      0.982 0.000 0.004 0.000 0.996
#> SRR037194     4  0.0188      0.982 0.000 0.004 0.000 0.996
#> SRR037195     4  0.0188      0.982 0.000 0.004 0.000 0.996
#> SRR037196     4  0.0188      0.982 0.000 0.004 0.000 0.996
#> SRR037197     4  0.0188      0.982 0.000 0.004 0.000 0.996
#> SRR037198     4  0.0188      0.982 0.000 0.004 0.000 0.996
#> SRR037199     1  0.0000      0.917 1.000 0.000 0.000 0.000
#> SRR037200     1  0.0000      0.917 1.000 0.000 0.000 0.000
#> SRR037201     1  0.0000      0.917 1.000 0.000 0.000 0.000
#> SRR037202     1  0.0000      0.917 1.000 0.000 0.000 0.000
#> SRR037203     1  0.0000      0.917 1.000 0.000 0.000 0.000
#> SRR037204     1  0.0000      0.917 1.000 0.000 0.000 0.000
#> SRR037205     1  0.0000      0.917 1.000 0.000 0.000 0.000
#> SRR037206     3  0.0000      0.964 0.000 0.000 1.000 0.000
#> SRR037207     3  0.0000      0.964 0.000 0.000 1.000 0.000
#> SRR037208     3  0.0000      0.964 0.000 0.000 1.000 0.000
#> SRR037209     3  0.0000      0.964 0.000 0.000 1.000 0.000
#> SRR037210     3  0.0000      0.964 0.000 0.000 1.000 0.000
#> SRR037211     3  0.0000      0.964 0.000 0.000 1.000 0.000
#> SRR037212     3  0.2469      0.918 0.000 0.000 0.892 0.108
#> SRR037213     3  0.2469      0.918 0.000 0.000 0.892 0.108
#> SRR037219     3  0.2469      0.918 0.000 0.000 0.892 0.108
#> SRR037214     3  0.1940      0.934 0.000 0.000 0.924 0.076
#> SRR037215     3  0.0000      0.964 0.000 0.000 1.000 0.000
#> SRR037216     3  0.0000      0.964 0.000 0.000 1.000 0.000
#> SRR037217     3  0.0000      0.964 0.000 0.000 1.000 0.000
#> SRR037218     3  0.0000      0.964 0.000 0.000 1.000 0.000
#> SRR037220     1  0.2973      0.910 0.856 0.000 0.000 0.144
#> SRR037221     1  0.2973      0.910 0.856 0.000 0.000 0.144
#> SRR037222     1  0.2973      0.910 0.856 0.000 0.000 0.144
#> SRR037223     1  0.2973      0.910 0.856 0.000 0.000 0.144
#> SRR037224     1  0.2973      0.910 0.856 0.000 0.000 0.144
#> SRR037225     1  0.2973      0.910 0.856 0.000 0.000 0.144
#> SRR037226     1  0.2973      0.910 0.856 0.000 0.000 0.144

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> SRR037165     4  0.0290      0.984 0.000 0.000 0.000 0.992 0.008
#> SRR037166     4  0.0290      0.984 0.000 0.000 0.000 0.992 0.008
#> SRR037167     4  0.0162      0.984 0.000 0.000 0.000 0.996 0.004
#> SRR037168     4  0.1410      0.953 0.000 0.000 0.000 0.940 0.060
#> SRR037169     4  0.1410      0.953 0.000 0.000 0.000 0.940 0.060
#> SRR037170     4  0.0162      0.984 0.000 0.000 0.000 0.996 0.004
#> SRR037171     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> SRR037172     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> SRR037173     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> SRR037174     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> SRR037175     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> SRR037176     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> SRR037177     2  0.0162      0.998 0.000 0.996 0.000 0.004 0.000
#> SRR037182     5  0.3837      0.999 0.000 0.000 0.308 0.000 0.692
#> SRR037183     5  0.3837      0.999 0.000 0.000 0.308 0.000 0.692
#> SRR037184     2  0.0162      0.998 0.000 0.996 0.000 0.004 0.000
#> SRR037185     2  0.0162      0.998 0.000 0.996 0.000 0.004 0.000
#> SRR037186     2  0.0162      0.998 0.000 0.996 0.000 0.004 0.000
#> SRR037187     2  0.0162      0.998 0.000 0.996 0.000 0.004 0.000
#> SRR037188     5  0.3837      0.999 0.000 0.000 0.308 0.000 0.692
#> SRR037178     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000
#> SRR037179     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000
#> SRR037180     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000
#> SRR037181     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000
#> SRR037189     2  0.0162      0.998 0.000 0.996 0.000 0.004 0.000
#> SRR037190     2  0.0162      0.998 0.000 0.996 0.000 0.004 0.000
#> SRR037191     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> SRR037192     2  0.0162      0.998 0.000 0.996 0.000 0.004 0.000
#> SRR037193     4  0.0000      0.984 0.000 0.000 0.000 1.000 0.000
#> SRR037194     4  0.0000      0.984 0.000 0.000 0.000 1.000 0.000
#> SRR037195     4  0.0000      0.984 0.000 0.000 0.000 1.000 0.000
#> SRR037196     4  0.0162      0.984 0.000 0.000 0.000 0.996 0.004
#> SRR037197     4  0.1197      0.960 0.000 0.000 0.000 0.952 0.048
#> SRR037198     4  0.0162      0.984 0.000 0.000 0.000 0.996 0.004
#> SRR037199     1  0.0000      0.858 1.000 0.000 0.000 0.000 0.000
#> SRR037200     1  0.0000      0.858 1.000 0.000 0.000 0.000 0.000
#> SRR037201     1  0.0000      0.858 1.000 0.000 0.000 0.000 0.000
#> SRR037202     1  0.0000      0.858 1.000 0.000 0.000 0.000 0.000
#> SRR037203     1  0.0000      0.858 1.000 0.000 0.000 0.000 0.000
#> SRR037204     1  0.0000      0.858 1.000 0.000 0.000 0.000 0.000
#> SRR037205     1  0.0000      0.858 1.000 0.000 0.000 0.000 0.000
#> SRR037206     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000
#> SRR037207     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000
#> SRR037208     3  0.0162      0.996 0.000 0.000 0.996 0.000 0.004
#> SRR037209     3  0.0162      0.996 0.000 0.000 0.996 0.000 0.004
#> SRR037210     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000
#> SRR037211     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000
#> SRR037212     5  0.3837      0.999 0.000 0.000 0.308 0.000 0.692
#> SRR037213     5  0.3837      0.999 0.000 0.000 0.308 0.000 0.692
#> SRR037219     5  0.3837      0.999 0.000 0.000 0.308 0.000 0.692
#> SRR037214     5  0.3857      0.994 0.000 0.000 0.312 0.000 0.688
#> SRR037215     3  0.0162      0.996 0.000 0.000 0.996 0.000 0.004
#> SRR037216     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000
#> SRR037217     3  0.0162      0.996 0.000 0.000 0.996 0.000 0.004
#> SRR037218     3  0.0162      0.996 0.000 0.000 0.996 0.000 0.004
#> SRR037220     1  0.3816      0.858 0.696 0.000 0.000 0.000 0.304
#> SRR037221     1  0.3816      0.858 0.696 0.000 0.000 0.000 0.304
#> SRR037222     1  0.3816      0.858 0.696 0.000 0.000 0.000 0.304
#> SRR037223     1  0.3816      0.858 0.696 0.000 0.000 0.000 0.304
#> SRR037224     1  0.3816      0.858 0.696 0.000 0.000 0.000 0.304
#> SRR037225     1  0.3816      0.858 0.696 0.000 0.000 0.000 0.304
#> SRR037226     1  0.3816      0.858 0.696 0.000 0.000 0.000 0.304

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4 p5    p6
#> SRR037165     4  0.1434      0.932 0.000 0.000 0.000 0.940 NA 0.012
#> SRR037166     4  0.1434      0.932 0.000 0.000 0.000 0.940 NA 0.012
#> SRR037167     4  0.1434      0.932 0.000 0.000 0.000 0.940 NA 0.012
#> SRR037168     4  0.3078      0.890 0.000 0.000 0.000 0.796 NA 0.012
#> SRR037169     4  0.3078      0.890 0.000 0.000 0.000 0.796 NA 0.012
#> SRR037170     4  0.3078      0.890 0.000 0.000 0.000 0.796 NA 0.012
#> SRR037171     2  0.0000      0.768 0.000 1.000 0.000 0.000 NA 0.000
#> SRR037172     2  0.0000      0.768 0.000 1.000 0.000 0.000 NA 0.000
#> SRR037173     2  0.0146      0.769 0.000 0.996 0.000 0.000 NA 0.000
#> SRR037174     2  0.0260      0.769 0.000 0.992 0.000 0.000 NA 0.000
#> SRR037175     2  0.0000      0.768 0.000 1.000 0.000 0.000 NA 0.000
#> SRR037176     2  0.0000      0.768 0.000 1.000 0.000 0.000 NA 0.000
#> SRR037177     2  0.4253      0.738 0.000 0.524 0.000 0.016 NA 0.000
#> SRR037182     6  0.0363      0.840 0.000 0.000 0.012 0.000 NA 0.988
#> SRR037183     6  0.0363      0.840 0.000 0.000 0.012 0.000 NA 0.988
#> SRR037184     2  0.4253      0.738 0.000 0.524 0.000 0.016 NA 0.000
#> SRR037185     2  0.4253      0.738 0.000 0.524 0.000 0.016 NA 0.000
#> SRR037186     2  0.4253      0.738 0.000 0.524 0.000 0.016 NA 0.000
#> SRR037187     2  0.4253      0.738 0.000 0.524 0.000 0.016 NA 0.000
#> SRR037188     6  0.0363      0.840 0.000 0.000 0.012 0.000 NA 0.988
#> SRR037178     3  0.2793      0.800 0.000 0.000 0.800 0.000 NA 0.200
#> SRR037179     3  0.2793      0.800 0.000 0.000 0.800 0.000 NA 0.200
#> SRR037180     3  0.2793      0.800 0.000 0.000 0.800 0.000 NA 0.200
#> SRR037181     3  0.2793      0.800 0.000 0.000 0.800 0.000 NA 0.200
#> SRR037189     2  0.4328      0.736 0.000 0.520 0.000 0.020 NA 0.000
#> SRR037190     2  0.1245      0.768 0.000 0.952 0.000 0.016 NA 0.000
#> SRR037191     2  0.0000      0.768 0.000 1.000 0.000 0.000 NA 0.000
#> SRR037192     2  0.4253      0.738 0.000 0.524 0.000 0.016 NA 0.000
#> SRR037193     4  0.0000      0.934 0.000 0.000 0.000 1.000 NA 0.000
#> SRR037194     4  0.0000      0.934 0.000 0.000 0.000 1.000 NA 0.000
#> SRR037195     4  0.0000      0.934 0.000 0.000 0.000 1.000 NA 0.000
#> SRR037196     4  0.0000      0.934 0.000 0.000 0.000 1.000 NA 0.000
#> SRR037197     4  0.2300      0.894 0.000 0.000 0.000 0.856 NA 0.000
#> SRR037198     4  0.0000      0.934 0.000 0.000 0.000 1.000 NA 0.000
#> SRR037199     1  0.3607      0.825 0.652 0.000 0.000 0.000 NA 0.000
#> SRR037200     1  0.3607      0.825 0.652 0.000 0.000 0.000 NA 0.000
#> SRR037201     1  0.3607      0.825 0.652 0.000 0.000 0.000 NA 0.000
#> SRR037202     1  0.3607      0.825 0.652 0.000 0.000 0.000 NA 0.000
#> SRR037203     1  0.3607      0.825 0.652 0.000 0.000 0.000 NA 0.000
#> SRR037204     1  0.3607      0.825 0.652 0.000 0.000 0.000 NA 0.000
#> SRR037205     1  0.3607      0.825 0.652 0.000 0.000 0.000 NA 0.000
#> SRR037206     3  0.0000      0.921 0.000 0.000 1.000 0.000 NA 0.000
#> SRR037207     3  0.0000      0.921 0.000 0.000 1.000 0.000 NA 0.000
#> SRR037208     3  0.0260      0.919 0.000 0.000 0.992 0.000 NA 0.008
#> SRR037209     3  0.0260      0.919 0.000 0.000 0.992 0.000 NA 0.008
#> SRR037210     3  0.0000      0.921 0.000 0.000 1.000 0.000 NA 0.000
#> SRR037211     3  0.0000      0.921 0.000 0.000 1.000 0.000 NA 0.000
#> SRR037212     6  0.2883      0.871 0.000 0.000 0.212 0.000 NA 0.788
#> SRR037213     6  0.2883      0.871 0.000 0.000 0.212 0.000 NA 0.788
#> SRR037219     6  0.2883      0.871 0.000 0.000 0.212 0.000 NA 0.788
#> SRR037214     6  0.2883      0.871 0.000 0.000 0.212 0.000 NA 0.788
#> SRR037215     3  0.0260      0.919 0.000 0.000 0.992 0.000 NA 0.008
#> SRR037216     3  0.0000      0.921 0.000 0.000 1.000 0.000 NA 0.000
#> SRR037217     3  0.0260      0.919 0.000 0.000 0.992 0.000 NA 0.008
#> SRR037218     3  0.0260      0.919 0.000 0.000 0.992 0.000 NA 0.008
#> SRR037220     1  0.0000      0.825 1.000 0.000 0.000 0.000 NA 0.000
#> SRR037221     1  0.0000      0.825 1.000 0.000 0.000 0.000 NA 0.000
#> SRR037222     1  0.0000      0.825 1.000 0.000 0.000 0.000 NA 0.000
#> SRR037223     1  0.0000      0.825 1.000 0.000 0.000 0.000 NA 0.000
#> SRR037224     1  0.0000      0.825 1.000 0.000 0.000 0.000 NA 0.000
#> SRR037225     1  0.0000      0.825 1.000 0.000 0.000 0.000 NA 0.000
#> SRR037226     1  0.0000      0.825 1.000 0.000 0.000 0.000 NA 0.000

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

consensus_heatmap(res, k = 2)

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

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

collect_plots(res)

plot of chunk CV-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.566           0.662       0.810         0.4351 0.500   0.500
#> 3 3 1.000           1.000       1.000         0.5068 0.845   0.689
#> 4 4 0.879           0.980       0.934         0.1223 0.905   0.724
#> 5 5 0.914           0.958       0.891         0.0563 0.974   0.896
#> 6 6 0.894           0.930       0.874         0.0324 0.981   0.915

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> SRR037165     2  0.9954      1.000 0.460 0.540
#> SRR037166     2  0.9954      1.000 0.460 0.540
#> SRR037167     2  0.9954      1.000 0.460 0.540
#> SRR037168     2  0.9954      1.000 0.460 0.540
#> SRR037169     2  0.9954      1.000 0.460 0.540
#> SRR037170     2  0.9954      1.000 0.460 0.540
#> SRR037171     2  0.9954      1.000 0.460 0.540
#> SRR037172     2  0.9954      1.000 0.460 0.540
#> SRR037173     2  0.9954      1.000 0.460 0.540
#> SRR037174     2  0.9954      1.000 0.460 0.540
#> SRR037175     2  0.9954      1.000 0.460 0.540
#> SRR037176     2  0.9954      1.000 0.460 0.540
#> SRR037177     2  0.9954      1.000 0.460 0.540
#> SRR037182     1  0.5059      0.291 0.888 0.112
#> SRR037183     1  0.3431      0.414 0.936 0.064
#> SRR037184     2  0.9954      1.000 0.460 0.540
#> SRR037185     2  0.9954      1.000 0.460 0.540
#> SRR037186     2  0.9954      1.000 0.460 0.540
#> SRR037187     2  0.9954      1.000 0.460 0.540
#> SRR037188     1  0.5737      0.216 0.864 0.136
#> SRR037178     1  0.9286     -0.569 0.656 0.344
#> SRR037179     1  0.9286     -0.569 0.656 0.344
#> SRR037180     1  0.9044     -0.498 0.680 0.320
#> SRR037181     1  0.9393     -0.604 0.644 0.356
#> SRR037189     2  0.9954      1.000 0.460 0.540
#> SRR037190     2  0.9954      1.000 0.460 0.540
#> SRR037191     2  0.9954      1.000 0.460 0.540
#> SRR037192     2  0.9954      1.000 0.460 0.540
#> SRR037193     2  0.9954      1.000 0.460 0.540
#> SRR037194     2  0.9954      1.000 0.460 0.540
#> SRR037195     2  0.9954      1.000 0.460 0.540
#> SRR037196     2  0.9954      1.000 0.460 0.540
#> SRR037197     2  0.9954      1.000 0.460 0.540
#> SRR037198     2  0.9954      1.000 0.460 0.540
#> SRR037199     1  0.9983      0.606 0.524 0.476
#> SRR037200     1  0.9983      0.606 0.524 0.476
#> SRR037201     1  0.9983      0.606 0.524 0.476
#> SRR037202     1  0.9983      0.606 0.524 0.476
#> SRR037203     1  0.9983      0.606 0.524 0.476
#> SRR037204     1  0.9983      0.606 0.524 0.476
#> SRR037205     1  0.9983      0.606 0.524 0.476
#> SRR037206     1  0.2043      0.472 0.968 0.032
#> SRR037207     1  0.1843      0.478 0.972 0.028
#> SRR037208     1  0.0000      0.513 1.000 0.000
#> SRR037209     1  0.0000      0.513 1.000 0.000
#> SRR037210     1  0.2423      0.460 0.960 0.040
#> SRR037211     1  0.3274      0.423 0.940 0.060
#> SRR037212     1  0.0376      0.516 0.996 0.004
#> SRR037213     1  0.0376      0.516 0.996 0.004
#> SRR037219     1  0.0672      0.517 0.992 0.008
#> SRR037214     1  0.0376      0.516 0.996 0.004
#> SRR037215     1  0.0000      0.513 1.000 0.000
#> SRR037216     1  0.2948      0.438 0.948 0.052
#> SRR037217     1  0.0000      0.513 1.000 0.000
#> SRR037218     1  0.0000      0.513 1.000 0.000
#> SRR037220     1  0.9983      0.606 0.524 0.476
#> SRR037221     1  0.9983      0.606 0.524 0.476
#> SRR037222     1  0.9983      0.606 0.524 0.476
#> SRR037223     1  0.9983      0.606 0.524 0.476
#> SRR037224     1  0.9983      0.606 0.524 0.476
#> SRR037225     1  0.9983      0.606 0.524 0.476
#> SRR037226     1  0.9983      0.606 0.524 0.476

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette p1 p2 p3
#> SRR037165     2       0          1  0  1  0
#> SRR037166     2       0          1  0  1  0
#> SRR037167     2       0          1  0  1  0
#> SRR037168     2       0          1  0  1  0
#> SRR037169     2       0          1  0  1  0
#> SRR037170     2       0          1  0  1  0
#> SRR037171     2       0          1  0  1  0
#> SRR037172     2       0          1  0  1  0
#> SRR037173     2       0          1  0  1  0
#> SRR037174     2       0          1  0  1  0
#> SRR037175     2       0          1  0  1  0
#> SRR037176     2       0          1  0  1  0
#> SRR037177     2       0          1  0  1  0
#> SRR037182     3       0          1  0  0  1
#> SRR037183     3       0          1  0  0  1
#> SRR037184     2       0          1  0  1  0
#> SRR037185     2       0          1  0  1  0
#> SRR037186     2       0          1  0  1  0
#> SRR037187     2       0          1  0  1  0
#> SRR037188     3       0          1  0  0  1
#> SRR037178     3       0          1  0  0  1
#> SRR037179     3       0          1  0  0  1
#> SRR037180     3       0          1  0  0  1
#> SRR037181     3       0          1  0  0  1
#> SRR037189     2       0          1  0  1  0
#> SRR037190     2       0          1  0  1  0
#> SRR037191     2       0          1  0  1  0
#> SRR037192     2       0          1  0  1  0
#> SRR037193     2       0          1  0  1  0
#> SRR037194     2       0          1  0  1  0
#> SRR037195     2       0          1  0  1  0
#> SRR037196     2       0          1  0  1  0
#> SRR037197     2       0          1  0  1  0
#> SRR037198     2       0          1  0  1  0
#> SRR037199     1       0          1  1  0  0
#> SRR037200     1       0          1  1  0  0
#> SRR037201     1       0          1  1  0  0
#> SRR037202     1       0          1  1  0  0
#> SRR037203     1       0          1  1  0  0
#> SRR037204     1       0          1  1  0  0
#> SRR037205     1       0          1  1  0  0
#> SRR037206     3       0          1  0  0  1
#> SRR037207     3       0          1  0  0  1
#> SRR037208     3       0          1  0  0  1
#> SRR037209     3       0          1  0  0  1
#> SRR037210     3       0          1  0  0  1
#> SRR037211     3       0          1  0  0  1
#> SRR037212     3       0          1  0  0  1
#> SRR037213     3       0          1  0  0  1
#> SRR037219     3       0          1  0  0  1
#> SRR037214     3       0          1  0  0  1
#> SRR037215     3       0          1  0  0  1
#> SRR037216     3       0          1  0  0  1
#> SRR037217     3       0          1  0  0  1
#> SRR037218     3       0          1  0  0  1
#> SRR037220     1       0          1  1  0  0
#> SRR037221     1       0          1  1  0  0
#> SRR037222     1       0          1  1  0  0
#> SRR037223     1       0          1  1  0  0
#> SRR037224     1       0          1  1  0  0
#> SRR037225     1       0          1  1  0  0
#> SRR037226     1       0          1  1  0  0

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2 p3    p4
#> SRR037165     4   0.000      1.000 0.000 0.000  0 1.000
#> SRR037166     4   0.000      1.000 0.000 0.000  0 1.000
#> SRR037167     4   0.000      1.000 0.000 0.000  0 1.000
#> SRR037168     4   0.000      1.000 0.000 0.000  0 1.000
#> SRR037169     4   0.000      1.000 0.000 0.000  0 1.000
#> SRR037170     4   0.000      1.000 0.000 0.000  0 1.000
#> SRR037171     2   0.376      1.000 0.000 0.784  0 0.216
#> SRR037172     2   0.376      1.000 0.000 0.784  0 0.216
#> SRR037173     2   0.376      1.000 0.000 0.784  0 0.216
#> SRR037174     2   0.376      1.000 0.000 0.784  0 0.216
#> SRR037175     2   0.376      1.000 0.000 0.784  0 0.216
#> SRR037176     2   0.376      1.000 0.000 0.784  0 0.216
#> SRR037177     2   0.376      1.000 0.000 0.784  0 0.216
#> SRR037182     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR037183     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR037184     2   0.376      1.000 0.000 0.784  0 0.216
#> SRR037185     2   0.376      1.000 0.000 0.784  0 0.216
#> SRR037186     2   0.376      1.000 0.000 0.784  0 0.216
#> SRR037187     2   0.376      1.000 0.000 0.784  0 0.216
#> SRR037188     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR037178     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR037179     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR037180     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR037181     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR037189     2   0.376      1.000 0.000 0.784  0 0.216
#> SRR037190     2   0.376      1.000 0.000 0.784  0 0.216
#> SRR037191     2   0.376      1.000 0.000 0.784  0 0.216
#> SRR037192     2   0.376      1.000 0.000 0.784  0 0.216
#> SRR037193     4   0.000      1.000 0.000 0.000  0 1.000
#> SRR037194     4   0.000      1.000 0.000 0.000  0 1.000
#> SRR037195     4   0.000      1.000 0.000 0.000  0 1.000
#> SRR037196     4   0.000      1.000 0.000 0.000  0 1.000
#> SRR037197     4   0.000      1.000 0.000 0.000  0 1.000
#> SRR037198     4   0.000      1.000 0.000 0.000  0 1.000
#> SRR037199     1   0.000      0.911 1.000 0.000  0 0.000
#> SRR037200     1   0.000      0.911 1.000 0.000  0 0.000
#> SRR037201     1   0.000      0.911 1.000 0.000  0 0.000
#> SRR037202     1   0.000      0.911 1.000 0.000  0 0.000
#> SRR037203     1   0.000      0.911 1.000 0.000  0 0.000
#> SRR037204     1   0.000      0.911 1.000 0.000  0 0.000
#> SRR037205     1   0.000      0.911 1.000 0.000  0 0.000
#> SRR037206     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR037207     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR037208     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR037209     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR037210     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR037211     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR037212     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR037213     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR037219     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR037214     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR037215     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR037216     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR037217     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR037218     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR037220     1   0.376      0.911 0.784 0.216  0 0.000
#> SRR037221     1   0.376      0.911 0.784 0.216  0 0.000
#> SRR037222     1   0.376      0.911 0.784 0.216  0 0.000
#> SRR037223     1   0.376      0.911 0.784 0.216  0 0.000
#> SRR037224     1   0.376      0.911 0.784 0.216  0 0.000
#> SRR037225     1   0.376      0.911 0.784 0.216  0 0.000
#> SRR037226     1   0.376      0.911 0.784 0.216  0 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette   p1    p2    p3    p4    p5
#> SRR037165     4  0.0000      0.893 0.00 0.000 0.000 1.000 0.000
#> SRR037166     4  0.0000      0.893 0.00 0.000 0.000 1.000 0.000
#> SRR037167     4  0.0000      0.893 0.00 0.000 0.000 1.000 0.000
#> SRR037168     4  0.0000      0.893 0.00 0.000 0.000 1.000 0.000
#> SRR037169     4  0.0000      0.893 0.00 0.000 0.000 1.000 0.000
#> SRR037170     4  0.0000      0.893 0.00 0.000 0.000 1.000 0.000
#> SRR037171     2  0.0000      0.999 0.00 1.000 0.000 0.000 0.000
#> SRR037172     2  0.0000      0.999 0.00 1.000 0.000 0.000 0.000
#> SRR037173     2  0.0000      0.999 0.00 1.000 0.000 0.000 0.000
#> SRR037174     2  0.0000      0.999 0.00 1.000 0.000 0.000 0.000
#> SRR037175     2  0.0000      0.999 0.00 1.000 0.000 0.000 0.000
#> SRR037176     2  0.0000      0.999 0.00 1.000 0.000 0.000 0.000
#> SRR037177     2  0.0290      0.994 0.00 0.992 0.000 0.000 0.008
#> SRR037182     3  0.1732      0.935 0.00 0.000 0.920 0.000 0.080
#> SRR037183     3  0.1732      0.935 0.00 0.000 0.920 0.000 0.080
#> SRR037184     2  0.0000      0.999 0.00 1.000 0.000 0.000 0.000
#> SRR037185     2  0.0290      0.994 0.00 0.992 0.000 0.000 0.008
#> SRR037186     2  0.0000      0.999 0.00 1.000 0.000 0.000 0.000
#> SRR037187     2  0.0000      0.999 0.00 1.000 0.000 0.000 0.000
#> SRR037188     3  0.1608      0.939 0.00 0.000 0.928 0.000 0.072
#> SRR037178     3  0.0000      0.958 0.00 0.000 1.000 0.000 0.000
#> SRR037179     3  0.0000      0.958 0.00 0.000 1.000 0.000 0.000
#> SRR037180     3  0.0162      0.958 0.00 0.000 0.996 0.000 0.004
#> SRR037181     3  0.0000      0.958 0.00 0.000 1.000 0.000 0.000
#> SRR037189     2  0.0000      0.999 0.00 1.000 0.000 0.000 0.000
#> SRR037190     2  0.0000      0.999 0.00 1.000 0.000 0.000 0.000
#> SRR037191     2  0.0000      0.999 0.00 1.000 0.000 0.000 0.000
#> SRR037192     2  0.0000      0.999 0.00 1.000 0.000 0.000 0.000
#> SRR037193     4  0.3966      0.830 0.00 0.000 0.000 0.664 0.336
#> SRR037194     4  0.3586      0.873 0.00 0.000 0.000 0.736 0.264
#> SRR037195     4  0.3534      0.876 0.00 0.000 0.000 0.744 0.256
#> SRR037196     4  0.3305      0.886 0.00 0.000 0.000 0.776 0.224
#> SRR037197     4  0.3305      0.886 0.00 0.000 0.000 0.776 0.224
#> SRR037198     4  0.3305      0.886 0.00 0.000 0.000 0.776 0.224
#> SRR037199     1  0.0000      1.000 1.00 0.000 0.000 0.000 0.000
#> SRR037200     1  0.0000      1.000 1.00 0.000 0.000 0.000 0.000
#> SRR037201     1  0.0000      1.000 1.00 0.000 0.000 0.000 0.000
#> SRR037202     1  0.0000      1.000 1.00 0.000 0.000 0.000 0.000
#> SRR037203     1  0.0000      1.000 1.00 0.000 0.000 0.000 0.000
#> SRR037204     1  0.0000      1.000 1.00 0.000 0.000 0.000 0.000
#> SRR037205     1  0.0000      1.000 1.00 0.000 0.000 0.000 0.000
#> SRR037206     3  0.2127      0.918 0.00 0.000 0.892 0.000 0.108
#> SRR037207     3  0.2127      0.918 0.00 0.000 0.892 0.000 0.108
#> SRR037208     3  0.0290      0.958 0.00 0.000 0.992 0.000 0.008
#> SRR037209     3  0.0290      0.958 0.00 0.000 0.992 0.000 0.008
#> SRR037210     3  0.2127      0.918 0.00 0.000 0.892 0.000 0.108
#> SRR037211     3  0.2179      0.915 0.00 0.000 0.888 0.000 0.112
#> SRR037212     3  0.1341      0.945 0.00 0.000 0.944 0.000 0.056
#> SRR037213     3  0.1341      0.945 0.00 0.000 0.944 0.000 0.056
#> SRR037219     3  0.1478      0.942 0.00 0.000 0.936 0.000 0.064
#> SRR037214     3  0.0404      0.958 0.00 0.000 0.988 0.000 0.012
#> SRR037215     3  0.0290      0.958 0.00 0.000 0.992 0.000 0.008
#> SRR037216     3  0.2127      0.918 0.00 0.000 0.892 0.000 0.108
#> SRR037217     3  0.0162      0.958 0.00 0.000 0.996 0.000 0.004
#> SRR037218     3  0.0162      0.958 0.00 0.000 0.996 0.000 0.004
#> SRR037220     5  0.4302      1.000 0.48 0.000 0.000 0.000 0.520
#> SRR037221     5  0.4302      1.000 0.48 0.000 0.000 0.000 0.520
#> SRR037222     5  0.4302      1.000 0.48 0.000 0.000 0.000 0.520
#> SRR037223     5  0.4302      1.000 0.48 0.000 0.000 0.000 0.520
#> SRR037224     5  0.4302      1.000 0.48 0.000 0.000 0.000 0.520
#> SRR037225     5  0.4302      1.000 0.48 0.000 0.000 0.000 0.520
#> SRR037226     5  0.4302      1.000 0.48 0.000 0.000 0.000 0.520

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR037165     4  0.3747      1.000 0.000 0.000 0.000 0.604 0.000 0.396
#> SRR037166     4  0.3747      1.000 0.000 0.000 0.000 0.604 0.000 0.396
#> SRR037167     4  0.3747      1.000 0.000 0.000 0.000 0.604 0.000 0.396
#> SRR037168     4  0.3747      1.000 0.000 0.000 0.000 0.604 0.000 0.396
#> SRR037169     4  0.3747      1.000 0.000 0.000 0.000 0.604 0.000 0.396
#> SRR037170     4  0.3747      1.000 0.000 0.000 0.000 0.604 0.000 0.396
#> SRR037171     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR037172     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR037173     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR037174     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR037175     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR037176     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR037177     2  0.0520      0.987 0.000 0.984 0.000 0.008 0.008 0.000
#> SRR037182     3  0.3914      0.794 0.000 0.000 0.768 0.128 0.104 0.000
#> SRR037183     3  0.4256      0.775 0.000 0.000 0.744 0.140 0.112 0.004
#> SRR037184     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR037185     2  0.0405      0.990 0.000 0.988 0.000 0.008 0.004 0.000
#> SRR037186     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR037187     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR037188     3  0.3384      0.824 0.000 0.000 0.812 0.120 0.068 0.000
#> SRR037178     3  0.0146      0.891 0.000 0.000 0.996 0.000 0.004 0.000
#> SRR037179     3  0.0000      0.891 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR037180     3  0.0000      0.891 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR037181     3  0.0146      0.891 0.000 0.000 0.996 0.000 0.004 0.000
#> SRR037189     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR037190     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR037191     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR037192     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR037193     6  0.2562      0.679 0.000 0.000 0.000 0.172 0.000 0.828
#> SRR037194     6  0.0937      0.839 0.000 0.000 0.000 0.040 0.000 0.960
#> SRR037195     6  0.0000      0.862 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR037196     6  0.1075      0.860 0.000 0.000 0.000 0.048 0.000 0.952
#> SRR037197     6  0.1327      0.840 0.000 0.000 0.000 0.064 0.000 0.936
#> SRR037198     6  0.1075      0.860 0.000 0.000 0.000 0.048 0.000 0.952
#> SRR037199     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR037200     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR037201     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR037202     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR037203     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR037204     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR037205     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR037206     3  0.3836      0.785 0.000 0.000 0.772 0.176 0.040 0.012
#> SRR037207     3  0.3869      0.782 0.000 0.000 0.768 0.180 0.040 0.012
#> SRR037208     3  0.0520      0.889 0.000 0.000 0.984 0.008 0.008 0.000
#> SRR037209     3  0.0520      0.889 0.000 0.000 0.984 0.008 0.008 0.000
#> SRR037210     3  0.3671      0.794 0.000 0.000 0.784 0.168 0.040 0.008
#> SRR037211     3  0.4086      0.770 0.000 0.000 0.752 0.188 0.044 0.016
#> SRR037212     3  0.2837      0.847 0.000 0.000 0.856 0.088 0.056 0.000
#> SRR037213     3  0.2837      0.847 0.000 0.000 0.856 0.088 0.056 0.000
#> SRR037219     3  0.3150      0.835 0.000 0.000 0.832 0.104 0.064 0.000
#> SRR037214     3  0.0508      0.892 0.000 0.000 0.984 0.012 0.004 0.000
#> SRR037215     3  0.0405      0.890 0.000 0.000 0.988 0.004 0.008 0.000
#> SRR037216     3  0.3671      0.794 0.000 0.000 0.784 0.168 0.040 0.008
#> SRR037217     3  0.0291      0.891 0.000 0.000 0.992 0.004 0.004 0.000
#> SRR037218     3  0.0520      0.890 0.000 0.000 0.984 0.008 0.008 0.000
#> SRR037220     5  0.2912      1.000 0.216 0.000 0.000 0.000 0.784 0.000
#> SRR037221     5  0.2912      1.000 0.216 0.000 0.000 0.000 0.784 0.000
#> SRR037222     5  0.2912      1.000 0.216 0.000 0.000 0.000 0.784 0.000
#> SRR037223     5  0.2912      1.000 0.216 0.000 0.000 0.000 0.784 0.000
#> SRR037224     5  0.2912      1.000 0.216 0.000 0.000 0.000 0.784 0.000
#> SRR037225     5  0.2912      1.000 0.216 0.000 0.000 0.000 0.784 0.000
#> SRR037226     5  0.2912      1.000 0.216 0.000 0.000 0.000 0.784 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 15332 rows and 62 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'hclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 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-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.414           0.827       0.877         0.4770 0.505   0.505
#> 3 3 0.613           0.844       0.882         0.1808 0.911   0.824
#> 4 4 0.847           0.889       0.886         0.3007 0.833   0.600
#> 5 5 0.836           0.844       0.874         0.0447 0.974   0.896
#> 6 6 0.840           0.890       0.867         0.0615 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] 4

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> SRR037165     2   0.260      0.888 0.044 0.956
#> SRR037166     2   0.260      0.888 0.044 0.956
#> SRR037167     2   0.260      0.888 0.044 0.956
#> SRR037168     1   0.625      0.772 0.844 0.156
#> SRR037169     1   0.625      0.772 0.844 0.156
#> SRR037170     1   0.625      0.772 0.844 0.156
#> SRR037171     2   0.000      0.889 0.000 1.000
#> SRR037172     2   0.000      0.889 0.000 1.000
#> SRR037173     2   0.000      0.889 0.000 1.000
#> SRR037174     2   0.000      0.889 0.000 1.000
#> SRR037175     2   0.000      0.889 0.000 1.000
#> SRR037176     2   0.000      0.889 0.000 1.000
#> SRR037177     2   0.260      0.888 0.044 0.956
#> SRR037182     1   0.886      0.570 0.696 0.304
#> SRR037183     1   0.886      0.570 0.696 0.304
#> SRR037184     2   0.260      0.888 0.044 0.956
#> SRR037185     2   0.260      0.888 0.044 0.956
#> SRR037186     2   0.260      0.888 0.044 0.956
#> SRR037187     2   0.260      0.888 0.044 0.956
#> SRR037188     1   0.886      0.570 0.696 0.304
#> SRR037178     2   0.625      0.861 0.156 0.844
#> SRR037179     2   0.625      0.861 0.156 0.844
#> SRR037180     2   0.625      0.861 0.156 0.844
#> SRR037181     2   0.625      0.861 0.156 0.844
#> SRR037189     2   0.260      0.888 0.044 0.956
#> SRR037190     2   0.000      0.889 0.000 1.000
#> SRR037191     2   0.000      0.889 0.000 1.000
#> SRR037192     2   0.260      0.888 0.044 0.956
#> SRR037193     2   0.260      0.888 0.044 0.956
#> SRR037194     2   0.260      0.888 0.044 0.956
#> SRR037195     2   0.260      0.888 0.044 0.956
#> SRR037196     1   0.876      0.670 0.704 0.296
#> SRR037197     1   0.625      0.772 0.844 0.156
#> SRR037198     1   0.876      0.670 0.704 0.296
#> SRR037199     1   0.204      0.842 0.968 0.032
#> SRR037200     1   0.204      0.842 0.968 0.032
#> SRR037201     1   0.204      0.842 0.968 0.032
#> SRR037202     1   0.000      0.851 1.000 0.000
#> SRR037203     1   0.000      0.851 1.000 0.000
#> SRR037204     1   0.000      0.851 1.000 0.000
#> SRR037205     1   0.000      0.851 1.000 0.000
#> SRR037206     2   0.625      0.861 0.156 0.844
#> SRR037207     2   0.625      0.861 0.156 0.844
#> SRR037208     2   0.625      0.861 0.156 0.844
#> SRR037209     2   0.625      0.861 0.156 0.844
#> SRR037210     2   0.625      0.861 0.156 0.844
#> SRR037211     2   0.625      0.861 0.156 0.844
#> SRR037212     1   0.886      0.570 0.696 0.304
#> SRR037213     1   0.886      0.570 0.696 0.304
#> SRR037219     1   0.886      0.570 0.696 0.304
#> SRR037214     2   0.653      0.849 0.168 0.832
#> SRR037215     2   0.625      0.861 0.156 0.844
#> SRR037216     2   0.625      0.861 0.156 0.844
#> SRR037217     2   0.625      0.861 0.156 0.844
#> SRR037218     2   0.625      0.861 0.156 0.844
#> SRR037220     1   0.000      0.851 1.000 0.000
#> SRR037221     1   0.000      0.851 1.000 0.000
#> SRR037222     1   0.000      0.851 1.000 0.000
#> SRR037223     1   0.000      0.851 1.000 0.000
#> SRR037224     1   0.000      0.851 1.000 0.000
#> SRR037225     1   0.000      0.851 1.000 0.000
#> SRR037226     1   0.000      0.851 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
#> SRR037165     2  0.4555      0.860 0.000 0.800 0.200
#> SRR037166     2  0.4555      0.860 0.000 0.800 0.200
#> SRR037167     2  0.4555      0.860 0.000 0.800 0.200
#> SRR037168     3  0.0000      0.667 0.000 0.000 1.000
#> SRR037169     3  0.0000      0.667 0.000 0.000 1.000
#> SRR037170     3  0.0000      0.667 0.000 0.000 1.000
#> SRR037171     2  0.3941      0.869 0.000 0.844 0.156
#> SRR037172     2  0.3941      0.869 0.000 0.844 0.156
#> SRR037173     2  0.3941      0.869 0.000 0.844 0.156
#> SRR037174     2  0.3941      0.869 0.000 0.844 0.156
#> SRR037175     2  0.3941      0.869 0.000 0.844 0.156
#> SRR037176     2  0.3941      0.869 0.000 0.844 0.156
#> SRR037177     2  0.4555      0.860 0.000 0.800 0.200
#> SRR037182     3  0.7661      0.650 0.044 0.452 0.504
#> SRR037183     3  0.7661      0.650 0.044 0.452 0.504
#> SRR037184     2  0.4555      0.860 0.000 0.800 0.200
#> SRR037185     2  0.4555      0.860 0.000 0.800 0.200
#> SRR037186     2  0.4555      0.860 0.000 0.800 0.200
#> SRR037187     2  0.4555      0.860 0.000 0.800 0.200
#> SRR037188     3  0.7661      0.650 0.044 0.452 0.504
#> SRR037178     2  0.0000      0.836 0.000 1.000 0.000
#> SRR037179     2  0.0000      0.836 0.000 1.000 0.000
#> SRR037180     2  0.0000      0.836 0.000 1.000 0.000
#> SRR037181     2  0.0000      0.836 0.000 1.000 0.000
#> SRR037189     2  0.4555      0.860 0.000 0.800 0.200
#> SRR037190     2  0.3941      0.869 0.000 0.844 0.156
#> SRR037191     2  0.3941      0.869 0.000 0.844 0.156
#> SRR037192     2  0.4555      0.860 0.000 0.800 0.200
#> SRR037193     2  0.4555      0.860 0.000 0.800 0.200
#> SRR037194     2  0.4555      0.860 0.000 0.800 0.200
#> SRR037195     2  0.4555      0.860 0.000 0.800 0.200
#> SRR037196     3  0.3686      0.677 0.000 0.140 0.860
#> SRR037197     3  0.0000      0.667 0.000 0.000 1.000
#> SRR037198     3  0.3686      0.677 0.000 0.140 0.860
#> SRR037199     1  0.1289      0.957 0.968 0.032 0.000
#> SRR037200     1  0.1289      0.957 0.968 0.032 0.000
#> SRR037201     1  0.1289      0.957 0.968 0.032 0.000
#> SRR037202     1  0.0000      0.988 1.000 0.000 0.000
#> SRR037203     1  0.0000      0.988 1.000 0.000 0.000
#> SRR037204     1  0.0000      0.988 1.000 0.000 0.000
#> SRR037205     1  0.0000      0.988 1.000 0.000 0.000
#> SRR037206     2  0.0000      0.836 0.000 1.000 0.000
#> SRR037207     2  0.0000      0.836 0.000 1.000 0.000
#> SRR037208     2  0.0000      0.836 0.000 1.000 0.000
#> SRR037209     2  0.0000      0.836 0.000 1.000 0.000
#> SRR037210     2  0.0000      0.836 0.000 1.000 0.000
#> SRR037211     2  0.0000      0.836 0.000 1.000 0.000
#> SRR037212     3  0.7661      0.650 0.044 0.452 0.504
#> SRR037213     3  0.7661      0.650 0.044 0.452 0.504
#> SRR037219     3  0.7661      0.650 0.044 0.452 0.504
#> SRR037214     2  0.0592      0.822 0.012 0.988 0.000
#> SRR037215     2  0.0000      0.836 0.000 1.000 0.000
#> SRR037216     2  0.0000      0.836 0.000 1.000 0.000
#> SRR037217     2  0.0000      0.836 0.000 1.000 0.000
#> SRR037218     2  0.0000      0.836 0.000 1.000 0.000
#> SRR037220     1  0.0000      0.988 1.000 0.000 0.000
#> SRR037221     1  0.0000      0.988 1.000 0.000 0.000
#> SRR037222     1  0.0000      0.988 1.000 0.000 0.000
#> SRR037223     1  0.0000      0.988 1.000 0.000 0.000
#> SRR037224     1  0.0000      0.988 1.000 0.000 0.000
#> SRR037225     1  0.0000      0.988 1.000 0.000 0.000
#> SRR037226     1  0.0000      0.988 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> SRR037165     2  0.2408      0.952 0.000 0.896 0.000 0.104
#> SRR037166     2  0.2408      0.952 0.000 0.896 0.000 0.104
#> SRR037167     2  0.2408      0.952 0.000 0.896 0.000 0.104
#> SRR037168     4  0.0000      0.659 0.000 0.000 0.000 1.000
#> SRR037169     4  0.0000      0.659 0.000 0.000 0.000 1.000
#> SRR037170     4  0.0000      0.659 0.000 0.000 0.000 1.000
#> SRR037171     2  0.0000      0.925 0.000 1.000 0.000 0.000
#> SRR037172     2  0.0000      0.925 0.000 1.000 0.000 0.000
#> SRR037173     2  0.0000      0.925 0.000 1.000 0.000 0.000
#> SRR037174     2  0.0000      0.925 0.000 1.000 0.000 0.000
#> SRR037175     2  0.0000      0.925 0.000 1.000 0.000 0.000
#> SRR037176     2  0.0000      0.925 0.000 1.000 0.000 0.000
#> SRR037177     2  0.2408      0.952 0.000 0.896 0.000 0.104
#> SRR037182     4  0.6071      0.507 0.044 0.000 0.452 0.504
#> SRR037183     4  0.6071      0.507 0.044 0.000 0.452 0.504
#> SRR037184     2  0.2408      0.952 0.000 0.896 0.000 0.104
#> SRR037185     2  0.2408      0.952 0.000 0.896 0.000 0.104
#> SRR037186     2  0.2408      0.952 0.000 0.896 0.000 0.104
#> SRR037187     2  0.2408      0.952 0.000 0.896 0.000 0.104
#> SRR037188     4  0.6071      0.507 0.044 0.000 0.452 0.504
#> SRR037178     3  0.0000      0.999 0.000 0.000 1.000 0.000
#> SRR037179     3  0.0000      0.999 0.000 0.000 1.000 0.000
#> SRR037180     3  0.0000      0.999 0.000 0.000 1.000 0.000
#> SRR037181     3  0.0000      0.999 0.000 0.000 1.000 0.000
#> SRR037189     2  0.2408      0.952 0.000 0.896 0.000 0.104
#> SRR037190     2  0.0000      0.925 0.000 1.000 0.000 0.000
#> SRR037191     2  0.0000      0.925 0.000 1.000 0.000 0.000
#> SRR037192     2  0.2408      0.952 0.000 0.896 0.000 0.104
#> SRR037193     2  0.2654      0.948 0.000 0.888 0.004 0.108
#> SRR037194     2  0.2654      0.948 0.000 0.888 0.004 0.108
#> SRR037195     2  0.2654      0.948 0.000 0.888 0.004 0.108
#> SRR037196     4  0.3907      0.469 0.000 0.232 0.000 0.768
#> SRR037197     4  0.0000      0.659 0.000 0.000 0.000 1.000
#> SRR037198     4  0.3907      0.469 0.000 0.232 0.000 0.768
#> SRR037199     1  0.1022      0.965 0.968 0.000 0.032 0.000
#> SRR037200     1  0.1022      0.965 0.968 0.000 0.032 0.000
#> SRR037201     1  0.1022      0.965 0.968 0.000 0.032 0.000
#> SRR037202     1  0.0000      0.991 1.000 0.000 0.000 0.000
#> SRR037203     1  0.0000      0.991 1.000 0.000 0.000 0.000
#> SRR037204     1  0.0000      0.991 1.000 0.000 0.000 0.000
#> SRR037205     1  0.0000      0.991 1.000 0.000 0.000 0.000
#> SRR037206     3  0.0000      0.999 0.000 0.000 1.000 0.000
#> SRR037207     3  0.0000      0.999 0.000 0.000 1.000 0.000
#> SRR037208     3  0.0000      0.999 0.000 0.000 1.000 0.000
#> SRR037209     3  0.0000      0.999 0.000 0.000 1.000 0.000
#> SRR037210     3  0.0000      0.999 0.000 0.000 1.000 0.000
#> SRR037211     3  0.0000      0.999 0.000 0.000 1.000 0.000
#> SRR037212     4  0.6071      0.507 0.044 0.000 0.452 0.504
#> SRR037213     4  0.6071      0.507 0.044 0.000 0.452 0.504
#> SRR037219     4  0.6071      0.507 0.044 0.000 0.452 0.504
#> SRR037214     3  0.0469      0.980 0.012 0.000 0.988 0.000
#> SRR037215     3  0.0000      0.999 0.000 0.000 1.000 0.000
#> SRR037216     3  0.0000      0.999 0.000 0.000 1.000 0.000
#> SRR037217     3  0.0000      0.999 0.000 0.000 1.000 0.000
#> SRR037218     3  0.0000      0.999 0.000 0.000 1.000 0.000
#> SRR037220     1  0.0000      0.991 1.000 0.000 0.000 0.000
#> SRR037221     1  0.0000      0.991 1.000 0.000 0.000 0.000
#> SRR037222     1  0.0000      0.991 1.000 0.000 0.000 0.000
#> SRR037223     1  0.0000      0.991 1.000 0.000 0.000 0.000
#> SRR037224     1  0.0000      0.991 1.000 0.000 0.000 0.000
#> SRR037225     1  0.0000      0.991 1.000 0.000 0.000 0.000
#> SRR037226     1  0.0000      0.991 1.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> SRR037165     2  0.0000      0.917 0.000 1.000 0.000 0.000 0.000
#> SRR037166     2  0.0000      0.917 0.000 1.000 0.000 0.000 0.000
#> SRR037167     2  0.0000      0.917 0.000 1.000 0.000 0.000 0.000
#> SRR037168     4  0.1282      0.544 0.004 0.044 0.000 0.952 0.000
#> SRR037169     4  0.1282      0.544 0.004 0.044 0.000 0.952 0.000
#> SRR037170     4  0.1282      0.544 0.004 0.044 0.000 0.952 0.000
#> SRR037171     2  0.3074      0.877 0.196 0.804 0.000 0.000 0.000
#> SRR037172     2  0.3074      0.877 0.196 0.804 0.000 0.000 0.000
#> SRR037173     2  0.3074      0.877 0.196 0.804 0.000 0.000 0.000
#> SRR037174     2  0.3074      0.877 0.196 0.804 0.000 0.000 0.000
#> SRR037175     2  0.3074      0.877 0.196 0.804 0.000 0.000 0.000
#> SRR037176     2  0.3074      0.877 0.196 0.804 0.000 0.000 0.000
#> SRR037177     2  0.0000      0.917 0.000 1.000 0.000 0.000 0.000
#> SRR037182     4  0.5230      0.503 0.044 0.000 0.452 0.504 0.000
#> SRR037183     4  0.5230      0.503 0.044 0.000 0.452 0.504 0.000
#> SRR037184     2  0.0000      0.917 0.000 1.000 0.000 0.000 0.000
#> SRR037185     2  0.0000      0.917 0.000 1.000 0.000 0.000 0.000
#> SRR037186     2  0.0000      0.917 0.000 1.000 0.000 0.000 0.000
#> SRR037187     2  0.0000      0.917 0.000 1.000 0.000 0.000 0.000
#> SRR037188     4  0.5230      0.503 0.044 0.000 0.452 0.504 0.000
#> SRR037178     3  0.0000      0.999 0.000 0.000 1.000 0.000 0.000
#> SRR037179     3  0.0000      0.999 0.000 0.000 1.000 0.000 0.000
#> SRR037180     3  0.0000      0.999 0.000 0.000 1.000 0.000 0.000
#> SRR037181     3  0.0000      0.999 0.000 0.000 1.000 0.000 0.000
#> SRR037189     2  0.0000      0.917 0.000 1.000 0.000 0.000 0.000
#> SRR037190     2  0.3074      0.877 0.196 0.804 0.000 0.000 0.000
#> SRR037191     2  0.3074      0.877 0.196 0.804 0.000 0.000 0.000
#> SRR037192     2  0.0000      0.917 0.000 1.000 0.000 0.000 0.000
#> SRR037193     2  0.1357      0.899 0.000 0.948 0.004 0.048 0.000
#> SRR037194     2  0.1357      0.899 0.000 0.948 0.004 0.048 0.000
#> SRR037195     2  0.1357      0.899 0.000 0.948 0.004 0.048 0.000
#> SRR037196     4  0.3752      0.462 0.000 0.292 0.000 0.708 0.000
#> SRR037197     4  0.0290      0.549 0.000 0.008 0.000 0.992 0.000
#> SRR037198     4  0.3752      0.462 0.000 0.292 0.000 0.708 0.000
#> SRR037199     1  0.4731      0.849 0.640 0.000 0.032 0.000 0.328
#> SRR037200     1  0.4731      0.849 0.640 0.000 0.032 0.000 0.328
#> SRR037201     1  0.4731      0.849 0.640 0.000 0.032 0.000 0.328
#> SRR037202     1  0.3109      0.890 0.800 0.000 0.000 0.000 0.200
#> SRR037203     1  0.3109      0.890 0.800 0.000 0.000 0.000 0.200
#> SRR037204     1  0.3109      0.890 0.800 0.000 0.000 0.000 0.200
#> SRR037205     1  0.3109      0.890 0.800 0.000 0.000 0.000 0.200
#> SRR037206     3  0.0000      0.999 0.000 0.000 1.000 0.000 0.000
#> SRR037207     3  0.0000      0.999 0.000 0.000 1.000 0.000 0.000
#> SRR037208     3  0.0000      0.999 0.000 0.000 1.000 0.000 0.000
#> SRR037209     3  0.0000      0.999 0.000 0.000 1.000 0.000 0.000
#> SRR037210     3  0.0000      0.999 0.000 0.000 1.000 0.000 0.000
#> SRR037211     3  0.0000      0.999 0.000 0.000 1.000 0.000 0.000
#> SRR037212     4  0.5230      0.503 0.044 0.000 0.452 0.504 0.000
#> SRR037213     4  0.5230      0.503 0.044 0.000 0.452 0.504 0.000
#> SRR037219     4  0.5230      0.503 0.044 0.000 0.452 0.504 0.000
#> SRR037214     3  0.0404      0.982 0.012 0.000 0.988 0.000 0.000
#> SRR037215     3  0.0000      0.999 0.000 0.000 1.000 0.000 0.000
#> SRR037216     3  0.0000      0.999 0.000 0.000 1.000 0.000 0.000
#> SRR037217     3  0.0000      0.999 0.000 0.000 1.000 0.000 0.000
#> SRR037218     3  0.0000      0.999 0.000 0.000 1.000 0.000 0.000
#> SRR037220     5  0.0000      0.906 0.000 0.000 0.000 0.000 1.000
#> SRR037221     5  0.0000      0.906 0.000 0.000 0.000 0.000 1.000
#> SRR037222     5  0.0000      0.906 0.000 0.000 0.000 0.000 1.000
#> SRR037223     5  0.2377      0.871 0.128 0.000 0.000 0.000 0.872
#> SRR037224     5  0.2377      0.871 0.128 0.000 0.000 0.000 0.872
#> SRR037225     5  0.0000      0.906 0.000 0.000 0.000 0.000 1.000
#> SRR037226     5  0.2377      0.871 0.128 0.000 0.000 0.000 0.872

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR037165     4   0.000      0.980 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR037166     4   0.000      0.980 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR037167     4   0.000      0.980 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR037168     6   0.220      0.591 0.000 0.056 0.000 0.044 0.000 0.900
#> SRR037169     6   0.220      0.591 0.000 0.056 0.000 0.044 0.000 0.900
#> SRR037170     6   0.220      0.591 0.000 0.056 0.000 0.044 0.000 0.900
#> SRR037171     2   0.353      1.000 0.000 0.672 0.000 0.328 0.000 0.000
#> SRR037172     2   0.353      1.000 0.000 0.672 0.000 0.328 0.000 0.000
#> SRR037173     2   0.353      1.000 0.000 0.672 0.000 0.328 0.000 0.000
#> SRR037174     2   0.353      1.000 0.000 0.672 0.000 0.328 0.000 0.000
#> SRR037175     2   0.353      1.000 0.000 0.672 0.000 0.328 0.000 0.000
#> SRR037176     2   0.353      1.000 0.000 0.672 0.000 0.328 0.000 0.000
#> SRR037177     4   0.000      0.980 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR037182     6   0.633      0.697 0.036 0.272 0.188 0.000 0.000 0.504
#> SRR037183     6   0.633      0.697 0.036 0.272 0.188 0.000 0.000 0.504
#> SRR037184     4   0.000      0.980 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR037185     4   0.000      0.980 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR037186     4   0.000      0.980 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR037187     4   0.000      0.980 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR037188     6   0.633      0.697 0.036 0.272 0.188 0.000 0.000 0.504
#> SRR037178     3   0.000      0.978 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR037179     3   0.000      0.978 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR037180     3   0.000      0.978 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR037181     3   0.000      0.978 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR037189     4   0.000      0.980 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR037190     2   0.353      1.000 0.000 0.672 0.000 0.328 0.000 0.000
#> SRR037191     2   0.353      1.000 0.000 0.672 0.000 0.328 0.000 0.000
#> SRR037192     4   0.000      0.980 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR037193     4   0.122      0.931 0.000 0.000 0.004 0.948 0.000 0.048
#> SRR037194     4   0.122      0.931 0.000 0.000 0.004 0.948 0.000 0.048
#> SRR037195     4   0.122      0.931 0.000 0.000 0.004 0.948 0.000 0.048
#> SRR037196     6   0.337      0.496 0.000 0.000 0.000 0.292 0.000 0.708
#> SRR037197     6   0.026      0.616 0.000 0.000 0.000 0.008 0.000 0.992
#> SRR037198     6   0.337      0.496 0.000 0.000 0.000 0.292 0.000 0.708
#> SRR037199     1   0.290      0.884 0.840 0.000 0.032 0.000 0.128 0.000
#> SRR037200     1   0.290      0.884 0.840 0.000 0.032 0.000 0.128 0.000
#> SRR037201     1   0.290      0.884 0.840 0.000 0.032 0.000 0.128 0.000
#> SRR037202     1   0.000      0.915 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR037203     1   0.000      0.915 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR037204     1   0.000      0.915 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR037205     1   0.000      0.915 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR037206     3   0.000      0.978 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR037207     3   0.000      0.978 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR037208     3   0.000      0.978 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR037209     3   0.000      0.978 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR037210     3   0.000      0.978 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR037211     3   0.000      0.978 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR037212     6   0.633      0.697 0.036 0.272 0.188 0.000 0.000 0.504
#> SRR037213     6   0.633      0.697 0.036 0.272 0.188 0.000 0.000 0.504
#> SRR037219     6   0.633      0.697 0.036 0.272 0.188 0.000 0.000 0.504
#> SRR037214     3   0.338      0.605 0.004 0.268 0.728 0.000 0.000 0.000
#> SRR037215     3   0.000      0.978 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR037216     3   0.000      0.978 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR037217     3   0.000      0.978 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR037218     3   0.000      0.978 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR037220     5   0.000      0.927 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR037221     5   0.000      0.927 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR037222     5   0.000      0.927 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR037223     5   0.214      0.901 0.128 0.000 0.000 0.000 0.872 0.000
#> SRR037224     5   0.214      0.901 0.128 0.000 0.000 0.000 0.872 0.000
#> SRR037225     5   0.000      0.927 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR037226     5   0.214      0.901 0.128 0.000 0.000 0.000 0.872 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-hclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-hclust-collect-classes

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


MAD:kmeans

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

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

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

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

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

collect_plots(res)

plot of chunk MAD-kmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.409           0.617       0.773         0.4470 0.545   0.545
#> 3 3 0.622           0.877       0.887         0.4416 0.696   0.491
#> 4 4 0.779           0.718       0.835         0.1393 0.926   0.785
#> 5 5 0.766           0.804       0.775         0.0688 0.894   0.634
#> 6 6 0.757           0.770       0.789         0.0416 0.989   0.948

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

suggest_best_k(res)
#> [1] 3

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> SRR037165     2  0.0000     0.7625 0.000 1.000
#> SRR037166     2  0.0000     0.7625 0.000 1.000
#> SRR037167     2  0.0000     0.7625 0.000 1.000
#> SRR037168     2  0.9129     0.3205 0.328 0.672
#> SRR037169     2  0.9129     0.3205 0.328 0.672
#> SRR037170     2  0.9129     0.3205 0.328 0.672
#> SRR037171     2  0.0000     0.7625 0.000 1.000
#> SRR037172     2  0.0000     0.7625 0.000 1.000
#> SRR037173     2  0.0000     0.7625 0.000 1.000
#> SRR037174     2  0.0000     0.7625 0.000 1.000
#> SRR037175     2  0.0000     0.7625 0.000 1.000
#> SRR037176     2  0.0000     0.7625 0.000 1.000
#> SRR037177     2  0.0000     0.7625 0.000 1.000
#> SRR037182     1  0.9580     0.3143 0.620 0.380
#> SRR037183     1  0.9522     0.3357 0.628 0.372
#> SRR037184     2  0.0000     0.7625 0.000 1.000
#> SRR037185     2  0.0000     0.7625 0.000 1.000
#> SRR037186     2  0.0000     0.7625 0.000 1.000
#> SRR037187     2  0.0000     0.7625 0.000 1.000
#> SRR037188     1  0.9933     0.0692 0.548 0.452
#> SRR037178     2  0.9286     0.5266 0.344 0.656
#> SRR037179     2  0.9286     0.5266 0.344 0.656
#> SRR037180     2  0.9286     0.5266 0.344 0.656
#> SRR037181     2  0.9286     0.5266 0.344 0.656
#> SRR037189     2  0.0000     0.7625 0.000 1.000
#> SRR037190     2  0.0000     0.7625 0.000 1.000
#> SRR037191     2  0.0000     0.7625 0.000 1.000
#> SRR037192     2  0.0000     0.7625 0.000 1.000
#> SRR037193     2  0.0000     0.7625 0.000 1.000
#> SRR037194     2  0.0000     0.7625 0.000 1.000
#> SRR037195     2  0.0000     0.7625 0.000 1.000
#> SRR037196     2  0.7139     0.5575 0.196 0.804
#> SRR037197     2  0.9129     0.3205 0.328 0.672
#> SRR037198     2  0.7139     0.5575 0.196 0.804
#> SRR037199     1  0.0672     0.7652 0.992 0.008
#> SRR037200     1  0.0672     0.7652 0.992 0.008
#> SRR037201     1  0.0672     0.7652 0.992 0.008
#> SRR037202     1  0.0938     0.7670 0.988 0.012
#> SRR037203     1  0.0938     0.7670 0.988 0.012
#> SRR037204     1  0.0938     0.7670 0.988 0.012
#> SRR037205     1  0.0938     0.7670 0.988 0.012
#> SRR037206     2  0.9286     0.5266 0.344 0.656
#> SRR037207     2  0.9286     0.5266 0.344 0.656
#> SRR037208     2  0.9286     0.5266 0.344 0.656
#> SRR037209     2  0.9286     0.5266 0.344 0.656
#> SRR037210     2  0.9286     0.5266 0.344 0.656
#> SRR037211     2  0.9286     0.5266 0.344 0.656
#> SRR037212     1  0.9522     0.3357 0.628 0.372
#> SRR037213     1  0.9522     0.3357 0.628 0.372
#> SRR037219     1  0.9522     0.3357 0.628 0.372
#> SRR037214     1  0.9944     0.0374 0.544 0.456
#> SRR037215     2  0.9286     0.5266 0.344 0.656
#> SRR037216     2  0.9286     0.5266 0.344 0.656
#> SRR037217     2  0.9286     0.5266 0.344 0.656
#> SRR037218     2  0.9286     0.5266 0.344 0.656
#> SRR037220     1  0.3733     0.7604 0.928 0.072
#> SRR037221     1  0.3733     0.7604 0.928 0.072
#> SRR037222     1  0.3733     0.7604 0.928 0.072
#> SRR037223     1  0.3733     0.7604 0.928 0.072
#> SRR037224     1  0.3733     0.7604 0.928 0.072
#> SRR037225     1  0.3733     0.7604 0.928 0.072
#> SRR037226     1  0.3733     0.7604 0.928 0.072

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> SRR037165     2  0.2689      0.881 0.036 0.932 0.032
#> SRR037166     2  0.2689      0.881 0.036 0.932 0.032
#> SRR037167     2  0.1647      0.871 0.036 0.960 0.004
#> SRR037168     2  0.4164      0.798 0.144 0.848 0.008
#> SRR037169     2  0.4413      0.782 0.160 0.832 0.008
#> SRR037170     2  0.4164      0.798 0.144 0.848 0.008
#> SRR037171     2  0.5526      0.826 0.036 0.792 0.172
#> SRR037172     2  0.5526      0.826 0.036 0.792 0.172
#> SRR037173     2  0.5295      0.837 0.036 0.808 0.156
#> SRR037174     2  0.5295      0.837 0.036 0.808 0.156
#> SRR037175     2  0.5526      0.826 0.036 0.792 0.172
#> SRR037176     2  0.5526      0.826 0.036 0.792 0.172
#> SRR037177     2  0.0237      0.878 0.000 0.996 0.004
#> SRR037182     3  0.7542      0.720 0.120 0.192 0.688
#> SRR037183     3  0.7542      0.720 0.120 0.192 0.688
#> SRR037184     2  0.2689      0.883 0.036 0.932 0.032
#> SRR037185     2  0.0237      0.878 0.000 0.996 0.004
#> SRR037186     2  0.2689      0.883 0.036 0.932 0.032
#> SRR037187     2  0.2689      0.883 0.036 0.932 0.032
#> SRR037188     3  0.7542      0.720 0.120 0.192 0.688
#> SRR037178     3  0.1289      0.895 0.000 0.032 0.968
#> SRR037179     3  0.1289      0.895 0.000 0.032 0.968
#> SRR037180     3  0.1289      0.895 0.000 0.032 0.968
#> SRR037181     3  0.1289      0.895 0.000 0.032 0.968
#> SRR037189     2  0.2689      0.883 0.036 0.932 0.032
#> SRR037190     2  0.5295      0.837 0.036 0.808 0.156
#> SRR037191     2  0.5526      0.826 0.036 0.792 0.172
#> SRR037192     2  0.2689      0.883 0.036 0.932 0.032
#> SRR037193     2  0.5413      0.837 0.036 0.800 0.164
#> SRR037194     2  0.2926      0.880 0.036 0.924 0.040
#> SRR037195     2  0.2926      0.880 0.036 0.924 0.040
#> SRR037196     2  0.3272      0.846 0.080 0.904 0.016
#> SRR037197     2  0.4413      0.782 0.160 0.832 0.008
#> SRR037198     2  0.3272      0.846 0.080 0.904 0.016
#> SRR037199     1  0.2448      0.986 0.924 0.000 0.076
#> SRR037200     1  0.2448      0.986 0.924 0.000 0.076
#> SRR037201     1  0.2448      0.986 0.924 0.000 0.076
#> SRR037202     1  0.2448      0.986 0.924 0.000 0.076
#> SRR037203     1  0.2537      0.985 0.920 0.000 0.080
#> SRR037204     1  0.2448      0.986 0.924 0.000 0.076
#> SRR037205     1  0.2448      0.986 0.924 0.000 0.076
#> SRR037206     3  0.1289      0.895 0.000 0.032 0.968
#> SRR037207     3  0.1289      0.895 0.000 0.032 0.968
#> SRR037208     3  0.1399      0.894 0.004 0.028 0.968
#> SRR037209     3  0.1399      0.894 0.004 0.028 0.968
#> SRR037210     3  0.1289      0.895 0.000 0.032 0.968
#> SRR037211     3  0.1289      0.895 0.000 0.032 0.968
#> SRR037212     3  0.7542      0.720 0.120 0.192 0.688
#> SRR037213     3  0.7542      0.720 0.120 0.192 0.688
#> SRR037219     3  0.7542      0.720 0.120 0.192 0.688
#> SRR037214     3  0.3500      0.844 0.004 0.116 0.880
#> SRR037215     3  0.1399      0.894 0.004 0.028 0.968
#> SRR037216     3  0.1289      0.895 0.000 0.032 0.968
#> SRR037217     3  0.1399      0.894 0.004 0.028 0.968
#> SRR037218     3  0.1399      0.894 0.004 0.028 0.968
#> SRR037220     1  0.3112      0.986 0.900 0.004 0.096
#> SRR037221     1  0.3112      0.986 0.900 0.004 0.096
#> SRR037222     1  0.3112      0.986 0.900 0.004 0.096
#> SRR037223     1  0.3193      0.985 0.896 0.004 0.100
#> SRR037224     1  0.3193      0.985 0.896 0.004 0.100
#> SRR037225     1  0.3112      0.986 0.900 0.004 0.096
#> SRR037226     1  0.3193      0.985 0.896 0.004 0.100

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> SRR037165     2  0.5070     0.0882 0.004 0.580 0.000 0.416
#> SRR037166     2  0.5070     0.0882 0.004 0.580 0.000 0.416
#> SRR037167     4  0.5143     0.2984 0.004 0.456 0.000 0.540
#> SRR037168     4  0.4212     0.9049 0.012 0.216 0.000 0.772
#> SRR037169     4  0.4212     0.9049 0.012 0.216 0.000 0.772
#> SRR037170     4  0.4212     0.9049 0.012 0.216 0.000 0.772
#> SRR037171     2  0.1389     0.7628 0.000 0.952 0.048 0.000
#> SRR037172     2  0.1389     0.7628 0.000 0.952 0.048 0.000
#> SRR037173     2  0.1211     0.7652 0.000 0.960 0.040 0.000
#> SRR037174     2  0.1211     0.7652 0.000 0.960 0.040 0.000
#> SRR037175     2  0.1389     0.7628 0.000 0.952 0.048 0.000
#> SRR037176     2  0.1389     0.7628 0.000 0.952 0.048 0.000
#> SRR037177     2  0.4136     0.5737 0.016 0.788 0.000 0.196
#> SRR037182     3  0.6607     0.4533 0.016 0.048 0.524 0.412
#> SRR037183     3  0.6607     0.4533 0.016 0.048 0.524 0.412
#> SRR037184     2  0.0779     0.7576 0.016 0.980 0.000 0.004
#> SRR037185     2  0.4136     0.5737 0.016 0.788 0.000 0.196
#> SRR037186     2  0.0779     0.7576 0.016 0.980 0.000 0.004
#> SRR037187     2  0.0779     0.7576 0.016 0.980 0.000 0.004
#> SRR037188     3  0.6607     0.4533 0.016 0.048 0.524 0.412
#> SRR037178     3  0.0469     0.8315 0.000 0.012 0.988 0.000
#> SRR037179     3  0.0469     0.8315 0.000 0.012 0.988 0.000
#> SRR037180     3  0.0469     0.8315 0.000 0.012 0.988 0.000
#> SRR037181     3  0.0469     0.8315 0.000 0.012 0.988 0.000
#> SRR037189     2  0.0779     0.7576 0.016 0.980 0.000 0.004
#> SRR037190     2  0.1211     0.7652 0.000 0.960 0.040 0.000
#> SRR037191     2  0.1389     0.7628 0.000 0.952 0.048 0.000
#> SRR037192     2  0.0779     0.7576 0.016 0.980 0.000 0.004
#> SRR037193     2  0.6077    -0.1107 0.000 0.496 0.044 0.460
#> SRR037194     2  0.5409    -0.2912 0.000 0.496 0.012 0.492
#> SRR037195     2  0.5409    -0.2912 0.000 0.496 0.012 0.492
#> SRR037196     4  0.4284     0.8956 0.000 0.224 0.012 0.764
#> SRR037197     4  0.4086     0.8985 0.008 0.216 0.000 0.776
#> SRR037198     4  0.4284     0.8956 0.000 0.224 0.012 0.764
#> SRR037199     1  0.3876     0.9298 0.836 0.000 0.040 0.124
#> SRR037200     1  0.3876     0.9298 0.836 0.000 0.040 0.124
#> SRR037201     1  0.3876     0.9298 0.836 0.000 0.040 0.124
#> SRR037202     1  0.3659     0.9313 0.840 0.000 0.024 0.136
#> SRR037203     1  0.3659     0.9313 0.840 0.000 0.024 0.136
#> SRR037204     1  0.3711     0.9311 0.836 0.000 0.024 0.140
#> SRR037205     1  0.3659     0.9313 0.840 0.000 0.024 0.136
#> SRR037206     3  0.2246     0.8289 0.004 0.016 0.928 0.052
#> SRR037207     3  0.2246     0.8289 0.004 0.016 0.928 0.052
#> SRR037208     3  0.2207     0.8303 0.004 0.012 0.928 0.056
#> SRR037209     3  0.2207     0.8303 0.004 0.012 0.928 0.056
#> SRR037210     3  0.2246     0.8289 0.004 0.016 0.928 0.052
#> SRR037211     3  0.2246     0.8289 0.004 0.016 0.928 0.052
#> SRR037212     3  0.6519     0.4963 0.020 0.040 0.548 0.392
#> SRR037213     3  0.6519     0.4963 0.020 0.040 0.548 0.392
#> SRR037219     3  0.6568     0.4596 0.020 0.040 0.524 0.416
#> SRR037214     3  0.2123     0.8142 0.004 0.032 0.936 0.028
#> SRR037215     3  0.2207     0.8303 0.004 0.012 0.928 0.056
#> SRR037216     3  0.2246     0.8289 0.004 0.016 0.928 0.052
#> SRR037217     3  0.1114     0.8301 0.004 0.016 0.972 0.008
#> SRR037218     3  0.1114     0.8301 0.004 0.016 0.972 0.008
#> SRR037220     1  0.1624     0.9306 0.952 0.000 0.020 0.028
#> SRR037221     1  0.1624     0.9306 0.952 0.000 0.020 0.028
#> SRR037222     1  0.1624     0.9306 0.952 0.000 0.020 0.028
#> SRR037223     1  0.1520     0.9322 0.956 0.000 0.020 0.024
#> SRR037224     1  0.1520     0.9322 0.956 0.000 0.020 0.024
#> SRR037225     1  0.1297     0.9319 0.964 0.000 0.020 0.016
#> SRR037226     1  0.1520     0.9322 0.956 0.000 0.020 0.024

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> SRR037165     4  0.3944     0.6679 0.004 0.272 0.000 0.720 0.004
#> SRR037166     4  0.3944     0.6679 0.004 0.272 0.000 0.720 0.004
#> SRR037167     4  0.3129     0.7621 0.004 0.156 0.000 0.832 0.008
#> SRR037168     4  0.3944     0.7150 0.000 0.052 0.000 0.788 0.160
#> SRR037169     4  0.3944     0.7150 0.000 0.052 0.000 0.788 0.160
#> SRR037170     4  0.3944     0.7150 0.000 0.052 0.000 0.788 0.160
#> SRR037171     2  0.0510     0.8904 0.000 0.984 0.016 0.000 0.000
#> SRR037172     2  0.0510     0.8904 0.000 0.984 0.016 0.000 0.000
#> SRR037173     2  0.0510     0.8904 0.000 0.984 0.016 0.000 0.000
#> SRR037174     2  0.0510     0.8904 0.000 0.984 0.016 0.000 0.000
#> SRR037175     2  0.0510     0.8904 0.000 0.984 0.016 0.000 0.000
#> SRR037176     2  0.0510     0.8904 0.000 0.984 0.016 0.000 0.000
#> SRR037177     2  0.5196     0.5045 0.004 0.632 0.000 0.308 0.056
#> SRR037182     5  0.6930     1.0000 0.024 0.008 0.316 0.144 0.508
#> SRR037183     5  0.6930     1.0000 0.024 0.008 0.316 0.144 0.508
#> SRR037184     2  0.2949     0.8651 0.004 0.876 0.000 0.068 0.052
#> SRR037185     2  0.5196     0.5045 0.004 0.632 0.000 0.308 0.056
#> SRR037186     2  0.2949     0.8651 0.004 0.876 0.000 0.068 0.052
#> SRR037187     2  0.2949     0.8651 0.004 0.876 0.000 0.068 0.052
#> SRR037188     5  0.6930     1.0000 0.024 0.008 0.316 0.144 0.508
#> SRR037178     3  0.3551     0.6950 0.000 0.000 0.772 0.008 0.220
#> SRR037179     3  0.3551     0.6950 0.000 0.000 0.772 0.008 0.220
#> SRR037180     3  0.3551     0.6950 0.000 0.000 0.772 0.008 0.220
#> SRR037181     3  0.3551     0.6950 0.000 0.000 0.772 0.008 0.220
#> SRR037189     2  0.2949     0.8651 0.004 0.876 0.000 0.068 0.052
#> SRR037190     2  0.0510     0.8904 0.000 0.984 0.016 0.000 0.000
#> SRR037191     2  0.0510     0.8904 0.000 0.984 0.016 0.000 0.000
#> SRR037192     2  0.2949     0.8651 0.004 0.876 0.000 0.068 0.052
#> SRR037193     4  0.5644     0.7324 0.000 0.208 0.012 0.660 0.120
#> SRR037194     4  0.5240     0.7443 0.000 0.204 0.000 0.676 0.120
#> SRR037195     4  0.5240     0.7443 0.000 0.204 0.000 0.676 0.120
#> SRR037196     4  0.3289     0.7710 0.000 0.048 0.000 0.844 0.108
#> SRR037197     4  0.4563     0.7047 0.000 0.048 0.000 0.708 0.244
#> SRR037198     4  0.3289     0.7710 0.000 0.048 0.000 0.844 0.108
#> SRR037199     1  0.2389     0.8657 0.916 0.008 0.008 0.024 0.044
#> SRR037200     1  0.2389     0.8657 0.916 0.008 0.008 0.024 0.044
#> SRR037201     1  0.2389     0.8657 0.916 0.008 0.008 0.024 0.044
#> SRR037202     1  0.0290     0.8657 0.992 0.000 0.008 0.000 0.000
#> SRR037203     1  0.0290     0.8657 0.992 0.000 0.008 0.000 0.000
#> SRR037204     1  0.0290     0.8657 0.992 0.000 0.008 0.000 0.000
#> SRR037205     1  0.0290     0.8657 0.992 0.000 0.008 0.000 0.000
#> SRR037206     3  0.0609     0.7839 0.000 0.000 0.980 0.000 0.020
#> SRR037207     3  0.0609     0.7839 0.000 0.000 0.980 0.000 0.020
#> SRR037208     3  0.0000     0.7867 0.000 0.000 1.000 0.000 0.000
#> SRR037209     3  0.0000     0.7867 0.000 0.000 1.000 0.000 0.000
#> SRR037210     3  0.0609     0.7839 0.000 0.000 0.980 0.000 0.020
#> SRR037211     3  0.0609     0.7839 0.000 0.000 0.980 0.000 0.020
#> SRR037212     5  0.6930     1.0000 0.024 0.008 0.316 0.144 0.508
#> SRR037213     5  0.6930     1.0000 0.024 0.008 0.316 0.144 0.508
#> SRR037219     5  0.6930     1.0000 0.024 0.008 0.316 0.144 0.508
#> SRR037214     3  0.4585     0.0851 0.000 0.008 0.592 0.004 0.396
#> SRR037215     3  0.0162     0.7860 0.000 0.000 0.996 0.004 0.000
#> SRR037216     3  0.0609     0.7839 0.000 0.000 0.980 0.000 0.020
#> SRR037217     3  0.3628     0.6912 0.000 0.000 0.772 0.012 0.216
#> SRR037218     3  0.3628     0.6912 0.000 0.000 0.772 0.012 0.216
#> SRR037220     1  0.4762     0.8677 0.684 0.004 0.008 0.024 0.280
#> SRR037221     1  0.4762     0.8677 0.684 0.004 0.008 0.024 0.280
#> SRR037222     1  0.4762     0.8677 0.684 0.004 0.008 0.024 0.280
#> SRR037223     1  0.4110     0.8680 0.736 0.000 0.008 0.012 0.244
#> SRR037224     1  0.4110     0.8680 0.736 0.000 0.008 0.012 0.244
#> SRR037225     1  0.4762     0.8677 0.684 0.004 0.008 0.024 0.280
#> SRR037226     1  0.4110     0.8680 0.736 0.000 0.008 0.012 0.244

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4 p5    p6
#> SRR037165     4  0.5466      0.654 0.000 0.192 0.000 0.604 NA 0.008
#> SRR037166     4  0.5466      0.654 0.000 0.192 0.000 0.604 NA 0.008
#> SRR037167     4  0.4067      0.729 0.000 0.072 0.000 0.752 NA 0.004
#> SRR037168     4  0.1563      0.660 0.000 0.012 0.000 0.932 NA 0.056
#> SRR037169     4  0.1563      0.660 0.000 0.012 0.000 0.932 NA 0.056
#> SRR037170     4  0.1563      0.660 0.000 0.012 0.000 0.932 NA 0.056
#> SRR037171     2  0.0363      0.833 0.000 0.988 0.012 0.000 NA 0.000
#> SRR037172     2  0.0363      0.833 0.000 0.988 0.012 0.000 NA 0.000
#> SRR037173     2  0.0260      0.834 0.000 0.992 0.008 0.000 NA 0.000
#> SRR037174     2  0.0260      0.834 0.000 0.992 0.008 0.000 NA 0.000
#> SRR037175     2  0.0363      0.833 0.000 0.988 0.012 0.000 NA 0.000
#> SRR037176     2  0.0622      0.833 0.000 0.980 0.012 0.000 NA 0.008
#> SRR037177     2  0.6476      0.578 0.000 0.548 0.000 0.192 NA 0.084
#> SRR037182     6  0.3877      0.954 0.000 0.000 0.160 0.076 NA 0.764
#> SRR037183     6  0.3877      0.954 0.000 0.000 0.160 0.076 NA 0.764
#> SRR037184     2  0.4734      0.789 0.000 0.728 0.000 0.040 NA 0.080
#> SRR037185     2  0.6476      0.578 0.000 0.548 0.000 0.192 NA 0.084
#> SRR037186     2  0.4734      0.789 0.000 0.728 0.000 0.040 NA 0.080
#> SRR037187     2  0.4734      0.789 0.000 0.728 0.000 0.040 NA 0.080
#> SRR037188     6  0.3877      0.954 0.000 0.000 0.160 0.076 NA 0.764
#> SRR037178     3  0.4300      0.680 0.000 0.000 0.712 0.000 NA 0.208
#> SRR037179     3  0.4300      0.680 0.000 0.000 0.712 0.000 NA 0.208
#> SRR037180     3  0.4300      0.680 0.000 0.000 0.712 0.000 NA 0.208
#> SRR037181     3  0.4300      0.680 0.000 0.000 0.712 0.000 NA 0.208
#> SRR037189     2  0.4734      0.789 0.000 0.728 0.000 0.040 NA 0.080
#> SRR037190     2  0.0260      0.834 0.000 0.992 0.008 0.000 NA 0.000
#> SRR037191     2  0.0363      0.833 0.000 0.988 0.012 0.000 NA 0.000
#> SRR037192     2  0.4734      0.789 0.000 0.728 0.000 0.040 NA 0.080
#> SRR037193     4  0.7026      0.686 0.000 0.140 0.016 0.392 NA 0.068
#> SRR037194     4  0.6990      0.688 0.000 0.140 0.012 0.392 NA 0.072
#> SRR037195     4  0.6990      0.688 0.000 0.140 0.012 0.392 NA 0.072
#> SRR037196     4  0.5197      0.726 0.000 0.016 0.000 0.600 NA 0.076
#> SRR037197     4  0.4307      0.649 0.000 0.012 0.000 0.752 NA 0.116
#> SRR037198     4  0.5197      0.726 0.000 0.016 0.000 0.600 NA 0.076
#> SRR037199     1  0.2595      0.793 0.888 0.004 0.000 0.008 NA 0.044
#> SRR037200     1  0.2595      0.793 0.888 0.004 0.000 0.008 NA 0.044
#> SRR037201     1  0.2595      0.793 0.888 0.004 0.000 0.008 NA 0.044
#> SRR037202     1  0.0458      0.794 0.984 0.000 0.000 0.000 NA 0.016
#> SRR037203     1  0.0458      0.794 0.984 0.000 0.000 0.000 NA 0.016
#> SRR037204     1  0.0458      0.794 0.984 0.000 0.000 0.000 NA 0.016
#> SRR037205     1  0.0458      0.794 0.984 0.000 0.000 0.000 NA 0.016
#> SRR037206     3  0.2149      0.771 0.000 0.000 0.900 0.004 NA 0.016
#> SRR037207     3  0.2149      0.771 0.000 0.000 0.900 0.004 NA 0.016
#> SRR037208     3  0.0000      0.785 0.000 0.000 1.000 0.000 NA 0.000
#> SRR037209     3  0.0000      0.785 0.000 0.000 1.000 0.000 NA 0.000
#> SRR037210     3  0.2149      0.771 0.000 0.000 0.900 0.004 NA 0.016
#> SRR037211     3  0.2149      0.771 0.000 0.000 0.900 0.004 NA 0.016
#> SRR037212     6  0.3860      0.952 0.000 0.000 0.164 0.072 NA 0.764
#> SRR037213     6  0.3860      0.952 0.000 0.000 0.164 0.072 NA 0.764
#> SRR037219     6  0.3877      0.954 0.000 0.000 0.160 0.076 NA 0.764
#> SRR037214     6  0.3482      0.672 0.000 0.000 0.316 0.000 NA 0.684
#> SRR037215     3  0.0000      0.785 0.000 0.000 1.000 0.000 NA 0.000
#> SRR037216     3  0.2149      0.771 0.000 0.000 0.900 0.004 NA 0.016
#> SRR037217     3  0.3885      0.680 0.000 0.000 0.736 0.000 NA 0.220
#> SRR037218     3  0.3885      0.680 0.000 0.000 0.736 0.000 NA 0.220
#> SRR037220     1  0.4018      0.791 0.580 0.000 0.000 0.000 NA 0.008
#> SRR037221     1  0.4018      0.791 0.580 0.000 0.000 0.000 NA 0.008
#> SRR037222     1  0.4018      0.791 0.580 0.000 0.000 0.000 NA 0.008
#> SRR037223     1  0.4476      0.790 0.640 0.000 0.000 0.000 NA 0.052
#> SRR037224     1  0.4476      0.790 0.640 0.000 0.000 0.000 NA 0.052
#> SRR037225     1  0.4018      0.791 0.580 0.000 0.000 0.000 NA 0.008
#> SRR037226     1  0.4476      0.790 0.640 0.000 0.000 0.000 NA 0.052

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

consensus_heatmap(res, k = 2)

plot of chunk tab-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 15332 rows and 62 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'skmeans' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 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           0.970       0.979         0.5002 0.500   0.500
#> 3 3 1.000           0.999       0.999         0.3106 0.845   0.689
#> 4 4 0.867           0.846       0.914         0.1448 0.867   0.634
#> 5 5 1.000           0.995       0.992         0.0680 0.904   0.646
#> 6 6 0.954           0.937       0.943         0.0305 0.981   0.904

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> SRR037165     2   0.000      0.984 0.000 1.000
#> SRR037166     2   0.000      0.984 0.000 1.000
#> SRR037167     2   0.000      0.984 0.000 1.000
#> SRR037168     2   0.343      0.944 0.064 0.936
#> SRR037169     2   0.343      0.944 0.064 0.936
#> SRR037170     2   0.343      0.944 0.064 0.936
#> SRR037171     2   0.000      0.984 0.000 1.000
#> SRR037172     2   0.000      0.984 0.000 1.000
#> SRR037173     2   0.000      0.984 0.000 1.000
#> SRR037174     2   0.000      0.984 0.000 1.000
#> SRR037175     2   0.000      0.984 0.000 1.000
#> SRR037176     2   0.000      0.984 0.000 1.000
#> SRR037177     2   0.000      0.984 0.000 1.000
#> SRR037182     1   0.000      0.972 1.000 0.000
#> SRR037183     1   0.000      0.972 1.000 0.000
#> SRR037184     2   0.000      0.984 0.000 1.000
#> SRR037185     2   0.000      0.984 0.000 1.000
#> SRR037186     2   0.000      0.984 0.000 1.000
#> SRR037187     2   0.000      0.984 0.000 1.000
#> SRR037188     1   0.000      0.972 1.000 0.000
#> SRR037178     1   0.343      0.958 0.936 0.064
#> SRR037179     1   0.343      0.958 0.936 0.064
#> SRR037180     1   0.343      0.958 0.936 0.064
#> SRR037181     1   0.343      0.958 0.936 0.064
#> SRR037189     2   0.000      0.984 0.000 1.000
#> SRR037190     2   0.000      0.984 0.000 1.000
#> SRR037191     2   0.000      0.984 0.000 1.000
#> SRR037192     2   0.000      0.984 0.000 1.000
#> SRR037193     2   0.000      0.984 0.000 1.000
#> SRR037194     2   0.000      0.984 0.000 1.000
#> SRR037195     2   0.000      0.984 0.000 1.000
#> SRR037196     2   0.343      0.944 0.064 0.936
#> SRR037197     2   0.343      0.944 0.064 0.936
#> SRR037198     2   0.343      0.944 0.064 0.936
#> SRR037199     1   0.000      0.972 1.000 0.000
#> SRR037200     1   0.000      0.972 1.000 0.000
#> SRR037201     1   0.000      0.972 1.000 0.000
#> SRR037202     1   0.000      0.972 1.000 0.000
#> SRR037203     1   0.000      0.972 1.000 0.000
#> SRR037204     1   0.000      0.972 1.000 0.000
#> SRR037205     1   0.000      0.972 1.000 0.000
#> SRR037206     1   0.343      0.958 0.936 0.064
#> SRR037207     1   0.343      0.958 0.936 0.064
#> SRR037208     1   0.343      0.958 0.936 0.064
#> SRR037209     1   0.343      0.958 0.936 0.064
#> SRR037210     1   0.343      0.958 0.936 0.064
#> SRR037211     1   0.343      0.958 0.936 0.064
#> SRR037212     1   0.000      0.972 1.000 0.000
#> SRR037213     1   0.000      0.972 1.000 0.000
#> SRR037219     1   0.000      0.972 1.000 0.000
#> SRR037214     1   0.000      0.972 1.000 0.000
#> SRR037215     1   0.343      0.958 0.936 0.064
#> SRR037216     1   0.343      0.958 0.936 0.064
#> SRR037217     1   0.343      0.958 0.936 0.064
#> SRR037218     1   0.343      0.958 0.936 0.064
#> SRR037220     1   0.000      0.972 1.000 0.000
#> SRR037221     1   0.000      0.972 1.000 0.000
#> SRR037222     1   0.000      0.972 1.000 0.000
#> SRR037223     1   0.000      0.972 1.000 0.000
#> SRR037224     1   0.000      0.972 1.000 0.000
#> SRR037225     1   0.000      0.972 1.000 0.000
#> SRR037226     1   0.000      0.972 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
#> SRR037165     2  0.0000      0.999 0.000 1.000 0.000
#> SRR037166     2  0.0000      0.999 0.000 1.000 0.000
#> SRR037167     2  0.0000      0.999 0.000 1.000 0.000
#> SRR037168     2  0.0237      0.996 0.004 0.996 0.000
#> SRR037169     2  0.0237      0.996 0.004 0.996 0.000
#> SRR037170     2  0.0237      0.996 0.004 0.996 0.000
#> SRR037171     2  0.0000      0.999 0.000 1.000 0.000
#> SRR037172     2  0.0000      0.999 0.000 1.000 0.000
#> SRR037173     2  0.0000      0.999 0.000 1.000 0.000
#> SRR037174     2  0.0000      0.999 0.000 1.000 0.000
#> SRR037175     2  0.0000      0.999 0.000 1.000 0.000
#> SRR037176     2  0.0000      0.999 0.000 1.000 0.000
#> SRR037177     2  0.0000      0.999 0.000 1.000 0.000
#> SRR037182     3  0.0237      0.997 0.004 0.000 0.996
#> SRR037183     3  0.0237      0.997 0.004 0.000 0.996
#> SRR037184     2  0.0000      0.999 0.000 1.000 0.000
#> SRR037185     2  0.0000      0.999 0.000 1.000 0.000
#> SRR037186     2  0.0000      0.999 0.000 1.000 0.000
#> SRR037187     2  0.0000      0.999 0.000 1.000 0.000
#> SRR037188     3  0.0237      0.997 0.004 0.000 0.996
#> SRR037178     3  0.0000      0.999 0.000 0.000 1.000
#> SRR037179     3  0.0000      0.999 0.000 0.000 1.000
#> SRR037180     3  0.0000      0.999 0.000 0.000 1.000
#> SRR037181     3  0.0000      0.999 0.000 0.000 1.000
#> SRR037189     2  0.0000      0.999 0.000 1.000 0.000
#> SRR037190     2  0.0000      0.999 0.000 1.000 0.000
#> SRR037191     2  0.0000      0.999 0.000 1.000 0.000
#> SRR037192     2  0.0000      0.999 0.000 1.000 0.000
#> SRR037193     2  0.0000      0.999 0.000 1.000 0.000
#> SRR037194     2  0.0000      0.999 0.000 1.000 0.000
#> SRR037195     2  0.0000      0.999 0.000 1.000 0.000
#> SRR037196     2  0.0000      0.999 0.000 1.000 0.000
#> SRR037197     2  0.0424      0.993 0.008 0.992 0.000
#> SRR037198     2  0.0000      0.999 0.000 1.000 0.000
#> SRR037199     1  0.0000      1.000 1.000 0.000 0.000
#> SRR037200     1  0.0000      1.000 1.000 0.000 0.000
#> SRR037201     1  0.0000      1.000 1.000 0.000 0.000
#> SRR037202     1  0.0000      1.000 1.000 0.000 0.000
#> SRR037203     1  0.0000      1.000 1.000 0.000 0.000
#> SRR037204     1  0.0000      1.000 1.000 0.000 0.000
#> SRR037205     1  0.0000      1.000 1.000 0.000 0.000
#> SRR037206     3  0.0000      0.999 0.000 0.000 1.000
#> SRR037207     3  0.0000      0.999 0.000 0.000 1.000
#> SRR037208     3  0.0000      0.999 0.000 0.000 1.000
#> SRR037209     3  0.0000      0.999 0.000 0.000 1.000
#> SRR037210     3  0.0000      0.999 0.000 0.000 1.000
#> SRR037211     3  0.0000      0.999 0.000 0.000 1.000
#> SRR037212     3  0.0237      0.997 0.004 0.000 0.996
#> SRR037213     3  0.0237      0.997 0.004 0.000 0.996
#> SRR037219     3  0.0237      0.997 0.004 0.000 0.996
#> SRR037214     3  0.0000      0.999 0.000 0.000 1.000
#> SRR037215     3  0.0000      0.999 0.000 0.000 1.000
#> SRR037216     3  0.0000      0.999 0.000 0.000 1.000
#> SRR037217     3  0.0000      0.999 0.000 0.000 1.000
#> SRR037218     3  0.0000      0.999 0.000 0.000 1.000
#> SRR037220     1  0.0000      1.000 1.000 0.000 0.000
#> SRR037221     1  0.0000      1.000 1.000 0.000 0.000
#> SRR037222     1  0.0000      1.000 1.000 0.000 0.000
#> SRR037223     1  0.0000      1.000 1.000 0.000 0.000
#> SRR037224     1  0.0000      1.000 1.000 0.000 0.000
#> SRR037225     1  0.0000      1.000 1.000 0.000 0.000
#> SRR037226     1  0.0000      1.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette p1    p2    p3    p4
#> SRR037165     2  0.4948      0.551  0 0.560 0.000 0.440
#> SRR037166     2  0.4948      0.551  0 0.560 0.000 0.440
#> SRR037167     2  0.4948      0.551  0 0.560 0.000 0.440
#> SRR037168     4  0.0188      0.679  0 0.004 0.000 0.996
#> SRR037169     4  0.0188      0.679  0 0.004 0.000 0.996
#> SRR037170     4  0.0188      0.679  0 0.004 0.000 0.996
#> SRR037171     2  0.0000      0.863  0 1.000 0.000 0.000
#> SRR037172     2  0.0000      0.863  0 1.000 0.000 0.000
#> SRR037173     2  0.0000      0.863  0 1.000 0.000 0.000
#> SRR037174     2  0.0000      0.863  0 1.000 0.000 0.000
#> SRR037175     2  0.0000      0.863  0 1.000 0.000 0.000
#> SRR037176     2  0.0000      0.863  0 1.000 0.000 0.000
#> SRR037177     2  0.0000      0.863  0 1.000 0.000 0.000
#> SRR037182     4  0.4948      0.523  0 0.000 0.440 0.560
#> SRR037183     4  0.4948      0.523  0 0.000 0.440 0.560
#> SRR037184     2  0.0000      0.863  0 1.000 0.000 0.000
#> SRR037185     2  0.0000      0.863  0 1.000 0.000 0.000
#> SRR037186     2  0.0000      0.863  0 1.000 0.000 0.000
#> SRR037187     2  0.0000      0.863  0 1.000 0.000 0.000
#> SRR037188     4  0.4948      0.523  0 0.000 0.440 0.560
#> SRR037178     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR037179     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR037180     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR037181     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR037189     2  0.0000      0.863  0 1.000 0.000 0.000
#> SRR037190     2  0.0000      0.863  0 1.000 0.000 0.000
#> SRR037191     2  0.0000      0.863  0 1.000 0.000 0.000
#> SRR037192     2  0.0000      0.863  0 1.000 0.000 0.000
#> SRR037193     2  0.4948      0.551  0 0.560 0.000 0.440
#> SRR037194     2  0.4948      0.551  0 0.560 0.000 0.440
#> SRR037195     2  0.4948      0.551  0 0.560 0.000 0.440
#> SRR037196     4  0.0188      0.679  0 0.004 0.000 0.996
#> SRR037197     4  0.0188      0.679  0 0.004 0.000 0.996
#> SRR037198     4  0.0188      0.679  0 0.004 0.000 0.996
#> SRR037199     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR037200     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR037201     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR037202     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR037203     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR037204     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR037205     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR037206     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR037207     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR037208     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR037209     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR037210     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR037211     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR037212     4  0.4948      0.523  0 0.000 0.440 0.560
#> SRR037213     4  0.4948      0.523  0 0.000 0.440 0.560
#> SRR037219     4  0.4948      0.523  0 0.000 0.440 0.560
#> SRR037214     3  0.0188      0.995  0 0.000 0.996 0.004
#> SRR037215     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR037216     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR037217     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR037218     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR037220     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR037221     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR037222     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR037223     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR037224     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR037225     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR037226     1  0.0000      1.000  1 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette p1 p2    p3    p4    p5
#> SRR037165     4  0.0794      0.981  0  0 0.000 0.972 0.028
#> SRR037166     4  0.0794      0.981  0  0 0.000 0.972 0.028
#> SRR037167     4  0.0794      0.981  0  0 0.000 0.972 0.028
#> SRR037168     4  0.1270      0.974  0  0 0.000 0.948 0.052
#> SRR037169     4  0.1270      0.974  0  0 0.000 0.948 0.052
#> SRR037170     4  0.1270      0.974  0  0 0.000 0.948 0.052
#> SRR037171     2  0.0000      1.000  0  1 0.000 0.000 0.000
#> SRR037172     2  0.0000      1.000  0  1 0.000 0.000 0.000
#> SRR037173     2  0.0000      1.000  0  1 0.000 0.000 0.000
#> SRR037174     2  0.0000      1.000  0  1 0.000 0.000 0.000
#> SRR037175     2  0.0000      1.000  0  1 0.000 0.000 0.000
#> SRR037176     2  0.0000      1.000  0  1 0.000 0.000 0.000
#> SRR037177     2  0.0000      1.000  0  1 0.000 0.000 0.000
#> SRR037182     5  0.0794      0.995  0  0 0.028 0.000 0.972
#> SRR037183     5  0.0794      0.995  0  0 0.028 0.000 0.972
#> SRR037184     2  0.0000      1.000  0  1 0.000 0.000 0.000
#> SRR037185     2  0.0000      1.000  0  1 0.000 0.000 0.000
#> SRR037186     2  0.0000      1.000  0  1 0.000 0.000 0.000
#> SRR037187     2  0.0000      1.000  0  1 0.000 0.000 0.000
#> SRR037188     5  0.0794      0.995  0  0 0.028 0.000 0.972
#> SRR037178     3  0.0000      1.000  0  0 1.000 0.000 0.000
#> SRR037179     3  0.0000      1.000  0  0 1.000 0.000 0.000
#> SRR037180     3  0.0000      1.000  0  0 1.000 0.000 0.000
#> SRR037181     3  0.0000      1.000  0  0 1.000 0.000 0.000
#> SRR037189     2  0.0000      1.000  0  1 0.000 0.000 0.000
#> SRR037190     2  0.0000      1.000  0  1 0.000 0.000 0.000
#> SRR037191     2  0.0000      1.000  0  1 0.000 0.000 0.000
#> SRR037192     2  0.0000      1.000  0  1 0.000 0.000 0.000
#> SRR037193     4  0.0000      0.982  0  0 0.000 1.000 0.000
#> SRR037194     4  0.0000      0.982  0  0 0.000 1.000 0.000
#> SRR037195     4  0.0000      0.982  0  0 0.000 1.000 0.000
#> SRR037196     4  0.0000      0.982  0  0 0.000 1.000 0.000
#> SRR037197     4  0.0703      0.975  0  0 0.000 0.976 0.024
#> SRR037198     4  0.0000      0.982  0  0 0.000 1.000 0.000
#> SRR037199     1  0.0000      1.000  1  0 0.000 0.000 0.000
#> SRR037200     1  0.0000      1.000  1  0 0.000 0.000 0.000
#> SRR037201     1  0.0000      1.000  1  0 0.000 0.000 0.000
#> SRR037202     1  0.0000      1.000  1  0 0.000 0.000 0.000
#> SRR037203     1  0.0000      1.000  1  0 0.000 0.000 0.000
#> SRR037204     1  0.0000      1.000  1  0 0.000 0.000 0.000
#> SRR037205     1  0.0000      1.000  1  0 0.000 0.000 0.000
#> SRR037206     3  0.0000      1.000  0  0 1.000 0.000 0.000
#> SRR037207     3  0.0000      1.000  0  0 1.000 0.000 0.000
#> SRR037208     3  0.0000      1.000  0  0 1.000 0.000 0.000
#> SRR037209     3  0.0000      1.000  0  0 1.000 0.000 0.000
#> SRR037210     3  0.0000      1.000  0  0 1.000 0.000 0.000
#> SRR037211     3  0.0000      1.000  0  0 1.000 0.000 0.000
#> SRR037212     5  0.0794      0.995  0  0 0.028 0.000 0.972
#> SRR037213     5  0.0794      0.995  0  0 0.028 0.000 0.972
#> SRR037219     5  0.0794      0.995  0  0 0.028 0.000 0.972
#> SRR037214     5  0.1270      0.972  0  0 0.052 0.000 0.948
#> SRR037215     3  0.0000      1.000  0  0 1.000 0.000 0.000
#> SRR037216     3  0.0000      1.000  0  0 1.000 0.000 0.000
#> SRR037217     3  0.0000      1.000  0  0 1.000 0.000 0.000
#> SRR037218     3  0.0000      1.000  0  0 1.000 0.000 0.000
#> SRR037220     1  0.0000      1.000  1  0 0.000 0.000 0.000
#> SRR037221     1  0.0000      1.000  1  0 0.000 0.000 0.000
#> SRR037222     1  0.0000      1.000  1  0 0.000 0.000 0.000
#> SRR037223     1  0.0000      1.000  1  0 0.000 0.000 0.000
#> SRR037224     1  0.0000      1.000  1  0 0.000 0.000 0.000
#> SRR037225     1  0.0000      1.000  1  0 0.000 0.000 0.000
#> SRR037226     1  0.0000      1.000  1  0 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1   p2    p3    p4    p5    p6
#> SRR037165     4  0.0260      0.989 0.000 0.00 0.000 0.992 0.008 0.000
#> SRR037166     4  0.0260      0.989 0.000 0.00 0.000 0.992 0.008 0.000
#> SRR037167     4  0.0000      0.992 0.000 0.00 0.000 1.000 0.000 0.000
#> SRR037168     4  0.0146      0.993 0.000 0.00 0.000 0.996 0.000 0.004
#> SRR037169     4  0.0146      0.993 0.000 0.00 0.000 0.996 0.000 0.004
#> SRR037170     4  0.0146      0.993 0.000 0.00 0.000 0.996 0.000 0.004
#> SRR037171     2  0.0000      0.927 0.000 1.00 0.000 0.000 0.000 0.000
#> SRR037172     2  0.0000      0.927 0.000 1.00 0.000 0.000 0.000 0.000
#> SRR037173     2  0.0000      0.927 0.000 1.00 0.000 0.000 0.000 0.000
#> SRR037174     2  0.0000      0.927 0.000 1.00 0.000 0.000 0.000 0.000
#> SRR037175     2  0.0000      0.927 0.000 1.00 0.000 0.000 0.000 0.000
#> SRR037176     2  0.0000      0.927 0.000 1.00 0.000 0.000 0.000 0.000
#> SRR037177     2  0.4310      0.267 0.000 0.54 0.000 0.440 0.020 0.000
#> SRR037182     6  0.0000      0.999 0.000 0.00 0.000 0.000 0.000 1.000
#> SRR037183     6  0.0000      0.999 0.000 0.00 0.000 0.000 0.000 1.000
#> SRR037184     2  0.0547      0.924 0.000 0.98 0.000 0.000 0.020 0.000
#> SRR037185     2  0.4310      0.267 0.000 0.54 0.000 0.440 0.020 0.000
#> SRR037186     2  0.0547      0.924 0.000 0.98 0.000 0.000 0.020 0.000
#> SRR037187     2  0.0547      0.924 0.000 0.98 0.000 0.000 0.020 0.000
#> SRR037188     6  0.0000      0.999 0.000 0.00 0.000 0.000 0.000 1.000
#> SRR037178     3  0.0000      1.000 0.000 0.00 1.000 0.000 0.000 0.000
#> SRR037179     3  0.0000      1.000 0.000 0.00 1.000 0.000 0.000 0.000
#> SRR037180     3  0.0000      1.000 0.000 0.00 1.000 0.000 0.000 0.000
#> SRR037181     3  0.0000      1.000 0.000 0.00 1.000 0.000 0.000 0.000
#> SRR037189     2  0.0547      0.924 0.000 0.98 0.000 0.000 0.020 0.000
#> SRR037190     2  0.0000      0.927 0.000 1.00 0.000 0.000 0.000 0.000
#> SRR037191     2  0.0000      0.927 0.000 1.00 0.000 0.000 0.000 0.000
#> SRR037192     2  0.0547      0.924 0.000 0.98 0.000 0.000 0.020 0.000
#> SRR037193     5  0.2762      0.977 0.000 0.00 0.000 0.196 0.804 0.000
#> SRR037194     5  0.2762      0.977 0.000 0.00 0.000 0.196 0.804 0.000
#> SRR037195     5  0.2762      0.977 0.000 0.00 0.000 0.196 0.804 0.000
#> SRR037196     5  0.2762      0.977 0.000 0.00 0.000 0.196 0.804 0.000
#> SRR037197     5  0.3448      0.871 0.000 0.00 0.000 0.280 0.716 0.004
#> SRR037198     5  0.2762      0.977 0.000 0.00 0.000 0.196 0.804 0.000
#> SRR037199     1  0.2597      0.916 0.824 0.00 0.000 0.000 0.176 0.000
#> SRR037200     1  0.2597      0.916 0.824 0.00 0.000 0.000 0.176 0.000
#> SRR037201     1  0.2597      0.916 0.824 0.00 0.000 0.000 0.176 0.000
#> SRR037202     1  0.2597      0.916 0.824 0.00 0.000 0.000 0.176 0.000
#> SRR037203     1  0.2597      0.916 0.824 0.00 0.000 0.000 0.176 0.000
#> SRR037204     1  0.2597      0.916 0.824 0.00 0.000 0.000 0.176 0.000
#> SRR037205     1  0.2597      0.916 0.824 0.00 0.000 0.000 0.176 0.000
#> SRR037206     3  0.0000      1.000 0.000 0.00 1.000 0.000 0.000 0.000
#> SRR037207     3  0.0000      1.000 0.000 0.00 1.000 0.000 0.000 0.000
#> SRR037208     3  0.0000      1.000 0.000 0.00 1.000 0.000 0.000 0.000
#> SRR037209     3  0.0000      1.000 0.000 0.00 1.000 0.000 0.000 0.000
#> SRR037210     3  0.0000      1.000 0.000 0.00 1.000 0.000 0.000 0.000
#> SRR037211     3  0.0000      1.000 0.000 0.00 1.000 0.000 0.000 0.000
#> SRR037212     6  0.0000      0.999 0.000 0.00 0.000 0.000 0.000 1.000
#> SRR037213     6  0.0000      0.999 0.000 0.00 0.000 0.000 0.000 1.000
#> SRR037219     6  0.0000      0.999 0.000 0.00 0.000 0.000 0.000 1.000
#> SRR037214     6  0.0146      0.994 0.000 0.00 0.004 0.000 0.000 0.996
#> SRR037215     3  0.0000      1.000 0.000 0.00 1.000 0.000 0.000 0.000
#> SRR037216     3  0.0000      1.000 0.000 0.00 1.000 0.000 0.000 0.000
#> SRR037217     3  0.0000      1.000 0.000 0.00 1.000 0.000 0.000 0.000
#> SRR037218     3  0.0000      1.000 0.000 0.00 1.000 0.000 0.000 0.000
#> SRR037220     1  0.0000      0.916 1.000 0.00 0.000 0.000 0.000 0.000
#> SRR037221     1  0.0000      0.916 1.000 0.00 0.000 0.000 0.000 0.000
#> SRR037222     1  0.0000      0.916 1.000 0.00 0.000 0.000 0.000 0.000
#> SRR037223     1  0.0000      0.916 1.000 0.00 0.000 0.000 0.000 0.000
#> SRR037224     1  0.0000      0.916 1.000 0.00 0.000 0.000 0.000 0.000
#> SRR037225     1  0.0000      0.916 1.000 0.00 0.000 0.000 0.000 0.000
#> SRR037226     1  0.0000      0.916 1.000 0.00 0.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-skmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-skmeans-collect-classes

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


MAD:pam**

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

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

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

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

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

collect_plots(res)

plot of chunk MAD-pam-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.530           0.719       0.839         0.4516 0.581   0.581
#> 3 3 1.000           0.988       0.994         0.4531 0.666   0.470
#> 4 4 0.902           0.913       0.885         0.0741 0.974   0.925
#> 5 5 0.912           0.865       0.930         0.0976 0.910   0.718
#> 6 6 1.000           0.998       0.998         0.0639 0.948   0.774

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> SRR037165     2  0.0000      0.737 0.000 1.000
#> SRR037166     2  0.0000      0.737 0.000 1.000
#> SRR037167     2  0.0000      0.737 0.000 1.000
#> SRR037168     1  0.9710      0.473 0.600 0.400
#> SRR037169     1  0.9710      0.473 0.600 0.400
#> SRR037170     1  0.9710      0.473 0.600 0.400
#> SRR037171     2  0.0000      0.737 0.000 1.000
#> SRR037172     2  0.0000      0.737 0.000 1.000
#> SRR037173     2  0.0000      0.737 0.000 1.000
#> SRR037174     2  0.0000      0.737 0.000 1.000
#> SRR037175     2  0.0000      0.737 0.000 1.000
#> SRR037176     2  0.0000      0.737 0.000 1.000
#> SRR037177     2  0.0000      0.737 0.000 1.000
#> SRR037182     2  0.9710      0.650 0.400 0.600
#> SRR037183     2  0.9710      0.650 0.400 0.600
#> SRR037184     2  0.0000      0.737 0.000 1.000
#> SRR037185     2  0.0000      0.737 0.000 1.000
#> SRR037186     2  0.0000      0.737 0.000 1.000
#> SRR037187     2  0.0000      0.737 0.000 1.000
#> SRR037188     2  0.9710      0.650 0.400 0.600
#> SRR037178     2  0.9710      0.650 0.400 0.600
#> SRR037179     2  0.9710      0.650 0.400 0.600
#> SRR037180     2  0.9710      0.650 0.400 0.600
#> SRR037181     2  0.9710      0.650 0.400 0.600
#> SRR037189     2  0.0000      0.737 0.000 1.000
#> SRR037190     2  0.0000      0.737 0.000 1.000
#> SRR037191     2  0.0000      0.737 0.000 1.000
#> SRR037192     2  0.0000      0.737 0.000 1.000
#> SRR037193     2  0.0000      0.737 0.000 1.000
#> SRR037194     2  0.0000      0.737 0.000 1.000
#> SRR037195     2  0.0000      0.737 0.000 1.000
#> SRR037196     2  0.0000      0.737 0.000 1.000
#> SRR037197     1  0.9710      0.473 0.600 0.400
#> SRR037198     2  0.0000      0.737 0.000 1.000
#> SRR037199     1  0.0672      0.855 0.992 0.008
#> SRR037200     1  0.0000      0.864 1.000 0.000
#> SRR037201     1  0.0000      0.864 1.000 0.000
#> SRR037202     1  0.0000      0.864 1.000 0.000
#> SRR037203     1  0.0000      0.864 1.000 0.000
#> SRR037204     1  0.0000      0.864 1.000 0.000
#> SRR037205     1  0.0000      0.864 1.000 0.000
#> SRR037206     2  0.9710      0.650 0.400 0.600
#> SRR037207     2  0.9710      0.650 0.400 0.600
#> SRR037208     2  0.9710      0.650 0.400 0.600
#> SRR037209     2  0.9710      0.650 0.400 0.600
#> SRR037210     2  0.9710      0.650 0.400 0.600
#> SRR037211     2  0.9710      0.650 0.400 0.600
#> SRR037212     2  0.9710      0.650 0.400 0.600
#> SRR037213     2  0.9710      0.650 0.400 0.600
#> SRR037219     2  0.9710      0.650 0.400 0.600
#> SRR037214     2  0.9710      0.650 0.400 0.600
#> SRR037215     2  0.9710      0.650 0.400 0.600
#> SRR037216     2  0.9710      0.650 0.400 0.600
#> SRR037217     2  0.9710      0.650 0.400 0.600
#> SRR037218     2  0.9710      0.650 0.400 0.600
#> SRR037220     1  0.0000      0.864 1.000 0.000
#> SRR037221     1  0.0000      0.864 1.000 0.000
#> SRR037222     1  0.0000      0.864 1.000 0.000
#> SRR037223     1  0.0000      0.864 1.000 0.000
#> SRR037224     1  0.0000      0.864 1.000 0.000
#> SRR037225     1  0.0000      0.864 1.000 0.000
#> SRR037226     1  0.0000      0.864 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
#> SRR037165     2   0.000      0.986  0 1.000 0.000
#> SRR037166     2   0.000      0.986  0 1.000 0.000
#> SRR037167     2   0.000      0.986  0 1.000 0.000
#> SRR037168     2   0.000      0.986  0 1.000 0.000
#> SRR037169     2   0.000      0.986  0 1.000 0.000
#> SRR037170     2   0.000      0.986  0 1.000 0.000
#> SRR037171     2   0.000      0.986  0 1.000 0.000
#> SRR037172     2   0.000      0.986  0 1.000 0.000
#> SRR037173     2   0.000      0.986  0 1.000 0.000
#> SRR037174     2   0.000      0.986  0 1.000 0.000
#> SRR037175     2   0.000      0.986  0 1.000 0.000
#> SRR037176     2   0.000      0.986  0 1.000 0.000
#> SRR037177     2   0.000      0.986  0 1.000 0.000
#> SRR037182     3   0.000      1.000  0 0.000 1.000
#> SRR037183     3   0.000      1.000  0 0.000 1.000
#> SRR037184     2   0.000      0.986  0 1.000 0.000
#> SRR037185     2   0.000      0.986  0 1.000 0.000
#> SRR037186     2   0.000      0.986  0 1.000 0.000
#> SRR037187     2   0.000      0.986  0 1.000 0.000
#> SRR037188     3   0.000      1.000  0 0.000 1.000
#> SRR037178     3   0.000      1.000  0 0.000 1.000
#> SRR037179     3   0.000      1.000  0 0.000 1.000
#> SRR037180     3   0.000      1.000  0 0.000 1.000
#> SRR037181     3   0.000      1.000  0 0.000 1.000
#> SRR037189     2   0.000      0.986  0 1.000 0.000
#> SRR037190     2   0.000      0.986  0 1.000 0.000
#> SRR037191     2   0.000      0.986  0 1.000 0.000
#> SRR037192     2   0.000      0.986  0 1.000 0.000
#> SRR037193     2   0.424      0.797  0 0.824 0.176
#> SRR037194     2   0.369      0.843  0 0.860 0.140
#> SRR037195     2   0.129      0.957  0 0.968 0.032
#> SRR037196     2   0.000      0.986  0 1.000 0.000
#> SRR037197     2   0.000      0.986  0 1.000 0.000
#> SRR037198     2   0.000      0.986  0 1.000 0.000
#> SRR037199     1   0.000      1.000  1 0.000 0.000
#> SRR037200     1   0.000      1.000  1 0.000 0.000
#> SRR037201     1   0.000      1.000  1 0.000 0.000
#> SRR037202     1   0.000      1.000  1 0.000 0.000
#> SRR037203     1   0.000      1.000  1 0.000 0.000
#> SRR037204     1   0.000      1.000  1 0.000 0.000
#> SRR037205     1   0.000      1.000  1 0.000 0.000
#> SRR037206     3   0.000      1.000  0 0.000 1.000
#> SRR037207     3   0.000      1.000  0 0.000 1.000
#> SRR037208     3   0.000      1.000  0 0.000 1.000
#> SRR037209     3   0.000      1.000  0 0.000 1.000
#> SRR037210     3   0.000      1.000  0 0.000 1.000
#> SRR037211     3   0.000      1.000  0 0.000 1.000
#> SRR037212     3   0.000      1.000  0 0.000 1.000
#> SRR037213     3   0.000      1.000  0 0.000 1.000
#> SRR037219     3   0.000      1.000  0 0.000 1.000
#> SRR037214     3   0.000      1.000  0 0.000 1.000
#> SRR037215     3   0.000      1.000  0 0.000 1.000
#> SRR037216     3   0.000      1.000  0 0.000 1.000
#> SRR037217     3   0.000      1.000  0 0.000 1.000
#> SRR037218     3   0.000      1.000  0 0.000 1.000
#> SRR037220     1   0.000      1.000  1 0.000 0.000
#> SRR037221     1   0.000      1.000  1 0.000 0.000
#> SRR037222     1   0.000      1.000  1 0.000 0.000
#> SRR037223     1   0.000      1.000  1 0.000 0.000
#> SRR037224     1   0.000      1.000  1 0.000 0.000
#> SRR037225     1   0.000      1.000  1 0.000 0.000
#> SRR037226     1   0.000      1.000  1 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> SRR037165     2  0.0000      0.860 0.000 1.000 0.000 0.000
#> SRR037166     2  0.0000      0.860 0.000 1.000 0.000 0.000
#> SRR037167     2  0.4661      0.740 0.348 0.652 0.000 0.000
#> SRR037168     2  0.4697      0.738 0.356 0.644 0.000 0.000
#> SRR037169     2  0.4697      0.738 0.356 0.644 0.000 0.000
#> SRR037170     2  0.4697      0.738 0.356 0.644 0.000 0.000
#> SRR037171     2  0.0000      0.860 0.000 1.000 0.000 0.000
#> SRR037172     2  0.0000      0.860 0.000 1.000 0.000 0.000
#> SRR037173     2  0.0000      0.860 0.000 1.000 0.000 0.000
#> SRR037174     2  0.0000      0.860 0.000 1.000 0.000 0.000
#> SRR037175     2  0.0000      0.860 0.000 1.000 0.000 0.000
#> SRR037176     2  0.0000      0.860 0.000 1.000 0.000 0.000
#> SRR037177     2  0.0000      0.860 0.000 1.000 0.000 0.000
#> SRR037182     3  0.0336      0.995 0.008 0.000 0.992 0.000
#> SRR037183     3  0.0336      0.995 0.008 0.000 0.992 0.000
#> SRR037184     2  0.0000      0.860 0.000 1.000 0.000 0.000
#> SRR037185     2  0.0000      0.860 0.000 1.000 0.000 0.000
#> SRR037186     2  0.0000      0.860 0.000 1.000 0.000 0.000
#> SRR037187     2  0.0000      0.860 0.000 1.000 0.000 0.000
#> SRR037188     3  0.0336      0.995 0.008 0.000 0.992 0.000
#> SRR037178     3  0.0000      0.997 0.000 0.000 1.000 0.000
#> SRR037179     3  0.0000      0.997 0.000 0.000 1.000 0.000
#> SRR037180     3  0.0000      0.997 0.000 0.000 1.000 0.000
#> SRR037181     3  0.0000      0.997 0.000 0.000 1.000 0.000
#> SRR037189     2  0.0000      0.860 0.000 1.000 0.000 0.000
#> SRR037190     2  0.0000      0.860 0.000 1.000 0.000 0.000
#> SRR037191     2  0.0000      0.860 0.000 1.000 0.000 0.000
#> SRR037192     2  0.0000      0.860 0.000 1.000 0.000 0.000
#> SRR037193     2  0.7345      0.567 0.348 0.484 0.168 0.000
#> SRR037194     2  0.7070      0.609 0.348 0.516 0.136 0.000
#> SRR037195     2  0.5582      0.719 0.348 0.620 0.032 0.000
#> SRR037196     2  0.4697      0.738 0.356 0.644 0.000 0.000
#> SRR037197     2  0.4697      0.738 0.356 0.644 0.000 0.000
#> SRR037198     2  0.4697      0.738 0.356 0.644 0.000 0.000
#> SRR037199     1  0.4697      1.000 0.644 0.000 0.000 0.356
#> SRR037200     1  0.4697      1.000 0.644 0.000 0.000 0.356
#> SRR037201     1  0.4697      1.000 0.644 0.000 0.000 0.356
#> SRR037202     1  0.4697      1.000 0.644 0.000 0.000 0.356
#> SRR037203     1  0.4697      1.000 0.644 0.000 0.000 0.356
#> SRR037204     1  0.4697      1.000 0.644 0.000 0.000 0.356
#> SRR037205     1  0.4697      1.000 0.644 0.000 0.000 0.356
#> SRR037206     3  0.0000      0.997 0.000 0.000 1.000 0.000
#> SRR037207     3  0.0000      0.997 0.000 0.000 1.000 0.000
#> SRR037208     3  0.0000      0.997 0.000 0.000 1.000 0.000
#> SRR037209     3  0.0000      0.997 0.000 0.000 1.000 0.000
#> SRR037210     3  0.0000      0.997 0.000 0.000 1.000 0.000
#> SRR037211     3  0.0000      0.997 0.000 0.000 1.000 0.000
#> SRR037212     3  0.0336      0.995 0.008 0.000 0.992 0.000
#> SRR037213     3  0.0336      0.995 0.008 0.000 0.992 0.000
#> SRR037219     3  0.0336      0.995 0.008 0.000 0.992 0.000
#> SRR037214     3  0.0336      0.995 0.008 0.000 0.992 0.000
#> SRR037215     3  0.0000      0.997 0.000 0.000 1.000 0.000
#> SRR037216     3  0.0000      0.997 0.000 0.000 1.000 0.000
#> SRR037217     3  0.0000      0.997 0.000 0.000 1.000 0.000
#> SRR037218     3  0.0000      0.997 0.000 0.000 1.000 0.000
#> SRR037220     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> SRR037221     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> SRR037222     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> SRR037223     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> SRR037224     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> SRR037225     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> SRR037226     4  0.0000      1.000 0.000 0.000 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette p1    p2    p3    p4 p5
#> SRR037165     2   0.000      1.000  0 1.000 0.000 0.000  0
#> SRR037166     2   0.000      1.000  0 1.000 0.000 0.000  0
#> SRR037167     4   0.420      0.489  0 0.408 0.000 0.592  0
#> SRR037168     4   0.000      0.734  0 0.000 0.000 1.000  0
#> SRR037169     4   0.000      0.734  0 0.000 0.000 1.000  0
#> SRR037170     4   0.000      0.734  0 0.000 0.000 1.000  0
#> SRR037171     2   0.000      1.000  0 1.000 0.000 0.000  0
#> SRR037172     2   0.000      1.000  0 1.000 0.000 0.000  0
#> SRR037173     2   0.000      1.000  0 1.000 0.000 0.000  0
#> SRR037174     2   0.000      1.000  0 1.000 0.000 0.000  0
#> SRR037175     2   0.000      1.000  0 1.000 0.000 0.000  0
#> SRR037176     2   0.000      1.000  0 1.000 0.000 0.000  0
#> SRR037177     2   0.000      1.000  0 1.000 0.000 0.000  0
#> SRR037182     3   0.420      0.595  0 0.000 0.592 0.408  0
#> SRR037183     3   0.420      0.595  0 0.000 0.592 0.408  0
#> SRR037184     2   0.000      1.000  0 1.000 0.000 0.000  0
#> SRR037185     2   0.000      1.000  0 1.000 0.000 0.000  0
#> SRR037186     2   0.000      1.000  0 1.000 0.000 0.000  0
#> SRR037187     2   0.000      1.000  0 1.000 0.000 0.000  0
#> SRR037188     3   0.420      0.595  0 0.000 0.592 0.408  0
#> SRR037178     3   0.000      0.857  0 0.000 1.000 0.000  0
#> SRR037179     3   0.000      0.857  0 0.000 1.000 0.000  0
#> SRR037180     3   0.000      0.857  0 0.000 1.000 0.000  0
#> SRR037181     3   0.000      0.857  0 0.000 1.000 0.000  0
#> SRR037189     2   0.000      1.000  0 1.000 0.000 0.000  0
#> SRR037190     2   0.000      1.000  0 1.000 0.000 0.000  0
#> SRR037191     2   0.000      1.000  0 1.000 0.000 0.000  0
#> SRR037192     2   0.000      1.000  0 1.000 0.000 0.000  0
#> SRR037193     4   0.420      0.489  0 0.408 0.000 0.592  0
#> SRR037194     4   0.420      0.489  0 0.408 0.000 0.592  0
#> SRR037195     4   0.420      0.489  0 0.408 0.000 0.592  0
#> SRR037196     4   0.000      0.734  0 0.000 0.000 1.000  0
#> SRR037197     4   0.000      0.734  0 0.000 0.000 1.000  0
#> SRR037198     4   0.000      0.734  0 0.000 0.000 1.000  0
#> SRR037199     1   0.000      1.000  1 0.000 0.000 0.000  0
#> SRR037200     1   0.000      1.000  1 0.000 0.000 0.000  0
#> SRR037201     1   0.000      1.000  1 0.000 0.000 0.000  0
#> SRR037202     1   0.000      1.000  1 0.000 0.000 0.000  0
#> SRR037203     1   0.000      1.000  1 0.000 0.000 0.000  0
#> SRR037204     1   0.000      1.000  1 0.000 0.000 0.000  0
#> SRR037205     1   0.000      1.000  1 0.000 0.000 0.000  0
#> SRR037206     3   0.000      0.857  0 0.000 1.000 0.000  0
#> SRR037207     3   0.000      0.857  0 0.000 1.000 0.000  0
#> SRR037208     3   0.000      0.857  0 0.000 1.000 0.000  0
#> SRR037209     3   0.000      0.857  0 0.000 1.000 0.000  0
#> SRR037210     3   0.000      0.857  0 0.000 1.000 0.000  0
#> SRR037211     3   0.000      0.857  0 0.000 1.000 0.000  0
#> SRR037212     3   0.420      0.595  0 0.000 0.592 0.408  0
#> SRR037213     3   0.420      0.595  0 0.000 0.592 0.408  0
#> SRR037219     3   0.420      0.595  0 0.000 0.592 0.408  0
#> SRR037214     3   0.348      0.719  0 0.000 0.752 0.248  0
#> SRR037215     3   0.000      0.857  0 0.000 1.000 0.000  0
#> SRR037216     3   0.000      0.857  0 0.000 1.000 0.000  0
#> SRR037217     3   0.000      0.857  0 0.000 1.000 0.000  0
#> SRR037218     3   0.000      0.857  0 0.000 1.000 0.000  0
#> SRR037220     5   0.000      1.000  0 0.000 0.000 0.000  1
#> SRR037221     5   0.000      1.000  0 0.000 0.000 0.000  1
#> SRR037222     5   0.000      1.000  0 0.000 0.000 0.000  1
#> SRR037223     5   0.000      1.000  0 0.000 0.000 0.000  1
#> SRR037224     5   0.000      1.000  0 0.000 0.000 0.000  1
#> SRR037225     5   0.000      1.000  0 0.000 0.000 0.000  1
#> SRR037226     5   0.000      1.000  0 0.000 0.000 0.000  1

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette p1    p2 p3    p4 p5    p6
#> SRR037165     2  0.0458      0.985  0 0.984  0 0.016  0 0.000
#> SRR037166     2  0.0458      0.985  0 0.984  0 0.016  0 0.000
#> SRR037167     4  0.0000      0.992  0 0.000  0 1.000  0 0.000
#> SRR037168     4  0.0458      0.989  0 0.000  0 0.984  0 0.016
#> SRR037169     4  0.0458      0.989  0 0.000  0 0.984  0 0.016
#> SRR037170     4  0.0458      0.989  0 0.000  0 0.984  0 0.016
#> SRR037171     2  0.0000      0.998  0 1.000  0 0.000  0 0.000
#> SRR037172     2  0.0000      0.998  0 1.000  0 0.000  0 0.000
#> SRR037173     2  0.0000      0.998  0 1.000  0 0.000  0 0.000
#> SRR037174     2  0.0000      0.998  0 1.000  0 0.000  0 0.000
#> SRR037175     2  0.0000      0.998  0 1.000  0 0.000  0 0.000
#> SRR037176     2  0.0000      0.998  0 1.000  0 0.000  0 0.000
#> SRR037177     2  0.0000      0.998  0 1.000  0 0.000  0 0.000
#> SRR037182     6  0.0000      1.000  0 0.000  0 0.000  0 1.000
#> SRR037183     6  0.0000      1.000  0 0.000  0 0.000  0 1.000
#> SRR037184     2  0.0000      0.998  0 1.000  0 0.000  0 0.000
#> SRR037185     2  0.0000      0.998  0 1.000  0 0.000  0 0.000
#> SRR037186     2  0.0000      0.998  0 1.000  0 0.000  0 0.000
#> SRR037187     2  0.0000      0.998  0 1.000  0 0.000  0 0.000
#> SRR037188     6  0.0000      1.000  0 0.000  0 0.000  0 1.000
#> SRR037178     3  0.0000      1.000  0 0.000  1 0.000  0 0.000
#> SRR037179     3  0.0000      1.000  0 0.000  1 0.000  0 0.000
#> SRR037180     3  0.0000      1.000  0 0.000  1 0.000  0 0.000
#> SRR037181     3  0.0000      1.000  0 0.000  1 0.000  0 0.000
#> SRR037189     2  0.0000      0.998  0 1.000  0 0.000  0 0.000
#> SRR037190     2  0.0000      0.998  0 1.000  0 0.000  0 0.000
#> SRR037191     2  0.0000      0.998  0 1.000  0 0.000  0 0.000
#> SRR037192     2  0.0000      0.998  0 1.000  0 0.000  0 0.000
#> SRR037193     4  0.0000      0.992  0 0.000  0 1.000  0 0.000
#> SRR037194     4  0.0000      0.992  0 0.000  0 1.000  0 0.000
#> SRR037195     4  0.0000      0.992  0 0.000  0 1.000  0 0.000
#> SRR037196     4  0.0000      0.992  0 0.000  0 1.000  0 0.000
#> SRR037197     4  0.0458      0.989  0 0.000  0 0.984  0 0.016
#> SRR037198     4  0.0000      0.992  0 0.000  0 1.000  0 0.000
#> SRR037199     1  0.0000      1.000  1 0.000  0 0.000  0 0.000
#> SRR037200     1  0.0000      1.000  1 0.000  0 0.000  0 0.000
#> SRR037201     1  0.0000      1.000  1 0.000  0 0.000  0 0.000
#> SRR037202     1  0.0000      1.000  1 0.000  0 0.000  0 0.000
#> SRR037203     1  0.0000      1.000  1 0.000  0 0.000  0 0.000
#> SRR037204     1  0.0000      1.000  1 0.000  0 0.000  0 0.000
#> SRR037205     1  0.0000      1.000  1 0.000  0 0.000  0 0.000
#> SRR037206     3  0.0000      1.000  0 0.000  1 0.000  0 0.000
#> SRR037207     3  0.0000      1.000  0 0.000  1 0.000  0 0.000
#> SRR037208     3  0.0000      1.000  0 0.000  1 0.000  0 0.000
#> SRR037209     3  0.0000      1.000  0 0.000  1 0.000  0 0.000
#> SRR037210     3  0.0000      1.000  0 0.000  1 0.000  0 0.000
#> SRR037211     3  0.0000      1.000  0 0.000  1 0.000  0 0.000
#> SRR037212     6  0.0000      1.000  0 0.000  0 0.000  0 1.000
#> SRR037213     6  0.0000      1.000  0 0.000  0 0.000  0 1.000
#> SRR037219     6  0.0000      1.000  0 0.000  0 0.000  0 1.000
#> SRR037214     6  0.0000      1.000  0 0.000  0 0.000  0 1.000
#> SRR037215     3  0.0000      1.000  0 0.000  1 0.000  0 0.000
#> SRR037216     3  0.0000      1.000  0 0.000  1 0.000  0 0.000
#> SRR037217     3  0.0000      1.000  0 0.000  1 0.000  0 0.000
#> SRR037218     3  0.0000      1.000  0 0.000  1 0.000  0 0.000
#> SRR037220     5  0.0000      1.000  0 0.000  0 0.000  1 0.000
#> SRR037221     5  0.0000      1.000  0 0.000  0 0.000  1 0.000
#> SRR037222     5  0.0000      1.000  0 0.000  0 0.000  1 0.000
#> SRR037223     5  0.0000      1.000  0 0.000  0 0.000  1 0.000
#> SRR037224     5  0.0000      1.000  0 0.000  0 0.000  1 0.000
#> SRR037225     5  0.0000      1.000  0 0.000  0 0.000  1 0.000
#> SRR037226     5  0.0000      1.000  0 0.000  0 0.000  1 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 15332 rows and 62 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'mclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 6.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk MAD-mclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.500           0.957       0.956         0.3659 0.645   0.645
#> 3 3 0.848           0.981       0.989         0.7785 0.700   0.535
#> 4 4 0.907           0.910       0.943         0.1491 0.859   0.617
#> 5 5 0.780           0.516       0.728         0.0530 0.909   0.682
#> 6 6 0.933           0.940       0.954         0.0406 0.858   0.491

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette  p1  p2
#> SRR037165     2   0.469      0.950 0.1 0.9
#> SRR037166     2   0.469      0.950 0.1 0.9
#> SRR037167     2   0.469      0.950 0.1 0.9
#> SRR037168     2   0.469      0.950 0.1 0.9
#> SRR037169     2   0.469      0.950 0.1 0.9
#> SRR037170     2   0.469      0.950 0.1 0.9
#> SRR037171     2   0.469      0.950 0.1 0.9
#> SRR037172     2   0.469      0.950 0.1 0.9
#> SRR037173     2   0.469      0.950 0.1 0.9
#> SRR037174     2   0.469      0.950 0.1 0.9
#> SRR037175     2   0.469      0.950 0.1 0.9
#> SRR037176     2   0.469      0.950 0.1 0.9
#> SRR037177     2   0.469      0.950 0.1 0.9
#> SRR037182     2   0.000      0.937 0.0 1.0
#> SRR037183     2   0.000      0.937 0.0 1.0
#> SRR037184     2   0.469      0.950 0.1 0.9
#> SRR037185     2   0.469      0.950 0.1 0.9
#> SRR037186     2   0.469      0.950 0.1 0.9
#> SRR037187     2   0.469      0.950 0.1 0.9
#> SRR037188     2   0.000      0.937 0.0 1.0
#> SRR037178     2   0.000      0.937 0.0 1.0
#> SRR037179     2   0.000      0.937 0.0 1.0
#> SRR037180     2   0.000      0.937 0.0 1.0
#> SRR037181     2   0.000      0.937 0.0 1.0
#> SRR037189     2   0.469      0.950 0.1 0.9
#> SRR037190     2   0.469      0.950 0.1 0.9
#> SRR037191     2   0.469      0.950 0.1 0.9
#> SRR037192     2   0.469      0.950 0.1 0.9
#> SRR037193     2   0.469      0.950 0.1 0.9
#> SRR037194     2   0.469      0.950 0.1 0.9
#> SRR037195     2   0.469      0.950 0.1 0.9
#> SRR037196     2   0.469      0.950 0.1 0.9
#> SRR037197     2   0.469      0.950 0.1 0.9
#> SRR037198     2   0.469      0.950 0.1 0.9
#> SRR037199     1   0.000      1.000 1.0 0.0
#> SRR037200     1   0.000      1.000 1.0 0.0
#> SRR037201     1   0.000      1.000 1.0 0.0
#> SRR037202     1   0.000      1.000 1.0 0.0
#> SRR037203     1   0.000      1.000 1.0 0.0
#> SRR037204     1   0.000      1.000 1.0 0.0
#> SRR037205     1   0.000      1.000 1.0 0.0
#> SRR037206     2   0.000      0.937 0.0 1.0
#> SRR037207     2   0.000      0.937 0.0 1.0
#> SRR037208     2   0.000      0.937 0.0 1.0
#> SRR037209     2   0.000      0.937 0.0 1.0
#> SRR037210     2   0.000      0.937 0.0 1.0
#> SRR037211     2   0.000      0.937 0.0 1.0
#> SRR037212     2   0.000      0.937 0.0 1.0
#> SRR037213     2   0.000      0.937 0.0 1.0
#> SRR037219     2   0.000      0.937 0.0 1.0
#> SRR037214     2   0.000      0.937 0.0 1.0
#> SRR037215     2   0.000      0.937 0.0 1.0
#> SRR037216     2   0.000      0.937 0.0 1.0
#> SRR037217     2   0.000      0.937 0.0 1.0
#> SRR037218     2   0.000      0.937 0.0 1.0
#> SRR037220     1   0.000      1.000 1.0 0.0
#> SRR037221     1   0.000      1.000 1.0 0.0
#> SRR037222     1   0.000      1.000 1.0 0.0
#> SRR037223     1   0.000      1.000 1.0 0.0
#> SRR037224     1   0.000      1.000 1.0 0.0
#> SRR037225     1   0.000      1.000 1.0 0.0
#> SRR037226     1   0.000      1.000 1.0 0.0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette p1  p2  p3
#> SRR037165     2   0.000      1.000  0 1.0 0.0
#> SRR037166     2   0.000      1.000  0 1.0 0.0
#> SRR037167     2   0.000      1.000  0 1.0 0.0
#> SRR037168     2   0.000      1.000  0 1.0 0.0
#> SRR037169     2   0.000      1.000  0 1.0 0.0
#> SRR037170     2   0.000      1.000  0 1.0 0.0
#> SRR037171     2   0.000      1.000  0 1.0 0.0
#> SRR037172     2   0.000      1.000  0 1.0 0.0
#> SRR037173     2   0.000      1.000  0 1.0 0.0
#> SRR037174     2   0.000      1.000  0 1.0 0.0
#> SRR037175     2   0.000      1.000  0 1.0 0.0
#> SRR037176     2   0.000      1.000  0 1.0 0.0
#> SRR037177     2   0.000      1.000  0 1.0 0.0
#> SRR037182     3   0.296      0.915  0 0.1 0.9
#> SRR037183     3   0.296      0.915  0 0.1 0.9
#> SRR037184     2   0.000      1.000  0 1.0 0.0
#> SRR037185     2   0.000      1.000  0 1.0 0.0
#> SRR037186     2   0.000      1.000  0 1.0 0.0
#> SRR037187     2   0.000      1.000  0 1.0 0.0
#> SRR037188     3   0.296      0.915  0 0.1 0.9
#> SRR037178     3   0.296      0.915  0 0.1 0.9
#> SRR037179     3   0.296      0.915  0 0.1 0.9
#> SRR037180     3   0.296      0.915  0 0.1 0.9
#> SRR037181     3   0.296      0.915  0 0.1 0.9
#> SRR037189     2   0.000      1.000  0 1.0 0.0
#> SRR037190     2   0.000      1.000  0 1.0 0.0
#> SRR037191     2   0.000      1.000  0 1.0 0.0
#> SRR037192     2   0.000      1.000  0 1.0 0.0
#> SRR037193     2   0.000      1.000  0 1.0 0.0
#> SRR037194     2   0.000      1.000  0 1.0 0.0
#> SRR037195     2   0.000      1.000  0 1.0 0.0
#> SRR037196     2   0.000      1.000  0 1.0 0.0
#> SRR037197     2   0.000      1.000  0 1.0 0.0
#> SRR037198     2   0.000      1.000  0 1.0 0.0
#> SRR037199     1   0.000      1.000  1 0.0 0.0
#> SRR037200     1   0.000      1.000  1 0.0 0.0
#> SRR037201     1   0.000      1.000  1 0.0 0.0
#> SRR037202     1   0.000      1.000  1 0.0 0.0
#> SRR037203     1   0.000      1.000  1 0.0 0.0
#> SRR037204     1   0.000      1.000  1 0.0 0.0
#> SRR037205     1   0.000      1.000  1 0.0 0.0
#> SRR037206     3   0.000      0.958  0 0.0 1.0
#> SRR037207     3   0.000      0.958  0 0.0 1.0
#> SRR037208     3   0.000      0.958  0 0.0 1.0
#> SRR037209     3   0.000      0.958  0 0.0 1.0
#> SRR037210     3   0.000      0.958  0 0.0 1.0
#> SRR037211     3   0.000      0.958  0 0.0 1.0
#> SRR037212     3   0.000      0.958  0 0.0 1.0
#> SRR037213     3   0.000      0.958  0 0.0 1.0
#> SRR037219     3   0.000      0.958  0 0.0 1.0
#> SRR037214     3   0.000      0.958  0 0.0 1.0
#> SRR037215     3   0.000      0.958  0 0.0 1.0
#> SRR037216     3   0.000      0.958  0 0.0 1.0
#> SRR037217     3   0.000      0.958  0 0.0 1.0
#> SRR037218     3   0.000      0.958  0 0.0 1.0
#> SRR037220     1   0.000      1.000  1 0.0 0.0
#> SRR037221     1   0.000      1.000  1 0.0 0.0
#> SRR037222     1   0.000      1.000  1 0.0 0.0
#> SRR037223     1   0.000      1.000  1 0.0 0.0
#> SRR037224     1   0.000      1.000  1 0.0 0.0
#> SRR037225     1   0.000      1.000  1 0.0 0.0
#> SRR037226     1   0.000      1.000  1 0.0 0.0

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette p1    p2    p3    p4
#> SRR037165     2  0.0469      0.946  0 0.988 0.000 0.012
#> SRR037166     2  0.0469      0.946  0 0.988 0.000 0.012
#> SRR037167     2  0.0336      0.948  0 0.992 0.000 0.008
#> SRR037168     2  0.4406      0.666  0 0.700 0.000 0.300
#> SRR037169     2  0.4981      0.353  0 0.536 0.000 0.464
#> SRR037170     2  0.4193      0.706  0 0.732 0.000 0.268
#> SRR037171     2  0.0000      0.946  0 1.000 0.000 0.000
#> SRR037172     2  0.0000      0.946  0 1.000 0.000 0.000
#> SRR037173     2  0.0000      0.946  0 1.000 0.000 0.000
#> SRR037174     2  0.0000      0.946  0 1.000 0.000 0.000
#> SRR037175     2  0.0000      0.946  0 1.000 0.000 0.000
#> SRR037176     2  0.0000      0.946  0 1.000 0.000 0.000
#> SRR037177     2  0.0336      0.948  0 0.992 0.000 0.008
#> SRR037182     4  0.4522      0.729  0 0.000 0.320 0.680
#> SRR037183     4  0.4522      0.729  0 0.000 0.320 0.680
#> SRR037184     2  0.0336      0.948  0 0.992 0.000 0.008
#> SRR037185     2  0.0336      0.948  0 0.992 0.000 0.008
#> SRR037186     2  0.0336      0.948  0 0.992 0.000 0.008
#> SRR037187     2  0.0336      0.948  0 0.992 0.000 0.008
#> SRR037188     4  0.4522      0.729  0 0.000 0.320 0.680
#> SRR037178     4  0.4697      0.702  0 0.000 0.356 0.644
#> SRR037179     4  0.4697      0.702  0 0.000 0.356 0.644
#> SRR037180     4  0.4697      0.702  0 0.000 0.356 0.644
#> SRR037181     4  0.4697      0.702  0 0.000 0.356 0.644
#> SRR037189     2  0.0336      0.948  0 0.992 0.000 0.008
#> SRR037190     2  0.0336      0.948  0 0.992 0.000 0.008
#> SRR037191     2  0.0000      0.946  0 1.000 0.000 0.000
#> SRR037192     2  0.0336      0.948  0 0.992 0.000 0.008
#> SRR037193     4  0.0000      0.772  0 0.000 0.000 1.000
#> SRR037194     4  0.0000      0.772  0 0.000 0.000 1.000
#> SRR037195     4  0.0000      0.772  0 0.000 0.000 1.000
#> SRR037196     4  0.0000      0.772  0 0.000 0.000 1.000
#> SRR037197     4  0.0000      0.772  0 0.000 0.000 1.000
#> SRR037198     4  0.0000      0.772  0 0.000 0.000 1.000
#> SRR037199     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR037200     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR037201     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR037202     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR037203     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR037204     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR037205     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR037206     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR037207     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR037208     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR037209     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR037210     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR037211     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR037212     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR037213     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR037219     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR037214     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR037215     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR037216     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR037217     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR037218     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR037220     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR037221     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR037222     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR037223     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR037224     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR037225     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR037226     1  0.0000      1.000  1 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette p1    p2    p3    p4    p5
#> SRR037165     2  0.0000     0.6681  0 1.000 0.000 0.000 0.000
#> SRR037166     2  0.0451     0.6624  0 0.988 0.004 0.000 0.008
#> SRR037167     2  0.3169     0.5334  0 0.840 0.016 0.004 0.140
#> SRR037168     2  0.7416    -0.1592  0 0.532 0.120 0.144 0.204
#> SRR037169     2  0.8102    -0.5956  0 0.376 0.116 0.304 0.204
#> SRR037170     2  0.6732     0.1164  0 0.612 0.116 0.100 0.172
#> SRR037171     2  0.4283     0.6375  0 0.544 0.000 0.456 0.000
#> SRR037172     2  0.4283     0.6375  0 0.544 0.000 0.456 0.000
#> SRR037173     2  0.4283     0.6375  0 0.544 0.000 0.456 0.000
#> SRR037174     2  0.4283     0.6375  0 0.544 0.000 0.456 0.000
#> SRR037175     2  0.4283     0.6375  0 0.544 0.000 0.456 0.000
#> SRR037176     2  0.4283     0.6375  0 0.544 0.000 0.456 0.000
#> SRR037177     2  0.0162     0.6660  0 0.996 0.004 0.000 0.000
#> SRR037182     5  0.6477     0.0201  0 0.000 0.248 0.256 0.496
#> SRR037183     5  0.6460     0.0196  0 0.000 0.248 0.252 0.500
#> SRR037184     2  0.0000     0.6681  0 1.000 0.000 0.000 0.000
#> SRR037185     2  0.0162     0.6660  0 0.996 0.004 0.000 0.000
#> SRR037186     2  0.0000     0.6681  0 1.000 0.000 0.000 0.000
#> SRR037187     2  0.0000     0.6681  0 1.000 0.000 0.000 0.000
#> SRR037188     5  0.6477     0.0201  0 0.000 0.248 0.256 0.496
#> SRR037178     3  0.0404     0.3151  0 0.000 0.988 0.000 0.012
#> SRR037179     3  0.0404     0.3151  0 0.000 0.988 0.000 0.012
#> SRR037180     3  0.0404     0.3151  0 0.000 0.988 0.000 0.012
#> SRR037181     3  0.0404     0.3151  0 0.000 0.988 0.000 0.012
#> SRR037189     2  0.0000     0.6681  0 1.000 0.000 0.000 0.000
#> SRR037190     2  0.4283     0.6375  0 0.544 0.000 0.456 0.000
#> SRR037191     2  0.4283     0.6375  0 0.544 0.000 0.456 0.000
#> SRR037192     2  0.0000     0.6681  0 1.000 0.000 0.000 0.000
#> SRR037193     3  0.8253    -0.7855  0 0.200 0.344 0.316 0.140
#> SRR037194     3  0.8253    -0.7855  0 0.200 0.344 0.316 0.140
#> SRR037195     3  0.8253    -0.7855  0 0.200 0.344 0.316 0.140
#> SRR037196     4  0.7905     0.9228  0 0.200 0.180 0.468 0.152
#> SRR037197     4  0.7626     0.8576  0 0.176 0.120 0.504 0.200
#> SRR037198     4  0.8034     0.9110  0 0.200 0.204 0.444 0.152
#> SRR037199     1  0.0000     1.0000  1 0.000 0.000 0.000 0.000
#> SRR037200     1  0.0000     1.0000  1 0.000 0.000 0.000 0.000
#> SRR037201     1  0.0000     1.0000  1 0.000 0.000 0.000 0.000
#> SRR037202     1  0.0000     1.0000  1 0.000 0.000 0.000 0.000
#> SRR037203     1  0.0000     1.0000  1 0.000 0.000 0.000 0.000
#> SRR037204     1  0.0000     1.0000  1 0.000 0.000 0.000 0.000
#> SRR037205     1  0.0000     1.0000  1 0.000 0.000 0.000 0.000
#> SRR037206     3  0.4297     0.3926  0 0.000 0.528 0.000 0.472
#> SRR037207     3  0.4297     0.3926  0 0.000 0.528 0.000 0.472
#> SRR037208     3  0.4297     0.3926  0 0.000 0.528 0.000 0.472
#> SRR037209     3  0.4297     0.3926  0 0.000 0.528 0.000 0.472
#> SRR037210     3  0.4297     0.3926  0 0.000 0.528 0.000 0.472
#> SRR037211     3  0.4297     0.3926  0 0.000 0.528 0.000 0.472
#> SRR037212     5  0.0162     0.5437  0 0.000 0.004 0.000 0.996
#> SRR037213     5  0.0162     0.5437  0 0.000 0.004 0.000 0.996
#> SRR037219     5  0.0404     0.5443  0 0.000 0.012 0.000 0.988
#> SRR037214     5  0.1410     0.4978  0 0.000 0.060 0.000 0.940
#> SRR037215     3  0.4302     0.3786  0 0.000 0.520 0.000 0.480
#> SRR037216     3  0.4297     0.3926  0 0.000 0.528 0.000 0.472
#> SRR037217     5  0.3932     0.0301  0 0.000 0.328 0.000 0.672
#> SRR037218     5  0.3895     0.0524  0 0.000 0.320 0.000 0.680
#> SRR037220     1  0.0000     1.0000  1 0.000 0.000 0.000 0.000
#> SRR037221     1  0.0000     1.0000  1 0.000 0.000 0.000 0.000
#> SRR037222     1  0.0000     1.0000  1 0.000 0.000 0.000 0.000
#> SRR037223     1  0.0000     1.0000  1 0.000 0.000 0.000 0.000
#> SRR037224     1  0.0000     1.0000  1 0.000 0.000 0.000 0.000
#> SRR037225     1  0.0000     1.0000  1 0.000 0.000 0.000 0.000
#> SRR037226     1  0.0000     1.0000  1 0.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette p1    p2    p3    p4    p5    p6
#> SRR037165     4  0.1806      0.889  0 0.088 0.000 0.908 0.004 0.000
#> SRR037166     4  0.2112      0.889  0 0.088 0.000 0.896 0.016 0.000
#> SRR037167     4  0.3845      0.844  0 0.088 0.000 0.772 0.140 0.000
#> SRR037168     5  0.0146      0.985  0 0.000 0.000 0.004 0.996 0.000
#> SRR037169     5  0.0146      0.985  0 0.000 0.000 0.004 0.996 0.000
#> SRR037170     5  0.0603      0.972  0 0.016 0.000 0.004 0.980 0.000
#> SRR037171     2  0.0000      0.973  0 1.000 0.000 0.000 0.000 0.000
#> SRR037172     2  0.0000      0.973  0 1.000 0.000 0.000 0.000 0.000
#> SRR037173     2  0.0000      0.973  0 1.000 0.000 0.000 0.000 0.000
#> SRR037174     2  0.0865      0.946  0 0.964 0.000 0.036 0.000 0.000
#> SRR037175     2  0.0000      0.973  0 1.000 0.000 0.000 0.000 0.000
#> SRR037176     2  0.0146      0.971  0 0.996 0.000 0.004 0.000 0.000
#> SRR037177     4  0.1908      0.890  0 0.096 0.000 0.900 0.004 0.000
#> SRR037182     6  0.0146      0.930  0 0.000 0.000 0.004 0.000 0.996
#> SRR037183     6  0.0146      0.930  0 0.000 0.000 0.004 0.000 0.996
#> SRR037184     4  0.1910      0.889  0 0.108 0.000 0.892 0.000 0.000
#> SRR037185     4  0.1908      0.890  0 0.096 0.000 0.900 0.004 0.000
#> SRR037186     4  0.1910      0.889  0 0.108 0.000 0.892 0.000 0.000
#> SRR037187     4  0.1910      0.889  0 0.108 0.000 0.892 0.000 0.000
#> SRR037188     6  0.0260      0.930  0 0.000 0.000 0.008 0.000 0.992
#> SRR037178     3  0.0937      0.964  0 0.000 0.960 0.000 0.000 0.040
#> SRR037179     3  0.0937      0.964  0 0.000 0.960 0.000 0.000 0.040
#> SRR037180     3  0.0937      0.964  0 0.000 0.960 0.000 0.000 0.040
#> SRR037181     3  0.0937      0.964  0 0.000 0.960 0.000 0.000 0.040
#> SRR037189     4  0.2003      0.885  0 0.116 0.000 0.884 0.000 0.000
#> SRR037190     2  0.1714      0.877  0 0.908 0.000 0.092 0.000 0.000
#> SRR037191     2  0.0146      0.972  0 0.996 0.000 0.004 0.000 0.000
#> SRR037192     4  0.1910      0.889  0 0.108 0.000 0.892 0.000 0.000
#> SRR037193     4  0.2442      0.804  0 0.000 0.000 0.852 0.144 0.004
#> SRR037194     4  0.2442      0.804  0 0.000 0.000 0.852 0.144 0.004
#> SRR037195     4  0.2442      0.804  0 0.000 0.000 0.852 0.144 0.004
#> SRR037196     4  0.2562      0.794  0 0.000 0.000 0.828 0.172 0.000
#> SRR037197     5  0.0458      0.975  0 0.000 0.000 0.016 0.984 0.000
#> SRR037198     4  0.2562      0.794  0 0.000 0.000 0.828 0.172 0.000
#> SRR037199     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR037200     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR037201     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR037202     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR037203     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR037204     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR037205     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR037206     3  0.0000      0.977  0 0.000 1.000 0.000 0.000 0.000
#> SRR037207     3  0.0000      0.977  0 0.000 1.000 0.000 0.000 0.000
#> SRR037208     3  0.0000      0.977  0 0.000 1.000 0.000 0.000 0.000
#> SRR037209     3  0.0146      0.976  0 0.000 0.996 0.004 0.000 0.000
#> SRR037210     3  0.0000      0.977  0 0.000 1.000 0.000 0.000 0.000
#> SRR037211     3  0.0000      0.977  0 0.000 1.000 0.000 0.000 0.000
#> SRR037212     6  0.0790      0.934  0 0.000 0.032 0.000 0.000 0.968
#> SRR037213     6  0.0790      0.934  0 0.000 0.032 0.000 0.000 0.968
#> SRR037219     6  0.0790      0.934  0 0.000 0.032 0.000 0.000 0.968
#> SRR037214     6  0.2941      0.715  0 0.000 0.220 0.000 0.000 0.780
#> SRR037215     3  0.0000      0.977  0 0.000 1.000 0.000 0.000 0.000
#> SRR037216     3  0.0000      0.977  0 0.000 1.000 0.000 0.000 0.000
#> SRR037217     3  0.1297      0.947  0 0.000 0.948 0.012 0.000 0.040
#> SRR037218     3  0.1745      0.919  0 0.000 0.920 0.012 0.000 0.068
#> SRR037220     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR037221     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR037222     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR037223     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR037224     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR037225     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR037226     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.688           0.837       0.933         0.4840 0.511   0.511
#> 3 3 0.731           0.876       0.925         0.3630 0.718   0.504
#> 4 4 0.930           0.910       0.948         0.1226 0.926   0.785
#> 5 5 0.865           0.752       0.868         0.0549 0.932   0.763
#> 6 6 0.932           0.857       0.934         0.0254 0.963   0.842

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> SRR037165     2  0.0000     0.9285 0.000 1.000
#> SRR037166     2  0.0000     0.9285 0.000 1.000
#> SRR037167     2  0.0000     0.9285 0.000 1.000
#> SRR037168     2  0.0000     0.9285 0.000 1.000
#> SRR037169     2  0.0376     0.9259 0.004 0.996
#> SRR037170     2  0.0000     0.9285 0.000 1.000
#> SRR037171     2  0.0000     0.9285 0.000 1.000
#> SRR037172     2  0.0000     0.9285 0.000 1.000
#> SRR037173     2  0.0000     0.9285 0.000 1.000
#> SRR037174     2  0.0000     0.9285 0.000 1.000
#> SRR037175     2  0.0000     0.9285 0.000 1.000
#> SRR037176     2  0.0000     0.9285 0.000 1.000
#> SRR037177     2  0.0000     0.9285 0.000 1.000
#> SRR037182     1  0.9993     0.0686 0.516 0.484
#> SRR037183     1  0.8861     0.5620 0.696 0.304
#> SRR037184     2  0.0000     0.9285 0.000 1.000
#> SRR037185     2  0.0000     0.9285 0.000 1.000
#> SRR037186     2  0.0000     0.9285 0.000 1.000
#> SRR037187     2  0.0000     0.9285 0.000 1.000
#> SRR037188     2  0.7883     0.6661 0.236 0.764
#> SRR037178     2  0.0672     0.9238 0.008 0.992
#> SRR037179     2  0.0672     0.9238 0.008 0.992
#> SRR037180     2  0.0672     0.9238 0.008 0.992
#> SRR037181     2  0.0672     0.9238 0.008 0.992
#> SRR037189     2  0.0000     0.9285 0.000 1.000
#> SRR037190     2  0.0000     0.9285 0.000 1.000
#> SRR037191     2  0.0000     0.9285 0.000 1.000
#> SRR037192     2  0.0000     0.9285 0.000 1.000
#> SRR037193     2  0.0000     0.9285 0.000 1.000
#> SRR037194     2  0.0000     0.9285 0.000 1.000
#> SRR037195     2  0.0000     0.9285 0.000 1.000
#> SRR037196     2  0.0000     0.9285 0.000 1.000
#> SRR037197     2  0.5737     0.7933 0.136 0.864
#> SRR037198     2  0.0000     0.9285 0.000 1.000
#> SRR037199     1  0.0000     0.9108 1.000 0.000
#> SRR037200     1  0.0000     0.9108 1.000 0.000
#> SRR037201     1  0.0000     0.9108 1.000 0.000
#> SRR037202     1  0.0000     0.9108 1.000 0.000
#> SRR037203     1  0.0000     0.9108 1.000 0.000
#> SRR037204     1  0.0000     0.9108 1.000 0.000
#> SRR037205     1  0.0000     0.9108 1.000 0.000
#> SRR037206     2  0.9522     0.4010 0.372 0.628
#> SRR037207     2  0.9522     0.4011 0.372 0.628
#> SRR037208     1  0.7883     0.6979 0.764 0.236
#> SRR037209     1  0.7950     0.6920 0.760 0.240
#> SRR037210     2  0.9491     0.4111 0.368 0.632
#> SRR037211     2  0.9323     0.4563 0.348 0.652
#> SRR037212     1  0.0000     0.9108 1.000 0.000
#> SRR037213     1  0.0000     0.9108 1.000 0.000
#> SRR037219     1  0.0000     0.9108 1.000 0.000
#> SRR037214     1  0.0000     0.9108 1.000 0.000
#> SRR037215     1  0.9087     0.5408 0.676 0.324
#> SRR037216     2  0.9460     0.4206 0.364 0.636
#> SRR037217     1  0.6623     0.7764 0.828 0.172
#> SRR037218     1  0.6438     0.7845 0.836 0.164
#> SRR037220     1  0.0000     0.9108 1.000 0.000
#> SRR037221     1  0.0000     0.9108 1.000 0.000
#> SRR037222     1  0.0000     0.9108 1.000 0.000
#> SRR037223     1  0.0000     0.9108 1.000 0.000
#> SRR037224     1  0.0000     0.9108 1.000 0.000
#> SRR037225     1  0.0000     0.9108 1.000 0.000
#> SRR037226     1  0.0000     0.9108 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
#> SRR037165     2  0.0000      0.887 0.000 1.000 0.000
#> SRR037166     2  0.0000      0.887 0.000 1.000 0.000
#> SRR037167     2  0.0237      0.886 0.000 0.996 0.004
#> SRR037168     2  0.0237      0.886 0.000 0.996 0.004
#> SRR037169     2  0.0661      0.882 0.008 0.988 0.004
#> SRR037170     2  0.0237      0.886 0.000 0.996 0.004
#> SRR037171     2  0.5178      0.789 0.000 0.744 0.256
#> SRR037172     2  0.5178      0.789 0.000 0.744 0.256
#> SRR037173     2  0.4654      0.819 0.000 0.792 0.208
#> SRR037174     2  0.4291      0.833 0.000 0.820 0.180
#> SRR037175     2  0.5178      0.789 0.000 0.744 0.256
#> SRR037176     2  0.5216      0.786 0.000 0.740 0.260
#> SRR037177     2  0.0000      0.887 0.000 1.000 0.000
#> SRR037182     3  0.7211      0.711 0.128 0.156 0.716
#> SRR037183     3  0.7372      0.698 0.128 0.168 0.704
#> SRR037184     2  0.1031      0.884 0.000 0.976 0.024
#> SRR037185     2  0.0000      0.887 0.000 1.000 0.000
#> SRR037186     2  0.0000      0.887 0.000 1.000 0.000
#> SRR037187     2  0.0237      0.887 0.000 0.996 0.004
#> SRR037188     3  0.5538      0.789 0.060 0.132 0.808
#> SRR037178     3  0.0237      0.904 0.000 0.004 0.996
#> SRR037179     3  0.0237      0.904 0.000 0.004 0.996
#> SRR037180     3  0.0237      0.904 0.000 0.004 0.996
#> SRR037181     3  0.0237      0.904 0.000 0.004 0.996
#> SRR037189     2  0.0000      0.887 0.000 1.000 0.000
#> SRR037190     2  0.4121      0.838 0.000 0.832 0.168
#> SRR037191     2  0.5254      0.782 0.000 0.736 0.264
#> SRR037192     2  0.0237      0.887 0.000 0.996 0.004
#> SRR037193     2  0.5926      0.654 0.000 0.644 0.356
#> SRR037194     2  0.5397      0.764 0.000 0.720 0.280
#> SRR037195     2  0.4974      0.803 0.000 0.764 0.236
#> SRR037196     2  0.0237      0.886 0.000 0.996 0.004
#> SRR037197     2  0.1129      0.875 0.020 0.976 0.004
#> SRR037198     2  0.0424      0.885 0.000 0.992 0.008
#> SRR037199     1  0.2356      0.918 0.928 0.000 0.072
#> SRR037200     1  0.0237      0.990 0.996 0.000 0.004
#> SRR037201     1  0.0237      0.990 0.996 0.000 0.004
#> SRR037202     1  0.0000      0.993 1.000 0.000 0.000
#> SRR037203     1  0.0000      0.993 1.000 0.000 0.000
#> SRR037204     1  0.0000      0.993 1.000 0.000 0.000
#> SRR037205     1  0.0000      0.993 1.000 0.000 0.000
#> SRR037206     3  0.0237      0.904 0.000 0.004 0.996
#> SRR037207     3  0.0237      0.904 0.000 0.004 0.996
#> SRR037208     3  0.0237      0.903 0.004 0.000 0.996
#> SRR037209     3  0.0237      0.903 0.004 0.000 0.996
#> SRR037210     3  0.0237      0.904 0.000 0.004 0.996
#> SRR037211     3  0.0237      0.904 0.000 0.004 0.996
#> SRR037212     3  0.5178      0.691 0.256 0.000 0.744
#> SRR037213     3  0.5098      0.702 0.248 0.000 0.752
#> SRR037219     3  0.5465      0.651 0.288 0.000 0.712
#> SRR037214     3  0.4002      0.796 0.160 0.000 0.840
#> SRR037215     3  0.0237      0.903 0.004 0.000 0.996
#> SRR037216     3  0.0237      0.904 0.000 0.004 0.996
#> SRR037217     3  0.0000      0.903 0.000 0.000 1.000
#> SRR037218     3  0.0000      0.903 0.000 0.000 1.000
#> SRR037220     1  0.0000      0.993 1.000 0.000 0.000
#> SRR037221     1  0.0000      0.993 1.000 0.000 0.000
#> SRR037222     1  0.0000      0.993 1.000 0.000 0.000
#> SRR037223     1  0.0000      0.993 1.000 0.000 0.000
#> SRR037224     1  0.0000      0.993 1.000 0.000 0.000
#> SRR037225     1  0.0000      0.993 1.000 0.000 0.000
#> SRR037226     1  0.0000      0.993 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> SRR037165     2  0.4907      0.495 0.000 0.580 0.000 0.420
#> SRR037166     2  0.4998      0.334 0.000 0.512 0.000 0.488
#> SRR037167     4  0.0469      1.000 0.000 0.012 0.000 0.988
#> SRR037168     4  0.0469      1.000 0.000 0.012 0.000 0.988
#> SRR037169     4  0.0469      1.000 0.000 0.012 0.000 0.988
#> SRR037170     4  0.0469      1.000 0.000 0.012 0.000 0.988
#> SRR037171     2  0.0000      0.854 0.000 1.000 0.000 0.000
#> SRR037172     2  0.0000      0.854 0.000 1.000 0.000 0.000
#> SRR037173     2  0.0188      0.855 0.000 0.996 0.000 0.004
#> SRR037174     2  0.0188      0.855 0.000 0.996 0.000 0.004
#> SRR037175     2  0.0000      0.854 0.000 1.000 0.000 0.000
#> SRR037176     2  0.0000      0.854 0.000 1.000 0.000 0.000
#> SRR037177     2  0.4925      0.463 0.000 0.572 0.000 0.428
#> SRR037182     3  0.1792      0.921 0.000 0.000 0.932 0.068
#> SRR037183     3  0.4193      0.653 0.000 0.000 0.732 0.268
#> SRR037184     2  0.1716      0.851 0.000 0.936 0.000 0.064
#> SRR037185     2  0.4643      0.613 0.000 0.656 0.000 0.344
#> SRR037186     2  0.2647      0.832 0.000 0.880 0.000 0.120
#> SRR037187     2  0.2345      0.841 0.000 0.900 0.000 0.100
#> SRR037188     3  0.0000      0.983 0.000 0.000 1.000 0.000
#> SRR037178     3  0.0000      0.983 0.000 0.000 1.000 0.000
#> SRR037179     3  0.0000      0.983 0.000 0.000 1.000 0.000
#> SRR037180     3  0.0000      0.983 0.000 0.000 1.000 0.000
#> SRR037181     3  0.0000      0.983 0.000 0.000 1.000 0.000
#> SRR037189     2  0.2647      0.832 0.000 0.880 0.000 0.120
#> SRR037190     2  0.0336      0.855 0.000 0.992 0.000 0.008
#> SRR037191     2  0.0000      0.854 0.000 1.000 0.000 0.000
#> SRR037192     2  0.1792      0.850 0.000 0.932 0.000 0.068
#> SRR037193     2  0.1624      0.844 0.000 0.952 0.028 0.020
#> SRR037194     2  0.3710      0.761 0.000 0.804 0.004 0.192
#> SRR037195     2  0.4608      0.662 0.000 0.692 0.004 0.304
#> SRR037196     4  0.0469      1.000 0.000 0.012 0.000 0.988
#> SRR037197     4  0.0469      1.000 0.000 0.012 0.000 0.988
#> SRR037198     4  0.0469      1.000 0.000 0.012 0.000 0.988
#> SRR037199     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> SRR037200     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> SRR037201     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> SRR037202     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> SRR037203     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> SRR037204     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> SRR037205     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> SRR037206     3  0.0000      0.983 0.000 0.000 1.000 0.000
#> SRR037207     3  0.0000      0.983 0.000 0.000 1.000 0.000
#> SRR037208     3  0.0000      0.983 0.000 0.000 1.000 0.000
#> SRR037209     3  0.0000      0.983 0.000 0.000 1.000 0.000
#> SRR037210     3  0.0000      0.983 0.000 0.000 1.000 0.000
#> SRR037211     3  0.0000      0.983 0.000 0.000 1.000 0.000
#> SRR037212     3  0.0000      0.983 0.000 0.000 1.000 0.000
#> SRR037213     3  0.0000      0.983 0.000 0.000 1.000 0.000
#> SRR037219     3  0.0000      0.983 0.000 0.000 1.000 0.000
#> SRR037214     3  0.0000      0.983 0.000 0.000 1.000 0.000
#> SRR037215     3  0.0000      0.983 0.000 0.000 1.000 0.000
#> SRR037216     3  0.0000      0.983 0.000 0.000 1.000 0.000
#> SRR037217     3  0.0000      0.983 0.000 0.000 1.000 0.000
#> SRR037218     3  0.0000      0.983 0.000 0.000 1.000 0.000
#> SRR037220     1  0.0469      0.995 0.988 0.000 0.000 0.012
#> SRR037221     1  0.0469      0.995 0.988 0.000 0.000 0.012
#> SRR037222     1  0.0469      0.995 0.988 0.000 0.000 0.012
#> SRR037223     1  0.0469      0.995 0.988 0.000 0.000 0.012
#> SRR037224     1  0.0469      0.995 0.988 0.000 0.000 0.012
#> SRR037225     1  0.0469      0.995 0.988 0.000 0.000 0.012
#> SRR037226     1  0.0469      0.995 0.988 0.000 0.000 0.012

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> SRR037165     4  0.2338      0.832 0.000 0.112 0.000 0.884 0.004
#> SRR037166     4  0.2358      0.838 0.000 0.104 0.000 0.888 0.008
#> SRR037167     4  0.0000      0.891 0.000 0.000 0.000 1.000 0.000
#> SRR037168     4  0.0404      0.890 0.000 0.000 0.000 0.988 0.012
#> SRR037169     4  0.0404      0.890 0.000 0.000 0.000 0.988 0.012
#> SRR037170     4  0.0404      0.890 0.000 0.000 0.000 0.988 0.012
#> SRR037171     2  0.0000      0.937 0.000 1.000 0.000 0.000 0.000
#> SRR037172     2  0.0000      0.937 0.000 1.000 0.000 0.000 0.000
#> SRR037173     2  0.0162      0.938 0.000 0.996 0.000 0.004 0.000
#> SRR037174     2  0.0290      0.939 0.000 0.992 0.000 0.008 0.000
#> SRR037175     2  0.0000      0.937 0.000 1.000 0.000 0.000 0.000
#> SRR037176     2  0.0290      0.935 0.000 0.992 0.000 0.000 0.008
#> SRR037177     2  0.3612      0.740 0.000 0.764 0.000 0.228 0.008
#> SRR037182     3  0.0912      0.831 0.000 0.000 0.972 0.012 0.016
#> SRR037183     3  0.1626      0.793 0.000 0.000 0.940 0.044 0.016
#> SRR037184     2  0.0955      0.937 0.000 0.968 0.000 0.028 0.004
#> SRR037185     2  0.3353      0.781 0.000 0.796 0.000 0.196 0.008
#> SRR037186     2  0.1571      0.923 0.000 0.936 0.000 0.060 0.004
#> SRR037187     2  0.1430      0.927 0.000 0.944 0.000 0.052 0.004
#> SRR037188     3  0.0566      0.842 0.000 0.000 0.984 0.004 0.012
#> SRR037178     3  0.0000      0.849 0.000 0.000 1.000 0.000 0.000
#> SRR037179     3  0.0000      0.849 0.000 0.000 1.000 0.000 0.000
#> SRR037180     3  0.0000      0.849 0.000 0.000 1.000 0.000 0.000
#> SRR037181     3  0.0000      0.849 0.000 0.000 1.000 0.000 0.000
#> SRR037189     2  0.1704      0.917 0.000 0.928 0.000 0.068 0.004
#> SRR037190     2  0.0404      0.939 0.000 0.988 0.000 0.012 0.000
#> SRR037191     2  0.0290      0.935 0.000 0.992 0.000 0.000 0.008
#> SRR037192     2  0.1205      0.933 0.000 0.956 0.000 0.040 0.004
#> SRR037193     5  0.6712      0.151 0.000 0.328 0.048 0.100 0.524
#> SRR037194     4  0.6497      0.438 0.000 0.252 0.016 0.556 0.176
#> SRR037195     4  0.4610      0.701 0.000 0.204 0.016 0.740 0.040
#> SRR037196     4  0.0290      0.891 0.000 0.000 0.000 0.992 0.008
#> SRR037197     4  0.0451      0.889 0.000 0.000 0.004 0.988 0.008
#> SRR037198     4  0.0290      0.891 0.000 0.000 0.000 0.992 0.008
#> SRR037199     1  0.0000      0.811 1.000 0.000 0.000 0.000 0.000
#> SRR037200     1  0.0000      0.811 1.000 0.000 0.000 0.000 0.000
#> SRR037201     1  0.0000      0.811 1.000 0.000 0.000 0.000 0.000
#> SRR037202     1  0.0000      0.811 1.000 0.000 0.000 0.000 0.000
#> SRR037203     1  0.0000      0.811 1.000 0.000 0.000 0.000 0.000
#> SRR037204     1  0.0000      0.811 1.000 0.000 0.000 0.000 0.000
#> SRR037205     1  0.0000      0.811 1.000 0.000 0.000 0.000 0.000
#> SRR037206     3  0.4283     -0.197 0.000 0.000 0.544 0.000 0.456
#> SRR037207     3  0.4304     -0.293 0.000 0.000 0.516 0.000 0.484
#> SRR037208     3  0.0404      0.843 0.000 0.000 0.988 0.000 0.012
#> SRR037209     3  0.0290      0.845 0.000 0.000 0.992 0.000 0.008
#> SRR037210     3  0.4278     -0.181 0.000 0.000 0.548 0.000 0.452
#> SRR037211     5  0.4451     -0.237 0.000 0.004 0.492 0.000 0.504
#> SRR037212     3  0.0290      0.846 0.000 0.000 0.992 0.000 0.008
#> SRR037213     3  0.0290      0.846 0.000 0.000 0.992 0.000 0.008
#> SRR037219     3  0.0579      0.841 0.000 0.000 0.984 0.008 0.008
#> SRR037214     3  0.0000      0.849 0.000 0.000 1.000 0.000 0.000
#> SRR037215     3  0.0290      0.845 0.000 0.000 0.992 0.000 0.008
#> SRR037216     3  0.4256     -0.129 0.000 0.000 0.564 0.000 0.436
#> SRR037217     3  0.0000      0.849 0.000 0.000 1.000 0.000 0.000
#> SRR037218     3  0.0000      0.849 0.000 0.000 1.000 0.000 0.000
#> SRR037220     1  0.4114      0.811 0.624 0.000 0.000 0.000 0.376
#> SRR037221     1  0.4114      0.811 0.624 0.000 0.000 0.000 0.376
#> SRR037222     1  0.4114      0.811 0.624 0.000 0.000 0.000 0.376
#> SRR037223     1  0.4114      0.811 0.624 0.000 0.000 0.000 0.376
#> SRR037224     1  0.4114      0.811 0.624 0.000 0.000 0.000 0.376
#> SRR037225     1  0.4114      0.811 0.624 0.000 0.000 0.000 0.376
#> SRR037226     1  0.4114      0.811 0.624 0.000 0.000 0.000 0.376

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR037165     4  0.0146     0.9302 0.000 0.000 0.000 0.996 0.000 0.004
#> SRR037166     4  0.0260     0.9303 0.000 0.000 0.000 0.992 0.000 0.008
#> SRR037167     4  0.0260     0.9288 0.000 0.000 0.000 0.992 0.000 0.008
#> SRR037168     4  0.0458     0.9269 0.000 0.000 0.000 0.984 0.000 0.016
#> SRR037169     4  0.0547     0.9252 0.000 0.000 0.000 0.980 0.000 0.020
#> SRR037170     4  0.0458     0.9269 0.000 0.000 0.000 0.984 0.000 0.016
#> SRR037171     2  0.0000     0.9967 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR037172     2  0.0000     0.9967 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR037173     2  0.0000     0.9967 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR037174     2  0.0000     0.9967 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR037175     2  0.0000     0.9967 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR037176     2  0.0000     0.9967 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR037177     2  0.0520     0.9880 0.000 0.984 0.000 0.008 0.000 0.008
#> SRR037182     3  0.0713     0.8668 0.000 0.000 0.972 0.000 0.000 0.028
#> SRR037183     3  0.0713     0.8668 0.000 0.000 0.972 0.000 0.000 0.028
#> SRR037184     2  0.0146     0.9962 0.000 0.996 0.000 0.000 0.000 0.004
#> SRR037185     2  0.0520     0.9880 0.000 0.984 0.000 0.008 0.000 0.008
#> SRR037186     2  0.0146     0.9962 0.000 0.996 0.000 0.000 0.000 0.004
#> SRR037187     2  0.0146     0.9962 0.000 0.996 0.000 0.000 0.000 0.004
#> SRR037188     3  0.0713     0.8668 0.000 0.000 0.972 0.000 0.000 0.028
#> SRR037178     3  0.0000     0.8823 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR037179     3  0.0000     0.8823 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR037180     3  0.0000     0.8823 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR037181     3  0.0000     0.8823 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR037189     2  0.0146     0.9962 0.000 0.996 0.000 0.000 0.000 0.004
#> SRR037190     2  0.0000     0.9967 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR037191     2  0.0000     0.9967 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR037192     2  0.0146     0.9962 0.000 0.996 0.000 0.000 0.000 0.004
#> SRR037193     6  0.3279     0.0917 0.000 0.000 0.000 0.176 0.028 0.796
#> SRR037194     4  0.3841     0.7305 0.000 0.000 0.000 0.716 0.028 0.256
#> SRR037195     4  0.2510     0.9019 0.000 0.000 0.000 0.872 0.028 0.100
#> SRR037196     4  0.2145     0.9163 0.000 0.000 0.000 0.900 0.028 0.072
#> SRR037197     4  0.2237     0.9152 0.000 0.000 0.000 0.896 0.036 0.068
#> SRR037198     4  0.2145     0.9163 0.000 0.000 0.000 0.900 0.028 0.072
#> SRR037199     1  0.0000     0.9993 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR037200     1  0.0000     0.9993 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR037201     1  0.0000     0.9993 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR037202     1  0.0000     0.9993 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR037203     1  0.0146     0.9955 0.996 0.000 0.000 0.000 0.004 0.000
#> SRR037204     1  0.0000     0.9993 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR037205     1  0.0000     0.9993 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR037206     3  0.3774    -0.2087 0.000 0.000 0.592 0.000 0.000 0.408
#> SRR037207     6  0.4262     0.3698 0.000 0.000 0.476 0.000 0.016 0.508
#> SRR037208     3  0.0260     0.8779 0.000 0.000 0.992 0.000 0.000 0.008
#> SRR037209     3  0.0260     0.8779 0.000 0.000 0.992 0.000 0.000 0.008
#> SRR037210     3  0.3838    -0.3601 0.000 0.000 0.552 0.000 0.000 0.448
#> SRR037211     6  0.4234     0.4405 0.000 0.000 0.440 0.000 0.016 0.544
#> SRR037212     3  0.0363     0.8781 0.000 0.000 0.988 0.000 0.000 0.012
#> SRR037213     3  0.0363     0.8781 0.000 0.000 0.988 0.000 0.000 0.012
#> SRR037219     3  0.0458     0.8758 0.000 0.000 0.984 0.000 0.000 0.016
#> SRR037214     3  0.0000     0.8823 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR037215     3  0.0146     0.8804 0.000 0.000 0.996 0.000 0.000 0.004
#> SRR037216     3  0.3706    -0.0925 0.000 0.000 0.620 0.000 0.000 0.380
#> SRR037217     3  0.0000     0.8823 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR037218     3  0.0000     0.8823 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR037220     5  0.1814     1.0000 0.100 0.000 0.000 0.000 0.900 0.000
#> SRR037221     5  0.1814     1.0000 0.100 0.000 0.000 0.000 0.900 0.000
#> SRR037222     5  0.1814     1.0000 0.100 0.000 0.000 0.000 0.900 0.000
#> SRR037223     5  0.1814     1.0000 0.100 0.000 0.000 0.000 0.900 0.000
#> SRR037224     5  0.1814     1.0000 0.100 0.000 0.000 0.000 0.900 0.000
#> SRR037225     5  0.1814     1.0000 0.100 0.000 0.000 0.000 0.900 0.000
#> SRR037226     5  0.1814     1.0000 0.100 0.000 0.000 0.000 0.900 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 15332 rows and 62 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#>   Subgroups are detected by 'hclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 6.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk ATC-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.458           0.818       0.877         0.4424 0.526   0.526
#> 3 3 0.746           0.869       0.938         0.4377 0.821   0.660
#> 4 4 0.770           0.835       0.889         0.1377 0.930   0.799
#> 5 5 0.876           0.746       0.870         0.0709 0.920   0.730
#> 6 6 0.949           0.903       0.922         0.0256 0.960   0.834

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

suggest_best_k(res)
#> [1] 6

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
#> SRR037165     2   0.000     0.8552 0.000 1.000
#> SRR037166     2   0.000     0.8552 0.000 1.000
#> SRR037167     2   0.943    -0.0207 0.360 0.640
#> SRR037168     1   0.753     0.9429 0.784 0.216
#> SRR037169     1   0.753     0.9429 0.784 0.216
#> SRR037170     1   0.753     0.9429 0.784 0.216
#> SRR037171     2   0.753     0.7844 0.216 0.784
#> SRR037172     2   0.753     0.7844 0.216 0.784
#> SRR037173     2   0.753     0.7844 0.216 0.784
#> SRR037174     2   0.753     0.7844 0.216 0.784
#> SRR037175     2   0.753     0.7844 0.216 0.784
#> SRR037176     2   0.753     0.7844 0.216 0.784
#> SRR037177     2   0.943    -0.0207 0.360 0.640
#> SRR037182     1   0.814     0.9403 0.748 0.252
#> SRR037183     1   0.814     0.9403 0.748 0.252
#> SRR037184     2   0.000     0.8552 0.000 1.000
#> SRR037185     2   0.943    -0.0207 0.360 0.640
#> SRR037186     2   0.000     0.8552 0.000 1.000
#> SRR037187     2   0.000     0.8552 0.000 1.000
#> SRR037188     1   0.814     0.9403 0.748 0.252
#> SRR037178     2   0.000     0.8552 0.000 1.000
#> SRR037179     2   0.000     0.8552 0.000 1.000
#> SRR037180     2   0.000     0.8552 0.000 1.000
#> SRR037181     2   0.000     0.8552 0.000 1.000
#> SRR037189     2   0.000     0.8552 0.000 1.000
#> SRR037190     2   0.753     0.7844 0.216 0.784
#> SRR037191     2   0.753     0.7844 0.216 0.784
#> SRR037192     2   0.000     0.8552 0.000 1.000
#> SRR037193     2   0.000     0.8552 0.000 1.000
#> SRR037194     2   0.000     0.8552 0.000 1.000
#> SRR037195     2   0.000     0.8552 0.000 1.000
#> SRR037196     1   0.814     0.9403 0.748 0.252
#> SRR037197     1   0.753     0.9429 0.784 0.216
#> SRR037198     1   0.814     0.9403 0.748 0.252
#> SRR037199     2   0.000     0.8552 0.000 1.000
#> SRR037200     2   0.000     0.8552 0.000 1.000
#> SRR037201     2   0.000     0.8552 0.000 1.000
#> SRR037202     1   0.753     0.9429 0.784 0.216
#> SRR037203     1   0.753     0.9429 0.784 0.216
#> SRR037204     1   0.753     0.9429 0.784 0.216
#> SRR037205     1   0.753     0.9429 0.784 0.216
#> SRR037206     2   0.753     0.7844 0.216 0.784
#> SRR037207     2   0.753     0.7844 0.216 0.784
#> SRR037208     2   0.000     0.8552 0.000 1.000
#> SRR037209     2   0.000     0.8552 0.000 1.000
#> SRR037210     2   0.753     0.7844 0.216 0.784
#> SRR037211     2   0.753     0.7844 0.216 0.784
#> SRR037212     1   0.814     0.9403 0.748 0.252
#> SRR037213     1   0.814     0.9403 0.748 0.252
#> SRR037219     1   0.814     0.9403 0.748 0.252
#> SRR037214     1   0.814     0.9403 0.748 0.252
#> SRR037215     2   0.000     0.8552 0.000 1.000
#> SRR037216     2   0.753     0.7844 0.216 0.784
#> SRR037217     2   0.000     0.8552 0.000 1.000
#> SRR037218     2   0.000     0.8552 0.000 1.000
#> SRR037220     2   0.000     0.8552 0.000 1.000
#> SRR037221     1   0.980     0.6903 0.584 0.416
#> SRR037222     1   0.980     0.6903 0.584 0.416
#> SRR037223     1   0.753     0.9429 0.784 0.216
#> SRR037224     1   0.753     0.9429 0.784 0.216
#> SRR037225     1   0.980     0.6903 0.584 0.416
#> SRR037226     1   0.753     0.9429 0.784 0.216

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2 p3
#> SRR037165     2   0.000      0.946 0.000 1.000  0
#> SRR037166     2   0.000      0.946 0.000 1.000  0
#> SRR037167     2   0.595      0.309 0.360 0.640  0
#> SRR037168     1   0.000      0.850 1.000 0.000  0
#> SRR037169     1   0.000      0.850 1.000 0.000  0
#> SRR037170     1   0.000      0.850 1.000 0.000  0
#> SRR037171     3   0.000      1.000 0.000 0.000  1
#> SRR037172     3   0.000      1.000 0.000 0.000  1
#> SRR037173     3   0.000      1.000 0.000 0.000  1
#> SRR037174     3   0.000      1.000 0.000 0.000  1
#> SRR037175     3   0.000      1.000 0.000 0.000  1
#> SRR037176     3   0.000      1.000 0.000 0.000  1
#> SRR037177     2   0.595      0.309 0.360 0.640  0
#> SRR037182     1   0.418      0.838 0.828 0.172  0
#> SRR037183     1   0.418      0.838 0.828 0.172  0
#> SRR037184     2   0.000      0.946 0.000 1.000  0
#> SRR037185     2   0.595      0.309 0.360 0.640  0
#> SRR037186     2   0.000      0.946 0.000 1.000  0
#> SRR037187     2   0.000      0.946 0.000 1.000  0
#> SRR037188     1   0.418      0.838 0.828 0.172  0
#> SRR037178     2   0.000      0.946 0.000 1.000  0
#> SRR037179     2   0.000      0.946 0.000 1.000  0
#> SRR037180     2   0.000      0.946 0.000 1.000  0
#> SRR037181     2   0.000      0.946 0.000 1.000  0
#> SRR037189     2   0.000      0.946 0.000 1.000  0
#> SRR037190     3   0.000      1.000 0.000 0.000  1
#> SRR037191     3   0.000      1.000 0.000 0.000  1
#> SRR037192     2   0.000      0.946 0.000 1.000  0
#> SRR037193     2   0.000      0.946 0.000 1.000  0
#> SRR037194     2   0.000      0.946 0.000 1.000  0
#> SRR037195     2   0.000      0.946 0.000 1.000  0
#> SRR037196     1   0.418      0.838 0.828 0.172  0
#> SRR037197     1   0.000      0.850 1.000 0.000  0
#> SRR037198     1   0.418      0.838 0.828 0.172  0
#> SRR037199     2   0.000      0.946 0.000 1.000  0
#> SRR037200     2   0.000      0.946 0.000 1.000  0
#> SRR037201     2   0.000      0.946 0.000 1.000  0
#> SRR037202     1   0.000      0.850 1.000 0.000  0
#> SRR037203     1   0.000      0.850 1.000 0.000  0
#> SRR037204     1   0.000      0.850 1.000 0.000  0
#> SRR037205     1   0.000      0.850 1.000 0.000  0
#> SRR037206     3   0.000      1.000 0.000 0.000  1
#> SRR037207     3   0.000      1.000 0.000 0.000  1
#> SRR037208     2   0.000      0.946 0.000 1.000  0
#> SRR037209     2   0.000      0.946 0.000 1.000  0
#> SRR037210     3   0.000      1.000 0.000 0.000  1
#> SRR037211     3   0.000      1.000 0.000 0.000  1
#> SRR037212     1   0.418      0.838 0.828 0.172  0
#> SRR037213     1   0.418      0.838 0.828 0.172  0
#> SRR037219     1   0.418      0.838 0.828 0.172  0
#> SRR037214     1   0.418      0.838 0.828 0.172  0
#> SRR037215     2   0.000      0.946 0.000 1.000  0
#> SRR037216     3   0.000      1.000 0.000 0.000  1
#> SRR037217     2   0.000      0.946 0.000 1.000  0
#> SRR037218     2   0.000      0.946 0.000 1.000  0
#> SRR037220     2   0.000      0.946 0.000 1.000  0
#> SRR037221     1   0.617      0.428 0.588 0.412  0
#> SRR037222     1   0.617      0.428 0.588 0.412  0
#> SRR037223     1   0.000      0.850 1.000 0.000  0
#> SRR037224     1   0.000      0.850 1.000 0.000  0
#> SRR037225     1   0.617      0.428 0.588 0.412  0
#> SRR037226     1   0.000      0.850 1.000 0.000  0

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1 p2    p3    p4
#> SRR037165     3   0.000      0.867 0.000  0 1.000 0.000
#> SRR037166     3   0.000      0.867 0.000  0 1.000 0.000
#> SRR037167     3   0.485      0.204 0.000  0 0.600 0.400
#> SRR037168     1   0.000      0.972 1.000  0 0.000 0.000
#> SRR037169     1   0.000      0.972 1.000  0 0.000 0.000
#> SRR037170     1   0.000      0.972 1.000  0 0.000 0.000
#> SRR037171     2   0.000      1.000 0.000  1 0.000 0.000
#> SRR037172     2   0.000      1.000 0.000  1 0.000 0.000
#> SRR037173     2   0.000      1.000 0.000  1 0.000 0.000
#> SRR037174     2   0.000      1.000 0.000  1 0.000 0.000
#> SRR037175     2   0.000      1.000 0.000  1 0.000 0.000
#> SRR037176     2   0.000      1.000 0.000  1 0.000 0.000
#> SRR037177     3   0.485      0.204 0.000  0 0.600 0.400
#> SRR037182     4   0.675      0.834 0.280  0 0.132 0.588
#> SRR037183     4   0.675      0.834 0.280  0 0.132 0.588
#> SRR037184     3   0.000      0.867 0.000  0 1.000 0.000
#> SRR037185     3   0.485      0.204 0.000  0 0.600 0.400
#> SRR037186     3   0.000      0.867 0.000  0 1.000 0.000
#> SRR037187     3   0.000      0.867 0.000  0 1.000 0.000
#> SRR037188     4   0.675      0.834 0.280  0 0.132 0.588
#> SRR037178     3   0.000      0.867 0.000  0 1.000 0.000
#> SRR037179     3   0.000      0.867 0.000  0 1.000 0.000
#> SRR037180     3   0.000      0.867 0.000  0 1.000 0.000
#> SRR037181     3   0.000      0.867 0.000  0 1.000 0.000
#> SRR037189     3   0.000      0.867 0.000  0 1.000 0.000
#> SRR037190     2   0.000      1.000 0.000  1 0.000 0.000
#> SRR037191     2   0.000      1.000 0.000  1 0.000 0.000
#> SRR037192     3   0.000      0.867 0.000  0 1.000 0.000
#> SRR037193     3   0.000      0.867 0.000  0 1.000 0.000
#> SRR037194     3   0.000      0.867 0.000  0 1.000 0.000
#> SRR037195     3   0.000      0.867 0.000  0 1.000 0.000
#> SRR037196     4   0.675      0.834 0.280  0 0.132 0.588
#> SRR037197     1   0.000      0.972 1.000  0 0.000 0.000
#> SRR037198     4   0.675      0.834 0.280  0 0.132 0.588
#> SRR037199     3   0.489      0.500 0.000  0 0.588 0.412
#> SRR037200     3   0.489      0.500 0.000  0 0.588 0.412
#> SRR037201     3   0.489      0.500 0.000  0 0.588 0.412
#> SRR037202     1   0.172      0.920 0.936  0 0.000 0.064
#> SRR037203     1   0.000      0.972 1.000  0 0.000 0.000
#> SRR037204     1   0.172      0.920 0.936  0 0.000 0.064
#> SRR037205     1   0.172      0.920 0.936  0 0.000 0.064
#> SRR037206     2   0.000      1.000 0.000  1 0.000 0.000
#> SRR037207     2   0.000      1.000 0.000  1 0.000 0.000
#> SRR037208     3   0.000      0.867 0.000  0 1.000 0.000
#> SRR037209     3   0.000      0.867 0.000  0 1.000 0.000
#> SRR037210     2   0.000      1.000 0.000  1 0.000 0.000
#> SRR037211     2   0.000      1.000 0.000  1 0.000 0.000
#> SRR037212     4   0.675      0.834 0.280  0 0.132 0.588
#> SRR037213     4   0.675      0.834 0.280  0 0.132 0.588
#> SRR037219     4   0.675      0.834 0.280  0 0.132 0.588
#> SRR037214     4   0.675      0.834 0.280  0 0.132 0.588
#> SRR037215     3   0.000      0.867 0.000  0 1.000 0.000
#> SRR037216     2   0.000      1.000 0.000  1 0.000 0.000
#> SRR037217     3   0.000      0.867 0.000  0 1.000 0.000
#> SRR037218     3   0.000      0.867 0.000  0 1.000 0.000
#> SRR037220     3   0.489      0.500 0.000  0 0.588 0.412
#> SRR037221     4   0.121      0.545 0.040  0 0.000 0.960
#> SRR037222     4   0.121      0.545 0.040  0 0.000 0.960
#> SRR037223     1   0.000      0.972 1.000  0 0.000 0.000
#> SRR037224     1   0.000      0.972 1.000  0 0.000 0.000
#> SRR037225     4   0.121      0.545 0.040  0 0.000 0.960
#> SRR037226     1   0.000      0.972 1.000  0 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1 p2    p3    p4    p5
#> SRR037165     4   0.000      0.934 0.000  0 0.000 1.000 0.000
#> SRR037166     4   0.000      0.934 0.000  0 0.000 1.000 0.000
#> SRR037167     4   0.561      0.362 0.000  0 0.104 0.600 0.296
#> SRR037168     1   0.368      0.727 0.720  0 0.280 0.000 0.000
#> SRR037169     1   0.368      0.727 0.720  0 0.280 0.000 0.000
#> SRR037170     1   0.368      0.727 0.720  0 0.280 0.000 0.000
#> SRR037171     2   0.000      1.000 0.000  1 0.000 0.000 0.000
#> SRR037172     2   0.000      1.000 0.000  1 0.000 0.000 0.000
#> SRR037173     2   0.000      1.000 0.000  1 0.000 0.000 0.000
#> SRR037174     2   0.000      1.000 0.000  1 0.000 0.000 0.000
#> SRR037175     2   0.000      1.000 0.000  1 0.000 0.000 0.000
#> SRR037176     2   0.000      1.000 0.000  1 0.000 0.000 0.000
#> SRR037177     4   0.561      0.362 0.000  0 0.104 0.600 0.296
#> SRR037182     3   0.430      0.395 0.000  0 0.516 0.000 0.484
#> SRR037183     3   0.430      0.395 0.000  0 0.516 0.000 0.484
#> SRR037184     4   0.000      0.934 0.000  0 0.000 1.000 0.000
#> SRR037185     4   0.561      0.362 0.000  0 0.104 0.600 0.296
#> SRR037186     4   0.000      0.934 0.000  0 0.000 1.000 0.000
#> SRR037187     4   0.000      0.934 0.000  0 0.000 1.000 0.000
#> SRR037188     3   0.430      0.395 0.000  0 0.516 0.000 0.484
#> SRR037178     4   0.000      0.934 0.000  0 0.000 1.000 0.000
#> SRR037179     4   0.000      0.934 0.000  0 0.000 1.000 0.000
#> SRR037180     4   0.000      0.934 0.000  0 0.000 1.000 0.000
#> SRR037181     4   0.000      0.934 0.000  0 0.000 1.000 0.000
#> SRR037189     4   0.000      0.934 0.000  0 0.000 1.000 0.000
#> SRR037190     2   0.000      1.000 0.000  1 0.000 0.000 0.000
#> SRR037191     2   0.000      1.000 0.000  1 0.000 0.000 0.000
#> SRR037192     4   0.000      0.934 0.000  0 0.000 1.000 0.000
#> SRR037193     4   0.000      0.934 0.000  0 0.000 1.000 0.000
#> SRR037194     4   0.000      0.934 0.000  0 0.000 1.000 0.000
#> SRR037195     4   0.000      0.934 0.000  0 0.000 1.000 0.000
#> SRR037196     3   0.430      0.395 0.000  0 0.516 0.000 0.484
#> SRR037197     1   0.368      0.727 0.720  0 0.280 0.000 0.000
#> SRR037198     3   0.430      0.395 0.000  0 0.516 0.000 0.484
#> SRR037199     3   0.591     -0.201 0.000  0 0.484 0.104 0.412
#> SRR037200     3   0.591     -0.201 0.000  0 0.484 0.104 0.412
#> SRR037201     3   0.591     -0.201 0.000  0 0.484 0.104 0.412
#> SRR037202     1   0.207      0.801 0.896  0 0.000 0.000 0.104
#> SRR037203     1   0.000      0.835 1.000  0 0.000 0.000 0.000
#> SRR037204     1   0.207      0.801 0.896  0 0.000 0.000 0.104
#> SRR037205     1   0.207      0.801 0.896  0 0.000 0.000 0.104
#> SRR037206     2   0.000      1.000 0.000  1 0.000 0.000 0.000
#> SRR037207     2   0.000      1.000 0.000  1 0.000 0.000 0.000
#> SRR037208     4   0.000      0.934 0.000  0 0.000 1.000 0.000
#> SRR037209     4   0.000      0.934 0.000  0 0.000 1.000 0.000
#> SRR037210     2   0.000      1.000 0.000  1 0.000 0.000 0.000
#> SRR037211     2   0.000      1.000 0.000  1 0.000 0.000 0.000
#> SRR037212     3   0.430      0.395 0.000  0 0.516 0.000 0.484
#> SRR037213     3   0.430      0.395 0.000  0 0.516 0.000 0.484
#> SRR037219     3   0.430      0.395 0.000  0 0.516 0.000 0.484
#> SRR037214     3   0.430      0.395 0.000  0 0.516 0.000 0.484
#> SRR037215     4   0.000      0.934 0.000  0 0.000 1.000 0.000
#> SRR037216     2   0.000      1.000 0.000  1 0.000 0.000 0.000
#> SRR037217     4   0.000      0.934 0.000  0 0.000 1.000 0.000
#> SRR037218     4   0.000      0.934 0.000  0 0.000 1.000 0.000
#> SRR037220     3   0.591     -0.201 0.000  0 0.484 0.104 0.412
#> SRR037221     5   0.000      1.000 0.000  0 0.000 0.000 1.000
#> SRR037222     5   0.000      1.000 0.000  0 0.000 0.000 1.000
#> SRR037223     1   0.000      0.835 1.000  0 0.000 0.000 0.000
#> SRR037224     1   0.000      0.835 1.000  0 0.000 0.000 0.000
#> SRR037225     5   0.000      1.000 0.000  0 0.000 0.000 1.000
#> SRR037226     1   0.000      0.835 1.000  0 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1 p2  p3    p4    p5    p6
#> SRR037165     3   0.000      0.936 0.000  0 1.0 0.000 0.000 0.000
#> SRR037166     3   0.000      0.936 0.000  0 1.0 0.000 0.000 0.000
#> SRR037167     3   0.376      0.400 0.000  0 0.6 0.000 0.000 0.400
#> SRR037168     4   0.000      1.000 0.000  0 0.0 1.000 0.000 0.000
#> SRR037169     4   0.000      1.000 0.000  0 0.0 1.000 0.000 0.000
#> SRR037170     4   0.000      1.000 0.000  0 0.0 1.000 0.000 0.000
#> SRR037171     2   0.000      1.000 0.000  1 0.0 0.000 0.000 0.000
#> SRR037172     2   0.000      1.000 0.000  1 0.0 0.000 0.000 0.000
#> SRR037173     2   0.000      1.000 0.000  1 0.0 0.000 0.000 0.000
#> SRR037174     2   0.000      1.000 0.000  1 0.0 0.000 0.000 0.000
#> SRR037175     2   0.000      1.000 0.000  1 0.0 0.000 0.000 0.000
#> SRR037176     2   0.000      1.000 0.000  1 0.0 0.000 0.000 0.000
#> SRR037177     3   0.376      0.400 0.000  0 0.6 0.000 0.000 0.400
#> SRR037182     6   0.000      1.000 0.000  0 0.0 0.000 0.000 1.000
#> SRR037183     6   0.000      1.000 0.000  0 0.0 0.000 0.000 1.000
#> SRR037184     3   0.000      0.936 0.000  0 1.0 0.000 0.000 0.000
#> SRR037185     3   0.376      0.400 0.000  0 0.6 0.000 0.000 0.400
#> SRR037186     3   0.000      0.936 0.000  0 1.0 0.000 0.000 0.000
#> SRR037187     3   0.000      0.936 0.000  0 1.0 0.000 0.000 0.000
#> SRR037188     6   0.000      1.000 0.000  0 0.0 0.000 0.000 1.000
#> SRR037178     3   0.000      0.936 0.000  0 1.0 0.000 0.000 0.000
#> SRR037179     3   0.000      0.936 0.000  0 1.0 0.000 0.000 0.000
#> SRR037180     3   0.000      0.936 0.000  0 1.0 0.000 0.000 0.000
#> SRR037181     3   0.000      0.936 0.000  0 1.0 0.000 0.000 0.000
#> SRR037189     3   0.000      0.936 0.000  0 1.0 0.000 0.000 0.000
#> SRR037190     2   0.000      1.000 0.000  1 0.0 0.000 0.000 0.000
#> SRR037191     2   0.000      1.000 0.000  1 0.0 0.000 0.000 0.000
#> SRR037192     3   0.000      0.936 0.000  0 1.0 0.000 0.000 0.000
#> SRR037193     3   0.000      0.936 0.000  0 1.0 0.000 0.000 0.000
#> SRR037194     3   0.000      0.936 0.000  0 1.0 0.000 0.000 0.000
#> SRR037195     3   0.000      0.936 0.000  0 1.0 0.000 0.000 0.000
#> SRR037196     6   0.000      1.000 0.000  0 0.0 0.000 0.000 1.000
#> SRR037197     4   0.000      1.000 0.000  0 0.0 1.000 0.000 0.000
#> SRR037198     6   0.000      1.000 0.000  0 0.0 0.000 0.000 1.000
#> SRR037199     5   0.000      0.729 0.000  0 0.0 0.000 1.000 0.000
#> SRR037200     5   0.000      0.729 0.000  0 0.0 0.000 1.000 0.000
#> SRR037201     5   0.000      0.729 0.000  0 0.0 0.000 1.000 0.000
#> SRR037202     1   0.339      0.878 0.704  0 0.0 0.296 0.000 0.000
#> SRR037203     1   0.376      0.902 0.600  0 0.0 0.400 0.000 0.000
#> SRR037204     1   0.339      0.878 0.704  0 0.0 0.296 0.000 0.000
#> SRR037205     1   0.339      0.878 0.704  0 0.0 0.296 0.000 0.000
#> SRR037206     2   0.000      1.000 0.000  1 0.0 0.000 0.000 0.000
#> SRR037207     2   0.000      1.000 0.000  1 0.0 0.000 0.000 0.000
#> SRR037208     3   0.000      0.936 0.000  0 1.0 0.000 0.000 0.000
#> SRR037209     3   0.000      0.936 0.000  0 1.0 0.000 0.000 0.000
#> SRR037210     2   0.000      1.000 0.000  1 0.0 0.000 0.000 0.000
#> SRR037211     2   0.000      1.000 0.000  1 0.0 0.000 0.000 0.000
#> SRR037212     6   0.000      1.000 0.000  0 0.0 0.000 0.000 1.000
#> SRR037213     6   0.000      1.000 0.000  0 0.0 0.000 0.000 1.000
#> SRR037219     6   0.000      1.000 0.000  0 0.0 0.000 0.000 1.000
#> SRR037214     6   0.000      1.000 0.000  0 0.0 0.000 0.000 1.000
#> SRR037215     3   0.000      0.936 0.000  0 1.0 0.000 0.000 0.000
#> SRR037216     2   0.000      1.000 0.000  1 0.0 0.000 0.000 0.000
#> SRR037217     3   0.000      0.936 0.000  0 1.0 0.000 0.000 0.000
#> SRR037218     3   0.000      0.936 0.000  0 1.0 0.000 0.000 0.000
#> SRR037220     5   0.000      0.729 0.000  0 0.0 0.000 1.000 0.000
#> SRR037221     5   0.584      0.625 0.400  0 0.0 0.000 0.412 0.188
#> SRR037222     5   0.584      0.625 0.400  0 0.0 0.000 0.412 0.188
#> SRR037223     1   0.376      0.902 0.600  0 0.0 0.400 0.000 0.000
#> SRR037224     1   0.376      0.902 0.600  0 0.0 0.400 0.000 0.000
#> SRR037225     5   0.584      0.625 0.400  0 0.0 0.000 0.412 0.188
#> SRR037226     1   0.376      0.902 0.600  0 0.0 0.400 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-hclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-hclust-collect-classes

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


ATC:kmeans**

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

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

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

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

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

collect_plots(res)

plot of chunk ATC-kmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.5066 0.494   0.494
#> 3 3 0.466           0.531       0.728         0.2739 0.737   0.513
#> 4 4 0.537           0.502       0.682         0.1400 0.825   0.533
#> 5 5 0.612           0.655       0.685         0.0677 0.867   0.549
#> 6 6 0.723           0.689       0.709         0.0463 0.931   0.688

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
#> SRR037165     2       0          1  0  1
#> SRR037166     2       0          1  0  1
#> SRR037167     1       0          1  1  0
#> SRR037168     1       0          1  1  0
#> SRR037169     1       0          1  1  0
#> SRR037170     1       0          1  1  0
#> SRR037171     2       0          1  0  1
#> SRR037172     2       0          1  0  1
#> SRR037173     2       0          1  0  1
#> SRR037174     2       0          1  0  1
#> SRR037175     2       0          1  0  1
#> SRR037176     2       0          1  0  1
#> SRR037177     1       0          1  1  0
#> SRR037182     1       0          1  1  0
#> SRR037183     1       0          1  1  0
#> SRR037184     2       0          1  0  1
#> SRR037185     1       0          1  1  0
#> SRR037186     2       0          1  0  1
#> SRR037187     2       0          1  0  1
#> SRR037188     1       0          1  1  0
#> SRR037178     2       0          1  0  1
#> SRR037179     2       0          1  0  1
#> SRR037180     2       0          1  0  1
#> SRR037181     2       0          1  0  1
#> SRR037189     2       0          1  0  1
#> SRR037190     2       0          1  0  1
#> SRR037191     2       0          1  0  1
#> SRR037192     2       0          1  0  1
#> SRR037193     2       0          1  0  1
#> SRR037194     2       0          1  0  1
#> SRR037195     2       0          1  0  1
#> SRR037196     1       0          1  1  0
#> SRR037197     1       0          1  1  0
#> SRR037198     1       0          1  1  0
#> SRR037199     2       0          1  0  1
#> SRR037200     1       0          1  1  0
#> SRR037201     1       0          1  1  0
#> SRR037202     1       0          1  1  0
#> SRR037203     1       0          1  1  0
#> SRR037204     1       0          1  1  0
#> SRR037205     1       0          1  1  0
#> SRR037206     2       0          1  0  1
#> SRR037207     2       0          1  0  1
#> SRR037208     2       0          1  0  1
#> SRR037209     2       0          1  0  1
#> SRR037210     2       0          1  0  1
#> SRR037211     2       0          1  0  1
#> SRR037212     1       0          1  1  0
#> SRR037213     1       0          1  1  0
#> SRR037219     1       0          1  1  0
#> SRR037214     1       0          1  1  0
#> SRR037215     2       0          1  0  1
#> SRR037216     2       0          1  0  1
#> SRR037217     2       0          1  0  1
#> SRR037218     2       0          1  0  1
#> SRR037220     1       0          1  1  0
#> SRR037221     1       0          1  1  0
#> SRR037222     1       0          1  1  0
#> SRR037223     1       0          1  1  0
#> SRR037224     1       0          1  1  0
#> SRR037225     1       0          1  1  0
#> SRR037226     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
#> SRR037165     2  0.6286     0.2853 0.000 0.536 0.464
#> SRR037166     2  0.6225     0.3578 0.000 0.568 0.432
#> SRR037167     2  0.4750     0.2844 0.216 0.784 0.000
#> SRR037168     1  0.4605     0.7319 0.796 0.204 0.000
#> SRR037169     1  0.4605     0.7319 0.796 0.204 0.000
#> SRR037170     1  0.4605     0.7319 0.796 0.204 0.000
#> SRR037171     3  0.0000     0.6990 0.000 0.000 1.000
#> SRR037172     3  0.0000     0.6990 0.000 0.000 1.000
#> SRR037173     3  0.0000     0.6990 0.000 0.000 1.000
#> SRR037174     3  0.0000     0.6990 0.000 0.000 1.000
#> SRR037175     3  0.0000     0.6990 0.000 0.000 1.000
#> SRR037176     3  0.0000     0.6990 0.000 0.000 1.000
#> SRR037177     2  0.5075     0.4932 0.068 0.836 0.096
#> SRR037182     1  0.6302     0.5552 0.520 0.480 0.000
#> SRR037183     1  0.5810     0.6911 0.664 0.336 0.000
#> SRR037184     3  0.6111     0.1304 0.000 0.396 0.604
#> SRR037185     2  0.5075     0.4932 0.068 0.836 0.096
#> SRR037186     2  0.6308     0.2849 0.000 0.508 0.492
#> SRR037187     2  0.6308     0.2849 0.000 0.508 0.492
#> SRR037188     2  0.5465     0.0557 0.288 0.712 0.000
#> SRR037178     3  0.6267     0.4989 0.000 0.452 0.548
#> SRR037179     3  0.6267     0.4989 0.000 0.452 0.548
#> SRR037180     3  0.6267     0.4989 0.000 0.452 0.548
#> SRR037181     3  0.6267     0.4989 0.000 0.452 0.548
#> SRR037189     2  0.6008     0.4473 0.000 0.628 0.372
#> SRR037190     3  0.0000     0.6990 0.000 0.000 1.000
#> SRR037191     3  0.0000     0.6990 0.000 0.000 1.000
#> SRR037192     2  0.6308     0.2849 0.000 0.508 0.492
#> SRR037193     3  0.5948     0.3951 0.000 0.360 0.640
#> SRR037194     2  0.6235     0.3128 0.000 0.564 0.436
#> SRR037195     2  0.6168     0.3614 0.000 0.588 0.412
#> SRR037196     2  0.4796     0.2740 0.220 0.780 0.000
#> SRR037197     1  0.4605     0.7319 0.796 0.204 0.000
#> SRR037198     2  0.4750     0.2844 0.216 0.784 0.000
#> SRR037199     2  0.6109     0.4374 0.192 0.760 0.048
#> SRR037200     1  0.6291     0.2731 0.532 0.468 0.000
#> SRR037201     1  0.6291     0.2731 0.532 0.468 0.000
#> SRR037202     1  0.0000     0.7593 1.000 0.000 0.000
#> SRR037203     1  0.0237     0.7605 0.996 0.004 0.000
#> SRR037204     1  0.0237     0.7575 0.996 0.004 0.000
#> SRR037205     1  0.0000     0.7593 1.000 0.000 0.000
#> SRR037206     3  0.3879     0.6926 0.000 0.152 0.848
#> SRR037207     3  0.3879     0.6926 0.000 0.152 0.848
#> SRR037208     3  0.6267     0.4989 0.000 0.452 0.548
#> SRR037209     3  0.6267     0.4989 0.000 0.452 0.548
#> SRR037210     3  0.3879     0.6926 0.000 0.152 0.848
#> SRR037211     3  0.3879     0.6926 0.000 0.152 0.848
#> SRR037212     1  0.6302     0.5552 0.520 0.480 0.000
#> SRR037213     1  0.6302     0.5552 0.520 0.480 0.000
#> SRR037219     1  0.5760     0.6966 0.672 0.328 0.000
#> SRR037214     2  0.4235     0.3660 0.176 0.824 0.000
#> SRR037215     3  0.6267     0.4989 0.000 0.452 0.548
#> SRR037216     3  0.3879     0.6926 0.000 0.152 0.848
#> SRR037217     2  0.5678     0.2587 0.000 0.684 0.316
#> SRR037218     2  0.5678     0.2587 0.000 0.684 0.316
#> SRR037220     2  0.6026     0.1880 0.376 0.624 0.000
#> SRR037221     1  0.5431     0.6167 0.716 0.284 0.000
#> SRR037222     1  0.5431     0.6167 0.716 0.284 0.000
#> SRR037223     1  0.0237     0.7605 0.996 0.004 0.000
#> SRR037224     1  0.0237     0.7605 0.996 0.004 0.000
#> SRR037225     1  0.0237     0.7575 0.996 0.004 0.000
#> SRR037226     1  0.0237     0.7605 0.996 0.004 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> SRR037165     2  0.3367     0.7625 0.000 0.864 0.108 0.028
#> SRR037166     2  0.3404     0.7621 0.000 0.864 0.104 0.032
#> SRR037167     4  0.5231     0.5162 0.012 0.384 0.000 0.604
#> SRR037168     1  0.5047     0.5244 0.668 0.016 0.000 0.316
#> SRR037169     1  0.5026     0.5288 0.672 0.016 0.000 0.312
#> SRR037170     1  0.5047     0.5244 0.668 0.016 0.000 0.316
#> SRR037171     3  0.5056     0.5924 0.000 0.164 0.760 0.076
#> SRR037172     3  0.5056     0.5924 0.000 0.164 0.760 0.076
#> SRR037173     3  0.5384     0.5787 0.000 0.196 0.728 0.076
#> SRR037174     3  0.5384     0.5787 0.000 0.196 0.728 0.076
#> SRR037175     3  0.5056     0.5924 0.000 0.164 0.760 0.076
#> SRR037176     3  0.5056     0.5924 0.000 0.164 0.760 0.076
#> SRR037177     4  0.5137     0.4360 0.004 0.452 0.000 0.544
#> SRR037182     4  0.6442     0.5003 0.244 0.124 0.000 0.632
#> SRR037183     4  0.4964     0.2451 0.380 0.004 0.000 0.616
#> SRR037184     2  0.2466     0.7437 0.000 0.900 0.096 0.004
#> SRR037185     4  0.5137     0.4360 0.004 0.452 0.000 0.544
#> SRR037186     2  0.2281     0.7477 0.000 0.904 0.096 0.000
#> SRR037187     2  0.2281     0.7477 0.000 0.904 0.096 0.000
#> SRR037188     4  0.6352     0.5770 0.108 0.260 0.000 0.632
#> SRR037178     3  0.6407     0.1098 0.000 0.384 0.544 0.072
#> SRR037179     3  0.6407     0.1098 0.000 0.384 0.544 0.072
#> SRR037180     3  0.6407     0.1098 0.000 0.384 0.544 0.072
#> SRR037181     3  0.6407     0.1098 0.000 0.384 0.544 0.072
#> SRR037189     2  0.3229     0.7259 0.000 0.880 0.048 0.072
#> SRR037190     3  0.5384     0.5787 0.000 0.196 0.728 0.076
#> SRR037191     3  0.5056     0.5924 0.000 0.164 0.760 0.076
#> SRR037192     2  0.2281     0.7477 0.000 0.904 0.096 0.000
#> SRR037193     2  0.5959     0.2649 0.000 0.568 0.388 0.044
#> SRR037194     2  0.4010     0.7450 0.000 0.816 0.156 0.028
#> SRR037195     2  0.4139     0.7470 0.000 0.816 0.144 0.040
#> SRR037196     4  0.5371     0.5360 0.020 0.364 0.000 0.616
#> SRR037197     1  0.5047     0.5244 0.668 0.016 0.000 0.316
#> SRR037198     4  0.5189     0.5262 0.012 0.372 0.000 0.616
#> SRR037199     2  0.9559     0.1018 0.188 0.348 0.144 0.320
#> SRR037200     4  0.7345     0.2248 0.348 0.104 0.020 0.528
#> SRR037201     4  0.7345     0.2248 0.348 0.104 0.020 0.528
#> SRR037202     1  0.0469     0.7736 0.988 0.000 0.000 0.012
#> SRR037203     1  0.0000     0.7777 1.000 0.000 0.000 0.000
#> SRR037204     1  0.3224     0.6756 0.864 0.016 0.000 0.120
#> SRR037205     1  0.0921     0.7641 0.972 0.000 0.000 0.028
#> SRR037206     3  0.1211     0.5955 0.000 0.000 0.960 0.040
#> SRR037207     3  0.1211     0.5955 0.000 0.000 0.960 0.040
#> SRR037208     3  0.6489     0.1176 0.000 0.372 0.548 0.080
#> SRR037209     3  0.6489     0.1176 0.000 0.372 0.548 0.080
#> SRR037210     3  0.1211     0.5955 0.000 0.000 0.960 0.040
#> SRR037211     3  0.1211     0.5955 0.000 0.000 0.960 0.040
#> SRR037212     4  0.6442     0.5003 0.244 0.124 0.000 0.632
#> SRR037213     4  0.6442     0.5003 0.244 0.124 0.000 0.632
#> SRR037219     4  0.4964     0.2451 0.380 0.004 0.000 0.616
#> SRR037214     4  0.5195     0.5576 0.032 0.276 0.000 0.692
#> SRR037215     3  0.6489     0.1176 0.000 0.372 0.548 0.080
#> SRR037216     3  0.1211     0.5955 0.000 0.000 0.960 0.040
#> SRR037217     2  0.6637     0.4992 0.000 0.572 0.324 0.104
#> SRR037218     2  0.6637     0.4992 0.000 0.572 0.324 0.104
#> SRR037220     4  0.7604     0.2517 0.312 0.140 0.020 0.528
#> SRR037221     4  0.6559     0.0975 0.456 0.076 0.000 0.468
#> SRR037222     4  0.6559     0.0975 0.456 0.076 0.000 0.468
#> SRR037223     1  0.0000     0.7777 1.000 0.000 0.000 0.000
#> SRR037224     1  0.0000     0.7777 1.000 0.000 0.000 0.000
#> SRR037225     1  0.3224     0.6756 0.864 0.016 0.000 0.120
#> SRR037226     1  0.0000     0.7777 1.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> SRR037165     3  0.6770      0.609 0.000 0.044 0.552 0.136 0.268
#> SRR037166     3  0.6770      0.609 0.000 0.044 0.552 0.136 0.268
#> SRR037167     4  0.4280      0.656 0.000 0.000 0.088 0.772 0.140
#> SRR037168     1  0.5954      0.475 0.576 0.016 0.020 0.348 0.040
#> SRR037169     1  0.5914      0.490 0.588 0.016 0.020 0.336 0.040
#> SRR037170     1  0.5954      0.475 0.576 0.016 0.020 0.348 0.040
#> SRR037171     2  0.1043      0.803 0.000 0.960 0.040 0.000 0.000
#> SRR037172     2  0.1043      0.803 0.000 0.960 0.040 0.000 0.000
#> SRR037173     2  0.3420      0.740 0.000 0.840 0.084 0.000 0.076
#> SRR037174     2  0.3476      0.737 0.000 0.836 0.088 0.000 0.076
#> SRR037175     2  0.1043      0.803 0.000 0.960 0.040 0.000 0.000
#> SRR037176     2  0.1043      0.803 0.000 0.960 0.040 0.000 0.000
#> SRR037177     4  0.5549      0.534 0.000 0.000 0.124 0.632 0.244
#> SRR037182     4  0.2389      0.733 0.116 0.000 0.004 0.880 0.000
#> SRR037183     4  0.2660      0.718 0.128 0.000 0.000 0.864 0.008
#> SRR037184     3  0.7343      0.585 0.000 0.080 0.468 0.124 0.328
#> SRR037185     4  0.5549      0.534 0.000 0.000 0.124 0.632 0.244
#> SRR037186     3  0.7352      0.582 0.000 0.080 0.464 0.124 0.332
#> SRR037187     3  0.7352      0.582 0.000 0.080 0.464 0.124 0.332
#> SRR037188     4  0.2006      0.740 0.072 0.000 0.012 0.916 0.000
#> SRR037178     3  0.2561      0.539 0.000 0.144 0.856 0.000 0.000
#> SRR037179     3  0.2561      0.539 0.000 0.144 0.856 0.000 0.000
#> SRR037180     3  0.2561      0.539 0.000 0.144 0.856 0.000 0.000
#> SRR037181     3  0.2561      0.539 0.000 0.144 0.856 0.000 0.000
#> SRR037189     3  0.7515      0.546 0.000 0.076 0.440 0.152 0.332
#> SRR037190     2  0.3476      0.737 0.000 0.836 0.088 0.000 0.076
#> SRR037191     2  0.1043      0.803 0.000 0.960 0.040 0.000 0.000
#> SRR037192     3  0.7352      0.582 0.000 0.080 0.464 0.124 0.332
#> SRR037193     3  0.5980      0.605 0.000 0.112 0.680 0.064 0.144
#> SRR037194     3  0.6587      0.616 0.000 0.040 0.580 0.136 0.244
#> SRR037195     3  0.6587      0.616 0.000 0.040 0.580 0.136 0.244
#> SRR037196     4  0.3176      0.712 0.000 0.000 0.064 0.856 0.080
#> SRR037197     1  0.5954      0.475 0.576 0.016 0.020 0.348 0.040
#> SRR037198     4  0.3176      0.712 0.000 0.000 0.064 0.856 0.080
#> SRR037199     5  0.7324      0.577 0.120 0.008 0.328 0.060 0.484
#> SRR037200     5  0.7812      0.875 0.204 0.008 0.080 0.232 0.476
#> SRR037201     5  0.7812      0.875 0.204 0.008 0.080 0.232 0.476
#> SRR037202     1  0.0807      0.701 0.976 0.012 0.000 0.000 0.012
#> SRR037203     1  0.0290      0.708 0.992 0.008 0.000 0.000 0.000
#> SRR037204     1  0.4368      0.414 0.764 0.016 0.000 0.036 0.184
#> SRR037205     1  0.1195      0.687 0.960 0.012 0.000 0.000 0.028
#> SRR037206     2  0.5939      0.701 0.000 0.608 0.252 0.008 0.132
#> SRR037207     2  0.5939      0.701 0.000 0.608 0.252 0.008 0.132
#> SRR037208     3  0.2798      0.534 0.000 0.140 0.852 0.000 0.008
#> SRR037209     3  0.2798      0.534 0.000 0.140 0.852 0.000 0.008
#> SRR037210     2  0.5939      0.701 0.000 0.608 0.252 0.008 0.132
#> SRR037211     2  0.5939      0.701 0.000 0.608 0.252 0.008 0.132
#> SRR037212     4  0.2389      0.733 0.116 0.000 0.004 0.880 0.000
#> SRR037213     4  0.2389      0.733 0.116 0.000 0.004 0.880 0.000
#> SRR037219     4  0.2660      0.718 0.128 0.000 0.000 0.864 0.008
#> SRR037214     4  0.3129      0.652 0.004 0.000 0.156 0.832 0.008
#> SRR037215     3  0.2798      0.534 0.000 0.140 0.852 0.000 0.008
#> SRR037216     2  0.5939      0.701 0.000 0.608 0.252 0.008 0.132
#> SRR037217     3  0.2562      0.586 0.000 0.032 0.900 0.060 0.008
#> SRR037218     3  0.2562      0.586 0.000 0.032 0.900 0.060 0.008
#> SRR037220     5  0.7537      0.874 0.200 0.000 0.080 0.232 0.488
#> SRR037221     5  0.7169      0.837 0.252 0.004 0.024 0.240 0.480
#> SRR037222     5  0.7169      0.837 0.252 0.004 0.024 0.240 0.480
#> SRR037223     1  0.0000      0.708 1.000 0.000 0.000 0.000 0.000
#> SRR037224     1  0.0000      0.708 1.000 0.000 0.000 0.000 0.000
#> SRR037225     1  0.4264      0.399 0.760 0.008 0.000 0.036 0.196
#> SRR037226     1  0.0000      0.708 1.000 0.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR037165     4  0.5141     0.6193 0.000 0.016 0.112 0.728 0.076 0.068
#> SRR037166     4  0.5141     0.6193 0.000 0.016 0.112 0.728 0.076 0.068
#> SRR037167     6  0.4948     0.5162 0.000 0.000 0.028 0.248 0.060 0.664
#> SRR037168     1  0.6450     0.5744 0.576 0.000 0.132 0.020 0.056 0.216
#> SRR037169     1  0.6395     0.5794 0.584 0.000 0.128 0.020 0.056 0.212
#> SRR037170     1  0.6450     0.5744 0.576 0.000 0.132 0.020 0.056 0.216
#> SRR037171     2  0.0790     0.7562 0.000 0.968 0.000 0.032 0.000 0.000
#> SRR037172     2  0.0790     0.7562 0.000 0.968 0.000 0.032 0.000 0.000
#> SRR037173     2  0.2489     0.7064 0.000 0.860 0.000 0.128 0.012 0.000
#> SRR037174     2  0.2489     0.7064 0.000 0.860 0.000 0.128 0.012 0.000
#> SRR037175     2  0.0790     0.7562 0.000 0.968 0.000 0.032 0.000 0.000
#> SRR037176     2  0.0790     0.7562 0.000 0.968 0.000 0.032 0.000 0.000
#> SRR037177     4  0.4466    -0.0577 0.000 0.000 0.016 0.536 0.008 0.440
#> SRR037182     6  0.2239     0.8499 0.072 0.000 0.000 0.008 0.020 0.900
#> SRR037183     6  0.2346     0.8432 0.084 0.000 0.004 0.004 0.016 0.892
#> SRR037184     4  0.1644     0.6801 0.000 0.052 0.012 0.932 0.000 0.004
#> SRR037185     4  0.4466    -0.0577 0.000 0.000 0.016 0.536 0.008 0.440
#> SRR037186     4  0.1692     0.6832 0.000 0.048 0.012 0.932 0.000 0.008
#> SRR037187     4  0.1692     0.6832 0.000 0.048 0.012 0.932 0.000 0.008
#> SRR037188     6  0.2283     0.8480 0.056 0.000 0.000 0.020 0.020 0.904
#> SRR037178     3  0.4431     0.9465 0.000 0.080 0.692 0.228 0.000 0.000
#> SRR037179     3  0.4431     0.9465 0.000 0.080 0.692 0.228 0.000 0.000
#> SRR037180     3  0.4431     0.9465 0.000 0.080 0.692 0.228 0.000 0.000
#> SRR037181     3  0.4431     0.9465 0.000 0.080 0.692 0.228 0.000 0.000
#> SRR037189     4  0.1675     0.6809 0.000 0.024 0.008 0.936 0.000 0.032
#> SRR037190     2  0.2489     0.7064 0.000 0.860 0.000 0.128 0.012 0.000
#> SRR037191     2  0.0790     0.7562 0.000 0.968 0.000 0.032 0.000 0.000
#> SRR037192     4  0.1692     0.6832 0.000 0.048 0.012 0.932 0.000 0.008
#> SRR037193     4  0.6449    -0.0136 0.000 0.028 0.372 0.480 0.072 0.048
#> SRR037194     4  0.5735     0.4806 0.000 0.004 0.232 0.624 0.072 0.068
#> SRR037195     4  0.5761     0.4866 0.000 0.004 0.228 0.624 0.072 0.072
#> SRR037196     6  0.4056     0.6900 0.000 0.000 0.024 0.144 0.056 0.776
#> SRR037197     1  0.6450     0.5744 0.576 0.000 0.132 0.020 0.056 0.216
#> SRR037198     6  0.4056     0.6900 0.000 0.000 0.024 0.144 0.056 0.776
#> SRR037199     5  0.5679     0.7759 0.088 0.008 0.192 0.032 0.664 0.016
#> SRR037200     5  0.6178     0.9072 0.124 0.008 0.084 0.024 0.656 0.104
#> SRR037201     5  0.6178     0.9072 0.124 0.008 0.084 0.024 0.656 0.104
#> SRR037202     1  0.1780     0.6989 0.932 0.004 0.024 0.004 0.036 0.000
#> SRR037203     1  0.0405     0.7219 0.988 0.004 0.008 0.000 0.000 0.000
#> SRR037204     1  0.4587     0.3734 0.696 0.004 0.032 0.008 0.248 0.012
#> SRR037205     1  0.2353     0.6677 0.896 0.004 0.024 0.004 0.072 0.000
#> SRR037206     2  0.6215     0.5499 0.000 0.520 0.324 0.012 0.112 0.032
#> SRR037207     2  0.6185     0.5504 0.000 0.520 0.324 0.012 0.116 0.028
#> SRR037208     3  0.4411     0.9362 0.000 0.080 0.712 0.204 0.004 0.000
#> SRR037209     3  0.4411     0.9362 0.000 0.080 0.712 0.204 0.004 0.000
#> SRR037210     2  0.6185     0.5504 0.000 0.520 0.324 0.012 0.116 0.028
#> SRR037211     2  0.6185     0.5504 0.000 0.520 0.324 0.012 0.116 0.028
#> SRR037212     6  0.2239     0.8499 0.072 0.000 0.000 0.008 0.020 0.900
#> SRR037213     6  0.2239     0.8499 0.072 0.000 0.000 0.008 0.020 0.900
#> SRR037219     6  0.2346     0.8432 0.084 0.000 0.004 0.004 0.016 0.892
#> SRR037214     6  0.2964     0.7733 0.000 0.000 0.100 0.024 0.020 0.856
#> SRR037215     3  0.4411     0.9362 0.000 0.080 0.712 0.204 0.004 0.000
#> SRR037216     2  0.6185     0.5504 0.000 0.520 0.324 0.012 0.116 0.028
#> SRR037217     3  0.4394     0.8471 0.000 0.008 0.676 0.276 0.000 0.040
#> SRR037218     3  0.4394     0.8471 0.000 0.008 0.676 0.276 0.000 0.040
#> SRR037220     5  0.4801     0.9076 0.124 0.000 0.040 0.004 0.736 0.096
#> SRR037221     5  0.4483     0.8956 0.152 0.000 0.012 0.000 0.732 0.104
#> SRR037222     5  0.4483     0.8956 0.152 0.000 0.012 0.000 0.732 0.104
#> SRR037223     1  0.0000     0.7230 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR037224     1  0.0000     0.7230 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR037225     1  0.4187     0.2857 0.652 0.000 0.012 0.000 0.324 0.012
#> SRR037226     1  0.0000     0.7230 1.000 0.000 0.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

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

collect_plots(res)

plot of chunk ATC-skmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.5066 0.494   0.494
#> 3 3 0.905           0.934       0.936         0.2307 0.866   0.733
#> 4 4 0.795           0.934       0.929         0.1889 0.867   0.644
#> 5 5 0.781           0.818       0.853         0.0570 0.966   0.857
#> 6 6 0.762           0.729       0.802         0.0397 0.937   0.723

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
#> SRR037165     2       0          1  0  1
#> SRR037166     2       0          1  0  1
#> SRR037167     1       0          1  1  0
#> SRR037168     1       0          1  1  0
#> SRR037169     1       0          1  1  0
#> SRR037170     1       0          1  1  0
#> SRR037171     2       0          1  0  1
#> SRR037172     2       0          1  0  1
#> SRR037173     2       0          1  0  1
#> SRR037174     2       0          1  0  1
#> SRR037175     2       0          1  0  1
#> SRR037176     2       0          1  0  1
#> SRR037177     1       0          1  1  0
#> SRR037182     1       0          1  1  0
#> SRR037183     1       0          1  1  0
#> SRR037184     2       0          1  0  1
#> SRR037185     1       0          1  1  0
#> SRR037186     2       0          1  0  1
#> SRR037187     2       0          1  0  1
#> SRR037188     1       0          1  1  0
#> SRR037178     2       0          1  0  1
#> SRR037179     2       0          1  0  1
#> SRR037180     2       0          1  0  1
#> SRR037181     2       0          1  0  1
#> SRR037189     2       0          1  0  1
#> SRR037190     2       0          1  0  1
#> SRR037191     2       0          1  0  1
#> SRR037192     2       0          1  0  1
#> SRR037193     2       0          1  0  1
#> SRR037194     2       0          1  0  1
#> SRR037195     2       0          1  0  1
#> SRR037196     1       0          1  1  0
#> SRR037197     1       0          1  1  0
#> SRR037198     1       0          1  1  0
#> SRR037199     2       0          1  0  1
#> SRR037200     1       0          1  1  0
#> SRR037201     1       0          1  1  0
#> SRR037202     1       0          1  1  0
#> SRR037203     1       0          1  1  0
#> SRR037204     1       0          1  1  0
#> SRR037205     1       0          1  1  0
#> SRR037206     2       0          1  0  1
#> SRR037207     2       0          1  0  1
#> SRR037208     2       0          1  0  1
#> SRR037209     2       0          1  0  1
#> SRR037210     2       0          1  0  1
#> SRR037211     2       0          1  0  1
#> SRR037212     1       0          1  1  0
#> SRR037213     1       0          1  1  0
#> SRR037219     1       0          1  1  0
#> SRR037214     1       0          1  1  0
#> SRR037215     2       0          1  0  1
#> SRR037216     2       0          1  0  1
#> SRR037217     2       0          1  0  1
#> SRR037218     2       0          1  0  1
#> SRR037220     1       0          1  1  0
#> SRR037221     1       0          1  1  0
#> SRR037222     1       0          1  1  0
#> SRR037223     1       0          1  1  0
#> SRR037224     1       0          1  1  0
#> SRR037225     1       0          1  1  0
#> SRR037226     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
#> SRR037165     2  0.0000      0.961 0.000 1.000 0.000
#> SRR037166     2  0.0000      0.961 0.000 1.000 0.000
#> SRR037167     3  0.0000      0.990 0.000 0.000 1.000
#> SRR037168     3  0.0000      0.990 0.000 0.000 1.000
#> SRR037169     3  0.0000      0.990 0.000 0.000 1.000
#> SRR037170     3  0.0000      0.990 0.000 0.000 1.000
#> SRR037171     2  0.0000      0.961 0.000 1.000 0.000
#> SRR037172     2  0.0000      0.961 0.000 1.000 0.000
#> SRR037173     2  0.0000      0.961 0.000 1.000 0.000
#> SRR037174     2  0.0000      0.961 0.000 1.000 0.000
#> SRR037175     2  0.0000      0.961 0.000 1.000 0.000
#> SRR037176     2  0.0000      0.961 0.000 1.000 0.000
#> SRR037177     3  0.1999      0.933 0.012 0.036 0.952
#> SRR037182     3  0.0000      0.990 0.000 0.000 1.000
#> SRR037183     3  0.0000      0.990 0.000 0.000 1.000
#> SRR037184     2  0.0592      0.956 0.012 0.988 0.000
#> SRR037185     3  0.1999      0.933 0.012 0.036 0.952
#> SRR037186     2  0.0592      0.956 0.012 0.988 0.000
#> SRR037187     2  0.0592      0.956 0.012 0.988 0.000
#> SRR037188     3  0.0000      0.990 0.000 0.000 1.000
#> SRR037178     2  0.2261      0.956 0.068 0.932 0.000
#> SRR037179     2  0.2261      0.956 0.068 0.932 0.000
#> SRR037180     2  0.2261      0.956 0.068 0.932 0.000
#> SRR037181     2  0.2261      0.956 0.068 0.932 0.000
#> SRR037189     2  0.5919      0.594 0.012 0.712 0.276
#> SRR037190     2  0.0000      0.961 0.000 1.000 0.000
#> SRR037191     2  0.0000      0.961 0.000 1.000 0.000
#> SRR037192     2  0.0592      0.956 0.012 0.988 0.000
#> SRR037193     2  0.0000      0.961 0.000 1.000 0.000
#> SRR037194     2  0.0000      0.961 0.000 1.000 0.000
#> SRR037195     2  0.0000      0.961 0.000 1.000 0.000
#> SRR037196     3  0.0000      0.990 0.000 0.000 1.000
#> SRR037197     3  0.0000      0.990 0.000 0.000 1.000
#> SRR037198     3  0.0000      0.990 0.000 0.000 1.000
#> SRR037199     1  0.0592      0.791 0.988 0.012 0.000
#> SRR037200     1  0.2537      0.866 0.920 0.000 0.080
#> SRR037201     1  0.2537      0.866 0.920 0.000 0.080
#> SRR037202     1  0.5431      0.839 0.716 0.000 0.284
#> SRR037203     1  0.5497      0.833 0.708 0.000 0.292
#> SRR037204     1  0.4235      0.873 0.824 0.000 0.176
#> SRR037205     1  0.5254      0.849 0.736 0.000 0.264
#> SRR037206     2  0.2261      0.956 0.068 0.932 0.000
#> SRR037207     2  0.2261      0.956 0.068 0.932 0.000
#> SRR037208     2  0.2261      0.956 0.068 0.932 0.000
#> SRR037209     2  0.2261      0.956 0.068 0.932 0.000
#> SRR037210     2  0.2261      0.956 0.068 0.932 0.000
#> SRR037211     2  0.2261      0.956 0.068 0.932 0.000
#> SRR037212     3  0.0000      0.990 0.000 0.000 1.000
#> SRR037213     3  0.0000      0.990 0.000 0.000 1.000
#> SRR037219     3  0.0000      0.990 0.000 0.000 1.000
#> SRR037214     3  0.0000      0.990 0.000 0.000 1.000
#> SRR037215     2  0.2261      0.956 0.068 0.932 0.000
#> SRR037216     2  0.2261      0.956 0.068 0.932 0.000
#> SRR037217     2  0.2261      0.956 0.068 0.932 0.000
#> SRR037218     2  0.2261      0.956 0.068 0.932 0.000
#> SRR037220     1  0.2537      0.866 0.920 0.000 0.080
#> SRR037221     1  0.2537      0.866 0.920 0.000 0.080
#> SRR037222     1  0.2537      0.866 0.920 0.000 0.080
#> SRR037223     1  0.5497      0.833 0.708 0.000 0.292
#> SRR037224     1  0.5497      0.833 0.708 0.000 0.292
#> SRR037225     1  0.4235      0.873 0.824 0.000 0.176
#> SRR037226     1  0.5497      0.833 0.708 0.000 0.292

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> SRR037165     2  0.2973      0.938 0.000 0.856 0.144 0.000
#> SRR037166     2  0.2973      0.938 0.000 0.856 0.144 0.000
#> SRR037167     4  0.0000      0.991 0.000 0.000 0.000 1.000
#> SRR037168     4  0.0000      0.991 0.000 0.000 0.000 1.000
#> SRR037169     4  0.0000      0.991 0.000 0.000 0.000 1.000
#> SRR037170     4  0.0000      0.991 0.000 0.000 0.000 1.000
#> SRR037171     2  0.3219      0.938 0.000 0.836 0.164 0.000
#> SRR037172     2  0.3219      0.938 0.000 0.836 0.164 0.000
#> SRR037173     2  0.3172      0.939 0.000 0.840 0.160 0.000
#> SRR037174     2  0.3172      0.939 0.000 0.840 0.160 0.000
#> SRR037175     2  0.3219      0.938 0.000 0.836 0.164 0.000
#> SRR037176     2  0.3219      0.938 0.000 0.836 0.164 0.000
#> SRR037177     4  0.1913      0.934 0.020 0.040 0.000 0.940
#> SRR037182     4  0.0000      0.991 0.000 0.000 0.000 1.000
#> SRR037183     4  0.0000      0.991 0.000 0.000 0.000 1.000
#> SRR037184     2  0.1174      0.863 0.020 0.968 0.012 0.000
#> SRR037185     4  0.1913      0.934 0.020 0.040 0.000 0.940
#> SRR037186     2  0.1174      0.863 0.020 0.968 0.012 0.000
#> SRR037187     2  0.1174      0.863 0.020 0.968 0.012 0.000
#> SRR037188     4  0.0000      0.991 0.000 0.000 0.000 1.000
#> SRR037178     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR037179     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR037180     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR037181     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR037189     2  0.1174      0.863 0.020 0.968 0.012 0.000
#> SRR037190     2  0.3123      0.940 0.000 0.844 0.156 0.000
#> SRR037191     2  0.3219      0.938 0.000 0.836 0.164 0.000
#> SRR037192     2  0.1174      0.863 0.020 0.968 0.012 0.000
#> SRR037193     2  0.3172      0.938 0.000 0.840 0.160 0.000
#> SRR037194     2  0.3074      0.939 0.000 0.848 0.152 0.000
#> SRR037195     2  0.3074      0.939 0.000 0.848 0.152 0.000
#> SRR037196     4  0.0000      0.991 0.000 0.000 0.000 1.000
#> SRR037197     4  0.0000      0.991 0.000 0.000 0.000 1.000
#> SRR037198     4  0.0000      0.991 0.000 0.000 0.000 1.000
#> SRR037199     1  0.1042      0.837 0.972 0.008 0.020 0.000
#> SRR037200     1  0.1042      0.853 0.972 0.008 0.000 0.020
#> SRR037201     1  0.1042      0.853 0.972 0.008 0.000 0.020
#> SRR037202     1  0.4134      0.816 0.740 0.000 0.000 0.260
#> SRR037203     1  0.4277      0.802 0.720 0.000 0.000 0.280
#> SRR037204     1  0.2760      0.859 0.872 0.000 0.000 0.128
#> SRR037205     1  0.3975      0.827 0.760 0.000 0.000 0.240
#> SRR037206     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR037207     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR037208     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR037209     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR037210     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR037211     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR037212     4  0.0000      0.991 0.000 0.000 0.000 1.000
#> SRR037213     4  0.0000      0.991 0.000 0.000 0.000 1.000
#> SRR037219     4  0.0000      0.991 0.000 0.000 0.000 1.000
#> SRR037214     4  0.0000      0.991 0.000 0.000 0.000 1.000
#> SRR037215     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR037216     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR037217     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR037218     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR037220     1  0.1042      0.853 0.972 0.008 0.000 0.020
#> SRR037221     1  0.0707      0.854 0.980 0.000 0.000 0.020
#> SRR037222     1  0.0707      0.854 0.980 0.000 0.000 0.020
#> SRR037223     1  0.4277      0.802 0.720 0.000 0.000 0.280
#> SRR037224     1  0.4277      0.802 0.720 0.000 0.000 0.280
#> SRR037225     1  0.2760      0.859 0.872 0.000 0.000 0.128
#> SRR037226     1  0.4277      0.802 0.720 0.000 0.000 0.280

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> SRR037165     2  0.0510      0.498 0.000 0.984 0.016 0.000 0.000
#> SRR037166     2  0.0510      0.498 0.000 0.984 0.016 0.000 0.000
#> SRR037167     4  0.1205      0.904 0.000 0.040 0.000 0.956 0.004
#> SRR037168     4  0.0000      0.920 0.000 0.000 0.000 1.000 0.000
#> SRR037169     4  0.0000      0.920 0.000 0.000 0.000 1.000 0.000
#> SRR037170     4  0.0000      0.920 0.000 0.000 0.000 1.000 0.000
#> SRR037171     2  0.6132      0.553 0.000 0.444 0.128 0.000 0.428
#> SRR037172     2  0.6132      0.553 0.000 0.444 0.128 0.000 0.428
#> SRR037173     2  0.6132      0.553 0.000 0.444 0.128 0.000 0.428
#> SRR037174     2  0.6132      0.553 0.000 0.444 0.128 0.000 0.428
#> SRR037175     2  0.6132      0.553 0.000 0.444 0.128 0.000 0.428
#> SRR037176     2  0.6132      0.553 0.000 0.444 0.128 0.000 0.428
#> SRR037177     4  0.4339      0.565 0.000 0.012 0.000 0.652 0.336
#> SRR037182     4  0.1357      0.923 0.000 0.004 0.000 0.948 0.048
#> SRR037183     4  0.1357      0.923 0.000 0.004 0.000 0.948 0.048
#> SRR037184     5  0.1792      1.000 0.000 0.084 0.000 0.000 0.916
#> SRR037185     4  0.4339      0.565 0.000 0.012 0.000 0.652 0.336
#> SRR037186     5  0.1792      1.000 0.000 0.084 0.000 0.000 0.916
#> SRR037187     5  0.1792      1.000 0.000 0.084 0.000 0.000 0.916
#> SRR037188     4  0.1357      0.923 0.000 0.004 0.000 0.948 0.048
#> SRR037178     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR037179     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR037180     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR037181     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR037189     5  0.1792      1.000 0.000 0.084 0.000 0.000 0.916
#> SRR037190     2  0.6132      0.553 0.000 0.444 0.128 0.000 0.428
#> SRR037191     2  0.6132      0.553 0.000 0.444 0.128 0.000 0.428
#> SRR037192     5  0.1792      1.000 0.000 0.084 0.000 0.000 0.916
#> SRR037193     2  0.0510      0.498 0.000 0.984 0.016 0.000 0.000
#> SRR037194     2  0.0510      0.498 0.000 0.984 0.016 0.000 0.000
#> SRR037195     2  0.0510      0.498 0.000 0.984 0.016 0.000 0.000
#> SRR037196     4  0.1041      0.907 0.000 0.032 0.000 0.964 0.004
#> SRR037197     4  0.0000      0.920 0.000 0.000 0.000 1.000 0.000
#> SRR037198     4  0.1041      0.907 0.000 0.032 0.000 0.964 0.004
#> SRR037199     1  0.1041      0.793 0.964 0.004 0.000 0.000 0.032
#> SRR037200     1  0.1041      0.793 0.964 0.004 0.000 0.000 0.032
#> SRR037201     1  0.1041      0.793 0.964 0.004 0.000 0.000 0.032
#> SRR037202     1  0.3752      0.751 0.708 0.000 0.000 0.292 0.000
#> SRR037203     1  0.3895      0.724 0.680 0.000 0.000 0.320 0.000
#> SRR037204     1  0.2179      0.814 0.888 0.000 0.000 0.112 0.000
#> SRR037205     1  0.3752      0.751 0.708 0.000 0.000 0.292 0.000
#> SRR037206     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR037207     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR037208     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR037209     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR037210     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR037211     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR037212     4  0.1357      0.923 0.000 0.004 0.000 0.948 0.048
#> SRR037213     4  0.1357      0.923 0.000 0.004 0.000 0.948 0.048
#> SRR037219     4  0.1357      0.923 0.000 0.004 0.000 0.948 0.048
#> SRR037214     4  0.1357      0.923 0.000 0.004 0.000 0.948 0.048
#> SRR037215     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR037216     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR037217     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR037218     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR037220     1  0.1041      0.793 0.964 0.004 0.000 0.000 0.032
#> SRR037221     1  0.0703      0.795 0.976 0.000 0.000 0.000 0.024
#> SRR037222     1  0.0703      0.795 0.976 0.000 0.000 0.000 0.024
#> SRR037223     1  0.3895      0.724 0.680 0.000 0.000 0.320 0.000
#> SRR037224     1  0.3837      0.738 0.692 0.000 0.000 0.308 0.000
#> SRR037225     1  0.2179      0.814 0.888 0.000 0.000 0.112 0.000
#> SRR037226     1  0.3837      0.738 0.692 0.000 0.000 0.308 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
#> SRR037165     4  0.1565      0.973 0.000 0.028 0.004 0.940 0.028 0.000
#> SRR037166     4  0.1565      0.973 0.000 0.028 0.004 0.940 0.028 0.000
#> SRR037167     5  0.5274     -0.132 0.000 0.000 0.000 0.100 0.492 0.408
#> SRR037168     6  0.3672      0.584 0.008 0.000 0.000 0.000 0.304 0.688
#> SRR037169     6  0.3672      0.584 0.008 0.000 0.000 0.000 0.304 0.688
#> SRR037170     6  0.3672      0.584 0.008 0.000 0.000 0.000 0.304 0.688
#> SRR037171     2  0.4328      0.698 0.000 0.724 0.112 0.164 0.000 0.000
#> SRR037172     2  0.4328      0.698 0.000 0.724 0.112 0.164 0.000 0.000
#> SRR037173     2  0.4328      0.698 0.000 0.724 0.112 0.164 0.000 0.000
#> SRR037174     2  0.4328      0.698 0.000 0.724 0.112 0.164 0.000 0.000
#> SRR037175     2  0.4328      0.698 0.000 0.724 0.112 0.164 0.000 0.000
#> SRR037176     2  0.4328      0.698 0.000 0.724 0.112 0.164 0.000 0.000
#> SRR037177     5  0.4949      0.670 0.000 0.144 0.000 0.000 0.648 0.208
#> SRR037182     6  0.0000      0.724 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR037183     6  0.0000      0.724 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR037184     2  0.3351      0.461 0.000 0.712 0.000 0.000 0.288 0.000
#> SRR037185     5  0.4949      0.670 0.000 0.144 0.000 0.000 0.648 0.208
#> SRR037186     2  0.3351      0.461 0.000 0.712 0.000 0.000 0.288 0.000
#> SRR037187     2  0.3351      0.461 0.000 0.712 0.000 0.000 0.288 0.000
#> SRR037188     6  0.0000      0.724 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR037178     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR037179     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR037180     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR037181     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR037189     2  0.3351      0.461 0.000 0.712 0.000 0.000 0.288 0.000
#> SRR037190     2  0.4328      0.698 0.000 0.724 0.112 0.164 0.000 0.000
#> SRR037191     2  0.4328      0.698 0.000 0.724 0.112 0.164 0.000 0.000
#> SRR037192     2  0.3351      0.461 0.000 0.712 0.000 0.000 0.288 0.000
#> SRR037193     4  0.1462      0.953 0.000 0.056 0.008 0.936 0.000 0.000
#> SRR037194     4  0.0777      0.974 0.000 0.024 0.004 0.972 0.000 0.000
#> SRR037195     4  0.0777      0.974 0.000 0.024 0.004 0.972 0.000 0.000
#> SRR037196     6  0.5536      0.190 0.008 0.000 0.000 0.108 0.380 0.504
#> SRR037197     6  0.3672      0.584 0.008 0.000 0.000 0.000 0.304 0.688
#> SRR037198     6  0.5536      0.190 0.008 0.000 0.000 0.108 0.380 0.504
#> SRR037199     1  0.3586      0.650 0.756 0.000 0.000 0.028 0.216 0.000
#> SRR037200     1  0.3586      0.650 0.756 0.000 0.000 0.028 0.216 0.000
#> SRR037201     1  0.3586      0.650 0.756 0.000 0.000 0.028 0.216 0.000
#> SRR037202     1  0.4167      0.693 0.708 0.000 0.000 0.000 0.056 0.236
#> SRR037203     1  0.4284      0.672 0.688 0.000 0.000 0.000 0.056 0.256
#> SRR037204     1  0.2912      0.725 0.844 0.000 0.000 0.000 0.040 0.116
#> SRR037205     1  0.4050      0.696 0.716 0.000 0.000 0.000 0.048 0.236
#> SRR037206     3  0.0260      0.994 0.000 0.008 0.992 0.000 0.000 0.000
#> SRR037207     3  0.0260      0.994 0.000 0.008 0.992 0.000 0.000 0.000
#> SRR037208     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR037209     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR037210     3  0.0260      0.994 0.000 0.008 0.992 0.000 0.000 0.000
#> SRR037211     3  0.0260      0.994 0.000 0.008 0.992 0.000 0.000 0.000
#> SRR037212     6  0.0000      0.724 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR037213     6  0.0000      0.724 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR037219     6  0.0000      0.724 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR037214     6  0.0000      0.724 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR037215     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR037216     3  0.0260      0.994 0.000 0.008 0.992 0.000 0.000 0.000
#> SRR037217     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR037218     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR037220     1  0.3558      0.651 0.760 0.000 0.000 0.028 0.212 0.000
#> SRR037221     1  0.2491      0.686 0.868 0.000 0.000 0.020 0.112 0.000
#> SRR037222     1  0.2491      0.686 0.868 0.000 0.000 0.020 0.112 0.000
#> SRR037223     1  0.4284      0.672 0.688 0.000 0.000 0.000 0.056 0.256
#> SRR037224     1  0.4215      0.686 0.700 0.000 0.000 0.000 0.056 0.244
#> SRR037225     1  0.2912      0.725 0.844 0.000 0.000 0.000 0.040 0.116
#> SRR037226     1  0.4215      0.686 0.700 0.000 0.000 0.000 0.056 0.244

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

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

collect_plots(res)

plot of chunk ATC-pam-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.949       0.980         0.5002 0.500   0.500
#> 3 3 0.654           0.733       0.823         0.2438 0.860   0.727
#> 4 4 0.750           0.787       0.899         0.2131 0.863   0.642
#> 5 5 0.790           0.585       0.811         0.0481 0.861   0.545
#> 6 6 0.863           0.740       0.869         0.0432 0.888   0.569

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
#> SRR037165     2   0.000      0.979 0.000 1.000
#> SRR037166     2   0.000      0.979 0.000 1.000
#> SRR037167     1   0.000      0.979 1.000 0.000
#> SRR037168     1   0.000      0.979 1.000 0.000
#> SRR037169     1   0.000      0.979 1.000 0.000
#> SRR037170     1   0.000      0.979 1.000 0.000
#> SRR037171     2   0.000      0.979 0.000 1.000
#> SRR037172     2   0.000      0.979 0.000 1.000
#> SRR037173     2   0.000      0.979 0.000 1.000
#> SRR037174     2   0.000      0.979 0.000 1.000
#> SRR037175     2   0.000      0.979 0.000 1.000
#> SRR037176     2   0.000      0.979 0.000 1.000
#> SRR037177     1   0.000      0.979 1.000 0.000
#> SRR037182     1   0.000      0.979 1.000 0.000
#> SRR037183     1   0.000      0.979 1.000 0.000
#> SRR037184     2   0.000      0.979 0.000 1.000
#> SRR037185     1   0.000      0.979 1.000 0.000
#> SRR037186     2   0.000      0.979 0.000 1.000
#> SRR037187     2   0.000      0.979 0.000 1.000
#> SRR037188     1   0.000      0.979 1.000 0.000
#> SRR037178     2   0.000      0.979 0.000 1.000
#> SRR037179     2   0.000      0.979 0.000 1.000
#> SRR037180     2   0.000      0.979 0.000 1.000
#> SRR037181     2   0.000      0.979 0.000 1.000
#> SRR037189     2   0.430      0.890 0.088 0.912
#> SRR037190     2   0.000      0.979 0.000 1.000
#> SRR037191     2   0.000      0.979 0.000 1.000
#> SRR037192     2   0.000      0.979 0.000 1.000
#> SRR037193     2   0.000      0.979 0.000 1.000
#> SRR037194     2   0.000      0.979 0.000 1.000
#> SRR037195     2   0.000      0.979 0.000 1.000
#> SRR037196     1   0.000      0.979 1.000 0.000
#> SRR037197     1   0.000      0.979 1.000 0.000
#> SRR037198     1   0.000      0.979 1.000 0.000
#> SRR037199     2   0.000      0.979 0.000 1.000
#> SRR037200     2   0.973      0.310 0.404 0.596
#> SRR037201     1   0.988      0.202 0.564 0.436
#> SRR037202     1   0.000      0.979 1.000 0.000
#> SRR037203     1   0.000      0.979 1.000 0.000
#> SRR037204     1   0.000      0.979 1.000 0.000
#> SRR037205     1   0.000      0.979 1.000 0.000
#> SRR037206     2   0.000      0.979 0.000 1.000
#> SRR037207     2   0.000      0.979 0.000 1.000
#> SRR037208     2   0.000      0.979 0.000 1.000
#> SRR037209     2   0.000      0.979 0.000 1.000
#> SRR037210     2   0.000      0.979 0.000 1.000
#> SRR037211     2   0.000      0.979 0.000 1.000
#> SRR037212     1   0.000      0.979 1.000 0.000
#> SRR037213     1   0.000      0.979 1.000 0.000
#> SRR037219     1   0.000      0.979 1.000 0.000
#> SRR037214     1   0.000      0.979 1.000 0.000
#> SRR037215     2   0.000      0.979 0.000 1.000
#> SRR037216     2   0.000      0.979 0.000 1.000
#> SRR037217     2   0.000      0.979 0.000 1.000
#> SRR037218     2   0.000      0.979 0.000 1.000
#> SRR037220     2   0.738      0.728 0.208 0.792
#> SRR037221     1   0.000      0.979 1.000 0.000
#> SRR037222     1   0.416      0.893 0.916 0.084
#> SRR037223     1   0.000      0.979 1.000 0.000
#> SRR037224     1   0.000      0.979 1.000 0.000
#> SRR037225     1   0.000      0.979 1.000 0.000
#> SRR037226     1   0.000      0.979 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
#> SRR037165     2  0.6111      0.772 0.000 0.604 0.396
#> SRR037166     2  0.6111      0.772 0.000 0.604 0.396
#> SRR037167     3  0.0000      0.759 0.000 0.000 1.000
#> SRR037168     3  0.6111      0.437 0.396 0.000 0.604
#> SRR037169     3  0.6111      0.437 0.396 0.000 0.604
#> SRR037170     3  0.6111      0.437 0.396 0.000 0.604
#> SRR037171     2  0.0000      0.689 0.000 1.000 0.000
#> SRR037172     2  0.0000      0.689 0.000 1.000 0.000
#> SRR037173     2  0.0000      0.689 0.000 1.000 0.000
#> SRR037174     2  0.0000      0.689 0.000 1.000 0.000
#> SRR037175     2  0.0000      0.689 0.000 1.000 0.000
#> SRR037176     2  0.0000      0.689 0.000 1.000 0.000
#> SRR037177     3  0.0000      0.759 0.000 0.000 1.000
#> SRR037182     3  0.0000      0.759 0.000 0.000 1.000
#> SRR037183     3  0.6111      0.437 0.396 0.000 0.604
#> SRR037184     2  0.6111      0.772 0.000 0.604 0.396
#> SRR037185     3  0.0000      0.759 0.000 0.000 1.000
#> SRR037186     2  0.6111      0.772 0.000 0.604 0.396
#> SRR037187     2  0.6111      0.772 0.000 0.604 0.396
#> SRR037188     3  0.0000      0.759 0.000 0.000 1.000
#> SRR037178     2  0.6111      0.772 0.000 0.604 0.396
#> SRR037179     2  0.6111      0.772 0.000 0.604 0.396
#> SRR037180     2  0.6111      0.772 0.000 0.604 0.396
#> SRR037181     2  0.6111      0.772 0.000 0.604 0.396
#> SRR037189     2  0.6305      0.646 0.000 0.516 0.484
#> SRR037190     2  0.0000      0.689 0.000 1.000 0.000
#> SRR037191     2  0.0000      0.689 0.000 1.000 0.000
#> SRR037192     2  0.6111      0.772 0.000 0.604 0.396
#> SRR037193     2  0.6111      0.772 0.000 0.604 0.396
#> SRR037194     2  0.6111      0.772 0.000 0.604 0.396
#> SRR037195     2  0.6111      0.772 0.000 0.604 0.396
#> SRR037196     3  0.0000      0.759 0.000 0.000 1.000
#> SRR037197     3  0.6111      0.437 0.396 0.000 0.604
#> SRR037198     3  0.0000      0.759 0.000 0.000 1.000
#> SRR037199     2  0.6111      0.772 0.000 0.604 0.396
#> SRR037200     1  0.4291      0.656 0.820 0.000 0.180
#> SRR037201     1  0.0424      0.914 0.992 0.000 0.008
#> SRR037202     1  0.0000      0.922 1.000 0.000 0.000
#> SRR037203     1  0.0000      0.922 1.000 0.000 0.000
#> SRR037204     1  0.0000      0.922 1.000 0.000 0.000
#> SRR037205     1  0.0000      0.922 1.000 0.000 0.000
#> SRR037206     2  0.0000      0.689 0.000 1.000 0.000
#> SRR037207     2  0.0000      0.689 0.000 1.000 0.000
#> SRR037208     2  0.6111      0.772 0.000 0.604 0.396
#> SRR037209     2  0.6111      0.772 0.000 0.604 0.396
#> SRR037210     2  0.0000      0.689 0.000 1.000 0.000
#> SRR037211     2  0.0000      0.689 0.000 1.000 0.000
#> SRR037212     3  0.0000      0.759 0.000 0.000 1.000
#> SRR037213     3  0.0000      0.759 0.000 0.000 1.000
#> SRR037219     3  0.6111      0.437 0.396 0.000 0.604
#> SRR037214     3  0.0000      0.759 0.000 0.000 1.000
#> SRR037215     2  0.6111      0.772 0.000 0.604 0.396
#> SRR037216     2  0.0000      0.689 0.000 1.000 0.000
#> SRR037217     2  0.6111      0.772 0.000 0.604 0.396
#> SRR037218     2  0.6111      0.772 0.000 0.604 0.396
#> SRR037220     1  0.6111      0.200 0.604 0.000 0.396
#> SRR037221     1  0.0000      0.922 1.000 0.000 0.000
#> SRR037222     1  0.0000      0.922 1.000 0.000 0.000
#> SRR037223     1  0.0000      0.922 1.000 0.000 0.000
#> SRR037224     1  0.0000      0.922 1.000 0.000 0.000
#> SRR037225     1  0.0000      0.922 1.000 0.000 0.000
#> SRR037226     1  0.0000      0.922 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1  p2    p3    p4
#> SRR037165     3   0.361      0.582 0.000 0.2 0.800 0.000
#> SRR037166     3   0.361      0.582 0.000 0.2 0.800 0.000
#> SRR037167     4   0.000      0.936 0.000 0.0 0.000 1.000
#> SRR037168     4   0.361      0.789 0.200 0.0 0.000 0.800
#> SRR037169     4   0.394      0.753 0.236 0.0 0.000 0.764
#> SRR037170     4   0.361      0.789 0.200 0.0 0.000 0.800
#> SRR037171     2   0.000      0.786 0.000 1.0 0.000 0.000
#> SRR037172     2   0.000      0.786 0.000 1.0 0.000 0.000
#> SRR037173     2   0.000      0.786 0.000 1.0 0.000 0.000
#> SRR037174     2   0.000      0.786 0.000 1.0 0.000 0.000
#> SRR037175     2   0.000      0.786 0.000 1.0 0.000 0.000
#> SRR037176     2   0.000      0.786 0.000 1.0 0.000 0.000
#> SRR037177     4   0.000      0.936 0.000 0.0 0.000 1.000
#> SRR037182     4   0.000      0.936 0.000 0.0 0.000 1.000
#> SRR037183     4   0.000      0.936 0.000 0.0 0.000 1.000
#> SRR037184     2   0.485      0.503 0.000 0.6 0.400 0.000
#> SRR037185     4   0.000      0.936 0.000 0.0 0.000 1.000
#> SRR037186     2   0.485      0.503 0.000 0.6 0.400 0.000
#> SRR037187     2   0.485      0.503 0.000 0.6 0.400 0.000
#> SRR037188     4   0.000      0.936 0.000 0.0 0.000 1.000
#> SRR037178     3   0.000      0.830 0.000 0.0 1.000 0.000
#> SRR037179     3   0.000      0.830 0.000 0.0 1.000 0.000
#> SRR037180     3   0.000      0.830 0.000 0.0 1.000 0.000
#> SRR037181     3   0.000      0.830 0.000 0.0 1.000 0.000
#> SRR037189     2   0.683      0.546 0.000 0.6 0.228 0.172
#> SRR037190     2   0.000      0.786 0.000 1.0 0.000 0.000
#> SRR037191     2   0.000      0.786 0.000 1.0 0.000 0.000
#> SRR037192     2   0.485      0.503 0.000 0.6 0.400 0.000
#> SRR037193     3   0.000      0.830 0.000 0.0 1.000 0.000
#> SRR037194     3   0.000      0.830 0.000 0.0 1.000 0.000
#> SRR037195     3   0.000      0.830 0.000 0.0 1.000 0.000
#> SRR037196     4   0.000      0.936 0.000 0.0 0.000 1.000
#> SRR037197     4   0.361      0.789 0.200 0.0 0.000 0.800
#> SRR037198     4   0.000      0.936 0.000 0.0 0.000 1.000
#> SRR037199     3   0.000      0.830 0.000 0.0 1.000 0.000
#> SRR037200     1   0.361      0.827 0.800 0.0 0.000 0.200
#> SRR037201     1   0.361      0.827 0.800 0.0 0.000 0.200
#> SRR037202     1   0.000      0.903 1.000 0.0 0.000 0.000
#> SRR037203     1   0.000      0.903 1.000 0.0 0.000 0.000
#> SRR037204     1   0.000      0.903 1.000 0.0 0.000 0.000
#> SRR037205     1   0.000      0.903 1.000 0.0 0.000 0.000
#> SRR037206     3   0.485      0.461 0.000 0.4 0.600 0.000
#> SRR037207     3   0.485      0.461 0.000 0.4 0.600 0.000
#> SRR037208     3   0.000      0.830 0.000 0.0 1.000 0.000
#> SRR037209     3   0.000      0.830 0.000 0.0 1.000 0.000
#> SRR037210     3   0.485      0.461 0.000 0.4 0.600 0.000
#> SRR037211     3   0.485      0.461 0.000 0.4 0.600 0.000
#> SRR037212     4   0.000      0.936 0.000 0.0 0.000 1.000
#> SRR037213     4   0.000      0.936 0.000 0.0 0.000 1.000
#> SRR037219     4   0.000      0.936 0.000 0.0 0.000 1.000
#> SRR037214     4   0.000      0.936 0.000 0.0 0.000 1.000
#> SRR037215     3   0.000      0.830 0.000 0.0 1.000 0.000
#> SRR037216     3   0.485      0.461 0.000 0.4 0.600 0.000
#> SRR037217     3   0.000      0.830 0.000 0.0 1.000 0.000
#> SRR037218     3   0.000      0.830 0.000 0.0 1.000 0.000
#> SRR037220     1   0.361      0.827 0.800 0.0 0.000 0.200
#> SRR037221     1   0.357      0.829 0.804 0.0 0.000 0.196
#> SRR037222     1   0.361      0.827 0.800 0.0 0.000 0.200
#> SRR037223     1   0.000      0.903 1.000 0.0 0.000 0.000
#> SRR037224     1   0.000      0.903 1.000 0.0 0.000 0.000
#> SRR037225     1   0.000      0.903 1.000 0.0 0.000 0.000
#> SRR037226     1   0.000      0.903 1.000 0.0 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> SRR037165     3   0.655      0.595 0.000 0.200 0.404 0.000 0.396
#> SRR037166     3   0.655      0.591 0.000 0.200 0.412 0.000 0.388
#> SRR037167     4   0.000      0.922 0.000 0.000 0.000 1.000 0.000
#> SRR037168     4   0.342      0.748 0.240 0.000 0.000 0.760 0.000
#> SRR037169     4   0.418      0.518 0.400 0.000 0.000 0.600 0.000
#> SRR037170     4   0.342      0.748 0.240 0.000 0.000 0.760 0.000
#> SRR037171     2   0.415      0.720 0.000 0.612 0.388 0.000 0.000
#> SRR037172     2   0.415      0.720 0.000 0.612 0.388 0.000 0.000
#> SRR037173     2   0.415      0.720 0.000 0.612 0.388 0.000 0.000
#> SRR037174     2   0.415      0.720 0.000 0.612 0.388 0.000 0.000
#> SRR037175     2   0.415      0.720 0.000 0.612 0.388 0.000 0.000
#> SRR037176     2   0.415      0.720 0.000 0.612 0.388 0.000 0.000
#> SRR037177     4   0.029      0.918 0.000 0.000 0.008 0.992 0.000
#> SRR037182     4   0.000      0.922 0.000 0.000 0.000 1.000 0.000
#> SRR037183     4   0.000      0.922 0.000 0.000 0.000 1.000 0.000
#> SRR037184     3   0.314      0.125 0.000 0.204 0.796 0.000 0.000
#> SRR037185     4   0.029      0.918 0.000 0.000 0.008 0.992 0.000
#> SRR037186     3   0.314      0.125 0.000 0.204 0.796 0.000 0.000
#> SRR037187     3   0.314      0.125 0.000 0.204 0.796 0.000 0.000
#> SRR037188     4   0.000      0.922 0.000 0.000 0.000 1.000 0.000
#> SRR037178     3   0.417      0.723 0.000 0.000 0.604 0.000 0.396
#> SRR037179     3   0.417      0.723 0.000 0.000 0.604 0.000 0.396
#> SRR037180     3   0.417      0.723 0.000 0.000 0.604 0.000 0.396
#> SRR037181     3   0.417      0.723 0.000 0.000 0.604 0.000 0.396
#> SRR037189     3   0.601     -0.222 0.000 0.204 0.584 0.212 0.000
#> SRR037190     2   0.415      0.720 0.000 0.612 0.388 0.000 0.000
#> SRR037191     2   0.415      0.720 0.000 0.612 0.388 0.000 0.000
#> SRR037192     3   0.314      0.125 0.000 0.204 0.796 0.000 0.000
#> SRR037193     3   0.417      0.723 0.000 0.000 0.604 0.000 0.396
#> SRR037194     3   0.417      0.723 0.000 0.000 0.604 0.000 0.396
#> SRR037195     3   0.417      0.723 0.000 0.000 0.604 0.000 0.396
#> SRR037196     4   0.000      0.922 0.000 0.000 0.000 1.000 0.000
#> SRR037197     4   0.342      0.748 0.240 0.000 0.000 0.760 0.000
#> SRR037198     4   0.000      0.922 0.000 0.000 0.000 1.000 0.000
#> SRR037199     5   0.311     -0.310 0.000 0.000 0.200 0.000 0.800
#> SRR037200     5   0.417     -0.193 0.396 0.000 0.000 0.000 0.604
#> SRR037201     5   0.417     -0.193 0.396 0.000 0.000 0.000 0.604
#> SRR037202     1   0.314      0.513 0.796 0.000 0.000 0.000 0.204
#> SRR037203     1   0.314      0.513 0.796 0.000 0.000 0.000 0.204
#> SRR037204     1   0.419      0.329 0.596 0.000 0.000 0.000 0.404
#> SRR037205     1   0.314      0.513 0.796 0.000 0.000 0.000 0.204
#> SRR037206     2   0.342      0.500 0.000 0.788 0.204 0.000 0.008
#> SRR037207     2   0.342      0.500 0.000 0.788 0.204 0.000 0.008
#> SRR037208     3   0.417      0.723 0.000 0.000 0.604 0.000 0.396
#> SRR037209     3   0.417      0.723 0.000 0.000 0.604 0.000 0.396
#> SRR037210     2   0.330      0.503 0.000 0.792 0.204 0.000 0.004
#> SRR037211     2   0.314      0.505 0.000 0.796 0.204 0.000 0.000
#> SRR037212     4   0.000      0.922 0.000 0.000 0.000 1.000 0.000
#> SRR037213     4   0.000      0.922 0.000 0.000 0.000 1.000 0.000
#> SRR037219     4   0.000      0.922 0.000 0.000 0.000 1.000 0.000
#> SRR037214     4   0.000      0.922 0.000 0.000 0.000 1.000 0.000
#> SRR037215     3   0.417      0.723 0.000 0.000 0.604 0.000 0.396
#> SRR037216     2   0.314      0.505 0.000 0.796 0.204 0.000 0.000
#> SRR037217     3   0.417      0.723 0.000 0.000 0.604 0.000 0.396
#> SRR037218     3   0.417      0.723 0.000 0.000 0.604 0.000 0.396
#> SRR037220     1   0.418      0.295 0.600 0.000 0.000 0.000 0.400
#> SRR037221     1   0.418      0.295 0.600 0.000 0.000 0.000 0.400
#> SRR037222     1   0.418      0.295 0.600 0.000 0.000 0.000 0.400
#> SRR037223     1   0.000      0.572 1.000 0.000 0.000 0.000 0.000
#> SRR037224     1   0.000      0.572 1.000 0.000 0.000 0.000 0.000
#> SRR037225     1   0.418      0.295 0.600 0.000 0.000 0.000 0.400
#> SRR037226     1   0.000      0.572 1.000 0.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR037165     3  0.2793      0.716 0.000 0.200 0.800 0.000 0.000 0.000
#> SRR037166     2  0.3804     -0.102 0.000 0.576 0.424 0.000 0.000 0.000
#> SRR037167     4  0.0000      0.908 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR037168     4  0.2996      0.742 0.228 0.000 0.000 0.772 0.000 0.000
#> SRR037169     4  0.3756      0.472 0.400 0.000 0.000 0.600 0.000 0.000
#> SRR037170     4  0.2996      0.742 0.228 0.000 0.000 0.772 0.000 0.000
#> SRR037171     2  0.3984      0.645 0.008 0.596 0.000 0.000 0.000 0.396
#> SRR037172     2  0.3984      0.645 0.008 0.596 0.000 0.000 0.000 0.396
#> SRR037173     2  0.3984      0.645 0.008 0.596 0.000 0.000 0.000 0.396
#> SRR037174     2  0.3984      0.645 0.008 0.596 0.000 0.000 0.000 0.396
#> SRR037175     2  0.3984      0.645 0.008 0.596 0.000 0.000 0.000 0.396
#> SRR037176     2  0.3984      0.645 0.008 0.596 0.000 0.000 0.000 0.396
#> SRR037177     4  0.0865      0.886 0.000 0.036 0.000 0.964 0.000 0.000
#> SRR037182     4  0.0000      0.908 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR037183     4  0.0000      0.908 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR037184     2  0.0146      0.617 0.000 0.996 0.004 0.000 0.000 0.000
#> SRR037185     4  0.2491      0.777 0.000 0.164 0.000 0.836 0.000 0.000
#> SRR037186     2  0.0146      0.617 0.000 0.996 0.004 0.000 0.000 0.000
#> SRR037187     2  0.0146      0.617 0.000 0.996 0.004 0.000 0.000 0.000
#> SRR037188     4  0.0000      0.908 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR037178     3  0.0000      0.970 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR037179     3  0.0000      0.970 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR037180     3  0.0000      0.970 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR037181     3  0.0000      0.970 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR037189     2  0.0146      0.615 0.000 0.996 0.000 0.004 0.000 0.000
#> SRR037190     2  0.3984      0.645 0.008 0.596 0.000 0.000 0.000 0.396
#> SRR037191     2  0.3984      0.645 0.008 0.596 0.000 0.000 0.000 0.396
#> SRR037192     2  0.0146      0.617 0.000 0.996 0.004 0.000 0.000 0.000
#> SRR037193     3  0.0000      0.970 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR037194     3  0.0000      0.970 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR037195     3  0.1765      0.882 0.000 0.096 0.904 0.000 0.000 0.000
#> SRR037196     4  0.0000      0.908 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR037197     4  0.2996      0.742 0.228 0.000 0.000 0.772 0.000 0.000
#> SRR037198     4  0.0000      0.908 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR037199     1  0.5917     -0.292 0.400 0.000 0.208 0.000 0.392 0.000
#> SRR037200     5  0.3756      0.415 0.400 0.000 0.000 0.000 0.600 0.000
#> SRR037201     5  0.3756      0.415 0.400 0.000 0.000 0.000 0.600 0.000
#> SRR037202     1  0.0260      0.589 0.992 0.000 0.000 0.000 0.008 0.000
#> SRR037203     1  0.0260      0.589 0.992 0.000 0.000 0.000 0.008 0.000
#> SRR037204     1  0.2854      0.353 0.792 0.000 0.000 0.000 0.208 0.000
#> SRR037205     1  0.0260      0.589 0.992 0.000 0.000 0.000 0.008 0.000
#> SRR037206     6  0.0000      1.000 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR037207     6  0.0000      1.000 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR037208     3  0.0000      0.970 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR037209     3  0.0000      0.970 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR037210     6  0.0000      1.000 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR037211     6  0.0000      1.000 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR037212     4  0.0000      0.908 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR037213     4  0.0000      0.908 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR037219     4  0.0000      0.908 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR037214     4  0.0000      0.908 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR037215     3  0.0000      0.970 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR037216     6  0.0000      1.000 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR037217     3  0.0000      0.970 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR037218     3  0.0000      0.970 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR037220     5  0.0000      0.747 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR037221     5  0.0000      0.747 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR037222     5  0.0000      0.747 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR037223     1  0.3774      0.457 0.592 0.000 0.000 0.000 0.408 0.000
#> SRR037224     1  0.3774      0.457 0.592 0.000 0.000 0.000 0.408 0.000
#> SRR037225     5  0.0000      0.747 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR037226     1  0.3774      0.457 0.592 0.000 0.000 0.000 0.408 0.000

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

consensus_heatmap(res, k = 2)

plot of chunk tab-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 15332 rows and 62 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#>   Subgroups are detected by 'mclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 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           0.994       0.997         0.3589 0.645   0.645
#> 3 3 1.000           0.988       0.987         0.8079 0.700   0.535
#> 4 4 1.000           0.958       0.976         0.1356 0.885   0.679
#> 5 5 0.852           0.827       0.857         0.0701 1.000   1.000
#> 6 6 0.951           0.911       0.956         0.0335 0.922   0.698

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> SRR037165     2   0.000      0.996 0.000 1.000
#> SRR037166     2   0.000      0.996 0.000 1.000
#> SRR037167     2   0.000      0.996 0.000 1.000
#> SRR037168     2   0.000      0.996 0.000 1.000
#> SRR037169     2   0.653      0.798 0.168 0.832
#> SRR037170     2   0.000      0.996 0.000 1.000
#> SRR037171     2   0.000      0.996 0.000 1.000
#> SRR037172     2   0.000      0.996 0.000 1.000
#> SRR037173     2   0.000      0.996 0.000 1.000
#> SRR037174     2   0.000      0.996 0.000 1.000
#> SRR037175     2   0.000      0.996 0.000 1.000
#> SRR037176     2   0.000      0.996 0.000 1.000
#> SRR037177     2   0.000      0.996 0.000 1.000
#> SRR037182     2   0.000      0.996 0.000 1.000
#> SRR037183     2   0.000      0.996 0.000 1.000
#> SRR037184     2   0.000      0.996 0.000 1.000
#> SRR037185     2   0.000      0.996 0.000 1.000
#> SRR037186     2   0.000      0.996 0.000 1.000
#> SRR037187     2   0.000      0.996 0.000 1.000
#> SRR037188     2   0.000      0.996 0.000 1.000
#> SRR037178     2   0.000      0.996 0.000 1.000
#> SRR037179     2   0.000      0.996 0.000 1.000
#> SRR037180     2   0.000      0.996 0.000 1.000
#> SRR037181     2   0.000      0.996 0.000 1.000
#> SRR037189     2   0.000      0.996 0.000 1.000
#> SRR037190     2   0.000      0.996 0.000 1.000
#> SRR037191     2   0.000      0.996 0.000 1.000
#> SRR037192     2   0.000      0.996 0.000 1.000
#> SRR037193     2   0.000      0.996 0.000 1.000
#> SRR037194     2   0.000      0.996 0.000 1.000
#> SRR037195     2   0.000      0.996 0.000 1.000
#> SRR037196     2   0.000      0.996 0.000 1.000
#> SRR037197     2   0.000      0.996 0.000 1.000
#> SRR037198     2   0.000      0.996 0.000 1.000
#> SRR037199     1   0.000      1.000 1.000 0.000
#> SRR037200     1   0.000      1.000 1.000 0.000
#> SRR037201     1   0.000      1.000 1.000 0.000
#> SRR037202     1   0.000      1.000 1.000 0.000
#> SRR037203     1   0.000      1.000 1.000 0.000
#> SRR037204     1   0.000      1.000 1.000 0.000
#> SRR037205     1   0.000      1.000 1.000 0.000
#> SRR037206     2   0.000      0.996 0.000 1.000
#> SRR037207     2   0.000      0.996 0.000 1.000
#> SRR037208     2   0.000      0.996 0.000 1.000
#> SRR037209     2   0.000      0.996 0.000 1.000
#> SRR037210     2   0.000      0.996 0.000 1.000
#> SRR037211     2   0.000      0.996 0.000 1.000
#> SRR037212     2   0.000      0.996 0.000 1.000
#> SRR037213     2   0.000      0.996 0.000 1.000
#> SRR037219     2   0.000      0.996 0.000 1.000
#> SRR037214     2   0.000      0.996 0.000 1.000
#> SRR037215     2   0.000      0.996 0.000 1.000
#> SRR037216     2   0.000      0.996 0.000 1.000
#> SRR037217     2   0.000      0.996 0.000 1.000
#> SRR037218     2   0.000      0.996 0.000 1.000
#> SRR037220     1   0.000      1.000 1.000 0.000
#> SRR037221     1   0.000      1.000 1.000 0.000
#> SRR037222     1   0.000      1.000 1.000 0.000
#> SRR037223     1   0.000      1.000 1.000 0.000
#> SRR037224     1   0.000      1.000 1.000 0.000
#> SRR037225     1   0.000      1.000 1.000 0.000
#> SRR037226     1   0.000      1.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette p1    p2    p3
#> SRR037165     2  0.0747      0.988  0 0.984 0.016
#> SRR037166     2  0.0747      0.988  0 0.984 0.016
#> SRR037167     2  0.0747      0.988  0 0.984 0.016
#> SRR037168     2  0.1163      0.983  0 0.972 0.028
#> SRR037169     2  0.1163      0.983  0 0.972 0.028
#> SRR037170     2  0.1031      0.985  0 0.976 0.024
#> SRR037171     2  0.0000      0.988  0 1.000 0.000
#> SRR037172     2  0.0000      0.988  0 1.000 0.000
#> SRR037173     2  0.0000      0.988  0 1.000 0.000
#> SRR037174     2  0.0000      0.988  0 1.000 0.000
#> SRR037175     2  0.0000      0.988  0 1.000 0.000
#> SRR037176     2  0.0000      0.988  0 1.000 0.000
#> SRR037177     2  0.0747      0.988  0 0.984 0.016
#> SRR037182     3  0.1529      0.982  0 0.040 0.960
#> SRR037183     3  0.1529      0.982  0 0.040 0.960
#> SRR037184     2  0.0000      0.988  0 1.000 0.000
#> SRR037185     2  0.0747      0.988  0 0.984 0.016
#> SRR037186     2  0.0000      0.988  0 1.000 0.000
#> SRR037187     2  0.0000      0.988  0 1.000 0.000
#> SRR037188     3  0.1529      0.982  0 0.040 0.960
#> SRR037178     3  0.1163      0.988  0 0.028 0.972
#> SRR037179     3  0.1163      0.988  0 0.028 0.972
#> SRR037180     3  0.1163      0.988  0 0.028 0.972
#> SRR037181     3  0.1163      0.988  0 0.028 0.972
#> SRR037189     2  0.0000      0.988  0 1.000 0.000
#> SRR037190     2  0.0000      0.988  0 1.000 0.000
#> SRR037191     2  0.0000      0.988  0 1.000 0.000
#> SRR037192     2  0.0000      0.988  0 1.000 0.000
#> SRR037193     2  0.1031      0.985  0 0.976 0.024
#> SRR037194     2  0.1031      0.985  0 0.976 0.024
#> SRR037195     2  0.1031      0.985  0 0.976 0.024
#> SRR037196     2  0.1031      0.985  0 0.976 0.024
#> SRR037197     2  0.1163      0.983  0 0.972 0.028
#> SRR037198     2  0.1031      0.985  0 0.976 0.024
#> SRR037199     1  0.0000      1.000  1 0.000 0.000
#> SRR037200     1  0.0000      1.000  1 0.000 0.000
#> SRR037201     1  0.0000      1.000  1 0.000 0.000
#> SRR037202     1  0.0000      1.000  1 0.000 0.000
#> SRR037203     1  0.0000      1.000  1 0.000 0.000
#> SRR037204     1  0.0000      1.000  1 0.000 0.000
#> SRR037205     1  0.0000      1.000  1 0.000 0.000
#> SRR037206     3  0.0000      0.970  0 0.000 1.000
#> SRR037207     3  0.0000      0.970  0 0.000 1.000
#> SRR037208     3  0.1163      0.988  0 0.028 0.972
#> SRR037209     3  0.1163      0.988  0 0.028 0.972
#> SRR037210     3  0.0000      0.970  0 0.000 1.000
#> SRR037211     3  0.0000      0.970  0 0.000 1.000
#> SRR037212     3  0.1529      0.982  0 0.040 0.960
#> SRR037213     3  0.1529      0.982  0 0.040 0.960
#> SRR037219     3  0.1529      0.982  0 0.040 0.960
#> SRR037214     3  0.1163      0.988  0 0.028 0.972
#> SRR037215     3  0.1163      0.988  0 0.028 0.972
#> SRR037216     3  0.0000      0.970  0 0.000 1.000
#> SRR037217     3  0.1163      0.988  0 0.028 0.972
#> SRR037218     3  0.1163      0.988  0 0.028 0.972
#> SRR037220     1  0.0000      1.000  1 0.000 0.000
#> SRR037221     1  0.0000      1.000  1 0.000 0.000
#> SRR037222     1  0.0000      1.000  1 0.000 0.000
#> SRR037223     1  0.0000      1.000  1 0.000 0.000
#> SRR037224     1  0.0000      1.000  1 0.000 0.000
#> SRR037225     1  0.0000      1.000  1 0.000 0.000
#> SRR037226     1  0.0000      1.000  1 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette p1    p2    p3    p4
#> SRR037165     2  0.1211    0.97237  0 0.960 0.000 0.040
#> SRR037166     2  0.1211    0.97237  0 0.960 0.000 0.040
#> SRR037167     2  0.1211    0.97237  0 0.960 0.000 0.040
#> SRR037168     4  0.0000    0.93747  0 0.000 0.000 1.000
#> SRR037169     4  0.0000    0.93747  0 0.000 0.000 1.000
#> SRR037170     4  0.0000    0.93747  0 0.000 0.000 1.000
#> SRR037171     2  0.0000    0.97311  0 1.000 0.000 0.000
#> SRR037172     2  0.0000    0.97311  0 1.000 0.000 0.000
#> SRR037173     2  0.0000    0.97311  0 1.000 0.000 0.000
#> SRR037174     2  0.0000    0.97311  0 1.000 0.000 0.000
#> SRR037175     2  0.0000    0.97311  0 1.000 0.000 0.000
#> SRR037176     2  0.0000    0.97311  0 1.000 0.000 0.000
#> SRR037177     2  0.1211    0.97237  0 0.960 0.000 0.040
#> SRR037182     4  0.0592    0.94164  0 0.000 0.016 0.984
#> SRR037183     4  0.0592    0.94164  0 0.000 0.016 0.984
#> SRR037184     2  0.0000    0.97311  0 1.000 0.000 0.000
#> SRR037185     2  0.1211    0.97237  0 0.960 0.000 0.040
#> SRR037186     2  0.0000    0.97311  0 1.000 0.000 0.000
#> SRR037187     2  0.0000    0.97311  0 1.000 0.000 0.000
#> SRR037188     4  0.0592    0.94164  0 0.000 0.016 0.984
#> SRR037178     3  0.1211    0.97899  0 0.000 0.960 0.040
#> SRR037179     3  0.1211    0.97899  0 0.000 0.960 0.040
#> SRR037180     3  0.1211    0.97899  0 0.000 0.960 0.040
#> SRR037181     3  0.1211    0.97899  0 0.000 0.960 0.040
#> SRR037189     2  0.1211    0.97237  0 0.960 0.000 0.040
#> SRR037190     2  0.0000    0.97311  0 1.000 0.000 0.000
#> SRR037191     2  0.1022    0.97351  0 0.968 0.000 0.032
#> SRR037192     2  0.0000    0.97311  0 1.000 0.000 0.000
#> SRR037193     2  0.1557    0.96697  0 0.944 0.000 0.056
#> SRR037194     2  0.1557    0.96697  0 0.944 0.000 0.056
#> SRR037195     2  0.1557    0.96697  0 0.944 0.000 0.056
#> SRR037196     2  0.1557    0.96697  0 0.944 0.000 0.056
#> SRR037197     4  0.0000    0.93747  0 0.000 0.000 1.000
#> SRR037198     2  0.1557    0.96697  0 0.944 0.000 0.056
#> SRR037199     1  0.0000    1.00000  1 0.000 0.000 0.000
#> SRR037200     1  0.0000    1.00000  1 0.000 0.000 0.000
#> SRR037201     1  0.0000    1.00000  1 0.000 0.000 0.000
#> SRR037202     1  0.0000    1.00000  1 0.000 0.000 0.000
#> SRR037203     1  0.0000    1.00000  1 0.000 0.000 0.000
#> SRR037204     1  0.0000    1.00000  1 0.000 0.000 0.000
#> SRR037205     1  0.0000    1.00000  1 0.000 0.000 0.000
#> SRR037206     3  0.0000    0.96266  0 0.000 1.000 0.000
#> SRR037207     3  0.0000    0.96266  0 0.000 1.000 0.000
#> SRR037208     3  0.1211    0.97899  0 0.000 0.960 0.040
#> SRR037209     3  0.1211    0.97899  0 0.000 0.960 0.040
#> SRR037210     3  0.0000    0.96266  0 0.000 1.000 0.000
#> SRR037211     3  0.0000    0.96266  0 0.000 1.000 0.000
#> SRR037212     4  0.0592    0.94164  0 0.000 0.016 0.984
#> SRR037213     4  0.0592    0.94164  0 0.000 0.016 0.984
#> SRR037219     4  0.0592    0.94164  0 0.000 0.016 0.984
#> SRR037214     4  0.4998    0.00292  0 0.000 0.488 0.512
#> SRR037215     3  0.1211    0.97899  0 0.000 0.960 0.040
#> SRR037216     3  0.0000    0.96266  0 0.000 1.000 0.000
#> SRR037217     3  0.1211    0.97899  0 0.000 0.960 0.040
#> SRR037218     3  0.1211    0.97899  0 0.000 0.960 0.040
#> SRR037220     1  0.0000    1.00000  1 0.000 0.000 0.000
#> SRR037221     1  0.0000    1.00000  1 0.000 0.000 0.000
#> SRR037222     1  0.0000    1.00000  1 0.000 0.000 0.000
#> SRR037223     1  0.0000    1.00000  1 0.000 0.000 0.000
#> SRR037224     1  0.0000    1.00000  1 0.000 0.000 0.000
#> SRR037225     1  0.0000    1.00000  1 0.000 0.000 0.000
#> SRR037226     1  0.0000    1.00000  1 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette p1    p2    p3    p4 p5
#> SRR037165     2  0.2813      0.691  0 0.832 0.000 0.000 NA
#> SRR037166     2  0.2852      0.690  0 0.828 0.000 0.000 NA
#> SRR037167     2  0.3837      0.651  0 0.692 0.000 0.000 NA
#> SRR037168     4  0.5338      0.729  0 0.072 0.000 0.604 NA
#> SRR037169     4  0.5459      0.707  0 0.072 0.000 0.568 NA
#> SRR037170     4  0.5353      0.726  0 0.072 0.000 0.600 NA
#> SRR037171     2  0.4242      0.561  0 0.572 0.000 0.000 NA
#> SRR037172     2  0.4242      0.561  0 0.572 0.000 0.000 NA
#> SRR037173     2  0.4114      0.589  0 0.624 0.000 0.000 NA
#> SRR037174     2  0.4114      0.589  0 0.624 0.000 0.000 NA
#> SRR037175     2  0.4242      0.561  0 0.572 0.000 0.000 NA
#> SRR037176     2  0.4242      0.561  0 0.572 0.000 0.000 NA
#> SRR037177     2  0.3636      0.665  0 0.728 0.000 0.000 NA
#> SRR037182     4  0.0794      0.838  0 0.028 0.000 0.972 NA
#> SRR037183     4  0.0510      0.839  0 0.016 0.000 0.984 NA
#> SRR037184     2  0.0000      0.706  0 1.000 0.000 0.000 NA
#> SRR037185     2  0.3707      0.661  0 0.716 0.000 0.000 NA
#> SRR037186     2  0.0000      0.706  0 1.000 0.000 0.000 NA
#> SRR037187     2  0.0000      0.706  0 1.000 0.000 0.000 NA
#> SRR037188     4  0.0794      0.838  0 0.028 0.000 0.972 NA
#> SRR037178     3  0.0000      0.998  0 0.000 1.000 0.000 NA
#> SRR037179     3  0.0000      0.998  0 0.000 1.000 0.000 NA
#> SRR037180     3  0.0000      0.998  0 0.000 1.000 0.000 NA
#> SRR037181     3  0.0000      0.998  0 0.000 1.000 0.000 NA
#> SRR037189     2  0.0703      0.706  0 0.976 0.000 0.000 NA
#> SRR037190     2  0.3684      0.626  0 0.720 0.000 0.000 NA
#> SRR037191     2  0.4242      0.561  0 0.572 0.000 0.000 NA
#> SRR037192     2  0.0000      0.706  0 1.000 0.000 0.000 NA
#> SRR037193     2  0.3876      0.648  0 0.684 0.000 0.000 NA
#> SRR037194     2  0.3876      0.648  0 0.684 0.000 0.000 NA
#> SRR037195     2  0.3876      0.648  0 0.684 0.000 0.000 NA
#> SRR037196     2  0.3949      0.637  0 0.668 0.000 0.000 NA
#> SRR037197     4  0.5322      0.731  0 0.072 0.000 0.608 NA
#> SRR037198     2  0.3932      0.640  0 0.672 0.000 0.000 NA
#> SRR037199     1  0.0000      1.000  1 0.000 0.000 0.000 NA
#> SRR037200     1  0.0000      1.000  1 0.000 0.000 0.000 NA
#> SRR037201     1  0.0000      1.000  1 0.000 0.000 0.000 NA
#> SRR037202     1  0.0000      1.000  1 0.000 0.000 0.000 NA
#> SRR037203     1  0.0000      1.000  1 0.000 0.000 0.000 NA
#> SRR037204     1  0.0000      1.000  1 0.000 0.000 0.000 NA
#> SRR037205     1  0.0000      1.000  1 0.000 0.000 0.000 NA
#> SRR037206     3  0.0000      0.998  0 0.000 1.000 0.000 NA
#> SRR037207     3  0.0000      0.998  0 0.000 1.000 0.000 NA
#> SRR037208     3  0.0162      0.997  0 0.000 0.996 0.004 NA
#> SRR037209     3  0.0162      0.997  0 0.000 0.996 0.004 NA
#> SRR037210     3  0.0000      0.998  0 0.000 1.000 0.000 NA
#> SRR037211     3  0.0000      0.998  0 0.000 1.000 0.000 NA
#> SRR037212     4  0.0510      0.839  0 0.016 0.000 0.984 NA
#> SRR037213     4  0.0510      0.839  0 0.016 0.000 0.984 NA
#> SRR037219     4  0.0794      0.838  0 0.028 0.000 0.972 NA
#> SRR037214     4  0.3210      0.667  0 0.000 0.212 0.788 NA
#> SRR037215     3  0.0162      0.997  0 0.000 0.996 0.004 NA
#> SRR037216     3  0.0000      0.998  0 0.000 1.000 0.000 NA
#> SRR037217     3  0.0162      0.997  0 0.000 0.996 0.004 NA
#> SRR037218     3  0.0162      0.997  0 0.000 0.996 0.004 NA
#> SRR037220     1  0.0000      1.000  1 0.000 0.000 0.000 NA
#> SRR037221     1  0.0000      1.000  1 0.000 0.000 0.000 NA
#> SRR037222     1  0.0000      1.000  1 0.000 0.000 0.000 NA
#> SRR037223     1  0.0000      1.000  1 0.000 0.000 0.000 NA
#> SRR037224     1  0.0000      1.000  1 0.000 0.000 0.000 NA
#> SRR037225     1  0.0000      1.000  1 0.000 0.000 0.000 NA
#> SRR037226     1  0.0000      1.000  1 0.000 0.000 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
#> SRR037165     4  0.0458      0.883  0 0.016 0.000 0.984 0.000 0.000
#> SRR037166     4  0.0458      0.883  0 0.016 0.000 0.984 0.000 0.000
#> SRR037167     4  0.1075      0.901  0 0.000 0.000 0.952 0.048 0.000
#> SRR037168     5  0.0363      1.000  0 0.000 0.000 0.012 0.988 0.000
#> SRR037169     5  0.0363      1.000  0 0.000 0.000 0.012 0.988 0.000
#> SRR037170     5  0.0363      1.000  0 0.000 0.000 0.012 0.988 0.000
#> SRR037171     2  0.0458      0.767  0 0.984 0.000 0.016 0.000 0.000
#> SRR037172     2  0.0000      0.769  0 1.000 0.000 0.000 0.000 0.000
#> SRR037173     2  0.3531      0.581  0 0.672 0.000 0.328 0.000 0.000
#> SRR037174     2  0.3531      0.581  0 0.672 0.000 0.328 0.000 0.000
#> SRR037175     2  0.0000      0.769  0 1.000 0.000 0.000 0.000 0.000
#> SRR037176     2  0.0000      0.769  0 1.000 0.000 0.000 0.000 0.000
#> SRR037177     4  0.1075      0.901  0 0.000 0.000 0.952 0.048 0.000
#> SRR037182     6  0.0000      0.962  0 0.000 0.000 0.000 0.000 1.000
#> SRR037183     6  0.0000      0.962  0 0.000 0.000 0.000 0.000 1.000
#> SRR037184     4  0.2697      0.744  0 0.188 0.000 0.812 0.000 0.000
#> SRR037185     4  0.1075      0.901  0 0.000 0.000 0.952 0.048 0.000
#> SRR037186     4  0.2697      0.744  0 0.188 0.000 0.812 0.000 0.000
#> SRR037187     4  0.2697      0.744  0 0.188 0.000 0.812 0.000 0.000
#> SRR037188     6  0.0000      0.962  0 0.000 0.000 0.000 0.000 1.000
#> SRR037178     3  0.0000      0.996  0 0.000 1.000 0.000 0.000 0.000
#> SRR037179     3  0.0000      0.996  0 0.000 1.000 0.000 0.000 0.000
#> SRR037180     3  0.0000      0.996  0 0.000 1.000 0.000 0.000 0.000
#> SRR037181     3  0.0000      0.996  0 0.000 1.000 0.000 0.000 0.000
#> SRR037189     4  0.1713      0.884  0 0.044 0.000 0.928 0.028 0.000
#> SRR037190     2  0.3867      0.160  0 0.512 0.000 0.488 0.000 0.000
#> SRR037191     2  0.0000      0.769  0 1.000 0.000 0.000 0.000 0.000
#> SRR037192     4  0.2697      0.744  0 0.188 0.000 0.812 0.000 0.000
#> SRR037193     4  0.1075      0.901  0 0.000 0.000 0.952 0.048 0.000
#> SRR037194     4  0.1075      0.901  0 0.000 0.000 0.952 0.048 0.000
#> SRR037195     4  0.1075      0.901  0 0.000 0.000 0.952 0.048 0.000
#> SRR037196     4  0.1075      0.901  0 0.000 0.000 0.952 0.048 0.000
#> SRR037197     5  0.0363      1.000  0 0.000 0.000 0.012 0.988 0.000
#> SRR037198     4  0.1075      0.901  0 0.000 0.000 0.952 0.048 0.000
#> SRR037199     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR037200     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR037201     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR037202     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR037203     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR037204     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR037205     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR037206     3  0.0363      0.993  0 0.000 0.988 0.000 0.012 0.000
#> SRR037207     3  0.0363      0.993  0 0.000 0.988 0.000 0.012 0.000
#> SRR037208     3  0.0000      0.996  0 0.000 1.000 0.000 0.000 0.000
#> SRR037209     3  0.0000      0.996  0 0.000 1.000 0.000 0.000 0.000
#> SRR037210     3  0.0363      0.993  0 0.000 0.988 0.000 0.012 0.000
#> SRR037211     3  0.0363      0.993  0 0.000 0.988 0.000 0.012 0.000
#> SRR037212     6  0.0000      0.962  0 0.000 0.000 0.000 0.000 1.000
#> SRR037213     6  0.0000      0.962  0 0.000 0.000 0.000 0.000 1.000
#> SRR037219     6  0.0000      0.962  0 0.000 0.000 0.000 0.000 1.000
#> SRR037214     6  0.2491      0.757  0 0.000 0.164 0.000 0.000 0.836
#> SRR037215     3  0.0000      0.996  0 0.000 1.000 0.000 0.000 0.000
#> SRR037216     3  0.0363      0.993  0 0.000 0.988 0.000 0.012 0.000
#> SRR037217     3  0.0000      0.996  0 0.000 1.000 0.000 0.000 0.000
#> SRR037218     3  0.0000      0.996  0 0.000 1.000 0.000 0.000 0.000
#> SRR037220     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR037221     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR037222     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR037223     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR037224     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR037225     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR037226     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

plot of chunk tab-ATC-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 15332 rows and 62 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#>   Subgroups are detected by 'NMF' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 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 0.747           0.904       0.948         0.4658 0.505   0.505
#> 3 3 0.584           0.598       0.784         0.3427 0.879   0.765
#> 4 4 0.592           0.807       0.846         0.1937 0.776   0.487
#> 5 5 0.713           0.736       0.825         0.0465 0.887   0.610
#> 6 6 0.770           0.684       0.816         0.0226 0.934   0.738

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
#> SRR037165     2   0.000      0.996 0.000 1.000
#> SRR037166     2   0.000      0.996 0.000 1.000
#> SRR037167     1   0.932      0.616 0.652 0.348
#> SRR037168     1   0.000      0.871 1.000 0.000
#> SRR037169     1   0.000      0.871 1.000 0.000
#> SRR037170     1   0.000      0.871 1.000 0.000
#> SRR037171     2   0.000      0.996 0.000 1.000
#> SRR037172     2   0.000      0.996 0.000 1.000
#> SRR037173     2   0.000      0.996 0.000 1.000
#> SRR037174     2   0.000      0.996 0.000 1.000
#> SRR037175     2   0.000      0.996 0.000 1.000
#> SRR037176     2   0.000      0.996 0.000 1.000
#> SRR037177     2   0.000      0.996 0.000 1.000
#> SRR037182     1   0.529      0.832 0.880 0.120
#> SRR037183     1   0.000      0.871 1.000 0.000
#> SRR037184     2   0.000      0.996 0.000 1.000
#> SRR037185     2   0.000      0.996 0.000 1.000
#> SRR037186     2   0.000      0.996 0.000 1.000
#> SRR037187     2   0.000      0.996 0.000 1.000
#> SRR037188     1   0.839      0.720 0.732 0.268
#> SRR037178     2   0.000      0.996 0.000 1.000
#> SRR037179     2   0.000      0.996 0.000 1.000
#> SRR037180     2   0.000      0.996 0.000 1.000
#> SRR037181     2   0.000      0.996 0.000 1.000
#> SRR037189     2   0.000      0.996 0.000 1.000
#> SRR037190     2   0.000      0.996 0.000 1.000
#> SRR037191     2   0.000      0.996 0.000 1.000
#> SRR037192     2   0.000      0.996 0.000 1.000
#> SRR037193     2   0.000      0.996 0.000 1.000
#> SRR037194     2   0.000      0.996 0.000 1.000
#> SRR037195     2   0.000      0.996 0.000 1.000
#> SRR037196     1   0.871      0.694 0.708 0.292
#> SRR037197     1   0.000      0.871 1.000 0.000
#> SRR037198     1   0.991      0.419 0.556 0.444
#> SRR037199     2   0.000      0.996 0.000 1.000
#> SRR037200     1   0.952      0.575 0.628 0.372
#> SRR037201     1   0.909      0.652 0.676 0.324
#> SRR037202     1   0.000      0.871 1.000 0.000
#> SRR037203     1   0.000      0.871 1.000 0.000
#> SRR037204     1   0.000      0.871 1.000 0.000
#> SRR037205     1   0.000      0.871 1.000 0.000
#> SRR037206     2   0.000      0.996 0.000 1.000
#> SRR037207     2   0.000      0.996 0.000 1.000
#> SRR037208     2   0.000      0.996 0.000 1.000
#> SRR037209     2   0.000      0.996 0.000 1.000
#> SRR037210     2   0.000      0.996 0.000 1.000
#> SRR037211     2   0.000      0.996 0.000 1.000
#> SRR037212     1   0.574      0.825 0.864 0.136
#> SRR037213     1   0.662      0.803 0.828 0.172
#> SRR037219     1   0.000      0.871 1.000 0.000
#> SRR037214     1   0.993      0.398 0.548 0.452
#> SRR037215     2   0.000      0.996 0.000 1.000
#> SRR037216     2   0.000      0.996 0.000 1.000
#> SRR037217     2   0.000      0.996 0.000 1.000
#> SRR037218     2   0.000      0.996 0.000 1.000
#> SRR037220     2   0.552      0.819 0.128 0.872
#> SRR037221     1   0.118      0.868 0.984 0.016
#> SRR037222     1   0.634      0.811 0.840 0.160
#> SRR037223     1   0.000      0.871 1.000 0.000
#> SRR037224     1   0.000      0.871 1.000 0.000
#> SRR037225     1   0.000      0.871 1.000 0.000
#> SRR037226     1   0.000      0.871 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
#> SRR037165     2  0.0983     0.6755 0.016 0.980 0.004
#> SRR037166     2  0.2446     0.6331 0.012 0.936 0.052
#> SRR037167     3  0.6442     0.4630 0.004 0.432 0.564
#> SRR037168     3  0.0000     0.6853 0.000 0.000 1.000
#> SRR037169     3  0.0424     0.6814 0.008 0.000 0.992
#> SRR037170     3  0.0000     0.6853 0.000 0.000 1.000
#> SRR037171     2  0.5431     0.7952 0.284 0.716 0.000
#> SRR037172     2  0.5327     0.7932 0.272 0.728 0.000
#> SRR037173     2  0.3038     0.7289 0.104 0.896 0.000
#> SRR037174     2  0.2711     0.7211 0.088 0.912 0.000
#> SRR037175     2  0.5431     0.7952 0.284 0.716 0.000
#> SRR037176     2  0.5431     0.7952 0.284 0.716 0.000
#> SRR037177     2  0.6521    -0.4018 0.004 0.500 0.496
#> SRR037182     3  0.3116     0.6589 0.000 0.108 0.892
#> SRR037183     3  0.0000     0.6853 0.000 0.000 1.000
#> SRR037184     2  0.0000     0.6667 0.000 1.000 0.000
#> SRR037185     2  0.6520    -0.3858 0.004 0.508 0.488
#> SRR037186     2  0.0475     0.6609 0.004 0.992 0.004
#> SRR037187     2  0.0237     0.6638 0.004 0.996 0.000
#> SRR037188     3  0.5291     0.5791 0.000 0.268 0.732
#> SRR037178     2  0.5859     0.7932 0.344 0.656 0.000
#> SRR037179     2  0.5859     0.7932 0.344 0.656 0.000
#> SRR037180     2  0.5859     0.7932 0.344 0.656 0.000
#> SRR037181     2  0.5859     0.7932 0.344 0.656 0.000
#> SRR037189     2  0.4834     0.3597 0.004 0.792 0.204
#> SRR037190     2  0.2537     0.7168 0.080 0.920 0.000
#> SRR037191     2  0.5706     0.7961 0.320 0.680 0.000
#> SRR037192     2  0.0237     0.6638 0.004 0.996 0.000
#> SRR037193     2  0.5706     0.7961 0.320 0.680 0.000
#> SRR037194     2  0.5363     0.7940 0.276 0.724 0.000
#> SRR037195     2  0.5061     0.7703 0.208 0.784 0.008
#> SRR037196     3  0.5905     0.5251 0.000 0.352 0.648
#> SRR037197     3  0.0000     0.6853 0.000 0.000 1.000
#> SRR037198     3  0.6386     0.4791 0.004 0.412 0.584
#> SRR037199     1  0.1529     0.6860 0.960 0.040 0.000
#> SRR037200     1  0.0592     0.7135 0.988 0.012 0.000
#> SRR037201     1  0.0592     0.7135 0.988 0.012 0.000
#> SRR037202     1  0.6260     0.2861 0.552 0.000 0.448
#> SRR037203     3  0.6225    -0.0729 0.432 0.000 0.568
#> SRR037204     1  0.5905     0.4425 0.648 0.000 0.352
#> SRR037205     1  0.6045     0.4083 0.620 0.000 0.380
#> SRR037206     2  0.5905     0.7898 0.352 0.648 0.000
#> SRR037207     2  0.5926     0.7870 0.356 0.644 0.000
#> SRR037208     2  0.5905     0.7900 0.352 0.648 0.000
#> SRR037209     2  0.5905     0.7900 0.352 0.648 0.000
#> SRR037210     2  0.5926     0.7870 0.356 0.644 0.000
#> SRR037211     2  0.5905     0.7898 0.352 0.648 0.000
#> SRR037212     3  0.0592     0.6845 0.000 0.012 0.988
#> SRR037213     3  0.1529     0.6797 0.000 0.040 0.960
#> SRR037219     3  0.0000     0.6853 0.000 0.000 1.000
#> SRR037214     3  0.8297     0.3320 0.168 0.200 0.632
#> SRR037215     2  0.5905     0.7900 0.352 0.648 0.000
#> SRR037216     2  0.5926     0.7870 0.356 0.644 0.000
#> SRR037217     2  0.5882     0.7918 0.348 0.652 0.000
#> SRR037218     2  0.5882     0.7918 0.348 0.652 0.000
#> SRR037220     1  0.0892     0.7078 0.980 0.020 0.000
#> SRR037221     1  0.2096     0.7003 0.944 0.004 0.052
#> SRR037222     1  0.0661     0.7144 0.988 0.004 0.008
#> SRR037223     3  0.5926     0.1472 0.356 0.000 0.644
#> SRR037224     3  0.6295    -0.1879 0.472 0.000 0.528
#> SRR037225     1  0.5905     0.4425 0.648 0.000 0.352
#> SRR037226     3  0.6309    -0.2528 0.496 0.000 0.504

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> SRR037165     2  0.1867      0.870 0.000 0.928 0.000 0.072
#> SRR037166     2  0.1867      0.870 0.000 0.928 0.000 0.072
#> SRR037167     4  0.4121      0.694 0.020 0.184 0.000 0.796
#> SRR037168     4  0.4775      0.771 0.232 0.028 0.000 0.740
#> SRR037169     4  0.4277      0.732 0.280 0.000 0.000 0.720
#> SRR037170     4  0.4764      0.775 0.220 0.032 0.000 0.748
#> SRR037171     2  0.2586      0.870 0.000 0.912 0.040 0.048
#> SRR037172     2  0.2319      0.872 0.000 0.924 0.036 0.040
#> SRR037173     2  0.1109      0.881 0.000 0.968 0.028 0.004
#> SRR037174     2  0.1388      0.881 0.000 0.960 0.028 0.012
#> SRR037175     2  0.2494      0.869 0.000 0.916 0.036 0.048
#> SRR037176     2  0.2660      0.866 0.000 0.908 0.036 0.056
#> SRR037177     2  0.4837      0.606 0.000 0.648 0.004 0.348
#> SRR037182     4  0.4610      0.798 0.052 0.008 0.136 0.804
#> SRR037183     4  0.5151      0.798 0.140 0.000 0.100 0.760
#> SRR037184     2  0.3279      0.868 0.000 0.872 0.032 0.096
#> SRR037185     2  0.4608      0.681 0.000 0.692 0.004 0.304
#> SRR037186     2  0.3443      0.845 0.000 0.848 0.016 0.136
#> SRR037187     2  0.3447      0.851 0.000 0.852 0.020 0.128
#> SRR037188     4  0.4131      0.769 0.008 0.020 0.156 0.816
#> SRR037178     3  0.3834      0.867 0.000 0.076 0.848 0.076
#> SRR037179     3  0.4039      0.858 0.000 0.084 0.836 0.080
#> SRR037180     3  0.3764      0.868 0.000 0.072 0.852 0.076
#> SRR037181     3  0.3900      0.864 0.000 0.084 0.844 0.072
#> SRR037189     2  0.3498      0.837 0.000 0.832 0.008 0.160
#> SRR037190     2  0.1724      0.881 0.000 0.948 0.032 0.020
#> SRR037191     2  0.3398      0.853 0.000 0.872 0.060 0.068
#> SRR037192     2  0.3447      0.851 0.000 0.852 0.020 0.128
#> SRR037193     2  0.3584      0.842 0.004 0.868 0.064 0.064
#> SRR037194     2  0.3156      0.865 0.000 0.884 0.048 0.068
#> SRR037195     2  0.4617      0.762 0.000 0.764 0.032 0.204
#> SRR037196     4  0.4205      0.763 0.056 0.124 0.000 0.820
#> SRR037197     4  0.4328      0.763 0.244 0.008 0.000 0.748
#> SRR037198     4  0.3890      0.751 0.028 0.132 0.004 0.836
#> SRR037199     3  0.6324      0.510 0.184 0.040 0.704 0.072
#> SRR037200     1  0.7113      0.623 0.596 0.040 0.292 0.072
#> SRR037201     1  0.7113      0.623 0.596 0.040 0.292 0.072
#> SRR037202     1  0.0707      0.805 0.980 0.000 0.000 0.020
#> SRR037203     1  0.1557      0.788 0.944 0.000 0.000 0.056
#> SRR037204     1  0.2868      0.784 0.864 0.000 0.136 0.000
#> SRR037205     1  0.1661      0.806 0.944 0.000 0.052 0.004
#> SRR037206     3  0.1716      0.893 0.000 0.064 0.936 0.000
#> SRR037207     3  0.2281      0.888 0.000 0.096 0.904 0.000
#> SRR037208     3  0.0707      0.887 0.000 0.020 0.980 0.000
#> SRR037209     3  0.0707      0.887 0.000 0.020 0.980 0.000
#> SRR037210     3  0.2281      0.887 0.000 0.096 0.904 0.000
#> SRR037211     3  0.2868      0.863 0.000 0.136 0.864 0.000
#> SRR037212     4  0.4872      0.728 0.028 0.000 0.244 0.728
#> SRR037213     4  0.4964      0.714 0.028 0.000 0.256 0.716
#> SRR037219     4  0.5217      0.793 0.108 0.000 0.136 0.756
#> SRR037214     3  0.3283      0.815 0.020 0.004 0.872 0.104
#> SRR037215     3  0.0707      0.887 0.000 0.020 0.980 0.000
#> SRR037216     3  0.2408      0.884 0.000 0.104 0.896 0.000
#> SRR037217     3  0.1042      0.886 0.000 0.020 0.972 0.008
#> SRR037218     3  0.1042      0.886 0.000 0.020 0.972 0.008
#> SRR037220     1  0.7400      0.705 0.644 0.156 0.128 0.072
#> SRR037221     1  0.5534      0.757 0.764 0.144 0.052 0.040
#> SRR037222     1  0.6379      0.737 0.716 0.152 0.068 0.064
#> SRR037223     1  0.1716      0.781 0.936 0.000 0.000 0.064
#> SRR037224     1  0.1389      0.794 0.952 0.000 0.000 0.048
#> SRR037225     1  0.0188      0.806 0.996 0.000 0.000 0.004
#> SRR037226     1  0.1022      0.801 0.968 0.000 0.000 0.032

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> SRR037165     2  0.6328      0.160 0.000 0.528 0.000 0.228 0.244
#> SRR037166     4  0.6036      0.293 0.000 0.308 0.000 0.548 0.144
#> SRR037167     4  0.2017      0.765 0.000 0.080 0.000 0.912 0.008
#> SRR037168     4  0.0703      0.796 0.024 0.000 0.000 0.976 0.000
#> SRR037169     4  0.1952      0.760 0.084 0.000 0.000 0.912 0.004
#> SRR037170     4  0.0865      0.797 0.024 0.004 0.000 0.972 0.000
#> SRR037171     2  0.1792      0.852 0.000 0.916 0.000 0.000 0.084
#> SRR037172     2  0.1732      0.856 0.000 0.920 0.000 0.000 0.080
#> SRR037173     2  0.0794      0.869 0.000 0.972 0.000 0.000 0.028
#> SRR037174     2  0.0609      0.869 0.000 0.980 0.000 0.000 0.020
#> SRR037175     2  0.1792      0.853 0.000 0.916 0.000 0.000 0.084
#> SRR037176     2  0.1851      0.850 0.000 0.912 0.000 0.000 0.088
#> SRR037177     2  0.3093      0.746 0.000 0.824 0.000 0.168 0.008
#> SRR037182     4  0.5351      0.385 0.008 0.012 0.324 0.624 0.032
#> SRR037183     4  0.4570      0.646 0.028 0.008 0.156 0.776 0.032
#> SRR037184     2  0.1808      0.863 0.000 0.936 0.020 0.004 0.040
#> SRR037185     2  0.2806      0.768 0.000 0.844 0.000 0.152 0.004
#> SRR037186     2  0.1885      0.861 0.000 0.932 0.020 0.004 0.044
#> SRR037187     2  0.1808      0.863 0.000 0.936 0.020 0.004 0.040
#> SRR037188     3  0.5650      0.331 0.004 0.016 0.560 0.380 0.040
#> SRR037178     3  0.2787      0.819 0.000 0.088 0.880 0.004 0.028
#> SRR037179     3  0.2932      0.812 0.000 0.104 0.864 0.000 0.032
#> SRR037180     3  0.2899      0.816 0.000 0.096 0.872 0.004 0.028
#> SRR037181     3  0.2899      0.816 0.000 0.096 0.872 0.004 0.028
#> SRR037189     2  0.1728      0.864 0.000 0.940 0.020 0.004 0.036
#> SRR037190     2  0.0404      0.870 0.000 0.988 0.000 0.000 0.012
#> SRR037191     2  0.2583      0.830 0.000 0.864 0.004 0.000 0.132
#> SRR037192     2  0.1808      0.863 0.000 0.936 0.020 0.004 0.040
#> SRR037193     5  0.4649      0.554 0.000 0.244 0.044 0.004 0.708
#> SRR037194     5  0.4973      0.563 0.000 0.132 0.012 0.120 0.736
#> SRR037195     4  0.4765      0.580 0.000 0.056 0.004 0.708 0.232
#> SRR037196     4  0.1153      0.797 0.008 0.024 0.000 0.964 0.004
#> SRR037197     4  0.0955      0.794 0.028 0.000 0.000 0.968 0.004
#> SRR037198     4  0.1412      0.794 0.008 0.036 0.000 0.952 0.004
#> SRR037199     5  0.5879      0.466 0.200 0.004 0.176 0.000 0.620
#> SRR037200     1  0.5033      0.631 0.716 0.004 0.156 0.000 0.124
#> SRR037201     1  0.4935      0.638 0.724 0.004 0.160 0.000 0.112
#> SRR037202     1  0.0404      0.839 0.988 0.000 0.000 0.012 0.000
#> SRR037203     1  0.1740      0.835 0.932 0.000 0.000 0.056 0.012
#> SRR037204     1  0.1978      0.827 0.932 0.000 0.024 0.012 0.032
#> SRR037205     1  0.0693      0.839 0.980 0.000 0.000 0.012 0.008
#> SRR037206     3  0.2754      0.816 0.000 0.080 0.880 0.000 0.040
#> SRR037207     3  0.4309      0.749 0.000 0.084 0.768 0.000 0.148
#> SRR037208     3  0.1116      0.821 0.000 0.004 0.964 0.004 0.028
#> SRR037209     3  0.1329      0.820 0.000 0.004 0.956 0.008 0.032
#> SRR037210     3  0.4428      0.742 0.000 0.084 0.756 0.000 0.160
#> SRR037211     3  0.4364      0.760 0.000 0.112 0.768 0.000 0.120
#> SRR037212     3  0.2934      0.785 0.004 0.004 0.880 0.076 0.036
#> SRR037213     3  0.2934      0.785 0.004 0.004 0.880 0.076 0.036
#> SRR037219     3  0.6224      0.168 0.072 0.000 0.504 0.396 0.028
#> SRR037214     3  0.1547      0.817 0.000 0.004 0.948 0.016 0.032
#> SRR037215     3  0.1026      0.822 0.000 0.004 0.968 0.004 0.024
#> SRR037216     3  0.4216      0.763 0.000 0.100 0.780 0.000 0.120
#> SRR037217     3  0.0613      0.823 0.000 0.004 0.984 0.004 0.008
#> SRR037218     3  0.0727      0.823 0.000 0.004 0.980 0.004 0.012
#> SRR037220     5  0.5485      0.404 0.284 0.056 0.020 0.000 0.640
#> SRR037221     1  0.3648      0.747 0.792 0.016 0.004 0.000 0.188
#> SRR037222     1  0.4209      0.694 0.744 0.028 0.004 0.000 0.224
#> SRR037223     1  0.2574      0.800 0.876 0.000 0.000 0.112 0.012
#> SRR037224     1  0.2017      0.825 0.912 0.000 0.000 0.080 0.008
#> SRR037225     1  0.2983      0.826 0.868 0.000 0.000 0.056 0.076
#> SRR037226     1  0.1956      0.830 0.916 0.000 0.000 0.076 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
#> SRR037165     4  0.6252     0.3783 0.012 0.216 0.044 0.580 0.000 0.148
#> SRR037166     4  0.4303     0.6775 0.008 0.084 0.036 0.784 0.000 0.088
#> SRR037167     4  0.1419     0.7841 0.016 0.016 0.000 0.952 0.004 0.012
#> SRR037168     4  0.1881     0.7726 0.008 0.004 0.000 0.928 0.020 0.040
#> SRR037169     4  0.3666     0.6771 0.008 0.000 0.000 0.796 0.140 0.056
#> SRR037170     4  0.1835     0.7748 0.008 0.008 0.000 0.932 0.016 0.036
#> SRR037171     2  0.0779     0.9433 0.008 0.976 0.000 0.008 0.000 0.008
#> SRR037172     2  0.0520     0.9457 0.000 0.984 0.000 0.008 0.000 0.008
#> SRR037173     2  0.0291     0.9474 0.000 0.992 0.000 0.004 0.000 0.004
#> SRR037174     2  0.0291     0.9475 0.004 0.992 0.000 0.000 0.000 0.004
#> SRR037175     2  0.0665     0.9445 0.004 0.980 0.000 0.008 0.000 0.008
#> SRR037176     2  0.0924     0.9409 0.008 0.972 0.004 0.008 0.000 0.008
#> SRR037177     2  0.3328     0.7337 0.000 0.788 0.012 0.192 0.000 0.008
#> SRR037182     3  0.6042     0.5344 0.008 0.004 0.592 0.212 0.024 0.160
#> SRR037183     3  0.6862     0.2012 0.012 0.004 0.436 0.344 0.040 0.164
#> SRR037184     2  0.0291     0.9469 0.004 0.992 0.000 0.000 0.000 0.004
#> SRR037185     2  0.3056     0.7789 0.000 0.820 0.012 0.160 0.000 0.008
#> SRR037186     2  0.0551     0.9442 0.004 0.984 0.004 0.000 0.000 0.008
#> SRR037187     2  0.0653     0.9429 0.004 0.980 0.004 0.000 0.000 0.012
#> SRR037188     3  0.4707     0.7152 0.008 0.004 0.736 0.096 0.012 0.144
#> SRR037178     3  0.0767     0.8451 0.012 0.004 0.976 0.000 0.000 0.008
#> SRR037179     3  0.0767     0.8451 0.012 0.004 0.976 0.000 0.000 0.008
#> SRR037180     3  0.0870     0.8449 0.012 0.004 0.972 0.000 0.000 0.012
#> SRR037181     3  0.0862     0.8451 0.016 0.004 0.972 0.000 0.000 0.008
#> SRR037189     2  0.0291     0.9469 0.004 0.992 0.000 0.000 0.000 0.004
#> SRR037190     2  0.0291     0.9475 0.004 0.992 0.000 0.000 0.000 0.004
#> SRR037191     2  0.2219     0.8932 0.016 0.916 0.020 0.012 0.000 0.036
#> SRR037192     2  0.0653     0.9429 0.004 0.980 0.004 0.000 0.000 0.012
#> SRR037193     6  0.7385     0.1776 0.088 0.132 0.080 0.172 0.000 0.528
#> SRR037194     4  0.6579    -0.0208 0.040 0.052 0.060 0.432 0.000 0.416
#> SRR037195     4  0.3999     0.6848 0.012 0.020 0.056 0.800 0.000 0.112
#> SRR037196     4  0.0924     0.7872 0.000 0.004 0.008 0.972 0.008 0.008
#> SRR037197     4  0.1442     0.7811 0.004 0.000 0.000 0.944 0.040 0.012
#> SRR037198     4  0.1026     0.7859 0.000 0.008 0.012 0.968 0.004 0.008
#> SRR037199     1  0.3745     0.7043 0.796 0.000 0.028 0.000 0.144 0.032
#> SRR037200     1  0.3566     0.7942 0.752 0.000 0.024 0.000 0.224 0.000
#> SRR037201     1  0.3566     0.7942 0.752 0.000 0.024 0.000 0.224 0.000
#> SRR037202     5  0.4090    -0.1553 0.384 0.000 0.000 0.004 0.604 0.008
#> SRR037203     5  0.2912     0.4979 0.104 0.000 0.000 0.012 0.856 0.028
#> SRR037204     1  0.4403     0.3982 0.520 0.000 0.008 0.000 0.460 0.012
#> SRR037205     5  0.4072    -0.3459 0.448 0.000 0.000 0.000 0.544 0.008
#> SRR037206     3  0.2823     0.8200 0.036 0.020 0.884 0.012 0.000 0.048
#> SRR037207     3  0.3997     0.7798 0.060 0.024 0.808 0.016 0.000 0.092
#> SRR037208     3  0.1924     0.8355 0.048 0.000 0.920 0.004 0.000 0.028
#> SRR037209     3  0.1924     0.8355 0.048 0.000 0.920 0.004 0.000 0.028
#> SRR037210     3  0.4270     0.7603 0.060 0.024 0.784 0.016 0.000 0.116
#> SRR037211     3  0.3924     0.7808 0.044 0.036 0.816 0.016 0.000 0.088
#> SRR037212     3  0.3103     0.8141 0.016 0.000 0.864 0.024 0.020 0.076
#> SRR037213     3  0.2832     0.8187 0.012 0.000 0.876 0.024 0.012 0.076
#> SRR037219     3  0.5676     0.6534 0.012 0.000 0.668 0.080 0.076 0.164
#> SRR037214     3  0.1908     0.8355 0.012 0.000 0.924 0.020 0.000 0.044
#> SRR037215     3  0.1478     0.8398 0.032 0.000 0.944 0.004 0.000 0.020
#> SRR037216     3  0.3921     0.7784 0.060 0.020 0.808 0.012 0.000 0.100
#> SRR037217     3  0.1421     0.8415 0.028 0.000 0.944 0.000 0.000 0.028
#> SRR037218     3  0.1341     0.8411 0.028 0.000 0.948 0.000 0.000 0.024
#> SRR037220     6  0.5386    -0.1519 0.096 0.008 0.004 0.000 0.312 0.580
#> SRR037221     5  0.5199     0.3023 0.084 0.004 0.004 0.000 0.584 0.324
#> SRR037222     5  0.5290     0.2351 0.084 0.004 0.004 0.000 0.552 0.356
#> SRR037223     5  0.2375     0.5398 0.020 0.000 0.000 0.016 0.896 0.068
#> SRR037224     5  0.0713     0.5925 0.000 0.000 0.000 0.000 0.972 0.028
#> SRR037225     5  0.3513     0.5399 0.060 0.000 0.000 0.000 0.796 0.144
#> SRR037226     5  0.0865     0.5935 0.000 0.000 0.000 0.000 0.964 0.036

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

consensus_heatmap(res, k = 2)

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