cola Report for recount2:SRP057065

Date: 2019-12-26 00:56:30 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 14198 rows and 51 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] 14198    51

Density distribution

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

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

plot of chunk density-heatmap

Suggest the best k

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

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

suggest_best_k(res_list)
The best k 1-PAC Mean silhouette Concordance Optional k
SD:pam 6 1.000 0.952 0.977 ** 2,3
CV:hclust 2 1.000 0.961 0.985 **
CV:kmeans 2 1.000 1.000 1.000 **
CV:pam 2 1.000 0.972 0.989 **
ATC:kmeans 2 1.000 0.991 0.996 **
ATC:skmeans 4 1.000 0.990 0.997 ** 2,3
ATC:pam 4 1.000 0.990 0.996 ** 2,3
ATC:mclust 2 1.000 0.990 0.988 **
CV:NMF 4 0.998 0.951 0.976 ** 2,3
MAD:skmeans 4 0.963 0.956 0.973 ** 2,3
ATC:hclust 6 0.951 0.923 0.960 ** 2,3,4,5
MAD:pam 6 0.946 0.858 0.922 * 2,3,5
SD:skmeans 4 0.941 0.954 0.973 *
CV:mclust 6 0.938 0.923 0.949 * 3,4,5
SD:mclust 5 0.934 0.924 0.958 *
CV:skmeans 3 0.931 0.970 0.984 * 2
MAD:kmeans 3 0.920 0.887 0.948 *
SD:NMF 4 0.912 0.862 0.943 * 3
MAD:NMF 4 0.906 0.842 0.934 * 2
MAD:mclust 5 0.903 0.827 0.933 *
SD:hclust 3 0.843 0.925 0.962
MAD:hclust 3 0.838 0.924 0.961
SD:kmeans 2 0.776 0.847 0.934
ATC:NMF 2 0.754 0.842 0.932

**: 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 0.794           0.944       0.957          0.479 0.523   0.523
#> CV:NMF      2 1.000           0.997       0.999          0.423 0.576   0.576
#> MAD:NMF     2 1.000           0.986       0.993          0.468 0.534   0.534
#> ATC:NMF     2 0.754           0.842       0.932          0.491 0.500   0.500
#> SD:skmeans  2 0.885           0.954       0.979          0.509 0.490   0.490
#> CV:skmeans  2 1.000           0.992       0.996          0.496 0.506   0.506
#> MAD:skmeans 2 1.000           0.986       0.994          0.510 0.490   0.490
#> ATC:skmeans 2 1.000           1.000       1.000          0.510 0.490   0.490
#> SD:mclust   2 0.447           0.862       0.917          0.438 0.534   0.534
#> CV:mclust   2 0.510           0.949       0.954          0.381 0.633   0.633
#> MAD:mclust  2 0.442           0.802       0.834          0.435 0.534   0.534
#> ATC:mclust  2 1.000           0.990       0.988          0.325 0.678   0.678
#> SD:kmeans   2 0.776           0.847       0.934          0.493 0.490   0.490
#> CV:kmeans   2 1.000           1.000       1.000          0.440 0.561   0.561
#> MAD:kmeans  2 0.810           0.939       0.967          0.503 0.490   0.490
#> ATC:kmeans  2 1.000           0.991       0.996          0.475 0.523   0.523
#> SD:pam      2 0.920           0.955       0.981          0.503 0.495   0.495
#> CV:pam      2 1.000           0.972       0.989          0.446 0.547   0.547
#> MAD:pam     2 1.000           0.972       0.988          0.509 0.492   0.492
#> ATC:pam     2 1.000           0.960       0.985          0.466 0.534   0.534
#> SD:hclust   2 0.655           0.904       0.938          0.489 0.492   0.492
#> CV:hclust   2 1.000           0.961       0.985          0.426 0.576   0.576
#> MAD:hclust  2 0.624           0.915       0.941          0.489 0.492   0.492
#> ATC:hclust  2 1.000           1.000       1.000          0.509 0.492   0.492
get_stats(res_list, k = 3)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      3 1.000           0.950       0.978          0.416 0.773   0.576
#> CV:NMF      3 0.918           0.909       0.962          0.587 0.753   0.571
#> MAD:NMF     3 0.826           0.876       0.929          0.435 0.787   0.601
#> ATC:NMF     3 0.467           0.688       0.819          0.316 0.747   0.550
#> SD:skmeans  3 0.797           0.888       0.928          0.185 0.918   0.832
#> CV:skmeans  3 0.931           0.970       0.984          0.265 0.848   0.706
#> MAD:skmeans 3 0.994           0.965       0.975          0.169 0.918   0.832
#> ATC:skmeans 3 1.000           1.000       1.000          0.175 0.911   0.818
#> SD:mclust   3 0.764           0.826       0.918          0.513 0.767   0.575
#> CV:mclust   3 1.000           0.974       0.972          0.698 0.718   0.554
#> MAD:mclust  3 0.592           0.740       0.873          0.469 0.661   0.440
#> ATC:mclust  3 0.515           0.937       0.930          0.549 0.835   0.757
#> SD:kmeans   3 0.887           0.770       0.900          0.344 0.829   0.662
#> CV:kmeans   3 0.646           0.867       0.895          0.418 0.762   0.583
#> MAD:kmeans  3 0.920           0.887       0.948          0.323 0.729   0.501
#> ATC:kmeans  3 0.755           0.922       0.925          0.353 0.777   0.594
#> SD:pam      3 0.971           0.939       0.976          0.344 0.704   0.469
#> CV:pam      3 0.741           0.818       0.926          0.470 0.755   0.571
#> MAD:pam     3 1.000           0.963       0.986          0.329 0.708   0.474
#> ATC:pam     3 1.000           0.920       0.973          0.418 0.749   0.552
#> SD:hclust   3 0.843           0.925       0.962          0.343 0.862   0.719
#> CV:hclust   3 0.639           0.777       0.851          0.378 0.784   0.626
#> MAD:hclust  3 0.838           0.924       0.961          0.345 0.859   0.713
#> ATC:hclust  3 1.000           0.998       0.999          0.277 0.859   0.713
get_stats(res_list, k = 4)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      4 0.912           0.862       0.943         0.1051 0.909   0.726
#> CV:NMF      4 0.998           0.951       0.976         0.1336 0.852   0.585
#> MAD:NMF     4 0.906           0.842       0.934         0.1167 0.855   0.592
#> ATC:NMF     4 0.717           0.791       0.873         0.1639 0.867   0.641
#> SD:skmeans  4 0.941           0.954       0.973         0.1557 0.867   0.684
#> CV:skmeans  4 0.842           0.857       0.907         0.0761 0.947   0.862
#> MAD:skmeans 4 0.963           0.956       0.973         0.1733 0.867   0.684
#> ATC:skmeans 4 1.000           0.990       0.997         0.0378 0.973   0.932
#> SD:mclust   4 0.886           0.906       0.963         0.0976 0.915   0.752
#> CV:mclust   4 0.965           0.925       0.954         0.1589 0.890   0.687
#> MAD:mclust  4 0.738           0.800       0.864         0.1162 0.881   0.670
#> ATC:mclust  4 0.714           0.740       0.805         0.2876 0.852   0.716
#> SD:kmeans   4 0.747           0.790       0.825         0.0970 0.859   0.653
#> CV:kmeans   4 0.781           0.765       0.842         0.1408 0.953   0.864
#> MAD:kmeans  4 0.736           0.785       0.783         0.0956 0.935   0.801
#> ATC:kmeans  4 0.804           0.857       0.901         0.1393 0.915   0.758
#> SD:pam      4 0.848           0.836       0.894         0.0844 0.905   0.726
#> CV:pam      4 0.790           0.868       0.936         0.0664 0.835   0.583
#> MAD:pam     4 0.863           0.752       0.838         0.0867 0.898   0.700
#> ATC:pam     4 1.000           0.990       0.996         0.1053 0.861   0.627
#> SD:hclust   4 0.749           0.890       0.911         0.0869 0.950   0.858
#> CV:hclust   4 0.820           0.858       0.935         0.1555 0.938   0.832
#> MAD:hclust  4 0.787           0.829       0.850         0.1139 0.915   0.758
#> ATC:hclust  4 1.000           0.987       0.991         0.1500 0.900   0.714
get_stats(res_list, k = 5)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      5 0.842           0.809       0.887         0.0501 0.917   0.687
#> CV:NMF      5 0.871           0.818       0.905         0.0454 0.950   0.793
#> MAD:NMF     5 0.895           0.874       0.922         0.0584 0.915   0.677
#> ATC:NMF     5 0.679           0.676       0.796         0.0551 0.922   0.697
#> SD:skmeans  5 0.790           0.704       0.858         0.0798 0.954   0.848
#> CV:skmeans  5 0.842           0.876       0.897         0.0566 0.895   0.690
#> MAD:skmeans 5 0.821           0.823       0.901         0.0675 0.952   0.844
#> ATC:skmeans 5 0.869           0.919       0.952         0.0453 0.998   0.996
#> SD:mclust   5 0.934           0.924       0.958         0.1062 0.882   0.593
#> CV:mclust   5 0.933           0.914       0.945         0.0349 0.973   0.886
#> MAD:mclust  5 0.903           0.827       0.933         0.0964 0.908   0.674
#> ATC:mclust  5 0.824           0.813       0.893         0.1904 0.812   0.522
#> SD:kmeans   5 0.729           0.787       0.761         0.0701 0.893   0.667
#> CV:kmeans   5 0.738           0.790       0.838         0.0721 0.889   0.655
#> MAD:kmeans  5 0.735           0.695       0.771         0.0660 0.949   0.824
#> ATC:kmeans  5 0.747           0.755       0.826         0.0639 0.965   0.870
#> SD:pam      5 0.891           0.948       0.949         0.0675 0.922   0.726
#> CV:pam      5 0.868           0.855       0.925         0.0810 0.929   0.753
#> MAD:pam     5 1.000           0.996       0.998         0.0724 0.885   0.605
#> ATC:pam     5 0.881           0.936       0.900         0.0762 0.934   0.757
#> SD:hclust   5 0.780           0.848       0.852         0.0938 0.915   0.721
#> CV:hclust   5 0.824           0.785       0.888         0.0570 0.954   0.862
#> MAD:hclust  5 0.790           0.784       0.755         0.0543 0.973   0.897
#> ATC:hclust  5 0.904           0.942       0.931         0.0412 0.973   0.890
get_stats(res_list, k = 6)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      6 0.844           0.798       0.872        0.03000 1.000   1.000
#> CV:NMF      6 0.896           0.749       0.882        0.03071 0.979   0.895
#> MAD:NMF     6 0.871           0.770       0.877        0.02615 0.996   0.980
#> ATC:NMF     6 0.699           0.623       0.769        0.02581 0.986   0.932
#> SD:skmeans  6 0.814           0.663       0.848        0.04264 0.915   0.697
#> CV:skmeans  6 0.933           0.968       0.970        0.05886 0.992   0.968
#> MAD:skmeans 6 0.804           0.707       0.850        0.04444 0.969   0.883
#> ATC:skmeans 6 0.869           0.527       0.785        0.06709 0.895   0.721
#> SD:mclust   6 0.871           0.862       0.905        0.02671 0.970   0.846
#> CV:mclust   6 0.938           0.923       0.949        0.00892 0.940   0.760
#> MAD:mclust  6 0.852           0.760       0.882        0.05343 0.956   0.786
#> ATC:mclust  6 0.890           0.852       0.924        0.07619 0.926   0.679
#> SD:kmeans   6 0.815           0.791       0.774        0.04344 0.940   0.729
#> CV:kmeans   6 0.793           0.668       0.781        0.05680 0.965   0.852
#> MAD:kmeans  6 0.818           0.665       0.756        0.04682 0.878   0.555
#> ATC:kmeans  6 0.800           0.737       0.805        0.04858 0.936   0.730
#> SD:pam      6 1.000           0.952       0.977        0.05406 0.962   0.827
#> CV:pam      6 0.881           0.851       0.901        0.02937 0.947   0.780
#> MAD:pam     6 0.946           0.858       0.922        0.04741 0.962   0.823
#> ATC:pam     6 0.887           0.896       0.919        0.05736 0.961   0.809
#> SD:hclust   6 0.809           0.812       0.841        0.02831 0.958   0.814
#> CV:hclust   6 0.823           0.784       0.877        0.03130 0.947   0.830
#> MAD:hclust  6 0.821           0.786       0.820        0.04086 0.938   0.745
#> ATC:hclust  6 0.951           0.923       0.960        0.04540 0.965   0.845

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 14198 rows and 51 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 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-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.655           0.904       0.938         0.4889 0.492   0.492
#> 3 3 0.843           0.925       0.962         0.3433 0.862   0.719
#> 4 4 0.749           0.890       0.911         0.0869 0.950   0.858
#> 5 5 0.780           0.848       0.852         0.0938 0.915   0.721
#> 6 6 0.809           0.812       0.841         0.0283 0.958   0.814

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
#> SRR2936906     1   0.000      0.866 1.000 0.000
#> SRR2936909     1   0.000      0.866 1.000 0.000
#> SRR2936918     1   0.000      0.866 1.000 0.000
#> SRR2936917     2   0.000      1.000 0.000 1.000
#> SRR2936916     1   0.866      0.751 0.712 0.288
#> SRR2936915     1   0.866      0.751 0.712 0.288
#> SRR2936914     2   0.000      1.000 0.000 1.000
#> SRR2936913     2   0.000      1.000 0.000 1.000
#> SRR2936912     1   0.000      0.866 1.000 0.000
#> SRR2936910     1   0.000      0.866 1.000 0.000
#> SRR2936911     2   0.000      1.000 0.000 1.000
#> SRR2936907     2   0.000      1.000 0.000 1.000
#> SRR2936908     2   0.000      1.000 0.000 1.000
#> SRR2936904     1   0.866      0.751 0.712 0.288
#> SRR2936905     2   0.000      1.000 0.000 1.000
#> SRR2936903     1   0.000      0.866 1.000 0.000
#> SRR2936901     1   0.866      0.751 0.712 0.288
#> SRR2936902     2   0.000      1.000 0.000 1.000
#> SRR2936900     1   0.000      0.866 1.000 0.000
#> SRR2936898     1   0.866      0.751 0.712 0.288
#> SRR2936899     1   0.866      0.751 0.712 0.288
#> SRR2936897     1   0.000      0.866 1.000 0.000
#> SRR2936896     2   0.000      1.000 0.000 1.000
#> SRR2936894     1   0.000      0.866 1.000 0.000
#> SRR2936893     2   0.000      1.000 0.000 1.000
#> SRR2936895     2   0.000      1.000 0.000 1.000
#> SRR2936892     2   0.000      1.000 0.000 1.000
#> SRR2936891     1   0.000      0.866 1.000 0.000
#> SRR2936890     2   0.000      1.000 0.000 1.000
#> SRR2936886     1   0.866      0.751 0.712 0.288
#> SRR2936885     1   0.000      0.866 1.000 0.000
#> SRR2936888     1   0.000      0.866 1.000 0.000
#> SRR2936889     2   0.000      1.000 0.000 1.000
#> SRR2936887     1   0.866      0.751 0.712 0.288
#> SRR2936884     2   0.000      1.000 0.000 1.000
#> SRR2936883     2   0.000      1.000 0.000 1.000
#> SRR2936881     2   0.000      1.000 0.000 1.000
#> SRR2936882     1   0.000      0.866 1.000 0.000
#> SRR2936880     2   0.000      1.000 0.000 1.000
#> SRR2936878     2   0.000      1.000 0.000 1.000
#> SRR2936879     1   0.866      0.751 0.712 0.288
#> SRR2936875     2   0.000      1.000 0.000 1.000
#> SRR2936877     2   0.000      1.000 0.000 1.000
#> SRR2936876     1   0.000      0.866 1.000 0.000
#> SRR2936873     1   0.000      0.866 1.000 0.000
#> SRR2936872     2   0.000      1.000 0.000 1.000
#> SRR2936871     2   0.000      1.000 0.000 1.000
#> SRR2936874     2   0.000      1.000 0.000 1.000
#> SRR2936870     1   0.000      0.866 1.000 0.000
#> SRR2936869     1   0.866      0.751 0.712 0.288
#> SRR2936868     1   0.866      0.751 0.712 0.288

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette  p1    p2    p3
#> SRR2936906     1   0.000      0.987 1.0 0.000 0.000
#> SRR2936909     1   0.000      0.987 1.0 0.000 0.000
#> SRR2936918     1   0.000      0.987 1.0 0.000 0.000
#> SRR2936917     2   0.000      0.919 0.0 1.000 0.000
#> SRR2936916     3   0.000      1.000 0.0 0.000 1.000
#> SRR2936915     3   0.000      1.000 0.0 0.000 1.000
#> SRR2936914     2   0.000      0.919 0.0 1.000 0.000
#> SRR2936913     2   0.000      0.919 0.0 1.000 0.000
#> SRR2936912     1   0.000      0.987 1.0 0.000 0.000
#> SRR2936910     1   0.000      0.987 1.0 0.000 0.000
#> SRR2936911     2   0.000      0.919 0.0 1.000 0.000
#> SRR2936907     2   0.000      0.919 0.0 1.000 0.000
#> SRR2936908     2   0.000      0.919 0.0 1.000 0.000
#> SRR2936904     3   0.000      1.000 0.0 0.000 1.000
#> SRR2936905     2   0.000      0.919 0.0 1.000 0.000
#> SRR2936903     1   0.000      0.987 1.0 0.000 0.000
#> SRR2936901     3   0.000      1.000 0.0 0.000 1.000
#> SRR2936902     2   0.546      0.684 0.0 0.712 0.288
#> SRR2936900     1   0.000      0.987 1.0 0.000 0.000
#> SRR2936898     3   0.000      1.000 0.0 0.000 1.000
#> SRR2936899     3   0.000      1.000 0.0 0.000 1.000
#> SRR2936897     1   0.000      0.987 1.0 0.000 0.000
#> SRR2936896     2   0.000      0.919 0.0 1.000 0.000
#> SRR2936894     1   0.000      0.987 1.0 0.000 0.000
#> SRR2936893     2   0.000      0.919 0.0 1.000 0.000
#> SRR2936895     2   0.546      0.684 0.0 0.712 0.288
#> SRR2936892     2   0.000      0.919 0.0 1.000 0.000
#> SRR2936891     1   0.000      0.987 1.0 0.000 0.000
#> SRR2936890     2   0.000      0.919 0.0 1.000 0.000
#> SRR2936886     3   0.000      1.000 0.0 0.000 1.000
#> SRR2936885     1   0.000      0.987 1.0 0.000 0.000
#> SRR2936888     1   0.000      0.987 1.0 0.000 0.000
#> SRR2936889     2   0.000      0.919 0.0 1.000 0.000
#> SRR2936887     3   0.000      1.000 0.0 0.000 1.000
#> SRR2936884     2   0.546      0.684 0.0 0.712 0.288
#> SRR2936883     2   0.546      0.684 0.0 0.712 0.288
#> SRR2936881     2   0.546      0.684 0.0 0.712 0.288
#> SRR2936882     1   0.000      0.987 1.0 0.000 0.000
#> SRR2936880     2   0.546      0.684 0.0 0.712 0.288
#> SRR2936878     2   0.000      0.919 0.0 1.000 0.000
#> SRR2936879     3   0.000      1.000 0.0 0.000 1.000
#> SRR2936875     2   0.000      0.919 0.0 1.000 0.000
#> SRR2936877     2   0.000      0.919 0.0 1.000 0.000
#> SRR2936876     1   0.455      0.754 0.8 0.000 0.200
#> SRR2936873     1   0.000      0.987 1.0 0.000 0.000
#> SRR2936872     2   0.000      0.919 0.0 1.000 0.000
#> SRR2936871     2   0.000      0.919 0.0 1.000 0.000
#> SRR2936874     2   0.000      0.919 0.0 1.000 0.000
#> SRR2936870     1   0.000      0.987 1.0 0.000 0.000
#> SRR2936869     3   0.000      1.000 0.0 0.000 1.000
#> SRR2936868     3   0.000      1.000 0.0 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3  p4
#> SRR2936906     1  0.3610      1.000 0.800 0.000 0.000 0.2
#> SRR2936909     4  0.0000      0.954 0.000 0.000 0.000 1.0
#> SRR2936918     1  0.3610      1.000 0.800 0.000 0.000 0.2
#> SRR2936917     2  0.3610      0.787 0.200 0.800 0.000 0.0
#> SRR2936916     3  0.0000      1.000 0.000 0.000 1.000 0.0
#> SRR2936915     3  0.0000      1.000 0.000 0.000 1.000 0.0
#> SRR2936914     2  0.3610      0.787 0.200 0.800 0.000 0.0
#> SRR2936913     2  0.3610      0.787 0.200 0.800 0.000 0.0
#> SRR2936912     4  0.0000      0.954 0.000 0.000 0.000 1.0
#> SRR2936910     1  0.3610      1.000 0.800 0.000 0.000 0.2
#> SRR2936911     2  0.3610      0.787 0.200 0.800 0.000 0.0
#> SRR2936907     2  0.0000      0.864 0.000 1.000 0.000 0.0
#> SRR2936908     2  0.0000      0.864 0.000 1.000 0.000 0.0
#> SRR2936904     3  0.0000      1.000 0.000 0.000 1.000 0.0
#> SRR2936905     2  0.0000      0.864 0.000 1.000 0.000 0.0
#> SRR2936903     4  0.0000      0.954 0.000 0.000 0.000 1.0
#> SRR2936901     3  0.0000      1.000 0.000 0.000 1.000 0.0
#> SRR2936902     2  0.4331      0.653 0.000 0.712 0.288 0.0
#> SRR2936900     4  0.0000      0.954 0.000 0.000 0.000 1.0
#> SRR2936898     3  0.0000      1.000 0.000 0.000 1.000 0.0
#> SRR2936899     3  0.0000      1.000 0.000 0.000 1.000 0.0
#> SRR2936897     4  0.0000      0.954 0.000 0.000 0.000 1.0
#> SRR2936896     2  0.0188      0.863 0.004 0.996 0.000 0.0
#> SRR2936894     1  0.3610      1.000 0.800 0.000 0.000 0.2
#> SRR2936893     2  0.0000      0.864 0.000 1.000 0.000 0.0
#> SRR2936895     2  0.4331      0.653 0.000 0.712 0.288 0.0
#> SRR2936892     2  0.0000      0.864 0.000 1.000 0.000 0.0
#> SRR2936891     1  0.3610      1.000 0.800 0.000 0.000 0.2
#> SRR2936890     2  0.0000      0.864 0.000 1.000 0.000 0.0
#> SRR2936886     3  0.0000      1.000 0.000 0.000 1.000 0.0
#> SRR2936885     4  0.0000      0.954 0.000 0.000 0.000 1.0
#> SRR2936888     1  0.3610      1.000 0.800 0.000 0.000 0.2
#> SRR2936889     2  0.0000      0.864 0.000 1.000 0.000 0.0
#> SRR2936887     3  0.0000      1.000 0.000 0.000 1.000 0.0
#> SRR2936884     2  0.4331      0.653 0.000 0.712 0.288 0.0
#> SRR2936883     2  0.4331      0.653 0.000 0.712 0.288 0.0
#> SRR2936881     2  0.4331      0.653 0.000 0.712 0.288 0.0
#> SRR2936882     4  0.0000      0.954 0.000 0.000 0.000 1.0
#> SRR2936880     2  0.4331      0.653 0.000 0.712 0.288 0.0
#> SRR2936878     2  0.3610      0.787 0.200 0.800 0.000 0.0
#> SRR2936879     3  0.0000      1.000 0.000 0.000 1.000 0.0
#> SRR2936875     2  0.0000      0.864 0.000 1.000 0.000 0.0
#> SRR2936877     2  0.3610      0.787 0.200 0.800 0.000 0.0
#> SRR2936876     4  0.3610      0.699 0.000 0.000 0.200 0.8
#> SRR2936873     1  0.3610      1.000 0.800 0.000 0.000 0.2
#> SRR2936872     2  0.0000      0.864 0.000 1.000 0.000 0.0
#> SRR2936871     2  0.0000      0.864 0.000 1.000 0.000 0.0
#> SRR2936874     2  0.0000      0.864 0.000 1.000 0.000 0.0
#> SRR2936870     1  0.3610      1.000 0.800 0.000 0.000 0.2
#> SRR2936869     3  0.0000      1.000 0.000 0.000 1.000 0.0
#> SRR2936868     3  0.0000      1.000 0.000 0.000 1.000 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
#> SRR2936906     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000
#> SRR2936909     3  0.3074     0.9586 0.196 0.000 0.804 0.000 0.000
#> SRR2936918     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000
#> SRR2936917     5  0.3730     1.0000 0.000 0.288 0.000 0.000 0.712
#> SRR2936916     4  0.4951     0.8046 0.000 0.000 0.196 0.704 0.100
#> SRR2936915     4  0.4951     0.8046 0.000 0.000 0.196 0.704 0.100
#> SRR2936914     5  0.3730     1.0000 0.000 0.288 0.000 0.000 0.712
#> SRR2936913     5  0.3730     1.0000 0.000 0.288 0.000 0.000 0.712
#> SRR2936912     3  0.3074     0.9586 0.196 0.000 0.804 0.000 0.000
#> SRR2936910     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000
#> SRR2936911     5  0.3730     1.0000 0.000 0.288 0.000 0.000 0.712
#> SRR2936907     2  0.0000     0.8209 0.000 1.000 0.000 0.000 0.000
#> SRR2936908     2  0.0000     0.8209 0.000 1.000 0.000 0.000 0.000
#> SRR2936904     4  0.0000     0.7982 0.000 0.000 0.000 1.000 0.000
#> SRR2936905     2  0.0000     0.8209 0.000 1.000 0.000 0.000 0.000
#> SRR2936903     3  0.3074     0.9586 0.196 0.000 0.804 0.000 0.000
#> SRR2936901     4  0.6333     0.7301 0.000 0.000 0.196 0.516 0.288
#> SRR2936902     2  0.3730     0.6965 0.000 0.712 0.000 0.000 0.288
#> SRR2936900     3  0.3074     0.9586 0.196 0.000 0.804 0.000 0.000
#> SRR2936898     4  0.6333     0.7301 0.000 0.000 0.196 0.516 0.288
#> SRR2936899     4  0.6333     0.7301 0.000 0.000 0.196 0.516 0.288
#> SRR2936897     3  0.3074     0.9586 0.196 0.000 0.804 0.000 0.000
#> SRR2936896     2  0.3876     0.0877 0.000 0.684 0.000 0.000 0.316
#> SRR2936894     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000
#> SRR2936893     2  0.0000     0.8209 0.000 1.000 0.000 0.000 0.000
#> SRR2936895     2  0.4886     0.6411 0.000 0.712 0.000 0.188 0.100
#> SRR2936892     2  0.0000     0.8209 0.000 1.000 0.000 0.000 0.000
#> SRR2936891     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000
#> SRR2936890     2  0.0000     0.8209 0.000 1.000 0.000 0.000 0.000
#> SRR2936886     4  0.0000     0.7982 0.000 0.000 0.000 1.000 0.000
#> SRR2936885     3  0.3074     0.9586 0.196 0.000 0.804 0.000 0.000
#> SRR2936888     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000
#> SRR2936889     2  0.0000     0.8209 0.000 1.000 0.000 0.000 0.000
#> SRR2936887     4  0.0000     0.7982 0.000 0.000 0.000 1.000 0.000
#> SRR2936884     2  0.3730     0.6965 0.000 0.712 0.000 0.000 0.288
#> SRR2936883     2  0.3730     0.6965 0.000 0.712 0.000 0.000 0.288
#> SRR2936881     2  0.3730     0.6965 0.000 0.712 0.000 0.000 0.288
#> SRR2936882     3  0.3074     0.9586 0.196 0.000 0.804 0.000 0.000
#> SRR2936880     2  0.3730     0.6965 0.000 0.712 0.000 0.000 0.288
#> SRR2936878     5  0.3730     1.0000 0.000 0.288 0.000 0.000 0.712
#> SRR2936879     4  0.4951     0.8046 0.000 0.000 0.196 0.704 0.100
#> SRR2936875     2  0.0000     0.8209 0.000 1.000 0.000 0.000 0.000
#> SRR2936877     5  0.3730     1.0000 0.000 0.288 0.000 0.000 0.712
#> SRR2936876     3  0.0162     0.7174 0.000 0.000 0.996 0.004 0.000
#> SRR2936873     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000
#> SRR2936872     2  0.0000     0.8209 0.000 1.000 0.000 0.000 0.000
#> SRR2936871     2  0.0000     0.8209 0.000 1.000 0.000 0.000 0.000
#> SRR2936874     2  0.0000     0.8209 0.000 1.000 0.000 0.000 0.000
#> SRR2936870     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000
#> SRR2936869     4  0.0000     0.7982 0.000 0.000 0.000 1.000 0.000
#> SRR2936868     4  0.0000     0.7982 0.000 0.000 0.000 1.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
#> SRR2936906     1   0.000     0.9687 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936909     6   0.000     0.7161 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR2936918     1   0.000     0.9687 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936917     5   0.000     0.9064 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR2936916     3   0.181     0.7721 0.000 0.100 0.900 0.000 0.000 0.000
#> SRR2936915     3   0.181     0.7721 0.000 0.100 0.900 0.000 0.000 0.000
#> SRR2936914     5   0.000     0.9064 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR2936913     5   0.000     0.9064 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR2936912     6   0.000     0.7161 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR2936910     1   0.000     0.9687 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936911     5   0.000     0.9064 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR2936907     2   0.335     0.8243 0.000 0.712 0.000 0.000 0.288 0.000
#> SRR2936908     2   0.335     0.8243 0.000 0.712 0.000 0.000 0.288 0.000
#> SRR2936904     4   0.387     1.0000 0.000 0.000 0.492 0.508 0.000 0.000
#> SRR2936905     2   0.335     0.8243 0.000 0.712 0.000 0.000 0.288 0.000
#> SRR2936903     6   0.387     0.7409 0.000 0.000 0.000 0.492 0.000 0.508
#> SRR2936901     3   0.335     0.8111 0.000 0.288 0.712 0.000 0.000 0.000
#> SRR2936902     2   0.000     0.6965 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936900     6   0.387     0.7409 0.000 0.000 0.000 0.492 0.000 0.508
#> SRR2936898     3   0.335     0.8111 0.000 0.288 0.712 0.000 0.000 0.000
#> SRR2936899     3   0.335     0.8111 0.000 0.288 0.712 0.000 0.000 0.000
#> SRR2936897     6   0.000     0.7161 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR2936896     5   0.375    -0.0877 0.000 0.396 0.000 0.000 0.604 0.000
#> SRR2936894     1   0.000     0.9687 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936893     2   0.335     0.8243 0.000 0.712 0.000 0.000 0.288 0.000
#> SRR2936895     2   0.270     0.6325 0.000 0.812 0.188 0.000 0.000 0.000
#> SRR2936892     2   0.335     0.8243 0.000 0.712 0.000 0.000 0.288 0.000
#> SRR2936891     1   0.000     0.9687 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936890     2   0.335     0.8243 0.000 0.712 0.000 0.000 0.288 0.000
#> SRR2936886     4   0.387     1.0000 0.000 0.000 0.492 0.508 0.000 0.000
#> SRR2936885     6   0.387     0.7409 0.000 0.000 0.000 0.492 0.000 0.508
#> SRR2936888     1   0.000     0.9687 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936889     2   0.335     0.8243 0.000 0.712 0.000 0.000 0.288 0.000
#> SRR2936887     4   0.387     1.0000 0.000 0.000 0.492 0.508 0.000 0.000
#> SRR2936884     2   0.000     0.6965 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936883     2   0.000     0.6965 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936881     2   0.000     0.6965 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936882     6   0.387     0.7409 0.000 0.000 0.000 0.492 0.000 0.508
#> SRR2936880     2   0.000     0.6965 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936878     5   0.000     0.9064 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR2936879     3   0.181     0.7721 0.000 0.100 0.900 0.000 0.000 0.000
#> SRR2936875     2   0.335     0.8243 0.000 0.712 0.000 0.000 0.288 0.000
#> SRR2936877     5   0.000     0.9064 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR2936876     6   0.279     0.4960 0.000 0.000 0.200 0.000 0.000 0.800
#> SRR2936873     1   0.276     0.7335 0.804 0.000 0.000 0.000 0.000 0.196
#> SRR2936872     2   0.335     0.8243 0.000 0.712 0.000 0.000 0.288 0.000
#> SRR2936871     2   0.335     0.8243 0.000 0.712 0.000 0.000 0.288 0.000
#> SRR2936874     2   0.335     0.8243 0.000 0.712 0.000 0.000 0.288 0.000
#> SRR2936870     1   0.000     0.9687 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936869     4   0.387     1.0000 0.000 0.000 0.492 0.508 0.000 0.000
#> SRR2936868     4   0.387     1.0000 0.000 0.000 0.492 0.508 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-hclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-hclust-collect-classes

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


SD:kmeans

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

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

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

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

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

collect_plots(res)

plot of chunk SD-kmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.776           0.847       0.934         0.4929 0.490   0.490
#> 3 3 0.887           0.770       0.900         0.3436 0.829   0.662
#> 4 4 0.747           0.790       0.825         0.0970 0.859   0.653
#> 5 5 0.729           0.787       0.761         0.0701 0.893   0.667
#> 6 6 0.815           0.791       0.774         0.0434 0.940   0.729

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
#> SRR2936906     1   0.000     0.8691 1.000 0.000
#> SRR2936909     1   0.000     0.8691 1.000 0.000
#> SRR2936918     1   0.000     0.8691 1.000 0.000
#> SRR2936917     2   0.000     0.9788 0.000 1.000
#> SRR2936916     2   0.000     0.9788 0.000 1.000
#> SRR2936915     1   0.993     0.3553 0.548 0.452
#> SRR2936914     2   0.000     0.9788 0.000 1.000
#> SRR2936913     2   0.000     0.9788 0.000 1.000
#> SRR2936912     1   0.000     0.8691 1.000 0.000
#> SRR2936910     1   0.000     0.8691 1.000 0.000
#> SRR2936911     2   0.000     0.9788 0.000 1.000
#> SRR2936907     2   0.000     0.9788 0.000 1.000
#> SRR2936908     2   0.000     0.9788 0.000 1.000
#> SRR2936904     1   0.311     0.8394 0.944 0.056
#> SRR2936905     2   0.000     0.9788 0.000 1.000
#> SRR2936903     1   0.000     0.8691 1.000 0.000
#> SRR2936901     1   0.204     0.8537 0.968 0.032
#> SRR2936902     2   0.000     0.9788 0.000 1.000
#> SRR2936900     1   0.000     0.8691 1.000 0.000
#> SRR2936898     1   0.900     0.5996 0.684 0.316
#> SRR2936899     1   0.993     0.3553 0.548 0.452
#> SRR2936897     1   0.000     0.8691 1.000 0.000
#> SRR2936896     2   0.000     0.9788 0.000 1.000
#> SRR2936894     1   0.000     0.8691 1.000 0.000
#> SRR2936893     2   0.000     0.9788 0.000 1.000
#> SRR2936895     2   0.000     0.9788 0.000 1.000
#> SRR2936892     2   0.000     0.9788 0.000 1.000
#> SRR2936891     1   0.000     0.8691 1.000 0.000
#> SRR2936890     2   0.000     0.9788 0.000 1.000
#> SRR2936886     1   0.958     0.5075 0.620 0.380
#> SRR2936885     1   0.000     0.8691 1.000 0.000
#> SRR2936888     1   0.000     0.8691 1.000 0.000
#> SRR2936889     2   0.000     0.9788 0.000 1.000
#> SRR2936887     1   0.958     0.5075 0.620 0.380
#> SRR2936884     2   0.000     0.9788 0.000 1.000
#> SRR2936883     2   0.000     0.9788 0.000 1.000
#> SRR2936881     2   0.000     0.9788 0.000 1.000
#> SRR2936882     1   0.000     0.8691 1.000 0.000
#> SRR2936880     2   0.000     0.9788 0.000 1.000
#> SRR2936878     2   0.000     0.9788 0.000 1.000
#> SRR2936879     1   0.996     0.3231 0.536 0.464
#> SRR2936875     2   0.000     0.9788 0.000 1.000
#> SRR2936877     2   0.000     0.9788 0.000 1.000
#> SRR2936876     1   0.000     0.8691 1.000 0.000
#> SRR2936873     1   0.000     0.8691 1.000 0.000
#> SRR2936872     2   0.000     0.9788 0.000 1.000
#> SRR2936871     2   0.000     0.9788 0.000 1.000
#> SRR2936874     2   0.000     0.9788 0.000 1.000
#> SRR2936870     1   0.000     0.8691 1.000 0.000
#> SRR2936869     2   0.988    -0.0328 0.436 0.564
#> SRR2936868     1   0.958     0.5075 0.620 0.380

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR2936906     1  0.0000      1.000 1.000 0.000 0.000
#> SRR2936909     1  0.0000      1.000 1.000 0.000 0.000
#> SRR2936918     1  0.0000      1.000 1.000 0.000 0.000
#> SRR2936917     2  0.6307      0.781 0.000 0.512 0.488
#> SRR2936916     3  0.6309      0.949 0.000 0.496 0.504
#> SRR2936915     3  0.6308      0.953 0.000 0.492 0.508
#> SRR2936914     2  0.6307      0.781 0.000 0.512 0.488
#> SRR2936913     2  0.6307      0.781 0.000 0.512 0.488
#> SRR2936912     1  0.0000      1.000 1.000 0.000 0.000
#> SRR2936910     1  0.0000      1.000 1.000 0.000 0.000
#> SRR2936911     2  0.6307      0.781 0.000 0.512 0.488
#> SRR2936907     2  0.6307      0.781 0.000 0.512 0.488
#> SRR2936908     2  0.6111      0.796 0.000 0.604 0.396
#> SRR2936904     3  0.8466      0.854 0.092 0.400 0.508
#> SRR2936905     2  0.6111      0.796 0.000 0.604 0.396
#> SRR2936903     1  0.0000      1.000 1.000 0.000 0.000
#> SRR2936901     3  0.6520      0.950 0.004 0.488 0.508
#> SRR2936902     2  0.4399     -0.298 0.000 0.812 0.188
#> SRR2936900     1  0.0000      1.000 1.000 0.000 0.000
#> SRR2936898     3  0.6308      0.953 0.000 0.492 0.508
#> SRR2936899     3  0.6308      0.953 0.000 0.492 0.508
#> SRR2936897     1  0.0000      1.000 1.000 0.000 0.000
#> SRR2936896     2  0.6307      0.781 0.000 0.512 0.488
#> SRR2936894     1  0.0000      1.000 1.000 0.000 0.000
#> SRR2936893     2  0.6111      0.796 0.000 0.604 0.396
#> SRR2936895     2  0.3619     -0.144 0.000 0.864 0.136
#> SRR2936892     2  0.6111      0.796 0.000 0.604 0.396
#> SRR2936891     1  0.0000      1.000 1.000 0.000 0.000
#> SRR2936890     2  0.6111      0.796 0.000 0.604 0.396
#> SRR2936886     3  0.6308      0.953 0.000 0.492 0.508
#> SRR2936885     1  0.0000      1.000 1.000 0.000 0.000
#> SRR2936888     1  0.0237      0.997 0.996 0.000 0.004
#> SRR2936889     2  0.6111      0.796 0.000 0.604 0.396
#> SRR2936887     3  0.6308      0.953 0.000 0.492 0.508
#> SRR2936884     2  0.0000      0.256 0.000 1.000 0.000
#> SRR2936883     2  0.4399     -0.298 0.000 0.812 0.188
#> SRR2936881     2  0.4399     -0.298 0.000 0.812 0.188
#> SRR2936882     1  0.0000      1.000 1.000 0.000 0.000
#> SRR2936880     2  0.3619     -0.144 0.000 0.864 0.136
#> SRR2936878     2  0.6307      0.781 0.000 0.512 0.488
#> SRR2936879     3  0.6308      0.953 0.000 0.492 0.508
#> SRR2936875     2  0.6111      0.796 0.000 0.604 0.396
#> SRR2936877     2  0.6307      0.781 0.000 0.512 0.488
#> SRR2936876     3  0.9387      0.610 0.272 0.220 0.508
#> SRR2936873     1  0.0000      1.000 1.000 0.000 0.000
#> SRR2936872     2  0.6111      0.796 0.000 0.604 0.396
#> SRR2936871     2  0.6111      0.796 0.000 0.604 0.396
#> SRR2936874     2  0.6111      0.796 0.000 0.604 0.396
#> SRR2936870     1  0.0237      0.997 0.996 0.000 0.004
#> SRR2936869     3  0.6308      0.953 0.000 0.492 0.508
#> SRR2936868     3  0.6308      0.953 0.000 0.492 0.508

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3 p4
#> SRR2936906     1  0.0000      0.929 1.000 0.000 0.000 NA
#> SRR2936909     1  0.2081      0.921 0.916 0.000 0.000 NA
#> SRR2936918     1  0.0000      0.929 1.000 0.000 0.000 NA
#> SRR2936917     2  0.4643      0.748 0.000 0.656 0.000 NA
#> SRR2936916     3  0.4245      0.725 0.000 0.116 0.820 NA
#> SRR2936915     3  0.1716      0.745 0.000 0.000 0.936 NA
#> SRR2936914     2  0.4643      0.748 0.000 0.656 0.000 NA
#> SRR2936913     2  0.4643      0.748 0.000 0.656 0.000 NA
#> SRR2936912     1  0.2081      0.921 0.916 0.000 0.000 NA
#> SRR2936910     1  0.0000      0.929 1.000 0.000 0.000 NA
#> SRR2936911     2  0.4643      0.748 0.000 0.656 0.000 NA
#> SRR2936907     2  0.1211      0.848 0.000 0.960 0.000 NA
#> SRR2936908     2  0.0707      0.858 0.000 0.980 0.020 NA
#> SRR2936904     3  0.5513      0.646 0.004 0.016 0.596 NA
#> SRR2936905     2  0.0779      0.858 0.000 0.980 0.016 NA
#> SRR2936903     1  0.3764      0.877 0.784 0.000 0.000 NA
#> SRR2936901     3  0.2081      0.733 0.000 0.000 0.916 NA
#> SRR2936902     3  0.4903      0.648 0.000 0.248 0.724 NA
#> SRR2936900     1  0.3764      0.877 0.784 0.000 0.000 NA
#> SRR2936898     3  0.0469      0.746 0.000 0.000 0.988 NA
#> SRR2936899     3  0.0469      0.746 0.000 0.000 0.988 NA
#> SRR2936897     1  0.2530      0.914 0.888 0.000 0.000 NA
#> SRR2936896     2  0.2589      0.828 0.000 0.884 0.000 NA
#> SRR2936894     1  0.0000      0.929 1.000 0.000 0.000 NA
#> SRR2936893     2  0.0707      0.858 0.000 0.980 0.020 NA
#> SRR2936895     3  0.5055      0.640 0.000 0.256 0.712 NA
#> SRR2936892     2  0.0707      0.858 0.000 0.980 0.020 NA
#> SRR2936891     1  0.0000      0.929 1.000 0.000 0.000 NA
#> SRR2936890     2  0.0707      0.858 0.000 0.980 0.020 NA
#> SRR2936886     3  0.5746      0.657 0.000 0.040 0.612 NA
#> SRR2936885     1  0.3764      0.877 0.784 0.000 0.000 NA
#> SRR2936888     1  0.1637      0.905 0.940 0.000 0.000 NA
#> SRR2936889     2  0.0707      0.858 0.000 0.980 0.020 NA
#> SRR2936887     3  0.5746      0.657 0.000 0.040 0.612 NA
#> SRR2936884     3  0.5478      0.511 0.000 0.344 0.628 NA
#> SRR2936883     3  0.4903      0.648 0.000 0.248 0.724 NA
#> SRR2936881     3  0.4903      0.648 0.000 0.248 0.724 NA
#> SRR2936882     1  0.3764      0.877 0.784 0.000 0.000 NA
#> SRR2936880     3  0.4964      0.639 0.000 0.256 0.716 NA
#> SRR2936878     2  0.4643      0.748 0.000 0.656 0.000 NA
#> SRR2936879     3  0.1716      0.745 0.000 0.000 0.936 NA
#> SRR2936875     2  0.0707      0.858 0.000 0.980 0.020 NA
#> SRR2936877     2  0.4643      0.748 0.000 0.656 0.000 NA
#> SRR2936876     3  0.6386      0.470 0.212 0.000 0.648 NA
#> SRR2936873     1  0.0000      0.929 1.000 0.000 0.000 NA
#> SRR2936872     2  0.0779      0.858 0.000 0.980 0.016 NA
#> SRR2936871     2  0.0707      0.858 0.000 0.980 0.020 NA
#> SRR2936874     2  0.0707      0.858 0.000 0.980 0.020 NA
#> SRR2936870     1  0.1637      0.905 0.940 0.000 0.000 NA
#> SRR2936869     3  0.5746      0.657 0.000 0.040 0.612 NA
#> SRR2936868     3  0.5746      0.657 0.000 0.040 0.612 NA

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4    p5
#> SRR2936906     1  0.4262     0.8410 0.560 0.000 0.000 0.440 0.000
#> SRR2936909     1  0.4572     0.8197 0.684 0.000 0.000 0.280 0.036
#> SRR2936918     1  0.4262     0.8410 0.560 0.000 0.000 0.440 0.000
#> SRR2936917     5  0.4161     1.0000 0.000 0.392 0.000 0.000 0.608
#> SRR2936916     3  0.5089     0.6727 0.000 0.072 0.756 0.068 0.104
#> SRR2936915     3  0.5422     0.4219 0.000 0.004 0.668 0.208 0.120
#> SRR2936914     5  0.4161     1.0000 0.000 0.392 0.000 0.000 0.608
#> SRR2936913     5  0.4161     1.0000 0.000 0.392 0.000 0.000 0.608
#> SRR2936912     1  0.4594     0.8207 0.680 0.000 0.000 0.284 0.036
#> SRR2936910     1  0.4262     0.8410 0.560 0.000 0.000 0.440 0.000
#> SRR2936911     5  0.4161     1.0000 0.000 0.392 0.000 0.000 0.608
#> SRR2936907     2  0.0510     0.9069 0.000 0.984 0.000 0.000 0.016
#> SRR2936908     2  0.0290     0.9243 0.000 0.992 0.008 0.000 0.000
#> SRR2936904     4  0.6715     0.8948 0.016 0.000 0.204 0.520 0.260
#> SRR2936905     2  0.0162     0.9226 0.000 0.996 0.000 0.000 0.004
#> SRR2936903     1  0.1393     0.6564 0.956 0.000 0.012 0.008 0.024
#> SRR2936901     3  0.4189     0.6362 0.060 0.000 0.816 0.080 0.044
#> SRR2936902     3  0.2230     0.7393 0.000 0.116 0.884 0.000 0.000
#> SRR2936900     1  0.0404     0.6863 0.988 0.000 0.012 0.000 0.000
#> SRR2936898     3  0.2989     0.6585 0.000 0.004 0.872 0.080 0.044
#> SRR2936899     3  0.2989     0.6585 0.000 0.004 0.872 0.080 0.044
#> SRR2936897     1  0.4210     0.8017 0.740 0.000 0.000 0.224 0.036
#> SRR2936896     2  0.4227    -0.5269 0.000 0.580 0.000 0.000 0.420
#> SRR2936894     1  0.4262     0.8410 0.560 0.000 0.000 0.440 0.000
#> SRR2936893     2  0.0290     0.9243 0.000 0.992 0.008 0.000 0.000
#> SRR2936895     3  0.2818     0.7333 0.000 0.128 0.860 0.008 0.004
#> SRR2936892     2  0.0290     0.9243 0.000 0.992 0.008 0.000 0.000
#> SRR2936891     1  0.4262     0.8410 0.560 0.000 0.000 0.440 0.000
#> SRR2936890     2  0.0000     0.9249 0.000 1.000 0.000 0.000 0.000
#> SRR2936886     4  0.6606     0.9734 0.000 0.008 0.268 0.512 0.212
#> SRR2936885     1  0.0404     0.6863 0.988 0.000 0.012 0.000 0.000
#> SRR2936888     1  0.5680     0.8036 0.492 0.000 0.000 0.428 0.080
#> SRR2936889     2  0.0000     0.9249 0.000 1.000 0.000 0.000 0.000
#> SRR2936887     4  0.6606     0.9734 0.000 0.008 0.268 0.512 0.212
#> SRR2936884     3  0.2648     0.7112 0.000 0.152 0.848 0.000 0.000
#> SRR2936883     3  0.2230     0.7393 0.000 0.116 0.884 0.000 0.000
#> SRR2936881     3  0.2230     0.7393 0.000 0.116 0.884 0.000 0.000
#> SRR2936882     1  0.0404     0.6863 0.988 0.000 0.012 0.000 0.000
#> SRR2936880     3  0.2377     0.7330 0.000 0.128 0.872 0.000 0.000
#> SRR2936878     5  0.4161     1.0000 0.000 0.392 0.000 0.000 0.608
#> SRR2936879     3  0.5422     0.4219 0.000 0.004 0.668 0.208 0.120
#> SRR2936875     2  0.0290     0.9243 0.000 0.992 0.008 0.000 0.000
#> SRR2936877     5  0.4161     1.0000 0.000 0.392 0.000 0.000 0.608
#> SRR2936876     3  0.8239     0.0562 0.272 0.000 0.376 0.212 0.140
#> SRR2936873     1  0.4262     0.8410 0.560 0.000 0.000 0.440 0.000
#> SRR2936872     2  0.0162     0.9226 0.000 0.996 0.000 0.000 0.004
#> SRR2936871     2  0.0000     0.9249 0.000 1.000 0.000 0.000 0.000
#> SRR2936874     2  0.0290     0.9243 0.000 0.992 0.008 0.000 0.000
#> SRR2936870     1  0.5680     0.8036 0.492 0.000 0.000 0.428 0.080
#> SRR2936869     4  0.6606     0.9734 0.000 0.008 0.268 0.512 0.212
#> SRR2936868     4  0.6606     0.9734 0.000 0.008 0.268 0.512 0.212

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR2936906     1  0.0260     0.8229 0.992 0.000 0.000 0.000 0.008 0.000
#> SRR2936909     1  0.4955     0.5164 0.712 0.000 0.020 0.016 0.076 0.176
#> SRR2936918     1  0.0000     0.8222 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936917     5  0.3482     0.9676 0.000 0.316 0.000 0.000 0.684 0.000
#> SRR2936916     3  0.7284     0.5626 0.000 0.040 0.484 0.072 0.156 0.248
#> SRR2936915     3  0.7377     0.4533 0.000 0.004 0.404 0.148 0.160 0.284
#> SRR2936914     5  0.3482     0.9676 0.000 0.316 0.000 0.000 0.684 0.000
#> SRR2936913     5  0.3482     0.9676 0.000 0.316 0.000 0.000 0.684 0.000
#> SRR2936912     1  0.4955     0.5164 0.712 0.000 0.020 0.016 0.076 0.176
#> SRR2936910     1  0.0000     0.8222 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936911     5  0.3482     0.9676 0.000 0.316 0.000 0.000 0.684 0.000
#> SRR2936907     2  0.0405     0.9670 0.000 0.988 0.000 0.000 0.004 0.008
#> SRR2936908     2  0.0935     0.9717 0.000 0.964 0.000 0.004 0.000 0.032
#> SRR2936904     4  0.3772     0.8214 0.000 0.000 0.032 0.812 0.088 0.068
#> SRR2936905     2  0.0146     0.9733 0.000 0.996 0.000 0.000 0.000 0.004
#> SRR2936903     6  0.3221     0.5967 0.264 0.000 0.000 0.000 0.000 0.736
#> SRR2936901     3  0.4897     0.6935 0.000 0.000 0.672 0.040 0.044 0.244
#> SRR2936902     3  0.1349     0.7582 0.000 0.056 0.940 0.004 0.000 0.000
#> SRR2936900     6  0.3695     0.6277 0.376 0.000 0.000 0.000 0.000 0.624
#> SRR2936898     3  0.4917     0.7077 0.000 0.008 0.700 0.040 0.044 0.208
#> SRR2936899     3  0.4917     0.7077 0.000 0.008 0.700 0.040 0.044 0.208
#> SRR2936897     1  0.5185     0.4444 0.680 0.000 0.020 0.016 0.076 0.208
#> SRR2936896     5  0.4234     0.7721 0.000 0.440 0.000 0.000 0.544 0.016
#> SRR2936894     1  0.0260     0.8229 0.992 0.000 0.000 0.000 0.008 0.000
#> SRR2936893     2  0.0935     0.9717 0.000 0.964 0.000 0.004 0.000 0.032
#> SRR2936895     3  0.1707     0.7547 0.000 0.056 0.928 0.012 0.000 0.004
#> SRR2936892     2  0.0935     0.9717 0.000 0.964 0.000 0.004 0.000 0.032
#> SRR2936891     1  0.0260     0.8229 0.992 0.000 0.000 0.000 0.008 0.000
#> SRR2936890     2  0.0000     0.9749 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936886     4  0.1141     0.9581 0.000 0.000 0.052 0.948 0.000 0.000
#> SRR2936885     6  0.3695     0.6277 0.376 0.000 0.000 0.000 0.000 0.624
#> SRR2936888     1  0.3339     0.7282 0.856 0.000 0.024 0.024 0.064 0.032
#> SRR2936889     2  0.0000     0.9749 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936887     4  0.1141     0.9581 0.000 0.000 0.052 0.948 0.000 0.000
#> SRR2936884     3  0.1555     0.7540 0.000 0.060 0.932 0.004 0.000 0.004
#> SRR2936883     3  0.1349     0.7582 0.000 0.056 0.940 0.004 0.000 0.000
#> SRR2936881     3  0.1349     0.7582 0.000 0.056 0.940 0.004 0.000 0.000
#> SRR2936882     6  0.3695     0.6277 0.376 0.000 0.000 0.000 0.000 0.624
#> SRR2936880     3  0.1349     0.7582 0.000 0.056 0.940 0.004 0.000 0.000
#> SRR2936878     5  0.3482     0.9676 0.000 0.316 0.000 0.000 0.684 0.000
#> SRR2936879     3  0.7450     0.4626 0.000 0.008 0.404 0.148 0.156 0.284
#> SRR2936875     2  0.0935     0.9717 0.000 0.964 0.000 0.004 0.000 0.032
#> SRR2936877     5  0.3619     0.9654 0.000 0.316 0.000 0.000 0.680 0.004
#> SRR2936876     6  0.7775    -0.0525 0.076 0.000 0.140 0.096 0.232 0.456
#> SRR2936873     1  0.0260     0.8229 0.992 0.000 0.000 0.000 0.008 0.000
#> SRR2936872     2  0.0146     0.9733 0.000 0.996 0.000 0.000 0.000 0.004
#> SRR2936871     2  0.0000     0.9749 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936874     2  0.0935     0.9717 0.000 0.964 0.000 0.004 0.000 0.032
#> SRR2936870     1  0.3339     0.7282 0.856 0.000 0.024 0.024 0.064 0.032
#> SRR2936869     4  0.1141     0.9581 0.000 0.000 0.052 0.948 0.000 0.000
#> SRR2936868     4  0.1141     0.9581 0.000 0.000 0.052 0.948 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-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 14198 rows and 51 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#>   Subgroups are detected by 'skmeans' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 4.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk SD-skmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.885           0.954       0.979         0.5087 0.490   0.490
#> 3 3 0.797           0.888       0.928         0.1851 0.918   0.832
#> 4 4 0.941           0.954       0.973         0.1557 0.867   0.684
#> 5 5 0.790           0.704       0.858         0.0798 0.954   0.848
#> 6 6 0.814           0.663       0.848         0.0426 0.915   0.697

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
#> SRR2936906     1   0.000      0.958 1.000 0.000
#> SRR2936909     1   0.000      0.958 1.000 0.000
#> SRR2936918     1   0.000      0.958 1.000 0.000
#> SRR2936917     2   0.000      0.997 0.000 1.000
#> SRR2936916     2   0.311      0.937 0.056 0.944
#> SRR2936915     1   0.000      0.958 1.000 0.000
#> SRR2936914     2   0.000      0.997 0.000 1.000
#> SRR2936913     2   0.000      0.997 0.000 1.000
#> SRR2936912     1   0.000      0.958 1.000 0.000
#> SRR2936910     1   0.000      0.958 1.000 0.000
#> SRR2936911     2   0.000      0.997 0.000 1.000
#> SRR2936907     2   0.000      0.997 0.000 1.000
#> SRR2936908     2   0.000      0.997 0.000 1.000
#> SRR2936904     1   0.000      0.958 1.000 0.000
#> SRR2936905     2   0.000      0.997 0.000 1.000
#> SRR2936903     1   0.000      0.958 1.000 0.000
#> SRR2936901     1   0.000      0.958 1.000 0.000
#> SRR2936902     2   0.000      0.997 0.000 1.000
#> SRR2936900     1   0.000      0.958 1.000 0.000
#> SRR2936898     1   0.000      0.958 1.000 0.000
#> SRR2936899     1   0.000      0.958 1.000 0.000
#> SRR2936897     1   0.000      0.958 1.000 0.000
#> SRR2936896     2   0.000      0.997 0.000 1.000
#> SRR2936894     1   0.000      0.958 1.000 0.000
#> SRR2936893     2   0.000      0.997 0.000 1.000
#> SRR2936895     2   0.000      0.997 0.000 1.000
#> SRR2936892     2   0.000      0.997 0.000 1.000
#> SRR2936891     1   0.000      0.958 1.000 0.000
#> SRR2936890     2   0.000      0.997 0.000 1.000
#> SRR2936886     1   0.722      0.770 0.800 0.200
#> SRR2936885     1   0.000      0.958 1.000 0.000
#> SRR2936888     1   0.000      0.958 1.000 0.000
#> SRR2936889     2   0.000      0.997 0.000 1.000
#> SRR2936887     1   0.722      0.770 0.800 0.200
#> SRR2936884     2   0.000      0.997 0.000 1.000
#> SRR2936883     2   0.000      0.997 0.000 1.000
#> SRR2936881     2   0.000      0.997 0.000 1.000
#> SRR2936882     1   0.000      0.958 1.000 0.000
#> SRR2936880     2   0.000      0.997 0.000 1.000
#> SRR2936878     2   0.000      0.997 0.000 1.000
#> SRR2936879     1   0.184      0.937 0.972 0.028
#> SRR2936875     2   0.000      0.997 0.000 1.000
#> SRR2936877     2   0.000      0.997 0.000 1.000
#> SRR2936876     1   0.000      0.958 1.000 0.000
#> SRR2936873     1   0.000      0.958 1.000 0.000
#> SRR2936872     2   0.000      0.997 0.000 1.000
#> SRR2936871     2   0.000      0.997 0.000 1.000
#> SRR2936874     2   0.000      0.997 0.000 1.000
#> SRR2936870     1   0.000      0.958 1.000 0.000
#> SRR2936869     1   0.971      0.393 0.600 0.400
#> SRR2936868     1   0.722      0.770 0.800 0.200

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR2936906     1  0.0000      0.951 1.000 0.000 0.000
#> SRR2936909     1  0.0000      0.951 1.000 0.000 0.000
#> SRR2936918     1  0.0000      0.951 1.000 0.000 0.000
#> SRR2936917     2  0.0000      0.925 0.000 1.000 0.000
#> SRR2936916     2  0.2711      0.830 0.088 0.912 0.000
#> SRR2936915     1  0.0000      0.951 1.000 0.000 0.000
#> SRR2936914     2  0.0000      0.925 0.000 1.000 0.000
#> SRR2936913     2  0.0000      0.925 0.000 1.000 0.000
#> SRR2936912     1  0.0000      0.951 1.000 0.000 0.000
#> SRR2936910     1  0.0000      0.951 1.000 0.000 0.000
#> SRR2936911     2  0.0000      0.925 0.000 1.000 0.000
#> SRR2936907     2  0.0000      0.925 0.000 1.000 0.000
#> SRR2936908     2  0.0000      0.925 0.000 1.000 0.000
#> SRR2936904     3  0.5363      0.641 0.276 0.000 0.724
#> SRR2936905     2  0.0000      0.925 0.000 1.000 0.000
#> SRR2936903     1  0.0000      0.951 1.000 0.000 0.000
#> SRR2936901     1  0.5363      0.666 0.724 0.000 0.276
#> SRR2936902     2  0.5363      0.694 0.000 0.724 0.276
#> SRR2936900     1  0.0000      0.951 1.000 0.000 0.000
#> SRR2936898     1  0.5363      0.666 0.724 0.000 0.276
#> SRR2936899     1  0.5363      0.666 0.724 0.000 0.276
#> SRR2936897     1  0.0000      0.951 1.000 0.000 0.000
#> SRR2936896     2  0.0000      0.925 0.000 1.000 0.000
#> SRR2936894     1  0.0000      0.951 1.000 0.000 0.000
#> SRR2936893     2  0.0000      0.925 0.000 1.000 0.000
#> SRR2936895     2  0.0000      0.925 0.000 1.000 0.000
#> SRR2936892     2  0.0000      0.925 0.000 1.000 0.000
#> SRR2936891     1  0.0000      0.951 1.000 0.000 0.000
#> SRR2936890     2  0.0000      0.925 0.000 1.000 0.000
#> SRR2936886     3  0.6841      0.922 0.076 0.200 0.724
#> SRR2936885     1  0.0000      0.951 1.000 0.000 0.000
#> SRR2936888     1  0.0000      0.951 1.000 0.000 0.000
#> SRR2936889     2  0.0000      0.925 0.000 1.000 0.000
#> SRR2936887     3  0.6841      0.922 0.076 0.200 0.724
#> SRR2936884     2  0.5363      0.694 0.000 0.724 0.276
#> SRR2936883     2  0.5363      0.694 0.000 0.724 0.276
#> SRR2936881     2  0.5363      0.694 0.000 0.724 0.276
#> SRR2936882     1  0.0000      0.951 1.000 0.000 0.000
#> SRR2936880     2  0.5363      0.694 0.000 0.724 0.276
#> SRR2936878     2  0.0000      0.925 0.000 1.000 0.000
#> SRR2936879     1  0.0237      0.947 0.996 0.004 0.000
#> SRR2936875     2  0.0000      0.925 0.000 1.000 0.000
#> SRR2936877     2  0.0000      0.925 0.000 1.000 0.000
#> SRR2936876     1  0.0000      0.951 1.000 0.000 0.000
#> SRR2936873     1  0.0000      0.951 1.000 0.000 0.000
#> SRR2936872     2  0.0000      0.925 0.000 1.000 0.000
#> SRR2936871     2  0.0000      0.925 0.000 1.000 0.000
#> SRR2936874     2  0.0000      0.925 0.000 1.000 0.000
#> SRR2936870     1  0.0000      0.951 1.000 0.000 0.000
#> SRR2936869     3  0.6804      0.917 0.072 0.204 0.724
#> SRR2936868     3  0.6841      0.922 0.076 0.200 0.724

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR2936906     1  0.0000      0.986 1.000 0.000 0.000 0.000
#> SRR2936909     1  0.0000      0.986 1.000 0.000 0.000 0.000
#> SRR2936918     1  0.0000      0.986 1.000 0.000 0.000 0.000
#> SRR2936917     2  0.1302      0.973 0.000 0.956 0.044 0.000
#> SRR2936916     2  0.1807      0.963 0.008 0.940 0.052 0.000
#> SRR2936915     1  0.0336      0.982 0.992 0.000 0.008 0.000
#> SRR2936914     2  0.1302      0.973 0.000 0.956 0.044 0.000
#> SRR2936913     2  0.1302      0.973 0.000 0.956 0.044 0.000
#> SRR2936912     1  0.0000      0.986 1.000 0.000 0.000 0.000
#> SRR2936910     1  0.0000      0.986 1.000 0.000 0.000 0.000
#> SRR2936911     2  0.1302      0.973 0.000 0.956 0.044 0.000
#> SRR2936907     2  0.0000      0.978 0.000 1.000 0.000 0.000
#> SRR2936908     2  0.0000      0.978 0.000 1.000 0.000 0.000
#> SRR2936904     4  0.4103      0.639 0.256 0.000 0.000 0.744
#> SRR2936905     2  0.0000      0.978 0.000 1.000 0.000 0.000
#> SRR2936903     1  0.1557      0.951 0.944 0.000 0.056 0.000
#> SRR2936901     3  0.1557      0.876 0.056 0.000 0.944 0.000
#> SRR2936902     3  0.1716      0.927 0.000 0.064 0.936 0.000
#> SRR2936900     1  0.1474      0.954 0.948 0.000 0.052 0.000
#> SRR2936898     3  0.1557      0.876 0.056 0.000 0.944 0.000
#> SRR2936899     3  0.1557      0.876 0.056 0.000 0.944 0.000
#> SRR2936897     1  0.0000      0.986 1.000 0.000 0.000 0.000
#> SRR2936896     2  0.1302      0.973 0.000 0.956 0.044 0.000
#> SRR2936894     1  0.0000      0.986 1.000 0.000 0.000 0.000
#> SRR2936893     2  0.0000      0.978 0.000 1.000 0.000 0.000
#> SRR2936895     2  0.1389      0.970 0.000 0.952 0.048 0.000
#> SRR2936892     2  0.0000      0.978 0.000 1.000 0.000 0.000
#> SRR2936891     1  0.0000      0.986 1.000 0.000 0.000 0.000
#> SRR2936890     2  0.0000      0.978 0.000 1.000 0.000 0.000
#> SRR2936886     4  0.0000      0.911 0.000 0.000 0.000 1.000
#> SRR2936885     1  0.1474      0.954 0.948 0.000 0.052 0.000
#> SRR2936888     1  0.0000      0.986 1.000 0.000 0.000 0.000
#> SRR2936889     2  0.0000      0.978 0.000 1.000 0.000 0.000
#> SRR2936887     4  0.0000      0.911 0.000 0.000 0.000 1.000
#> SRR2936884     3  0.1792      0.923 0.000 0.068 0.932 0.000
#> SRR2936883     3  0.1716      0.927 0.000 0.064 0.936 0.000
#> SRR2936881     3  0.1716      0.927 0.000 0.064 0.936 0.000
#> SRR2936882     1  0.1474      0.954 0.948 0.000 0.052 0.000
#> SRR2936880     3  0.1716      0.927 0.000 0.064 0.936 0.000
#> SRR2936878     2  0.1302      0.973 0.000 0.956 0.044 0.000
#> SRR2936879     1  0.0336      0.982 0.992 0.000 0.008 0.000
#> SRR2936875     2  0.0000      0.978 0.000 1.000 0.000 0.000
#> SRR2936877     2  0.1302      0.973 0.000 0.956 0.044 0.000
#> SRR2936876     1  0.0336      0.982 0.992 0.000 0.008 0.000
#> SRR2936873     1  0.0000      0.986 1.000 0.000 0.000 0.000
#> SRR2936872     2  0.0000      0.978 0.000 1.000 0.000 0.000
#> SRR2936871     2  0.0000      0.978 0.000 1.000 0.000 0.000
#> SRR2936874     2  0.0000      0.978 0.000 1.000 0.000 0.000
#> SRR2936870     1  0.0000      0.986 1.000 0.000 0.000 0.000
#> SRR2936869     4  0.0000      0.911 0.000 0.000 0.000 1.000
#> SRR2936868     4  0.0000      0.911 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
#> SRR2936906     1  0.0000     0.8535 1.000 0.000 0.000 0.000 0.000
#> SRR2936909     1  0.0000     0.8535 1.000 0.000 0.000 0.000 0.000
#> SRR2936918     1  0.0000     0.8535 1.000 0.000 0.000 0.000 0.000
#> SRR2936917     2  0.4451     0.6355 0.000 0.644 0.340 0.000 0.016
#> SRR2936916     3  0.7324     0.2351 0.036 0.224 0.436 0.000 0.304
#> SRR2936915     1  0.3816     0.5588 0.696 0.000 0.000 0.000 0.304
#> SRR2936914     2  0.4451     0.6355 0.000 0.644 0.340 0.000 0.016
#> SRR2936913     2  0.4451     0.6355 0.000 0.644 0.340 0.000 0.016
#> SRR2936912     1  0.0000     0.8535 1.000 0.000 0.000 0.000 0.000
#> SRR2936910     1  0.0000     0.8535 1.000 0.000 0.000 0.000 0.000
#> SRR2936911     2  0.4451     0.6355 0.000 0.644 0.340 0.000 0.016
#> SRR2936907     2  0.0000     0.7973 0.000 1.000 0.000 0.000 0.000
#> SRR2936908     2  0.0000     0.7973 0.000 1.000 0.000 0.000 0.000
#> SRR2936904     4  0.3966     0.4768 0.336 0.000 0.000 0.664 0.000
#> SRR2936905     2  0.0000     0.7973 0.000 1.000 0.000 0.000 0.000
#> SRR2936903     5  0.4249     0.0436 0.432 0.000 0.000 0.000 0.568
#> SRR2936901     5  0.4029     0.7273 0.004 0.000 0.316 0.000 0.680
#> SRR2936902     3  0.0510     0.8531 0.000 0.000 0.984 0.000 0.016
#> SRR2936900     1  0.4297     0.0104 0.528 0.000 0.000 0.000 0.472
#> SRR2936898     5  0.4029     0.7273 0.004 0.000 0.316 0.000 0.680
#> SRR2936899     5  0.4029     0.7273 0.004 0.000 0.316 0.000 0.680
#> SRR2936897     1  0.0000     0.8535 1.000 0.000 0.000 0.000 0.000
#> SRR2936896     2  0.4451     0.6355 0.000 0.644 0.340 0.000 0.016
#> SRR2936894     1  0.0000     0.8535 1.000 0.000 0.000 0.000 0.000
#> SRR2936893     2  0.0000     0.7973 0.000 1.000 0.000 0.000 0.000
#> SRR2936895     2  0.4723     0.4299 0.000 0.536 0.448 0.000 0.016
#> SRR2936892     2  0.0000     0.7973 0.000 1.000 0.000 0.000 0.000
#> SRR2936891     1  0.0000     0.8535 1.000 0.000 0.000 0.000 0.000
#> SRR2936890     2  0.0000     0.7973 0.000 1.000 0.000 0.000 0.000
#> SRR2936886     4  0.0000     0.8818 0.000 0.000 0.000 1.000 0.000
#> SRR2936885     1  0.4291     0.0373 0.536 0.000 0.000 0.000 0.464
#> SRR2936888     1  0.0000     0.8535 1.000 0.000 0.000 0.000 0.000
#> SRR2936889     2  0.0000     0.7973 0.000 1.000 0.000 0.000 0.000
#> SRR2936887     4  0.0000     0.8818 0.000 0.000 0.000 1.000 0.000
#> SRR2936884     3  0.0000     0.8426 0.000 0.000 1.000 0.000 0.000
#> SRR2936883     3  0.0510     0.8531 0.000 0.000 0.984 0.000 0.016
#> SRR2936881     3  0.0510     0.8531 0.000 0.000 0.984 0.000 0.016
#> SRR2936882     1  0.4297     0.0104 0.528 0.000 0.000 0.000 0.472
#> SRR2936880     3  0.0510     0.8531 0.000 0.000 0.984 0.000 0.016
#> SRR2936878     2  0.4451     0.6355 0.000 0.644 0.340 0.000 0.016
#> SRR2936879     1  0.2929     0.7035 0.820 0.000 0.000 0.000 0.180
#> SRR2936875     2  0.0000     0.7973 0.000 1.000 0.000 0.000 0.000
#> SRR2936877     2  0.4451     0.6355 0.000 0.644 0.340 0.000 0.016
#> SRR2936876     1  0.0794     0.8356 0.972 0.000 0.000 0.000 0.028
#> SRR2936873     1  0.0000     0.8535 1.000 0.000 0.000 0.000 0.000
#> SRR2936872     2  0.0000     0.7973 0.000 1.000 0.000 0.000 0.000
#> SRR2936871     2  0.0000     0.7973 0.000 1.000 0.000 0.000 0.000
#> SRR2936874     2  0.0000     0.7973 0.000 1.000 0.000 0.000 0.000
#> SRR2936870     1  0.0000     0.8535 1.000 0.000 0.000 0.000 0.000
#> SRR2936869     4  0.0000     0.8818 0.000 0.000 0.000 1.000 0.000
#> SRR2936868     4  0.0000     0.8818 0.000 0.000 0.000 1.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
#> SRR2936906     1  0.0000      0.955 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936909     1  0.0000      0.955 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936918     1  0.0000      0.955 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936917     2  0.5558      0.458 0.000 0.524 0.316 0.000 0.160 0.000
#> SRR2936916     5  0.3659     -0.217 0.000 0.000 0.364 0.000 0.636 0.000
#> SRR2936915     5  0.2491      0.383 0.164 0.000 0.000 0.000 0.836 0.000
#> SRR2936914     2  0.5558      0.458 0.000 0.524 0.316 0.000 0.160 0.000
#> SRR2936913     2  0.5558      0.458 0.000 0.524 0.316 0.000 0.160 0.000
#> SRR2936912     1  0.0000      0.955 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936910     1  0.0000      0.955 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936911     2  0.5558      0.458 0.000 0.524 0.316 0.000 0.160 0.000
#> SRR2936907     2  0.0000      0.760 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936908     2  0.0000      0.760 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936904     4  0.3810      0.180 0.428 0.000 0.000 0.572 0.000 0.000
#> SRR2936905     2  0.0000      0.760 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936903     6  0.3706      0.624 0.380 0.000 0.000 0.000 0.000 0.620
#> SRR2936901     6  0.0000      0.547 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR2936902     3  0.0865      0.802 0.000 0.000 0.964 0.000 0.000 0.036
#> SRR2936900     6  0.3854      0.568 0.464 0.000 0.000 0.000 0.000 0.536
#> SRR2936898     6  0.0000      0.547 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR2936899     6  0.0000      0.547 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR2936897     1  0.0000      0.955 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936896     2  0.5558      0.458 0.000 0.524 0.316 0.000 0.160 0.000
#> SRR2936894     1  0.0000      0.955 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936893     2  0.0000      0.760 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936895     3  0.5678     -0.220 0.000 0.376 0.464 0.000 0.160 0.000
#> SRR2936892     2  0.0000      0.760 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936891     1  0.0000      0.955 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936890     2  0.0000      0.760 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936886     4  0.0000      0.837 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR2936885     6  0.3862      0.547 0.476 0.000 0.000 0.000 0.000 0.524
#> SRR2936888     1  0.0000      0.955 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936889     2  0.0000      0.760 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936887     4  0.0000      0.837 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR2936884     3  0.0000      0.772 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR2936883     3  0.0865      0.802 0.000 0.000 0.964 0.000 0.000 0.036
#> SRR2936881     3  0.0865      0.802 0.000 0.000 0.964 0.000 0.000 0.036
#> SRR2936882     6  0.3857      0.562 0.468 0.000 0.000 0.000 0.000 0.532
#> SRR2936880     3  0.0865      0.802 0.000 0.000 0.964 0.000 0.000 0.036
#> SRR2936878     2  0.5558      0.458 0.000 0.524 0.316 0.000 0.160 0.000
#> SRR2936879     5  0.3823      0.131 0.436 0.000 0.000 0.000 0.564 0.000
#> SRR2936875     2  0.0000      0.760 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936877     2  0.5558      0.458 0.000 0.524 0.316 0.000 0.160 0.000
#> SRR2936876     1  0.3647      0.199 0.640 0.000 0.000 0.000 0.360 0.000
#> SRR2936873     1  0.0000      0.955 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936872     2  0.0000      0.760 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936871     2  0.0000      0.760 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936874     2  0.0000      0.760 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936870     1  0.0000      0.955 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936869     4  0.0000      0.837 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR2936868     4  0.0000      0.837 0.000 0.000 0.000 1.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 14198 rows and 51 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.920           0.955       0.981         0.5025 0.495   0.495
#> 3 3 0.971           0.939       0.976         0.3440 0.704   0.469
#> 4 4 0.848           0.836       0.894         0.0844 0.905   0.726
#> 5 5 0.891           0.948       0.949         0.0675 0.922   0.726
#> 6 6 1.000           0.952       0.977         0.0541 0.962   0.827

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
#> SRR2936906     1   0.000      0.963 1.000 0.000
#> SRR2936909     1   0.000      0.963 1.000 0.000
#> SRR2936918     1   0.000      0.963 1.000 0.000
#> SRR2936917     2   0.000      0.992 0.000 1.000
#> SRR2936916     2   0.000      0.992 0.000 1.000
#> SRR2936915     2   0.000      0.992 0.000 1.000
#> SRR2936914     2   0.000      0.992 0.000 1.000
#> SRR2936913     2   0.000      0.992 0.000 1.000
#> SRR2936912     1   0.000      0.963 1.000 0.000
#> SRR2936910     1   0.000      0.963 1.000 0.000
#> SRR2936911     2   0.000      0.992 0.000 1.000
#> SRR2936907     2   0.000      0.992 0.000 1.000
#> SRR2936908     2   0.000      0.992 0.000 1.000
#> SRR2936904     1   0.000      0.963 1.000 0.000
#> SRR2936905     2   0.000      0.992 0.000 1.000
#> SRR2936903     1   0.000      0.963 1.000 0.000
#> SRR2936901     1   0.000      0.963 1.000 0.000
#> SRR2936902     2   0.000      0.992 0.000 1.000
#> SRR2936900     1   0.000      0.963 1.000 0.000
#> SRR2936898     1   0.000      0.963 1.000 0.000
#> SRR2936899     1   0.000      0.963 1.000 0.000
#> SRR2936897     1   0.000      0.963 1.000 0.000
#> SRR2936896     2   0.000      0.992 0.000 1.000
#> SRR2936894     1   0.000      0.963 1.000 0.000
#> SRR2936893     2   0.000      0.992 0.000 1.000
#> SRR2936895     2   0.000      0.992 0.000 1.000
#> SRR2936892     2   0.000      0.992 0.000 1.000
#> SRR2936891     1   0.000      0.963 1.000 0.000
#> SRR2936890     2   0.000      0.992 0.000 1.000
#> SRR2936886     1   0.722      0.759 0.800 0.200
#> SRR2936885     1   0.000      0.963 1.000 0.000
#> SRR2936888     1   0.000      0.963 1.000 0.000
#> SRR2936889     2   0.000      0.992 0.000 1.000
#> SRR2936887     1   0.722      0.759 0.800 0.200
#> SRR2936884     2   0.000      0.992 0.000 1.000
#> SRR2936883     2   0.000      0.992 0.000 1.000
#> SRR2936881     2   0.000      0.992 0.000 1.000
#> SRR2936882     1   0.000      0.963 1.000 0.000
#> SRR2936880     2   0.000      0.992 0.000 1.000
#> SRR2936878     2   0.000      0.992 0.000 1.000
#> SRR2936879     2   0.722      0.739 0.200 0.800
#> SRR2936875     2   0.000      0.992 0.000 1.000
#> SRR2936877     2   0.000      0.992 0.000 1.000
#> SRR2936876     1   0.000      0.963 1.000 0.000
#> SRR2936873     1   0.000      0.963 1.000 0.000
#> SRR2936872     2   0.000      0.992 0.000 1.000
#> SRR2936871     2   0.000      0.992 0.000 1.000
#> SRR2936874     2   0.000      0.992 0.000 1.000
#> SRR2936870     1   0.000      0.963 1.000 0.000
#> SRR2936869     2   0.000      0.992 0.000 1.000
#> SRR2936868     1   0.963      0.408 0.612 0.388

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR2936906     1  0.0000      0.998 1.000 0.000 0.000
#> SRR2936909     1  0.0000      0.998 1.000 0.000 0.000
#> SRR2936918     1  0.0000      0.998 1.000 0.000 0.000
#> SRR2936917     2  0.0000      0.981 0.000 1.000 0.000
#> SRR2936916     3  0.0000      0.944 0.000 0.000 1.000
#> SRR2936915     3  0.0000      0.944 0.000 0.000 1.000
#> SRR2936914     2  0.0000      0.981 0.000 1.000 0.000
#> SRR2936913     2  0.0000      0.981 0.000 1.000 0.000
#> SRR2936912     1  0.0000      0.998 1.000 0.000 0.000
#> SRR2936910     1  0.0000      0.998 1.000 0.000 0.000
#> SRR2936911     2  0.0000      0.981 0.000 1.000 0.000
#> SRR2936907     2  0.0000      0.981 0.000 1.000 0.000
#> SRR2936908     2  0.0000      0.981 0.000 1.000 0.000
#> SRR2936904     3  0.0000      0.944 0.000 0.000 1.000
#> SRR2936905     2  0.0000      0.981 0.000 1.000 0.000
#> SRR2936903     3  0.0000      0.944 0.000 0.000 1.000
#> SRR2936901     3  0.0000      0.944 0.000 0.000 1.000
#> SRR2936902     3  0.0000      0.944 0.000 0.000 1.000
#> SRR2936900     1  0.0000      0.998 1.000 0.000 0.000
#> SRR2936898     3  0.0000      0.944 0.000 0.000 1.000
#> SRR2936899     3  0.0000      0.944 0.000 0.000 1.000
#> SRR2936897     1  0.0000      0.998 1.000 0.000 0.000
#> SRR2936896     2  0.0000      0.981 0.000 1.000 0.000
#> SRR2936894     1  0.0000      0.998 1.000 0.000 0.000
#> SRR2936893     2  0.0000      0.981 0.000 1.000 0.000
#> SRR2936895     3  0.5431      0.581 0.000 0.284 0.716
#> SRR2936892     2  0.0000      0.981 0.000 1.000 0.000
#> SRR2936891     1  0.0000      0.998 1.000 0.000 0.000
#> SRR2936890     2  0.0000      0.981 0.000 1.000 0.000
#> SRR2936886     3  0.0000      0.944 0.000 0.000 1.000
#> SRR2936885     1  0.1163      0.969 0.972 0.000 0.028
#> SRR2936888     1  0.0000      0.998 1.000 0.000 0.000
#> SRR2936889     2  0.0000      0.981 0.000 1.000 0.000
#> SRR2936887     3  0.0000      0.944 0.000 0.000 1.000
#> SRR2936884     2  0.5760      0.497 0.000 0.672 0.328
#> SRR2936883     3  0.0000      0.944 0.000 0.000 1.000
#> SRR2936881     3  0.0000      0.944 0.000 0.000 1.000
#> SRR2936882     1  0.0000      0.998 1.000 0.000 0.000
#> SRR2936880     3  0.0000      0.944 0.000 0.000 1.000
#> SRR2936878     2  0.0000      0.981 0.000 1.000 0.000
#> SRR2936879     3  0.0000      0.944 0.000 0.000 1.000
#> SRR2936875     2  0.0000      0.981 0.000 1.000 0.000
#> SRR2936877     2  0.0000      0.981 0.000 1.000 0.000
#> SRR2936876     3  0.6126      0.332 0.400 0.000 0.600
#> SRR2936873     1  0.0000      0.998 1.000 0.000 0.000
#> SRR2936872     2  0.0000      0.981 0.000 1.000 0.000
#> SRR2936871     2  0.0000      0.981 0.000 1.000 0.000
#> SRR2936874     2  0.0000      0.981 0.000 1.000 0.000
#> SRR2936870     1  0.0000      0.998 1.000 0.000 0.000
#> SRR2936869     3  0.4555      0.735 0.000 0.200 0.800
#> SRR2936868     3  0.0237      0.941 0.000 0.004 0.996

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR2936906     1   0.000     0.9711 1.000 0.000 0.000 0.000
#> SRR2936909     1   0.000     0.9711 1.000 0.000 0.000 0.000
#> SRR2936918     1   0.000     0.9711 1.000 0.000 0.000 0.000
#> SRR2936917     2   0.464     0.7553 0.000 0.656 0.000 0.344
#> SRR2936916     3   0.000     0.8030 0.000 0.000 1.000 0.000
#> SRR2936915     3   0.387     0.3355 0.000 0.000 0.772 0.228
#> SRR2936914     2   0.464     0.7553 0.000 0.656 0.000 0.344
#> SRR2936913     2   0.464     0.7553 0.000 0.656 0.000 0.344
#> SRR2936912     1   0.000     0.9711 1.000 0.000 0.000 0.000
#> SRR2936910     1   0.000     0.9711 1.000 0.000 0.000 0.000
#> SRR2936911     2   0.464     0.7553 0.000 0.656 0.000 0.344
#> SRR2936907     2   0.000     0.8823 0.000 1.000 0.000 0.000
#> SRR2936908     2   0.000     0.8823 0.000 1.000 0.000 0.000
#> SRR2936904     4   0.464     0.9979 0.000 0.000 0.344 0.656
#> SRR2936905     2   0.000     0.8823 0.000 1.000 0.000 0.000
#> SRR2936903     3   0.497     0.0325 0.456 0.000 0.544 0.000
#> SRR2936901     3   0.000     0.8030 0.000 0.000 1.000 0.000
#> SRR2936902     3   0.000     0.8030 0.000 0.000 1.000 0.000
#> SRR2936900     1   0.000     0.9711 1.000 0.000 0.000 0.000
#> SRR2936898     3   0.000     0.8030 0.000 0.000 1.000 0.000
#> SRR2936899     3   0.000     0.8030 0.000 0.000 1.000 0.000
#> SRR2936897     1   0.000     0.9711 1.000 0.000 0.000 0.000
#> SRR2936896     2   0.172     0.8637 0.000 0.936 0.000 0.064
#> SRR2936894     1   0.000     0.9711 1.000 0.000 0.000 0.000
#> SRR2936893     2   0.000     0.8823 0.000 1.000 0.000 0.000
#> SRR2936895     3   0.344     0.5759 0.000 0.184 0.816 0.000
#> SRR2936892     2   0.000     0.8823 0.000 1.000 0.000 0.000
#> SRR2936891     1   0.000     0.9711 1.000 0.000 0.000 0.000
#> SRR2936890     2   0.000     0.8823 0.000 1.000 0.000 0.000
#> SRR2936886     4   0.464     0.9979 0.000 0.000 0.344 0.656
#> SRR2936885     1   0.000     0.9711 1.000 0.000 0.000 0.000
#> SRR2936888     1   0.000     0.9711 1.000 0.000 0.000 0.000
#> SRR2936889     2   0.000     0.8823 0.000 1.000 0.000 0.000
#> SRR2936887     4   0.464     0.9979 0.000 0.000 0.344 0.656
#> SRR2936884     3   0.464     0.3731 0.000 0.344 0.656 0.000
#> SRR2936883     3   0.000     0.8030 0.000 0.000 1.000 0.000
#> SRR2936881     3   0.000     0.8030 0.000 0.000 1.000 0.000
#> SRR2936882     1   0.000     0.9711 1.000 0.000 0.000 0.000
#> SRR2936880     3   0.000     0.8030 0.000 0.000 1.000 0.000
#> SRR2936878     2   0.464     0.7553 0.000 0.656 0.000 0.344
#> SRR2936879     3   0.000     0.8030 0.000 0.000 1.000 0.000
#> SRR2936875     2   0.000     0.8823 0.000 1.000 0.000 0.000
#> SRR2936877     2   0.464     0.7553 0.000 0.656 0.000 0.344
#> SRR2936876     1   0.456     0.3985 0.672 0.000 0.328 0.000
#> SRR2936873     1   0.000     0.9711 1.000 0.000 0.000 0.000
#> SRR2936872     2   0.000     0.8823 0.000 1.000 0.000 0.000
#> SRR2936871     2   0.000     0.8823 0.000 1.000 0.000 0.000
#> SRR2936874     2   0.000     0.8823 0.000 1.000 0.000 0.000
#> SRR2936870     1   0.000     0.9711 1.000 0.000 0.000 0.000
#> SRR2936869     4   0.480     0.9917 0.000 0.004 0.340 0.656
#> SRR2936868     4   0.464     0.9979 0.000 0.000 0.344 0.656

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette  p1    p2    p3    p4    p5
#> SRR2936906     1   0.000      0.951 1.0 0.000 0.000 0.000 0.000
#> SRR2936909     1   0.000      0.951 1.0 0.000 0.000 0.000 0.000
#> SRR2936918     1   0.000      0.951 1.0 0.000 0.000 0.000 0.000
#> SRR2936917     5   0.311      1.000 0.0 0.200 0.000 0.000 0.800
#> SRR2936916     3   0.000      0.968 0.0 0.000 1.000 0.000 0.000
#> SRR2936915     3   0.340      0.700 0.0 0.000 0.764 0.236 0.000
#> SRR2936914     5   0.311      1.000 0.0 0.200 0.000 0.000 0.800
#> SRR2936913     5   0.311      1.000 0.0 0.200 0.000 0.000 0.800
#> SRR2936912     1   0.000      0.951 1.0 0.000 0.000 0.000 0.000
#> SRR2936910     1   0.000      0.951 1.0 0.000 0.000 0.000 0.000
#> SRR2936911     5   0.311      1.000 0.0 0.200 0.000 0.000 0.800
#> SRR2936907     2   0.000      0.973 0.0 1.000 0.000 0.000 0.000
#> SRR2936908     2   0.000      0.973 0.0 1.000 0.000 0.000 0.000
#> SRR2936904     4   0.000      1.000 0.0 0.000 0.000 1.000 0.000
#> SRR2936905     2   0.000      0.973 0.0 1.000 0.000 0.000 0.000
#> SRR2936903     1   0.311      0.842 0.8 0.000 0.000 0.000 0.200
#> SRR2936901     3   0.223      0.872 0.0 0.000 0.884 0.000 0.116
#> SRR2936902     3   0.000      0.968 0.0 0.000 1.000 0.000 0.000
#> SRR2936900     1   0.311      0.842 0.8 0.000 0.000 0.000 0.200
#> SRR2936898     3   0.000      0.968 0.0 0.000 1.000 0.000 0.000
#> SRR2936899     3   0.000      0.968 0.0 0.000 1.000 0.000 0.000
#> SRR2936897     1   0.000      0.951 1.0 0.000 0.000 0.000 0.000
#> SRR2936896     2   0.337      0.592 0.0 0.768 0.000 0.000 0.232
#> SRR2936894     1   0.000      0.951 1.0 0.000 0.000 0.000 0.000
#> SRR2936893     2   0.000      0.973 0.0 1.000 0.000 0.000 0.000
#> SRR2936895     3   0.000      0.968 0.0 0.000 1.000 0.000 0.000
#> SRR2936892     2   0.000      0.973 0.0 1.000 0.000 0.000 0.000
#> SRR2936891     1   0.000      0.951 1.0 0.000 0.000 0.000 0.000
#> SRR2936890     2   0.000      0.973 0.0 1.000 0.000 0.000 0.000
#> SRR2936886     4   0.000      1.000 0.0 0.000 0.000 1.000 0.000
#> SRR2936885     1   0.311      0.842 0.8 0.000 0.000 0.000 0.200
#> SRR2936888     1   0.000      0.951 1.0 0.000 0.000 0.000 0.000
#> SRR2936889     2   0.000      0.973 0.0 1.000 0.000 0.000 0.000
#> SRR2936887     4   0.000      1.000 0.0 0.000 0.000 1.000 0.000
#> SRR2936884     3   0.000      0.968 0.0 0.000 1.000 0.000 0.000
#> SRR2936883     3   0.000      0.968 0.0 0.000 1.000 0.000 0.000
#> SRR2936881     3   0.000      0.968 0.0 0.000 1.000 0.000 0.000
#> SRR2936882     1   0.311      0.842 0.8 0.000 0.000 0.000 0.200
#> SRR2936880     3   0.000      0.968 0.0 0.000 1.000 0.000 0.000
#> SRR2936878     5   0.311      1.000 0.0 0.200 0.000 0.000 0.800
#> SRR2936879     3   0.000      0.968 0.0 0.000 1.000 0.000 0.000
#> SRR2936875     2   0.000      0.973 0.0 1.000 0.000 0.000 0.000
#> SRR2936877     5   0.311      1.000 0.0 0.200 0.000 0.000 0.800
#> SRR2936876     1   0.000      0.951 1.0 0.000 0.000 0.000 0.000
#> SRR2936873     1   0.000      0.951 1.0 0.000 0.000 0.000 0.000
#> SRR2936872     2   0.000      0.973 0.0 1.000 0.000 0.000 0.000
#> SRR2936871     2   0.000      0.973 0.0 1.000 0.000 0.000 0.000
#> SRR2936874     2   0.000      0.973 0.0 1.000 0.000 0.000 0.000
#> SRR2936870     1   0.000      0.951 1.0 0.000 0.000 0.000 0.000
#> SRR2936869     4   0.000      1.000 0.0 0.000 0.000 1.000 0.000
#> SRR2936868     4   0.000      1.000 0.0 0.000 0.000 1.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
#> SRR2936906     1   0.000      0.995 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936909     1   0.000      0.995 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936918     1   0.000      0.995 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936917     5   0.000      1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR2936916     3   0.000      0.950 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR2936915     3   0.405      0.679 0.000 0.000 0.716 0.236 0.000 0.048
#> SRR2936914     5   0.000      1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR2936913     5   0.000      1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR2936912     1   0.000      0.995 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936910     1   0.000      0.995 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936911     5   0.000      1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR2936907     2   0.000      0.959 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936908     2   0.000      0.959 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936904     4   0.000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR2936905     2   0.000      0.959 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936903     6   0.000      0.926 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR2936901     3   0.249      0.839 0.000 0.000 0.836 0.000 0.000 0.164
#> SRR2936902     3   0.000      0.950 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR2936900     6   0.107      0.976 0.048 0.000 0.000 0.000 0.000 0.952
#> SRR2936898     3   0.107      0.936 0.000 0.000 0.952 0.000 0.000 0.048
#> SRR2936899     3   0.107      0.936 0.000 0.000 0.952 0.000 0.000 0.048
#> SRR2936897     1   0.000      0.995 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936896     2   0.378      0.299 0.000 0.588 0.000 0.000 0.412 0.000
#> SRR2936894     1   0.000      0.995 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936893     2   0.000      0.959 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936895     3   0.000      0.950 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR2936892     2   0.000      0.959 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936891     1   0.000      0.995 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936890     2   0.000      0.959 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936886     4   0.000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR2936885     6   0.107      0.976 0.048 0.000 0.000 0.000 0.000 0.952
#> SRR2936888     1   0.000      0.995 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936889     2   0.000      0.959 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936887     4   0.000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR2936884     3   0.000      0.950 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR2936883     3   0.000      0.950 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR2936881     3   0.000      0.950 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR2936882     6   0.107      0.976 0.048 0.000 0.000 0.000 0.000 0.952
#> SRR2936880     3   0.000      0.950 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR2936878     5   0.000      1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR2936879     3   0.107      0.936 0.000 0.000 0.952 0.000 0.000 0.048
#> SRR2936875     2   0.000      0.959 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936877     5   0.000      1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR2936876     1   0.107      0.941 0.952 0.000 0.000 0.000 0.000 0.048
#> SRR2936873     1   0.000      0.995 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936872     2   0.000      0.959 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936871     2   0.000      0.959 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936874     2   0.000      0.959 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936870     1   0.000      0.995 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936869     4   0.000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR2936868     4   0.000      1.000 0.000 0.000 0.000 1.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-pam-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-pam-collect-classes

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


SD:mclust*

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

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

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

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

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

collect_plots(res)

plot of chunk SD-mclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.447           0.862       0.917         0.4377 0.534   0.534
#> 3 3 0.764           0.826       0.918         0.5132 0.767   0.575
#> 4 4 0.886           0.906       0.963         0.0976 0.915   0.752
#> 5 5 0.934           0.924       0.958         0.1062 0.882   0.593
#> 6 6 0.871           0.862       0.905         0.0267 0.970   0.846

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
#> SRR2936906     2   0.634      0.879 0.160 0.840
#> SRR2936909     2   0.634      0.879 0.160 0.840
#> SRR2936918     2   0.634      0.879 0.160 0.840
#> SRR2936917     2   0.000      0.903 0.000 1.000
#> SRR2936916     2   0.625      0.880 0.156 0.844
#> SRR2936915     2   0.625      0.880 0.156 0.844
#> SRR2936914     2   0.000      0.903 0.000 1.000
#> SRR2936913     2   0.000      0.903 0.000 1.000
#> SRR2936912     2   0.634      0.879 0.160 0.840
#> SRR2936910     2   0.634      0.879 0.160 0.840
#> SRR2936911     2   0.000      0.903 0.000 1.000
#> SRR2936907     2   0.000      0.903 0.000 1.000
#> SRR2936908     2   0.000      0.903 0.000 1.000
#> SRR2936904     2   0.625      0.880 0.156 0.844
#> SRR2936905     2   0.000      0.903 0.000 1.000
#> SRR2936903     1   0.000      0.878 1.000 0.000
#> SRR2936901     1   0.000      0.878 1.000 0.000
#> SRR2936902     1   0.000      0.878 1.000 0.000
#> SRR2936900     1   0.000      0.878 1.000 0.000
#> SRR2936898     1   0.000      0.878 1.000 0.000
#> SRR2936899     1   0.000      0.878 1.000 0.000
#> SRR2936897     2   0.644      0.876 0.164 0.836
#> SRR2936896     2   0.430      0.893 0.088 0.912
#> SRR2936894     2   0.634      0.879 0.160 0.840
#> SRR2936893     2   0.000      0.903 0.000 1.000
#> SRR2936895     2   0.644      0.876 0.164 0.836
#> SRR2936892     2   0.000      0.903 0.000 1.000
#> SRR2936891     2   0.634      0.879 0.160 0.840
#> SRR2936890     2   0.000      0.903 0.000 1.000
#> SRR2936886     1   0.866      0.662 0.712 0.288
#> SRR2936885     1   0.000      0.878 1.000 0.000
#> SRR2936888     1   0.866      0.662 0.712 0.288
#> SRR2936889     2   0.000      0.903 0.000 1.000
#> SRR2936887     1   0.866      0.662 0.712 0.288
#> SRR2936884     1   0.000      0.878 1.000 0.000
#> SRR2936883     1   0.000      0.878 1.000 0.000
#> SRR2936881     1   0.000      0.878 1.000 0.000
#> SRR2936882     1   0.000      0.878 1.000 0.000
#> SRR2936880     1   0.000      0.878 1.000 0.000
#> SRR2936878     2   0.000      0.903 0.000 1.000
#> SRR2936879     2   0.634      0.878 0.160 0.840
#> SRR2936875     2   0.000      0.903 0.000 1.000
#> SRR2936877     2   0.000      0.903 0.000 1.000
#> SRR2936876     2   0.634      0.879 0.160 0.840
#> SRR2936873     2   0.634      0.879 0.160 0.840
#> SRR2936872     2   0.000      0.903 0.000 1.000
#> SRR2936871     2   0.000      0.903 0.000 1.000
#> SRR2936874     2   0.000      0.903 0.000 1.000
#> SRR2936870     1   0.866      0.662 0.712 0.288
#> SRR2936869     1   0.866      0.662 0.712 0.288
#> SRR2936868     1   0.866      0.662 0.712 0.288

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR2936906     1   0.000      0.910 1.000 0.000 0.000
#> SRR2936909     1   0.000      0.910 1.000 0.000 0.000
#> SRR2936918     1   0.000      0.910 1.000 0.000 0.000
#> SRR2936917     2   0.196      0.900 0.056 0.944 0.000
#> SRR2936916     1   0.599      0.402 0.632 0.368 0.000
#> SRR2936915     1   0.327      0.821 0.884 0.116 0.000
#> SRR2936914     2   0.216      0.894 0.064 0.936 0.000
#> SRR2936913     2   0.000      0.935 0.000 1.000 0.000
#> SRR2936912     1   0.000      0.910 1.000 0.000 0.000
#> SRR2936910     1   0.000      0.910 1.000 0.000 0.000
#> SRR2936911     2   0.000      0.935 0.000 1.000 0.000
#> SRR2936907     2   0.000      0.935 0.000 1.000 0.000
#> SRR2936908     2   0.000      0.935 0.000 1.000 0.000
#> SRR2936904     3   0.972      0.106 0.220 0.384 0.396
#> SRR2936905     2   0.000      0.935 0.000 1.000 0.000
#> SRR2936903     3   0.000      0.871 0.000 0.000 1.000
#> SRR2936901     3   0.000      0.871 0.000 0.000 1.000
#> SRR2936902     3   0.000      0.871 0.000 0.000 1.000
#> SRR2936900     3   0.000      0.871 0.000 0.000 1.000
#> SRR2936898     3   0.000      0.871 0.000 0.000 1.000
#> SRR2936899     3   0.000      0.871 0.000 0.000 1.000
#> SRR2936897     1   0.000      0.910 1.000 0.000 0.000
#> SRR2936896     2   0.369      0.828 0.140 0.860 0.000
#> SRR2936894     1   0.000      0.910 1.000 0.000 0.000
#> SRR2936893     2   0.000      0.935 0.000 1.000 0.000
#> SRR2936895     2   0.929      0.140 0.168 0.476 0.356
#> SRR2936892     2   0.000      0.935 0.000 1.000 0.000
#> SRR2936891     1   0.000      0.910 1.000 0.000 0.000
#> SRR2936890     2   0.000      0.935 0.000 1.000 0.000
#> SRR2936886     3   0.597      0.746 0.216 0.032 0.752
#> SRR2936885     3   0.000      0.871 0.000 0.000 1.000
#> SRR2936888     3   0.665      0.665 0.288 0.032 0.680
#> SRR2936889     2   0.000      0.935 0.000 1.000 0.000
#> SRR2936887     3   0.597      0.746 0.216 0.032 0.752
#> SRR2936884     3   0.000      0.871 0.000 0.000 1.000
#> SRR2936883     3   0.000      0.871 0.000 0.000 1.000
#> SRR2936881     3   0.000      0.871 0.000 0.000 1.000
#> SRR2936882     3   0.000      0.871 0.000 0.000 1.000
#> SRR2936880     3   0.000      0.871 0.000 0.000 1.000
#> SRR2936878     2   0.348      0.842 0.128 0.872 0.000
#> SRR2936879     1   0.613      0.319 0.600 0.400 0.000
#> SRR2936875     2   0.000      0.935 0.000 1.000 0.000
#> SRR2936877     2   0.348      0.842 0.128 0.872 0.000
#> SRR2936876     1   0.000      0.910 1.000 0.000 0.000
#> SRR2936873     1   0.000      0.910 1.000 0.000 0.000
#> SRR2936872     2   0.000      0.935 0.000 1.000 0.000
#> SRR2936871     2   0.000      0.935 0.000 1.000 0.000
#> SRR2936874     2   0.000      0.935 0.000 1.000 0.000
#> SRR2936870     3   0.665      0.665 0.288 0.032 0.680
#> SRR2936869     3   0.597      0.746 0.216 0.032 0.752
#> SRR2936868     3   0.597      0.746 0.216 0.032 0.752

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2 p3    p4
#> SRR2936906     1  0.0000     0.9092 1.000 0.000  0 0.000
#> SRR2936909     1  0.0000     0.9092 1.000 0.000  0 0.000
#> SRR2936918     1  0.0000     0.9092 1.000 0.000  0 0.000
#> SRR2936917     2  0.0000     0.9371 0.000 1.000  0 0.000
#> SRR2936916     1  0.4522     0.5370 0.680 0.320  0 0.000
#> SRR2936915     1  0.0336     0.9034 0.992 0.008  0 0.000
#> SRR2936914     2  0.0000     0.9371 0.000 1.000  0 0.000
#> SRR2936913     2  0.0000     0.9371 0.000 1.000  0 0.000
#> SRR2936912     1  0.0000     0.9092 1.000 0.000  0 0.000
#> SRR2936910     1  0.0000     0.9092 1.000 0.000  0 0.000
#> SRR2936911     2  0.0000     0.9371 0.000 1.000  0 0.000
#> SRR2936907     2  0.0000     0.9371 0.000 1.000  0 0.000
#> SRR2936908     2  0.0000     0.9371 0.000 1.000  0 0.000
#> SRR2936904     2  0.5167     0.0289 0.004 0.508  0 0.488
#> SRR2936905     2  0.0000     0.9371 0.000 1.000  0 0.000
#> SRR2936903     3  0.0000     1.0000 0.000 0.000  1 0.000
#> SRR2936901     3  0.0000     1.0000 0.000 0.000  1 0.000
#> SRR2936902     3  0.0000     1.0000 0.000 0.000  1 0.000
#> SRR2936900     3  0.0000     1.0000 0.000 0.000  1 0.000
#> SRR2936898     3  0.0000     1.0000 0.000 0.000  1 0.000
#> SRR2936899     3  0.0000     1.0000 0.000 0.000  1 0.000
#> SRR2936897     1  0.2868     0.7935 0.864 0.136  0 0.000
#> SRR2936896     2  0.3172     0.8005 0.160 0.840  0 0.000
#> SRR2936894     1  0.0000     0.9092 1.000 0.000  0 0.000
#> SRR2936893     2  0.0000     0.9371 0.000 1.000  0 0.000
#> SRR2936895     2  0.3172     0.8005 0.160 0.840  0 0.000
#> SRR2936892     2  0.0000     0.9371 0.000 1.000  0 0.000
#> SRR2936891     1  0.0000     0.9092 1.000 0.000  0 0.000
#> SRR2936890     2  0.0000     0.9371 0.000 1.000  0 0.000
#> SRR2936886     4  0.0000     1.0000 0.000 0.000  0 1.000
#> SRR2936885     3  0.0000     1.0000 0.000 0.000  1 0.000
#> SRR2936888     4  0.0000     1.0000 0.000 0.000  0 1.000
#> SRR2936889     2  0.0000     0.9371 0.000 1.000  0 0.000
#> SRR2936887     4  0.0000     1.0000 0.000 0.000  0 1.000
#> SRR2936884     3  0.0000     1.0000 0.000 0.000  1 0.000
#> SRR2936883     3  0.0000     1.0000 0.000 0.000  1 0.000
#> SRR2936881     3  0.0000     1.0000 0.000 0.000  1 0.000
#> SRR2936882     3  0.0000     1.0000 0.000 0.000  1 0.000
#> SRR2936880     3  0.0000     1.0000 0.000 0.000  1 0.000
#> SRR2936878     2  0.2868     0.8272 0.136 0.864  0 0.000
#> SRR2936879     1  0.4679     0.4692 0.648 0.352  0 0.000
#> SRR2936875     2  0.0000     0.9371 0.000 1.000  0 0.000
#> SRR2936877     2  0.2868     0.8272 0.136 0.864  0 0.000
#> SRR2936876     1  0.0000     0.9092 1.000 0.000  0 0.000
#> SRR2936873     1  0.0000     0.9092 1.000 0.000  0 0.000
#> SRR2936872     2  0.0000     0.9371 0.000 1.000  0 0.000
#> SRR2936871     2  0.0000     0.9371 0.000 1.000  0 0.000
#> SRR2936874     2  0.0000     0.9371 0.000 1.000  0 0.000
#> SRR2936870     4  0.0000     1.0000 0.000 0.000  0 1.000
#> SRR2936869     4  0.0000     1.0000 0.000 0.000  0 1.000
#> SRR2936868     4  0.0000     1.0000 0.000 0.000  0 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
#> SRR2936906     1  0.0000      0.965 1.000 0.000  0 0.000 0.000
#> SRR2936909     1  0.0794      0.966 0.972 0.000  0 0.000 0.028
#> SRR2936918     1  0.0880      0.965 0.968 0.000  0 0.000 0.032
#> SRR2936917     5  0.2471      0.807 0.000 0.136  0 0.000 0.864
#> SRR2936916     5  0.4392      0.388 0.380 0.008  0 0.000 0.612
#> SRR2936915     1  0.0880      0.965 0.968 0.000  0 0.000 0.032
#> SRR2936914     5  0.2471      0.807 0.000 0.136  0 0.000 0.864
#> SRR2936913     5  0.3109      0.765 0.000 0.200  0 0.000 0.800
#> SRR2936912     1  0.0162      0.965 0.996 0.000  0 0.000 0.004
#> SRR2936910     1  0.0000      0.965 1.000 0.000  0 0.000 0.000
#> SRR2936911     5  0.3109      0.765 0.000 0.200  0 0.000 0.800
#> SRR2936907     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR2936908     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR2936904     4  0.5404      0.707 0.072 0.116  0 0.732 0.080
#> SRR2936905     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR2936903     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR2936901     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR2936902     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR2936900     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR2936898     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR2936899     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR2936897     1  0.3109      0.791 0.800 0.000  0 0.000 0.200
#> SRR2936896     5  0.0609      0.822 0.000 0.020  0 0.000 0.980
#> SRR2936894     1  0.0000      0.965 1.000 0.000  0 0.000 0.000
#> SRR2936893     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR2936895     5  0.0609      0.822 0.000 0.020  0 0.000 0.980
#> SRR2936892     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR2936891     1  0.0000      0.965 1.000 0.000  0 0.000 0.000
#> SRR2936890     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR2936886     4  0.0000      0.959 0.000 0.000  0 1.000 0.000
#> SRR2936885     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR2936888     4  0.0000      0.959 0.000 0.000  0 1.000 0.000
#> SRR2936889     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR2936887     4  0.0000      0.959 0.000 0.000  0 1.000 0.000
#> SRR2936884     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR2936883     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR2936881     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR2936882     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR2936880     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR2936878     5  0.0609      0.822 0.000 0.020  0 0.000 0.980
#> SRR2936879     5  0.4570      0.419 0.348 0.020  0 0.000 0.632
#> SRR2936875     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR2936877     5  0.0609      0.822 0.000 0.020  0 0.000 0.980
#> SRR2936876     1  0.0880      0.965 0.968 0.000  0 0.000 0.032
#> SRR2936873     1  0.0794      0.966 0.972 0.000  0 0.000 0.028
#> SRR2936872     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR2936871     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR2936874     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR2936870     4  0.0000      0.959 0.000 0.000  0 1.000 0.000
#> SRR2936869     4  0.0000      0.959 0.000 0.000  0 1.000 0.000
#> SRR2936868     4  0.0000      0.959 0.000 0.000  0 1.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
#> SRR2936906     1  0.0000      0.892 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936909     1  0.2436      0.809 0.880 0.000 0.000 0.000 0.032 0.088
#> SRR2936918     1  0.1088      0.883 0.960 0.000 0.000 0.000 0.016 0.024
#> SRR2936917     5  0.2416      0.819 0.000 0.156 0.000 0.000 0.844 0.000
#> SRR2936916     6  0.5499      0.625 0.116 0.100 0.000 0.000 0.108 0.676
#> SRR2936915     6  0.4523      0.329 0.452 0.000 0.000 0.000 0.032 0.516
#> SRR2936914     5  0.2416      0.819 0.000 0.156 0.000 0.000 0.844 0.000
#> SRR2936913     5  0.2793      0.793 0.000 0.200 0.000 0.000 0.800 0.000
#> SRR2936912     1  0.0000      0.892 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936910     1  0.0000      0.892 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936911     5  0.2793      0.793 0.000 0.200 0.000 0.000 0.800 0.000
#> SRR2936907     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936908     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936904     4  0.5565      0.527 0.004 0.188 0.000 0.644 0.032 0.132
#> SRR2936905     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936903     3  0.2362      0.922 0.000 0.000 0.860 0.000 0.004 0.136
#> SRR2936901     3  0.1610      0.938 0.000 0.000 0.916 0.000 0.000 0.084
#> SRR2936902     3  0.0937      0.945 0.000 0.000 0.960 0.000 0.000 0.040
#> SRR2936900     3  0.2362      0.922 0.000 0.000 0.860 0.000 0.004 0.136
#> SRR2936898     3  0.0000      0.948 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR2936899     3  0.0000      0.948 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR2936897     6  0.4316      0.578 0.312 0.000 0.000 0.000 0.040 0.648
#> SRR2936896     5  0.2234      0.742 0.000 0.004 0.000 0.000 0.872 0.124
#> SRR2936894     1  0.1921      0.851 0.916 0.000 0.000 0.000 0.032 0.052
#> SRR2936893     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936895     5  0.2668      0.699 0.000 0.004 0.000 0.000 0.828 0.168
#> SRR2936892     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936891     1  0.0458      0.890 0.984 0.000 0.000 0.000 0.016 0.000
#> SRR2936890     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936886     4  0.0000      0.921 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR2936885     3  0.2320      0.923 0.000 0.000 0.864 0.000 0.004 0.132
#> SRR2936888     4  0.1204      0.908 0.000 0.000 0.000 0.944 0.000 0.056
#> SRR2936889     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936887     4  0.0000      0.921 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR2936884     3  0.0000      0.948 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR2936883     3  0.0000      0.948 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR2936881     3  0.0000      0.948 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR2936882     3  0.2362      0.922 0.000 0.000 0.860 0.000 0.004 0.136
#> SRR2936880     3  0.0000      0.948 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR2936878     5  0.0146      0.798 0.000 0.004 0.000 0.000 0.996 0.000
#> SRR2936879     6  0.3732      0.620 0.076 0.000 0.000 0.000 0.144 0.780
#> SRR2936875     2  0.0146      0.995 0.004 0.996 0.000 0.000 0.000 0.000
#> SRR2936877     5  0.0146      0.798 0.000 0.004 0.000 0.000 0.996 0.000
#> SRR2936876     1  0.4186      0.284 0.656 0.000 0.000 0.000 0.032 0.312
#> SRR2936873     1  0.0000      0.892 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936872     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936871     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936874     2  0.0146      0.995 0.004 0.996 0.000 0.000 0.000 0.000
#> SRR2936870     4  0.1204      0.908 0.000 0.000 0.000 0.944 0.000 0.056
#> SRR2936869     4  0.0000      0.921 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR2936868     4  0.0000      0.921 0.000 0.000 0.000 1.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 14198 rows and 51 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#>   Subgroups are detected by 'NMF' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 4.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk SD-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.794           0.944       0.957         0.4788 0.523   0.523
#> 3 3 1.000           0.950       0.978         0.4160 0.773   0.576
#> 4 4 0.912           0.862       0.943         0.1051 0.909   0.726
#> 5 5 0.842           0.809       0.887         0.0501 0.917   0.687
#> 6 6 0.844           0.798       0.872         0.0300 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] 4
#> attr(,"optional")
#> [1] 3

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette    p1    p2
#> SRR2936906     1  0.4690      0.929 0.900 0.100
#> SRR2936909     1  0.4562      0.932 0.904 0.096
#> SRR2936918     1  0.4562      0.932 0.904 0.096
#> SRR2936917     1  0.0672      0.936 0.992 0.008
#> SRR2936916     1  0.4431      0.932 0.908 0.092
#> SRR2936915     1  0.5519      0.910 0.872 0.128
#> SRR2936914     2  0.7056      0.792 0.192 0.808
#> SRR2936913     2  0.0000      0.988 0.000 1.000
#> SRR2936912     1  0.4562      0.932 0.904 0.096
#> SRR2936910     1  0.4562      0.932 0.904 0.096
#> SRR2936911     2  0.0938      0.978 0.012 0.988
#> SRR2936907     2  0.0000      0.988 0.000 1.000
#> SRR2936908     2  0.0000      0.988 0.000 1.000
#> SRR2936904     2  0.1843      0.963 0.028 0.972
#> SRR2936905     2  0.0000      0.988 0.000 1.000
#> SRR2936903     1  0.0000      0.934 1.000 0.000
#> SRR2936901     1  0.0672      0.934 0.992 0.008
#> SRR2936902     1  0.1843      0.931 0.972 0.028
#> SRR2936900     1  0.0000      0.934 1.000 0.000
#> SRR2936898     1  0.0672      0.934 0.992 0.008
#> SRR2936899     1  0.1633      0.932 0.976 0.024
#> SRR2936897     1  0.4562      0.932 0.904 0.096
#> SRR2936896     1  0.6343      0.808 0.840 0.160
#> SRR2936894     1  0.4562      0.932 0.904 0.096
#> SRR2936893     2  0.0000      0.988 0.000 1.000
#> SRR2936895     1  0.0376      0.935 0.996 0.004
#> SRR2936892     2  0.0000      0.988 0.000 1.000
#> SRR2936891     1  0.4562      0.932 0.904 0.096
#> SRR2936890     2  0.0000      0.988 0.000 1.000
#> SRR2936886     2  0.0000      0.988 0.000 1.000
#> SRR2936885     1  0.0000      0.934 1.000 0.000
#> SRR2936888     1  0.6148      0.887 0.848 0.152
#> SRR2936889     2  0.0000      0.988 0.000 1.000
#> SRR2936887     2  0.0000      0.988 0.000 1.000
#> SRR2936884     1  0.1843      0.931 0.972 0.028
#> SRR2936883     1  0.1843      0.931 0.972 0.028
#> SRR2936881     1  0.1633      0.932 0.976 0.024
#> SRR2936882     1  0.0000      0.934 1.000 0.000
#> SRR2936880     1  0.1414      0.933 0.980 0.020
#> SRR2936878     1  0.1843      0.931 0.972 0.028
#> SRR2936879     1  0.4431      0.932 0.908 0.092
#> SRR2936875     2  0.0000      0.988 0.000 1.000
#> SRR2936877     1  0.0672      0.934 0.992 0.008
#> SRR2936876     1  0.4562      0.932 0.904 0.096
#> SRR2936873     1  0.4562      0.932 0.904 0.096
#> SRR2936872     2  0.0000      0.988 0.000 1.000
#> SRR2936871     2  0.0000      0.988 0.000 1.000
#> SRR2936874     2  0.0000      0.988 0.000 1.000
#> SRR2936870     1  0.6343      0.879 0.840 0.160
#> SRR2936869     2  0.0000      0.988 0.000 1.000
#> SRR2936868     2  0.0000      0.988 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR2936906     1  0.0000      0.999 1.000 0.000 0.000
#> SRR2936909     1  0.0000      0.999 1.000 0.000 0.000
#> SRR2936918     1  0.0000      0.999 1.000 0.000 0.000
#> SRR2936917     3  0.4796      0.721 0.220 0.000 0.780
#> SRR2936916     1  0.0000      0.999 1.000 0.000 0.000
#> SRR2936915     1  0.0237      0.995 0.996 0.004 0.000
#> SRR2936914     3  0.5363      0.605 0.000 0.276 0.724
#> SRR2936913     2  0.0424      0.995 0.000 0.992 0.008
#> SRR2936912     1  0.0000      0.999 1.000 0.000 0.000
#> SRR2936910     1  0.0000      0.999 1.000 0.000 0.000
#> SRR2936911     2  0.0424      0.995 0.000 0.992 0.008
#> SRR2936907     2  0.0000      0.998 0.000 1.000 0.000
#> SRR2936908     2  0.0000      0.998 0.000 1.000 0.000
#> SRR2936904     2  0.0000      0.998 0.000 1.000 0.000
#> SRR2936905     2  0.0000      0.998 0.000 1.000 0.000
#> SRR2936903     3  0.0424      0.938 0.008 0.000 0.992
#> SRR2936901     3  0.0424      0.938 0.008 0.000 0.992
#> SRR2936902     3  0.0424      0.938 0.008 0.000 0.992
#> SRR2936900     3  0.1031      0.929 0.024 0.000 0.976
#> SRR2936898     3  0.0237      0.937 0.004 0.000 0.996
#> SRR2936899     3  0.0237      0.937 0.004 0.000 0.996
#> SRR2936897     1  0.0000      0.999 1.000 0.000 0.000
#> SRR2936896     3  0.0000      0.935 0.000 0.000 1.000
#> SRR2936894     1  0.0000      0.999 1.000 0.000 0.000
#> SRR2936893     2  0.0000      0.998 0.000 1.000 0.000
#> SRR2936895     3  0.6295      0.142 0.472 0.000 0.528
#> SRR2936892     2  0.0000      0.998 0.000 1.000 0.000
#> SRR2936891     1  0.0000      0.999 1.000 0.000 0.000
#> SRR2936890     2  0.0000      0.998 0.000 1.000 0.000
#> SRR2936886     2  0.0424      0.995 0.000 0.992 0.008
#> SRR2936885     3  0.0592      0.936 0.012 0.000 0.988
#> SRR2936888     1  0.0237      0.996 0.996 0.000 0.004
#> SRR2936889     2  0.0000      0.998 0.000 1.000 0.000
#> SRR2936887     2  0.0424      0.995 0.000 0.992 0.008
#> SRR2936884     3  0.0000      0.935 0.000 0.000 1.000
#> SRR2936883     3  0.0000      0.935 0.000 0.000 1.000
#> SRR2936881     3  0.0424      0.938 0.008 0.000 0.992
#> SRR2936882     3  0.0747      0.934 0.016 0.000 0.984
#> SRR2936880     3  0.0424      0.938 0.008 0.000 0.992
#> SRR2936878     3  0.0424      0.938 0.008 0.000 0.992
#> SRR2936879     1  0.0000      0.999 1.000 0.000 0.000
#> SRR2936875     2  0.0000      0.998 0.000 1.000 0.000
#> SRR2936877     3  0.0424      0.938 0.008 0.000 0.992
#> SRR2936876     1  0.0000      0.999 1.000 0.000 0.000
#> SRR2936873     1  0.0000      0.999 1.000 0.000 0.000
#> SRR2936872     2  0.0000      0.998 0.000 1.000 0.000
#> SRR2936871     2  0.0000      0.998 0.000 1.000 0.000
#> SRR2936874     2  0.0000      0.998 0.000 1.000 0.000
#> SRR2936870     1  0.0237      0.996 0.996 0.000 0.004
#> SRR2936869     2  0.0424      0.995 0.000 0.992 0.008
#> SRR2936868     2  0.0424      0.995 0.000 0.992 0.008

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR2936906     1  0.0000     0.9221 1.000 0.000 0.000 0.000
#> SRR2936909     1  0.0188     0.9213 0.996 0.000 0.000 0.004
#> SRR2936918     1  0.0188     0.9211 0.996 0.000 0.000 0.004
#> SRR2936917     3  0.5594     0.6387 0.100 0.180 0.720 0.000
#> SRR2936916     1  0.0000     0.9221 1.000 0.000 0.000 0.000
#> SRR2936915     1  0.0188     0.9213 0.996 0.000 0.000 0.004
#> SRR2936914     4  0.4998     0.0378 0.000 0.000 0.488 0.512
#> SRR2936913     4  0.0336     0.8422 0.000 0.008 0.000 0.992
#> SRR2936912     1  0.0188     0.9211 0.996 0.000 0.000 0.004
#> SRR2936910     1  0.0188     0.9211 0.996 0.000 0.000 0.004
#> SRR2936911     4  0.0336     0.8422 0.000 0.008 0.000 0.992
#> SRR2936907     2  0.0817     0.9555 0.000 0.976 0.000 0.024
#> SRR2936908     2  0.0469     0.9602 0.000 0.988 0.000 0.012
#> SRR2936904     2  0.0336     0.9606 0.000 0.992 0.000 0.008
#> SRR2936905     2  0.0000     0.9604 0.000 1.000 0.000 0.000
#> SRR2936903     3  0.0000     0.9700 0.000 0.000 1.000 0.000
#> SRR2936901     3  0.0000     0.9700 0.000 0.000 1.000 0.000
#> SRR2936902     3  0.0000     0.9700 0.000 0.000 1.000 0.000
#> SRR2936900     3  0.1792     0.8999 0.068 0.000 0.932 0.000
#> SRR2936898     3  0.0000     0.9700 0.000 0.000 1.000 0.000
#> SRR2936899     3  0.0000     0.9700 0.000 0.000 1.000 0.000
#> SRR2936897     1  0.0000     0.9221 1.000 0.000 0.000 0.000
#> SRR2936896     3  0.1022     0.9442 0.000 0.000 0.968 0.032
#> SRR2936894     1  0.0000     0.9221 1.000 0.000 0.000 0.000
#> SRR2936893     2  0.3764     0.7664 0.000 0.784 0.000 0.216
#> SRR2936895     4  0.7542     0.2568 0.312 0.000 0.212 0.476
#> SRR2936892     2  0.2345     0.9015 0.000 0.900 0.000 0.100
#> SRR2936891     1  0.0000     0.9221 1.000 0.000 0.000 0.000
#> SRR2936890     2  0.0469     0.9602 0.000 0.988 0.000 0.012
#> SRR2936886     4  0.0336     0.8422 0.000 0.008 0.000 0.992
#> SRR2936885     3  0.0707     0.9546 0.000 0.000 0.980 0.020
#> SRR2936888     1  0.4977     0.1893 0.540 0.000 0.000 0.460
#> SRR2936889     2  0.1940     0.9247 0.000 0.924 0.000 0.076
#> SRR2936887     4  0.0336     0.8422 0.000 0.008 0.000 0.992
#> SRR2936884     3  0.0000     0.9700 0.000 0.000 1.000 0.000
#> SRR2936883     3  0.0000     0.9700 0.000 0.000 1.000 0.000
#> SRR2936881     3  0.0000     0.9700 0.000 0.000 1.000 0.000
#> SRR2936882     3  0.0000     0.9700 0.000 0.000 1.000 0.000
#> SRR2936880     3  0.0000     0.9700 0.000 0.000 1.000 0.000
#> SRR2936878     3  0.0000     0.9700 0.000 0.000 1.000 0.000
#> SRR2936879     1  0.0657     0.9140 0.984 0.012 0.000 0.004
#> SRR2936875     2  0.0000     0.9604 0.000 1.000 0.000 0.000
#> SRR2936877     3  0.0000     0.9700 0.000 0.000 1.000 0.000
#> SRR2936876     1  0.1004     0.9042 0.972 0.024 0.000 0.004
#> SRR2936873     1  0.0188     0.9213 0.996 0.000 0.000 0.004
#> SRR2936872     2  0.0000     0.9604 0.000 1.000 0.000 0.000
#> SRR2936871     2  0.0000     0.9604 0.000 1.000 0.000 0.000
#> SRR2936874     2  0.0000     0.9604 0.000 1.000 0.000 0.000
#> SRR2936870     1  0.4989     0.1548 0.528 0.000 0.000 0.472
#> SRR2936869     4  0.0592     0.8386 0.000 0.016 0.000 0.984
#> SRR2936868     4  0.0592     0.8386 0.000 0.016 0.000 0.984

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4    p5
#> SRR2936906     1  0.0932      0.972 0.972 0.000 0.020 0.004 0.004
#> SRR2936909     1  0.0451      0.973 0.988 0.000 0.000 0.004 0.008
#> SRR2936918     1  0.0693      0.976 0.980 0.000 0.012 0.000 0.008
#> SRR2936917     5  0.3556      0.635 0.036 0.012 0.116 0.000 0.836
#> SRR2936916     1  0.0880      0.962 0.968 0.000 0.000 0.000 0.032
#> SRR2936915     1  0.0510      0.970 0.984 0.000 0.000 0.000 0.016
#> SRR2936914     5  0.4968      0.650 0.000 0.000 0.152 0.136 0.712
#> SRR2936913     5  0.4367      0.138 0.000 0.008 0.000 0.372 0.620
#> SRR2936912     1  0.0162      0.975 0.996 0.000 0.000 0.000 0.004
#> SRR2936910     1  0.0290      0.973 0.992 0.000 0.000 0.000 0.008
#> SRR2936911     4  0.4109      0.449 0.000 0.012 0.000 0.700 0.288
#> SRR2936907     2  0.0579      0.968 0.000 0.984 0.000 0.008 0.008
#> SRR2936908     2  0.0162      0.970 0.000 0.996 0.000 0.004 0.000
#> SRR2936904     2  0.0451      0.968 0.008 0.988 0.000 0.004 0.000
#> SRR2936905     2  0.0290      0.970 0.000 0.992 0.000 0.000 0.008
#> SRR2936903     3  0.2416      0.826 0.060 0.000 0.908 0.016 0.016
#> SRR2936901     3  0.0912      0.852 0.016 0.000 0.972 0.000 0.012
#> SRR2936902     3  0.1043      0.835 0.000 0.000 0.960 0.000 0.040
#> SRR2936900     3  0.4347      0.606 0.256 0.000 0.716 0.004 0.024
#> SRR2936898     3  0.1483      0.848 0.012 0.000 0.952 0.028 0.008
#> SRR2936899     3  0.1356      0.849 0.012 0.000 0.956 0.028 0.004
#> SRR2936897     1  0.1026      0.970 0.968 0.000 0.024 0.004 0.004
#> SRR2936896     5  0.6527      0.621 0.000 0.004 0.328 0.184 0.484
#> SRR2936894     1  0.0865      0.971 0.972 0.000 0.024 0.000 0.004
#> SRR2936893     2  0.2389      0.891 0.000 0.880 0.000 0.116 0.004
#> SRR2936895     4  0.6608      0.488 0.280 0.000 0.024 0.544 0.152
#> SRR2936892     2  0.1502      0.944 0.000 0.940 0.000 0.056 0.004
#> SRR2936891     1  0.0671      0.974 0.980 0.000 0.016 0.000 0.004
#> SRR2936890     2  0.0162      0.970 0.000 0.996 0.000 0.004 0.000
#> SRR2936886     4  0.0807      0.662 0.000 0.012 0.012 0.976 0.000
#> SRR2936885     3  0.4478      0.730 0.084 0.000 0.788 0.104 0.024
#> SRR2936888     4  0.5407      0.383 0.424 0.000 0.004 0.524 0.048
#> SRR2936889     2  0.1638      0.938 0.000 0.932 0.000 0.064 0.004
#> SRR2936887     4  0.1074      0.663 0.000 0.016 0.012 0.968 0.004
#> SRR2936884     3  0.1282      0.829 0.000 0.000 0.952 0.004 0.044
#> SRR2936883     3  0.1300      0.842 0.000 0.000 0.956 0.016 0.028
#> SRR2936881     3  0.0880      0.841 0.000 0.000 0.968 0.000 0.032
#> SRR2936882     3  0.4095      0.656 0.220 0.000 0.752 0.004 0.024
#> SRR2936880     3  0.1124      0.842 0.004 0.000 0.960 0.000 0.036
#> SRR2936878     5  0.4030      0.637 0.000 0.000 0.352 0.000 0.648
#> SRR2936879     1  0.1790      0.951 0.940 0.004 0.036 0.004 0.016
#> SRR2936875     2  0.0579      0.967 0.000 0.984 0.000 0.008 0.008
#> SRR2936877     5  0.4383      0.537 0.000 0.000 0.424 0.004 0.572
#> SRR2936876     1  0.1235      0.963 0.964 0.012 0.004 0.004 0.016
#> SRR2936873     1  0.0404      0.976 0.988 0.000 0.012 0.000 0.000
#> SRR2936872     2  0.0579      0.967 0.000 0.984 0.000 0.008 0.008
#> SRR2936871     2  0.0162      0.970 0.000 0.996 0.000 0.000 0.004
#> SRR2936874     2  0.0579      0.967 0.000 0.984 0.000 0.008 0.008
#> SRR2936870     4  0.5447      0.440 0.396 0.000 0.012 0.552 0.040
#> SRR2936869     4  0.1173      0.662 0.000 0.020 0.012 0.964 0.004
#> SRR2936868     4  0.1299      0.661 0.000 0.020 0.012 0.960 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
#> SRR2936906     1  0.0405      0.911 0.988 0.000 0.000 0.004 0.000 0.008
#> SRR2936909     1  0.1007      0.906 0.956 0.000 0.000 0.000 0.000 0.044
#> SRR2936918     1  0.1501      0.884 0.924 0.000 0.000 0.000 0.000 0.076
#> SRR2936917     5  0.3300      0.610 0.020 0.004 0.008 0.000 0.816 0.152
#> SRR2936916     1  0.3134      0.802 0.820 0.000 0.000 0.000 0.036 0.144
#> SRR2936915     1  0.1444      0.889 0.928 0.000 0.000 0.000 0.000 0.072
#> SRR2936914     5  0.1737      0.642 0.000 0.000 0.020 0.040 0.932 0.008
#> SRR2936913     5  0.4974      0.432 0.000 0.008 0.000 0.220 0.660 0.112
#> SRR2936912     1  0.1152      0.909 0.952 0.000 0.000 0.004 0.000 0.044
#> SRR2936910     1  0.0603      0.910 0.980 0.000 0.000 0.004 0.000 0.016
#> SRR2936911     4  0.5112      0.468 0.000 0.008 0.000 0.648 0.132 0.212
#> SRR2936907     2  0.1124      0.956 0.000 0.956 0.000 0.036 0.000 0.008
#> SRR2936908     2  0.0363      0.963 0.000 0.988 0.000 0.012 0.000 0.000
#> SRR2936904     2  0.0717      0.963 0.000 0.976 0.000 0.016 0.000 0.008
#> SRR2936905     2  0.0146      0.962 0.000 0.996 0.000 0.004 0.000 0.000
#> SRR2936903     3  0.1789      0.911 0.032 0.000 0.924 0.000 0.000 0.044
#> SRR2936901     3  0.0520      0.935 0.008 0.000 0.984 0.000 0.000 0.008
#> SRR2936902     3  0.0260      0.935 0.000 0.000 0.992 0.000 0.008 0.000
#> SRR2936900     3  0.3316      0.800 0.136 0.000 0.812 0.000 0.000 0.052
#> SRR2936898     3  0.0436      0.937 0.004 0.000 0.988 0.004 0.004 0.000
#> SRR2936899     3  0.0436      0.937 0.004 0.000 0.988 0.004 0.004 0.000
#> SRR2936897     1  0.2225      0.885 0.892 0.000 0.008 0.008 0.000 0.092
#> SRR2936896     5  0.7482      0.145 0.012 0.000 0.084 0.260 0.336 0.308
#> SRR2936894     1  0.0692      0.912 0.976 0.000 0.000 0.004 0.000 0.020
#> SRR2936893     2  0.1588      0.937 0.000 0.924 0.000 0.072 0.000 0.004
#> SRR2936895     4  0.7466      0.195 0.136 0.000 0.012 0.372 0.144 0.336
#> SRR2936892     2  0.1349      0.948 0.000 0.940 0.000 0.056 0.000 0.004
#> SRR2936891     1  0.0508      0.911 0.984 0.000 0.000 0.004 0.000 0.012
#> SRR2936890     2  0.0692      0.961 0.000 0.976 0.000 0.020 0.000 0.004
#> SRR2936886     4  0.0862      0.643 0.000 0.016 0.000 0.972 0.004 0.008
#> SRR2936885     3  0.3046      0.882 0.036 0.000 0.868 0.036 0.004 0.056
#> SRR2936888     4  0.5973      0.451 0.292 0.000 0.000 0.496 0.008 0.204
#> SRR2936889     2  0.2170      0.904 0.000 0.888 0.000 0.100 0.000 0.012
#> SRR2936887     4  0.0603      0.641 0.000 0.016 0.000 0.980 0.004 0.000
#> SRR2936884     3  0.1262      0.921 0.000 0.000 0.956 0.008 0.020 0.016
#> SRR2936883     3  0.0551      0.934 0.000 0.000 0.984 0.004 0.008 0.004
#> SRR2936881     3  0.0260      0.935 0.000 0.000 0.992 0.000 0.008 0.000
#> SRR2936882     3  0.3049      0.841 0.104 0.000 0.844 0.004 0.000 0.048
#> SRR2936880     3  0.0260      0.935 0.000 0.000 0.992 0.000 0.008 0.000
#> SRR2936878     5  0.3470      0.635 0.000 0.000 0.152 0.000 0.796 0.052
#> SRR2936879     1  0.4320      0.700 0.692 0.028 0.004 0.004 0.004 0.268
#> SRR2936875     2  0.1219      0.938 0.000 0.948 0.000 0.004 0.000 0.048
#> SRR2936877     5  0.6352      0.523 0.020 0.012 0.180 0.000 0.512 0.276
#> SRR2936876     1  0.3481      0.762 0.756 0.012 0.000 0.000 0.004 0.228
#> SRR2936873     1  0.0547      0.911 0.980 0.000 0.000 0.000 0.000 0.020
#> SRR2936872     2  0.0692      0.953 0.000 0.976 0.000 0.004 0.000 0.020
#> SRR2936871     2  0.0146      0.960 0.000 0.996 0.000 0.000 0.000 0.004
#> SRR2936874     2  0.0865      0.948 0.000 0.964 0.000 0.000 0.000 0.036
#> SRR2936870     4  0.5832      0.458 0.292 0.000 0.000 0.508 0.004 0.196
#> SRR2936869     4  0.2085      0.624 0.000 0.056 0.000 0.912 0.008 0.024
#> SRR2936868     4  0.1682      0.630 0.000 0.052 0.000 0.928 0.000 0.020

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

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

collect_plots(res)

plot of chunk CV-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.961       0.985         0.4257 0.576   0.576
#> 3 3 0.639           0.777       0.851         0.3784 0.784   0.626
#> 4 4 0.820           0.858       0.935         0.1555 0.938   0.832
#> 5 5 0.824           0.785       0.888         0.0570 0.954   0.862
#> 6 6 0.823           0.784       0.877         0.0313 0.947   0.830

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
#> SRR2936906     1   0.000      0.976 1.000 0.000
#> SRR2936909     1   0.000      0.976 1.000 0.000
#> SRR2936918     1   0.000      0.976 1.000 0.000
#> SRR2936917     2   0.000      0.987 0.000 1.000
#> SRR2936916     2   0.000      0.987 0.000 1.000
#> SRR2936915     2   0.000      0.987 0.000 1.000
#> SRR2936914     2   0.000      0.987 0.000 1.000
#> SRR2936913     2   0.000      0.987 0.000 1.000
#> SRR2936912     1   0.000      0.976 1.000 0.000
#> SRR2936910     1   0.000      0.976 1.000 0.000
#> SRR2936911     2   0.000      0.987 0.000 1.000
#> SRR2936907     2   0.000      0.987 0.000 1.000
#> SRR2936908     2   0.000      0.987 0.000 1.000
#> SRR2936904     2   0.000      0.987 0.000 1.000
#> SRR2936905     2   0.000      0.987 0.000 1.000
#> SRR2936903     1   0.000      0.976 1.000 0.000
#> SRR2936901     2   0.966      0.340 0.392 0.608
#> SRR2936902     2   0.000      0.987 0.000 1.000
#> SRR2936900     1   0.000      0.976 1.000 0.000
#> SRR2936898     2   0.000      0.987 0.000 1.000
#> SRR2936899     2   0.000      0.987 0.000 1.000
#> SRR2936897     1   0.909      0.512 0.676 0.324
#> SRR2936896     2   0.000      0.987 0.000 1.000
#> SRR2936894     1   0.000      0.976 1.000 0.000
#> SRR2936893     2   0.000      0.987 0.000 1.000
#> SRR2936895     2   0.000      0.987 0.000 1.000
#> SRR2936892     2   0.000      0.987 0.000 1.000
#> SRR2936891     1   0.000      0.976 1.000 0.000
#> SRR2936890     2   0.000      0.987 0.000 1.000
#> SRR2936886     2   0.000      0.987 0.000 1.000
#> SRR2936885     1   0.000      0.976 1.000 0.000
#> SRR2936888     1   0.000      0.976 1.000 0.000
#> SRR2936889     2   0.000      0.987 0.000 1.000
#> SRR2936887     2   0.000      0.987 0.000 1.000
#> SRR2936884     2   0.000      0.987 0.000 1.000
#> SRR2936883     2   0.000      0.987 0.000 1.000
#> SRR2936881     2   0.000      0.987 0.000 1.000
#> SRR2936882     1   0.000      0.976 1.000 0.000
#> SRR2936880     2   0.000      0.987 0.000 1.000
#> SRR2936878     2   0.000      0.987 0.000 1.000
#> SRR2936879     2   0.000      0.987 0.000 1.000
#> SRR2936875     2   0.000      0.987 0.000 1.000
#> SRR2936877     2   0.000      0.987 0.000 1.000
#> SRR2936876     2   0.295      0.934 0.052 0.948
#> SRR2936873     1   0.000      0.976 1.000 0.000
#> SRR2936872     2   0.000      0.987 0.000 1.000
#> SRR2936871     2   0.000      0.987 0.000 1.000
#> SRR2936874     2   0.000      0.987 0.000 1.000
#> SRR2936870     1   0.000      0.976 1.000 0.000
#> SRR2936869     2   0.000      0.987 0.000 1.000
#> SRR2936868     2   0.000      0.987 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR2936906     1   0.000      0.896 1.000 0.000 0.000
#> SRR2936909     1   0.000      0.896 1.000 0.000 0.000
#> SRR2936918     1   0.000      0.896 1.000 0.000 0.000
#> SRR2936917     2   0.000      0.871 0.000 1.000 0.000
#> SRR2936916     3   0.617      0.871 0.000 0.412 0.588
#> SRR2936915     3   0.617      0.871 0.000 0.412 0.588
#> SRR2936914     2   0.000      0.871 0.000 1.000 0.000
#> SRR2936913     2   0.000      0.871 0.000 1.000 0.000
#> SRR2936912     1   0.000      0.896 1.000 0.000 0.000
#> SRR2936910     1   0.000      0.896 1.000 0.000 0.000
#> SRR2936911     2   0.000      0.871 0.000 1.000 0.000
#> SRR2936907     2   0.000      0.871 0.000 1.000 0.000
#> SRR2936908     2   0.000      0.871 0.000 1.000 0.000
#> SRR2936904     2   0.624     -0.449 0.000 0.560 0.440
#> SRR2936905     2   0.000      0.871 0.000 1.000 0.000
#> SRR2936903     1   0.595      0.760 0.640 0.000 0.360
#> SRR2936901     3   0.000      0.336 0.000 0.000 1.000
#> SRR2936902     3   0.610      0.899 0.000 0.392 0.608
#> SRR2936900     1   0.595      0.760 0.640 0.000 0.360
#> SRR2936898     3   0.610      0.899 0.000 0.392 0.608
#> SRR2936899     3   0.610      0.899 0.000 0.392 0.608
#> SRR2936897     1   0.839      0.457 0.624 0.172 0.204
#> SRR2936896     2   0.000      0.871 0.000 1.000 0.000
#> SRR2936894     1   0.000      0.896 1.000 0.000 0.000
#> SRR2936893     2   0.000      0.871 0.000 1.000 0.000
#> SRR2936895     2   0.455      0.598 0.000 0.800 0.200
#> SRR2936892     2   0.000      0.871 0.000 1.000 0.000
#> SRR2936891     1   0.000      0.896 1.000 0.000 0.000
#> SRR2936890     2   0.000      0.871 0.000 1.000 0.000
#> SRR2936886     2   0.455      0.598 0.000 0.800 0.200
#> SRR2936885     1   0.595      0.760 0.640 0.000 0.360
#> SRR2936888     1   0.000      0.896 1.000 0.000 0.000
#> SRR2936889     2   0.000      0.871 0.000 1.000 0.000
#> SRR2936887     2   0.455      0.598 0.000 0.800 0.200
#> SRR2936884     3   0.610      0.899 0.000 0.392 0.608
#> SRR2936883     3   0.610      0.899 0.000 0.392 0.608
#> SRR2936881     3   0.610      0.899 0.000 0.392 0.608
#> SRR2936882     1   0.595      0.760 0.640 0.000 0.360
#> SRR2936880     3   0.610      0.899 0.000 0.392 0.608
#> SRR2936878     2   0.000      0.871 0.000 1.000 0.000
#> SRR2936879     2   0.610     -0.237 0.000 0.608 0.392
#> SRR2936875     2   0.000      0.871 0.000 1.000 0.000
#> SRR2936877     2   0.000      0.871 0.000 1.000 0.000
#> SRR2936876     3   0.595      0.840 0.000 0.360 0.640
#> SRR2936873     1   0.000      0.896 1.000 0.000 0.000
#> SRR2936872     2   0.000      0.871 0.000 1.000 0.000
#> SRR2936871     2   0.000      0.871 0.000 1.000 0.000
#> SRR2936874     2   0.000      0.871 0.000 1.000 0.000
#> SRR2936870     1   0.000      0.896 1.000 0.000 0.000
#> SRR2936869     2   0.455      0.598 0.000 0.800 0.200
#> SRR2936868     2   0.455      0.598 0.000 0.800 0.200

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3   p4
#> SRR2936906     1   0.000      0.957 1.000 0.000 0.000 0.00
#> SRR2936909     1   0.000      0.957 1.000 0.000 0.000 0.00
#> SRR2936918     1   0.000      0.957 1.000 0.000 0.000 0.00
#> SRR2936917     2   0.000      0.923 0.000 1.000 0.000 0.00
#> SRR2936916     3   0.276      0.837 0.000 0.128 0.872 0.00
#> SRR2936915     3   0.276      0.837 0.000 0.128 0.872 0.00
#> SRR2936914     2   0.000      0.923 0.000 1.000 0.000 0.00
#> SRR2936913     2   0.000      0.923 0.000 1.000 0.000 0.00
#> SRR2936912     1   0.000      0.957 1.000 0.000 0.000 0.00
#> SRR2936910     1   0.000      0.957 1.000 0.000 0.000 0.00
#> SRR2936911     2   0.000      0.923 0.000 1.000 0.000 0.00
#> SRR2936907     2   0.000      0.923 0.000 1.000 0.000 0.00
#> SRR2936908     2   0.000      0.923 0.000 1.000 0.000 0.00
#> SRR2936904     3   0.496      0.184 0.000 0.448 0.552 0.00
#> SRR2936905     2   0.000      0.923 0.000 1.000 0.000 0.00
#> SRR2936903     4   0.000      1.000 0.000 0.000 0.000 1.00
#> SRR2936901     3   0.462      0.397 0.000 0.000 0.660 0.34
#> SRR2936902     3   0.147      0.880 0.000 0.052 0.948 0.00
#> SRR2936900     4   0.000      1.000 0.000 0.000 0.000 1.00
#> SRR2936898     3   0.147      0.880 0.000 0.052 0.948 0.00
#> SRR2936899     3   0.147      0.880 0.000 0.052 0.948 0.00
#> SRR2936897     1   0.478      0.473 0.624 0.000 0.376 0.00
#> SRR2936896     2   0.000      0.923 0.000 1.000 0.000 0.00
#> SRR2936894     1   0.000      0.957 1.000 0.000 0.000 0.00
#> SRR2936893     2   0.000      0.923 0.000 1.000 0.000 0.00
#> SRR2936895     2   0.365      0.743 0.000 0.796 0.204 0.00
#> SRR2936892     2   0.000      0.923 0.000 1.000 0.000 0.00
#> SRR2936891     1   0.000      0.957 1.000 0.000 0.000 0.00
#> SRR2936890     2   0.000      0.923 0.000 1.000 0.000 0.00
#> SRR2936886     2   0.365      0.743 0.000 0.796 0.204 0.00
#> SRR2936885     4   0.000      1.000 0.000 0.000 0.000 1.00
#> SRR2936888     1   0.000      0.957 1.000 0.000 0.000 0.00
#> SRR2936889     2   0.000      0.923 0.000 1.000 0.000 0.00
#> SRR2936887     2   0.365      0.743 0.000 0.796 0.204 0.00
#> SRR2936884     3   0.147      0.880 0.000 0.052 0.948 0.00
#> SRR2936883     3   0.147      0.880 0.000 0.052 0.948 0.00
#> SRR2936881     3   0.147      0.880 0.000 0.052 0.948 0.00
#> SRR2936882     4   0.000      1.000 0.000 0.000 0.000 1.00
#> SRR2936880     3   0.147      0.880 0.000 0.052 0.948 0.00
#> SRR2936878     2   0.000      0.923 0.000 1.000 0.000 0.00
#> SRR2936879     2   0.495      0.154 0.000 0.556 0.444 0.00
#> SRR2936875     2   0.000      0.923 0.000 1.000 0.000 0.00
#> SRR2936877     2   0.000      0.923 0.000 1.000 0.000 0.00
#> SRR2936876     3   0.194      0.833 0.000 0.076 0.924 0.00
#> SRR2936873     1   0.000      0.957 1.000 0.000 0.000 0.00
#> SRR2936872     2   0.000      0.923 0.000 1.000 0.000 0.00
#> SRR2936871     2   0.000      0.923 0.000 1.000 0.000 0.00
#> SRR2936874     2   0.000      0.923 0.000 1.000 0.000 0.00
#> SRR2936870     1   0.000      0.957 1.000 0.000 0.000 0.00
#> SRR2936869     2   0.365      0.743 0.000 0.796 0.204 0.00
#> SRR2936868     2   0.365      0.743 0.000 0.796 0.204 0.00

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3   p4    p5
#> SRR2936906     1   0.281     0.8913 0.832 0.000 0.000 0.00 0.168
#> SRR2936909     1   0.000     0.8674 1.000 0.000 0.000 0.00 0.000
#> SRR2936918     1   0.289     0.8898 0.824 0.000 0.000 0.00 0.176
#> SRR2936917     2   0.000     0.8804 0.000 1.000 0.000 0.00 0.000
#> SRR2936916     5   0.538     0.9494 0.000 0.064 0.368 0.00 0.568
#> SRR2936915     5   0.538     0.9494 0.000 0.064 0.368 0.00 0.568
#> SRR2936914     2   0.000     0.8804 0.000 1.000 0.000 0.00 0.000
#> SRR2936913     2   0.000     0.8804 0.000 1.000 0.000 0.00 0.000
#> SRR2936912     1   0.000     0.8674 1.000 0.000 0.000 0.00 0.000
#> SRR2936910     1   0.273     0.8915 0.840 0.000 0.000 0.00 0.160
#> SRR2936911     2   0.000     0.8804 0.000 1.000 0.000 0.00 0.000
#> SRR2936907     2   0.000     0.8804 0.000 1.000 0.000 0.00 0.000
#> SRR2936908     2   0.000     0.8804 0.000 1.000 0.000 0.00 0.000
#> SRR2936904     2   0.672    -0.3528 0.000 0.384 0.368 0.00 0.248
#> SRR2936905     2   0.000     0.8804 0.000 1.000 0.000 0.00 0.000
#> SRR2936903     4   0.000     1.0000 0.000 0.000 0.000 1.00 0.000
#> SRR2936901     3   0.672     0.1048 0.000 0.000 0.404 0.34 0.256
#> SRR2936902     3   0.000     0.7608 0.000 0.000 1.000 0.00 0.000
#> SRR2936900     4   0.000     1.0000 0.000 0.000 0.000 1.00 0.000
#> SRR2936898     3   0.314     0.6660 0.000 0.000 0.796 0.00 0.204
#> SRR2936899     3   0.314     0.6660 0.000 0.000 0.796 0.00 0.204
#> SRR2936897     1   0.411     0.3994 0.624 0.000 0.000 0.00 0.376
#> SRR2936896     2   0.000     0.8804 0.000 1.000 0.000 0.00 0.000
#> SRR2936894     1   0.289     0.8898 0.824 0.000 0.000 0.00 0.176
#> SRR2936893     2   0.000     0.8804 0.000 1.000 0.000 0.00 0.000
#> SRR2936895     2   0.353     0.6491 0.000 0.744 0.256 0.00 0.000
#> SRR2936892     2   0.000     0.8804 0.000 1.000 0.000 0.00 0.000
#> SRR2936891     1   0.289     0.8898 0.824 0.000 0.000 0.00 0.176
#> SRR2936890     2   0.000     0.8804 0.000 1.000 0.000 0.00 0.000
#> SRR2936886     2   0.353     0.6491 0.000 0.744 0.256 0.00 0.000
#> SRR2936885     4   0.000     1.0000 0.000 0.000 0.000 1.00 0.000
#> SRR2936888     1   0.000     0.8674 1.000 0.000 0.000 0.00 0.000
#> SRR2936889     2   0.000     0.8804 0.000 1.000 0.000 0.00 0.000
#> SRR2936887     2   0.353     0.6491 0.000 0.744 0.256 0.00 0.000
#> SRR2936884     3   0.000     0.7608 0.000 0.000 1.000 0.00 0.000
#> SRR2936883     3   0.000     0.7608 0.000 0.000 1.000 0.00 0.000
#> SRR2936881     3   0.000     0.7608 0.000 0.000 1.000 0.00 0.000
#> SRR2936882     4   0.000     1.0000 0.000 0.000 0.000 1.00 0.000
#> SRR2936880     3   0.000     0.7608 0.000 0.000 1.000 0.00 0.000
#> SRR2936878     2   0.000     0.8804 0.000 1.000 0.000 0.00 0.000
#> SRR2936879     2   0.645     0.0409 0.000 0.492 0.296 0.00 0.212
#> SRR2936875     2   0.000     0.8804 0.000 1.000 0.000 0.00 0.000
#> SRR2936877     2   0.000     0.8804 0.000 1.000 0.000 0.00 0.000
#> SRR2936876     5   0.520     0.9009 0.000 0.064 0.316 0.00 0.620
#> SRR2936873     1   0.281     0.8913 0.832 0.000 0.000 0.00 0.168
#> SRR2936872     2   0.000     0.8804 0.000 1.000 0.000 0.00 0.000
#> SRR2936871     2   0.000     0.8804 0.000 1.000 0.000 0.00 0.000
#> SRR2936874     2   0.000     0.8804 0.000 1.000 0.000 0.00 0.000
#> SRR2936870     1   0.000     0.8674 1.000 0.000 0.000 0.00 0.000
#> SRR2936869     2   0.353     0.6491 0.000 0.744 0.256 0.00 0.000
#> SRR2936868     2   0.353     0.6491 0.000 0.744 0.256 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
#> SRR2936906     1   0.372      0.825 0.616 0.000 0.000 0.000 0.384 0.000
#> SRR2936909     5   0.000      0.860 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR2936918     1   0.291      0.900 0.784 0.000 0.000 0.000 0.216 0.000
#> SRR2936917     2   0.000      0.904 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936916     4   0.353      0.536 0.000 0.000 0.328 0.672 0.000 0.000
#> SRR2936915     4   0.353      0.536 0.000 0.000 0.328 0.672 0.000 0.000
#> SRR2936914     2   0.000      0.904 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936913     2   0.000      0.904 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936912     5   0.000      0.860 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR2936910     1   0.331      0.890 0.720 0.000 0.000 0.000 0.280 0.000
#> SRR2936911     2   0.000      0.904 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936907     2   0.000      0.904 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936908     2   0.000      0.904 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936904     4   0.625      0.260 0.004 0.320 0.324 0.352 0.000 0.000
#> SRR2936905     2   0.000      0.904 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936903     6   0.000      1.000 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR2936901     4   0.765     -0.198 0.212 0.000 0.260 0.320 0.000 0.208
#> SRR2936902     3   0.000      0.873 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR2936900     6   0.000      1.000 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR2936898     3   0.282      0.697 0.000 0.000 0.796 0.204 0.000 0.000
#> SRR2936899     3   0.282      0.697 0.000 0.000 0.796 0.204 0.000 0.000
#> SRR2936897     5   0.441      0.465 0.040 0.000 0.000 0.336 0.624 0.000
#> SRR2936896     2   0.000      0.904 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936894     1   0.291      0.900 0.784 0.000 0.000 0.000 0.216 0.000
#> SRR2936893     2   0.000      0.904 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936895     2   0.379      0.668 0.000 0.744 0.216 0.040 0.000 0.000
#> SRR2936892     2   0.000      0.904 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936891     1   0.291      0.900 0.784 0.000 0.000 0.000 0.216 0.000
#> SRR2936890     2   0.000      0.904 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936886     2   0.379      0.668 0.000 0.744 0.216 0.040 0.000 0.000
#> SRR2936885     6   0.000      1.000 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR2936888     5   0.000      0.860 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR2936889     2   0.000      0.904 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936887     2   0.379      0.668 0.000 0.744 0.216 0.040 0.000 0.000
#> SRR2936884     3   0.000      0.873 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR2936883     3   0.000      0.873 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR2936881     3   0.000      0.873 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR2936882     6   0.000      1.000 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR2936880     3   0.000      0.873 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR2936878     2   0.000      0.904 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936879     2   0.601     -0.169 0.000 0.428 0.256 0.316 0.000 0.000
#> SRR2936875     2   0.000      0.904 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936877     2   0.000      0.904 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936876     4   0.433      0.515 0.040 0.000 0.316 0.644 0.000 0.000
#> SRR2936873     1   0.372      0.825 0.616 0.000 0.000 0.000 0.384 0.000
#> SRR2936872     2   0.000      0.904 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936871     2   0.000      0.904 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936874     2   0.000      0.904 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936870     5   0.000      0.860 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR2936869     2   0.379      0.668 0.000 0.744 0.216 0.040 0.000 0.000
#> SRR2936868     2   0.379      0.668 0.000 0.744 0.216 0.040 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

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

collect_plots(res)

plot of chunk CV-kmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4398 0.561   0.561
#> 3 3 0.646           0.867       0.895         0.4176 0.762   0.583
#> 4 4 0.781           0.765       0.842         0.1408 0.953   0.864
#> 5 5 0.738           0.790       0.838         0.0721 0.889   0.655
#> 6 6 0.793           0.668       0.781         0.0568 0.965   0.852

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
#> SRR2936906     1       0          1  1  0
#> SRR2936909     1       0          1  1  0
#> SRR2936918     1       0          1  1  0
#> SRR2936917     2       0          1  0  1
#> SRR2936916     2       0          1  0  1
#> SRR2936915     2       0          1  0  1
#> SRR2936914     2       0          1  0  1
#> SRR2936913     2       0          1  0  1
#> SRR2936912     1       0          1  1  0
#> SRR2936910     1       0          1  1  0
#> SRR2936911     2       0          1  0  1
#> SRR2936907     2       0          1  0  1
#> SRR2936908     2       0          1  0  1
#> SRR2936904     2       0          1  0  1
#> SRR2936905     2       0          1  0  1
#> SRR2936903     1       0          1  1  0
#> SRR2936901     1       0          1  1  0
#> SRR2936902     2       0          1  0  1
#> SRR2936900     1       0          1  1  0
#> SRR2936898     2       0          1  0  1
#> SRR2936899     2       0          1  0  1
#> SRR2936897     1       0          1  1  0
#> SRR2936896     2       0          1  0  1
#> SRR2936894     1       0          1  1  0
#> SRR2936893     2       0          1  0  1
#> SRR2936895     2       0          1  0  1
#> SRR2936892     2       0          1  0  1
#> SRR2936891     1       0          1  1  0
#> SRR2936890     2       0          1  0  1
#> SRR2936886     2       0          1  0  1
#> SRR2936885     1       0          1  1  0
#> SRR2936888     1       0          1  1  0
#> SRR2936889     2       0          1  0  1
#> SRR2936887     2       0          1  0  1
#> SRR2936884     2       0          1  0  1
#> SRR2936883     2       0          1  0  1
#> SRR2936881     2       0          1  0  1
#> SRR2936882     1       0          1  1  0
#> SRR2936880     2       0          1  0  1
#> SRR2936878     2       0          1  0  1
#> SRR2936879     2       0          1  0  1
#> SRR2936875     2       0          1  0  1
#> SRR2936877     2       0          1  0  1
#> SRR2936876     2       0          1  0  1
#> SRR2936873     1       0          1  1  0
#> SRR2936872     2       0          1  0  1
#> SRR2936871     2       0          1  0  1
#> SRR2936874     2       0          1  0  1
#> SRR2936870     1       0          1  1  0
#> SRR2936869     2       0          1  0  1
#> SRR2936868     2       0          1  0  1

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR2936906     1  0.0000      0.932 1.000 0.000 0.000
#> SRR2936909     1  0.0237      0.932 0.996 0.000 0.004
#> SRR2936918     1  0.0000      0.932 1.000 0.000 0.000
#> SRR2936917     2  0.0000      0.920 0.000 1.000 0.000
#> SRR2936916     3  0.5291      0.897 0.000 0.268 0.732
#> SRR2936915     3  0.5291      0.897 0.000 0.268 0.732
#> SRR2936914     2  0.0000      0.920 0.000 1.000 0.000
#> SRR2936913     2  0.0000      0.920 0.000 1.000 0.000
#> SRR2936912     1  0.0237      0.932 0.996 0.000 0.004
#> SRR2936910     1  0.0000      0.932 1.000 0.000 0.000
#> SRR2936911     2  0.0000      0.920 0.000 1.000 0.000
#> SRR2936907     2  0.0000      0.920 0.000 1.000 0.000
#> SRR2936908     2  0.0000      0.920 0.000 1.000 0.000
#> SRR2936904     3  0.5968      0.739 0.000 0.364 0.636
#> SRR2936905     2  0.0000      0.920 0.000 1.000 0.000
#> SRR2936903     1  0.5291      0.821 0.732 0.000 0.268
#> SRR2936901     3  0.0237      0.655 0.004 0.000 0.996
#> SRR2936902     3  0.4605      0.911 0.000 0.204 0.796
#> SRR2936900     1  0.5254      0.821 0.736 0.000 0.264
#> SRR2936898     3  0.4504      0.905 0.000 0.196 0.804
#> SRR2936899     3  0.4504      0.905 0.000 0.196 0.804
#> SRR2936897     1  0.2959      0.870 0.900 0.000 0.100
#> SRR2936896     2  0.0000      0.920 0.000 1.000 0.000
#> SRR2936894     1  0.0000      0.932 1.000 0.000 0.000
#> SRR2936893     2  0.0000      0.920 0.000 1.000 0.000
#> SRR2936895     2  0.5363      0.523 0.000 0.724 0.276
#> SRR2936892     2  0.0000      0.920 0.000 1.000 0.000
#> SRR2936891     1  0.0000      0.932 1.000 0.000 0.000
#> SRR2936890     2  0.0000      0.920 0.000 1.000 0.000
#> SRR2936886     2  0.5363      0.523 0.000 0.724 0.276
#> SRR2936885     1  0.5291      0.821 0.732 0.000 0.268
#> SRR2936888     1  0.0424      0.931 0.992 0.000 0.008
#> SRR2936889     2  0.0000      0.920 0.000 1.000 0.000
#> SRR2936887     2  0.5363      0.523 0.000 0.724 0.276
#> SRR2936884     3  0.5327      0.893 0.000 0.272 0.728
#> SRR2936883     3  0.4654      0.912 0.000 0.208 0.792
#> SRR2936881     3  0.4654      0.912 0.000 0.208 0.792
#> SRR2936882     1  0.5254      0.821 0.736 0.000 0.264
#> SRR2936880     3  0.4654      0.912 0.000 0.208 0.792
#> SRR2936878     2  0.0000      0.920 0.000 1.000 0.000
#> SRR2936879     3  0.5327      0.893 0.000 0.272 0.728
#> SRR2936875     2  0.0000      0.920 0.000 1.000 0.000
#> SRR2936877     2  0.0000      0.920 0.000 1.000 0.000
#> SRR2936876     3  0.5178      0.900 0.000 0.256 0.744
#> SRR2936873     1  0.0237      0.932 0.996 0.000 0.004
#> SRR2936872     2  0.0000      0.920 0.000 1.000 0.000
#> SRR2936871     2  0.0000      0.920 0.000 1.000 0.000
#> SRR2936874     2  0.0000      0.920 0.000 1.000 0.000
#> SRR2936870     1  0.0424      0.931 0.992 0.000 0.008
#> SRR2936869     2  0.3879      0.746 0.000 0.848 0.152
#> SRR2936868     2  0.5363      0.523 0.000 0.724 0.276

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR2936906     1  0.0707      0.961 0.980 0.000 0.020 0.000
#> SRR2936909     1  0.0524      0.958 0.988 0.000 0.008 0.004
#> SRR2936918     1  0.0707      0.961 0.980 0.000 0.020 0.000
#> SRR2936917     2  0.1637      0.851 0.000 0.940 0.000 0.060
#> SRR2936916     3  0.5897      0.698 0.000 0.044 0.588 0.368
#> SRR2936915     3  0.5897      0.698 0.000 0.044 0.588 0.368
#> SRR2936914     2  0.1637      0.851 0.000 0.940 0.000 0.060
#> SRR2936913     2  0.1637      0.851 0.000 0.940 0.000 0.060
#> SRR2936912     1  0.0524      0.958 0.988 0.000 0.008 0.004
#> SRR2936910     1  0.0707      0.961 0.980 0.000 0.020 0.000
#> SRR2936911     2  0.1637      0.851 0.000 0.940 0.000 0.060
#> SRR2936907     2  0.1637      0.851 0.000 0.940 0.000 0.060
#> SRR2936908     2  0.0000      0.859 0.000 1.000 0.000 0.000
#> SRR2936904     3  0.7688      0.488 0.000 0.220 0.416 0.364
#> SRR2936905     2  0.0000      0.859 0.000 1.000 0.000 0.000
#> SRR2936903     4  0.4941      0.760 0.436 0.000 0.000 0.564
#> SRR2936901     4  0.4933      0.134 0.000 0.000 0.432 0.568
#> SRR2936902     3  0.1022      0.790 0.000 0.032 0.968 0.000
#> SRR2936900     4  0.4941      0.760 0.436 0.000 0.000 0.564
#> SRR2936898     3  0.1356      0.787 0.000 0.032 0.960 0.008
#> SRR2936899     3  0.1356      0.787 0.000 0.032 0.960 0.008
#> SRR2936897     1  0.3088      0.809 0.888 0.000 0.052 0.060
#> SRR2936896     2  0.1637      0.851 0.000 0.940 0.000 0.060
#> SRR2936894     1  0.0707      0.961 0.980 0.000 0.020 0.000
#> SRR2936893     2  0.0000      0.859 0.000 1.000 0.000 0.000
#> SRR2936895     2  0.7397      0.233 0.000 0.508 0.200 0.292
#> SRR2936892     2  0.0000      0.859 0.000 1.000 0.000 0.000
#> SRR2936891     1  0.0707      0.961 0.980 0.000 0.020 0.000
#> SRR2936890     2  0.0000      0.859 0.000 1.000 0.000 0.000
#> SRR2936886     2  0.7588      0.155 0.000 0.468 0.220 0.312
#> SRR2936885     4  0.4941      0.760 0.436 0.000 0.000 0.564
#> SRR2936888     1  0.0657      0.957 0.984 0.000 0.012 0.004
#> SRR2936889     2  0.0000      0.859 0.000 1.000 0.000 0.000
#> SRR2936887     2  0.7588      0.155 0.000 0.468 0.220 0.312
#> SRR2936884     3  0.1022      0.790 0.000 0.032 0.968 0.000
#> SRR2936883     3  0.1022      0.790 0.000 0.032 0.968 0.000
#> SRR2936881     3  0.1022      0.790 0.000 0.032 0.968 0.000
#> SRR2936882     4  0.4941      0.760 0.436 0.000 0.000 0.564
#> SRR2936880     3  0.1022      0.790 0.000 0.032 0.968 0.000
#> SRR2936878     2  0.1637      0.851 0.000 0.940 0.000 0.060
#> SRR2936879     3  0.5954      0.701 0.000 0.052 0.604 0.344
#> SRR2936875     2  0.0000      0.859 0.000 1.000 0.000 0.000
#> SRR2936877     2  0.1637      0.851 0.000 0.940 0.000 0.060
#> SRR2936876     3  0.6035      0.682 0.020 0.020 0.588 0.372
#> SRR2936873     1  0.0188      0.960 0.996 0.000 0.000 0.004
#> SRR2936872     2  0.0000      0.859 0.000 1.000 0.000 0.000
#> SRR2936871     2  0.0000      0.859 0.000 1.000 0.000 0.000
#> SRR2936874     2  0.0000      0.859 0.000 1.000 0.000 0.000
#> SRR2936870     1  0.0657      0.957 0.984 0.000 0.012 0.004
#> SRR2936869     2  0.5910      0.538 0.000 0.672 0.084 0.244
#> SRR2936868     2  0.7588      0.155 0.000 0.468 0.220 0.312

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4    p5
#> SRR2936906     1  0.1410      0.867 0.940 0.000 0.000 0.060 0.000
#> SRR2936909     1  0.2511      0.821 0.892 0.000 0.000 0.080 0.028
#> SRR2936918     1  0.1410      0.867 0.940 0.000 0.000 0.060 0.000
#> SRR2936917     2  0.4031      0.821 0.000 0.772 0.000 0.044 0.184
#> SRR2936916     4  0.3909      0.625 0.000 0.000 0.216 0.760 0.024
#> SRR2936915     4  0.3909      0.625 0.000 0.000 0.216 0.760 0.024
#> SRR2936914     2  0.4031      0.821 0.000 0.772 0.000 0.044 0.184
#> SRR2936913     2  0.4031      0.821 0.000 0.772 0.000 0.044 0.184
#> SRR2936912     1  0.1704      0.845 0.928 0.000 0.000 0.068 0.004
#> SRR2936910     1  0.1410      0.867 0.940 0.000 0.000 0.060 0.000
#> SRR2936911     2  0.4031      0.821 0.000 0.772 0.000 0.044 0.184
#> SRR2936907     2  0.3958      0.821 0.000 0.776 0.000 0.040 0.184
#> SRR2936908     2  0.0000      0.854 0.000 1.000 0.000 0.000 0.000
#> SRR2936904     4  0.3991      0.656 0.000 0.048 0.172 0.780 0.000
#> SRR2936905     2  0.0000      0.854 0.000 1.000 0.000 0.000 0.000
#> SRR2936903     5  0.3774      0.993 0.296 0.000 0.000 0.000 0.704
#> SRR2936901     3  0.4268      0.478 0.000 0.000 0.648 0.008 0.344
#> SRR2936902     3  0.0162      0.939 0.000 0.000 0.996 0.004 0.000
#> SRR2936900     5  0.4152      0.993 0.296 0.000 0.000 0.012 0.692
#> SRR2936898     3  0.0162      0.936 0.000 0.000 0.996 0.004 0.000
#> SRR2936899     3  0.0162      0.936 0.000 0.000 0.996 0.004 0.000
#> SRR2936897     1  0.5109      0.353 0.580 0.000 0.008 0.384 0.028
#> SRR2936896     2  0.4031      0.821 0.000 0.772 0.000 0.044 0.184
#> SRR2936894     1  0.1410      0.867 0.940 0.000 0.000 0.060 0.000
#> SRR2936893     2  0.0000      0.854 0.000 1.000 0.000 0.000 0.000
#> SRR2936895     4  0.7298      0.505 0.000 0.388 0.104 0.424 0.084
#> SRR2936892     2  0.0000      0.854 0.000 1.000 0.000 0.000 0.000
#> SRR2936891     1  0.1410      0.867 0.940 0.000 0.000 0.060 0.000
#> SRR2936890     2  0.0000      0.854 0.000 1.000 0.000 0.000 0.000
#> SRR2936886     4  0.7219      0.590 0.000 0.332 0.104 0.480 0.084
#> SRR2936885     5  0.3774      0.993 0.296 0.000 0.000 0.000 0.704
#> SRR2936888     1  0.1478      0.850 0.936 0.000 0.000 0.064 0.000
#> SRR2936889     2  0.0000      0.854 0.000 1.000 0.000 0.000 0.000
#> SRR2936887     4  0.7219      0.590 0.000 0.332 0.104 0.480 0.084
#> SRR2936884     3  0.0162      0.939 0.000 0.000 0.996 0.004 0.000
#> SRR2936883     3  0.0162      0.939 0.000 0.000 0.996 0.004 0.000
#> SRR2936881     3  0.0162      0.939 0.000 0.000 0.996 0.004 0.000
#> SRR2936882     5  0.4152      0.993 0.296 0.000 0.000 0.012 0.692
#> SRR2936880     3  0.0162      0.939 0.000 0.000 0.996 0.004 0.000
#> SRR2936878     2  0.4031      0.821 0.000 0.772 0.000 0.044 0.184
#> SRR2936879     4  0.3521      0.627 0.000 0.004 0.232 0.764 0.000
#> SRR2936875     2  0.0000      0.854 0.000 1.000 0.000 0.000 0.000
#> SRR2936877     2  0.4031      0.821 0.000 0.772 0.000 0.044 0.184
#> SRR2936876     4  0.3687      0.611 0.000 0.000 0.180 0.792 0.028
#> SRR2936873     1  0.0955      0.859 0.968 0.000 0.000 0.028 0.004
#> SRR2936872     2  0.0000      0.854 0.000 1.000 0.000 0.000 0.000
#> SRR2936871     2  0.0000      0.854 0.000 1.000 0.000 0.000 0.000
#> SRR2936874     2  0.0000      0.854 0.000 1.000 0.000 0.000 0.000
#> SRR2936870     1  0.1478      0.850 0.936 0.000 0.000 0.064 0.000
#> SRR2936869     2  0.6476     -0.159 0.000 0.544 0.044 0.328 0.084
#> SRR2936868     4  0.7219      0.590 0.000 0.332 0.104 0.480 0.084

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR2936906     1  0.0000     0.8846 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936909     1  0.4344     0.7798 0.716 0.000 0.000 0.096 0.188 0.000
#> SRR2936918     1  0.0146     0.8843 0.996 0.000 0.000 0.004 0.000 0.000
#> SRR2936917     2  0.0000     0.6407 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936916     4  0.1141     0.4877 0.000 0.000 0.052 0.948 0.000 0.000
#> SRR2936915     4  0.1141     0.4877 0.000 0.000 0.052 0.948 0.000 0.000
#> SRR2936914     2  0.0000     0.6407 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936913     2  0.0000     0.6407 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936912     1  0.3516     0.8398 0.788 0.000 0.000 0.048 0.164 0.000
#> SRR2936910     1  0.0146     0.8843 0.996 0.000 0.000 0.004 0.000 0.000
#> SRR2936911     2  0.0000     0.6407 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936907     2  0.0000     0.6407 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936908     2  0.3838     0.6961 0.000 0.552 0.000 0.000 0.000 0.448
#> SRR2936904     4  0.4102     0.3918 0.000 0.004 0.048 0.752 0.188 0.008
#> SRR2936905     2  0.3838     0.6961 0.000 0.552 0.000 0.000 0.000 0.448
#> SRR2936903     6  0.5559     0.9894 0.176 0.000 0.000 0.000 0.284 0.540
#> SRR2936901     3  0.4428     0.6215 0.000 0.000 0.696 0.000 0.084 0.220
#> SRR2936902     3  0.0146     0.9505 0.000 0.000 0.996 0.000 0.004 0.000
#> SRR2936900     6  0.5625     0.9894 0.176 0.000 0.000 0.000 0.304 0.520
#> SRR2936898     3  0.0713     0.9421 0.000 0.000 0.972 0.000 0.028 0.000
#> SRR2936899     3  0.0713     0.9421 0.000 0.000 0.972 0.000 0.028 0.000
#> SRR2936897     4  0.5514    -0.0284 0.272 0.000 0.000 0.552 0.176 0.000
#> SRR2936896     2  0.0146     0.6378 0.000 0.996 0.000 0.000 0.000 0.004
#> SRR2936894     1  0.0000     0.8846 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936893     2  0.3838     0.6961 0.000 0.552 0.000 0.000 0.000 0.448
#> SRR2936895     5  0.8097     0.7032 0.000 0.116 0.060 0.288 0.360 0.176
#> SRR2936892     2  0.3838     0.6961 0.000 0.552 0.000 0.000 0.000 0.448
#> SRR2936891     1  0.0000     0.8846 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936890     2  0.3838     0.6961 0.000 0.552 0.000 0.000 0.000 0.448
#> SRR2936886     4  0.7013    -0.5068 0.000 0.108 0.048 0.404 0.396 0.044
#> SRR2936885     6  0.5559     0.9894 0.176 0.000 0.000 0.000 0.284 0.540
#> SRR2936888     1  0.2814     0.8593 0.820 0.000 0.000 0.008 0.172 0.000
#> SRR2936889     2  0.3838     0.6961 0.000 0.552 0.000 0.000 0.000 0.448
#> SRR2936887     4  0.7013    -0.5068 0.000 0.108 0.048 0.404 0.396 0.044
#> SRR2936884     3  0.0146     0.9505 0.000 0.000 0.996 0.000 0.004 0.000
#> SRR2936883     3  0.0146     0.9505 0.000 0.000 0.996 0.000 0.004 0.000
#> SRR2936881     3  0.0000     0.9504 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR2936882     6  0.5625     0.9894 0.176 0.000 0.000 0.000 0.304 0.520
#> SRR2936880     3  0.0000     0.9504 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR2936878     2  0.0000     0.6407 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936879     4  0.3063     0.4523 0.000 0.000 0.068 0.840 0.092 0.000
#> SRR2936875     2  0.3843     0.6930 0.000 0.548 0.000 0.000 0.000 0.452
#> SRR2936877     2  0.0000     0.6407 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936876     4  0.1625     0.4494 0.000 0.000 0.012 0.928 0.060 0.000
#> SRR2936873     1  0.3088     0.8573 0.832 0.000 0.000 0.048 0.120 0.000
#> SRR2936872     2  0.3838     0.6961 0.000 0.552 0.000 0.000 0.000 0.448
#> SRR2936871     2  0.3838     0.6961 0.000 0.552 0.000 0.000 0.000 0.448
#> SRR2936874     2  0.3843     0.6930 0.000 0.548 0.000 0.000 0.000 0.452
#> SRR2936870     1  0.2814     0.8593 0.820 0.000 0.000 0.008 0.172 0.000
#> SRR2936869     5  0.7667     0.7258 0.000 0.152 0.016 0.264 0.396 0.172
#> SRR2936868     4  0.7013    -0.5068 0.000 0.108 0.048 0.404 0.396 0.044

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

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

collect_plots(res)

plot of chunk CV-skmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.992       0.996         0.4957 0.506   0.506
#> 3 3 0.931           0.970       0.984         0.2646 0.848   0.706
#> 4 4 0.842           0.857       0.907         0.0761 0.947   0.862
#> 5 5 0.842           0.876       0.897         0.0566 0.895   0.690
#> 6 6 0.933           0.968       0.970         0.0589 0.992   0.968

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
#> SRR2936906     1  0.0000      1.000 1.000 0.000
#> SRR2936909     1  0.0000      1.000 1.000 0.000
#> SRR2936918     1  0.0000      1.000 1.000 0.000
#> SRR2936917     2  0.0000      0.994 0.000 1.000
#> SRR2936916     1  0.0000      1.000 1.000 0.000
#> SRR2936915     1  0.0000      1.000 1.000 0.000
#> SRR2936914     2  0.0000      0.994 0.000 1.000
#> SRR2936913     2  0.0000      0.994 0.000 1.000
#> SRR2936912     1  0.0000      1.000 1.000 0.000
#> SRR2936910     1  0.0000      1.000 1.000 0.000
#> SRR2936911     2  0.0000      0.994 0.000 1.000
#> SRR2936907     2  0.0000      0.994 0.000 1.000
#> SRR2936908     2  0.0000      0.994 0.000 1.000
#> SRR2936904     2  0.0000      0.994 0.000 1.000
#> SRR2936905     2  0.0000      0.994 0.000 1.000
#> SRR2936903     1  0.0000      1.000 1.000 0.000
#> SRR2936901     1  0.0000      1.000 1.000 0.000
#> SRR2936902     2  0.6801      0.780 0.180 0.820
#> SRR2936900     1  0.0000      1.000 1.000 0.000
#> SRR2936898     1  0.0000      1.000 1.000 0.000
#> SRR2936899     1  0.0376      0.996 0.996 0.004
#> SRR2936897     1  0.0000      1.000 1.000 0.000
#> SRR2936896     2  0.0000      0.994 0.000 1.000
#> SRR2936894     1  0.0000      1.000 1.000 0.000
#> SRR2936893     2  0.0000      0.994 0.000 1.000
#> SRR2936895     2  0.0000      0.994 0.000 1.000
#> SRR2936892     2  0.0000      0.994 0.000 1.000
#> SRR2936891     1  0.0000      1.000 1.000 0.000
#> SRR2936890     2  0.0000      0.994 0.000 1.000
#> SRR2936886     2  0.0000      0.994 0.000 1.000
#> SRR2936885     1  0.0000      1.000 1.000 0.000
#> SRR2936888     1  0.0000      1.000 1.000 0.000
#> SRR2936889     2  0.0000      0.994 0.000 1.000
#> SRR2936887     2  0.0000      0.994 0.000 1.000
#> SRR2936884     2  0.0000      0.994 0.000 1.000
#> SRR2936883     2  0.0000      0.994 0.000 1.000
#> SRR2936881     2  0.0000      0.994 0.000 1.000
#> SRR2936882     1  0.0000      1.000 1.000 0.000
#> SRR2936880     2  0.0000      0.994 0.000 1.000
#> SRR2936878     2  0.0000      0.994 0.000 1.000
#> SRR2936879     2  0.0000      0.994 0.000 1.000
#> SRR2936875     2  0.0000      0.994 0.000 1.000
#> SRR2936877     2  0.0000      0.994 0.000 1.000
#> SRR2936876     1  0.0000      1.000 1.000 0.000
#> SRR2936873     1  0.0000      1.000 1.000 0.000
#> SRR2936872     2  0.0000      0.994 0.000 1.000
#> SRR2936871     2  0.0000      0.994 0.000 1.000
#> SRR2936874     2  0.0000      0.994 0.000 1.000
#> SRR2936870     1  0.0000      1.000 1.000 0.000
#> SRR2936869     2  0.0000      0.994 0.000 1.000
#> SRR2936868     2  0.0000      0.994 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette  p1 p2  p3
#> SRR2936906     1   0.000      0.950 1.0  0 0.0
#> SRR2936909     1   0.000      0.950 1.0  0 0.0
#> SRR2936918     1   0.000      0.950 1.0  0 0.0
#> SRR2936917     2   0.000      1.000 0.0  1 0.0
#> SRR2936916     1   0.000      0.950 1.0  0 0.0
#> SRR2936915     1   0.000      0.950 1.0  0 0.0
#> SRR2936914     2   0.000      1.000 0.0  1 0.0
#> SRR2936913     2   0.000      1.000 0.0  1 0.0
#> SRR2936912     1   0.000      0.950 1.0  0 0.0
#> SRR2936910     1   0.000      0.950 1.0  0 0.0
#> SRR2936911     2   0.000      1.000 0.0  1 0.0
#> SRR2936907     2   0.000      1.000 0.0  1 0.0
#> SRR2936908     2   0.000      1.000 0.0  1 0.0
#> SRR2936904     2   0.000      1.000 0.0  1 0.0
#> SRR2936905     2   0.000      1.000 0.0  1 0.0
#> SRR2936903     1   0.455      0.794 0.8  0 0.2
#> SRR2936901     3   0.000      1.000 0.0  0 1.0
#> SRR2936902     3   0.000      1.000 0.0  0 1.0
#> SRR2936900     1   0.455      0.794 0.8  0 0.2
#> SRR2936898     3   0.000      1.000 0.0  0 1.0
#> SRR2936899     3   0.000      1.000 0.0  0 1.0
#> SRR2936897     1   0.000      0.950 1.0  0 0.0
#> SRR2936896     2   0.000      1.000 0.0  1 0.0
#> SRR2936894     1   0.000      0.950 1.0  0 0.0
#> SRR2936893     2   0.000      1.000 0.0  1 0.0
#> SRR2936895     2   0.000      1.000 0.0  1 0.0
#> SRR2936892     2   0.000      1.000 0.0  1 0.0
#> SRR2936891     1   0.000      0.950 1.0  0 0.0
#> SRR2936890     2   0.000      1.000 0.0  1 0.0
#> SRR2936886     2   0.000      1.000 0.0  1 0.0
#> SRR2936885     1   0.455      0.794 0.8  0 0.2
#> SRR2936888     1   0.000      0.950 1.0  0 0.0
#> SRR2936889     2   0.000      1.000 0.0  1 0.0
#> SRR2936887     2   0.000      1.000 0.0  1 0.0
#> SRR2936884     3   0.000      1.000 0.0  0 1.0
#> SRR2936883     3   0.000      1.000 0.0  0 1.0
#> SRR2936881     3   0.000      1.000 0.0  0 1.0
#> SRR2936882     1   0.455      0.794 0.8  0 0.2
#> SRR2936880     3   0.000      1.000 0.0  0 1.0
#> SRR2936878     2   0.000      1.000 0.0  1 0.0
#> SRR2936879     2   0.000      1.000 0.0  1 0.0
#> SRR2936875     2   0.000      1.000 0.0  1 0.0
#> SRR2936877     2   0.000      1.000 0.0  1 0.0
#> SRR2936876     1   0.000      0.950 1.0  0 0.0
#> SRR2936873     1   0.000      0.950 1.0  0 0.0
#> SRR2936872     2   0.000      1.000 0.0  1 0.0
#> SRR2936871     2   0.000      1.000 0.0  1 0.0
#> SRR2936874     2   0.000      1.000 0.0  1 0.0
#> SRR2936870     1   0.000      0.950 1.0  0 0.0
#> SRR2936869     2   0.000      1.000 0.0  1 0.0
#> SRR2936868     2   0.000      1.000 0.0  1 0.0

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR2936906     1   0.000     0.8938 1.000 0.000 0.000 0.000
#> SRR2936909     1   0.000     0.8938 1.000 0.000 0.000 0.000
#> SRR2936918     1   0.000     0.8938 1.000 0.000 0.000 0.000
#> SRR2936917     2   0.000     0.9524 0.000 1.000 0.000 0.000
#> SRR2936916     1   0.498     0.3197 0.540 0.000 0.000 0.460
#> SRR2936915     1   0.497     0.3296 0.548 0.000 0.000 0.452
#> SRR2936914     2   0.000     0.9524 0.000 1.000 0.000 0.000
#> SRR2936913     2   0.000     0.9524 0.000 1.000 0.000 0.000
#> SRR2936912     1   0.000     0.8938 1.000 0.000 0.000 0.000
#> SRR2936910     1   0.000     0.8938 1.000 0.000 0.000 0.000
#> SRR2936911     2   0.000     0.9524 0.000 1.000 0.000 0.000
#> SRR2936907     2   0.000     0.9524 0.000 1.000 0.000 0.000
#> SRR2936908     2   0.000     0.9524 0.000 1.000 0.000 0.000
#> SRR2936904     2   0.462     0.6600 0.000 0.660 0.000 0.340
#> SRR2936905     2   0.000     0.9524 0.000 1.000 0.000 0.000
#> SRR2936903     4   0.647     0.8030 0.416 0.000 0.072 0.512
#> SRR2936901     4   0.517    -0.0964 0.004 0.000 0.484 0.512
#> SRR2936902     3   0.000     0.9443 0.000 0.000 1.000 0.000
#> SRR2936900     4   0.647     0.8030 0.416 0.000 0.072 0.512
#> SRR2936898     3   0.000     0.9443 0.000 0.000 1.000 0.000
#> SRR2936899     3   0.000     0.9443 0.000 0.000 1.000 0.000
#> SRR2936897     1   0.000     0.8938 1.000 0.000 0.000 0.000
#> SRR2936896     2   0.000     0.9524 0.000 1.000 0.000 0.000
#> SRR2936894     1   0.000     0.8938 1.000 0.000 0.000 0.000
#> SRR2936893     2   0.000     0.9524 0.000 1.000 0.000 0.000
#> SRR2936895     2   0.000     0.9524 0.000 1.000 0.000 0.000
#> SRR2936892     2   0.000     0.9524 0.000 1.000 0.000 0.000
#> SRR2936891     1   0.000     0.8938 1.000 0.000 0.000 0.000
#> SRR2936890     2   0.000     0.9524 0.000 1.000 0.000 0.000
#> SRR2936886     2   0.373     0.8021 0.000 0.788 0.000 0.212
#> SRR2936885     4   0.647     0.8030 0.416 0.000 0.072 0.512
#> SRR2936888     1   0.000     0.8938 1.000 0.000 0.000 0.000
#> SRR2936889     2   0.000     0.9524 0.000 1.000 0.000 0.000
#> SRR2936887     2   0.373     0.8021 0.000 0.788 0.000 0.212
#> SRR2936884     3   0.353     0.6565 0.000 0.192 0.808 0.000
#> SRR2936883     3   0.000     0.9443 0.000 0.000 1.000 0.000
#> SRR2936881     3   0.000     0.9443 0.000 0.000 1.000 0.000
#> SRR2936882     4   0.647     0.8030 0.416 0.000 0.072 0.512
#> SRR2936880     3   0.000     0.9443 0.000 0.000 1.000 0.000
#> SRR2936878     2   0.000     0.9524 0.000 1.000 0.000 0.000
#> SRR2936879     2   0.000     0.9524 0.000 1.000 0.000 0.000
#> SRR2936875     2   0.000     0.9524 0.000 1.000 0.000 0.000
#> SRR2936877     2   0.000     0.9524 0.000 1.000 0.000 0.000
#> SRR2936876     1   0.000     0.8938 1.000 0.000 0.000 0.000
#> SRR2936873     1   0.000     0.8938 1.000 0.000 0.000 0.000
#> SRR2936872     2   0.000     0.9524 0.000 1.000 0.000 0.000
#> SRR2936871     2   0.000     0.9524 0.000 1.000 0.000 0.000
#> SRR2936874     2   0.000     0.9524 0.000 1.000 0.000 0.000
#> SRR2936870     1   0.000     0.8938 1.000 0.000 0.000 0.000
#> SRR2936869     2   0.373     0.8021 0.000 0.788 0.000 0.212
#> SRR2936868     2   0.373     0.8021 0.000 0.788 0.000 0.212

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4    p5
#> SRR2936906     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000
#> SRR2936909     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000
#> SRR2936918     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000
#> SRR2936917     2  0.0000     0.9981 0.000 1.000 0.000 0.000 0.000
#> SRR2936916     4  0.6552    -0.0904 0.248 0.000 0.000 0.476 0.276
#> SRR2936915     4  0.6552    -0.0904 0.248 0.000 0.000 0.476 0.276
#> SRR2936914     2  0.0000     0.9981 0.000 1.000 0.000 0.000 0.000
#> SRR2936913     2  0.0000     0.9981 0.000 1.000 0.000 0.000 0.000
#> SRR2936912     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000
#> SRR2936910     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000
#> SRR2936911     2  0.0000     0.9981 0.000 1.000 0.000 0.000 0.000
#> SRR2936907     2  0.0000     0.9981 0.000 1.000 0.000 0.000 0.000
#> SRR2936908     2  0.0000     0.9981 0.000 1.000 0.000 0.000 0.000
#> SRR2936904     4  0.4321     0.5051 0.000 0.396 0.000 0.600 0.004
#> SRR2936905     2  0.0000     0.9981 0.000 1.000 0.000 0.000 0.000
#> SRR2936903     5  0.3885     0.8941 0.268 0.000 0.008 0.000 0.724
#> SRR2936901     5  0.3661     0.4854 0.000 0.000 0.276 0.000 0.724
#> SRR2936902     3  0.0162     0.9452 0.000 0.000 0.996 0.004 0.000
#> SRR2936900     5  0.3885     0.8941 0.268 0.000 0.008 0.000 0.724
#> SRR2936898     3  0.0000     0.9462 0.000 0.000 1.000 0.000 0.000
#> SRR2936899     3  0.0000     0.9462 0.000 0.000 1.000 0.000 0.000
#> SRR2936897     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000
#> SRR2936896     2  0.0000     0.9981 0.000 1.000 0.000 0.000 0.000
#> SRR2936894     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000
#> SRR2936893     2  0.0000     0.9981 0.000 1.000 0.000 0.000 0.000
#> SRR2936895     2  0.0404     0.9812 0.000 0.988 0.000 0.012 0.000
#> SRR2936892     2  0.0000     0.9981 0.000 1.000 0.000 0.000 0.000
#> SRR2936891     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000
#> SRR2936890     2  0.0000     0.9981 0.000 1.000 0.000 0.000 0.000
#> SRR2936886     4  0.4306     0.4996 0.000 0.492 0.000 0.508 0.000
#> SRR2936885     5  0.3885     0.8941 0.268 0.000 0.008 0.000 0.724
#> SRR2936888     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000
#> SRR2936889     2  0.0000     0.9981 0.000 1.000 0.000 0.000 0.000
#> SRR2936887     4  0.4306     0.4996 0.000 0.492 0.000 0.508 0.000
#> SRR2936884     3  0.3196     0.6740 0.000 0.192 0.804 0.004 0.000
#> SRR2936883     3  0.0162     0.9452 0.000 0.000 0.996 0.004 0.000
#> SRR2936881     3  0.0000     0.9462 0.000 0.000 1.000 0.000 0.000
#> SRR2936882     5  0.3885     0.8941 0.268 0.000 0.008 0.000 0.724
#> SRR2936880     3  0.0000     0.9462 0.000 0.000 1.000 0.000 0.000
#> SRR2936878     2  0.0000     0.9981 0.000 1.000 0.000 0.000 0.000
#> SRR2936879     2  0.0404     0.9812 0.000 0.988 0.000 0.012 0.000
#> SRR2936875     2  0.0000     0.9981 0.000 1.000 0.000 0.000 0.000
#> SRR2936877     2  0.0000     0.9981 0.000 1.000 0.000 0.000 0.000
#> SRR2936876     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000
#> SRR2936873     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000
#> SRR2936872     2  0.0000     0.9981 0.000 1.000 0.000 0.000 0.000
#> SRR2936871     2  0.0000     0.9981 0.000 1.000 0.000 0.000 0.000
#> SRR2936874     2  0.0000     0.9981 0.000 1.000 0.000 0.000 0.000
#> SRR2936870     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000
#> SRR2936869     4  0.4306     0.4996 0.000 0.492 0.000 0.508 0.000
#> SRR2936868     4  0.4306     0.4996 0.000 0.492 0.000 0.508 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
#> SRR2936906     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936909     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936918     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936917     2  0.0000      0.990 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936916     5  0.0547      1.000 0.020 0.000 0.000 0.000 0.980 0.000
#> SRR2936915     5  0.0547      1.000 0.020 0.000 0.000 0.000 0.980 0.000
#> SRR2936914     2  0.0000      0.990 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936913     2  0.0000      0.990 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936912     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936910     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936911     2  0.0000      0.990 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936907     2  0.0000      0.990 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936908     2  0.0000      0.990 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936904     4  0.4524      0.553 0.000 0.100 0.000 0.760 0.076 0.064
#> SRR2936905     2  0.0000      0.990 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936903     6  0.1327      0.966 0.064 0.000 0.000 0.000 0.000 0.936
#> SRR2936901     6  0.1327      0.875 0.000 0.000 0.064 0.000 0.000 0.936
#> SRR2936902     3  0.0260      0.980 0.000 0.000 0.992 0.008 0.000 0.000
#> SRR2936900     6  0.1387      0.968 0.068 0.000 0.000 0.000 0.000 0.932
#> SRR2936898     3  0.0260      0.980 0.000 0.000 0.992 0.000 0.000 0.008
#> SRR2936899     3  0.0260      0.980 0.000 0.000 0.992 0.000 0.000 0.008
#> SRR2936897     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936896     2  0.0000      0.990 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936894     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936893     2  0.0000      0.990 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936895     2  0.0937      0.947 0.000 0.960 0.000 0.040 0.000 0.000
#> SRR2936892     2  0.0000      0.990 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936891     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936890     2  0.0000      0.990 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936886     4  0.2527      0.911 0.000 0.168 0.000 0.832 0.000 0.000
#> SRR2936885     6  0.1387      0.968 0.068 0.000 0.000 0.000 0.000 0.932
#> SRR2936888     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936889     2  0.0000      0.990 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936887     4  0.2527      0.911 0.000 0.168 0.000 0.832 0.000 0.000
#> SRR2936884     3  0.1265      0.919 0.000 0.044 0.948 0.008 0.000 0.000
#> SRR2936883     3  0.0260      0.980 0.000 0.000 0.992 0.008 0.000 0.000
#> SRR2936881     3  0.0000      0.982 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR2936882     6  0.1387      0.968 0.068 0.000 0.000 0.000 0.000 0.932
#> SRR2936880     3  0.0000      0.982 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR2936878     2  0.0000      0.990 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936879     2  0.2686      0.846 0.000 0.876 0.000 0.080 0.012 0.032
#> SRR2936875     2  0.0000      0.990 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936877     2  0.0000      0.990 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936876     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936873     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936872     2  0.0000      0.990 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936871     2  0.0000      0.990 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936874     2  0.0000      0.990 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936870     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936869     4  0.2527      0.911 0.000 0.168 0.000 0.832 0.000 0.000
#> SRR2936868     4  0.2527      0.911 0.000 0.168 0.000 0.832 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-skmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-skmeans-collect-classes

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


CV:pam**

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

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

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

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

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

collect_plots(res)

plot of chunk CV-pam-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.972       0.989         0.4460 0.547   0.547
#> 3 3 0.741           0.818       0.926         0.4702 0.755   0.571
#> 4 4 0.790           0.868       0.936         0.0664 0.835   0.583
#> 5 5 0.868           0.855       0.925         0.0810 0.929   0.753
#> 6 6 0.881           0.851       0.901         0.0294 0.947   0.780

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

suggest_best_k(res)
#> [1] 2

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette    p1    p2
#> SRR2936906     1   0.000      0.965 1.000 0.000
#> SRR2936909     1   0.000      0.965 1.000 0.000
#> SRR2936918     1   0.000      0.965 1.000 0.000
#> SRR2936917     2   0.000      1.000 0.000 1.000
#> SRR2936916     2   0.000      1.000 0.000 1.000
#> SRR2936915     2   0.000      1.000 0.000 1.000
#> SRR2936914     2   0.000      1.000 0.000 1.000
#> SRR2936913     2   0.000      1.000 0.000 1.000
#> SRR2936912     1   0.000      0.965 1.000 0.000
#> SRR2936910     1   0.000      0.965 1.000 0.000
#> SRR2936911     2   0.000      1.000 0.000 1.000
#> SRR2936907     2   0.000      1.000 0.000 1.000
#> SRR2936908     2   0.000      1.000 0.000 1.000
#> SRR2936904     2   0.000      1.000 0.000 1.000
#> SRR2936905     2   0.000      1.000 0.000 1.000
#> SRR2936903     1   0.000      0.965 1.000 0.000
#> SRR2936901     1   0.482      0.866 0.896 0.104
#> SRR2936902     2   0.000      1.000 0.000 1.000
#> SRR2936900     1   0.000      0.965 1.000 0.000
#> SRR2936898     2   0.000      1.000 0.000 1.000
#> SRR2936899     2   0.000      1.000 0.000 1.000
#> SRR2936897     1   0.000      0.965 1.000 0.000
#> SRR2936896     2   0.000      1.000 0.000 1.000
#> SRR2936894     1   0.000      0.965 1.000 0.000
#> SRR2936893     2   0.000      1.000 0.000 1.000
#> SRR2936895     2   0.000      1.000 0.000 1.000
#> SRR2936892     2   0.000      1.000 0.000 1.000
#> SRR2936891     1   0.000      0.965 1.000 0.000
#> SRR2936890     2   0.000      1.000 0.000 1.000
#> SRR2936886     2   0.000      1.000 0.000 1.000
#> SRR2936885     1   0.000      0.965 1.000 0.000
#> SRR2936888     1   0.000      0.965 1.000 0.000
#> SRR2936889     2   0.000      1.000 0.000 1.000
#> SRR2936887     2   0.000      1.000 0.000 1.000
#> SRR2936884     2   0.000      1.000 0.000 1.000
#> SRR2936883     2   0.000      1.000 0.000 1.000
#> SRR2936881     2   0.000      1.000 0.000 1.000
#> SRR2936882     1   0.000      0.965 1.000 0.000
#> SRR2936880     2   0.000      1.000 0.000 1.000
#> SRR2936878     2   0.000      1.000 0.000 1.000
#> SRR2936879     2   0.000      1.000 0.000 1.000
#> SRR2936875     2   0.000      1.000 0.000 1.000
#> SRR2936877     2   0.000      1.000 0.000 1.000
#> SRR2936876     1   0.991      0.218 0.556 0.444
#> SRR2936873     1   0.000      0.965 1.000 0.000
#> SRR2936872     2   0.000      1.000 0.000 1.000
#> SRR2936871     2   0.000      1.000 0.000 1.000
#> SRR2936874     2   0.000      1.000 0.000 1.000
#> SRR2936870     1   0.000      0.965 1.000 0.000
#> SRR2936869     2   0.000      1.000 0.000 1.000
#> SRR2936868     2   0.000      1.000 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1   p2    p3
#> SRR2936906     1  0.0000      0.962 1.000 0.00 0.000
#> SRR2936909     1  0.0000      0.962 1.000 0.00 0.000
#> SRR2936918     1  0.0000      0.962 1.000 0.00 0.000
#> SRR2936917     2  0.0000      0.885 0.000 1.00 0.000
#> SRR2936916     3  0.4555      0.708 0.000 0.20 0.800
#> SRR2936915     3  0.4555      0.708 0.000 0.20 0.800
#> SRR2936914     2  0.0000      0.885 0.000 1.00 0.000
#> SRR2936913     2  0.0000      0.885 0.000 1.00 0.000
#> SRR2936912     1  0.0000      0.962 1.000 0.00 0.000
#> SRR2936910     1  0.0000      0.962 1.000 0.00 0.000
#> SRR2936911     2  0.0000      0.885 0.000 1.00 0.000
#> SRR2936907     2  0.0000      0.885 0.000 1.00 0.000
#> SRR2936908     2  0.0000      0.885 0.000 1.00 0.000
#> SRR2936904     2  0.6192      0.370 0.000 0.58 0.420
#> SRR2936905     2  0.0000      0.885 0.000 1.00 0.000
#> SRR2936903     3  0.6192      0.109 0.420 0.00 0.580
#> SRR2936901     3  0.0000      0.895 0.000 0.00 1.000
#> SRR2936902     3  0.0000      0.895 0.000 0.00 1.000
#> SRR2936900     1  0.0592      0.955 0.988 0.00 0.012
#> SRR2936898     3  0.0000      0.895 0.000 0.00 1.000
#> SRR2936899     3  0.0000      0.895 0.000 0.00 1.000
#> SRR2936897     1  0.4887      0.656 0.772 0.00 0.228
#> SRR2936896     2  0.0000      0.885 0.000 1.00 0.000
#> SRR2936894     1  0.0000      0.962 1.000 0.00 0.000
#> SRR2936893     2  0.0000      0.885 0.000 1.00 0.000
#> SRR2936895     2  0.6192      0.370 0.000 0.58 0.420
#> SRR2936892     2  0.0000      0.885 0.000 1.00 0.000
#> SRR2936891     1  0.0000      0.962 1.000 0.00 0.000
#> SRR2936890     2  0.0000      0.885 0.000 1.00 0.000
#> SRR2936886     2  0.6192      0.370 0.000 0.58 0.420
#> SRR2936885     1  0.4555      0.757 0.800 0.00 0.200
#> SRR2936888     1  0.0000      0.962 1.000 0.00 0.000
#> SRR2936889     2  0.0000      0.885 0.000 1.00 0.000
#> SRR2936887     2  0.6192      0.370 0.000 0.58 0.420
#> SRR2936884     3  0.0000      0.895 0.000 0.00 1.000
#> SRR2936883     3  0.0000      0.895 0.000 0.00 1.000
#> SRR2936881     3  0.0000      0.895 0.000 0.00 1.000
#> SRR2936882     1  0.0237      0.960 0.996 0.00 0.004
#> SRR2936880     3  0.0000      0.895 0.000 0.00 1.000
#> SRR2936878     2  0.0000      0.885 0.000 1.00 0.000
#> SRR2936879     3  0.4555      0.708 0.000 0.20 0.800
#> SRR2936875     2  0.0000      0.885 0.000 1.00 0.000
#> SRR2936877     2  0.0000      0.885 0.000 1.00 0.000
#> SRR2936876     3  0.0000      0.895 0.000 0.00 1.000
#> SRR2936873     1  0.0000      0.962 1.000 0.00 0.000
#> SRR2936872     2  0.0000      0.885 0.000 1.00 0.000
#> SRR2936871     2  0.0000      0.885 0.000 1.00 0.000
#> SRR2936874     2  0.0000      0.885 0.000 1.00 0.000
#> SRR2936870     1  0.0000      0.962 1.000 0.00 0.000
#> SRR2936869     2  0.4555      0.706 0.000 0.80 0.200
#> SRR2936868     2  0.6192      0.370 0.000 0.58 0.420

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1  p2    p3   p4
#> SRR2936906     1   0.000      0.946 1.000 0.0 0.000 0.00
#> SRR2936909     1   0.000      0.946 1.000 0.0 0.000 0.00
#> SRR2936918     1   0.000      0.946 1.000 0.0 0.000 0.00
#> SRR2936917     2   0.000      0.986 0.000 1.0 0.000 0.00
#> SRR2936916     3   0.361      0.752 0.000 0.2 0.800 0.00
#> SRR2936915     3   0.361      0.752 0.000 0.2 0.800 0.00
#> SRR2936914     2   0.000      0.986 0.000 1.0 0.000 0.00
#> SRR2936913     2   0.000      0.986 0.000 1.0 0.000 0.00
#> SRR2936912     1   0.000      0.946 1.000 0.0 0.000 0.00
#> SRR2936910     1   0.000      0.946 1.000 0.0 0.000 0.00
#> SRR2936911     2   0.000      0.986 0.000 1.0 0.000 0.00
#> SRR2936907     2   0.000      0.986 0.000 1.0 0.000 0.00
#> SRR2936908     2   0.000      0.986 0.000 1.0 0.000 0.00
#> SRR2936904     3   0.485      0.584 0.000 0.4 0.600 0.00
#> SRR2936905     2   0.000      0.986 0.000 1.0 0.000 0.00
#> SRR2936903     4   0.000      0.991 0.000 0.0 0.000 1.00
#> SRR2936901     4   0.121      0.962 0.000 0.0 0.040 0.96
#> SRR2936902     3   0.000      0.757 0.000 0.0 1.000 0.00
#> SRR2936900     4   0.000      0.991 0.000 0.0 0.000 1.00
#> SRR2936898     3   0.000      0.757 0.000 0.0 1.000 0.00
#> SRR2936899     3   0.000      0.757 0.000 0.0 1.000 0.00
#> SRR2936897     1   0.488      0.255 0.592 0.0 0.408 0.00
#> SRR2936896     2   0.000      0.986 0.000 1.0 0.000 0.00
#> SRR2936894     1   0.000      0.946 1.000 0.0 0.000 0.00
#> SRR2936893     2   0.000      0.986 0.000 1.0 0.000 0.00
#> SRR2936895     3   0.485      0.584 0.000 0.4 0.600 0.00
#> SRR2936892     2   0.000      0.986 0.000 1.0 0.000 0.00
#> SRR2936891     1   0.000      0.946 1.000 0.0 0.000 0.00
#> SRR2936890     2   0.000      0.986 0.000 1.0 0.000 0.00
#> SRR2936886     3   0.485      0.584 0.000 0.4 0.600 0.00
#> SRR2936885     4   0.000      0.991 0.000 0.0 0.000 1.00
#> SRR2936888     1   0.000      0.946 1.000 0.0 0.000 0.00
#> SRR2936889     2   0.000      0.986 0.000 1.0 0.000 0.00
#> SRR2936887     3   0.485      0.584 0.000 0.4 0.600 0.00
#> SRR2936884     3   0.000      0.757 0.000 0.0 1.000 0.00
#> SRR2936883     3   0.000      0.757 0.000 0.0 1.000 0.00
#> SRR2936881     3   0.000      0.757 0.000 0.0 1.000 0.00
#> SRR2936882     4   0.000      0.991 0.000 0.0 0.000 1.00
#> SRR2936880     3   0.000      0.757 0.000 0.0 1.000 0.00
#> SRR2936878     2   0.000      0.986 0.000 1.0 0.000 0.00
#> SRR2936879     3   0.361      0.752 0.000 0.2 0.800 0.00
#> SRR2936875     2   0.000      0.986 0.000 1.0 0.000 0.00
#> SRR2936877     2   0.000      0.986 0.000 1.0 0.000 0.00
#> SRR2936876     3   0.000      0.757 0.000 0.0 1.000 0.00
#> SRR2936873     1   0.000      0.946 1.000 0.0 0.000 0.00
#> SRR2936872     2   0.000      0.986 0.000 1.0 0.000 0.00
#> SRR2936871     2   0.000      0.986 0.000 1.0 0.000 0.00
#> SRR2936874     2   0.000      0.986 0.000 1.0 0.000 0.00
#> SRR2936870     1   0.000      0.946 1.000 0.0 0.000 0.00
#> SRR2936869     2   0.361      0.661 0.000 0.8 0.200 0.00
#> SRR2936868     3   0.485      0.584 0.000 0.4 0.600 0.00

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4    p5
#> SRR2936906     1   0.000     0.9549 1.000 0.000 0.000 0.000 0.000
#> SRR2936909     1   0.120     0.9181 0.952 0.000 0.000 0.048 0.000
#> SRR2936918     1   0.000     0.9549 1.000 0.000 0.000 0.000 0.000
#> SRR2936917     2   0.000     1.0000 0.000 1.000 0.000 0.000 0.000
#> SRR2936916     4   0.000     0.5067 0.000 0.000 0.000 1.000 0.000
#> SRR2936915     4   0.000     0.5067 0.000 0.000 0.000 1.000 0.000
#> SRR2936914     2   0.000     1.0000 0.000 1.000 0.000 0.000 0.000
#> SRR2936913     2   0.000     1.0000 0.000 1.000 0.000 0.000 0.000
#> SRR2936912     1   0.000     0.9549 1.000 0.000 0.000 0.000 0.000
#> SRR2936910     1   0.000     0.9549 1.000 0.000 0.000 0.000 0.000
#> SRR2936911     2   0.000     1.0000 0.000 1.000 0.000 0.000 0.000
#> SRR2936907     2   0.000     1.0000 0.000 1.000 0.000 0.000 0.000
#> SRR2936908     2   0.000     1.0000 0.000 1.000 0.000 0.000 0.000
#> SRR2936904     4   0.281     0.6379 0.000 0.168 0.000 0.832 0.000
#> SRR2936905     2   0.000     1.0000 0.000 1.000 0.000 0.000 0.000
#> SRR2936903     5   0.000     0.8657 0.000 0.000 0.000 0.000 1.000
#> SRR2936901     5   0.431    -0.0254 0.000 0.000 0.492 0.000 0.508
#> SRR2936902     3   0.000     0.9344 0.000 0.000 1.000 0.000 0.000
#> SRR2936900     5   0.000     0.8657 0.000 0.000 0.000 0.000 1.000
#> SRR2936898     3   0.000     0.9344 0.000 0.000 1.000 0.000 0.000
#> SRR2936899     3   0.000     0.9344 0.000 0.000 1.000 0.000 0.000
#> SRR2936897     1   0.417     0.5089 0.604 0.000 0.000 0.396 0.000
#> SRR2936896     2   0.000     1.0000 0.000 1.000 0.000 0.000 0.000
#> SRR2936894     1   0.000     0.9549 1.000 0.000 0.000 0.000 0.000
#> SRR2936893     2   0.000     1.0000 0.000 1.000 0.000 0.000 0.000
#> SRR2936895     4   0.655     0.5447 0.000 0.384 0.200 0.416 0.000
#> SRR2936892     2   0.000     1.0000 0.000 1.000 0.000 0.000 0.000
#> SRR2936891     1   0.000     0.9549 1.000 0.000 0.000 0.000 0.000
#> SRR2936890     2   0.000     1.0000 0.000 1.000 0.000 0.000 0.000
#> SRR2936886     4   0.414     0.6615 0.000 0.384 0.000 0.616 0.000
#> SRR2936885     5   0.000     0.8657 0.000 0.000 0.000 0.000 1.000
#> SRR2936888     1   0.000     0.9549 1.000 0.000 0.000 0.000 0.000
#> SRR2936889     2   0.000     1.0000 0.000 1.000 0.000 0.000 0.000
#> SRR2936887     4   0.414     0.6615 0.000 0.384 0.000 0.616 0.000
#> SRR2936884     3   0.000     0.9344 0.000 0.000 1.000 0.000 0.000
#> SRR2936883     3   0.000     0.9344 0.000 0.000 1.000 0.000 0.000
#> SRR2936881     3   0.000     0.9344 0.000 0.000 1.000 0.000 0.000
#> SRR2936882     5   0.000     0.8657 0.000 0.000 0.000 0.000 1.000
#> SRR2936880     3   0.000     0.9344 0.000 0.000 1.000 0.000 0.000
#> SRR2936878     2   0.000     1.0000 0.000 1.000 0.000 0.000 0.000
#> SRR2936879     4   0.314     0.3203 0.000 0.000 0.204 0.796 0.000
#> SRR2936875     2   0.000     1.0000 0.000 1.000 0.000 0.000 0.000
#> SRR2936877     2   0.000     1.0000 0.000 1.000 0.000 0.000 0.000
#> SRR2936876     3   0.418     0.4674 0.000 0.000 0.600 0.400 0.000
#> SRR2936873     1   0.000     0.9549 1.000 0.000 0.000 0.000 0.000
#> SRR2936872     2   0.000     1.0000 0.000 1.000 0.000 0.000 0.000
#> SRR2936871     2   0.000     1.0000 0.000 1.000 0.000 0.000 0.000
#> SRR2936874     2   0.000     1.0000 0.000 1.000 0.000 0.000 0.000
#> SRR2936870     1   0.000     0.9549 1.000 0.000 0.000 0.000 0.000
#> SRR2936869     4   0.417     0.6444 0.000 0.396 0.000 0.604 0.000
#> SRR2936868     4   0.415     0.6569 0.000 0.388 0.000 0.612 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
#> SRR2936906     1  0.0000     0.8398 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936909     1  0.3123     0.8105 0.824 0.000 0.000 0.136 0.040 0.000
#> SRR2936918     1  0.0000     0.8398 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936917     2  0.0000     0.9453 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936916     5  0.0000     0.8767 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR2936915     5  0.0000     0.8767 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR2936914     2  0.0000     0.9453 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936913     2  0.0000     0.9453 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936912     1  0.3804     0.7067 0.576 0.000 0.000 0.424 0.000 0.000
#> SRR2936910     1  0.2260     0.8217 0.860 0.000 0.000 0.140 0.000 0.000
#> SRR2936911     2  0.0000     0.9453 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936907     2  0.0000     0.9453 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936908     2  0.0000     0.9453 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936904     5  0.3370     0.5893 0.000 0.148 0.000 0.048 0.804 0.000
#> SRR2936905     2  0.0000     0.9453 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936903     6  0.0000     0.8586 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR2936901     6  0.3868     0.0261 0.000 0.000 0.492 0.000 0.000 0.508
#> SRR2936902     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR2936900     6  0.0000     0.8586 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR2936898     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR2936899     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR2936897     5  0.2219     0.7914 0.000 0.000 0.000 0.136 0.864 0.000
#> SRR2936896     2  0.0000     0.9453 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936894     1  0.0000     0.8398 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936893     2  0.0000     0.9453 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936895     2  0.7308    -0.7615 0.000 0.352 0.200 0.328 0.120 0.000
#> SRR2936892     2  0.0000     0.9453 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936891     1  0.0000     0.8398 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936890     2  0.0000     0.9453 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936886     4  0.5353     0.9951 0.000 0.352 0.000 0.528 0.120 0.000
#> SRR2936885     6  0.0000     0.8586 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR2936888     1  0.3860     0.6800 0.528 0.000 0.000 0.472 0.000 0.000
#> SRR2936889     2  0.0000     0.9453 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936887     4  0.5353     0.9951 0.000 0.352 0.000 0.528 0.120 0.000
#> SRR2936884     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR2936883     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR2936881     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR2936882     6  0.0000     0.8586 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR2936880     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR2936878     2  0.0000     0.9453 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936879     5  0.0146     0.8755 0.000 0.000 0.000 0.004 0.996 0.000
#> SRR2936875     2  0.0000     0.9453 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936877     2  0.0000     0.9453 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936876     5  0.2003     0.7939 0.000 0.000 0.116 0.000 0.884 0.000
#> SRR2936873     1  0.0000     0.8398 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936872     2  0.0000     0.9453 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936871     2  0.0000     0.9453 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936874     2  0.0000     0.9453 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936870     1  0.3860     0.6800 0.528 0.000 0.000 0.472 0.000 0.000
#> SRR2936869     4  0.5329     0.9951 0.000 0.356 0.000 0.528 0.116 0.000
#> SRR2936868     4  0.5329     0.9951 0.000 0.356 0.000 0.528 0.116 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-pam-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-pam-collect-classes

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


CV:mclust*

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

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

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

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 14198 rows and 51 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 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-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.510           0.949       0.954        0.38089 0.633   0.633
#> 3 3 1.000           0.974       0.972        0.69779 0.718   0.554
#> 4 4 0.965           0.925       0.954        0.15892 0.890   0.687
#> 5 5 0.933           0.914       0.945        0.03491 0.973   0.886
#> 6 6 0.938           0.923       0.949        0.00892 0.940   0.760

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
#> SRR2936906     2   0.482      0.940 0.104 0.896
#> SRR2936909     2   0.482      0.940 0.104 0.896
#> SRR2936918     2   0.482      0.940 0.104 0.896
#> SRR2936917     2   0.000      0.935 0.000 1.000
#> SRR2936916     2   0.482      0.940 0.104 0.896
#> SRR2936915     2   0.482      0.940 0.104 0.896
#> SRR2936914     2   0.000      0.935 0.000 1.000
#> SRR2936913     2   0.000      0.935 0.000 1.000
#> SRR2936912     2   0.482      0.940 0.104 0.896
#> SRR2936910     2   0.482      0.940 0.104 0.896
#> SRR2936911     2   0.000      0.935 0.000 1.000
#> SRR2936907     2   0.000      0.935 0.000 1.000
#> SRR2936908     2   0.000      0.935 0.000 1.000
#> SRR2936904     2   0.482      0.940 0.104 0.896
#> SRR2936905     2   0.000      0.935 0.000 1.000
#> SRR2936903     1   0.000      1.000 1.000 0.000
#> SRR2936901     1   0.000      1.000 1.000 0.000
#> SRR2936902     1   0.000      1.000 1.000 0.000
#> SRR2936900     1   0.000      1.000 1.000 0.000
#> SRR2936898     1   0.000      1.000 1.000 0.000
#> SRR2936899     1   0.000      1.000 1.000 0.000
#> SRR2936897     2   0.482      0.940 0.104 0.896
#> SRR2936896     2   0.000      0.935 0.000 1.000
#> SRR2936894     2   0.482      0.940 0.104 0.896
#> SRR2936893     2   0.000      0.935 0.000 1.000
#> SRR2936895     2   0.814      0.770 0.252 0.748
#> SRR2936892     2   0.000      0.935 0.000 1.000
#> SRR2936891     2   0.482      0.940 0.104 0.896
#> SRR2936890     2   0.000      0.935 0.000 1.000
#> SRR2936886     2   0.482      0.940 0.104 0.896
#> SRR2936885     1   0.000      1.000 1.000 0.000
#> SRR2936888     2   0.482      0.940 0.104 0.896
#> SRR2936889     2   0.000      0.935 0.000 1.000
#> SRR2936887     2   0.482      0.940 0.104 0.896
#> SRR2936884     1   0.000      1.000 1.000 0.000
#> SRR2936883     1   0.000      1.000 1.000 0.000
#> SRR2936881     1   0.000      1.000 1.000 0.000
#> SRR2936882     1   0.000      1.000 1.000 0.000
#> SRR2936880     1   0.000      1.000 1.000 0.000
#> SRR2936878     2   0.000      0.935 0.000 1.000
#> SRR2936879     2   0.482      0.940 0.104 0.896
#> SRR2936875     2   0.000      0.935 0.000 1.000
#> SRR2936877     2   0.000      0.935 0.000 1.000
#> SRR2936876     2   0.482      0.940 0.104 0.896
#> SRR2936873     2   0.482      0.940 0.104 0.896
#> SRR2936872     2   0.000      0.935 0.000 1.000
#> SRR2936871     2   0.000      0.935 0.000 1.000
#> SRR2936874     2   0.000      0.935 0.000 1.000
#> SRR2936870     2   0.482      0.940 0.104 0.896
#> SRR2936869     2   0.482      0.940 0.104 0.896
#> SRR2936868     2   0.482      0.940 0.104 0.896

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR2936906     1  0.2651      0.972 0.928 0.012 0.060
#> SRR2936909     1  0.2651      0.972 0.928 0.012 0.060
#> SRR2936918     1  0.2651      0.972 0.928 0.012 0.060
#> SRR2936917     2  0.0000      0.986 0.000 1.000 0.000
#> SRR2936916     1  0.2651      0.972 0.928 0.012 0.060
#> SRR2936915     1  0.2301      0.970 0.936 0.004 0.060
#> SRR2936914     2  0.0237      0.983 0.004 0.996 0.000
#> SRR2936913     2  0.3816      0.849 0.148 0.852 0.000
#> SRR2936912     1  0.2301      0.970 0.936 0.004 0.060
#> SRR2936910     1  0.2301      0.970 0.936 0.004 0.060
#> SRR2936911     2  0.2066      0.942 0.060 0.940 0.000
#> SRR2936907     2  0.0000      0.986 0.000 1.000 0.000
#> SRR2936908     2  0.0000      0.986 0.000 1.000 0.000
#> SRR2936904     1  0.2651      0.972 0.928 0.012 0.060
#> SRR2936905     2  0.0000      0.986 0.000 1.000 0.000
#> SRR2936903     3  0.0000      1.000 0.000 0.000 1.000
#> SRR2936901     3  0.0000      1.000 0.000 0.000 1.000
#> SRR2936902     3  0.0000      1.000 0.000 0.000 1.000
#> SRR2936900     3  0.0000      1.000 0.000 0.000 1.000
#> SRR2936898     3  0.0000      1.000 0.000 0.000 1.000
#> SRR2936899     3  0.0000      1.000 0.000 0.000 1.000
#> SRR2936897     1  0.2651      0.972 0.928 0.012 0.060
#> SRR2936896     1  0.1031      0.941 0.976 0.024 0.000
#> SRR2936894     1  0.2651      0.972 0.928 0.012 0.060
#> SRR2936893     2  0.0000      0.986 0.000 1.000 0.000
#> SRR2936895     1  0.0424      0.949 0.992 0.008 0.000
#> SRR2936892     2  0.0000      0.986 0.000 1.000 0.000
#> SRR2936891     1  0.2651      0.972 0.928 0.012 0.060
#> SRR2936890     2  0.0000      0.986 0.000 1.000 0.000
#> SRR2936886     1  0.0237      0.948 0.996 0.000 0.004
#> SRR2936885     3  0.0000      1.000 0.000 0.000 1.000
#> SRR2936888     1  0.2165      0.968 0.936 0.000 0.064
#> SRR2936889     2  0.0000      0.986 0.000 1.000 0.000
#> SRR2936887     1  0.0237      0.948 0.996 0.000 0.004
#> SRR2936884     3  0.0000      1.000 0.000 0.000 1.000
#> SRR2936883     3  0.0000      1.000 0.000 0.000 1.000
#> SRR2936881     3  0.0000      1.000 0.000 0.000 1.000
#> SRR2936882     3  0.0000      1.000 0.000 0.000 1.000
#> SRR2936880     3  0.0000      1.000 0.000 0.000 1.000
#> SRR2936878     1  0.1411      0.937 0.964 0.036 0.000
#> SRR2936879     1  0.2651      0.972 0.928 0.012 0.060
#> SRR2936875     2  0.0000      0.986 0.000 1.000 0.000
#> SRR2936877     1  0.1289      0.936 0.968 0.032 0.000
#> SRR2936876     1  0.2301      0.970 0.936 0.004 0.060
#> SRR2936873     1  0.2651      0.972 0.928 0.012 0.060
#> SRR2936872     2  0.0000      0.986 0.000 1.000 0.000
#> SRR2936871     2  0.0000      0.986 0.000 1.000 0.000
#> SRR2936874     2  0.0000      0.986 0.000 1.000 0.000
#> SRR2936870     1  0.2165      0.968 0.936 0.000 0.064
#> SRR2936869     1  0.0237      0.948 0.996 0.000 0.004
#> SRR2936868     1  0.0237      0.948 0.996 0.000 0.004

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR2936906     1  0.0000      0.997 1.000 0.000 0.000 0.000
#> SRR2936909     1  0.0000      0.997 1.000 0.000 0.000 0.000
#> SRR2936918     1  0.0000      0.997 1.000 0.000 0.000 0.000
#> SRR2936917     2  0.0000      0.971 0.000 1.000 0.000 0.000
#> SRR2936916     1  0.0188      0.996 0.996 0.004 0.000 0.000
#> SRR2936915     1  0.0188      0.996 0.996 0.004 0.000 0.000
#> SRR2936914     2  0.0000      0.971 0.000 1.000 0.000 0.000
#> SRR2936913     2  0.4564      0.502 0.000 0.672 0.000 0.328
#> SRR2936912     1  0.0000      0.997 1.000 0.000 0.000 0.000
#> SRR2936910     1  0.0000      0.997 1.000 0.000 0.000 0.000
#> SRR2936911     2  0.1474      0.925 0.000 0.948 0.000 0.052
#> SRR2936907     2  0.0000      0.971 0.000 1.000 0.000 0.000
#> SRR2936908     2  0.0000      0.971 0.000 1.000 0.000 0.000
#> SRR2936904     1  0.0188      0.996 0.996 0.004 0.000 0.000
#> SRR2936905     2  0.0000      0.971 0.000 1.000 0.000 0.000
#> SRR2936903     3  0.0707      0.988 0.000 0.000 0.980 0.020
#> SRR2936901     3  0.0707      0.988 0.000 0.000 0.980 0.020
#> SRR2936902     3  0.0188      0.991 0.000 0.000 0.996 0.004
#> SRR2936900     3  0.0707      0.988 0.000 0.000 0.980 0.020
#> SRR2936898     3  0.0188      0.991 0.000 0.000 0.996 0.004
#> SRR2936899     3  0.0188      0.991 0.000 0.000 0.996 0.004
#> SRR2936897     1  0.0188      0.996 0.996 0.004 0.000 0.000
#> SRR2936896     4  0.5174      0.619 0.368 0.012 0.000 0.620
#> SRR2936894     1  0.0000      0.997 1.000 0.000 0.000 0.000
#> SRR2936893     2  0.0000      0.971 0.000 1.000 0.000 0.000
#> SRR2936895     4  0.4790      0.606 0.380 0.000 0.000 0.620
#> SRR2936892     2  0.0000      0.971 0.000 1.000 0.000 0.000
#> SRR2936891     1  0.0000      0.997 1.000 0.000 0.000 0.000
#> SRR2936890     2  0.0000      0.971 0.000 1.000 0.000 0.000
#> SRR2936886     4  0.0707      0.806 0.020 0.000 0.000 0.980
#> SRR2936885     3  0.0707      0.988 0.000 0.000 0.980 0.020
#> SRR2936888     4  0.2216      0.789 0.092 0.000 0.000 0.908
#> SRR2936889     2  0.0000      0.971 0.000 1.000 0.000 0.000
#> SRR2936887     4  0.0707      0.806 0.020 0.000 0.000 0.980
#> SRR2936884     3  0.0188      0.991 0.000 0.000 0.996 0.004
#> SRR2936883     3  0.0188      0.991 0.000 0.000 0.996 0.004
#> SRR2936881     3  0.0188      0.991 0.000 0.000 0.996 0.004
#> SRR2936882     3  0.0707      0.988 0.000 0.000 0.980 0.020
#> SRR2936880     3  0.0188      0.991 0.000 0.000 0.996 0.004
#> SRR2936878     4  0.5615      0.625 0.356 0.032 0.000 0.612
#> SRR2936879     1  0.0188      0.996 0.996 0.004 0.000 0.000
#> SRR2936875     2  0.0000      0.971 0.000 1.000 0.000 0.000
#> SRR2936877     4  0.5527      0.628 0.356 0.028 0.000 0.616
#> SRR2936876     1  0.0188      0.996 0.996 0.004 0.000 0.000
#> SRR2936873     1  0.0000      0.997 1.000 0.000 0.000 0.000
#> SRR2936872     2  0.0000      0.971 0.000 1.000 0.000 0.000
#> SRR2936871     2  0.0000      0.971 0.000 1.000 0.000 0.000
#> SRR2936874     2  0.0000      0.971 0.000 1.000 0.000 0.000
#> SRR2936870     4  0.2216      0.789 0.092 0.000 0.000 0.908
#> SRR2936869     4  0.0707      0.806 0.020 0.000 0.000 0.980
#> SRR2936868     4  0.0707      0.806 0.020 0.000 0.000 0.980

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4    p5
#> SRR2936906     1  0.0162      0.988 0.996 0.000 0.000 0.004 0.000
#> SRR2936909     1  0.0000      0.991 1.000 0.000 0.000 0.000 0.000
#> SRR2936918     1  0.0000      0.991 1.000 0.000 0.000 0.000 0.000
#> SRR2936917     2  0.0000      0.979 0.000 1.000 0.000 0.000 0.000
#> SRR2936916     1  0.0000      0.991 1.000 0.000 0.000 0.000 0.000
#> SRR2936915     1  0.0290      0.985 0.992 0.000 0.000 0.008 0.000
#> SRR2936914     2  0.0000      0.979 0.000 1.000 0.000 0.000 0.000
#> SRR2936913     2  0.3177      0.728 0.000 0.792 0.000 0.208 0.000
#> SRR2936912     1  0.0290      0.985 0.992 0.000 0.000 0.008 0.000
#> SRR2936910     1  0.0000      0.991 1.000 0.000 0.000 0.000 0.000
#> SRR2936911     2  0.1410      0.925 0.000 0.940 0.000 0.060 0.000
#> SRR2936907     2  0.0000      0.979 0.000 1.000 0.000 0.000 0.000
#> SRR2936908     2  0.0000      0.979 0.000 1.000 0.000 0.000 0.000
#> SRR2936904     1  0.0000      0.991 1.000 0.000 0.000 0.000 0.000
#> SRR2936905     2  0.0000      0.979 0.000 1.000 0.000 0.000 0.000
#> SRR2936903     5  0.1732      1.000 0.000 0.000 0.080 0.000 0.920
#> SRR2936901     5  0.1732      1.000 0.000 0.000 0.080 0.000 0.920
#> SRR2936902     3  0.1608      0.915 0.000 0.000 0.928 0.000 0.072
#> SRR2936900     5  0.1732      1.000 0.000 0.000 0.080 0.000 0.920
#> SRR2936898     3  0.0000      0.987 0.000 0.000 1.000 0.000 0.000
#> SRR2936899     3  0.0000      0.987 0.000 0.000 1.000 0.000 0.000
#> SRR2936897     1  0.0000      0.991 1.000 0.000 0.000 0.000 0.000
#> SRR2936896     4  0.5509      0.569 0.360 0.076 0.000 0.564 0.000
#> SRR2936894     1  0.0000      0.991 1.000 0.000 0.000 0.000 0.000
#> SRR2936893     2  0.0000      0.979 0.000 1.000 0.000 0.000 0.000
#> SRR2936895     4  0.4060      0.572 0.360 0.000 0.000 0.640 0.000
#> SRR2936892     2  0.0000      0.979 0.000 1.000 0.000 0.000 0.000
#> SRR2936891     1  0.0000      0.991 1.000 0.000 0.000 0.000 0.000
#> SRR2936890     2  0.0000      0.979 0.000 1.000 0.000 0.000 0.000
#> SRR2936886     4  0.0000      0.732 0.000 0.000 0.000 1.000 0.000
#> SRR2936885     5  0.1732      1.000 0.000 0.000 0.080 0.000 0.920
#> SRR2936888     4  0.3239      0.704 0.068 0.000 0.000 0.852 0.080
#> SRR2936889     2  0.0000      0.979 0.000 1.000 0.000 0.000 0.000
#> SRR2936887     4  0.0000      0.732 0.000 0.000 0.000 1.000 0.000
#> SRR2936884     3  0.0000      0.987 0.000 0.000 1.000 0.000 0.000
#> SRR2936883     3  0.0000      0.987 0.000 0.000 1.000 0.000 0.000
#> SRR2936881     3  0.0000      0.987 0.000 0.000 1.000 0.000 0.000
#> SRR2936882     5  0.1732      1.000 0.000 0.000 0.080 0.000 0.920
#> SRR2936880     3  0.0000      0.987 0.000 0.000 1.000 0.000 0.000
#> SRR2936878     4  0.5583      0.577 0.352 0.084 0.000 0.564 0.000
#> SRR2936879     1  0.1608      0.898 0.928 0.000 0.000 0.072 0.000
#> SRR2936875     2  0.0000      0.979 0.000 1.000 0.000 0.000 0.000
#> SRR2936877     4  0.5583      0.577 0.352 0.084 0.000 0.564 0.000
#> SRR2936876     1  0.0000      0.991 1.000 0.000 0.000 0.000 0.000
#> SRR2936873     1  0.0000      0.991 1.000 0.000 0.000 0.000 0.000
#> SRR2936872     2  0.0000      0.979 0.000 1.000 0.000 0.000 0.000
#> SRR2936871     2  0.0000      0.979 0.000 1.000 0.000 0.000 0.000
#> SRR2936874     2  0.0000      0.979 0.000 1.000 0.000 0.000 0.000
#> SRR2936870     4  0.3239      0.704 0.068 0.000 0.000 0.852 0.080
#> SRR2936869     4  0.0000      0.732 0.000 0.000 0.000 1.000 0.000
#> SRR2936868     4  0.0000      0.732 0.000 0.000 0.000 1.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
#> SRR2936906     1  0.1267      0.916 0.940 0.000 0.000 0.000 0.060 0.000
#> SRR2936909     1  0.0713      0.921 0.972 0.000 0.000 0.000 0.028 0.000
#> SRR2936918     1  0.0790      0.919 0.968 0.000 0.000 0.000 0.032 0.000
#> SRR2936917     2  0.0000      0.960 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936916     1  0.1863      0.885 0.896 0.000 0.000 0.000 0.104 0.000
#> SRR2936915     1  0.1863      0.885 0.896 0.000 0.000 0.000 0.104 0.000
#> SRR2936914     2  0.0000      0.960 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936913     2  0.1610      0.906 0.000 0.916 0.000 0.084 0.000 0.000
#> SRR2936912     1  0.0790      0.919 0.968 0.000 0.000 0.000 0.032 0.000
#> SRR2936910     1  0.0713      0.920 0.972 0.000 0.000 0.000 0.028 0.000
#> SRR2936911     2  0.1267      0.924 0.000 0.940 0.000 0.060 0.000 0.000
#> SRR2936907     2  0.0000      0.960 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936908     2  0.0000      0.960 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936904     1  0.1863      0.885 0.896 0.000 0.000 0.000 0.104 0.000
#> SRR2936905     2  0.0000      0.960 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936903     6  0.0000      0.999 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR2936901     6  0.0146      0.995 0.000 0.000 0.004 0.000 0.000 0.996
#> SRR2936902     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR2936900     6  0.0000      0.999 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR2936898     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR2936899     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR2936897     1  0.1610      0.894 0.916 0.000 0.000 0.000 0.084 0.000
#> SRR2936896     2  0.4523      0.742 0.048 0.756 0.000 0.084 0.112 0.000
#> SRR2936894     1  0.1267      0.916 0.940 0.000 0.000 0.000 0.060 0.000
#> SRR2936893     2  0.0000      0.960 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936895     4  0.5574      0.438 0.048 0.164 0.000 0.648 0.140 0.000
#> SRR2936892     2  0.0000      0.960 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936891     1  0.1267      0.916 0.940 0.000 0.000 0.000 0.060 0.000
#> SRR2936890     2  0.0000      0.960 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936886     4  0.0000      0.851 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR2936885     6  0.0000      0.999 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR2936888     5  0.2793      1.000 0.000 0.000 0.000 0.200 0.800 0.000
#> SRR2936889     2  0.0000      0.960 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936887     4  0.0000      0.851 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR2936884     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR2936883     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR2936881     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR2936882     6  0.0000      0.999 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR2936880     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR2936878     2  0.3059      0.861 0.020 0.856 0.000 0.084 0.040 0.000
#> SRR2936879     1  0.4599      0.632 0.696 0.164 0.000 0.000 0.140 0.000
#> SRR2936875     2  0.0000      0.960 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936877     2  0.3059      0.861 0.020 0.856 0.000 0.084 0.040 0.000
#> SRR2936876     1  0.0937      0.920 0.960 0.000 0.000 0.000 0.040 0.000
#> SRR2936873     1  0.0713      0.921 0.972 0.000 0.000 0.000 0.028 0.000
#> SRR2936872     2  0.0000      0.960 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936871     2  0.0000      0.960 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936874     2  0.0000      0.960 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936870     5  0.2793      1.000 0.000 0.000 0.000 0.200 0.800 0.000
#> SRR2936869     4  0.0000      0.851 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR2936868     4  0.0000      0.851 0.000 0.000 0.000 1.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-mclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-mclust-collect-classes

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


CV:NMF**

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

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

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

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 14198 rows and 51 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 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-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.997       0.999         0.4232 0.576   0.576
#> 3 3 0.918           0.909       0.962         0.5867 0.753   0.571
#> 4 4 0.998           0.951       0.976         0.1336 0.852   0.585
#> 5 5 0.871           0.818       0.905         0.0454 0.950   0.793
#> 6 6 0.896           0.749       0.882         0.0307 0.979   0.895

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette    p1    p2
#> SRR2936906     2  0.0000      1.000 0.000 1.000
#> SRR2936909     2  0.0000      1.000 0.000 1.000
#> SRR2936918     2  0.0000      1.000 0.000 1.000
#> SRR2936917     2  0.0000      1.000 0.000 1.000
#> SRR2936916     2  0.0000      1.000 0.000 1.000
#> SRR2936915     2  0.0000      1.000 0.000 1.000
#> SRR2936914     2  0.0000      1.000 0.000 1.000
#> SRR2936913     2  0.0000      1.000 0.000 1.000
#> SRR2936912     2  0.0000      1.000 0.000 1.000
#> SRR2936910     2  0.0000      1.000 0.000 1.000
#> SRR2936911     2  0.0000      1.000 0.000 1.000
#> SRR2936907     2  0.0000      1.000 0.000 1.000
#> SRR2936908     2  0.0000      1.000 0.000 1.000
#> SRR2936904     2  0.0000      1.000 0.000 1.000
#> SRR2936905     2  0.0000      1.000 0.000 1.000
#> SRR2936903     1  0.0000      0.995 1.000 0.000
#> SRR2936901     1  0.0000      0.995 1.000 0.000
#> SRR2936902     1  0.0000      0.995 1.000 0.000
#> SRR2936900     1  0.0000      0.995 1.000 0.000
#> SRR2936898     1  0.0000      0.995 1.000 0.000
#> SRR2936899     1  0.0000      0.995 1.000 0.000
#> SRR2936897     2  0.0000      1.000 0.000 1.000
#> SRR2936896     1  0.3431      0.932 0.936 0.064
#> SRR2936894     2  0.0000      1.000 0.000 1.000
#> SRR2936893     2  0.0000      1.000 0.000 1.000
#> SRR2936895     2  0.0938      0.988 0.012 0.988
#> SRR2936892     2  0.0000      1.000 0.000 1.000
#> SRR2936891     2  0.0000      1.000 0.000 1.000
#> SRR2936890     2  0.0000      1.000 0.000 1.000
#> SRR2936886     2  0.0000      1.000 0.000 1.000
#> SRR2936885     1  0.0000      0.995 1.000 0.000
#> SRR2936888     2  0.0000      1.000 0.000 1.000
#> SRR2936889     2  0.0000      1.000 0.000 1.000
#> SRR2936887     2  0.0000      1.000 0.000 1.000
#> SRR2936884     1  0.0000      0.995 1.000 0.000
#> SRR2936883     1  0.0000      0.995 1.000 0.000
#> SRR2936881     1  0.0000      0.995 1.000 0.000
#> SRR2936882     1  0.0000      0.995 1.000 0.000
#> SRR2936880     1  0.0000      0.995 1.000 0.000
#> SRR2936878     1  0.0000      0.995 1.000 0.000
#> SRR2936879     2  0.0000      1.000 0.000 1.000
#> SRR2936875     2  0.0000      1.000 0.000 1.000
#> SRR2936877     1  0.0000      0.995 1.000 0.000
#> SRR2936876     2  0.0000      1.000 0.000 1.000
#> SRR2936873     2  0.0000      1.000 0.000 1.000
#> SRR2936872     2  0.0000      1.000 0.000 1.000
#> SRR2936871     2  0.0000      1.000 0.000 1.000
#> SRR2936874     2  0.0000      1.000 0.000 1.000
#> SRR2936870     2  0.0000      1.000 0.000 1.000
#> SRR2936869     2  0.0000      1.000 0.000 1.000
#> SRR2936868     2  0.0000      1.000 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR2936906     1  0.0237      0.933 0.996 0.004 0.000
#> SRR2936909     1  0.0237      0.933 0.996 0.004 0.000
#> SRR2936918     1  0.0237      0.933 0.996 0.004 0.000
#> SRR2936917     1  0.5591      0.584 0.696 0.304 0.000
#> SRR2936916     1  0.0237      0.933 0.996 0.004 0.000
#> SRR2936915     1  0.0237      0.933 0.996 0.004 0.000
#> SRR2936914     2  0.0424      0.948 0.008 0.992 0.000
#> SRR2936913     1  0.1411      0.908 0.964 0.036 0.000
#> SRR2936912     1  0.0237      0.933 0.996 0.004 0.000
#> SRR2936910     1  0.0237      0.933 0.996 0.004 0.000
#> SRR2936911     1  0.5327      0.635 0.728 0.272 0.000
#> SRR2936907     2  0.0000      0.953 0.000 1.000 0.000
#> SRR2936908     2  0.0000      0.953 0.000 1.000 0.000
#> SRR2936904     2  0.0000      0.953 0.000 1.000 0.000
#> SRR2936905     2  0.0000      0.953 0.000 1.000 0.000
#> SRR2936903     3  0.0000      0.994 0.000 0.000 1.000
#> SRR2936901     3  0.0000      0.994 0.000 0.000 1.000
#> SRR2936902     3  0.0000      0.994 0.000 0.000 1.000
#> SRR2936900     3  0.0000      0.994 0.000 0.000 1.000
#> SRR2936898     3  0.0000      0.994 0.000 0.000 1.000
#> SRR2936899     3  0.0000      0.994 0.000 0.000 1.000
#> SRR2936897     1  0.0237      0.933 0.996 0.004 0.000
#> SRR2936896     3  0.2537      0.910 0.080 0.000 0.920
#> SRR2936894     1  0.0237      0.933 0.996 0.004 0.000
#> SRR2936893     2  0.0000      0.953 0.000 1.000 0.000
#> SRR2936895     1  0.0424      0.927 0.992 0.000 0.008
#> SRR2936892     2  0.0000      0.953 0.000 1.000 0.000
#> SRR2936891     1  0.0237      0.933 0.996 0.004 0.000
#> SRR2936890     2  0.0000      0.953 0.000 1.000 0.000
#> SRR2936886     1  0.5138      0.649 0.748 0.252 0.000
#> SRR2936885     3  0.0000      0.994 0.000 0.000 1.000
#> SRR2936888     1  0.0000      0.931 1.000 0.000 0.000
#> SRR2936889     2  0.0000      0.953 0.000 1.000 0.000
#> SRR2936887     1  0.5859      0.469 0.656 0.344 0.000
#> SRR2936884     3  0.0000      0.994 0.000 0.000 1.000
#> SRR2936883     3  0.0000      0.994 0.000 0.000 1.000
#> SRR2936881     3  0.0000      0.994 0.000 0.000 1.000
#> SRR2936882     3  0.0000      0.994 0.000 0.000 1.000
#> SRR2936880     3  0.0000      0.994 0.000 0.000 1.000
#> SRR2936878     3  0.0237      0.990 0.000 0.004 0.996
#> SRR2936879     1  0.0237      0.933 0.996 0.004 0.000
#> SRR2936875     2  0.0000      0.953 0.000 1.000 0.000
#> SRR2936877     3  0.0000      0.994 0.000 0.000 1.000
#> SRR2936876     1  0.0237      0.933 0.996 0.004 0.000
#> SRR2936873     1  0.0237      0.933 0.996 0.004 0.000
#> SRR2936872     2  0.0000      0.953 0.000 1.000 0.000
#> SRR2936871     2  0.0000      0.953 0.000 1.000 0.000
#> SRR2936874     2  0.0000      0.953 0.000 1.000 0.000
#> SRR2936870     1  0.0000      0.931 1.000 0.000 0.000
#> SRR2936869     2  0.4235      0.761 0.176 0.824 0.000
#> SRR2936868     2  0.6204      0.220 0.424 0.576 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR2936906     1  0.0000      0.996 1.000 0.000 0.000 0.000
#> SRR2936909     1  0.0000      0.996 1.000 0.000 0.000 0.000
#> SRR2936918     1  0.0188      0.996 0.996 0.000 0.000 0.004
#> SRR2936917     4  0.7202      0.203 0.396 0.140 0.000 0.464
#> SRR2936916     1  0.0336      0.995 0.992 0.000 0.000 0.008
#> SRR2936915     1  0.0336      0.995 0.992 0.000 0.000 0.008
#> SRR2936914     4  0.0817      0.890 0.000 0.024 0.000 0.976
#> SRR2936913     4  0.0376      0.899 0.004 0.004 0.000 0.992
#> SRR2936912     1  0.0336      0.995 0.992 0.000 0.000 0.008
#> SRR2936910     1  0.0336      0.995 0.992 0.000 0.000 0.008
#> SRR2936911     4  0.0376      0.899 0.004 0.004 0.000 0.992
#> SRR2936907     2  0.0188      0.998 0.000 0.996 0.000 0.004
#> SRR2936908     2  0.0188      0.998 0.000 0.996 0.000 0.004
#> SRR2936904     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> SRR2936905     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> SRR2936903     3  0.0000      0.999 0.000 0.000 1.000 0.000
#> SRR2936901     3  0.0000      0.999 0.000 0.000 1.000 0.000
#> SRR2936902     3  0.0000      0.999 0.000 0.000 1.000 0.000
#> SRR2936900     3  0.0000      0.999 0.000 0.000 1.000 0.000
#> SRR2936898     3  0.0000      0.999 0.000 0.000 1.000 0.000
#> SRR2936899     3  0.0000      0.999 0.000 0.000 1.000 0.000
#> SRR2936897     1  0.0188      0.996 0.996 0.000 0.000 0.004
#> SRR2936896     4  0.4454      0.549 0.000 0.000 0.308 0.692
#> SRR2936894     1  0.0188      0.996 0.996 0.000 0.000 0.004
#> SRR2936893     2  0.0188      0.998 0.000 0.996 0.000 0.004
#> SRR2936895     4  0.2345      0.855 0.100 0.000 0.000 0.900
#> SRR2936892     2  0.0188      0.998 0.000 0.996 0.000 0.004
#> SRR2936891     1  0.0000      0.996 1.000 0.000 0.000 0.000
#> SRR2936890     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> SRR2936886     4  0.0188      0.899 0.004 0.000 0.000 0.996
#> SRR2936885     3  0.0000      0.999 0.000 0.000 1.000 0.000
#> SRR2936888     4  0.2149      0.865 0.088 0.000 0.000 0.912
#> SRR2936889     2  0.0188      0.998 0.000 0.996 0.000 0.004
#> SRR2936887     4  0.0188      0.899 0.000 0.004 0.000 0.996
#> SRR2936884     3  0.0000      0.999 0.000 0.000 1.000 0.000
#> SRR2936883     3  0.0000      0.999 0.000 0.000 1.000 0.000
#> SRR2936881     3  0.0000      0.999 0.000 0.000 1.000 0.000
#> SRR2936882     3  0.0000      0.999 0.000 0.000 1.000 0.000
#> SRR2936880     3  0.0000      0.999 0.000 0.000 1.000 0.000
#> SRR2936878     3  0.0336      0.991 0.000 0.008 0.992 0.000
#> SRR2936879     1  0.0000      0.996 1.000 0.000 0.000 0.000
#> SRR2936875     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> SRR2936877     3  0.0000      0.999 0.000 0.000 1.000 0.000
#> SRR2936876     1  0.0188      0.994 0.996 0.000 0.000 0.004
#> SRR2936873     1  0.0000      0.996 1.000 0.000 0.000 0.000
#> SRR2936872     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> SRR2936871     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> SRR2936874     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> SRR2936870     4  0.2011      0.870 0.080 0.000 0.000 0.920
#> SRR2936869     4  0.0336      0.898 0.000 0.008 0.000 0.992
#> SRR2936868     4  0.0188      0.899 0.000 0.004 0.000 0.996

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4    p5
#> SRR2936906     1  0.0609    0.92894 0.980 0.000 0.000 0.000 0.020
#> SRR2936909     1  0.0162    0.93138 0.996 0.000 0.000 0.000 0.004
#> SRR2936918     1  0.2280    0.87281 0.880 0.000 0.000 0.000 0.120
#> SRR2936917     5  0.7279    0.23003 0.096 0.148 0.000 0.216 0.540
#> SRR2936916     1  0.3612    0.74431 0.764 0.000 0.000 0.008 0.228
#> SRR2936915     1  0.2230    0.87327 0.884 0.000 0.000 0.000 0.116
#> SRR2936914     4  0.5492    0.07127 0.000 0.064 0.000 0.504 0.432
#> SRR2936913     4  0.4206    0.49219 0.000 0.016 0.000 0.696 0.288
#> SRR2936912     1  0.0162    0.93056 0.996 0.000 0.000 0.000 0.004
#> SRR2936910     1  0.0000    0.93110 1.000 0.000 0.000 0.000 0.000
#> SRR2936911     5  0.5083    0.00719 0.004 0.028 0.000 0.428 0.540
#> SRR2936907     2  0.0404    0.98012 0.000 0.988 0.000 0.000 0.012
#> SRR2936908     2  0.0000    0.98453 0.000 1.000 0.000 0.000 0.000
#> SRR2936904     2  0.2536    0.87380 0.004 0.868 0.000 0.000 0.128
#> SRR2936905     2  0.0000    0.98453 0.000 1.000 0.000 0.000 0.000
#> SRR2936903     3  0.0290    0.95392 0.000 0.000 0.992 0.000 0.008
#> SRR2936901     3  0.0000    0.95590 0.000 0.000 1.000 0.000 0.000
#> SRR2936902     3  0.0000    0.95590 0.000 0.000 1.000 0.000 0.000
#> SRR2936900     3  0.0963    0.93714 0.000 0.000 0.964 0.000 0.036
#> SRR2936898     3  0.3274    0.67213 0.000 0.000 0.780 0.000 0.220
#> SRR2936899     3  0.1544    0.90200 0.000 0.000 0.932 0.000 0.068
#> SRR2936897     1  0.0703    0.92291 0.976 0.000 0.000 0.000 0.024
#> SRR2936896     5  0.6628    0.55230 0.040 0.004 0.208 0.148 0.600
#> SRR2936894     1  0.0162    0.93149 0.996 0.000 0.000 0.000 0.004
#> SRR2936893     2  0.0162    0.98418 0.000 0.996 0.000 0.000 0.004
#> SRR2936895     5  0.6256    0.35522 0.188 0.000 0.004 0.248 0.560
#> SRR2936892     2  0.0000    0.98453 0.000 1.000 0.000 0.000 0.000
#> SRR2936891     1  0.0404    0.93082 0.988 0.000 0.000 0.000 0.012
#> SRR2936890     2  0.0290    0.98273 0.000 0.992 0.000 0.000 0.008
#> SRR2936886     4  0.0000    0.83033 0.000 0.000 0.000 1.000 0.000
#> SRR2936885     3  0.0510    0.95062 0.000 0.000 0.984 0.000 0.016
#> SRR2936888     4  0.1557    0.79233 0.052 0.000 0.000 0.940 0.008
#> SRR2936889     2  0.0290    0.98273 0.000 0.992 0.000 0.000 0.008
#> SRR2936887     4  0.0000    0.83033 0.000 0.000 0.000 1.000 0.000
#> SRR2936884     3  0.0000    0.95590 0.000 0.000 1.000 0.000 0.000
#> SRR2936883     3  0.0000    0.95590 0.000 0.000 1.000 0.000 0.000
#> SRR2936881     3  0.0510    0.94942 0.000 0.000 0.984 0.000 0.016
#> SRR2936882     3  0.0794    0.94323 0.000 0.000 0.972 0.000 0.028
#> SRR2936880     3  0.0404    0.95156 0.000 0.000 0.988 0.000 0.012
#> SRR2936878     5  0.4674    0.50967 0.000 0.024 0.316 0.004 0.656
#> SRR2936879     1  0.3561    0.63639 0.740 0.000 0.000 0.000 0.260
#> SRR2936875     2  0.0290    0.98058 0.000 0.992 0.000 0.000 0.008
#> SRR2936877     5  0.4219    0.32735 0.000 0.000 0.416 0.000 0.584
#> SRR2936876     1  0.0510    0.92761 0.984 0.000 0.000 0.000 0.016
#> SRR2936873     1  0.0290    0.93110 0.992 0.000 0.000 0.000 0.008
#> SRR2936872     2  0.0162    0.98418 0.000 0.996 0.000 0.000 0.004
#> SRR2936871     2  0.0000    0.98453 0.000 1.000 0.000 0.000 0.000
#> SRR2936874     2  0.0290    0.98058 0.000 0.992 0.000 0.000 0.008
#> SRR2936870     4  0.1408    0.79981 0.044 0.000 0.000 0.948 0.008
#> SRR2936869     4  0.0000    0.83033 0.000 0.000 0.000 1.000 0.000
#> SRR2936868     4  0.0000    0.83033 0.000 0.000 0.000 1.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
#> SRR2936906     1  0.0622     0.8713 0.980 0.000 0.000 0.000 0.012 0.008
#> SRR2936909     1  0.0146     0.8761 0.996 0.000 0.000 0.000 0.004 0.000
#> SRR2936918     1  0.2431     0.7787 0.860 0.000 0.000 0.000 0.008 0.132
#> SRR2936917     6  0.6386     0.3416 0.016 0.100 0.000 0.064 0.256 0.564
#> SRR2936916     6  0.5020    -0.0145 0.436 0.000 0.000 0.004 0.060 0.500
#> SRR2936915     1  0.3802     0.4684 0.676 0.000 0.000 0.000 0.012 0.312
#> SRR2936914     6  0.6860     0.2512 0.000 0.064 0.000 0.220 0.284 0.432
#> SRR2936913     4  0.6349    -0.3631 0.000 0.024 0.000 0.400 0.188 0.388
#> SRR2936912     1  0.0891     0.8721 0.968 0.000 0.000 0.000 0.024 0.008
#> SRR2936910     1  0.0622     0.8757 0.980 0.000 0.000 0.000 0.012 0.008
#> SRR2936911     5  0.6627    -0.2415 0.004 0.036 0.000 0.216 0.460 0.284
#> SRR2936907     2  0.0260     0.9494 0.000 0.992 0.000 0.000 0.000 0.008
#> SRR2936908     2  0.0000     0.9539 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936904     2  0.4693     0.3971 0.012 0.532 0.000 0.000 0.024 0.432
#> SRR2936905     2  0.0146     0.9530 0.000 0.996 0.000 0.000 0.000 0.004
#> SRR2936903     3  0.0260     0.9290 0.000 0.000 0.992 0.000 0.008 0.000
#> SRR2936901     3  0.0000     0.9306 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR2936902     3  0.0508     0.9314 0.000 0.000 0.984 0.000 0.012 0.004
#> SRR2936900     3  0.0603     0.9250 0.000 0.000 0.980 0.000 0.016 0.004
#> SRR2936898     3  0.3817     0.2451 0.000 0.000 0.568 0.000 0.432 0.000
#> SRR2936899     3  0.1910     0.8603 0.000 0.000 0.892 0.000 0.108 0.000
#> SRR2936897     1  0.1829     0.8416 0.920 0.000 0.000 0.000 0.056 0.024
#> SRR2936896     5  0.2434     0.7173 0.032 0.000 0.056 0.016 0.896 0.000
#> SRR2936894     1  0.0291     0.8762 0.992 0.000 0.000 0.000 0.004 0.004
#> SRR2936893     2  0.0000     0.9539 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936895     5  0.2608     0.6595 0.080 0.000 0.000 0.048 0.872 0.000
#> SRR2936892     2  0.0000     0.9539 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936891     1  0.0520     0.8738 0.984 0.000 0.000 0.000 0.008 0.008
#> SRR2936890     2  0.0146     0.9522 0.000 0.996 0.000 0.000 0.000 0.004
#> SRR2936886     4  0.0000     0.8536 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR2936885     3  0.0508     0.9268 0.000 0.000 0.984 0.000 0.012 0.004
#> SRR2936888     4  0.1924     0.8022 0.048 0.000 0.000 0.920 0.004 0.028
#> SRR2936889     2  0.0000     0.9539 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936887     4  0.0000     0.8536 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR2936884     3  0.0692     0.9302 0.000 0.000 0.976 0.000 0.020 0.004
#> SRR2936883     3  0.0603     0.9310 0.000 0.000 0.980 0.000 0.016 0.004
#> SRR2936881     3  0.0790     0.9263 0.000 0.000 0.968 0.000 0.032 0.000
#> SRR2936882     3  0.0603     0.9250 0.000 0.000 0.980 0.000 0.016 0.004
#> SRR2936880     3  0.0790     0.9263 0.000 0.000 0.968 0.000 0.032 0.000
#> SRR2936878     5  0.3228     0.6830 0.004 0.012 0.080 0.000 0.848 0.056
#> SRR2936879     1  0.4646     0.0897 0.500 0.000 0.000 0.000 0.460 0.040
#> SRR2936875     2  0.0603     0.9427 0.004 0.980 0.000 0.000 0.000 0.016
#> SRR2936877     5  0.2346     0.6895 0.008 0.000 0.124 0.000 0.868 0.000
#> SRR2936876     1  0.1138     0.8646 0.960 0.004 0.000 0.000 0.024 0.012
#> SRR2936873     1  0.0000     0.8757 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936872     2  0.0000     0.9539 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936871     2  0.0146     0.9527 0.000 0.996 0.000 0.000 0.000 0.004
#> SRR2936874     2  0.0692     0.9401 0.004 0.976 0.000 0.000 0.000 0.020
#> SRR2936870     4  0.1401     0.8298 0.020 0.000 0.000 0.948 0.004 0.028
#> SRR2936869     4  0.0260     0.8501 0.000 0.000 0.000 0.992 0.000 0.008
#> SRR2936868     4  0.0000     0.8536 0.000 0.000 0.000 1.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-NMF-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-NMF-collect-classes

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


MAD:hclust

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

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

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

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

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

collect_plots(res)

plot of chunk MAD-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.624           0.915       0.941         0.4885 0.492   0.492
#> 3 3 0.838           0.924       0.961         0.3447 0.859   0.713
#> 4 4 0.787           0.829       0.850         0.1139 0.915   0.758
#> 5 5 0.790           0.784       0.755         0.0543 0.973   0.897
#> 6 6 0.821           0.786       0.820         0.0409 0.938   0.745

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
#> SRR2936906     1  0.0000      0.877 1.000 0.000
#> SRR2936909     1  0.0000      0.877 1.000 0.000
#> SRR2936918     1  0.0000      0.877 1.000 0.000
#> SRR2936917     2  0.0000      0.996 0.000 1.000
#> SRR2936916     1  0.8144      0.801 0.748 0.252
#> SRR2936915     1  0.8144      0.801 0.748 0.252
#> SRR2936914     2  0.0000      0.996 0.000 1.000
#> SRR2936913     2  0.0000      0.996 0.000 1.000
#> SRR2936912     1  0.0000      0.877 1.000 0.000
#> SRR2936910     1  0.0000      0.877 1.000 0.000
#> SRR2936911     2  0.0000      0.996 0.000 1.000
#> SRR2936907     2  0.0000      0.996 0.000 1.000
#> SRR2936908     2  0.0000      0.996 0.000 1.000
#> SRR2936904     1  0.8144      0.801 0.748 0.252
#> SRR2936905     2  0.0000      0.996 0.000 1.000
#> SRR2936903     1  0.0000      0.877 1.000 0.000
#> SRR2936901     1  0.8144      0.801 0.748 0.252
#> SRR2936902     2  0.0938      0.989 0.012 0.988
#> SRR2936900     1  0.0000      0.877 1.000 0.000
#> SRR2936898     1  0.8144      0.801 0.748 0.252
#> SRR2936899     1  0.8144      0.801 0.748 0.252
#> SRR2936897     1  0.0000      0.877 1.000 0.000
#> SRR2936896     2  0.0000      0.996 0.000 1.000
#> SRR2936894     1  0.0000      0.877 1.000 0.000
#> SRR2936893     2  0.0000      0.996 0.000 1.000
#> SRR2936895     2  0.0938      0.989 0.012 0.988
#> SRR2936892     2  0.0000      0.996 0.000 1.000
#> SRR2936891     1  0.0000      0.877 1.000 0.000
#> SRR2936890     2  0.0000      0.996 0.000 1.000
#> SRR2936886     1  0.8144      0.801 0.748 0.252
#> SRR2936885     1  0.0000      0.877 1.000 0.000
#> SRR2936888     1  0.0000      0.877 1.000 0.000
#> SRR2936889     2  0.0000      0.996 0.000 1.000
#> SRR2936887     1  0.8144      0.801 0.748 0.252
#> SRR2936884     2  0.0938      0.989 0.012 0.988
#> SRR2936883     2  0.0938      0.989 0.012 0.988
#> SRR2936881     2  0.0938      0.989 0.012 0.988
#> SRR2936882     1  0.0000      0.877 1.000 0.000
#> SRR2936880     2  0.0938      0.989 0.012 0.988
#> SRR2936878     2  0.0000      0.996 0.000 1.000
#> SRR2936879     1  0.8144      0.801 0.748 0.252
#> SRR2936875     2  0.0000      0.996 0.000 1.000
#> SRR2936877     2  0.0000      0.996 0.000 1.000
#> SRR2936876     1  0.6048      0.840 0.852 0.148
#> SRR2936873     1  0.0000      0.877 1.000 0.000
#> SRR2936872     2  0.0000      0.996 0.000 1.000
#> SRR2936871     2  0.0000      0.996 0.000 1.000
#> SRR2936874     2  0.0000      0.996 0.000 1.000
#> SRR2936870     1  0.0000      0.877 1.000 0.000
#> SRR2936869     1  0.8144      0.801 0.748 0.252
#> SRR2936868     1  0.8144      0.801 0.748 0.252

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR2936906     1   0.000      0.983 1.000 0.000 0.000
#> SRR2936909     1   0.245      0.928 0.924 0.000 0.076
#> SRR2936918     1   0.000      0.983 1.000 0.000 0.000
#> SRR2936917     2   0.000      0.926 0.000 1.000 0.000
#> SRR2936916     3   0.000      0.981 0.000 0.000 1.000
#> SRR2936915     3   0.000      0.981 0.000 0.000 1.000
#> SRR2936914     2   0.000      0.926 0.000 1.000 0.000
#> SRR2936913     2   0.000      0.926 0.000 1.000 0.000
#> SRR2936912     1   0.245      0.928 0.924 0.000 0.076
#> SRR2936910     1   0.000      0.983 1.000 0.000 0.000
#> SRR2936911     2   0.000      0.926 0.000 1.000 0.000
#> SRR2936907     2   0.000      0.926 0.000 1.000 0.000
#> SRR2936908     2   0.000      0.926 0.000 1.000 0.000
#> SRR2936904     3   0.000      0.981 0.000 0.000 1.000
#> SRR2936905     2   0.000      0.926 0.000 1.000 0.000
#> SRR2936903     1   0.000      0.983 1.000 0.000 0.000
#> SRR2936901     3   0.000      0.981 0.000 0.000 1.000
#> SRR2936902     2   0.525      0.720 0.000 0.736 0.264
#> SRR2936900     1   0.000      0.983 1.000 0.000 0.000
#> SRR2936898     3   0.000      0.981 0.000 0.000 1.000
#> SRR2936899     3   0.000      0.981 0.000 0.000 1.000
#> SRR2936897     1   0.245      0.928 0.924 0.000 0.076
#> SRR2936896     2   0.000      0.926 0.000 1.000 0.000
#> SRR2936894     1   0.000      0.983 1.000 0.000 0.000
#> SRR2936893     2   0.000      0.926 0.000 1.000 0.000
#> SRR2936895     2   0.525      0.720 0.000 0.736 0.264
#> SRR2936892     2   0.000      0.926 0.000 1.000 0.000
#> SRR2936891     1   0.000      0.983 1.000 0.000 0.000
#> SRR2936890     2   0.000      0.926 0.000 1.000 0.000
#> SRR2936886     3   0.000      0.981 0.000 0.000 1.000
#> SRR2936885     1   0.000      0.983 1.000 0.000 0.000
#> SRR2936888     1   0.000      0.983 1.000 0.000 0.000
#> SRR2936889     2   0.000      0.926 0.000 1.000 0.000
#> SRR2936887     3   0.000      0.981 0.000 0.000 1.000
#> SRR2936884     2   0.525      0.720 0.000 0.736 0.264
#> SRR2936883     2   0.525      0.720 0.000 0.736 0.264
#> SRR2936881     2   0.525      0.720 0.000 0.736 0.264
#> SRR2936882     1   0.000      0.983 1.000 0.000 0.000
#> SRR2936880     2   0.525      0.720 0.000 0.736 0.264
#> SRR2936878     2   0.000      0.926 0.000 1.000 0.000
#> SRR2936879     3   0.000      0.981 0.000 0.000 1.000
#> SRR2936875     2   0.000      0.926 0.000 1.000 0.000
#> SRR2936877     2   0.000      0.926 0.000 1.000 0.000
#> SRR2936876     3   0.445      0.747 0.192 0.000 0.808
#> SRR2936873     1   0.000      0.983 1.000 0.000 0.000
#> SRR2936872     2   0.000      0.926 0.000 1.000 0.000
#> SRR2936871     2   0.000      0.926 0.000 1.000 0.000
#> SRR2936874     2   0.000      0.926 0.000 1.000 0.000
#> SRR2936870     1   0.000      0.983 1.000 0.000 0.000
#> SRR2936869     3   0.000      0.981 0.000 0.000 1.000
#> SRR2936868     3   0.000      0.981 0.000 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR2936906     1  0.3528      0.907 0.808 0.000 0.000 0.192
#> SRR2936909     1  0.1940      0.846 0.924 0.000 0.076 0.000
#> SRR2936918     1  0.3528      0.907 0.808 0.000 0.000 0.192
#> SRR2936917     4  0.4998      1.000 0.000 0.488 0.000 0.512
#> SRR2936916     3  0.0469      0.962 0.000 0.000 0.988 0.012
#> SRR2936915     3  0.0469      0.962 0.000 0.000 0.988 0.012
#> SRR2936914     4  0.4998      1.000 0.000 0.488 0.000 0.512
#> SRR2936913     4  0.4998      1.000 0.000 0.488 0.000 0.512
#> SRR2936912     1  0.1940      0.846 0.924 0.000 0.076 0.000
#> SRR2936910     1  0.3528      0.907 0.808 0.000 0.000 0.192
#> SRR2936911     4  0.4998      1.000 0.000 0.488 0.000 0.512
#> SRR2936907     2  0.0000      0.708 0.000 1.000 0.000 0.000
#> SRR2936908     2  0.0000      0.708 0.000 1.000 0.000 0.000
#> SRR2936904     3  0.0336      0.963 0.000 0.000 0.992 0.008
#> SRR2936905     2  0.0000      0.708 0.000 1.000 0.000 0.000
#> SRR2936903     1  0.0000      0.886 1.000 0.000 0.000 0.000
#> SRR2936901     3  0.1637      0.944 0.000 0.000 0.940 0.060
#> SRR2936902     2  0.6508      0.554 0.000 0.600 0.104 0.296
#> SRR2936900     1  0.0000      0.886 1.000 0.000 0.000 0.000
#> SRR2936898     3  0.1637      0.944 0.000 0.000 0.940 0.060
#> SRR2936899     3  0.1637      0.944 0.000 0.000 0.940 0.060
#> SRR2936897     1  0.1940      0.846 0.924 0.000 0.076 0.000
#> SRR2936896     2  0.1940      0.547 0.000 0.924 0.000 0.076
#> SRR2936894     1  0.3528      0.907 0.808 0.000 0.000 0.192
#> SRR2936893     2  0.0000      0.708 0.000 1.000 0.000 0.000
#> SRR2936895     2  0.6756      0.539 0.000 0.600 0.148 0.252
#> SRR2936892     2  0.0000      0.708 0.000 1.000 0.000 0.000
#> SRR2936891     1  0.3528      0.907 0.808 0.000 0.000 0.192
#> SRR2936890     2  0.0000      0.708 0.000 1.000 0.000 0.000
#> SRR2936886     3  0.0336      0.963 0.000 0.000 0.992 0.008
#> SRR2936885     1  0.0000      0.886 1.000 0.000 0.000 0.000
#> SRR2936888     1  0.3528      0.907 0.808 0.000 0.000 0.192
#> SRR2936889     2  0.0000      0.708 0.000 1.000 0.000 0.000
#> SRR2936887     3  0.0336      0.963 0.000 0.000 0.992 0.008
#> SRR2936884     2  0.6508      0.554 0.000 0.600 0.104 0.296
#> SRR2936883     2  0.6508      0.554 0.000 0.600 0.104 0.296
#> SRR2936881     2  0.6508      0.554 0.000 0.600 0.104 0.296
#> SRR2936882     1  0.0000      0.886 1.000 0.000 0.000 0.000
#> SRR2936880     2  0.6508      0.554 0.000 0.600 0.104 0.296
#> SRR2936878     4  0.4998      1.000 0.000 0.488 0.000 0.512
#> SRR2936879     3  0.0469      0.962 0.000 0.000 0.988 0.012
#> SRR2936875     2  0.0000      0.708 0.000 1.000 0.000 0.000
#> SRR2936877     4  0.4998      1.000 0.000 0.488 0.000 0.512
#> SRR2936876     3  0.3528      0.782 0.192 0.000 0.808 0.000
#> SRR2936873     1  0.3528      0.907 0.808 0.000 0.000 0.192
#> SRR2936872     2  0.0000      0.708 0.000 1.000 0.000 0.000
#> SRR2936871     2  0.0000      0.708 0.000 1.000 0.000 0.000
#> SRR2936874     2  0.0000      0.708 0.000 1.000 0.000 0.000
#> SRR2936870     1  0.3528      0.907 0.808 0.000 0.000 0.192
#> SRR2936869     3  0.0336      0.963 0.000 0.000 0.992 0.008
#> SRR2936868     3  0.0336      0.963 0.000 0.000 0.992 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
#> SRR2936906     1   0.427      0.772 0.552 0.000 0.000 0.000 0.448
#> SRR2936909     1   0.188      0.686 0.924 0.000 0.000 0.064 0.012
#> SRR2936918     1   0.427      0.772 0.552 0.000 0.000 0.000 0.448
#> SRR2936917     5   0.624      1.000 0.000 0.400 0.000 0.144 0.456
#> SRR2936916     3   0.134      0.857 0.000 0.000 0.944 0.056 0.000
#> SRR2936915     3   0.134      0.857 0.000 0.000 0.944 0.056 0.000
#> SRR2936914     5   0.624      1.000 0.000 0.400 0.000 0.144 0.456
#> SRR2936913     5   0.624      1.000 0.000 0.400 0.000 0.144 0.456
#> SRR2936912     1   0.188      0.686 0.924 0.000 0.000 0.064 0.012
#> SRR2936910     1   0.427      0.772 0.552 0.000 0.000 0.000 0.448
#> SRR2936911     5   0.624      1.000 0.000 0.400 0.000 0.144 0.456
#> SRR2936907     2   0.000      0.744 0.000 1.000 0.000 0.000 0.000
#> SRR2936908     2   0.000      0.744 0.000 1.000 0.000 0.000 0.000
#> SRR2936904     4   0.406      1.000 0.000 0.000 0.360 0.640 0.000
#> SRR2936905     2   0.000      0.744 0.000 1.000 0.000 0.000 0.000
#> SRR2936903     1   0.000      0.725 1.000 0.000 0.000 0.000 0.000
#> SRR2936901     3   0.000      0.862 0.000 0.000 1.000 0.000 0.000
#> SRR2936902     2   0.682      0.597 0.000 0.600 0.164 0.152 0.084
#> SRR2936900     1   0.000      0.725 1.000 0.000 0.000 0.000 0.000
#> SRR2936898     3   0.000      0.862 0.000 0.000 1.000 0.000 0.000
#> SRR2936899     3   0.000      0.862 0.000 0.000 1.000 0.000 0.000
#> SRR2936897     1   0.188      0.686 0.924 0.000 0.000 0.064 0.012
#> SRR2936896     2   0.327      0.421 0.000 0.844 0.000 0.112 0.044
#> SRR2936894     1   0.427      0.772 0.552 0.000 0.000 0.000 0.448
#> SRR2936893     2   0.000      0.744 0.000 1.000 0.000 0.000 0.000
#> SRR2936895     2   0.674      0.584 0.000 0.600 0.112 0.204 0.084
#> SRR2936892     2   0.000      0.744 0.000 1.000 0.000 0.000 0.000
#> SRR2936891     1   0.427      0.772 0.552 0.000 0.000 0.000 0.448
#> SRR2936890     2   0.000      0.744 0.000 1.000 0.000 0.000 0.000
#> SRR2936886     4   0.406      1.000 0.000 0.000 0.360 0.640 0.000
#> SRR2936885     1   0.000      0.725 1.000 0.000 0.000 0.000 0.000
#> SRR2936888     1   0.427      0.772 0.552 0.000 0.000 0.000 0.448
#> SRR2936889     2   0.000      0.744 0.000 1.000 0.000 0.000 0.000
#> SRR2936887     4   0.406      1.000 0.000 0.000 0.360 0.640 0.000
#> SRR2936884     2   0.682      0.597 0.000 0.600 0.164 0.152 0.084
#> SRR2936883     2   0.682      0.597 0.000 0.600 0.164 0.152 0.084
#> SRR2936881     2   0.682      0.597 0.000 0.600 0.164 0.152 0.084
#> SRR2936882     1   0.000      0.725 1.000 0.000 0.000 0.000 0.000
#> SRR2936880     2   0.682      0.597 0.000 0.600 0.164 0.152 0.084
#> SRR2936878     5   0.624      1.000 0.000 0.400 0.000 0.144 0.456
#> SRR2936879     3   0.134      0.857 0.000 0.000 0.944 0.056 0.000
#> SRR2936875     2   0.000      0.744 0.000 1.000 0.000 0.000 0.000
#> SRR2936877     5   0.624      1.000 0.000 0.400 0.000 0.144 0.456
#> SRR2936876     3   0.544      0.501 0.192 0.000 0.684 0.112 0.012
#> SRR2936873     1   0.427      0.772 0.552 0.000 0.000 0.000 0.448
#> SRR2936872     2   0.000      0.744 0.000 1.000 0.000 0.000 0.000
#> SRR2936871     2   0.000      0.744 0.000 1.000 0.000 0.000 0.000
#> SRR2936874     2   0.000      0.744 0.000 1.000 0.000 0.000 0.000
#> SRR2936870     1   0.427      0.772 0.552 0.000 0.000 0.000 0.448
#> SRR2936869     4   0.406      1.000 0.000 0.000 0.360 0.640 0.000
#> SRR2936868     4   0.406      1.000 0.000 0.000 0.360 0.640 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
#> SRR2936906     1   0.000      0.938 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936909     6   0.436      0.843 0.000 0.108 0.008 0.144 0.000 0.740
#> SRR2936918     1   0.000      0.938 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936917     5   0.000      0.884 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR2936916     3   0.026      0.898 0.000 0.000 0.992 0.008 0.000 0.000
#> SRR2936915     3   0.026      0.898 0.000 0.000 0.992 0.008 0.000 0.000
#> SRR2936914     5   0.000      0.884 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR2936913     5   0.000      0.884 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR2936912     6   0.436      0.843 0.000 0.108 0.008 0.144 0.000 0.740
#> SRR2936910     1   0.000      0.938 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936911     5   0.000      0.884 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR2936907     2   0.376      0.714 0.000 0.600 0.000 0.000 0.400 0.000
#> SRR2936908     2   0.376      0.714 0.000 0.600 0.000 0.000 0.400 0.000
#> SRR2936904     4   0.238      0.946 0.000 0.000 0.152 0.848 0.000 0.000
#> SRR2936905     2   0.376      0.714 0.000 0.600 0.000 0.000 0.400 0.000
#> SRR2936903     6   0.026      0.885 0.008 0.000 0.000 0.000 0.000 0.992
#> SRR2936901     3   0.120      0.901 0.000 0.056 0.944 0.000 0.000 0.000
#> SRR2936902     2   0.191      0.588 0.000 0.892 0.108 0.000 0.000 0.000
#> SRR2936900     6   0.026      0.885 0.008 0.000 0.000 0.000 0.000 0.992
#> SRR2936898     3   0.120      0.901 0.000 0.056 0.944 0.000 0.000 0.000
#> SRR2936899     3   0.120      0.901 0.000 0.056 0.944 0.000 0.000 0.000
#> SRR2936897     6   0.436      0.843 0.000 0.108 0.008 0.144 0.000 0.740
#> SRR2936896     5   0.383     -0.421 0.000 0.444 0.000 0.000 0.556 0.000
#> SRR2936894     1   0.000      0.938 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936893     2   0.376      0.714 0.000 0.600 0.000 0.000 0.400 0.000
#> SRR2936895     2   0.263      0.573 0.000 0.840 0.152 0.008 0.000 0.000
#> SRR2936892     2   0.376      0.714 0.000 0.600 0.000 0.000 0.400 0.000
#> SRR2936891     1   0.000      0.938 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936890     2   0.376      0.714 0.000 0.600 0.000 0.000 0.400 0.000
#> SRR2936886     4   0.270      0.987 0.000 0.000 0.188 0.812 0.000 0.000
#> SRR2936885     6   0.026      0.885 0.008 0.000 0.000 0.000 0.000 0.992
#> SRR2936888     1   0.000      0.938 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936889     2   0.376      0.714 0.000 0.600 0.000 0.000 0.400 0.000
#> SRR2936887     4   0.270      0.987 0.000 0.000 0.188 0.812 0.000 0.000
#> SRR2936884     2   0.191      0.588 0.000 0.892 0.108 0.000 0.000 0.000
#> SRR2936883     2   0.191      0.588 0.000 0.892 0.108 0.000 0.000 0.000
#> SRR2936881     2   0.191      0.588 0.000 0.892 0.108 0.000 0.000 0.000
#> SRR2936882     6   0.026      0.885 0.008 0.000 0.000 0.000 0.000 0.992
#> SRR2936880     2   0.191      0.588 0.000 0.892 0.108 0.000 0.000 0.000
#> SRR2936878     5   0.000      0.884 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR2936879     3   0.026      0.898 0.000 0.000 0.992 0.008 0.000 0.000
#> SRR2936875     2   0.376      0.714 0.000 0.600 0.000 0.000 0.400 0.000
#> SRR2936877     5   0.000      0.884 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR2936876     3   0.472      0.627 0.000 0.108 0.696 0.188 0.000 0.008
#> SRR2936873     1   0.374      0.294 0.608 0.000 0.000 0.000 0.000 0.392
#> SRR2936872     2   0.376      0.714 0.000 0.600 0.000 0.000 0.400 0.000
#> SRR2936871     2   0.376      0.714 0.000 0.600 0.000 0.000 0.400 0.000
#> SRR2936874     2   0.376      0.714 0.000 0.600 0.000 0.000 0.400 0.000
#> SRR2936870     1   0.000      0.938 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936869     4   0.270      0.987 0.000 0.000 0.188 0.812 0.000 0.000
#> SRR2936868     4   0.270      0.987 0.000 0.000 0.188 0.812 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)
#> Error in mat[ceiling(1:nr/h_ratio), ceiling(1:nc/w_ratio), drop = FALSE]: subscript out of bounds

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 14198 rows and 51 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.810           0.939       0.967         0.5032 0.490   0.490
#> 3 3 0.920           0.887       0.948         0.3234 0.729   0.501
#> 4 4 0.736           0.785       0.783         0.0956 0.935   0.801
#> 5 5 0.735           0.695       0.771         0.0660 0.949   0.824
#> 6 6 0.818           0.665       0.756         0.0468 0.878   0.555

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
#> SRR2936906     1  0.0000      0.931 1.000 0.000
#> SRR2936909     1  0.0000      0.931 1.000 0.000
#> SRR2936918     1  0.0000      0.931 1.000 0.000
#> SRR2936917     2  0.0000      1.000 0.000 1.000
#> SRR2936916     2  0.0672      0.991 0.008 0.992
#> SRR2936915     1  0.7376      0.794 0.792 0.208
#> SRR2936914     2  0.0000      1.000 0.000 1.000
#> SRR2936913     2  0.0000      1.000 0.000 1.000
#> SRR2936912     1  0.0000      0.931 1.000 0.000
#> SRR2936910     1  0.0000      0.931 1.000 0.000
#> SRR2936911     2  0.0000      1.000 0.000 1.000
#> SRR2936907     2  0.0000      1.000 0.000 1.000
#> SRR2936908     2  0.0000      1.000 0.000 1.000
#> SRR2936904     1  0.4161      0.890 0.916 0.084
#> SRR2936905     2  0.0000      1.000 0.000 1.000
#> SRR2936903     1  0.0000      0.931 1.000 0.000
#> SRR2936901     1  0.0000      0.931 1.000 0.000
#> SRR2936902     2  0.0000      1.000 0.000 1.000
#> SRR2936900     1  0.0000      0.931 1.000 0.000
#> SRR2936898     1  0.2948      0.908 0.948 0.052
#> SRR2936899     1  0.4939      0.875 0.892 0.108
#> SRR2936897     1  0.0000      0.931 1.000 0.000
#> SRR2936896     2  0.0000      1.000 0.000 1.000
#> SRR2936894     1  0.0000      0.931 1.000 0.000
#> SRR2936893     2  0.0000      1.000 0.000 1.000
#> SRR2936895     2  0.0000      1.000 0.000 1.000
#> SRR2936892     2  0.0000      1.000 0.000 1.000
#> SRR2936891     1  0.0000      0.931 1.000 0.000
#> SRR2936890     2  0.0000      1.000 0.000 1.000
#> SRR2936886     1  0.7219      0.802 0.800 0.200
#> SRR2936885     1  0.0000      0.931 1.000 0.000
#> SRR2936888     1  0.0000      0.931 1.000 0.000
#> SRR2936889     2  0.0000      1.000 0.000 1.000
#> SRR2936887     1  0.7219      0.802 0.800 0.200
#> SRR2936884     2  0.0000      1.000 0.000 1.000
#> SRR2936883     2  0.0000      1.000 0.000 1.000
#> SRR2936881     2  0.0000      1.000 0.000 1.000
#> SRR2936882     1  0.0000      0.931 1.000 0.000
#> SRR2936880     2  0.0000      1.000 0.000 1.000
#> SRR2936878     2  0.0000      1.000 0.000 1.000
#> SRR2936879     1  0.7376      0.794 0.792 0.208
#> SRR2936875     2  0.0000      1.000 0.000 1.000
#> SRR2936877     2  0.0000      1.000 0.000 1.000
#> SRR2936876     1  0.0000      0.931 1.000 0.000
#> SRR2936873     1  0.0000      0.931 1.000 0.000
#> SRR2936872     2  0.0000      1.000 0.000 1.000
#> SRR2936871     2  0.0000      1.000 0.000 1.000
#> SRR2936874     2  0.0000      1.000 0.000 1.000
#> SRR2936870     1  0.0000      0.931 1.000 0.000
#> SRR2936869     1  0.9754      0.435 0.592 0.408
#> SRR2936868     1  0.7745      0.769 0.772 0.228

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR2936906     1  0.0000      1.000 1.000 0.000 0.000
#> SRR2936909     1  0.0000      1.000 1.000 0.000 0.000
#> SRR2936918     1  0.0000      1.000 1.000 0.000 0.000
#> SRR2936917     2  0.0237      0.947 0.000 0.996 0.004
#> SRR2936916     3  0.0000      0.871 0.000 0.000 1.000
#> SRR2936915     3  0.0237      0.873 0.004 0.000 0.996
#> SRR2936914     2  0.0237      0.947 0.000 0.996 0.004
#> SRR2936913     2  0.0237      0.947 0.000 0.996 0.004
#> SRR2936912     1  0.0000      1.000 1.000 0.000 0.000
#> SRR2936910     1  0.0000      1.000 1.000 0.000 0.000
#> SRR2936911     2  0.0237      0.947 0.000 0.996 0.004
#> SRR2936907     2  0.0000      0.947 0.000 1.000 0.000
#> SRR2936908     2  0.1411      0.953 0.000 0.964 0.036
#> SRR2936904     3  0.1529      0.841 0.040 0.000 0.960
#> SRR2936905     2  0.1411      0.953 0.000 0.964 0.036
#> SRR2936903     1  0.0000      1.000 1.000 0.000 0.000
#> SRR2936901     3  0.0237      0.873 0.004 0.000 0.996
#> SRR2936902     3  0.5591      0.609 0.000 0.304 0.696
#> SRR2936900     1  0.0000      1.000 1.000 0.000 0.000
#> SRR2936898     3  0.0237      0.873 0.004 0.000 0.996
#> SRR2936899     3  0.0237      0.873 0.004 0.000 0.996
#> SRR2936897     1  0.0000      1.000 1.000 0.000 0.000
#> SRR2936896     2  0.0237      0.947 0.000 0.996 0.004
#> SRR2936894     1  0.0000      1.000 1.000 0.000 0.000
#> SRR2936893     2  0.1411      0.953 0.000 0.964 0.036
#> SRR2936895     3  0.6180      0.382 0.000 0.416 0.584
#> SRR2936892     2  0.1411      0.953 0.000 0.964 0.036
#> SRR2936891     1  0.0000      1.000 1.000 0.000 0.000
#> SRR2936890     2  0.1411      0.953 0.000 0.964 0.036
#> SRR2936886     3  0.0237      0.873 0.004 0.000 0.996
#> SRR2936885     1  0.0000      1.000 1.000 0.000 0.000
#> SRR2936888     1  0.0000      1.000 1.000 0.000 0.000
#> SRR2936889     2  0.1411      0.953 0.000 0.964 0.036
#> SRR2936887     3  0.0237      0.873 0.004 0.000 0.996
#> SRR2936884     2  0.6204      0.123 0.000 0.576 0.424
#> SRR2936883     3  0.5591      0.609 0.000 0.304 0.696
#> SRR2936881     3  0.5591      0.609 0.000 0.304 0.696
#> SRR2936882     1  0.0000      1.000 1.000 0.000 0.000
#> SRR2936880     3  0.6180      0.382 0.000 0.416 0.584
#> SRR2936878     2  0.0237      0.947 0.000 0.996 0.004
#> SRR2936879     3  0.0237      0.873 0.004 0.000 0.996
#> SRR2936875     2  0.1411      0.953 0.000 0.964 0.036
#> SRR2936877     2  0.0237      0.947 0.000 0.996 0.004
#> SRR2936876     3  0.0237      0.873 0.004 0.000 0.996
#> SRR2936873     1  0.0000      1.000 1.000 0.000 0.000
#> SRR2936872     2  0.1411      0.953 0.000 0.964 0.036
#> SRR2936871     2  0.1411      0.953 0.000 0.964 0.036
#> SRR2936874     2  0.1411      0.953 0.000 0.964 0.036
#> SRR2936870     1  0.0000      1.000 1.000 0.000 0.000
#> SRR2936869     3  0.0237      0.871 0.000 0.004 0.996
#> SRR2936868     3  0.0237      0.873 0.004 0.000 0.996

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR2936906     1  0.0000      0.923 1.000 0.000 0.000 0.000
#> SRR2936909     1  0.2868      0.908 0.864 0.000 0.136 0.000
#> SRR2936918     1  0.0000      0.923 1.000 0.000 0.000 0.000
#> SRR2936917     2  0.0000      0.698 0.000 1.000 0.000 0.000
#> SRR2936916     4  0.4972     -0.112 0.000 0.000 0.456 0.544
#> SRR2936915     4  0.3569      0.669 0.000 0.000 0.196 0.804
#> SRR2936914     2  0.0000      0.698 0.000 1.000 0.000 0.000
#> SRR2936913     2  0.0000      0.698 0.000 1.000 0.000 0.000
#> SRR2936912     1  0.2760      0.910 0.872 0.000 0.128 0.000
#> SRR2936910     1  0.0000      0.923 1.000 0.000 0.000 0.000
#> SRR2936911     2  0.0000      0.698 0.000 1.000 0.000 0.000
#> SRR2936907     2  0.4624      0.832 0.000 0.660 0.340 0.000
#> SRR2936908     2  0.4905      0.839 0.000 0.632 0.364 0.004
#> SRR2936904     4  0.0895      0.682 0.004 0.000 0.020 0.976
#> SRR2936905     2  0.4905      0.839 0.000 0.632 0.364 0.004
#> SRR2936903     1  0.3975      0.874 0.760 0.000 0.240 0.000
#> SRR2936901     4  0.4866      0.488 0.000 0.000 0.404 0.596
#> SRR2936902     3  0.6249      0.916 0.000 0.072 0.592 0.336
#> SRR2936900     1  0.3975      0.874 0.760 0.000 0.240 0.000
#> SRR2936898     4  0.4605      0.514 0.000 0.000 0.336 0.664
#> SRR2936899     4  0.4605      0.514 0.000 0.000 0.336 0.664
#> SRR2936897     1  0.3024      0.906 0.852 0.000 0.148 0.000
#> SRR2936896     2  0.4643      0.831 0.000 0.656 0.344 0.000
#> SRR2936894     1  0.0000      0.923 1.000 0.000 0.000 0.000
#> SRR2936893     2  0.4905      0.839 0.000 0.632 0.364 0.004
#> SRR2936895     3  0.6412      0.917 0.000 0.088 0.592 0.320
#> SRR2936892     2  0.4905      0.839 0.000 0.632 0.364 0.004
#> SRR2936891     1  0.0000      0.923 1.000 0.000 0.000 0.000
#> SRR2936890     2  0.4905      0.839 0.000 0.632 0.364 0.004
#> SRR2936886     4  0.0336      0.697 0.000 0.000 0.008 0.992
#> SRR2936885     1  0.3975      0.874 0.760 0.000 0.240 0.000
#> SRR2936888     1  0.0336      0.921 0.992 0.000 0.008 0.000
#> SRR2936889     2  0.4905      0.839 0.000 0.632 0.364 0.004
#> SRR2936887     4  0.0336      0.697 0.000 0.000 0.008 0.992
#> SRR2936884     3  0.6233      0.739 0.000 0.124 0.660 0.216
#> SRR2936883     3  0.6249      0.916 0.000 0.072 0.592 0.336
#> SRR2936881     3  0.6249      0.916 0.000 0.072 0.592 0.336
#> SRR2936882     1  0.3975      0.874 0.760 0.000 0.240 0.000
#> SRR2936880     3  0.6412      0.917 0.000 0.088 0.592 0.320
#> SRR2936878     2  0.0000      0.698 0.000 1.000 0.000 0.000
#> SRR2936879     4  0.3873      0.648 0.000 0.000 0.228 0.772
#> SRR2936875     2  0.4905      0.839 0.000 0.632 0.364 0.004
#> SRR2936877     2  0.0000      0.698 0.000 1.000 0.000 0.000
#> SRR2936876     4  0.4072      0.658 0.000 0.000 0.252 0.748
#> SRR2936873     1  0.0000      0.923 1.000 0.000 0.000 0.000
#> SRR2936872     2  0.4905      0.839 0.000 0.632 0.364 0.004
#> SRR2936871     2  0.4905      0.839 0.000 0.632 0.364 0.004
#> SRR2936874     2  0.4905      0.839 0.000 0.632 0.364 0.004
#> SRR2936870     1  0.0336      0.921 0.992 0.000 0.008 0.000
#> SRR2936869     4  0.0336      0.697 0.000 0.000 0.008 0.992
#> SRR2936868     4  0.0336      0.697 0.000 0.000 0.008 0.992

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4 p5
#> SRR2936906     1  0.4697     0.7943 0.648 0.000 0.000 0.032 NA
#> SRR2936909     1  0.1329     0.7478 0.956 0.000 0.004 0.032 NA
#> SRR2936918     1  0.4623     0.7954 0.664 0.000 0.000 0.032 NA
#> SRR2936917     2  0.0404     0.6121 0.000 0.988 0.012 0.000 NA
#> SRR2936916     3  0.4573     0.5763 0.000 0.000 0.744 0.164 NA
#> SRR2936915     4  0.6047     0.1740 0.000 0.000 0.400 0.480 NA
#> SRR2936914     2  0.0404     0.6121 0.000 0.988 0.012 0.000 NA
#> SRR2936913     2  0.0404     0.6121 0.000 0.988 0.012 0.000 NA
#> SRR2936912     1  0.1026     0.7514 0.968 0.000 0.004 0.024 NA
#> SRR2936910     1  0.4623     0.7954 0.664 0.000 0.000 0.032 NA
#> SRR2936911     2  0.0404     0.6121 0.000 0.988 0.012 0.000 NA
#> SRR2936907     2  0.5597     0.7997 0.000 0.488 0.072 0.000 NA
#> SRR2936908     2  0.5733     0.8012 0.000 0.476 0.084 0.000 NA
#> SRR2936904     4  0.3359     0.7815 0.000 0.000 0.108 0.840 NA
#> SRR2936905     2  0.5733     0.8012 0.000 0.476 0.084 0.000 NA
#> SRR2936903     1  0.3862     0.6897 0.824 0.000 0.012 0.072 NA
#> SRR2936901     3  0.5375     0.4328 0.000 0.000 0.604 0.320 NA
#> SRR2936902     3  0.0865     0.7374 0.000 0.024 0.972 0.000 NA
#> SRR2936900     1  0.3689     0.6970 0.836 0.000 0.012 0.068 NA
#> SRR2936898     3  0.5139     0.4540 0.000 0.000 0.648 0.280 NA
#> SRR2936899     3  0.5139     0.4540 0.000 0.000 0.648 0.280 NA
#> SRR2936897     1  0.1329     0.7478 0.956 0.000 0.004 0.032 NA
#> SRR2936896     2  0.5613     0.7368 0.000 0.648 0.096 0.012 NA
#> SRR2936894     1  0.4697     0.7943 0.648 0.000 0.000 0.032 NA
#> SRR2936893     2  0.6075     0.8002 0.000 0.476 0.084 0.012 NA
#> SRR2936895     3  0.0865     0.7374 0.000 0.024 0.972 0.000 NA
#> SRR2936892     2  0.6077     0.7988 0.000 0.472 0.084 0.012 NA
#> SRR2936891     1  0.4697     0.7943 0.648 0.000 0.000 0.032 NA
#> SRR2936890     2  0.5733     0.8012 0.000 0.476 0.084 0.000 NA
#> SRR2936886     4  0.2471     0.8137 0.000 0.000 0.136 0.864 NA
#> SRR2936885     1  0.3515     0.7018 0.844 0.000 0.008 0.064 NA
#> SRR2936888     1  0.5102     0.7860 0.620 0.000 0.008 0.036 NA
#> SRR2936889     2  0.5733     0.8012 0.000 0.476 0.084 0.000 NA
#> SRR2936887     4  0.2471     0.8137 0.000 0.000 0.136 0.864 NA
#> SRR2936884     3  0.1493     0.7113 0.000 0.028 0.948 0.000 NA
#> SRR2936883     3  0.0865     0.7374 0.000 0.024 0.972 0.000 NA
#> SRR2936881     3  0.0865     0.7374 0.000 0.024 0.972 0.000 NA
#> SRR2936882     1  0.3626     0.6997 0.840 0.000 0.012 0.064 NA
#> SRR2936880     3  0.0865     0.7374 0.000 0.024 0.972 0.000 NA
#> SRR2936878     2  0.0404     0.6121 0.000 0.988 0.012 0.000 NA
#> SRR2936879     3  0.6024    -0.0802 0.000 0.000 0.472 0.412 NA
#> SRR2936875     2  0.6075     0.8002 0.000 0.476 0.084 0.012 NA
#> SRR2936877     2  0.0404     0.6121 0.000 0.988 0.012 0.000 NA
#> SRR2936876     4  0.7689     0.4228 0.184 0.000 0.196 0.496 NA
#> SRR2936873     1  0.4623     0.7954 0.664 0.000 0.000 0.032 NA
#> SRR2936872     2  0.5733     0.8012 0.000 0.476 0.084 0.000 NA
#> SRR2936871     2  0.5733     0.8012 0.000 0.476 0.084 0.000 NA
#> SRR2936874     2  0.6077     0.7988 0.000 0.472 0.084 0.012 NA
#> SRR2936870     1  0.5102     0.7860 0.620 0.000 0.008 0.036 NA
#> SRR2936869     4  0.2471     0.8137 0.000 0.000 0.136 0.864 NA
#> SRR2936868     4  0.2471     0.8137 0.000 0.000 0.136 0.864 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
#> SRR2936906     1  0.0000     0.8178 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936909     1  0.5615     0.4143 0.584 0.088 0.008 0.020 0.000 0.300
#> SRR2936918     1  0.0146     0.8179 0.996 0.004 0.000 0.000 0.000 0.000
#> SRR2936917     5  0.0000     0.8923 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR2936916     3  0.6070     0.4057 0.000 0.016 0.460 0.164 0.000 0.360
#> SRR2936915     6  0.5976    -0.2471 0.000 0.000 0.228 0.364 0.000 0.408
#> SRR2936914     5  0.0000     0.8923 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR2936913     5  0.0000     0.8923 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR2936912     1  0.5537     0.4183 0.588 0.088 0.008 0.016 0.000 0.300
#> SRR2936910     1  0.0291     0.8174 0.992 0.004 0.004 0.000 0.000 0.000
#> SRR2936911     5  0.0000     0.8923 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR2936907     2  0.3595     0.9459 0.000 0.704 0.000 0.000 0.288 0.008
#> SRR2936908     2  0.4593     0.9466 0.000 0.660 0.008 0.000 0.280 0.052
#> SRR2936904     4  0.2826     0.8542 0.000 0.000 0.028 0.844 0.000 0.128
#> SRR2936905     2  0.3468     0.9551 0.000 0.712 0.004 0.000 0.284 0.000
#> SRR2936903     6  0.6070     0.0937 0.344 0.224 0.004 0.000 0.000 0.428
#> SRR2936901     3  0.6175     0.5084 0.000 0.028 0.508 0.172 0.000 0.292
#> SRR2936902     3  0.1088     0.7598 0.000 0.024 0.960 0.000 0.016 0.000
#> SRR2936900     6  0.5995     0.0540 0.388 0.196 0.004 0.000 0.000 0.412
#> SRR2936898     3  0.6092     0.5239 0.000 0.028 0.532 0.172 0.000 0.268
#> SRR2936899     3  0.6092     0.5239 0.000 0.028 0.532 0.172 0.000 0.268
#> SRR2936897     1  0.5739     0.3759 0.564 0.096 0.008 0.020 0.000 0.312
#> SRR2936896     5  0.5112    -0.2709 0.000 0.392 0.000 0.008 0.536 0.064
#> SRR2936894     1  0.0000     0.8178 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936893     2  0.4944     0.9436 0.000 0.644 0.008 0.008 0.280 0.060
#> SRR2936895     3  0.1232     0.7584 0.000 0.024 0.956 0.000 0.016 0.004
#> SRR2936892     2  0.4944     0.9436 0.000 0.644 0.008 0.008 0.280 0.060
#> SRR2936891     1  0.0000     0.8178 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936890     2  0.3468     0.9551 0.000 0.712 0.004 0.000 0.284 0.000
#> SRR2936886     4  0.0865     0.9656 0.000 0.000 0.036 0.964 0.000 0.000
#> SRR2936885     6  0.5995     0.0540 0.388 0.196 0.004 0.000 0.000 0.412
#> SRR2936888     1  0.2146     0.7795 0.908 0.060 0.024 0.008 0.000 0.000
#> SRR2936889     2  0.3468     0.9551 0.000 0.712 0.004 0.000 0.284 0.000
#> SRR2936887     4  0.0865     0.9656 0.000 0.000 0.036 0.964 0.000 0.000
#> SRR2936884     3  0.1464     0.7476 0.000 0.036 0.944 0.000 0.016 0.004
#> SRR2936883     3  0.1088     0.7598 0.000 0.024 0.960 0.000 0.016 0.000
#> SRR2936881     3  0.1088     0.7598 0.000 0.024 0.960 0.000 0.016 0.000
#> SRR2936882     6  0.5995     0.0540 0.388 0.196 0.004 0.000 0.000 0.412
#> SRR2936880     3  0.1088     0.7598 0.000 0.024 0.960 0.000 0.016 0.000
#> SRR2936878     5  0.0000     0.8923 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR2936879     6  0.6087    -0.3059 0.000 0.000 0.292 0.316 0.000 0.392
#> SRR2936875     2  0.4944     0.9436 0.000 0.644 0.008 0.008 0.280 0.060
#> SRR2936877     5  0.1007     0.8664 0.000 0.000 0.000 0.000 0.956 0.044
#> SRR2936876     6  0.4580    -0.2009 0.000 0.000 0.052 0.336 0.000 0.612
#> SRR2936873     1  0.0291     0.8174 0.992 0.004 0.004 0.000 0.000 0.000
#> SRR2936872     2  0.3468     0.9551 0.000 0.712 0.004 0.000 0.284 0.000
#> SRR2936871     2  0.3468     0.9551 0.000 0.712 0.004 0.000 0.284 0.000
#> SRR2936874     2  0.4944     0.9436 0.000 0.644 0.008 0.008 0.280 0.060
#> SRR2936870     1  0.2146     0.7795 0.908 0.060 0.024 0.008 0.000 0.000
#> SRR2936869     4  0.0865     0.9656 0.000 0.000 0.036 0.964 0.000 0.000
#> SRR2936868     4  0.0865     0.9656 0.000 0.000 0.036 0.964 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-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 14198 rows and 51 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'skmeans' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 4.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk MAD-skmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.986       0.994         0.5103 0.490   0.490
#> 3 3 0.994           0.965       0.975         0.1693 0.918   0.832
#> 4 4 0.963           0.956       0.973         0.1733 0.867   0.684
#> 5 5 0.821           0.823       0.901         0.0675 0.952   0.844
#> 6 6 0.804           0.707       0.850         0.0444 0.969   0.883

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette   p1   p2
#> SRR2936906     1   0.000      0.990 1.00 0.00
#> SRR2936909     1   0.000      0.990 1.00 0.00
#> SRR2936918     1   0.000      0.990 1.00 0.00
#> SRR2936917     2   0.000      0.998 0.00 1.00
#> SRR2936916     2   0.242      0.958 0.04 0.96
#> SRR2936915     1   0.000      0.990 1.00 0.00
#> SRR2936914     2   0.000      0.998 0.00 1.00
#> SRR2936913     2   0.000      0.998 0.00 1.00
#> SRR2936912     1   0.000      0.990 1.00 0.00
#> SRR2936910     1   0.000      0.990 1.00 0.00
#> SRR2936911     2   0.000      0.998 0.00 1.00
#> SRR2936907     2   0.000      0.998 0.00 1.00
#> SRR2936908     2   0.000      0.998 0.00 1.00
#> SRR2936904     1   0.000      0.990 1.00 0.00
#> SRR2936905     2   0.000      0.998 0.00 1.00
#> SRR2936903     1   0.000      0.990 1.00 0.00
#> SRR2936901     1   0.000      0.990 1.00 0.00
#> SRR2936902     2   0.000      0.998 0.00 1.00
#> SRR2936900     1   0.000      0.990 1.00 0.00
#> SRR2936898     1   0.000      0.990 1.00 0.00
#> SRR2936899     1   0.000      0.990 1.00 0.00
#> SRR2936897     1   0.000      0.990 1.00 0.00
#> SRR2936896     2   0.000      0.998 0.00 1.00
#> SRR2936894     1   0.000      0.990 1.00 0.00
#> SRR2936893     2   0.000      0.998 0.00 1.00
#> SRR2936895     2   0.000      0.998 0.00 1.00
#> SRR2936892     2   0.000      0.998 0.00 1.00
#> SRR2936891     1   0.000      0.990 1.00 0.00
#> SRR2936890     2   0.000      0.998 0.00 1.00
#> SRR2936886     1   0.000      0.990 1.00 0.00
#> SRR2936885     1   0.000      0.990 1.00 0.00
#> SRR2936888     1   0.000      0.990 1.00 0.00
#> SRR2936889     2   0.000      0.998 0.00 1.00
#> SRR2936887     1   0.000      0.990 1.00 0.00
#> SRR2936884     2   0.000      0.998 0.00 1.00
#> SRR2936883     2   0.000      0.998 0.00 1.00
#> SRR2936881     2   0.000      0.998 0.00 1.00
#> SRR2936882     1   0.000      0.990 1.00 0.00
#> SRR2936880     2   0.000      0.998 0.00 1.00
#> SRR2936878     2   0.000      0.998 0.00 1.00
#> SRR2936879     1   0.000      0.990 1.00 0.00
#> SRR2936875     2   0.000      0.998 0.00 1.00
#> SRR2936877     2   0.000      0.998 0.00 1.00
#> SRR2936876     1   0.000      0.990 1.00 0.00
#> SRR2936873     1   0.000      0.990 1.00 0.00
#> SRR2936872     2   0.000      0.998 0.00 1.00
#> SRR2936871     2   0.000      0.998 0.00 1.00
#> SRR2936874     2   0.000      0.998 0.00 1.00
#> SRR2936870     1   0.000      0.990 1.00 0.00
#> SRR2936869     1   0.827      0.650 0.74 0.26
#> SRR2936868     1   0.000      0.990 1.00 0.00

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR2936906     1   0.000      0.983 1.000 0.000 0.000
#> SRR2936909     1   0.000      0.983 1.000 0.000 0.000
#> SRR2936918     1   0.000      0.983 1.000 0.000 0.000
#> SRR2936917     2   0.000      0.975 0.000 1.000 0.000
#> SRR2936916     2   0.382      0.797 0.148 0.852 0.000
#> SRR2936915     1   0.175      0.938 0.952 0.000 0.048
#> SRR2936914     2   0.000      0.975 0.000 1.000 0.000
#> SRR2936913     2   0.000      0.975 0.000 1.000 0.000
#> SRR2936912     1   0.000      0.983 1.000 0.000 0.000
#> SRR2936910     1   0.000      0.983 1.000 0.000 0.000
#> SRR2936911     2   0.000      0.975 0.000 1.000 0.000
#> SRR2936907     2   0.000      0.975 0.000 1.000 0.000
#> SRR2936908     2   0.000      0.975 0.000 1.000 0.000
#> SRR2936904     3   0.263      0.986 0.084 0.000 0.916
#> SRR2936905     2   0.000      0.975 0.000 1.000 0.000
#> SRR2936903     1   0.000      0.983 1.000 0.000 0.000
#> SRR2936901     1   0.263      0.908 0.916 0.000 0.084
#> SRR2936902     2   0.263      0.924 0.000 0.916 0.084
#> SRR2936900     1   0.000      0.983 1.000 0.000 0.000
#> SRR2936898     1   0.263      0.908 0.916 0.000 0.084
#> SRR2936899     1   0.263      0.908 0.916 0.000 0.084
#> SRR2936897     1   0.000      0.983 1.000 0.000 0.000
#> SRR2936896     2   0.000      0.975 0.000 1.000 0.000
#> SRR2936894     1   0.000      0.983 1.000 0.000 0.000
#> SRR2936893     2   0.000      0.975 0.000 1.000 0.000
#> SRR2936895     2   0.000      0.975 0.000 1.000 0.000
#> SRR2936892     2   0.000      0.975 0.000 1.000 0.000
#> SRR2936891     1   0.000      0.983 1.000 0.000 0.000
#> SRR2936890     2   0.000      0.975 0.000 1.000 0.000
#> SRR2936886     3   0.263      0.986 0.084 0.000 0.916
#> SRR2936885     1   0.000      0.983 1.000 0.000 0.000
#> SRR2936888     1   0.000      0.983 1.000 0.000 0.000
#> SRR2936889     2   0.000      0.975 0.000 1.000 0.000
#> SRR2936887     3   0.263      0.986 0.084 0.000 0.916
#> SRR2936884     2   0.263      0.924 0.000 0.916 0.084
#> SRR2936883     2   0.263      0.924 0.000 0.916 0.084
#> SRR2936881     2   0.263      0.924 0.000 0.916 0.084
#> SRR2936882     1   0.000      0.983 1.000 0.000 0.000
#> SRR2936880     2   0.263      0.924 0.000 0.916 0.084
#> SRR2936878     2   0.000      0.975 0.000 1.000 0.000
#> SRR2936879     1   0.000      0.983 1.000 0.000 0.000
#> SRR2936875     2   0.000      0.975 0.000 1.000 0.000
#> SRR2936877     2   0.000      0.975 0.000 1.000 0.000
#> SRR2936876     1   0.000      0.983 1.000 0.000 0.000
#> SRR2936873     1   0.000      0.983 1.000 0.000 0.000
#> SRR2936872     2   0.000      0.975 0.000 1.000 0.000
#> SRR2936871     2   0.000      0.975 0.000 1.000 0.000
#> SRR2936874     2   0.000      0.975 0.000 1.000 0.000
#> SRR2936870     1   0.000      0.983 1.000 0.000 0.000
#> SRR2936869     3   0.315      0.945 0.044 0.040 0.916
#> SRR2936868     3   0.263      0.986 0.084 0.000 0.916

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR2936906     1  0.0000      0.996 1.000 0.000 0.000 0.000
#> SRR2936909     1  0.0000      0.996 1.000 0.000 0.000 0.000
#> SRR2936918     1  0.0000      0.996 1.000 0.000 0.000 0.000
#> SRR2936917     2  0.1637      0.950 0.000 0.940 0.060 0.000
#> SRR2936916     2  0.5507      0.711 0.156 0.732 0.112 0.000
#> SRR2936915     1  0.1059      0.975 0.972 0.000 0.016 0.012
#> SRR2936914     2  0.1637      0.950 0.000 0.940 0.060 0.000
#> SRR2936913     2  0.1637      0.950 0.000 0.940 0.060 0.000
#> SRR2936912     1  0.0000      0.996 1.000 0.000 0.000 0.000
#> SRR2936910     1  0.0000      0.996 1.000 0.000 0.000 0.000
#> SRR2936911     2  0.1637      0.950 0.000 0.940 0.060 0.000
#> SRR2936907     2  0.0000      0.960 0.000 1.000 0.000 0.000
#> SRR2936908     2  0.0000      0.960 0.000 1.000 0.000 0.000
#> SRR2936904     4  0.0921      0.962 0.028 0.000 0.000 0.972
#> SRR2936905     2  0.0000      0.960 0.000 1.000 0.000 0.000
#> SRR2936903     1  0.0188      0.995 0.996 0.000 0.004 0.000
#> SRR2936901     3  0.2469      0.864 0.108 0.000 0.892 0.000
#> SRR2936902     3  0.0707      0.912 0.000 0.020 0.980 0.000
#> SRR2936900     1  0.0188      0.995 0.996 0.000 0.004 0.000
#> SRR2936898     3  0.2408      0.868 0.104 0.000 0.896 0.000
#> SRR2936899     3  0.2408      0.868 0.104 0.000 0.896 0.000
#> SRR2936897     1  0.0000      0.996 1.000 0.000 0.000 0.000
#> SRR2936896     2  0.1637      0.950 0.000 0.940 0.060 0.000
#> SRR2936894     1  0.0000      0.996 1.000 0.000 0.000 0.000
#> SRR2936893     2  0.0000      0.960 0.000 1.000 0.000 0.000
#> SRR2936895     2  0.2149      0.930 0.000 0.912 0.088 0.000
#> SRR2936892     2  0.0000      0.960 0.000 1.000 0.000 0.000
#> SRR2936891     1  0.0000      0.996 1.000 0.000 0.000 0.000
#> SRR2936890     2  0.0000      0.960 0.000 1.000 0.000 0.000
#> SRR2936886     4  0.0000      0.991 0.000 0.000 0.000 1.000
#> SRR2936885     1  0.0188      0.995 0.996 0.000 0.004 0.000
#> SRR2936888     1  0.0000      0.996 1.000 0.000 0.000 0.000
#> SRR2936889     2  0.0000      0.960 0.000 1.000 0.000 0.000
#> SRR2936887     4  0.0000      0.991 0.000 0.000 0.000 1.000
#> SRR2936884     3  0.2149      0.841 0.000 0.088 0.912 0.000
#> SRR2936883     3  0.0707      0.912 0.000 0.020 0.980 0.000
#> SRR2936881     3  0.0707      0.912 0.000 0.020 0.980 0.000
#> SRR2936882     1  0.0188      0.995 0.996 0.000 0.004 0.000
#> SRR2936880     3  0.0707      0.912 0.000 0.020 0.980 0.000
#> SRR2936878     2  0.1637      0.950 0.000 0.940 0.060 0.000
#> SRR2936879     1  0.0469      0.989 0.988 0.000 0.012 0.000
#> SRR2936875     2  0.0000      0.960 0.000 1.000 0.000 0.000
#> SRR2936877     2  0.1637      0.950 0.000 0.940 0.060 0.000
#> SRR2936876     1  0.0469      0.989 0.988 0.000 0.012 0.000
#> SRR2936873     1  0.0000      0.996 1.000 0.000 0.000 0.000
#> SRR2936872     2  0.0000      0.960 0.000 1.000 0.000 0.000
#> SRR2936871     2  0.0000      0.960 0.000 1.000 0.000 0.000
#> SRR2936874     2  0.0000      0.960 0.000 1.000 0.000 0.000
#> SRR2936870     1  0.0000      0.996 1.000 0.000 0.000 0.000
#> SRR2936869     4  0.0000      0.991 0.000 0.000 0.000 1.000
#> SRR2936868     4  0.0000      0.991 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
#> SRR2936906     1  0.0000      0.896 1.000 0.000 0.000 0.000 0.000
#> SRR2936909     1  0.0000      0.896 1.000 0.000 0.000 0.000 0.000
#> SRR2936918     1  0.0000      0.896 1.000 0.000 0.000 0.000 0.000
#> SRR2936917     2  0.3661      0.725 0.000 0.724 0.276 0.000 0.000
#> SRR2936916     3  0.6094      0.585 0.100 0.064 0.664 0.000 0.172
#> SRR2936915     1  0.3521      0.707 0.764 0.000 0.000 0.004 0.232
#> SRR2936914     2  0.3661      0.725 0.000 0.724 0.276 0.000 0.000
#> SRR2936913     2  0.3661      0.725 0.000 0.724 0.276 0.000 0.000
#> SRR2936912     1  0.0000      0.896 1.000 0.000 0.000 0.000 0.000
#> SRR2936910     1  0.0000      0.896 1.000 0.000 0.000 0.000 0.000
#> SRR2936911     2  0.3661      0.725 0.000 0.724 0.276 0.000 0.000
#> SRR2936907     2  0.0000      0.858 0.000 1.000 0.000 0.000 0.000
#> SRR2936908     2  0.0000      0.858 0.000 1.000 0.000 0.000 0.000
#> SRR2936904     4  0.1965      0.858 0.096 0.000 0.000 0.904 0.000
#> SRR2936905     2  0.0000      0.858 0.000 1.000 0.000 0.000 0.000
#> SRR2936903     1  0.4045      0.519 0.644 0.000 0.000 0.000 0.356
#> SRR2936901     5  0.4101      0.957 0.048 0.000 0.184 0.000 0.768
#> SRR2936902     3  0.0290      0.825 0.000 0.000 0.992 0.000 0.008
#> SRR2936900     1  0.3612      0.667 0.732 0.000 0.000 0.000 0.268
#> SRR2936898     5  0.3845      0.978 0.024 0.000 0.208 0.000 0.768
#> SRR2936899     5  0.3845      0.978 0.024 0.000 0.208 0.000 0.768
#> SRR2936897     1  0.0000      0.896 1.000 0.000 0.000 0.000 0.000
#> SRR2936896     2  0.3661      0.725 0.000 0.724 0.276 0.000 0.000
#> SRR2936894     1  0.0000      0.896 1.000 0.000 0.000 0.000 0.000
#> SRR2936893     2  0.0000      0.858 0.000 1.000 0.000 0.000 0.000
#> SRR2936895     3  0.3895      0.389 0.000 0.320 0.680 0.000 0.000
#> SRR2936892     2  0.0000      0.858 0.000 1.000 0.000 0.000 0.000
#> SRR2936891     1  0.0000      0.896 1.000 0.000 0.000 0.000 0.000
#> SRR2936890     2  0.0000      0.858 0.000 1.000 0.000 0.000 0.000
#> SRR2936886     4  0.0162      0.966 0.004 0.000 0.000 0.996 0.000
#> SRR2936885     1  0.3586      0.671 0.736 0.000 0.000 0.000 0.264
#> SRR2936888     1  0.0000      0.896 1.000 0.000 0.000 0.000 0.000
#> SRR2936889     2  0.0000      0.858 0.000 1.000 0.000 0.000 0.000
#> SRR2936887     4  0.0162      0.966 0.004 0.000 0.000 0.996 0.000
#> SRR2936884     3  0.0162      0.820 0.000 0.004 0.996 0.000 0.000
#> SRR2936883     3  0.0290      0.825 0.000 0.000 0.992 0.000 0.008
#> SRR2936881     3  0.0290      0.825 0.000 0.000 0.992 0.000 0.008
#> SRR2936882     1  0.3612      0.667 0.732 0.000 0.000 0.000 0.268
#> SRR2936880     3  0.0290      0.825 0.000 0.000 0.992 0.000 0.008
#> SRR2936878     2  0.3661      0.725 0.000 0.724 0.276 0.000 0.000
#> SRR2936879     1  0.2629      0.806 0.860 0.000 0.000 0.004 0.136
#> SRR2936875     2  0.0000      0.858 0.000 1.000 0.000 0.000 0.000
#> SRR2936877     2  0.3661      0.725 0.000 0.724 0.276 0.000 0.000
#> SRR2936876     1  0.1892      0.847 0.916 0.000 0.000 0.004 0.080
#> SRR2936873     1  0.0000      0.896 1.000 0.000 0.000 0.000 0.000
#> SRR2936872     2  0.0000      0.858 0.000 1.000 0.000 0.000 0.000
#> SRR2936871     2  0.0000      0.858 0.000 1.000 0.000 0.000 0.000
#> SRR2936874     2  0.0000      0.858 0.000 1.000 0.000 0.000 0.000
#> SRR2936870     1  0.0000      0.896 1.000 0.000 0.000 0.000 0.000
#> SRR2936869     4  0.0162      0.966 0.004 0.000 0.000 0.996 0.000
#> SRR2936868     4  0.0162      0.966 0.004 0.000 0.000 0.996 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
#> SRR2936906     1  0.0000      0.826 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936909     1  0.0000      0.826 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936918     1  0.0000      0.826 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936917     2  0.5288      0.600 0.000 0.592 0.252 0.000 0.000 0.156
#> SRR2936916     6  0.4095     -0.454 0.000 0.008 0.480 0.000 0.000 0.512
#> SRR2936915     6  0.2527      0.304 0.168 0.000 0.000 0.000 0.000 0.832
#> SRR2936914     2  0.5288      0.600 0.000 0.592 0.252 0.000 0.000 0.156
#> SRR2936913     2  0.5288      0.600 0.000 0.592 0.252 0.000 0.000 0.156
#> SRR2936912     1  0.0000      0.826 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936910     1  0.0000      0.826 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936911     2  0.5288      0.600 0.000 0.592 0.252 0.000 0.000 0.156
#> SRR2936907     2  0.0000      0.803 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936908     2  0.0000      0.803 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936904     4  0.3030      0.712 0.168 0.000 0.000 0.816 0.008 0.008
#> SRR2936905     2  0.0000      0.803 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936903     1  0.3797      0.383 0.580 0.000 0.000 0.000 0.420 0.000
#> SRR2936901     5  0.0363      1.000 0.000 0.000 0.012 0.000 0.988 0.000
#> SRR2936902     3  0.0458      0.882 0.000 0.000 0.984 0.000 0.016 0.000
#> SRR2936900     1  0.3547      0.549 0.668 0.000 0.000 0.000 0.332 0.000
#> SRR2936898     5  0.0363      1.000 0.000 0.000 0.012 0.000 0.988 0.000
#> SRR2936899     5  0.0363      1.000 0.000 0.000 0.012 0.000 0.988 0.000
#> SRR2936897     1  0.0000      0.826 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936896     2  0.5288      0.600 0.000 0.592 0.252 0.000 0.000 0.156
#> SRR2936894     1  0.0000      0.826 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936893     2  0.0000      0.803 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936895     3  0.4915      0.403 0.000 0.188 0.656 0.000 0.000 0.156
#> SRR2936892     2  0.0000      0.803 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936891     1  0.0000      0.826 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936890     2  0.0000      0.803 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936886     4  0.0000      0.936 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR2936885     1  0.3499      0.565 0.680 0.000 0.000 0.000 0.320 0.000
#> SRR2936888     1  0.0000      0.826 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936889     2  0.0000      0.803 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936887     4  0.0000      0.936 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR2936884     3  0.0260      0.875 0.000 0.000 0.992 0.000 0.008 0.000
#> SRR2936883     3  0.0458      0.882 0.000 0.000 0.984 0.000 0.016 0.000
#> SRR2936881     3  0.0458      0.882 0.000 0.000 0.984 0.000 0.016 0.000
#> SRR2936882     1  0.3547      0.549 0.668 0.000 0.000 0.000 0.332 0.000
#> SRR2936880     3  0.0458      0.882 0.000 0.000 0.984 0.000 0.016 0.000
#> SRR2936878     2  0.5288      0.600 0.000 0.592 0.252 0.000 0.000 0.156
#> SRR2936879     6  0.4161      0.101 0.448 0.000 0.000 0.000 0.012 0.540
#> SRR2936875     2  0.0000      0.803 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936877     2  0.5288      0.600 0.000 0.592 0.252 0.000 0.000 0.156
#> SRR2936876     1  0.4184     -0.310 0.500 0.000 0.000 0.000 0.012 0.488
#> SRR2936873     1  0.0000      0.826 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936872     2  0.0000      0.803 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936871     2  0.0000      0.803 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936874     2  0.0000      0.803 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936870     1  0.0000      0.826 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936869     4  0.0000      0.936 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR2936868     4  0.0000      0.936 0.000 0.000 0.000 1.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 14198 rows and 51 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'pam' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 6.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk MAD-pam-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.972       0.988         0.5089 0.492   0.492
#> 3 3 1.000           0.963       0.986         0.3287 0.708   0.474
#> 4 4 0.863           0.752       0.838         0.0867 0.898   0.700
#> 5 5 1.000           0.996       0.998         0.0724 0.885   0.605
#> 6 6 0.946           0.858       0.922         0.0474 0.962   0.823

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
#> SRR2936906     1   0.000      0.990 1.000 0.000
#> SRR2936909     1   0.000      0.990 1.000 0.000
#> SRR2936918     1   0.000      0.990 1.000 0.000
#> SRR2936917     2   0.000      0.984 0.000 1.000
#> SRR2936916     2   0.000      0.984 0.000 1.000
#> SRR2936915     1   0.204      0.959 0.968 0.032
#> SRR2936914     2   0.000      0.984 0.000 1.000
#> SRR2936913     2   0.000      0.984 0.000 1.000
#> SRR2936912     1   0.000      0.990 1.000 0.000
#> SRR2936910     1   0.000      0.990 1.000 0.000
#> SRR2936911     2   0.000      0.984 0.000 1.000
#> SRR2936907     2   0.000      0.984 0.000 1.000
#> SRR2936908     2   0.000      0.984 0.000 1.000
#> SRR2936904     1   0.000      0.990 1.000 0.000
#> SRR2936905     2   0.000      0.984 0.000 1.000
#> SRR2936903     1   0.000      0.990 1.000 0.000
#> SRR2936901     1   0.000      0.990 1.000 0.000
#> SRR2936902     2   0.000      0.984 0.000 1.000
#> SRR2936900     1   0.000      0.990 1.000 0.000
#> SRR2936898     1   0.000      0.990 1.000 0.000
#> SRR2936899     1   0.000      0.990 1.000 0.000
#> SRR2936897     1   0.000      0.990 1.000 0.000
#> SRR2936896     2   0.000      0.984 0.000 1.000
#> SRR2936894     1   0.000      0.990 1.000 0.000
#> SRR2936893     2   0.000      0.984 0.000 1.000
#> SRR2936895     2   0.000      0.984 0.000 1.000
#> SRR2936892     2   0.000      0.984 0.000 1.000
#> SRR2936891     1   0.000      0.990 1.000 0.000
#> SRR2936890     2   0.000      0.984 0.000 1.000
#> SRR2936886     1   0.000      0.990 1.000 0.000
#> SRR2936885     1   0.000      0.990 1.000 0.000
#> SRR2936888     1   0.000      0.990 1.000 0.000
#> SRR2936889     2   0.000      0.984 0.000 1.000
#> SRR2936887     1   0.000      0.990 1.000 0.000
#> SRR2936884     2   0.000      0.984 0.000 1.000
#> SRR2936883     2   0.000      0.984 0.000 1.000
#> SRR2936881     2   0.000      0.984 0.000 1.000
#> SRR2936882     1   0.000      0.990 1.000 0.000
#> SRR2936880     2   0.000      0.984 0.000 1.000
#> SRR2936878     2   0.000      0.984 0.000 1.000
#> SRR2936879     2   0.722      0.750 0.200 0.800
#> SRR2936875     2   0.000      0.984 0.000 1.000
#> SRR2936877     2   0.000      0.984 0.000 1.000
#> SRR2936876     1   0.000      0.990 1.000 0.000
#> SRR2936873     1   0.000      0.990 1.000 0.000
#> SRR2936872     2   0.000      0.984 0.000 1.000
#> SRR2936871     2   0.000      0.984 0.000 1.000
#> SRR2936874     2   0.000      0.984 0.000 1.000
#> SRR2936870     1   0.000      0.990 1.000 0.000
#> SRR2936869     2   0.722      0.748 0.200 0.800
#> SRR2936868     1   0.722      0.745 0.800 0.200

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR2936906     1  0.0000      1.000 1.000 0.000 0.000
#> SRR2936909     1  0.0000      1.000 1.000 0.000 0.000
#> SRR2936918     1  0.0000      1.000 1.000 0.000 0.000
#> SRR2936917     2  0.0000      0.988 0.000 1.000 0.000
#> SRR2936916     3  0.0000      0.968 0.000 0.000 1.000
#> SRR2936915     3  0.0000      0.968 0.000 0.000 1.000
#> SRR2936914     2  0.0000      0.988 0.000 1.000 0.000
#> SRR2936913     2  0.0000      0.988 0.000 1.000 0.000
#> SRR2936912     1  0.0000      1.000 1.000 0.000 0.000
#> SRR2936910     1  0.0000      1.000 1.000 0.000 0.000
#> SRR2936911     2  0.0000      0.988 0.000 1.000 0.000
#> SRR2936907     2  0.0000      0.988 0.000 1.000 0.000
#> SRR2936908     2  0.0000      0.988 0.000 1.000 0.000
#> SRR2936904     3  0.2356      0.901 0.072 0.000 0.928
#> SRR2936905     2  0.0000      0.988 0.000 1.000 0.000
#> SRR2936903     3  0.6267      0.173 0.452 0.000 0.548
#> SRR2936901     3  0.0000      0.968 0.000 0.000 1.000
#> SRR2936902     3  0.0000      0.968 0.000 0.000 1.000
#> SRR2936900     1  0.0000      1.000 1.000 0.000 0.000
#> SRR2936898     3  0.0000      0.968 0.000 0.000 1.000
#> SRR2936899     3  0.0000      0.968 0.000 0.000 1.000
#> SRR2936897     1  0.0000      1.000 1.000 0.000 0.000
#> SRR2936896     2  0.0000      0.988 0.000 1.000 0.000
#> SRR2936894     1  0.0000      1.000 1.000 0.000 0.000
#> SRR2936893     2  0.0000      0.988 0.000 1.000 0.000
#> SRR2936895     3  0.0237      0.965 0.000 0.004 0.996
#> SRR2936892     2  0.0000      0.988 0.000 1.000 0.000
#> SRR2936891     1  0.0000      1.000 1.000 0.000 0.000
#> SRR2936890     2  0.0000      0.988 0.000 1.000 0.000
#> SRR2936886     3  0.0000      0.968 0.000 0.000 1.000
#> SRR2936885     1  0.0000      1.000 1.000 0.000 0.000
#> SRR2936888     1  0.0000      1.000 1.000 0.000 0.000
#> SRR2936889     2  0.0000      0.988 0.000 1.000 0.000
#> SRR2936887     3  0.0000      0.968 0.000 0.000 1.000
#> SRR2936884     2  0.4555      0.749 0.000 0.800 0.200
#> SRR2936883     3  0.0000      0.968 0.000 0.000 1.000
#> SRR2936881     3  0.0000      0.968 0.000 0.000 1.000
#> SRR2936882     1  0.0000      1.000 1.000 0.000 0.000
#> SRR2936880     3  0.0000      0.968 0.000 0.000 1.000
#> SRR2936878     2  0.0000      0.988 0.000 1.000 0.000
#> SRR2936879     3  0.0000      0.968 0.000 0.000 1.000
#> SRR2936875     2  0.0000      0.988 0.000 1.000 0.000
#> SRR2936877     2  0.0000      0.988 0.000 1.000 0.000
#> SRR2936876     3  0.0000      0.968 0.000 0.000 1.000
#> SRR2936873     1  0.0000      1.000 1.000 0.000 0.000
#> SRR2936872     2  0.0000      0.988 0.000 1.000 0.000
#> SRR2936871     2  0.0000      0.988 0.000 1.000 0.000
#> SRR2936874     2  0.0000      0.988 0.000 1.000 0.000
#> SRR2936870     1  0.0000      1.000 1.000 0.000 0.000
#> SRR2936869     3  0.0000      0.968 0.000 0.000 1.000
#> SRR2936868     3  0.0000      0.968 0.000 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR2936906     1   0.497      1.000 0.548 0.000 0.000 0.452
#> SRR2936909     1   0.497      1.000 0.548 0.000 0.000 0.452
#> SRR2936918     1   0.497      1.000 0.548 0.000 0.000 0.452
#> SRR2936917     4   0.497      0.722 0.452 0.000 0.000 0.548
#> SRR2936916     3   0.497      0.794 0.000 0.452 0.548 0.000
#> SRR2936915     3   0.000      0.686 0.000 0.000 1.000 0.000
#> SRR2936914     4   0.497      0.722 0.452 0.000 0.000 0.548
#> SRR2936913     4   0.497      0.722 0.452 0.000 0.000 0.548
#> SRR2936912     1   0.497      1.000 0.548 0.000 0.000 0.452
#> SRR2936910     1   0.497      1.000 0.548 0.000 0.000 0.452
#> SRR2936911     4   0.497      0.722 0.452 0.000 0.000 0.548
#> SRR2936907     2   0.497      0.806 0.452 0.548 0.000 0.000
#> SRR2936908     2   0.497      0.806 0.452 0.548 0.000 0.000
#> SRR2936904     3   0.147      0.646 0.052 0.000 0.948 0.000
#> SRR2936905     2   0.497      0.806 0.452 0.548 0.000 0.000
#> SRR2936903     4   0.769     -0.616 0.252 0.000 0.296 0.452
#> SRR2936901     3   0.497      0.794 0.000 0.452 0.548 0.000
#> SRR2936902     3   0.497      0.794 0.000 0.452 0.548 0.000
#> SRR2936900     1   0.497      1.000 0.548 0.000 0.000 0.452
#> SRR2936898     3   0.497      0.794 0.000 0.452 0.548 0.000
#> SRR2936899     3   0.497      0.794 0.000 0.452 0.548 0.000
#> SRR2936897     1   0.497      1.000 0.548 0.000 0.000 0.452
#> SRR2936896     2   0.497      0.806 0.452 0.548 0.000 0.000
#> SRR2936894     1   0.497      1.000 0.548 0.000 0.000 0.452
#> SRR2936893     2   0.497      0.806 0.452 0.548 0.000 0.000
#> SRR2936895     2   0.494     -0.718 0.000 0.564 0.436 0.000
#> SRR2936892     2   0.497      0.806 0.452 0.548 0.000 0.000
#> SRR2936891     1   0.497      1.000 0.548 0.000 0.000 0.452
#> SRR2936890     2   0.497      0.806 0.452 0.548 0.000 0.000
#> SRR2936886     3   0.000      0.686 0.000 0.000 1.000 0.000
#> SRR2936885     1   0.497      1.000 0.548 0.000 0.000 0.452
#> SRR2936888     1   0.497      1.000 0.548 0.000 0.000 0.452
#> SRR2936889     2   0.497      0.806 0.452 0.548 0.000 0.000
#> SRR2936887     3   0.000      0.686 0.000 0.000 1.000 0.000
#> SRR2936884     2   0.000      0.220 0.000 1.000 0.000 0.000
#> SRR2936883     3   0.497      0.794 0.000 0.452 0.548 0.000
#> SRR2936881     3   0.497      0.794 0.000 0.452 0.548 0.000
#> SRR2936882     1   0.497      1.000 0.548 0.000 0.000 0.452
#> SRR2936880     3   0.497      0.794 0.000 0.452 0.548 0.000
#> SRR2936878     4   0.497      0.722 0.452 0.000 0.000 0.548
#> SRR2936879     3   0.497      0.794 0.000 0.452 0.548 0.000
#> SRR2936875     2   0.497      0.806 0.452 0.548 0.000 0.000
#> SRR2936877     4   0.497      0.722 0.452 0.000 0.000 0.548
#> SRR2936876     3   0.497      0.255 0.000 0.000 0.548 0.452
#> SRR2936873     1   0.497      1.000 0.548 0.000 0.000 0.452
#> SRR2936872     2   0.497      0.806 0.452 0.548 0.000 0.000
#> SRR2936871     2   0.497      0.806 0.452 0.548 0.000 0.000
#> SRR2936874     2   0.497      0.806 0.452 0.548 0.000 0.000
#> SRR2936870     1   0.497      1.000 0.548 0.000 0.000 0.452
#> SRR2936869     3   0.000      0.686 0.000 0.000 1.000 0.000
#> SRR2936868     3   0.000      0.686 0.000 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette p1    p2 p3 p4    p5
#> SRR2936906     1   0.000      1.000  1 0.000  0  0 0.000
#> SRR2936909     1   0.000      1.000  1 0.000  0  0 0.000
#> SRR2936918     1   0.000      1.000  1 0.000  0  0 0.000
#> SRR2936917     5   0.000      1.000  0 0.000  0  0 1.000
#> SRR2936916     3   0.000      1.000  0 0.000  1  0 0.000
#> SRR2936915     4   0.000      1.000  0 0.000  0  1 0.000
#> SRR2936914     5   0.000      1.000  0 0.000  0  0 1.000
#> SRR2936913     5   0.000      1.000  0 0.000  0  0 1.000
#> SRR2936912     1   0.000      1.000  1 0.000  0  0 0.000
#> SRR2936910     1   0.000      1.000  1 0.000  0  0 0.000
#> SRR2936911     5   0.000      1.000  0 0.000  0  0 1.000
#> SRR2936907     2   0.000      0.991  0 1.000  0  0 0.000
#> SRR2936908     2   0.000      0.991  0 1.000  0  0 0.000
#> SRR2936904     4   0.000      1.000  0 0.000  0  1 0.000
#> SRR2936905     2   0.000      0.991  0 1.000  0  0 0.000
#> SRR2936903     1   0.000      1.000  1 0.000  0  0 0.000
#> SRR2936901     3   0.000      1.000  0 0.000  1  0 0.000
#> SRR2936902     3   0.000      1.000  0 0.000  1  0 0.000
#> SRR2936900     1   0.000      1.000  1 0.000  0  0 0.000
#> SRR2936898     3   0.000      1.000  0 0.000  1  0 0.000
#> SRR2936899     3   0.000      1.000  0 0.000  1  0 0.000
#> SRR2936897     1   0.000      1.000  1 0.000  0  0 0.000
#> SRR2936896     2   0.196      0.894  0 0.904  0  0 0.096
#> SRR2936894     1   0.000      1.000  1 0.000  0  0 0.000
#> SRR2936893     2   0.000      0.991  0 1.000  0  0 0.000
#> SRR2936895     3   0.000      1.000  0 0.000  1  0 0.000
#> SRR2936892     2   0.000      0.991  0 1.000  0  0 0.000
#> SRR2936891     1   0.000      1.000  1 0.000  0  0 0.000
#> SRR2936890     2   0.000      0.991  0 1.000  0  0 0.000
#> SRR2936886     4   0.000      1.000  0 0.000  0  1 0.000
#> SRR2936885     1   0.000      1.000  1 0.000  0  0 0.000
#> SRR2936888     1   0.000      1.000  1 0.000  0  0 0.000
#> SRR2936889     2   0.000      0.991  0 1.000  0  0 0.000
#> SRR2936887     4   0.000      1.000  0 0.000  0  1 0.000
#> SRR2936884     3   0.000      1.000  0 0.000  1  0 0.000
#> SRR2936883     3   0.000      1.000  0 0.000  1  0 0.000
#> SRR2936881     3   0.000      1.000  0 0.000  1  0 0.000
#> SRR2936882     1   0.000      1.000  1 0.000  0  0 0.000
#> SRR2936880     3   0.000      1.000  0 0.000  1  0 0.000
#> SRR2936878     5   0.000      1.000  0 0.000  0  0 1.000
#> SRR2936879     3   0.000      1.000  0 0.000  1  0 0.000
#> SRR2936875     2   0.000      0.991  0 1.000  0  0 0.000
#> SRR2936877     5   0.000      1.000  0 0.000  0  0 1.000
#> SRR2936876     1   0.000      1.000  1 0.000  0  0 0.000
#> SRR2936873     1   0.000      1.000  1 0.000  0  0 0.000
#> SRR2936872     2   0.000      0.991  0 1.000  0  0 0.000
#> SRR2936871     2   0.000      0.991  0 1.000  0  0 0.000
#> SRR2936874     2   0.000      0.991  0 1.000  0  0 0.000
#> SRR2936870     1   0.000      1.000  1 0.000  0  0 0.000
#> SRR2936869     4   0.000      1.000  0 0.000  0  1 0.000
#> SRR2936868     4   0.000      1.000  0 0.000  0  1 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
#> SRR2936906     1   0.000     0.9296 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936909     1   0.000     0.9296 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936918     1   0.000     0.9296 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936917     5   0.000     1.0000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR2936916     3   0.381     0.8184 0.000 0.000 0.572 0.000 0.000 0.428
#> SRR2936915     4   0.381     0.4402 0.000 0.000 0.428 0.572 0.000 0.000
#> SRR2936914     5   0.000     1.0000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR2936913     5   0.000     1.0000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR2936912     1   0.000     0.9296 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936910     1   0.000     0.9296 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936911     5   0.000     1.0000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR2936907     2   0.000     0.9909 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936908     2   0.000     0.9909 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936904     4   0.000     0.9060 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR2936905     2   0.000     0.9909 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936903     6   0.381     0.2594 0.000 0.000 0.428 0.000 0.000 0.572
#> SRR2936901     3   0.026     0.6309 0.000 0.000 0.992 0.000 0.000 0.008
#> SRR2936902     3   0.381     0.8184 0.000 0.000 0.572 0.000 0.000 0.428
#> SRR2936900     6   0.381     0.7131 0.428 0.000 0.000 0.000 0.000 0.572
#> SRR2936898     3   0.000     0.6390 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR2936899     3   0.000     0.6390 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR2936897     1   0.000     0.9296 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936896     2   0.176     0.8938 0.000 0.904 0.000 0.000 0.096 0.000
#> SRR2936894     1   0.000     0.9296 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936893     2   0.000     0.9909 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936895     3   0.381     0.8184 0.000 0.000 0.572 0.000 0.000 0.428
#> SRR2936892     2   0.000     0.9909 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936891     1   0.000     0.9296 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936890     2   0.000     0.9909 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936886     4   0.000     0.9060 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR2936885     6   0.381     0.7131 0.428 0.000 0.000 0.000 0.000 0.572
#> SRR2936888     1   0.000     0.9296 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936889     2   0.000     0.9909 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936887     4   0.000     0.9060 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR2936884     3   0.381     0.8184 0.000 0.000 0.572 0.000 0.000 0.428
#> SRR2936883     3   0.381     0.8184 0.000 0.000 0.572 0.000 0.000 0.428
#> SRR2936881     3   0.381     0.8184 0.000 0.000 0.572 0.000 0.000 0.428
#> SRR2936882     6   0.381     0.7131 0.428 0.000 0.000 0.000 0.000 0.572
#> SRR2936880     3   0.381     0.8184 0.000 0.000 0.572 0.000 0.000 0.428
#> SRR2936878     5   0.000     1.0000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR2936879     3   0.000     0.6390 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR2936875     2   0.000     0.9909 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936877     5   0.000     1.0000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR2936876     1   0.406     0.0995 0.552 0.000 0.440 0.000 0.000 0.008
#> SRR2936873     1   0.000     0.9296 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936872     2   0.000     0.9909 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936871     2   0.000     0.9909 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936874     2   0.000     0.9909 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936870     1   0.000     0.9296 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936869     4   0.000     0.9060 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR2936868     4   0.000     0.9060 0.000 0.000 0.000 1.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-pam-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-pam-collect-classes

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


MAD:mclust*

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

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

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

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

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

collect_plots(res)

plot of chunk MAD-mclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.442           0.802       0.834         0.4352 0.534   0.534
#> 3 3 0.592           0.740       0.873         0.4687 0.661   0.440
#> 4 4 0.738           0.800       0.864         0.1162 0.881   0.670
#> 5 5 0.903           0.827       0.933         0.0964 0.908   0.674
#> 6 6 0.852           0.760       0.882         0.0534 0.956   0.786

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
#> SRR2936906     2   0.000      0.729 0.000 1.000
#> SRR2936909     2   0.000      0.729 0.000 1.000
#> SRR2936918     2   0.000      0.729 0.000 1.000
#> SRR2936917     2   0.680      0.737 0.180 0.820
#> SRR2936916     2   0.278      0.687 0.048 0.952
#> SRR2936915     2   0.000      0.729 0.000 1.000
#> SRR2936914     2   0.680      0.737 0.180 0.820
#> SRR2936913     2   0.680      0.737 0.180 0.820
#> SRR2936912     2   0.000      0.729 0.000 1.000
#> SRR2936910     2   0.000      0.729 0.000 1.000
#> SRR2936911     2   0.680      0.737 0.180 0.820
#> SRR2936907     2   0.963      0.687 0.388 0.612
#> SRR2936908     2   0.963      0.687 0.388 0.612
#> SRR2936904     2   0.000      0.729 0.000 1.000
#> SRR2936905     2   0.963      0.687 0.388 0.612
#> SRR2936903     1   0.963      0.974 0.612 0.388
#> SRR2936901     1   0.963      0.974 0.612 0.388
#> SRR2936902     1   0.963      0.974 0.612 0.388
#> SRR2936900     1   0.963      0.974 0.612 0.388
#> SRR2936898     1   0.963      0.974 0.612 0.388
#> SRR2936899     1   0.963      0.974 0.612 0.388
#> SRR2936897     2   0.000      0.729 0.000 1.000
#> SRR2936896     2   0.278      0.687 0.048 0.952
#> SRR2936894     2   0.000      0.729 0.000 1.000
#> SRR2936893     2   0.963      0.687 0.388 0.612
#> SRR2936895     2   0.295      0.682 0.052 0.948
#> SRR2936892     2   0.963      0.687 0.388 0.612
#> SRR2936891     2   0.000      0.729 0.000 1.000
#> SRR2936890     2   0.963      0.687 0.388 0.612
#> SRR2936886     1   0.988      0.946 0.564 0.436
#> SRR2936885     1   0.963      0.974 0.612 0.388
#> SRR2936888     1   0.988      0.946 0.564 0.436
#> SRR2936889     2   0.963      0.687 0.388 0.612
#> SRR2936887     1   0.988      0.946 0.564 0.436
#> SRR2936884     1   0.963      0.974 0.612 0.388
#> SRR2936883     1   0.963      0.974 0.612 0.388
#> SRR2936881     1   0.963      0.974 0.612 0.388
#> SRR2936882     1   0.963      0.974 0.612 0.388
#> SRR2936880     1   0.963      0.974 0.612 0.388
#> SRR2936878     2   0.680      0.737 0.180 0.820
#> SRR2936879     2   0.000      0.729 0.000 1.000
#> SRR2936875     2   0.963      0.687 0.388 0.612
#> SRR2936877     2   0.680      0.737 0.180 0.820
#> SRR2936876     2   0.000      0.729 0.000 1.000
#> SRR2936873     2   0.000      0.729 0.000 1.000
#> SRR2936872     2   0.963      0.687 0.388 0.612
#> SRR2936871     2   0.963      0.687 0.388 0.612
#> SRR2936874     2   0.963      0.687 0.388 0.612
#> SRR2936870     1   0.988      0.946 0.564 0.436
#> SRR2936869     1   0.988      0.946 0.564 0.436
#> SRR2936868     1   0.988      0.946 0.564 0.436

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR2936906     1  0.0000      0.797 1.000 0.000 0.000
#> SRR2936909     1  0.0829      0.797 0.984 0.004 0.012
#> SRR2936918     1  0.0000      0.797 1.000 0.000 0.000
#> SRR2936917     2  0.6421      0.394 0.424 0.572 0.004
#> SRR2936916     1  0.5115      0.646 0.796 0.188 0.016
#> SRR2936915     1  0.5008      0.657 0.804 0.180 0.016
#> SRR2936914     2  0.6421      0.394 0.424 0.572 0.004
#> SRR2936913     2  0.6421      0.394 0.424 0.572 0.004
#> SRR2936912     1  0.0000      0.797 1.000 0.000 0.000
#> SRR2936910     1  0.0000      0.797 1.000 0.000 0.000
#> SRR2936911     2  0.6421      0.394 0.424 0.572 0.004
#> SRR2936907     2  0.0000      0.769 0.000 1.000 0.000
#> SRR2936908     2  0.0000      0.769 0.000 1.000 0.000
#> SRR2936904     1  0.5115      0.646 0.796 0.188 0.016
#> SRR2936905     2  0.0000      0.769 0.000 1.000 0.000
#> SRR2936903     3  0.0000      0.985 0.000 0.000 1.000
#> SRR2936901     3  0.0000      0.985 0.000 0.000 1.000
#> SRR2936902     3  0.0000      0.985 0.000 0.000 1.000
#> SRR2936900     3  0.3412      0.820 0.124 0.000 0.876
#> SRR2936898     3  0.0000      0.985 0.000 0.000 1.000
#> SRR2936899     3  0.0000      0.985 0.000 0.000 1.000
#> SRR2936897     1  0.0592      0.798 0.988 0.000 0.012
#> SRR2936896     2  0.6683      0.173 0.492 0.500 0.008
#> SRR2936894     1  0.0000      0.797 1.000 0.000 0.000
#> SRR2936893     2  0.0000      0.769 0.000 1.000 0.000
#> SRR2936895     1  0.8380      0.611 0.600 0.124 0.276
#> SRR2936892     2  0.0000      0.769 0.000 1.000 0.000
#> SRR2936891     1  0.0000      0.797 1.000 0.000 0.000
#> SRR2936890     2  0.0000      0.769 0.000 1.000 0.000
#> SRR2936886     1  0.5785      0.651 0.668 0.000 0.332
#> SRR2936885     3  0.0592      0.975 0.012 0.000 0.988
#> SRR2936888     1  0.5785      0.651 0.668 0.000 0.332
#> SRR2936889     2  0.0000      0.769 0.000 1.000 0.000
#> SRR2936887     1  0.5785      0.651 0.668 0.000 0.332
#> SRR2936884     3  0.0000      0.985 0.000 0.000 1.000
#> SRR2936883     3  0.0000      0.985 0.000 0.000 1.000
#> SRR2936881     3  0.0000      0.985 0.000 0.000 1.000
#> SRR2936882     3  0.0000      0.985 0.000 0.000 1.000
#> SRR2936880     3  0.0000      0.985 0.000 0.000 1.000
#> SRR2936878     2  0.6421      0.394 0.424 0.572 0.004
#> SRR2936879     1  0.5115      0.646 0.796 0.188 0.016
#> SRR2936875     2  0.0000      0.769 0.000 1.000 0.000
#> SRR2936877     2  0.6421      0.394 0.424 0.572 0.004
#> SRR2936876     1  0.0983      0.797 0.980 0.004 0.016
#> SRR2936873     1  0.0000      0.797 1.000 0.000 0.000
#> SRR2936872     2  0.0000      0.769 0.000 1.000 0.000
#> SRR2936871     2  0.0000      0.769 0.000 1.000 0.000
#> SRR2936874     2  0.0000      0.769 0.000 1.000 0.000
#> SRR2936870     1  0.5785      0.651 0.668 0.000 0.332
#> SRR2936869     1  0.5785      0.651 0.668 0.000 0.332
#> SRR2936868     1  0.5785      0.651 0.668 0.000 0.332

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR2936906     1  0.4804     0.8841 0.616 0.000 0.000 0.384
#> SRR2936909     1  0.5112     0.8809 0.608 0.008 0.000 0.384
#> SRR2936918     1  0.4804     0.8841 0.616 0.000 0.000 0.384
#> SRR2936917     2  0.4830     0.7180 0.392 0.608 0.000 0.000
#> SRR2936916     1  0.7071     0.7835 0.504 0.112 0.004 0.380
#> SRR2936915     1  0.7877     0.5011 0.392 0.224 0.004 0.380
#> SRR2936914     2  0.4830     0.7180 0.392 0.608 0.000 0.000
#> SRR2936913     2  0.4830     0.7180 0.392 0.608 0.000 0.000
#> SRR2936912     1  0.4804     0.8841 0.616 0.000 0.000 0.384
#> SRR2936910     1  0.4804     0.8841 0.616 0.000 0.000 0.384
#> SRR2936911     2  0.4830     0.7180 0.392 0.608 0.000 0.000
#> SRR2936907     2  0.0000     0.8397 0.000 1.000 0.000 0.000
#> SRR2936908     2  0.0000     0.8397 0.000 1.000 0.000 0.000
#> SRR2936904     2  0.7005    -0.0394 0.104 0.500 0.004 0.392
#> SRR2936905     2  0.0000     0.8397 0.000 1.000 0.000 0.000
#> SRR2936903     3  0.1389     0.8567 0.000 0.000 0.952 0.048
#> SRR2936901     3  0.0000     0.8888 0.000 0.000 1.000 0.000
#> SRR2936902     3  0.0000     0.8888 0.000 0.000 1.000 0.000
#> SRR2936900     3  0.5613     0.1728 0.028 0.000 0.592 0.380
#> SRR2936898     3  0.0000     0.8888 0.000 0.000 1.000 0.000
#> SRR2936899     3  0.0000     0.8888 0.000 0.000 1.000 0.000
#> SRR2936897     1  0.4804     0.8841 0.616 0.000 0.000 0.384
#> SRR2936896     1  0.7504     0.6978 0.460 0.160 0.004 0.376
#> SRR2936894     1  0.4804     0.8841 0.616 0.000 0.000 0.384
#> SRR2936893     2  0.0000     0.8397 0.000 1.000 0.000 0.000
#> SRR2936895     1  0.7310     0.7458 0.480 0.136 0.004 0.380
#> SRR2936892     2  0.0000     0.8397 0.000 1.000 0.000 0.000
#> SRR2936891     1  0.4804     0.8841 0.616 0.000 0.000 0.384
#> SRR2936890     2  0.0000     0.8397 0.000 1.000 0.000 0.000
#> SRR2936886     4  0.0188     0.9735 0.000 0.000 0.004 0.996
#> SRR2936885     3  0.5428     0.1952 0.020 0.000 0.600 0.380
#> SRR2936888     4  0.1305     0.9441 0.036 0.000 0.004 0.960
#> SRR2936889     2  0.0000     0.8397 0.000 1.000 0.000 0.000
#> SRR2936887     4  0.0188     0.9735 0.000 0.000 0.004 0.996
#> SRR2936884     3  0.0000     0.8888 0.000 0.000 1.000 0.000
#> SRR2936883     3  0.0000     0.8888 0.000 0.000 1.000 0.000
#> SRR2936881     3  0.0000     0.8888 0.000 0.000 1.000 0.000
#> SRR2936882     3  0.1389     0.8567 0.000 0.000 0.952 0.048
#> SRR2936880     3  0.0000     0.8888 0.000 0.000 1.000 0.000
#> SRR2936878     2  0.4830     0.7180 0.392 0.608 0.000 0.000
#> SRR2936879     1  0.7027     0.7866 0.508 0.108 0.004 0.380
#> SRR2936875     2  0.0336     0.8355 0.008 0.992 0.000 0.000
#> SRR2936877     2  0.4855     0.7132 0.400 0.600 0.000 0.000
#> SRR2936876     1  0.5272     0.8787 0.608 0.008 0.004 0.380
#> SRR2936873     1  0.4804     0.8841 0.616 0.000 0.000 0.384
#> SRR2936872     2  0.0000     0.8397 0.000 1.000 0.000 0.000
#> SRR2936871     2  0.0000     0.8397 0.000 1.000 0.000 0.000
#> SRR2936874     2  0.0336     0.8355 0.008 0.992 0.000 0.000
#> SRR2936870     4  0.1305     0.9441 0.036 0.000 0.004 0.960
#> SRR2936869     4  0.0188     0.9735 0.000 0.000 0.004 0.996
#> SRR2936868     4  0.0188     0.9735 0.000 0.000 0.004 0.996

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4    p5
#> SRR2936906     1  0.0000     0.9141 1.000 0.000 0.000 0.000 0.000
#> SRR2936909     1  0.1331     0.9025 0.952 0.008 0.000 0.000 0.040
#> SRR2936918     1  0.0000     0.9141 1.000 0.000 0.000 0.000 0.000
#> SRR2936917     5  0.0162     0.9043 0.000 0.004 0.000 0.000 0.996
#> SRR2936916     1  0.2561     0.8200 0.856 0.000 0.000 0.000 0.144
#> SRR2936915     1  0.1568     0.8983 0.944 0.020 0.000 0.000 0.036
#> SRR2936914     5  0.0162     0.9043 0.000 0.004 0.000 0.000 0.996
#> SRR2936913     5  0.0162     0.9043 0.000 0.004 0.000 0.000 0.996
#> SRR2936912     1  0.0000     0.9141 1.000 0.000 0.000 0.000 0.000
#> SRR2936910     1  0.0000     0.9141 1.000 0.000 0.000 0.000 0.000
#> SRR2936911     5  0.0162     0.9043 0.000 0.004 0.000 0.000 0.996
#> SRR2936907     2  0.0000     0.9460 0.000 1.000 0.000 0.000 0.000
#> SRR2936908     2  0.0000     0.9460 0.000 1.000 0.000 0.000 0.000
#> SRR2936904     1  0.3086     0.8454 0.876 0.020 0.000 0.068 0.036
#> SRR2936905     2  0.0000     0.9460 0.000 1.000 0.000 0.000 0.000
#> SRR2936903     3  0.0963     0.9086 0.036 0.000 0.964 0.000 0.000
#> SRR2936901     3  0.0000     0.9235 0.000 0.000 1.000 0.000 0.000
#> SRR2936902     3  0.0000     0.9235 0.000 0.000 1.000 0.000 0.000
#> SRR2936900     3  0.4201     0.2830 0.408 0.000 0.592 0.000 0.000
#> SRR2936898     3  0.0000     0.9235 0.000 0.000 1.000 0.000 0.000
#> SRR2936899     3  0.1197     0.9004 0.048 0.000 0.952 0.000 0.000
#> SRR2936897     1  0.0000     0.9141 1.000 0.000 0.000 0.000 0.000
#> SRR2936896     5  0.4161     0.2013 0.392 0.000 0.000 0.000 0.608
#> SRR2936894     1  0.0000     0.9141 1.000 0.000 0.000 0.000 0.000
#> SRR2936893     2  0.0000     0.9460 0.000 1.000 0.000 0.000 0.000
#> SRR2936895     1  0.6003    -0.0414 0.444 0.000 0.112 0.000 0.444
#> SRR2936892     2  0.0000     0.9460 0.000 1.000 0.000 0.000 0.000
#> SRR2936891     1  0.0000     0.9141 1.000 0.000 0.000 0.000 0.000
#> SRR2936890     2  0.0000     0.9460 0.000 1.000 0.000 0.000 0.000
#> SRR2936886     4  0.0000     0.7623 0.000 0.000 0.000 1.000 0.000
#> SRR2936885     3  0.1908     0.8632 0.092 0.000 0.908 0.000 0.000
#> SRR2936888     4  0.4367     0.3451 0.416 0.000 0.004 0.580 0.000
#> SRR2936889     2  0.0000     0.9460 0.000 1.000 0.000 0.000 0.000
#> SRR2936887     4  0.0000     0.7623 0.000 0.000 0.000 1.000 0.000
#> SRR2936884     3  0.0000     0.9235 0.000 0.000 1.000 0.000 0.000
#> SRR2936883     3  0.0000     0.9235 0.000 0.000 1.000 0.000 0.000
#> SRR2936881     3  0.0000     0.9235 0.000 0.000 1.000 0.000 0.000
#> SRR2936882     3  0.1341     0.8976 0.056 0.000 0.944 0.000 0.000
#> SRR2936880     3  0.0000     0.9235 0.000 0.000 1.000 0.000 0.000
#> SRR2936878     5  0.0162     0.9043 0.000 0.004 0.000 0.000 0.996
#> SRR2936879     1  0.1965     0.8669 0.904 0.000 0.000 0.000 0.096
#> SRR2936875     2  0.3210     0.7311 0.212 0.788 0.000 0.000 0.000
#> SRR2936877     5  0.0162     0.9043 0.000 0.004 0.000 0.000 0.996
#> SRR2936876     1  0.1331     0.9025 0.952 0.008 0.000 0.000 0.040
#> SRR2936873     1  0.0000     0.9141 1.000 0.000 0.000 0.000 0.000
#> SRR2936872     2  0.0000     0.9460 0.000 1.000 0.000 0.000 0.000
#> SRR2936871     2  0.0000     0.9460 0.000 1.000 0.000 0.000 0.000
#> SRR2936874     2  0.3210     0.7311 0.212 0.788 0.000 0.000 0.000
#> SRR2936870     4  0.4367     0.3451 0.416 0.000 0.004 0.580 0.000
#> SRR2936869     4  0.0000     0.7623 0.000 0.000 0.000 1.000 0.000
#> SRR2936868     4  0.0000     0.7623 0.000 0.000 0.000 1.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
#> SRR2936906     1   0.000      0.949 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936909     3   0.381      0.142 0.368 0.004 0.628 0.000 0.000 0.000
#> SRR2936918     1   0.000      0.949 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936917     5   0.000      0.919 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR2936916     3   0.522      0.447 0.112 0.000 0.560 0.000 0.328 0.000
#> SRR2936915     3   0.529      0.502 0.116 0.340 0.544 0.000 0.000 0.000
#> SRR2936914     5   0.000      0.919 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR2936913     5   0.000      0.919 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR2936912     1   0.000      0.949 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936910     1   0.000      0.949 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936911     5   0.000      0.919 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR2936907     2   0.000      0.991 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936908     2   0.000      0.991 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936904     3   0.582      0.471 0.084 0.328 0.544 0.044 0.000 0.000
#> SRR2936905     2   0.000      0.991 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936903     6   0.373      0.487 0.000 0.000 0.388 0.000 0.000 0.612
#> SRR2936901     6   0.000      0.814 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR2936902     6   0.000      0.814 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR2936900     6   0.380      0.462 0.000 0.000 0.420 0.000 0.000 0.580
#> SRR2936898     6   0.000      0.814 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR2936899     6   0.000      0.814 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR2936897     1   0.302      0.517 0.768 0.000 0.232 0.000 0.000 0.000
#> SRR2936896     5   0.356      0.263 0.000 0.000 0.336 0.000 0.664 0.000
#> SRR2936894     1   0.000      0.949 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936893     2   0.000      0.991 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936895     3   0.564      0.207 0.000 0.000 0.464 0.000 0.384 0.152
#> SRR2936892     2   0.000      0.991 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936891     1   0.000      0.949 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936890     2   0.000      0.991 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936886     4   0.000      0.774 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR2936885     6   0.380      0.462 0.000 0.000 0.420 0.000 0.000 0.580
#> SRR2936888     4   0.384      0.336 0.000 0.000 0.448 0.552 0.000 0.000
#> SRR2936889     2   0.000      0.991 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936887     4   0.000      0.774 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR2936884     6   0.000      0.814 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR2936883     6   0.000      0.814 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR2936881     6   0.000      0.814 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR2936882     6   0.380      0.462 0.000 0.000 0.420 0.000 0.000 0.580
#> SRR2936880     6   0.000      0.814 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR2936878     5   0.000      0.919 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR2936879     3   0.545      0.524 0.284 0.000 0.556 0.000 0.160 0.000
#> SRR2936875     2   0.079      0.959 0.032 0.968 0.000 0.000 0.000 0.000
#> SRR2936877     5   0.000      0.919 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR2936876     3   0.215      0.517 0.116 0.004 0.880 0.000 0.000 0.000
#> SRR2936873     1   0.000      0.949 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936872     2   0.000      0.991 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936871     2   0.000      0.991 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936874     2   0.079      0.959 0.032 0.968 0.000 0.000 0.000 0.000
#> SRR2936870     4   0.384      0.336 0.000 0.000 0.448 0.552 0.000 0.000
#> SRR2936869     4   0.000      0.774 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR2936868     4   0.000      0.774 0.000 0.000 0.000 1.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 14198 rows and 51 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'NMF' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 4.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk MAD-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.986       0.993         0.4682 0.534   0.534
#> 3 3 0.826           0.876       0.929         0.4351 0.787   0.601
#> 4 4 0.906           0.842       0.934         0.1167 0.855   0.592
#> 5 5 0.895           0.874       0.922         0.0584 0.915   0.677
#> 6 6 0.871           0.770       0.877         0.0262 0.996   0.980

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette    p1    p2
#> SRR2936906     1  0.0000      0.992 1.000 0.000
#> SRR2936909     1  0.0000      0.992 1.000 0.000
#> SRR2936918     1  0.0000      0.992 1.000 0.000
#> SRR2936917     1  0.0000      0.992 1.000 0.000
#> SRR2936916     1  0.0000      0.992 1.000 0.000
#> SRR2936915     1  0.7219      0.751 0.800 0.200
#> SRR2936914     1  0.1414      0.974 0.980 0.020
#> SRR2936913     2  0.3879      0.916 0.076 0.924
#> SRR2936912     1  0.0000      0.992 1.000 0.000
#> SRR2936910     1  0.0000      0.992 1.000 0.000
#> SRR2936911     2  0.0000      0.995 0.000 1.000
#> SRR2936907     2  0.0000      0.995 0.000 1.000
#> SRR2936908     2  0.0000      0.995 0.000 1.000
#> SRR2936904     2  0.0000      0.995 0.000 1.000
#> SRR2936905     2  0.0000      0.995 0.000 1.000
#> SRR2936903     1  0.0000      0.992 1.000 0.000
#> SRR2936901     1  0.0000      0.992 1.000 0.000
#> SRR2936902     1  0.0000      0.992 1.000 0.000
#> SRR2936900     1  0.0000      0.992 1.000 0.000
#> SRR2936898     1  0.0000      0.992 1.000 0.000
#> SRR2936899     1  0.0000      0.992 1.000 0.000
#> SRR2936897     1  0.0000      0.992 1.000 0.000
#> SRR2936896     1  0.0376      0.989 0.996 0.004
#> SRR2936894     1  0.0000      0.992 1.000 0.000
#> SRR2936893     2  0.0000      0.995 0.000 1.000
#> SRR2936895     1  0.0000      0.992 1.000 0.000
#> SRR2936892     2  0.0000      0.995 0.000 1.000
#> SRR2936891     1  0.0000      0.992 1.000 0.000
#> SRR2936890     2  0.0000      0.995 0.000 1.000
#> SRR2936886     2  0.0000      0.995 0.000 1.000
#> SRR2936885     1  0.0000      0.992 1.000 0.000
#> SRR2936888     1  0.0000      0.992 1.000 0.000
#> SRR2936889     2  0.0000      0.995 0.000 1.000
#> SRR2936887     2  0.0000      0.995 0.000 1.000
#> SRR2936884     1  0.0000      0.992 1.000 0.000
#> SRR2936883     1  0.0000      0.992 1.000 0.000
#> SRR2936881     1  0.0000      0.992 1.000 0.000
#> SRR2936882     1  0.0000      0.992 1.000 0.000
#> SRR2936880     1  0.0000      0.992 1.000 0.000
#> SRR2936878     1  0.0000      0.992 1.000 0.000
#> SRR2936879     1  0.2043      0.963 0.968 0.032
#> SRR2936875     2  0.0000      0.995 0.000 1.000
#> SRR2936877     1  0.0000      0.992 1.000 0.000
#> SRR2936876     1  0.0000      0.992 1.000 0.000
#> SRR2936873     1  0.0000      0.992 1.000 0.000
#> SRR2936872     2  0.0000      0.995 0.000 1.000
#> SRR2936871     2  0.0000      0.995 0.000 1.000
#> SRR2936874     2  0.0000      0.995 0.000 1.000
#> SRR2936870     1  0.0000      0.992 1.000 0.000
#> SRR2936869     2  0.0000      0.995 0.000 1.000
#> SRR2936868     2  0.0000      0.995 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR2936906     1  0.1163      0.957 0.972 0.000 0.028
#> SRR2936909     1  0.1163      0.957 0.972 0.000 0.028
#> SRR2936918     1  0.1031      0.956 0.976 0.000 0.024
#> SRR2936917     3  0.1163      0.922 0.028 0.000 0.972
#> SRR2936916     1  0.1163      0.957 0.972 0.000 0.028
#> SRR2936915     1  0.1919      0.942 0.956 0.020 0.024
#> SRR2936914     3  0.2056      0.880 0.024 0.024 0.952
#> SRR2936913     2  0.8129      0.647 0.244 0.632 0.124
#> SRR2936912     1  0.1031      0.956 0.976 0.000 0.024
#> SRR2936910     1  0.1031      0.956 0.976 0.000 0.024
#> SRR2936911     2  0.6079      0.769 0.216 0.748 0.036
#> SRR2936907     2  0.0000      0.923 0.000 1.000 0.000
#> SRR2936908     2  0.0000      0.923 0.000 1.000 0.000
#> SRR2936904     2  0.0000      0.923 0.000 1.000 0.000
#> SRR2936905     2  0.0000      0.923 0.000 1.000 0.000
#> SRR2936903     3  0.1529      0.918 0.040 0.000 0.960
#> SRR2936901     3  0.1163      0.922 0.028 0.000 0.972
#> SRR2936902     3  0.1031      0.922 0.024 0.000 0.976
#> SRR2936900     3  0.5621      0.616 0.308 0.000 0.692
#> SRR2936898     3  0.1529      0.917 0.040 0.000 0.960
#> SRR2936899     3  0.1031      0.922 0.024 0.000 0.976
#> SRR2936897     1  0.1163      0.957 0.972 0.000 0.028
#> SRR2936896     3  0.1860      0.891 0.052 0.000 0.948
#> SRR2936894     1  0.1163      0.957 0.972 0.000 0.028
#> SRR2936893     2  0.0000      0.923 0.000 1.000 0.000
#> SRR2936895     1  0.6252      0.150 0.556 0.000 0.444
#> SRR2936892     2  0.0000      0.923 0.000 1.000 0.000
#> SRR2936891     1  0.1163      0.957 0.972 0.000 0.028
#> SRR2936890     2  0.0000      0.923 0.000 1.000 0.000
#> SRR2936886     2  0.6148      0.740 0.244 0.728 0.028
#> SRR2936885     3  0.5810      0.563 0.336 0.000 0.664
#> SRR2936888     1  0.0892      0.921 0.980 0.000 0.020
#> SRR2936889     2  0.0000      0.923 0.000 1.000 0.000
#> SRR2936887     2  0.5894      0.769 0.220 0.752 0.028
#> SRR2936884     3  0.0000      0.910 0.000 0.000 1.000
#> SRR2936883     3  0.0000      0.910 0.000 0.000 1.000
#> SRR2936881     3  0.1031      0.922 0.024 0.000 0.976
#> SRR2936882     3  0.5733      0.587 0.324 0.000 0.676
#> SRR2936880     3  0.1163      0.922 0.028 0.000 0.972
#> SRR2936878     3  0.1031      0.922 0.024 0.000 0.976
#> SRR2936879     1  0.1711      0.951 0.960 0.008 0.032
#> SRR2936875     2  0.0000      0.923 0.000 1.000 0.000
#> SRR2936877     3  0.1163      0.922 0.028 0.000 0.972
#> SRR2936876     1  0.1163      0.957 0.972 0.000 0.028
#> SRR2936873     1  0.1163      0.957 0.972 0.000 0.028
#> SRR2936872     2  0.0000      0.923 0.000 1.000 0.000
#> SRR2936871     2  0.0000      0.923 0.000 1.000 0.000
#> SRR2936874     2  0.0000      0.923 0.000 1.000 0.000
#> SRR2936870     1  0.0892      0.921 0.980 0.000 0.020
#> SRR2936869     2  0.4015      0.870 0.096 0.876 0.028
#> SRR2936868     2  0.4609      0.850 0.128 0.844 0.028

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR2936906     1  0.0000      0.915 1.000 0.000 0.000 0.000
#> SRR2936909     1  0.0188      0.914 0.996 0.000 0.000 0.004
#> SRR2936918     1  0.0000      0.915 1.000 0.000 0.000 0.000
#> SRR2936917     3  0.0672      0.924 0.008 0.008 0.984 0.000
#> SRR2936916     1  0.0000      0.915 1.000 0.000 0.000 0.000
#> SRR2936915     1  0.0188      0.914 0.996 0.000 0.000 0.004
#> SRR2936914     3  0.2408      0.876 0.000 0.000 0.896 0.104
#> SRR2936913     4  0.0336      0.810 0.000 0.008 0.000 0.992
#> SRR2936912     1  0.0000      0.915 1.000 0.000 0.000 0.000
#> SRR2936910     1  0.0000      0.915 1.000 0.000 0.000 0.000
#> SRR2936911     4  0.0188      0.810 0.000 0.004 0.000 0.996
#> SRR2936907     2  0.0336      0.989 0.000 0.992 0.000 0.008
#> SRR2936908     2  0.0000      0.990 0.000 1.000 0.000 0.000
#> SRR2936904     2  0.0188      0.990 0.000 0.996 0.000 0.004
#> SRR2936905     2  0.0000      0.990 0.000 1.000 0.000 0.000
#> SRR2936903     3  0.0188      0.929 0.004 0.000 0.996 0.000
#> SRR2936901     3  0.0000      0.930 0.000 0.000 1.000 0.000
#> SRR2936902     3  0.0000      0.930 0.000 0.000 1.000 0.000
#> SRR2936900     1  0.4855      0.348 0.600 0.000 0.400 0.000
#> SRR2936898     3  0.2081      0.895 0.000 0.000 0.916 0.084
#> SRR2936899     3  0.1474      0.916 0.000 0.000 0.948 0.052
#> SRR2936897     1  0.0000      0.915 1.000 0.000 0.000 0.000
#> SRR2936896     3  0.3486      0.791 0.000 0.000 0.812 0.188
#> SRR2936894     1  0.0000      0.915 1.000 0.000 0.000 0.000
#> SRR2936893     2  0.1118      0.970 0.000 0.964 0.000 0.036
#> SRR2936895     4  0.5793      0.325 0.048 0.000 0.324 0.628
#> SRR2936892     2  0.0592      0.985 0.000 0.984 0.000 0.016
#> SRR2936891     1  0.0000      0.915 1.000 0.000 0.000 0.000
#> SRR2936890     2  0.0188      0.990 0.000 0.996 0.000 0.004
#> SRR2936886     4  0.0188      0.810 0.000 0.004 0.000 0.996
#> SRR2936885     3  0.6052      0.317 0.048 0.000 0.556 0.396
#> SRR2936888     4  0.4981      0.245 0.464 0.000 0.000 0.536
#> SRR2936889     2  0.1302      0.964 0.000 0.956 0.000 0.044
#> SRR2936887     4  0.0188      0.810 0.000 0.004 0.000 0.996
#> SRR2936884     3  0.0817      0.926 0.000 0.000 0.976 0.024
#> SRR2936883     3  0.1211      0.922 0.000 0.000 0.960 0.040
#> SRR2936881     3  0.0000      0.930 0.000 0.000 1.000 0.000
#> SRR2936882     1  0.5493      0.163 0.528 0.000 0.456 0.016
#> SRR2936880     3  0.0000      0.930 0.000 0.000 1.000 0.000
#> SRR2936878     3  0.0000      0.930 0.000 0.000 1.000 0.000
#> SRR2936879     1  0.0188      0.914 0.996 0.000 0.000 0.004
#> SRR2936875     2  0.0000      0.990 0.000 1.000 0.000 0.000
#> SRR2936877     3  0.0469      0.925 0.012 0.000 0.988 0.000
#> SRR2936876     1  0.0657      0.904 0.984 0.012 0.000 0.004
#> SRR2936873     1  0.0188      0.914 0.996 0.000 0.000 0.004
#> SRR2936872     2  0.0000      0.990 0.000 1.000 0.000 0.000
#> SRR2936871     2  0.0000      0.990 0.000 1.000 0.000 0.000
#> SRR2936874     2  0.0000      0.990 0.000 1.000 0.000 0.000
#> SRR2936870     4  0.4985      0.235 0.468 0.000 0.000 0.532
#> SRR2936869     4  0.1211      0.799 0.000 0.040 0.000 0.960
#> SRR2936868     4  0.1118      0.802 0.000 0.036 0.000 0.964

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4    p5
#> SRR2936906     1  0.0609      0.973 0.980 0.000 0.020 0.000 0.000
#> SRR2936909     1  0.0794      0.974 0.972 0.000 0.028 0.000 0.000
#> SRR2936918     1  0.0854      0.969 0.976 0.000 0.012 0.008 0.004
#> SRR2936917     5  0.1571      0.897 0.004 0.000 0.060 0.000 0.936
#> SRR2936916     1  0.0912      0.950 0.972 0.000 0.000 0.016 0.012
#> SRR2936915     1  0.0613      0.961 0.984 0.004 0.000 0.008 0.004
#> SRR2936914     5  0.1357      0.893 0.000 0.000 0.048 0.004 0.948
#> SRR2936913     5  0.4029      0.569 0.024 0.000 0.000 0.232 0.744
#> SRR2936912     1  0.0451      0.966 0.988 0.000 0.004 0.008 0.000
#> SRR2936910     1  0.0451      0.966 0.988 0.000 0.004 0.008 0.000
#> SRR2936911     4  0.4937      0.273 0.024 0.004 0.000 0.580 0.392
#> SRR2936907     2  0.0290      0.983 0.000 0.992 0.000 0.008 0.000
#> SRR2936908     2  0.0000      0.984 0.000 1.000 0.000 0.000 0.000
#> SRR2936904     2  0.0162      0.983 0.000 0.996 0.000 0.000 0.004
#> SRR2936905     2  0.0162      0.985 0.000 0.996 0.000 0.000 0.004
#> SRR2936903     3  0.1430      0.895 0.052 0.000 0.944 0.004 0.000
#> SRR2936901     3  0.0865      0.905 0.024 0.000 0.972 0.000 0.004
#> SRR2936902     3  0.1341      0.894 0.000 0.000 0.944 0.000 0.056
#> SRR2936900     3  0.2852      0.797 0.172 0.000 0.828 0.000 0.000
#> SRR2936898     3  0.1282      0.901 0.004 0.000 0.952 0.044 0.000
#> SRR2936899     3  0.1197      0.899 0.000 0.000 0.952 0.048 0.000
#> SRR2936897     1  0.1043      0.969 0.960 0.000 0.040 0.000 0.000
#> SRR2936896     5  0.2927      0.871 0.000 0.000 0.060 0.068 0.872
#> SRR2936894     1  0.0963      0.971 0.964 0.000 0.036 0.000 0.000
#> SRR2936893     2  0.1502      0.955 0.000 0.940 0.000 0.056 0.004
#> SRR2936895     4  0.5543      0.635 0.108 0.000 0.052 0.716 0.124
#> SRR2936892     2  0.0794      0.974 0.000 0.972 0.000 0.028 0.000
#> SRR2936891     1  0.0880      0.973 0.968 0.000 0.032 0.000 0.000
#> SRR2936890     2  0.0510      0.980 0.000 0.984 0.000 0.016 0.000
#> SRR2936886     4  0.0955      0.730 0.000 0.004 0.028 0.968 0.000
#> SRR2936885     3  0.3238      0.832 0.028 0.000 0.836 0.136 0.000
#> SRR2936888     4  0.4866      0.453 0.396 0.000 0.004 0.580 0.020
#> SRR2936889     2  0.1410      0.952 0.000 0.940 0.000 0.060 0.000
#> SRR2936887     4  0.1116      0.730 0.000 0.004 0.028 0.964 0.004
#> SRR2936884     3  0.2230      0.881 0.000 0.000 0.912 0.044 0.044
#> SRR2936883     3  0.2260      0.881 0.000 0.000 0.908 0.064 0.028
#> SRR2936881     3  0.1043      0.900 0.000 0.000 0.960 0.000 0.040
#> SRR2936882     3  0.2732      0.811 0.160 0.000 0.840 0.000 0.000
#> SRR2936880     3  0.1357      0.897 0.004 0.000 0.948 0.000 0.048
#> SRR2936878     5  0.1792      0.894 0.000 0.000 0.084 0.000 0.916
#> SRR2936879     1  0.1522      0.960 0.944 0.012 0.044 0.000 0.000
#> SRR2936875     2  0.0162      0.985 0.000 0.996 0.000 0.000 0.004
#> SRR2936877     5  0.2179      0.881 0.000 0.000 0.100 0.004 0.896
#> SRR2936876     1  0.1728      0.956 0.940 0.020 0.036 0.004 0.000
#> SRR2936873     1  0.0794      0.974 0.972 0.000 0.028 0.000 0.000
#> SRR2936872     2  0.0162      0.985 0.000 0.996 0.000 0.000 0.004
#> SRR2936871     2  0.0162      0.985 0.000 0.996 0.000 0.000 0.004
#> SRR2936874     2  0.0162      0.985 0.000 0.996 0.000 0.000 0.004
#> SRR2936870     4  0.4852      0.483 0.380 0.000 0.008 0.596 0.016
#> SRR2936869     4  0.1124      0.729 0.000 0.004 0.036 0.960 0.000
#> SRR2936868     4  0.1205      0.727 0.000 0.004 0.040 0.956 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
#> SRR2936906     1  0.1196      0.902 0.952 0.000 0.008 0.000 0.000 0.040
#> SRR2936909     1  0.1387      0.894 0.932 0.000 0.000 0.000 0.000 0.068
#> SRR2936918     1  0.2624      0.854 0.844 0.000 0.004 0.004 0.000 0.148
#> SRR2936917     5  0.0858      0.792 0.000 0.000 0.004 0.000 0.968 0.028
#> SRR2936916     1  0.3806      0.777 0.752 0.000 0.000 0.008 0.028 0.212
#> SRR2936915     1  0.2553      0.855 0.848 0.000 0.000 0.008 0.000 0.144
#> SRR2936914     5  0.0665      0.794 0.000 0.000 0.004 0.008 0.980 0.008
#> SRR2936913     5  0.2608      0.723 0.000 0.000 0.000 0.048 0.872 0.080
#> SRR2936912     1  0.0790      0.903 0.968 0.000 0.000 0.000 0.000 0.032
#> SRR2936910     1  0.1411      0.902 0.936 0.000 0.004 0.000 0.000 0.060
#> SRR2936911     4  0.5635     -0.212 0.004 0.000 0.000 0.528 0.152 0.316
#> SRR2936907     2  0.0935      0.963 0.000 0.964 0.000 0.032 0.000 0.004
#> SRR2936908     2  0.0508      0.966 0.000 0.984 0.000 0.012 0.000 0.004
#> SRR2936904     2  0.0891      0.963 0.000 0.968 0.000 0.024 0.000 0.008
#> SRR2936905     2  0.0000      0.965 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936903     3  0.1003      0.942 0.020 0.000 0.964 0.000 0.000 0.016
#> SRR2936901     3  0.0862      0.948 0.016 0.000 0.972 0.000 0.004 0.008
#> SRR2936902     3  0.0603      0.948 0.000 0.000 0.980 0.000 0.016 0.004
#> SRR2936900     3  0.2586      0.863 0.100 0.000 0.868 0.000 0.000 0.032
#> SRR2936898     3  0.1218      0.946 0.004 0.000 0.956 0.012 0.000 0.028
#> SRR2936899     3  0.0972      0.945 0.000 0.000 0.964 0.008 0.000 0.028
#> SRR2936897     1  0.1588      0.889 0.924 0.000 0.004 0.000 0.000 0.072
#> SRR2936896     6  0.7440      0.000 0.020 0.012 0.036 0.336 0.256 0.340
#> SRR2936894     1  0.0717      0.903 0.976 0.000 0.008 0.000 0.000 0.016
#> SRR2936893     2  0.1524      0.951 0.000 0.932 0.000 0.060 0.000 0.008
#> SRR2936895     4  0.6344     -0.352 0.096 0.000 0.008 0.436 0.048 0.412
#> SRR2936892     2  0.1644      0.941 0.000 0.920 0.000 0.076 0.000 0.004
#> SRR2936891     1  0.1049      0.904 0.960 0.000 0.008 0.000 0.000 0.032
#> SRR2936890     2  0.0632      0.965 0.000 0.976 0.000 0.024 0.000 0.000
#> SRR2936886     4  0.1015      0.478 0.000 0.012 0.004 0.968 0.004 0.012
#> SRR2936885     3  0.2307      0.917 0.016 0.000 0.904 0.048 0.000 0.032
#> SRR2936888     4  0.6088      0.235 0.244 0.000 0.000 0.440 0.004 0.312
#> SRR2936889     2  0.1858      0.925 0.000 0.904 0.000 0.092 0.000 0.004
#> SRR2936887     4  0.1015      0.473 0.000 0.012 0.004 0.968 0.004 0.012
#> SRR2936884     3  0.1262      0.940 0.000 0.000 0.956 0.008 0.020 0.016
#> SRR2936883     3  0.0767      0.947 0.000 0.000 0.976 0.008 0.012 0.004
#> SRR2936881     3  0.1138      0.947 0.004 0.000 0.960 0.000 0.012 0.024
#> SRR2936882     3  0.2122      0.895 0.076 0.000 0.900 0.000 0.000 0.024
#> SRR2936880     3  0.1138      0.947 0.004 0.000 0.960 0.000 0.012 0.024
#> SRR2936878     5  0.2474      0.753 0.000 0.000 0.040 0.000 0.880 0.080
#> SRR2936879     1  0.3620      0.765 0.772 0.044 0.000 0.000 0.000 0.184
#> SRR2936875     2  0.0865      0.951 0.000 0.964 0.000 0.000 0.000 0.036
#> SRR2936877     5  0.5378      0.428 0.032 0.000 0.072 0.000 0.604 0.292
#> SRR2936876     1  0.2703      0.825 0.824 0.004 0.000 0.000 0.000 0.172
#> SRR2936873     1  0.0692      0.903 0.976 0.000 0.004 0.000 0.000 0.020
#> SRR2936872     2  0.0363      0.962 0.000 0.988 0.000 0.000 0.000 0.012
#> SRR2936871     2  0.0146      0.964 0.000 0.996 0.000 0.000 0.000 0.004
#> SRR2936874     2  0.0972      0.959 0.000 0.964 0.000 0.008 0.000 0.028
#> SRR2936870     4  0.5997      0.257 0.224 0.000 0.000 0.468 0.004 0.304
#> SRR2936869     4  0.1578      0.478 0.000 0.048 0.004 0.936 0.000 0.012
#> SRR2936868     4  0.1605      0.480 0.000 0.044 0.004 0.936 0.000 0.016

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

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

collect_plots(res)

plot of chunk ATC-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.5087 0.492   0.492
#> 3 3 1.000           0.998       0.999         0.2771 0.859   0.713
#> 4 4 1.000           0.987       0.991         0.1500 0.900   0.714
#> 5 5 0.904           0.942       0.931         0.0412 0.973   0.890
#> 6 6 0.951           0.923       0.960         0.0454 0.965   0.845

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
#> SRR2936906     1       0          1  1  0
#> SRR2936909     1       0          1  1  0
#> SRR2936918     1       0          1  1  0
#> SRR2936917     2       0          1  0  1
#> SRR2936916     1       0          1  1  0
#> SRR2936915     1       0          1  1  0
#> SRR2936914     2       0          1  0  1
#> SRR2936913     2       0          1  0  1
#> SRR2936912     1       0          1  1  0
#> SRR2936910     1       0          1  1  0
#> SRR2936911     2       0          1  0  1
#> SRR2936907     2       0          1  0  1
#> SRR2936908     2       0          1  0  1
#> SRR2936904     1       0          1  1  0
#> SRR2936905     2       0          1  0  1
#> SRR2936903     1       0          1  1  0
#> SRR2936901     1       0          1  1  0
#> SRR2936902     2       0          1  0  1
#> SRR2936900     1       0          1  1  0
#> SRR2936898     1       0          1  1  0
#> SRR2936899     1       0          1  1  0
#> SRR2936897     1       0          1  1  0
#> SRR2936896     2       0          1  0  1
#> SRR2936894     1       0          1  1  0
#> SRR2936893     2       0          1  0  1
#> SRR2936895     2       0          1  0  1
#> SRR2936892     2       0          1  0  1
#> SRR2936891     1       0          1  1  0
#> SRR2936890     2       0          1  0  1
#> SRR2936886     1       0          1  1  0
#> SRR2936885     1       0          1  1  0
#> SRR2936888     1       0          1  1  0
#> SRR2936889     2       0          1  0  1
#> SRR2936887     1       0          1  1  0
#> SRR2936884     2       0          1  0  1
#> SRR2936883     2       0          1  0  1
#> SRR2936881     2       0          1  0  1
#> SRR2936882     1       0          1  1  0
#> SRR2936880     2       0          1  0  1
#> SRR2936878     2       0          1  0  1
#> SRR2936879     1       0          1  1  0
#> SRR2936875     2       0          1  0  1
#> SRR2936877     2       0          1  0  1
#> SRR2936876     1       0          1  1  0
#> SRR2936873     1       0          1  1  0
#> SRR2936872     2       0          1  0  1
#> SRR2936871     2       0          1  0  1
#> SRR2936874     2       0          1  0  1
#> SRR2936870     1       0          1  1  0
#> SRR2936869     1       0          1  1  0
#> SRR2936868     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
#> SRR2936906     1  0.0000      0.995 1.000  0 0.000
#> SRR2936909     1  0.0747      0.987 0.984  0 0.016
#> SRR2936918     1  0.0000      0.995 1.000  0 0.000
#> SRR2936917     2  0.0000      1.000 0.000  1 0.000
#> SRR2936916     3  0.0000      1.000 0.000  0 1.000
#> SRR2936915     3  0.0000      1.000 0.000  0 1.000
#> SRR2936914     2  0.0000      1.000 0.000  1 0.000
#> SRR2936913     2  0.0000      1.000 0.000  1 0.000
#> SRR2936912     1  0.0747      0.987 0.984  0 0.016
#> SRR2936910     1  0.0000      0.995 1.000  0 0.000
#> SRR2936911     2  0.0000      1.000 0.000  1 0.000
#> SRR2936907     2  0.0000      1.000 0.000  1 0.000
#> SRR2936908     2  0.0000      1.000 0.000  1 0.000
#> SRR2936904     3  0.0000      1.000 0.000  0 1.000
#> SRR2936905     2  0.0000      1.000 0.000  1 0.000
#> SRR2936903     1  0.0747      0.987 0.984  0 0.016
#> SRR2936901     3  0.0000      1.000 0.000  0 1.000
#> SRR2936902     2  0.0000      1.000 0.000  1 0.000
#> SRR2936900     1  0.0000      0.995 1.000  0 0.000
#> SRR2936898     3  0.0000      1.000 0.000  0 1.000
#> SRR2936899     3  0.0000      1.000 0.000  0 1.000
#> SRR2936897     1  0.0747      0.987 0.984  0 0.016
#> SRR2936896     2  0.0000      1.000 0.000  1 0.000
#> SRR2936894     1  0.0000      0.995 1.000  0 0.000
#> SRR2936893     2  0.0000      1.000 0.000  1 0.000
#> SRR2936895     2  0.0000      1.000 0.000  1 0.000
#> SRR2936892     2  0.0000      1.000 0.000  1 0.000
#> SRR2936891     1  0.0000      0.995 1.000  0 0.000
#> SRR2936890     2  0.0000      1.000 0.000  1 0.000
#> SRR2936886     3  0.0000      1.000 0.000  0 1.000
#> SRR2936885     1  0.0000      0.995 1.000  0 0.000
#> SRR2936888     1  0.0000      0.995 1.000  0 0.000
#> SRR2936889     2  0.0000      1.000 0.000  1 0.000
#> SRR2936887     3  0.0000      1.000 0.000  0 1.000
#> SRR2936884     2  0.0000      1.000 0.000  1 0.000
#> SRR2936883     2  0.0000      1.000 0.000  1 0.000
#> SRR2936881     2  0.0000      1.000 0.000  1 0.000
#> SRR2936882     1  0.0000      0.995 1.000  0 0.000
#> SRR2936880     2  0.0000      1.000 0.000  1 0.000
#> SRR2936878     2  0.0000      1.000 0.000  1 0.000
#> SRR2936879     3  0.0000      1.000 0.000  0 1.000
#> SRR2936875     2  0.0000      1.000 0.000  1 0.000
#> SRR2936877     2  0.0000      1.000 0.000  1 0.000
#> SRR2936876     3  0.0000      1.000 0.000  0 1.000
#> SRR2936873     1  0.0000      0.995 1.000  0 0.000
#> SRR2936872     2  0.0000      1.000 0.000  1 0.000
#> SRR2936871     2  0.0000      1.000 0.000  1 0.000
#> SRR2936874     2  0.0000      1.000 0.000  1 0.000
#> SRR2936870     1  0.0000      0.995 1.000  0 0.000
#> SRR2936869     3  0.0000      1.000 0.000  0 1.000
#> SRR2936868     3  0.0000      1.000 0.000  0 1.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR2936906     1  0.0000      0.996 1.000 0.000 0.000 0.000
#> SRR2936909     1  0.0592      0.989 0.984 0.000 0.000 0.016
#> SRR2936918     1  0.0000      0.996 1.000 0.000 0.000 0.000
#> SRR2936917     4  0.0592      0.959 0.000 0.016 0.000 0.984
#> SRR2936916     3  0.0000      0.997 0.000 0.000 1.000 0.000
#> SRR2936915     3  0.0000      0.997 0.000 0.000 1.000 0.000
#> SRR2936914     4  0.0592      0.959 0.000 0.016 0.000 0.984
#> SRR2936913     4  0.0592      0.959 0.000 0.016 0.000 0.984
#> SRR2936912     1  0.0592      0.989 0.984 0.000 0.000 0.016
#> SRR2936910     1  0.0000      0.996 1.000 0.000 0.000 0.000
#> SRR2936911     4  0.0592      0.959 0.000 0.016 0.000 0.984
#> SRR2936907     4  0.2973      0.872 0.000 0.144 0.000 0.856
#> SRR2936908     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR2936904     3  0.0592      0.987 0.000 0.000 0.984 0.016
#> SRR2936905     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR2936903     1  0.0592      0.989 0.984 0.000 0.000 0.016
#> SRR2936901     3  0.0188      0.995 0.000 0.000 0.996 0.004
#> SRR2936902     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR2936900     1  0.0000      0.996 1.000 0.000 0.000 0.000
#> SRR2936898     3  0.0000      0.997 0.000 0.000 1.000 0.000
#> SRR2936899     3  0.0000      0.997 0.000 0.000 1.000 0.000
#> SRR2936897     1  0.0592      0.989 0.984 0.000 0.000 0.016
#> SRR2936896     4  0.2973      0.872 0.000 0.144 0.000 0.856
#> SRR2936894     1  0.0000      0.996 1.000 0.000 0.000 0.000
#> SRR2936893     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR2936895     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR2936892     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR2936891     1  0.0000      0.996 1.000 0.000 0.000 0.000
#> SRR2936890     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR2936886     3  0.0000      0.997 0.000 0.000 1.000 0.000
#> SRR2936885     1  0.0000      0.996 1.000 0.000 0.000 0.000
#> SRR2936888     1  0.0000      0.996 1.000 0.000 0.000 0.000
#> SRR2936889     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR2936887     3  0.0000      0.997 0.000 0.000 1.000 0.000
#> SRR2936884     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR2936883     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR2936881     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR2936882     1  0.0000      0.996 1.000 0.000 0.000 0.000
#> SRR2936880     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR2936878     4  0.0592      0.959 0.000 0.016 0.000 0.984
#> SRR2936879     3  0.0000      0.997 0.000 0.000 1.000 0.000
#> SRR2936875     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR2936877     4  0.0592      0.959 0.000 0.016 0.000 0.984
#> SRR2936876     3  0.0592      0.987 0.000 0.000 0.984 0.016
#> SRR2936873     1  0.0000      0.996 1.000 0.000 0.000 0.000
#> SRR2936872     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR2936871     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR2936874     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR2936870     1  0.0000      0.996 1.000 0.000 0.000 0.000
#> SRR2936869     3  0.0000      0.997 0.000 0.000 1.000 0.000
#> SRR2936868     3  0.0000      0.997 0.000 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4    p5
#> SRR2936906     1  0.0162      0.910 0.996 0.000 0.004 0.000 0.000
#> SRR2936909     1  0.3983      0.735 0.660 0.000 0.340 0.000 0.000
#> SRR2936918     1  0.0000      0.910 1.000 0.000 0.000 0.000 0.000
#> SRR2936917     5  0.0000      0.949 0.000 0.000 0.000 0.000 1.000
#> SRR2936916     3  0.4045      0.995 0.000 0.000 0.644 0.356 0.000
#> SRR2936915     3  0.4088      0.981 0.000 0.000 0.632 0.368 0.000
#> SRR2936914     5  0.0000      0.949 0.000 0.000 0.000 0.000 1.000
#> SRR2936913     5  0.0000      0.949 0.000 0.000 0.000 0.000 1.000
#> SRR2936912     1  0.3983      0.735 0.660 0.000 0.340 0.000 0.000
#> SRR2936910     1  0.0000      0.910 1.000 0.000 0.000 0.000 0.000
#> SRR2936911     5  0.0000      0.949 0.000 0.000 0.000 0.000 1.000
#> SRR2936907     5  0.2424      0.844 0.000 0.132 0.000 0.000 0.868
#> SRR2936908     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR2936904     4  0.0794      0.958 0.000 0.000 0.028 0.972 0.000
#> SRR2936905     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR2936903     1  0.3983      0.735 0.660 0.000 0.340 0.000 0.000
#> SRR2936901     4  0.0963      0.940 0.000 0.000 0.036 0.964 0.000
#> SRR2936902     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR2936900     1  0.0404      0.909 0.988 0.000 0.012 0.000 0.000
#> SRR2936898     3  0.4045      0.995 0.000 0.000 0.644 0.356 0.000
#> SRR2936899     3  0.4045      0.995 0.000 0.000 0.644 0.356 0.000
#> SRR2936897     1  0.3983      0.735 0.660 0.000 0.340 0.000 0.000
#> SRR2936896     5  0.2424      0.844 0.000 0.132 0.000 0.000 0.868
#> SRR2936894     1  0.0162      0.910 0.996 0.000 0.004 0.000 0.000
#> SRR2936893     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR2936895     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR2936892     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR2936891     1  0.0162      0.910 0.996 0.000 0.004 0.000 0.000
#> SRR2936890     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR2936886     4  0.0000      0.976 0.000 0.000 0.000 1.000 0.000
#> SRR2936885     1  0.0404      0.909 0.988 0.000 0.012 0.000 0.000
#> SRR2936888     1  0.0162      0.910 0.996 0.000 0.004 0.000 0.000
#> SRR2936889     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR2936887     4  0.0000      0.976 0.000 0.000 0.000 1.000 0.000
#> SRR2936884     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR2936883     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR2936881     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR2936882     1  0.0404      0.909 0.988 0.000 0.012 0.000 0.000
#> SRR2936880     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR2936878     5  0.0000      0.949 0.000 0.000 0.000 0.000 1.000
#> SRR2936879     3  0.4045      0.995 0.000 0.000 0.644 0.356 0.000
#> SRR2936875     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR2936877     5  0.0000      0.949 0.000 0.000 0.000 0.000 1.000
#> SRR2936876     4  0.0794      0.958 0.000 0.000 0.028 0.972 0.000
#> SRR2936873     1  0.0162      0.910 0.996 0.000 0.004 0.000 0.000
#> SRR2936872     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR2936871     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR2936874     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR2936870     1  0.0162      0.910 0.996 0.000 0.004 0.000 0.000
#> SRR2936869     4  0.0000      0.976 0.000 0.000 0.000 1.000 0.000
#> SRR2936868     4  0.0000      0.976 0.000 0.000 0.000 1.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
#> SRR2936906     1  0.0000      0.822 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936909     6  0.0000      1.000 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR2936918     1  0.0363      0.821 0.988 0.000 0.000 0.000 0.000 0.012
#> SRR2936917     5  0.0000      0.947 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR2936916     3  0.0000      0.993 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR2936915     3  0.0632      0.973 0.000 0.000 0.976 0.024 0.000 0.000
#> SRR2936914     5  0.0000      0.947 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR2936913     5  0.0000      0.947 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR2936912     6  0.0000      1.000 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR2936910     1  0.0363      0.821 0.988 0.000 0.000 0.000 0.000 0.012
#> SRR2936911     5  0.0000      0.947 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR2936907     5  0.2178      0.836 0.000 0.132 0.000 0.000 0.868 0.000
#> SRR2936908     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936904     4  0.0000      0.972 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR2936905     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936903     6  0.0000      1.000 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR2936901     4  0.1204      0.961 0.000 0.000 0.056 0.944 0.000 0.000
#> SRR2936902     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936900     1  0.3765      0.529 0.596 0.000 0.000 0.000 0.000 0.404
#> SRR2936898     3  0.0000      0.993 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR2936899     3  0.0000      0.993 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR2936897     6  0.0000      1.000 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR2936896     5  0.2178      0.836 0.000 0.132 0.000 0.000 0.868 0.000
#> SRR2936894     1  0.0000      0.822 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936893     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936895     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936892     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936891     1  0.0000      0.822 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936890     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936886     4  0.0713      0.985 0.000 0.000 0.028 0.972 0.000 0.000
#> SRR2936885     1  0.3765      0.529 0.596 0.000 0.000 0.000 0.000 0.404
#> SRR2936888     1  0.0000      0.822 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936889     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936887     4  0.0713      0.985 0.000 0.000 0.028 0.972 0.000 0.000
#> SRR2936884     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936883     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936881     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936882     1  0.3765      0.529 0.596 0.000 0.000 0.000 0.000 0.404
#> SRR2936880     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936878     5  0.0000      0.947 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR2936879     3  0.0000      0.993 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR2936875     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936877     5  0.0000      0.947 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR2936876     4  0.0363      0.972 0.000 0.000 0.000 0.988 0.000 0.012
#> SRR2936873     1  0.3547      0.610 0.668 0.000 0.000 0.000 0.000 0.332
#> SRR2936872     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936871     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936874     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936870     1  0.0000      0.822 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936869     4  0.0713      0.985 0.000 0.000 0.028 0.972 0.000 0.000
#> SRR2936868     4  0.0713      0.985 0.000 0.000 0.028 0.972 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 14198 rows and 51 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           0.991       0.996         0.4750 0.523   0.523
#> 3 3 0.755           0.922       0.925         0.3533 0.777   0.594
#> 4 4 0.804           0.857       0.901         0.1393 0.915   0.758
#> 5 5 0.747           0.755       0.826         0.0639 0.965   0.870
#> 6 6 0.800           0.737       0.805         0.0486 0.936   0.730

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
#> SRR2936906     1   0.000      0.988 1.000 0.000
#> SRR2936909     1   0.000      0.988 1.000 0.000
#> SRR2936918     1   0.000      0.988 1.000 0.000
#> SRR2936917     2   0.000      1.000 0.000 1.000
#> SRR2936916     2   0.000      1.000 0.000 1.000
#> SRR2936915     2   0.000      1.000 0.000 1.000
#> SRR2936914     2   0.000      1.000 0.000 1.000
#> SRR2936913     2   0.000      1.000 0.000 1.000
#> SRR2936912     1   0.000      0.988 1.000 0.000
#> SRR2936910     1   0.000      0.988 1.000 0.000
#> SRR2936911     2   0.000      1.000 0.000 1.000
#> SRR2936907     2   0.000      1.000 0.000 1.000
#> SRR2936908     2   0.000      1.000 0.000 1.000
#> SRR2936904     1   0.000      0.988 1.000 0.000
#> SRR2936905     2   0.000      1.000 0.000 1.000
#> SRR2936903     1   0.000      0.988 1.000 0.000
#> SRR2936901     1   0.343      0.930 0.936 0.064
#> SRR2936902     2   0.000      1.000 0.000 1.000
#> SRR2936900     1   0.000      0.988 1.000 0.000
#> SRR2936898     2   0.000      1.000 0.000 1.000
#> SRR2936899     2   0.000      1.000 0.000 1.000
#> SRR2936897     1   0.000      0.988 1.000 0.000
#> SRR2936896     2   0.000      1.000 0.000 1.000
#> SRR2936894     1   0.000      0.988 1.000 0.000
#> SRR2936893     2   0.000      1.000 0.000 1.000
#> SRR2936895     2   0.000      1.000 0.000 1.000
#> SRR2936892     2   0.000      1.000 0.000 1.000
#> SRR2936891     1   0.000      0.988 1.000 0.000
#> SRR2936890     2   0.000      1.000 0.000 1.000
#> SRR2936886     2   0.000      1.000 0.000 1.000
#> SRR2936885     1   0.000      0.988 1.000 0.000
#> SRR2936888     1   0.000      0.988 1.000 0.000
#> SRR2936889     2   0.000      1.000 0.000 1.000
#> SRR2936887     2   0.000      1.000 0.000 1.000
#> SRR2936884     2   0.000      1.000 0.000 1.000
#> SRR2936883     2   0.000      1.000 0.000 1.000
#> SRR2936881     2   0.000      1.000 0.000 1.000
#> SRR2936882     1   0.000      0.988 1.000 0.000
#> SRR2936880     2   0.000      1.000 0.000 1.000
#> SRR2936878     2   0.000      1.000 0.000 1.000
#> SRR2936879     2   0.000      1.000 0.000 1.000
#> SRR2936875     2   0.000      1.000 0.000 1.000
#> SRR2936877     2   0.000      1.000 0.000 1.000
#> SRR2936876     1   0.000      0.988 1.000 0.000
#> SRR2936873     1   0.000      0.988 1.000 0.000
#> SRR2936872     2   0.000      1.000 0.000 1.000
#> SRR2936871     2   0.000      1.000 0.000 1.000
#> SRR2936874     2   0.000      1.000 0.000 1.000
#> SRR2936870     1   0.000      0.988 1.000 0.000
#> SRR2936869     2   0.000      1.000 0.000 1.000
#> SRR2936868     1   0.605      0.832 0.852 0.148

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR2936906     1    0.00      1.000 1.000 0.000 0.000
#> SRR2936909     1    0.00      1.000 1.000 0.000 0.000
#> SRR2936918     1    0.00      1.000 1.000 0.000 0.000
#> SRR2936917     2    0.47      0.828 0.000 0.788 0.212
#> SRR2936916     3    0.47      0.947 0.000 0.212 0.788
#> SRR2936915     3    0.47      0.947 0.000 0.212 0.788
#> SRR2936914     2    0.47      0.828 0.000 0.788 0.212
#> SRR2936913     2    0.47      0.828 0.000 0.788 0.212
#> SRR2936912     1    0.00      1.000 1.000 0.000 0.000
#> SRR2936910     1    0.00      1.000 1.000 0.000 0.000
#> SRR2936911     2    0.47      0.828 0.000 0.788 0.212
#> SRR2936907     2    0.47      0.828 0.000 0.788 0.212
#> SRR2936908     2    0.00      0.911 0.000 1.000 0.000
#> SRR2936904     3    0.47      0.691 0.212 0.000 0.788
#> SRR2936905     2    0.00      0.911 0.000 1.000 0.000
#> SRR2936903     1    0.00      1.000 1.000 0.000 0.000
#> SRR2936901     3    0.47      0.947 0.000 0.212 0.788
#> SRR2936902     2    0.00      0.911 0.000 1.000 0.000
#> SRR2936900     1    0.00      1.000 1.000 0.000 0.000
#> SRR2936898     3    0.47      0.947 0.000 0.212 0.788
#> SRR2936899     3    0.47      0.947 0.000 0.212 0.788
#> SRR2936897     1    0.00      1.000 1.000 0.000 0.000
#> SRR2936896     2    0.47      0.828 0.000 0.788 0.212
#> SRR2936894     1    0.00      1.000 1.000 0.000 0.000
#> SRR2936893     2    0.00      0.911 0.000 1.000 0.000
#> SRR2936895     2    0.00      0.911 0.000 1.000 0.000
#> SRR2936892     2    0.00      0.911 0.000 1.000 0.000
#> SRR2936891     1    0.00      1.000 1.000 0.000 0.000
#> SRR2936890     2    0.00      0.911 0.000 1.000 0.000
#> SRR2936886     3    0.47      0.947 0.000 0.212 0.788
#> SRR2936885     1    0.00      1.000 1.000 0.000 0.000
#> SRR2936888     1    0.00      1.000 1.000 0.000 0.000
#> SRR2936889     2    0.00      0.911 0.000 1.000 0.000
#> SRR2936887     3    0.47      0.947 0.000 0.212 0.788
#> SRR2936884     2    0.00      0.911 0.000 1.000 0.000
#> SRR2936883     2    0.00      0.911 0.000 1.000 0.000
#> SRR2936881     2    0.00      0.911 0.000 1.000 0.000
#> SRR2936882     1    0.00      1.000 1.000 0.000 0.000
#> SRR2936880     2    0.00      0.911 0.000 1.000 0.000
#> SRR2936878     2    0.47      0.828 0.000 0.788 0.212
#> SRR2936879     3    0.47      0.947 0.000 0.212 0.788
#> SRR2936875     2    0.00      0.911 0.000 1.000 0.000
#> SRR2936877     2    0.47      0.828 0.000 0.788 0.212
#> SRR2936876     3    0.47      0.691 0.212 0.000 0.788
#> SRR2936873     1    0.00      1.000 1.000 0.000 0.000
#> SRR2936872     2    0.00      0.911 0.000 1.000 0.000
#> SRR2936871     2    0.00      0.911 0.000 1.000 0.000
#> SRR2936874     2    0.00      0.911 0.000 1.000 0.000
#> SRR2936870     1    0.00      1.000 1.000 0.000 0.000
#> SRR2936869     3    0.47      0.947 0.000 0.212 0.788
#> SRR2936868     3    0.47      0.947 0.000 0.212 0.788

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR2936906     1  0.0921      0.913 0.972 0.000 0.000 0.028
#> SRR2936909     1  0.4193      0.829 0.732 0.000 0.000 0.268
#> SRR2936918     1  0.0921      0.913 0.972 0.000 0.000 0.028
#> SRR2936917     4  0.4406      1.000 0.000 0.300 0.000 0.700
#> SRR2936916     3  0.0000      0.968 0.000 0.000 1.000 0.000
#> SRR2936915     3  0.0000      0.968 0.000 0.000 1.000 0.000
#> SRR2936914     4  0.4406      1.000 0.000 0.300 0.000 0.700
#> SRR2936913     4  0.4406      1.000 0.000 0.300 0.000 0.700
#> SRR2936912     1  0.4193      0.829 0.732 0.000 0.000 0.268
#> SRR2936910     1  0.1211      0.914 0.960 0.000 0.000 0.040
#> SRR2936911     4  0.4406      1.000 0.000 0.300 0.000 0.700
#> SRR2936907     2  0.4941     -0.365 0.000 0.564 0.000 0.436
#> SRR2936908     2  0.0000      0.877 0.000 1.000 0.000 0.000
#> SRR2936904     3  0.3074      0.867 0.000 0.000 0.848 0.152
#> SRR2936905     2  0.0000      0.877 0.000 1.000 0.000 0.000
#> SRR2936903     1  0.4222      0.826 0.728 0.000 0.000 0.272
#> SRR2936901     3  0.0921      0.955 0.000 0.000 0.972 0.028
#> SRR2936902     2  0.2469      0.797 0.000 0.892 0.108 0.000
#> SRR2936900     1  0.1022      0.915 0.968 0.000 0.000 0.032
#> SRR2936898     3  0.0000      0.968 0.000 0.000 1.000 0.000
#> SRR2936899     3  0.0000      0.968 0.000 0.000 1.000 0.000
#> SRR2936897     1  0.4222      0.826 0.728 0.000 0.000 0.272
#> SRR2936896     2  0.4941     -0.365 0.000 0.564 0.000 0.436
#> SRR2936894     1  0.0921      0.913 0.972 0.000 0.000 0.028
#> SRR2936893     2  0.0000      0.877 0.000 1.000 0.000 0.000
#> SRR2936895     2  0.0592      0.873 0.000 0.984 0.016 0.000
#> SRR2936892     2  0.0817      0.869 0.000 0.976 0.024 0.000
#> SRR2936891     1  0.0921      0.913 0.972 0.000 0.000 0.028
#> SRR2936890     2  0.0000      0.877 0.000 1.000 0.000 0.000
#> SRR2936886     3  0.0000      0.968 0.000 0.000 1.000 0.000
#> SRR2936885     1  0.2011      0.908 0.920 0.000 0.000 0.080
#> SRR2936888     1  0.0921      0.913 0.972 0.000 0.000 0.028
#> SRR2936889     2  0.0000      0.877 0.000 1.000 0.000 0.000
#> SRR2936887     3  0.0000      0.968 0.000 0.000 1.000 0.000
#> SRR2936884     2  0.0000      0.877 0.000 1.000 0.000 0.000
#> SRR2936883     2  0.2469      0.797 0.000 0.892 0.108 0.000
#> SRR2936881     2  0.2469      0.797 0.000 0.892 0.108 0.000
#> SRR2936882     1  0.1022      0.915 0.968 0.000 0.000 0.032
#> SRR2936880     2  0.0817      0.869 0.000 0.976 0.024 0.000
#> SRR2936878     4  0.4406      1.000 0.000 0.300 0.000 0.700
#> SRR2936879     3  0.0000      0.968 0.000 0.000 1.000 0.000
#> SRR2936875     2  0.0000      0.877 0.000 1.000 0.000 0.000
#> SRR2936877     4  0.4406      1.000 0.000 0.300 0.000 0.700
#> SRR2936876     3  0.3400      0.845 0.000 0.000 0.820 0.180
#> SRR2936873     1  0.2011      0.908 0.920 0.000 0.000 0.080
#> SRR2936872     2  0.0000      0.877 0.000 1.000 0.000 0.000
#> SRR2936871     2  0.0000      0.877 0.000 1.000 0.000 0.000
#> SRR2936874     2  0.2011      0.825 0.000 0.920 0.080 0.000
#> SRR2936870     1  0.0921      0.913 0.972 0.000 0.000 0.028
#> SRR2936869     3  0.0000      0.968 0.000 0.000 1.000 0.000
#> SRR2936868     3  0.0817      0.957 0.000 0.000 0.976 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
#> SRR2936906     1   0.000     0.7103 1.000 0.000 0.000 0.000 0.000
#> SRR2936909     3   0.420     0.9855 0.408 0.000 0.592 0.000 0.000
#> SRR2936918     1   0.191     0.6922 0.908 0.000 0.000 0.000 0.092
#> SRR2936917     5   0.256     0.9980 0.000 0.144 0.000 0.000 0.856
#> SRR2936916     4   0.388     0.6171 0.000 0.000 0.316 0.684 0.000
#> SRR2936915     4   0.029     0.8944 0.000 0.000 0.008 0.992 0.000
#> SRR2936914     5   0.256     0.9980 0.000 0.144 0.000 0.000 0.856
#> SRR2936913     5   0.256     0.9980 0.000 0.144 0.000 0.000 0.856
#> SRR2936912     3   0.420     0.9855 0.408 0.000 0.592 0.000 0.000
#> SRR2936910     1   0.446     0.5766 0.756 0.000 0.152 0.000 0.092
#> SRR2936911     5   0.256     0.9980 0.000 0.144 0.000 0.000 0.856
#> SRR2936907     2   0.457    -0.0828 0.000 0.580 0.012 0.000 0.408
#> SRR2936908     2   0.000     0.8003 0.000 1.000 0.000 0.000 0.000
#> SRR2936904     4   0.434     0.7182 0.000 0.000 0.296 0.684 0.020
#> SRR2936905     2   0.000     0.8003 0.000 1.000 0.000 0.000 0.000
#> SRR2936903     3   0.483     0.9561 0.408 0.000 0.568 0.000 0.024
#> SRR2936901     4   0.112     0.8916 0.000 0.000 0.016 0.964 0.020
#> SRR2936902     2   0.448     0.6969 0.000 0.668 0.308 0.024 0.000
#> SRR2936900     1   0.510     0.5015 0.692 0.000 0.192 0.000 0.116
#> SRR2936898     4   0.029     0.8944 0.000 0.000 0.008 0.992 0.000
#> SRR2936899     4   0.029     0.8944 0.000 0.000 0.008 0.992 0.000
#> SRR2936897     3   0.420     0.9855 0.408 0.000 0.592 0.000 0.000
#> SRR2936896     2   0.457    -0.0828 0.000 0.580 0.012 0.000 0.408
#> SRR2936894     1   0.000     0.7103 1.000 0.000 0.000 0.000 0.000
#> SRR2936893     2   0.000     0.8003 0.000 1.000 0.000 0.000 0.000
#> SRR2936895     2   0.384     0.7092 0.000 0.692 0.308 0.000 0.000
#> SRR2936892     2   0.134     0.7923 0.000 0.944 0.056 0.000 0.000
#> SRR2936891     1   0.000     0.7103 1.000 0.000 0.000 0.000 0.000
#> SRR2936890     2   0.000     0.8003 0.000 1.000 0.000 0.000 0.000
#> SRR2936886     4   0.173     0.8909 0.000 0.000 0.080 0.920 0.000
#> SRR2936885     1   0.551     0.3484 0.632 0.000 0.252 0.000 0.116
#> SRR2936888     1   0.029     0.7088 0.992 0.000 0.000 0.000 0.008
#> SRR2936889     2   0.000     0.8003 0.000 1.000 0.000 0.000 0.000
#> SRR2936887     4   0.173     0.8909 0.000 0.000 0.080 0.920 0.000
#> SRR2936884     2   0.293     0.7569 0.000 0.820 0.180 0.000 0.000
#> SRR2936883     2   0.448     0.6969 0.000 0.668 0.308 0.024 0.000
#> SRR2936881     2   0.448     0.6969 0.000 0.668 0.308 0.024 0.000
#> SRR2936882     1   0.510     0.5015 0.692 0.000 0.192 0.000 0.116
#> SRR2936880     2   0.384     0.7092 0.000 0.692 0.308 0.000 0.000
#> SRR2936878     5   0.256     0.9980 0.000 0.144 0.000 0.000 0.856
#> SRR2936879     4   0.029     0.8944 0.000 0.000 0.008 0.992 0.000
#> SRR2936875     2   0.000     0.8003 0.000 1.000 0.000 0.000 0.000
#> SRR2936877     5   0.295     0.9899 0.000 0.144 0.012 0.000 0.844
#> SRR2936876     4   0.432     0.6584 0.000 0.000 0.292 0.688 0.020
#> SRR2936873     1   0.535     0.3414 0.636 0.000 0.272 0.000 0.092
#> SRR2936872     2   0.000     0.8003 0.000 1.000 0.000 0.000 0.000
#> SRR2936871     2   0.000     0.8003 0.000 1.000 0.000 0.000 0.000
#> SRR2936874     2   0.344     0.7572 0.000 0.808 0.172 0.020 0.000
#> SRR2936870     1   0.029     0.7088 0.992 0.000 0.000 0.000 0.008
#> SRR2936869     4   0.148     0.8915 0.000 0.000 0.064 0.936 0.000
#> SRR2936868     4   0.173     0.8909 0.000 0.000 0.080 0.920 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
#> SRR2936906     1  0.0146      0.748 0.996 0.000 0.004 0.000 0.000 0.000
#> SRR2936909     6  0.3351      0.991 0.288 0.000 0.000 0.000 0.000 0.712
#> SRR2936918     1  0.2480      0.735 0.872 0.000 0.104 0.000 0.024 0.000
#> SRR2936917     5  0.0937      0.992 0.000 0.040 0.000 0.000 0.960 0.000
#> SRR2936916     3  0.4205      0.102 0.000 0.000 0.564 0.420 0.000 0.016
#> SRR2936915     4  0.0717      0.849 0.000 0.000 0.016 0.976 0.000 0.008
#> SRR2936914     5  0.0937      0.992 0.000 0.040 0.000 0.000 0.960 0.000
#> SRR2936913     5  0.1082      0.992 0.000 0.040 0.000 0.000 0.956 0.004
#> SRR2936912     6  0.3351      0.991 0.288 0.000 0.000 0.000 0.000 0.712
#> SRR2936910     1  0.4587      0.665 0.736 0.000 0.104 0.000 0.024 0.136
#> SRR2936911     5  0.1082      0.992 0.000 0.040 0.000 0.000 0.956 0.004
#> SRR2936907     2  0.5134      0.402 0.000 0.628 0.008 0.000 0.256 0.108
#> SRR2936908     2  0.1588      0.745 0.000 0.924 0.004 0.000 0.000 0.072
#> SRR2936904     4  0.5326      0.714 0.000 0.000 0.172 0.612 0.004 0.212
#> SRR2936905     2  0.0000      0.761 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936903     6  0.3859      0.972 0.288 0.000 0.020 0.000 0.000 0.692
#> SRR2936901     4  0.1949      0.836 0.000 0.000 0.088 0.904 0.004 0.004
#> SRR2936902     3  0.4046      0.788 0.000 0.368 0.620 0.004 0.000 0.008
#> SRR2936900     1  0.4734      0.627 0.680 0.000 0.152 0.000 0.000 0.168
#> SRR2936898     4  0.1124      0.844 0.000 0.000 0.036 0.956 0.000 0.008
#> SRR2936899     4  0.1124      0.844 0.000 0.000 0.036 0.956 0.000 0.008
#> SRR2936897     6  0.3351      0.991 0.288 0.000 0.000 0.000 0.000 0.712
#> SRR2936896     2  0.5211      0.394 0.000 0.620 0.008 0.000 0.256 0.116
#> SRR2936894     1  0.0146      0.748 0.996 0.000 0.004 0.000 0.000 0.000
#> SRR2936893     2  0.1588      0.745 0.000 0.924 0.004 0.000 0.000 0.072
#> SRR2936895     3  0.4437      0.742 0.000 0.392 0.576 0.000 0.000 0.032
#> SRR2936892     2  0.3017      0.658 0.000 0.844 0.084 0.000 0.000 0.072
#> SRR2936891     1  0.0146      0.748 0.996 0.000 0.004 0.000 0.000 0.000
#> SRR2936890     2  0.0000      0.761 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936886     4  0.3215      0.851 0.000 0.000 0.100 0.828 0.000 0.072
#> SRR2936885     1  0.5177      0.516 0.612 0.000 0.152 0.000 0.000 0.236
#> SRR2936888     1  0.0725      0.744 0.976 0.000 0.012 0.000 0.012 0.000
#> SRR2936889     2  0.0000      0.761 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936887     4  0.3215      0.851 0.000 0.000 0.100 0.828 0.000 0.072
#> SRR2936884     2  0.4333     -0.266 0.000 0.596 0.376 0.000 0.000 0.028
#> SRR2936883     3  0.4046      0.788 0.000 0.368 0.620 0.004 0.000 0.008
#> SRR2936881     3  0.3807      0.788 0.000 0.368 0.628 0.004 0.000 0.000
#> SRR2936882     1  0.4734      0.627 0.680 0.000 0.152 0.000 0.000 0.168
#> SRR2936880     3  0.3975      0.763 0.000 0.392 0.600 0.000 0.000 0.008
#> SRR2936878     5  0.0937      0.992 0.000 0.040 0.000 0.000 0.960 0.000
#> SRR2936879     4  0.1124      0.844 0.000 0.000 0.036 0.956 0.000 0.008
#> SRR2936875     2  0.1588      0.745 0.000 0.924 0.004 0.000 0.000 0.072
#> SRR2936877     5  0.2051      0.966 0.000 0.040 0.008 0.000 0.916 0.036
#> SRR2936876     4  0.5037      0.543 0.000 0.000 0.088 0.604 0.004 0.304
#> SRR2936873     1  0.5426      0.510 0.616 0.000 0.104 0.000 0.024 0.256
#> SRR2936872     2  0.0000      0.761 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936871     2  0.0000      0.761 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936874     2  0.4586      0.222 0.000 0.660 0.264 0.000 0.000 0.076
#> SRR2936870     1  0.0725      0.744 0.976 0.000 0.012 0.000 0.012 0.000
#> SRR2936869     4  0.3063      0.851 0.000 0.000 0.092 0.840 0.000 0.068
#> SRR2936868     4  0.3352      0.849 0.000 0.000 0.112 0.816 0.000 0.072

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)
#> Error in mat[ceiling(1:nr/h_ratio), ceiling(1:nc/w_ratio), drop = FALSE]: subscript out of bounds

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

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

collect_plots(res)

plot of chunk ATC-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.5103 0.490   0.490
#> 3 3 1.000           1.000       1.000         0.1751 0.911   0.818
#> 4 4 1.000           0.990       0.997         0.0378 0.973   0.932
#> 5 5 0.869           0.919       0.952         0.0453 0.998   0.996
#> 6 6 0.869           0.527       0.785         0.0671 0.895   0.721

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette    p1    p2
#> SRR2936906     1  0.0000      1.000 1.000 0.000
#> SRR2936909     1  0.0000      1.000 1.000 0.000
#> SRR2936918     1  0.0000      1.000 1.000 0.000
#> SRR2936917     2  0.0000      1.000 0.000 1.000
#> SRR2936916     2  0.0000      1.000 0.000 1.000
#> SRR2936915     1  0.0000      1.000 1.000 0.000
#> SRR2936914     2  0.0000      1.000 0.000 1.000
#> SRR2936913     2  0.0000      1.000 0.000 1.000
#> SRR2936912     1  0.0000      1.000 1.000 0.000
#> SRR2936910     1  0.0000      1.000 1.000 0.000
#> SRR2936911     2  0.0000      1.000 0.000 1.000
#> SRR2936907     2  0.0000      1.000 0.000 1.000
#> SRR2936908     2  0.0000      1.000 0.000 1.000
#> SRR2936904     1  0.0000      1.000 1.000 0.000
#> SRR2936905     2  0.0000      1.000 0.000 1.000
#> SRR2936903     1  0.0000      1.000 1.000 0.000
#> SRR2936901     1  0.0000      1.000 1.000 0.000
#> SRR2936902     2  0.0000      1.000 0.000 1.000
#> SRR2936900     1  0.0000      1.000 1.000 0.000
#> SRR2936898     1  0.0376      0.996 0.996 0.004
#> SRR2936899     1  0.0000      1.000 1.000 0.000
#> SRR2936897     1  0.0000      1.000 1.000 0.000
#> SRR2936896     2  0.0000      1.000 0.000 1.000
#> SRR2936894     1  0.0000      1.000 1.000 0.000
#> SRR2936893     2  0.0000      1.000 0.000 1.000
#> SRR2936895     2  0.0000      1.000 0.000 1.000
#> SRR2936892     2  0.0000      1.000 0.000 1.000
#> SRR2936891     1  0.0000      1.000 1.000 0.000
#> SRR2936890     2  0.0000      1.000 0.000 1.000
#> SRR2936886     1  0.0000      1.000 1.000 0.000
#> SRR2936885     1  0.0000      1.000 1.000 0.000
#> SRR2936888     1  0.0000      1.000 1.000 0.000
#> SRR2936889     2  0.0000      1.000 0.000 1.000
#> SRR2936887     1  0.0000      1.000 1.000 0.000
#> SRR2936884     2  0.0000      1.000 0.000 1.000
#> SRR2936883     2  0.0000      1.000 0.000 1.000
#> SRR2936881     2  0.0000      1.000 0.000 1.000
#> SRR2936882     1  0.0000      1.000 1.000 0.000
#> SRR2936880     2  0.0000      1.000 0.000 1.000
#> SRR2936878     2  0.0000      1.000 0.000 1.000
#> SRR2936879     2  0.0000      1.000 0.000 1.000
#> SRR2936875     2  0.0000      1.000 0.000 1.000
#> SRR2936877     2  0.0000      1.000 0.000 1.000
#> SRR2936876     1  0.0000      1.000 1.000 0.000
#> SRR2936873     1  0.0000      1.000 1.000 0.000
#> SRR2936872     2  0.0000      1.000 0.000 1.000
#> SRR2936871     2  0.0000      1.000 0.000 1.000
#> SRR2936874     2  0.0000      1.000 0.000 1.000
#> SRR2936870     1  0.0000      1.000 1.000 0.000
#> SRR2936869     1  0.0000      1.000 1.000 0.000
#> SRR2936868     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
#> SRR2936906     1       0          1  1  0  0
#> SRR2936909     1       0          1  1  0  0
#> SRR2936918     1       0          1  1  0  0
#> SRR2936917     2       0          1  0  1  0
#> SRR2936916     2       0          1  0  1  0
#> SRR2936915     1       0          1  1  0  0
#> SRR2936914     2       0          1  0  1  0
#> SRR2936913     2       0          1  0  1  0
#> SRR2936912     1       0          1  1  0  0
#> SRR2936910     1       0          1  1  0  0
#> SRR2936911     2       0          1  0  1  0
#> SRR2936907     2       0          1  0  1  0
#> SRR2936908     2       0          1  0  1  0
#> SRR2936904     1       0          1  1  0  0
#> SRR2936905     2       0          1  0  1  0
#> SRR2936903     1       0          1  1  0  0
#> SRR2936901     1       0          1  1  0  0
#> SRR2936902     2       0          1  0  1  0
#> SRR2936900     1       0          1  1  0  0
#> SRR2936898     3       0          1  0  0  1
#> SRR2936899     3       0          1  0  0  1
#> SRR2936897     1       0          1  1  0  0
#> SRR2936896     2       0          1  0  1  0
#> SRR2936894     1       0          1  1  0  0
#> SRR2936893     2       0          1  0  1  0
#> SRR2936895     2       0          1  0  1  0
#> SRR2936892     2       0          1  0  1  0
#> SRR2936891     1       0          1  1  0  0
#> SRR2936890     2       0          1  0  1  0
#> SRR2936886     3       0          1  0  0  1
#> SRR2936885     1       0          1  1  0  0
#> SRR2936888     1       0          1  1  0  0
#> SRR2936889     2       0          1  0  1  0
#> SRR2936887     3       0          1  0  0  1
#> SRR2936884     2       0          1  0  1  0
#> SRR2936883     2       0          1  0  1  0
#> SRR2936881     2       0          1  0  1  0
#> SRR2936882     1       0          1  1  0  0
#> SRR2936880     2       0          1  0  1  0
#> SRR2936878     2       0          1  0  1  0
#> SRR2936879     2       0          1  0  1  0
#> SRR2936875     2       0          1  0  1  0
#> SRR2936877     2       0          1  0  1  0
#> SRR2936876     1       0          1  1  0  0
#> SRR2936873     1       0          1  1  0  0
#> SRR2936872     2       0          1  0  1  0
#> SRR2936871     2       0          1  0  1  0
#> SRR2936874     2       0          1  0  1  0
#> SRR2936870     1       0          1  1  0  0
#> SRR2936869     3       0          1  0  0  1
#> SRR2936868     3       0          1  0  0  1

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette p1    p2    p3    p4
#> SRR2936906     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR2936909     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR2936918     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR2936917     2  0.0000      0.998  0 1.000 0.000 0.000
#> SRR2936916     2  0.0000      0.998  0 1.000 0.000 0.000
#> SRR2936915     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR2936914     2  0.0000      0.998  0 1.000 0.000 0.000
#> SRR2936913     2  0.0000      0.998  0 1.000 0.000 0.000
#> SRR2936912     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR2936910     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR2936911     2  0.0000      0.998  0 1.000 0.000 0.000
#> SRR2936907     2  0.0188      0.998  0 0.996 0.004 0.000
#> SRR2936908     2  0.0188      0.998  0 0.996 0.004 0.000
#> SRR2936904     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR2936905     2  0.0188      0.998  0 0.996 0.004 0.000
#> SRR2936903     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR2936901     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR2936902     2  0.0000      0.998  0 1.000 0.000 0.000
#> SRR2936900     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR2936898     3  0.0188      0.888  0 0.000 0.996 0.004
#> SRR2936899     3  0.0188      0.888  0 0.000 0.996 0.004
#> SRR2936897     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR2936896     2  0.0000      0.998  0 1.000 0.000 0.000
#> SRR2936894     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR2936893     2  0.0188      0.998  0 0.996 0.004 0.000
#> SRR2936895     2  0.0000      0.998  0 1.000 0.000 0.000
#> SRR2936892     2  0.0188      0.998  0 0.996 0.004 0.000
#> SRR2936891     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR2936890     2  0.0188      0.998  0 0.996 0.004 0.000
#> SRR2936886     4  0.0000      1.000  0 0.000 0.000 1.000
#> SRR2936885     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR2936888     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR2936889     2  0.0188      0.998  0 0.996 0.004 0.000
#> SRR2936887     4  0.0000      1.000  0 0.000 0.000 1.000
#> SRR2936884     2  0.0000      0.998  0 1.000 0.000 0.000
#> SRR2936883     2  0.0000      0.998  0 1.000 0.000 0.000
#> SRR2936881     2  0.0000      0.998  0 1.000 0.000 0.000
#> SRR2936882     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR2936880     2  0.0000      0.998  0 1.000 0.000 0.000
#> SRR2936878     2  0.0000      0.998  0 1.000 0.000 0.000
#> SRR2936879     3  0.2469      0.778  0 0.108 0.892 0.000
#> SRR2936875     2  0.0188      0.998  0 0.996 0.004 0.000
#> SRR2936877     2  0.0000      0.998  0 1.000 0.000 0.000
#> SRR2936876     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR2936873     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR2936872     2  0.0188      0.998  0 0.996 0.004 0.000
#> SRR2936871     2  0.0188      0.998  0 0.996 0.004 0.000
#> SRR2936874     2  0.0188      0.998  0 0.996 0.004 0.000
#> SRR2936870     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR2936869     4  0.0000      1.000  0 0.000 0.000 1.000
#> SRR2936868     4  0.0000      1.000  0 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
#> SRR2936906     1  0.0000      0.988 1.000 0.000 0.000  0 0.000
#> SRR2936909     1  0.0000      0.988 1.000 0.000 0.000  0 0.000
#> SRR2936918     1  0.0000      0.988 1.000 0.000 0.000  0 0.000
#> SRR2936917     2  0.0000      0.906 0.000 1.000 0.000  0 0.000
#> SRR2936916     2  0.0290      0.904 0.000 0.992 0.000  0 0.008
#> SRR2936915     1  0.3242      0.725 0.784 0.000 0.000  0 0.216
#> SRR2936914     2  0.0000      0.906 0.000 1.000 0.000  0 0.000
#> SRR2936913     2  0.0000      0.906 0.000 1.000 0.000  0 0.000
#> SRR2936912     1  0.0000      0.988 1.000 0.000 0.000  0 0.000
#> SRR2936910     1  0.0000      0.988 1.000 0.000 0.000  0 0.000
#> SRR2936911     2  0.0000      0.906 0.000 1.000 0.000  0 0.000
#> SRR2936907     2  0.2966      0.879 0.000 0.816 0.000  0 0.184
#> SRR2936908     2  0.2966      0.879 0.000 0.816 0.000  0 0.184
#> SRR2936904     1  0.0000      0.988 1.000 0.000 0.000  0 0.000
#> SRR2936905     2  0.2966      0.879 0.000 0.816 0.000  0 0.184
#> SRR2936903     1  0.0000      0.988 1.000 0.000 0.000  0 0.000
#> SRR2936901     1  0.0000      0.988 1.000 0.000 0.000  0 0.000
#> SRR2936902     2  0.0290      0.904 0.000 0.992 0.000  0 0.008
#> SRR2936900     1  0.0000      0.988 1.000 0.000 0.000  0 0.000
#> SRR2936898     3  0.0000      1.000 0.000 0.000 1.000  0 0.000
#> SRR2936899     3  0.0000      1.000 0.000 0.000 1.000  0 0.000
#> SRR2936897     1  0.0000      0.988 1.000 0.000 0.000  0 0.000
#> SRR2936896     2  0.0000      0.906 0.000 1.000 0.000  0 0.000
#> SRR2936894     1  0.0000      0.988 1.000 0.000 0.000  0 0.000
#> SRR2936893     2  0.2966      0.879 0.000 0.816 0.000  0 0.184
#> SRR2936895     2  0.0162      0.905 0.000 0.996 0.000  0 0.004
#> SRR2936892     2  0.2966      0.879 0.000 0.816 0.000  0 0.184
#> SRR2936891     1  0.0000      0.988 1.000 0.000 0.000  0 0.000
#> SRR2936890     2  0.2966      0.879 0.000 0.816 0.000  0 0.184
#> SRR2936886     4  0.0000      1.000 0.000 0.000 0.000  1 0.000
#> SRR2936885     1  0.0000      0.988 1.000 0.000 0.000  0 0.000
#> SRR2936888     1  0.0000      0.988 1.000 0.000 0.000  0 0.000
#> SRR2936889     2  0.2966      0.879 0.000 0.816 0.000  0 0.184
#> SRR2936887     4  0.0000      1.000 0.000 0.000 0.000  1 0.000
#> SRR2936884     2  0.0290      0.904 0.000 0.992 0.000  0 0.008
#> SRR2936883     2  0.0290      0.904 0.000 0.992 0.000  0 0.008
#> SRR2936881     2  0.0290      0.904 0.000 0.992 0.000  0 0.008
#> SRR2936882     1  0.0000      0.988 1.000 0.000 0.000  0 0.000
#> SRR2936880     2  0.0290      0.904 0.000 0.992 0.000  0 0.008
#> SRR2936878     2  0.0000      0.906 0.000 1.000 0.000  0 0.000
#> SRR2936879     5  0.2843      0.000 0.000 0.008 0.144  0 0.848
#> SRR2936875     2  0.2966      0.879 0.000 0.816 0.000  0 0.184
#> SRR2936877     2  0.0000      0.906 0.000 1.000 0.000  0 0.000
#> SRR2936876     1  0.0000      0.988 1.000 0.000 0.000  0 0.000
#> SRR2936873     1  0.0000      0.988 1.000 0.000 0.000  0 0.000
#> SRR2936872     2  0.2966      0.879 0.000 0.816 0.000  0 0.184
#> SRR2936871     2  0.2966      0.879 0.000 0.816 0.000  0 0.184
#> SRR2936874     2  0.2966      0.879 0.000 0.816 0.000  0 0.184
#> SRR2936870     1  0.0000      0.988 1.000 0.000 0.000  0 0.000
#> SRR2936869     4  0.0000      1.000 0.000 0.000 0.000  1 0.000
#> SRR2936868     4  0.0000      1.000 0.000 0.000 0.000  1 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
#> SRR2936906     1  0.0000      1.000 1.000 0.000 0.000  0 0.000 0.000
#> SRR2936909     1  0.0000      1.000 1.000 0.000 0.000  0 0.000 0.000
#> SRR2936918     1  0.0000      1.000 1.000 0.000 0.000  0 0.000 0.000
#> SRR2936917     2  0.3868     -0.961 0.000 0.508 0.492  0 0.000 0.000
#> SRR2936916     3  0.3868      1.000 0.000 0.496 0.504  0 0.000 0.000
#> SRR2936915     5  0.5171     -0.117 0.416 0.000 0.000  0 0.496 0.088
#> SRR2936914     2  0.3868     -0.961 0.000 0.508 0.492  0 0.000 0.000
#> SRR2936913     2  0.3868     -0.961 0.000 0.508 0.492  0 0.000 0.000
#> SRR2936912     1  0.0000      1.000 1.000 0.000 0.000  0 0.000 0.000
#> SRR2936910     1  0.0000      1.000 1.000 0.000 0.000  0 0.000 0.000
#> SRR2936911     2  0.3868     -0.961 0.000 0.508 0.492  0 0.000 0.000
#> SRR2936907     2  0.0000      0.560 0.000 1.000 0.000  0 0.000 0.000
#> SRR2936908     2  0.0000      0.560 0.000 1.000 0.000  0 0.000 0.000
#> SRR2936904     1  0.0146      0.995 0.996 0.000 0.000  0 0.004 0.000
#> SRR2936905     2  0.0000      0.560 0.000 1.000 0.000  0 0.000 0.000
#> SRR2936903     1  0.0000      1.000 1.000 0.000 0.000  0 0.000 0.000
#> SRR2936901     1  0.0000      1.000 1.000 0.000 0.000  0 0.000 0.000
#> SRR2936902     3  0.3868      1.000 0.000 0.496 0.504  0 0.000 0.000
#> SRR2936900     1  0.0000      1.000 1.000 0.000 0.000  0 0.000 0.000
#> SRR2936898     5  0.3868      0.286 0.000 0.000 0.496  0 0.504 0.000
#> SRR2936899     5  0.3868      0.286 0.000 0.000 0.496  0 0.504 0.000
#> SRR2936897     1  0.0000      1.000 1.000 0.000 0.000  0 0.000 0.000
#> SRR2936896     2  0.3868     -0.961 0.000 0.508 0.492  0 0.000 0.000
#> SRR2936894     1  0.0000      1.000 1.000 0.000 0.000  0 0.000 0.000
#> SRR2936893     2  0.0000      0.560 0.000 1.000 0.000  0 0.000 0.000
#> SRR2936895     2  0.3869     -0.987 0.000 0.500 0.500  0 0.000 0.000
#> SRR2936892     2  0.0000      0.560 0.000 1.000 0.000  0 0.000 0.000
#> SRR2936891     1  0.0000      1.000 1.000 0.000 0.000  0 0.000 0.000
#> SRR2936890     2  0.0000      0.560 0.000 1.000 0.000  0 0.000 0.000
#> SRR2936886     4  0.0000      1.000 0.000 0.000 0.000  1 0.000 0.000
#> SRR2936885     1  0.0000      1.000 1.000 0.000 0.000  0 0.000 0.000
#> SRR2936888     1  0.0000      1.000 1.000 0.000 0.000  0 0.000 0.000
#> SRR2936889     2  0.0000      0.560 0.000 1.000 0.000  0 0.000 0.000
#> SRR2936887     4  0.0000      1.000 0.000 0.000 0.000  1 0.000 0.000
#> SRR2936884     3  0.3868      1.000 0.000 0.496 0.504  0 0.000 0.000
#> SRR2936883     3  0.3868      1.000 0.000 0.496 0.504  0 0.000 0.000
#> SRR2936881     3  0.3868      1.000 0.000 0.496 0.504  0 0.000 0.000
#> SRR2936882     1  0.0000      1.000 1.000 0.000 0.000  0 0.000 0.000
#> SRR2936880     3  0.3868      1.000 0.000 0.496 0.504  0 0.000 0.000
#> SRR2936878     2  0.3868     -0.961 0.000 0.508 0.492  0 0.000 0.000
#> SRR2936879     6  0.0000      0.000 0.000 0.000 0.000  0 0.000 1.000
#> SRR2936875     2  0.0000      0.560 0.000 1.000 0.000  0 0.000 0.000
#> SRR2936877     2  0.3868     -0.961 0.000 0.508 0.492  0 0.000 0.000
#> SRR2936876     1  0.0000      1.000 1.000 0.000 0.000  0 0.000 0.000
#> SRR2936873     1  0.0000      1.000 1.000 0.000 0.000  0 0.000 0.000
#> SRR2936872     2  0.0000      0.560 0.000 1.000 0.000  0 0.000 0.000
#> SRR2936871     2  0.0000      0.560 0.000 1.000 0.000  0 0.000 0.000
#> SRR2936874     2  0.0000      0.560 0.000 1.000 0.000  0 0.000 0.000
#> SRR2936870     1  0.0000      1.000 1.000 0.000 0.000  0 0.000 0.000
#> SRR2936869     4  0.0000      1.000 0.000 0.000 0.000  1 0.000 0.000
#> SRR2936868     4  0.0000      1.000 0.000 0.000 0.000  1 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-skmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-skmeans-collect-classes

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


ATC:pam**

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

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

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

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

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

collect_plots(res)

plot of chunk ATC-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.960       0.985         0.4658 0.534   0.534
#> 3 3 1.000           0.920       0.973         0.4181 0.749   0.552
#> 4 4 1.000           0.990       0.996         0.1053 0.861   0.627
#> 5 5 0.881           0.936       0.900         0.0762 0.934   0.757
#> 6 6 0.887           0.896       0.919         0.0574 0.961   0.809

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette    p1    p2
#> SRR2936906     1   0.000      0.977 1.000 0.000
#> SRR2936909     1   0.000      0.977 1.000 0.000
#> SRR2936918     1   0.000      0.977 1.000 0.000
#> SRR2936917     2   0.000      0.988 0.000 1.000
#> SRR2936916     2   0.000      0.988 0.000 1.000
#> SRR2936915     2   0.000      0.988 0.000 1.000
#> SRR2936914     2   0.000      0.988 0.000 1.000
#> SRR2936913     2   0.000      0.988 0.000 1.000
#> SRR2936912     1   0.000      0.977 1.000 0.000
#> SRR2936910     1   0.000      0.977 1.000 0.000
#> SRR2936911     2   0.000      0.988 0.000 1.000
#> SRR2936907     2   0.000      0.988 0.000 1.000
#> SRR2936908     2   0.000      0.988 0.000 1.000
#> SRR2936904     1   0.000      0.977 1.000 0.000
#> SRR2936905     2   0.000      0.988 0.000 1.000
#> SRR2936903     1   0.000      0.977 1.000 0.000
#> SRR2936901     1   0.958      0.370 0.620 0.380
#> SRR2936902     2   0.000      0.988 0.000 1.000
#> SRR2936900     1   0.000      0.977 1.000 0.000
#> SRR2936898     2   0.000      0.988 0.000 1.000
#> SRR2936899     2   0.000      0.988 0.000 1.000
#> SRR2936897     1   0.000      0.977 1.000 0.000
#> SRR2936896     2   0.000      0.988 0.000 1.000
#> SRR2936894     1   0.000      0.977 1.000 0.000
#> SRR2936893     2   0.000      0.988 0.000 1.000
#> SRR2936895     2   0.000      0.988 0.000 1.000
#> SRR2936892     2   0.000      0.988 0.000 1.000
#> SRR2936891     1   0.000      0.977 1.000 0.000
#> SRR2936890     2   0.000      0.988 0.000 1.000
#> SRR2936886     2   0.000      0.988 0.000 1.000
#> SRR2936885     1   0.000      0.977 1.000 0.000
#> SRR2936888     1   0.000      0.977 1.000 0.000
#> SRR2936889     2   0.000      0.988 0.000 1.000
#> SRR2936887     2   0.000      0.988 0.000 1.000
#> SRR2936884     2   0.000      0.988 0.000 1.000
#> SRR2936883     2   0.000      0.988 0.000 1.000
#> SRR2936881     2   0.000      0.988 0.000 1.000
#> SRR2936882     1   0.000      0.977 1.000 0.000
#> SRR2936880     2   0.000      0.988 0.000 1.000
#> SRR2936878     2   0.000      0.988 0.000 1.000
#> SRR2936879     2   0.000      0.988 0.000 1.000
#> SRR2936875     2   0.000      0.988 0.000 1.000
#> SRR2936877     2   0.000      0.988 0.000 1.000
#> SRR2936876     1   0.000      0.977 1.000 0.000
#> SRR2936873     1   0.000      0.977 1.000 0.000
#> SRR2936872     2   0.000      0.988 0.000 1.000
#> SRR2936871     2   0.000      0.988 0.000 1.000
#> SRR2936874     2   0.000      0.988 0.000 1.000
#> SRR2936870     1   0.000      0.977 1.000 0.000
#> SRR2936869     2   0.000      0.988 0.000 1.000
#> SRR2936868     2   0.955      0.371 0.376 0.624

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette p1    p2    p3
#> SRR2936906     1   0.000     1.0000  1 0.000 0.000
#> SRR2936909     1   0.000     1.0000  1 0.000 0.000
#> SRR2936918     1   0.000     1.0000  1 0.000 0.000
#> SRR2936917     2   0.000     0.9764  0 1.000 0.000
#> SRR2936916     3   0.000     0.9180  0 0.000 1.000
#> SRR2936915     3   0.000     0.9180  0 0.000 1.000
#> SRR2936914     2   0.000     0.9764  0 1.000 0.000
#> SRR2936913     2   0.000     0.9764  0 1.000 0.000
#> SRR2936912     1   0.000     1.0000  1 0.000 0.000
#> SRR2936910     1   0.000     1.0000  1 0.000 0.000
#> SRR2936911     2   0.000     0.9764  0 1.000 0.000
#> SRR2936907     2   0.000     0.9764  0 1.000 0.000
#> SRR2936908     2   0.000     0.9764  0 1.000 0.000
#> SRR2936904     3   0.000     0.9180  0 0.000 1.000
#> SRR2936905     2   0.000     0.9764  0 1.000 0.000
#> SRR2936903     1   0.000     1.0000  1 0.000 0.000
#> SRR2936901     3   0.000     0.9180  0 0.000 1.000
#> SRR2936902     3   0.629     0.1495  0 0.468 0.532
#> SRR2936900     1   0.000     1.0000  1 0.000 0.000
#> SRR2936898     3   0.000     0.9180  0 0.000 1.000
#> SRR2936899     3   0.000     0.9180  0 0.000 1.000
#> SRR2936897     1   0.000     1.0000  1 0.000 0.000
#> SRR2936896     2   0.000     0.9764  0 1.000 0.000
#> SRR2936894     1   0.000     1.0000  1 0.000 0.000
#> SRR2936893     2   0.000     0.9764  0 1.000 0.000
#> SRR2936895     2   0.000     0.9764  0 1.000 0.000
#> SRR2936892     2   0.000     0.9764  0 1.000 0.000
#> SRR2936891     1   0.000     1.0000  1 0.000 0.000
#> SRR2936890     2   0.000     0.9764  0 1.000 0.000
#> SRR2936886     3   0.000     0.9180  0 0.000 1.000
#> SRR2936885     1   0.000     1.0000  1 0.000 0.000
#> SRR2936888     1   0.000     1.0000  1 0.000 0.000
#> SRR2936889     2   0.000     0.9764  0 1.000 0.000
#> SRR2936887     3   0.000     0.9180  0 0.000 1.000
#> SRR2936884     2   0.000     0.9764  0 1.000 0.000
#> SRR2936883     2   0.625     0.0789  0 0.556 0.444
#> SRR2936881     3   0.629     0.1495  0 0.468 0.532
#> SRR2936882     1   0.000     1.0000  1 0.000 0.000
#> SRR2936880     2   0.000     0.9764  0 1.000 0.000
#> SRR2936878     2   0.000     0.9764  0 1.000 0.000
#> SRR2936879     3   0.000     0.9180  0 0.000 1.000
#> SRR2936875     2   0.000     0.9764  0 1.000 0.000
#> SRR2936877     2   0.000     0.9764  0 1.000 0.000
#> SRR2936876     3   0.000     0.9180  0 0.000 1.000
#> SRR2936873     1   0.000     1.0000  1 0.000 0.000
#> SRR2936872     2   0.000     0.9764  0 1.000 0.000
#> SRR2936871     2   0.000     0.9764  0 1.000 0.000
#> SRR2936874     2   0.000     0.9764  0 1.000 0.000
#> SRR2936870     1   0.000     1.0000  1 0.000 0.000
#> SRR2936869     3   0.000     0.9180  0 0.000 1.000
#> SRR2936868     3   0.000     0.9180  0 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette p1    p2    p3 p4
#> SRR2936906     1   0.000      1.000  1 0.000 0.000  0
#> SRR2936909     1   0.000      1.000  1 0.000 0.000  0
#> SRR2936918     1   0.000      1.000  1 0.000 0.000  0
#> SRR2936917     4   0.000      1.000  0 0.000 0.000  1
#> SRR2936916     2   0.373      0.731  0 0.788 0.212  0
#> SRR2936915     3   0.000      1.000  0 0.000 1.000  0
#> SRR2936914     4   0.000      1.000  0 0.000 0.000  1
#> SRR2936913     4   0.000      1.000  0 0.000 0.000  1
#> SRR2936912     1   0.000      1.000  1 0.000 0.000  0
#> SRR2936910     1   0.000      1.000  1 0.000 0.000  0
#> SRR2936911     4   0.000      1.000  0 0.000 0.000  1
#> SRR2936907     2   0.000      0.987  0 1.000 0.000  0
#> SRR2936908     2   0.000      0.987  0 1.000 0.000  0
#> SRR2936904     3   0.000      1.000  0 0.000 1.000  0
#> SRR2936905     2   0.000      0.987  0 1.000 0.000  0
#> SRR2936903     1   0.000      1.000  1 0.000 0.000  0
#> SRR2936901     3   0.000      1.000  0 0.000 1.000  0
#> SRR2936902     2   0.000      0.987  0 1.000 0.000  0
#> SRR2936900     1   0.000      1.000  1 0.000 0.000  0
#> SRR2936898     3   0.000      1.000  0 0.000 1.000  0
#> SRR2936899     3   0.000      1.000  0 0.000 1.000  0
#> SRR2936897     1   0.000      1.000  1 0.000 0.000  0
#> SRR2936896     2   0.000      0.987  0 1.000 0.000  0
#> SRR2936894     1   0.000      1.000  1 0.000 0.000  0
#> SRR2936893     2   0.000      0.987  0 1.000 0.000  0
#> SRR2936895     2   0.000      0.987  0 1.000 0.000  0
#> SRR2936892     2   0.000      0.987  0 1.000 0.000  0
#> SRR2936891     1   0.000      1.000  1 0.000 0.000  0
#> SRR2936890     2   0.000      0.987  0 1.000 0.000  0
#> SRR2936886     3   0.000      1.000  0 0.000 1.000  0
#> SRR2936885     1   0.000      1.000  1 0.000 0.000  0
#> SRR2936888     1   0.000      1.000  1 0.000 0.000  0
#> SRR2936889     2   0.000      0.987  0 1.000 0.000  0
#> SRR2936887     3   0.000      1.000  0 0.000 1.000  0
#> SRR2936884     2   0.000      0.987  0 1.000 0.000  0
#> SRR2936883     2   0.000      0.987  0 1.000 0.000  0
#> SRR2936881     2   0.000      0.987  0 1.000 0.000  0
#> SRR2936882     1   0.000      1.000  1 0.000 0.000  0
#> SRR2936880     2   0.000      0.987  0 1.000 0.000  0
#> SRR2936878     4   0.000      1.000  0 0.000 0.000  1
#> SRR2936879     3   0.000      1.000  0 0.000 1.000  0
#> SRR2936875     2   0.000      0.987  0 1.000 0.000  0
#> SRR2936877     4   0.000      1.000  0 0.000 0.000  1
#> SRR2936876     3   0.000      1.000  0 0.000 1.000  0
#> SRR2936873     1   0.000      1.000  1 0.000 0.000  0
#> SRR2936872     2   0.000      0.987  0 1.000 0.000  0
#> SRR2936871     2   0.000      0.987  0 1.000 0.000  0
#> SRR2936874     2   0.000      0.987  0 1.000 0.000  0
#> SRR2936870     1   0.000      1.000  1 0.000 0.000  0
#> SRR2936869     3   0.000      1.000  0 0.000 1.000  0
#> SRR2936868     3   0.000      1.000  0 0.000 1.000  0

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4 p5
#> SRR2936906     1  0.0000      0.801 1.000 0.000 0.000 0.000  0
#> SRR2936909     1  0.4182      0.835 0.600 0.000 0.400 0.000  0
#> SRR2936918     1  0.3143      0.857 0.796 0.000 0.204 0.000  0
#> SRR2936917     5  0.0000      1.000 0.000 0.000 0.000 0.000  1
#> SRR2936916     3  0.5844      0.716 0.000 0.244 0.600 0.156  0
#> SRR2936915     4  0.0000      0.994 0.000 0.000 0.000 1.000  0
#> SRR2936914     5  0.0000      1.000 0.000 0.000 0.000 0.000  1
#> SRR2936913     5  0.0000      1.000 0.000 0.000 0.000 0.000  1
#> SRR2936912     1  0.4182      0.835 0.600 0.000 0.400 0.000  0
#> SRR2936910     1  0.4088      0.843 0.632 0.000 0.368 0.000  0
#> SRR2936911     5  0.0000      1.000 0.000 0.000 0.000 0.000  1
#> SRR2936907     2  0.0000      1.000 0.000 1.000 0.000 0.000  0
#> SRR2936908     2  0.0000      1.000 0.000 1.000 0.000 0.000  0
#> SRR2936904     4  0.0880      0.972 0.000 0.000 0.032 0.968  0
#> SRR2936905     2  0.0000      1.000 0.000 1.000 0.000 0.000  0
#> SRR2936903     1  0.4182      0.835 0.600 0.000 0.400 0.000  0
#> SRR2936901     4  0.0000      0.994 0.000 0.000 0.000 1.000  0
#> SRR2936902     3  0.4182      0.946 0.000 0.400 0.600 0.000  0
#> SRR2936900     1  0.3143      0.857 0.796 0.000 0.204 0.000  0
#> SRR2936898     4  0.0000      0.994 0.000 0.000 0.000 1.000  0
#> SRR2936899     4  0.0000      0.994 0.000 0.000 0.000 1.000  0
#> SRR2936897     1  0.4182      0.835 0.600 0.000 0.400 0.000  0
#> SRR2936896     2  0.0000      1.000 0.000 1.000 0.000 0.000  0
#> SRR2936894     1  0.0000      0.801 1.000 0.000 0.000 0.000  0
#> SRR2936893     2  0.0000      1.000 0.000 1.000 0.000 0.000  0
#> SRR2936895     3  0.4182      0.946 0.000 0.400 0.600 0.000  0
#> SRR2936892     2  0.0000      1.000 0.000 1.000 0.000 0.000  0
#> SRR2936891     1  0.0000      0.801 1.000 0.000 0.000 0.000  0
#> SRR2936890     2  0.0000      1.000 0.000 1.000 0.000 0.000  0
#> SRR2936886     4  0.0000      0.994 0.000 0.000 0.000 1.000  0
#> SRR2936885     1  0.3612      0.856 0.732 0.000 0.268 0.000  0
#> SRR2936888     1  0.0000      0.801 1.000 0.000 0.000 0.000  0
#> SRR2936889     2  0.0000      1.000 0.000 1.000 0.000 0.000  0
#> SRR2936887     4  0.0000      0.994 0.000 0.000 0.000 1.000  0
#> SRR2936884     3  0.4182      0.946 0.000 0.400 0.600 0.000  0
#> SRR2936883     3  0.4182      0.946 0.000 0.400 0.600 0.000  0
#> SRR2936881     3  0.4182      0.946 0.000 0.400 0.600 0.000  0
#> SRR2936882     1  0.3143      0.857 0.796 0.000 0.204 0.000  0
#> SRR2936880     3  0.4182      0.946 0.000 0.400 0.600 0.000  0
#> SRR2936878     5  0.0000      1.000 0.000 0.000 0.000 0.000  1
#> SRR2936879     4  0.0000      0.994 0.000 0.000 0.000 1.000  0
#> SRR2936875     2  0.0000      1.000 0.000 1.000 0.000 0.000  0
#> SRR2936877     5  0.0000      1.000 0.000 0.000 0.000 0.000  1
#> SRR2936876     4  0.0963      0.968 0.000 0.000 0.036 0.964  0
#> SRR2936873     1  0.4101      0.843 0.628 0.000 0.372 0.000  0
#> SRR2936872     2  0.0000      1.000 0.000 1.000 0.000 0.000  0
#> SRR2936871     2  0.0000      1.000 0.000 1.000 0.000 0.000  0
#> SRR2936874     2  0.0000      1.000 0.000 1.000 0.000 0.000  0
#> SRR2936870     1  0.0000      0.801 1.000 0.000 0.000 0.000  0
#> SRR2936869     4  0.0000      0.994 0.000 0.000 0.000 1.000  0
#> SRR2936868     4  0.0000      0.994 0.000 0.000 0.000 1.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
#> SRR2936906     1   0.000      1.000 1.000 0.0 0.0 0.000  0 0.000
#> SRR2936909     6   0.279      0.794 0.200 0.0 0.0 0.000  0 0.800
#> SRR2936918     6   0.387      0.685 0.488 0.0 0.0 0.000  0 0.512
#> SRR2936917     5   0.000      1.000 0.000 0.0 0.0 0.000  1 0.000
#> SRR2936916     3   0.000      0.920 0.000 0.0 1.0 0.000  0 0.000
#> SRR2936915     4   0.279      0.899 0.000 0.0 0.0 0.800  0 0.200
#> SRR2936914     5   0.000      1.000 0.000 0.0 0.0 0.000  1 0.000
#> SRR2936913     5   0.000      1.000 0.000 0.0 0.0 0.000  1 0.000
#> SRR2936912     6   0.279      0.794 0.200 0.0 0.0 0.000  0 0.800
#> SRR2936910     6   0.352      0.804 0.324 0.0 0.0 0.000  0 0.676
#> SRR2936911     5   0.000      1.000 0.000 0.0 0.0 0.000  1 0.000
#> SRR2936907     2   0.000      0.980 0.000 1.0 0.0 0.000  0 0.000
#> SRR2936908     2   0.000      0.980 0.000 1.0 0.0 0.000  0 0.000
#> SRR2936904     4   0.150      0.848 0.000 0.0 0.0 0.924  0 0.076
#> SRR2936905     2   0.000      0.980 0.000 1.0 0.0 0.000  0 0.000
#> SRR2936903     6   0.279      0.794 0.200 0.0 0.0 0.000  0 0.800
#> SRR2936901     4   0.279      0.899 0.000 0.0 0.0 0.800  0 0.200
#> SRR2936902     3   0.000      0.920 0.000 0.0 1.0 0.000  0 0.000
#> SRR2936900     6   0.387      0.685 0.488 0.0 0.0 0.000  0 0.512
#> SRR2936898     4   0.279      0.899 0.000 0.0 0.0 0.800  0 0.200
#> SRR2936899     4   0.279      0.899 0.000 0.0 0.0 0.800  0 0.200
#> SRR2936897     6   0.279      0.794 0.200 0.0 0.0 0.000  0 0.800
#> SRR2936896     2   0.000      0.980 0.000 1.0 0.0 0.000  0 0.000
#> SRR2936894     1   0.000      1.000 1.000 0.0 0.0 0.000  0 0.000
#> SRR2936893     2   0.000      0.980 0.000 1.0 0.0 0.000  0 0.000
#> SRR2936895     3   0.000      0.920 0.000 0.0 1.0 0.000  0 0.000
#> SRR2936892     2   0.000      0.980 0.000 1.0 0.0 0.000  0 0.000
#> SRR2936891     1   0.000      1.000 1.000 0.0 0.0 0.000  0 0.000
#> SRR2936890     2   0.000      0.980 0.000 1.0 0.0 0.000  0 0.000
#> SRR2936886     4   0.000      0.884 0.000 0.0 0.0 1.000  0 0.000
#> SRR2936885     6   0.377      0.761 0.408 0.0 0.0 0.000  0 0.592
#> SRR2936888     1   0.000      1.000 1.000 0.0 0.0 0.000  0 0.000
#> SRR2936889     2   0.000      0.980 0.000 1.0 0.0 0.000  0 0.000
#> SRR2936887     4   0.000      0.884 0.000 0.0 0.0 1.000  0 0.000
#> SRR2936884     3   0.376      0.338 0.000 0.4 0.6 0.000  0 0.000
#> SRR2936883     3   0.000      0.920 0.000 0.0 1.0 0.000  0 0.000
#> SRR2936881     3   0.000      0.920 0.000 0.0 1.0 0.000  0 0.000
#> SRR2936882     6   0.387      0.685 0.488 0.0 0.0 0.000  0 0.512
#> SRR2936880     3   0.000      0.920 0.000 0.0 1.0 0.000  0 0.000
#> SRR2936878     5   0.000      1.000 0.000 0.0 0.0 0.000  1 0.000
#> SRR2936879     4   0.279      0.899 0.000 0.0 0.0 0.800  0 0.200
#> SRR2936875     2   0.000      0.980 0.000 1.0 0.0 0.000  0 0.000
#> SRR2936877     5   0.000      1.000 0.000 0.0 0.0 0.000  1 0.000
#> SRR2936876     4   0.353      0.825 0.000 0.0 0.0 0.672  0 0.328
#> SRR2936873     6   0.350      0.805 0.320 0.0 0.0 0.000  0 0.680
#> SRR2936872     2   0.000      0.980 0.000 1.0 0.0 0.000  0 0.000
#> SRR2936871     2   0.000      0.980 0.000 1.0 0.0 0.000  0 0.000
#> SRR2936874     2   0.279      0.729 0.000 0.8 0.2 0.000  0 0.000
#> SRR2936870     1   0.000      1.000 1.000 0.0 0.0 0.000  0 0.000
#> SRR2936869     4   0.000      0.884 0.000 0.0 0.0 1.000  0 0.000
#> SRR2936868     4   0.000      0.884 0.000 0.0 0.0 1.000  0 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-pam-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-pam-collect-classes

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


ATC:mclust**

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

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

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

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

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

collect_plots(res)

plot of chunk ATC-mclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.990       0.988         0.3250 0.678   0.678
#> 3 3 0.515           0.937       0.930         0.5492 0.835   0.757
#> 4 4 0.714           0.740       0.805         0.2876 0.852   0.716
#> 5 5 0.824           0.813       0.893         0.1904 0.812   0.522
#> 6 6 0.890           0.852       0.924         0.0762 0.926   0.679

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
#> SRR2936906     1  0.0000      0.991 1.000 0.000
#> SRR2936909     1  0.0000      0.991 1.000 0.000
#> SRR2936918     1  0.0000      0.991 1.000 0.000
#> SRR2936917     1  0.2236      0.978 0.964 0.036
#> SRR2936916     1  0.0672      0.989 0.992 0.008
#> SRR2936915     1  0.0376      0.990 0.996 0.004
#> SRR2936914     1  0.2236      0.978 0.964 0.036
#> SRR2936913     1  0.2236      0.978 0.964 0.036
#> SRR2936912     1  0.0000      0.991 1.000 0.000
#> SRR2936910     1  0.0000      0.991 1.000 0.000
#> SRR2936911     1  0.2236      0.978 0.964 0.036
#> SRR2936907     2  0.1184      1.000 0.016 0.984
#> SRR2936908     2  0.1184      1.000 0.016 0.984
#> SRR2936904     1  0.0938      0.988 0.988 0.012
#> SRR2936905     2  0.1184      1.000 0.016 0.984
#> SRR2936903     1  0.0000      0.991 1.000 0.000
#> SRR2936901     1  0.0000      0.991 1.000 0.000
#> SRR2936902     1  0.0000      0.991 1.000 0.000
#> SRR2936900     1  0.0000      0.991 1.000 0.000
#> SRR2936898     1  0.0376      0.990 0.996 0.004
#> SRR2936899     1  0.0672      0.989 0.992 0.008
#> SRR2936897     1  0.0000      0.991 1.000 0.000
#> SRR2936896     1  0.1633      0.984 0.976 0.024
#> SRR2936894     1  0.0000      0.991 1.000 0.000
#> SRR2936893     2  0.1184      1.000 0.016 0.984
#> SRR2936895     1  0.0672      0.989 0.992 0.008
#> SRR2936892     1  0.2043      0.978 0.968 0.032
#> SRR2936891     1  0.0000      0.991 1.000 0.000
#> SRR2936890     2  0.1184      1.000 0.016 0.984
#> SRR2936886     1  0.0938      0.988 0.988 0.012
#> SRR2936885     1  0.0000      0.991 1.000 0.000
#> SRR2936888     1  0.0000      0.991 1.000 0.000
#> SRR2936889     2  0.1184      1.000 0.016 0.984
#> SRR2936887     1  0.0938      0.988 0.988 0.012
#> SRR2936884     1  0.1184      0.986 0.984 0.016
#> SRR2936883     1  0.1184      0.986 0.984 0.016
#> SRR2936881     1  0.0938      0.988 0.988 0.012
#> SRR2936882     1  0.0000      0.991 1.000 0.000
#> SRR2936880     1  0.1184      0.986 0.984 0.016
#> SRR2936878     1  0.2236      0.978 0.964 0.036
#> SRR2936879     1  0.0376      0.990 0.996 0.004
#> SRR2936875     2  0.1184      1.000 0.016 0.984
#> SRR2936877     1  0.2236      0.978 0.964 0.036
#> SRR2936876     1  0.0000      0.991 1.000 0.000
#> SRR2936873     1  0.0000      0.991 1.000 0.000
#> SRR2936872     2  0.1184      1.000 0.016 0.984
#> SRR2936871     2  0.1184      1.000 0.016 0.984
#> SRR2936874     2  0.1184      1.000 0.016 0.984
#> SRR2936870     1  0.0000      0.991 1.000 0.000
#> SRR2936869     1  0.0938      0.988 0.988 0.012
#> SRR2936868     1  0.0938      0.988 0.988 0.012

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR2936906     1  0.3482      0.917 0.872 0.128 0.000
#> SRR2936909     1  0.0000      0.908 1.000 0.000 0.000
#> SRR2936918     1  0.3482      0.917 0.872 0.128 0.000
#> SRR2936917     3  0.3482      1.000 0.128 0.000 0.872
#> SRR2936916     1  0.0000      0.908 1.000 0.000 0.000
#> SRR2936915     1  0.3482      0.917 0.872 0.128 0.000
#> SRR2936914     3  0.3482      1.000 0.128 0.000 0.872
#> SRR2936913     3  0.3482      1.000 0.128 0.000 0.872
#> SRR2936912     1  0.3482      0.917 0.872 0.128 0.000
#> SRR2936910     1  0.3482      0.917 0.872 0.128 0.000
#> SRR2936911     3  0.3482      1.000 0.128 0.000 0.872
#> SRR2936907     2  0.0000      1.000 0.000 1.000 0.000
#> SRR2936908     2  0.0000      1.000 0.000 1.000 0.000
#> SRR2936904     1  0.3482      0.917 0.872 0.128 0.000
#> SRR2936905     2  0.0000      1.000 0.000 1.000 0.000
#> SRR2936903     1  0.0000      0.908 1.000 0.000 0.000
#> SRR2936901     1  0.0000      0.908 1.000 0.000 0.000
#> SRR2936902     1  0.0000      0.908 1.000 0.000 0.000
#> SRR2936900     1  0.0000      0.908 1.000 0.000 0.000
#> SRR2936898     1  0.3482      0.917 0.872 0.128 0.000
#> SRR2936899     1  0.3482      0.917 0.872 0.128 0.000
#> SRR2936897     1  0.3482      0.917 0.872 0.128 0.000
#> SRR2936896     1  0.0000      0.908 1.000 0.000 0.000
#> SRR2936894     1  0.3482      0.917 0.872 0.128 0.000
#> SRR2936893     2  0.0000      1.000 0.000 1.000 0.000
#> SRR2936895     1  0.0000      0.908 1.000 0.000 0.000
#> SRR2936892     1  0.4002      0.896 0.840 0.160 0.000
#> SRR2936891     1  0.3482      0.917 0.872 0.128 0.000
#> SRR2936890     2  0.0000      1.000 0.000 1.000 0.000
#> SRR2936886     1  0.3482      0.895 0.872 0.000 0.128
#> SRR2936885     1  0.3482      0.917 0.872 0.128 0.000
#> SRR2936888     1  0.3482      0.895 0.872 0.000 0.128
#> SRR2936889     2  0.0000      1.000 0.000 1.000 0.000
#> SRR2936887     1  0.3482      0.895 0.872 0.000 0.128
#> SRR2936884     1  0.0892      0.902 0.980 0.020 0.000
#> SRR2936883     1  0.1289      0.907 0.968 0.032 0.000
#> SRR2936881     1  0.0892      0.902 0.980 0.020 0.000
#> SRR2936882     1  0.0000      0.908 1.000 0.000 0.000
#> SRR2936880     1  0.0892      0.902 0.980 0.020 0.000
#> SRR2936878     3  0.3482      1.000 0.128 0.000 0.872
#> SRR2936879     1  0.3482      0.917 0.872 0.128 0.000
#> SRR2936875     2  0.0000      1.000 0.000 1.000 0.000
#> SRR2936877     3  0.3482      1.000 0.128 0.000 0.872
#> SRR2936876     1  0.0000      0.908 1.000 0.000 0.000
#> SRR2936873     1  0.3482      0.917 0.872 0.128 0.000
#> SRR2936872     2  0.0000      1.000 0.000 1.000 0.000
#> SRR2936871     2  0.0000      1.000 0.000 1.000 0.000
#> SRR2936874     2  0.0000      1.000 0.000 1.000 0.000
#> SRR2936870     1  0.3482      0.895 0.872 0.000 0.128
#> SRR2936869     1  0.3482      0.895 0.872 0.000 0.128
#> SRR2936868     1  0.3482      0.895 0.872 0.000 0.128

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR2936906     1  0.0000     0.6539 1.000 0.000 0.000 0.000
#> SRR2936909     1  0.4406     0.7121 0.700 0.000 0.000 0.300
#> SRR2936918     1  0.0000     0.6539 1.000 0.000 0.000 0.000
#> SRR2936917     3  0.4543     1.0000 0.000 0.000 0.676 0.324
#> SRR2936916     1  0.6423     0.6449 0.544 0.008 0.052 0.396
#> SRR2936915     1  0.5476     0.6846 0.584 0.020 0.000 0.396
#> SRR2936914     3  0.4543     1.0000 0.000 0.000 0.676 0.324
#> SRR2936913     3  0.4543     1.0000 0.000 0.000 0.676 0.324
#> SRR2936912     1  0.0469     0.6548 0.988 0.000 0.012 0.000
#> SRR2936910     1  0.0469     0.6548 0.988 0.000 0.012 0.000
#> SRR2936911     3  0.4543     1.0000 0.000 0.000 0.676 0.324
#> SRR2936907     2  0.0000     0.9864 0.000 1.000 0.000 0.000
#> SRR2936908     2  0.0000     0.9864 0.000 1.000 0.000 0.000
#> SRR2936904     1  0.8932     0.0715 0.496 0.132 0.208 0.164
#> SRR2936905     2  0.0000     0.9864 0.000 1.000 0.000 0.000
#> SRR2936903     1  0.4564     0.7090 0.672 0.000 0.000 0.328
#> SRR2936901     1  0.4543     0.7095 0.676 0.000 0.000 0.324
#> SRR2936902     1  0.5268     0.6879 0.592 0.012 0.000 0.396
#> SRR2936900     1  0.0188     0.6516 0.996 0.000 0.000 0.004
#> SRR2936898     1  0.5268     0.6858 0.592 0.000 0.012 0.396
#> SRR2936899     1  0.5476     0.6846 0.584 0.020 0.000 0.396
#> SRR2936897     1  0.4522     0.7104 0.680 0.000 0.000 0.320
#> SRR2936896     4  0.7716    -0.5655 0.380 0.000 0.224 0.396
#> SRR2936894     1  0.0469     0.6548 0.988 0.000 0.012 0.000
#> SRR2936893     2  0.0000     0.9864 0.000 1.000 0.000 0.000
#> SRR2936895     1  0.6121     0.6495 0.552 0.000 0.052 0.396
#> SRR2936892     2  0.2081     0.8607 0.084 0.916 0.000 0.000
#> SRR2936891     1  0.0469     0.6548 0.988 0.000 0.012 0.000
#> SRR2936890     2  0.0000     0.9864 0.000 1.000 0.000 0.000
#> SRR2936886     4  0.6258     0.7061 0.076 0.000 0.324 0.600
#> SRR2936885     1  0.4543     0.7095 0.676 0.000 0.000 0.324
#> SRR2936888     1  0.0000     0.6539 1.000 0.000 0.000 0.000
#> SRR2936889     2  0.0000     0.9864 0.000 1.000 0.000 0.000
#> SRR2936887     4  0.6258     0.7061 0.076 0.000 0.324 0.600
#> SRR2936884     1  0.7089     0.6198 0.516 0.040 0.048 0.396
#> SRR2936883     1  0.6575     0.6484 0.540 0.048 0.016 0.396
#> SRR2936881     1  0.7089     0.6198 0.516 0.040 0.048 0.396
#> SRR2936882     1  0.0188     0.6516 0.996 0.000 0.000 0.004
#> SRR2936880     1  0.7089     0.6198 0.516 0.040 0.048 0.396
#> SRR2936878     3  0.4543     1.0000 0.000 0.000 0.676 0.324
#> SRR2936879     1  0.5268     0.6879 0.592 0.012 0.000 0.396
#> SRR2936875     2  0.0188     0.9829 0.000 0.996 0.000 0.004
#> SRR2936877     3  0.4543     1.0000 0.000 0.000 0.676 0.324
#> SRR2936876     1  0.4543     0.7095 0.676 0.000 0.000 0.324
#> SRR2936873     1  0.0000     0.6539 1.000 0.000 0.000 0.000
#> SRR2936872     2  0.0000     0.9864 0.000 1.000 0.000 0.000
#> SRR2936871     2  0.0000     0.9864 0.000 1.000 0.000 0.000
#> SRR2936874     2  0.0000     0.9864 0.000 1.000 0.000 0.000
#> SRR2936870     1  0.0000     0.6539 1.000 0.000 0.000 0.000
#> SRR2936869     4  0.6258     0.7061 0.076 0.000 0.324 0.600
#> SRR2936868     4  0.6258     0.7061 0.076 0.000 0.324 0.600

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4    p5
#> SRR2936906     1  0.0162      0.801 0.996 0.000 0.004 0.000 0.000
#> SRR2936909     1  0.4341      0.577 0.592 0.000 0.404 0.000 0.004
#> SRR2936918     1  0.0162      0.801 0.996 0.000 0.004 0.000 0.000
#> SRR2936917     5  0.1478      1.000 0.000 0.000 0.064 0.000 0.936
#> SRR2936916     3  0.3291      0.833 0.000 0.040 0.840 0.000 0.120
#> SRR2936915     3  0.1965      0.849 0.024 0.052 0.924 0.000 0.000
#> SRR2936914     5  0.1478      1.000 0.000 0.000 0.064 0.000 0.936
#> SRR2936913     5  0.1478      1.000 0.000 0.000 0.064 0.000 0.936
#> SRR2936912     1  0.0162      0.801 0.996 0.000 0.004 0.000 0.000
#> SRR2936910     1  0.0162      0.801 0.996 0.000 0.004 0.000 0.000
#> SRR2936911     5  0.1478      1.000 0.000 0.000 0.064 0.000 0.936
#> SRR2936907     2  0.0000      0.994 0.000 1.000 0.000 0.000 0.000
#> SRR2936908     2  0.0000      0.994 0.000 1.000 0.000 0.000 0.000
#> SRR2936904     4  0.6274     -0.039 0.420 0.016 0.072 0.484 0.008
#> SRR2936905     2  0.0000      0.994 0.000 1.000 0.000 0.000 0.000
#> SRR2936903     1  0.5973      0.572 0.552 0.000 0.360 0.024 0.064
#> SRR2936901     3  0.5461     -0.256 0.408 0.000 0.528 0.000 0.064
#> SRR2936902     3  0.2260      0.758 0.028 0.000 0.908 0.000 0.064
#> SRR2936900     1  0.4582      0.729 0.764 0.000 0.164 0.024 0.048
#> SRR2936898     3  0.1830      0.854 0.004 0.052 0.932 0.000 0.012
#> SRR2936899     3  0.1670      0.852 0.012 0.052 0.936 0.000 0.000
#> SRR2936897     1  0.4182      0.570 0.600 0.000 0.400 0.000 0.000
#> SRR2936896     3  0.3010      0.790 0.004 0.000 0.824 0.000 0.172
#> SRR2936894     1  0.0162      0.801 0.996 0.000 0.004 0.000 0.000
#> SRR2936893     2  0.0000      0.994 0.000 1.000 0.000 0.000 0.000
#> SRR2936895     3  0.3495      0.797 0.028 0.000 0.812 0.000 0.160
#> SRR2936892     2  0.1502      0.936 0.000 0.940 0.004 0.056 0.000
#> SRR2936891     1  0.0162      0.801 0.996 0.000 0.004 0.000 0.000
#> SRR2936890     2  0.0000      0.994 0.000 1.000 0.000 0.000 0.000
#> SRR2936886     4  0.0703      0.839 0.024 0.000 0.000 0.976 0.000
#> SRR2936885     1  0.3586      0.674 0.736 0.000 0.264 0.000 0.000
#> SRR2936888     1  0.0865      0.790 0.972 0.000 0.004 0.024 0.000
#> SRR2936889     2  0.0000      0.994 0.000 1.000 0.000 0.000 0.000
#> SRR2936887     4  0.0703      0.839 0.024 0.000 0.000 0.976 0.000
#> SRR2936884     3  0.3226      0.842 0.000 0.060 0.852 0.000 0.088
#> SRR2936883     3  0.1638      0.851 0.000 0.064 0.932 0.000 0.004
#> SRR2936881     3  0.3359      0.838 0.000 0.052 0.840 0.000 0.108
#> SRR2936882     1  0.4582      0.729 0.764 0.000 0.164 0.024 0.048
#> SRR2936880     3  0.3359      0.838 0.000 0.052 0.840 0.000 0.108
#> SRR2936878     5  0.1478      1.000 0.000 0.000 0.064 0.000 0.936
#> SRR2936879     3  0.1597      0.852 0.012 0.048 0.940 0.000 0.000
#> SRR2936875     2  0.0000      0.994 0.000 1.000 0.000 0.000 0.000
#> SRR2936877     5  0.1478      1.000 0.000 0.000 0.064 0.000 0.936
#> SRR2936876     1  0.4497      0.545 0.568 0.000 0.424 0.000 0.008
#> SRR2936873     1  0.0162      0.801 0.996 0.000 0.004 0.000 0.000
#> SRR2936872     2  0.0000      0.994 0.000 1.000 0.000 0.000 0.000
#> SRR2936871     2  0.0000      0.994 0.000 1.000 0.000 0.000 0.000
#> SRR2936874     2  0.0000      0.994 0.000 1.000 0.000 0.000 0.000
#> SRR2936870     1  0.0865      0.790 0.972 0.000 0.004 0.024 0.000
#> SRR2936869     4  0.0703      0.839 0.024 0.000 0.000 0.976 0.000
#> SRR2936868     4  0.0703      0.839 0.024 0.000 0.000 0.976 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
#> SRR2936906     1  0.0458     0.9327 0.984 0.000 0.000 0.000 0.000 0.016
#> SRR2936909     6  0.2877     0.6671 0.168 0.000 0.012 0.000 0.000 0.820
#> SRR2936918     1  0.1204     0.8959 0.944 0.000 0.000 0.000 0.000 0.056
#> SRR2936917     5  0.0000     0.9989 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR2936916     3  0.0000     0.8913 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR2936915     3  0.0363     0.8900 0.000 0.000 0.988 0.000 0.000 0.012
#> SRR2936914     5  0.0000     0.9989 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR2936913     5  0.0000     0.9989 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR2936912     1  0.0146     0.9360 0.996 0.000 0.000 0.000 0.000 0.004
#> SRR2936910     1  0.0146     0.9360 0.996 0.000 0.000 0.000 0.000 0.004
#> SRR2936911     5  0.0000     0.9989 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR2936907     2  0.0000     0.9948 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936908     2  0.0000     0.9948 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936904     6  0.5761     0.0287 0.000 0.172 0.000 0.396 0.000 0.432
#> SRR2936905     2  0.0000     0.9948 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936903     6  0.0000     0.6691 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR2936901     6  0.3737     0.2652 0.000 0.000 0.392 0.000 0.000 0.608
#> SRR2936902     3  0.3404     0.7153 0.000 0.000 0.760 0.000 0.016 0.224
#> SRR2936900     6  0.1007     0.6865 0.044 0.000 0.000 0.000 0.000 0.956
#> SRR2936898     3  0.0000     0.8913 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR2936899     3  0.0363     0.8900 0.000 0.000 0.988 0.000 0.000 0.012
#> SRR2936897     6  0.4047     0.4212 0.384 0.000 0.012 0.000 0.000 0.604
#> SRR2936896     3  0.3515     0.6351 0.000 0.000 0.676 0.000 0.324 0.000
#> SRR2936894     1  0.0000     0.9355 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936893     2  0.0000     0.9948 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936895     3  0.2996     0.7676 0.000 0.000 0.772 0.000 0.228 0.000
#> SRR2936892     2  0.0937     0.9573 0.000 0.960 0.000 0.040 0.000 0.000
#> SRR2936891     1  0.0000     0.9355 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR2936890     2  0.0000     0.9948 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936886     4  0.0000     1.0000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR2936885     6  0.3748     0.5550 0.300 0.000 0.012 0.000 0.000 0.688
#> SRR2936888     1  0.2562     0.8032 0.828 0.000 0.000 0.172 0.000 0.000
#> SRR2936889     2  0.0000     0.9948 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936887     4  0.0000     1.0000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR2936884     3  0.2697     0.8068 0.000 0.000 0.812 0.000 0.188 0.000
#> SRR2936883     3  0.1663     0.8645 0.000 0.000 0.912 0.000 0.088 0.000
#> SRR2936881     3  0.0000     0.8913 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR2936882     6  0.1007     0.6865 0.044 0.000 0.000 0.000 0.000 0.956
#> SRR2936880     3  0.0000     0.8913 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR2936878     5  0.0000     0.9989 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR2936879     3  0.0363     0.8900 0.000 0.000 0.988 0.000 0.000 0.012
#> SRR2936875     2  0.0260     0.9869 0.000 0.992 0.008 0.000 0.000 0.000
#> SRR2936877     5  0.0146     0.9944 0.000 0.000 0.004 0.000 0.996 0.000
#> SRR2936876     6  0.3563     0.4393 0.000 0.000 0.336 0.000 0.000 0.664
#> SRR2936873     1  0.0363     0.9334 0.988 0.000 0.000 0.000 0.000 0.012
#> SRR2936872     2  0.0000     0.9948 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936871     2  0.0000     0.9948 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936874     2  0.0000     0.9948 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR2936870     1  0.2562     0.8032 0.828 0.000 0.000 0.172 0.000 0.000
#> SRR2936869     4  0.0000     1.0000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR2936868     4  0.0000     1.0000 0.000 0.000 0.000 1.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 14198 rows and 51 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.754           0.842       0.932         0.4912 0.500   0.500
#> 3 3 0.467           0.688       0.819         0.3161 0.747   0.550
#> 4 4 0.717           0.791       0.873         0.1639 0.867   0.641
#> 5 5 0.679           0.676       0.796         0.0551 0.922   0.697
#> 6 6 0.699           0.623       0.769         0.0258 0.986   0.932

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
#> SRR2936906     1  0.0000      0.917 1.000 0.000
#> SRR2936909     1  0.1184      0.915 0.984 0.016
#> SRR2936918     1  0.0000      0.917 1.000 0.000
#> SRR2936917     1  0.0000      0.917 1.000 0.000
#> SRR2936916     1  0.0000      0.917 1.000 0.000
#> SRR2936915     1  0.9552      0.443 0.624 0.376
#> SRR2936914     1  0.0000      0.917 1.000 0.000
#> SRR2936913     1  0.9286      0.521 0.656 0.344
#> SRR2936912     1  0.0000      0.917 1.000 0.000
#> SRR2936910     1  0.0000      0.917 1.000 0.000
#> SRR2936911     2  0.2948      0.893 0.052 0.948
#> SRR2936907     2  0.0000      0.926 0.000 1.000
#> SRR2936908     2  0.0000      0.926 0.000 1.000
#> SRR2936904     2  0.0000      0.926 0.000 1.000
#> SRR2936905     2  0.0000      0.926 0.000 1.000
#> SRR2936903     1  0.2603      0.904 0.956 0.044
#> SRR2936901     1  0.6148      0.814 0.848 0.152
#> SRR2936902     2  0.9754      0.265 0.408 0.592
#> SRR2936900     1  0.0938      0.916 0.988 0.012
#> SRR2936898     1  0.3274      0.895 0.940 0.060
#> SRR2936899     1  0.9286      0.517 0.656 0.344
#> SRR2936897     1  0.2423      0.906 0.960 0.040
#> SRR2936896     2  0.0376      0.924 0.004 0.996
#> SRR2936894     1  0.0000      0.917 1.000 0.000
#> SRR2936893     2  0.0000      0.926 0.000 1.000
#> SRR2936895     1  0.4431      0.871 0.908 0.092
#> SRR2936892     2  0.0000      0.926 0.000 1.000
#> SRR2936891     1  0.0000      0.917 1.000 0.000
#> SRR2936890     2  0.0000      0.926 0.000 1.000
#> SRR2936886     2  0.2778      0.896 0.048 0.952
#> SRR2936885     1  0.2778      0.902 0.952 0.048
#> SRR2936888     1  0.0000      0.917 1.000 0.000
#> SRR2936889     2  0.0000      0.926 0.000 1.000
#> SRR2936887     2  0.2236      0.905 0.036 0.964
#> SRR2936884     2  0.9833      0.214 0.424 0.576
#> SRR2936883     1  0.9635      0.413 0.612 0.388
#> SRR2936881     1  0.1633      0.912 0.976 0.024
#> SRR2936882     1  0.0000      0.917 1.000 0.000
#> SRR2936880     1  0.0938      0.916 0.988 0.012
#> SRR2936878     1  0.0000      0.917 1.000 0.000
#> SRR2936879     2  0.8955      0.518 0.312 0.688
#> SRR2936875     2  0.0000      0.926 0.000 1.000
#> SRR2936877     2  0.3431      0.882 0.064 0.936
#> SRR2936876     1  0.6438      0.801 0.836 0.164
#> SRR2936873     1  0.0000      0.917 1.000 0.000
#> SRR2936872     2  0.0000      0.926 0.000 1.000
#> SRR2936871     2  0.0000      0.926 0.000 1.000
#> SRR2936874     2  0.0000      0.926 0.000 1.000
#> SRR2936870     1  0.0000      0.917 1.000 0.000
#> SRR2936869     2  0.0000      0.926 0.000 1.000
#> SRR2936868     2  0.0000      0.926 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR2936906     1  0.5431     0.7004 0.716 0.000 0.284
#> SRR2936909     1  0.3851     0.7579 0.860 0.004 0.136
#> SRR2936918     1  0.4504     0.7418 0.804 0.000 0.196
#> SRR2936917     1  0.3193     0.7630 0.896 0.004 0.100
#> SRR2936916     1  0.3941     0.7526 0.844 0.000 0.156
#> SRR2936915     1  0.8345     0.6115 0.628 0.200 0.172
#> SRR2936914     3  0.6189    -0.0365 0.364 0.004 0.632
#> SRR2936913     3  0.3644     0.7209 0.004 0.124 0.872
#> SRR2936912     1  0.6095     0.5852 0.608 0.000 0.392
#> SRR2936910     1  0.5785     0.6581 0.668 0.000 0.332
#> SRR2936911     3  0.3551     0.7219 0.000 0.132 0.868
#> SRR2936907     2  0.0237     0.9185 0.000 0.996 0.004
#> SRR2936908     2  0.0237     0.9185 0.000 0.996 0.004
#> SRR2936904     2  0.1585     0.9043 0.008 0.964 0.028
#> SRR2936905     2  0.0000     0.9185 0.000 1.000 0.000
#> SRR2936903     1  0.2152     0.7510 0.948 0.016 0.036
#> SRR2936901     1  0.4790     0.7062 0.848 0.096 0.056
#> SRR2936902     1  0.7890     0.1268 0.512 0.432 0.056
#> SRR2936900     1  0.1877     0.7527 0.956 0.012 0.032
#> SRR2936898     1  0.5291     0.6947 0.732 0.000 0.268
#> SRR2936899     1  0.7603     0.6138 0.688 0.172 0.140
#> SRR2936897     1  0.5650     0.6791 0.688 0.000 0.312
#> SRR2936896     3  0.6274     0.3428 0.000 0.456 0.544
#> SRR2936894     1  0.4750     0.7385 0.784 0.000 0.216
#> SRR2936893     2  0.1411     0.8991 0.000 0.964 0.036
#> SRR2936895     3  0.1482     0.6765 0.020 0.012 0.968
#> SRR2936892     2  0.1031     0.9085 0.000 0.976 0.024
#> SRR2936891     1  0.5835     0.6532 0.660 0.000 0.340
#> SRR2936890     2  0.0424     0.9179 0.000 0.992 0.008
#> SRR2936886     3  0.4291     0.7072 0.000 0.180 0.820
#> SRR2936885     1  0.4834     0.7465 0.792 0.004 0.204
#> SRR2936888     3  0.3038     0.5992 0.104 0.000 0.896
#> SRR2936889     2  0.1163     0.9078 0.000 0.972 0.028
#> SRR2936887     3  0.4605     0.6926 0.000 0.204 0.796
#> SRR2936884     1  0.8631     0.3057 0.520 0.372 0.108
#> SRR2936883     1  0.7949     0.5291 0.640 0.252 0.108
#> SRR2936881     1  0.3415     0.7427 0.900 0.020 0.080
#> SRR2936882     1  0.1585     0.7541 0.964 0.008 0.028
#> SRR2936880     1  0.3370     0.7425 0.904 0.024 0.072
#> SRR2936878     1  0.2590     0.7623 0.924 0.004 0.072
#> SRR2936879     2  0.8511     0.2986 0.244 0.604 0.152
#> SRR2936875     2  0.0424     0.9155 0.008 0.992 0.000
#> SRR2936877     2  0.5268     0.6531 0.212 0.776 0.012
#> SRR2936876     1  0.4768     0.7383 0.848 0.100 0.052
#> SRR2936873     1  0.4750     0.7357 0.784 0.000 0.216
#> SRR2936872     2  0.0661     0.9129 0.008 0.988 0.004
#> SRR2936871     2  0.0000     0.9185 0.000 1.000 0.000
#> SRR2936874     2  0.0237     0.9176 0.004 0.996 0.000
#> SRR2936870     3  0.3686     0.5535 0.140 0.000 0.860
#> SRR2936869     3  0.6225     0.4028 0.000 0.432 0.568
#> SRR2936868     3  0.6095     0.4794 0.000 0.392 0.608

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR2936906     1  0.1042      0.916 0.972 0.000 0.008 0.020
#> SRR2936909     1  0.1526      0.907 0.960 0.016 0.012 0.012
#> SRR2936918     1  0.0895      0.915 0.976 0.000 0.020 0.004
#> SRR2936917     1  0.3428      0.798 0.844 0.000 0.144 0.012
#> SRR2936916     1  0.1398      0.905 0.956 0.000 0.040 0.004
#> SRR2936915     1  0.4599      0.743 0.792 0.168 0.012 0.028
#> SRR2936914     4  0.7464      0.411 0.296 0.000 0.208 0.496
#> SRR2936913     4  0.4084      0.770 0.036 0.044 0.064 0.856
#> SRR2936912     1  0.2300      0.897 0.920 0.000 0.016 0.064
#> SRR2936910     1  0.1584      0.913 0.952 0.000 0.012 0.036
#> SRR2936911     4  0.1284      0.779 0.024 0.012 0.000 0.964
#> SRR2936907     2  0.0927      0.926 0.000 0.976 0.016 0.008
#> SRR2936908     2  0.0336      0.929 0.000 0.992 0.008 0.000
#> SRR2936904     2  0.0859      0.921 0.004 0.980 0.008 0.008
#> SRR2936905     2  0.0188      0.929 0.000 0.996 0.004 0.000
#> SRR2936903     3  0.2528      0.788 0.080 0.004 0.908 0.008
#> SRR2936901     3  0.2019      0.801 0.032 0.024 0.940 0.004
#> SRR2936902     3  0.2222      0.793 0.000 0.060 0.924 0.016
#> SRR2936900     3  0.5488      0.501 0.340 0.012 0.636 0.012
#> SRR2936898     3  0.3632      0.764 0.008 0.004 0.832 0.156
#> SRR2936899     3  0.3384      0.784 0.000 0.024 0.860 0.116
#> SRR2936897     1  0.1722      0.908 0.944 0.000 0.008 0.048
#> SRR2936896     4  0.6311      0.644 0.008 0.212 0.108 0.672
#> SRR2936894     1  0.1584      0.915 0.952 0.000 0.036 0.012
#> SRR2936893     2  0.1406      0.920 0.000 0.960 0.016 0.024
#> SRR2936895     4  0.2821      0.757 0.020 0.004 0.076 0.900
#> SRR2936892     2  0.1297      0.921 0.000 0.964 0.016 0.020
#> SRR2936891     1  0.2060      0.906 0.932 0.000 0.016 0.052
#> SRR2936890     2  0.0927      0.926 0.000 0.976 0.016 0.008
#> SRR2936886     4  0.2291      0.785 0.016 0.036 0.016 0.932
#> SRR2936885     3  0.4718      0.745 0.092 0.000 0.792 0.116
#> SRR2936888     4  0.4635      0.620 0.268 0.000 0.012 0.720
#> SRR2936889     2  0.1411      0.920 0.000 0.960 0.020 0.020
#> SRR2936887     4  0.2141      0.785 0.012 0.040 0.012 0.936
#> SRR2936884     3  0.3616      0.779 0.000 0.036 0.852 0.112
#> SRR2936883     3  0.3404      0.786 0.000 0.032 0.864 0.104
#> SRR2936881     3  0.2140      0.808 0.008 0.008 0.932 0.052
#> SRR2936882     3  0.4690      0.612 0.276 0.000 0.712 0.012
#> SRR2936880     3  0.2271      0.808 0.008 0.012 0.928 0.052
#> SRR2936878     3  0.5345      0.289 0.428 0.000 0.560 0.012
#> SRR2936879     2  0.6149      0.340 0.356 0.596 0.016 0.032
#> SRR2936875     2  0.0524      0.923 0.008 0.988 0.004 0.000
#> SRR2936877     2  0.4990      0.726 0.060 0.784 0.144 0.012
#> SRR2936876     1  0.4765      0.754 0.788 0.164 0.032 0.016
#> SRR2936873     1  0.0804      0.917 0.980 0.000 0.012 0.008
#> SRR2936872     2  0.0000      0.928 0.000 1.000 0.000 0.000
#> SRR2936871     2  0.0188      0.929 0.000 0.996 0.004 0.000
#> SRR2936874     2  0.0000      0.928 0.000 1.000 0.000 0.000
#> SRR2936870     4  0.4868      0.569 0.304 0.000 0.012 0.684
#> SRR2936869     4  0.4900      0.671 0.000 0.236 0.032 0.732
#> SRR2936868     4  0.4645      0.711 0.008 0.204 0.020 0.768

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4    p5
#> SRR2936906     1  0.1568     0.7294 0.944 0.000 0.000 0.020 0.036
#> SRR2936909     1  0.3944     0.6431 0.720 0.004 0.004 0.000 0.272
#> SRR2936918     1  0.2347     0.6824 0.912 0.000 0.016 0.016 0.056
#> SRR2936917     1  0.5087     0.5317 0.740 0.004 0.108 0.016 0.132
#> SRR2936916     1  0.1153     0.7086 0.964 0.000 0.008 0.004 0.024
#> SRR2936915     1  0.3728     0.6632 0.840 0.092 0.004 0.016 0.048
#> SRR2936914     1  0.7683     0.1674 0.504 0.004 0.172 0.216 0.104
#> SRR2936913     4  0.6845     0.5497 0.084 0.104 0.100 0.660 0.052
#> SRR2936912     1  0.4821     0.6394 0.680 0.000 0.004 0.044 0.272
#> SRR2936910     1  0.3438     0.7196 0.808 0.000 0.000 0.020 0.172
#> SRR2936911     4  0.3691     0.4709 0.008 0.008 0.008 0.804 0.172
#> SRR2936907     2  0.0727     0.9618 0.000 0.980 0.012 0.004 0.004
#> SRR2936908     2  0.0451     0.9618 0.000 0.988 0.000 0.004 0.008
#> SRR2936904     2  0.2156     0.9290 0.004 0.924 0.004 0.036 0.032
#> SRR2936905     2  0.0290     0.9623 0.000 0.992 0.000 0.008 0.000
#> SRR2936903     3  0.2909     0.7911 0.028 0.008 0.892 0.016 0.056
#> SRR2936901     3  0.1794     0.8053 0.008 0.012 0.944 0.012 0.024
#> SRR2936902     3  0.1836     0.8017 0.000 0.040 0.936 0.008 0.016
#> SRR2936900     3  0.5683     0.5353 0.256 0.004 0.640 0.008 0.092
#> SRR2936898     3  0.4539     0.7554 0.008 0.000 0.768 0.100 0.124
#> SRR2936899     3  0.4085     0.7776 0.004 0.008 0.812 0.084 0.092
#> SRR2936897     1  0.5181     0.4420 0.564 0.004 0.004 0.028 0.400
#> SRR2936896     5  0.6843     0.3435 0.000 0.108 0.060 0.292 0.540
#> SRR2936894     1  0.3365     0.7159 0.808 0.000 0.008 0.004 0.180
#> SRR2936893     2  0.1299     0.9586 0.000 0.960 0.012 0.020 0.008
#> SRR2936895     5  0.5458     0.0772 0.000 0.000 0.060 0.464 0.476
#> SRR2936892     2  0.1211     0.9546 0.000 0.960 0.016 0.024 0.000
#> SRR2936891     1  0.2850     0.7299 0.872 0.000 0.000 0.036 0.092
#> SRR2936890     2  0.0912     0.9590 0.000 0.972 0.012 0.016 0.000
#> SRR2936886     4  0.2346     0.6229 0.008 0.052 0.016 0.916 0.008
#> SRR2936885     3  0.5388     0.7108 0.088 0.008 0.748 0.072 0.084
#> SRR2936888     4  0.5688     0.4333 0.296 0.000 0.008 0.608 0.088
#> SRR2936889     2  0.1560     0.9481 0.000 0.948 0.020 0.028 0.004
#> SRR2936887     4  0.2220     0.6232 0.008 0.052 0.016 0.920 0.004
#> SRR2936884     3  0.2988     0.7972 0.000 0.024 0.880 0.072 0.024
#> SRR2936883     3  0.2770     0.8041 0.004 0.020 0.896 0.060 0.020
#> SRR2936881     3  0.3366     0.7745 0.000 0.000 0.828 0.032 0.140
#> SRR2936882     3  0.5042     0.6459 0.180 0.000 0.716 0.008 0.096
#> SRR2936880     3  0.3810     0.7561 0.000 0.000 0.792 0.040 0.168
#> SRR2936878     5  0.6810     0.1883 0.180 0.004 0.356 0.008 0.452
#> SRR2936879     5  0.6045     0.5249 0.116 0.200 0.004 0.028 0.652
#> SRR2936875     2  0.2249     0.8827 0.000 0.896 0.008 0.000 0.096
#> SRR2936877     5  0.5819     0.5764 0.060 0.128 0.104 0.004 0.704
#> SRR2936876     5  0.6104     0.3581 0.256 0.148 0.008 0.000 0.588
#> SRR2936873     1  0.3910     0.6776 0.740 0.000 0.004 0.008 0.248
#> SRR2936872     2  0.0290     0.9604 0.000 0.992 0.000 0.000 0.008
#> SRR2936871     2  0.0510     0.9579 0.000 0.984 0.000 0.000 0.016
#> SRR2936874     2  0.1124     0.9460 0.000 0.960 0.004 0.000 0.036
#> SRR2936870     4  0.5839     0.3153 0.368 0.000 0.008 0.544 0.080
#> SRR2936869     4  0.5247     0.4888 0.004 0.320 0.024 0.632 0.020
#> SRR2936868     4  0.5054     0.5233 0.004 0.280 0.024 0.672 0.020

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5 p6
#> SRR2936906     1  0.1769      0.658 0.924 0.000 0.000 0.012 0.004 NA
#> SRR2936909     1  0.3665      0.498 0.728 0.000 0.000 0.000 0.252 NA
#> SRR2936918     1  0.3541      0.608 0.748 0.000 0.000 0.020 0.000 NA
#> SRR2936917     1  0.4860      0.446 0.516 0.000 0.040 0.000 0.008 NA
#> SRR2936916     1  0.4329      0.549 0.624 0.000 0.004 0.012 0.008 NA
#> SRR2936915     1  0.5363      0.576 0.688 0.060 0.000 0.012 0.064 NA
#> SRR2936914     1  0.7586      0.178 0.392 0.000 0.116 0.172 0.020 NA
#> SRR2936913     4  0.6733      0.391 0.048 0.044 0.024 0.536 0.044 NA
#> SRR2936912     1  0.3534      0.585 0.796 0.000 0.000 0.036 0.160 NA
#> SRR2936910     1  0.2563      0.655 0.892 0.000 0.000 0.036 0.044 NA
#> SRR2936911     4  0.6141      0.207 0.012 0.000 0.040 0.596 0.192 NA
#> SRR2936907     2  0.0551      0.911 0.000 0.984 0.004 0.004 0.000 NA
#> SRR2936908     2  0.0582      0.910 0.000 0.984 0.004 0.004 0.004 NA
#> SRR2936904     2  0.6510      0.439 0.012 0.548 0.012 0.052 0.092 NA
#> SRR2936905     2  0.1570      0.899 0.000 0.944 0.004 0.008 0.016 NA
#> SRR2936903     3  0.3272      0.829 0.044 0.004 0.852 0.004 0.016 NA
#> SRR2936901     3  0.2026      0.847 0.008 0.004 0.916 0.000 0.012 NA
#> SRR2936902     3  0.2112      0.848 0.000 0.028 0.916 0.000 0.020 NA
#> SRR2936900     3  0.5452      0.668 0.192 0.004 0.648 0.000 0.024 NA
#> SRR2936898     3  0.2886      0.828 0.004 0.000 0.876 0.028 0.060 NA
#> SRR2936899     3  0.2687      0.832 0.004 0.000 0.888 0.028 0.052 NA
#> SRR2936897     1  0.4783      0.403 0.640 0.000 0.000 0.032 0.300 NA
#> SRR2936896     5  0.6635      0.365 0.008 0.040 0.076 0.236 0.580 NA
#> SRR2936894     1  0.1484      0.655 0.944 0.000 0.004 0.008 0.040 NA
#> SRR2936893     2  0.1490      0.904 0.000 0.948 0.004 0.024 0.016 NA
#> SRR2936895     5  0.6954      0.123 0.016 0.000 0.080 0.376 0.416 NA
#> SRR2936892     2  0.1894      0.891 0.000 0.928 0.004 0.040 0.016 NA
#> SRR2936891     1  0.3161      0.644 0.852 0.000 0.004 0.032 0.020 NA
#> SRR2936890     2  0.0748      0.909 0.000 0.976 0.004 0.016 0.000 NA
#> SRR2936886     4  0.2295      0.555 0.016 0.072 0.000 0.900 0.004 NA
#> SRR2936885     3  0.5964      0.710 0.104 0.004 0.672 0.072 0.028 NA
#> SRR2936888     4  0.5964      0.317 0.324 0.000 0.000 0.532 0.044 NA
#> SRR2936889     2  0.2427      0.874 0.000 0.900 0.004 0.056 0.020 NA
#> SRR2936887     4  0.3203      0.559 0.028 0.088 0.004 0.856 0.016 NA
#> SRR2936884     3  0.2290      0.844 0.000 0.012 0.912 0.040 0.016 NA
#> SRR2936883     3  0.1722      0.847 0.000 0.004 0.936 0.036 0.008 NA
#> SRR2936881     3  0.1816      0.844 0.004 0.000 0.928 0.004 0.048 NA
#> SRR2936882     3  0.4735      0.747 0.144 0.000 0.724 0.000 0.028 NA
#> SRR2936880     3  0.2256      0.840 0.004 0.000 0.908 0.008 0.048 NA
#> SRR2936878     1  0.7334     -0.170 0.336 0.004 0.268 0.008 0.324 NA
#> SRR2936879     5  0.5025      0.523 0.192 0.104 0.004 0.016 0.684 NA
#> SRR2936875     2  0.1814      0.874 0.000 0.900 0.000 0.000 0.100 NA
#> SRR2936877     5  0.5009      0.556 0.108 0.096 0.048 0.008 0.736 NA
#> SRR2936876     5  0.5201      0.172 0.392 0.064 0.000 0.000 0.532 NA
#> SRR2936873     1  0.2799      0.615 0.852 0.000 0.000 0.012 0.124 NA
#> SRR2936872     2  0.0508      0.911 0.000 0.984 0.000 0.000 0.004 NA
#> SRR2936871     2  0.2150      0.883 0.000 0.912 0.004 0.004 0.036 NA
#> SRR2936874     2  0.1845      0.890 0.000 0.916 0.004 0.000 0.072 NA
#> SRR2936870     4  0.6050      0.125 0.412 0.000 0.000 0.448 0.040 NA
#> SRR2936869     4  0.4119      0.493 0.000 0.280 0.004 0.692 0.016 NA
#> SRR2936868     4  0.4088      0.502 0.004 0.268 0.004 0.704 0.016 NA

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

consensus_heatmap(res, k = 2)

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