cola Report for recount2:SRP043364

Date: 2019-12-26 00:20:27 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 16960 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] 16960    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
CV:skmeans 2 1.000 0.992 0.994 **
ATC:kmeans 2 1.000 0.995 0.998 **
CV:pam 3 0.969 0.955 0.980 **
ATC:pam 6 0.943 0.875 0.947 * 2,3
ATC:skmeans 2 0.918 0.932 0.973 *
CV:NMF 3 0.902 0.891 0.955 *
ATC:NMF 2 0.880 0.907 0.962
CV:mclust 4 0.843 0.852 0.927
MAD:mclust 4 0.746 0.831 0.913
SD:mclust 4 0.704 0.808 0.895
ATC:hclust 4 0.692 0.849 0.926
ATC:mclust 3 0.683 0.841 0.925
CV:hclust 5 0.683 0.594 0.790
SD:NMF 2 0.660 0.819 0.926
MAD:NMF 2 0.636 0.822 0.925
MAD:skmeans 2 0.615 0.775 0.904
MAD:pam 2 0.578 0.842 0.918
SD:skmeans 2 0.550 0.817 0.917
CV:kmeans 2 0.493 0.858 0.886
SD:kmeans 2 0.456 0.749 0.880
SD:pam 2 0.299 0.769 0.841
MAD:kmeans 2 0.244 0.759 0.856
SD:hclust 2 0.221 0.649 0.767
MAD:hclust 2 0.162 0.503 0.749

**: 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.660           0.819       0.926          0.483 0.523   0.523
#> CV:NMF      2 0.647           0.856       0.934          0.491 0.506   0.506
#> MAD:NMF     2 0.636           0.822       0.925          0.486 0.534   0.534
#> ATC:NMF     2 0.880           0.907       0.962          0.478 0.514   0.514
#> SD:skmeans  2 0.550           0.817       0.917          0.501 0.500   0.500
#> CV:skmeans  2 1.000           0.992       0.994          0.501 0.500   0.500
#> MAD:skmeans 2 0.615           0.775       0.904          0.504 0.500   0.500
#> ATC:skmeans 2 0.918           0.932       0.973          0.505 0.492   0.492
#> SD:mclust   2 0.272           0.672       0.767          0.416 0.561   0.561
#> CV:mclust   2 0.324           0.744       0.832          0.410 0.500   0.500
#> MAD:mclust  2 0.289           0.823       0.828          0.425 0.523   0.523
#> ATC:mclust  2 0.388           0.772       0.876          0.449 0.523   0.523
#> SD:kmeans   2 0.456           0.749       0.880          0.472 0.523   0.523
#> CV:kmeans   2 0.493           0.858       0.886          0.489 0.500   0.500
#> MAD:kmeans  2 0.244           0.759       0.856          0.482 0.500   0.500
#> ATC:kmeans  2 1.000           0.995       0.998          0.468 0.534   0.534
#> SD:pam      2 0.299           0.769       0.841          0.485 0.492   0.492
#> CV:pam      2 0.556           0.598       0.838          0.508 0.495   0.495
#> MAD:pam     2 0.578           0.842       0.918          0.506 0.490   0.490
#> ATC:pam     2 1.000           1.000       1.000          0.454 0.547   0.547
#> SD:hclust   2 0.221           0.649       0.767          0.430 0.561   0.561
#> CV:hclust   2 0.394           0.766       0.874          0.320 0.704   0.704
#> MAD:hclust  2 0.162           0.503       0.749          0.439 0.500   0.500
#> ATC:hclust  2 0.284           0.781       0.849          0.404 0.534   0.534
get_stats(res_list, k = 3)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      3 0.539           0.714       0.873          0.381 0.759   0.561
#> CV:NMF      3 0.902           0.891       0.955          0.376 0.769   0.564
#> MAD:NMF     3 0.590           0.722       0.875          0.377 0.693   0.475
#> ATC:NMF     3 0.741           0.885       0.923          0.399 0.733   0.516
#> SD:skmeans  3 0.500           0.674       0.828          0.336 0.802   0.621
#> CV:skmeans  3 0.762           0.850       0.935          0.336 0.782   0.582
#> MAD:skmeans 3 0.622           0.665       0.859          0.331 0.770   0.567
#> ATC:skmeans 3 0.853           0.814       0.924          0.287 0.845   0.691
#> SD:mclust   3 0.245           0.454       0.714          0.387 0.558   0.355
#> CV:mclust   3 0.415           0.691       0.824          0.462 0.820   0.649
#> MAD:mclust  3 0.207           0.339       0.708          0.414 0.825   0.684
#> ATC:mclust  3 0.683           0.841       0.925          0.447 0.525   0.292
#> SD:kmeans   3 0.314           0.520       0.726          0.371 0.704   0.491
#> CV:kmeans   3 0.633           0.639       0.776          0.328 0.767   0.559
#> MAD:kmeans  3 0.347           0.520       0.764          0.344 0.741   0.531
#> ATC:kmeans  3 0.691           0.811       0.916          0.347 0.619   0.404
#> SD:pam      3 0.549           0.700       0.858          0.380 0.591   0.331
#> CV:pam      3 0.969           0.955       0.980          0.321 0.759   0.548
#> MAD:pam     3 0.757           0.742       0.895          0.316 0.649   0.396
#> ATC:pam     3 0.922           0.878       0.954          0.367 0.597   0.395
#> SD:hclust   3 0.262           0.563       0.722          0.278 0.962   0.933
#> CV:hclust   3 0.458           0.603       0.744          0.897 0.622   0.478
#> MAD:hclust  3 0.183           0.513       0.691          0.342 0.818   0.680
#> ATC:hclust  3 0.445           0.628       0.796          0.390 0.551   0.417
get_stats(res_list, k = 4)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      4 0.656           0.680       0.843         0.1178 0.861   0.616
#> CV:NMF      4 0.846           0.833       0.922         0.0922 0.853   0.601
#> MAD:NMF     4 0.667           0.705       0.857         0.1183 0.809   0.504
#> ATC:NMF     4 0.777           0.782       0.901         0.0902 0.929   0.789
#> SD:skmeans  4 0.606           0.588       0.810         0.1275 0.837   0.576
#> CV:skmeans  4 0.762           0.681       0.825         0.1187 0.810   0.505
#> MAD:skmeans 4 0.674           0.563       0.801         0.1264 0.864   0.623
#> ATC:skmeans 4 0.723           0.651       0.843         0.1113 0.933   0.814
#> SD:mclust   4 0.704           0.808       0.895         0.2242 0.860   0.649
#> CV:mclust   4 0.843           0.852       0.927         0.2179 0.892   0.706
#> MAD:mclust  4 0.746           0.831       0.913         0.1826 0.762   0.491
#> ATC:mclust  4 0.744           0.650       0.860         0.0616 0.763   0.469
#> SD:kmeans   4 0.615           0.661       0.740         0.1349 0.855   0.623
#> CV:kmeans   4 0.654           0.684       0.761         0.1298 0.798   0.495
#> MAD:kmeans  4 0.620           0.684       0.820         0.1333 0.864   0.640
#> ATC:kmeans  4 0.665           0.801       0.883         0.1522 0.747   0.428
#> SD:pam      4 0.643           0.598       0.823         0.1203 0.875   0.651
#> CV:pam      4 0.785           0.798       0.874         0.1079 0.911   0.737
#> MAD:pam     4 0.658           0.704       0.853         0.1219 0.840   0.571
#> ATC:pam     4 0.822           0.730       0.902         0.1935 0.802   0.528
#> SD:hclust   4 0.432           0.452       0.658         0.2694 0.732   0.509
#> CV:hclust   4 0.520           0.604       0.776         0.1552 0.724   0.405
#> MAD:hclust  4 0.404           0.500       0.688         0.2223 0.704   0.405
#> ATC:hclust  4 0.692           0.849       0.926         0.2272 0.755   0.560
get_stats(res_list, k = 5)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      5 0.643           0.601       0.803         0.0707 0.819   0.420
#> CV:NMF      5 0.764           0.783       0.840         0.0729 0.871   0.568
#> MAD:NMF     5 0.629           0.595       0.794         0.0661 0.875   0.556
#> ATC:NMF     5 0.679           0.601       0.785         0.0740 0.962   0.863
#> SD:skmeans  5 0.771           0.781       0.884         0.0663 0.907   0.661
#> CV:skmeans  5 0.796           0.694       0.817         0.0813 0.809   0.393
#> MAD:skmeans 5 0.721           0.787       0.878         0.0644 0.891   0.608
#> ATC:skmeans 5 0.698           0.637       0.807         0.0586 0.924   0.751
#> SD:mclust   5 0.664           0.710       0.835         0.1067 0.906   0.676
#> CV:mclust   5 0.899           0.807       0.925         0.0864 0.925   0.730
#> MAD:mclust  5 0.784           0.786       0.884         0.1164 0.912   0.697
#> ATC:mclust  5 0.691           0.781       0.887         0.0511 0.897   0.706
#> SD:kmeans   5 0.641           0.647       0.767         0.0797 0.893   0.629
#> CV:kmeans   5 0.693           0.672       0.745         0.0826 0.885   0.605
#> MAD:kmeans  5 0.652           0.597       0.742         0.0824 0.896   0.635
#> ATC:kmeans  5 0.724           0.627       0.810         0.0787 0.976   0.910
#> SD:pam      5 0.775           0.733       0.889         0.0681 0.888   0.616
#> CV:pam      5 0.822           0.796       0.888         0.0760 0.908   0.664
#> MAD:pam     5 0.802           0.767       0.901         0.0653 0.866   0.555
#> ATC:pam     5 0.881           0.824       0.932         0.0466 0.949   0.812
#> SD:hclust   5 0.525           0.357       0.628         0.0998 0.783   0.409
#> CV:hclust   5 0.683           0.594       0.790         0.0863 0.865   0.582
#> MAD:hclust  5 0.536           0.492       0.669         0.0596 0.924   0.731
#> ATC:hclust  5 0.693           0.821       0.925         0.0265 0.982   0.942
get_stats(res_list, k = 6)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      6 0.699           0.500       0.738         0.0474 0.935   0.694
#> CV:NMF      6 0.828           0.770       0.856         0.0439 0.901   0.574
#> MAD:NMF     6 0.665           0.555       0.693         0.0474 0.918   0.621
#> ATC:NMF     6 0.645           0.503       0.705         0.0472 0.923   0.709
#> SD:skmeans  6 0.776           0.684       0.822         0.0463 0.925   0.649
#> CV:skmeans  6 0.878           0.777       0.897         0.0417 0.922   0.628
#> MAD:skmeans 6 0.790           0.707       0.840         0.0457 0.935   0.691
#> ATC:skmeans 6 0.705           0.533       0.756         0.0424 0.953   0.810
#> SD:mclust   6 0.672           0.609       0.761         0.0494 0.947   0.750
#> CV:mclust   6 0.733           0.665       0.799         0.0338 0.965   0.844
#> MAD:mclust  6 0.672           0.677       0.776         0.0275 0.935   0.700
#> ATC:mclust  6 0.783           0.738       0.829         0.0914 0.889   0.631
#> SD:kmeans   6 0.680           0.534       0.733         0.0457 0.968   0.837
#> CV:kmeans   6 0.809           0.752       0.819         0.0487 0.947   0.739
#> MAD:kmeans  6 0.681           0.612       0.717         0.0449 0.911   0.590
#> ATC:kmeans  6 0.729           0.611       0.776         0.0449 0.951   0.809
#> SD:pam      6 0.793           0.689       0.829         0.0455 0.907   0.595
#> CV:pam      6 0.820           0.822       0.889         0.0308 0.969   0.837
#> MAD:pam     6 0.829           0.774       0.879         0.0505 0.917   0.631
#> ATC:pam     6 0.943           0.875       0.947         0.0578 0.893   0.592
#> SD:hclust   6 0.517           0.427       0.625         0.0280 0.880   0.539
#> CV:hclust   6 0.752           0.757       0.855         0.0261 0.905   0.644
#> MAD:hclust  6 0.539           0.447       0.678         0.0350 0.901   0.668
#> ATC:hclust  6 0.690           0.759       0.873         0.1030 0.929   0.759

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

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

collect_plots(res)

plot of chunk SD-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.221           0.649       0.767         0.4301 0.561   0.561
#> 3 3 0.262           0.563       0.722         0.2782 0.962   0.933
#> 4 4 0.432           0.452       0.658         0.2694 0.732   0.509
#> 5 5 0.525           0.357       0.628         0.0998 0.783   0.409
#> 6 6 0.517           0.427       0.625         0.0280 0.880   0.539

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
#> SRR1424656     1  0.0000     0.7983 1.000 0.000
#> SRR1424657     1  0.0000     0.7983 1.000 0.000
#> SRR1424658     1  0.1633     0.7922 0.976 0.024
#> SRR1424659     1  0.0672     0.7977 0.992 0.008
#> SRR1424660     1  0.0000     0.7983 1.000 0.000
#> SRR1424661     2  0.6438     0.7624 0.164 0.836
#> SRR1424662     2  0.9358     0.6343 0.352 0.648
#> SRR1424663     1  0.0376     0.7981 0.996 0.004
#> SRR1424664     1  0.0672     0.7977 0.992 0.008
#> SRR1424665     1  0.0000     0.7983 1.000 0.000
#> SRR1424666     1  0.8608     0.4379 0.716 0.284
#> SRR1424667     2  0.6531     0.7626 0.168 0.832
#> SRR1424668     1  0.6531     0.7125 0.832 0.168
#> SRR1424669     1  0.8608     0.4379 0.716 0.284
#> SRR1424670     1  0.0000     0.7983 1.000 0.000
#> SRR1424671     2  0.5178     0.7386 0.116 0.884
#> SRR1424672     1  0.6343     0.7164 0.840 0.160
#> SRR1424674     1  0.0376     0.7981 0.996 0.004
#> SRR1424673     1  0.8443     0.6238 0.728 0.272
#> SRR1424675     1  0.9608     0.1840 0.616 0.384
#> SRR1424676     1  0.4298     0.7638 0.912 0.088
#> SRR1424677     2  0.8327     0.7281 0.264 0.736
#> SRR1424678     2  0.9896     0.4526 0.440 0.560
#> SRR1424679     2  0.9896     0.4526 0.440 0.560
#> SRR1424680     2  0.6531     0.7626 0.168 0.832
#> SRR1424681     1  0.4022     0.7687 0.920 0.080
#> SRR1424682     2  0.8144     0.4867 0.252 0.748
#> SRR1424683     2  0.6531     0.7626 0.168 0.832
#> SRR1424685     1  0.4022     0.7687 0.920 0.080
#> SRR1424686     1  0.6343     0.7164 0.840 0.160
#> SRR1424687     2  0.8661     0.7136 0.288 0.712
#> SRR1424688     1  0.2043     0.7876 0.968 0.032
#> SRR1424689     1  0.7219     0.6231 0.800 0.200
#> SRR1424690     1  0.0938     0.7969 0.988 0.012
#> SRR1424691     1  0.0938     0.7969 0.988 0.012
#> SRR1424692     2  0.6438     0.7624 0.164 0.836
#> SRR1424684     2  0.9896     0.4526 0.440 0.560
#> SRR1424693     1  0.0938     0.7969 0.988 0.012
#> SRR1424694     2  0.6623     0.7626 0.172 0.828
#> SRR1424695     1  0.7815     0.5489 0.768 0.232
#> SRR1424696     1  0.9833    -0.0343 0.576 0.424
#> SRR1424697     2  0.9427     0.2920 0.360 0.640
#> SRR1424698     1  0.6438     0.7195 0.836 0.164
#> SRR1424699     1  0.8763     0.4314 0.704 0.296
#> SRR1424700     1  0.8763     0.4314 0.704 0.296
#> SRR1424701     1  0.8763     0.4314 0.704 0.296
#> SRR1424702     1  0.6531     0.7125 0.832 0.168
#> SRR1424703     1  0.6531     0.7125 0.832 0.168
#> SRR1424704     1  0.6531     0.7125 0.832 0.168
#> SRR1424706     2  0.9393     0.2989 0.356 0.644
#> SRR1424707     1  0.6531     0.7125 0.832 0.168

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1424656     1   0.254     0.7064 0.920 0.000 0.080
#> SRR1424657     1   0.254     0.7064 0.920 0.000 0.080
#> SRR1424658     1   0.296     0.6838 0.900 0.000 0.100
#> SRR1424659     1   0.263     0.6906 0.916 0.000 0.084
#> SRR1424660     1   0.254     0.7064 0.920 0.000 0.080
#> SRR1424661     2   0.199     0.7219 0.048 0.948 0.004
#> SRR1424662     2   0.956     0.0995 0.268 0.484 0.248
#> SRR1424663     1   0.277     0.7063 0.916 0.004 0.080
#> SRR1424664     1   0.263     0.6906 0.916 0.000 0.084
#> SRR1424665     1   0.254     0.7064 0.920 0.000 0.080
#> SRR1424666     1   0.714     0.4114 0.644 0.044 0.312
#> SRR1424667     3   0.736     0.4840 0.112 0.188 0.700
#> SRR1424668     1   0.626     0.6385 0.752 0.052 0.196
#> SRR1424669     1   0.714     0.4114 0.644 0.044 0.312
#> SRR1424670     1   0.254     0.7064 0.920 0.000 0.080
#> SRR1424671     2   0.000     0.6963 0.000 1.000 0.000
#> SRR1424672     1   0.611     0.6418 0.760 0.048 0.192
#> SRR1424674     1   0.277     0.7063 0.916 0.004 0.080
#> SRR1424673     1   0.759     0.5706 0.652 0.080 0.268
#> SRR1424675     1   0.749    -0.1908 0.500 0.036 0.464
#> SRR1424676     1   0.538     0.6507 0.820 0.068 0.112
#> SRR1424677     2   0.382     0.7029 0.148 0.852 0.000
#> SRR1424678     3   0.550     0.8447 0.292 0.000 0.708
#> SRR1424679     3   0.550     0.8447 0.292 0.000 0.708
#> SRR1424680     2   0.255     0.7219 0.056 0.932 0.012
#> SRR1424681     1   0.523     0.6571 0.828 0.068 0.104
#> SRR1424682     2   0.825     0.5014 0.252 0.620 0.128
#> SRR1424683     2   0.255     0.7219 0.056 0.932 0.012
#> SRR1424685     1   0.523     0.6571 0.828 0.068 0.104
#> SRR1424686     1   0.606     0.6511 0.764 0.048 0.188
#> SRR1424687     2   0.499     0.6862 0.160 0.816 0.024
#> SRR1424688     1   0.354     0.6777 0.888 0.012 0.100
#> SRR1424689     1   0.590     0.3944 0.680 0.004 0.316
#> SRR1424690     1   0.140     0.7069 0.968 0.004 0.028
#> SRR1424691     1   0.140     0.7069 0.968 0.004 0.028
#> SRR1424692     2   0.175     0.7223 0.048 0.952 0.000
#> SRR1424684     3   0.550     0.8447 0.292 0.000 0.708
#> SRR1424693     1   0.140     0.7069 0.968 0.004 0.028
#> SRR1424694     2   0.255     0.7233 0.056 0.932 0.012
#> SRR1424695     1   0.673     0.2865 0.644 0.024 0.332
#> SRR1424696     1   0.954    -0.2140 0.460 0.204 0.336
#> SRR1424697     2   0.886     0.3303 0.360 0.512 0.128
#> SRR1424698     1   0.631     0.6531 0.748 0.052 0.200
#> SRR1424699     1   0.658     0.0466 0.572 0.008 0.420
#> SRR1424700     1   0.658     0.0466 0.572 0.008 0.420
#> SRR1424701     1   0.658     0.0466 0.572 0.008 0.420
#> SRR1424702     1   0.621     0.6412 0.756 0.052 0.192
#> SRR1424703     1   0.611     0.6603 0.764 0.052 0.184
#> SRR1424704     1   0.621     0.6412 0.756 0.052 0.192
#> SRR1424706     2   0.885     0.3391 0.356 0.516 0.128
#> SRR1424707     1   0.621     0.6412 0.756 0.052 0.192

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1424656     1  0.4406    0.51162 0.700 0.000 0.300 0.000
#> SRR1424657     1  0.4406    0.51162 0.700 0.000 0.300 0.000
#> SRR1424658     1  0.6349    0.48553 0.548 0.056 0.392 0.004
#> SRR1424659     1  0.6292    0.48886 0.548 0.052 0.396 0.004
#> SRR1424660     1  0.4406    0.51162 0.700 0.000 0.300 0.000
#> SRR1424661     4  0.1635    0.83681 0.044 0.008 0.000 0.948
#> SRR1424662     4  0.8784    0.20231 0.096 0.312 0.136 0.456
#> SRR1424663     1  0.4431    0.50778 0.696 0.000 0.304 0.000
#> SRR1424664     1  0.6292    0.48886 0.548 0.052 0.396 0.004
#> SRR1424665     1  0.4406    0.51162 0.700 0.000 0.300 0.000
#> SRR1424666     1  0.8390    0.28204 0.396 0.276 0.308 0.020
#> SRR1424667     2  0.4010    0.35325 0.000 0.816 0.028 0.156
#> SRR1424668     3  0.4222    0.47869 0.272 0.000 0.728 0.000
#> SRR1424669     1  0.8390    0.28204 0.396 0.276 0.308 0.020
#> SRR1424670     1  0.4406    0.51162 0.700 0.000 0.300 0.000
#> SRR1424671     4  0.0336    0.80715 0.000 0.000 0.008 0.992
#> SRR1424672     3  0.4304    0.46046 0.284 0.000 0.716 0.000
#> SRR1424674     1  0.4431    0.50778 0.696 0.000 0.304 0.000
#> SRR1424673     3  0.7570    0.42893 0.292 0.168 0.528 0.012
#> SRR1424675     2  0.6936    0.52751 0.332 0.568 0.084 0.016
#> SRR1424676     1  0.5731    0.39165 0.768 0.072 0.092 0.068
#> SRR1424677     4  0.3716    0.78372 0.096 0.000 0.052 0.852
#> SRR1424678     2  0.3356    0.69374 0.176 0.824 0.000 0.000
#> SRR1424679     2  0.3356    0.69374 0.176 0.824 0.000 0.000
#> SRR1424680     4  0.2040    0.83859 0.048 0.012 0.004 0.936
#> SRR1424681     1  0.5600    0.40011 0.776 0.068 0.088 0.068
#> SRR1424682     4  0.6637    0.27939 0.060 0.016 0.348 0.576
#> SRR1424683     4  0.2040    0.83859 0.048 0.012 0.004 0.936
#> SRR1424685     1  0.5600    0.40011 0.776 0.068 0.088 0.068
#> SRR1424686     1  0.4955   -0.40752 0.556 0.000 0.444 0.000
#> SRR1424687     4  0.4761    0.76480 0.100 0.032 0.052 0.816
#> SRR1424688     1  0.3442    0.43932 0.880 0.068 0.040 0.012
#> SRR1424689     1  0.6573    0.11702 0.616 0.276 0.104 0.004
#> SRR1424690     1  0.1209    0.49828 0.964 0.000 0.032 0.004
#> SRR1424691     1  0.1209    0.49828 0.964 0.000 0.032 0.004
#> SRR1424692     4  0.1302    0.83724 0.044 0.000 0.000 0.956
#> SRR1424684     2  0.3356    0.69374 0.176 0.824 0.000 0.000
#> SRR1424693     1  0.1209    0.49828 0.964 0.000 0.032 0.004
#> SRR1424694     4  0.1975    0.83734 0.048 0.016 0.000 0.936
#> SRR1424695     1  0.6137   -0.13858 0.636 0.308 0.028 0.028
#> SRR1424696     1  0.8318   -0.21213 0.440 0.324 0.028 0.208
#> SRR1424697     3  0.6719    0.00145 0.052 0.016 0.472 0.460
#> SRR1424698     1  0.6723   -0.44250 0.472 0.076 0.448 0.004
#> SRR1424699     2  0.5591    0.57225 0.484 0.500 0.008 0.008
#> SRR1424700     2  0.5591    0.57225 0.484 0.500 0.008 0.008
#> SRR1424701     2  0.5591    0.57225 0.484 0.500 0.008 0.008
#> SRR1424702     3  0.5127    0.61195 0.356 0.012 0.632 0.000
#> SRR1424703     3  0.6229    0.49169 0.416 0.056 0.528 0.000
#> SRR1424704     3  0.5127    0.61195 0.356 0.012 0.632 0.000
#> SRR1424706     3  0.6720   -0.01266 0.052 0.016 0.468 0.464
#> SRR1424707     3  0.5127    0.61195 0.356 0.012 0.632 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
#> SRR1424656     1  0.0162     0.6190 0.996 0.000 0.000 0.000 0.004
#> SRR1424657     1  0.0162     0.6190 0.996 0.000 0.000 0.000 0.004
#> SRR1424658     5  0.4589    -0.1126 0.472 0.004 0.004 0.000 0.520
#> SRR1424659     1  0.4251     0.0238 0.624 0.000 0.004 0.000 0.372
#> SRR1424660     1  0.0162     0.6190 0.996 0.000 0.000 0.000 0.004
#> SRR1424661     4  0.1605     0.8730 0.040 0.004 0.000 0.944 0.012
#> SRR1424662     2  0.7605    -0.0650 0.040 0.404 0.004 0.308 0.244
#> SRR1424663     1  0.0162     0.6187 0.996 0.000 0.004 0.000 0.000
#> SRR1424664     1  0.4251     0.0238 0.624 0.000 0.004 0.000 0.372
#> SRR1424665     1  0.0609     0.6109 0.980 0.000 0.000 0.000 0.020
#> SRR1424666     5  0.6756     0.4633 0.268 0.108 0.032 0.016 0.576
#> SRR1424667     2  0.3128     0.3185 0.000 0.824 0.004 0.004 0.168
#> SRR1424668     3  0.4451     0.0687 0.492 0.000 0.504 0.000 0.004
#> SRR1424669     5  0.6756     0.4633 0.268 0.108 0.032 0.016 0.576
#> SRR1424670     1  0.0290     0.6152 0.992 0.000 0.000 0.000 0.008
#> SRR1424671     4  0.2130     0.7959 0.000 0.000 0.012 0.908 0.080
#> SRR1424672     1  0.4307    -0.1780 0.504 0.000 0.496 0.000 0.000
#> SRR1424674     1  0.0162     0.6187 0.996 0.000 0.004 0.000 0.000
#> SRR1424673     3  0.5417     0.2906 0.124 0.068 0.740 0.008 0.060
#> SRR1424675     2  0.8028     0.4645 0.104 0.468 0.240 0.012 0.176
#> SRR1424676     3  0.7641     0.0743 0.360 0.016 0.440 0.072 0.112
#> SRR1424677     4  0.3406     0.8318 0.040 0.000 0.020 0.856 0.084
#> SRR1424678     2  0.3074     0.5938 0.000 0.804 0.196 0.000 0.000
#> SRR1424679     2  0.3074     0.5938 0.000 0.804 0.196 0.000 0.000
#> SRR1424680     4  0.1808     0.8771 0.044 0.012 0.000 0.936 0.008
#> SRR1424681     3  0.7531     0.0739 0.368 0.012 0.440 0.072 0.108
#> SRR1424682     4  0.6212     0.4324 0.008 0.016 0.312 0.576 0.088
#> SRR1424683     4  0.1808     0.8771 0.044 0.012 0.000 0.936 0.008
#> SRR1424685     3  0.7531     0.0739 0.368 0.012 0.440 0.072 0.108
#> SRR1424686     3  0.4130     0.3222 0.292 0.012 0.696 0.000 0.000
#> SRR1424687     4  0.4270     0.8105 0.040 0.016 0.032 0.820 0.092
#> SRR1424688     3  0.7434    -0.1013 0.368 0.024 0.400 0.012 0.196
#> SRR1424689     3  0.8663    -0.2301 0.192 0.236 0.296 0.004 0.272
#> SRR1424690     1  0.6855     0.1824 0.496 0.012 0.316 0.008 0.168
#> SRR1424691     1  0.6855     0.1824 0.496 0.012 0.316 0.008 0.168
#> SRR1424692     4  0.1043     0.8760 0.040 0.000 0.000 0.960 0.000
#> SRR1424684     2  0.3074     0.5938 0.000 0.804 0.196 0.000 0.000
#> SRR1424693     1  0.6855     0.1824 0.496 0.012 0.316 0.008 0.168
#> SRR1424694     4  0.1710     0.8763 0.040 0.016 0.000 0.940 0.004
#> SRR1424695     3  0.8098    -0.3829 0.044 0.248 0.408 0.028 0.272
#> SRR1424696     5  0.9315    -0.3802 0.044 0.256 0.216 0.208 0.276
#> SRR1424697     3  0.5324    -0.1878 0.016 0.016 0.504 0.460 0.004
#> SRR1424698     3  0.1461     0.3097 0.028 0.004 0.952 0.000 0.016
#> SRR1424699     2  0.6889     0.5464 0.028 0.436 0.408 0.004 0.124
#> SRR1424700     2  0.6889     0.5464 0.028 0.436 0.408 0.004 0.124
#> SRR1424701     2  0.6889     0.5464 0.028 0.436 0.408 0.004 0.124
#> SRR1424702     3  0.4527     0.3693 0.260 0.000 0.700 0.000 0.040
#> SRR1424703     3  0.3400     0.4089 0.116 0.004 0.840 0.000 0.040
#> SRR1424704     3  0.4597     0.3673 0.260 0.000 0.696 0.000 0.044
#> SRR1424706     3  0.5238    -0.1968 0.012 0.016 0.504 0.464 0.004
#> SRR1424707     3  0.4527     0.3693 0.260 0.000 0.700 0.000 0.040

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR1424656     1  0.0000     0.6342 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1424657     1  0.0000     0.6342 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1424658     1  0.5750    -0.0494 0.448 0.000 0.000 0.000 0.172 0.380
#> SRR1424659     1  0.4322     0.0157 0.600 0.000 0.000 0.000 0.028 0.372
#> SRR1424660     1  0.0000     0.6342 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1424661     4  0.3947     0.7163 0.040 0.028 0.076 0.820 0.000 0.036
#> SRR1424662     2  0.9062    -0.1073 0.044 0.348 0.116 0.192 0.100 0.200
#> SRR1424663     1  0.0291     0.6340 0.992 0.000 0.004 0.000 0.004 0.000
#> SRR1424664     1  0.4322     0.0157 0.600 0.000 0.000 0.000 0.028 0.372
#> SRR1424665     1  0.0458     0.6291 0.984 0.000 0.000 0.000 0.000 0.016
#> SRR1424666     6  0.8064     1.0000 0.256 0.076 0.104 0.012 0.116 0.436
#> SRR1424667     2  0.5684     0.3646 0.000 0.656 0.108 0.000 0.100 0.136
#> SRR1424668     3  0.3997     0.4425 0.488 0.000 0.508 0.000 0.000 0.004
#> SRR1424669     6  0.8064     1.0000 0.256 0.076 0.104 0.012 0.116 0.436
#> SRR1424670     1  0.0692     0.6212 0.976 0.000 0.000 0.000 0.004 0.020
#> SRR1424671     4  0.6284     0.3212 0.000 0.100 0.060 0.448 0.000 0.392
#> SRR1424672     3  0.3999     0.4275 0.496 0.000 0.500 0.000 0.004 0.000
#> SRR1424674     1  0.0291     0.6340 0.992 0.000 0.004 0.000 0.004 0.000
#> SRR1424673     3  0.4796     0.4506 0.104 0.012 0.728 0.008 0.144 0.004
#> SRR1424675     5  0.6964    -0.0410 0.080 0.176 0.224 0.008 0.508 0.004
#> SRR1424676     5  0.6267     0.2858 0.356 0.000 0.024 0.064 0.508 0.048
#> SRR1424677     4  0.3467     0.7701 0.040 0.000 0.012 0.848 0.052 0.048
#> SRR1424678     2  0.3881     0.5830 0.000 0.600 0.004 0.000 0.396 0.000
#> SRR1424679     2  0.3881     0.5830 0.000 0.600 0.004 0.000 0.396 0.000
#> SRR1424680     4  0.1605     0.8053 0.044 0.000 0.000 0.936 0.016 0.004
#> SRR1424681     5  0.6282     0.2784 0.364 0.000 0.024 0.064 0.500 0.048
#> SRR1424682     4  0.5765     0.3312 0.008 0.000 0.340 0.552 0.052 0.048
#> SRR1424683     4  0.1605     0.8053 0.044 0.000 0.000 0.936 0.016 0.004
#> SRR1424685     5  0.6282     0.2784 0.364 0.000 0.024 0.064 0.500 0.048
#> SRR1424686     3  0.5994     0.4540 0.284 0.000 0.440 0.000 0.276 0.000
#> SRR1424687     4  0.4322     0.7509 0.040 0.000 0.052 0.800 0.064 0.044
#> SRR1424688     5  0.4456     0.0656 0.360 0.000 0.000 0.008 0.608 0.024
#> SRR1424689     5  0.6116     0.1766 0.176 0.032 0.024 0.000 0.612 0.156
#> SRR1424690     1  0.4315     0.1042 0.492 0.000 0.000 0.004 0.492 0.012
#> SRR1424691     1  0.4315     0.1042 0.492 0.000 0.000 0.004 0.492 0.012
#> SRR1424692     4  0.1196     0.8019 0.040 0.000 0.008 0.952 0.000 0.000
#> SRR1424684     2  0.3881     0.5830 0.000 0.600 0.004 0.000 0.396 0.000
#> SRR1424693     1  0.4315     0.1042 0.492 0.000 0.000 0.004 0.492 0.012
#> SRR1424694     4  0.1794     0.8016 0.040 0.000 0.036 0.924 0.000 0.000
#> SRR1424695     5  0.2850     0.3161 0.036 0.032 0.004 0.028 0.888 0.012
#> SRR1424696     5  0.5502     0.0977 0.036 0.032 0.040 0.192 0.688 0.012
#> SRR1424697     3  0.4284     0.0614 0.012 0.000 0.544 0.440 0.000 0.004
#> SRR1424698     3  0.3563     0.3954 0.000 0.000 0.664 0.000 0.336 0.000
#> SRR1424699     5  0.4893     0.2299 0.000 0.172 0.168 0.000 0.660 0.000
#> SRR1424700     5  0.4893     0.2299 0.000 0.172 0.168 0.000 0.660 0.000
#> SRR1424701     5  0.4893     0.2299 0.000 0.172 0.168 0.000 0.660 0.000
#> SRR1424702     3  0.5208     0.6507 0.248 0.000 0.604 0.000 0.148 0.000
#> SRR1424703     3  0.4546     0.5766 0.104 0.000 0.692 0.000 0.204 0.000
#> SRR1424704     3  0.5361     0.6491 0.252 0.000 0.596 0.000 0.148 0.004
#> SRR1424706     3  0.4199     0.0492 0.008 0.000 0.544 0.444 0.000 0.004
#> SRR1424707     3  0.5208     0.6507 0.248 0.000 0.604 0.000 0.148 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 16960 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.456           0.749       0.880         0.4721 0.523   0.523
#> 3 3 0.314           0.520       0.726         0.3707 0.704   0.491
#> 4 4 0.615           0.661       0.740         0.1349 0.855   0.623
#> 5 5 0.641           0.647       0.767         0.0797 0.893   0.629
#> 6 6 0.680           0.534       0.733         0.0457 0.968   0.837

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
#> SRR1424656     1  0.3274     0.8654 0.940 0.060
#> SRR1424657     1  0.2423     0.8690 0.960 0.040
#> SRR1424658     1  0.8813     0.5842 0.700 0.300
#> SRR1424659     1  0.3733     0.8616 0.928 0.072
#> SRR1424660     1  0.0376     0.8735 0.996 0.004
#> SRR1424661     2  0.9248     0.6028 0.340 0.660
#> SRR1424662     2  0.3114     0.8135 0.056 0.944
#> SRR1424663     1  0.0000     0.8731 1.000 0.000
#> SRR1424664     1  0.3733     0.8616 0.928 0.072
#> SRR1424665     1  0.3733     0.8616 0.928 0.072
#> SRR1424666     1  0.0672     0.8738 0.992 0.008
#> SRR1424667     2  0.0938     0.8101 0.012 0.988
#> SRR1424668     1  0.0000     0.8731 1.000 0.000
#> SRR1424669     1  0.5737     0.8113 0.864 0.136
#> SRR1424670     1  0.3733     0.8616 0.928 0.072
#> SRR1424671     2  0.7376     0.7445 0.208 0.792
#> SRR1424672     1  0.0376     0.8721 0.996 0.004
#> SRR1424674     1  0.1414     0.8734 0.980 0.020
#> SRR1424673     1  0.9833     0.0764 0.576 0.424
#> SRR1424675     2  0.4690     0.7811 0.100 0.900
#> SRR1424676     2  0.8713     0.5450 0.292 0.708
#> SRR1424677     2  0.2236     0.8065 0.036 0.964
#> SRR1424678     2  0.0672     0.8105 0.008 0.992
#> SRR1424679     2  0.7376     0.6852 0.208 0.792
#> SRR1424680     2  0.0672     0.8105 0.008 0.992
#> SRR1424681     1  0.0376     0.8721 0.996 0.004
#> SRR1424682     1  0.9833     0.0764 0.576 0.424
#> SRR1424683     2  0.6048     0.7849 0.148 0.852
#> SRR1424685     1  0.0376     0.8721 0.996 0.004
#> SRR1424686     1  0.0000     0.8731 1.000 0.000
#> SRR1424687     2  0.8661     0.6580 0.288 0.712
#> SRR1424688     1  0.6148     0.7900 0.848 0.152
#> SRR1424689     1  0.6712     0.7691 0.824 0.176
#> SRR1424690     1  0.3733     0.8616 0.928 0.072
#> SRR1424691     1  0.0000     0.8731 1.000 0.000
#> SRR1424692     2  0.4298     0.8078 0.088 0.912
#> SRR1424684     2  0.7376     0.6852 0.208 0.792
#> SRR1424693     1  0.3733     0.8616 0.928 0.072
#> SRR1424694     2  0.7453     0.7446 0.212 0.788
#> SRR1424695     1  0.8713     0.5976 0.708 0.292
#> SRR1424696     2  0.0938     0.8101 0.012 0.988
#> SRR1424697     1  0.9833     0.0764 0.576 0.424
#> SRR1424698     1  0.1414     0.8687 0.980 0.020
#> SRR1424699     2  0.0000     0.8083 0.000 1.000
#> SRR1424700     2  0.9608     0.3112 0.384 0.616
#> SRR1424701     1  0.6048     0.8083 0.852 0.148
#> SRR1424702     1  0.1184     0.8684 0.984 0.016
#> SRR1424703     1  0.1184     0.8684 0.984 0.016
#> SRR1424704     1  0.0938     0.8690 0.988 0.012
#> SRR1424706     2  0.9087     0.6150 0.324 0.676
#> SRR1424707     1  0.1184     0.8684 0.984 0.016

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1424656     1  0.0000      0.781 1.000 0.000 0.000
#> SRR1424657     1  0.0000      0.781 1.000 0.000 0.000
#> SRR1424658     1  0.4121      0.642 0.832 0.000 0.168
#> SRR1424659     1  0.0000      0.781 1.000 0.000 0.000
#> SRR1424660     1  0.1267      0.774 0.972 0.004 0.024
#> SRR1424661     2  0.4810      0.587 0.140 0.832 0.028
#> SRR1424662     2  0.6675      0.343 0.404 0.584 0.012
#> SRR1424663     1  0.1031      0.775 0.976 0.000 0.024
#> SRR1424664     1  0.0237      0.779 0.996 0.000 0.004
#> SRR1424665     1  0.0237      0.780 0.996 0.000 0.004
#> SRR1424666     1  0.4782      0.680 0.820 0.016 0.164
#> SRR1424667     2  0.5882      0.296 0.000 0.652 0.348
#> SRR1424668     1  0.4897      0.676 0.812 0.016 0.172
#> SRR1424669     1  0.3295      0.710 0.896 0.008 0.096
#> SRR1424670     1  0.0000      0.781 1.000 0.000 0.000
#> SRR1424671     2  0.4062      0.563 0.000 0.836 0.164
#> SRR1424672     1  0.6714      0.572 0.672 0.032 0.296
#> SRR1424674     1  0.0000      0.781 1.000 0.000 0.000
#> SRR1424673     2  0.7620      0.367 0.056 0.596 0.348
#> SRR1424675     3  0.7841      0.169 0.056 0.408 0.536
#> SRR1424676     3  0.7277      0.345 0.060 0.280 0.660
#> SRR1424677     2  0.0000      0.577 0.000 1.000 0.000
#> SRR1424678     2  0.6192      0.176 0.000 0.580 0.420
#> SRR1424679     3  0.7742      0.276 0.060 0.356 0.584
#> SRR1424680     2  0.5216      0.393 0.000 0.740 0.260
#> SRR1424681     1  0.6931      0.573 0.640 0.032 0.328
#> SRR1424682     2  0.7770      0.317 0.056 0.560 0.384
#> SRR1424683     2  0.3686      0.591 0.140 0.860 0.000
#> SRR1424685     1  0.6931      0.573 0.640 0.032 0.328
#> SRR1424686     1  0.5956      0.654 0.720 0.016 0.264
#> SRR1424687     2  0.4002      0.583 0.160 0.840 0.000
#> SRR1424688     1  0.6193      0.618 0.692 0.016 0.292
#> SRR1424689     1  0.6047      0.572 0.680 0.008 0.312
#> SRR1424690     1  0.4842      0.690 0.776 0.000 0.224
#> SRR1424691     1  0.6027      0.651 0.712 0.016 0.272
#> SRR1424692     2  0.0000      0.577 0.000 1.000 0.000
#> SRR1424684     3  0.7760      0.270 0.060 0.360 0.580
#> SRR1424693     1  0.6062      0.634 0.708 0.016 0.276
#> SRR1424694     2  0.4702      0.548 0.212 0.788 0.000
#> SRR1424695     1  0.6229      0.528 0.652 0.008 0.340
#> SRR1424696     2  0.7001      0.190 0.024 0.588 0.388
#> SRR1424697     2  0.6686      0.390 0.016 0.612 0.372
#> SRR1424698     3  0.8042      0.388 0.200 0.148 0.652
#> SRR1424699     3  0.6482      0.310 0.024 0.296 0.680
#> SRR1424700     3  0.5894      0.364 0.028 0.220 0.752
#> SRR1424701     3  0.6856      0.400 0.132 0.128 0.740
#> SRR1424702     3  0.8700      0.301 0.276 0.148 0.576
#> SRR1424703     3  0.8284      0.368 0.224 0.148 0.628
#> SRR1424704     3  0.8622      0.263 0.296 0.132 0.572
#> SRR1424706     2  0.5656      0.488 0.004 0.712 0.284
#> SRR1424707     3  0.8673      0.308 0.272 0.148 0.580

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1424656     1  0.0376      0.745 0.992 0.004 0.000 0.004
#> SRR1424657     1  0.1356      0.746 0.960 0.000 0.008 0.032
#> SRR1424658     1  0.1707      0.739 0.952 0.024 0.020 0.004
#> SRR1424659     1  0.0336      0.746 0.992 0.008 0.000 0.000
#> SRR1424660     1  0.2124      0.740 0.932 0.000 0.040 0.028
#> SRR1424661     4  0.1297      0.878 0.000 0.020 0.016 0.964
#> SRR1424662     4  0.6021      0.577 0.260 0.028 0.036 0.676
#> SRR1424663     1  0.2032      0.742 0.936 0.000 0.028 0.036
#> SRR1424664     1  0.1139      0.742 0.972 0.008 0.008 0.012
#> SRR1424665     1  0.1082      0.744 0.972 0.004 0.020 0.004
#> SRR1424666     1  0.5274      0.554 0.724 0.020 0.236 0.020
#> SRR1424667     2  0.5172      0.621 0.000 0.704 0.036 0.260
#> SRR1424668     1  0.5889      0.491 0.640 0.008 0.312 0.040
#> SRR1424669     1  0.2616      0.725 0.920 0.028 0.036 0.016
#> SRR1424670     1  0.0937      0.745 0.976 0.012 0.000 0.012
#> SRR1424671     4  0.2089      0.864 0.000 0.020 0.048 0.932
#> SRR1424672     1  0.6763      0.339 0.488 0.024 0.444 0.044
#> SRR1424674     1  0.2197      0.747 0.936 0.012 0.024 0.028
#> SRR1424673     3  0.5728      0.345 0.004 0.020 0.544 0.432
#> SRR1424675     2  0.3593      0.837 0.016 0.868 0.024 0.092
#> SRR1424676     2  0.3556      0.769 0.020 0.864 0.104 0.012
#> SRR1424677     4  0.1902      0.871 0.000 0.064 0.004 0.932
#> SRR1424678     2  0.3024      0.810 0.000 0.852 0.000 0.148
#> SRR1424679     2  0.2616      0.834 0.016 0.920 0.028 0.036
#> SRR1424680     4  0.4123      0.681 0.000 0.220 0.008 0.772
#> SRR1424681     3  0.8118     -0.367 0.400 0.124 0.432 0.044
#> SRR1424682     3  0.4877      0.528 0.000 0.008 0.664 0.328
#> SRR1424683     4  0.0921      0.888 0.000 0.028 0.000 0.972
#> SRR1424685     1  0.8172      0.383 0.444 0.132 0.380 0.044
#> SRR1424686     1  0.6512      0.343 0.492 0.016 0.452 0.040
#> SRR1424687     4  0.1443      0.880 0.028 0.008 0.004 0.960
#> SRR1424688     1  0.7783      0.566 0.548 0.152 0.268 0.032
#> SRR1424689     1  0.6960      0.609 0.624 0.204 0.160 0.012
#> SRR1424690     1  0.6869      0.600 0.612 0.132 0.248 0.008
#> SRR1424691     1  0.7681      0.551 0.544 0.128 0.296 0.032
#> SRR1424692     4  0.1004      0.889 0.000 0.024 0.004 0.972
#> SRR1424684     2  0.2715      0.833 0.016 0.916 0.032 0.036
#> SRR1424693     1  0.7419      0.575 0.572 0.144 0.264 0.020
#> SRR1424694     4  0.1631      0.885 0.016 0.020 0.008 0.956
#> SRR1424695     1  0.6887      0.615 0.632 0.200 0.156 0.012
#> SRR1424696     2  0.3450      0.802 0.000 0.836 0.008 0.156
#> SRR1424697     3  0.5143      0.487 0.000 0.012 0.628 0.360
#> SRR1424698     3  0.2846      0.699 0.012 0.052 0.908 0.028
#> SRR1424699     2  0.4059      0.748 0.000 0.788 0.200 0.012
#> SRR1424700     2  0.4194      0.727 0.000 0.764 0.228 0.008
#> SRR1424701     3  0.3663      0.637 0.008 0.128 0.848 0.016
#> SRR1424702     3  0.2730      0.712 0.036 0.020 0.916 0.028
#> SRR1424703     3  0.2929      0.704 0.024 0.040 0.908 0.028
#> SRR1424704     3  0.2214      0.709 0.044 0.000 0.928 0.028
#> SRR1424706     3  0.5570      0.337 0.000 0.020 0.540 0.440
#> SRR1424707     3  0.2940      0.713 0.036 0.028 0.908 0.028

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4    p5
#> SRR1424656     1  0.0324      0.762 0.992 0.004 0.000 0.000 0.004
#> SRR1424657     1  0.1357      0.747 0.948 0.004 0.000 0.000 0.048
#> SRR1424658     1  0.2521      0.699 0.900 0.024 0.008 0.000 0.068
#> SRR1424659     1  0.0960      0.761 0.972 0.016 0.008 0.000 0.004
#> SRR1424660     1  0.3807      0.660 0.792 0.004 0.028 0.000 0.176
#> SRR1424661     4  0.1372      0.832 0.000 0.024 0.016 0.956 0.004
#> SRR1424662     4  0.7949      0.154 0.372 0.072 0.060 0.424 0.072
#> SRR1424663     1  0.3737      0.611 0.764 0.004 0.008 0.000 0.224
#> SRR1424664     1  0.0960      0.761 0.972 0.016 0.008 0.000 0.004
#> SRR1424665     1  0.1168      0.750 0.960 0.008 0.000 0.000 0.032
#> SRR1424666     1  0.5856      0.518 0.660 0.024 0.132 0.000 0.184
#> SRR1424667     2  0.5803      0.616 0.000 0.700 0.072 0.120 0.108
#> SRR1424668     1  0.6066      0.308 0.568 0.008 0.120 0.000 0.304
#> SRR1424669     1  0.6039      0.546 0.680 0.064 0.072 0.008 0.176
#> SRR1424670     1  0.1524      0.760 0.952 0.016 0.016 0.000 0.016
#> SRR1424671     4  0.2273      0.823 0.000 0.024 0.024 0.920 0.032
#> SRR1424672     5  0.6461      0.267 0.332 0.008 0.156 0.000 0.504
#> SRR1424674     1  0.3807      0.553 0.776 0.008 0.012 0.000 0.204
#> SRR1424673     3  0.6717      0.482 0.000 0.028 0.508 0.328 0.136
#> SRR1424675     2  0.3197      0.783 0.000 0.868 0.024 0.028 0.080
#> SRR1424676     2  0.4264      0.458 0.000 0.620 0.004 0.000 0.376
#> SRR1424677     4  0.1200      0.833 0.000 0.012 0.016 0.964 0.008
#> SRR1424678     2  0.2491      0.778 0.000 0.896 0.000 0.068 0.036
#> SRR1424679     2  0.2179      0.781 0.000 0.888 0.000 0.000 0.112
#> SRR1424680     4  0.3612      0.574 0.000 0.268 0.000 0.732 0.000
#> SRR1424681     5  0.4376      0.600 0.144 0.000 0.092 0.000 0.764
#> SRR1424682     3  0.5884      0.644 0.000 0.012 0.616 0.260 0.112
#> SRR1424683     4  0.0727      0.838 0.000 0.012 0.004 0.980 0.004
#> SRR1424685     5  0.3992      0.620 0.124 0.000 0.080 0.000 0.796
#> SRR1424686     5  0.6175      0.284 0.344 0.000 0.148 0.000 0.508
#> SRR1424687     4  0.3300      0.768 0.008 0.012 0.012 0.852 0.116
#> SRR1424688     5  0.4715      0.647 0.296 0.020 0.012 0.000 0.672
#> SRR1424689     5  0.5445      0.469 0.384 0.036 0.016 0.000 0.564
#> SRR1424690     5  0.4193      0.655 0.304 0.000 0.012 0.000 0.684
#> SRR1424691     5  0.4024      0.667 0.220 0.000 0.028 0.000 0.752
#> SRR1424692     4  0.0671      0.838 0.000 0.016 0.004 0.980 0.000
#> SRR1424684     2  0.2074      0.785 0.000 0.896 0.000 0.000 0.104
#> SRR1424693     5  0.4283      0.659 0.292 0.004 0.012 0.000 0.692
#> SRR1424694     4  0.0968      0.838 0.000 0.012 0.004 0.972 0.012
#> SRR1424695     5  0.5401      0.463 0.428 0.040 0.008 0.000 0.524
#> SRR1424696     2  0.2871      0.770 0.000 0.872 0.000 0.088 0.040
#> SRR1424697     3  0.5415      0.609 0.000 0.012 0.624 0.308 0.056
#> SRR1424698     3  0.2522      0.737 0.000 0.000 0.880 0.012 0.108
#> SRR1424699     2  0.5159      0.616 0.000 0.640 0.300 0.004 0.056
#> SRR1424700     2  0.5613      0.573 0.000 0.592 0.308 0.000 0.100
#> SRR1424701     3  0.3551      0.651 0.000 0.044 0.820 0.000 0.136
#> SRR1424702     3  0.3652      0.733 0.004 0.000 0.784 0.012 0.200
#> SRR1424703     3  0.2522      0.737 0.000 0.000 0.880 0.012 0.108
#> SRR1424704     3  0.3618      0.733 0.004 0.000 0.788 0.012 0.196
#> SRR1424706     3  0.4786      0.522 0.000 0.012 0.620 0.356 0.012
#> SRR1424707     3  0.3556      0.744 0.004 0.004 0.808 0.012 0.172

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR1424656     1  0.0146     0.5446 0.996 0.000 0.000 0.000 0.000 0.004
#> SRR1424657     1  0.1908     0.5337 0.916 0.000 0.000 0.000 0.028 0.056
#> SRR1424658     1  0.1856     0.4967 0.920 0.000 0.000 0.000 0.048 0.032
#> SRR1424659     1  0.1349     0.5211 0.940 0.000 0.000 0.000 0.004 0.056
#> SRR1424660     1  0.5010     0.2922 0.668 0.000 0.008 0.000 0.156 0.168
#> SRR1424661     4  0.1949     0.8406 0.000 0.020 0.020 0.924 0.000 0.036
#> SRR1424662     1  0.6392    -0.4031 0.416 0.020 0.008 0.164 0.000 0.392
#> SRR1424663     1  0.4923     0.3032 0.656 0.000 0.000 0.000 0.176 0.168
#> SRR1424664     1  0.1462     0.5165 0.936 0.000 0.000 0.000 0.008 0.056
#> SRR1424665     1  0.1168     0.5314 0.956 0.000 0.000 0.000 0.028 0.016
#> SRR1424666     6  0.6950     0.1603 0.368 0.004 0.100 0.000 0.124 0.404
#> SRR1424667     2  0.5051     0.4246 0.000 0.520 0.008 0.056 0.000 0.416
#> SRR1424668     1  0.7384    -0.0737 0.444 0.012 0.120 0.000 0.236 0.188
#> SRR1424669     6  0.4361     0.2102 0.436 0.004 0.000 0.000 0.016 0.544
#> SRR1424670     1  0.2261     0.4988 0.884 0.004 0.000 0.000 0.008 0.104
#> SRR1424671     4  0.3730     0.7994 0.000 0.020 0.028 0.824 0.028 0.100
#> SRR1424672     5  0.7402     0.1988 0.188 0.012 0.144 0.000 0.456 0.200
#> SRR1424674     1  0.4814     0.3639 0.696 0.012 0.000 0.000 0.120 0.172
#> SRR1424673     3  0.7114     0.4293 0.000 0.020 0.480 0.228 0.068 0.204
#> SRR1424675     2  0.2512     0.6937 0.000 0.868 0.000 0.008 0.008 0.116
#> SRR1424676     2  0.4136     0.2587 0.000 0.560 0.000 0.000 0.428 0.012
#> SRR1424677     4  0.1232     0.8491 0.000 0.004 0.016 0.956 0.000 0.024
#> SRR1424678     2  0.1075     0.7090 0.000 0.952 0.000 0.048 0.000 0.000
#> SRR1424679     2  0.1075     0.7139 0.000 0.952 0.000 0.000 0.048 0.000
#> SRR1424680     4  0.4583     0.5205 0.000 0.288 0.000 0.660 0.032 0.020
#> SRR1424681     5  0.5272     0.5280 0.080 0.000 0.116 0.000 0.696 0.108
#> SRR1424682     3  0.5300     0.5971 0.000 0.004 0.652 0.240 0.044 0.060
#> SRR1424683     4  0.0551     0.8595 0.000 0.004 0.000 0.984 0.004 0.008
#> SRR1424685     5  0.4278     0.5944 0.076 0.000 0.060 0.000 0.780 0.084
#> SRR1424686     5  0.7059     0.2464 0.196 0.000 0.152 0.000 0.476 0.176
#> SRR1424687     4  0.4449     0.6766 0.000 0.004 0.008 0.712 0.056 0.220
#> SRR1424688     5  0.3472     0.6440 0.160 0.012 0.004 0.000 0.804 0.020
#> SRR1424689     5  0.5696     0.4906 0.188 0.028 0.004 0.000 0.624 0.156
#> SRR1424690     5  0.2982     0.6605 0.164 0.000 0.004 0.000 0.820 0.012
#> SRR1424691     5  0.2487     0.6631 0.092 0.000 0.032 0.000 0.876 0.000
#> SRR1424692     4  0.0520     0.8597 0.000 0.008 0.000 0.984 0.000 0.008
#> SRR1424684     2  0.1267     0.7121 0.000 0.940 0.000 0.000 0.060 0.000
#> SRR1424693     5  0.3194     0.6622 0.144 0.004 0.004 0.000 0.824 0.024
#> SRR1424694     4  0.1321     0.8543 0.000 0.004 0.000 0.952 0.020 0.024
#> SRR1424695     5  0.4823     0.5471 0.220 0.020 0.004 0.000 0.692 0.064
#> SRR1424696     2  0.3406     0.6617 0.000 0.832 0.000 0.100 0.044 0.024
#> SRR1424697     3  0.4509     0.6029 0.000 0.004 0.688 0.260 0.020 0.028
#> SRR1424698     3  0.3233     0.6834 0.000 0.004 0.832 0.000 0.060 0.104
#> SRR1424699     2  0.5907     0.4858 0.000 0.532 0.260 0.000 0.012 0.196
#> SRR1424700     2  0.6199     0.4515 0.000 0.496 0.264 0.000 0.020 0.220
#> SRR1424701     3  0.4669     0.5482 0.000 0.028 0.700 0.000 0.052 0.220
#> SRR1424702     3  0.2696     0.7019 0.000 0.000 0.856 0.000 0.116 0.028
#> SRR1424703     3  0.3127     0.6869 0.000 0.004 0.840 0.000 0.056 0.100
#> SRR1424704     3  0.2740     0.7012 0.000 0.000 0.852 0.000 0.120 0.028
#> SRR1424706     3  0.4615     0.4886 0.000 0.004 0.612 0.340 0.000 0.044
#> SRR1424707     3  0.1663     0.7138 0.000 0.000 0.912 0.000 0.088 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 16960 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 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-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.550           0.817       0.917         0.5006 0.500   0.500
#> 3 3 0.500           0.674       0.828         0.3359 0.802   0.621
#> 4 4 0.606           0.588       0.810         0.1275 0.837   0.576
#> 5 5 0.771           0.781       0.884         0.0663 0.907   0.661
#> 6 6 0.776           0.684       0.822         0.0463 0.925   0.649

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
#> SRR1424656     1   0.000      0.908 1.000 0.000
#> SRR1424657     1   0.000      0.908 1.000 0.000
#> SRR1424658     1   0.958      0.469 0.620 0.380
#> SRR1424659     1   0.000      0.908 1.000 0.000
#> SRR1424660     1   0.000      0.908 1.000 0.000
#> SRR1424661     2   0.904      0.585 0.320 0.680
#> SRR1424662     2   0.000      0.888 0.000 1.000
#> SRR1424663     1   0.000      0.908 1.000 0.000
#> SRR1424664     1   0.000      0.908 1.000 0.000
#> SRR1424665     1   0.722      0.743 0.800 0.200
#> SRR1424666     1   0.000      0.908 1.000 0.000
#> SRR1424667     2   0.000      0.888 0.000 1.000
#> SRR1424668     1   0.000      0.908 1.000 0.000
#> SRR1424669     1   0.625      0.786 0.844 0.156
#> SRR1424670     1   0.000      0.908 1.000 0.000
#> SRR1424671     2   0.000      0.888 0.000 1.000
#> SRR1424672     1   0.000      0.908 1.000 0.000
#> SRR1424674     1   0.000      0.908 1.000 0.000
#> SRR1424673     2   0.958      0.489 0.380 0.620
#> SRR1424675     2   0.000      0.888 0.000 1.000
#> SRR1424676     2   0.671      0.716 0.176 0.824
#> SRR1424677     2   0.000      0.888 0.000 1.000
#> SRR1424678     2   0.000      0.888 0.000 1.000
#> SRR1424679     2   0.000      0.888 0.000 1.000
#> SRR1424680     2   0.000      0.888 0.000 1.000
#> SRR1424681     1   0.000      0.908 1.000 0.000
#> SRR1424682     2   0.958      0.489 0.380 0.620
#> SRR1424683     2   0.000      0.888 0.000 1.000
#> SRR1424685     1   0.118      0.897 0.984 0.016
#> SRR1424686     1   0.000      0.908 1.000 0.000
#> SRR1424687     2   0.000      0.888 0.000 1.000
#> SRR1424688     1   0.821      0.672 0.744 0.256
#> SRR1424689     1   0.904      0.581 0.680 0.320
#> SRR1424690     1   0.000      0.908 1.000 0.000
#> SRR1424691     1   0.000      0.908 1.000 0.000
#> SRR1424692     2   0.000      0.888 0.000 1.000
#> SRR1424684     2   0.000      0.888 0.000 1.000
#> SRR1424693     1   0.714      0.747 0.804 0.196
#> SRR1424694     2   0.000      0.888 0.000 1.000
#> SRR1424695     1   0.958      0.469 0.620 0.380
#> SRR1424696     2   0.000      0.888 0.000 1.000
#> SRR1424697     2   0.958      0.489 0.380 0.620
#> SRR1424698     1   0.343      0.857 0.936 0.064
#> SRR1424699     2   0.000      0.888 0.000 1.000
#> SRR1424700     2   0.722      0.681 0.200 0.800
#> SRR1424701     1   0.775      0.708 0.772 0.228
#> SRR1424702     1   0.000      0.908 1.000 0.000
#> SRR1424703     1   0.000      0.908 1.000 0.000
#> SRR1424704     1   0.000      0.908 1.000 0.000
#> SRR1424706     2   0.714      0.728 0.196 0.804
#> SRR1424707     1   0.000      0.908 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
#> SRR1424656     1   0.000     0.7753 1.000 0.000 0.000
#> SRR1424657     1   0.000     0.7753 1.000 0.000 0.000
#> SRR1424658     1   0.466     0.7119 0.856 0.076 0.068
#> SRR1424659     1   0.000     0.7753 1.000 0.000 0.000
#> SRR1424660     1   0.480     0.6728 0.780 0.000 0.220
#> SRR1424661     2   0.445     0.6618 0.000 0.808 0.192
#> SRR1424662     2   0.341     0.7186 0.124 0.876 0.000
#> SRR1424663     1   0.000     0.7753 1.000 0.000 0.000
#> SRR1424664     1   0.000     0.7753 1.000 0.000 0.000
#> SRR1424665     1   0.253     0.7549 0.936 0.020 0.044
#> SRR1424666     1   0.502     0.6549 0.760 0.000 0.240
#> SRR1424667     2   0.153     0.7869 0.000 0.960 0.040
#> SRR1424668     1   0.502     0.6549 0.760 0.000 0.240
#> SRR1424669     1   0.699     0.6364 0.724 0.180 0.096
#> SRR1424670     1   0.000     0.7753 1.000 0.000 0.000
#> SRR1424671     2   0.465     0.6420 0.000 0.792 0.208
#> SRR1424672     1   0.514     0.6471 0.748 0.000 0.252
#> SRR1424674     1   0.000     0.7753 1.000 0.000 0.000
#> SRR1424673     3   0.597     0.4992 0.000 0.364 0.636
#> SRR1424675     2   0.245     0.7791 0.000 0.924 0.076
#> SRR1424676     2   0.540     0.5821 0.000 0.720 0.280
#> SRR1424677     2   0.254     0.7771 0.000 0.920 0.080
#> SRR1424678     2   0.236     0.7810 0.000 0.928 0.072
#> SRR1424679     2   0.536     0.5873 0.000 0.724 0.276
#> SRR1424680     2   0.000     0.7874 0.000 1.000 0.000
#> SRR1424681     1   0.627     0.4979 0.548 0.000 0.452
#> SRR1424682     3   0.536     0.6296 0.000 0.276 0.724
#> SRR1424683     2   0.254     0.7771 0.000 0.920 0.080
#> SRR1424685     1   0.623     0.5213 0.564 0.000 0.436
#> SRR1424686     1   0.590     0.5966 0.648 0.000 0.352
#> SRR1424687     2   0.254     0.7771 0.000 0.920 0.080
#> SRR1424688     1   0.580     0.6835 0.736 0.016 0.248
#> SRR1424689     1   0.787     0.5944 0.632 0.092 0.276
#> SRR1424690     1   0.470     0.7109 0.788 0.000 0.212
#> SRR1424691     1   0.470     0.7106 0.788 0.000 0.212
#> SRR1424692     2   0.254     0.7771 0.000 0.920 0.080
#> SRR1424684     2   0.497     0.6402 0.000 0.764 0.236
#> SRR1424693     1   0.554     0.6863 0.740 0.008 0.252
#> SRR1424694     2   0.475     0.7402 0.068 0.852 0.080
#> SRR1424695     1   0.826     0.5653 0.608 0.116 0.276
#> SRR1424696     2   0.236     0.7810 0.000 0.928 0.072
#> SRR1424697     3   0.540     0.6261 0.000 0.280 0.720
#> SRR1424698     3   0.000     0.7363 0.000 0.000 1.000
#> SRR1424699     2   0.627     0.0822 0.000 0.548 0.452
#> SRR1424700     3   0.590     0.2166 0.000 0.352 0.648
#> SRR1424701     3   0.254     0.6777 0.000 0.080 0.920
#> SRR1424702     3   0.245     0.7337 0.076 0.000 0.924
#> SRR1424703     3   0.164     0.7415 0.044 0.000 0.956
#> SRR1424704     3   0.245     0.7337 0.076 0.000 0.924
#> SRR1424706     3   0.543     0.6214 0.000 0.284 0.716
#> SRR1424707     3   0.245     0.7337 0.076 0.000 0.924

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1424656     1  0.0000     0.7033 1.000 0.000 0.000 0.000
#> SRR1424657     1  0.0000     0.7033 1.000 0.000 0.000 0.000
#> SRR1424658     1  0.3726     0.5308 0.788 0.212 0.000 0.000
#> SRR1424659     1  0.0000     0.7033 1.000 0.000 0.000 0.000
#> SRR1424660     1  0.3688     0.5727 0.792 0.000 0.208 0.000
#> SRR1424661     4  0.0000     0.9682 0.000 0.000 0.000 1.000
#> SRR1424662     4  0.3311     0.7423 0.172 0.000 0.000 0.828
#> SRR1424663     1  0.0000     0.7033 1.000 0.000 0.000 0.000
#> SRR1424664     1  0.0000     0.7033 1.000 0.000 0.000 0.000
#> SRR1424665     1  0.1302     0.6861 0.956 0.044 0.000 0.000
#> SRR1424666     1  0.4406     0.4712 0.700 0.000 0.300 0.000
#> SRR1424667     2  0.4543     0.6089 0.000 0.676 0.000 0.324
#> SRR1424668     1  0.4040     0.5416 0.752 0.000 0.248 0.000
#> SRR1424669     1  0.4888     0.1997 0.588 0.412 0.000 0.000
#> SRR1424670     1  0.0000     0.7033 1.000 0.000 0.000 0.000
#> SRR1424671     4  0.0000     0.9682 0.000 0.000 0.000 1.000
#> SRR1424672     1  0.4985     0.2769 0.532 0.000 0.468 0.000
#> SRR1424674     1  0.0000     0.7033 1.000 0.000 0.000 0.000
#> SRR1424673     3  0.4989     0.1991 0.000 0.000 0.528 0.472
#> SRR1424675     2  0.4304     0.6637 0.000 0.716 0.000 0.284
#> SRR1424676     2  0.0000     0.7312 0.000 1.000 0.000 0.000
#> SRR1424677     4  0.0000     0.9682 0.000 0.000 0.000 1.000
#> SRR1424678     2  0.4304     0.6637 0.000 0.716 0.000 0.284
#> SRR1424679     2  0.0000     0.7312 0.000 1.000 0.000 0.000
#> SRR1424680     4  0.0336     0.9604 0.000 0.008 0.000 0.992
#> SRR1424681     3  0.7636     0.0349 0.248 0.284 0.468 0.000
#> SRR1424682     3  0.4543     0.4691 0.000 0.000 0.676 0.324
#> SRR1424683     4  0.0000     0.9682 0.000 0.000 0.000 1.000
#> SRR1424685     3  0.7803     0.0327 0.248 0.284 0.464 0.004
#> SRR1424686     1  0.4985     0.2769 0.532 0.000 0.468 0.000
#> SRR1424687     4  0.0000     0.9682 0.000 0.000 0.000 1.000
#> SRR1424688     1  0.7523     0.2709 0.416 0.400 0.184 0.000
#> SRR1424689     2  0.0000     0.7312 0.000 1.000 0.000 0.000
#> SRR1424690     1  0.7265     0.3756 0.528 0.288 0.184 0.000
#> SRR1424691     1  0.7390     0.3551 0.512 0.284 0.204 0.000
#> SRR1424692     4  0.0000     0.9682 0.000 0.000 0.000 1.000
#> SRR1424684     2  0.0000     0.7312 0.000 1.000 0.000 0.000
#> SRR1424693     1  0.7523     0.2640 0.412 0.404 0.184 0.000
#> SRR1424694     4  0.0000     0.9682 0.000 0.000 0.000 1.000
#> SRR1424695     2  0.3764     0.4747 0.216 0.784 0.000 0.000
#> SRR1424696     2  0.4304     0.6637 0.000 0.716 0.000 0.284
#> SRR1424697     3  0.4008     0.5470 0.000 0.000 0.756 0.244
#> SRR1424698     3  0.0000     0.6603 0.000 0.000 1.000 0.000
#> SRR1424699     2  0.4304     0.5973 0.000 0.716 0.284 0.000
#> SRR1424700     2  0.4304     0.5973 0.000 0.716 0.284 0.000
#> SRR1424701     3  0.4985    -0.2039 0.000 0.468 0.532 0.000
#> SRR1424702     3  0.0000     0.6603 0.000 0.000 1.000 0.000
#> SRR1424703     3  0.0000     0.6603 0.000 0.000 1.000 0.000
#> SRR1424704     3  0.0000     0.6603 0.000 0.000 1.000 0.000
#> SRR1424706     3  0.4992     0.1803 0.000 0.000 0.524 0.476
#> SRR1424707     3  0.0000     0.6603 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
#> SRR1424656     1  0.0000     0.8573 1.000 0.000 0.000 0.000 0.000
#> SRR1424657     1  0.0000     0.8573 1.000 0.000 0.000 0.000 0.000
#> SRR1424658     1  0.2554     0.8000 0.892 0.036 0.000 0.000 0.072
#> SRR1424659     1  0.0324     0.8582 0.992 0.004 0.000 0.000 0.004
#> SRR1424660     1  0.0880     0.8547 0.968 0.000 0.000 0.000 0.032
#> SRR1424661     4  0.0000     0.9484 0.000 0.000 0.000 1.000 0.000
#> SRR1424662     4  0.4552     0.6353 0.240 0.040 0.000 0.716 0.004
#> SRR1424663     1  0.1410     0.8499 0.940 0.000 0.000 0.000 0.060
#> SRR1424664     1  0.0162     0.8575 0.996 0.004 0.000 0.000 0.000
#> SRR1424665     1  0.1282     0.8383 0.952 0.004 0.000 0.000 0.044
#> SRR1424666     1  0.4063     0.7921 0.820 0.044 0.096 0.000 0.040
#> SRR1424667     2  0.3048     0.7370 0.000 0.820 0.000 0.176 0.004
#> SRR1424668     1  0.4510     0.7432 0.756 0.004 0.076 0.000 0.164
#> SRR1424669     1  0.3462     0.7341 0.792 0.196 0.000 0.000 0.012
#> SRR1424670     1  0.0324     0.8582 0.992 0.004 0.000 0.000 0.004
#> SRR1424671     4  0.0000     0.9484 0.000 0.000 0.000 1.000 0.000
#> SRR1424672     1  0.6075     0.4568 0.544 0.004 0.124 0.000 0.328
#> SRR1424674     1  0.2806     0.7784 0.844 0.004 0.000 0.000 0.152
#> SRR1424673     3  0.5217     0.5056 0.000 0.044 0.588 0.364 0.004
#> SRR1424675     2  0.0324     0.8462 0.000 0.992 0.004 0.004 0.000
#> SRR1424676     2  0.2929     0.7287 0.000 0.820 0.000 0.000 0.180
#> SRR1424677     4  0.0000     0.9484 0.000 0.000 0.000 1.000 0.000
#> SRR1424678     2  0.1597     0.8497 0.000 0.940 0.000 0.048 0.012
#> SRR1424679     2  0.1410     0.8457 0.000 0.940 0.000 0.000 0.060
#> SRR1424680     4  0.1522     0.9011 0.000 0.044 0.000 0.944 0.012
#> SRR1424681     5  0.3297     0.7455 0.084 0.000 0.068 0.000 0.848
#> SRR1424682     3  0.3783     0.7245 0.000 0.000 0.740 0.252 0.008
#> SRR1424683     4  0.0000     0.9484 0.000 0.000 0.000 1.000 0.000
#> SRR1424685     5  0.2409     0.7925 0.056 0.000 0.028 0.008 0.908
#> SRR1424686     1  0.6186     0.3802 0.512 0.004 0.128 0.000 0.356
#> SRR1424687     4  0.0290     0.9442 0.000 0.000 0.000 0.992 0.008
#> SRR1424688     5  0.1412     0.8191 0.036 0.008 0.000 0.004 0.952
#> SRR1424689     5  0.4555     0.0393 0.008 0.472 0.000 0.000 0.520
#> SRR1424690     5  0.1124     0.8256 0.036 0.004 0.000 0.000 0.960
#> SRR1424691     5  0.0865     0.8249 0.024 0.000 0.004 0.000 0.972
#> SRR1424692     4  0.0000     0.9484 0.000 0.000 0.000 1.000 0.000
#> SRR1424684     2  0.1410     0.8457 0.000 0.940 0.000 0.000 0.060
#> SRR1424693     5  0.0912     0.8233 0.016 0.012 0.000 0.000 0.972
#> SRR1424694     4  0.0000     0.9484 0.000 0.000 0.000 1.000 0.000
#> SRR1424695     5  0.4080     0.5634 0.020 0.252 0.000 0.000 0.728
#> SRR1424696     2  0.2189     0.8385 0.000 0.904 0.000 0.084 0.012
#> SRR1424697     3  0.3336     0.7458 0.000 0.000 0.772 0.228 0.000
#> SRR1424698     3  0.0000     0.8304 0.000 0.000 1.000 0.000 0.000
#> SRR1424699     2  0.3305     0.7576 0.000 0.776 0.224 0.000 0.000
#> SRR1424700     2  0.3424     0.7437 0.000 0.760 0.240 0.000 0.000
#> SRR1424701     3  0.2424     0.6998 0.000 0.132 0.868 0.000 0.000
#> SRR1424702     3  0.0290     0.8306 0.000 0.000 0.992 0.000 0.008
#> SRR1424703     3  0.0000     0.8304 0.000 0.000 1.000 0.000 0.000
#> SRR1424704     3  0.0290     0.8306 0.000 0.000 0.992 0.000 0.008
#> SRR1424706     3  0.3612     0.7108 0.000 0.000 0.732 0.268 0.000
#> SRR1424707     3  0.0162     0.8309 0.000 0.000 0.996 0.000 0.004

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR1424656     1  0.3515     0.6109 0.676 0.000 0.000 0.000 0.000 0.324
#> SRR1424657     1  0.3823     0.4344 0.564 0.000 0.000 0.000 0.000 0.436
#> SRR1424658     1  0.3708     0.6636 0.752 0.020 0.000 0.000 0.008 0.220
#> SRR1424659     1  0.2491     0.6787 0.836 0.000 0.000 0.000 0.000 0.164
#> SRR1424660     6  0.3151     0.3516 0.252 0.000 0.000 0.000 0.000 0.748
#> SRR1424661     4  0.0260     0.9556 0.000 0.008 0.000 0.992 0.000 0.000
#> SRR1424662     1  0.4843     0.2923 0.608 0.016 0.000 0.340 0.004 0.032
#> SRR1424663     6  0.3076     0.3819 0.240 0.000 0.000 0.000 0.000 0.760
#> SRR1424664     1  0.2048     0.6772 0.880 0.000 0.000 0.000 0.000 0.120
#> SRR1424665     1  0.3584     0.6243 0.688 0.000 0.000 0.000 0.004 0.308
#> SRR1424666     1  0.4189    -0.1121 0.552 0.008 0.004 0.000 0.000 0.436
#> SRR1424667     2  0.4168     0.7608 0.128 0.764 0.000 0.096 0.000 0.012
#> SRR1424668     6  0.2020     0.5116 0.096 0.000 0.008 0.000 0.000 0.896
#> SRR1424669     1  0.2265     0.5404 0.896 0.024 0.000 0.000 0.004 0.076
#> SRR1424670     1  0.2278     0.6725 0.868 0.004 0.000 0.000 0.000 0.128
#> SRR1424671     4  0.0520     0.9510 0.000 0.008 0.000 0.984 0.000 0.008
#> SRR1424672     6  0.2230     0.5540 0.016 0.000 0.016 0.000 0.064 0.904
#> SRR1424674     6  0.3741     0.2136 0.320 0.000 0.000 0.000 0.008 0.672
#> SRR1424673     3  0.6230     0.3621 0.020 0.008 0.464 0.368 0.000 0.140
#> SRR1424675     2  0.1594     0.8468 0.052 0.932 0.000 0.000 0.000 0.016
#> SRR1424676     2  0.2263     0.8003 0.000 0.884 0.000 0.000 0.100 0.016
#> SRR1424677     4  0.0000     0.9583 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1424678     2  0.0717     0.8555 0.000 0.976 0.000 0.016 0.008 0.000
#> SRR1424679     2  0.0632     0.8548 0.000 0.976 0.000 0.000 0.024 0.000
#> SRR1424680     4  0.2915     0.7573 0.000 0.184 0.000 0.808 0.008 0.000
#> SRR1424681     6  0.4673     0.1666 0.004 0.016 0.012 0.000 0.428 0.540
#> SRR1424682     3  0.4926     0.6656 0.000 0.000 0.640 0.240 0.000 0.120
#> SRR1424683     4  0.0000     0.9583 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1424685     6  0.4661     0.0674 0.000 0.032 0.004 0.000 0.464 0.500
#> SRR1424686     6  0.4240     0.5390 0.068 0.000 0.016 0.000 0.164 0.752
#> SRR1424687     4  0.1082     0.9321 0.040 0.000 0.000 0.956 0.004 0.000
#> SRR1424688     5  0.0405     0.9102 0.004 0.008 0.000 0.000 0.988 0.000
#> SRR1424689     5  0.4593     0.6836 0.176 0.096 0.000 0.000 0.716 0.012
#> SRR1424690     5  0.0405     0.9089 0.008 0.000 0.000 0.000 0.988 0.004
#> SRR1424691     5  0.0363     0.9061 0.000 0.000 0.000 0.000 0.988 0.012
#> SRR1424692     4  0.0000     0.9583 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1424684     2  0.0632     0.8548 0.000 0.976 0.000 0.000 0.024 0.000
#> SRR1424693     5  0.0000     0.9109 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1424694     4  0.0000     0.9583 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1424695     5  0.2007     0.8743 0.044 0.036 0.000 0.000 0.916 0.004
#> SRR1424696     2  0.1701     0.8389 0.000 0.920 0.000 0.072 0.008 0.000
#> SRR1424697     3  0.3189     0.7177 0.000 0.000 0.760 0.236 0.000 0.004
#> SRR1424698     3  0.0000     0.8079 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1424699     2  0.4180     0.6861 0.024 0.680 0.288 0.000 0.000 0.008
#> SRR1424700     2  0.4274     0.6833 0.024 0.676 0.288 0.000 0.000 0.012
#> SRR1424701     3  0.1794     0.7675 0.024 0.028 0.932 0.000 0.000 0.016
#> SRR1424702     3  0.1327     0.8055 0.000 0.000 0.936 0.000 0.000 0.064
#> SRR1424703     3  0.0000     0.8079 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1424704     3  0.1556     0.7992 0.000 0.000 0.920 0.000 0.000 0.080
#> SRR1424706     3  0.3405     0.6837 0.000 0.000 0.724 0.272 0.000 0.004
#> SRR1424707     3  0.0547     0.8113 0.000 0.000 0.980 0.000 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-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 16960 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 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-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.299           0.769       0.841         0.4845 0.492   0.492
#> 3 3 0.549           0.700       0.858         0.3802 0.591   0.331
#> 4 4 0.643           0.598       0.823         0.1203 0.875   0.651
#> 5 5 0.775           0.733       0.889         0.0681 0.888   0.616
#> 6 6 0.793           0.689       0.829         0.0455 0.907   0.595

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
#> SRR1424656     2  0.0000      0.848 0.000 1.000
#> SRR1424657     2  0.0000      0.848 0.000 1.000
#> SRR1424658     2  0.0000      0.848 0.000 1.000
#> SRR1424659     2  0.0000      0.848 0.000 1.000
#> SRR1424660     1  0.9460      0.768 0.636 0.364
#> SRR1424661     1  0.7219      0.827 0.800 0.200
#> SRR1424662     2  0.6438      0.730 0.164 0.836
#> SRR1424663     1  0.9491      0.766 0.632 0.368
#> SRR1424664     2  0.0000      0.848 0.000 1.000
#> SRR1424665     2  0.0000      0.848 0.000 1.000
#> SRR1424666     1  0.9491      0.766 0.632 0.368
#> SRR1424667     2  0.9460      0.642 0.364 0.636
#> SRR1424668     1  0.9491      0.766 0.632 0.368
#> SRR1424669     2  0.0000      0.848 0.000 1.000
#> SRR1424670     2  0.0000      0.848 0.000 1.000
#> SRR1424671     1  0.0000      0.696 1.000 0.000
#> SRR1424672     1  0.9491      0.766 0.632 0.368
#> SRR1424674     2  0.0000      0.848 0.000 1.000
#> SRR1424673     1  0.7528      0.828 0.784 0.216
#> SRR1424675     2  0.7453      0.771 0.212 0.788
#> SRR1424676     2  0.7528      0.770 0.216 0.784
#> SRR1424677     1  0.0000      0.696 1.000 0.000
#> SRR1424678     2  0.7602      0.768 0.220 0.780
#> SRR1424679     2  0.7453      0.771 0.212 0.788
#> SRR1424680     2  0.9491      0.639 0.368 0.632
#> SRR1424681     1  0.9460      0.768 0.636 0.364
#> SRR1424682     1  0.6531      0.818 0.832 0.168
#> SRR1424683     1  0.7602      0.408 0.780 0.220
#> SRR1424685     1  0.9896      0.664 0.560 0.440
#> SRR1424686     1  0.9460      0.768 0.636 0.364
#> SRR1424687     2  0.7219      0.720 0.200 0.800
#> SRR1424688     2  0.2778      0.841 0.048 0.952
#> SRR1424689     2  0.0000      0.848 0.000 1.000
#> SRR1424690     2  0.0000      0.848 0.000 1.000
#> SRR1424691     2  0.0376      0.846 0.004 0.996
#> SRR1424692     1  0.8081      0.339 0.752 0.248
#> SRR1424684     2  0.7453      0.771 0.212 0.788
#> SRR1424693     2  0.2603      0.842 0.044 0.956
#> SRR1424694     2  0.7219      0.720 0.200 0.800
#> SRR1424695     2  0.2603      0.842 0.044 0.956
#> SRR1424696     2  0.7602      0.768 0.220 0.780
#> SRR1424697     1  0.6531      0.818 0.832 0.168
#> SRR1424698     1  0.7674      0.828 0.776 0.224
#> SRR1424699     1  0.0000      0.696 1.000 0.000
#> SRR1424700     2  0.8144      0.524 0.252 0.748
#> SRR1424701     1  0.7453      0.820 0.788 0.212
#> SRR1424702     1  0.7453      0.828 0.788 0.212
#> SRR1424703     1  0.7453      0.828 0.788 0.212
#> SRR1424704     1  0.7453      0.828 0.788 0.212
#> SRR1424706     1  0.6531      0.818 0.832 0.168
#> SRR1424707     1  0.7453      0.828 0.788 0.212

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1424656     1  0.0000     0.9135 1.000 0.000 0.000
#> SRR1424657     1  0.0000     0.9135 1.000 0.000 0.000
#> SRR1424658     1  0.0000     0.9135 1.000 0.000 0.000
#> SRR1424659     1  0.0000     0.9135 1.000 0.000 0.000
#> SRR1424660     3  0.4346     0.7197 0.184 0.000 0.816
#> SRR1424661     2  0.9811     0.3325 0.244 0.404 0.352
#> SRR1424662     1  0.0237     0.9109 0.996 0.004 0.000
#> SRR1424663     1  0.0237     0.9110 0.996 0.000 0.004
#> SRR1424664     1  0.0000     0.9135 1.000 0.000 0.000
#> SRR1424665     1  0.0000     0.9135 1.000 0.000 0.000
#> SRR1424666     1  0.0000     0.9135 1.000 0.000 0.000
#> SRR1424667     2  0.4099     0.7002 0.008 0.852 0.140
#> SRR1424668     1  0.0237     0.9110 0.996 0.000 0.004
#> SRR1424669     1  0.0000     0.9135 1.000 0.000 0.000
#> SRR1424670     1  0.0000     0.9135 1.000 0.000 0.000
#> SRR1424671     3  0.5968     0.2308 0.000 0.364 0.636
#> SRR1424672     1  0.4555     0.6699 0.800 0.000 0.200
#> SRR1424674     1  0.0000     0.9135 1.000 0.000 0.000
#> SRR1424673     3  0.4555     0.6547 0.200 0.000 0.800
#> SRR1424675     2  0.2537     0.7159 0.080 0.920 0.000
#> SRR1424676     2  0.0237     0.7281 0.004 0.996 0.000
#> SRR1424677     2  0.3816     0.6976 0.000 0.852 0.148
#> SRR1424678     2  0.0237     0.7281 0.004 0.996 0.000
#> SRR1424679     2  0.0237     0.7281 0.004 0.996 0.000
#> SRR1424680     2  0.3816     0.6976 0.000 0.852 0.148
#> SRR1424681     3  0.4539     0.7569 0.016 0.148 0.836
#> SRR1424682     3  0.0237     0.7997 0.000 0.004 0.996
#> SRR1424683     2  0.9032     0.4944 0.340 0.512 0.148
#> SRR1424685     1  0.3879     0.8084 0.848 0.152 0.000
#> SRR1424686     3  0.4790     0.7681 0.096 0.056 0.848
#> SRR1424687     3  0.7289    -0.1785 0.028 0.468 0.504
#> SRR1424688     2  0.5882     0.4368 0.348 0.652 0.000
#> SRR1424689     1  0.3816     0.8120 0.852 0.148 0.000
#> SRR1424690     1  0.3816     0.8120 0.852 0.148 0.000
#> SRR1424691     1  0.4047     0.8094 0.848 0.148 0.004
#> SRR1424692     2  0.3816     0.6976 0.000 0.852 0.148
#> SRR1424684     2  0.0237     0.7281 0.004 0.996 0.000
#> SRR1424693     1  0.6299     0.0373 0.524 0.476 0.000
#> SRR1424694     2  0.9047     0.4876 0.344 0.508 0.148
#> SRR1424695     2  0.5882     0.4368 0.348 0.652 0.000
#> SRR1424696     2  0.0237     0.7281 0.004 0.996 0.000
#> SRR1424697     3  0.0000     0.7979 0.000 0.000 1.000
#> SRR1424698     3  0.3816     0.7607 0.000 0.148 0.852
#> SRR1424699     2  0.6307     0.0582 0.000 0.512 0.488
#> SRR1424700     3  0.6008     0.4687 0.000 0.372 0.628
#> SRR1424701     3  0.0237     0.7997 0.000 0.004 0.996
#> SRR1424702     3  0.0237     0.7997 0.000 0.004 0.996
#> SRR1424703     3  0.3816     0.7607 0.000 0.148 0.852
#> SRR1424704     3  0.4749     0.7732 0.072 0.076 0.852
#> SRR1424706     3  0.0000     0.7979 0.000 0.000 1.000
#> SRR1424707     3  0.0237     0.7997 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
#> SRR1424656     1  0.0000     0.6876 1.000 0.000 0.000 0.000
#> SRR1424657     1  0.4898    -0.0417 0.584 0.000 0.000 0.416
#> SRR1424658     1  0.0000     0.6876 1.000 0.000 0.000 0.000
#> SRR1424659     1  0.0188     0.6872 0.996 0.000 0.000 0.004
#> SRR1424660     3  0.4866     0.3592 0.404 0.000 0.596 0.000
#> SRR1424661     4  0.5244     0.3545 0.372 0.008 0.004 0.616
#> SRR1424662     1  0.0000     0.6876 1.000 0.000 0.000 0.000
#> SRR1424663     1  0.0000     0.6876 1.000 0.000 0.000 0.000
#> SRR1424664     1  0.0000     0.6876 1.000 0.000 0.000 0.000
#> SRR1424665     1  0.0000     0.6876 1.000 0.000 0.000 0.000
#> SRR1424666     1  0.4776     0.2537 0.624 0.000 0.376 0.000
#> SRR1424667     2  0.3610     0.7148 0.000 0.800 0.000 0.200
#> SRR1424668     1  0.0895     0.6795 0.976 0.000 0.020 0.004
#> SRR1424669     1  0.4088     0.5081 0.764 0.000 0.232 0.004
#> SRR1424670     1  0.0188     0.6872 0.996 0.000 0.000 0.004
#> SRR1424671     4  0.6587     0.3579 0.000 0.132 0.252 0.616
#> SRR1424672     3  0.4967     0.1943 0.452 0.000 0.548 0.000
#> SRR1424674     1  0.0000     0.6876 1.000 0.000 0.000 0.000
#> SRR1424673     3  0.4661     0.4562 0.348 0.000 0.652 0.000
#> SRR1424675     2  0.3569     0.6403 0.196 0.804 0.000 0.000
#> SRR1424676     2  0.0336     0.7691 0.000 0.992 0.000 0.008
#> SRR1424677     2  0.3610     0.7148 0.000 0.800 0.000 0.200
#> SRR1424678     2  0.0000     0.7759 0.000 1.000 0.000 0.000
#> SRR1424679     2  0.0000     0.7759 0.000 1.000 0.000 0.000
#> SRR1424680     2  0.4697     0.4958 0.000 0.644 0.000 0.356
#> SRR1424681     3  0.4387     0.6383 0.000 0.200 0.776 0.024
#> SRR1424682     3  0.0000     0.8554 0.000 0.000 1.000 0.000
#> SRR1424683     4  0.2773     0.6061 0.004 0.116 0.000 0.880
#> SRR1424685     1  0.7605     0.3105 0.416 0.200 0.000 0.384
#> SRR1424686     3  0.0000     0.8554 0.000 0.000 1.000 0.000
#> SRR1424687     4  0.0524     0.6553 0.000 0.008 0.004 0.988
#> SRR1424688     4  0.3610     0.5515 0.000 0.200 0.000 0.800
#> SRR1424689     1  0.7605     0.3105 0.416 0.200 0.000 0.384
#> SRR1424690     1  0.7605     0.3105 0.416 0.200 0.000 0.384
#> SRR1424691     1  0.7605     0.3105 0.416 0.200 0.000 0.384
#> SRR1424692     4  0.4964     0.1377 0.004 0.380 0.000 0.616
#> SRR1424684     2  0.0000     0.7759 0.000 1.000 0.000 0.000
#> SRR1424693     1  0.7605     0.3105 0.416 0.200 0.000 0.384
#> SRR1424694     4  0.0524     0.6552 0.004 0.008 0.000 0.988
#> SRR1424695     1  0.7605     0.3105 0.416 0.200 0.000 0.384
#> SRR1424696     4  0.3726     0.5561 0.000 0.212 0.000 0.788
#> SRR1424697     3  0.0000     0.8554 0.000 0.000 1.000 0.000
#> SRR1424698     3  0.0000     0.8554 0.000 0.000 1.000 0.000
#> SRR1424699     2  0.3688     0.6495 0.000 0.792 0.208 0.000
#> SRR1424700     3  0.3791     0.6444 0.000 0.200 0.796 0.004
#> SRR1424701     3  0.0000     0.8554 0.000 0.000 1.000 0.000
#> SRR1424702     3  0.0000     0.8554 0.000 0.000 1.000 0.000
#> SRR1424703     3  0.0000     0.8554 0.000 0.000 1.000 0.000
#> SRR1424704     3  0.0000     0.8554 0.000 0.000 1.000 0.000
#> SRR1424706     3  0.0000     0.8554 0.000 0.000 1.000 0.000
#> SRR1424707     3  0.0000     0.8554 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
#> SRR1424656     1  0.0000     0.8501 1.000 0.000 0.000 0.000 0.000
#> SRR1424657     1  0.3305     0.6118 0.776 0.000 0.000 0.224 0.000
#> SRR1424658     1  0.0000     0.8501 1.000 0.000 0.000 0.000 0.000
#> SRR1424659     1  0.0000     0.8501 1.000 0.000 0.000 0.000 0.000
#> SRR1424660     1  0.4126     0.3098 0.620 0.000 0.380 0.000 0.000
#> SRR1424661     4  0.0000     0.8559 0.000 0.000 0.000 1.000 0.000
#> SRR1424662     1  0.0000     0.8501 1.000 0.000 0.000 0.000 0.000
#> SRR1424663     1  0.0000     0.8501 1.000 0.000 0.000 0.000 0.000
#> SRR1424664     1  0.0000     0.8501 1.000 0.000 0.000 0.000 0.000
#> SRR1424665     1  0.0000     0.8501 1.000 0.000 0.000 0.000 0.000
#> SRR1424666     3  0.4273     0.2373 0.448 0.000 0.552 0.000 0.000
#> SRR1424667     2  0.3109     0.7483 0.000 0.800 0.000 0.200 0.000
#> SRR1424668     1  0.3928     0.6099 0.700 0.000 0.004 0.000 0.296
#> SRR1424669     1  0.6023     0.4787 0.572 0.000 0.168 0.000 0.260
#> SRR1424670     1  0.0000     0.8501 1.000 0.000 0.000 0.000 0.000
#> SRR1424671     4  0.0000     0.8559 0.000 0.000 0.000 1.000 0.000
#> SRR1424672     3  0.4273     0.2373 0.448 0.000 0.552 0.000 0.000
#> SRR1424674     1  0.3730     0.6225 0.712 0.000 0.000 0.000 0.288
#> SRR1424673     3  0.4015     0.4461 0.348 0.000 0.652 0.000 0.000
#> SRR1424675     2  0.0000     0.8699 0.000 1.000 0.000 0.000 0.000
#> SRR1424676     2  0.0000     0.8699 0.000 1.000 0.000 0.000 0.000
#> SRR1424677     2  0.4088     0.5269 0.000 0.632 0.000 0.368 0.000
#> SRR1424678     2  0.0000     0.8699 0.000 1.000 0.000 0.000 0.000
#> SRR1424679     2  0.0000     0.8699 0.000 1.000 0.000 0.000 0.000
#> SRR1424680     2  0.2929     0.7213 0.000 0.820 0.000 0.180 0.000
#> SRR1424681     3  0.4300     0.1375 0.000 0.000 0.524 0.000 0.476
#> SRR1424682     3  0.0000     0.8361 0.000 0.000 1.000 0.000 0.000
#> SRR1424683     4  0.0000     0.8559 0.000 0.000 0.000 1.000 0.000
#> SRR1424685     5  0.0000     0.9290 0.000 0.000 0.000 0.000 1.000
#> SRR1424686     3  0.0162     0.8342 0.004 0.000 0.996 0.000 0.000
#> SRR1424687     4  0.3612     0.6072 0.000 0.000 0.000 0.732 0.268
#> SRR1424688     5  0.3932     0.3512 0.000 0.000 0.000 0.328 0.672
#> SRR1424689     5  0.0000     0.9290 0.000 0.000 0.000 0.000 1.000
#> SRR1424690     5  0.0000     0.9290 0.000 0.000 0.000 0.000 1.000
#> SRR1424691     5  0.0000     0.9290 0.000 0.000 0.000 0.000 1.000
#> SRR1424692     4  0.0000     0.8559 0.000 0.000 0.000 1.000 0.000
#> SRR1424684     2  0.0000     0.8699 0.000 1.000 0.000 0.000 0.000
#> SRR1424693     5  0.0000     0.9290 0.000 0.000 0.000 0.000 1.000
#> SRR1424694     4  0.0000     0.8559 0.000 0.000 0.000 1.000 0.000
#> SRR1424695     5  0.0000     0.9290 0.000 0.000 0.000 0.000 1.000
#> SRR1424696     4  0.4448     0.0934 0.000 0.004 0.000 0.516 0.480
#> SRR1424697     3  0.0000     0.8361 0.000 0.000 1.000 0.000 0.000
#> SRR1424698     3  0.0000     0.8361 0.000 0.000 1.000 0.000 0.000
#> SRR1424699     2  0.3109     0.7186 0.000 0.800 0.200 0.000 0.000
#> SRR1424700     3  0.3988     0.5554 0.000 0.016 0.732 0.000 0.252
#> SRR1424701     3  0.0000     0.8361 0.000 0.000 1.000 0.000 0.000
#> SRR1424702     3  0.0000     0.8361 0.000 0.000 1.000 0.000 0.000
#> SRR1424703     3  0.0000     0.8361 0.000 0.000 1.000 0.000 0.000
#> SRR1424704     3  0.0000     0.8361 0.000 0.000 1.000 0.000 0.000
#> SRR1424706     3  0.0000     0.8361 0.000 0.000 1.000 0.000 0.000
#> SRR1424707     3  0.0000     0.8361 0.000 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR1424656     1  0.0000      0.854 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1424657     1  0.0865      0.837 0.964 0.000 0.000 0.036 0.000 0.000
#> SRR1424658     1  0.2664      0.802 0.816 0.000 0.000 0.000 0.000 0.184
#> SRR1424659     1  0.2823      0.792 0.796 0.000 0.000 0.000 0.000 0.204
#> SRR1424660     1  0.1196      0.822 0.952 0.000 0.008 0.000 0.000 0.040
#> SRR1424661     4  0.0000      0.921 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1424662     1  0.0000      0.854 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1424663     1  0.2562      0.666 0.828 0.000 0.000 0.000 0.000 0.172
#> SRR1424664     1  0.2730      0.798 0.808 0.000 0.000 0.000 0.000 0.192
#> SRR1424665     1  0.0000      0.854 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1424666     6  0.0937      0.583 0.040 0.000 0.000 0.000 0.000 0.960
#> SRR1424667     2  0.2902      0.706 0.000 0.800 0.000 0.196 0.000 0.004
#> SRR1424668     6  0.5630      0.501 0.260 0.000 0.000 0.000 0.204 0.536
#> SRR1424669     6  0.7181      0.167 0.284 0.000 0.096 0.000 0.228 0.392
#> SRR1424670     1  0.2996      0.723 0.772 0.000 0.000 0.000 0.000 0.228
#> SRR1424671     4  0.0000      0.921 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1424672     6  0.2597      0.621 0.176 0.000 0.000 0.000 0.000 0.824
#> SRR1424674     6  0.5697      0.464 0.284 0.000 0.000 0.000 0.200 0.516
#> SRR1424673     6  0.2572      0.576 0.136 0.000 0.012 0.000 0.000 0.852
#> SRR1424675     2  0.3607      0.597 0.000 0.652 0.348 0.000 0.000 0.000
#> SRR1424676     2  0.0000      0.835 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1424677     2  0.3833      0.299 0.000 0.556 0.000 0.444 0.000 0.000
#> SRR1424678     2  0.0000      0.835 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1424679     2  0.0000      0.835 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1424680     2  0.1957      0.770 0.000 0.888 0.000 0.112 0.000 0.000
#> SRR1424681     6  0.3464      0.332 0.000 0.000 0.000 0.000 0.312 0.688
#> SRR1424682     3  0.3742      0.818 0.000 0.004 0.648 0.000 0.000 0.348
#> SRR1424683     4  0.0000      0.921 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1424685     5  0.3634      0.260 0.000 0.000 0.000 0.000 0.644 0.356
#> SRR1424686     3  0.3847      0.812 0.008 0.000 0.644 0.000 0.000 0.348
#> SRR1424687     4  0.3531      0.432 0.000 0.000 0.000 0.672 0.328 0.000
#> SRR1424688     5  0.3266      0.550 0.000 0.000 0.000 0.272 0.728 0.000
#> SRR1424689     5  0.0000      0.808 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1424690     5  0.0000      0.808 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1424691     5  0.0000      0.808 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1424692     4  0.0000      0.921 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1424684     2  0.0000      0.835 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1424693     5  0.0000      0.808 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1424694     4  0.0000      0.921 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1424695     5  0.0000      0.808 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1424696     5  0.4150      0.303 0.000 0.016 0.000 0.392 0.592 0.000
#> SRR1424697     3  0.3607      0.821 0.000 0.000 0.652 0.000 0.000 0.348
#> SRR1424698     3  0.3607      0.821 0.000 0.000 0.652 0.000 0.000 0.348
#> SRR1424699     3  0.3843     -0.419 0.000 0.452 0.548 0.000 0.000 0.000
#> SRR1424700     3  0.0935      0.499 0.000 0.004 0.964 0.000 0.032 0.000
#> SRR1424701     3  0.0000      0.530 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1424702     3  0.3607      0.821 0.000 0.000 0.652 0.000 0.000 0.348
#> SRR1424703     3  0.3607      0.821 0.000 0.000 0.652 0.000 0.000 0.348
#> SRR1424704     3  0.3607      0.821 0.000 0.000 0.652 0.000 0.000 0.348
#> SRR1424706     3  0.3607      0.821 0.000 0.000 0.652 0.000 0.000 0.348
#> SRR1424707     3  0.3607      0.821 0.000 0.000 0.652 0.000 0.000 0.348

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 16960 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 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-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.272           0.672       0.767         0.4160 0.561   0.561
#> 3 3 0.245           0.454       0.714         0.3867 0.558   0.355
#> 4 4 0.704           0.808       0.895         0.2242 0.860   0.649
#> 5 5 0.664           0.710       0.835         0.1067 0.906   0.676
#> 6 6 0.672           0.609       0.761         0.0494 0.947   0.750

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
#> SRR1424656     1   0.997      0.996 0.532 0.468
#> SRR1424657     1   0.997      0.996 0.532 0.468
#> SRR1424658     2   0.000      0.637 0.000 1.000
#> SRR1424659     1   0.997      0.996 0.532 0.468
#> SRR1424660     1   0.997      0.996 0.532 0.468
#> SRR1424661     2   0.802      0.690 0.244 0.756
#> SRR1424662     2   0.802      0.690 0.244 0.756
#> SRR1424663     1   0.997      0.996 0.532 0.468
#> SRR1424664     1   0.997      0.996 0.532 0.468
#> SRR1424665     1   0.997      0.996 0.532 0.468
#> SRR1424666     1   0.997      0.996 0.532 0.468
#> SRR1424667     2   0.997      0.575 0.468 0.532
#> SRR1424668     1   0.997      0.996 0.532 0.468
#> SRR1424669     2   0.343      0.535 0.064 0.936
#> SRR1424670     1   0.997      0.996 0.532 0.468
#> SRR1424671     2   0.802      0.690 0.244 0.756
#> SRR1424672     1   0.998      0.985 0.524 0.476
#> SRR1424674     1   0.997      0.996 0.532 0.468
#> SRR1424673     2   0.000      0.637 0.000 1.000
#> SRR1424675     2   0.833      0.613 0.264 0.736
#> SRR1424676     2   0.000      0.637 0.000 1.000
#> SRR1424677     2   0.802      0.690 0.244 0.756
#> SRR1424678     2   0.997      0.575 0.468 0.532
#> SRR1424679     2   0.833      0.613 0.264 0.736
#> SRR1424680     2   0.997      0.575 0.468 0.532
#> SRR1424681     1   0.998      0.991 0.528 0.472
#> SRR1424682     2   0.722      0.682 0.200 0.800
#> SRR1424683     2   0.802      0.690 0.244 0.756
#> SRR1424685     2   0.980     -0.758 0.416 0.584
#> SRR1424686     1   0.997      0.996 0.532 0.468
#> SRR1424687     2   0.802      0.690 0.244 0.756
#> SRR1424688     2   0.963     -0.685 0.388 0.612
#> SRR1424689     2   0.000      0.637 0.000 1.000
#> SRR1424690     1   0.997      0.996 0.532 0.468
#> SRR1424691     1   1.000      0.964 0.512 0.488
#> SRR1424692     2   0.802      0.690 0.244 0.756
#> SRR1424684     2   0.839      0.614 0.268 0.732
#> SRR1424693     2   0.963     -0.685 0.388 0.612
#> SRR1424694     2   0.802      0.690 0.244 0.756
#> SRR1424695     2   0.000      0.637 0.000 1.000
#> SRR1424696     2   0.839      0.614 0.268 0.732
#> SRR1424697     2   0.722      0.682 0.200 0.800
#> SRR1424698     2   0.000      0.637 0.000 1.000
#> SRR1424699     2   0.839      0.614 0.268 0.732
#> SRR1424700     2   0.697      0.617 0.188 0.812
#> SRR1424701     2   0.000      0.637 0.000 1.000
#> SRR1424702     2   0.000      0.637 0.000 1.000
#> SRR1424703     2   0.000      0.637 0.000 1.000
#> SRR1424704     2   0.000      0.637 0.000 1.000
#> SRR1424706     2   0.802      0.690 0.244 0.756
#> SRR1424707     2   0.000      0.637 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
#> SRR1424656     1  0.0000     0.7039 1.000 0.000 0.000
#> SRR1424657     1  0.0424     0.6992 0.992 0.000 0.008
#> SRR1424658     1  0.5621     0.3394 0.692 0.000 0.308
#> SRR1424659     1  0.0000     0.7039 1.000 0.000 0.000
#> SRR1424660     1  0.1031     0.7078 0.976 0.024 0.000
#> SRR1424661     3  0.3686     0.5945 0.140 0.000 0.860
#> SRR1424662     3  0.5058     0.5517 0.244 0.000 0.756
#> SRR1424663     1  0.0000     0.7039 1.000 0.000 0.000
#> SRR1424664     1  0.0000     0.7039 1.000 0.000 0.000
#> SRR1424665     1  0.0000     0.7039 1.000 0.000 0.000
#> SRR1424666     1  0.0237     0.7033 0.996 0.004 0.000
#> SRR1424667     2  0.6553     0.1870 0.008 0.580 0.412
#> SRR1424668     1  0.3832     0.6601 0.880 0.020 0.100
#> SRR1424669     1  0.4796     0.5119 0.780 0.000 0.220
#> SRR1424670     1  0.0000     0.7039 1.000 0.000 0.000
#> SRR1424671     3  0.0000     0.5234 0.000 0.000 1.000
#> SRR1424672     1  0.8711     0.5274 0.592 0.224 0.184
#> SRR1424674     1  0.4062     0.7080 0.836 0.164 0.000
#> SRR1424673     3  0.7768     0.2957 0.344 0.064 0.592
#> SRR1424675     2  0.3551     0.4541 0.000 0.868 0.132
#> SRR1424676     1  0.9457     0.3056 0.484 0.204 0.312
#> SRR1424677     3  0.1643     0.5104 0.000 0.044 0.956
#> SRR1424678     2  0.6180     0.2681 0.008 0.660 0.332
#> SRR1424679     2  0.3551     0.4541 0.000 0.868 0.132
#> SRR1424680     3  0.4750     0.3509 0.000 0.216 0.784
#> SRR1424681     1  0.4842     0.6985 0.776 0.224 0.000
#> SRR1424682     3  0.8610     0.2625 0.336 0.116 0.548
#> SRR1424683     3  0.3686     0.5945 0.140 0.000 0.860
#> SRR1424685     1  0.5070     0.6967 0.772 0.224 0.004
#> SRR1424686     1  0.4842     0.6985 0.776 0.224 0.000
#> SRR1424687     3  0.5621     0.4969 0.308 0.000 0.692
#> SRR1424688     1  0.4842     0.6985 0.776 0.224 0.000
#> SRR1424689     1  0.9502     0.3065 0.480 0.212 0.308
#> SRR1424690     1  0.4796     0.6992 0.780 0.220 0.000
#> SRR1424691     1  0.4842     0.6985 0.776 0.224 0.000
#> SRR1424692     3  0.3686     0.5945 0.140 0.000 0.860
#> SRR1424684     2  0.3965     0.4530 0.008 0.860 0.132
#> SRR1424693     1  0.4842     0.6985 0.776 0.224 0.000
#> SRR1424694     3  0.3686     0.5945 0.140 0.000 0.860
#> SRR1424695     1  0.9425     0.3085 0.488 0.200 0.312
#> SRR1424696     2  0.6682     0.0888 0.008 0.504 0.488
#> SRR1424697     3  0.7497     0.3717 0.276 0.072 0.652
#> SRR1424698     2  0.9998    -0.1901 0.336 0.340 0.324
#> SRR1424699     2  0.5678     0.3393 0.000 0.684 0.316
#> SRR1424700     2  0.7749     0.2829 0.072 0.616 0.312
#> SRR1424701     3  0.9721    -0.1570 0.336 0.232 0.432
#> SRR1424702     1  0.9997     0.0942 0.344 0.332 0.324
#> SRR1424703     2  0.9998    -0.1901 0.336 0.340 0.324
#> SRR1424704     2  0.9998    -0.1901 0.336 0.340 0.324
#> SRR1424706     3  0.0424     0.5273 0.008 0.000 0.992
#> SRR1424707     1  0.9997     0.0942 0.344 0.332 0.324

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1424656     1  0.0000      0.880 1.000 0.000 0.000 0.000
#> SRR1424657     1  0.0000      0.880 1.000 0.000 0.000 0.000
#> SRR1424658     1  0.0000      0.880 1.000 0.000 0.000 0.000
#> SRR1424659     1  0.0000      0.880 1.000 0.000 0.000 0.000
#> SRR1424660     1  0.0000      0.880 1.000 0.000 0.000 0.000
#> SRR1424661     4  0.0000      0.856 0.000 0.000 0.000 1.000
#> SRR1424662     4  0.4817      0.382 0.388 0.000 0.000 0.612
#> SRR1424663     1  0.0000      0.880 1.000 0.000 0.000 0.000
#> SRR1424664     1  0.0000      0.880 1.000 0.000 0.000 0.000
#> SRR1424665     1  0.0000      0.880 1.000 0.000 0.000 0.000
#> SRR1424666     1  0.0000      0.880 1.000 0.000 0.000 0.000
#> SRR1424667     2  0.4730      0.399 0.000 0.636 0.000 0.364
#> SRR1424668     1  0.0469      0.879 0.988 0.000 0.012 0.000
#> SRR1424669     1  0.0000      0.880 1.000 0.000 0.000 0.000
#> SRR1424670     1  0.0000      0.880 1.000 0.000 0.000 0.000
#> SRR1424671     4  0.0000      0.856 0.000 0.000 0.000 1.000
#> SRR1424672     1  0.3942      0.832 0.764 0.000 0.236 0.000
#> SRR1424674     1  0.2469      0.871 0.892 0.000 0.108 0.000
#> SRR1424673     3  0.4643      0.562 0.000 0.000 0.656 0.344
#> SRR1424675     2  0.1022      0.874 0.000 0.968 0.032 0.000
#> SRR1424676     2  0.2722      0.832 0.064 0.904 0.032 0.000
#> SRR1424677     4  0.0000      0.856 0.000 0.000 0.000 1.000
#> SRR1424678     2  0.0592      0.870 0.000 0.984 0.000 0.016
#> SRR1424679     2  0.0000      0.878 0.000 1.000 0.000 0.000
#> SRR1424680     4  0.0188      0.853 0.000 0.004 0.000 0.996
#> SRR1424681     1  0.4706      0.810 0.732 0.020 0.248 0.000
#> SRR1424682     3  0.3610      0.716 0.000 0.000 0.800 0.200
#> SRR1424683     4  0.0000      0.856 0.000 0.000 0.000 1.000
#> SRR1424685     1  0.4610      0.822 0.744 0.020 0.236 0.000
#> SRR1424686     1  0.3801      0.842 0.780 0.000 0.220 0.000
#> SRR1424687     4  0.4543      0.512 0.324 0.000 0.000 0.676
#> SRR1424688     1  0.4436      0.836 0.764 0.020 0.216 0.000
#> SRR1424689     1  0.4079      0.852 0.800 0.020 0.180 0.000
#> SRR1424690     1  0.4163      0.850 0.792 0.020 0.188 0.000
#> SRR1424691     1  0.4610      0.822 0.744 0.020 0.236 0.000
#> SRR1424692     4  0.0000      0.856 0.000 0.000 0.000 1.000
#> SRR1424684     2  0.0000      0.878 0.000 1.000 0.000 0.000
#> SRR1424693     1  0.4472      0.833 0.760 0.020 0.220 0.000
#> SRR1424694     4  0.0000      0.856 0.000 0.000 0.000 1.000
#> SRR1424695     1  0.4079      0.852 0.800 0.020 0.180 0.000
#> SRR1424696     2  0.0188      0.878 0.000 0.996 0.000 0.004
#> SRR1424697     3  0.4072      0.677 0.000 0.000 0.748 0.252
#> SRR1424698     3  0.0000      0.827 0.000 0.000 1.000 0.000
#> SRR1424699     2  0.2760      0.815 0.000 0.872 0.128 0.000
#> SRR1424700     2  0.3400      0.758 0.000 0.820 0.180 0.000
#> SRR1424701     3  0.0592      0.815 0.000 0.016 0.984 0.000
#> SRR1424702     3  0.0000      0.827 0.000 0.000 1.000 0.000
#> SRR1424703     3  0.0000      0.827 0.000 0.000 1.000 0.000
#> SRR1424704     3  0.0000      0.827 0.000 0.000 1.000 0.000
#> SRR1424706     3  0.4855      0.447 0.000 0.000 0.600 0.400
#> SRR1424707     3  0.0000      0.827 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
#> SRR1424656     1  0.0794      0.758 0.972 0.000 0.000 0.000 0.028
#> SRR1424657     1  0.1410      0.754 0.940 0.000 0.000 0.000 0.060
#> SRR1424658     1  0.0290      0.748 0.992 0.000 0.000 0.000 0.008
#> SRR1424659     1  0.0794      0.755 0.972 0.000 0.000 0.000 0.028
#> SRR1424660     1  0.3561      0.549 0.740 0.000 0.000 0.000 0.260
#> SRR1424661     4  0.0609      0.899 0.000 0.020 0.000 0.980 0.000
#> SRR1424662     4  0.4629      0.579 0.280 0.020 0.012 0.688 0.000
#> SRR1424663     5  0.3612      0.700 0.268 0.000 0.000 0.000 0.732
#> SRR1424664     1  0.0703      0.757 0.976 0.000 0.000 0.000 0.024
#> SRR1424665     1  0.0162      0.755 0.996 0.000 0.000 0.000 0.004
#> SRR1424666     5  0.3612      0.700 0.268 0.000 0.000 0.000 0.732
#> SRR1424667     2  0.4919      0.584 0.000 0.656 0.012 0.304 0.028
#> SRR1424668     5  0.3715      0.705 0.260 0.000 0.004 0.000 0.736
#> SRR1424669     1  0.0794      0.761 0.972 0.000 0.000 0.000 0.028
#> SRR1424670     1  0.0963      0.759 0.964 0.000 0.000 0.000 0.036
#> SRR1424671     4  0.0000      0.910 0.000 0.000 0.000 1.000 0.000
#> SRR1424672     5  0.3731      0.729 0.160 0.000 0.040 0.000 0.800
#> SRR1424674     1  0.3074      0.686 0.804 0.000 0.000 0.000 0.196
#> SRR1424673     3  0.4494      0.537 0.000 0.000 0.608 0.380 0.012
#> SRR1424675     2  0.3452      0.826 0.000 0.820 0.000 0.148 0.032
#> SRR1424676     2  0.5136      0.612 0.116 0.688 0.000 0.000 0.196
#> SRR1424677     4  0.0000      0.910 0.000 0.000 0.000 1.000 0.000
#> SRR1424678     2  0.2773      0.820 0.000 0.836 0.000 0.164 0.000
#> SRR1424679     2  0.0609      0.794 0.000 0.980 0.000 0.000 0.020
#> SRR1424680     4  0.1399      0.880 0.000 0.020 0.000 0.952 0.028
#> SRR1424681     5  0.1753      0.684 0.032 0.000 0.032 0.000 0.936
#> SRR1424682     3  0.3210      0.703 0.000 0.000 0.788 0.212 0.000
#> SRR1424683     4  0.0000      0.910 0.000 0.000 0.000 1.000 0.000
#> SRR1424685     5  0.4276      0.466 0.244 0.000 0.032 0.000 0.724
#> SRR1424686     5  0.2388      0.711 0.072 0.000 0.028 0.000 0.900
#> SRR1424687     4  0.2561      0.771 0.144 0.000 0.000 0.856 0.000
#> SRR1424688     1  0.4225      0.577 0.632 0.000 0.004 0.000 0.364
#> SRR1424689     1  0.4074      0.582 0.636 0.000 0.000 0.000 0.364
#> SRR1424690     1  0.4114      0.583 0.624 0.000 0.000 0.000 0.376
#> SRR1424691     5  0.4862      0.119 0.364 0.000 0.032 0.000 0.604
#> SRR1424692     4  0.0000      0.910 0.000 0.000 0.000 1.000 0.000
#> SRR1424684     2  0.0609      0.794 0.000 0.980 0.000 0.000 0.020
#> SRR1424693     1  0.4225      0.577 0.632 0.000 0.004 0.000 0.364
#> SRR1424694     4  0.0000      0.910 0.000 0.000 0.000 1.000 0.000
#> SRR1424695     1  0.4015      0.595 0.652 0.000 0.000 0.000 0.348
#> SRR1424696     2  0.2813      0.817 0.000 0.832 0.000 0.168 0.000
#> SRR1424697     3  0.4015      0.587 0.000 0.000 0.652 0.348 0.000
#> SRR1424698     3  0.0404      0.783 0.000 0.000 0.988 0.000 0.012
#> SRR1424699     2  0.3123      0.823 0.000 0.828 0.000 0.160 0.012
#> SRR1424700     2  0.3242      0.721 0.000 0.784 0.000 0.000 0.216
#> SRR1424701     3  0.3999      0.483 0.000 0.000 0.656 0.000 0.344
#> SRR1424702     3  0.0510      0.783 0.000 0.000 0.984 0.000 0.016
#> SRR1424703     3  0.0404      0.783 0.000 0.000 0.988 0.000 0.012
#> SRR1424704     3  0.0404      0.783 0.000 0.000 0.988 0.000 0.012
#> SRR1424706     3  0.4182      0.507 0.000 0.000 0.600 0.400 0.000
#> SRR1424707     3  0.0794      0.778 0.000 0.000 0.972 0.000 0.028

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR1424656     1  0.4332     0.5676 0.700 0.000 0.000 0.000 0.072 0.228
#> SRR1424657     1  0.5611     0.4100 0.544 0.000 0.000 0.000 0.228 0.228
#> SRR1424658     1  0.1204     0.5776 0.944 0.000 0.000 0.000 0.000 0.056
#> SRR1424659     1  0.4127     0.5837 0.680 0.000 0.000 0.000 0.036 0.284
#> SRR1424660     5  0.2883     0.7121 0.212 0.000 0.000 0.000 0.788 0.000
#> SRR1424661     4  0.1152     0.8219 0.000 0.004 0.000 0.952 0.000 0.044
#> SRR1424662     4  0.5319     0.5424 0.252 0.004 0.004 0.624 0.004 0.112
#> SRR1424663     5  0.2092     0.7511 0.124 0.000 0.000 0.000 0.876 0.000
#> SRR1424664     1  0.3874     0.5858 0.732 0.000 0.000 0.000 0.040 0.228
#> SRR1424665     1  0.0632     0.6095 0.976 0.000 0.000 0.000 0.024 0.000
#> SRR1424666     5  0.2882     0.7265 0.180 0.000 0.008 0.000 0.812 0.000
#> SRR1424667     2  0.4387     0.7129 0.000 0.736 0.008 0.152 0.000 0.104
#> SRR1424668     5  0.2048     0.7524 0.120 0.000 0.000 0.000 0.880 0.000
#> SRR1424669     1  0.0790     0.6102 0.968 0.000 0.000 0.000 0.032 0.000
#> SRR1424670     1  0.4382     0.5708 0.696 0.000 0.000 0.000 0.076 0.228
#> SRR1424671     4  0.0260     0.8377 0.000 0.000 0.000 0.992 0.000 0.008
#> SRR1424672     5  0.0363     0.7536 0.012 0.000 0.000 0.000 0.988 0.000
#> SRR1424674     5  0.5907    -0.2531 0.352 0.000 0.000 0.000 0.436 0.212
#> SRR1424673     3  0.4429     0.5699 0.000 0.012 0.600 0.372 0.000 0.016
#> SRR1424675     2  0.5037     0.6503 0.000 0.672 0.000 0.116 0.016 0.196
#> SRR1424676     6  0.6652     0.4979 0.260 0.132 0.000 0.000 0.100 0.508
#> SRR1424677     4  0.0000     0.8405 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1424678     2  0.2048     0.7783 0.000 0.880 0.000 0.120 0.000 0.000
#> SRR1424679     2  0.0881     0.7170 0.000 0.972 0.008 0.000 0.008 0.012
#> SRR1424680     4  0.5239    -0.0446 0.000 0.440 0.004 0.476 0.000 0.080
#> SRR1424681     5  0.1644     0.7076 0.000 0.004 0.000 0.000 0.920 0.076
#> SRR1424682     3  0.4056     0.6566 0.000 0.012 0.696 0.276 0.000 0.016
#> SRR1424683     4  0.1265     0.8368 0.000 0.008 0.000 0.948 0.000 0.044
#> SRR1424685     5  0.3462     0.6790 0.100 0.004 0.000 0.000 0.816 0.080
#> SRR1424686     5  0.0458     0.7451 0.000 0.000 0.000 0.000 0.984 0.016
#> SRR1424687     4  0.3128     0.7900 0.076 0.012 0.000 0.860 0.012 0.040
#> SRR1424688     1  0.5491     0.3835 0.584 0.004 0.000 0.000 0.180 0.232
#> SRR1424689     1  0.5620     0.2864 0.552 0.004 0.000 0.000 0.172 0.272
#> SRR1424690     1  0.5367     0.3891 0.572 0.004 0.000 0.000 0.300 0.124
#> SRR1424691     5  0.3266     0.6914 0.084 0.004 0.000 0.000 0.832 0.080
#> SRR1424692     4  0.0000     0.8405 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1424684     2  0.0520     0.7181 0.000 0.984 0.008 0.000 0.008 0.000
#> SRR1424693     1  0.5475     0.3793 0.588 0.004 0.000 0.000 0.184 0.224
#> SRR1424694     4  0.1367     0.8356 0.000 0.012 0.000 0.944 0.000 0.044
#> SRR1424695     1  0.5394     0.3742 0.600 0.004 0.000 0.000 0.172 0.224
#> SRR1424696     2  0.2092     0.7774 0.000 0.876 0.000 0.124 0.000 0.000
#> SRR1424697     3  0.4234     0.5814 0.000 0.004 0.608 0.372 0.000 0.016
#> SRR1424698     3  0.0820     0.7306 0.000 0.000 0.972 0.000 0.016 0.012
#> SRR1424699     2  0.5730     0.4282 0.000 0.504 0.000 0.160 0.004 0.332
#> SRR1424700     6  0.5291     0.3933 0.000 0.328 0.000 0.000 0.120 0.552
#> SRR1424701     6  0.5748     0.4602 0.004 0.008 0.288 0.000 0.148 0.552
#> SRR1424702     3  0.0458     0.7377 0.000 0.000 0.984 0.000 0.016 0.000
#> SRR1424703     3  0.0458     0.7377 0.000 0.000 0.984 0.000 0.016 0.000
#> SRR1424704     3  0.0458     0.7377 0.000 0.000 0.984 0.000 0.016 0.000
#> SRR1424706     3  0.4255     0.5695 0.000 0.004 0.600 0.380 0.000 0.016
#> SRR1424707     3  0.0713     0.7305 0.000 0.000 0.972 0.000 0.028 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 16960 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 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk SD-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.660           0.819       0.926         0.4835 0.523   0.523
#> 3 3 0.539           0.714       0.873         0.3814 0.759   0.561
#> 4 4 0.656           0.680       0.843         0.1178 0.861   0.616
#> 5 5 0.643           0.601       0.803         0.0707 0.819   0.420
#> 6 6 0.699           0.500       0.738         0.0474 0.935   0.694

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

suggest_best_k(res)
#> [1] 2

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette    p1    p2
#> SRR1424656     1  0.0000     0.9138 1.000 0.000
#> SRR1424657     1  0.0000     0.9138 1.000 0.000
#> SRR1424658     1  0.9635     0.3626 0.612 0.388
#> SRR1424659     1  0.0000     0.9138 1.000 0.000
#> SRR1424660     1  0.0000     0.9138 1.000 0.000
#> SRR1424661     2  0.9993     0.0494 0.484 0.516
#> SRR1424662     2  0.0672     0.9063 0.008 0.992
#> SRR1424663     1  0.0000     0.9138 1.000 0.000
#> SRR1424664     1  0.0000     0.9138 1.000 0.000
#> SRR1424665     1  0.3274     0.8709 0.940 0.060
#> SRR1424666     1  0.0376     0.9115 0.996 0.004
#> SRR1424667     2  0.0000     0.9095 0.000 1.000
#> SRR1424668     1  0.0000     0.9138 1.000 0.000
#> SRR1424669     1  0.9833     0.3041 0.576 0.424
#> SRR1424670     1  0.0000     0.9138 1.000 0.000
#> SRR1424671     2  0.2603     0.8856 0.044 0.956
#> SRR1424672     1  0.0000     0.9138 1.000 0.000
#> SRR1424674     1  0.0000     0.9138 1.000 0.000
#> SRR1424673     1  0.7815     0.6648 0.768 0.232
#> SRR1424675     2  0.0000     0.9095 0.000 1.000
#> SRR1424676     2  0.7528     0.6879 0.216 0.784
#> SRR1424677     2  0.0000     0.9095 0.000 1.000
#> SRR1424678     2  0.0000     0.9095 0.000 1.000
#> SRR1424679     2  0.0000     0.9095 0.000 1.000
#> SRR1424680     2  0.0000     0.9095 0.000 1.000
#> SRR1424681     1  0.0000     0.9138 1.000 0.000
#> SRR1424682     1  0.9427     0.4129 0.640 0.360
#> SRR1424683     2  0.0000     0.9095 0.000 1.000
#> SRR1424685     1  0.0000     0.9138 1.000 0.000
#> SRR1424686     1  0.0000     0.9138 1.000 0.000
#> SRR1424687     2  0.5946     0.7934 0.144 0.856
#> SRR1424688     1  0.4562     0.8382 0.904 0.096
#> SRR1424689     1  0.5842     0.7936 0.860 0.140
#> SRR1424690     1  0.0000     0.9138 1.000 0.000
#> SRR1424691     1  0.0000     0.9138 1.000 0.000
#> SRR1424692     2  0.0000     0.9095 0.000 1.000
#> SRR1424684     2  0.0000     0.9095 0.000 1.000
#> SRR1424693     1  0.0376     0.9117 0.996 0.004
#> SRR1424694     2  0.2778     0.8832 0.048 0.952
#> SRR1424695     1  0.9608     0.3718 0.616 0.384
#> SRR1424696     2  0.0000     0.9095 0.000 1.000
#> SRR1424697     1  0.8081     0.6406 0.752 0.248
#> SRR1424698     1  0.0000     0.9138 1.000 0.000
#> SRR1424699     2  0.0000     0.9095 0.000 1.000
#> SRR1424700     2  0.5946     0.7841 0.144 0.856
#> SRR1424701     1  0.0376     0.9117 0.996 0.004
#> SRR1424702     1  0.0000     0.9138 1.000 0.000
#> SRR1424703     1  0.0000     0.9138 1.000 0.000
#> SRR1424704     1  0.0000     0.9138 1.000 0.000
#> SRR1424706     2  0.9170     0.4940 0.332 0.668
#> SRR1424707     1  0.0000     0.9138 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
#> SRR1424656     1  0.0000     0.8292 1.000 0.000 0.000
#> SRR1424657     1  0.0000     0.8292 1.000 0.000 0.000
#> SRR1424658     1  0.0000     0.8292 1.000 0.000 0.000
#> SRR1424659     1  0.0000     0.8292 1.000 0.000 0.000
#> SRR1424660     1  0.0237     0.8278 0.996 0.000 0.004
#> SRR1424661     2  0.5109     0.6448 0.008 0.780 0.212
#> SRR1424662     1  0.4796     0.6913 0.780 0.220 0.000
#> SRR1424663     1  0.0000     0.8292 1.000 0.000 0.000
#> SRR1424664     1  0.0000     0.8292 1.000 0.000 0.000
#> SRR1424665     1  0.0000     0.8292 1.000 0.000 0.000
#> SRR1424666     1  0.4452     0.6663 0.808 0.000 0.192
#> SRR1424667     2  0.0000     0.8331 0.000 1.000 0.000
#> SRR1424668     1  0.5465     0.5056 0.712 0.000 0.288
#> SRR1424669     1  0.4504     0.7121 0.804 0.196 0.000
#> SRR1424670     1  0.0000     0.8292 1.000 0.000 0.000
#> SRR1424671     2  0.6168     0.2574 0.000 0.588 0.412
#> SRR1424672     3  0.5733     0.4830 0.324 0.000 0.676
#> SRR1424674     1  0.0000     0.8292 1.000 0.000 0.000
#> SRR1424673     3  0.4702     0.6388 0.000 0.212 0.788
#> SRR1424675     2  0.0000     0.8331 0.000 1.000 0.000
#> SRR1424676     2  0.5706     0.5860 0.000 0.680 0.320
#> SRR1424677     2  0.0000     0.8331 0.000 1.000 0.000
#> SRR1424678     2  0.0237     0.8324 0.000 0.996 0.004
#> SRR1424679     2  0.4555     0.7243 0.000 0.800 0.200
#> SRR1424680     2  0.0000     0.8331 0.000 1.000 0.000
#> SRR1424681     3  0.5016     0.5507 0.240 0.000 0.760
#> SRR1424682     3  0.0000     0.8389 0.000 0.000 1.000
#> SRR1424683     2  0.0000     0.8331 0.000 1.000 0.000
#> SRR1424685     3  0.6225    -0.0147 0.432 0.000 0.568
#> SRR1424686     1  0.4887     0.6700 0.772 0.000 0.228
#> SRR1424687     2  0.0747     0.8266 0.000 0.984 0.016
#> SRR1424688     1  0.5988     0.5064 0.632 0.000 0.368
#> SRR1424689     1  0.4002     0.7577 0.840 0.000 0.160
#> SRR1424690     1  0.4399     0.7357 0.812 0.000 0.188
#> SRR1424691     1  0.6140     0.4350 0.596 0.000 0.404
#> SRR1424692     2  0.0000     0.8331 0.000 1.000 0.000
#> SRR1424684     2  0.4346     0.7375 0.000 0.816 0.184
#> SRR1424693     1  0.6079     0.4681 0.612 0.000 0.388
#> SRR1424694     2  0.5650     0.4571 0.312 0.688 0.000
#> SRR1424695     1  0.4504     0.7285 0.804 0.000 0.196
#> SRR1424696     2  0.0000     0.8331 0.000 1.000 0.000
#> SRR1424697     3  0.2537     0.7884 0.000 0.080 0.920
#> SRR1424698     3  0.0000     0.8389 0.000 0.000 1.000
#> SRR1424699     2  0.4796     0.7084 0.000 0.780 0.220
#> SRR1424700     2  0.5591     0.6114 0.000 0.696 0.304
#> SRR1424701     3  0.0000     0.8389 0.000 0.000 1.000
#> SRR1424702     3  0.0000     0.8389 0.000 0.000 1.000
#> SRR1424703     3  0.0000     0.8389 0.000 0.000 1.000
#> SRR1424704     3  0.0000     0.8389 0.000 0.000 1.000
#> SRR1424706     3  0.4062     0.7021 0.000 0.164 0.836
#> SRR1424707     3  0.0000     0.8389 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
#> SRR1424656     1  0.0336     0.8273 0.992 0.008 0.000 0.000
#> SRR1424657     1  0.0469     0.8271 0.988 0.012 0.000 0.000
#> SRR1424658     1  0.1118     0.8199 0.964 0.036 0.000 0.000
#> SRR1424659     1  0.0188     0.8275 0.996 0.004 0.000 0.000
#> SRR1424660     1  0.1871     0.8160 0.948 0.016 0.012 0.024
#> SRR1424661     4  0.0336     0.8394 0.008 0.000 0.000 0.992
#> SRR1424662     4  0.3970     0.8340 0.084 0.076 0.000 0.840
#> SRR1424663     1  0.2376     0.8085 0.928 0.020 0.012 0.040
#> SRR1424664     1  0.0000     0.8275 1.000 0.000 0.000 0.000
#> SRR1424665     1  0.0469     0.8268 0.988 0.012 0.000 0.000
#> SRR1424666     1  0.3328     0.7835 0.884 0.020 0.020 0.076
#> SRR1424667     4  0.2149     0.8713 0.000 0.088 0.000 0.912
#> SRR1424668     1  0.4667     0.6824 0.788 0.020 0.172 0.020
#> SRR1424669     1  0.5453     0.4125 0.592 0.020 0.000 0.388
#> SRR1424670     1  0.0336     0.8268 0.992 0.008 0.000 0.000
#> SRR1424671     4  0.2402     0.8744 0.000 0.076 0.012 0.912
#> SRR1424672     3  0.7153     0.0839 0.440 0.020 0.464 0.076
#> SRR1424674     1  0.0707     0.8256 0.980 0.020 0.000 0.000
#> SRR1424673     3  0.4509     0.5871 0.004 0.000 0.708 0.288
#> SRR1424675     2  0.4134     0.5120 0.000 0.740 0.000 0.260
#> SRR1424676     2  0.1247     0.7530 0.012 0.968 0.016 0.004
#> SRR1424677     4  0.1940     0.8752 0.000 0.076 0.000 0.924
#> SRR1424678     2  0.1576     0.7515 0.000 0.948 0.004 0.048
#> SRR1424679     2  0.1396     0.7547 0.004 0.960 0.004 0.032
#> SRR1424680     2  0.1716     0.7449 0.000 0.936 0.000 0.064
#> SRR1424681     3  0.8999     0.1647 0.276 0.220 0.428 0.076
#> SRR1424682     3  0.2924     0.7897 0.000 0.016 0.884 0.100
#> SRR1424683     4  0.3161     0.8437 0.012 0.124 0.000 0.864
#> SRR1424685     2  0.9080     0.0575 0.236 0.408 0.280 0.076
#> SRR1424686     1  0.6007     0.6385 0.712 0.020 0.192 0.076
#> SRR1424687     4  0.0336     0.8503 0.000 0.008 0.000 0.992
#> SRR1424688     2  0.3172     0.6674 0.160 0.840 0.000 0.000
#> SRR1424689     1  0.4933     0.2957 0.568 0.432 0.000 0.000
#> SRR1424690     1  0.3801     0.6733 0.780 0.220 0.000 0.000
#> SRR1424691     1  0.6805     0.5060 0.604 0.220 0.176 0.000
#> SRR1424692     4  0.1940     0.8752 0.000 0.076 0.000 0.924
#> SRR1424684     2  0.1256     0.7547 0.008 0.964 0.000 0.028
#> SRR1424693     2  0.3945     0.5926 0.216 0.780 0.004 0.000
#> SRR1424694     4  0.6735     0.2253 0.388 0.096 0.000 0.516
#> SRR1424695     1  0.4994     0.1642 0.520 0.480 0.000 0.000
#> SRR1424696     2  0.2401     0.7257 0.004 0.904 0.000 0.092
#> SRR1424697     3  0.2342     0.8037 0.000 0.008 0.912 0.080
#> SRR1424698     3  0.0469     0.8216 0.000 0.012 0.988 0.000
#> SRR1424699     2  0.6136     0.3907 0.000 0.584 0.356 0.060
#> SRR1424700     2  0.5360     0.3065 0.000 0.552 0.436 0.012
#> SRR1424701     3  0.0336     0.8240 0.000 0.008 0.992 0.000
#> SRR1424702     3  0.0188     0.8258 0.004 0.000 0.996 0.000
#> SRR1424703     3  0.0336     0.8240 0.000 0.008 0.992 0.000
#> SRR1424704     3  0.0376     0.8257 0.004 0.004 0.992 0.000
#> SRR1424706     3  0.2124     0.7938 0.000 0.028 0.932 0.040
#> SRR1424707     3  0.0000     0.8256 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
#> SRR1424656     1  0.0290      0.788 0.992 0.000 0.000 0.000 0.008
#> SRR1424657     1  0.1638      0.776 0.932 0.000 0.000 0.004 0.064
#> SRR1424658     1  0.0794      0.781 0.972 0.000 0.000 0.000 0.028
#> SRR1424659     1  0.0963      0.787 0.964 0.000 0.000 0.000 0.036
#> SRR1424660     1  0.1357      0.765 0.948 0.000 0.004 0.000 0.048
#> SRR1424661     4  0.0162      0.753 0.000 0.004 0.000 0.996 0.000
#> SRR1424662     1  0.6083     -0.146 0.452 0.012 0.000 0.452 0.084
#> SRR1424663     1  0.3999      0.400 0.656 0.000 0.000 0.000 0.344
#> SRR1424664     1  0.1341      0.782 0.944 0.000 0.000 0.000 0.056
#> SRR1424665     1  0.0162      0.785 0.996 0.000 0.000 0.000 0.004
#> SRR1424666     5  0.4705      0.135 0.404 0.004 0.012 0.000 0.580
#> SRR1424667     4  0.3289      0.697 0.000 0.048 0.000 0.844 0.108
#> SRR1424668     1  0.3284      0.645 0.828 0.000 0.148 0.000 0.024
#> SRR1424669     4  0.7011      0.178 0.308 0.016 0.000 0.444 0.232
#> SRR1424670     1  0.2074      0.757 0.896 0.000 0.000 0.000 0.104
#> SRR1424671     4  0.3556      0.642 0.000 0.004 0.168 0.808 0.020
#> SRR1424672     5  0.3906      0.582 0.132 0.000 0.068 0.000 0.800
#> SRR1424674     1  0.1410      0.777 0.940 0.000 0.000 0.000 0.060
#> SRR1424673     3  0.5006      0.380 0.000 0.000 0.624 0.328 0.048
#> SRR1424675     2  0.8988      0.127 0.124 0.448 0.152 0.164 0.112
#> SRR1424676     2  0.0613      0.759 0.000 0.984 0.004 0.004 0.008
#> SRR1424677     4  0.0324      0.753 0.000 0.004 0.000 0.992 0.004
#> SRR1424678     2  0.0162      0.759 0.000 0.996 0.000 0.004 0.000
#> SRR1424679     2  0.0404      0.756 0.000 0.988 0.000 0.000 0.012
#> SRR1424680     2  0.3184      0.721 0.000 0.852 0.000 0.100 0.048
#> SRR1424681     5  0.5366      0.600 0.132 0.092 0.048 0.000 0.728
#> SRR1424682     5  0.6477      0.164 0.000 0.000 0.352 0.192 0.456
#> SRR1424683     4  0.5083      0.520 0.000 0.160 0.000 0.700 0.140
#> SRR1424685     5  0.5731      0.223 0.072 0.364 0.000 0.008 0.556
#> SRR1424686     5  0.4086      0.501 0.240 0.000 0.024 0.000 0.736
#> SRR1424687     4  0.3707      0.504 0.000 0.000 0.000 0.716 0.284
#> SRR1424688     2  0.5337      0.542 0.136 0.684 0.004 0.000 0.176
#> SRR1424689     2  0.6120      0.296 0.244 0.580 0.000 0.004 0.172
#> SRR1424690     1  0.6614     -0.162 0.448 0.236 0.000 0.000 0.316
#> SRR1424691     5  0.5852      0.469 0.180 0.192 0.004 0.000 0.624
#> SRR1424692     4  0.0324      0.753 0.000 0.004 0.000 0.992 0.004
#> SRR1424684     2  0.0162      0.758 0.000 0.996 0.000 0.000 0.004
#> SRR1424693     2  0.4549      0.608 0.048 0.728 0.004 0.000 0.220
#> SRR1424694     5  0.7593      0.275 0.108 0.140 0.000 0.272 0.480
#> SRR1424695     2  0.3918      0.678 0.096 0.804 0.000 0.000 0.100
#> SRR1424696     2  0.2632      0.740 0.000 0.888 0.000 0.072 0.040
#> SRR1424697     3  0.0992      0.855 0.000 0.000 0.968 0.008 0.024
#> SRR1424698     3  0.0162      0.858 0.000 0.000 0.996 0.000 0.004
#> SRR1424699     3  0.5004      0.607 0.000 0.256 0.672 0.000 0.072
#> SRR1424700     3  0.4923      0.617 0.000 0.252 0.680 0.000 0.068
#> SRR1424701     3  0.0880      0.852 0.000 0.032 0.968 0.000 0.000
#> SRR1424702     3  0.0880      0.852 0.000 0.000 0.968 0.000 0.032
#> SRR1424703     3  0.0000      0.858 0.000 0.000 1.000 0.000 0.000
#> SRR1424704     3  0.0404      0.859 0.000 0.000 0.988 0.000 0.012
#> SRR1424706     3  0.2074      0.808 0.000 0.000 0.896 0.104 0.000
#> SRR1424707     3  0.0609      0.858 0.000 0.000 0.980 0.000 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
#> SRR1424656     1  0.1863    0.70673 0.920 0.000 0.000 0.000 0.036 0.044
#> SRR1424657     1  0.2730    0.63972 0.836 0.000 0.000 0.000 0.152 0.012
#> SRR1424658     1  0.0713    0.70206 0.972 0.000 0.000 0.000 0.028 0.000
#> SRR1424659     1  0.3103    0.66703 0.784 0.000 0.000 0.000 0.008 0.208
#> SRR1424660     1  0.2715    0.69680 0.872 0.000 0.012 0.000 0.028 0.088
#> SRR1424661     4  0.0790    0.63801 0.000 0.000 0.000 0.968 0.032 0.000
#> SRR1424662     1  0.5886    0.08332 0.464 0.004 0.000 0.376 0.152 0.004
#> SRR1424663     1  0.4504    0.50936 0.592 0.000 0.000 0.000 0.040 0.368
#> SRR1424664     1  0.4478    0.60975 0.688 0.000 0.000 0.000 0.084 0.228
#> SRR1424665     1  0.0692    0.70046 0.976 0.000 0.000 0.000 0.020 0.004
#> SRR1424666     6  0.3206    0.50095 0.068 0.000 0.000 0.000 0.104 0.828
#> SRR1424667     4  0.4710    0.37761 0.000 0.040 0.000 0.620 0.328 0.012
#> SRR1424668     1  0.4448    0.54079 0.724 0.000 0.188 0.000 0.076 0.012
#> SRR1424669     5  0.7049   -0.28316 0.168 0.008 0.000 0.072 0.388 0.364
#> SRR1424670     1  0.5091    0.29179 0.504 0.000 0.000 0.000 0.080 0.416
#> SRR1424671     4  0.2361    0.61325 0.000 0.000 0.012 0.880 0.104 0.004
#> SRR1424672     6  0.4075    0.42933 0.004 0.000 0.012 0.004 0.312 0.668
#> SRR1424674     1  0.3841    0.55405 0.724 0.000 0.000 0.000 0.244 0.032
#> SRR1424673     4  0.6802    0.13422 0.028 0.000 0.388 0.388 0.176 0.020
#> SRR1424675     2  0.6999    0.09144 0.088 0.416 0.092 0.016 0.384 0.004
#> SRR1424676     2  0.0260    0.65008 0.000 0.992 0.000 0.000 0.008 0.000
#> SRR1424677     4  0.1350    0.63428 0.000 0.020 0.000 0.952 0.020 0.008
#> SRR1424678     2  0.0260    0.65019 0.000 0.992 0.000 0.000 0.008 0.000
#> SRR1424679     2  0.0260    0.64855 0.000 0.992 0.000 0.000 0.008 0.000
#> SRR1424680     2  0.4043    0.54066 0.000 0.756 0.000 0.128 0.116 0.000
#> SRR1424681     6  0.2936    0.57876 0.004 0.060 0.020 0.000 0.044 0.872
#> SRR1424682     6  0.7347    0.27296 0.000 0.040 0.084 0.216 0.168 0.492
#> SRR1424683     4  0.5217    0.20076 0.004 0.100 0.000 0.576 0.320 0.000
#> SRR1424685     2  0.5881    0.03166 0.004 0.456 0.000 0.000 0.364 0.176
#> SRR1424686     6  0.0984    0.57729 0.012 0.000 0.008 0.000 0.012 0.968
#> SRR1424687     4  0.4389    0.05717 0.000 0.000 0.000 0.528 0.024 0.448
#> SRR1424688     5  0.5862   -0.00294 0.160 0.348 0.000 0.000 0.484 0.008
#> SRR1424689     2  0.5698    0.16529 0.016 0.500 0.000 0.000 0.108 0.376
#> SRR1424690     6  0.6718    0.04299 0.148 0.084 0.000 0.000 0.292 0.476
#> SRR1424691     5  0.5920   -0.00182 0.028 0.124 0.000 0.000 0.528 0.320
#> SRR1424692     4  0.0291    0.63806 0.000 0.000 0.000 0.992 0.004 0.004
#> SRR1424684     2  0.0146    0.65027 0.000 0.996 0.000 0.000 0.004 0.000
#> SRR1424693     2  0.4661    0.29948 0.012 0.584 0.000 0.000 0.376 0.028
#> SRR1424694     5  0.6347    0.02189 0.072 0.036 0.000 0.372 0.488 0.032
#> SRR1424695     2  0.4615    0.53269 0.032 0.728 0.000 0.000 0.172 0.068
#> SRR1424696     2  0.4051    0.56615 0.000 0.756 0.000 0.076 0.164 0.004
#> SRR1424697     3  0.0405    0.90612 0.000 0.000 0.988 0.008 0.000 0.004
#> SRR1424698     3  0.0291    0.90605 0.000 0.000 0.992 0.000 0.004 0.004
#> SRR1424699     3  0.4336    0.70800 0.000 0.160 0.724 0.000 0.116 0.000
#> SRR1424700     3  0.3612    0.78314 0.000 0.100 0.796 0.000 0.104 0.000
#> SRR1424701     3  0.0146    0.90717 0.000 0.000 0.996 0.000 0.004 0.000
#> SRR1424702     3  0.1644    0.86803 0.000 0.000 0.920 0.000 0.004 0.076
#> SRR1424703     3  0.0000    0.90667 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1424704     3  0.0858    0.90024 0.000 0.000 0.968 0.000 0.004 0.028
#> SRR1424706     3  0.2669    0.75500 0.000 0.000 0.836 0.156 0.008 0.000
#> SRR1424707     3  0.0146    0.90698 0.000 0.000 0.996 0.000 0.000 0.004

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

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

collect_plots(res)

plot of chunk CV-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.394           0.766       0.874         0.3204 0.704   0.704
#> 3 3 0.458           0.603       0.744         0.8969 0.622   0.478
#> 4 4 0.520           0.604       0.776         0.1552 0.724   0.405
#> 5 5 0.683           0.594       0.790         0.0863 0.865   0.582
#> 6 6 0.752           0.757       0.855         0.0261 0.905   0.644

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
#> SRR1424656     1  0.6801     0.7789 0.820 0.180
#> SRR1424657     1  0.6801     0.7789 0.820 0.180
#> SRR1424658     1  0.6801     0.7789 0.820 0.180
#> SRR1424659     1  0.6801     0.7789 0.820 0.180
#> SRR1424660     1  0.6801     0.7789 0.820 0.180
#> SRR1424661     2  0.0672     0.6740 0.008 0.992
#> SRR1424662     2  0.1843     0.6749 0.028 0.972
#> SRR1424663     1  0.6801     0.7789 0.820 0.180
#> SRR1424664     1  0.6801     0.7789 0.820 0.180
#> SRR1424665     1  0.6801     0.7789 0.820 0.180
#> SRR1424666     1  0.9522     0.0149 0.628 0.372
#> SRR1424667     2  0.9775     0.7073 0.412 0.588
#> SRR1424668     1  0.6801     0.7789 0.820 0.180
#> SRR1424669     1  0.9522     0.0149 0.628 0.372
#> SRR1424670     1  0.6801     0.7789 0.820 0.180
#> SRR1424671     2  0.0376     0.6729 0.004 0.996
#> SRR1424672     1  0.6801     0.7789 0.820 0.180
#> SRR1424674     1  0.6801     0.7789 0.820 0.180
#> SRR1424673     1  0.7219     0.7625 0.800 0.200
#> SRR1424675     1  0.7219     0.7625 0.800 0.200
#> SRR1424676     1  0.4298     0.7880 0.912 0.088
#> SRR1424677     2  0.9552     0.7730 0.376 0.624
#> SRR1424678     1  0.4298     0.7880 0.912 0.088
#> SRR1424679     1  0.4298     0.7880 0.912 0.088
#> SRR1424680     2  0.9522     0.7775 0.372 0.628
#> SRR1424681     1  0.4298     0.7880 0.912 0.088
#> SRR1424682     1  0.4298     0.7880 0.912 0.088
#> SRR1424683     2  0.9522     0.7775 0.372 0.628
#> SRR1424685     1  0.4298     0.7880 0.912 0.088
#> SRR1424686     1  0.0000     0.8492 1.000 0.000
#> SRR1424687     1  0.5059     0.7464 0.888 0.112
#> SRR1424688     1  0.0000     0.8492 1.000 0.000
#> SRR1424689     1  0.0376     0.8482 0.996 0.004
#> SRR1424690     1  0.0376     0.8482 0.996 0.004
#> SRR1424691     1  0.0376     0.8482 0.996 0.004
#> SRR1424692     2  0.9522     0.7775 0.372 0.628
#> SRR1424684     1  0.4298     0.7880 0.912 0.088
#> SRR1424693     1  0.0376     0.8482 0.996 0.004
#> SRR1424694     2  0.9522     0.7775 0.372 0.628
#> SRR1424695     1  0.0376     0.8482 0.996 0.004
#> SRR1424696     1  0.1843     0.8363 0.972 0.028
#> SRR1424697     1  0.0376     0.8496 0.996 0.004
#> SRR1424698     1  0.0376     0.8496 0.996 0.004
#> SRR1424699     1  0.0376     0.8496 0.996 0.004
#> SRR1424700     1  0.0376     0.8496 0.996 0.004
#> SRR1424701     1  0.0376     0.8496 0.996 0.004
#> SRR1424702     1  0.0376     0.8496 0.996 0.004
#> SRR1424703     1  0.0376     0.8496 0.996 0.004
#> SRR1424704     1  0.0376     0.8496 0.996 0.004
#> SRR1424706     1  0.0376     0.8496 0.996 0.004
#> SRR1424707     1  0.0376     0.8496 0.996 0.004

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1424656     3  0.0237      0.784 0.000 0.004 0.996
#> SRR1424657     3  0.0237      0.784 0.000 0.004 0.996
#> SRR1424658     3  0.0000      0.784 0.000 0.000 1.000
#> SRR1424659     3  0.4750      0.502 0.216 0.000 0.784
#> SRR1424660     3  0.0237      0.784 0.000 0.004 0.996
#> SRR1424661     2  0.9129      0.478 0.288 0.532 0.180
#> SRR1424662     2  0.9231      0.476 0.308 0.512 0.180
#> SRR1424663     3  0.0000      0.784 0.000 0.000 1.000
#> SRR1424664     3  0.4750      0.502 0.216 0.000 0.784
#> SRR1424665     3  0.0000      0.784 0.000 0.000 1.000
#> SRR1424666     2  0.5618      0.302 0.260 0.732 0.008
#> SRR1424667     2  0.2063      0.640 0.044 0.948 0.008
#> SRR1424668     3  0.0000      0.784 0.000 0.000 1.000
#> SRR1424669     2  0.5618      0.302 0.260 0.732 0.008
#> SRR1424670     3  0.0000      0.784 0.000 0.000 1.000
#> SRR1424671     2  0.9048      0.479 0.288 0.540 0.172
#> SRR1424672     3  0.0000      0.784 0.000 0.000 1.000
#> SRR1424674     3  0.0000      0.784 0.000 0.000 1.000
#> SRR1424673     3  0.1315      0.767 0.008 0.020 0.972
#> SRR1424675     3  0.1315      0.767 0.008 0.020 0.972
#> SRR1424676     1  0.6495      0.499 0.536 0.460 0.004
#> SRR1424677     2  0.0237      0.663 0.004 0.996 0.000
#> SRR1424678     1  0.6495      0.499 0.536 0.460 0.004
#> SRR1424679     1  0.6495      0.499 0.536 0.460 0.004
#> SRR1424680     2  0.0000      0.666 0.000 1.000 0.000
#> SRR1424681     1  0.6495      0.499 0.536 0.460 0.004
#> SRR1424682     1  0.6495      0.499 0.536 0.460 0.004
#> SRR1424683     2  0.0000      0.666 0.000 1.000 0.000
#> SRR1424685     1  0.6495      0.499 0.536 0.460 0.004
#> SRR1424686     3  0.5480      0.743 0.264 0.004 0.732
#> SRR1424687     2  0.9152     -0.468 0.428 0.428 0.144
#> SRR1424688     3  0.5517      0.741 0.268 0.004 0.728
#> SRR1424689     1  0.7339      0.537 0.708 0.148 0.144
#> SRR1424690     1  0.6828      0.374 0.656 0.032 0.312
#> SRR1424691     1  0.6828      0.374 0.656 0.032 0.312
#> SRR1424692     2  0.0000      0.666 0.000 1.000 0.000
#> SRR1424684     1  0.6495      0.499 0.536 0.460 0.004
#> SRR1424693     1  0.6828      0.374 0.656 0.032 0.312
#> SRR1424694     2  0.0000      0.666 0.000 1.000 0.000
#> SRR1424695     1  0.6828      0.374 0.656 0.032 0.312
#> SRR1424696     1  0.9546      0.503 0.472 0.216 0.312
#> SRR1424697     3  0.5650      0.734 0.312 0.000 0.688
#> SRR1424698     3  0.5650      0.734 0.312 0.000 0.688
#> SRR1424699     3  0.5650      0.734 0.312 0.000 0.688
#> SRR1424700     3  0.5650      0.734 0.312 0.000 0.688
#> SRR1424701     3  0.5650      0.734 0.312 0.000 0.688
#> SRR1424702     3  0.5650      0.734 0.312 0.000 0.688
#> SRR1424703     3  0.5650      0.734 0.312 0.000 0.688
#> SRR1424704     3  0.5650      0.734 0.312 0.000 0.688
#> SRR1424706     3  0.5650      0.734 0.312 0.000 0.688
#> SRR1424707     3  0.5650      0.734 0.312 0.000 0.688

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1424656     1  0.0188     0.8759 0.996 0.004 0.000 0.000
#> SRR1424657     1  0.0188     0.8759 0.996 0.004 0.000 0.000
#> SRR1424658     1  0.0000     0.8773 1.000 0.000 0.000 0.000
#> SRR1424659     1  0.3764     0.6336 0.784 0.000 0.000 0.216
#> SRR1424660     1  0.0188     0.8759 0.996 0.004 0.000 0.000
#> SRR1424661     4  0.4936     0.9035 0.008 0.340 0.000 0.652
#> SRR1424662     4  0.4814     0.8937 0.008 0.316 0.000 0.676
#> SRR1424663     1  0.0000     0.8773 1.000 0.000 0.000 0.000
#> SRR1424664     1  0.3764     0.6336 0.784 0.000 0.000 0.216
#> SRR1424665     1  0.0000     0.8773 1.000 0.000 0.000 0.000
#> SRR1424666     2  0.5112     0.5371 0.008 0.608 0.000 0.384
#> SRR1424667     2  0.3591     0.2916 0.008 0.824 0.000 0.168
#> SRR1424668     1  0.0000     0.8773 1.000 0.000 0.000 0.000
#> SRR1424669     2  0.5112     0.5371 0.008 0.608 0.000 0.384
#> SRR1424670     1  0.0000     0.8773 1.000 0.000 0.000 0.000
#> SRR1424671     4  0.4888     0.8256 0.000 0.412 0.000 0.588
#> SRR1424672     1  0.0000     0.8773 1.000 0.000 0.000 0.000
#> SRR1424674     1  0.0000     0.8773 1.000 0.000 0.000 0.000
#> SRR1424673     1  0.1004     0.8582 0.972 0.004 0.000 0.024
#> SRR1424675     1  0.1004     0.8582 0.972 0.004 0.000 0.024
#> SRR1424676     2  0.7714     0.6435 0.000 0.448 0.292 0.260
#> SRR1424677     2  0.0188     0.3376 0.000 0.996 0.004 0.000
#> SRR1424678     2  0.7714     0.6435 0.000 0.448 0.292 0.260
#> SRR1424679     2  0.7714     0.6435 0.000 0.448 0.292 0.260
#> SRR1424680     2  0.0000     0.3334 0.000 1.000 0.000 0.000
#> SRR1424681     2  0.7714     0.6435 0.000 0.448 0.292 0.260
#> SRR1424682     2  0.7714     0.6435 0.000 0.448 0.292 0.260
#> SRR1424683     2  0.0000     0.3334 0.000 1.000 0.000 0.000
#> SRR1424685     2  0.7714     0.6435 0.000 0.448 0.292 0.260
#> SRR1424686     1  0.5773     0.0954 0.592 0.004 0.376 0.028
#> SRR1424687     2  0.7738     0.4787 0.000 0.424 0.336 0.240
#> SRR1424688     1  0.5786     0.0803 0.588 0.004 0.380 0.028
#> SRR1424689     3  0.6680     0.0710 0.000 0.136 0.604 0.260
#> SRR1424690     3  0.7526     0.3399 0.168 0.020 0.568 0.244
#> SRR1424691     3  0.7526     0.3399 0.168 0.020 0.568 0.244
#> SRR1424692     2  0.0000     0.3334 0.000 1.000 0.000 0.000
#> SRR1424684     2  0.7714     0.6435 0.000 0.448 0.292 0.260
#> SRR1424693     3  0.7526     0.3399 0.168 0.020 0.568 0.244
#> SRR1424694     2  0.0000     0.3334 0.000 1.000 0.000 0.000
#> SRR1424695     3  0.7526     0.3399 0.168 0.020 0.568 0.244
#> SRR1424696     3  0.9635    -0.1493 0.168 0.204 0.384 0.244
#> SRR1424697     3  0.3444     0.6946 0.184 0.000 0.816 0.000
#> SRR1424698     3  0.3444     0.6946 0.184 0.000 0.816 0.000
#> SRR1424699     3  0.3444     0.6946 0.184 0.000 0.816 0.000
#> SRR1424700     3  0.3444     0.6946 0.184 0.000 0.816 0.000
#> SRR1424701     3  0.3444     0.6946 0.184 0.000 0.816 0.000
#> SRR1424702     3  0.3444     0.6946 0.184 0.000 0.816 0.000
#> SRR1424703     3  0.3444     0.6946 0.184 0.000 0.816 0.000
#> SRR1424704     3  0.3444     0.6946 0.184 0.000 0.816 0.000
#> SRR1424706     3  0.3444     0.6946 0.184 0.000 0.816 0.000
#> SRR1424707     3  0.3444     0.6946 0.184 0.000 0.816 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
#> SRR1424656     1  0.0162    0.88195 0.996 0.004 0.000 0.000 0.000
#> SRR1424657     1  0.0162    0.88195 0.996 0.004 0.000 0.000 0.000
#> SRR1424658     1  0.0000    0.88329 1.000 0.000 0.000 0.000 0.000
#> SRR1424659     1  0.3242    0.64613 0.784 0.000 0.000 0.000 0.216
#> SRR1424660     1  0.0162    0.88195 0.996 0.004 0.000 0.000 0.000
#> SRR1424661     4  0.3849    0.78905 0.004 0.136 0.000 0.808 0.052
#> SRR1424662     4  0.5304    0.70360 0.004 0.352 0.000 0.592 0.052
#> SRR1424663     1  0.0000    0.88329 1.000 0.000 0.000 0.000 0.000
#> SRR1424664     1  0.3242    0.64613 0.784 0.000 0.000 0.000 0.216
#> SRR1424665     1  0.0000    0.88329 1.000 0.000 0.000 0.000 0.000
#> SRR1424666     5  0.3662    0.13197 0.004 0.252 0.000 0.000 0.744
#> SRR1424667     5  0.5029   -0.17999 0.004 0.444 0.000 0.024 0.528
#> SRR1424668     1  0.0000    0.88329 1.000 0.000 0.000 0.000 0.000
#> SRR1424669     5  0.3662    0.13197 0.004 0.252 0.000 0.000 0.744
#> SRR1424670     1  0.0000    0.88329 1.000 0.000 0.000 0.000 0.000
#> SRR1424671     4  0.0000    0.72669 0.000 0.000 0.000 1.000 0.000
#> SRR1424672     1  0.0000    0.88329 1.000 0.000 0.000 0.000 0.000
#> SRR1424674     1  0.0000    0.88329 1.000 0.000 0.000 0.000 0.000
#> SRR1424673     1  0.0865    0.86718 0.972 0.024 0.000 0.000 0.004
#> SRR1424675     1  0.0865    0.86718 0.972 0.024 0.000 0.000 0.004
#> SRR1424676     2  0.4430    0.84891 0.000 0.540 0.004 0.000 0.456
#> SRR1424677     2  0.6671   -0.31504 0.000 0.420 0.000 0.340 0.240
#> SRR1424678     2  0.4430    0.84891 0.000 0.540 0.004 0.000 0.456
#> SRR1424679     2  0.4430    0.84891 0.000 0.540 0.004 0.000 0.456
#> SRR1424680     5  0.6582   -0.08492 0.000 0.216 0.000 0.344 0.440
#> SRR1424681     2  0.4430    0.84891 0.000 0.540 0.004 0.000 0.456
#> SRR1424682     2  0.4430    0.84891 0.000 0.540 0.004 0.000 0.456
#> SRR1424683     5  0.6582   -0.08492 0.000 0.216 0.000 0.344 0.440
#> SRR1424685     2  0.4430    0.84891 0.000 0.540 0.004 0.000 0.456
#> SRR1424686     1  0.5865    0.35995 0.592 0.028 0.320 0.000 0.060
#> SRR1424687     5  0.2719    0.02242 0.000 0.004 0.144 0.000 0.852
#> SRR1424688     1  0.5939    0.35300 0.588 0.032 0.320 0.000 0.060
#> SRR1424689     5  0.6573   -0.22174 0.000 0.224 0.320 0.000 0.456
#> SRR1424690     5  0.7355    0.07497 0.168 0.056 0.320 0.000 0.456
#> SRR1424691     5  0.7355    0.07497 0.168 0.056 0.320 0.000 0.456
#> SRR1424692     5  0.5901   -0.07413 0.000 0.116 0.000 0.344 0.540
#> SRR1424684     2  0.4430    0.84891 0.000 0.540 0.004 0.000 0.456
#> SRR1424693     5  0.7355    0.07497 0.168 0.056 0.320 0.000 0.456
#> SRR1424694     5  0.5901   -0.07413 0.000 0.116 0.000 0.344 0.540
#> SRR1424695     5  0.7355    0.07497 0.168 0.056 0.320 0.000 0.456
#> SRR1424696     5  0.6181    0.00633 0.168 0.036 0.156 0.000 0.640
#> SRR1424697     3  0.0000    1.00000 0.000 0.000 1.000 0.000 0.000
#> SRR1424698     3  0.0000    1.00000 0.000 0.000 1.000 0.000 0.000
#> SRR1424699     3  0.0000    1.00000 0.000 0.000 1.000 0.000 0.000
#> SRR1424700     3  0.0000    1.00000 0.000 0.000 1.000 0.000 0.000
#> SRR1424701     3  0.0000    1.00000 0.000 0.000 1.000 0.000 0.000
#> SRR1424702     3  0.0000    1.00000 0.000 0.000 1.000 0.000 0.000
#> SRR1424703     3  0.0000    1.00000 0.000 0.000 1.000 0.000 0.000
#> SRR1424704     3  0.0000    1.00000 0.000 0.000 1.000 0.000 0.000
#> SRR1424706     3  0.0000    1.00000 0.000 0.000 1.000 0.000 0.000
#> SRR1424707     3  0.0000    1.00000 0.000 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR1424656     1  0.0405      0.888 0.988 0.000 0.000 0.004 0.000 0.008
#> SRR1424657     1  0.0405      0.888 0.988 0.000 0.000 0.004 0.000 0.008
#> SRR1424658     1  0.0000      0.889 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1424659     1  0.3455      0.698 0.784 0.000 0.000 0.000 0.036 0.180
#> SRR1424660     1  0.0405      0.888 0.988 0.000 0.000 0.004 0.000 0.008
#> SRR1424661     2  0.5303      0.613 0.000 0.600 0.000 0.204 0.000 0.196
#> SRR1424662     2  0.3126      0.465 0.000 0.752 0.000 0.000 0.000 0.248
#> SRR1424663     1  0.0260      0.888 0.992 0.000 0.000 0.000 0.000 0.008
#> SRR1424664     1  0.3455      0.698 0.784 0.000 0.000 0.000 0.036 0.180
#> SRR1424665     1  0.0000      0.889 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1424666     6  0.2972      0.841 0.000 0.000 0.000 0.128 0.036 0.836
#> SRR1424667     6  0.4613      0.641 0.000 0.180 0.000 0.128 0.000 0.692
#> SRR1424668     1  0.0000      0.889 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1424669     6  0.2972      0.841 0.000 0.000 0.000 0.128 0.036 0.836
#> SRR1424670     1  0.0000      0.889 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1424671     2  0.4544      0.550 0.000 0.668 0.000 0.256 0.000 0.076
#> SRR1424672     1  0.0000      0.889 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1424674     1  0.0000      0.889 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1424673     1  0.0790      0.874 0.968 0.000 0.000 0.000 0.000 0.032
#> SRR1424675     1  0.0790      0.874 0.968 0.000 0.000 0.000 0.000 0.032
#> SRR1424676     5  0.0000      0.670 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1424677     4  0.3601      0.560 0.000 0.000 0.000 0.684 0.312 0.004
#> SRR1424678     5  0.0000      0.670 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1424679     5  0.0000      0.670 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1424680     4  0.1814      0.815 0.000 0.000 0.000 0.900 0.100 0.000
#> SRR1424681     5  0.0000      0.670 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1424682     5  0.0000      0.670 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1424683     4  0.1814      0.815 0.000 0.000 0.000 0.900 0.100 0.000
#> SRR1424685     5  0.0000      0.670 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1424686     1  0.5904      0.353 0.584 0.000 0.272 0.004 0.088 0.052
#> SRR1424687     5  0.6758      0.299 0.000 0.000 0.132 0.324 0.452 0.092
#> SRR1424688     1  0.5946      0.344 0.580 0.000 0.272 0.004 0.092 0.052
#> SRR1424689     5  0.5774      0.441 0.000 0.000 0.272 0.000 0.504 0.224
#> SRR1424690     5  0.6376      0.572 0.160 0.000 0.272 0.000 0.516 0.052
#> SRR1424691     5  0.6376      0.572 0.160 0.000 0.272 0.000 0.516 0.052
#> SRR1424692     4  0.1556      0.778 0.000 0.000 0.000 0.920 0.000 0.080
#> SRR1424684     5  0.0000      0.670 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1424693     5  0.6376      0.572 0.160 0.000 0.272 0.000 0.516 0.052
#> SRR1424694     4  0.1556      0.778 0.000 0.000 0.000 0.920 0.000 0.080
#> SRR1424695     5  0.6376      0.572 0.160 0.000 0.272 0.000 0.516 0.052
#> SRR1424696     5  0.7735      0.487 0.160 0.000 0.144 0.112 0.492 0.092
#> SRR1424697     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1424698     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1424699     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1424700     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1424701     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1424702     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1424703     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1424704     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1424706     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1424707     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

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 16960 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 0.493           0.858       0.886         0.4885 0.500   0.500
#> 3 3 0.633           0.639       0.776         0.3278 0.767   0.559
#> 4 4 0.654           0.684       0.761         0.1298 0.798   0.495
#> 5 5 0.693           0.672       0.745         0.0826 0.885   0.605
#> 6 6 0.809           0.752       0.819         0.0487 0.947   0.739

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
#> SRR1424656     1  0.0672      0.911 0.992 0.008
#> SRR1424657     1  0.0000      0.909 1.000 0.000
#> SRR1424658     1  0.0376      0.911 0.996 0.004
#> SRR1424659     1  0.0672      0.911 0.992 0.008
#> SRR1424660     1  0.0672      0.911 0.992 0.008
#> SRR1424661     1  0.7219      0.796 0.800 0.200
#> SRR1424662     1  0.7056      0.803 0.808 0.192
#> SRR1424663     1  0.0672      0.911 0.992 0.008
#> SRR1424664     1  0.0672      0.911 0.992 0.008
#> SRR1424665     1  0.0376      0.911 0.996 0.004
#> SRR1424666     1  0.0672      0.911 0.992 0.008
#> SRR1424667     1  0.7453      0.791 0.788 0.212
#> SRR1424668     1  0.0672      0.911 0.992 0.008
#> SRR1424669     1  0.1633      0.903 0.976 0.024
#> SRR1424670     1  0.0672      0.911 0.992 0.008
#> SRR1424671     1  0.7219      0.796 0.800 0.200
#> SRR1424672     1  0.0672      0.911 0.992 0.008
#> SRR1424674     1  0.0672      0.911 0.992 0.008
#> SRR1424673     1  0.3733      0.885 0.928 0.072
#> SRR1424675     1  0.4298      0.877 0.912 0.088
#> SRR1424676     2  0.4161      0.862 0.084 0.916
#> SRR1424677     2  0.2603      0.841 0.044 0.956
#> SRR1424678     2  0.2423      0.844 0.040 0.960
#> SRR1424679     2  0.4161      0.862 0.084 0.916
#> SRR1424680     2  0.3733      0.830 0.072 0.928
#> SRR1424681     2  0.7674      0.863 0.224 0.776
#> SRR1424682     2  0.0938      0.842 0.012 0.988
#> SRR1424683     1  0.7745      0.778 0.772 0.228
#> SRR1424685     2  0.4022      0.863 0.080 0.920
#> SRR1424686     2  0.8661      0.823 0.288 0.712
#> SRR1424687     2  0.2423      0.847 0.040 0.960
#> SRR1424688     2  0.8608      0.829 0.284 0.716
#> SRR1424689     2  0.7950      0.858 0.240 0.760
#> SRR1424690     2  0.7950      0.858 0.240 0.760
#> SRR1424691     2  0.7950      0.858 0.240 0.760
#> SRR1424692     1  0.9393      0.609 0.644 0.356
#> SRR1424684     2  0.3733      0.859 0.072 0.928
#> SRR1424693     2  0.7950      0.858 0.240 0.760
#> SRR1424694     2  0.4298      0.823 0.088 0.912
#> SRR1424695     2  0.7950      0.858 0.240 0.760
#> SRR1424696     2  0.2778      0.843 0.048 0.952
#> SRR1424697     2  0.1414      0.845 0.020 0.980
#> SRR1424698     2  0.7453      0.858 0.212 0.788
#> SRR1424699     2  0.2423      0.858 0.040 0.960
#> SRR1424700     2  0.7453      0.858 0.212 0.788
#> SRR1424701     2  0.7453      0.858 0.212 0.788
#> SRR1424702     2  0.7453      0.858 0.212 0.788
#> SRR1424703     2  0.7453      0.858 0.212 0.788
#> SRR1424704     2  0.7453      0.858 0.212 0.788
#> SRR1424706     2  0.0376      0.839 0.004 0.996
#> SRR1424707     2  0.7453      0.858 0.212 0.788

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1424656     1  0.0237     0.9114 0.996 0.004 0.000
#> SRR1424657     1  0.0424     0.9107 0.992 0.008 0.000
#> SRR1424658     1  0.0424     0.9114 0.992 0.008 0.000
#> SRR1424659     1  0.0592     0.9106 0.988 0.012 0.000
#> SRR1424660     1  0.0237     0.9114 0.996 0.004 0.000
#> SRR1424661     1  0.6260     0.4663 0.552 0.448 0.000
#> SRR1424662     1  0.5397     0.6974 0.720 0.280 0.000
#> SRR1424663     1  0.0237     0.9117 0.996 0.004 0.000
#> SRR1424664     1  0.0424     0.9115 0.992 0.008 0.000
#> SRR1424665     1  0.0237     0.9114 0.996 0.004 0.000
#> SRR1424666     1  0.1643     0.9087 0.956 0.044 0.000
#> SRR1424667     2  0.6308    -0.4613 0.492 0.508 0.000
#> SRR1424668     1  0.0892     0.9112 0.980 0.020 0.000
#> SRR1424669     1  0.1753     0.9073 0.952 0.048 0.000
#> SRR1424670     1  0.1643     0.9087 0.956 0.044 0.000
#> SRR1424671     1  0.6309     0.4068 0.504 0.496 0.000
#> SRR1424672     1  0.1529     0.9091 0.960 0.040 0.000
#> SRR1424674     1  0.1163     0.9101 0.972 0.028 0.000
#> SRR1424673     1  0.2537     0.8859 0.920 0.080 0.000
#> SRR1424675     1  0.4062     0.8211 0.836 0.164 0.000
#> SRR1424676     2  0.6675     0.4535 0.012 0.584 0.404
#> SRR1424677     2  0.2165     0.5782 0.000 0.936 0.064
#> SRR1424678     2  0.5591     0.5610 0.000 0.696 0.304
#> SRR1424679     2  0.6675     0.4535 0.012 0.584 0.404
#> SRR1424680     2  0.1878     0.5721 0.004 0.952 0.044
#> SRR1424681     2  0.7394     0.2331 0.032 0.496 0.472
#> SRR1424682     2  0.6291     0.3060 0.000 0.532 0.468
#> SRR1424683     2  0.2496     0.5242 0.068 0.928 0.004
#> SRR1424685     2  0.6675     0.4535 0.012 0.584 0.404
#> SRR1424686     3  0.8590     0.4360 0.164 0.236 0.600
#> SRR1424687     2  0.6274     0.3221 0.000 0.544 0.456
#> SRR1424688     3  0.8165    -0.0377 0.072 0.416 0.512
#> SRR1424689     3  0.6820     0.5336 0.052 0.248 0.700
#> SRR1424690     3  0.6820     0.5336 0.052 0.248 0.700
#> SRR1424691     3  0.6820     0.5336 0.052 0.248 0.700
#> SRR1424692     2  0.2846     0.5588 0.020 0.924 0.056
#> SRR1424684     2  0.6172     0.5527 0.012 0.680 0.308
#> SRR1424693     3  0.6820     0.5336 0.052 0.248 0.700
#> SRR1424694     2  0.3573     0.5749 0.004 0.876 0.120
#> SRR1424695     3  0.7571     0.2379 0.052 0.356 0.592
#> SRR1424696     2  0.5529     0.5535 0.000 0.704 0.296
#> SRR1424697     3  0.1620     0.7439 0.012 0.024 0.964
#> SRR1424698     3  0.0747     0.7611 0.016 0.000 0.984
#> SRR1424699     3  0.0000     0.7529 0.000 0.000 1.000
#> SRR1424700     3  0.0747     0.7611 0.016 0.000 0.984
#> SRR1424701     3  0.0747     0.7611 0.016 0.000 0.984
#> SRR1424702     3  0.0747     0.7611 0.016 0.000 0.984
#> SRR1424703     3  0.0747     0.7611 0.016 0.000 0.984
#> SRR1424704     3  0.0747     0.7611 0.016 0.000 0.984
#> SRR1424706     3  0.1289     0.7365 0.000 0.032 0.968
#> SRR1424707     3  0.0747     0.7611 0.016 0.000 0.984

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1424656     1  0.0592      0.761 0.984 0.000 0.000 0.016
#> SRR1424657     1  0.0592      0.761 0.984 0.000 0.000 0.016
#> SRR1424658     1  0.0817      0.763 0.976 0.000 0.000 0.024
#> SRR1424659     1  0.1888      0.762 0.940 0.016 0.000 0.044
#> SRR1424660     1  0.0592      0.761 0.984 0.000 0.000 0.016
#> SRR1424661     4  0.5193      0.664 0.324 0.020 0.000 0.656
#> SRR1424662     4  0.4961      0.495 0.448 0.000 0.000 0.552
#> SRR1424663     1  0.0188      0.763 0.996 0.000 0.000 0.004
#> SRR1424664     1  0.1888      0.762 0.940 0.016 0.000 0.044
#> SRR1424665     1  0.0707      0.758 0.980 0.000 0.000 0.020
#> SRR1424666     1  0.5893      0.726 0.724 0.028 0.060 0.188
#> SRR1424667     4  0.5920      0.610 0.152 0.068 0.040 0.740
#> SRR1424668     1  0.4153      0.750 0.820 0.000 0.048 0.132
#> SRR1424669     1  0.6394      0.706 0.700 0.052 0.060 0.188
#> SRR1424670     1  0.5724      0.731 0.732 0.024 0.056 0.188
#> SRR1424671     4  0.4323      0.678 0.204 0.020 0.000 0.776
#> SRR1424672     1  0.5556      0.738 0.756 0.028 0.060 0.156
#> SRR1424674     1  0.4173      0.757 0.828 0.004 0.048 0.120
#> SRR1424673     1  0.6224      0.598 0.644 0.012 0.060 0.284
#> SRR1424675     1  0.7276      0.516 0.568 0.056 0.056 0.320
#> SRR1424676     2  0.3876      0.671 0.000 0.836 0.040 0.124
#> SRR1424677     2  0.4761      0.336 0.000 0.628 0.000 0.372
#> SRR1424678     2  0.3351      0.643 0.000 0.844 0.008 0.148
#> SRR1424679     2  0.3876      0.671 0.000 0.836 0.040 0.124
#> SRR1424680     2  0.4961      0.212 0.000 0.552 0.000 0.448
#> SRR1424681     2  0.4768      0.675 0.008 0.800 0.072 0.120
#> SRR1424682     2  0.4181      0.671 0.000 0.820 0.052 0.128
#> SRR1424683     4  0.4418      0.520 0.032 0.184 0.000 0.784
#> SRR1424685     2  0.3587      0.674 0.000 0.856 0.040 0.104
#> SRR1424686     1  0.8436     -0.232 0.356 0.344 0.280 0.020
#> SRR1424687     2  0.5040      0.655 0.008 0.764 0.180 0.048
#> SRR1424688     2  0.7130      0.587 0.056 0.636 0.228 0.080
#> SRR1424689     2  0.6028      0.530 0.020 0.628 0.324 0.028
#> SRR1424690     2  0.5955      0.528 0.020 0.628 0.328 0.024
#> SRR1424691     2  0.5955      0.528 0.020 0.628 0.328 0.024
#> SRR1424692     4  0.5523      0.538 0.032 0.260 0.012 0.696
#> SRR1424684     2  0.3280      0.659 0.000 0.860 0.016 0.124
#> SRR1424693     2  0.5955      0.528 0.020 0.628 0.328 0.024
#> SRR1424694     2  0.7592      0.310 0.024 0.532 0.128 0.316
#> SRR1424695     2  0.5785      0.580 0.020 0.672 0.280 0.028
#> SRR1424696     2  0.5097      0.659 0.008 0.776 0.140 0.076
#> SRR1424697     3  0.2234      0.981 0.004 0.064 0.924 0.008
#> SRR1424698     3  0.1743      0.992 0.004 0.056 0.940 0.000
#> SRR1424699     3  0.1824      0.988 0.000 0.060 0.936 0.004
#> SRR1424700     3  0.1930      0.991 0.004 0.056 0.936 0.004
#> SRR1424701     3  0.1930      0.991 0.004 0.056 0.936 0.004
#> SRR1424702     3  0.1743      0.992 0.004 0.056 0.940 0.000
#> SRR1424703     3  0.1743      0.992 0.004 0.056 0.940 0.000
#> SRR1424704     3  0.1743      0.992 0.004 0.056 0.940 0.000
#> SRR1424706     3  0.2342      0.963 0.000 0.080 0.912 0.008
#> SRR1424707     3  0.1743      0.992 0.004 0.056 0.940 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
#> SRR1424656     1  0.0162      0.733 0.996 0.000 0.000 0.004 0.000
#> SRR1424657     1  0.0671      0.726 0.980 0.000 0.000 0.004 0.016
#> SRR1424658     1  0.0324      0.733 0.992 0.000 0.000 0.004 0.004
#> SRR1424659     1  0.1331      0.724 0.952 0.000 0.000 0.008 0.040
#> SRR1424660     1  0.0162      0.733 0.996 0.000 0.000 0.004 0.000
#> SRR1424661     4  0.4633      0.571 0.128 0.104 0.000 0.760 0.008
#> SRR1424662     4  0.4452      0.464 0.272 0.000 0.000 0.696 0.032
#> SRR1424663     1  0.0162      0.735 0.996 0.000 0.000 0.000 0.004
#> SRR1424664     1  0.0898      0.731 0.972 0.000 0.000 0.008 0.020
#> SRR1424665     1  0.0162      0.733 0.996 0.000 0.000 0.004 0.000
#> SRR1424666     1  0.6794      0.372 0.428 0.000 0.004 0.240 0.328
#> SRR1424667     4  0.3283      0.528 0.008 0.028 0.000 0.848 0.116
#> SRR1424668     1  0.5010      0.621 0.708 0.000 0.000 0.144 0.148
#> SRR1424669     1  0.6800      0.367 0.424 0.000 0.004 0.240 0.332
#> SRR1424670     1  0.6630      0.394 0.444 0.000 0.000 0.240 0.316
#> SRR1424671     4  0.2625      0.589 0.016 0.108 0.000 0.876 0.000
#> SRR1424672     1  0.6291      0.510 0.544 0.004 0.000 0.172 0.280
#> SRR1424674     1  0.5263      0.612 0.680 0.000 0.000 0.144 0.176
#> SRR1424673     4  0.6866     -0.271 0.364 0.000 0.004 0.380 0.252
#> SRR1424675     4  0.7516     -0.258 0.340 0.028 0.004 0.360 0.268
#> SRR1424676     2  0.3724      0.821 0.000 0.776 0.020 0.000 0.204
#> SRR1424677     2  0.1741      0.650 0.000 0.936 0.000 0.024 0.040
#> SRR1424678     2  0.2848      0.807 0.000 0.840 0.004 0.000 0.156
#> SRR1424679     2  0.3724      0.822 0.000 0.776 0.020 0.000 0.204
#> SRR1424680     2  0.3710      0.499 0.000 0.808 0.000 0.144 0.048
#> SRR1424681     2  0.4750      0.752 0.000 0.692 0.044 0.004 0.260
#> SRR1424682     2  0.4019      0.796 0.000 0.768 0.028 0.004 0.200
#> SRR1424683     4  0.5053      0.454 0.004 0.304 0.000 0.644 0.048
#> SRR1424685     2  0.4153      0.800 0.000 0.736 0.020 0.004 0.240
#> SRR1424686     5  0.7062      0.515 0.288 0.040 0.172 0.000 0.500
#> SRR1424687     5  0.5292      0.607 0.000 0.252 0.084 0.004 0.660
#> SRR1424688     5  0.6985      0.679 0.080 0.084 0.148 0.048 0.640
#> SRR1424689     5  0.4818      0.757 0.000 0.080 0.212 0.000 0.708
#> SRR1424690     5  0.4847      0.757 0.000 0.080 0.216 0.000 0.704
#> SRR1424691     5  0.4901      0.755 0.000 0.084 0.216 0.000 0.700
#> SRR1424692     4  0.5626      0.460 0.000 0.232 0.004 0.640 0.124
#> SRR1424684     2  0.3427      0.824 0.000 0.796 0.012 0.000 0.192
#> SRR1424693     5  0.4847      0.757 0.000 0.080 0.216 0.000 0.704
#> SRR1424694     5  0.7124      0.327 0.000 0.332 0.032 0.184 0.452
#> SRR1424695     5  0.4725      0.755 0.000 0.080 0.200 0.000 0.720
#> SRR1424696     5  0.5929      0.493 0.000 0.328 0.048 0.040 0.584
#> SRR1424697     3  0.0740      0.976 0.000 0.008 0.980 0.004 0.008
#> SRR1424698     3  0.0162      0.988 0.000 0.004 0.996 0.000 0.000
#> SRR1424699     3  0.0162      0.987 0.000 0.004 0.996 0.000 0.000
#> SRR1424700     3  0.0324      0.986 0.000 0.004 0.992 0.000 0.004
#> SRR1424701     3  0.0324      0.986 0.000 0.004 0.992 0.000 0.004
#> SRR1424702     3  0.0324      0.988 0.000 0.004 0.992 0.004 0.000
#> SRR1424703     3  0.0162      0.988 0.000 0.004 0.996 0.000 0.000
#> SRR1424704     3  0.0324      0.988 0.000 0.004 0.992 0.004 0.000
#> SRR1424706     3  0.1179      0.956 0.000 0.016 0.964 0.004 0.016
#> SRR1424707     3  0.0162      0.988 0.000 0.000 0.996 0.004 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR1424656     1  0.0000     0.8466 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1424657     1  0.0547     0.8369 0.980 0.000 0.000 0.000 0.000 0.020
#> SRR1424658     1  0.0405     0.8470 0.988 0.000 0.000 0.004 0.008 0.000
#> SRR1424659     1  0.1592     0.8331 0.940 0.000 0.000 0.008 0.020 0.032
#> SRR1424660     1  0.0260     0.8471 0.992 0.000 0.000 0.000 0.008 0.000
#> SRR1424661     4  0.3307     0.7196 0.108 0.000 0.000 0.820 0.000 0.072
#> SRR1424662     4  0.5239     0.5926 0.196 0.000 0.000 0.644 0.012 0.148
#> SRR1424663     1  0.0806     0.8448 0.972 0.000 0.000 0.000 0.020 0.008
#> SRR1424664     1  0.1478     0.8334 0.944 0.000 0.000 0.004 0.020 0.032
#> SRR1424665     1  0.0291     0.8465 0.992 0.000 0.000 0.004 0.004 0.000
#> SRR1424666     6  0.3691     0.8058 0.168 0.000 0.000 0.004 0.048 0.780
#> SRR1424667     6  0.4811    -0.1829 0.000 0.008 0.000 0.448 0.036 0.508
#> SRR1424668     1  0.3961     0.0441 0.556 0.000 0.000 0.004 0.000 0.440
#> SRR1424669     6  0.4121     0.8023 0.144 0.004 0.000 0.008 0.076 0.768
#> SRR1424670     6  0.3494     0.8046 0.168 0.000 0.000 0.004 0.036 0.792
#> SRR1424671     4  0.3121     0.6645 0.008 0.000 0.000 0.796 0.004 0.192
#> SRR1424672     6  0.4226     0.6165 0.264 0.000 0.000 0.004 0.040 0.692
#> SRR1424674     1  0.4536    -0.0641 0.496 0.000 0.000 0.004 0.024 0.476
#> SRR1424673     6  0.3548     0.7917 0.136 0.000 0.000 0.068 0.000 0.796
#> SRR1424675     6  0.4049     0.8062 0.132 0.004 0.000 0.040 0.036 0.788
#> SRR1424676     2  0.1462     0.8746 0.000 0.936 0.000 0.000 0.056 0.008
#> SRR1424677     2  0.3808     0.6711 0.000 0.784 0.000 0.132 0.080 0.004
#> SRR1424678     2  0.0146     0.8633 0.000 0.996 0.000 0.000 0.000 0.004
#> SRR1424679     2  0.1285     0.8751 0.000 0.944 0.000 0.000 0.052 0.004
#> SRR1424680     2  0.4933     0.4386 0.000 0.624 0.000 0.272 0.104 0.000
#> SRR1424681     2  0.1946     0.8656 0.000 0.912 0.004 0.000 0.072 0.012
#> SRR1424682     2  0.1478     0.8677 0.000 0.944 0.004 0.000 0.032 0.020
#> SRR1424683     4  0.3747     0.6769 0.000 0.112 0.000 0.784 0.104 0.000
#> SRR1424685     2  0.1802     0.8682 0.000 0.916 0.000 0.000 0.072 0.012
#> SRR1424686     5  0.6251     0.5921 0.212 0.044 0.072 0.004 0.620 0.048
#> SRR1424687     5  0.5388     0.6558 0.000 0.124 0.020 0.116 0.700 0.040
#> SRR1424688     5  0.5049     0.7622 0.016 0.084 0.064 0.028 0.760 0.048
#> SRR1424689     5  0.4111     0.8002 0.000 0.100 0.088 0.008 0.788 0.016
#> SRR1424690     5  0.4165     0.8070 0.000 0.120 0.088 0.000 0.772 0.020
#> SRR1424691     5  0.4081     0.8065 0.000 0.120 0.088 0.000 0.776 0.016
#> SRR1424692     4  0.3879     0.6628 0.000 0.052 0.000 0.788 0.140 0.020
#> SRR1424684     2  0.1285     0.8726 0.000 0.944 0.000 0.000 0.052 0.004
#> SRR1424693     5  0.4165     0.8070 0.000 0.120 0.088 0.000 0.772 0.020
#> SRR1424694     5  0.5893     0.3571 0.000 0.068 0.008 0.300 0.572 0.052
#> SRR1424695     5  0.4066     0.8069 0.000 0.120 0.080 0.000 0.780 0.020
#> SRR1424696     5  0.5257     0.6143 0.000 0.124 0.016 0.140 0.696 0.024
#> SRR1424697     3  0.0984     0.9647 0.000 0.000 0.968 0.012 0.008 0.012
#> SRR1424698     3  0.1003     0.9681 0.000 0.000 0.964 0.004 0.004 0.028
#> SRR1424699     3  0.1390     0.9633 0.000 0.000 0.948 0.016 0.004 0.032
#> SRR1424700     3  0.1622     0.9575 0.000 0.000 0.940 0.016 0.016 0.028
#> SRR1424701     3  0.1622     0.9575 0.000 0.000 0.940 0.016 0.016 0.028
#> SRR1424702     3  0.0748     0.9679 0.000 0.000 0.976 0.004 0.004 0.016
#> SRR1424703     3  0.1003     0.9681 0.000 0.000 0.964 0.004 0.004 0.028
#> SRR1424704     3  0.0837     0.9678 0.000 0.000 0.972 0.004 0.004 0.020
#> SRR1424706     3  0.1086     0.9627 0.000 0.000 0.964 0.012 0.012 0.012
#> SRR1424707     3  0.0551     0.9687 0.000 0.000 0.984 0.004 0.004 0.008

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

consensus_heatmap(res, k = 2)

plot of chunk tab-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 16960 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 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-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.994         0.5014 0.500   0.500
#> 3 3 0.762           0.850       0.935         0.3358 0.782   0.582
#> 4 4 0.762           0.681       0.825         0.1187 0.810   0.505
#> 5 5 0.796           0.694       0.817         0.0813 0.809   0.393
#> 6 6 0.878           0.777       0.897         0.0417 0.922   0.628

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
#> SRR1424656     1  0.0000      0.997 1.000 0.000
#> SRR1424657     1  0.0000      0.997 1.000 0.000
#> SRR1424658     1  0.0000      0.997 1.000 0.000
#> SRR1424659     1  0.0000      0.997 1.000 0.000
#> SRR1424660     1  0.0000      0.997 1.000 0.000
#> SRR1424661     1  0.0672      0.995 0.992 0.008
#> SRR1424662     1  0.0672      0.995 0.992 0.008
#> SRR1424663     1  0.0000      0.997 1.000 0.000
#> SRR1424664     1  0.0000      0.997 1.000 0.000
#> SRR1424665     1  0.0000      0.997 1.000 0.000
#> SRR1424666     1  0.0000      0.997 1.000 0.000
#> SRR1424667     1  0.0672      0.995 0.992 0.008
#> SRR1424668     1  0.0000      0.997 1.000 0.000
#> SRR1424669     1  0.0000      0.997 1.000 0.000
#> SRR1424670     1  0.0000      0.997 1.000 0.000
#> SRR1424671     1  0.0672      0.995 0.992 0.008
#> SRR1424672     1  0.0000      0.997 1.000 0.000
#> SRR1424674     1  0.0000      0.997 1.000 0.000
#> SRR1424673     1  0.0672      0.995 0.992 0.008
#> SRR1424675     1  0.0672      0.995 0.992 0.008
#> SRR1424676     2  0.0000      0.992 0.000 1.000
#> SRR1424677     2  0.0000      0.992 0.000 1.000
#> SRR1424678     2  0.0000      0.992 0.000 1.000
#> SRR1424679     2  0.0000      0.992 0.000 1.000
#> SRR1424680     2  0.0000      0.992 0.000 1.000
#> SRR1424681     2  0.0672      0.992 0.008 0.992
#> SRR1424682     2  0.0000      0.992 0.000 1.000
#> SRR1424683     1  0.0672      0.995 0.992 0.008
#> SRR1424685     2  0.0000      0.992 0.000 1.000
#> SRR1424686     2  0.5178      0.877 0.116 0.884
#> SRR1424687     2  0.0000      0.992 0.000 1.000
#> SRR1424688     2  0.0672      0.992 0.008 0.992
#> SRR1424689     2  0.0672      0.992 0.008 0.992
#> SRR1424690     2  0.0672      0.992 0.008 0.992
#> SRR1424691     2  0.0672      0.992 0.008 0.992
#> SRR1424692     1  0.0672      0.995 0.992 0.008
#> SRR1424684     2  0.0000      0.992 0.000 1.000
#> SRR1424693     2  0.0672      0.992 0.008 0.992
#> SRR1424694     2  0.0000      0.992 0.000 1.000
#> SRR1424695     2  0.0672      0.992 0.008 0.992
#> SRR1424696     2  0.0000      0.992 0.000 1.000
#> SRR1424697     2  0.0000      0.992 0.000 1.000
#> SRR1424698     2  0.0672      0.992 0.008 0.992
#> SRR1424699     2  0.0000      0.992 0.000 1.000
#> SRR1424700     2  0.0672      0.992 0.008 0.992
#> SRR1424701     2  0.0672      0.992 0.008 0.992
#> SRR1424702     2  0.0672      0.992 0.008 0.992
#> SRR1424703     2  0.0672      0.992 0.008 0.992
#> SRR1424704     2  0.0672      0.992 0.008 0.992
#> SRR1424706     2  0.0000      0.992 0.000 1.000
#> SRR1424707     2  0.0672      0.992 0.008 0.992

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1424656     1  0.0000      0.968 1.000 0.000 0.000
#> SRR1424657     1  0.0000      0.968 1.000 0.000 0.000
#> SRR1424658     1  0.0000      0.968 1.000 0.000 0.000
#> SRR1424659     1  0.0000      0.968 1.000 0.000 0.000
#> SRR1424660     1  0.0000      0.968 1.000 0.000 0.000
#> SRR1424661     1  0.2165      0.923 0.936 0.064 0.000
#> SRR1424662     1  0.0000      0.968 1.000 0.000 0.000
#> SRR1424663     1  0.0000      0.968 1.000 0.000 0.000
#> SRR1424664     1  0.0000      0.968 1.000 0.000 0.000
#> SRR1424665     1  0.0000      0.968 1.000 0.000 0.000
#> SRR1424666     1  0.0000      0.968 1.000 0.000 0.000
#> SRR1424667     1  0.4178      0.823 0.828 0.172 0.000
#> SRR1424668     1  0.0000      0.968 1.000 0.000 0.000
#> SRR1424669     1  0.0000      0.968 1.000 0.000 0.000
#> SRR1424670     1  0.0000      0.968 1.000 0.000 0.000
#> SRR1424671     1  0.4235      0.818 0.824 0.176 0.000
#> SRR1424672     1  0.0000      0.968 1.000 0.000 0.000
#> SRR1424674     1  0.0000      0.968 1.000 0.000 0.000
#> SRR1424673     1  0.0000      0.968 1.000 0.000 0.000
#> SRR1424675     1  0.4121      0.827 0.832 0.168 0.000
#> SRR1424676     2  0.0000      0.904 0.000 1.000 0.000
#> SRR1424677     2  0.0000      0.904 0.000 1.000 0.000
#> SRR1424678     2  0.0000      0.904 0.000 1.000 0.000
#> SRR1424679     2  0.0000      0.904 0.000 1.000 0.000
#> SRR1424680     2  0.0000      0.904 0.000 1.000 0.000
#> SRR1424681     2  0.4452      0.727 0.000 0.808 0.192
#> SRR1424682     2  0.4654      0.711 0.000 0.792 0.208
#> SRR1424683     2  0.2261      0.839 0.068 0.932 0.000
#> SRR1424685     2  0.0000      0.904 0.000 1.000 0.000
#> SRR1424686     3  0.4473      0.707 0.164 0.008 0.828
#> SRR1424687     2  0.2066      0.865 0.000 0.940 0.060
#> SRR1424688     2  0.5098      0.612 0.000 0.752 0.248
#> SRR1424689     3  0.5882      0.502 0.000 0.348 0.652
#> SRR1424690     3  0.5882      0.502 0.000 0.348 0.652
#> SRR1424691     3  0.5882      0.502 0.000 0.348 0.652
#> SRR1424692     2  0.0237      0.901 0.004 0.996 0.000
#> SRR1424684     2  0.0000      0.904 0.000 1.000 0.000
#> SRR1424693     3  0.5882      0.502 0.000 0.348 0.652
#> SRR1424694     2  0.0000      0.904 0.000 1.000 0.000
#> SRR1424695     2  0.6079      0.309 0.000 0.612 0.388
#> SRR1424696     2  0.0000      0.904 0.000 1.000 0.000
#> SRR1424697     3  0.0000      0.865 0.000 0.000 1.000
#> SRR1424698     3  0.0000      0.865 0.000 0.000 1.000
#> SRR1424699     3  0.0000      0.865 0.000 0.000 1.000
#> SRR1424700     3  0.0000      0.865 0.000 0.000 1.000
#> SRR1424701     3  0.0000      0.865 0.000 0.000 1.000
#> SRR1424702     3  0.0000      0.865 0.000 0.000 1.000
#> SRR1424703     3  0.0000      0.865 0.000 0.000 1.000
#> SRR1424704     3  0.0000      0.865 0.000 0.000 1.000
#> SRR1424706     3  0.0000      0.865 0.000 0.000 1.000
#> SRR1424707     3  0.0000      0.865 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
#> SRR1424656     1  0.0188     0.8415 0.996 0.000 0.000 0.004
#> SRR1424657     1  0.0817     0.8308 0.976 0.000 0.000 0.024
#> SRR1424658     1  0.0188     0.8415 0.996 0.000 0.000 0.004
#> SRR1424659     1  0.0188     0.8409 0.996 0.004 0.000 0.000
#> SRR1424660     1  0.0188     0.8415 0.996 0.000 0.000 0.004
#> SRR1424661     4  0.4888     0.2377 0.412 0.000 0.000 0.588
#> SRR1424662     1  0.4382     0.5120 0.704 0.000 0.000 0.296
#> SRR1424663     1  0.0188     0.8415 0.996 0.000 0.000 0.004
#> SRR1424664     1  0.0000     0.8413 1.000 0.000 0.000 0.000
#> SRR1424665     1  0.0188     0.8415 0.996 0.000 0.000 0.004
#> SRR1424666     1  0.2530     0.8291 0.896 0.004 0.000 0.100
#> SRR1424667     4  0.4800     0.2381 0.340 0.004 0.000 0.656
#> SRR1424668     1  0.2345     0.8316 0.900 0.000 0.000 0.100
#> SRR1424669     1  0.2593     0.8276 0.892 0.004 0.000 0.104
#> SRR1424670     1  0.2466     0.8301 0.900 0.004 0.000 0.096
#> SRR1424671     4  0.4677     0.2777 0.316 0.004 0.000 0.680
#> SRR1424672     1  0.2281     0.8310 0.904 0.000 0.000 0.096
#> SRR1424674     1  0.2149     0.8332 0.912 0.000 0.000 0.088
#> SRR1424673     1  0.4746     0.5154 0.632 0.000 0.000 0.368
#> SRR1424675     1  0.4991     0.4704 0.608 0.004 0.000 0.388
#> SRR1424676     2  0.0336     0.6932 0.000 0.992 0.000 0.008
#> SRR1424677     4  0.4941     0.4515 0.000 0.436 0.000 0.564
#> SRR1424678     2  0.1211     0.6644 0.000 0.960 0.000 0.040
#> SRR1424679     2  0.0336     0.6932 0.000 0.992 0.000 0.008
#> SRR1424680     4  0.4898     0.4696 0.000 0.416 0.000 0.584
#> SRR1424681     2  0.0000     0.6950 0.000 1.000 0.000 0.000
#> SRR1424682     2  0.3606     0.5385 0.000 0.840 0.140 0.020
#> SRR1424683     4  0.5414     0.4898 0.020 0.376 0.000 0.604
#> SRR1424685     2  0.0000     0.6950 0.000 1.000 0.000 0.000
#> SRR1424686     1  0.9559    -0.1570 0.316 0.112 0.280 0.292
#> SRR1424687     4  0.4855    -0.0916 0.000 0.400 0.000 0.600
#> SRR1424688     2  0.6594     0.6418 0.012 0.588 0.068 0.332
#> SRR1424689     2  0.6316     0.6654 0.000 0.612 0.088 0.300
#> SRR1424690     2  0.6316     0.6654 0.000 0.612 0.088 0.300
#> SRR1424691     2  0.6316     0.6654 0.000 0.612 0.088 0.300
#> SRR1424692     4  0.2546     0.4927 0.008 0.092 0.000 0.900
#> SRR1424684     2  0.0469     0.6902 0.000 0.988 0.000 0.012
#> SRR1424693     2  0.6259     0.6665 0.000 0.616 0.084 0.300
#> SRR1424694     4  0.2647     0.4712 0.000 0.120 0.000 0.880
#> SRR1424695     2  0.6079     0.6662 0.000 0.628 0.072 0.300
#> SRR1424696     4  0.4679     0.0337 0.000 0.352 0.000 0.648
#> SRR1424697     3  0.0000     1.0000 0.000 0.000 1.000 0.000
#> SRR1424698     3  0.0000     1.0000 0.000 0.000 1.000 0.000
#> SRR1424699     3  0.0000     1.0000 0.000 0.000 1.000 0.000
#> SRR1424700     3  0.0000     1.0000 0.000 0.000 1.000 0.000
#> SRR1424701     3  0.0000     1.0000 0.000 0.000 1.000 0.000
#> SRR1424702     3  0.0000     1.0000 0.000 0.000 1.000 0.000
#> SRR1424703     3  0.0000     1.0000 0.000 0.000 1.000 0.000
#> SRR1424704     3  0.0000     1.0000 0.000 0.000 1.000 0.000
#> SRR1424706     3  0.0000     1.0000 0.000 0.000 1.000 0.000
#> SRR1424707     3  0.0000     1.0000 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
#> SRR1424656     1  0.0000     0.7974 1.000 0.000 0.000 0.000 0.000
#> SRR1424657     1  0.0324     0.7936 0.992 0.004 0.000 0.004 0.000
#> SRR1424658     1  0.0162     0.7962 0.996 0.000 0.000 0.004 0.000
#> SRR1424659     1  0.0798     0.7854 0.976 0.000 0.000 0.016 0.008
#> SRR1424660     1  0.0000     0.7974 1.000 0.000 0.000 0.000 0.000
#> SRR1424661     1  0.6708     0.2144 0.480 0.180 0.000 0.328 0.012
#> SRR1424662     1  0.4557     0.3118 0.584 0.012 0.000 0.404 0.000
#> SRR1424663     1  0.0000     0.7974 1.000 0.000 0.000 0.000 0.000
#> SRR1424664     1  0.0566     0.7905 0.984 0.000 0.000 0.012 0.004
#> SRR1424665     1  0.0000     0.7974 1.000 0.000 0.000 0.000 0.000
#> SRR1424666     4  0.4088     0.6822 0.304 0.000 0.000 0.688 0.008
#> SRR1424667     4  0.0693     0.6639 0.008 0.012 0.000 0.980 0.000
#> SRR1424668     4  0.4268     0.4961 0.444 0.000 0.000 0.556 0.000
#> SRR1424669     4  0.3942     0.6996 0.260 0.000 0.000 0.728 0.012
#> SRR1424670     4  0.4127     0.6763 0.312 0.000 0.000 0.680 0.008
#> SRR1424671     4  0.3583     0.5314 0.016 0.168 0.000 0.808 0.008
#> SRR1424672     4  0.4225     0.6291 0.364 0.004 0.000 0.632 0.000
#> SRR1424674     1  0.4448    -0.4255 0.516 0.004 0.000 0.480 0.000
#> SRR1424673     4  0.1410     0.6915 0.060 0.000 0.000 0.940 0.000
#> SRR1424675     4  0.1502     0.6939 0.056 0.004 0.000 0.940 0.000
#> SRR1424676     2  0.3837     0.7693 0.000 0.692 0.000 0.000 0.308
#> SRR1424677     2  0.1403     0.6330 0.000 0.952 0.000 0.024 0.024
#> SRR1424678     2  0.3177     0.7616 0.000 0.792 0.000 0.000 0.208
#> SRR1424679     2  0.3816     0.7715 0.000 0.696 0.000 0.000 0.304
#> SRR1424680     2  0.2110     0.5770 0.000 0.912 0.000 0.072 0.016
#> SRR1424681     2  0.3932     0.7540 0.000 0.672 0.000 0.000 0.328
#> SRR1424682     2  0.3848     0.7467 0.000 0.788 0.040 0.000 0.172
#> SRR1424683     2  0.4442     0.3150 0.004 0.676 0.000 0.304 0.016
#> SRR1424685     2  0.3857     0.7680 0.000 0.688 0.000 0.000 0.312
#> SRR1424686     5  0.5917     0.0882 0.436 0.004 0.088 0.000 0.472
#> SRR1424687     5  0.4206     0.6020 0.000 0.272 0.000 0.020 0.708
#> SRR1424688     5  0.2686     0.6904 0.012 0.080 0.012 0.004 0.892
#> SRR1424689     5  0.0609     0.7034 0.000 0.000 0.020 0.000 0.980
#> SRR1424690     5  0.0609     0.7034 0.000 0.000 0.020 0.000 0.980
#> SRR1424691     5  0.0609     0.7034 0.000 0.000 0.020 0.000 0.980
#> SRR1424692     5  0.6960     0.2753 0.004 0.328 0.000 0.328 0.340
#> SRR1424684     2  0.3774     0.7736 0.000 0.704 0.000 0.000 0.296
#> SRR1424693     5  0.0671     0.7017 0.000 0.004 0.016 0.000 0.980
#> SRR1424694     5  0.5245     0.5569 0.000 0.328 0.000 0.064 0.608
#> SRR1424695     5  0.0671     0.7017 0.000 0.004 0.016 0.000 0.980
#> SRR1424696     5  0.4642     0.5897 0.000 0.308 0.000 0.032 0.660
#> SRR1424697     3  0.0290     0.9917 0.000 0.000 0.992 0.000 0.008
#> SRR1424698     3  0.0000     0.9979 0.000 0.000 1.000 0.000 0.000
#> SRR1424699     3  0.0000     0.9979 0.000 0.000 1.000 0.000 0.000
#> SRR1424700     3  0.0000     0.9979 0.000 0.000 1.000 0.000 0.000
#> SRR1424701     3  0.0000     0.9979 0.000 0.000 1.000 0.000 0.000
#> SRR1424702     3  0.0000     0.9979 0.000 0.000 1.000 0.000 0.000
#> SRR1424703     3  0.0000     0.9979 0.000 0.000 1.000 0.000 0.000
#> SRR1424704     3  0.0000     0.9979 0.000 0.000 1.000 0.000 0.000
#> SRR1424706     3  0.0290     0.9917 0.000 0.000 0.992 0.000 0.008
#> SRR1424707     3  0.0000     0.9979 0.000 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR1424656     1  0.0000     0.8581 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1424657     1  0.0405     0.8528 0.988 0.000 0.000 0.004 0.000 0.008
#> SRR1424658     1  0.0000     0.8581 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1424659     1  0.1364     0.8346 0.944 0.000 0.000 0.004 0.004 0.048
#> SRR1424660     1  0.0000     0.8581 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1424661     4  0.3979     0.5194 0.256 0.000 0.000 0.712 0.004 0.028
#> SRR1424662     1  0.5837     0.0561 0.488 0.000 0.000 0.348 0.008 0.156
#> SRR1424663     1  0.0260     0.8562 0.992 0.000 0.000 0.000 0.000 0.008
#> SRR1424664     1  0.1082     0.8399 0.956 0.000 0.000 0.004 0.000 0.040
#> SRR1424665     1  0.0000     0.8581 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1424666     6  0.1297     0.8035 0.040 0.000 0.000 0.012 0.000 0.948
#> SRR1424667     6  0.3545     0.5913 0.000 0.008 0.000 0.236 0.008 0.748
#> SRR1424668     6  0.3699     0.5879 0.336 0.000 0.000 0.000 0.004 0.660
#> SRR1424669     6  0.1434     0.8002 0.028 0.000 0.000 0.012 0.012 0.948
#> SRR1424670     6  0.1267     0.8028 0.060 0.000 0.000 0.000 0.000 0.940
#> SRR1424671     4  0.4034     0.3951 0.004 0.008 0.000 0.680 0.008 0.300
#> SRR1424672     6  0.2673     0.7709 0.128 0.004 0.000 0.004 0.008 0.856
#> SRR1424674     6  0.4135     0.4396 0.404 0.000 0.000 0.004 0.008 0.584
#> SRR1424673     6  0.1787     0.7723 0.000 0.008 0.000 0.068 0.004 0.920
#> SRR1424675     6  0.2044     0.7708 0.004 0.008 0.000 0.068 0.008 0.912
#> SRR1424676     2  0.0458     0.9379 0.000 0.984 0.000 0.000 0.016 0.000
#> SRR1424677     2  0.3601     0.5076 0.000 0.684 0.000 0.312 0.000 0.004
#> SRR1424678     2  0.0405     0.9322 0.000 0.988 0.000 0.008 0.000 0.004
#> SRR1424679     2  0.0603     0.9378 0.000 0.980 0.000 0.000 0.016 0.004
#> SRR1424680     4  0.3052     0.5966 0.000 0.216 0.000 0.780 0.000 0.004
#> SRR1424681     2  0.0777     0.9307 0.000 0.972 0.000 0.000 0.024 0.004
#> SRR1424682     2  0.0436     0.9351 0.000 0.988 0.004 0.004 0.004 0.000
#> SRR1424683     4  0.1693     0.7299 0.004 0.044 0.000 0.932 0.000 0.020
#> SRR1424685     2  0.0458     0.9379 0.000 0.984 0.000 0.000 0.016 0.000
#> SRR1424686     1  0.5646     0.0389 0.468 0.004 0.036 0.016 0.452 0.024
#> SRR1424687     5  0.5133     0.4183 0.000 0.100 0.000 0.336 0.564 0.000
#> SRR1424688     5  0.2643     0.7463 0.008 0.000 0.000 0.128 0.856 0.008
#> SRR1424689     5  0.0603     0.8447 0.000 0.016 0.000 0.000 0.980 0.004
#> SRR1424690     5  0.0458     0.8466 0.000 0.016 0.000 0.000 0.984 0.000
#> SRR1424691     5  0.0458     0.8466 0.000 0.016 0.000 0.000 0.984 0.000
#> SRR1424692     4  0.0405     0.7231 0.000 0.004 0.000 0.988 0.008 0.000
#> SRR1424684     2  0.0551     0.9370 0.000 0.984 0.000 0.004 0.008 0.004
#> SRR1424693     5  0.0458     0.8466 0.000 0.016 0.000 0.000 0.984 0.000
#> SRR1424694     4  0.3166     0.5328 0.000 0.008 0.000 0.800 0.184 0.008
#> SRR1424695     5  0.0458     0.8466 0.000 0.016 0.000 0.000 0.984 0.000
#> SRR1424696     5  0.4333     0.4328 0.000 0.020 0.000 0.380 0.596 0.004
#> SRR1424697     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1424698     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1424699     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1424700     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1424701     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1424702     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1424703     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1424704     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1424706     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1424707     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-skmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-skmeans-collect-classes

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


CV:pam**

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

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

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

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

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

collect_plots(res)

plot of chunk CV-pam-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.556           0.598       0.838         0.5079 0.495   0.495
#> 3 3 0.969           0.955       0.980         0.3213 0.759   0.548
#> 4 4 0.785           0.798       0.874         0.1079 0.911   0.737
#> 5 5 0.822           0.796       0.888         0.0760 0.908   0.664
#> 6 6 0.820           0.822       0.889         0.0308 0.969   0.837

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
#> SRR1424656     1  0.9754      0.755 0.592 0.408
#> SRR1424657     1  0.9754      0.755 0.592 0.408
#> SRR1424658     1  0.9754      0.755 0.592 0.408
#> SRR1424659     1  0.9754      0.755 0.592 0.408
#> SRR1424660     1  0.9754      0.755 0.592 0.408
#> SRR1424661     1  0.9754      0.755 0.592 0.408
#> SRR1424662     1  0.9754      0.755 0.592 0.408
#> SRR1424663     1  0.9754      0.755 0.592 0.408
#> SRR1424664     1  0.9754      0.755 0.592 0.408
#> SRR1424665     1  0.9754      0.755 0.592 0.408
#> SRR1424666     1  0.9754      0.755 0.592 0.408
#> SRR1424667     2  0.0000      0.394 0.000 1.000
#> SRR1424668     1  0.9754      0.755 0.592 0.408
#> SRR1424669     1  0.9754      0.755 0.592 0.408
#> SRR1424670     1  0.9754      0.755 0.592 0.408
#> SRR1424671     2  0.8955     -0.414 0.312 0.688
#> SRR1424672     1  0.9754      0.755 0.592 0.408
#> SRR1424674     1  0.9754      0.755 0.592 0.408
#> SRR1424673     1  0.9754      0.755 0.592 0.408
#> SRR1424675     2  0.0000      0.394 0.000 1.000
#> SRR1424676     2  0.9686      0.830 0.396 0.604
#> SRR1424677     2  0.9754      0.826 0.408 0.592
#> SRR1424678     2  0.9686      0.830 0.396 0.604
#> SRR1424679     2  0.9686      0.830 0.396 0.604
#> SRR1424680     2  0.9686      0.830 0.396 0.604
#> SRR1424681     1  0.0672      0.442 0.992 0.008
#> SRR1424682     1  0.9710     -0.575 0.600 0.400
#> SRR1424683     2  0.0000      0.394 0.000 1.000
#> SRR1424685     1  0.9393      0.668 0.644 0.356
#> SRR1424686     1  0.0000      0.439 1.000 0.000
#> SRR1424687     2  0.9754      0.826 0.408 0.592
#> SRR1424688     2  0.0000      0.394 0.000 1.000
#> SRR1424689     2  0.9686      0.830 0.396 0.604
#> SRR1424690     2  0.9661      0.827 0.392 0.608
#> SRR1424691     2  0.9754      0.826 0.408 0.592
#> SRR1424692     2  0.3584      0.475 0.068 0.932
#> SRR1424684     2  0.9686      0.830 0.396 0.604
#> SRR1424693     2  0.9686      0.830 0.396 0.604
#> SRR1424694     2  0.9754      0.826 0.408 0.592
#> SRR1424695     2  0.9686      0.830 0.396 0.604
#> SRR1424696     2  0.9686      0.830 0.396 0.604
#> SRR1424697     1  0.9954     -0.675 0.540 0.460
#> SRR1424698     1  0.0000      0.439 1.000 0.000
#> SRR1424699     2  0.9754      0.826 0.408 0.592
#> SRR1424700     2  0.9754      0.826 0.408 0.592
#> SRR1424701     1  0.9552     -0.533 0.624 0.376
#> SRR1424702     1  0.0376      0.433 0.996 0.004
#> SRR1424703     1  0.0000      0.439 1.000 0.000
#> SRR1424704     1  0.0000      0.439 1.000 0.000
#> SRR1424706     2  0.9754      0.826 0.408 0.592
#> SRR1424707     1  0.0672      0.426 0.992 0.008

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1424656     1  0.0000      0.972 1.000 0.000 0.000
#> SRR1424657     1  0.0000      0.972 1.000 0.000 0.000
#> SRR1424658     1  0.0000      0.972 1.000 0.000 0.000
#> SRR1424659     1  0.0000      0.972 1.000 0.000 0.000
#> SRR1424660     1  0.0000      0.972 1.000 0.000 0.000
#> SRR1424661     1  0.0000      0.972 1.000 0.000 0.000
#> SRR1424662     1  0.0000      0.972 1.000 0.000 0.000
#> SRR1424663     1  0.0000      0.972 1.000 0.000 0.000
#> SRR1424664     1  0.0000      0.972 1.000 0.000 0.000
#> SRR1424665     1  0.0000      0.972 1.000 0.000 0.000
#> SRR1424666     1  0.0000      0.972 1.000 0.000 0.000
#> SRR1424667     2  0.0000      0.975 0.000 1.000 0.000
#> SRR1424668     1  0.0000      0.972 1.000 0.000 0.000
#> SRR1424669     1  0.0000      0.972 1.000 0.000 0.000
#> SRR1424670     1  0.0000      0.972 1.000 0.000 0.000
#> SRR1424671     1  0.5497      0.576 0.708 0.292 0.000
#> SRR1424672     1  0.0000      0.972 1.000 0.000 0.000
#> SRR1424674     1  0.0000      0.972 1.000 0.000 0.000
#> SRR1424673     1  0.0000      0.972 1.000 0.000 0.000
#> SRR1424675     2  0.4452      0.756 0.192 0.808 0.000
#> SRR1424676     2  0.4974      0.694 0.000 0.764 0.236
#> SRR1424677     2  0.0000      0.975 0.000 1.000 0.000
#> SRR1424678     2  0.0000      0.975 0.000 1.000 0.000
#> SRR1424679     2  0.0000      0.975 0.000 1.000 0.000
#> SRR1424680     2  0.0000      0.975 0.000 1.000 0.000
#> SRR1424681     3  0.2711      0.903 0.088 0.000 0.912
#> SRR1424682     3  0.0237      0.989 0.000 0.004 0.996
#> SRR1424683     2  0.0000      0.975 0.000 1.000 0.000
#> SRR1424685     1  0.5371      0.789 0.812 0.140 0.048
#> SRR1424686     3  0.0000      0.992 0.000 0.000 1.000
#> SRR1424687     2  0.0000      0.975 0.000 1.000 0.000
#> SRR1424688     2  0.0424      0.968 0.008 0.992 0.000
#> SRR1424689     2  0.0000      0.975 0.000 1.000 0.000
#> SRR1424690     2  0.0000      0.975 0.000 1.000 0.000
#> SRR1424691     2  0.0237      0.972 0.000 0.996 0.004
#> SRR1424692     2  0.0000      0.975 0.000 1.000 0.000
#> SRR1424684     2  0.0000      0.975 0.000 1.000 0.000
#> SRR1424693     2  0.0000      0.975 0.000 1.000 0.000
#> SRR1424694     2  0.0000      0.975 0.000 1.000 0.000
#> SRR1424695     2  0.0000      0.975 0.000 1.000 0.000
#> SRR1424696     2  0.0000      0.975 0.000 1.000 0.000
#> SRR1424697     3  0.0000      0.992 0.000 0.000 1.000
#> SRR1424698     3  0.0000      0.992 0.000 0.000 1.000
#> SRR1424699     3  0.0000      0.992 0.000 0.000 1.000
#> SRR1424700     3  0.0000      0.992 0.000 0.000 1.000
#> SRR1424701     3  0.0000      0.992 0.000 0.000 1.000
#> SRR1424702     3  0.0000      0.992 0.000 0.000 1.000
#> SRR1424703     3  0.0000      0.992 0.000 0.000 1.000
#> SRR1424704     3  0.0000      0.992 0.000 0.000 1.000
#> SRR1424706     3  0.0000      0.992 0.000 0.000 1.000
#> SRR1424707     3  0.0000      0.992 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
#> SRR1424656     1  0.0000      0.909 1.000 0.000 0.000 0.000
#> SRR1424657     1  0.0000      0.909 1.000 0.000 0.000 0.000
#> SRR1424658     1  0.0000      0.909 1.000 0.000 0.000 0.000
#> SRR1424659     1  0.0000      0.909 1.000 0.000 0.000 0.000
#> SRR1424660     1  0.0000      0.909 1.000 0.000 0.000 0.000
#> SRR1424661     1  0.0188      0.909 0.996 0.004 0.000 0.000
#> SRR1424662     1  0.0000      0.909 1.000 0.000 0.000 0.000
#> SRR1424663     1  0.0000      0.909 1.000 0.000 0.000 0.000
#> SRR1424664     1  0.0000      0.909 1.000 0.000 0.000 0.000
#> SRR1424665     1  0.0000      0.909 1.000 0.000 0.000 0.000
#> SRR1424666     1  0.3311      0.868 0.828 0.172 0.000 0.000
#> SRR1424667     4  0.3311      0.676 0.000 0.172 0.000 0.828
#> SRR1424668     1  0.3311      0.868 0.828 0.172 0.000 0.000
#> SRR1424669     1  0.4049      0.837 0.780 0.212 0.000 0.008
#> SRR1424670     1  0.3311      0.868 0.828 0.172 0.000 0.000
#> SRR1424671     1  0.7188      0.456 0.536 0.172 0.000 0.292
#> SRR1424672     1  0.3266      0.870 0.832 0.168 0.000 0.000
#> SRR1424674     1  0.2011      0.895 0.920 0.080 0.000 0.000
#> SRR1424673     1  0.3311      0.868 0.828 0.172 0.000 0.000
#> SRR1424675     4  0.5143      0.583 0.076 0.172 0.000 0.752
#> SRR1424676     2  0.3907      0.654 0.000 0.828 0.032 0.140
#> SRR1424677     4  0.4285      0.632 0.000 0.076 0.104 0.820
#> SRR1424678     2  0.4981      0.565 0.000 0.536 0.000 0.464
#> SRR1424679     2  0.4977      0.569 0.000 0.540 0.000 0.460
#> SRR1424680     4  0.0188      0.770 0.000 0.004 0.000 0.996
#> SRR1424681     2  0.4168      0.652 0.000 0.828 0.092 0.080
#> SRR1424682     2  0.5290      0.263 0.000 0.584 0.404 0.012
#> SRR1424683     4  0.2408      0.733 0.000 0.104 0.000 0.896
#> SRR1424685     2  0.2988      0.645 0.012 0.876 0.000 0.112
#> SRR1424686     3  0.2081      0.869 0.000 0.000 0.916 0.084
#> SRR1424687     4  0.0000      0.770 0.000 0.000 0.000 1.000
#> SRR1424688     4  0.4500      0.560 0.000 0.316 0.000 0.684
#> SRR1424689     4  0.4008      0.658 0.000 0.244 0.000 0.756
#> SRR1424690     4  0.4008      0.658 0.000 0.244 0.000 0.756
#> SRR1424691     4  0.4008      0.658 0.000 0.244 0.000 0.756
#> SRR1424692     4  0.2345      0.736 0.000 0.100 0.000 0.900
#> SRR1424684     2  0.4981      0.565 0.000 0.536 0.000 0.464
#> SRR1424693     4  0.4008      0.658 0.000 0.244 0.000 0.756
#> SRR1424694     4  0.0000      0.770 0.000 0.000 0.000 1.000
#> SRR1424695     4  0.0000      0.770 0.000 0.000 0.000 1.000
#> SRR1424696     4  0.0000      0.770 0.000 0.000 0.000 1.000
#> SRR1424697     3  0.0000      0.988 0.000 0.000 1.000 0.000
#> SRR1424698     3  0.0000      0.988 0.000 0.000 1.000 0.000
#> SRR1424699     3  0.0000      0.988 0.000 0.000 1.000 0.000
#> SRR1424700     3  0.0000      0.988 0.000 0.000 1.000 0.000
#> SRR1424701     3  0.0000      0.988 0.000 0.000 1.000 0.000
#> SRR1424702     3  0.0000      0.988 0.000 0.000 1.000 0.000
#> SRR1424703     3  0.0000      0.988 0.000 0.000 1.000 0.000
#> SRR1424704     3  0.0000      0.988 0.000 0.000 1.000 0.000
#> SRR1424706     3  0.0000      0.988 0.000 0.000 1.000 0.000
#> SRR1424707     3  0.0000      0.988 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
#> SRR1424656     1  0.0000      0.982 1.000 0.000 0.000 0.000 0.000
#> SRR1424657     1  0.0000      0.982 1.000 0.000 0.000 0.000 0.000
#> SRR1424658     1  0.0000      0.982 1.000 0.000 0.000 0.000 0.000
#> SRR1424659     1  0.0000      0.982 1.000 0.000 0.000 0.000 0.000
#> SRR1424660     1  0.0000      0.982 1.000 0.000 0.000 0.000 0.000
#> SRR1424661     1  0.0880      0.949 0.968 0.000 0.000 0.032 0.000
#> SRR1424662     1  0.0000      0.982 1.000 0.000 0.000 0.000 0.000
#> SRR1424663     1  0.0000      0.982 1.000 0.000 0.000 0.000 0.000
#> SRR1424664     1  0.0000      0.982 1.000 0.000 0.000 0.000 0.000
#> SRR1424665     1  0.0000      0.982 1.000 0.000 0.000 0.000 0.000
#> SRR1424666     4  0.0000      0.672 0.000 0.000 0.000 1.000 0.000
#> SRR1424667     4  0.0000      0.672 0.000 0.000 0.000 1.000 0.000
#> SRR1424668     4  0.4273      0.410 0.448 0.000 0.000 0.552 0.000
#> SRR1424669     4  0.1483      0.656 0.008 0.012 0.000 0.952 0.028
#> SRR1424670     4  0.3508      0.654 0.252 0.000 0.000 0.748 0.000
#> SRR1424671     4  0.7029      0.542 0.188 0.228 0.000 0.536 0.048
#> SRR1424672     4  0.4287      0.384 0.460 0.000 0.000 0.540 0.000
#> SRR1424674     1  0.2020      0.849 0.900 0.000 0.000 0.100 0.000
#> SRR1424673     4  0.3039      0.693 0.192 0.000 0.000 0.808 0.000
#> SRR1424675     4  0.5537      0.424 0.000 0.264 0.000 0.624 0.112
#> SRR1424676     2  0.3796      0.723 0.000 0.700 0.000 0.000 0.300
#> SRR1424677     5  0.4291      0.622 0.000 0.464 0.000 0.000 0.536
#> SRR1424678     2  0.0404      0.673 0.000 0.988 0.000 0.000 0.012
#> SRR1424679     2  0.0963      0.688 0.000 0.964 0.000 0.000 0.036
#> SRR1424680     5  0.4138      0.722 0.000 0.384 0.000 0.000 0.616
#> SRR1424681     2  0.3837      0.718 0.000 0.692 0.000 0.000 0.308
#> SRR1424682     2  0.3636      0.562 0.000 0.728 0.272 0.000 0.000
#> SRR1424683     5  0.5391      0.728 0.000 0.300 0.000 0.084 0.616
#> SRR1424685     2  0.3928      0.723 0.004 0.700 0.000 0.000 0.296
#> SRR1424686     3  0.1410      0.928 0.000 0.000 0.940 0.000 0.060
#> SRR1424687     5  0.3707      0.777 0.000 0.284 0.000 0.000 0.716
#> SRR1424688     5  0.2230      0.546 0.000 0.116 0.000 0.000 0.884
#> SRR1424689     5  0.0000      0.690 0.000 0.000 0.000 0.000 1.000
#> SRR1424690     5  0.0000      0.690 0.000 0.000 0.000 0.000 1.000
#> SRR1424691     5  0.0000      0.690 0.000 0.000 0.000 0.000 1.000
#> SRR1424692     5  0.5237      0.738 0.000 0.300 0.000 0.072 0.628
#> SRR1424684     2  0.1197      0.680 0.000 0.952 0.000 0.000 0.048
#> SRR1424693     5  0.0000      0.690 0.000 0.000 0.000 0.000 1.000
#> SRR1424694     5  0.3684      0.778 0.000 0.280 0.000 0.000 0.720
#> SRR1424695     5  0.3636      0.778 0.000 0.272 0.000 0.000 0.728
#> SRR1424696     5  0.3636      0.778 0.000 0.272 0.000 0.000 0.728
#> SRR1424697     3  0.0000      0.993 0.000 0.000 1.000 0.000 0.000
#> SRR1424698     3  0.0000      0.993 0.000 0.000 1.000 0.000 0.000
#> SRR1424699     3  0.0000      0.993 0.000 0.000 1.000 0.000 0.000
#> SRR1424700     3  0.0000      0.993 0.000 0.000 1.000 0.000 0.000
#> SRR1424701     3  0.0000      0.993 0.000 0.000 1.000 0.000 0.000
#> SRR1424702     3  0.0000      0.993 0.000 0.000 1.000 0.000 0.000
#> SRR1424703     3  0.0000      0.993 0.000 0.000 1.000 0.000 0.000
#> SRR1424704     3  0.0000      0.993 0.000 0.000 1.000 0.000 0.000
#> SRR1424706     3  0.0000      0.993 0.000 0.000 1.000 0.000 0.000
#> SRR1424707     3  0.0000      0.993 0.000 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2   p3    p4    p5    p6
#> SRR1424656     1  0.0000      0.982 1.000 0.000 0.00 0.000 0.000 0.000
#> SRR1424657     1  0.0000      0.982 1.000 0.000 0.00 0.000 0.000 0.000
#> SRR1424658     1  0.0000      0.982 1.000 0.000 0.00 0.000 0.000 0.000
#> SRR1424659     1  0.0000      0.982 1.000 0.000 0.00 0.000 0.000 0.000
#> SRR1424660     1  0.0000      0.982 1.000 0.000 0.00 0.000 0.000 0.000
#> SRR1424661     1  0.0713      0.954 0.972 0.000 0.00 0.000 0.000 0.028
#> SRR1424662     1  0.0000      0.982 1.000 0.000 0.00 0.000 0.000 0.000
#> SRR1424663     1  0.0000      0.982 1.000 0.000 0.00 0.000 0.000 0.000
#> SRR1424664     1  0.0000      0.982 1.000 0.000 0.00 0.000 0.000 0.000
#> SRR1424665     1  0.0000      0.982 1.000 0.000 0.00 0.000 0.000 0.000
#> SRR1424666     6  0.0146      0.683 0.000 0.000 0.00 0.000 0.004 0.996
#> SRR1424667     6  0.0146      0.683 0.000 0.000 0.00 0.000 0.004 0.996
#> SRR1424668     6  0.4076      0.393 0.452 0.000 0.00 0.000 0.008 0.540
#> SRR1424669     6  0.0665      0.682 0.008 0.008 0.00 0.000 0.004 0.980
#> SRR1424670     6  0.3151      0.663 0.252 0.000 0.00 0.000 0.000 0.748
#> SRR1424671     6  0.7429      0.544 0.064 0.124 0.00 0.152 0.136 0.524
#> SRR1424672     6  0.4089      0.356 0.468 0.000 0.00 0.000 0.008 0.524
#> SRR1424674     1  0.1814      0.847 0.900 0.000 0.00 0.000 0.000 0.100
#> SRR1424673     6  0.2980      0.702 0.192 0.000 0.00 0.000 0.008 0.800
#> SRR1424675     6  0.3945      0.329 0.000 0.000 0.00 0.380 0.008 0.612
#> SRR1424676     2  0.2092      0.742 0.000 0.876 0.00 0.000 0.124 0.000
#> SRR1424677     4  0.3101      0.633 0.000 0.244 0.00 0.756 0.000 0.000
#> SRR1424678     2  0.2260      0.748 0.000 0.860 0.00 0.140 0.000 0.000
#> SRR1424679     2  0.2135      0.753 0.000 0.872 0.00 0.128 0.000 0.000
#> SRR1424680     4  0.0000      0.878 0.000 0.000 0.00 1.000 0.000 0.000
#> SRR1424681     2  0.3309      0.671 0.000 0.720 0.00 0.000 0.280 0.000
#> SRR1424682     2  0.3555      0.594 0.000 0.712 0.28 0.008 0.000 0.000
#> SRR1424683     4  0.2454      0.731 0.000 0.000 0.00 0.840 0.000 0.160
#> SRR1424685     2  0.3309      0.671 0.000 0.720 0.00 0.000 0.280 0.000
#> SRR1424686     3  0.2631      0.784 0.000 0.000 0.82 0.000 0.180 0.000
#> SRR1424687     4  0.0260      0.878 0.000 0.000 0.00 0.992 0.008 0.000
#> SRR1424688     5  0.3563      0.701 0.000 0.000 0.00 0.336 0.664 0.000
#> SRR1424689     5  0.2260      0.937 0.000 0.000 0.00 0.140 0.860 0.000
#> SRR1424690     5  0.2260      0.937 0.000 0.000 0.00 0.140 0.860 0.000
#> SRR1424691     5  0.2260      0.937 0.000 0.000 0.00 0.140 0.860 0.000
#> SRR1424692     4  0.0000      0.878 0.000 0.000 0.00 1.000 0.000 0.000
#> SRR1424684     2  0.3371      0.614 0.000 0.708 0.00 0.292 0.000 0.000
#> SRR1424693     5  0.2260      0.937 0.000 0.000 0.00 0.140 0.860 0.000
#> SRR1424694     4  0.0260      0.878 0.000 0.000 0.00 0.992 0.008 0.000
#> SRR1424695     4  0.2912      0.662 0.000 0.000 0.00 0.784 0.216 0.000
#> SRR1424696     4  0.0458      0.876 0.000 0.000 0.00 0.984 0.016 0.000
#> SRR1424697     3  0.0000      0.981 0.000 0.000 1.00 0.000 0.000 0.000
#> SRR1424698     3  0.0000      0.981 0.000 0.000 1.00 0.000 0.000 0.000
#> SRR1424699     3  0.0000      0.981 0.000 0.000 1.00 0.000 0.000 0.000
#> SRR1424700     3  0.0000      0.981 0.000 0.000 1.00 0.000 0.000 0.000
#> SRR1424701     3  0.0000      0.981 0.000 0.000 1.00 0.000 0.000 0.000
#> SRR1424702     3  0.0000      0.981 0.000 0.000 1.00 0.000 0.000 0.000
#> SRR1424703     3  0.0000      0.981 0.000 0.000 1.00 0.000 0.000 0.000
#> SRR1424704     3  0.0000      0.981 0.000 0.000 1.00 0.000 0.000 0.000
#> SRR1424706     3  0.0000      0.981 0.000 0.000 1.00 0.000 0.000 0.000
#> SRR1424707     3  0.0000      0.981 0.000 0.000 1.00 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

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

collect_plots(res)

plot of chunk CV-mclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.324           0.744       0.832         0.4104 0.500   0.500
#> 3 3 0.415           0.691       0.824         0.4616 0.820   0.649
#> 4 4 0.843           0.852       0.927         0.2179 0.892   0.706
#> 5 5 0.899           0.807       0.925         0.0864 0.925   0.730
#> 6 6 0.733           0.665       0.799         0.0338 0.965   0.844

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
#> SRR1424656     1  0.0000      0.779 1.000 0.000
#> SRR1424657     1  0.0000      0.779 1.000 0.000
#> SRR1424658     1  0.0000      0.779 1.000 0.000
#> SRR1424659     1  0.5519      0.765 0.872 0.128
#> SRR1424660     1  0.0000      0.779 1.000 0.000
#> SRR1424661     1  0.8386      0.727 0.732 0.268
#> SRR1424662     1  0.8386      0.727 0.732 0.268
#> SRR1424663     1  0.0000      0.779 1.000 0.000
#> SRR1424664     1  0.0000      0.779 1.000 0.000
#> SRR1424665     1  0.0000      0.779 1.000 0.000
#> SRR1424666     1  0.8267      0.730 0.740 0.260
#> SRR1424667     1  0.8386      0.727 0.732 0.268
#> SRR1424668     1  0.0000      0.779 1.000 0.000
#> SRR1424669     1  0.8386      0.727 0.732 0.268
#> SRR1424670     1  0.0000      0.779 1.000 0.000
#> SRR1424671     1  0.8386      0.727 0.732 0.268
#> SRR1424672     1  0.8386      0.727 0.732 0.268
#> SRR1424674     1  0.0000      0.779 1.000 0.000
#> SRR1424673     1  0.8386      0.727 0.732 0.268
#> SRR1424675     1  0.8386      0.727 0.732 0.268
#> SRR1424676     2  0.8081      0.811 0.248 0.752
#> SRR1424677     2  0.8081      0.811 0.248 0.752
#> SRR1424678     2  0.8081      0.811 0.248 0.752
#> SRR1424679     2  0.8081      0.811 0.248 0.752
#> SRR1424680     2  0.8608      0.766 0.284 0.716
#> SRR1424681     2  0.8081      0.811 0.248 0.752
#> SRR1424682     2  0.8081      0.811 0.248 0.752
#> SRR1424683     1  0.8386      0.727 0.732 0.268
#> SRR1424685     2  0.8144      0.807 0.252 0.748
#> SRR1424686     2  0.9522      0.589 0.372 0.628
#> SRR1424687     2  0.8081      0.811 0.248 0.752
#> SRR1424688     2  0.9933      0.347 0.452 0.548
#> SRR1424689     2  0.8081      0.811 0.248 0.752
#> SRR1424690     2  0.8081      0.811 0.248 0.752
#> SRR1424691     2  0.8081      0.811 0.248 0.752
#> SRR1424692     1  0.8386      0.727 0.732 0.268
#> SRR1424684     2  0.8081      0.811 0.248 0.752
#> SRR1424693     2  0.8081      0.811 0.248 0.752
#> SRR1424694     2  0.9983      0.249 0.476 0.524
#> SRR1424695     2  0.8081      0.811 0.248 0.752
#> SRR1424696     2  0.8386      0.787 0.268 0.732
#> SRR1424697     2  0.1633      0.738 0.024 0.976
#> SRR1424698     2  0.0000      0.720 0.000 1.000
#> SRR1424699     2  0.1633      0.738 0.024 0.976
#> SRR1424700     2  0.1633      0.738 0.024 0.976
#> SRR1424701     2  0.0938      0.730 0.012 0.988
#> SRR1424702     2  0.0000      0.720 0.000 1.000
#> SRR1424703     2  0.0000      0.720 0.000 1.000
#> SRR1424704     2  0.1633      0.738 0.024 0.976
#> SRR1424706     2  0.1633      0.738 0.024 0.976
#> SRR1424707     2  0.0000      0.720 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
#> SRR1424656     1   0.000      0.756 1.000 0.000 0.000
#> SRR1424657     1   0.000      0.756 1.000 0.000 0.000
#> SRR1424658     1   0.000      0.756 1.000 0.000 0.000
#> SRR1424659     1   0.000      0.756 1.000 0.000 0.000
#> SRR1424660     1   0.000      0.756 1.000 0.000 0.000
#> SRR1424661     1   0.782      0.463 0.504 0.444 0.052
#> SRR1424662     1   0.782      0.463 0.504 0.444 0.052
#> SRR1424663     1   0.000      0.756 1.000 0.000 0.000
#> SRR1424664     1   0.000      0.756 1.000 0.000 0.000
#> SRR1424665     1   0.000      0.756 1.000 0.000 0.000
#> SRR1424666     1   0.327      0.712 0.884 0.116 0.000
#> SRR1424667     1   0.775      0.451 0.500 0.452 0.048
#> SRR1424668     1   0.000      0.756 1.000 0.000 0.000
#> SRR1424669     1   0.608      0.407 0.612 0.388 0.000
#> SRR1424670     1   0.000      0.756 1.000 0.000 0.000
#> SRR1424671     1   0.782      0.463 0.504 0.444 0.052
#> SRR1424672     1   0.559      0.555 0.696 0.304 0.000
#> SRR1424674     1   0.000      0.756 1.000 0.000 0.000
#> SRR1424673     1   0.608      0.529 0.612 0.388 0.000
#> SRR1424675     1   0.610      0.523 0.608 0.392 0.000
#> SRR1424676     2   0.116      0.808 0.000 0.972 0.028
#> SRR1424677     2   0.435      0.742 0.000 0.816 0.184
#> SRR1424678     2   0.116      0.808 0.000 0.972 0.028
#> SRR1424679     2   0.103      0.808 0.000 0.976 0.024
#> SRR1424680     2   0.175      0.774 0.000 0.952 0.048
#> SRR1424681     2   0.485      0.804 0.128 0.836 0.036
#> SRR1424682     2   0.388      0.727 0.000 0.848 0.152
#> SRR1424683     1   0.782      0.463 0.504 0.444 0.052
#> SRR1424685     2   0.145      0.812 0.008 0.968 0.024
#> SRR1424686     2   0.440      0.776 0.188 0.812 0.000
#> SRR1424687     2   0.388      0.727 0.000 0.848 0.152
#> SRR1424688     2   0.429      0.781 0.180 0.820 0.000
#> SRR1424689     2   0.485      0.804 0.128 0.836 0.036
#> SRR1424690     2   0.491      0.773 0.184 0.804 0.012
#> SRR1424691     2   0.462      0.800 0.144 0.836 0.020
#> SRR1424692     2   0.784     -0.419 0.460 0.488 0.052
#> SRR1424684     2   0.000      0.804 0.000 1.000 0.000
#> SRR1424693     2   0.489      0.804 0.124 0.836 0.040
#> SRR1424694     2   0.153      0.781 0.000 0.960 0.040
#> SRR1424695     2   0.445      0.796 0.152 0.836 0.012
#> SRR1424696     2   0.000      0.804 0.000 1.000 0.000
#> SRR1424697     3   0.588      0.722 0.000 0.348 0.652
#> SRR1424698     3   0.216      0.745 0.000 0.064 0.936
#> SRR1424699     3   0.588      0.722 0.000 0.348 0.652
#> SRR1424700     3   0.581      0.732 0.000 0.336 0.664
#> SRR1424701     3   0.506      0.757 0.000 0.244 0.756
#> SRR1424702     3   0.216      0.745 0.000 0.064 0.936
#> SRR1424703     3   0.216      0.745 0.000 0.064 0.936
#> SRR1424704     3   0.608      0.723 0.004 0.344 0.652
#> SRR1424706     3   0.588      0.722 0.000 0.348 0.652
#> SRR1424707     3   0.216      0.745 0.000 0.064 0.936

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1424656     1  0.3444      0.819 0.816 0.000 0.000 0.184
#> SRR1424657     1  0.3444      0.819 0.816 0.000 0.000 0.184
#> SRR1424658     1  0.3444      0.819 0.816 0.000 0.000 0.184
#> SRR1424659     1  0.0469      0.869 0.988 0.000 0.000 0.012
#> SRR1424660     1  0.0188      0.870 0.996 0.000 0.000 0.004
#> SRR1424661     4  0.0336      0.958 0.000 0.008 0.000 0.992
#> SRR1424662     4  0.0336      0.958 0.000 0.008 0.000 0.992
#> SRR1424663     1  0.0000      0.869 1.000 0.000 0.000 0.000
#> SRR1424664     1  0.0000      0.869 1.000 0.000 0.000 0.000
#> SRR1424665     1  0.3688      0.806 0.792 0.000 0.000 0.208
#> SRR1424666     1  0.0188      0.870 0.996 0.000 0.000 0.004
#> SRR1424667     4  0.3128      0.903 0.040 0.076 0.000 0.884
#> SRR1424668     1  0.3688      0.806 0.792 0.000 0.000 0.208
#> SRR1424669     2  0.5387      0.298 0.400 0.584 0.000 0.016
#> SRR1424670     1  0.0000      0.869 1.000 0.000 0.000 0.000
#> SRR1424671     4  0.0336      0.958 0.000 0.008 0.000 0.992
#> SRR1424672     1  0.0000      0.869 1.000 0.000 0.000 0.000
#> SRR1424674     1  0.0000      0.869 1.000 0.000 0.000 0.000
#> SRR1424673     1  0.3810      0.802 0.804 0.008 0.000 0.188
#> SRR1424675     1  0.5028      0.236 0.596 0.400 0.000 0.004
#> SRR1424676     2  0.0000      0.894 0.000 1.000 0.000 0.000
#> SRR1424677     2  0.2469      0.825 0.000 0.892 0.000 0.108
#> SRR1424678     2  0.0469      0.893 0.012 0.988 0.000 0.000
#> SRR1424679     2  0.0000      0.894 0.000 1.000 0.000 0.000
#> SRR1424680     2  0.4522      0.540 0.000 0.680 0.000 0.320
#> SRR1424681     2  0.0336      0.893 0.000 0.992 0.000 0.008
#> SRR1424682     2  0.4012      0.735 0.016 0.800 0.184 0.000
#> SRR1424683     4  0.1545      0.947 0.040 0.008 0.000 0.952
#> SRR1424685     2  0.0469      0.893 0.012 0.988 0.000 0.000
#> SRR1424686     2  0.5126      0.183 0.444 0.552 0.004 0.000
#> SRR1424687     2  0.0592      0.891 0.016 0.984 0.000 0.000
#> SRR1424688     2  0.0469      0.893 0.012 0.988 0.000 0.000
#> SRR1424689     2  0.0336      0.893 0.000 0.992 0.000 0.008
#> SRR1424690     2  0.0336      0.893 0.000 0.992 0.000 0.008
#> SRR1424691     2  0.0336      0.893 0.000 0.992 0.000 0.008
#> SRR1424692     4  0.2224      0.941 0.040 0.032 0.000 0.928
#> SRR1424684     2  0.0000      0.894 0.000 1.000 0.000 0.000
#> SRR1424693     2  0.0336      0.893 0.000 0.992 0.000 0.008
#> SRR1424694     2  0.3881      0.754 0.016 0.812 0.000 0.172
#> SRR1424695     2  0.0188      0.894 0.000 0.996 0.000 0.004
#> SRR1424696     2  0.0592      0.891 0.016 0.984 0.000 0.000
#> SRR1424697     3  0.0336      0.991 0.000 0.008 0.992 0.000
#> SRR1424698     3  0.0000      0.993 0.000 0.000 1.000 0.000
#> SRR1424699     3  0.0336      0.991 0.000 0.008 0.992 0.000
#> SRR1424700     3  0.0707      0.978 0.000 0.020 0.980 0.000
#> SRR1424701     3  0.0000      0.993 0.000 0.000 1.000 0.000
#> SRR1424702     3  0.0000      0.993 0.000 0.000 1.000 0.000
#> SRR1424703     3  0.0000      0.993 0.000 0.000 1.000 0.000
#> SRR1424704     3  0.0188      0.993 0.000 0.004 0.996 0.000
#> SRR1424706     3  0.0336      0.991 0.000 0.008 0.992 0.000
#> SRR1424707     3  0.0000      0.993 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
#> SRR1424656     1  0.0880     0.9484 0.968 0.000 0.000 0.032 0.000
#> SRR1424657     1  0.0880     0.9484 0.968 0.000 0.000 0.032 0.000
#> SRR1424658     1  0.0880     0.9484 0.968 0.000 0.000 0.032 0.000
#> SRR1424659     1  0.0000     0.9559 1.000 0.000 0.000 0.000 0.000
#> SRR1424660     1  0.0000     0.9559 1.000 0.000 0.000 0.000 0.000
#> SRR1424661     4  0.0000     0.9001 0.000 0.000 0.000 1.000 0.000
#> SRR1424662     4  0.0000     0.9001 0.000 0.000 0.000 1.000 0.000
#> SRR1424663     1  0.0000     0.9559 1.000 0.000 0.000 0.000 0.000
#> SRR1424664     1  0.0000     0.9559 1.000 0.000 0.000 0.000 0.000
#> SRR1424665     1  0.0963     0.9463 0.964 0.000 0.000 0.036 0.000
#> SRR1424666     1  0.0000     0.9559 1.000 0.000 0.000 0.000 0.000
#> SRR1424667     4  0.3807     0.6782 0.012 0.240 0.000 0.748 0.000
#> SRR1424668     1  0.0963     0.9463 0.964 0.000 0.000 0.036 0.000
#> SRR1424669     5  0.4735     0.0514 0.460 0.016 0.000 0.000 0.524
#> SRR1424670     1  0.0000     0.9559 1.000 0.000 0.000 0.000 0.000
#> SRR1424671     4  0.0000     0.9001 0.000 0.000 0.000 1.000 0.000
#> SRR1424672     1  0.0000     0.9559 1.000 0.000 0.000 0.000 0.000
#> SRR1424674     1  0.0000     0.9559 1.000 0.000 0.000 0.000 0.000
#> SRR1424673     1  0.0510     0.9524 0.984 0.000 0.000 0.016 0.000
#> SRR1424675     1  0.4114     0.3580 0.624 0.000 0.000 0.000 0.376
#> SRR1424676     5  0.3857     0.4979 0.000 0.312 0.000 0.000 0.688
#> SRR1424677     2  0.0000     0.7871 0.000 1.000 0.000 0.000 0.000
#> SRR1424678     2  0.0290     0.7852 0.000 0.992 0.000 0.000 0.008
#> SRR1424679     5  0.4283     0.1509 0.000 0.456 0.000 0.000 0.544
#> SRR1424680     2  0.0162     0.7849 0.000 0.996 0.000 0.004 0.000
#> SRR1424681     5  0.1121     0.8235 0.000 0.044 0.000 0.000 0.956
#> SRR1424682     2  0.4709     0.3426 0.000 0.612 0.364 0.000 0.024
#> SRR1424683     4  0.3011     0.8226 0.016 0.140 0.000 0.844 0.000
#> SRR1424685     5  0.1270     0.8191 0.000 0.052 0.000 0.000 0.948
#> SRR1424686     5  0.2233     0.7722 0.080 0.016 0.000 0.000 0.904
#> SRR1424687     2  0.3177     0.6164 0.000 0.792 0.000 0.000 0.208
#> SRR1424688     5  0.1121     0.8235 0.000 0.044 0.000 0.000 0.956
#> SRR1424689     5  0.0000     0.8294 0.000 0.000 0.000 0.000 1.000
#> SRR1424690     5  0.0000     0.8294 0.000 0.000 0.000 0.000 1.000
#> SRR1424691     5  0.0000     0.8294 0.000 0.000 0.000 0.000 1.000
#> SRR1424692     4  0.1914     0.8823 0.016 0.060 0.000 0.924 0.000
#> SRR1424684     2  0.4287    -0.0624 0.000 0.540 0.000 0.000 0.460
#> SRR1424693     5  0.0000     0.8294 0.000 0.000 0.000 0.000 1.000
#> SRR1424694     2  0.0404     0.7824 0.000 0.988 0.000 0.012 0.000
#> SRR1424695     5  0.0510     0.8292 0.000 0.016 0.000 0.000 0.984
#> SRR1424696     2  0.0000     0.7871 0.000 1.000 0.000 0.000 0.000
#> SRR1424697     3  0.0162     0.9701 0.000 0.004 0.996 0.000 0.000
#> SRR1424698     3  0.0000     0.9717 0.000 0.000 1.000 0.000 0.000
#> SRR1424699     3  0.0162     0.9701 0.000 0.004 0.996 0.000 0.000
#> SRR1424700     3  0.3039     0.7333 0.000 0.000 0.808 0.000 0.192
#> SRR1424701     3  0.0000     0.9717 0.000 0.000 1.000 0.000 0.000
#> SRR1424702     3  0.0000     0.9717 0.000 0.000 1.000 0.000 0.000
#> SRR1424703     3  0.0000     0.9717 0.000 0.000 1.000 0.000 0.000
#> SRR1424704     3  0.0000     0.9717 0.000 0.000 1.000 0.000 0.000
#> SRR1424706     3  0.0162     0.9701 0.000 0.004 0.996 0.000 0.000
#> SRR1424707     3  0.0000     0.9717 0.000 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5 p6
#> SRR1424656     1  0.3996     0.6332 0.512 0.000 0.000 0.004 0.000 NA
#> SRR1424657     1  0.3995     0.6357 0.516 0.000 0.000 0.004 0.000 NA
#> SRR1424658     1  0.3998     0.6297 0.504 0.000 0.000 0.004 0.000 NA
#> SRR1424659     1  0.3198     0.7127 0.740 0.000 0.000 0.000 0.000 NA
#> SRR1424660     1  0.0146     0.7232 0.996 0.000 0.000 0.000 0.000 NA
#> SRR1424661     4  0.0000     0.8456 0.000 0.000 0.000 1.000 0.000 NA
#> SRR1424662     4  0.0622     0.8398 0.012 0.000 0.000 0.980 0.000 NA
#> SRR1424663     1  0.0000     0.7225 1.000 0.000 0.000 0.000 0.000 NA
#> SRR1424664     1  0.2178     0.7283 0.868 0.000 0.000 0.000 0.000 NA
#> SRR1424665     1  0.4401     0.6308 0.512 0.000 0.000 0.024 0.000 NA
#> SRR1424666     1  0.0363     0.7183 0.988 0.000 0.000 0.000 0.000 NA
#> SRR1424667     4  0.4813     0.5820 0.012 0.324 0.000 0.616 0.000 NA
#> SRR1424668     1  0.5368     0.6040 0.508 0.000 0.000 0.116 0.000 NA
#> SRR1424669     1  0.5197    -0.0826 0.504 0.068 0.000 0.000 0.420 NA
#> SRR1424670     1  0.0000     0.7225 1.000 0.000 0.000 0.000 0.000 NA
#> SRR1424671     4  0.0000     0.8456 0.000 0.000 0.000 1.000 0.000 NA
#> SRR1424672     1  0.0000     0.7225 1.000 0.000 0.000 0.000 0.000 NA
#> SRR1424674     1  0.3023     0.7178 0.768 0.000 0.000 0.000 0.000 NA
#> SRR1424673     1  0.2070     0.6774 0.896 0.012 0.000 0.092 0.000 NA
#> SRR1424675     1  0.5448     0.2319 0.608 0.112 0.000 0.020 0.260 NA
#> SRR1424676     5  0.5988    -0.1005 0.000 0.364 0.000 0.000 0.404 NA
#> SRR1424677     2  0.2133     0.6469 0.000 0.912 0.000 0.020 0.016 NA
#> SRR1424678     2  0.3500     0.6226 0.000 0.768 0.000 0.000 0.028 NA
#> SRR1424679     2  0.6015    -0.0201 0.000 0.384 0.000 0.000 0.376 NA
#> SRR1424680     2  0.2129     0.6153 0.000 0.904 0.000 0.040 0.000 NA
#> SRR1424681     5  0.2868     0.7079 0.000 0.132 0.000 0.000 0.840 NA
#> SRR1424682     2  0.6184     0.4651 0.000 0.580 0.196 0.000 0.068 NA
#> SRR1424683     4  0.3968     0.8101 0.032 0.132 0.000 0.788 0.000 NA
#> SRR1424685     5  0.4077     0.4656 0.000 0.320 0.000 0.008 0.660 NA
#> SRR1424686     5  0.4549     0.5415 0.264 0.048 0.000 0.000 0.676 NA
#> SRR1424687     2  0.3627     0.5160 0.000 0.752 0.000 0.020 0.224 NA
#> SRR1424688     5  0.4364     0.6521 0.112 0.140 0.000 0.000 0.740 NA
#> SRR1424689     5  0.0000     0.7670 0.000 0.000 0.000 0.000 1.000 NA
#> SRR1424690     5  0.0000     0.7670 0.000 0.000 0.000 0.000 1.000 NA
#> SRR1424691     5  0.0000     0.7670 0.000 0.000 0.000 0.000 1.000 NA
#> SRR1424692     4  0.3897     0.8035 0.024 0.140 0.000 0.788 0.000 NA
#> SRR1424684     2  0.6001     0.0667 0.000 0.412 0.000 0.000 0.348 NA
#> SRR1424693     5  0.0000     0.7670 0.000 0.000 0.000 0.000 1.000 NA
#> SRR1424694     2  0.2216     0.6446 0.000 0.908 0.000 0.024 0.016 NA
#> SRR1424695     5  0.1387     0.7549 0.000 0.068 0.000 0.000 0.932 NA
#> SRR1424696     2  0.2318     0.6703 0.000 0.904 0.000 0.020 0.028 NA
#> SRR1424697     3  0.2062     0.9119 0.000 0.004 0.900 0.008 0.000 NA
#> SRR1424698     3  0.0000     0.9446 0.000 0.000 1.000 0.000 0.000 NA
#> SRR1424699     3  0.2838     0.8514 0.000 0.004 0.808 0.000 0.000 NA
#> SRR1424700     3  0.2491     0.8025 0.000 0.000 0.836 0.000 0.164 NA
#> SRR1424701     3  0.0000     0.9446 0.000 0.000 1.000 0.000 0.000 NA
#> SRR1424702     3  0.0000     0.9446 0.000 0.000 1.000 0.000 0.000 NA
#> SRR1424703     3  0.0000     0.9446 0.000 0.000 1.000 0.000 0.000 NA
#> SRR1424704     3  0.0000     0.9446 0.000 0.000 1.000 0.000 0.000 NA
#> SRR1424706     3  0.2062     0.9119 0.000 0.004 0.900 0.008 0.000 NA
#> SRR1424707     3  0.0000     0.9446 0.000 0.000 1.000 0.000 0.000 NA

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

consensus_heatmap(res, k = 2)

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

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

collect_plots(res)

plot of chunk CV-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.647           0.856       0.934         0.4914 0.506   0.506
#> 3 3 0.902           0.891       0.955         0.3764 0.769   0.564
#> 4 4 0.846           0.833       0.922         0.0922 0.853   0.601
#> 5 5 0.764           0.783       0.840         0.0729 0.871   0.568
#> 6 6 0.828           0.770       0.856         0.0439 0.901   0.574

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
#> SRR1424656     1   0.000    0.92153 1.000 0.000
#> SRR1424657     1   0.000    0.92153 1.000 0.000
#> SRR1424658     1   0.000    0.92153 1.000 0.000
#> SRR1424659     1   0.000    0.92153 1.000 0.000
#> SRR1424660     1   0.000    0.92153 1.000 0.000
#> SRR1424661     1   0.311    0.88195 0.944 0.056
#> SRR1424662     1   0.000    0.92153 1.000 0.000
#> SRR1424663     1   0.000    0.92153 1.000 0.000
#> SRR1424664     1   0.000    0.92153 1.000 0.000
#> SRR1424665     1   0.000    0.92153 1.000 0.000
#> SRR1424666     1   0.000    0.92153 1.000 0.000
#> SRR1424667     1   0.932    0.52370 0.652 0.348
#> SRR1424668     1   0.000    0.92153 1.000 0.000
#> SRR1424669     1   0.000    0.92153 1.000 0.000
#> SRR1424670     1   0.000    0.92153 1.000 0.000
#> SRR1424671     1   0.988    0.32404 0.564 0.436
#> SRR1424672     1   0.000    0.92153 1.000 0.000
#> SRR1424674     1   0.000    0.92153 1.000 0.000
#> SRR1424673     1   0.000    0.92153 1.000 0.000
#> SRR1424675     1   0.644    0.78513 0.836 0.164
#> SRR1424676     2   0.000    0.92944 0.000 1.000
#> SRR1424677     2   0.000    0.92944 0.000 1.000
#> SRR1424678     2   0.000    0.92944 0.000 1.000
#> SRR1424679     2   0.000    0.92944 0.000 1.000
#> SRR1424680     2   0.000    0.92944 0.000 1.000
#> SRR1424681     2   0.141    0.92541 0.020 0.980
#> SRR1424682     2   0.000    0.92944 0.000 1.000
#> SRR1424683     2   0.000    0.92944 0.000 1.000
#> SRR1424685     2   0.000    0.92944 0.000 1.000
#> SRR1424686     2   0.981    0.36140 0.420 0.580
#> SRR1424687     2   0.000    0.92944 0.000 1.000
#> SRR1424688     2   0.595    0.85761 0.144 0.856
#> SRR1424689     2   0.506    0.88401 0.112 0.888
#> SRR1424690     1   0.995   -0.00797 0.540 0.460
#> SRR1424691     2   0.625    0.84216 0.156 0.844
#> SRR1424692     2   0.000    0.92944 0.000 1.000
#> SRR1424684     2   0.000    0.92944 0.000 1.000
#> SRR1424693     2   0.000    0.92944 0.000 1.000
#> SRR1424694     2   0.000    0.92944 0.000 1.000
#> SRR1424695     2   0.118    0.92656 0.016 0.984
#> SRR1424696     2   0.000    0.92944 0.000 1.000
#> SRR1424697     2   0.184    0.92291 0.028 0.972
#> SRR1424698     2   0.482    0.88921 0.104 0.896
#> SRR1424699     2   0.000    0.92944 0.000 1.000
#> SRR1424700     2   0.388    0.90357 0.076 0.924
#> SRR1424701     2   0.552    0.87031 0.128 0.872
#> SRR1424702     2   0.506    0.88368 0.112 0.888
#> SRR1424703     2   0.482    0.88921 0.104 0.896
#> SRR1424704     2   0.949    0.49182 0.368 0.632
#> SRR1424706     2   0.000    0.92944 0.000 1.000
#> SRR1424707     2   0.482    0.88921 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
#> SRR1424656     1  0.0000     0.9665 1.000 0.000 0.000
#> SRR1424657     1  0.0000     0.9665 1.000 0.000 0.000
#> SRR1424658     1  0.0000     0.9665 1.000 0.000 0.000
#> SRR1424659     1  0.0000     0.9665 1.000 0.000 0.000
#> SRR1424660     1  0.0000     0.9665 1.000 0.000 0.000
#> SRR1424661     1  0.0424     0.9614 0.992 0.008 0.000
#> SRR1424662     1  0.0000     0.9665 1.000 0.000 0.000
#> SRR1424663     1  0.0000     0.9665 1.000 0.000 0.000
#> SRR1424664     1  0.0000     0.9665 1.000 0.000 0.000
#> SRR1424665     1  0.0000     0.9665 1.000 0.000 0.000
#> SRR1424666     1  0.0000     0.9665 1.000 0.000 0.000
#> SRR1424667     2  0.0747     0.9223 0.016 0.984 0.000
#> SRR1424668     1  0.0000     0.9665 1.000 0.000 0.000
#> SRR1424669     1  0.0592     0.9581 0.988 0.012 0.000
#> SRR1424670     1  0.0000     0.9665 1.000 0.000 0.000
#> SRR1424671     1  0.6309     0.0172 0.504 0.496 0.000
#> SRR1424672     1  0.0592     0.9571 0.988 0.000 0.012
#> SRR1424674     1  0.0000     0.9665 1.000 0.000 0.000
#> SRR1424673     1  0.0000     0.9665 1.000 0.000 0.000
#> SRR1424675     1  0.1753     0.9248 0.952 0.048 0.000
#> SRR1424676     2  0.0000     0.9350 0.000 1.000 0.000
#> SRR1424677     2  0.0000     0.9350 0.000 1.000 0.000
#> SRR1424678     2  0.0000     0.9350 0.000 1.000 0.000
#> SRR1424679     2  0.0000     0.9350 0.000 1.000 0.000
#> SRR1424680     2  0.0000     0.9350 0.000 1.000 0.000
#> SRR1424681     2  0.6154     0.3397 0.000 0.592 0.408
#> SRR1424682     2  0.2537     0.8684 0.000 0.920 0.080
#> SRR1424683     2  0.0000     0.9350 0.000 1.000 0.000
#> SRR1424685     2  0.0000     0.9350 0.000 1.000 0.000
#> SRR1424686     3  0.0237     0.9460 0.004 0.000 0.996
#> SRR1424687     2  0.0000     0.9350 0.000 1.000 0.000
#> SRR1424688     3  0.4413     0.8400 0.124 0.024 0.852
#> SRR1424689     3  0.8156     0.5878 0.160 0.196 0.644
#> SRR1424690     3  0.4062     0.8132 0.164 0.000 0.836
#> SRR1424691     3  0.0000     0.9480 0.000 0.000 1.000
#> SRR1424692     2  0.0000     0.9350 0.000 1.000 0.000
#> SRR1424684     2  0.0000     0.9350 0.000 1.000 0.000
#> SRR1424693     3  0.2261     0.8968 0.000 0.068 0.932
#> SRR1424694     2  0.0000     0.9350 0.000 1.000 0.000
#> SRR1424695     2  0.7169     0.2528 0.028 0.568 0.404
#> SRR1424696     2  0.0000     0.9350 0.000 1.000 0.000
#> SRR1424697     3  0.0000     0.9480 0.000 0.000 1.000
#> SRR1424698     3  0.0000     0.9480 0.000 0.000 1.000
#> SRR1424699     3  0.0000     0.9480 0.000 0.000 1.000
#> SRR1424700     3  0.0000     0.9480 0.000 0.000 1.000
#> SRR1424701     3  0.0000     0.9480 0.000 0.000 1.000
#> SRR1424702     3  0.0000     0.9480 0.000 0.000 1.000
#> SRR1424703     3  0.0000     0.9480 0.000 0.000 1.000
#> SRR1424704     3  0.0000     0.9480 0.000 0.000 1.000
#> SRR1424706     3  0.1031     0.9314 0.000 0.024 0.976
#> SRR1424707     3  0.0000     0.9480 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
#> SRR1424656     1  0.0336      0.941 0.992 0.008 0.000 0.000
#> SRR1424657     1  0.1211      0.926 0.960 0.040 0.000 0.000
#> SRR1424658     1  0.2011      0.893 0.920 0.080 0.000 0.000
#> SRR1424659     1  0.0921      0.933 0.972 0.028 0.000 0.000
#> SRR1424660     1  0.0188      0.942 0.996 0.004 0.000 0.000
#> SRR1424661     1  0.4843      0.358 0.604 0.000 0.000 0.396
#> SRR1424662     1  0.1389      0.925 0.952 0.000 0.000 0.048
#> SRR1424663     1  0.0188      0.942 0.996 0.004 0.000 0.000
#> SRR1424664     1  0.0336      0.941 0.992 0.008 0.000 0.000
#> SRR1424665     1  0.0000      0.942 1.000 0.000 0.000 0.000
#> SRR1424666     1  0.0469      0.939 0.988 0.000 0.000 0.012
#> SRR1424667     4  0.1118      0.825 0.036 0.000 0.000 0.964
#> SRR1424668     1  0.0000      0.942 1.000 0.000 0.000 0.000
#> SRR1424669     1  0.2149      0.891 0.912 0.000 0.000 0.088
#> SRR1424670     1  0.0376      0.942 0.992 0.004 0.000 0.004
#> SRR1424671     4  0.3266      0.716 0.168 0.000 0.000 0.832
#> SRR1424672     1  0.0657      0.940 0.984 0.000 0.012 0.004
#> SRR1424674     1  0.2647      0.850 0.880 0.120 0.000 0.000
#> SRR1424673     1  0.1389      0.925 0.952 0.000 0.000 0.048
#> SRR1424675     1  0.1302      0.928 0.956 0.000 0.000 0.044
#> SRR1424676     2  0.1211      0.855 0.000 0.960 0.000 0.040
#> SRR1424677     4  0.1022      0.833 0.000 0.032 0.000 0.968
#> SRR1424678     2  0.3486      0.769 0.000 0.812 0.000 0.188
#> SRR1424679     2  0.2647      0.825 0.000 0.880 0.000 0.120
#> SRR1424680     2  0.3266      0.788 0.000 0.832 0.000 0.168
#> SRR1424681     2  0.0000      0.856 0.000 1.000 0.000 0.000
#> SRR1424682     2  0.7336      0.321 0.000 0.528 0.216 0.256
#> SRR1424683     4  0.4888      0.153 0.000 0.412 0.000 0.588
#> SRR1424685     2  0.2589      0.827 0.000 0.884 0.000 0.116
#> SRR1424686     3  0.5250      0.209 0.008 0.440 0.552 0.000
#> SRR1424687     4  0.0592      0.838 0.000 0.016 0.000 0.984
#> SRR1424688     2  0.0469      0.853 0.012 0.988 0.000 0.000
#> SRR1424689     2  0.1489      0.843 0.004 0.952 0.044 0.000
#> SRR1424690     2  0.3300      0.756 0.008 0.848 0.144 0.000
#> SRR1424691     2  0.1109      0.850 0.004 0.968 0.028 0.000
#> SRR1424692     4  0.0336      0.839 0.000 0.008 0.000 0.992
#> SRR1424684     2  0.1389      0.854 0.000 0.952 0.000 0.048
#> SRR1424693     2  0.0592      0.855 0.000 0.984 0.016 0.000
#> SRR1424694     2  0.3649      0.708 0.000 0.796 0.000 0.204
#> SRR1424695     2  0.0188      0.855 0.004 0.996 0.000 0.000
#> SRR1424696     2  0.4250      0.667 0.000 0.724 0.000 0.276
#> SRR1424697     3  0.0000      0.947 0.000 0.000 1.000 0.000
#> SRR1424698     3  0.0000      0.947 0.000 0.000 1.000 0.000
#> SRR1424699     3  0.0188      0.943 0.000 0.000 0.996 0.004
#> SRR1424700     3  0.0000      0.947 0.000 0.000 1.000 0.000
#> SRR1424701     3  0.0000      0.947 0.000 0.000 1.000 0.000
#> SRR1424702     3  0.0000      0.947 0.000 0.000 1.000 0.000
#> SRR1424703     3  0.0000      0.947 0.000 0.000 1.000 0.000
#> SRR1424704     3  0.0000      0.947 0.000 0.000 1.000 0.000
#> SRR1424706     3  0.0000      0.947 0.000 0.000 1.000 0.000
#> SRR1424707     3  0.0000      0.947 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
#> SRR1424656     1  0.2329     0.7887 0.876 0.000 0.000 0.000 0.124
#> SRR1424657     5  0.4210     0.3563 0.412 0.000 0.000 0.000 0.588
#> SRR1424658     1  0.1608     0.8213 0.928 0.000 0.000 0.000 0.072
#> SRR1424659     1  0.1851     0.8185 0.912 0.000 0.000 0.000 0.088
#> SRR1424660     1  0.0794     0.8343 0.972 0.000 0.000 0.000 0.028
#> SRR1424661     4  0.3689     0.6218 0.256 0.000 0.000 0.740 0.004
#> SRR1424662     1  0.0579     0.8338 0.984 0.000 0.000 0.008 0.008
#> SRR1424663     1  0.1608     0.8243 0.928 0.000 0.000 0.000 0.072
#> SRR1424664     1  0.3123     0.7310 0.812 0.004 0.000 0.000 0.184
#> SRR1424665     1  0.0162     0.8352 0.996 0.000 0.000 0.000 0.004
#> SRR1424666     1  0.3333     0.8181 0.788 0.004 0.000 0.000 0.208
#> SRR1424667     4  0.3280     0.6773 0.012 0.000 0.000 0.812 0.176
#> SRR1424668     1  0.2813     0.8285 0.832 0.000 0.000 0.000 0.168
#> SRR1424669     1  0.3846     0.8140 0.776 0.004 0.000 0.020 0.200
#> SRR1424670     1  0.3003     0.8259 0.812 0.000 0.000 0.000 0.188
#> SRR1424671     4  0.5993     0.4039 0.260 0.000 0.000 0.576 0.164
#> SRR1424672     1  0.4659     0.7831 0.716 0.016 0.020 0.004 0.244
#> SRR1424674     5  0.4256    -0.2591 0.436 0.000 0.000 0.000 0.564
#> SRR1424673     1  0.3086     0.8244 0.816 0.000 0.000 0.004 0.180
#> SRR1424675     1  0.3474     0.8194 0.796 0.008 0.000 0.004 0.192
#> SRR1424676     2  0.0609     0.9318 0.000 0.980 0.000 0.000 0.020
#> SRR1424677     4  0.4278    -0.0164 0.000 0.452 0.000 0.548 0.000
#> SRR1424678     2  0.0609     0.9295 0.000 0.980 0.000 0.020 0.000
#> SRR1424679     2  0.0609     0.9318 0.000 0.980 0.000 0.000 0.020
#> SRR1424680     2  0.0579     0.9334 0.000 0.984 0.000 0.008 0.008
#> SRR1424681     2  0.1282     0.9057 0.000 0.952 0.000 0.004 0.044
#> SRR1424682     2  0.4561     0.7009 0.000 0.760 0.164 0.064 0.012
#> SRR1424683     2  0.2179     0.8499 0.000 0.888 0.000 0.112 0.000
#> SRR1424685     2  0.0290     0.9324 0.000 0.992 0.000 0.008 0.000
#> SRR1424686     5  0.4505     0.7206 0.012 0.088 0.112 0.004 0.784
#> SRR1424687     4  0.1124     0.6771 0.000 0.004 0.000 0.960 0.036
#> SRR1424688     5  0.3424     0.7473 0.000 0.240 0.000 0.000 0.760
#> SRR1424689     5  0.3650     0.7716 0.000 0.176 0.028 0.000 0.796
#> SRR1424690     5  0.4249     0.7457 0.008 0.100 0.100 0.000 0.792
#> SRR1424691     5  0.3675     0.7684 0.000 0.188 0.024 0.000 0.788
#> SRR1424692     4  0.0162     0.6892 0.000 0.004 0.000 0.996 0.000
#> SRR1424684     2  0.0609     0.9318 0.000 0.980 0.000 0.000 0.020
#> SRR1424693     5  0.4063     0.7062 0.000 0.280 0.012 0.000 0.708
#> SRR1424694     5  0.3848     0.6910 0.000 0.040 0.000 0.172 0.788
#> SRR1424695     5  0.3242     0.7584 0.000 0.216 0.000 0.000 0.784
#> SRR1424696     5  0.5167     0.6608 0.000 0.116 0.000 0.200 0.684
#> SRR1424697     3  0.0000     0.9990 0.000 0.000 1.000 0.000 0.000
#> SRR1424698     3  0.0000     0.9990 0.000 0.000 1.000 0.000 0.000
#> SRR1424699     3  0.0000     0.9990 0.000 0.000 1.000 0.000 0.000
#> SRR1424700     3  0.0000     0.9990 0.000 0.000 1.000 0.000 0.000
#> SRR1424701     3  0.0000     0.9990 0.000 0.000 1.000 0.000 0.000
#> SRR1424702     3  0.0000     0.9990 0.000 0.000 1.000 0.000 0.000
#> SRR1424703     3  0.0000     0.9990 0.000 0.000 1.000 0.000 0.000
#> SRR1424704     3  0.0000     0.9990 0.000 0.000 1.000 0.000 0.000
#> SRR1424706     3  0.0290     0.9908 0.000 0.000 0.992 0.008 0.000
#> SRR1424707     3  0.0000     0.9990 0.000 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR1424656     1  0.1327     0.8550 0.936 0.000 0.000 0.000 0.064 0.000
#> SRR1424657     1  0.3672     0.3703 0.632 0.000 0.000 0.000 0.368 0.000
#> SRR1424658     1  0.1584     0.8555 0.928 0.000 0.000 0.000 0.064 0.008
#> SRR1424659     1  0.2088     0.8361 0.904 0.000 0.000 0.000 0.028 0.068
#> SRR1424660     1  0.0806     0.8539 0.972 0.000 0.000 0.000 0.020 0.008
#> SRR1424661     4  0.4181     0.0165 0.476 0.000 0.000 0.512 0.000 0.012
#> SRR1424662     1  0.1080     0.8185 0.960 0.000 0.000 0.004 0.004 0.032
#> SRR1424663     1  0.1564     0.8537 0.936 0.000 0.000 0.000 0.024 0.040
#> SRR1424664     1  0.3118     0.7937 0.836 0.000 0.000 0.000 0.072 0.092
#> SRR1424665     1  0.0547     0.8323 0.980 0.000 0.000 0.000 0.000 0.020
#> SRR1424666     6  0.2980     0.6491 0.180 0.000 0.000 0.000 0.012 0.808
#> SRR1424667     6  0.4609     0.2733 0.016 0.004 0.000 0.452 0.008 0.520
#> SRR1424668     6  0.3986     0.5548 0.464 0.000 0.000 0.000 0.004 0.532
#> SRR1424669     6  0.3352     0.6573 0.208 0.000 0.000 0.008 0.008 0.776
#> SRR1424670     6  0.3923     0.6197 0.372 0.000 0.000 0.000 0.008 0.620
#> SRR1424671     6  0.5516     0.3859 0.108 0.000 0.000 0.368 0.008 0.516
#> SRR1424672     6  0.3625     0.6032 0.144 0.004 0.004 0.004 0.040 0.804
#> SRR1424674     6  0.5345     0.3932 0.116 0.000 0.000 0.000 0.364 0.520
#> SRR1424673     6  0.3930     0.6004 0.420 0.000 0.000 0.004 0.000 0.576
#> SRR1424675     6  0.4332     0.6508 0.344 0.020 0.000 0.000 0.008 0.628
#> SRR1424676     2  0.0260     0.9060 0.000 0.992 0.000 0.000 0.008 0.000
#> SRR1424677     2  0.3634     0.5124 0.000 0.644 0.000 0.356 0.000 0.000
#> SRR1424678     2  0.0146     0.9065 0.000 0.996 0.000 0.000 0.004 0.000
#> SRR1424679     2  0.0436     0.9056 0.000 0.988 0.000 0.004 0.004 0.004
#> SRR1424680     2  0.0146     0.9065 0.000 0.996 0.000 0.000 0.004 0.000
#> SRR1424681     2  0.2911     0.8110 0.000 0.832 0.000 0.000 0.024 0.144
#> SRR1424682     2  0.4298     0.7822 0.000 0.776 0.036 0.028 0.020 0.140
#> SRR1424683     2  0.1411     0.8771 0.000 0.936 0.000 0.060 0.000 0.004
#> SRR1424685     2  0.0436     0.9060 0.000 0.988 0.000 0.004 0.004 0.004
#> SRR1424686     5  0.3381     0.7434 0.028 0.004 0.008 0.000 0.816 0.144
#> SRR1424687     4  0.4063     0.1355 0.000 0.004 0.000 0.572 0.420 0.004
#> SRR1424688     5  0.1152     0.9268 0.000 0.044 0.000 0.000 0.952 0.004
#> SRR1424689     5  0.2044     0.9103 0.008 0.028 0.000 0.004 0.920 0.040
#> SRR1424690     5  0.0622     0.9221 0.008 0.012 0.000 0.000 0.980 0.000
#> SRR1424691     5  0.0951     0.9238 0.004 0.020 0.000 0.000 0.968 0.008
#> SRR1424692     4  0.0806     0.4055 0.000 0.008 0.000 0.972 0.020 0.000
#> SRR1424684     2  0.0551     0.9046 0.000 0.984 0.000 0.004 0.008 0.004
#> SRR1424693     5  0.2006     0.8800 0.000 0.104 0.000 0.000 0.892 0.004
#> SRR1424694     5  0.1268     0.9135 0.004 0.008 0.000 0.036 0.952 0.000
#> SRR1424695     5  0.1265     0.9267 0.008 0.044 0.000 0.000 0.948 0.000
#> SRR1424696     5  0.1738     0.9209 0.000 0.052 0.000 0.016 0.928 0.004
#> SRR1424697     3  0.0000     0.9864 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1424698     3  0.0000     0.9864 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1424699     3  0.0146     0.9843 0.000 0.000 0.996 0.000 0.004 0.000
#> SRR1424700     3  0.0692     0.9716 0.000 0.000 0.976 0.000 0.004 0.020
#> SRR1424701     3  0.0000     0.9864 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1424702     3  0.0000     0.9864 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1424703     3  0.0000     0.9864 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1424704     3  0.1858     0.9047 0.000 0.000 0.904 0.004 0.000 0.092
#> SRR1424706     3  0.0146     0.9840 0.000 0.000 0.996 0.004 0.000 0.000
#> SRR1424707     3  0.0000     0.9864 0.000 0.000 1.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-NMF-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-NMF-collect-classes

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


MAD:hclust

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

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

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

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

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

collect_plots(res)

plot of chunk MAD-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.162           0.503       0.749         0.4394 0.500   0.500
#> 3 3 0.183           0.513       0.691         0.3425 0.818   0.680
#> 4 4 0.404           0.500       0.688         0.2223 0.704   0.405
#> 5 5 0.536           0.492       0.669         0.0596 0.924   0.731
#> 6 6 0.539           0.447       0.678         0.0350 0.901   0.668

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
#> SRR1424656     1  0.8499     0.6711 0.724 0.276
#> SRR1424657     1  0.8499     0.6711 0.724 0.276
#> SRR1424658     1  0.9635     0.5818 0.612 0.388
#> SRR1424659     1  0.9248     0.6410 0.660 0.340
#> SRR1424660     1  0.8499     0.6711 0.724 0.276
#> SRR1424661     2  0.2236     0.6328 0.036 0.964
#> SRR1424662     2  0.5294     0.6091 0.120 0.880
#> SRR1424663     1  0.8386     0.6719 0.732 0.268
#> SRR1424664     1  0.9248     0.6410 0.660 0.340
#> SRR1424665     1  0.8499     0.6711 0.724 0.276
#> SRR1424666     2  0.9922     0.1020 0.448 0.552
#> SRR1424667     2  0.2043     0.6197 0.032 0.968
#> SRR1424668     1  0.1184     0.5720 0.984 0.016
#> SRR1424669     2  0.9922     0.1020 0.448 0.552
#> SRR1424670     1  0.9248     0.6410 0.660 0.340
#> SRR1424671     2  0.5408     0.5814 0.124 0.876
#> SRR1424672     1  0.0938     0.5732 0.988 0.012
#> SRR1424674     1  0.8267     0.6725 0.740 0.260
#> SRR1424673     1  0.5408     0.4587 0.876 0.124
#> SRR1424675     2  0.9286     0.2392 0.344 0.656
#> SRR1424676     1  0.9795     0.4027 0.584 0.416
#> SRR1424677     2  0.5408     0.6052 0.124 0.876
#> SRR1424678     2  0.8763     0.3379 0.296 0.704
#> SRR1424679     2  0.8763     0.3379 0.296 0.704
#> SRR1424680     2  0.2043     0.6197 0.032 0.968
#> SRR1424681     1  0.8861     0.6159 0.696 0.304
#> SRR1424682     2  0.9993     0.2832 0.484 0.516
#> SRR1424683     2  0.2236     0.6328 0.036 0.964
#> SRR1424685     1  0.8861     0.6159 0.696 0.304
#> SRR1424686     1  0.1184     0.5720 0.984 0.016
#> SRR1424687     2  0.5294     0.6066 0.120 0.880
#> SRR1424688     1  0.9686     0.5651 0.604 0.396
#> SRR1424689     2  0.9881     0.0252 0.436 0.564
#> SRR1424690     1  0.9552     0.5929 0.624 0.376
#> SRR1424691     1  0.9552     0.5929 0.624 0.376
#> SRR1424692     2  0.2236     0.6328 0.036 0.964
#> SRR1424684     2  0.8763     0.3379 0.296 0.704
#> SRR1424693     1  0.9552     0.5929 0.624 0.376
#> SRR1424694     2  0.2236     0.6328 0.036 0.964
#> SRR1424695     2  0.9087     0.2656 0.324 0.676
#> SRR1424696     2  0.8861     0.3240 0.304 0.696
#> SRR1424697     2  1.0000     0.2681 0.496 0.504
#> SRR1424698     1  0.4562     0.5337 0.904 0.096
#> SRR1424699     1  0.9996     0.3391 0.512 0.488
#> SRR1424700     1  0.9996     0.3391 0.512 0.488
#> SRR1424701     1  0.9996     0.3391 0.512 0.488
#> SRR1424702     1  0.1414     0.5624 0.980 0.020
#> SRR1424703     1  0.1633     0.5611 0.976 0.024
#> SRR1424704     1  0.2043     0.5534 0.968 0.032
#> SRR1424706     2  0.9522     0.3920 0.372 0.628
#> SRR1424707     1  0.1414     0.5624 0.980 0.020

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1424656     1  0.1315      0.599 0.972 0.020 0.008
#> SRR1424657     1  0.1315      0.599 0.972 0.020 0.008
#> SRR1424658     1  0.4953      0.479 0.808 0.176 0.016
#> SRR1424659     1  0.4139      0.539 0.860 0.124 0.016
#> SRR1424660     1  0.1315      0.599 0.972 0.020 0.008
#> SRR1424661     3  0.3116      0.780 0.108 0.000 0.892
#> SRR1424662     2  0.9173      0.470 0.264 0.536 0.200
#> SRR1424663     1  0.0983      0.600 0.980 0.016 0.004
#> SRR1424664     1  0.4139      0.539 0.860 0.124 0.016
#> SRR1424665     1  0.1315      0.599 0.972 0.020 0.008
#> SRR1424666     1  0.7694      0.186 0.616 0.316 0.068
#> SRR1424667     2  0.7633      0.493 0.132 0.684 0.184
#> SRR1424668     1  0.6834      0.562 0.740 0.148 0.112
#> SRR1424669     1  0.7694      0.186 0.616 0.316 0.068
#> SRR1424670     1  0.3690      0.555 0.884 0.100 0.016
#> SRR1424671     3  0.1031      0.736 0.024 0.000 0.976
#> SRR1424672     1  0.6764      0.563 0.744 0.148 0.108
#> SRR1424674     1  0.0983      0.600 0.980 0.016 0.004
#> SRR1424673     1  0.9029      0.409 0.504 0.352 0.144
#> SRR1424675     2  0.7001      0.679 0.340 0.628 0.032
#> SRR1424676     1  0.8505      0.343 0.600 0.256 0.144
#> SRR1424677     3  0.5356      0.749 0.196 0.020 0.784
#> SRR1424678     2  0.6224      0.750 0.296 0.688 0.016
#> SRR1424679     2  0.6224      0.750 0.296 0.688 0.016
#> SRR1424680     3  0.5954      0.693 0.092 0.116 0.792
#> SRR1424681     1  0.6719      0.534 0.744 0.096 0.160
#> SRR1424682     3  0.8556      0.501 0.256 0.148 0.596
#> SRR1424683     3  0.4489      0.766 0.108 0.036 0.856
#> SRR1424685     1  0.6719      0.534 0.744 0.096 0.160
#> SRR1424686     1  0.6902      0.561 0.736 0.148 0.116
#> SRR1424687     3  0.5406      0.748 0.200 0.020 0.780
#> SRR1424688     1  0.7807      0.420 0.656 0.236 0.108
#> SRR1424689     1  0.7054     -0.377 0.524 0.456 0.020
#> SRR1424690     1  0.7482      0.463 0.688 0.204 0.108
#> SRR1424691     1  0.7482      0.463 0.688 0.204 0.108
#> SRR1424692     3  0.3116      0.780 0.108 0.000 0.892
#> SRR1424684     2  0.6224      0.750 0.296 0.688 0.016
#> SRR1424693     1  0.7482      0.463 0.688 0.204 0.108
#> SRR1424694     3  0.3116      0.780 0.108 0.000 0.892
#> SRR1424695     2  0.8308      0.685 0.336 0.568 0.096
#> SRR1424696     2  0.8534      0.688 0.320 0.564 0.116
#> SRR1424697     3  0.8637      0.487 0.260 0.152 0.588
#> SRR1424698     1  0.9006      0.455 0.536 0.304 0.160
#> SRR1424699     1  0.8179     -0.126 0.504 0.424 0.072
#> SRR1424700     1  0.8179     -0.126 0.504 0.424 0.072
#> SRR1424701     1  0.8179     -0.126 0.504 0.424 0.072
#> SRR1424702     1  0.7441      0.543 0.700 0.164 0.136
#> SRR1424703     1  0.8120      0.525 0.640 0.224 0.136
#> SRR1424704     1  0.7615      0.537 0.688 0.164 0.148
#> SRR1424706     3  0.7447      0.628 0.160 0.140 0.700
#> SRR1424707     1  0.7441      0.543 0.700 0.164 0.136

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1424656     1  0.5705     0.5944 0.704 0.000 0.204 0.092
#> SRR1424657     1  0.5705     0.5944 0.704 0.000 0.204 0.092
#> SRR1424658     1  0.0592     0.5485 0.984 0.016 0.000 0.000
#> SRR1424659     1  0.2222     0.5710 0.924 0.016 0.060 0.000
#> SRR1424660     1  0.5705     0.5944 0.704 0.000 0.204 0.092
#> SRR1424661     4  0.0188     0.8651 0.004 0.000 0.000 0.996
#> SRR1424662     2  0.6520     0.4151 0.132 0.676 0.016 0.176
#> SRR1424663     1  0.5716     0.5898 0.700 0.000 0.212 0.088
#> SRR1424664     1  0.2222     0.5710 0.924 0.016 0.060 0.000
#> SRR1424665     1  0.5669     0.5951 0.708 0.000 0.200 0.092
#> SRR1424666     1  0.8771     0.1017 0.424 0.292 0.232 0.052
#> SRR1424667     2  0.3443     0.4998 0.016 0.848 0.000 0.136
#> SRR1424668     3  0.5217     0.2947 0.380 0.000 0.608 0.012
#> SRR1424669     1  0.8771     0.1017 0.424 0.292 0.232 0.052
#> SRR1424670     1  0.4144     0.5998 0.828 0.000 0.104 0.068
#> SRR1424671     4  0.2480     0.8036 0.000 0.008 0.088 0.904
#> SRR1424672     3  0.5099     0.2903 0.380 0.000 0.612 0.008
#> SRR1424674     1  0.5661     0.5850 0.700 0.000 0.220 0.080
#> SRR1424673     3  0.4915     0.3896 0.040 0.172 0.776 0.012
#> SRR1424675     2  0.5304     0.7028 0.036 0.740 0.208 0.016
#> SRR1424676     3  0.9211     0.0644 0.100 0.248 0.424 0.228
#> SRR1424677     4  0.2984     0.8137 0.000 0.028 0.084 0.888
#> SRR1424678     2  0.3498     0.7153 0.008 0.832 0.160 0.000
#> SRR1424679     2  0.3498     0.7153 0.008 0.832 0.160 0.000
#> SRR1424680     4  0.3266     0.8062 0.040 0.084 0.000 0.876
#> SRR1424681     3  0.8645     0.1142 0.188 0.072 0.492 0.248
#> SRR1424682     3  0.5778    -0.0994 0.000 0.028 0.500 0.472
#> SRR1424683     4  0.1211     0.8523 0.040 0.000 0.000 0.960
#> SRR1424685     3  0.8645     0.1142 0.188 0.072 0.492 0.248
#> SRR1424686     3  0.4663     0.4398 0.272 0.000 0.716 0.012
#> SRR1424687     4  0.3107     0.8175 0.000 0.036 0.080 0.884
#> SRR1424688     1  0.8930     0.2742 0.480 0.108 0.240 0.172
#> SRR1424689     2  0.7008     0.4161 0.276 0.564 0.160 0.000
#> SRR1424690     1  0.8495     0.3295 0.520 0.076 0.232 0.172
#> SRR1424691     1  0.8495     0.3295 0.520 0.076 0.232 0.172
#> SRR1424692     4  0.0188     0.8651 0.004 0.000 0.000 0.996
#> SRR1424684     2  0.3498     0.7153 0.008 0.832 0.160 0.000
#> SRR1424693     1  0.8495     0.3295 0.520 0.076 0.232 0.172
#> SRR1424694     4  0.0188     0.8651 0.004 0.000 0.000 0.996
#> SRR1424695     2  0.7871     0.6365 0.116 0.612 0.152 0.120
#> SRR1424696     2  0.7905     0.6350 0.104 0.608 0.148 0.140
#> SRR1424697     3  0.5688    -0.0742 0.000 0.024 0.512 0.464
#> SRR1424698     3  0.4286     0.3669 0.024 0.124 0.828 0.024
#> SRR1424699     2  0.6590     0.5565 0.036 0.520 0.420 0.024
#> SRR1424700     2  0.6590     0.5565 0.036 0.520 0.420 0.024
#> SRR1424701     2  0.6590     0.5565 0.036 0.520 0.420 0.024
#> SRR1424702     3  0.3024     0.5205 0.148 0.000 0.852 0.000
#> SRR1424703     3  0.1722     0.4861 0.008 0.048 0.944 0.000
#> SRR1424704     3  0.3479     0.5215 0.148 0.000 0.840 0.012
#> SRR1424706     4  0.5386     0.4136 0.000 0.024 0.344 0.632
#> SRR1424707     3  0.3024     0.5205 0.148 0.000 0.852 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
#> SRR1424656     1  0.4914      0.583 0.704 0.000 0.204 0.092 NA
#> SRR1424657     1  0.4914      0.583 0.704 0.000 0.204 0.092 NA
#> SRR1424658     1  0.2179      0.520 0.888 0.000 0.000 0.000 NA
#> SRR1424659     1  0.1740      0.544 0.932 0.000 0.012 0.000 NA
#> SRR1424660     1  0.4914      0.583 0.704 0.000 0.204 0.092 NA
#> SRR1424661     4  0.0162      0.669 0.004 0.000 0.000 0.996 NA
#> SRR1424662     2  0.7007      0.406 0.112 0.432 0.000 0.052 NA
#> SRR1424663     1  0.5301      0.574 0.688 0.000 0.212 0.088 NA
#> SRR1424664     1  0.1740      0.544 0.932 0.000 0.012 0.000 NA
#> SRR1424665     1  0.4883      0.583 0.708 0.000 0.200 0.092 NA
#> SRR1424666     1  0.7782      0.168 0.440 0.076 0.116 0.020 NA
#> SRR1424667     2  0.4227      0.497 0.000 0.580 0.000 0.000 NA
#> SRR1424668     3  0.4714      0.433 0.324 0.000 0.644 0.000 NA
#> SRR1424669     1  0.7782      0.168 0.440 0.076 0.116 0.020 NA
#> SRR1424670     1  0.4729      0.587 0.772 0.000 0.124 0.068 NA
#> SRR1424671     4  0.3949      0.493 0.000 0.000 0.000 0.668 NA
#> SRR1424672     3  0.4731      0.429 0.328 0.000 0.640 0.000 NA
#> SRR1424674     1  0.5282      0.566 0.684 0.000 0.224 0.080 NA
#> SRR1424673     3  0.6837      0.476 0.052 0.264 0.564 0.004 NA
#> SRR1424675     2  0.3228      0.674 0.016 0.860 0.016 0.004 NA
#> SRR1424676     2  0.9055      0.126 0.144 0.416 0.124 0.224 NA
#> SRR1424677     4  0.2917      0.654 0.000 0.028 0.032 0.888 NA
#> SRR1424678     2  0.0880      0.690 0.000 0.968 0.000 0.000 NA
#> SRR1424679     2  0.0880      0.690 0.000 0.968 0.000 0.000 NA
#> SRR1424680     4  0.3049      0.622 0.012 0.084 0.000 0.872 NA
#> SRR1424681     4  0.9719     -0.193 0.236 0.220 0.208 0.244 NA
#> SRR1424682     4  0.6358      0.205 0.012 0.028 0.436 0.472 NA
#> SRR1424683     4  0.1281      0.659 0.012 0.000 0.000 0.956 NA
#> SRR1424685     4  0.9719     -0.193 0.236 0.220 0.208 0.244 NA
#> SRR1424686     3  0.3523      0.640 0.140 0.004 0.824 0.000 NA
#> SRR1424687     4  0.2970      0.653 0.000 0.028 0.028 0.884 NA
#> SRR1424688     1  0.9104      0.275 0.384 0.240 0.064 0.164 NA
#> SRR1424689     2  0.5766      0.488 0.284 0.620 0.076 0.000 NA
#> SRR1424690     1  0.8953      0.349 0.424 0.200 0.064 0.164 NA
#> SRR1424691     1  0.8953      0.349 0.424 0.200 0.064 0.164 NA
#> SRR1424692     4  0.0162      0.669 0.004 0.000 0.000 0.996 NA
#> SRR1424684     2  0.0880      0.690 0.000 0.968 0.000 0.000 NA
#> SRR1424693     1  0.8953      0.349 0.424 0.200 0.064 0.164 NA
#> SRR1424694     4  0.0162      0.669 0.004 0.000 0.000 0.996 NA
#> SRR1424695     2  0.5328      0.613 0.068 0.744 0.004 0.116 NA
#> SRR1424696     2  0.5272      0.605 0.060 0.736 0.000 0.136 NA
#> SRR1424697     4  0.6043      0.160 0.012 0.020 0.464 0.464 NA
#> SRR1424698     3  0.5491      0.359 0.000 0.300 0.616 0.004 NA
#> SRR1424699     2  0.5016      0.581 0.000 0.704 0.204 0.004 NA
#> SRR1424700     2  0.5016      0.581 0.000 0.704 0.204 0.004 NA
#> SRR1424701     2  0.5016      0.581 0.000 0.704 0.204 0.004 NA
#> SRR1424702     3  0.0404      0.707 0.012 0.000 0.988 0.000 NA
#> SRR1424703     3  0.3391      0.602 0.012 0.188 0.800 0.000 NA
#> SRR1424704     3  0.0898      0.704 0.008 0.000 0.972 0.000 NA
#> SRR1424706     4  0.5342      0.427 0.000 0.020 0.308 0.632 NA
#> SRR1424707     3  0.0404      0.707 0.012 0.000 0.988 0.000 NA

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5 p6
#> SRR1424656     1  0.0000     0.5528 1.000 0.000 0.000 0.000 0.000 NA
#> SRR1424657     1  0.0000     0.5528 1.000 0.000 0.000 0.000 0.000 NA
#> SRR1424658     1  0.3950     0.3923 0.564 0.000 0.000 0.000 0.004 NA
#> SRR1424659     1  0.3795     0.4267 0.632 0.000 0.000 0.000 0.004 NA
#> SRR1424660     1  0.0000     0.5528 1.000 0.000 0.000 0.000 0.000 NA
#> SRR1424661     4  0.1753     0.7195 0.084 0.000 0.000 0.912 0.000 NA
#> SRR1424662     5  0.5300     0.7722 0.108 0.132 0.000 0.040 0.704 NA
#> SRR1424663     1  0.0862     0.5512 0.972 0.000 0.008 0.000 0.004 NA
#> SRR1424664     1  0.3795     0.4267 0.632 0.000 0.000 0.000 0.004 NA
#> SRR1424665     1  0.0146     0.5524 0.996 0.000 0.000 0.000 0.000 NA
#> SRR1424666     1  0.6776    -0.1603 0.400 0.016 0.012 0.008 0.364 NA
#> SRR1424667     5  0.3076     0.7544 0.000 0.240 0.000 0.000 0.760 NA
#> SRR1424668     1  0.5001    -0.3319 0.480 0.000 0.468 0.000 0.032 NA
#> SRR1424669     1  0.6776    -0.1603 0.400 0.016 0.012 0.008 0.364 NA
#> SRR1424670     1  0.2668     0.5218 0.828 0.000 0.004 0.000 0.000 NA
#> SRR1424671     4  0.6386     0.0886 0.000 0.000 0.084 0.488 0.092 NA
#> SRR1424672     1  0.5000    -0.3280 0.484 0.000 0.464 0.000 0.032 NA
#> SRR1424674     1  0.1148     0.5498 0.960 0.000 0.020 0.000 0.004 NA
#> SRR1424673     3  0.6904     0.5377 0.072 0.188 0.580 0.004 0.092 NA
#> SRR1424675     2  0.4407     0.5666 0.016 0.792 0.048 0.004 0.080 NA
#> SRR1424676     2  0.8066     0.0923 0.284 0.396 0.020 0.140 0.028 NA
#> SRR1424677     4  0.4063     0.6992 0.080 0.008 0.012 0.808 0.016 NA
#> SRR1424678     2  0.1010     0.6051 0.000 0.960 0.000 0.000 0.036 NA
#> SRR1424679     2  0.1010     0.6051 0.000 0.960 0.000 0.000 0.036 NA
#> SRR1424680     4  0.4072     0.6601 0.084 0.084 0.000 0.792 0.000 NA
#> SRR1424681     1  0.8305     0.1766 0.432 0.196 0.044 0.160 0.028 NA
#> SRR1424682     4  0.6199     0.2676 0.024 0.008 0.404 0.472 0.016 NA
#> SRR1424683     4  0.2527     0.7074 0.084 0.000 0.000 0.876 0.000 NA
#> SRR1424685     1  0.8305     0.1766 0.432 0.196 0.044 0.160 0.028 NA
#> SRR1424686     3  0.4935     0.5679 0.288 0.004 0.644 0.000 0.032 NA
#> SRR1424687     4  0.4175     0.6979 0.080 0.012 0.008 0.804 0.024 NA
#> SRR1424688     1  0.7399     0.2038 0.344 0.228 0.012 0.080 0.000 NA
#> SRR1424689     2  0.6145     0.3228 0.184 0.616 0.028 0.000 0.036 NA
#> SRR1424690     1  0.7287     0.2697 0.384 0.192 0.012 0.080 0.000 NA
#> SRR1424691     1  0.7287     0.2697 0.384 0.192 0.012 0.080 0.000 NA
#> SRR1424692     4  0.1610     0.7203 0.084 0.000 0.000 0.916 0.000 NA
#> SRR1424684     2  0.1010     0.6051 0.000 0.960 0.000 0.000 0.036 NA
#> SRR1424693     1  0.7287     0.2697 0.384 0.192 0.012 0.080 0.000 NA
#> SRR1424694     4  0.1610     0.7203 0.084 0.000 0.000 0.916 0.000 NA
#> SRR1424695     2  0.4827     0.5424 0.032 0.744 0.004 0.092 0.008 NA
#> SRR1424696     2  0.4797     0.5349 0.028 0.736 0.000 0.112 0.008 NA
#> SRR1424697     4  0.5592     0.1912 0.024 0.004 0.456 0.464 0.008 NA
#> SRR1424698     3  0.6318     0.3803 0.000 0.220 0.576 0.004 0.088 NA
#> SRR1424699     2  0.5943     0.5628 0.000 0.632 0.172 0.004 0.096 NA
#> SRR1424700     2  0.5943     0.5628 0.000 0.632 0.172 0.004 0.096 NA
#> SRR1424701     2  0.5943     0.5628 0.000 0.632 0.172 0.004 0.096 NA
#> SRR1424702     3  0.2300     0.7259 0.144 0.000 0.856 0.000 0.000 NA
#> SRR1424703     3  0.3971     0.6572 0.068 0.184 0.748 0.000 0.000 NA
#> SRR1424704     3  0.3010     0.7103 0.132 0.000 0.836 0.000 0.028 NA
#> SRR1424706     4  0.4795     0.4819 0.000 0.004 0.308 0.632 0.008 NA
#> SRR1424707     3  0.2300     0.7259 0.144 0.000 0.856 0.000 0.000 NA

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-hclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-hclust-collect-classes

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


MAD:kmeans

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

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

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

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

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

collect_plots(res)

plot of chunk MAD-kmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.244           0.759       0.856         0.4823 0.500   0.500
#> 3 3 0.347           0.520       0.764         0.3443 0.741   0.531
#> 4 4 0.620           0.684       0.820         0.1333 0.864   0.640
#> 5 5 0.652           0.597       0.742         0.0824 0.896   0.635
#> 6 6 0.681           0.612       0.717         0.0449 0.911   0.590

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
#> SRR1424656     1  0.5737      0.854 0.864 0.136
#> SRR1424657     1  0.5519      0.856 0.872 0.128
#> SRR1424658     1  0.8909      0.669 0.692 0.308
#> SRR1424659     1  0.5842      0.853 0.860 0.140
#> SRR1424660     1  0.0376      0.860 0.996 0.004
#> SRR1424661     2  0.9209      0.660 0.336 0.664
#> SRR1424662     2  0.4022      0.779 0.080 0.920
#> SRR1424663     1  0.1184      0.862 0.984 0.016
#> SRR1424664     1  0.5842      0.853 0.860 0.140
#> SRR1424665     1  0.7883      0.764 0.764 0.236
#> SRR1424666     1  0.0938      0.858 0.988 0.012
#> SRR1424667     2  0.0672      0.774 0.008 0.992
#> SRR1424668     1  0.0376      0.860 0.996 0.004
#> SRR1424669     1  0.6712      0.837 0.824 0.176
#> SRR1424670     1  0.5842      0.853 0.860 0.140
#> SRR1424671     2  0.7674      0.733 0.224 0.776
#> SRR1424672     1  0.0376      0.860 0.996 0.004
#> SRR1424674     1  0.5059      0.860 0.888 0.112
#> SRR1424673     2  0.9996      0.400 0.488 0.512
#> SRR1424675     2  0.0672      0.775 0.008 0.992
#> SRR1424676     2  0.7139      0.644 0.196 0.804
#> SRR1424677     2  0.4562      0.773 0.096 0.904
#> SRR1424678     2  0.0672      0.774 0.008 0.992
#> SRR1424679     2  0.7139      0.644 0.196 0.804
#> SRR1424680     2  0.0938      0.774 0.012 0.988
#> SRR1424681     1  0.0376      0.859 0.996 0.004
#> SRR1424682     2  0.9996      0.401 0.488 0.512
#> SRR1424683     2  0.6438      0.770 0.164 0.836
#> SRR1424685     1  0.1184      0.863 0.984 0.016
#> SRR1424686     1  0.0000      0.859 1.000 0.000
#> SRR1424687     2  0.8081      0.717 0.248 0.752
#> SRR1424688     1  0.7950      0.763 0.760 0.240
#> SRR1424689     1  0.8016      0.770 0.756 0.244
#> SRR1424690     1  0.5842      0.853 0.860 0.140
#> SRR1424691     1  0.1184      0.863 0.984 0.016
#> SRR1424692     2  0.5178      0.780 0.116 0.884
#> SRR1424684     2  0.7219      0.639 0.200 0.800
#> SRR1424693     1  0.5842      0.853 0.860 0.140
#> SRR1424694     2  0.6343      0.768 0.160 0.840
#> SRR1424695     1  0.8955      0.668 0.688 0.312
#> SRR1424696     2  0.0938      0.774 0.012 0.988
#> SRR1424697     2  0.9996      0.401 0.488 0.512
#> SRR1424698     1  0.5294      0.758 0.880 0.120
#> SRR1424699     2  0.1184      0.774 0.016 0.984
#> SRR1424700     2  0.9209      0.369 0.336 0.664
#> SRR1424701     1  0.8016      0.714 0.756 0.244
#> SRR1424702     1  0.2043      0.848 0.968 0.032
#> SRR1424703     1  0.2423      0.844 0.960 0.040
#> SRR1424704     1  0.1184      0.854 0.984 0.016
#> SRR1424706     2  0.9044      0.665 0.320 0.680
#> SRR1424707     1  0.2043      0.848 0.968 0.032

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1424656     1  0.0592     0.8328 0.988 0.012 0.000
#> SRR1424657     1  0.0848     0.8310 0.984 0.008 0.008
#> SRR1424658     1  0.3851     0.7505 0.860 0.136 0.004
#> SRR1424659     1  0.0592     0.8328 0.988 0.012 0.000
#> SRR1424660     1  0.2866     0.8102 0.916 0.008 0.076
#> SRR1424661     3  0.5241     0.4476 0.132 0.048 0.820
#> SRR1424662     3  0.7962     0.2783 0.352 0.072 0.576
#> SRR1424663     1  0.0424     0.8299 0.992 0.008 0.000
#> SRR1424664     1  0.0747     0.8316 0.984 0.016 0.000
#> SRR1424665     1  0.1765     0.8211 0.956 0.040 0.004
#> SRR1424666     1  0.5020     0.7299 0.796 0.012 0.192
#> SRR1424667     2  0.6215     0.2808 0.000 0.572 0.428
#> SRR1424668     1  0.4755     0.7388 0.808 0.008 0.184
#> SRR1424669     1  0.3888     0.8181 0.888 0.064 0.048
#> SRR1424670     1  0.0592     0.8328 0.988 0.012 0.000
#> SRR1424671     3  0.2165     0.4221 0.000 0.064 0.936
#> SRR1424672     1  0.5115     0.7313 0.796 0.016 0.188
#> SRR1424674     1  0.0592     0.8328 0.988 0.012 0.000
#> SRR1424673     3  0.5852     0.4178 0.060 0.152 0.788
#> SRR1424675     2  0.5737     0.5058 0.012 0.732 0.256
#> SRR1424676     2  0.4799     0.5501 0.032 0.836 0.132
#> SRR1424677     3  0.4931     0.2946 0.000 0.232 0.768
#> SRR1424678     2  0.5678     0.4499 0.000 0.684 0.316
#> SRR1424679     2  0.5119     0.5532 0.032 0.816 0.152
#> SRR1424680     3  0.6286    -0.1768 0.000 0.464 0.536
#> SRR1424681     1  0.7564     0.6967 0.692 0.152 0.156
#> SRR1424682     3  0.6245     0.4009 0.060 0.180 0.760
#> SRR1424683     3  0.6677     0.4098 0.168 0.088 0.744
#> SRR1424685     1  0.7026     0.7337 0.728 0.152 0.120
#> SRR1424686     1  0.6587     0.7405 0.752 0.092 0.156
#> SRR1424687     3  0.6181     0.4293 0.156 0.072 0.772
#> SRR1424688     1  0.5115     0.7566 0.768 0.228 0.004
#> SRR1424689     1  0.6047     0.6572 0.680 0.312 0.008
#> SRR1424690     1  0.4291     0.8012 0.840 0.152 0.008
#> SRR1424691     1  0.4390     0.7989 0.840 0.148 0.012
#> SRR1424692     3  0.4887     0.2965 0.000 0.228 0.772
#> SRR1424684     2  0.5239     0.5520 0.032 0.808 0.160
#> SRR1424693     1  0.4861     0.7809 0.800 0.192 0.008
#> SRR1424694     3  0.6929     0.3670 0.260 0.052 0.688
#> SRR1424695     1  0.5929     0.6420 0.676 0.320 0.004
#> SRR1424696     2  0.6434     0.3686 0.008 0.612 0.380
#> SRR1424697     3  0.5743     0.4134 0.044 0.172 0.784
#> SRR1424698     2  0.9274    -0.0844 0.160 0.456 0.384
#> SRR1424699     2  0.2165     0.5108 0.000 0.936 0.064
#> SRR1424700     2  0.0592     0.4970 0.012 0.988 0.000
#> SRR1424701     2  0.8058     0.0222 0.072 0.552 0.376
#> SRR1424702     3  0.9868     0.0575 0.256 0.360 0.384
#> SRR1424703     2  0.9596    -0.1259 0.200 0.416 0.384
#> SRR1424704     3  0.9963     0.0725 0.316 0.308 0.376
#> SRR1424706     3  0.4390     0.4195 0.012 0.148 0.840
#> SRR1424707     3  0.9868     0.0575 0.256 0.360 0.384

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1424656     1  0.0000      0.763 1.000 0.000 0.000 0.000
#> SRR1424657     1  0.0707      0.762 0.980 0.000 0.000 0.020
#> SRR1424658     1  0.1114      0.760 0.972 0.008 0.004 0.016
#> SRR1424659     1  0.0188      0.763 0.996 0.004 0.000 0.000
#> SRR1424660     1  0.5371      0.585 0.728 0.020 0.224 0.028
#> SRR1424661     4  0.1985      0.916 0.020 0.012 0.024 0.944
#> SRR1424662     4  0.4167      0.801 0.128 0.036 0.008 0.828
#> SRR1424663     1  0.1958      0.754 0.944 0.020 0.008 0.028
#> SRR1424664     1  0.0376      0.763 0.992 0.004 0.000 0.004
#> SRR1424665     1  0.0967      0.760 0.976 0.004 0.004 0.016
#> SRR1424666     1  0.6416      0.432 0.616 0.044 0.316 0.024
#> SRR1424667     2  0.4820      0.625 0.000 0.692 0.012 0.296
#> SRR1424668     1  0.6244      0.400 0.596 0.024 0.352 0.028
#> SRR1424669     1  0.5690      0.633 0.744 0.068 0.164 0.024
#> SRR1424670     1  0.0188      0.763 0.996 0.004 0.000 0.000
#> SRR1424671     4  0.2255      0.894 0.000 0.012 0.068 0.920
#> SRR1424672     1  0.6656      0.314 0.528 0.036 0.408 0.028
#> SRR1424674     1  0.0895      0.763 0.976 0.004 0.000 0.020
#> SRR1424673     3  0.4993      0.582 0.000 0.028 0.712 0.260
#> SRR1424675     2  0.3813      0.824 0.000 0.828 0.024 0.148
#> SRR1424676     2  0.2644      0.807 0.000 0.908 0.032 0.060
#> SRR1424677     4  0.2002      0.904 0.000 0.044 0.020 0.936
#> SRR1424678     2  0.3448      0.812 0.000 0.828 0.004 0.168
#> SRR1424679     2  0.3037      0.826 0.000 0.888 0.036 0.076
#> SRR1424680     4  0.2973      0.820 0.000 0.144 0.000 0.856
#> SRR1424681     3  0.8193     -0.225 0.376 0.152 0.436 0.036
#> SRR1424682     3  0.3539      0.692 0.000 0.004 0.820 0.176
#> SRR1424683     4  0.1394      0.921 0.016 0.008 0.012 0.964
#> SRR1424685     3  0.8294     -0.219 0.364 0.168 0.432 0.036
#> SRR1424686     1  0.6656      0.325 0.528 0.036 0.408 0.028
#> SRR1424687     4  0.1892      0.913 0.036 0.004 0.016 0.944
#> SRR1424688     1  0.6886      0.644 0.664 0.180 0.120 0.036
#> SRR1424689     1  0.6156      0.657 0.696 0.212 0.068 0.024
#> SRR1424690     1  0.6329      0.664 0.700 0.152 0.128 0.020
#> SRR1424691     1  0.6755      0.652 0.676 0.152 0.140 0.032
#> SRR1424692     4  0.1388      0.916 0.000 0.028 0.012 0.960
#> SRR1424684     2  0.2943      0.826 0.000 0.892 0.032 0.076
#> SRR1424693     1  0.6616      0.646 0.672 0.180 0.128 0.020
#> SRR1424694     4  0.1543      0.910 0.032 0.008 0.004 0.956
#> SRR1424695     1  0.5859      0.666 0.724 0.192 0.056 0.028
#> SRR1424696     2  0.3400      0.805 0.000 0.820 0.000 0.180
#> SRR1424697     3  0.4059      0.669 0.000 0.012 0.788 0.200
#> SRR1424698     3  0.1256      0.745 0.000 0.028 0.964 0.008
#> SRR1424699     2  0.5105      0.668 0.000 0.696 0.276 0.028
#> SRR1424700     2  0.4988      0.662 0.000 0.692 0.288 0.020
#> SRR1424701     3  0.2402      0.708 0.000 0.076 0.912 0.012
#> SRR1424702     3  0.0672      0.751 0.008 0.008 0.984 0.000
#> SRR1424703     3  0.1443      0.746 0.004 0.028 0.960 0.008
#> SRR1424704     3  0.0895      0.750 0.020 0.004 0.976 0.000
#> SRR1424706     3  0.4630      0.612 0.000 0.016 0.732 0.252
#> SRR1424707     3  0.1042      0.751 0.008 0.020 0.972 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
#> SRR1424656     1  0.0000     0.6395 1.000 0.000 0.000 0.000 0.000
#> SRR1424657     1  0.1041     0.6352 0.964 0.004 0.000 0.000 0.032
#> SRR1424658     1  0.2390     0.5600 0.896 0.020 0.000 0.000 0.084
#> SRR1424659     1  0.1018     0.6375 0.968 0.016 0.000 0.000 0.016
#> SRR1424660     1  0.4910     0.4083 0.672 0.004 0.048 0.000 0.276
#> SRR1424661     4  0.1603     0.8513 0.004 0.032 0.004 0.948 0.012
#> SRR1424662     4  0.6962     0.5216 0.232 0.052 0.004 0.564 0.148
#> SRR1424663     1  0.3662     0.4840 0.744 0.004 0.000 0.000 0.252
#> SRR1424664     1  0.0898     0.6375 0.972 0.008 0.000 0.000 0.020
#> SRR1424665     1  0.1670     0.6001 0.936 0.012 0.000 0.000 0.052
#> SRR1424666     1  0.6932     0.2434 0.484 0.028 0.100 0.016 0.372
#> SRR1424667     2  0.5003     0.6073 0.000 0.720 0.004 0.140 0.136
#> SRR1424668     1  0.6436     0.2045 0.528 0.012 0.096 0.012 0.352
#> SRR1424669     1  0.5294     0.3599 0.560 0.028 0.004 0.008 0.400
#> SRR1424670     1  0.1082     0.6382 0.964 0.008 0.000 0.000 0.028
#> SRR1424671     4  0.2122     0.8426 0.000 0.032 0.008 0.924 0.036
#> SRR1424672     5  0.6883     0.0129 0.392 0.004 0.144 0.020 0.440
#> SRR1424674     1  0.2361     0.5727 0.892 0.012 0.000 0.000 0.096
#> SRR1424673     3  0.6952     0.6042 0.000 0.036 0.528 0.240 0.196
#> SRR1424675     2  0.1568     0.7771 0.000 0.944 0.000 0.036 0.020
#> SRR1424676     2  0.4127     0.5500 0.000 0.680 0.000 0.008 0.312
#> SRR1424677     4  0.1442     0.8601 0.000 0.032 0.012 0.952 0.004
#> SRR1424678     2  0.1608     0.7725 0.000 0.928 0.000 0.072 0.000
#> SRR1424679     2  0.1877     0.7845 0.000 0.924 0.000 0.012 0.064
#> SRR1424680     4  0.4197     0.6303 0.000 0.244 0.000 0.728 0.028
#> SRR1424681     5  0.5569     0.4512 0.164 0.012 0.132 0.004 0.688
#> SRR1424682     3  0.5525     0.7356 0.000 0.008 0.664 0.212 0.116
#> SRR1424683     4  0.1547     0.8601 0.004 0.032 0.000 0.948 0.016
#> SRR1424685     5  0.5153     0.4691 0.148 0.012 0.108 0.004 0.728
#> SRR1424686     5  0.6542     0.1899 0.328 0.004 0.164 0.004 0.500
#> SRR1424687     4  0.3578     0.7880 0.004 0.016 0.004 0.812 0.164
#> SRR1424688     5  0.6168     0.4819 0.396 0.048 0.044 0.000 0.512
#> SRR1424689     5  0.6838     0.4032 0.404 0.080 0.044 0.008 0.464
#> SRR1424690     5  0.5685     0.5143 0.408 0.016 0.048 0.000 0.528
#> SRR1424691     5  0.5737     0.5330 0.376 0.016 0.056 0.000 0.552
#> SRR1424692     4  0.0865     0.8613 0.000 0.024 0.004 0.972 0.000
#> SRR1424684     2  0.2069     0.7830 0.000 0.912 0.000 0.012 0.076
#> SRR1424693     5  0.5895     0.5252 0.392 0.028 0.048 0.000 0.532
#> SRR1424694     4  0.1770     0.8559 0.008 0.008 0.000 0.936 0.048
#> SRR1424695     1  0.6313    -0.4682 0.460 0.060 0.040 0.000 0.440
#> SRR1424696     2  0.3476     0.7467 0.000 0.836 0.000 0.088 0.076
#> SRR1424697     3  0.4855     0.7591 0.000 0.004 0.716 0.204 0.076
#> SRR1424698     3  0.0404     0.7826 0.000 0.000 0.988 0.000 0.012
#> SRR1424699     2  0.4801     0.5446 0.000 0.604 0.372 0.004 0.020
#> SRR1424700     2  0.4961     0.5378 0.000 0.596 0.372 0.004 0.028
#> SRR1424701     3  0.1668     0.7430 0.000 0.028 0.940 0.000 0.032
#> SRR1424702     3  0.2921     0.8045 0.000 0.000 0.856 0.020 0.124
#> SRR1424703     3  0.0404     0.7826 0.000 0.000 0.988 0.000 0.012
#> SRR1424704     3  0.2969     0.8026 0.000 0.000 0.852 0.020 0.128
#> SRR1424706     3  0.4070     0.6960 0.000 0.004 0.728 0.256 0.012
#> SRR1424707     3  0.2722     0.8084 0.000 0.000 0.872 0.020 0.108

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR1424656     1  0.0260     0.7121 0.992 0.000 0.000 0.000 0.000 0.008
#> SRR1424657     1  0.1267     0.6912 0.940 0.000 0.000 0.000 0.000 0.060
#> SRR1424658     1  0.1124     0.7011 0.956 0.000 0.000 0.000 0.036 0.008
#> SRR1424659     1  0.1155     0.7095 0.956 0.004 0.000 0.000 0.004 0.036
#> SRR1424660     6  0.4393     0.2127 0.480 0.000 0.016 0.000 0.004 0.500
#> SRR1424661     4  0.1793     0.8468 0.000 0.016 0.004 0.932 0.008 0.040
#> SRR1424662     1  0.8257     0.0635 0.348 0.036 0.004 0.224 0.180 0.208
#> SRR1424663     1  0.3955    -0.0718 0.560 0.000 0.000 0.000 0.004 0.436
#> SRR1424664     1  0.1442     0.7072 0.944 0.004 0.000 0.000 0.012 0.040
#> SRR1424665     1  0.1176     0.7073 0.956 0.000 0.000 0.000 0.020 0.024
#> SRR1424666     6  0.5610     0.3549 0.288 0.016 0.028 0.000 0.064 0.604
#> SRR1424667     2  0.6467     0.4771 0.000 0.540 0.004 0.056 0.184 0.216
#> SRR1424668     6  0.4658     0.4861 0.340 0.000 0.040 0.000 0.008 0.612
#> SRR1424669     1  0.6652     0.1798 0.396 0.024 0.004 0.000 0.256 0.320
#> SRR1424670     1  0.1732     0.7017 0.920 0.004 0.000 0.000 0.004 0.072
#> SRR1424671     4  0.3390     0.8210 0.000 0.016 0.016 0.848 0.048 0.072
#> SRR1424672     6  0.5303     0.5698 0.244 0.000 0.060 0.000 0.052 0.644
#> SRR1424674     1  0.3314     0.4352 0.740 0.000 0.000 0.000 0.004 0.256
#> SRR1424673     6  0.6569    -0.3129 0.000 0.016 0.384 0.168 0.020 0.412
#> SRR1424675     2  0.2487     0.7366 0.000 0.892 0.004 0.004 0.048 0.052
#> SRR1424676     2  0.3398     0.5717 0.000 0.740 0.000 0.000 0.252 0.008
#> SRR1424677     4  0.1604     0.8548 0.000 0.008 0.008 0.944 0.016 0.024
#> SRR1424678     2  0.1049     0.7386 0.000 0.960 0.000 0.032 0.008 0.000
#> SRR1424679     2  0.1204     0.7442 0.000 0.944 0.000 0.000 0.056 0.000
#> SRR1424680     4  0.4470     0.4973 0.000 0.300 0.000 0.656 0.032 0.012
#> SRR1424681     6  0.5542     0.3156 0.056 0.004 0.036 0.000 0.340 0.564
#> SRR1424682     3  0.6023     0.6461 0.000 0.016 0.600 0.172 0.024 0.188
#> SRR1424683     4  0.0436     0.8660 0.000 0.004 0.000 0.988 0.004 0.004
#> SRR1424685     6  0.5416     0.2798 0.048 0.004 0.032 0.000 0.356 0.560
#> SRR1424686     6  0.5927     0.5795 0.188 0.000 0.064 0.000 0.136 0.612
#> SRR1424687     4  0.5138     0.6634 0.004 0.016 0.008 0.676 0.220 0.076
#> SRR1424688     5  0.5541     0.8539 0.252 0.020 0.012 0.004 0.632 0.080
#> SRR1424689     5  0.4773     0.7836 0.232 0.036 0.020 0.000 0.696 0.016
#> SRR1424690     5  0.5254     0.8612 0.224 0.000 0.016 0.000 0.640 0.120
#> SRR1424691     5  0.5475     0.8175 0.200 0.000 0.016 0.000 0.620 0.164
#> SRR1424692     4  0.0000     0.8663 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1424684     2  0.1588     0.7412 0.000 0.924 0.000 0.000 0.072 0.004
#> SRR1424693     5  0.5478     0.8722 0.216 0.012 0.016 0.004 0.652 0.100
#> SRR1424694     4  0.0951     0.8631 0.000 0.004 0.000 0.968 0.020 0.008
#> SRR1424695     5  0.4335     0.8187 0.292 0.024 0.008 0.004 0.672 0.000
#> SRR1424696     2  0.3677     0.6856 0.000 0.804 0.000 0.064 0.120 0.012
#> SRR1424697     3  0.5353     0.6900 0.000 0.008 0.664 0.184 0.020 0.124
#> SRR1424698     3  0.1483     0.7488 0.000 0.008 0.944 0.000 0.036 0.012
#> SRR1424699     2  0.5762     0.4300 0.000 0.512 0.372 0.000 0.080 0.036
#> SRR1424700     2  0.5855     0.4128 0.000 0.496 0.380 0.000 0.088 0.036
#> SRR1424701     3  0.3005     0.6671 0.000 0.016 0.856 0.000 0.092 0.036
#> SRR1424702     3  0.2955     0.7486 0.004 0.000 0.816 0.000 0.008 0.172
#> SRR1424703     3  0.1167     0.7545 0.000 0.008 0.960 0.000 0.020 0.012
#> SRR1424704     3  0.3154     0.7390 0.004 0.000 0.800 0.000 0.012 0.184
#> SRR1424706     3  0.4558     0.6315 0.000 0.008 0.700 0.240 0.016 0.036
#> SRR1424707     3  0.2655     0.7608 0.004 0.000 0.848 0.000 0.008 0.140

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

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

collect_plots(res)

plot of chunk MAD-skmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.615           0.775       0.904         0.5037 0.500   0.500
#> 3 3 0.622           0.665       0.859         0.3308 0.770   0.567
#> 4 4 0.674           0.563       0.801         0.1264 0.864   0.623
#> 5 5 0.721           0.787       0.878         0.0644 0.891   0.608
#> 6 6 0.790           0.707       0.840         0.0457 0.935   0.691

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

suggest_best_k(res)
#> [1] 2

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette    p1    p2
#> SRR1424656     1  0.0000      0.877 1.000 0.000
#> SRR1424657     1  0.0000      0.877 1.000 0.000
#> SRR1424658     1  0.9608      0.464 0.616 0.384
#> SRR1424659     1  0.0000      0.877 1.000 0.000
#> SRR1424660     1  0.0000      0.877 1.000 0.000
#> SRR1424661     2  0.9286      0.522 0.344 0.656
#> SRR1424662     2  0.0000      0.880 0.000 1.000
#> SRR1424663     1  0.0000      0.877 1.000 0.000
#> SRR1424664     1  0.0000      0.877 1.000 0.000
#> SRR1424665     1  0.9491      0.492 0.632 0.368
#> SRR1424666     1  0.0000      0.877 1.000 0.000
#> SRR1424667     2  0.0000      0.880 0.000 1.000
#> SRR1424668     1  0.0000      0.877 1.000 0.000
#> SRR1424669     1  0.3584      0.822 0.932 0.068
#> SRR1424670     1  0.0000      0.877 1.000 0.000
#> SRR1424671     2  0.0000      0.880 0.000 1.000
#> SRR1424672     1  0.0000      0.877 1.000 0.000
#> SRR1424674     1  0.0000      0.877 1.000 0.000
#> SRR1424673     2  0.9608      0.455 0.384 0.616
#> SRR1424675     2  0.0000      0.880 0.000 1.000
#> SRR1424676     2  0.0938      0.870 0.012 0.988
#> SRR1424677     2  0.0000      0.880 0.000 1.000
#> SRR1424678     2  0.0000      0.880 0.000 1.000
#> SRR1424679     2  0.0000      0.880 0.000 1.000
#> SRR1424680     2  0.0000      0.880 0.000 1.000
#> SRR1424681     1  0.0000      0.877 1.000 0.000
#> SRR1424682     2  0.9608      0.455 0.384 0.616
#> SRR1424683     2  0.0000      0.880 0.000 1.000
#> SRR1424685     1  0.0000      0.877 1.000 0.000
#> SRR1424686     1  0.0000      0.877 1.000 0.000
#> SRR1424687     2  0.0000      0.880 0.000 1.000
#> SRR1424688     1  0.9608      0.464 0.616 0.384
#> SRR1424689     1  0.9358      0.517 0.648 0.352
#> SRR1424690     1  0.0000      0.877 1.000 0.000
#> SRR1424691     1  0.0000      0.877 1.000 0.000
#> SRR1424692     2  0.0000      0.880 0.000 1.000
#> SRR1424684     2  0.0000      0.880 0.000 1.000
#> SRR1424693     1  0.9286      0.528 0.656 0.344
#> SRR1424694     2  0.0000      0.880 0.000 1.000
#> SRR1424695     1  0.9608      0.464 0.616 0.384
#> SRR1424696     2  0.0000      0.880 0.000 1.000
#> SRR1424697     2  0.9608      0.455 0.384 0.616
#> SRR1424698     1  0.7528      0.623 0.784 0.216
#> SRR1424699     2  0.0000      0.880 0.000 1.000
#> SRR1424700     2  0.7139      0.645 0.196 0.804
#> SRR1424701     1  0.9129      0.489 0.672 0.328
#> SRR1424702     1  0.0000      0.877 1.000 0.000
#> SRR1424703     1  0.0000      0.877 1.000 0.000
#> SRR1424704     1  0.0000      0.877 1.000 0.000
#> SRR1424706     2  0.9248      0.527 0.340 0.660
#> SRR1424707     1  0.0000      0.877 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
#> SRR1424656     1  0.0000     0.7566 1.000 0.000 0.000
#> SRR1424657     1  0.0000     0.7566 1.000 0.000 0.000
#> SRR1424658     1  0.0424     0.7544 0.992 0.008 0.000
#> SRR1424659     1  0.0000     0.7566 1.000 0.000 0.000
#> SRR1424660     1  0.6008     0.4044 0.628 0.000 0.372
#> SRR1424661     2  0.1411     0.8896 0.000 0.964 0.036
#> SRR1424662     2  0.2356     0.8540 0.072 0.928 0.000
#> SRR1424663     1  0.0000     0.7566 1.000 0.000 0.000
#> SRR1424664     1  0.0000     0.7566 1.000 0.000 0.000
#> SRR1424665     1  0.0424     0.7544 0.992 0.008 0.000
#> SRR1424666     1  0.6252     0.2542 0.556 0.000 0.444
#> SRR1424667     2  0.0000     0.9026 0.000 1.000 0.000
#> SRR1424668     1  0.6079     0.3796 0.612 0.000 0.388
#> SRR1424669     1  0.7295     0.3411 0.584 0.036 0.380
#> SRR1424670     1  0.0000     0.7566 1.000 0.000 0.000
#> SRR1424671     2  0.1411     0.8896 0.000 0.964 0.036
#> SRR1424672     1  0.6095     0.3720 0.608 0.000 0.392
#> SRR1424674     1  0.0000     0.7566 1.000 0.000 0.000
#> SRR1424673     3  0.4702     0.6767 0.000 0.212 0.788
#> SRR1424675     2  0.0592     0.9016 0.000 0.988 0.012
#> SRR1424676     2  0.4702     0.7146 0.000 0.788 0.212
#> SRR1424677     2  0.0592     0.9023 0.000 0.988 0.012
#> SRR1424678     2  0.0592     0.9016 0.000 0.988 0.012
#> SRR1424679     2  0.4702     0.7146 0.000 0.788 0.212
#> SRR1424680     2  0.0000     0.9026 0.000 1.000 0.000
#> SRR1424681     3  0.6140    -0.1073 0.404 0.000 0.596
#> SRR1424682     3  0.4702     0.6767 0.000 0.212 0.788
#> SRR1424683     2  0.0424     0.9028 0.000 0.992 0.008
#> SRR1424685     3  0.6154    -0.1190 0.408 0.000 0.592
#> SRR1424686     1  0.6286     0.2764 0.536 0.000 0.464
#> SRR1424687     2  0.0592     0.9023 0.000 0.988 0.012
#> SRR1424688     1  0.4978     0.6705 0.780 0.004 0.216
#> SRR1424689     1  0.5506     0.6601 0.764 0.016 0.220
#> SRR1424690     1  0.4605     0.6783 0.796 0.000 0.204
#> SRR1424691     1  0.4605     0.6783 0.796 0.000 0.204
#> SRR1424692     2  0.0592     0.9023 0.000 0.988 0.012
#> SRR1424684     2  0.4346     0.7489 0.000 0.816 0.184
#> SRR1424693     1  0.4978     0.6705 0.780 0.004 0.216
#> SRR1424694     2  0.1399     0.8923 0.028 0.968 0.004
#> SRR1424695     1  0.5268     0.6678 0.776 0.012 0.212
#> SRR1424696     2  0.0592     0.9016 0.000 0.988 0.012
#> SRR1424697     3  0.4702     0.6767 0.000 0.212 0.788
#> SRR1424698     3  0.0000     0.7382 0.000 0.000 1.000
#> SRR1424699     2  0.6095     0.3006 0.000 0.608 0.392
#> SRR1424700     3  0.6140     0.0201 0.000 0.404 0.596
#> SRR1424701     3  0.0424     0.7350 0.000 0.008 0.992
#> SRR1424702     3  0.0592     0.7374 0.012 0.000 0.988
#> SRR1424703     3  0.0000     0.7382 0.000 0.000 1.000
#> SRR1424704     3  0.0592     0.7374 0.012 0.000 0.988
#> SRR1424706     3  0.4750     0.6724 0.000 0.216 0.784
#> SRR1424707     3  0.0592     0.7374 0.012 0.000 0.988

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1424656     1  0.0000     0.6869 1.000 0.000 0.000 0.000
#> SRR1424657     1  0.0000     0.6869 1.000 0.000 0.000 0.000
#> SRR1424658     1  0.2266     0.6265 0.912 0.084 0.000 0.004
#> SRR1424659     1  0.0000     0.6869 1.000 0.000 0.000 0.000
#> SRR1424660     1  0.4790     0.3180 0.620 0.000 0.380 0.000
#> SRR1424661     4  0.0376     0.9851 0.004 0.000 0.004 0.992
#> SRR1424662     4  0.1489     0.9383 0.044 0.004 0.000 0.952
#> SRR1424663     1  0.0000     0.6869 1.000 0.000 0.000 0.000
#> SRR1424664     1  0.0000     0.6869 1.000 0.000 0.000 0.000
#> SRR1424665     1  0.1302     0.6618 0.956 0.044 0.000 0.000
#> SRR1424666     1  0.5000     0.0757 0.500 0.000 0.500 0.000
#> SRR1424667     2  0.4866     0.4219 0.000 0.596 0.000 0.404
#> SRR1424668     1  0.4898     0.2627 0.584 0.000 0.416 0.000
#> SRR1424669     2  0.5165     0.1019 0.484 0.512 0.004 0.000
#> SRR1424670     1  0.0000     0.6869 1.000 0.000 0.000 0.000
#> SRR1424671     4  0.0336     0.9837 0.000 0.000 0.008 0.992
#> SRR1424672     1  0.4992     0.1641 0.524 0.000 0.476 0.000
#> SRR1424674     1  0.0000     0.6869 1.000 0.000 0.000 0.000
#> SRR1424673     3  0.4454     0.5337 0.000 0.000 0.692 0.308
#> SRR1424675     2  0.4713     0.4859 0.000 0.640 0.000 0.360
#> SRR1424676     2  0.0469     0.6123 0.000 0.988 0.000 0.012
#> SRR1424677     4  0.0188     0.9861 0.000 0.000 0.004 0.996
#> SRR1424678     2  0.4730     0.4815 0.000 0.636 0.000 0.364
#> SRR1424679     2  0.0817     0.6202 0.000 0.976 0.000 0.024
#> SRR1424680     4  0.0336     0.9800 0.000 0.008 0.000 0.992
#> SRR1424681     3  0.7304     0.2286 0.164 0.344 0.492 0.000
#> SRR1424682     3  0.3688     0.6576 0.000 0.000 0.792 0.208
#> SRR1424683     4  0.0000     0.9863 0.000 0.000 0.000 1.000
#> SRR1424685     3  0.7393     0.2378 0.152 0.352 0.492 0.004
#> SRR1424686     1  0.5167     0.1439 0.508 0.004 0.488 0.000
#> SRR1424687     4  0.0376     0.9854 0.000 0.004 0.004 0.992
#> SRR1424688     1  0.6423     0.2710 0.508 0.436 0.048 0.008
#> SRR1424689     2  0.0592     0.6001 0.000 0.984 0.016 0.000
#> SRR1424690     1  0.5971     0.3764 0.584 0.368 0.048 0.000
#> SRR1424691     1  0.6176     0.3720 0.572 0.368 0.060 0.000
#> SRR1424692     4  0.0000     0.9863 0.000 0.000 0.000 1.000
#> SRR1424684     2  0.1022     0.6210 0.000 0.968 0.000 0.032
#> SRR1424693     1  0.6423     0.2710 0.508 0.436 0.048 0.008
#> SRR1424694     4  0.0188     0.9854 0.000 0.004 0.000 0.996
#> SRR1424695     2  0.5692    -0.0888 0.400 0.576 0.016 0.008
#> SRR1424696     2  0.4817     0.4542 0.000 0.612 0.000 0.388
#> SRR1424697     3  0.1792     0.7224 0.000 0.000 0.932 0.068
#> SRR1424698     3  0.0000     0.7400 0.000 0.000 1.000 0.000
#> SRR1424699     2  0.4920     0.3973 0.000 0.628 0.368 0.004
#> SRR1424700     2  0.4920     0.3973 0.000 0.628 0.368 0.004
#> SRR1424701     3  0.5000    -0.2429 0.000 0.496 0.504 0.000
#> SRR1424702     3  0.0000     0.7400 0.000 0.000 1.000 0.000
#> SRR1424703     3  0.0000     0.7400 0.000 0.000 1.000 0.000
#> SRR1424704     3  0.0000     0.7400 0.000 0.000 1.000 0.000
#> SRR1424706     3  0.4250     0.5853 0.000 0.000 0.724 0.276
#> SRR1424707     3  0.0000     0.7400 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
#> SRR1424656     1  0.2230      0.826 0.884 0.000 0.000 0.000 0.116
#> SRR1424657     1  0.2179      0.826 0.888 0.000 0.000 0.000 0.112
#> SRR1424658     1  0.3366      0.752 0.784 0.004 0.000 0.000 0.212
#> SRR1424659     1  0.2230      0.826 0.884 0.000 0.000 0.000 0.116
#> SRR1424660     1  0.0671      0.801 0.980 0.000 0.004 0.000 0.016
#> SRR1424661     4  0.0000      0.959 0.000 0.000 0.000 1.000 0.000
#> SRR1424662     4  0.3695      0.762 0.164 0.036 0.000 0.800 0.000
#> SRR1424663     1  0.0609      0.804 0.980 0.000 0.000 0.000 0.020
#> SRR1424664     1  0.2230      0.826 0.884 0.000 0.000 0.000 0.116
#> SRR1424665     1  0.3160      0.775 0.808 0.004 0.000 0.000 0.188
#> SRR1424666     1  0.3688      0.708 0.812 0.036 0.148 0.000 0.004
#> SRR1424667     2  0.3039      0.732 0.000 0.808 0.000 0.192 0.000
#> SRR1424668     1  0.3921      0.698 0.800 0.000 0.128 0.000 0.072
#> SRR1424669     1  0.2929      0.726 0.840 0.152 0.000 0.000 0.008
#> SRR1424670     1  0.2230      0.826 0.884 0.000 0.000 0.000 0.116
#> SRR1424671     4  0.0000      0.959 0.000 0.000 0.000 1.000 0.000
#> SRR1424672     1  0.5059      0.584 0.696 0.000 0.192 0.000 0.112
#> SRR1424674     1  0.2773      0.812 0.836 0.000 0.000 0.000 0.164
#> SRR1424673     3  0.4506      0.716 0.000 0.036 0.716 0.244 0.004
#> SRR1424675     2  0.0162      0.869 0.000 0.996 0.000 0.004 0.000
#> SRR1424676     2  0.1270      0.868 0.000 0.948 0.000 0.000 0.052
#> SRR1424677     4  0.0000      0.959 0.000 0.000 0.000 1.000 0.000
#> SRR1424678     2  0.1121      0.870 0.000 0.956 0.000 0.044 0.000
#> SRR1424679     2  0.1121      0.871 0.000 0.956 0.000 0.000 0.044
#> SRR1424680     4  0.2068      0.873 0.000 0.092 0.000 0.904 0.004
#> SRR1424681     5  0.5900      0.530 0.212 0.000 0.188 0.000 0.600
#> SRR1424682     3  0.3242      0.774 0.000 0.000 0.784 0.216 0.000
#> SRR1424683     4  0.0000      0.959 0.000 0.000 0.000 1.000 0.000
#> SRR1424685     5  0.5208      0.643 0.184 0.004 0.104 0.004 0.704
#> SRR1424686     1  0.5836      0.423 0.608 0.000 0.176 0.000 0.216
#> SRR1424687     4  0.0000      0.959 0.000 0.000 0.000 1.000 0.000
#> SRR1424688     5  0.0451      0.804 0.008 0.004 0.000 0.000 0.988
#> SRR1424689     5  0.4397      0.131 0.004 0.432 0.000 0.000 0.564
#> SRR1424690     5  0.0290      0.803 0.008 0.000 0.000 0.000 0.992
#> SRR1424691     5  0.0609      0.802 0.020 0.000 0.000 0.000 0.980
#> SRR1424692     4  0.0000      0.959 0.000 0.000 0.000 1.000 0.000
#> SRR1424684     2  0.1197      0.870 0.000 0.952 0.000 0.000 0.048
#> SRR1424693     5  0.0324      0.803 0.004 0.004 0.000 0.000 0.992
#> SRR1424694     4  0.0000      0.959 0.000 0.000 0.000 1.000 0.000
#> SRR1424695     5  0.2561      0.731 0.020 0.096 0.000 0.000 0.884
#> SRR1424696     2  0.2130      0.849 0.000 0.908 0.000 0.080 0.012
#> SRR1424697     3  0.3160      0.794 0.000 0.004 0.808 0.188 0.000
#> SRR1424698     3  0.0451      0.842 0.000 0.008 0.988 0.000 0.004
#> SRR1424699     2  0.3491      0.756 0.000 0.768 0.228 0.000 0.004
#> SRR1424700     2  0.3491      0.756 0.000 0.768 0.228 0.000 0.004
#> SRR1424701     3  0.3300      0.613 0.000 0.204 0.792 0.000 0.004
#> SRR1424702     3  0.0000      0.843 0.000 0.000 1.000 0.000 0.000
#> SRR1424703     3  0.0451      0.842 0.000 0.008 0.988 0.000 0.004
#> SRR1424704     3  0.0162      0.842 0.000 0.000 0.996 0.000 0.004
#> SRR1424706     3  0.3676      0.762 0.000 0.004 0.760 0.232 0.004
#> SRR1424707     3  0.0162      0.844 0.000 0.004 0.996 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR1424656     1  0.0713     0.7079 0.972 0.000 0.000 0.000 0.000 0.028
#> SRR1424657     1  0.1327     0.6908 0.936 0.000 0.000 0.000 0.000 0.064
#> SRR1424658     1  0.0767     0.7062 0.976 0.012 0.000 0.000 0.008 0.004
#> SRR1424659     1  0.0603     0.7105 0.980 0.000 0.000 0.000 0.004 0.016
#> SRR1424660     1  0.3867    -0.0974 0.512 0.000 0.000 0.000 0.000 0.488
#> SRR1424661     4  0.0291     0.9445 0.000 0.004 0.000 0.992 0.000 0.004
#> SRR1424662     1  0.6282     0.1200 0.428 0.008 0.000 0.336 0.004 0.224
#> SRR1424663     1  0.3944     0.0874 0.568 0.000 0.000 0.000 0.004 0.428
#> SRR1424664     1  0.0790     0.7070 0.968 0.000 0.000 0.000 0.000 0.032
#> SRR1424665     1  0.0632     0.7100 0.976 0.000 0.000 0.000 0.000 0.024
#> SRR1424666     6  0.3748     0.4007 0.224 0.000 0.016 0.000 0.012 0.748
#> SRR1424667     2  0.4577     0.7082 0.000 0.684 0.000 0.056 0.012 0.248
#> SRR1424668     6  0.4595     0.4095 0.352 0.000 0.012 0.000 0.028 0.608
#> SRR1424669     1  0.4939     0.2201 0.496 0.024 0.000 0.000 0.024 0.456
#> SRR1424670     1  0.0858     0.7077 0.968 0.000 0.000 0.000 0.004 0.028
#> SRR1424671     4  0.0622     0.9404 0.000 0.008 0.000 0.980 0.000 0.012
#> SRR1424672     6  0.4989     0.5912 0.232 0.000 0.024 0.000 0.076 0.668
#> SRR1424674     1  0.3314     0.4762 0.740 0.000 0.000 0.000 0.004 0.256
#> SRR1424673     3  0.5674     0.5550 0.000 0.008 0.548 0.288 0.000 0.156
#> SRR1424675     2  0.1745     0.8441 0.000 0.920 0.000 0.000 0.012 0.068
#> SRR1424676     2  0.0622     0.8584 0.000 0.980 0.000 0.000 0.008 0.012
#> SRR1424677     4  0.0405     0.9426 0.000 0.000 0.004 0.988 0.000 0.008
#> SRR1424678     2  0.0260     0.8609 0.000 0.992 0.000 0.008 0.000 0.000
#> SRR1424679     2  0.0260     0.8607 0.000 0.992 0.000 0.000 0.008 0.000
#> SRR1424680     4  0.2994     0.7350 0.000 0.208 0.000 0.788 0.000 0.004
#> SRR1424681     6  0.4694     0.5239 0.012 0.004 0.024 0.000 0.364 0.596
#> SRR1424682     3  0.4422     0.7297 0.000 0.000 0.700 0.212 0.000 0.088
#> SRR1424683     4  0.0000     0.9465 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1424685     6  0.4382     0.4427 0.000 0.004 0.012 0.004 0.416 0.564
#> SRR1424686     6  0.5532     0.6567 0.168 0.000 0.020 0.000 0.192 0.620
#> SRR1424687     4  0.2101     0.8771 0.000 0.000 0.004 0.892 0.004 0.100
#> SRR1424688     5  0.1666     0.8913 0.020 0.036 0.000 0.000 0.936 0.008
#> SRR1424689     5  0.4590     0.6703 0.028 0.148 0.000 0.000 0.736 0.088
#> SRR1424690     5  0.0508     0.8954 0.012 0.000 0.000 0.000 0.984 0.004
#> SRR1424691     5  0.0692     0.8872 0.004 0.000 0.000 0.000 0.976 0.020
#> SRR1424692     4  0.0000     0.9465 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1424684     2  0.0405     0.8600 0.000 0.988 0.000 0.000 0.008 0.004
#> SRR1424693     5  0.0520     0.8982 0.008 0.008 0.000 0.000 0.984 0.000
#> SRR1424694     4  0.0000     0.9465 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1424695     5  0.1923     0.8769 0.016 0.064 0.000 0.000 0.916 0.004
#> SRR1424696     2  0.1364     0.8441 0.000 0.944 0.000 0.048 0.004 0.004
#> SRR1424697     3  0.3364     0.7665 0.000 0.000 0.780 0.196 0.000 0.024
#> SRR1424698     3  0.0146     0.8258 0.000 0.000 0.996 0.000 0.000 0.004
#> SRR1424699     2  0.4643     0.6957 0.000 0.672 0.260 0.000 0.012 0.056
#> SRR1424700     2  0.4778     0.6746 0.000 0.652 0.276 0.000 0.012 0.060
#> SRR1424701     3  0.2605     0.7476 0.000 0.040 0.884 0.000 0.012 0.064
#> SRR1424702     3  0.1204     0.8232 0.000 0.000 0.944 0.000 0.000 0.056
#> SRR1424703     3  0.0146     0.8258 0.000 0.000 0.996 0.000 0.000 0.004
#> SRR1424704     3  0.1556     0.8140 0.000 0.000 0.920 0.000 0.000 0.080
#> SRR1424706     3  0.3314     0.7431 0.000 0.000 0.764 0.224 0.000 0.012
#> SRR1424707     3  0.0632     0.8278 0.000 0.000 0.976 0.000 0.000 0.024

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

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

collect_plots(res)

plot of chunk MAD-pam-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.578           0.842       0.918         0.5062 0.490   0.490
#> 3 3 0.757           0.742       0.895         0.3161 0.649   0.396
#> 4 4 0.658           0.704       0.853         0.1219 0.840   0.571
#> 5 5 0.802           0.767       0.901         0.0653 0.866   0.555
#> 6 6 0.829           0.774       0.879         0.0505 0.917   0.631

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
#> SRR1424656     2  0.1184     0.9381 0.016 0.984
#> SRR1424657     2  0.1184     0.9381 0.016 0.984
#> SRR1424658     2  0.1184     0.9381 0.016 0.984
#> SRR1424659     2  0.1184     0.9381 0.016 0.984
#> SRR1424660     1  0.5842     0.8246 0.860 0.140
#> SRR1424661     1  0.0000     0.8715 1.000 0.000
#> SRR1424662     2  0.1184     0.9381 0.016 0.984
#> SRR1424663     1  0.6887     0.7979 0.816 0.184
#> SRR1424664     2  0.1184     0.9381 0.016 0.984
#> SRR1424665     2  0.1184     0.9381 0.016 0.984
#> SRR1424666     1  0.6887     0.7979 0.816 0.184
#> SRR1424667     2  0.5294     0.8533 0.120 0.880
#> SRR1424668     1  0.6887     0.7979 0.816 0.184
#> SRR1424669     2  0.1184     0.9381 0.016 0.984
#> SRR1424670     2  0.1184     0.9381 0.016 0.984
#> SRR1424671     1  0.1184     0.8697 0.984 0.016
#> SRR1424672     1  0.6887     0.7979 0.816 0.184
#> SRR1424674     2  0.1184     0.9381 0.016 0.984
#> SRR1424673     1  0.3431     0.8534 0.936 0.064
#> SRR1424675     2  0.0000     0.9368 0.000 1.000
#> SRR1424676     2  0.3431     0.9000 0.064 0.936
#> SRR1424677     1  0.1184     0.8697 0.984 0.016
#> SRR1424678     2  0.6887     0.8031 0.184 0.816
#> SRR1424679     2  0.0376     0.9361 0.004 0.996
#> SRR1424680     2  0.6887     0.8031 0.184 0.816
#> SRR1424681     1  0.5294     0.8337 0.880 0.120
#> SRR1424682     1  0.1184     0.8697 0.984 0.016
#> SRR1424683     1  0.9358     0.4203 0.648 0.352
#> SRR1424685     1  0.6887     0.7979 0.816 0.184
#> SRR1424686     1  0.5294     0.8337 0.880 0.120
#> SRR1424687     2  0.6887     0.8031 0.184 0.816
#> SRR1424688     2  0.2236     0.9196 0.036 0.964
#> SRR1424689     2  0.0000     0.9368 0.000 1.000
#> SRR1424690     2  0.0938     0.9381 0.012 0.988
#> SRR1424691     2  0.1184     0.9381 0.016 0.984
#> SRR1424692     1  0.9833     0.2183 0.576 0.424
#> SRR1424684     2  0.0000     0.9368 0.000 1.000
#> SRR1424693     2  0.0000     0.9368 0.000 1.000
#> SRR1424694     2  0.6887     0.8031 0.184 0.816
#> SRR1424695     2  0.0000     0.9368 0.000 1.000
#> SRR1424696     2  0.6712     0.8111 0.176 0.824
#> SRR1424697     1  0.0672     0.8711 0.992 0.008
#> SRR1424698     1  0.0938     0.8706 0.988 0.012
#> SRR1424699     1  0.1184     0.8697 0.984 0.016
#> SRR1424700     1  0.9970     0.0553 0.532 0.468
#> SRR1424701     1  0.1184     0.8697 0.984 0.016
#> SRR1424702     1  0.0000     0.8715 1.000 0.000
#> SRR1424703     1  0.0000     0.8715 1.000 0.000
#> SRR1424704     1  0.0000     0.8715 1.000 0.000
#> SRR1424706     1  0.1184     0.8697 0.984 0.016
#> SRR1424707     1  0.0000     0.8715 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
#> SRR1424656     1  0.0000     0.9345 1.000 0.000 0.000
#> SRR1424657     1  0.0424     0.9316 0.992 0.008 0.000
#> SRR1424658     1  0.0000     0.9345 1.000 0.000 0.000
#> SRR1424659     1  0.0000     0.9345 1.000 0.000 0.000
#> SRR1424660     3  0.3340     0.7918 0.120 0.000 0.880
#> SRR1424661     1  0.8434     0.1205 0.560 0.336 0.104
#> SRR1424662     1  0.0424     0.9316 0.992 0.008 0.000
#> SRR1424663     1  0.0424     0.9307 0.992 0.000 0.008
#> SRR1424664     1  0.0000     0.9345 1.000 0.000 0.000
#> SRR1424665     1  0.0000     0.9345 1.000 0.000 0.000
#> SRR1424666     1  0.2796     0.8443 0.908 0.000 0.092
#> SRR1424667     2  0.0237     0.7635 0.004 0.996 0.000
#> SRR1424668     1  0.0424     0.9307 0.992 0.000 0.008
#> SRR1424669     1  0.0000     0.9345 1.000 0.000 0.000
#> SRR1424670     1  0.0000     0.9345 1.000 0.000 0.000
#> SRR1424671     3  0.6280     0.1252 0.000 0.460 0.540
#> SRR1424672     1  0.5465     0.5506 0.712 0.000 0.288
#> SRR1424674     1  0.0000     0.9345 1.000 0.000 0.000
#> SRR1424673     3  0.4399     0.7224 0.188 0.000 0.812
#> SRR1424675     2  0.0424     0.7638 0.008 0.992 0.000
#> SRR1424676     2  0.0661     0.7615 0.008 0.988 0.004
#> SRR1424677     2  0.0000     0.7625 0.000 1.000 0.000
#> SRR1424678     2  0.0000     0.7625 0.000 1.000 0.000
#> SRR1424679     2  0.0424     0.7638 0.008 0.992 0.000
#> SRR1424680     2  0.0000     0.7625 0.000 1.000 0.000
#> SRR1424681     3  0.0000     0.8852 0.000 0.000 1.000
#> SRR1424682     3  0.0000     0.8852 0.000 0.000 1.000
#> SRR1424683     2  0.6244     0.3667 0.440 0.560 0.000
#> SRR1424685     1  0.0424     0.9316 0.992 0.008 0.000
#> SRR1424686     3  0.0000     0.8852 0.000 0.000 1.000
#> SRR1424687     2  0.6683    -0.0317 0.008 0.500 0.492
#> SRR1424688     2  0.6295     0.3191 0.472 0.528 0.000
#> SRR1424689     1  0.2356     0.8558 0.928 0.072 0.000
#> SRR1424690     1  0.0592     0.9254 0.988 0.012 0.000
#> SRR1424691     1  0.0000     0.9345 1.000 0.000 0.000
#> SRR1424692     2  0.0000     0.7625 0.000 1.000 0.000
#> SRR1424684     2  0.0424     0.7638 0.008 0.992 0.000
#> SRR1424693     2  0.6295     0.3191 0.472 0.528 0.000
#> SRR1424694     2  0.6286     0.3217 0.464 0.536 0.000
#> SRR1424695     2  0.6295     0.3191 0.472 0.528 0.000
#> SRR1424696     2  0.0424     0.7638 0.008 0.992 0.000
#> SRR1424697     3  0.0000     0.8852 0.000 0.000 1.000
#> SRR1424698     3  0.0000     0.8852 0.000 0.000 1.000
#> SRR1424699     3  0.6286     0.2970 0.000 0.464 0.536
#> SRR1424700     3  0.5706     0.5489 0.000 0.320 0.680
#> SRR1424701     3  0.0000     0.8852 0.000 0.000 1.000
#> SRR1424702     3  0.0000     0.8852 0.000 0.000 1.000
#> SRR1424703     3  0.0000     0.8852 0.000 0.000 1.000
#> SRR1424704     3  0.0000     0.8852 0.000 0.000 1.000
#> SRR1424706     3  0.0000     0.8852 0.000 0.000 1.000
#> SRR1424707     3  0.0000     0.8852 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
#> SRR1424656     1   0.000      0.756 1.000 0.000 0.000 0.000
#> SRR1424657     4   0.495      0.375 0.444 0.000 0.000 0.556
#> SRR1424658     1   0.000      0.756 1.000 0.000 0.000 0.000
#> SRR1424659     1   0.000      0.756 1.000 0.000 0.000 0.000
#> SRR1424660     3   0.464      0.525 0.344 0.000 0.656 0.000
#> SRR1424661     4   0.512      0.643 0.164 0.000 0.080 0.756
#> SRR1424662     1   0.000      0.756 1.000 0.000 0.000 0.000
#> SRR1424663     1   0.000      0.756 1.000 0.000 0.000 0.000
#> SRR1424664     1   0.000      0.756 1.000 0.000 0.000 0.000
#> SRR1424665     1   0.000      0.756 1.000 0.000 0.000 0.000
#> SRR1424666     1   0.456      0.489 0.672 0.000 0.328 0.000
#> SRR1424667     2   0.361      0.721 0.000 0.800 0.000 0.200
#> SRR1424668     1   0.208      0.726 0.916 0.000 0.084 0.000
#> SRR1424669     1   0.353      0.666 0.808 0.000 0.192 0.000
#> SRR1424670     1   0.000      0.756 1.000 0.000 0.000 0.000
#> SRR1424671     4   0.522      0.629 0.000 0.108 0.136 0.756
#> SRR1424672     1   0.499      0.103 0.524 0.000 0.476 0.000
#> SRR1424674     1   0.000      0.756 1.000 0.000 0.000 0.000
#> SRR1424673     3   0.353      0.723 0.192 0.000 0.808 0.000
#> SRR1424675     2   0.327      0.704 0.168 0.832 0.000 0.000
#> SRR1424676     2   0.000      0.829 0.000 1.000 0.000 0.000
#> SRR1424677     2   0.361      0.721 0.000 0.800 0.000 0.200
#> SRR1424678     2   0.000      0.829 0.000 1.000 0.000 0.000
#> SRR1424679     2   0.000      0.829 0.000 1.000 0.000 0.000
#> SRR1424680     4   0.401      0.600 0.000 0.244 0.000 0.756
#> SRR1424681     3   0.361      0.705 0.000 0.200 0.800 0.000
#> SRR1424682     3   0.000      0.905 0.000 0.000 1.000 0.000
#> SRR1424683     4   0.247      0.702 0.000 0.108 0.000 0.892
#> SRR1424685     1   0.716      0.558 0.556 0.200 0.000 0.244
#> SRR1424686     3   0.000      0.905 0.000 0.000 1.000 0.000
#> SRR1424687     4   0.000      0.713 0.000 0.000 0.000 1.000
#> SRR1424688     4   0.361      0.585 0.000 0.200 0.000 0.800
#> SRR1424689     1   0.716      0.558 0.556 0.200 0.000 0.244
#> SRR1424690     1   0.716      0.558 0.556 0.200 0.000 0.244
#> SRR1424691     1   0.716      0.558 0.556 0.200 0.000 0.244
#> SRR1424692     4   0.401      0.600 0.000 0.244 0.000 0.756
#> SRR1424684     2   0.000      0.829 0.000 1.000 0.000 0.000
#> SRR1424693     1   0.716      0.558 0.556 0.200 0.000 0.244
#> SRR1424694     4   0.000      0.713 0.000 0.000 0.000 1.000
#> SRR1424695     1   0.716      0.558 0.556 0.200 0.000 0.244
#> SRR1424696     4   0.361      0.585 0.000 0.200 0.000 0.800
#> SRR1424697     3   0.000      0.905 0.000 0.000 1.000 0.000
#> SRR1424698     3   0.000      0.905 0.000 0.000 1.000 0.000
#> SRR1424699     2   0.361      0.692 0.000 0.800 0.200 0.000
#> SRR1424700     3   0.452      0.459 0.000 0.320 0.680 0.000
#> SRR1424701     3   0.000      0.905 0.000 0.000 1.000 0.000
#> SRR1424702     3   0.000      0.905 0.000 0.000 1.000 0.000
#> SRR1424703     3   0.000      0.905 0.000 0.000 1.000 0.000
#> SRR1424704     3   0.000      0.905 0.000 0.000 1.000 0.000
#> SRR1424706     3   0.000      0.905 0.000 0.000 1.000 0.000
#> SRR1424707     3   0.000      0.905 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
#> SRR1424656     1   0.000     0.8760 1.000 0.000 0.000 0.000 0.000
#> SRR1424657     1   0.179     0.8055 0.916 0.000 0.000 0.084 0.000
#> SRR1424658     1   0.000     0.8760 1.000 0.000 0.000 0.000 0.000
#> SRR1424659     1   0.000     0.8760 1.000 0.000 0.000 0.000 0.000
#> SRR1424660     1   0.327     0.6522 0.780 0.000 0.220 0.000 0.000
#> SRR1424661     4   0.000     0.7790 0.000 0.000 0.000 1.000 0.000
#> SRR1424662     1   0.000     0.8760 1.000 0.000 0.000 0.000 0.000
#> SRR1424663     1   0.000     0.8760 1.000 0.000 0.000 0.000 0.000
#> SRR1424664     1   0.000     0.8760 1.000 0.000 0.000 0.000 0.000
#> SRR1424665     1   0.000     0.8760 1.000 0.000 0.000 0.000 0.000
#> SRR1424666     3   0.407     0.4246 0.364 0.000 0.636 0.000 0.000
#> SRR1424667     2   0.311     0.7714 0.000 0.800 0.000 0.200 0.000
#> SRR1424668     1   0.620     0.4015 0.552 0.000 0.240 0.000 0.208
#> SRR1424669     1   0.445    -0.0727 0.508 0.000 0.488 0.000 0.004
#> SRR1424670     1   0.000     0.8760 1.000 0.000 0.000 0.000 0.000
#> SRR1424671     4   0.000     0.7790 0.000 0.000 0.000 1.000 0.000
#> SRR1424672     3   0.405     0.4426 0.356 0.000 0.644 0.000 0.000
#> SRR1424674     1   0.127     0.8461 0.948 0.000 0.000 0.000 0.052
#> SRR1424673     3   0.304     0.7032 0.192 0.000 0.808 0.000 0.000
#> SRR1424675     2   0.000     0.9059 0.000 1.000 0.000 0.000 0.000
#> SRR1424676     2   0.000     0.9059 0.000 1.000 0.000 0.000 0.000
#> SRR1424677     2   0.281     0.8040 0.000 0.832 0.000 0.168 0.000
#> SRR1424678     2   0.000     0.9059 0.000 1.000 0.000 0.000 0.000
#> SRR1424679     2   0.000     0.9059 0.000 1.000 0.000 0.000 0.000
#> SRR1424680     4   0.428     0.2485 0.000 0.452 0.000 0.548 0.000
#> SRR1424681     3   0.342     0.6519 0.000 0.000 0.760 0.000 0.240
#> SRR1424682     3   0.000     0.8785 0.000 0.000 1.000 0.000 0.000
#> SRR1424683     4   0.000     0.7790 0.000 0.000 0.000 1.000 0.000
#> SRR1424685     5   0.000     1.0000 0.000 0.000 0.000 0.000 1.000
#> SRR1424686     3   0.000     0.8785 0.000 0.000 1.000 0.000 0.000
#> SRR1424687     4   0.368     0.5562 0.000 0.000 0.000 0.720 0.280
#> SRR1424688     4   0.430     0.2185 0.000 0.000 0.000 0.516 0.484
#> SRR1424689     5   0.000     1.0000 0.000 0.000 0.000 0.000 1.000
#> SRR1424690     5   0.000     1.0000 0.000 0.000 0.000 0.000 1.000
#> SRR1424691     5   0.000     1.0000 0.000 0.000 0.000 0.000 1.000
#> SRR1424692     4   0.000     0.7790 0.000 0.000 0.000 1.000 0.000
#> SRR1424684     2   0.000     0.9059 0.000 1.000 0.000 0.000 0.000
#> SRR1424693     5   0.000     1.0000 0.000 0.000 0.000 0.000 1.000
#> SRR1424694     4   0.000     0.7790 0.000 0.000 0.000 1.000 0.000
#> SRR1424695     5   0.000     1.0000 0.000 0.000 0.000 0.000 1.000
#> SRR1424696     4   0.442     0.3034 0.000 0.004 0.000 0.548 0.448
#> SRR1424697     3   0.000     0.8785 0.000 0.000 1.000 0.000 0.000
#> SRR1424698     3   0.000     0.8785 0.000 0.000 1.000 0.000 0.000
#> SRR1424699     2   0.311     0.7362 0.000 0.800 0.200 0.000 0.000
#> SRR1424700     3   0.495     0.4085 0.000 0.288 0.656 0.000 0.056
#> SRR1424701     3   0.000     0.8785 0.000 0.000 1.000 0.000 0.000
#> SRR1424702     3   0.000     0.8785 0.000 0.000 1.000 0.000 0.000
#> SRR1424703     3   0.000     0.8785 0.000 0.000 1.000 0.000 0.000
#> SRR1424704     3   0.000     0.8785 0.000 0.000 1.000 0.000 0.000
#> SRR1424706     3   0.000     0.8785 0.000 0.000 1.000 0.000 0.000
#> SRR1424707     3   0.000     0.8785 0.000 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR1424656     1  0.0000     0.9502 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1424657     1  0.0632     0.9356 0.976 0.000 0.000 0.024 0.000 0.000
#> SRR1424658     1  0.0260     0.9491 0.992 0.000 0.000 0.000 0.000 0.008
#> SRR1424659     1  0.1957     0.8743 0.888 0.000 0.000 0.000 0.000 0.112
#> SRR1424660     1  0.0790     0.9266 0.968 0.000 0.032 0.000 0.000 0.000
#> SRR1424661     4  0.0000     0.7764 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1424662     1  0.0000     0.9502 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1424663     1  0.0632     0.9393 0.976 0.000 0.000 0.000 0.000 0.024
#> SRR1424664     1  0.0260     0.9491 0.992 0.000 0.000 0.000 0.000 0.008
#> SRR1424665     1  0.0000     0.9502 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1424666     6  0.3481     0.8034 0.032 0.000 0.192 0.000 0.000 0.776
#> SRR1424667     2  0.2793     0.7287 0.000 0.800 0.000 0.200 0.000 0.000
#> SRR1424668     6  0.3727     0.8059 0.040 0.000 0.188 0.000 0.004 0.768
#> SRR1424669     3  0.5989     0.0853 0.276 0.000 0.512 0.000 0.012 0.200
#> SRR1424670     1  0.2730     0.7710 0.808 0.000 0.000 0.000 0.000 0.192
#> SRR1424671     4  0.0000     0.7764 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1424672     6  0.3618     0.8047 0.040 0.000 0.192 0.000 0.000 0.768
#> SRR1424674     6  0.3050     0.5893 0.236 0.000 0.000 0.000 0.000 0.764
#> SRR1424673     6  0.3298     0.7740 0.008 0.000 0.236 0.000 0.000 0.756
#> SRR1424675     2  0.2969     0.7407 0.000 0.776 0.000 0.000 0.000 0.224
#> SRR1424676     2  0.0000     0.8500 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1424677     2  0.2527     0.7598 0.000 0.832 0.000 0.168 0.000 0.000
#> SRR1424678     2  0.0000     0.8500 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1424679     2  0.0000     0.8500 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1424680     4  0.3847     0.2009 0.000 0.456 0.000 0.544 0.000 0.000
#> SRR1424681     6  0.5440     0.6478 0.000 0.000 0.224 0.000 0.200 0.576
#> SRR1424682     3  0.0000     0.8804 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1424683     4  0.0000     0.7764 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1424685     6  0.3804     0.2705 0.000 0.000 0.000 0.000 0.424 0.576
#> SRR1424686     3  0.0000     0.8804 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1424687     4  0.3221     0.5617 0.000 0.000 0.000 0.736 0.264 0.000
#> SRR1424688     4  0.3857     0.2559 0.000 0.000 0.000 0.532 0.468 0.000
#> SRR1424689     5  0.0000     1.0000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1424690     5  0.0000     1.0000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1424691     5  0.0000     1.0000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1424692     4  0.0000     0.7764 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1424684     2  0.0000     0.8500 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1424693     5  0.0000     1.0000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1424694     4  0.0000     0.7764 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1424695     5  0.0000     1.0000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1424696     4  0.3975     0.2900 0.000 0.004 0.000 0.544 0.452 0.000
#> SRR1424697     3  0.0000     0.8804 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1424698     3  0.0000     0.8804 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1424699     2  0.5440     0.5716 0.000 0.576 0.200 0.000 0.000 0.224
#> SRR1424700     3  0.5881     0.5066 0.000 0.084 0.608 0.000 0.084 0.224
#> SRR1424701     3  0.2969     0.6886 0.000 0.000 0.776 0.000 0.000 0.224
#> SRR1424702     3  0.0000     0.8804 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1424703     3  0.0000     0.8804 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1424704     3  0.0000     0.8804 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1424706     3  0.0000     0.8804 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1424707     3  0.0000     0.8804 0.000 0.000 1.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-pam-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-pam-collect-classes

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


MAD:mclust

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

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

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

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 16960 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 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-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.289           0.823       0.828         0.4246 0.523   0.523
#> 3 3 0.207           0.339       0.708         0.4137 0.825   0.684
#> 4 4 0.746           0.831       0.913         0.1826 0.762   0.491
#> 5 5 0.784           0.786       0.884         0.1164 0.912   0.697
#> 6 6 0.672           0.677       0.776         0.0275 0.935   0.700

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
#> SRR1424656     1   0.753      0.986 0.784 0.216
#> SRR1424657     1   0.753      0.986 0.784 0.216
#> SRR1424658     2   0.722      0.737 0.200 0.800
#> SRR1424659     1   0.753      0.986 0.784 0.216
#> SRR1424660     1   0.753      0.986 0.784 0.216
#> SRR1424661     2   0.000      0.782 0.000 1.000
#> SRR1424662     2   0.000      0.782 0.000 1.000
#> SRR1424663     1   0.753      0.986 0.784 0.216
#> SRR1424664     1   0.753      0.986 0.784 0.216
#> SRR1424665     1   0.767      0.979 0.776 0.224
#> SRR1424666     1   0.775      0.974 0.772 0.228
#> SRR1424667     2   0.753      0.664 0.216 0.784
#> SRR1424668     1   0.753      0.986 0.784 0.216
#> SRR1424669     2   0.876      0.567 0.296 0.704
#> SRR1424670     1   0.753      0.986 0.784 0.216
#> SRR1424671     2   0.000      0.782 0.000 1.000
#> SRR1424672     1   0.753      0.986 0.784 0.216
#> SRR1424674     1   0.753      0.986 0.784 0.216
#> SRR1424673     2   0.714      0.739 0.196 0.804
#> SRR1424675     2   0.980      0.696 0.416 0.584
#> SRR1424676     2   0.722      0.737 0.200 0.800
#> SRR1424677     2   0.000      0.782 0.000 1.000
#> SRR1424678     2   0.753      0.664 0.216 0.784
#> SRR1424679     2   0.980      0.696 0.416 0.584
#> SRR1424680     2   0.753      0.664 0.216 0.784
#> SRR1424681     1   0.753      0.986 0.784 0.216
#> SRR1424682     2   0.000      0.782 0.000 1.000
#> SRR1424683     2   0.000      0.782 0.000 1.000
#> SRR1424685     1   0.775      0.974 0.772 0.228
#> SRR1424686     1   0.753      0.986 0.784 0.216
#> SRR1424687     2   0.000      0.782 0.000 1.000
#> SRR1424688     1   0.827      0.930 0.740 0.260
#> SRR1424689     2   0.722      0.737 0.200 0.800
#> SRR1424690     1   0.753      0.986 0.784 0.216
#> SRR1424691     1   0.753      0.986 0.784 0.216
#> SRR1424692     2   0.000      0.782 0.000 1.000
#> SRR1424684     2   0.980      0.696 0.416 0.584
#> SRR1424693     1   0.886      0.850 0.696 0.304
#> SRR1424694     2   0.000      0.782 0.000 1.000
#> SRR1424695     2   0.722      0.737 0.200 0.800
#> SRR1424696     2   0.980      0.696 0.416 0.584
#> SRR1424697     2   0.000      0.782 0.000 1.000
#> SRR1424698     2   0.722      0.737 0.200 0.800
#> SRR1424699     2   0.917      0.700 0.332 0.668
#> SRR1424700     2   0.973      0.702 0.404 0.596
#> SRR1424701     2   0.722      0.737 0.200 0.800
#> SRR1424702     2   0.722      0.737 0.200 0.800
#> SRR1424703     2   0.722      0.737 0.200 0.800
#> SRR1424704     2   0.722      0.737 0.200 0.800
#> SRR1424706     2   0.000      0.782 0.000 1.000
#> SRR1424707     2   0.722      0.737 0.200 0.800

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1424656     1  0.0000     0.8159 1.000 0.000 0.000
#> SRR1424657     1  0.0892     0.8021 0.980 0.020 0.000
#> SRR1424658     1  0.6111     0.0821 0.604 0.396 0.000
#> SRR1424659     1  0.0000     0.8159 1.000 0.000 0.000
#> SRR1424660     1  0.0000     0.8159 1.000 0.000 0.000
#> SRR1424661     2  0.8042     0.0872 0.148 0.652 0.200
#> SRR1424662     2  0.8568     0.0943 0.192 0.608 0.200
#> SRR1424663     1  0.0000     0.8159 1.000 0.000 0.000
#> SRR1424664     1  0.0000     0.8159 1.000 0.000 0.000
#> SRR1424665     1  0.0000     0.8159 1.000 0.000 0.000
#> SRR1424666     1  0.4335     0.7295 0.864 0.036 0.100
#> SRR1424667     3  0.6832     0.0829 0.020 0.376 0.604
#> SRR1424668     1  0.1337     0.8069 0.972 0.016 0.012
#> SRR1424669     1  0.5591     0.3715 0.696 0.304 0.000
#> SRR1424670     1  0.0000     0.8159 1.000 0.000 0.000
#> SRR1424671     2  0.4555    -0.0821 0.000 0.800 0.200
#> SRR1424672     1  0.6255     0.5744 0.668 0.320 0.012
#> SRR1424674     1  0.0000     0.8159 1.000 0.000 0.000
#> SRR1424673     3  0.9431     0.3310 0.176 0.400 0.424
#> SRR1424675     2  0.6647     0.0477 0.008 0.540 0.452
#> SRR1424676     2  0.6744     0.1913 0.300 0.668 0.032
#> SRR1424677     2  0.4555    -0.0821 0.000 0.800 0.200
#> SRR1424678     3  0.6651     0.0761 0.020 0.340 0.640
#> SRR1424679     2  0.6280     0.0456 0.000 0.540 0.460
#> SRR1424680     2  0.5968    -0.0814 0.000 0.636 0.364
#> SRR1424681     1  0.4784     0.7548 0.796 0.200 0.004
#> SRR1424682     3  0.9177     0.3581 0.148 0.400 0.452
#> SRR1424683     2  0.8095     0.0894 0.152 0.648 0.200
#> SRR1424685     1  0.4887     0.7324 0.772 0.228 0.000
#> SRR1424686     1  0.5122     0.7509 0.788 0.200 0.012
#> SRR1424687     2  0.8940     0.0832 0.232 0.568 0.200
#> SRR1424688     1  0.4555     0.7563 0.800 0.200 0.000
#> SRR1424689     2  0.6896     0.1496 0.392 0.588 0.020
#> SRR1424690     1  0.4555     0.7563 0.800 0.200 0.000
#> SRR1424691     1  0.4555     0.7563 0.800 0.200 0.000
#> SRR1424692     2  0.7298     0.0394 0.100 0.700 0.200
#> SRR1424684     2  0.7029     0.0477 0.020 0.540 0.440
#> SRR1424693     1  0.4555     0.7563 0.800 0.200 0.000
#> SRR1424694     2  0.8199     0.0925 0.160 0.640 0.200
#> SRR1424695     2  0.6235     0.0366 0.436 0.564 0.000
#> SRR1424696     2  0.6738     0.0583 0.020 0.624 0.356
#> SRR1424697     3  0.9028     0.3580 0.132 0.432 0.436
#> SRR1424698     2  0.8943    -0.0327 0.128 0.480 0.392
#> SRR1424699     2  0.5785     0.1077 0.000 0.668 0.332
#> SRR1424700     2  0.7213     0.1410 0.060 0.668 0.272
#> SRR1424701     2  0.5276     0.1026 0.128 0.820 0.052
#> SRR1424702     2  0.9355    -0.0217 0.180 0.480 0.340
#> SRR1424703     2  0.9095    -0.0254 0.144 0.480 0.376
#> SRR1424704     2  0.9224    -0.0202 0.160 0.480 0.360
#> SRR1424706     2  0.6400    -0.0990 0.052 0.740 0.208
#> SRR1424707     2  0.9355    -0.0217 0.180 0.480 0.340

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1424656     1  0.0000      0.883 1.000 0.000 0.000 0.000
#> SRR1424657     1  0.0000      0.883 1.000 0.000 0.000 0.000
#> SRR1424658     1  0.0000      0.883 1.000 0.000 0.000 0.000
#> SRR1424659     1  0.0000      0.883 1.000 0.000 0.000 0.000
#> SRR1424660     1  0.0000      0.883 1.000 0.000 0.000 0.000
#> SRR1424661     4  0.0000      0.860 0.000 0.000 0.000 1.000
#> SRR1424662     4  0.4888      0.324 0.412 0.000 0.000 0.588
#> SRR1424663     1  0.0000      0.883 1.000 0.000 0.000 0.000
#> SRR1424664     1  0.0000      0.883 1.000 0.000 0.000 0.000
#> SRR1424665     1  0.0000      0.883 1.000 0.000 0.000 0.000
#> SRR1424666     1  0.3764      0.657 0.784 0.000 0.216 0.000
#> SRR1424667     2  0.4730      0.406 0.000 0.636 0.000 0.364
#> SRR1424668     1  0.0817      0.871 0.976 0.000 0.024 0.000
#> SRR1424669     1  0.0000      0.883 1.000 0.000 0.000 0.000
#> SRR1424670     1  0.0000      0.883 1.000 0.000 0.000 0.000
#> SRR1424671     4  0.0000      0.860 0.000 0.000 0.000 1.000
#> SRR1424672     1  0.3873      0.835 0.772 0.000 0.228 0.000
#> SRR1424674     1  0.0000      0.883 1.000 0.000 0.000 0.000
#> SRR1424673     3  0.3610      0.775 0.000 0.000 0.800 0.200
#> SRR1424675     2  0.0000      0.912 0.000 1.000 0.000 0.000
#> SRR1424676     2  0.1118      0.882 0.036 0.964 0.000 0.000
#> SRR1424677     4  0.0000      0.860 0.000 0.000 0.000 1.000
#> SRR1424678     2  0.0000      0.912 0.000 1.000 0.000 0.000
#> SRR1424679     2  0.0000      0.912 0.000 1.000 0.000 0.000
#> SRR1424680     4  0.0000      0.860 0.000 0.000 0.000 1.000
#> SRR1424681     1  0.3610      0.855 0.800 0.000 0.200 0.000
#> SRR1424682     3  0.3610      0.775 0.000 0.000 0.800 0.200
#> SRR1424683     4  0.0000      0.860 0.000 0.000 0.000 1.000
#> SRR1424685     1  0.3610      0.855 0.800 0.000 0.200 0.000
#> SRR1424686     1  0.3610      0.855 0.800 0.000 0.200 0.000
#> SRR1424687     4  0.4605      0.505 0.336 0.000 0.000 0.664
#> SRR1424688     1  0.3610      0.855 0.800 0.000 0.200 0.000
#> SRR1424689     1  0.3266      0.863 0.832 0.000 0.168 0.000
#> SRR1424690     1  0.3610      0.855 0.800 0.000 0.200 0.000
#> SRR1424691     1  0.3610      0.855 0.800 0.000 0.200 0.000
#> SRR1424692     4  0.0000      0.860 0.000 0.000 0.000 1.000
#> SRR1424684     2  0.0000      0.912 0.000 1.000 0.000 0.000
#> SRR1424693     1  0.3610      0.855 0.800 0.000 0.200 0.000
#> SRR1424694     4  0.0000      0.860 0.000 0.000 0.000 1.000
#> SRR1424695     1  0.3751      0.855 0.800 0.004 0.196 0.000
#> SRR1424696     2  0.0000      0.912 0.000 1.000 0.000 0.000
#> SRR1424697     3  0.3610      0.775 0.000 0.000 0.800 0.200
#> SRR1424698     3  0.0000      0.871 0.000 0.000 1.000 0.000
#> SRR1424699     2  0.0336      0.908 0.000 0.992 0.000 0.008
#> SRR1424700     2  0.3610      0.703 0.000 0.800 0.200 0.000
#> SRR1424701     3  0.0000      0.871 0.000 0.000 1.000 0.000
#> SRR1424702     3  0.0000      0.871 0.000 0.000 1.000 0.000
#> SRR1424703     3  0.0000      0.871 0.000 0.000 1.000 0.000
#> SRR1424704     3  0.0000      0.871 0.000 0.000 1.000 0.000
#> SRR1424706     3  0.3975      0.730 0.000 0.000 0.760 0.240
#> SRR1424707     3  0.0000      0.871 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
#> SRR1424656     1  0.0794      0.813 0.972 0.000 0.000 0.000 0.028
#> SRR1424657     1  0.0963      0.810 0.964 0.000 0.000 0.000 0.036
#> SRR1424658     1  0.0703      0.801 0.976 0.000 0.000 0.000 0.024
#> SRR1424659     1  0.0794      0.813 0.972 0.000 0.000 0.000 0.028
#> SRR1424660     1  0.4307     -0.374 0.504 0.000 0.000 0.000 0.496
#> SRR1424661     4  0.0000      0.936 0.000 0.000 0.000 1.000 0.000
#> SRR1424662     4  0.4270      0.490 0.320 0.000 0.000 0.668 0.012
#> SRR1424663     5  0.3395      0.812 0.236 0.000 0.000 0.000 0.764
#> SRR1424664     1  0.0609      0.814 0.980 0.000 0.000 0.000 0.020
#> SRR1424665     1  0.0162      0.809 0.996 0.000 0.000 0.000 0.004
#> SRR1424666     5  0.4297      0.805 0.236 0.000 0.036 0.000 0.728
#> SRR1424667     2  0.4639      0.474 0.000 0.632 0.000 0.344 0.024
#> SRR1424668     5  0.3395      0.812 0.236 0.000 0.000 0.000 0.764
#> SRR1424669     1  0.0609      0.814 0.980 0.000 0.000 0.000 0.020
#> SRR1424670     1  0.0794      0.813 0.972 0.000 0.000 0.000 0.028
#> SRR1424671     4  0.0000      0.936 0.000 0.000 0.000 1.000 0.000
#> SRR1424672     5  0.4237      0.814 0.152 0.000 0.076 0.000 0.772
#> SRR1424674     1  0.1121      0.806 0.956 0.000 0.000 0.000 0.044
#> SRR1424673     3  0.3242      0.803 0.000 0.000 0.784 0.216 0.000
#> SRR1424675     2  0.1043      0.895 0.000 0.960 0.000 0.040 0.000
#> SRR1424676     2  0.3193      0.800 0.028 0.840 0.000 0.000 0.132
#> SRR1424677     4  0.0000      0.936 0.000 0.000 0.000 1.000 0.000
#> SRR1424678     2  0.1043      0.895 0.000 0.960 0.000 0.040 0.000
#> SRR1424679     2  0.0000      0.881 0.000 1.000 0.000 0.000 0.000
#> SRR1424680     4  0.0404      0.929 0.000 0.000 0.000 0.988 0.012
#> SRR1424681     5  0.1364      0.767 0.036 0.000 0.012 0.000 0.952
#> SRR1424682     3  0.3109      0.813 0.000 0.000 0.800 0.200 0.000
#> SRR1424683     4  0.0000      0.936 0.000 0.000 0.000 1.000 0.000
#> SRR1424685     5  0.3530      0.588 0.204 0.000 0.012 0.000 0.784
#> SRR1424686     5  0.1809      0.787 0.060 0.000 0.012 0.000 0.928
#> SRR1424687     4  0.1270      0.890 0.052 0.000 0.000 0.948 0.000
#> SRR1424688     1  0.3628      0.732 0.772 0.000 0.012 0.000 0.216
#> SRR1424689     1  0.3210      0.740 0.788 0.000 0.000 0.000 0.212
#> SRR1424690     1  0.3628      0.739 0.772 0.000 0.012 0.000 0.216
#> SRR1424691     1  0.4537      0.512 0.592 0.000 0.012 0.000 0.396
#> SRR1424692     4  0.0000      0.936 0.000 0.000 0.000 1.000 0.000
#> SRR1424684     2  0.0000      0.881 0.000 1.000 0.000 0.000 0.000
#> SRR1424693     1  0.3596      0.737 0.776 0.000 0.012 0.000 0.212
#> SRR1424694     4  0.0000      0.936 0.000 0.000 0.000 1.000 0.000
#> SRR1424695     1  0.3596      0.732 0.776 0.000 0.012 0.000 0.212
#> SRR1424696     2  0.1043      0.895 0.000 0.960 0.000 0.040 0.000
#> SRR1424697     3  0.3210      0.806 0.000 0.000 0.788 0.212 0.000
#> SRR1424698     3  0.0000      0.866 0.000 0.000 1.000 0.000 0.000
#> SRR1424699     2  0.1043      0.895 0.000 0.960 0.000 0.040 0.000
#> SRR1424700     2  0.3160      0.764 0.000 0.808 0.004 0.000 0.188
#> SRR1424701     3  0.3003      0.740 0.000 0.000 0.812 0.000 0.188
#> SRR1424702     3  0.0000      0.866 0.000 0.000 1.000 0.000 0.000
#> SRR1424703     3  0.0000      0.866 0.000 0.000 1.000 0.000 0.000
#> SRR1424704     3  0.0000      0.866 0.000 0.000 1.000 0.000 0.000
#> SRR1424706     3  0.3424      0.776 0.000 0.000 0.760 0.240 0.000
#> SRR1424707     3  0.0000      0.866 0.000 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR1424656     1  0.4079      0.728 0.744 0.000 0.000 0.000 0.172 0.084
#> SRR1424657     1  0.4783      0.555 0.616 0.000 0.000 0.000 0.308 0.076
#> SRR1424658     1  0.1285      0.586 0.944 0.000 0.004 0.000 0.000 0.052
#> SRR1424659     1  0.4381      0.737 0.732 0.000 0.004 0.000 0.136 0.128
#> SRR1424660     5  0.2883      0.765 0.212 0.000 0.000 0.000 0.788 0.000
#> SRR1424661     4  0.0713      0.866 0.000 0.000 0.000 0.972 0.000 0.028
#> SRR1424662     4  0.4990      0.638 0.124 0.000 0.000 0.688 0.020 0.168
#> SRR1424663     5  0.2762      0.776 0.196 0.000 0.000 0.000 0.804 0.000
#> SRR1424664     1  0.3834      0.740 0.772 0.000 0.000 0.000 0.144 0.084
#> SRR1424665     1  0.3202      0.745 0.816 0.000 0.000 0.000 0.144 0.040
#> SRR1424666     5  0.4801      0.670 0.196 0.000 0.136 0.000 0.668 0.000
#> SRR1424667     2  0.4871      0.560 0.000 0.644 0.000 0.112 0.000 0.244
#> SRR1424668     5  0.2871      0.779 0.192 0.000 0.004 0.000 0.804 0.000
#> SRR1424669     1  0.3555      0.734 0.776 0.000 0.000 0.000 0.184 0.040
#> SRR1424670     1  0.4044      0.733 0.744 0.000 0.000 0.000 0.180 0.076
#> SRR1424671     4  0.1204      0.859 0.000 0.000 0.000 0.944 0.000 0.056
#> SRR1424672     5  0.3384      0.787 0.120 0.000 0.068 0.000 0.812 0.000
#> SRR1424674     1  0.4357      0.702 0.696 0.000 0.000 0.000 0.232 0.072
#> SRR1424673     3  0.3578      0.645 0.000 0.000 0.660 0.340 0.000 0.000
#> SRR1424675     2  0.2129      0.778 0.000 0.904 0.000 0.040 0.000 0.056
#> SRR1424676     6  0.7488      0.373 0.248 0.292 0.000 0.000 0.136 0.324
#> SRR1424677     4  0.1204      0.859 0.000 0.000 0.000 0.944 0.000 0.056
#> SRR1424678     2  0.0865      0.798 0.000 0.964 0.000 0.036 0.000 0.000
#> SRR1424679     2  0.0363      0.789 0.000 0.988 0.000 0.000 0.000 0.012
#> SRR1424680     4  0.5034      0.465 0.000 0.240 0.000 0.628 0.000 0.132
#> SRR1424681     5  0.0291      0.756 0.000 0.000 0.004 0.000 0.992 0.004
#> SRR1424682     3  0.2793      0.749 0.000 0.000 0.800 0.200 0.000 0.000
#> SRR1424683     4  0.0146      0.867 0.000 0.000 0.000 0.996 0.000 0.004
#> SRR1424685     5  0.0405      0.759 0.000 0.000 0.008 0.000 0.988 0.004
#> SRR1424686     5  0.0806      0.769 0.008 0.000 0.020 0.000 0.972 0.000
#> SRR1424687     4  0.2768      0.745 0.012 0.000 0.000 0.832 0.156 0.000
#> SRR1424688     1  0.4929      0.581 0.600 0.000 0.004 0.000 0.324 0.072
#> SRR1424689     6  0.5947      0.221 0.240 0.000 0.000 0.000 0.312 0.448
#> SRR1424690     1  0.4908      0.593 0.584 0.000 0.004 0.000 0.348 0.064
#> SRR1424691     5  0.1806      0.681 0.088 0.000 0.004 0.000 0.908 0.000
#> SRR1424692     4  0.0260      0.867 0.000 0.000 0.000 0.992 0.000 0.008
#> SRR1424684     2  0.0713      0.787 0.000 0.972 0.000 0.000 0.000 0.028
#> SRR1424693     1  0.5136      0.566 0.584 0.000 0.004 0.000 0.320 0.092
#> SRR1424694     4  0.0363      0.866 0.000 0.000 0.000 0.988 0.000 0.012
#> SRR1424695     1  0.5109      0.558 0.592 0.000 0.004 0.000 0.312 0.092
#> SRR1424696     2  0.2258      0.783 0.000 0.896 0.000 0.044 0.000 0.060
#> SRR1424697     3  0.3515      0.663 0.000 0.000 0.676 0.324 0.000 0.000
#> SRR1424698     3  0.2234      0.666 0.000 0.000 0.872 0.000 0.004 0.124
#> SRR1424699     2  0.4685      0.136 0.000 0.520 0.000 0.044 0.000 0.436
#> SRR1424700     6  0.5798      0.234 0.000 0.352 0.000 0.000 0.188 0.460
#> SRR1424701     6  0.5806      0.266 0.000 0.000 0.344 0.000 0.192 0.464
#> SRR1424702     3  0.0260      0.777 0.000 0.000 0.992 0.000 0.008 0.000
#> SRR1424703     3  0.0146      0.776 0.000 0.000 0.996 0.000 0.004 0.000
#> SRR1424704     3  0.0260      0.777 0.000 0.000 0.992 0.000 0.008 0.000
#> SRR1424706     3  0.3578      0.644 0.000 0.000 0.660 0.340 0.000 0.000
#> SRR1424707     3  0.0260      0.777 0.000 0.000 0.992 0.000 0.008 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 16960 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 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk MAD-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.636           0.822       0.925         0.4863 0.534   0.534
#> 3 3 0.590           0.722       0.875         0.3769 0.693   0.475
#> 4 4 0.667           0.705       0.857         0.1183 0.809   0.504
#> 5 5 0.629           0.595       0.794         0.0661 0.875   0.556
#> 6 6 0.665           0.555       0.693         0.0474 0.918   0.621

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
#> SRR1424656     1  0.0000     0.8907 1.000 0.000
#> SRR1424657     1  0.0000     0.8907 1.000 0.000
#> SRR1424658     1  0.9686     0.3931 0.604 0.396
#> SRR1424659     1  0.0000     0.8907 1.000 0.000
#> SRR1424660     1  0.0000     0.8907 1.000 0.000
#> SRR1424661     1  0.9998     0.0646 0.508 0.492
#> SRR1424662     2  0.0000     0.9515 0.000 1.000
#> SRR1424663     1  0.0000     0.8907 1.000 0.000
#> SRR1424664     1  0.0000     0.8907 1.000 0.000
#> SRR1424665     1  0.6887     0.7465 0.816 0.184
#> SRR1424666     1  0.0000     0.8907 1.000 0.000
#> SRR1424667     2  0.0000     0.9515 0.000 1.000
#> SRR1424668     1  0.0000     0.8907 1.000 0.000
#> SRR1424669     1  0.9000     0.5702 0.684 0.316
#> SRR1424670     1  0.0000     0.8907 1.000 0.000
#> SRR1424671     2  0.0938     0.9431 0.012 0.988
#> SRR1424672     1  0.0000     0.8907 1.000 0.000
#> SRR1424674     1  0.0000     0.8907 1.000 0.000
#> SRR1424673     1  0.8016     0.6645 0.756 0.244
#> SRR1424675     2  0.0000     0.9515 0.000 1.000
#> SRR1424676     2  0.2043     0.9236 0.032 0.968
#> SRR1424677     2  0.0000     0.9515 0.000 1.000
#> SRR1424678     2  0.0000     0.9515 0.000 1.000
#> SRR1424679     2  0.0000     0.9515 0.000 1.000
#> SRR1424680     2  0.0000     0.9515 0.000 1.000
#> SRR1424681     1  0.0000     0.8907 1.000 0.000
#> SRR1424682     1  0.9460     0.4442 0.636 0.364
#> SRR1424683     2  0.0000     0.9515 0.000 1.000
#> SRR1424685     1  0.0000     0.8907 1.000 0.000
#> SRR1424686     1  0.0000     0.8907 1.000 0.000
#> SRR1424687     2  0.8016     0.6354 0.244 0.756
#> SRR1424688     1  0.7815     0.6888 0.768 0.232
#> SRR1424689     1  0.6801     0.7515 0.820 0.180
#> SRR1424690     1  0.0000     0.8907 1.000 0.000
#> SRR1424691     1  0.0000     0.8907 1.000 0.000
#> SRR1424692     2  0.0000     0.9515 0.000 1.000
#> SRR1424684     2  0.0000     0.9515 0.000 1.000
#> SRR1424693     1  0.0672     0.8869 0.992 0.008
#> SRR1424694     2  0.2423     0.9169 0.040 0.960
#> SRR1424695     1  0.9686     0.3931 0.604 0.396
#> SRR1424696     2  0.0000     0.9515 0.000 1.000
#> SRR1424697     1  0.8144     0.6532 0.748 0.252
#> SRR1424698     1  0.0376     0.8890 0.996 0.004
#> SRR1424699     2  0.0000     0.9515 0.000 1.000
#> SRR1424700     2  0.0000     0.9515 0.000 1.000
#> SRR1424701     1  0.2236     0.8715 0.964 0.036
#> SRR1424702     1  0.0000     0.8907 1.000 0.000
#> SRR1424703     1  0.0000     0.8907 1.000 0.000
#> SRR1424704     1  0.0000     0.8907 1.000 0.000
#> SRR1424706     2  0.9522     0.3448 0.372 0.628
#> SRR1424707     1  0.2236     0.8715 0.964 0.036

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1424656     1  0.0000     0.8253 1.000 0.000 0.000
#> SRR1424657     1  0.0000     0.8253 1.000 0.000 0.000
#> SRR1424658     1  0.0000     0.8253 1.000 0.000 0.000
#> SRR1424659     1  0.0000     0.8253 1.000 0.000 0.000
#> SRR1424660     1  0.2261     0.7859 0.932 0.000 0.068
#> SRR1424661     2  0.6349     0.6708 0.080 0.764 0.156
#> SRR1424662     1  0.5926     0.5116 0.644 0.356 0.000
#> SRR1424663     1  0.0000     0.8253 1.000 0.000 0.000
#> SRR1424664     1  0.0000     0.8253 1.000 0.000 0.000
#> SRR1424665     1  0.0000     0.8253 1.000 0.000 0.000
#> SRR1424666     3  0.6291     0.2191 0.468 0.000 0.532
#> SRR1424667     2  0.0000     0.8552 0.000 1.000 0.000
#> SRR1424668     1  0.6154     0.1245 0.592 0.000 0.408
#> SRR1424669     1  0.5268     0.6965 0.776 0.212 0.012
#> SRR1424670     1  0.0000     0.8253 1.000 0.000 0.000
#> SRR1424671     2  0.5948     0.3791 0.000 0.640 0.360
#> SRR1424672     3  0.5098     0.6500 0.248 0.000 0.752
#> SRR1424674     1  0.0000     0.8253 1.000 0.000 0.000
#> SRR1424673     3  0.4504     0.6835 0.000 0.196 0.804
#> SRR1424675     2  0.0000     0.8552 0.000 1.000 0.000
#> SRR1424676     2  0.4555     0.7748 0.000 0.800 0.200
#> SRR1424677     2  0.0000     0.8552 0.000 1.000 0.000
#> SRR1424678     2  0.1643     0.8482 0.000 0.956 0.044
#> SRR1424679     2  0.4555     0.7748 0.000 0.800 0.200
#> SRR1424680     2  0.0000     0.8552 0.000 1.000 0.000
#> SRR1424681     3  0.2066     0.8072 0.060 0.000 0.940
#> SRR1424682     3  0.0000     0.8378 0.000 0.000 1.000
#> SRR1424683     2  0.0237     0.8550 0.000 0.996 0.004
#> SRR1424685     3  0.6192     0.0757 0.420 0.000 0.580
#> SRR1424686     1  0.5733     0.4052 0.676 0.000 0.324
#> SRR1424687     2  0.3267     0.7839 0.000 0.884 0.116
#> SRR1424688     1  0.4555     0.7246 0.800 0.000 0.200
#> SRR1424689     1  0.2625     0.8026 0.916 0.000 0.084
#> SRR1424690     1  0.2625     0.8027 0.916 0.000 0.084
#> SRR1424691     1  0.4974     0.6911 0.764 0.000 0.236
#> SRR1424692     2  0.0000     0.8552 0.000 1.000 0.000
#> SRR1424684     2  0.4555     0.7748 0.000 0.800 0.200
#> SRR1424693     1  0.4654     0.7184 0.792 0.000 0.208
#> SRR1424694     1  0.6823     0.1457 0.504 0.484 0.012
#> SRR1424695     1  0.4504     0.7283 0.804 0.000 0.196
#> SRR1424696     2  0.0000     0.8552 0.000 1.000 0.000
#> SRR1424697     3  0.2796     0.7842 0.000 0.092 0.908
#> SRR1424698     3  0.0000     0.8378 0.000 0.000 1.000
#> SRR1424699     2  0.4555     0.7748 0.000 0.800 0.200
#> SRR1424700     2  0.5058     0.7318 0.000 0.756 0.244
#> SRR1424701     3  0.0000     0.8378 0.000 0.000 1.000
#> SRR1424702     3  0.0000     0.8378 0.000 0.000 1.000
#> SRR1424703     3  0.0000     0.8378 0.000 0.000 1.000
#> SRR1424704     3  0.0000     0.8378 0.000 0.000 1.000
#> SRR1424706     3  0.4399     0.6928 0.000 0.188 0.812
#> SRR1424707     3  0.0000     0.8378 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
#> SRR1424656     1  0.0000     0.8512 1.000 0.000 0.000 0.000
#> SRR1424657     1  0.0592     0.8488 0.984 0.016 0.000 0.000
#> SRR1424658     1  0.1022     0.8428 0.968 0.032 0.000 0.000
#> SRR1424659     1  0.0000     0.8512 1.000 0.000 0.000 0.000
#> SRR1424660     1  0.1733     0.8311 0.948 0.000 0.028 0.024
#> SRR1424661     4  0.0712     0.8840 0.004 0.004 0.008 0.984
#> SRR1424662     4  0.2943     0.9083 0.032 0.076 0.000 0.892
#> SRR1424663     1  0.0804     0.8454 0.980 0.000 0.008 0.012
#> SRR1424664     1  0.0000     0.8512 1.000 0.000 0.000 0.000
#> SRR1424665     1  0.0188     0.8508 0.996 0.004 0.000 0.000
#> SRR1424666     1  0.4469     0.7323 0.808 0.000 0.112 0.080
#> SRR1424667     4  0.2149     0.9127 0.000 0.088 0.000 0.912
#> SRR1424668     1  0.4136     0.6914 0.788 0.000 0.196 0.016
#> SRR1424669     4  0.3950     0.7056 0.184 0.008 0.004 0.804
#> SRR1424670     1  0.0000     0.8512 1.000 0.000 0.000 0.000
#> SRR1424671     4  0.2124     0.9152 0.000 0.068 0.008 0.924
#> SRR1424672     3  0.6434     0.1742 0.432 0.000 0.500 0.068
#> SRR1424674     1  0.0707     0.8476 0.980 0.020 0.000 0.000
#> SRR1424673     3  0.4134     0.6564 0.000 0.000 0.740 0.260
#> SRR1424675     2  0.4454     0.3615 0.000 0.692 0.000 0.308
#> SRR1424676     2  0.0844     0.7136 0.004 0.980 0.004 0.012
#> SRR1424677     4  0.2081     0.9135 0.000 0.084 0.000 0.916
#> SRR1424678     2  0.1389     0.7020 0.000 0.952 0.000 0.048
#> SRR1424679     2  0.0895     0.7107 0.000 0.976 0.004 0.020
#> SRR1424680     2  0.1211     0.7064 0.000 0.960 0.000 0.040
#> SRR1424681     3  0.7755     0.4788 0.160 0.164 0.608 0.068
#> SRR1424682     3  0.2053     0.8351 0.000 0.004 0.924 0.072
#> SRR1424683     4  0.3711     0.8591 0.024 0.140 0.000 0.836
#> SRR1424685     2  0.9161     0.0172 0.280 0.332 0.320 0.068
#> SRR1424686     1  0.5172     0.6841 0.744 0.000 0.188 0.068
#> SRR1424687     4  0.0779     0.8936 0.000 0.016 0.004 0.980
#> SRR1424688     2  0.3626     0.6226 0.184 0.812 0.004 0.000
#> SRR1424689     2  0.4817     0.2753 0.388 0.612 0.000 0.000
#> SRR1424690     1  0.3486     0.7123 0.812 0.188 0.000 0.000
#> SRR1424691     1  0.4609     0.6531 0.752 0.224 0.024 0.000
#> SRR1424692     4  0.2081     0.9135 0.000 0.084 0.000 0.916
#> SRR1424684     2  0.1339     0.7129 0.008 0.964 0.004 0.024
#> SRR1424693     2  0.4836     0.4164 0.320 0.672 0.008 0.000
#> SRR1424694     1  0.6876     0.4274 0.576 0.144 0.000 0.280
#> SRR1424695     1  0.4898     0.2972 0.584 0.416 0.000 0.000
#> SRR1424696     2  0.0937     0.7123 0.012 0.976 0.000 0.012
#> SRR1424697     3  0.1902     0.8381 0.000 0.004 0.932 0.064
#> SRR1424698     3  0.0657     0.8542 0.000 0.012 0.984 0.004
#> SRR1424699     2  0.6347     0.2745 0.000 0.548 0.384 0.068
#> SRR1424700     2  0.5682     0.1893 0.000 0.520 0.456 0.024
#> SRR1424701     3  0.0927     0.8521 0.000 0.016 0.976 0.008
#> SRR1424702     3  0.0000     0.8589 0.000 0.000 1.000 0.000
#> SRR1424703     3  0.0524     0.8557 0.000 0.008 0.988 0.004
#> SRR1424704     3  0.0000     0.8589 0.000 0.000 1.000 0.000
#> SRR1424706     3  0.1284     0.8506 0.000 0.012 0.964 0.024
#> SRR1424707     3  0.0000     0.8589 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
#> SRR1424656     1  0.0510     0.8231 0.984 0.000 0.000 0.000 0.016
#> SRR1424657     1  0.2179     0.7747 0.888 0.000 0.000 0.000 0.112
#> SRR1424658     1  0.1671     0.8046 0.924 0.000 0.000 0.000 0.076
#> SRR1424659     1  0.0703     0.8221 0.976 0.000 0.000 0.000 0.024
#> SRR1424660     1  0.2825     0.7125 0.860 0.000 0.016 0.000 0.124
#> SRR1424661     4  0.0794     0.7510 0.000 0.000 0.000 0.972 0.028
#> SRR1424662     4  0.5390     0.5762 0.212 0.008 0.000 0.676 0.104
#> SRR1424663     1  0.3210     0.6466 0.788 0.000 0.000 0.000 0.212
#> SRR1424664     1  0.0794     0.8207 0.972 0.000 0.000 0.000 0.028
#> SRR1424665     1  0.1043     0.8080 0.960 0.000 0.000 0.000 0.040
#> SRR1424666     5  0.5291    -0.0563 0.456 0.000 0.048 0.000 0.496
#> SRR1424667     4  0.3267     0.7105 0.000 0.044 0.000 0.844 0.112
#> SRR1424668     1  0.3697     0.6636 0.820 0.000 0.100 0.000 0.080
#> SRR1424669     4  0.7103     0.2552 0.304 0.012 0.004 0.436 0.244
#> SRR1424670     1  0.0609     0.8212 0.980 0.000 0.000 0.000 0.020
#> SRR1424671     4  0.2650     0.7286 0.000 0.004 0.068 0.892 0.036
#> SRR1424672     5  0.5339     0.5162 0.152 0.000 0.176 0.000 0.672
#> SRR1424674     1  0.1410     0.8042 0.940 0.000 0.000 0.000 0.060
#> SRR1424673     3  0.4333     0.7166 0.012 0.000 0.788 0.120 0.080
#> SRR1424675     2  0.8682     0.1084 0.112 0.484 0.112 0.176 0.116
#> SRR1424676     2  0.0486     0.6961 0.004 0.988 0.004 0.004 0.000
#> SRR1424677     4  0.0162     0.7531 0.000 0.004 0.000 0.996 0.000
#> SRR1424678     2  0.0703     0.6908 0.000 0.976 0.000 0.024 0.000
#> SRR1424679     2  0.0324     0.6925 0.000 0.992 0.004 0.004 0.000
#> SRR1424680     2  0.3579     0.6579 0.000 0.828 0.000 0.072 0.100
#> SRR1424681     5  0.5566     0.5164 0.108 0.024 0.180 0.000 0.688
#> SRR1424682     3  0.5772     0.3820 0.000 0.000 0.584 0.120 0.296
#> SRR1424683     4  0.5809     0.4256 0.008 0.164 0.000 0.640 0.188
#> SRR1424685     5  0.6332     0.2475 0.096 0.288 0.036 0.000 0.580
#> SRR1424686     5  0.4874     0.3796 0.328 0.000 0.040 0.000 0.632
#> SRR1424687     4  0.3612     0.5727 0.000 0.000 0.000 0.732 0.268
#> SRR1424688     2  0.5678     0.4544 0.128 0.612 0.000 0.000 0.260
#> SRR1424689     2  0.4610     0.5172 0.188 0.740 0.000 0.004 0.068
#> SRR1424690     1  0.6578    -0.1692 0.468 0.248 0.000 0.000 0.284
#> SRR1424691     5  0.6123     0.3384 0.224 0.188 0.004 0.000 0.584
#> SRR1424692     4  0.0451     0.7533 0.000 0.004 0.000 0.988 0.008
#> SRR1424684     2  0.0162     0.6955 0.000 0.996 0.000 0.004 0.000
#> SRR1424693     2  0.5831     0.4081 0.128 0.580 0.000 0.000 0.292
#> SRR1424694     5  0.8228     0.0253 0.156 0.268 0.000 0.188 0.388
#> SRR1424695     2  0.6171     0.3442 0.240 0.556 0.000 0.000 0.204
#> SRR1424696     2  0.3825     0.6612 0.020 0.816 0.000 0.028 0.136
#> SRR1424697     3  0.1168     0.8239 0.000 0.000 0.960 0.008 0.032
#> SRR1424698     3  0.0162     0.8275 0.000 0.000 0.996 0.000 0.004
#> SRR1424699     3  0.5583     0.4559 0.000 0.336 0.584 0.004 0.076
#> SRR1424700     3  0.5619     0.4653 0.000 0.332 0.584 0.004 0.080
#> SRR1424701     3  0.1211     0.8176 0.000 0.024 0.960 0.000 0.016
#> SRR1424702     3  0.1121     0.8200 0.000 0.000 0.956 0.000 0.044
#> SRR1424703     3  0.0000     0.8271 0.000 0.000 1.000 0.000 0.000
#> SRR1424704     3  0.0510     0.8282 0.000 0.000 0.984 0.000 0.016
#> SRR1424706     3  0.2230     0.7817 0.000 0.000 0.884 0.116 0.000
#> SRR1424707     3  0.0609     0.8279 0.000 0.000 0.980 0.000 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
#> SRR1424656     1  0.2457     0.7999 0.880 0.000 0.000 0.000 0.084 0.036
#> SRR1424657     1  0.3492     0.7369 0.796 0.016 0.000 0.004 0.172 0.012
#> SRR1424658     1  0.1820     0.8035 0.924 0.012 0.000 0.000 0.056 0.008
#> SRR1424659     1  0.2973     0.7835 0.836 0.004 0.000 0.000 0.024 0.136
#> SRR1424660     1  0.3935     0.7363 0.804 0.064 0.048 0.000 0.000 0.084
#> SRR1424661     4  0.0862     0.7165 0.004 0.008 0.000 0.972 0.016 0.000
#> SRR1424662     4  0.6108     0.3905 0.272 0.228 0.000 0.488 0.000 0.012
#> SRR1424663     1  0.3920     0.7631 0.768 0.008 0.000 0.000 0.056 0.168
#> SRR1424664     1  0.3633     0.7728 0.812 0.052 0.000 0.000 0.020 0.116
#> SRR1424665     1  0.1738     0.7818 0.928 0.052 0.000 0.000 0.004 0.016
#> SRR1424666     6  0.4041     0.6861 0.096 0.136 0.004 0.000 0.000 0.764
#> SRR1424667     4  0.3984     0.4838 0.000 0.396 0.000 0.596 0.000 0.008
#> SRR1424668     1  0.5215     0.5900 0.696 0.056 0.188 0.004 0.008 0.048
#> SRR1424669     2  0.6635    -0.3967 0.152 0.404 0.000 0.060 0.000 0.384
#> SRR1424670     1  0.4759     0.5873 0.640 0.052 0.000 0.000 0.012 0.296
#> SRR1424671     4  0.3060     0.6888 0.004 0.044 0.036 0.876 0.012 0.028
#> SRR1424672     6  0.3901     0.6873 0.032 0.016 0.008 0.000 0.160 0.784
#> SRR1424674     1  0.4241     0.7226 0.764 0.040 0.000 0.004 0.160 0.032
#> SRR1424673     3  0.6304     0.5349 0.056 0.056 0.636 0.184 0.008 0.060
#> SRR1424675     2  0.3119     0.2579 0.092 0.860 0.016 0.016 0.008 0.008
#> SRR1424676     2  0.3989     0.4555 0.000 0.528 0.000 0.000 0.468 0.004
#> SRR1424677     4  0.0508     0.7151 0.000 0.012 0.000 0.984 0.000 0.004
#> SRR1424678     2  0.3979     0.4718 0.000 0.540 0.000 0.004 0.456 0.000
#> SRR1424679     2  0.3833     0.4773 0.000 0.556 0.000 0.000 0.444 0.000
#> SRR1424680     5  0.5531    -0.0538 0.000 0.344 0.000 0.128 0.524 0.004
#> SRR1424681     6  0.1950     0.7642 0.008 0.012 0.020 0.000 0.032 0.928
#> SRR1424682     6  0.6537     0.4945 0.000 0.024 0.116 0.200 0.076 0.584
#> SRR1424683     4  0.4164     0.4102 0.004 0.012 0.000 0.668 0.308 0.008
#> SRR1424685     5  0.5112     0.2119 0.004 0.068 0.004 0.000 0.568 0.356
#> SRR1424686     6  0.2239     0.7559 0.048 0.000 0.020 0.000 0.024 0.908
#> SRR1424687     4  0.4444     0.2698 0.000 0.008 0.000 0.612 0.024 0.356
#> SRR1424688     5  0.3087     0.4532 0.160 0.012 0.000 0.004 0.820 0.004
#> SRR1424689     2  0.6345     0.2604 0.076 0.548 0.000 0.000 0.244 0.132
#> SRR1424690     5  0.5917     0.2732 0.252 0.004 0.000 0.000 0.500 0.244
#> SRR1424691     5  0.4122     0.3853 0.048 0.000 0.000 0.000 0.704 0.248
#> SRR1424692     4  0.0405     0.7173 0.000 0.004 0.000 0.988 0.008 0.000
#> SRR1424684     2  0.3843     0.4742 0.000 0.548 0.000 0.000 0.452 0.000
#> SRR1424693     5  0.2151     0.3955 0.008 0.072 0.000 0.000 0.904 0.016
#> SRR1424694     5  0.5433     0.0832 0.056 0.004 0.000 0.376 0.540 0.024
#> SRR1424695     5  0.5341     0.2414 0.096 0.208 0.000 0.000 0.656 0.040
#> SRR1424696     5  0.3855     0.0760 0.000 0.272 0.000 0.024 0.704 0.000
#> SRR1424697     3  0.1334     0.8414 0.000 0.000 0.948 0.020 0.000 0.032
#> SRR1424698     3  0.0405     0.8426 0.004 0.000 0.988 0.000 0.000 0.008
#> SRR1424699     3  0.3650     0.6732 0.000 0.272 0.716 0.000 0.008 0.004
#> SRR1424700     3  0.3508     0.6656 0.000 0.292 0.704 0.000 0.004 0.000
#> SRR1424701     3  0.0000     0.8442 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1424702     3  0.2219     0.7791 0.000 0.000 0.864 0.000 0.000 0.136
#> SRR1424703     3  0.0000     0.8442 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1424704     3  0.1610     0.8243 0.000 0.000 0.916 0.000 0.000 0.084
#> SRR1424706     3  0.3052     0.6837 0.000 0.004 0.780 0.216 0.000 0.000
#> SRR1424707     3  0.0632     0.8429 0.000 0.000 0.976 0.000 0.000 0.024

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 16960 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 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-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.284           0.781       0.849         0.4038 0.534   0.534
#> 3 3 0.445           0.628       0.796         0.3900 0.551   0.417
#> 4 4 0.692           0.849       0.926         0.2272 0.755   0.560
#> 5 5 0.693           0.821       0.925         0.0265 0.982   0.942
#> 6 6 0.690           0.759       0.873         0.1030 0.929   0.759

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
#> SRR1424656     1  0.0376      0.804 0.996 0.004
#> SRR1424657     1  0.0376      0.804 0.996 0.004
#> SRR1424658     2  0.9795      0.865 0.416 0.584
#> SRR1424659     1  0.0000      0.807 1.000 0.000
#> SRR1424660     1  0.5629      0.629 0.868 0.132
#> SRR1424661     1  0.0000      0.807 1.000 0.000
#> SRR1424662     2  0.9795      0.865 0.416 0.584
#> SRR1424663     1  0.0000      0.807 1.000 0.000
#> SRR1424664     1  0.0000      0.807 1.000 0.000
#> SRR1424665     1  0.7139      0.478 0.804 0.196
#> SRR1424666     1  0.7376      0.779 0.792 0.208
#> SRR1424667     2  0.7376      0.782 0.208 0.792
#> SRR1424668     1  0.7376      0.779 0.792 0.208
#> SRR1424669     1  0.5946      0.608 0.856 0.144
#> SRR1424670     1  0.0938      0.798 0.988 0.012
#> SRR1424671     1  0.0000      0.807 1.000 0.000
#> SRR1424672     1  0.7376      0.779 0.792 0.208
#> SRR1424674     1  0.0376      0.804 0.996 0.004
#> SRR1424673     1  0.7376      0.779 0.792 0.208
#> SRR1424675     2  0.9795      0.865 0.416 0.584
#> SRR1424676     2  0.9795      0.865 0.416 0.584
#> SRR1424677     2  0.9909      0.822 0.444 0.556
#> SRR1424678     2  0.7376      0.782 0.208 0.792
#> SRR1424679     2  0.7376      0.782 0.208 0.792
#> SRR1424680     2  0.7376      0.782 0.208 0.792
#> SRR1424681     1  0.0000      0.807 1.000 0.000
#> SRR1424682     1  0.7376      0.779 0.792 0.208
#> SRR1424683     2  0.9815      0.861 0.420 0.580
#> SRR1424685     1  0.0000      0.807 1.000 0.000
#> SRR1424686     1  0.7376      0.779 0.792 0.208
#> SRR1424687     1  0.7219      0.466 0.800 0.200
#> SRR1424688     2  0.9795      0.865 0.416 0.584
#> SRR1424689     1  0.5946      0.608 0.856 0.144
#> SRR1424690     1  0.0000      0.807 1.000 0.000
#> SRR1424691     1  0.0000      0.807 1.000 0.000
#> SRR1424692     2  0.9815      0.861 0.420 0.580
#> SRR1424684     2  0.7376      0.782 0.208 0.792
#> SRR1424693     1  0.0938      0.798 0.988 0.012
#> SRR1424694     2  0.9815      0.861 0.420 0.580
#> SRR1424695     2  0.9850      0.849 0.428 0.572
#> SRR1424696     2  0.7376      0.782 0.208 0.792
#> SRR1424697     1  0.7376      0.779 0.792 0.208
#> SRR1424698     1  0.7376      0.779 0.792 0.208
#> SRR1424699     2  0.9795      0.865 0.416 0.584
#> SRR1424700     2  0.9795      0.865 0.416 0.584
#> SRR1424701     1  0.5629      0.629 0.868 0.132
#> SRR1424702     1  0.7376      0.779 0.792 0.208
#> SRR1424703     1  0.7376      0.779 0.792 0.208
#> SRR1424704     1  0.7376      0.779 0.792 0.208
#> SRR1424706     1  0.7376      0.779 0.792 0.208
#> SRR1424707     1  0.7376      0.779 0.792 0.208

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1424656     1  0.3686      0.668 0.860 0.000 0.140
#> SRR1424657     1  0.3686      0.668 0.860 0.000 0.140
#> SRR1424658     1  0.6244      0.264 0.560 0.440 0.000
#> SRR1424659     1  0.3752      0.667 0.856 0.000 0.144
#> SRR1424660     1  0.0592      0.667 0.988 0.000 0.012
#> SRR1424661     1  0.3752      0.667 0.856 0.000 0.144
#> SRR1424662     1  0.6244      0.264 0.560 0.440 0.000
#> SRR1424663     1  0.3752      0.667 0.856 0.000 0.144
#> SRR1424664     1  0.3752      0.667 0.856 0.000 0.144
#> SRR1424665     1  0.2486      0.647 0.932 0.060 0.008
#> SRR1424666     3  0.1860      0.970 0.052 0.000 0.948
#> SRR1424667     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1424668     3  0.1860      0.970 0.052 0.000 0.948
#> SRR1424669     1  0.0000      0.666 1.000 0.000 0.000
#> SRR1424670     1  0.3551      0.669 0.868 0.000 0.132
#> SRR1424671     1  0.3752      0.667 0.856 0.000 0.144
#> SRR1424672     3  0.1860      0.970 0.052 0.000 0.948
#> SRR1424674     1  0.3686      0.668 0.860 0.000 0.140
#> SRR1424673     1  0.6026      0.356 0.624 0.000 0.376
#> SRR1424675     1  0.6244      0.264 0.560 0.440 0.000
#> SRR1424676     1  0.6244      0.264 0.560 0.440 0.000
#> SRR1424677     1  0.6168      0.301 0.588 0.412 0.000
#> SRR1424678     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1424679     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1424680     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1424681     1  0.3752      0.667 0.856 0.000 0.144
#> SRR1424682     3  0.1753      0.969 0.048 0.000 0.952
#> SRR1424683     1  0.6235      0.270 0.564 0.436 0.000
#> SRR1424685     1  0.3752      0.667 0.856 0.000 0.144
#> SRR1424686     3  0.1860      0.970 0.052 0.000 0.948
#> SRR1424687     1  0.1964      0.644 0.944 0.056 0.000
#> SRR1424688     1  0.6244      0.264 0.560 0.440 0.000
#> SRR1424689     1  0.0000      0.666 1.000 0.000 0.000
#> SRR1424690     1  0.3752      0.667 0.856 0.000 0.144
#> SRR1424691     1  0.3752      0.667 0.856 0.000 0.144
#> SRR1424692     1  0.6235      0.270 0.564 0.436 0.000
#> SRR1424684     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1424693     1  0.3551      0.669 0.868 0.000 0.132
#> SRR1424694     1  0.6235      0.270 0.564 0.436 0.000
#> SRR1424695     1  0.6215      0.282 0.572 0.428 0.000
#> SRR1424696     2  0.0000      1.000 0.000 1.000 0.000
#> SRR1424697     1  0.6026      0.356 0.624 0.000 0.376
#> SRR1424698     3  0.0000      0.950 0.000 0.000 1.000
#> SRR1424699     1  0.6244      0.264 0.560 0.440 0.000
#> SRR1424700     1  0.6244      0.264 0.560 0.440 0.000
#> SRR1424701     1  0.0592      0.667 0.988 0.000 0.012
#> SRR1424702     3  0.0000      0.950 0.000 0.000 1.000
#> SRR1424703     1  0.6026      0.356 0.624 0.000 0.376
#> SRR1424704     3  0.0000      0.950 0.000 0.000 1.000
#> SRR1424706     1  0.6026      0.356 0.624 0.000 0.376
#> SRR1424707     1  0.6026      0.356 0.624 0.000 0.376

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1 p2    p3    p4
#> SRR1424656     1  0.0188      0.865 0.996  0 0.000 0.004
#> SRR1424657     1  0.0188      0.865 0.996  0 0.000 0.004
#> SRR1424658     4  0.0000      0.946 0.000  0 0.000 1.000
#> SRR1424659     1  0.0000      0.865 1.000  0 0.000 0.000
#> SRR1424660     1  0.3024      0.775 0.852  0 0.000 0.148
#> SRR1424661     1  0.0000      0.865 1.000  0 0.000 0.000
#> SRR1424662     4  0.0000      0.946 0.000  0 0.000 1.000
#> SRR1424663     1  0.0000      0.865 1.000  0 0.000 0.000
#> SRR1424664     1  0.0000      0.865 1.000  0 0.000 0.000
#> SRR1424665     1  0.4040      0.675 0.752  0 0.000 0.248
#> SRR1424666     3  0.3444      0.890 0.184  0 0.816 0.000
#> SRR1424667     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR1424668     3  0.3444      0.890 0.184  0 0.816 0.000
#> SRR1424669     1  0.3726      0.726 0.788  0 0.000 0.212
#> SRR1424670     1  0.0469      0.862 0.988  0 0.000 0.012
#> SRR1424671     1  0.0000      0.865 1.000  0 0.000 0.000
#> SRR1424672     3  0.3444      0.890 0.184  0 0.816 0.000
#> SRR1424674     1  0.0188      0.865 0.996  0 0.000 0.004
#> SRR1424673     1  0.3907      0.662 0.768  0 0.232 0.000
#> SRR1424675     4  0.0000      0.946 0.000  0 0.000 1.000
#> SRR1424676     4  0.0000      0.946 0.000  0 0.000 1.000
#> SRR1424677     4  0.0921      0.924 0.028  0 0.000 0.972
#> SRR1424678     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR1424679     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR1424680     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR1424681     1  0.0000      0.865 1.000  0 0.000 0.000
#> SRR1424682     3  0.3400      0.890 0.180  0 0.820 0.000
#> SRR1424683     4  0.0336      0.944 0.008  0 0.000 0.992
#> SRR1424685     1  0.0000      0.865 1.000  0 0.000 0.000
#> SRR1424686     3  0.3444      0.890 0.184  0 0.816 0.000
#> SRR1424687     4  0.4877      0.176 0.408  0 0.000 0.592
#> SRR1424688     4  0.0000      0.946 0.000  0 0.000 1.000
#> SRR1424689     1  0.3688      0.730 0.792  0 0.000 0.208
#> SRR1424690     1  0.0188      0.865 0.996  0 0.000 0.004
#> SRR1424691     1  0.0000      0.865 1.000  0 0.000 0.000
#> SRR1424692     4  0.0336      0.944 0.008  0 0.000 0.992
#> SRR1424684     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR1424693     1  0.3569      0.714 0.804  0 0.000 0.196
#> SRR1424694     4  0.0336      0.944 0.008  0 0.000 0.992
#> SRR1424695     4  0.0469      0.939 0.012  0 0.000 0.988
#> SRR1424696     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR1424697     1  0.3907      0.662 0.768  0 0.232 0.000
#> SRR1424698     3  0.0000      0.808 0.000  0 1.000 0.000
#> SRR1424699     4  0.0000      0.946 0.000  0 0.000 1.000
#> SRR1424700     4  0.0000      0.946 0.000  0 0.000 1.000
#> SRR1424701     1  0.3356      0.755 0.824  0 0.000 0.176
#> SRR1424702     3  0.0000      0.808 0.000  0 1.000 0.000
#> SRR1424703     1  0.3907      0.662 0.768  0 0.232 0.000
#> SRR1424704     3  0.0000      0.808 0.000  0 1.000 0.000
#> SRR1424706     1  0.3907      0.662 0.768  0 0.232 0.000
#> SRR1424707     1  0.3907      0.662 0.768  0 0.232 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
#> SRR1424656     1  0.0162      0.857 0.996  0 0.000 0.004 0.000
#> SRR1424657     1  0.0162      0.857 0.996  0 0.000 0.004 0.000
#> SRR1424658     4  0.0000      0.939 0.000  0 0.000 1.000 0.000
#> SRR1424659     1  0.0000      0.857 1.000  0 0.000 0.000 0.000
#> SRR1424660     1  0.2605      0.763 0.852  0 0.000 0.148 0.000
#> SRR1424661     1  0.0451      0.855 0.988  0 0.004 0.000 0.008
#> SRR1424662     4  0.0000      0.939 0.000  0 0.000 1.000 0.000
#> SRR1424663     1  0.0162      0.856 0.996  0 0.004 0.000 0.000
#> SRR1424664     1  0.0000      0.857 1.000  0 0.000 0.000 0.000
#> SRR1424665     1  0.3480      0.660 0.752  0 0.000 0.248 0.000
#> SRR1424666     3  0.2929      0.868 0.180  0 0.820 0.000 0.000
#> SRR1424667     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> SRR1424668     3  0.2929      0.868 0.180  0 0.820 0.000 0.000
#> SRR1424669     1  0.3210      0.710 0.788  0 0.000 0.212 0.000
#> SRR1424670     1  0.0404      0.855 0.988  0 0.000 0.012 0.000
#> SRR1424671     5  0.0162      0.000 0.004  0 0.000 0.000 0.996
#> SRR1424672     3  0.2929      0.868 0.180  0 0.820 0.000 0.000
#> SRR1424674     1  0.0162      0.857 0.996  0 0.000 0.004 0.000
#> SRR1424673     1  0.3395      0.658 0.764  0 0.236 0.000 0.000
#> SRR1424675     4  0.0000      0.939 0.000  0 0.000 1.000 0.000
#> SRR1424676     4  0.0000      0.939 0.000  0 0.000 1.000 0.000
#> SRR1424677     4  0.0865      0.913 0.024  0 0.000 0.972 0.004
#> SRR1424678     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> SRR1424679     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> SRR1424680     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> SRR1424681     1  0.0162      0.856 0.996  0 0.004 0.000 0.000
#> SRR1424682     3  0.3086      0.867 0.180  0 0.816 0.000 0.004
#> SRR1424683     4  0.0290      0.936 0.000  0 0.000 0.992 0.008
#> SRR1424685     1  0.0162      0.856 0.996  0 0.004 0.000 0.000
#> SRR1424686     3  0.2929      0.868 0.180  0 0.820 0.000 0.000
#> SRR1424687     4  0.4341      0.179 0.404  0 0.000 0.592 0.004
#> SRR1424688     4  0.0000      0.939 0.000  0 0.000 1.000 0.000
#> SRR1424689     1  0.3177      0.714 0.792  0 0.000 0.208 0.000
#> SRR1424690     1  0.0162      0.857 0.996  0 0.000 0.004 0.000
#> SRR1424691     1  0.0000      0.857 1.000  0 0.000 0.000 0.000
#> SRR1424692     4  0.0290      0.936 0.000  0 0.000 0.992 0.008
#> SRR1424684     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> SRR1424693     1  0.3074      0.706 0.804  0 0.000 0.196 0.000
#> SRR1424694     4  0.0290      0.936 0.000  0 0.000 0.992 0.008
#> SRR1424695     4  0.0404      0.928 0.012  0 0.000 0.988 0.000
#> SRR1424696     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> SRR1424697     1  0.3395      0.658 0.764  0 0.236 0.000 0.000
#> SRR1424698     3  0.0162      0.759 0.000  0 0.996 0.000 0.004
#> SRR1424699     4  0.0000      0.939 0.000  0 0.000 1.000 0.000
#> SRR1424700     4  0.0000      0.939 0.000  0 0.000 1.000 0.000
#> SRR1424701     1  0.2891      0.741 0.824  0 0.000 0.176 0.000
#> SRR1424702     3  0.0162      0.759 0.000  0 0.996 0.000 0.004
#> SRR1424703     1  0.3395      0.658 0.764  0 0.236 0.000 0.000
#> SRR1424704     3  0.0162      0.759 0.000  0 0.996 0.000 0.004
#> SRR1424706     1  0.3395      0.658 0.764  0 0.236 0.000 0.000
#> SRR1424707     1  0.3395      0.658 0.764  0 0.236 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1 p2    p3    p4    p5    p6
#> SRR1424656     1  0.2969      0.695 0.776  0 0.000 0.000 0.000 0.224
#> SRR1424657     1  0.2969      0.695 0.776  0 0.000 0.000 0.000 0.224
#> SRR1424658     4  0.2219      0.834 0.000  0 0.000 0.864 0.000 0.136
#> SRR1424659     1  0.2631      0.713 0.820  0 0.000 0.000 0.000 0.180
#> SRR1424660     6  0.2854      0.775 0.208  0 0.000 0.000 0.000 0.792
#> SRR1424661     1  0.0260      0.742 0.992  0 0.000 0.000 0.008 0.000
#> SRR1424662     4  0.0713      0.858 0.000  0 0.000 0.972 0.000 0.028
#> SRR1424663     1  0.0000      0.744 1.000  0 0.000 0.000 0.000 0.000
#> SRR1424664     1  0.2631      0.713 0.820  0 0.000 0.000 0.000 0.180
#> SRR1424665     6  0.2740      0.802 0.060  0 0.000 0.076 0.000 0.864
#> SRR1424666     3  0.2664      0.862 0.184  0 0.816 0.000 0.000 0.000
#> SRR1424667     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> SRR1424668     3  0.2664      0.862 0.184  0 0.816 0.000 0.000 0.000
#> SRR1424669     6  0.1049      0.828 0.032  0 0.000 0.008 0.000 0.960
#> SRR1424670     1  0.3023      0.689 0.768  0 0.000 0.000 0.000 0.232
#> SRR1424671     5  0.0000      0.000 0.000  0 0.000 0.000 1.000 0.000
#> SRR1424672     3  0.2664      0.862 0.184  0 0.816 0.000 0.000 0.000
#> SRR1424674     1  0.2969      0.695 0.776  0 0.000 0.000 0.000 0.224
#> SRR1424673     1  0.3023      0.589 0.768  0 0.232 0.000 0.000 0.000
#> SRR1424675     4  0.2491      0.825 0.000  0 0.000 0.836 0.000 0.164
#> SRR1424676     4  0.0713      0.857 0.000  0 0.000 0.972 0.000 0.028
#> SRR1424677     4  0.1806      0.835 0.000  0 0.000 0.908 0.004 0.088
#> SRR1424678     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> SRR1424679     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> SRR1424680     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> SRR1424681     1  0.0000      0.744 1.000  0 0.000 0.000 0.000 0.000
#> SRR1424682     3  0.2631      0.861 0.180  0 0.820 0.000 0.000 0.000
#> SRR1424683     4  0.0972      0.857 0.000  0 0.000 0.964 0.008 0.028
#> SRR1424685     1  0.0000      0.744 1.000  0 0.000 0.000 0.000 0.000
#> SRR1424686     3  0.2664      0.862 0.184  0 0.816 0.000 0.000 0.000
#> SRR1424687     4  0.5599      0.177 0.152  0 0.000 0.540 0.004 0.304
#> SRR1424688     4  0.0146      0.856 0.000  0 0.000 0.996 0.000 0.004
#> SRR1424689     6  0.1010      0.831 0.036  0 0.000 0.004 0.000 0.960
#> SRR1424690     1  0.2996      0.671 0.772  0 0.000 0.000 0.000 0.228
#> SRR1424691     1  0.2664      0.711 0.816  0 0.000 0.000 0.000 0.184
#> SRR1424692     4  0.0972      0.857 0.000  0 0.000 0.964 0.008 0.028
#> SRR1424684     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> SRR1424693     1  0.5408      0.305 0.552  0 0.000 0.144 0.000 0.304
#> SRR1424694     4  0.0972      0.857 0.000  0 0.000 0.964 0.008 0.028
#> SRR1424695     4  0.2300      0.833 0.000  0 0.000 0.856 0.000 0.144
#> SRR1424696     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> SRR1424697     1  0.3023      0.589 0.768  0 0.232 0.000 0.000 0.000
#> SRR1424698     3  0.0458      0.746 0.000  0 0.984 0.000 0.000 0.016
#> SRR1424699     4  0.2491      0.825 0.000  0 0.000 0.836 0.000 0.164
#> SRR1424700     4  0.2491      0.825 0.000  0 0.000 0.836 0.000 0.164
#> SRR1424701     6  0.2597      0.805 0.176  0 0.000 0.000 0.000 0.824
#> SRR1424702     3  0.0458      0.746 0.000  0 0.984 0.000 0.000 0.016
#> SRR1424703     1  0.3023      0.589 0.768  0 0.232 0.000 0.000 0.000
#> SRR1424704     3  0.0458      0.746 0.000  0 0.984 0.000 0.000 0.016
#> SRR1424706     1  0.3023      0.589 0.768  0 0.232 0.000 0.000 0.000
#> SRR1424707     1  0.3023      0.589 0.768  0 0.232 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-hclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-hclust-collect-classes

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


ATC:kmeans**

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

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

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

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 16960 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.995       0.998         0.4677 0.534   0.534
#> 3 3 0.691           0.811       0.916         0.3468 0.619   0.404
#> 4 4 0.665           0.801       0.883         0.1522 0.747   0.428
#> 5 5 0.724           0.627       0.810         0.0787 0.976   0.910
#> 6 6 0.729           0.611       0.776         0.0449 0.951   0.809

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

suggest_best_k(res)
#> [1] 2

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette    p1    p2
#> SRR1424656     1   0.000      0.996 1.000 0.000
#> SRR1424657     1   0.000      0.996 1.000 0.000
#> SRR1424658     2   0.000      1.000 0.000 1.000
#> SRR1424659     1   0.000      0.996 1.000 0.000
#> SRR1424660     1   0.000      0.996 1.000 0.000
#> SRR1424661     1   0.000      0.996 1.000 0.000
#> SRR1424662     2   0.000      1.000 0.000 1.000
#> SRR1424663     1   0.000      0.996 1.000 0.000
#> SRR1424664     1   0.000      0.996 1.000 0.000
#> SRR1424665     1   0.000      0.996 1.000 0.000
#> SRR1424666     1   0.000      0.996 1.000 0.000
#> SRR1424667     2   0.000      1.000 0.000 1.000
#> SRR1424668     1   0.000      0.996 1.000 0.000
#> SRR1424669     1   0.000      0.996 1.000 0.000
#> SRR1424670     1   0.000      0.996 1.000 0.000
#> SRR1424671     1   0.000      0.996 1.000 0.000
#> SRR1424672     1   0.000      0.996 1.000 0.000
#> SRR1424674     1   0.000      0.996 1.000 0.000
#> SRR1424673     1   0.000      0.996 1.000 0.000
#> SRR1424675     2   0.000      1.000 0.000 1.000
#> SRR1424676     2   0.000      1.000 0.000 1.000
#> SRR1424677     2   0.000      1.000 0.000 1.000
#> SRR1424678     2   0.000      1.000 0.000 1.000
#> SRR1424679     2   0.000      1.000 0.000 1.000
#> SRR1424680     2   0.000      1.000 0.000 1.000
#> SRR1424681     1   0.000      0.996 1.000 0.000
#> SRR1424682     1   0.000      0.996 1.000 0.000
#> SRR1424683     2   0.000      1.000 0.000 1.000
#> SRR1424685     1   0.000      0.996 1.000 0.000
#> SRR1424686     1   0.000      0.996 1.000 0.000
#> SRR1424687     1   0.000      0.996 1.000 0.000
#> SRR1424688     2   0.000      1.000 0.000 1.000
#> SRR1424689     1   0.518      0.869 0.884 0.116
#> SRR1424690     1   0.000      0.996 1.000 0.000
#> SRR1424691     1   0.000      0.996 1.000 0.000
#> SRR1424692     2   0.000      1.000 0.000 1.000
#> SRR1424684     2   0.000      1.000 0.000 1.000
#> SRR1424693     1   0.000      0.996 1.000 0.000
#> SRR1424694     2   0.000      1.000 0.000 1.000
#> SRR1424695     2   0.000      1.000 0.000 1.000
#> SRR1424696     2   0.000      1.000 0.000 1.000
#> SRR1424697     1   0.000      0.996 1.000 0.000
#> SRR1424698     1   0.000      0.996 1.000 0.000
#> SRR1424699     2   0.000      1.000 0.000 1.000
#> SRR1424700     2   0.000      1.000 0.000 1.000
#> SRR1424701     1   0.000      0.996 1.000 0.000
#> SRR1424702     1   0.000      0.996 1.000 0.000
#> SRR1424703     1   0.000      0.996 1.000 0.000
#> SRR1424704     1   0.000      0.996 1.000 0.000
#> SRR1424706     1   0.000      0.996 1.000 0.000
#> SRR1424707     1   0.000      0.996 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
#> SRR1424656     1  0.0424      0.885 0.992 0.000 0.008
#> SRR1424657     1  0.0424      0.885 0.992 0.000 0.008
#> SRR1424658     1  0.5733      0.476 0.676 0.324 0.000
#> SRR1424659     3  0.5529      0.651 0.296 0.000 0.704
#> SRR1424660     3  0.6095      0.450 0.392 0.000 0.608
#> SRR1424661     1  0.2959      0.812 0.900 0.000 0.100
#> SRR1424662     1  0.4291      0.744 0.820 0.180 0.000
#> SRR1424663     3  0.5529      0.651 0.296 0.000 0.704
#> SRR1424664     1  0.3816      0.762 0.852 0.000 0.148
#> SRR1424665     1  0.0000      0.886 1.000 0.000 0.000
#> SRR1424666     3  0.0000      0.902 0.000 0.000 1.000
#> SRR1424667     2  0.0000      0.891 0.000 1.000 0.000
#> SRR1424668     3  0.0000      0.902 0.000 0.000 1.000
#> SRR1424669     1  0.0000      0.886 1.000 0.000 0.000
#> SRR1424670     1  0.0424      0.885 0.992 0.000 0.008
#> SRR1424671     1  0.0000      0.886 1.000 0.000 0.000
#> SRR1424672     3  0.0000      0.902 0.000 0.000 1.000
#> SRR1424674     1  0.0424      0.885 0.992 0.000 0.008
#> SRR1424673     3  0.1860      0.885 0.052 0.000 0.948
#> SRR1424675     2  0.4002      0.792 0.160 0.840 0.000
#> SRR1424676     1  0.4062      0.763 0.836 0.164 0.000
#> SRR1424677     1  0.0000      0.886 1.000 0.000 0.000
#> SRR1424678     2  0.0000      0.891 0.000 1.000 0.000
#> SRR1424679     2  0.0000      0.891 0.000 1.000 0.000
#> SRR1424680     2  0.0000      0.891 0.000 1.000 0.000
#> SRR1424681     3  0.1860      0.883 0.052 0.000 0.948
#> SRR1424682     3  0.0000      0.902 0.000 0.000 1.000
#> SRR1424683     1  0.2066      0.862 0.940 0.060 0.000
#> SRR1424685     1  0.5431      0.545 0.716 0.000 0.284
#> SRR1424686     3  0.0000      0.902 0.000 0.000 1.000
#> SRR1424687     1  0.0000      0.886 1.000 0.000 0.000
#> SRR1424688     1  0.2066      0.862 0.940 0.060 0.000
#> SRR1424689     1  0.0000      0.886 1.000 0.000 0.000
#> SRR1424690     1  0.0000      0.886 1.000 0.000 0.000
#> SRR1424691     3  0.4796      0.752 0.220 0.000 0.780
#> SRR1424692     1  0.4291      0.744 0.820 0.180 0.000
#> SRR1424684     2  0.0000      0.891 0.000 1.000 0.000
#> SRR1424693     1  0.0000      0.886 1.000 0.000 0.000
#> SRR1424694     1  0.2066      0.862 0.940 0.060 0.000
#> SRR1424695     1  0.2066      0.862 0.940 0.060 0.000
#> SRR1424696     2  0.0000      0.891 0.000 1.000 0.000
#> SRR1424697     3  0.0000      0.902 0.000 0.000 1.000
#> SRR1424698     3  0.0424      0.898 0.008 0.000 0.992
#> SRR1424699     2  0.4887      0.715 0.228 0.772 0.000
#> SRR1424700     2  0.6079      0.394 0.388 0.612 0.000
#> SRR1424701     1  0.6204      0.150 0.576 0.000 0.424
#> SRR1424702     3  0.0000      0.902 0.000 0.000 1.000
#> SRR1424703     3  0.0424      0.898 0.008 0.000 0.992
#> SRR1424704     3  0.0000      0.902 0.000 0.000 1.000
#> SRR1424706     3  0.2796      0.862 0.092 0.000 0.908
#> SRR1424707     3  0.0000      0.902 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
#> SRR1424656     1  0.0592     0.8174 0.984 0.000 0.000 0.016
#> SRR1424657     1  0.1302     0.8125 0.956 0.000 0.000 0.044
#> SRR1424658     4  0.3245     0.8374 0.100 0.028 0.000 0.872
#> SRR1424659     1  0.3356     0.7631 0.824 0.000 0.176 0.000
#> SRR1424660     1  0.3219     0.7691 0.836 0.000 0.164 0.000
#> SRR1424661     1  0.1940     0.7968 0.924 0.000 0.000 0.076
#> SRR1424662     4  0.3791     0.8348 0.200 0.004 0.000 0.796
#> SRR1424663     1  0.3400     0.7599 0.820 0.000 0.180 0.000
#> SRR1424664     1  0.0469     0.8201 0.988 0.000 0.012 0.000
#> SRR1424665     1  0.4431     0.5660 0.696 0.000 0.000 0.304
#> SRR1424666     3  0.0000     0.9197 0.000 0.000 1.000 0.000
#> SRR1424667     2  0.0188     1.0000 0.000 0.996 0.000 0.004
#> SRR1424668     3  0.0000     0.9197 0.000 0.000 1.000 0.000
#> SRR1424669     1  0.4040     0.6932 0.752 0.000 0.000 0.248
#> SRR1424670     1  0.0592     0.8174 0.984 0.000 0.000 0.016
#> SRR1424671     1  0.4991     0.4149 0.608 0.004 0.000 0.388
#> SRR1424672     3  0.0000     0.9197 0.000 0.000 1.000 0.000
#> SRR1424674     1  0.1302     0.8125 0.956 0.000 0.000 0.044
#> SRR1424673     3  0.4655     0.6635 0.208 0.000 0.760 0.032
#> SRR1424675     4  0.3074     0.7435 0.000 0.152 0.000 0.848
#> SRR1424676     4  0.2300     0.8237 0.064 0.016 0.000 0.920
#> SRR1424677     4  0.2704     0.8403 0.124 0.000 0.000 0.876
#> SRR1424678     2  0.0188     1.0000 0.000 0.996 0.000 0.004
#> SRR1424679     2  0.0188     1.0000 0.000 0.996 0.000 0.004
#> SRR1424680     2  0.0188     1.0000 0.000 0.996 0.000 0.004
#> SRR1424681     1  0.4008     0.6823 0.756 0.000 0.244 0.000
#> SRR1424682     3  0.0000     0.9197 0.000 0.000 1.000 0.000
#> SRR1424683     4  0.3907     0.8022 0.232 0.000 0.000 0.768
#> SRR1424685     1  0.2011     0.8100 0.920 0.000 0.080 0.000
#> SRR1424686     3  0.0000     0.9197 0.000 0.000 1.000 0.000
#> SRR1424687     1  0.2081     0.7840 0.916 0.000 0.000 0.084
#> SRR1424688     4  0.3907     0.8022 0.232 0.000 0.000 0.768
#> SRR1424689     4  0.4277     0.5897 0.280 0.000 0.000 0.720
#> SRR1424690     1  0.0336     0.8185 0.992 0.000 0.000 0.008
#> SRR1424691     1  0.3444     0.7556 0.816 0.000 0.184 0.000
#> SRR1424692     4  0.3498     0.8349 0.160 0.008 0.000 0.832
#> SRR1424684     2  0.0188     1.0000 0.000 0.996 0.000 0.004
#> SRR1424693     1  0.3311     0.6883 0.828 0.000 0.000 0.172
#> SRR1424694     4  0.3907     0.8022 0.232 0.000 0.000 0.768
#> SRR1424695     4  0.3172     0.8379 0.160 0.000 0.000 0.840
#> SRR1424696     2  0.0188     1.0000 0.000 0.996 0.000 0.004
#> SRR1424697     3  0.0469     0.9153 0.000 0.000 0.988 0.012
#> SRR1424698     3  0.1151     0.9035 0.008 0.000 0.968 0.024
#> SRR1424699     4  0.3074     0.7435 0.000 0.152 0.000 0.848
#> SRR1424700     4  0.3447     0.7604 0.020 0.128 0.000 0.852
#> SRR1424701     1  0.5510     0.5309 0.600 0.000 0.024 0.376
#> SRR1424702     3  0.0000     0.9197 0.000 0.000 1.000 0.000
#> SRR1424703     3  0.1256     0.9015 0.008 0.000 0.964 0.028
#> SRR1424704     3  0.0000     0.9197 0.000 0.000 1.000 0.000
#> SRR1424706     3  0.5853    -0.0544 0.460 0.000 0.508 0.032
#> SRR1424707     3  0.0000     0.9197 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
#> SRR1424656     1  0.0992      0.789 0.968 0.000 0.000 0.008 0.024
#> SRR1424657     1  0.1281      0.787 0.956 0.000 0.000 0.012 0.032
#> SRR1424658     5  0.2278      0.536 0.032 0.000 0.000 0.060 0.908
#> SRR1424659     1  0.1331      0.781 0.952 0.000 0.040 0.008 0.000
#> SRR1424660     1  0.1251      0.783 0.956 0.000 0.036 0.008 0.000
#> SRR1424661     1  0.4341      0.468 0.628 0.000 0.000 0.364 0.008
#> SRR1424662     5  0.4666      0.399 0.040 0.000 0.000 0.284 0.676
#> SRR1424663     1  0.3546      0.734 0.832 0.000 0.048 0.116 0.004
#> SRR1424664     1  0.0609      0.790 0.980 0.000 0.000 0.000 0.020
#> SRR1424665     1  0.5849      0.254 0.508 0.000 0.000 0.100 0.392
#> SRR1424666     3  0.0865      0.852 0.024 0.000 0.972 0.004 0.000
#> SRR1424667     2  0.0000      0.993 0.000 1.000 0.000 0.000 0.000
#> SRR1424668     3  0.0609      0.852 0.020 0.000 0.980 0.000 0.000
#> SRR1424669     1  0.5082      0.575 0.664 0.000 0.000 0.076 0.260
#> SRR1424670     1  0.1981      0.782 0.924 0.000 0.000 0.048 0.028
#> SRR1424671     4  0.2491      0.292 0.068 0.000 0.000 0.896 0.036
#> SRR1424672     3  0.0703      0.852 0.024 0.000 0.976 0.000 0.000
#> SRR1424674     1  0.2067      0.781 0.920 0.000 0.000 0.048 0.032
#> SRR1424673     3  0.6057      0.554 0.116 0.000 0.564 0.312 0.008
#> SRR1424675     5  0.1792      0.499 0.000 0.084 0.000 0.000 0.916
#> SRR1424676     5  0.2660      0.535 0.008 0.000 0.000 0.128 0.864
#> SRR1424677     4  0.4504     -0.261 0.008 0.000 0.000 0.564 0.428
#> SRR1424678     2  0.0000      0.993 0.000 1.000 0.000 0.000 0.000
#> SRR1424679     2  0.0000      0.993 0.000 1.000 0.000 0.000 0.000
#> SRR1424680     2  0.0566      0.986 0.000 0.984 0.000 0.004 0.012
#> SRR1424681     1  0.4117      0.701 0.788 0.000 0.096 0.116 0.000
#> SRR1424682     3  0.0510      0.849 0.000 0.000 0.984 0.016 0.000
#> SRR1424683     5  0.5289      0.116 0.048 0.000 0.000 0.452 0.500
#> SRR1424685     1  0.3273      0.743 0.848 0.000 0.036 0.112 0.004
#> SRR1424686     3  0.0703      0.852 0.024 0.000 0.976 0.000 0.000
#> SRR1424687     1  0.3615      0.716 0.808 0.000 0.000 0.156 0.036
#> SRR1424688     5  0.5289      0.123 0.048 0.000 0.000 0.452 0.500
#> SRR1424689     5  0.4906      0.190 0.232 0.000 0.000 0.076 0.692
#> SRR1424690     1  0.1568      0.786 0.944 0.000 0.000 0.036 0.020
#> SRR1424691     1  0.3409      0.734 0.836 0.000 0.052 0.112 0.000
#> SRR1424692     5  0.4979      0.070 0.028 0.000 0.000 0.480 0.492
#> SRR1424684     2  0.0000      0.993 0.000 1.000 0.000 0.000 0.000
#> SRR1424693     1  0.4263      0.656 0.760 0.000 0.000 0.180 0.060
#> SRR1424694     5  0.5291      0.115 0.048 0.000 0.000 0.456 0.496
#> SRR1424695     5  0.3489      0.525 0.036 0.000 0.000 0.144 0.820
#> SRR1424696     2  0.0566      0.986 0.000 0.984 0.000 0.004 0.012
#> SRR1424697     3  0.4441      0.719 0.024 0.000 0.716 0.252 0.008
#> SRR1424698     3  0.2707      0.804 0.000 0.000 0.860 0.132 0.008
#> SRR1424699     5  0.1892      0.500 0.004 0.080 0.000 0.000 0.916
#> SRR1424700     5  0.1830      0.503 0.008 0.068 0.000 0.000 0.924
#> SRR1424701     1  0.6963      0.111 0.400 0.000 0.012 0.220 0.368
#> SRR1424702     3  0.0510      0.849 0.000 0.000 0.984 0.016 0.000
#> SRR1424703     3  0.3700      0.740 0.000 0.000 0.752 0.240 0.008
#> SRR1424704     3  0.0510      0.849 0.000 0.000 0.984 0.016 0.000
#> SRR1424706     3  0.6879      0.309 0.228 0.000 0.420 0.344 0.008
#> SRR1424707     3  0.0693      0.853 0.012 0.000 0.980 0.008 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
#> SRR1424656     1  0.0653     0.7410 0.980 0.000 0.000 0.004 0.004 0.012
#> SRR1424657     1  0.1672     0.7345 0.932 0.000 0.000 0.048 0.004 0.016
#> SRR1424658     4  0.4466     0.1556 0.016 0.000 0.000 0.536 0.440 0.008
#> SRR1424659     1  0.2345     0.7267 0.904 0.000 0.040 0.000 0.028 0.028
#> SRR1424660     1  0.3947     0.7198 0.800 0.000 0.036 0.000 0.072 0.092
#> SRR1424661     1  0.7360     0.2386 0.500 0.000 0.120 0.112 0.044 0.224
#> SRR1424662     4  0.3066     0.6983 0.016 0.000 0.000 0.836 0.132 0.016
#> SRR1424663     1  0.4521     0.6387 0.748 0.000 0.128 0.000 0.032 0.092
#> SRR1424664     1  0.0291     0.7422 0.992 0.000 0.004 0.000 0.004 0.000
#> SRR1424665     1  0.6345     0.2763 0.556 0.000 0.000 0.136 0.228 0.080
#> SRR1424666     3  0.3823     0.7347 0.000 0.000 0.564 0.000 0.000 0.436
#> SRR1424667     2  0.0000     0.9877 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1424668     3  0.3847     0.7360 0.000 0.000 0.544 0.000 0.000 0.456
#> SRR1424669     1  0.5516     0.4235 0.588 0.000 0.008 0.008 0.288 0.108
#> SRR1424670     1  0.2277     0.7323 0.908 0.000 0.000 0.032 0.032 0.028
#> SRR1424671     6  0.7703     0.0000 0.008 0.000 0.272 0.208 0.160 0.352
#> SRR1424672     3  0.3843     0.7365 0.000 0.000 0.548 0.000 0.000 0.452
#> SRR1424674     1  0.2459     0.7266 0.896 0.000 0.000 0.052 0.020 0.032
#> SRR1424673     3  0.3374     0.1631 0.044 0.000 0.824 0.000 0.012 0.120
#> SRR1424675     5  0.3978     0.5020 0.000 0.032 0.000 0.268 0.700 0.000
#> SRR1424676     4  0.3867     0.5225 0.004 0.000 0.000 0.688 0.296 0.012
#> SRR1424677     4  0.4496     0.4825 0.000 0.000 0.000 0.708 0.136 0.156
#> SRR1424678     2  0.0405     0.9862 0.000 0.988 0.000 0.000 0.008 0.004
#> SRR1424679     2  0.0000     0.9877 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1424680     2  0.0862     0.9807 0.000 0.972 0.000 0.008 0.016 0.004
#> SRR1424681     1  0.6038     0.5020 0.588 0.000 0.196 0.000 0.052 0.164
#> SRR1424682     3  0.4328     0.7262 0.000 0.000 0.520 0.000 0.020 0.460
#> SRR1424683     4  0.1218     0.7375 0.012 0.000 0.000 0.956 0.004 0.028
#> SRR1424685     1  0.5062     0.6337 0.708 0.000 0.124 0.000 0.052 0.116
#> SRR1424686     3  0.3833     0.7366 0.000 0.000 0.556 0.000 0.000 0.444
#> SRR1424687     1  0.5499     0.6115 0.672 0.000 0.000 0.144 0.092 0.092
#> SRR1424688     4  0.0653     0.7443 0.012 0.000 0.000 0.980 0.004 0.004
#> SRR1424689     5  0.5915     0.3971 0.240 0.000 0.000 0.092 0.596 0.072
#> SRR1424690     1  0.2197     0.7292 0.900 0.000 0.000 0.000 0.044 0.056
#> SRR1424691     1  0.4915     0.6299 0.716 0.000 0.144 0.000 0.044 0.096
#> SRR1424692     4  0.1858     0.6910 0.000 0.000 0.000 0.912 0.012 0.076
#> SRR1424684     2  0.0000     0.9877 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1424693     1  0.5307     0.6050 0.684 0.000 0.000 0.160 0.080 0.076
#> SRR1424694     4  0.1296     0.7375 0.012 0.000 0.000 0.952 0.004 0.032
#> SRR1424695     4  0.3542     0.6672 0.020 0.000 0.000 0.796 0.164 0.020
#> SRR1424696     2  0.0862     0.9807 0.000 0.972 0.000 0.008 0.016 0.004
#> SRR1424697     3  0.1434     0.3779 0.012 0.000 0.940 0.000 0.000 0.048
#> SRR1424698     3  0.4040     0.6516 0.000 0.000 0.688 0.000 0.032 0.280
#> SRR1424699     5  0.3956     0.5090 0.000 0.032 0.000 0.264 0.704 0.000
#> SRR1424700     5  0.3956     0.5090 0.000 0.032 0.000 0.264 0.704 0.000
#> SRR1424701     5  0.7124     0.0619 0.296 0.000 0.224 0.000 0.392 0.088
#> SRR1424702     3  0.4325     0.7272 0.000 0.000 0.524 0.000 0.020 0.456
#> SRR1424703     3  0.0291     0.4525 0.004 0.000 0.992 0.000 0.000 0.004
#> SRR1424704     3  0.4328     0.7262 0.000 0.000 0.520 0.000 0.020 0.460
#> SRR1424706     3  0.4703    -0.0927 0.072 0.000 0.724 0.000 0.036 0.168
#> SRR1424707     3  0.3592     0.7244 0.000 0.000 0.656 0.000 0.000 0.344

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-kmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-kmeans-collect-classes

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


ATC:skmeans*

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

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

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

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

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

collect_plots(res)

plot of chunk ATC-skmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.918           0.932       0.973         0.5050 0.492   0.492
#> 3 3 0.853           0.814       0.924         0.2870 0.845   0.691
#> 4 4 0.723           0.651       0.843         0.1113 0.933   0.814
#> 5 5 0.698           0.637       0.807         0.0586 0.924   0.751
#> 6 6 0.705           0.533       0.756         0.0424 0.953   0.810

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
#> SRR1424656     1   0.000      0.994 1.000 0.000
#> SRR1424657     1   0.000      0.994 1.000 0.000
#> SRR1424658     2   0.000      0.944 0.000 1.000
#> SRR1424659     1   0.000      0.994 1.000 0.000
#> SRR1424660     1   0.000      0.994 1.000 0.000
#> SRR1424661     1   0.000      0.994 1.000 0.000
#> SRR1424662     2   0.000      0.944 0.000 1.000
#> SRR1424663     1   0.000      0.994 1.000 0.000
#> SRR1424664     1   0.000      0.994 1.000 0.000
#> SRR1424665     2   0.992      0.197 0.448 0.552
#> SRR1424666     1   0.000      0.994 1.000 0.000
#> SRR1424667     2   0.000      0.944 0.000 1.000
#> SRR1424668     1   0.000      0.994 1.000 0.000
#> SRR1424669     2   0.584      0.817 0.140 0.860
#> SRR1424670     2   0.995      0.206 0.460 0.540
#> SRR1424671     1   0.595      0.818 0.856 0.144
#> SRR1424672     1   0.000      0.994 1.000 0.000
#> SRR1424674     1   0.000      0.994 1.000 0.000
#> SRR1424673     1   0.000      0.994 1.000 0.000
#> SRR1424675     2   0.000      0.944 0.000 1.000
#> SRR1424676     2   0.000      0.944 0.000 1.000
#> SRR1424677     2   0.000      0.944 0.000 1.000
#> SRR1424678     2   0.000      0.944 0.000 1.000
#> SRR1424679     2   0.000      0.944 0.000 1.000
#> SRR1424680     2   0.000      0.944 0.000 1.000
#> SRR1424681     1   0.000      0.994 1.000 0.000
#> SRR1424682     1   0.000      0.994 1.000 0.000
#> SRR1424683     2   0.000      0.944 0.000 1.000
#> SRR1424685     1   0.000      0.994 1.000 0.000
#> SRR1424686     1   0.000      0.994 1.000 0.000
#> SRR1424687     2   0.722      0.746 0.200 0.800
#> SRR1424688     2   0.000      0.944 0.000 1.000
#> SRR1424689     2   0.000      0.944 0.000 1.000
#> SRR1424690     1   0.000      0.994 1.000 0.000
#> SRR1424691     1   0.000      0.994 1.000 0.000
#> SRR1424692     2   0.000      0.944 0.000 1.000
#> SRR1424684     2   0.000      0.944 0.000 1.000
#> SRR1424693     2   0.000      0.944 0.000 1.000
#> SRR1424694     2   0.000      0.944 0.000 1.000
#> SRR1424695     2   0.000      0.944 0.000 1.000
#> SRR1424696     2   0.000      0.944 0.000 1.000
#> SRR1424697     1   0.000      0.994 1.000 0.000
#> SRR1424698     1   0.000      0.994 1.000 0.000
#> SRR1424699     2   0.000      0.944 0.000 1.000
#> SRR1424700     2   0.000      0.944 0.000 1.000
#> SRR1424701     1   0.000      0.994 1.000 0.000
#> SRR1424702     1   0.000      0.994 1.000 0.000
#> SRR1424703     1   0.000      0.994 1.000 0.000
#> SRR1424704     1   0.000      0.994 1.000 0.000
#> SRR1424706     1   0.000      0.994 1.000 0.000
#> SRR1424707     1   0.000      0.994 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1424656     1   0.000      0.842 1.000 0.000 0.000
#> SRR1424657     1   0.000      0.842 1.000 0.000 0.000
#> SRR1424658     2   0.000      0.921 0.000 1.000 0.000
#> SRR1424659     1   0.254      0.823 0.920 0.000 0.080
#> SRR1424660     3   0.000      0.919 0.000 0.000 1.000
#> SRR1424661     3   0.630      0.140 0.472 0.000 0.528
#> SRR1424662     2   0.000      0.921 0.000 1.000 0.000
#> SRR1424663     1   0.533      0.614 0.728 0.000 0.272
#> SRR1424664     1   0.254      0.823 0.920 0.000 0.080
#> SRR1424665     1   0.619      0.226 0.580 0.420 0.000
#> SRR1424666     3   0.000      0.919 0.000 0.000 1.000
#> SRR1424667     2   0.000      0.921 0.000 1.000 0.000
#> SRR1424668     3   0.000      0.919 0.000 0.000 1.000
#> SRR1424669     2   0.579      0.499 0.000 0.668 0.332
#> SRR1424670     1   0.000      0.842 1.000 0.000 0.000
#> SRR1424671     3   0.207      0.862 0.060 0.000 0.940
#> SRR1424672     3   0.000      0.919 0.000 0.000 1.000
#> SRR1424674     1   0.000      0.842 1.000 0.000 0.000
#> SRR1424673     3   0.000      0.919 0.000 0.000 1.000
#> SRR1424675     2   0.000      0.921 0.000 1.000 0.000
#> SRR1424676     2   0.000      0.921 0.000 1.000 0.000
#> SRR1424677     2   0.000      0.921 0.000 1.000 0.000
#> SRR1424678     2   0.000      0.921 0.000 1.000 0.000
#> SRR1424679     2   0.000      0.921 0.000 1.000 0.000
#> SRR1424680     2   0.000      0.921 0.000 1.000 0.000
#> SRR1424681     3   0.280      0.836 0.092 0.000 0.908
#> SRR1424682     3   0.000      0.919 0.000 0.000 1.000
#> SRR1424683     2   0.254      0.875 0.080 0.920 0.000
#> SRR1424685     3   0.583      0.450 0.340 0.000 0.660
#> SRR1424686     3   0.000      0.919 0.000 0.000 1.000
#> SRR1424687     2   0.619      0.333 0.420 0.580 0.000
#> SRR1424688     2   0.254      0.875 0.080 0.920 0.000
#> SRR1424689     2   0.000      0.921 0.000 1.000 0.000
#> SRR1424690     1   0.510      0.658 0.752 0.000 0.248
#> SRR1424691     3   0.583      0.450 0.340 0.000 0.660
#> SRR1424692     2   0.207      0.887 0.060 0.940 0.000
#> SRR1424684     2   0.000      0.921 0.000 1.000 0.000
#> SRR1424693     2   0.619      0.333 0.420 0.580 0.000
#> SRR1424694     2   0.254      0.875 0.080 0.920 0.000
#> SRR1424695     2   0.000      0.921 0.000 1.000 0.000
#> SRR1424696     2   0.000      0.921 0.000 1.000 0.000
#> SRR1424697     3   0.000      0.919 0.000 0.000 1.000
#> SRR1424698     3   0.000      0.919 0.000 0.000 1.000
#> SRR1424699     2   0.000      0.921 0.000 1.000 0.000
#> SRR1424700     2   0.000      0.921 0.000 1.000 0.000
#> SRR1424701     3   0.000      0.919 0.000 0.000 1.000
#> SRR1424702     3   0.000      0.919 0.000 0.000 1.000
#> SRR1424703     3   0.000      0.919 0.000 0.000 1.000
#> SRR1424704     3   0.000      0.919 0.000 0.000 1.000
#> SRR1424706     3   0.000      0.919 0.000 0.000 1.000
#> SRR1424707     3   0.000      0.919 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
#> SRR1424656     1  0.0000      0.827 1.000 0.000 0.000 0.000
#> SRR1424657     1  0.1389      0.815 0.952 0.000 0.000 0.048
#> SRR1424658     2  0.0707      0.731 0.000 0.980 0.000 0.020
#> SRR1424659     1  0.0188      0.827 0.996 0.000 0.004 0.000
#> SRR1424660     3  0.0707      0.883 0.020 0.000 0.980 0.000
#> SRR1424661     3  0.7687      0.161 0.224 0.000 0.428 0.348
#> SRR1424662     2  0.2081      0.689 0.000 0.916 0.000 0.084
#> SRR1424663     1  0.3569      0.671 0.804 0.000 0.196 0.000
#> SRR1424664     1  0.0000      0.827 1.000 0.000 0.000 0.000
#> SRR1424665     1  0.6617      0.329 0.600 0.280 0.000 0.120
#> SRR1424666     3  0.0000      0.891 0.000 0.000 1.000 0.000
#> SRR1424667     2  0.0000      0.737 0.000 1.000 0.000 0.000
#> SRR1424668     3  0.0336      0.889 0.008 0.000 0.992 0.000
#> SRR1424669     2  0.5288      0.231 0.000 0.520 0.008 0.472
#> SRR1424670     1  0.2760      0.775 0.872 0.000 0.000 0.128
#> SRR1424671     3  0.5070      0.391 0.004 0.000 0.580 0.416
#> SRR1424672     3  0.0336      0.889 0.008 0.000 0.992 0.000
#> SRR1424674     1  0.1557      0.811 0.944 0.000 0.000 0.056
#> SRR1424673     3  0.0000      0.891 0.000 0.000 1.000 0.000
#> SRR1424675     2  0.1474      0.712 0.000 0.948 0.000 0.052
#> SRR1424676     2  0.0000      0.737 0.000 1.000 0.000 0.000
#> SRR1424677     2  0.4866     -0.381 0.000 0.596 0.000 0.404
#> SRR1424678     2  0.0000      0.737 0.000 1.000 0.000 0.000
#> SRR1424679     2  0.0000      0.737 0.000 1.000 0.000 0.000
#> SRR1424680     2  0.1940      0.697 0.000 0.924 0.000 0.076
#> SRR1424681     3  0.2281      0.828 0.096 0.000 0.904 0.000
#> SRR1424682     3  0.0000      0.891 0.000 0.000 1.000 0.000
#> SRR1424683     4  0.4989      0.527 0.000 0.472 0.000 0.528
#> SRR1424685     3  0.4897      0.506 0.332 0.000 0.660 0.008
#> SRR1424686     3  0.0336      0.889 0.008 0.000 0.992 0.000
#> SRR1424687     4  0.4901      0.425 0.108 0.112 0.000 0.780
#> SRR1424688     2  0.4898     -0.343 0.000 0.584 0.000 0.416
#> SRR1424689     2  0.4955      0.280 0.000 0.556 0.000 0.444
#> SRR1424690     1  0.5070      0.648 0.748 0.000 0.192 0.060
#> SRR1424691     3  0.4543      0.532 0.324 0.000 0.676 0.000
#> SRR1424692     4  0.4989      0.527 0.000 0.472 0.000 0.528
#> SRR1424684     2  0.0188      0.736 0.000 0.996 0.000 0.004
#> SRR1424693     4  0.7717      0.127 0.304 0.252 0.000 0.444
#> SRR1424694     4  0.4989      0.527 0.000 0.472 0.000 0.528
#> SRR1424695     2  0.1940      0.697 0.000 0.924 0.000 0.076
#> SRR1424696     2  0.1940      0.697 0.000 0.924 0.000 0.076
#> SRR1424697     3  0.0000      0.891 0.000 0.000 1.000 0.000
#> SRR1424698     3  0.0000      0.891 0.000 0.000 1.000 0.000
#> SRR1424699     2  0.3172      0.626 0.000 0.840 0.000 0.160
#> SRR1424700     2  0.3356      0.610 0.000 0.824 0.000 0.176
#> SRR1424701     3  0.3311      0.750 0.000 0.000 0.828 0.172
#> SRR1424702     3  0.0000      0.891 0.000 0.000 1.000 0.000
#> SRR1424703     3  0.0000      0.891 0.000 0.000 1.000 0.000
#> SRR1424704     3  0.0000      0.891 0.000 0.000 1.000 0.000
#> SRR1424706     3  0.0000      0.891 0.000 0.000 1.000 0.000
#> SRR1424707     3  0.0000      0.891 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
#> SRR1424656     1  0.0162     0.7579 0.996 0.000 0.000 0.004 0.000
#> SRR1424657     1  0.2046     0.7386 0.916 0.000 0.000 0.068 0.016
#> SRR1424658     2  0.1668     0.8172 0.000 0.940 0.000 0.028 0.032
#> SRR1424659     1  0.0898     0.7578 0.972 0.000 0.000 0.008 0.020
#> SRR1424660     3  0.3361     0.8315 0.020 0.000 0.856 0.032 0.092
#> SRR1424661     4  0.6654     0.2386 0.100 0.000 0.204 0.608 0.088
#> SRR1424662     2  0.2068     0.7847 0.000 0.904 0.000 0.092 0.004
#> SRR1424663     1  0.5763     0.5481 0.680 0.000 0.184 0.040 0.096
#> SRR1424664     1  0.0510     0.7588 0.984 0.000 0.000 0.000 0.016
#> SRR1424665     1  0.5855     0.0601 0.536 0.108 0.000 0.000 0.356
#> SRR1424666     3  0.1800     0.8615 0.000 0.000 0.932 0.020 0.048
#> SRR1424667     2  0.0510     0.8235 0.000 0.984 0.000 0.000 0.016
#> SRR1424668     3  0.2304     0.8550 0.004 0.000 0.908 0.020 0.068
#> SRR1424669     5  0.4136     0.7816 0.000 0.188 0.000 0.048 0.764
#> SRR1424670     1  0.3912     0.6790 0.804 0.000 0.000 0.108 0.088
#> SRR1424671     4  0.4687     0.2907 0.000 0.000 0.288 0.672 0.040
#> SRR1424672     3  0.2632     0.8479 0.004 0.000 0.892 0.032 0.072
#> SRR1424674     1  0.2669     0.7302 0.876 0.000 0.000 0.104 0.020
#> SRR1424673     3  0.0566     0.8682 0.000 0.000 0.984 0.004 0.012
#> SRR1424675     2  0.1410     0.7902 0.000 0.940 0.000 0.000 0.060
#> SRR1424676     2  0.0510     0.8235 0.000 0.984 0.000 0.000 0.016
#> SRR1424677     4  0.4876     0.3791 0.000 0.396 0.000 0.576 0.028
#> SRR1424678     2  0.0510     0.8235 0.000 0.984 0.000 0.000 0.016
#> SRR1424679     2  0.0510     0.8235 0.000 0.984 0.000 0.000 0.016
#> SRR1424680     2  0.1732     0.7961 0.000 0.920 0.000 0.080 0.000
#> SRR1424681     3  0.4733     0.7660 0.056 0.000 0.772 0.044 0.128
#> SRR1424682     3  0.0000     0.8722 0.000 0.000 1.000 0.000 0.000
#> SRR1424683     4  0.4595     0.3843 0.004 0.400 0.000 0.588 0.008
#> SRR1424685     3  0.7464     0.4283 0.184 0.000 0.528 0.116 0.172
#> SRR1424686     3  0.2304     0.8550 0.004 0.000 0.908 0.020 0.068
#> SRR1424687     4  0.4888     0.1428 0.028 0.008 0.000 0.644 0.320
#> SRR1424688     2  0.4912     0.2911 0.012 0.644 0.000 0.320 0.024
#> SRR1424689     5  0.3884     0.7877 0.004 0.288 0.000 0.000 0.708
#> SRR1424690     1  0.7174     0.4322 0.544 0.000 0.216 0.076 0.164
#> SRR1424691     3  0.6322     0.5924 0.180 0.000 0.640 0.060 0.120
#> SRR1424692     4  0.4138     0.4072 0.000 0.384 0.000 0.616 0.000
#> SRR1424684     2  0.0162     0.8247 0.000 0.996 0.000 0.000 0.004
#> SRR1424693     4  0.8527    -0.0476 0.196 0.224 0.000 0.296 0.284
#> SRR1424694     4  0.4892     0.3936 0.012 0.392 0.000 0.584 0.012
#> SRR1424695     2  0.2351     0.7843 0.000 0.896 0.000 0.088 0.016
#> SRR1424696     2  0.1732     0.7961 0.000 0.920 0.000 0.080 0.000
#> SRR1424697     3  0.0162     0.8714 0.000 0.000 0.996 0.004 0.000
#> SRR1424698     3  0.0671     0.8668 0.000 0.000 0.980 0.004 0.016
#> SRR1424699     2  0.3949     0.2465 0.000 0.668 0.000 0.000 0.332
#> SRR1424700     2  0.4201    -0.0570 0.000 0.592 0.000 0.000 0.408
#> SRR1424701     3  0.4452     0.0268 0.000 0.000 0.500 0.004 0.496
#> SRR1424702     3  0.0000     0.8722 0.000 0.000 1.000 0.000 0.000
#> SRR1424703     3  0.0566     0.8682 0.000 0.000 0.984 0.004 0.012
#> SRR1424704     3  0.0000     0.8722 0.000 0.000 1.000 0.000 0.000
#> SRR1424706     3  0.0566     0.8682 0.000 0.000 0.984 0.004 0.012
#> SRR1424707     3  0.0000     0.8722 0.000 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR1424656     1  0.0146     0.6886 0.996 0.000 0.000 0.000 0.004 0.000
#> SRR1424657     1  0.2203     0.6713 0.896 0.000 0.000 0.084 0.016 0.004
#> SRR1424658     2  0.2922     0.7429 0.000 0.864 0.000 0.068 0.012 0.056
#> SRR1424659     1  0.2518     0.6624 0.880 0.000 0.004 0.008 0.096 0.012
#> SRR1424660     3  0.4019     0.6129 0.012 0.000 0.652 0.000 0.332 0.004
#> SRR1424661     4  0.7128     0.0261 0.088 0.000 0.088 0.508 0.264 0.052
#> SRR1424662     2  0.3017     0.6801 0.000 0.816 0.000 0.164 0.000 0.020
#> SRR1424663     1  0.5921    -0.1325 0.432 0.000 0.180 0.004 0.384 0.000
#> SRR1424664     1  0.1757     0.6816 0.928 0.000 0.000 0.008 0.052 0.012
#> SRR1424665     1  0.5838     0.3794 0.592 0.044 0.000 0.020 0.056 0.288
#> SRR1424666     3  0.2793     0.7376 0.000 0.000 0.800 0.000 0.200 0.000
#> SRR1424667     2  0.0146     0.7719 0.000 0.996 0.000 0.000 0.000 0.004
#> SRR1424668     3  0.3101     0.7119 0.000 0.000 0.756 0.000 0.244 0.000
#> SRR1424669     6  0.5137     0.3440 0.000 0.092 0.004 0.020 0.216 0.668
#> SRR1424670     1  0.4801     0.4937 0.704 0.000 0.000 0.052 0.200 0.044
#> SRR1424671     4  0.6075     0.1682 0.000 0.000 0.180 0.604 0.132 0.084
#> SRR1424672     3  0.3198     0.6993 0.000 0.000 0.740 0.000 0.260 0.000
#> SRR1424674     1  0.3737     0.6129 0.772 0.000 0.000 0.184 0.036 0.008
#> SRR1424673     3  0.0820     0.7939 0.000 0.000 0.972 0.000 0.016 0.012
#> SRR1424675     2  0.1556     0.7274 0.000 0.920 0.000 0.000 0.000 0.080
#> SRR1424676     2  0.0146     0.7719 0.000 0.996 0.000 0.000 0.000 0.004
#> SRR1424677     4  0.6132     0.4069 0.000 0.376 0.000 0.480 0.076 0.068
#> SRR1424678     2  0.0146     0.7719 0.000 0.996 0.000 0.000 0.000 0.004
#> SRR1424679     2  0.0146     0.7719 0.000 0.996 0.000 0.000 0.000 0.004
#> SRR1424680     2  0.2135     0.7253 0.000 0.872 0.000 0.128 0.000 0.000
#> SRR1424681     3  0.4561     0.4093 0.036 0.000 0.536 0.000 0.428 0.000
#> SRR1424682     3  0.0000     0.8041 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1424683     4  0.4027     0.4530 0.004 0.352 0.000 0.636 0.004 0.004
#> SRR1424685     5  0.5349    -0.0528 0.080 0.000 0.316 0.020 0.584 0.000
#> SRR1424686     3  0.3126     0.7090 0.000 0.000 0.752 0.000 0.248 0.000
#> SRR1424687     5  0.6275     0.0617 0.004 0.004 0.000 0.292 0.420 0.280
#> SRR1424688     2  0.5178    -0.1181 0.012 0.484 0.000 0.460 0.028 0.016
#> SRR1424689     6  0.2913     0.4268 0.000 0.180 0.000 0.004 0.004 0.812
#> SRR1424690     5  0.7744     0.0990 0.312 0.000 0.176 0.032 0.372 0.108
#> SRR1424691     3  0.5087     0.3213 0.080 0.000 0.508 0.000 0.412 0.000
#> SRR1424692     4  0.4167     0.4724 0.000 0.344 0.000 0.636 0.012 0.008
#> SRR1424684     2  0.0458     0.7705 0.000 0.984 0.000 0.016 0.000 0.000
#> SRR1424693     5  0.8255     0.1311 0.116 0.076 0.000 0.232 0.368 0.208
#> SRR1424694     4  0.4320     0.4824 0.008 0.300 0.000 0.668 0.016 0.008
#> SRR1424695     2  0.3470     0.6656 0.000 0.792 0.000 0.176 0.012 0.020
#> SRR1424696     2  0.2135     0.7253 0.000 0.872 0.000 0.128 0.000 0.000
#> SRR1424697     3  0.0291     0.8019 0.000 0.000 0.992 0.000 0.004 0.004
#> SRR1424698     3  0.1003     0.7878 0.000 0.000 0.964 0.000 0.016 0.020
#> SRR1424699     2  0.3547     0.4151 0.000 0.668 0.000 0.000 0.000 0.332
#> SRR1424700     2  0.3838     0.1379 0.000 0.552 0.000 0.000 0.000 0.448
#> SRR1424701     6  0.4571     0.1831 0.004 0.000 0.432 0.000 0.028 0.536
#> SRR1424702     3  0.0000     0.8041 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1424703     3  0.0820     0.7939 0.000 0.000 0.972 0.000 0.016 0.012
#> SRR1424704     3  0.0000     0.8041 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1424706     3  0.0820     0.7939 0.000 0.000 0.972 0.000 0.016 0.012
#> SRR1424707     3  0.0000     0.8041 0.000 0.000 1.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-skmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-skmeans-collect-classes

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


ATC:pam*

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

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

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

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

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

collect_plots(res)

plot of chunk ATC-pam-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4539 0.547   0.547
#> 3 3 0.922           0.878       0.954         0.3673 0.597   0.395
#> 4 4 0.822           0.730       0.902         0.1935 0.802   0.528
#> 5 5 0.881           0.824       0.932         0.0466 0.949   0.812
#> 6 6 0.943           0.875       0.947         0.0578 0.893   0.592

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
#> SRR1424656     1       0          1  1  0
#> SRR1424657     1       0          1  1  0
#> SRR1424658     2       0          1  0  1
#> SRR1424659     1       0          1  1  0
#> SRR1424660     1       0          1  1  0
#> SRR1424661     1       0          1  1  0
#> SRR1424662     2       0          1  0  1
#> SRR1424663     1       0          1  1  0
#> SRR1424664     1       0          1  1  0
#> SRR1424665     1       0          1  1  0
#> SRR1424666     1       0          1  1  0
#> SRR1424667     2       0          1  0  1
#> SRR1424668     1       0          1  1  0
#> SRR1424669     1       0          1  1  0
#> SRR1424670     1       0          1  1  0
#> SRR1424671     1       0          1  1  0
#> SRR1424672     1       0          1  1  0
#> SRR1424674     1       0          1  1  0
#> SRR1424673     1       0          1  1  0
#> SRR1424675     2       0          1  0  1
#> SRR1424676     2       0          1  0  1
#> SRR1424677     1       0          1  1  0
#> SRR1424678     2       0          1  0  1
#> SRR1424679     2       0          1  0  1
#> SRR1424680     2       0          1  0  1
#> SRR1424681     1       0          1  1  0
#> SRR1424682     1       0          1  1  0
#> SRR1424683     2       0          1  0  1
#> SRR1424685     1       0          1  1  0
#> SRR1424686     1       0          1  1  0
#> SRR1424687     1       0          1  1  0
#> SRR1424688     2       0          1  0  1
#> SRR1424689     1       0          1  1  0
#> SRR1424690     1       0          1  1  0
#> SRR1424691     1       0          1  1  0
#> SRR1424692     2       0          1  0  1
#> SRR1424684     2       0          1  0  1
#> SRR1424693     1       0          1  1  0
#> SRR1424694     2       0          1  0  1
#> SRR1424695     2       0          1  0  1
#> SRR1424696     2       0          1  0  1
#> SRR1424697     1       0          1  1  0
#> SRR1424698     1       0          1  1  0
#> SRR1424699     2       0          1  0  1
#> SRR1424700     2       0          1  0  1
#> SRR1424701     1       0          1  1  0
#> SRR1424702     1       0          1  1  0
#> SRR1424703     1       0          1  1  0
#> SRR1424704     1       0          1  1  0
#> SRR1424706     1       0          1  1  0
#> SRR1424707     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
#> SRR1424656     1  0.0000     0.9206 1.000 0.000 0.000
#> SRR1424657     1  0.0000     0.9206 1.000 0.000 0.000
#> SRR1424658     1  0.2066     0.8731 0.940 0.060 0.000
#> SRR1424659     1  0.5968     0.4308 0.636 0.000 0.364
#> SRR1424660     3  0.0000     0.9980 0.000 0.000 1.000
#> SRR1424661     1  0.0000     0.9206 1.000 0.000 0.000
#> SRR1424662     1  0.0000     0.9206 1.000 0.000 0.000
#> SRR1424663     1  0.6026     0.4045 0.624 0.000 0.376
#> SRR1424664     1  0.1643     0.8806 0.956 0.000 0.044
#> SRR1424665     1  0.0000     0.9206 1.000 0.000 0.000
#> SRR1424666     3  0.0000     0.9980 0.000 0.000 1.000
#> SRR1424667     2  0.0000     0.8809 0.000 1.000 0.000
#> SRR1424668     3  0.0000     0.9980 0.000 0.000 1.000
#> SRR1424669     1  0.0000     0.9206 1.000 0.000 0.000
#> SRR1424670     1  0.0000     0.9206 1.000 0.000 0.000
#> SRR1424671     1  0.0237     0.9180 0.996 0.000 0.004
#> SRR1424672     3  0.0000     0.9980 0.000 0.000 1.000
#> SRR1424674     1  0.0000     0.9206 1.000 0.000 0.000
#> SRR1424673     3  0.0000     0.9980 0.000 0.000 1.000
#> SRR1424675     2  0.5968     0.4791 0.364 0.636 0.000
#> SRR1424676     1  0.4504     0.6850 0.804 0.196 0.000
#> SRR1424677     1  0.0000     0.9206 1.000 0.000 0.000
#> SRR1424678     2  0.0000     0.8809 0.000 1.000 0.000
#> SRR1424679     2  0.0000     0.8809 0.000 1.000 0.000
#> SRR1424680     2  0.0000     0.8809 0.000 1.000 0.000
#> SRR1424681     3  0.0000     0.9980 0.000 0.000 1.000
#> SRR1424682     3  0.0000     0.9980 0.000 0.000 1.000
#> SRR1424683     1  0.0000     0.9206 1.000 0.000 0.000
#> SRR1424685     1  0.0000     0.9206 1.000 0.000 0.000
#> SRR1424686     3  0.0000     0.9980 0.000 0.000 1.000
#> SRR1424687     1  0.0000     0.9206 1.000 0.000 0.000
#> SRR1424688     1  0.0747     0.9097 0.984 0.016 0.000
#> SRR1424689     1  0.0000     0.9206 1.000 0.000 0.000
#> SRR1424690     1  0.0000     0.9206 1.000 0.000 0.000
#> SRR1424691     3  0.1031     0.9679 0.024 0.000 0.976
#> SRR1424692     1  0.2066     0.8731 0.940 0.060 0.000
#> SRR1424684     2  0.0000     0.8809 0.000 1.000 0.000
#> SRR1424693     1  0.0000     0.9206 1.000 0.000 0.000
#> SRR1424694     1  0.0000     0.9206 1.000 0.000 0.000
#> SRR1424695     1  0.0000     0.9206 1.000 0.000 0.000
#> SRR1424696     2  0.0000     0.8809 0.000 1.000 0.000
#> SRR1424697     3  0.0000     0.9980 0.000 0.000 1.000
#> SRR1424698     3  0.0000     0.9980 0.000 0.000 1.000
#> SRR1424699     2  0.5968     0.4791 0.364 0.636 0.000
#> SRR1424700     1  0.6274    -0.0109 0.544 0.456 0.000
#> SRR1424701     3  0.0000     0.9980 0.000 0.000 1.000
#> SRR1424702     3  0.0000     0.9980 0.000 0.000 1.000
#> SRR1424703     3  0.0000     0.9980 0.000 0.000 1.000
#> SRR1424704     3  0.0000     0.9980 0.000 0.000 1.000
#> SRR1424706     3  0.0000     0.9980 0.000 0.000 1.000
#> SRR1424707     3  0.0000     0.9980 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
#> SRR1424656     1  0.0000    0.79878 1.000 0.000 0.000 0.000
#> SRR1424657     1  0.3837    0.56443 0.776 0.000 0.000 0.224
#> SRR1424658     4  0.1302    0.77195 0.044 0.000 0.000 0.956
#> SRR1424659     1  0.0000    0.79878 1.000 0.000 0.000 0.000
#> SRR1424660     1  0.0592    0.79260 0.984 0.000 0.016 0.000
#> SRR1424661     1  0.4994   -0.00629 0.520 0.000 0.000 0.480
#> SRR1424662     4  0.0592    0.78948 0.016 0.000 0.000 0.984
#> SRR1424663     1  0.1474    0.77024 0.948 0.000 0.052 0.000
#> SRR1424664     1  0.0000    0.79878 1.000 0.000 0.000 0.000
#> SRR1424665     1  0.0000    0.79878 1.000 0.000 0.000 0.000
#> SRR1424666     3  0.0000    1.00000 0.000 0.000 1.000 0.000
#> SRR1424667     2  0.0000    0.84593 0.000 1.000 0.000 0.000
#> SRR1424668     3  0.0000    1.00000 0.000 0.000 1.000 0.000
#> SRR1424669     1  0.2589    0.71545 0.884 0.000 0.000 0.116
#> SRR1424670     1  0.0000    0.79878 1.000 0.000 0.000 0.000
#> SRR1424671     4  0.6290    0.19205 0.364 0.000 0.068 0.568
#> SRR1424672     3  0.0000    1.00000 0.000 0.000 1.000 0.000
#> SRR1424674     1  0.0000    0.79878 1.000 0.000 0.000 0.000
#> SRR1424673     3  0.0000    1.00000 0.000 0.000 1.000 0.000
#> SRR1424675     2  0.4989    0.22661 0.000 0.528 0.000 0.472
#> SRR1424676     4  0.0188    0.79138 0.000 0.004 0.000 0.996
#> SRR1424677     4  0.0000    0.79348 0.000 0.000 0.000 1.000
#> SRR1424678     2  0.0000    0.84593 0.000 1.000 0.000 0.000
#> SRR1424679     2  0.0000    0.84593 0.000 1.000 0.000 0.000
#> SRR1424680     2  0.0000    0.84593 0.000 1.000 0.000 0.000
#> SRR1424681     3  0.0000    1.00000 0.000 0.000 1.000 0.000
#> SRR1424682     3  0.0000    1.00000 0.000 0.000 1.000 0.000
#> SRR1424683     4  0.0000    0.79348 0.000 0.000 0.000 1.000
#> SRR1424685     1  0.0000    0.79878 1.000 0.000 0.000 0.000
#> SRR1424686     3  0.0000    1.00000 0.000 0.000 1.000 0.000
#> SRR1424687     1  0.1940    0.75481 0.924 0.000 0.000 0.076
#> SRR1424688     4  0.0000    0.79348 0.000 0.000 0.000 1.000
#> SRR1424689     1  0.4830    0.22707 0.608 0.000 0.000 0.392
#> SRR1424690     1  0.0000    0.79878 1.000 0.000 0.000 0.000
#> SRR1424691     1  0.4994    0.16376 0.520 0.000 0.480 0.000
#> SRR1424692     4  0.0000    0.79348 0.000 0.000 0.000 1.000
#> SRR1424684     2  0.0000    0.84593 0.000 1.000 0.000 0.000
#> SRR1424693     1  0.4933    0.11434 0.568 0.000 0.000 0.432
#> SRR1424694     4  0.0188    0.79284 0.004 0.000 0.000 0.996
#> SRR1424695     4  0.4955    0.14743 0.444 0.000 0.000 0.556
#> SRR1424696     2  0.0000    0.84593 0.000 1.000 0.000 0.000
#> SRR1424697     3  0.0000    1.00000 0.000 0.000 1.000 0.000
#> SRR1424698     3  0.0000    1.00000 0.000 0.000 1.000 0.000
#> SRR1424699     2  0.4989    0.22661 0.000 0.528 0.000 0.472
#> SRR1424700     4  0.5503    0.04820 0.468 0.016 0.000 0.516
#> SRR1424701     1  0.4624    0.49249 0.660 0.000 0.340 0.000
#> SRR1424702     3  0.0000    1.00000 0.000 0.000 1.000 0.000
#> SRR1424703     3  0.0000    1.00000 0.000 0.000 1.000 0.000
#> SRR1424704     3  0.0000    1.00000 0.000 0.000 1.000 0.000
#> SRR1424706     3  0.0000    1.00000 0.000 0.000 1.000 0.000
#> SRR1424707     3  0.0000    1.00000 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
#> SRR1424656     1  0.0000     0.8201 1.000  0 0.000 0.000 0.000
#> SRR1424657     1  0.2852     0.6745 0.828  0 0.000 0.172 0.000
#> SRR1424658     5  0.5752     0.5265 0.148  0 0.000 0.240 0.612
#> SRR1424659     1  0.0000     0.8201 1.000  0 0.000 0.000 0.000
#> SRR1424660     1  0.1043     0.7935 0.960  0 0.040 0.000 0.000
#> SRR1424661     1  0.3816     0.5105 0.696  0 0.000 0.304 0.000
#> SRR1424662     4  0.0865     0.9141 0.024  0 0.000 0.972 0.004
#> SRR1424663     1  0.0703     0.8065 0.976  0 0.024 0.000 0.000
#> SRR1424664     1  0.0000     0.8201 1.000  0 0.000 0.000 0.000
#> SRR1424665     1  0.0000     0.8201 1.000  0 0.000 0.000 0.000
#> SRR1424666     3  0.0000     0.9725 0.000  0 1.000 0.000 0.000
#> SRR1424667     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000
#> SRR1424668     3  0.0000     0.9725 0.000  0 1.000 0.000 0.000
#> SRR1424669     1  0.0162     0.8200 0.996  0 0.000 0.004 0.000
#> SRR1424670     1  0.0162     0.8200 0.996  0 0.000 0.004 0.000
#> SRR1424671     4  0.0404     0.9236 0.012  0 0.000 0.988 0.000
#> SRR1424672     3  0.0000     0.9725 0.000  0 1.000 0.000 0.000
#> SRR1424674     1  0.0000     0.8201 1.000  0 0.000 0.000 0.000
#> SRR1424673     3  0.0000     0.9725 0.000  0 1.000 0.000 0.000
#> SRR1424675     5  0.0000     0.8669 0.000  0 0.000 0.000 1.000
#> SRR1424676     4  0.0609     0.9215 0.000  0 0.000 0.980 0.020
#> SRR1424677     4  0.0162     0.9313 0.000  0 0.000 0.996 0.004
#> SRR1424678     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000
#> SRR1424679     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000
#> SRR1424680     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000
#> SRR1424681     3  0.0000     0.9725 0.000  0 1.000 0.000 0.000
#> SRR1424682     3  0.0000     0.9725 0.000  0 1.000 0.000 0.000
#> SRR1424683     4  0.0162     0.9313 0.000  0 0.000 0.996 0.004
#> SRR1424685     1  0.0162     0.8200 0.996  0 0.000 0.004 0.000
#> SRR1424686     3  0.0000     0.9725 0.000  0 1.000 0.000 0.000
#> SRR1424687     1  0.4287     0.1352 0.540  0 0.000 0.460 0.000
#> SRR1424688     4  0.0000     0.9311 0.000  0 0.000 1.000 0.000
#> SRR1424689     1  0.4390     0.2391 0.568  0 0.000 0.004 0.428
#> SRR1424690     1  0.0162     0.8200 0.996  0 0.000 0.004 0.000
#> SRR1424691     3  0.3774     0.5306 0.296  0 0.704 0.000 0.000
#> SRR1424692     4  0.0162     0.9313 0.000  0 0.000 0.996 0.004
#> SRR1424684     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000
#> SRR1424693     1  0.4201     0.2792 0.592  0 0.000 0.408 0.000
#> SRR1424694     4  0.0000     0.9311 0.000  0 0.000 1.000 0.000
#> SRR1424695     4  0.3816     0.4777 0.304  0 0.000 0.696 0.000
#> SRR1424696     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000
#> SRR1424697     3  0.0000     0.9725 0.000  0 1.000 0.000 0.000
#> SRR1424698     3  0.0000     0.9725 0.000  0 1.000 0.000 0.000
#> SRR1424699     5  0.0000     0.8669 0.000  0 0.000 0.000 1.000
#> SRR1424700     5  0.0000     0.8669 0.000  0 0.000 0.000 1.000
#> SRR1424701     1  0.6219     0.0602 0.472  0 0.144 0.000 0.384
#> SRR1424702     3  0.0000     0.9725 0.000  0 1.000 0.000 0.000
#> SRR1424703     3  0.0000     0.9725 0.000  0 1.000 0.000 0.000
#> SRR1424704     3  0.0000     0.9725 0.000  0 1.000 0.000 0.000
#> SRR1424706     3  0.0000     0.9725 0.000  0 1.000 0.000 0.000
#> SRR1424707     3  0.0000     0.9725 0.000  0 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1 p2    p3    p4    p5    p6
#> SRR1424656     1  0.0000     0.9275 1.000  0 0.000 0.000 0.000 0.000
#> SRR1424657     1  0.0000     0.9275 1.000  0 0.000 0.000 0.000 0.000
#> SRR1424658     5  0.5872    -0.0101 0.196  0 0.000 0.000 0.404 0.400
#> SRR1424659     1  0.0000     0.9275 1.000  0 0.000 0.000 0.000 0.000
#> SRR1424660     1  0.2135     0.8071 0.872  0 0.000 0.000 0.128 0.000
#> SRR1424661     1  0.0937     0.8953 0.960  0 0.000 0.040 0.000 0.000
#> SRR1424662     4  0.0260     0.9362 0.000  0 0.000 0.992 0.008 0.000
#> SRR1424663     1  0.0000     0.9275 1.000  0 0.000 0.000 0.000 0.000
#> SRR1424664     1  0.0000     0.9275 1.000  0 0.000 0.000 0.000 0.000
#> SRR1424665     1  0.0000     0.9275 1.000  0 0.000 0.000 0.000 0.000
#> SRR1424666     3  0.0000     0.9643 0.000  0 1.000 0.000 0.000 0.000
#> SRR1424667     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000 0.000
#> SRR1424668     3  0.0000     0.9643 0.000  0 1.000 0.000 0.000 0.000
#> SRR1424669     5  0.1007     0.8373 0.044  0 0.000 0.000 0.956 0.000
#> SRR1424670     1  0.3659     0.3596 0.636  0 0.000 0.000 0.364 0.000
#> SRR1424671     4  0.3428     0.5903 0.000  0 0.000 0.696 0.304 0.000
#> SRR1424672     3  0.0000     0.9643 0.000  0 1.000 0.000 0.000 0.000
#> SRR1424674     1  0.0000     0.9275 1.000  0 0.000 0.000 0.000 0.000
#> SRR1424673     3  0.0000     0.9643 0.000  0 1.000 0.000 0.000 0.000
#> SRR1424675     6  0.0000     1.0000 0.000  0 0.000 0.000 0.000 1.000
#> SRR1424676     4  0.0520     0.9340 0.000  0 0.000 0.984 0.008 0.008
#> SRR1424677     4  0.0363     0.9356 0.000  0 0.000 0.988 0.012 0.000
#> SRR1424678     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000 0.000
#> SRR1424679     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000 0.000
#> SRR1424680     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000 0.000
#> SRR1424681     3  0.0000     0.9643 0.000  0 1.000 0.000 0.000 0.000
#> SRR1424682     3  0.0000     0.9643 0.000  0 1.000 0.000 0.000 0.000
#> SRR1424683     4  0.0000     0.9362 0.000  0 0.000 1.000 0.000 0.000
#> SRR1424685     5  0.1007     0.8373 0.044  0 0.000 0.000 0.956 0.000
#> SRR1424686     3  0.0000     0.9643 0.000  0 1.000 0.000 0.000 0.000
#> SRR1424687     5  0.1082     0.8255 0.004  0 0.000 0.040 0.956 0.000
#> SRR1424688     4  0.1141     0.9012 0.000  0 0.000 0.948 0.052 0.000
#> SRR1424689     5  0.1007     0.8373 0.044  0 0.000 0.000 0.956 0.000
#> SRR1424690     5  0.1075     0.8353 0.048  0 0.000 0.000 0.952 0.000
#> SRR1424691     5  0.2402     0.7108 0.004  0 0.140 0.000 0.856 0.000
#> SRR1424692     4  0.0000     0.9362 0.000  0 0.000 1.000 0.000 0.000
#> SRR1424684     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000 0.000
#> SRR1424693     5  0.1007     0.8229 0.000  0 0.000 0.044 0.956 0.000
#> SRR1424694     4  0.0000     0.9362 0.000  0 0.000 1.000 0.000 0.000
#> SRR1424695     5  0.3446     0.5276 0.000  0 0.000 0.308 0.692 0.000
#> SRR1424696     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000 0.000
#> SRR1424697     3  0.0000     0.9643 0.000  0 1.000 0.000 0.000 0.000
#> SRR1424698     3  0.0000     0.9643 0.000  0 1.000 0.000 0.000 0.000
#> SRR1424699     6  0.0000     1.0000 0.000  0 0.000 0.000 0.000 1.000
#> SRR1424700     6  0.0000     1.0000 0.000  0 0.000 0.000 0.000 1.000
#> SRR1424701     3  0.6524     0.2354 0.068  0 0.512 0.000 0.260 0.160
#> SRR1424702     3  0.0000     0.9643 0.000  0 1.000 0.000 0.000 0.000
#> SRR1424703     3  0.0000     0.9643 0.000  0 1.000 0.000 0.000 0.000
#> SRR1424704     3  0.0000     0.9643 0.000  0 1.000 0.000 0.000 0.000
#> SRR1424706     3  0.0000     0.9643 0.000  0 1.000 0.000 0.000 0.000
#> SRR1424707     3  0.0000     0.9643 0.000  0 1.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

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

collect_plots(res)

plot of chunk ATC-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 0.388           0.772       0.876         0.4490 0.523   0.523
#> 3 3 0.683           0.841       0.925         0.4475 0.525   0.292
#> 4 4 0.744           0.650       0.860         0.0616 0.763   0.469
#> 5 5 0.691           0.781       0.887         0.0511 0.897   0.706
#> 6 6 0.783           0.738       0.829         0.0914 0.889   0.631

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
#> SRR1424656     2  0.0000    0.89373 0.000 1.000
#> SRR1424657     2  0.0000    0.89373 0.000 1.000
#> SRR1424658     2  0.0000    0.89373 0.000 1.000
#> SRR1424659     2  0.0000    0.89373 0.000 1.000
#> SRR1424660     1  0.7883    0.79360 0.764 0.236
#> SRR1424661     2  0.0000    0.89373 0.000 1.000
#> SRR1424662     1  0.7219    0.82848 0.800 0.200
#> SRR1424663     1  0.9815    0.46671 0.580 0.420
#> SRR1424664     2  0.0000    0.89373 0.000 1.000
#> SRR1424665     1  0.9998    0.22456 0.508 0.492
#> SRR1424666     1  0.0000    0.81752 1.000 0.000
#> SRR1424667     1  0.5842    0.86457 0.860 0.140
#> SRR1424668     1  0.0376    0.81901 0.996 0.004
#> SRR1424669     1  0.9552    0.57957 0.624 0.376
#> SRR1424670     2  0.0000    0.89373 0.000 1.000
#> SRR1424671     2  0.0000    0.89373 0.000 1.000
#> SRR1424672     1  0.0376    0.81901 0.996 0.004
#> SRR1424674     2  0.0938    0.88738 0.012 0.988
#> SRR1424673     1  0.7219    0.82848 0.800 0.200
#> SRR1424675     1  0.5842    0.86457 0.860 0.140
#> SRR1424676     1  0.5842    0.86457 0.860 0.140
#> SRR1424677     2  0.0000    0.89373 0.000 1.000
#> SRR1424678     1  0.5842    0.86457 0.860 0.140
#> SRR1424679     1  0.5842    0.86457 0.860 0.140
#> SRR1424680     1  0.5842    0.86457 0.860 0.140
#> SRR1424681     1  0.6973    0.83711 0.812 0.188
#> SRR1424682     1  0.0376    0.81901 0.996 0.004
#> SRR1424683     2  0.0000    0.89373 0.000 1.000
#> SRR1424685     2  0.9881    0.00442 0.436 0.564
#> SRR1424686     1  0.0376    0.81901 0.996 0.004
#> SRR1424687     2  0.9754    0.13786 0.408 0.592
#> SRR1424688     1  0.9970    0.35115 0.532 0.468
#> SRR1424689     2  0.5629    0.76999 0.132 0.868
#> SRR1424690     2  0.4161    0.82689 0.084 0.916
#> SRR1424691     1  0.7219    0.82848 0.800 0.200
#> SRR1424692     2  0.0000    0.89373 0.000 1.000
#> SRR1424684     1  0.5842    0.86457 0.860 0.140
#> SRR1424693     2  0.9686    0.17800 0.396 0.604
#> SRR1424694     2  0.0000    0.89373 0.000 1.000
#> SRR1424695     2  0.1843    0.87634 0.028 0.972
#> SRR1424696     1  0.5946    0.86294 0.856 0.144
#> SRR1424697     1  0.0376    0.81901 0.996 0.004
#> SRR1424698     1  0.5842    0.86457 0.860 0.140
#> SRR1424699     1  0.5842    0.86457 0.860 0.140
#> SRR1424700     1  0.5842    0.86457 0.860 0.140
#> SRR1424701     1  0.5842    0.86457 0.860 0.140
#> SRR1424702     1  0.0000    0.81752 1.000 0.000
#> SRR1424703     1  0.0376    0.81901 0.996 0.004
#> SRR1424704     1  0.0000    0.81752 1.000 0.000
#> SRR1424706     1  0.9044    0.67654 0.680 0.320
#> SRR1424707     1  0.0000    0.81752 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
#> SRR1424656     1  0.0475      0.867 0.992 0.004 0.004
#> SRR1424657     1  0.0000      0.866 1.000 0.000 0.000
#> SRR1424658     2  0.0424      0.914 0.008 0.992 0.000
#> SRR1424659     1  0.4575      0.790 0.812 0.184 0.004
#> SRR1424660     1  0.4861      0.782 0.800 0.192 0.008
#> SRR1424661     2  0.6189      0.462 0.364 0.632 0.004
#> SRR1424662     1  0.4002      0.754 0.840 0.160 0.000
#> SRR1424663     1  0.0000      0.866 1.000 0.000 0.000
#> SRR1424664     1  0.4629      0.786 0.808 0.188 0.004
#> SRR1424665     1  0.6079      0.459 0.612 0.388 0.000
#> SRR1424666     3  0.0237      0.955 0.004 0.000 0.996
#> SRR1424667     2  0.0000      0.915 0.000 1.000 0.000
#> SRR1424668     3  0.0237      0.955 0.004 0.000 0.996
#> SRR1424669     2  0.3965      0.786 0.132 0.860 0.008
#> SRR1424670     1  0.0000      0.866 1.000 0.000 0.000
#> SRR1424671     2  0.0829      0.914 0.012 0.984 0.004
#> SRR1424672     3  0.4121      0.800 0.168 0.000 0.832
#> SRR1424674     1  0.0237      0.867 0.996 0.000 0.004
#> SRR1424673     3  0.1289      0.930 0.000 0.032 0.968
#> SRR1424675     2  0.0000      0.915 0.000 1.000 0.000
#> SRR1424676     2  0.0661      0.915 0.008 0.988 0.004
#> SRR1424677     2  0.0848      0.914 0.008 0.984 0.008
#> SRR1424678     2  0.0475      0.916 0.004 0.992 0.004
#> SRR1424679     2  0.0237      0.916 0.000 0.996 0.004
#> SRR1424680     2  0.0592      0.915 0.012 0.988 0.000
#> SRR1424681     1  0.0237      0.866 0.996 0.000 0.004
#> SRR1424682     3  0.0000      0.955 0.000 0.000 1.000
#> SRR1424683     2  0.6045      0.434 0.380 0.620 0.000
#> SRR1424685     1  0.0237      0.866 0.996 0.000 0.004
#> SRR1424686     3  0.4399      0.773 0.188 0.000 0.812
#> SRR1424687     1  0.0237      0.866 0.996 0.000 0.004
#> SRR1424688     1  0.5929      0.475 0.676 0.320 0.004
#> SRR1424689     2  0.0237      0.915 0.004 0.996 0.000
#> SRR1424690     1  0.3918      0.821 0.856 0.140 0.004
#> SRR1424691     1  0.0424      0.866 0.992 0.000 0.008
#> SRR1424692     2  0.0592      0.915 0.012 0.988 0.000
#> SRR1424684     2  0.0237      0.916 0.000 0.996 0.004
#> SRR1424693     1  0.0237      0.867 0.996 0.000 0.004
#> SRR1424694     2  0.6095      0.406 0.392 0.608 0.000
#> SRR1424695     1  0.4521      0.795 0.816 0.180 0.004
#> SRR1424696     2  0.0661      0.915 0.008 0.988 0.004
#> SRR1424697     3  0.0000      0.955 0.000 0.000 1.000
#> SRR1424698     2  0.1753      0.885 0.000 0.952 0.048
#> SRR1424699     2  0.0000      0.915 0.000 1.000 0.000
#> SRR1424700     2  0.0000      0.915 0.000 1.000 0.000
#> SRR1424701     2  0.0237      0.915 0.000 0.996 0.004
#> SRR1424702     3  0.0000      0.955 0.000 0.000 1.000
#> SRR1424703     3  0.0237      0.954 0.000 0.004 0.996
#> SRR1424704     3  0.0000      0.955 0.000 0.000 1.000
#> SRR1424706     2  0.4002      0.793 0.000 0.840 0.160
#> SRR1424707     3  0.0237      0.955 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
#> SRR1424656     1  0.0188      0.770 0.996 0.000 0.004 0.000
#> SRR1424657     1  0.0000      0.770 1.000 0.000 0.000 0.000
#> SRR1424658     1  0.5345      0.233 0.560 0.012 0.000 0.428
#> SRR1424659     1  0.0657      0.768 0.984 0.000 0.004 0.012
#> SRR1424660     1  0.1545      0.741 0.952 0.008 0.040 0.000
#> SRR1424661     4  0.4948      0.319 0.440 0.000 0.000 0.560
#> SRR1424662     1  0.4916      0.242 0.576 0.000 0.000 0.424
#> SRR1424663     1  0.0000      0.770 1.000 0.000 0.000 0.000
#> SRR1424664     1  0.0657      0.768 0.984 0.000 0.004 0.012
#> SRR1424665     1  0.3039      0.730 0.900 0.012 0.036 0.052
#> SRR1424666     3  0.0000      0.900 0.000 0.000 1.000 0.000
#> SRR1424667     2  0.0000      0.830 0.000 1.000 0.000 0.000
#> SRR1424668     3  0.0000      0.900 0.000 0.000 1.000 0.000
#> SRR1424669     1  0.3047      0.730 0.900 0.012 0.040 0.048
#> SRR1424670     1  0.0000      0.770 1.000 0.000 0.000 0.000
#> SRR1424671     4  0.6203      0.351 0.380 0.012 0.036 0.572
#> SRR1424672     3  0.1118      0.873 0.036 0.000 0.964 0.000
#> SRR1424674     1  0.0188      0.770 0.996 0.000 0.004 0.000
#> SRR1424673     3  0.4776      0.390 0.376 0.000 0.624 0.000
#> SRR1424675     2  0.4981      0.346 0.000 0.536 0.000 0.464
#> SRR1424676     1  0.6379      0.195 0.524 0.012 0.040 0.424
#> SRR1424677     4  0.1771      0.422 0.004 0.012 0.036 0.948
#> SRR1424678     2  0.0000      0.830 0.000 1.000 0.000 0.000
#> SRR1424679     2  0.0000      0.830 0.000 1.000 0.000 0.000
#> SRR1424680     2  0.1211      0.813 0.040 0.960 0.000 0.000
#> SRR1424681     1  0.0188      0.768 0.996 0.000 0.004 0.000
#> SRR1424682     3  0.0000      0.900 0.000 0.000 1.000 0.000
#> SRR1424683     4  0.4679      0.334 0.352 0.000 0.000 0.648
#> SRR1424685     1  0.0000      0.770 1.000 0.000 0.000 0.000
#> SRR1424686     3  0.1118      0.873 0.036 0.000 0.964 0.000
#> SRR1424687     1  0.1302      0.756 0.956 0.000 0.000 0.044
#> SRR1424688     1  0.5088      0.246 0.572 0.000 0.004 0.424
#> SRR1424689     1  0.5373      0.531 0.716 0.012 0.032 0.240
#> SRR1424690     1  0.0188      0.770 0.996 0.000 0.004 0.000
#> SRR1424691     1  0.0188      0.770 0.996 0.000 0.004 0.000
#> SRR1424692     4  0.1677      0.440 0.040 0.012 0.000 0.948
#> SRR1424684     2  0.0000      0.830 0.000 1.000 0.000 0.000
#> SRR1424693     1  0.1824      0.750 0.936 0.000 0.004 0.060
#> SRR1424694     4  0.4761      0.289 0.372 0.000 0.000 0.628
#> SRR1424695     1  0.5509      0.237 0.560 0.012 0.004 0.424
#> SRR1424696     2  0.1118      0.814 0.036 0.964 0.000 0.000
#> SRR1424697     3  0.0188      0.898 0.004 0.000 0.996 0.000
#> SRR1424698     3  0.1677      0.869 0.000 0.012 0.948 0.040
#> SRR1424699     2  0.4981      0.346 0.000 0.536 0.000 0.464
#> SRR1424700     1  0.5396      0.182 0.524 0.012 0.000 0.464
#> SRR1424701     1  0.2610      0.732 0.900 0.012 0.000 0.088
#> SRR1424702     3  0.0000      0.900 0.000 0.000 1.000 0.000
#> SRR1424703     3  0.0000      0.900 0.000 0.000 1.000 0.000
#> SRR1424704     3  0.0000      0.900 0.000 0.000 1.000 0.000
#> SRR1424706     3  0.5204      0.374 0.376 0.012 0.612 0.000
#> SRR1424707     3  0.0000      0.900 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
#> SRR1424656     1  0.1478      0.830 0.936 0.000 0.000 0.000 0.064
#> SRR1424657     1  0.0000      0.843 1.000 0.000 0.000 0.000 0.000
#> SRR1424658     1  0.4610      0.208 0.556 0.000 0.000 0.012 0.432
#> SRR1424659     1  0.2464      0.808 0.888 0.000 0.000 0.016 0.096
#> SRR1424660     1  0.2012      0.828 0.920 0.000 0.020 0.000 0.060
#> SRR1424661     4  0.4299      0.396 0.388 0.000 0.000 0.608 0.004
#> SRR1424662     1  0.2864      0.770 0.864 0.000 0.000 0.112 0.024
#> SRR1424663     1  0.0000      0.843 1.000 0.000 0.000 0.000 0.000
#> SRR1424664     1  0.2464      0.808 0.888 0.000 0.000 0.016 0.096
#> SRR1424665     1  0.2920      0.778 0.852 0.000 0.000 0.016 0.132
#> SRR1424666     3  0.2516      0.777 0.140 0.000 0.860 0.000 0.000
#> SRR1424667     2  0.0000      0.975 0.000 1.000 0.000 0.000 0.000
#> SRR1424668     3  0.0000      0.951 0.000 0.000 1.000 0.000 0.000
#> SRR1424669     1  0.2856      0.809 0.872 0.000 0.008 0.016 0.104
#> SRR1424670     1  0.0162      0.843 0.996 0.000 0.000 0.004 0.000
#> SRR1424671     4  0.3325      0.667 0.112 0.004 0.012 0.852 0.020
#> SRR1424672     3  0.0000      0.951 0.000 0.000 1.000 0.000 0.000
#> SRR1424674     1  0.0162      0.843 0.996 0.000 0.000 0.004 0.000
#> SRR1424673     3  0.2439      0.829 0.120 0.000 0.876 0.004 0.000
#> SRR1424675     5  0.3876      0.384 0.000 0.316 0.000 0.000 0.684
#> SRR1424676     1  0.3552      0.764 0.840 0.004 0.012 0.116 0.028
#> SRR1424677     4  0.1074      0.713 0.000 0.004 0.012 0.968 0.016
#> SRR1424678     2  0.0000      0.975 0.000 1.000 0.000 0.000 0.000
#> SRR1424679     2  0.0000      0.975 0.000 1.000 0.000 0.000 0.000
#> SRR1424680     2  0.2130      0.893 0.012 0.908 0.000 0.000 0.080
#> SRR1424681     1  0.0671      0.840 0.980 0.000 0.016 0.004 0.000
#> SRR1424682     3  0.0000      0.951 0.000 0.000 1.000 0.000 0.000
#> SRR1424683     1  0.5979      0.389 0.588 0.000 0.000 0.192 0.220
#> SRR1424685     1  0.0290      0.843 0.992 0.000 0.000 0.008 0.000
#> SRR1424686     3  0.0000      0.951 0.000 0.000 1.000 0.000 0.000
#> SRR1424687     1  0.0566      0.842 0.984 0.000 0.000 0.012 0.004
#> SRR1424688     1  0.4593      0.658 0.748 0.000 0.000 0.124 0.128
#> SRR1424689     5  0.4264      0.487 0.376 0.000 0.000 0.004 0.620
#> SRR1424690     1  0.2361      0.809 0.892 0.000 0.000 0.012 0.096
#> SRR1424691     1  0.0162      0.843 0.996 0.000 0.004 0.000 0.000
#> SRR1424692     4  0.1074      0.716 0.012 0.004 0.000 0.968 0.016
#> SRR1424684     2  0.0000      0.975 0.000 1.000 0.000 0.000 0.000
#> SRR1424693     1  0.1281      0.838 0.956 0.000 0.000 0.032 0.012
#> SRR1424694     1  0.5950      0.396 0.592 0.000 0.000 0.188 0.220
#> SRR1424695     1  0.4548      0.742 0.752 0.000 0.000 0.124 0.124
#> SRR1424696     2  0.0404      0.965 0.012 0.988 0.000 0.000 0.000
#> SRR1424697     3  0.0324      0.948 0.004 0.000 0.992 0.004 0.000
#> SRR1424698     3  0.0510      0.940 0.000 0.000 0.984 0.000 0.016
#> SRR1424699     5  0.4622      0.481 0.040 0.276 0.000 0.000 0.684
#> SRR1424700     5  0.4170      0.607 0.140 0.080 0.000 0.000 0.780
#> SRR1424701     5  0.3999      0.541 0.344 0.000 0.000 0.000 0.656
#> SRR1424702     3  0.0000      0.951 0.000 0.000 1.000 0.000 0.000
#> SRR1424703     3  0.0162      0.950 0.000 0.000 0.996 0.004 0.000
#> SRR1424704     3  0.0000      0.951 0.000 0.000 1.000 0.000 0.000
#> SRR1424706     3  0.2439      0.829 0.120 0.000 0.876 0.004 0.000
#> SRR1424707     3  0.0000      0.951 0.000 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR1424656     1  0.3862     0.5263 0.524 0.000 0.000 0.000 0.476 0.000
#> SRR1424657     5  0.0260     0.7145 0.008 0.000 0.000 0.000 0.992 0.000
#> SRR1424658     1  0.3914     0.6520 0.768 0.000 0.000 0.000 0.128 0.104
#> SRR1424659     1  0.3351     0.7357 0.712 0.000 0.000 0.000 0.288 0.000
#> SRR1424660     5  0.4972    -0.0798 0.256 0.000 0.116 0.000 0.628 0.000
#> SRR1424661     5  0.4472     0.1223 0.028 0.000 0.000 0.476 0.496 0.000
#> SRR1424662     5  0.3136     0.6440 0.188 0.000 0.000 0.000 0.796 0.016
#> SRR1424663     5  0.0458     0.7188 0.000 0.000 0.000 0.016 0.984 0.000
#> SRR1424664     1  0.3351     0.7357 0.712 0.000 0.000 0.000 0.288 0.000
#> SRR1424665     1  0.3619     0.7170 0.680 0.000 0.000 0.000 0.316 0.004
#> SRR1424666     3  0.0547     0.9583 0.000 0.000 0.980 0.000 0.020 0.000
#> SRR1424667     2  0.0000     0.9361 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1424668     3  0.0000     0.9686 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1424669     1  0.5833     0.5342 0.508 0.000 0.076 0.000 0.372 0.044
#> SRR1424670     5  0.0260     0.7133 0.008 0.000 0.000 0.000 0.992 0.000
#> SRR1424671     4  0.0363     0.9123 0.012 0.000 0.000 0.988 0.000 0.000
#> SRR1424672     3  0.0146     0.9676 0.000 0.000 0.996 0.000 0.004 0.000
#> SRR1424674     5  0.0146     0.7155 0.004 0.000 0.000 0.000 0.996 0.000
#> SRR1424673     3  0.1341     0.9434 0.000 0.000 0.948 0.028 0.024 0.000
#> SRR1424675     6  0.2783     0.8019 0.016 0.148 0.000 0.000 0.000 0.836
#> SRR1424676     5  0.4662     0.5917 0.164 0.004 0.052 0.000 0.736 0.044
#> SRR1424677     4  0.1204     0.9436 0.056 0.000 0.000 0.944 0.000 0.000
#> SRR1424678     2  0.0000     0.9361 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1424679     2  0.0000     0.9361 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1424680     2  0.4010     0.7845 0.076 0.800 0.000 0.000 0.068 0.056
#> SRR1424681     5  0.1218     0.7126 0.004 0.000 0.012 0.028 0.956 0.000
#> SRR1424682     3  0.0000     0.9686 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1424683     5  0.5920     0.5142 0.220 0.000 0.000 0.068 0.604 0.108
#> SRR1424685     5  0.0363     0.7188 0.000 0.000 0.000 0.012 0.988 0.000
#> SRR1424686     3  0.0260     0.9663 0.000 0.000 0.992 0.000 0.008 0.000
#> SRR1424687     5  0.1663     0.6833 0.088 0.000 0.000 0.000 0.912 0.000
#> SRR1424688     5  0.4717     0.5484 0.308 0.000 0.000 0.008 0.632 0.052
#> SRR1424689     1  0.5140     0.1574 0.520 0.000 0.000 0.000 0.088 0.392
#> SRR1424690     5  0.4264    -0.1550 0.332 0.000 0.032 0.000 0.636 0.000
#> SRR1424691     5  0.0993     0.7168 0.012 0.000 0.000 0.024 0.964 0.000
#> SRR1424692     4  0.1807     0.9346 0.060 0.000 0.000 0.920 0.020 0.000
#> SRR1424684     2  0.0000     0.9361 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1424693     5  0.2219     0.6565 0.136 0.000 0.000 0.000 0.864 0.000
#> SRR1424694     5  0.5920     0.5142 0.220 0.000 0.000 0.068 0.604 0.108
#> SRR1424695     1  0.4085     0.6617 0.704 0.000 0.000 0.000 0.252 0.044
#> SRR1424696     2  0.1471     0.8865 0.004 0.932 0.000 0.000 0.064 0.000
#> SRR1424697     3  0.0713     0.9604 0.000 0.000 0.972 0.028 0.000 0.000
#> SRR1424698     3  0.2300     0.8228 0.000 0.000 0.856 0.000 0.000 0.144
#> SRR1424699     6  0.2318     0.8630 0.044 0.064 0.000 0.000 0.000 0.892
#> SRR1424700     6  0.1910     0.8566 0.108 0.000 0.000 0.000 0.000 0.892
#> SRR1424701     6  0.3602     0.7740 0.160 0.000 0.000 0.000 0.056 0.784
#> SRR1424702     3  0.0000     0.9686 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1424703     3  0.0713     0.9604 0.000 0.000 0.972 0.028 0.000 0.000
#> SRR1424704     3  0.0000     0.9686 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1424706     3  0.1421     0.9392 0.000 0.000 0.944 0.028 0.028 0.000
#> SRR1424707     3  0.0000     0.9686 0.000 0.000 1.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

plot of chunk tab-ATC-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 16960 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.880           0.907       0.962         0.4777 0.514   0.514
#> 3 3 0.741           0.885       0.923         0.3992 0.733   0.516
#> 4 4 0.777           0.782       0.901         0.0902 0.929   0.789
#> 5 5 0.679           0.601       0.785         0.0740 0.962   0.863
#> 6 6 0.645           0.503       0.705         0.0472 0.923   0.709

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
#> SRR1424656     2  0.6438      0.784 0.164 0.836
#> SRR1424657     2  0.3274      0.917 0.060 0.940
#> SRR1424658     2  0.0000      0.974 0.000 1.000
#> SRR1424659     1  0.0938      0.927 0.988 0.012
#> SRR1424660     1  0.9170      0.539 0.668 0.332
#> SRR1424661     1  0.9522      0.455 0.628 0.372
#> SRR1424662     2  0.0000      0.974 0.000 1.000
#> SRR1424663     1  0.0938      0.927 0.988 0.012
#> SRR1424664     2  0.9850      0.166 0.428 0.572
#> SRR1424665     2  0.0000      0.974 0.000 1.000
#> SRR1424666     1  0.0000      0.931 1.000 0.000
#> SRR1424667     2  0.0000      0.974 0.000 1.000
#> SRR1424668     1  0.0000      0.931 1.000 0.000
#> SRR1424669     2  0.0000      0.974 0.000 1.000
#> SRR1424670     2  0.0000      0.974 0.000 1.000
#> SRR1424671     2  0.0000      0.974 0.000 1.000
#> SRR1424672     1  0.0000      0.931 1.000 0.000
#> SRR1424674     2  0.0000      0.974 0.000 1.000
#> SRR1424673     1  0.0376      0.930 0.996 0.004
#> SRR1424675     2  0.0000      0.974 0.000 1.000
#> SRR1424676     2  0.0000      0.974 0.000 1.000
#> SRR1424677     2  0.0000      0.974 0.000 1.000
#> SRR1424678     2  0.0000      0.974 0.000 1.000
#> SRR1424679     2  0.0000      0.974 0.000 1.000
#> SRR1424680     2  0.0000      0.974 0.000 1.000
#> SRR1424681     1  0.0000      0.931 1.000 0.000
#> SRR1424682     1  0.0000      0.931 1.000 0.000
#> SRR1424683     2  0.0000      0.974 0.000 1.000
#> SRR1424685     1  0.9552      0.445 0.624 0.376
#> SRR1424686     1  0.0000      0.931 1.000 0.000
#> SRR1424687     2  0.0000      0.974 0.000 1.000
#> SRR1424688     2  0.0000      0.974 0.000 1.000
#> SRR1424689     2  0.0000      0.974 0.000 1.000
#> SRR1424690     2  0.3274      0.917 0.060 0.940
#> SRR1424691     1  0.1184      0.924 0.984 0.016
#> SRR1424692     2  0.0000      0.974 0.000 1.000
#> SRR1424684     2  0.0000      0.974 0.000 1.000
#> SRR1424693     2  0.0000      0.974 0.000 1.000
#> SRR1424694     2  0.0000      0.974 0.000 1.000
#> SRR1424695     2  0.0000      0.974 0.000 1.000
#> SRR1424696     2  0.0000      0.974 0.000 1.000
#> SRR1424697     1  0.0000      0.931 1.000 0.000
#> SRR1424698     1  0.0000      0.931 1.000 0.000
#> SRR1424699     2  0.0000      0.974 0.000 1.000
#> SRR1424700     2  0.0000      0.974 0.000 1.000
#> SRR1424701     2  0.0000      0.974 0.000 1.000
#> SRR1424702     1  0.0000      0.931 1.000 0.000
#> SRR1424703     1  0.0000      0.931 1.000 0.000
#> SRR1424704     1  0.0000      0.931 1.000 0.000
#> SRR1424706     1  0.4939      0.847 0.892 0.108
#> SRR1424707     1  0.0000      0.931 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
#> SRR1424656     1  0.0661      0.913 0.988 0.004 0.008
#> SRR1424657     1  0.0237      0.914 0.996 0.004 0.000
#> SRR1424658     1  0.0424      0.913 0.992 0.008 0.000
#> SRR1424659     1  0.2537      0.877 0.920 0.000 0.080
#> SRR1424660     3  0.3375      0.882 0.100 0.008 0.892
#> SRR1424661     1  0.6337      0.710 0.736 0.044 0.220
#> SRR1424662     2  0.6307      0.298 0.488 0.512 0.000
#> SRR1424663     1  0.4002      0.809 0.840 0.000 0.160
#> SRR1424664     1  0.1267      0.908 0.972 0.004 0.024
#> SRR1424665     1  0.0237      0.914 0.996 0.004 0.000
#> SRR1424666     3  0.0237      0.968 0.000 0.004 0.996
#> SRR1424667     2  0.2356      0.913 0.072 0.928 0.000
#> SRR1424668     3  0.0000      0.969 0.000 0.000 1.000
#> SRR1424669     2  0.3551      0.905 0.132 0.868 0.000
#> SRR1424670     1  0.0237      0.914 0.996 0.004 0.000
#> SRR1424671     2  0.0829      0.874 0.012 0.984 0.004
#> SRR1424672     3  0.0000      0.969 0.000 0.000 1.000
#> SRR1424674     1  0.0237      0.914 0.996 0.004 0.000
#> SRR1424673     3  0.1643      0.945 0.000 0.044 0.956
#> SRR1424675     2  0.1753      0.904 0.048 0.952 0.000
#> SRR1424676     2  0.3412      0.910 0.124 0.876 0.000
#> SRR1424677     2  0.0237      0.873 0.004 0.996 0.000
#> SRR1424678     2  0.2356      0.913 0.072 0.928 0.000
#> SRR1424679     2  0.2625      0.914 0.084 0.916 0.000
#> SRR1424680     2  0.3192      0.909 0.112 0.888 0.000
#> SRR1424681     3  0.0237      0.968 0.004 0.000 0.996
#> SRR1424682     3  0.0000      0.969 0.000 0.000 1.000
#> SRR1424683     2  0.5835      0.591 0.340 0.660 0.000
#> SRR1424685     3  0.4609      0.826 0.128 0.028 0.844
#> SRR1424686     3  0.0237      0.968 0.004 0.000 0.996
#> SRR1424687     2  0.5202      0.887 0.136 0.820 0.044
#> SRR1424688     1  0.1411      0.901 0.964 0.036 0.000
#> SRR1424689     2  0.3816      0.899 0.148 0.852 0.000
#> SRR1424690     1  0.0237      0.914 0.996 0.004 0.000
#> SRR1424691     1  0.5098      0.715 0.752 0.000 0.248
#> SRR1424692     2  0.1529      0.883 0.040 0.960 0.000
#> SRR1424684     2  0.3116      0.913 0.108 0.892 0.000
#> SRR1424693     1  0.4555      0.673 0.800 0.200 0.000
#> SRR1424694     1  0.2625      0.877 0.916 0.084 0.000
#> SRR1424695     1  0.1031      0.904 0.976 0.024 0.000
#> SRR1424696     2  0.4002      0.892 0.160 0.840 0.000
#> SRR1424697     3  0.0000      0.969 0.000 0.000 1.000
#> SRR1424698     3  0.0000      0.969 0.000 0.000 1.000
#> SRR1424699     2  0.2261      0.912 0.068 0.932 0.000
#> SRR1424700     2  0.2959      0.913 0.100 0.900 0.000
#> SRR1424701     2  0.3769      0.908 0.104 0.880 0.016
#> SRR1424702     3  0.0000      0.969 0.000 0.000 1.000
#> SRR1424703     3  0.0592      0.964 0.000 0.012 0.988
#> SRR1424704     3  0.0000      0.969 0.000 0.000 1.000
#> SRR1424706     3  0.3551      0.871 0.000 0.132 0.868
#> SRR1424707     3  0.0000      0.969 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
#> SRR1424656     1  0.0188     0.8845 0.996 0.000 0.000 0.004
#> SRR1424657     1  0.0336     0.8839 0.992 0.000 0.000 0.008
#> SRR1424658     1  0.0524     0.8836 0.988 0.008 0.000 0.004
#> SRR1424659     1  0.1452     0.8747 0.956 0.000 0.008 0.036
#> SRR1424660     3  0.4623     0.8410 0.012 0.060 0.812 0.116
#> SRR1424661     1  0.6384     0.0781 0.496 0.000 0.064 0.440
#> SRR1424662     1  0.3801     0.6368 0.780 0.220 0.000 0.000
#> SRR1424663     1  0.1724     0.8702 0.948 0.000 0.020 0.032
#> SRR1424664     1  0.0817     0.8822 0.976 0.000 0.000 0.024
#> SRR1424665     1  0.0188     0.8838 0.996 0.000 0.000 0.004
#> SRR1424666     3  0.3350     0.8904 0.004 0.016 0.864 0.116
#> SRR1424667     2  0.0657     0.8319 0.004 0.984 0.000 0.012
#> SRR1424668     3  0.0000     0.9544 0.000 0.000 1.000 0.000
#> SRR1424669     2  0.2773     0.7628 0.004 0.880 0.000 0.116
#> SRR1424670     1  0.0707     0.8831 0.980 0.000 0.000 0.020
#> SRR1424671     4  0.3216     0.6716 0.000 0.076 0.044 0.880
#> SRR1424672     3  0.0779     0.9495 0.004 0.000 0.980 0.016
#> SRR1424674     1  0.0336     0.8839 0.992 0.000 0.000 0.008
#> SRR1424673     3  0.0376     0.9534 0.000 0.004 0.992 0.004
#> SRR1424675     2  0.0895     0.8291 0.004 0.976 0.000 0.020
#> SRR1424676     2  0.0657     0.8319 0.004 0.984 0.000 0.012
#> SRR1424677     4  0.4761     0.3280 0.000 0.372 0.000 0.628
#> SRR1424678     2  0.0657     0.8319 0.004 0.984 0.000 0.012
#> SRR1424679     2  0.0592     0.8295 0.016 0.984 0.000 0.000
#> SRR1424680     2  0.6440     0.1281 0.080 0.564 0.000 0.356
#> SRR1424681     3  0.3043     0.8963 0.008 0.004 0.876 0.112
#> SRR1424682     3  0.0000     0.9544 0.000 0.000 1.000 0.000
#> SRR1424683     4  0.6747     0.2278 0.372 0.100 0.000 0.528
#> SRR1424685     3  0.3978     0.8775 0.016 0.032 0.848 0.104
#> SRR1424686     3  0.0895     0.9479 0.004 0.000 0.976 0.020
#> SRR1424687     2  0.5404     0.4783 0.012 0.704 0.256 0.028
#> SRR1424688     1  0.1940     0.8494 0.924 0.000 0.000 0.076
#> SRR1424689     2  0.2918     0.7650 0.008 0.876 0.000 0.116
#> SRR1424690     1  0.1022     0.8791 0.968 0.000 0.000 0.032
#> SRR1424691     1  0.3528     0.6826 0.808 0.000 0.192 0.000
#> SRR1424692     4  0.2647     0.6770 0.000 0.120 0.000 0.880
#> SRR1424684     2  0.0927     0.8281 0.016 0.976 0.000 0.008
#> SRR1424693     1  0.2867     0.8015 0.884 0.104 0.000 0.012
#> SRR1424694     1  0.4212     0.6853 0.772 0.012 0.000 0.216
#> SRR1424695     1  0.0376     0.8842 0.992 0.004 0.000 0.004
#> SRR1424696     2  0.7188     0.0850 0.244 0.552 0.000 0.204
#> SRR1424697     3  0.0000     0.9544 0.000 0.000 1.000 0.000
#> SRR1424698     3  0.0000     0.9544 0.000 0.000 1.000 0.000
#> SRR1424699     2  0.0000     0.8309 0.000 1.000 0.000 0.000
#> SRR1424700     2  0.0817     0.8238 0.000 0.976 0.000 0.024
#> SRR1424701     2  0.2011     0.7913 0.000 0.920 0.000 0.080
#> SRR1424702     3  0.0000     0.9544 0.000 0.000 1.000 0.000
#> SRR1424703     3  0.0188     0.9536 0.000 0.004 0.996 0.000
#> SRR1424704     3  0.0000     0.9544 0.000 0.000 1.000 0.000
#> SRR1424706     3  0.1389     0.9301 0.000 0.048 0.952 0.000
#> SRR1424707     3  0.0524     0.9531 0.000 0.004 0.988 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
#> SRR1424656     1  0.0566     0.8390 0.984 0.000 0.000 0.004 0.012
#> SRR1424657     1  0.1740     0.8325 0.932 0.000 0.000 0.012 0.056
#> SRR1424658     1  0.1864     0.8340 0.924 0.004 0.000 0.004 0.068
#> SRR1424659     1  0.1282     0.8354 0.952 0.000 0.004 0.000 0.044
#> SRR1424660     5  0.6168     0.1137 0.044 0.064 0.312 0.000 0.580
#> SRR1424661     4  0.5677     0.5493 0.244 0.000 0.068 0.656 0.032
#> SRR1424662     1  0.5303     0.5596 0.660 0.232 0.000 0.000 0.108
#> SRR1424663     1  0.2193     0.8046 0.900 0.000 0.008 0.000 0.092
#> SRR1424664     1  0.0703     0.8376 0.976 0.000 0.000 0.000 0.024
#> SRR1424665     1  0.1168     0.8367 0.960 0.000 0.000 0.008 0.032
#> SRR1424666     3  0.4522     0.2022 0.008 0.000 0.552 0.000 0.440
#> SRR1424667     2  0.2249     0.6593 0.000 0.896 0.000 0.008 0.096
#> SRR1424668     3  0.1942     0.6715 0.012 0.000 0.920 0.000 0.068
#> SRR1424669     5  0.4533     0.0372 0.008 0.448 0.000 0.000 0.544
#> SRR1424670     1  0.0794     0.8375 0.972 0.000 0.000 0.000 0.028
#> SRR1424671     4  0.0992     0.7809 0.000 0.024 0.000 0.968 0.008
#> SRR1424672     3  0.3916     0.5231 0.012 0.000 0.732 0.000 0.256
#> SRR1424674     1  0.2722     0.8131 0.872 0.000 0.000 0.020 0.108
#> SRR1424673     3  0.0162     0.6924 0.000 0.000 0.996 0.000 0.004
#> SRR1424675     2  0.1041     0.6995 0.000 0.964 0.000 0.032 0.004
#> SRR1424676     2  0.0404     0.7003 0.000 0.988 0.000 0.000 0.012
#> SRR1424677     4  0.3388     0.6550 0.000 0.200 0.000 0.792 0.008
#> SRR1424678     2  0.0955     0.6947 0.000 0.968 0.000 0.004 0.028
#> SRR1424679     2  0.0162     0.7000 0.000 0.996 0.000 0.004 0.000
#> SRR1424680     2  0.5818     0.3642 0.016 0.592 0.000 0.316 0.076
#> SRR1424681     3  0.4576     0.3323 0.016 0.000 0.608 0.000 0.376
#> SRR1424682     3  0.2891     0.6120 0.000 0.000 0.824 0.000 0.176
#> SRR1424683     4  0.4023     0.7643 0.092 0.076 0.000 0.816 0.016
#> SRR1424685     3  0.5588     0.2807 0.048 0.016 0.572 0.000 0.364
#> SRR1424686     3  0.4553     0.4285 0.016 0.000 0.652 0.004 0.328
#> SRR1424687     2  0.7689    -0.3629 0.020 0.344 0.316 0.016 0.304
#> SRR1424688     1  0.3759     0.7798 0.816 0.000 0.000 0.092 0.092
#> SRR1424689     2  0.4306     0.3076 0.000 0.660 0.000 0.012 0.328
#> SRR1424690     1  0.2237     0.8318 0.904 0.000 0.008 0.004 0.084
#> SRR1424691     1  0.5226     0.3595 0.572 0.000 0.376 0.000 0.052
#> SRR1424692     4  0.1750     0.7836 0.000 0.028 0.000 0.936 0.036
#> SRR1424684     2  0.1597     0.6927 0.000 0.940 0.000 0.012 0.048
#> SRR1424693     1  0.5527     0.5757 0.656 0.232 0.000 0.008 0.104
#> SRR1424694     1  0.5147     0.6492 0.692 0.004 0.000 0.208 0.096
#> SRR1424695     1  0.2946     0.8044 0.868 0.044 0.000 0.000 0.088
#> SRR1424696     2  0.6678     0.4379 0.108 0.616 0.000 0.176 0.100
#> SRR1424697     3  0.3430     0.6425 0.000 0.000 0.776 0.004 0.220
#> SRR1424698     3  0.2329     0.6839 0.000 0.000 0.876 0.000 0.124
#> SRR1424699     2  0.2969     0.6526 0.000 0.852 0.000 0.020 0.128
#> SRR1424700     2  0.3194     0.6388 0.000 0.832 0.000 0.020 0.148
#> SRR1424701     2  0.6041     0.3550 0.000 0.604 0.104 0.020 0.272
#> SRR1424702     3  0.2561     0.6790 0.000 0.000 0.856 0.000 0.144
#> SRR1424703     3  0.3819     0.6304 0.000 0.000 0.756 0.016 0.228
#> SRR1424704     3  0.0000     0.6919 0.000 0.000 1.000 0.000 0.000
#> SRR1424706     3  0.3858     0.6305 0.000 0.008 0.760 0.008 0.224
#> SRR1424707     3  0.2864     0.6779 0.000 0.000 0.852 0.012 0.136

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR1424656     1  0.2212     0.6600 0.880 0.000 0.000 0.000 0.112 0.008
#> SRR1424657     1  0.3717     0.5840 0.708 0.000 0.000 0.000 0.276 0.016
#> SRR1424658     1  0.4239     0.6213 0.740 0.052 0.000 0.000 0.192 0.016
#> SRR1424659     1  0.0935     0.6611 0.964 0.000 0.004 0.000 0.000 0.032
#> SRR1424660     6  0.5041     0.5038 0.036 0.072 0.084 0.000 0.060 0.748
#> SRR1424661     4  0.3822     0.7093 0.112 0.000 0.064 0.804 0.004 0.016
#> SRR1424662     1  0.4407     0.5462 0.772 0.092 0.000 0.004 0.040 0.092
#> SRR1424663     1  0.3323     0.6177 0.836 0.000 0.032 0.000 0.028 0.104
#> SRR1424664     1  0.0622     0.6633 0.980 0.000 0.000 0.000 0.008 0.012
#> SRR1424665     1  0.2902     0.6325 0.800 0.000 0.000 0.000 0.196 0.004
#> SRR1424666     6  0.4131     0.0199 0.004 0.004 0.388 0.000 0.004 0.600
#> SRR1424667     2  0.3582     0.6319 0.000 0.776 0.000 0.008 0.024 0.192
#> SRR1424668     3  0.3432     0.5677 0.000 0.000 0.800 0.000 0.052 0.148
#> SRR1424669     6  0.3758     0.4815 0.024 0.232 0.000 0.000 0.004 0.740
#> SRR1424670     1  0.1391     0.6574 0.944 0.000 0.000 0.000 0.016 0.040
#> SRR1424671     4  0.0260     0.8314 0.000 0.000 0.000 0.992 0.008 0.000
#> SRR1424672     3  0.3724     0.4652 0.004 0.000 0.716 0.000 0.012 0.268
#> SRR1424674     1  0.5805     0.3338 0.456 0.004 0.004 0.008 0.424 0.104
#> SRR1424673     3  0.1075     0.6224 0.000 0.000 0.952 0.000 0.000 0.048
#> SRR1424675     2  0.1630     0.7777 0.000 0.940 0.000 0.020 0.016 0.024
#> SRR1424676     2  0.1151     0.7733 0.000 0.956 0.000 0.000 0.012 0.032
#> SRR1424677     4  0.3801     0.7702 0.000 0.132 0.008 0.804 0.024 0.032
#> SRR1424678     2  0.1267     0.7655 0.000 0.940 0.000 0.000 0.000 0.060
#> SRR1424679     2  0.0260     0.7772 0.000 0.992 0.000 0.000 0.000 0.008
#> SRR1424680     2  0.4898     0.6401 0.008 0.716 0.000 0.180 0.044 0.052
#> SRR1424681     3  0.4888     0.1688 0.052 0.000 0.536 0.000 0.004 0.408
#> SRR1424682     3  0.3052     0.5379 0.000 0.000 0.780 0.000 0.004 0.216
#> SRR1424683     4  0.3005     0.8140 0.036 0.088 0.000 0.860 0.004 0.012
#> SRR1424685     3  0.6580     0.0577 0.160 0.028 0.472 0.000 0.016 0.324
#> SRR1424686     3  0.5679     0.3353 0.004 0.000 0.572 0.004 0.228 0.192
#> SRR1424687     6  0.8645     0.3203 0.156 0.260 0.192 0.004 0.084 0.304
#> SRR1424688     1  0.6426     0.2923 0.440 0.016 0.000 0.064 0.412 0.068
#> SRR1424689     6  0.5501     0.1348 0.000 0.336 0.000 0.000 0.144 0.520
#> SRR1424690     1  0.6281     0.4361 0.536 0.016 0.024 0.000 0.280 0.144
#> SRR1424691     3  0.6444     0.2035 0.304 0.000 0.504 0.000 0.112 0.080
#> SRR1424692     4  0.1434     0.8208 0.000 0.000 0.000 0.940 0.048 0.012
#> SRR1424684     2  0.1483     0.7695 0.000 0.944 0.000 0.008 0.012 0.036
#> SRR1424693     1  0.6849     0.1122 0.436 0.348 0.000 0.004 0.108 0.104
#> SRR1424694     5  0.7190    -0.4678 0.336 0.008 0.000 0.252 0.344 0.060
#> SRR1424695     1  0.4999     0.5448 0.720 0.112 0.000 0.004 0.120 0.044
#> SRR1424696     2  0.5527     0.6326 0.024 0.700 0.000 0.120 0.088 0.068
#> SRR1424697     3  0.3847     0.5636 0.008 0.000 0.748 0.004 0.220 0.020
#> SRR1424698     3  0.2377     0.6117 0.000 0.000 0.868 0.004 0.124 0.004
#> SRR1424699     2  0.4590     0.5360 0.000 0.668 0.008 0.000 0.268 0.056
#> SRR1424700     2  0.4874     0.5070 0.000 0.636 0.008 0.000 0.284 0.072
#> SRR1424701     5  0.7163    -0.3250 0.000 0.320 0.228 0.000 0.364 0.088
#> SRR1424702     3  0.1858     0.6230 0.000 0.000 0.904 0.000 0.092 0.004
#> SRR1424703     3  0.4193     0.4361 0.000 0.000 0.624 0.000 0.352 0.024
#> SRR1424704     3  0.1141     0.6216 0.000 0.000 0.948 0.000 0.000 0.052
#> SRR1424706     3  0.4579     0.4779 0.000 0.008 0.652 0.004 0.300 0.036
#> SRR1424707     3  0.3156     0.5918 0.000 0.000 0.800 0.000 0.180 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-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