cola Report for recount2:ERP005938

Date: 2019-12-25 22:26:22 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 18140 rows and 52 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] 18140    52

Density distribution

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

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

plot of chunk density-heatmap

Suggest the best k

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

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

suggest_best_k(res_list)
The best k 1-PAC Mean silhouette Concordance Optional k
SD:hclust 2 1.000 1.000 1.000 **
SD:kmeans 2 1.000 0.971 0.973 **
SD:mclust 2 1.000 1.000 1.000 **
CV:hclust 2 1.000 0.998 0.999 **
CV:kmeans 2 1.000 1.000 1.000 **
CV:pam 2 1.000 0.991 0.996 **
MAD:hclust 2 1.000 1.000 1.000 **
MAD:mclust 2 1.000 0.998 0.999 **
ATC:hclust 2 1.000 1.000 1.000 **
ATC:skmeans 2 1.000 0.992 0.996 **
CV:mclust 2 0.962 0.950 0.980 **
ATC:kmeans 3 0.962 0.949 0.980 ** 2
CV:skmeans 2 0.960 0.936 0.975 **
MAD:skmeans 2 0.959 0.953 0.980 **
ATC:pam 5 0.918 0.874 0.956 * 2,3,4
CV:NMF 2 0.910 0.905 0.961 *
SD:pam 4 0.906 0.890 0.954 * 2
SD:skmeans 3 0.889 0.889 0.947
MAD:pam 5 0.808 0.883 0.927
MAD:NMF 2 0.737 0.884 0.951
SD:NMF 2 0.701 0.882 0.946
ATC:NMF 2 0.633 0.810 0.915
ATC:mclust 4 0.570 0.854 0.872
MAD:kmeans 2 0.483 0.817 0.836

**: 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.701           0.882       0.946          0.457 0.538   0.538
#> CV:NMF      2 0.910           0.905       0.961          0.398 0.618   0.618
#> MAD:NMF     2 0.737           0.884       0.951          0.505 0.491   0.491
#> ATC:NMF     2 0.633           0.810       0.915          0.476 0.502   0.502
#> SD:skmeans  2 0.687           0.876       0.942          0.464 0.551   0.551
#> CV:skmeans  2 0.960           0.936       0.975          0.406 0.599   0.599
#> MAD:skmeans 2 0.959           0.953       0.980          0.504 0.497   0.497
#> ATC:skmeans 2 1.000           0.992       0.996          0.497 0.502   0.502
#> SD:mclust   2 1.000           1.000       1.000          0.112 0.889   0.889
#> CV:mclust   2 0.962           0.950       0.980          0.291 0.708   0.708
#> MAD:mclust  2 1.000           0.998       0.999          0.114 0.889   0.889
#> ATC:mclust  2 0.743           0.929       0.957          0.291 0.708   0.708
#> SD:kmeans   2 1.000           0.971       0.973          0.135 0.889   0.889
#> CV:kmeans   2 1.000           1.000       1.000          0.238 0.762   0.762
#> MAD:kmeans  2 0.483           0.817       0.836          0.374 0.502   0.502
#> ATC:kmeans  2 1.000           1.000       1.000          0.112 0.889   0.889
#> SD:pam      2 1.000           1.000       1.000          0.112 0.889   0.889
#> CV:pam      2 1.000           0.991       0.996          0.215 0.792   0.792
#> MAD:pam     2 0.705           0.943       0.940          0.157 0.889   0.889
#> ATC:pam     2 1.000           1.000       1.000          0.112 0.889   0.889
#> SD:hclust   2 1.000           1.000       1.000          0.112 0.889   0.889
#> CV:hclust   2 1.000           0.998       0.999          0.238 0.762   0.762
#> MAD:hclust  2 1.000           1.000       1.000          0.112 0.889   0.889
#> ATC:hclust  2 1.000           1.000       1.000          0.112 0.889   0.889
get_stats(res_list, k = 3)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      3 0.450           0.590       0.805         0.4035 0.619   0.394
#> CV:NMF      3 0.466           0.645       0.829         0.5575 0.716   0.549
#> MAD:NMF     3 0.528           0.764       0.867         0.3154 0.718   0.487
#> ATC:NMF     3 0.407           0.633       0.790         0.3014 0.813   0.645
#> SD:skmeans  3 0.889           0.889       0.947         0.4545 0.744   0.546
#> CV:skmeans  3 0.590           0.627       0.776         0.4539 0.673   0.489
#> MAD:skmeans 3 0.790           0.874       0.929         0.3285 0.787   0.592
#> ATC:skmeans 3 0.728           0.487       0.780         0.3102 0.922   0.844
#> SD:mclust   3 0.344           0.664       0.804         2.8877 0.706   0.669
#> CV:mclust   3 0.350           0.316       0.686         0.7175 0.630   0.508
#> MAD:mclust  3 0.322           0.473       0.733         3.3337 0.548   0.491
#> ATC:mclust  3 0.481           0.755       0.879         0.5619 0.882   0.837
#> SD:kmeans   3 0.799           0.908       0.954         2.1147 0.729   0.695
#> CV:kmeans   3 0.448           0.681       0.803         1.1225 0.736   0.654
#> MAD:kmeans  3 0.615           0.803       0.909         0.3684 0.642   0.457
#> ATC:kmeans  3 0.962           0.949       0.980         4.0272 0.549   0.493
#> SD:pam      3 0.635           0.909       0.950         2.7266 0.729   0.695
#> CV:pam      3 0.964           0.882       0.969         0.2477 0.966   0.957
#> MAD:pam     3 0.627           0.844       0.921         1.9545 0.706   0.669
#> ATC:pam     3 1.000           0.986       0.995         3.9513 0.557   0.501
#> SD:hclust   3 0.649           0.872       0.938         2.6062 0.706   0.669
#> CV:hclust   3 1.000           0.979       0.999         0.0259 0.995   0.994
#> MAD:hclust  3 0.429           0.609       0.768         3.2726 0.729   0.695
#> ATC:hclust  3 0.669           0.838       0.921         3.8080 0.563   0.508
get_stats(res_list, k = 4)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      4 0.440           0.594       0.741         0.1449 0.825   0.538
#> CV:NMF      4 0.628           0.625       0.832         0.1428 0.883   0.698
#> MAD:NMF     4 0.576           0.657       0.812         0.1295 0.835   0.551
#> ATC:NMF     4 0.365           0.510       0.730         0.1116 0.865   0.664
#> SD:skmeans  4 0.871           0.809       0.911         0.0887 0.908   0.732
#> CV:skmeans  4 0.539           0.522       0.759         0.1523 0.722   0.425
#> MAD:skmeans 4 0.705           0.787       0.874         0.1113 0.908   0.732
#> ATC:skmeans 4 0.647           0.557       0.722         0.0984 0.744   0.445
#> SD:mclust   4 0.475           0.826       0.849         0.4174 0.767   0.623
#> CV:mclust   4 0.264           0.592       0.736         0.0516 0.623   0.484
#> MAD:mclust  4 0.603           0.790       0.866         0.3488 0.687   0.406
#> ATC:mclust  4 0.570           0.854       0.872         0.4551 0.643   0.444
#> SD:kmeans   4 0.821           0.860       0.933         0.5959 0.701   0.516
#> CV:kmeans   4 0.470           0.638       0.817         0.1765 0.795   0.628
#> MAD:kmeans  4 0.747           0.753       0.893         0.3384 0.677   0.410
#> ATC:kmeans  4 0.678           0.805       0.880         0.2222 0.824   0.618
#> SD:pam      4 0.906           0.890       0.954         0.5386 0.705   0.537
#> CV:pam      4 0.663           0.894       0.944         0.3629 0.905   0.875
#> MAD:pam     4 0.724           0.882       0.929         0.4021 0.753   0.590
#> ATC:pam     4 1.000           0.950       0.983         0.1277 0.926   0.834
#> SD:hclust   4 0.573           0.803       0.880         0.2413 0.984   0.973
#> CV:hclust   4 0.576           0.611       0.869         0.5020 0.967   0.956
#> MAD:hclust  4 0.420           0.652       0.749         0.3494 0.686   0.498
#> ATC:hclust  4 0.569           0.687       0.808         0.1560 1.000   1.000
get_stats(res_list, k = 5)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      5 0.526           0.472       0.724         0.0629 0.921   0.703
#> CV:NMF      5 0.577           0.542       0.712         0.0681 0.943   0.825
#> MAD:NMF     5 0.592           0.563       0.761         0.0598 0.897   0.625
#> ATC:NMF     5 0.388           0.386       0.615         0.0599 0.918   0.762
#> SD:skmeans  5 0.749           0.703       0.852         0.0829 0.888   0.614
#> CV:skmeans  5 0.667           0.685       0.829         0.1119 0.827   0.553
#> MAD:skmeans 5 0.680           0.616       0.792         0.0672 0.917   0.699
#> ATC:skmeans 5 0.679           0.664       0.827         0.0668 0.903   0.652
#> SD:mclust   5 0.528           0.764       0.840         0.0915 0.928   0.833
#> CV:mclust   5 0.345           0.452       0.739         0.1320 0.780   0.673
#> MAD:mclust  5 0.546           0.644       0.779         0.0850 0.955   0.851
#> ATC:mclust  5 0.659           0.504       0.756         0.0430 0.686   0.331
#> SD:kmeans   5 0.657           0.559       0.762         0.1140 0.922   0.764
#> CV:kmeans   5 0.476           0.471       0.714         0.1447 0.905   0.766
#> MAD:kmeans  5 0.619           0.649       0.793         0.1117 0.863   0.597
#> ATC:kmeans  5 0.696           0.694       0.808         0.0798 0.959   0.869
#> SD:pam      5 0.787           0.813       0.911         0.1495 0.894   0.715
#> CV:pam      5 0.488           0.628       0.857         0.3178 0.934   0.901
#> MAD:pam     5 0.808           0.883       0.927         0.1949 0.760   0.421
#> ATC:pam     5 0.918           0.874       0.956         0.2095 0.807   0.523
#> SD:hclust   5 0.571           0.730       0.854         0.3777 0.729   0.531
#> CV:hclust   5 0.468           0.725       0.817         0.1292 1.000   1.000
#> MAD:hclust  5 0.611           0.626       0.782         0.1801 0.843   0.548
#> ATC:hclust  5 0.800           0.825       0.908         0.1423 0.814   0.597
get_stats(res_list, k = 6)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      6 0.593           0.458       0.700         0.0345 0.914   0.650
#> CV:NMF      6 0.630           0.551       0.751         0.0492 0.824   0.466
#> MAD:NMF     6 0.650           0.551       0.747         0.0341 0.931   0.694
#> ATC:NMF     6 0.423           0.375       0.595         0.0781 0.814   0.460
#> SD:skmeans  6 0.798           0.669       0.824         0.0460 0.938   0.710
#> CV:skmeans  6 0.715           0.696       0.794         0.0530 0.926   0.727
#> MAD:skmeans 6 0.719           0.590       0.738         0.0431 0.914   0.626
#> ATC:skmeans 6 0.695           0.546       0.761         0.0402 0.965   0.842
#> SD:mclust   6 0.540           0.667       0.728         0.1486 0.720   0.343
#> CV:mclust   6 0.331           0.409       0.697         0.1467 0.723   0.492
#> MAD:mclust  6 0.581           0.478       0.746         0.0637 0.867   0.556
#> ATC:mclust  6 0.639           0.576       0.779         0.1259 0.783   0.421
#> SD:kmeans   6 0.651           0.508       0.701         0.0593 0.860   0.531
#> CV:kmeans   6 0.477           0.581       0.755         0.0919 0.856   0.584
#> MAD:kmeans  6 0.721           0.626       0.785         0.0587 0.915   0.661
#> ATC:kmeans  6 0.691           0.563       0.764         0.0548 0.961   0.856
#> SD:pam      6 0.807           0.767       0.881         0.1021 0.852   0.516
#> CV:pam      6 0.502           0.432       0.752         0.1338 0.748   0.614
#> MAD:pam     6 0.855           0.853       0.923         0.0425 0.962   0.832
#> ATC:pam     6 0.878           0.842       0.953         0.0190 0.986   0.942
#> SD:hclust   6 0.596           0.632       0.816         0.0826 0.928   0.767
#> CV:hclust   6 0.496           0.695       0.819         0.0470 0.962   0.947
#> MAD:hclust  6 0.660           0.682       0.762         0.0290 0.975   0.887
#> ATC:hclust  6 0.779           0.764       0.885         0.0442 0.987   0.955

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 18140 rows and 52 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 1.000           1.000       1.000         0.1117 0.889   0.889
#> 3 3 0.649           0.872       0.938         2.6062 0.706   0.669
#> 4 4 0.573           0.803       0.880         0.2413 0.984   0.973
#> 5 5 0.571           0.730       0.854         0.3777 0.729   0.531
#> 6 6 0.596           0.632       0.816         0.0826 0.928   0.767

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
#> ERR519515     1       0          1  1  0
#> ERR519516     1       0          1  1  0
#> ERR519520     1       0          1  1  0
#> ERR519513     1       0          1  1  0
#> ERR519481     1       0          1  1  0
#> ERR519491     1       0          1  1  0
#> ERR519473     1       0          1  1  0
#> ERR519518     1       0          1  1  0
#> ERR519512     1       0          1  1  0
#> ERR519521     1       0          1  1  0
#> ERR519488     1       0          1  1  0
#> ERR519493     1       0          1  1  0
#> ERR519514     1       0          1  1  0
#> ERR519479     1       0          1  1  0
#> ERR519509     1       0          1  1  0
#> ERR519472     1       0          1  1  0
#> ERR519510     1       0          1  1  0
#> ERR519470     1       0          1  1  0
#> ERR519495     1       0          1  1  0
#> ERR519522     1       0          1  1  0
#> ERR519523     1       0          1  1  0
#> ERR519503     1       0          1  1  0
#> ERR519471     1       0          1  1  0
#> ERR519500     1       0          1  1  0
#> ERR519485     1       0          1  1  0
#> ERR519476     2       0          1  0  1
#> ERR519502     1       0          1  1  0
#> ERR519486     1       0          1  1  0
#> ERR519478     1       0          1  1  0
#> ERR519497     1       0          1  1  0
#> ERR519467     1       0          1  1  0
#> ERR519489     1       0          1  1  0
#> ERR519494     1       0          1  1  0
#> ERR519474     1       0          1  1  0
#> ERR519505     1       0          1  1  0
#> ERR519517     1       0          1  1  0
#> ERR519484     1       0          1  1  0
#> ERR519498     1       0          1  1  0
#> ERR519490     1       0          1  1  0
#> ERR519507     1       0          1  1  0
#> ERR519511     1       0          1  1  0
#> ERR519468     1       0          1  1  0
#> ERR519482     1       0          1  1  0
#> ERR519475     2       0          1  0  1
#> ERR519496     1       0          1  1  0
#> ERR519506     1       0          1  1  0
#> ERR519469     1       0          1  1  0
#> ERR519480     1       0          1  1  0
#> ERR519487     1       0          1  1  0
#> ERR519483     1       0          1  1  0
#> ERR519477     2       0          1  0  1
#> ERR519499     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
#> ERR519515     1  0.0000     0.9334 1.000  0 0.000
#> ERR519516     1  0.0237     0.9333 0.996  0 0.004
#> ERR519520     1  0.0000     0.9334 1.000  0 0.000
#> ERR519513     1  0.3412     0.9013 0.876  0 0.124
#> ERR519481     1  0.3412     0.9002 0.876  0 0.124
#> ERR519491     1  0.0237     0.9333 0.996  0 0.004
#> ERR519473     1  0.3551     0.8962 0.868  0 0.132
#> ERR519518     1  0.2796     0.9136 0.908  0 0.092
#> ERR519512     1  0.0000     0.9334 1.000  0 0.000
#> ERR519521     1  0.0000     0.9334 1.000  0 0.000
#> ERR519488     1  0.0000     0.9334 1.000  0 0.000
#> ERR519493     1  0.0237     0.9333 0.996  0 0.004
#> ERR519514     1  0.0000     0.9334 1.000  0 0.000
#> ERR519479     1  0.3551     0.8962 0.868  0 0.132
#> ERR519509     1  0.0000     0.9334 1.000  0 0.000
#> ERR519472     1  0.3482     0.8993 0.872  0 0.128
#> ERR519510     1  0.3412     0.9002 0.876  0 0.124
#> ERR519470     1  0.0000     0.9334 1.000  0 0.000
#> ERR519495     1  0.2448     0.9196 0.924  0 0.076
#> ERR519522     1  0.0000     0.9334 1.000  0 0.000
#> ERR519523     1  0.0000     0.9334 1.000  0 0.000
#> ERR519503     3  0.6308     0.0642 0.492  0 0.508
#> ERR519471     1  0.0000     0.9334 1.000  0 0.000
#> ERR519500     1  0.0237     0.9333 0.996  0 0.004
#> ERR519485     1  0.0892     0.9288 0.980  0 0.020
#> ERR519476     2  0.0000     1.0000 0.000  1 0.000
#> ERR519502     1  0.3412     0.9002 0.876  0 0.124
#> ERR519486     1  0.0892     0.9288 0.980  0 0.020
#> ERR519478     1  0.0000     0.9334 1.000  0 0.000
#> ERR519497     1  0.2796     0.9136 0.908  0 0.092
#> ERR519467     1  0.0000     0.9334 1.000  0 0.000
#> ERR519489     1  0.0237     0.9333 0.996  0 0.004
#> ERR519494     3  0.1860     0.7376 0.052  0 0.948
#> ERR519474     1  0.0237     0.9333 0.996  0 0.004
#> ERR519505     1  0.3482     0.8992 0.872  0 0.128
#> ERR519517     3  0.0000     0.7629 0.000  0 1.000
#> ERR519484     1  0.4002     0.8701 0.840  0 0.160
#> ERR519498     1  0.3412     0.9013 0.876  0 0.124
#> ERR519490     3  0.0000     0.7629 0.000  0 1.000
#> ERR519507     1  0.3551     0.8962 0.868  0 0.132
#> ERR519511     1  0.3412     0.9002 0.876  0 0.124
#> ERR519468     1  0.3816     0.8829 0.852  0 0.148
#> ERR519482     3  0.0000     0.7629 0.000  0 1.000
#> ERR519475     2  0.0000     1.0000 0.000  1 0.000
#> ERR519496     1  0.0000     0.9334 1.000  0 0.000
#> ERR519506     3  0.5254     0.5787 0.264  0 0.736
#> ERR519469     1  0.3816     0.8829 0.852  0 0.148
#> ERR519480     3  0.0000     0.7629 0.000  0 1.000
#> ERR519487     3  0.0000     0.7629 0.000  0 1.000
#> ERR519483     3  0.5254     0.5787 0.264  0 0.736
#> ERR519477     2  0.0000     1.0000 0.000  1 0.000
#> ERR519499     3  0.0000     0.7629 0.000  0 1.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1 p2    p3    p4
#> ERR519515     1  0.3801      0.723 0.780  0 0.000 0.220
#> ERR519516     1  0.3726      0.732 0.788  0 0.000 0.212
#> ERR519520     1  0.0188      0.820 0.996  0 0.000 0.004
#> ERR519513     1  0.3099      0.805 0.876  0 0.020 0.104
#> ERR519481     1  0.2988      0.803 0.876  0 0.012 0.112
#> ERR519491     1  0.3726      0.732 0.788  0 0.000 0.212
#> ERR519473     1  0.3161      0.801 0.864  0 0.012 0.124
#> ERR519518     1  0.2412      0.813 0.908  0 0.008 0.084
#> ERR519512     1  0.0188      0.820 0.996  0 0.000 0.004
#> ERR519521     1  0.0000      0.820 1.000  0 0.000 0.000
#> ERR519488     1  0.4193      0.658 0.732  0 0.000 0.268
#> ERR519493     1  0.3726      0.732 0.788  0 0.000 0.212
#> ERR519514     1  0.3801      0.723 0.780  0 0.000 0.220
#> ERR519479     1  0.3161      0.801 0.864  0 0.012 0.124
#> ERR519509     1  0.4193      0.658 0.732  0 0.000 0.268
#> ERR519472     1  0.3105      0.804 0.868  0 0.012 0.120
#> ERR519510     1  0.2988      0.803 0.876  0 0.012 0.112
#> ERR519470     1  0.3801      0.723 0.780  0 0.000 0.220
#> ERR519495     1  0.2675      0.821 0.892  0 0.008 0.100
#> ERR519522     1  0.1474      0.812 0.948  0 0.000 0.052
#> ERR519523     1  0.0336      0.820 0.992  0 0.000 0.008
#> ERR519503     4  0.4542      0.569 0.228  0 0.020 0.752
#> ERR519471     1  0.3801      0.723 0.780  0 0.000 0.220
#> ERR519500     1  0.1118      0.817 0.964  0 0.000 0.036
#> ERR519485     1  0.4088      0.717 0.764  0 0.004 0.232
#> ERR519476     2  0.0000      1.000 0.000  1 0.000 0.000
#> ERR519502     1  0.2988      0.803 0.876  0 0.012 0.112
#> ERR519486     1  0.4088      0.717 0.764  0 0.004 0.232
#> ERR519478     1  0.3801      0.723 0.780  0 0.000 0.220
#> ERR519497     1  0.2412      0.813 0.908  0 0.008 0.084
#> ERR519467     1  0.1474      0.812 0.948  0 0.000 0.052
#> ERR519489     1  0.1118      0.817 0.964  0 0.000 0.036
#> ERR519494     3  0.4127      0.711 0.052  0 0.824 0.124
#> ERR519474     1  0.1389      0.816 0.952  0 0.000 0.048
#> ERR519505     1  0.3160      0.804 0.872  0 0.020 0.108
#> ERR519517     3  0.0000      0.956 0.000  0 1.000 0.000
#> ERR519484     1  0.3787      0.778 0.840  0 0.036 0.124
#> ERR519498     1  0.3099      0.805 0.876  0 0.020 0.104
#> ERR519490     3  0.0000      0.956 0.000  0 1.000 0.000
#> ERR519507     1  0.3161      0.801 0.864  0 0.012 0.124
#> ERR519511     1  0.2988      0.803 0.876  0 0.012 0.112
#> ERR519468     1  0.3542      0.791 0.852  0 0.028 0.120
#> ERR519482     3  0.0000      0.956 0.000  0 1.000 0.000
#> ERR519475     2  0.0000      1.000 0.000  1 0.000 0.000
#> ERR519496     1  0.3801      0.723 0.780  0 0.000 0.220
#> ERR519506     4  0.0707      0.737 0.000  0 0.020 0.980
#> ERR519469     1  0.3497      0.791 0.852  0 0.024 0.124
#> ERR519480     3  0.0000      0.956 0.000  0 1.000 0.000
#> ERR519487     3  0.0000      0.956 0.000  0 1.000 0.000
#> ERR519483     4  0.0707      0.737 0.000  0 0.020 0.980
#> ERR519477     2  0.0000      1.000 0.000  1 0.000 0.000
#> ERR519499     3  0.0000      0.956 0.000  0 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1 p2    p3    p4    p5
#> ERR519515     1  0.1043      0.813 0.960  0 0.000 0.040 0.000
#> ERR519516     1  0.3242      0.756 0.784  0 0.000 0.216 0.000
#> ERR519520     4  0.4689      0.203 0.424  0 0.000 0.560 0.016
#> ERR519513     4  0.3274      0.670 0.000  0 0.000 0.780 0.220
#> ERR519481     4  0.0794      0.776 0.028  0 0.000 0.972 0.000
#> ERR519491     1  0.3242      0.756 0.784  0 0.000 0.216 0.000
#> ERR519473     4  0.0955      0.775 0.028  0 0.000 0.968 0.004
#> ERR519518     4  0.1626      0.773 0.044  0 0.000 0.940 0.016
#> ERR519512     4  0.4689      0.203 0.424  0 0.000 0.560 0.016
#> ERR519521     4  0.2966      0.717 0.136  0 0.000 0.848 0.016
#> ERR519488     1  0.0609      0.738 0.980  0 0.000 0.000 0.020
#> ERR519493     1  0.3242      0.756 0.784  0 0.000 0.216 0.000
#> ERR519514     1  0.1043      0.813 0.960  0 0.000 0.040 0.000
#> ERR519479     4  0.1892      0.765 0.080  0 0.000 0.916 0.004
#> ERR519509     1  0.0609      0.738 0.980  0 0.000 0.000 0.020
#> ERR519472     4  0.1041      0.775 0.032  0 0.000 0.964 0.004
#> ERR519510     4  0.2761      0.752 0.024  0 0.000 0.872 0.104
#> ERR519470     1  0.1043      0.813 0.960  0 0.000 0.040 0.000
#> ERR519495     4  0.3231      0.678 0.196  0 0.000 0.800 0.004
#> ERR519522     1  0.3421      0.703 0.788  0 0.000 0.204 0.008
#> ERR519523     4  0.4696      0.190 0.428  0 0.000 0.556 0.016
#> ERR519503     5  0.4256      0.590 0.436  0 0.000 0.000 0.564
#> ERR519471     1  0.1043      0.813 0.960  0 0.000 0.040 0.000
#> ERR519500     4  0.4138      0.335 0.384  0 0.000 0.616 0.000
#> ERR519485     1  0.3710      0.762 0.784  0 0.000 0.192 0.024
#> ERR519476     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> ERR519502     4  0.0794      0.776 0.028  0 0.000 0.972 0.000
#> ERR519486     1  0.3710      0.762 0.784  0 0.000 0.192 0.024
#> ERR519478     1  0.1205      0.812 0.956  0 0.000 0.040 0.004
#> ERR519497     4  0.2054      0.775 0.052  0 0.000 0.920 0.028
#> ERR519467     1  0.3642      0.682 0.760  0 0.000 0.232 0.008
#> ERR519489     4  0.4060      0.382 0.360  0 0.000 0.640 0.000
#> ERR519494     3  0.3282      0.694 0.000  0 0.804 0.188 0.008
#> ERR519474     4  0.4171      0.309 0.396  0 0.000 0.604 0.000
#> ERR519505     4  0.4210      0.650 0.036  0 0.000 0.740 0.224
#> ERR519517     3  0.0000      0.952 0.000  0 1.000 0.000 0.000
#> ERR519484     4  0.2959      0.736 0.008  0 0.016 0.864 0.112
#> ERR519498     4  0.2006      0.765 0.012  0 0.000 0.916 0.072
#> ERR519490     3  0.0000      0.952 0.000  0 1.000 0.000 0.000
#> ERR519507     4  0.1892      0.765 0.080  0 0.000 0.916 0.004
#> ERR519511     4  0.2761      0.752 0.024  0 0.000 0.872 0.104
#> ERR519468     4  0.3455      0.665 0.000  0 0.008 0.784 0.208
#> ERR519482     3  0.0000      0.952 0.000  0 1.000 0.000 0.000
#> ERR519475     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> ERR519496     1  0.2127      0.805 0.892  0 0.000 0.108 0.000
#> ERR519506     5  0.3789      0.794 0.212  0 0.000 0.020 0.768
#> ERR519469     4  0.3333      0.666 0.000  0 0.004 0.788 0.208
#> ERR519480     3  0.0162      0.949 0.000  0 0.996 0.000 0.004
#> ERR519487     3  0.0000      0.952 0.000  0 1.000 0.000 0.000
#> ERR519483     5  0.3789      0.794 0.212  0 0.000 0.020 0.768
#> ERR519477     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> ERR519499     3  0.0000      0.952 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
#> ERR519515     1  0.1141     0.8091 0.948  0 0.000 0.000 0.052 0.000
#> ERR519516     1  0.4088     0.6595 0.668  0 0.000 0.020 0.308 0.004
#> ERR519520     5  0.4332     0.3940 0.288  0 0.000 0.048 0.664 0.000
#> ERR519513     4  0.1327     0.6226 0.000  0 0.000 0.936 0.064 0.000
#> ERR519481     5  0.2092     0.5696 0.000  0 0.000 0.124 0.876 0.000
#> ERR519491     1  0.4053     0.6683 0.676  0 0.000 0.020 0.300 0.004
#> ERR519473     5  0.2288     0.5825 0.004  0 0.000 0.116 0.876 0.004
#> ERR519518     5  0.2178     0.5804 0.000  0 0.000 0.132 0.868 0.000
#> ERR519512     5  0.4332     0.3940 0.288  0 0.000 0.048 0.664 0.000
#> ERR519521     5  0.1141     0.5638 0.000  0 0.000 0.052 0.948 0.000
#> ERR519488     1  0.0260     0.7471 0.992  0 0.000 0.000 0.000 0.008
#> ERR519493     1  0.4053     0.6683 0.676  0 0.000 0.020 0.300 0.004
#> ERR519514     1  0.1141     0.8091 0.948  0 0.000 0.000 0.052 0.000
#> ERR519479     5  0.3557     0.5919 0.056  0 0.000 0.140 0.800 0.004
#> ERR519509     1  0.0260     0.7471 0.992  0 0.000 0.000 0.000 0.008
#> ERR519472     5  0.2355     0.5855 0.008  0 0.000 0.112 0.876 0.004
#> ERR519510     5  0.3817     0.0234 0.000  0 0.000 0.432 0.568 0.000
#> ERR519470     1  0.1141     0.8091 0.948  0 0.000 0.000 0.052 0.000
#> ERR519495     5  0.4497     0.5529 0.184  0 0.000 0.100 0.712 0.004
#> ERR519522     1  0.3161     0.6927 0.776  0 0.000 0.000 0.216 0.008
#> ERR519523     5  0.4291     0.3882 0.292  0 0.000 0.044 0.664 0.000
#> ERR519503     6  0.3838     0.2680 0.448  0 0.000 0.000 0.000 0.552
#> ERR519471     1  0.1141     0.8091 0.948  0 0.000 0.000 0.052 0.000
#> ERR519500     5  0.3724     0.4407 0.268  0 0.000 0.012 0.716 0.004
#> ERR519485     1  0.3922     0.7581 0.772  0 0.000 0.028 0.172 0.028
#> ERR519476     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000 0.000
#> ERR519502     5  0.2092     0.5696 0.000  0 0.000 0.124 0.876 0.000
#> ERR519486     1  0.3922     0.7581 0.772  0 0.000 0.028 0.172 0.028
#> ERR519478     1  0.1285     0.8082 0.944  0 0.000 0.000 0.052 0.004
#> ERR519497     5  0.2491     0.5700 0.000  0 0.000 0.164 0.836 0.000
#> ERR519467     1  0.3804     0.5725 0.656  0 0.000 0.000 0.336 0.008
#> ERR519489     5  0.3584     0.4736 0.244  0 0.000 0.012 0.740 0.004
#> ERR519494     3  0.3506     0.7004 0.000  0 0.792 0.156 0.052 0.000
#> ERR519474     5  0.3788     0.4182 0.280  0 0.000 0.012 0.704 0.004
#> ERR519505     4  0.0547     0.5745 0.000  0 0.000 0.980 0.020 0.000
#> ERR519517     3  0.0000     0.9502 0.000  0 1.000 0.000 0.000 0.000
#> ERR519484     5  0.3995    -0.1228 0.000  0 0.004 0.480 0.516 0.000
#> ERR519498     4  0.3151     0.5068 0.000  0 0.000 0.748 0.252 0.000
#> ERR519490     3  0.0363     0.9475 0.000  0 0.988 0.012 0.000 0.000
#> ERR519507     5  0.3557     0.5919 0.056  0 0.000 0.140 0.800 0.004
#> ERR519511     5  0.3817     0.0234 0.000  0 0.000 0.432 0.568 0.000
#> ERR519468     4  0.4062     0.4680 0.000  0 0.008 0.552 0.440 0.000
#> ERR519482     3  0.0363     0.9475 0.000  0 0.988 0.012 0.000 0.000
#> ERR519475     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000 0.000
#> ERR519496     1  0.2383     0.7968 0.880  0 0.000 0.024 0.096 0.000
#> ERR519506     6  0.0508     0.6382 0.012  0 0.000 0.004 0.000 0.984
#> ERR519469     4  0.3961     0.4668 0.000  0 0.004 0.556 0.440 0.000
#> ERR519480     3  0.0146     0.9485 0.000  0 0.996 0.000 0.000 0.004
#> ERR519487     3  0.0000     0.9502 0.000  0 1.000 0.000 0.000 0.000
#> ERR519483     6  0.0363     0.6390 0.012  0 0.000 0.000 0.000 0.988
#> ERR519477     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000 0.000
#> ERR519499     3  0.0000     0.9502 0.000  0 1.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

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

collect_plots(res)

plot of chunk SD-kmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.971       0.973         0.1353 0.889   0.889
#> 3 3 0.799           0.908       0.954         2.1147 0.729   0.695
#> 4 4 0.821           0.860       0.933         0.5959 0.701   0.516
#> 5 5 0.657           0.559       0.762         0.1140 0.922   0.764
#> 6 6 0.651           0.508       0.701         0.0593 0.860   0.531

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
#> ERR519515     1  0.1184      0.971 0.984 0.016
#> ERR519516     1  0.0000      0.974 1.000 0.000
#> ERR519520     1  0.0000      0.974 1.000 0.000
#> ERR519513     1  0.3114      0.960 0.944 0.056
#> ERR519481     1  0.2423      0.967 0.960 0.040
#> ERR519491     1  0.1184      0.971 0.984 0.016
#> ERR519473     1  0.2423      0.967 0.960 0.040
#> ERR519518     1  0.3114      0.960 0.944 0.056
#> ERR519512     1  0.0000      0.974 1.000 0.000
#> ERR519521     1  0.2423      0.967 0.960 0.040
#> ERR519488     1  0.1184      0.971 0.984 0.016
#> ERR519493     1  0.0938      0.972 0.988 0.012
#> ERR519514     1  0.1184      0.971 0.984 0.016
#> ERR519479     1  0.0376      0.974 0.996 0.004
#> ERR519509     1  0.1184      0.971 0.984 0.016
#> ERR519472     1  0.0000      0.974 1.000 0.000
#> ERR519510     1  0.1633      0.971 0.976 0.024
#> ERR519470     1  0.1184      0.971 0.984 0.016
#> ERR519495     1  0.1184      0.971 0.984 0.016
#> ERR519522     1  0.1184      0.971 0.984 0.016
#> ERR519523     1  0.0000      0.974 1.000 0.000
#> ERR519503     1  0.1184      0.971 0.984 0.016
#> ERR519471     1  0.1184      0.971 0.984 0.016
#> ERR519500     1  0.0000      0.974 1.000 0.000
#> ERR519485     1  0.1184      0.971 0.984 0.016
#> ERR519476     2  0.3114      1.000 0.056 0.944
#> ERR519502     1  0.2423      0.967 0.960 0.040
#> ERR519486     1  0.1184      0.971 0.984 0.016
#> ERR519478     1  0.1184      0.971 0.984 0.016
#> ERR519497     1  0.2423      0.967 0.960 0.040
#> ERR519467     1  0.1184      0.971 0.984 0.016
#> ERR519489     1  0.0000      0.974 1.000 0.000
#> ERR519494     1  0.3114      0.960 0.944 0.056
#> ERR519474     1  0.0000      0.974 1.000 0.000
#> ERR519505     1  0.1633      0.971 0.976 0.024
#> ERR519517     1  0.3114      0.960 0.944 0.056
#> ERR519484     1  0.2423      0.967 0.960 0.040
#> ERR519498     1  0.2423      0.967 0.960 0.040
#> ERR519490     1  0.3114      0.960 0.944 0.056
#> ERR519507     1  0.0376      0.974 0.996 0.004
#> ERR519511     1  0.1633      0.971 0.976 0.024
#> ERR519468     1  0.3114      0.960 0.944 0.056
#> ERR519482     1  0.3114      0.960 0.944 0.056
#> ERR519475     2  0.3114      1.000 0.056 0.944
#> ERR519496     1  0.1184      0.971 0.984 0.016
#> ERR519506     1  0.1184      0.971 0.984 0.016
#> ERR519469     1  0.2423      0.967 0.960 0.040
#> ERR519480     1  0.3114      0.960 0.944 0.056
#> ERR519487     1  0.3114      0.960 0.944 0.056
#> ERR519483     1  0.1184      0.971 0.984 0.016
#> ERR519477     2  0.3114      1.000 0.056 0.944
#> ERR519499     1  0.3114      0.960 0.944 0.056

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> ERR519515     1  0.0000      0.935 1.000 0.000 0.000
#> ERR519516     1  0.0000      0.935 1.000 0.000 0.000
#> ERR519520     1  0.0000      0.935 1.000 0.000 0.000
#> ERR519513     3  0.0424      1.000 0.008 0.000 0.992
#> ERR519481     1  0.5216      0.707 0.740 0.000 0.260
#> ERR519491     1  0.0000      0.935 1.000 0.000 0.000
#> ERR519473     1  0.5216      0.707 0.740 0.000 0.260
#> ERR519518     1  0.6154      0.429 0.592 0.000 0.408
#> ERR519512     1  0.0000      0.935 1.000 0.000 0.000
#> ERR519521     1  0.0747      0.926 0.984 0.000 0.016
#> ERR519488     1  0.0000      0.935 1.000 0.000 0.000
#> ERR519493     1  0.0000      0.935 1.000 0.000 0.000
#> ERR519514     1  0.0000      0.935 1.000 0.000 0.000
#> ERR519479     1  0.0000      0.935 1.000 0.000 0.000
#> ERR519509     1  0.0000      0.935 1.000 0.000 0.000
#> ERR519472     1  0.0000      0.935 1.000 0.000 0.000
#> ERR519510     1  0.0747      0.926 0.984 0.000 0.016
#> ERR519470     1  0.0000      0.935 1.000 0.000 0.000
#> ERR519495     1  0.0000      0.935 1.000 0.000 0.000
#> ERR519522     1  0.0000      0.935 1.000 0.000 0.000
#> ERR519523     1  0.0000      0.935 1.000 0.000 0.000
#> ERR519503     1  0.0000      0.935 1.000 0.000 0.000
#> ERR519471     1  0.0000      0.935 1.000 0.000 0.000
#> ERR519500     1  0.0000      0.935 1.000 0.000 0.000
#> ERR519485     1  0.0000      0.935 1.000 0.000 0.000
#> ERR519476     2  0.0424      0.996 0.000 0.992 0.008
#> ERR519502     1  0.5216      0.707 0.740 0.000 0.260
#> ERR519486     1  0.0000      0.935 1.000 0.000 0.000
#> ERR519478     1  0.0000      0.935 1.000 0.000 0.000
#> ERR519497     1  0.5178      0.712 0.744 0.000 0.256
#> ERR519467     1  0.0000      0.935 1.000 0.000 0.000
#> ERR519489     1  0.0000      0.935 1.000 0.000 0.000
#> ERR519494     3  0.0424      1.000 0.008 0.000 0.992
#> ERR519474     1  0.0000      0.935 1.000 0.000 0.000
#> ERR519505     1  0.5178      0.712 0.744 0.000 0.256
#> ERR519517     3  0.0424      1.000 0.008 0.000 0.992
#> ERR519484     1  0.5363      0.684 0.724 0.000 0.276
#> ERR519498     1  0.5216      0.707 0.740 0.000 0.260
#> ERR519490     3  0.0424      1.000 0.008 0.000 0.992
#> ERR519507     1  0.0000      0.935 1.000 0.000 0.000
#> ERR519511     1  0.1964      0.898 0.944 0.000 0.056
#> ERR519468     3  0.0424      1.000 0.008 0.000 0.992
#> ERR519482     3  0.0424      1.000 0.008 0.000 0.992
#> ERR519475     2  0.0000      0.998 0.000 1.000 0.000
#> ERR519496     1  0.0000      0.935 1.000 0.000 0.000
#> ERR519506     1  0.0000      0.935 1.000 0.000 0.000
#> ERR519469     1  0.0000      0.935 1.000 0.000 0.000
#> ERR519480     3  0.0424      1.000 0.008 0.000 0.992
#> ERR519487     3  0.0424      1.000 0.008 0.000 0.992
#> ERR519483     1  0.0000      0.935 1.000 0.000 0.000
#> ERR519477     2  0.0000      0.998 0.000 1.000 0.000
#> ERR519499     3  0.0424      1.000 0.008 0.000 0.992

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> ERR519515     1  0.0592      0.909 0.984 0.000 0.000 0.016
#> ERR519516     4  0.5000     -0.153 0.496 0.000 0.000 0.504
#> ERR519520     4  0.3444      0.756 0.184 0.000 0.000 0.816
#> ERR519513     3  0.4343      0.560 0.004 0.000 0.732 0.264
#> ERR519481     4  0.0927      0.910 0.008 0.000 0.016 0.976
#> ERR519491     1  0.0707      0.908 0.980 0.000 0.000 0.020
#> ERR519473     4  0.1209      0.910 0.032 0.000 0.004 0.964
#> ERR519518     4  0.1557      0.884 0.000 0.000 0.056 0.944
#> ERR519512     4  0.1557      0.891 0.056 0.000 0.000 0.944
#> ERR519521     4  0.0469      0.910 0.012 0.000 0.000 0.988
#> ERR519488     1  0.1302      0.905 0.956 0.000 0.000 0.044
#> ERR519493     1  0.4790      0.416 0.620 0.000 0.000 0.380
#> ERR519514     1  0.0592      0.909 0.984 0.000 0.000 0.016
#> ERR519479     4  0.1211      0.910 0.040 0.000 0.000 0.960
#> ERR519509     1  0.1302      0.905 0.956 0.000 0.000 0.044
#> ERR519472     4  0.1389      0.908 0.048 0.000 0.000 0.952
#> ERR519510     4  0.1022      0.913 0.032 0.000 0.000 0.968
#> ERR519470     1  0.0592      0.909 0.984 0.000 0.000 0.016
#> ERR519495     4  0.4746      0.462 0.368 0.000 0.000 0.632
#> ERR519522     1  0.1302      0.905 0.956 0.000 0.000 0.044
#> ERR519523     4  0.2216      0.861 0.092 0.000 0.000 0.908
#> ERR519503     1  0.1022      0.898 0.968 0.000 0.000 0.032
#> ERR519471     1  0.0592      0.909 0.984 0.000 0.000 0.016
#> ERR519500     4  0.0921      0.907 0.028 0.000 0.000 0.972
#> ERR519485     1  0.0592      0.907 0.984 0.000 0.000 0.016
#> ERR519476     2  0.0564      0.994 0.004 0.988 0.004 0.004
#> ERR519502     4  0.0779      0.909 0.004 0.000 0.016 0.980
#> ERR519486     1  0.2081      0.865 0.916 0.000 0.000 0.084
#> ERR519478     1  0.1302      0.905 0.956 0.000 0.000 0.044
#> ERR519497     4  0.1042      0.907 0.008 0.000 0.020 0.972
#> ERR519467     1  0.1302      0.905 0.956 0.000 0.000 0.044
#> ERR519489     4  0.1022      0.905 0.032 0.000 0.000 0.968
#> ERR519494     3  0.0188      0.947 0.000 0.000 0.996 0.004
#> ERR519474     1  0.4103      0.694 0.744 0.000 0.000 0.256
#> ERR519505     4  0.1174      0.899 0.012 0.000 0.020 0.968
#> ERR519517     3  0.0336      0.947 0.000 0.000 0.992 0.008
#> ERR519484     4  0.1406      0.908 0.024 0.000 0.016 0.960
#> ERR519498     4  0.0895      0.904 0.004 0.000 0.020 0.976
#> ERR519490     3  0.0188      0.947 0.000 0.000 0.996 0.004
#> ERR519507     4  0.1211      0.910 0.040 0.000 0.000 0.960
#> ERR519511     4  0.0817      0.913 0.024 0.000 0.000 0.976
#> ERR519468     3  0.0336      0.947 0.000 0.000 0.992 0.008
#> ERR519482     3  0.0188      0.947 0.000 0.000 0.996 0.004
#> ERR519475     2  0.0000      0.997 0.000 1.000 0.000 0.000
#> ERR519496     1  0.0592      0.909 0.984 0.000 0.000 0.016
#> ERR519506     1  0.3172      0.793 0.840 0.000 0.000 0.160
#> ERR519469     4  0.1389      0.908 0.048 0.000 0.000 0.952
#> ERR519480     3  0.0188      0.947 0.000 0.000 0.996 0.004
#> ERR519487     3  0.0336      0.947 0.000 0.000 0.992 0.008
#> ERR519483     1  0.3123      0.797 0.844 0.000 0.000 0.156
#> ERR519477     2  0.0000      0.997 0.000 1.000 0.000 0.000
#> ERR519499     3  0.0336      0.947 0.000 0.000 0.992 0.008

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> ERR519515     1  0.1197      0.712 0.952 0.000 0.000 0.000 0.048
#> ERR519516     1  0.6725     -0.359 0.400 0.000 0.000 0.344 0.256
#> ERR519520     4  0.4618      0.465 0.208 0.000 0.000 0.724 0.068
#> ERR519513     3  0.6549      0.209 0.000 0.000 0.436 0.360 0.204
#> ERR519481     4  0.2127      0.635 0.000 0.000 0.000 0.892 0.108
#> ERR519491     1  0.4165      0.397 0.672 0.000 0.000 0.008 0.320
#> ERR519473     4  0.4201      0.357 0.000 0.000 0.000 0.592 0.408
#> ERR519518     4  0.1300      0.627 0.000 0.000 0.028 0.956 0.016
#> ERR519512     4  0.3532      0.585 0.092 0.000 0.000 0.832 0.076
#> ERR519521     4  0.1671      0.628 0.000 0.000 0.000 0.924 0.076
#> ERR519488     1  0.0000      0.707 1.000 0.000 0.000 0.000 0.000
#> ERR519493     1  0.5956     -0.289 0.476 0.000 0.000 0.108 0.416
#> ERR519514     1  0.1197      0.712 0.952 0.000 0.000 0.000 0.048
#> ERR519479     4  0.4283      0.285 0.000 0.000 0.000 0.544 0.456
#> ERR519509     1  0.0000      0.707 1.000 0.000 0.000 0.000 0.000
#> ERR519472     4  0.4383      0.335 0.004 0.000 0.000 0.572 0.424
#> ERR519510     4  0.3561      0.555 0.000 0.000 0.000 0.740 0.260
#> ERR519470     1  0.1121      0.712 0.956 0.000 0.000 0.000 0.044
#> ERR519495     5  0.5896     -0.164 0.100 0.000 0.000 0.448 0.452
#> ERR519522     1  0.1341      0.683 0.944 0.000 0.000 0.000 0.056
#> ERR519523     4  0.4216      0.552 0.100 0.000 0.000 0.780 0.120
#> ERR519503     1  0.2852      0.560 0.828 0.000 0.000 0.000 0.172
#> ERR519471     1  0.1270      0.710 0.948 0.000 0.000 0.000 0.052
#> ERR519500     4  0.4184      0.533 0.016 0.000 0.000 0.700 0.284
#> ERR519485     1  0.4114      0.272 0.624 0.000 0.000 0.000 0.376
#> ERR519476     2  0.1121      0.976 0.000 0.956 0.000 0.000 0.044
#> ERR519502     4  0.0880      0.641 0.000 0.000 0.000 0.968 0.032
#> ERR519486     1  0.4620      0.166 0.592 0.000 0.000 0.016 0.392
#> ERR519478     1  0.0290      0.707 0.992 0.000 0.000 0.000 0.008
#> ERR519497     4  0.1041      0.633 0.000 0.000 0.004 0.964 0.032
#> ERR519467     1  0.1764      0.675 0.928 0.000 0.000 0.008 0.064
#> ERR519489     4  0.4109      0.531 0.012 0.000 0.000 0.700 0.288
#> ERR519494     3  0.0807      0.890 0.000 0.000 0.976 0.012 0.012
#> ERR519474     5  0.6154      0.491 0.348 0.000 0.000 0.144 0.508
#> ERR519505     4  0.4590      0.303 0.000 0.000 0.012 0.568 0.420
#> ERR519517     3  0.1121      0.890 0.000 0.000 0.956 0.000 0.044
#> ERR519484     4  0.4242      0.406 0.000 0.000 0.000 0.572 0.428
#> ERR519498     4  0.3563      0.528 0.000 0.000 0.012 0.780 0.208
#> ERR519490     3  0.0807      0.890 0.000 0.000 0.976 0.012 0.012
#> ERR519507     4  0.4291      0.263 0.000 0.000 0.000 0.536 0.464
#> ERR519511     4  0.3480      0.584 0.000 0.000 0.000 0.752 0.248
#> ERR519468     3  0.0798      0.891 0.000 0.000 0.976 0.008 0.016
#> ERR519482     3  0.0807      0.890 0.000 0.000 0.976 0.012 0.012
#> ERR519475     2  0.0000      0.988 0.000 1.000 0.000 0.000 0.000
#> ERR519496     1  0.3684      0.467 0.720 0.000 0.000 0.000 0.280
#> ERR519506     5  0.4644      0.575 0.280 0.000 0.000 0.040 0.680
#> ERR519469     4  0.4227      0.342 0.000 0.000 0.000 0.580 0.420
#> ERR519480     3  0.1121      0.887 0.000 0.000 0.956 0.000 0.044
#> ERR519487     3  0.1121      0.890 0.000 0.000 0.956 0.000 0.044
#> ERR519483     5  0.4644      0.575 0.280 0.000 0.000 0.040 0.680
#> ERR519477     2  0.0000      0.988 0.000 1.000 0.000 0.000 0.000
#> ERR519499     3  0.1121      0.890 0.000 0.000 0.956 0.000 0.044

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> ERR519515     1  0.1141     0.7254 0.948 0.000 0.000 0.000 0.052 0.000
#> ERR519516     1  0.6419    -0.1794 0.340 0.000 0.000 0.324 0.324 0.012
#> ERR519520     4  0.3036     0.4210 0.124 0.000 0.000 0.840 0.008 0.028
#> ERR519513     6  0.5784     0.4176 0.000 0.000 0.236 0.168 0.020 0.576
#> ERR519481     4  0.4963     0.4464 0.000 0.000 0.000 0.612 0.288 0.100
#> ERR519491     1  0.4499     0.4741 0.620 0.000 0.000 0.012 0.344 0.024
#> ERR519473     5  0.3819     0.3358 0.000 0.000 0.000 0.340 0.652 0.008
#> ERR519518     4  0.4403     0.3510 0.000 0.000 0.000 0.708 0.096 0.196
#> ERR519512     4  0.1788     0.5362 0.040 0.000 0.000 0.928 0.028 0.004
#> ERR519521     4  0.0000     0.5225 0.000 0.000 0.000 1.000 0.000 0.000
#> ERR519488     1  0.1075     0.7119 0.952 0.000 0.000 0.000 0.000 0.048
#> ERR519493     5  0.5467    -0.1327 0.428 0.000 0.000 0.044 0.488 0.040
#> ERR519514     1  0.1141     0.7254 0.948 0.000 0.000 0.000 0.052 0.000
#> ERR519479     5  0.3555     0.4204 0.000 0.000 0.000 0.280 0.712 0.008
#> ERR519509     1  0.1075     0.7119 0.952 0.000 0.000 0.000 0.000 0.048
#> ERR519472     5  0.3668     0.3762 0.004 0.000 0.000 0.328 0.668 0.000
#> ERR519510     6  0.6128     0.0871 0.000 0.000 0.000 0.340 0.316 0.344
#> ERR519470     1  0.1141     0.7254 0.948 0.000 0.000 0.000 0.052 0.000
#> ERR519495     5  0.4594     0.4239 0.092 0.000 0.000 0.232 0.676 0.000
#> ERR519522     1  0.3332     0.6297 0.808 0.000 0.000 0.144 0.000 0.048
#> ERR519523     4  0.2461     0.5193 0.064 0.000 0.000 0.888 0.044 0.004
#> ERR519503     1  0.5324     0.3941 0.592 0.000 0.000 0.000 0.172 0.236
#> ERR519471     1  0.1802     0.7173 0.916 0.000 0.000 0.000 0.072 0.012
#> ERR519500     4  0.3852     0.3375 0.004 0.000 0.000 0.612 0.384 0.000
#> ERR519485     1  0.4978     0.3630 0.532 0.000 0.000 0.000 0.396 0.072
#> ERR519476     2  0.0806     0.9825 0.000 0.972 0.000 0.000 0.020 0.008
#> ERR519502     4  0.4791     0.4653 0.000 0.000 0.000 0.652 0.244 0.104
#> ERR519486     1  0.5040     0.3319 0.516 0.000 0.000 0.000 0.408 0.076
#> ERR519478     1  0.1265     0.7155 0.948 0.000 0.000 0.000 0.008 0.044
#> ERR519497     4  0.4136     0.3410 0.000 0.000 0.000 0.732 0.076 0.192
#> ERR519467     1  0.4112     0.5866 0.724 0.000 0.000 0.224 0.004 0.048
#> ERR519489     4  0.3986     0.3271 0.004 0.000 0.000 0.608 0.384 0.004
#> ERR519494     3  0.3139     0.9021 0.000 0.000 0.816 0.000 0.032 0.152
#> ERR519474     5  0.5751     0.2461 0.252 0.000 0.000 0.076 0.604 0.068
#> ERR519505     6  0.4854     0.5152 0.000 0.000 0.000 0.264 0.100 0.636
#> ERR519517     3  0.0458     0.9050 0.000 0.000 0.984 0.000 0.000 0.016
#> ERR519484     5  0.5895    -0.2404 0.000 0.000 0.000 0.208 0.436 0.356
#> ERR519498     6  0.4886     0.4056 0.000 0.000 0.000 0.432 0.060 0.508
#> ERR519490     3  0.3139     0.9031 0.000 0.000 0.816 0.000 0.032 0.152
#> ERR519507     5  0.3468     0.4296 0.000 0.000 0.000 0.264 0.728 0.008
#> ERR519511     5  0.5753    -0.1657 0.000 0.000 0.000 0.384 0.444 0.172
#> ERR519468     3  0.2815     0.9043 0.000 0.000 0.848 0.000 0.032 0.120
#> ERR519482     3  0.3139     0.9031 0.000 0.000 0.816 0.000 0.032 0.152
#> ERR519475     2  0.0000     0.9913 0.000 1.000 0.000 0.000 0.000 0.000
#> ERR519496     1  0.3934     0.5381 0.676 0.000 0.000 0.000 0.304 0.020
#> ERR519506     5  0.5320     0.1580 0.144 0.000 0.000 0.000 0.576 0.280
#> ERR519469     5  0.3684     0.3508 0.000 0.000 0.000 0.332 0.664 0.004
#> ERR519480     3  0.1333     0.8975 0.000 0.000 0.944 0.000 0.008 0.048
#> ERR519487     3  0.0363     0.9047 0.000 0.000 0.988 0.000 0.000 0.012
#> ERR519483     5  0.5335     0.1493 0.148 0.000 0.000 0.000 0.576 0.276
#> ERR519477     2  0.0000     0.9913 0.000 1.000 0.000 0.000 0.000 0.000
#> ERR519499     3  0.0363     0.9047 0.000 0.000 0.988 0.000 0.000 0.012

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

consensus_heatmap(res, k = 2)

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

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

collect_plots(res)

plot of chunk SD-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.687           0.876       0.942         0.4641 0.551   0.551
#> 3 3 0.889           0.889       0.947         0.4545 0.744   0.546
#> 4 4 0.871           0.809       0.911         0.0887 0.908   0.732
#> 5 5 0.749           0.703       0.852         0.0829 0.888   0.614
#> 6 6 0.798           0.669       0.824         0.0460 0.938   0.710

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
#> ERR519515     1  0.0000      0.925 1.000 0.000
#> ERR519516     1  0.0000      0.925 1.000 0.000
#> ERR519520     1  0.0376      0.924 0.996 0.004
#> ERR519513     2  0.0000      0.953 0.000 1.000
#> ERR519481     1  0.7299      0.771 0.796 0.204
#> ERR519491     1  0.0000      0.925 1.000 0.000
#> ERR519473     1  0.7299      0.771 0.796 0.204
#> ERR519518     1  0.9686      0.457 0.604 0.396
#> ERR519512     1  0.0376      0.924 0.996 0.004
#> ERR519521     1  0.0376      0.924 0.996 0.004
#> ERR519488     1  0.0000      0.925 1.000 0.000
#> ERR519493     1  0.0000      0.925 1.000 0.000
#> ERR519514     1  0.0000      0.925 1.000 0.000
#> ERR519479     1  0.0376      0.924 0.996 0.004
#> ERR519509     1  0.0000      0.925 1.000 0.000
#> ERR519472     1  0.0376      0.924 0.996 0.004
#> ERR519510     1  0.6247      0.815 0.844 0.156
#> ERR519470     1  0.0000      0.925 1.000 0.000
#> ERR519495     1  0.0000      0.925 1.000 0.000
#> ERR519522     1  0.0000      0.925 1.000 0.000
#> ERR519523     1  0.0376      0.924 0.996 0.004
#> ERR519503     2  0.7299      0.745 0.204 0.796
#> ERR519471     1  0.0000      0.925 1.000 0.000
#> ERR519500     1  0.0376      0.924 0.996 0.004
#> ERR519485     1  0.0000      0.925 1.000 0.000
#> ERR519476     2  0.0376      0.952 0.004 0.996
#> ERR519502     1  0.7299      0.771 0.796 0.204
#> ERR519486     1  0.0000      0.925 1.000 0.000
#> ERR519478     1  0.0000      0.925 1.000 0.000
#> ERR519497     1  0.9686      0.457 0.604 0.396
#> ERR519467     1  0.0000      0.925 1.000 0.000
#> ERR519489     1  0.0376      0.924 0.996 0.004
#> ERR519494     2  0.0000      0.953 0.000 1.000
#> ERR519474     1  0.0000      0.925 1.000 0.000
#> ERR519505     2  0.0000      0.953 0.000 1.000
#> ERR519517     2  0.0000      0.953 0.000 1.000
#> ERR519484     1  0.9710      0.448 0.600 0.400
#> ERR519498     2  0.7745      0.653 0.228 0.772
#> ERR519490     2  0.0000      0.953 0.000 1.000
#> ERR519507     1  0.6887      0.790 0.816 0.184
#> ERR519511     1  0.7299      0.771 0.796 0.204
#> ERR519468     2  0.0000      0.953 0.000 1.000
#> ERR519482     2  0.0000      0.953 0.000 1.000
#> ERR519475     2  0.0376      0.952 0.004 0.996
#> ERR519496     1  0.0000      0.925 1.000 0.000
#> ERR519506     2  0.0672      0.950 0.008 0.992
#> ERR519469     1  0.0376      0.924 0.996 0.004
#> ERR519480     2  0.0000      0.953 0.000 1.000
#> ERR519487     2  0.0000      0.953 0.000 1.000
#> ERR519483     2  0.7219      0.750 0.200 0.800
#> ERR519477     2  0.0376      0.952 0.004 0.996
#> ERR519499     2  0.0000      0.953 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
#> ERR519515     1  0.0000      0.933 1.000 0.000 0.000
#> ERR519516     1  0.5327      0.632 0.728 0.272 0.000
#> ERR519520     2  0.6154      0.325 0.408 0.592 0.000
#> ERR519513     3  0.4931      0.716 0.000 0.232 0.768
#> ERR519481     2  0.0424      0.940 0.008 0.992 0.000
#> ERR519491     1  0.0747      0.933 0.984 0.016 0.000
#> ERR519473     2  0.0000      0.938 0.000 1.000 0.000
#> ERR519518     2  0.0747      0.929 0.000 0.984 0.016
#> ERR519512     2  0.2711      0.876 0.088 0.912 0.000
#> ERR519521     2  0.0592      0.940 0.012 0.988 0.000
#> ERR519488     1  0.0592      0.926 0.988 0.000 0.012
#> ERR519493     1  0.0747      0.933 0.984 0.016 0.000
#> ERR519514     1  0.0237      0.934 0.996 0.004 0.000
#> ERR519479     2  0.0747      0.939 0.016 0.984 0.000
#> ERR519509     1  0.0592      0.926 0.988 0.000 0.012
#> ERR519472     2  0.0892      0.937 0.020 0.980 0.000
#> ERR519510     2  0.0592      0.940 0.012 0.988 0.000
#> ERR519470     1  0.0000      0.933 1.000 0.000 0.000
#> ERR519495     1  0.5905      0.420 0.648 0.352 0.000
#> ERR519522     1  0.0747      0.933 0.984 0.016 0.000
#> ERR519523     2  0.5785      0.508 0.332 0.668 0.000
#> ERR519503     3  0.5138      0.664 0.252 0.000 0.748
#> ERR519471     1  0.0000      0.933 1.000 0.000 0.000
#> ERR519500     2  0.0892      0.937 0.020 0.980 0.000
#> ERR519485     1  0.0424      0.929 0.992 0.000 0.008
#> ERR519476     3  0.0747      0.950 0.016 0.000 0.984
#> ERR519502     2  0.0000      0.938 0.000 1.000 0.000
#> ERR519486     1  0.0747      0.933 0.984 0.016 0.000
#> ERR519478     1  0.0237      0.934 0.996 0.004 0.000
#> ERR519497     2  0.0747      0.929 0.000 0.984 0.016
#> ERR519467     1  0.0747      0.933 0.984 0.016 0.000
#> ERR519489     2  0.1031      0.934 0.024 0.976 0.000
#> ERR519494     3  0.0892      0.955 0.000 0.020 0.980
#> ERR519474     1  0.4750      0.722 0.784 0.216 0.000
#> ERR519505     3  0.0892      0.952 0.000 0.020 0.980
#> ERR519517     3  0.0892      0.955 0.000 0.020 0.980
#> ERR519484     2  0.0000      0.938 0.000 1.000 0.000
#> ERR519498     2  0.0747      0.929 0.000 0.984 0.016
#> ERR519490     3  0.0892      0.955 0.000 0.020 0.980
#> ERR519507     2  0.0592      0.940 0.012 0.988 0.000
#> ERR519511     2  0.0592      0.940 0.012 0.988 0.000
#> ERR519468     3  0.0892      0.955 0.000 0.020 0.980
#> ERR519482     3  0.0892      0.955 0.000 0.020 0.980
#> ERR519475     3  0.0747      0.950 0.016 0.000 0.984
#> ERR519496     1  0.0747      0.933 0.984 0.016 0.000
#> ERR519506     3  0.0747      0.950 0.016 0.000 0.984
#> ERR519469     2  0.0424      0.934 0.000 0.992 0.008
#> ERR519480     3  0.0592      0.955 0.000 0.012 0.988
#> ERR519487     3  0.0747      0.956 0.000 0.016 0.984
#> ERR519483     3  0.0892      0.948 0.020 0.000 0.980
#> ERR519477     3  0.0747      0.950 0.016 0.000 0.984
#> ERR519499     3  0.0747      0.956 0.000 0.016 0.984

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> ERR519515     1  0.0000      0.926 1.000 0.000 0.000 0.000
#> ERR519516     1  0.4855      0.462 0.644 0.004 0.000 0.352
#> ERR519520     4  0.5336      0.118 0.492 0.004 0.004 0.500
#> ERR519513     3  0.0804      0.914 0.000 0.008 0.980 0.012
#> ERR519481     4  0.0188      0.838 0.000 0.000 0.004 0.996
#> ERR519491     1  0.0000      0.926 1.000 0.000 0.000 0.000
#> ERR519473     4  0.1909      0.834 0.008 0.048 0.004 0.940
#> ERR519518     4  0.4800      0.485 0.000 0.004 0.340 0.656
#> ERR519512     4  0.3072      0.775 0.124 0.004 0.004 0.868
#> ERR519521     4  0.0564      0.837 0.004 0.004 0.004 0.988
#> ERR519488     1  0.0376      0.924 0.992 0.004 0.000 0.004
#> ERR519493     1  0.1209      0.906 0.964 0.032 0.000 0.004
#> ERR519514     1  0.0000      0.926 1.000 0.000 0.000 0.000
#> ERR519479     4  0.1722      0.834 0.008 0.048 0.000 0.944
#> ERR519509     1  0.0376      0.924 0.992 0.004 0.000 0.004
#> ERR519472     4  0.1722      0.834 0.008 0.048 0.000 0.944
#> ERR519510     4  0.1042      0.834 0.000 0.008 0.020 0.972
#> ERR519470     1  0.0000      0.926 1.000 0.000 0.000 0.000
#> ERR519495     4  0.6149      0.157 0.472 0.048 0.000 0.480
#> ERR519522     1  0.0376      0.924 0.992 0.004 0.000 0.004
#> ERR519523     4  0.4897      0.539 0.324 0.004 0.004 0.668
#> ERR519503     2  0.1661      0.929 0.052 0.944 0.004 0.000
#> ERR519471     1  0.0000      0.926 1.000 0.000 0.000 0.000
#> ERR519500     4  0.0672      0.838 0.008 0.008 0.000 0.984
#> ERR519485     1  0.1004      0.911 0.972 0.024 0.000 0.004
#> ERR519476     2  0.1637      0.959 0.000 0.940 0.060 0.000
#> ERR519502     4  0.0469      0.837 0.000 0.000 0.012 0.988
#> ERR519486     1  0.1109      0.909 0.968 0.028 0.000 0.004
#> ERR519478     1  0.0376      0.924 0.992 0.004 0.000 0.004
#> ERR519497     4  0.4905      0.442 0.000 0.004 0.364 0.632
#> ERR519467     1  0.0376      0.924 0.992 0.004 0.000 0.004
#> ERR519489     4  0.0672      0.838 0.008 0.008 0.000 0.984
#> ERR519494     3  0.0592      0.939 0.000 0.016 0.984 0.000
#> ERR519474     1  0.6120      0.145 0.520 0.048 0.000 0.432
#> ERR519505     3  0.5950      0.196 0.000 0.416 0.544 0.040
#> ERR519517     3  0.0592      0.939 0.000 0.016 0.984 0.000
#> ERR519484     4  0.2089      0.833 0.000 0.048 0.020 0.932
#> ERR519498     3  0.1970      0.869 0.000 0.008 0.932 0.060
#> ERR519490     3  0.0592      0.939 0.000 0.016 0.984 0.000
#> ERR519507     4  0.1909      0.834 0.008 0.048 0.004 0.940
#> ERR519511     4  0.1059      0.835 0.000 0.012 0.016 0.972
#> ERR519468     3  0.0592      0.939 0.000 0.016 0.984 0.000
#> ERR519482     3  0.0592      0.939 0.000 0.016 0.984 0.000
#> ERR519475     2  0.1637      0.959 0.000 0.940 0.060 0.000
#> ERR519496     1  0.0000      0.926 1.000 0.000 0.000 0.000
#> ERR519506     2  0.0657      0.949 0.004 0.984 0.012 0.000
#> ERR519469     4  0.1909      0.834 0.008 0.048 0.004 0.940
#> ERR519480     3  0.0592      0.939 0.000 0.016 0.984 0.000
#> ERR519487     3  0.0592      0.939 0.000 0.016 0.984 0.000
#> ERR519483     2  0.0657      0.949 0.004 0.984 0.012 0.000
#> ERR519477     2  0.1637      0.959 0.000 0.940 0.060 0.000
#> ERR519499     3  0.0592      0.939 0.000 0.016 0.984 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
#> ERR519515     1  0.0000     0.9204 1.000 0.000 0.000 0.000 0.000
#> ERR519516     1  0.5708     0.3100 0.528 0.000 0.000 0.384 0.088
#> ERR519520     4  0.1965     0.6191 0.096 0.000 0.000 0.904 0.000
#> ERR519513     3  0.3812     0.7250 0.000 0.000 0.772 0.024 0.204
#> ERR519481     5  0.4304     0.2933 0.000 0.000 0.000 0.484 0.516
#> ERR519491     1  0.1956     0.8933 0.928 0.008 0.000 0.012 0.052
#> ERR519473     5  0.4467     0.5529 0.000 0.016 0.000 0.344 0.640
#> ERR519518     4  0.4365     0.5676 0.000 0.000 0.116 0.768 0.116
#> ERR519512     4  0.0609     0.6456 0.020 0.000 0.000 0.980 0.000
#> ERR519521     4  0.0290     0.6432 0.000 0.000 0.000 0.992 0.008
#> ERR519488     1  0.0162     0.9202 0.996 0.000 0.000 0.004 0.000
#> ERR519493     1  0.4061     0.7554 0.776 0.012 0.000 0.024 0.188
#> ERR519514     1  0.0000     0.9204 1.000 0.000 0.000 0.000 0.000
#> ERR519479     5  0.3807     0.6101 0.000 0.012 0.000 0.240 0.748
#> ERR519509     1  0.0162     0.9202 0.996 0.000 0.000 0.004 0.000
#> ERR519472     5  0.4610     0.5279 0.000 0.016 0.000 0.388 0.596
#> ERR519510     5  0.3274     0.3361 0.000 0.000 0.000 0.220 0.780
#> ERR519470     1  0.0000     0.9204 1.000 0.000 0.000 0.000 0.000
#> ERR519495     5  0.6342     0.4816 0.192 0.012 0.000 0.220 0.576
#> ERR519522     1  0.0162     0.9202 0.996 0.000 0.000 0.004 0.000
#> ERR519523     4  0.2624     0.5716 0.116 0.000 0.000 0.872 0.012
#> ERR519503     2  0.1270     0.8512 0.052 0.948 0.000 0.000 0.000
#> ERR519471     1  0.0000     0.9204 1.000 0.000 0.000 0.000 0.000
#> ERR519500     4  0.3305     0.3613 0.000 0.000 0.000 0.776 0.224
#> ERR519485     1  0.2074     0.8902 0.920 0.016 0.000 0.004 0.060
#> ERR519476     2  0.0609     0.8814 0.000 0.980 0.020 0.000 0.000
#> ERR519502     4  0.4171     0.0633 0.000 0.000 0.000 0.604 0.396
#> ERR519486     1  0.3005     0.8456 0.856 0.012 0.000 0.008 0.124
#> ERR519478     1  0.0162     0.9202 0.996 0.000 0.000 0.004 0.000
#> ERR519497     4  0.5373     0.4831 0.000 0.000 0.112 0.652 0.236
#> ERR519467     1  0.2179     0.8453 0.888 0.000 0.000 0.112 0.000
#> ERR519489     4  0.1908     0.5861 0.000 0.000 0.000 0.908 0.092
#> ERR519494     3  0.0290     0.9636 0.000 0.000 0.992 0.000 0.008
#> ERR519474     5  0.6899     0.1859 0.352 0.012 0.000 0.208 0.428
#> ERR519505     2  0.8376     0.1064 0.000 0.352 0.196 0.176 0.276
#> ERR519517     3  0.0000     0.9640 0.000 0.000 1.000 0.000 0.000
#> ERR519484     5  0.1365     0.5088 0.000 0.004 0.004 0.040 0.952
#> ERR519498     4  0.6556     0.3195 0.000 0.000 0.264 0.476 0.260
#> ERR519490     3  0.0404     0.9628 0.000 0.000 0.988 0.000 0.012
#> ERR519507     5  0.3819     0.6116 0.000 0.016 0.000 0.228 0.756
#> ERR519511     5  0.2329     0.4580 0.000 0.000 0.000 0.124 0.876
#> ERR519468     3  0.0404     0.9628 0.000 0.000 0.988 0.000 0.012
#> ERR519482     3  0.0404     0.9628 0.000 0.000 0.988 0.000 0.012
#> ERR519475     2  0.0609     0.8814 0.000 0.980 0.020 0.000 0.000
#> ERR519496     1  0.0510     0.9158 0.984 0.000 0.000 0.000 0.016
#> ERR519506     2  0.0000     0.8764 0.000 1.000 0.000 0.000 0.000
#> ERR519469     5  0.4737     0.5245 0.000 0.016 0.004 0.380 0.600
#> ERR519480     3  0.0000     0.9640 0.000 0.000 1.000 0.000 0.000
#> ERR519487     3  0.0000     0.9640 0.000 0.000 1.000 0.000 0.000
#> ERR519483     2  0.0404     0.8712 0.000 0.988 0.000 0.000 0.012
#> ERR519477     2  0.0609     0.8814 0.000 0.980 0.020 0.000 0.000
#> ERR519499     3  0.0000     0.9640 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
#> ERR519515     1  0.0146    0.85025 0.996 0.000 0.000 0.000 0.000 0.004
#> ERR519516     4  0.6582   -0.16176 0.380 0.000 0.000 0.428 0.084 0.108
#> ERR519520     4  0.1367    0.61125 0.044 0.000 0.000 0.944 0.000 0.012
#> ERR519513     6  0.3986    0.14953 0.000 0.000 0.464 0.004 0.000 0.532
#> ERR519481     5  0.5959    0.00524 0.000 0.000 0.000 0.260 0.452 0.288
#> ERR519491     1  0.4715    0.73903 0.736 0.000 0.000 0.048 0.080 0.136
#> ERR519473     5  0.1858    0.70645 0.000 0.000 0.000 0.092 0.904 0.004
#> ERR519518     4  0.5791    0.20104 0.000 0.000 0.076 0.560 0.052 0.312
#> ERR519512     4  0.0964    0.62516 0.016 0.000 0.000 0.968 0.012 0.004
#> ERR519521     4  0.1700    0.62120 0.000 0.000 0.000 0.928 0.048 0.024
#> ERR519488     1  0.1633    0.83997 0.932 0.000 0.000 0.044 0.000 0.024
#> ERR519493     1  0.6347    0.52433 0.548 0.000 0.000 0.060 0.200 0.192
#> ERR519514     1  0.0146    0.85025 0.996 0.000 0.000 0.000 0.000 0.004
#> ERR519479     5  0.2039    0.67606 0.000 0.000 0.000 0.020 0.904 0.076
#> ERR519509     1  0.1633    0.83997 0.932 0.000 0.000 0.044 0.000 0.024
#> ERR519472     5  0.1812    0.71340 0.000 0.000 0.000 0.080 0.912 0.008
#> ERR519510     6  0.3736    0.61851 0.000 0.000 0.000 0.068 0.156 0.776
#> ERR519470     1  0.0146    0.85025 0.996 0.000 0.000 0.000 0.000 0.004
#> ERR519495     5  0.2831    0.67540 0.056 0.000 0.000 0.036 0.876 0.032
#> ERR519522     1  0.1745    0.83750 0.924 0.000 0.000 0.056 0.000 0.020
#> ERR519523     4  0.1863    0.61777 0.060 0.000 0.000 0.920 0.016 0.004
#> ERR519503     2  0.3084    0.80014 0.136 0.832 0.000 0.008 0.000 0.024
#> ERR519471     1  0.0547    0.84869 0.980 0.000 0.000 0.000 0.000 0.020
#> ERR519500     4  0.4066    0.42171 0.004 0.000 0.000 0.696 0.272 0.028
#> ERR519485     1  0.4430    0.72905 0.732 0.004 0.000 0.012 0.064 0.188
#> ERR519476     2  0.0000    0.94376 0.000 1.000 0.000 0.000 0.000 0.000
#> ERR519502     4  0.6102    0.01383 0.000 0.000 0.000 0.376 0.292 0.332
#> ERR519486     1  0.5243    0.62273 0.616 0.000 0.000 0.016 0.092 0.276
#> ERR519478     1  0.1549    0.84068 0.936 0.000 0.000 0.044 0.000 0.020
#> ERR519497     4  0.4829    0.00660 0.000 0.000 0.056 0.520 0.000 0.424
#> ERR519467     1  0.3974    0.57366 0.680 0.000 0.000 0.296 0.000 0.024
#> ERR519489     4  0.3062    0.57327 0.000 0.000 0.000 0.824 0.144 0.032
#> ERR519494     3  0.0146    0.99443 0.000 0.000 0.996 0.000 0.000 0.004
#> ERR519474     5  0.7659   -0.02209 0.276 0.000 0.000 0.200 0.304 0.220
#> ERR519505     6  0.4909    0.57314 0.000 0.104 0.068 0.100 0.000 0.728
#> ERR519517     3  0.0000    0.99921 0.000 0.000 1.000 0.000 0.000 0.000
#> ERR519484     6  0.3725    0.51068 0.000 0.000 0.000 0.008 0.316 0.676
#> ERR519498     6  0.4570    0.49317 0.000 0.000 0.092 0.228 0.000 0.680
#> ERR519490     3  0.0000    0.99921 0.000 0.000 1.000 0.000 0.000 0.000
#> ERR519507     5  0.1616    0.68905 0.000 0.000 0.000 0.020 0.932 0.048
#> ERR519511     6  0.4498    0.50576 0.000 0.000 0.000 0.056 0.300 0.644
#> ERR519468     3  0.0000    0.99921 0.000 0.000 1.000 0.000 0.000 0.000
#> ERR519482     3  0.0000    0.99921 0.000 0.000 1.000 0.000 0.000 0.000
#> ERR519475     2  0.0000    0.94376 0.000 1.000 0.000 0.000 0.000 0.000
#> ERR519496     1  0.1644    0.83421 0.932 0.000 0.000 0.004 0.012 0.052
#> ERR519506     2  0.0291    0.94200 0.000 0.992 0.000 0.004 0.000 0.004
#> ERR519469     5  0.2191    0.69357 0.000 0.000 0.004 0.120 0.876 0.000
#> ERR519480     3  0.0000    0.99921 0.000 0.000 1.000 0.000 0.000 0.000
#> ERR519487     3  0.0000    0.99921 0.000 0.000 1.000 0.000 0.000 0.000
#> ERR519483     2  0.1994    0.90133 0.016 0.920 0.000 0.008 0.004 0.052
#> ERR519477     2  0.0000    0.94376 0.000 1.000 0.000 0.000 0.000 0.000
#> ERR519499     3  0.0000    0.99921 0.000 0.000 1.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-skmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-skmeans-collect-classes

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


SD:pam*

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

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

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

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

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000          0.112 0.889   0.889
#> 3 3 0.635           0.909       0.950          2.727 0.729   0.695
#> 4 4 0.906           0.890       0.954          0.539 0.705   0.537
#> 5 5 0.787           0.813       0.911          0.149 0.894   0.715
#> 6 6 0.807           0.767       0.881          0.102 0.852   0.516

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette p1 p2
#> ERR519515     1       0          1  1  0
#> ERR519516     1       0          1  1  0
#> ERR519520     1       0          1  1  0
#> ERR519513     1       0          1  1  0
#> ERR519481     1       0          1  1  0
#> ERR519491     1       0          1  1  0
#> ERR519473     1       0          1  1  0
#> ERR519518     1       0          1  1  0
#> ERR519512     1       0          1  1  0
#> ERR519521     1       0          1  1  0
#> ERR519488     1       0          1  1  0
#> ERR519493     1       0          1  1  0
#> ERR519514     1       0          1  1  0
#> ERR519479     1       0          1  1  0
#> ERR519509     1       0          1  1  0
#> ERR519472     1       0          1  1  0
#> ERR519510     1       0          1  1  0
#> ERR519470     1       0          1  1  0
#> ERR519495     1       0          1  1  0
#> ERR519522     1       0          1  1  0
#> ERR519523     1       0          1  1  0
#> ERR519503     1       0          1  1  0
#> ERR519471     1       0          1  1  0
#> ERR519500     1       0          1  1  0
#> ERR519485     1       0          1  1  0
#> ERR519476     2       0          1  0  1
#> ERR519502     1       0          1  1  0
#> ERR519486     1       0          1  1  0
#> ERR519478     1       0          1  1  0
#> ERR519497     1       0          1  1  0
#> ERR519467     1       0          1  1  0
#> ERR519489     1       0          1  1  0
#> ERR519494     1       0          1  1  0
#> ERR519474     1       0          1  1  0
#> ERR519505     1       0          1  1  0
#> ERR519517     1       0          1  1  0
#> ERR519484     1       0          1  1  0
#> ERR519498     1       0          1  1  0
#> ERR519490     1       0          1  1  0
#> ERR519507     1       0          1  1  0
#> ERR519511     1       0          1  1  0
#> ERR519468     1       0          1  1  0
#> ERR519482     1       0          1  1  0
#> ERR519475     2       0          1  0  1
#> ERR519496     1       0          1  1  0
#> ERR519506     1       0          1  1  0
#> ERR519469     1       0          1  1  0
#> ERR519480     1       0          1  1  0
#> ERR519487     1       0          1  1  0
#> ERR519483     1       0          1  1  0
#> ERR519477     2       0          1  0  1
#> ERR519499     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
#> ERR519515     1  0.0000      0.932 1.000  0 0.000
#> ERR519516     1  0.0237      0.931 0.996  0 0.004
#> ERR519520     1  0.0000      0.932 1.000  0 0.000
#> ERR519513     3  0.0000      0.965 0.000  0 1.000
#> ERR519481     1  0.3686      0.883 0.860  0 0.140
#> ERR519491     1  0.0000      0.932 1.000  0 0.000
#> ERR519473     1  0.3686      0.883 0.860  0 0.140
#> ERR519518     1  0.6308      0.210 0.508  0 0.492
#> ERR519512     1  0.0237      0.931 0.996  0 0.004
#> ERR519521     1  0.3686      0.883 0.860  0 0.140
#> ERR519488     1  0.0000      0.932 1.000  0 0.000
#> ERR519493     1  0.0000      0.932 1.000  0 0.000
#> ERR519514     1  0.0000      0.932 1.000  0 0.000
#> ERR519479     1  0.3686      0.883 0.860  0 0.140
#> ERR519509     1  0.0000      0.932 1.000  0 0.000
#> ERR519472     1  0.0000      0.932 1.000  0 0.000
#> ERR519510     1  0.3686      0.883 0.860  0 0.140
#> ERR519470     1  0.0000      0.932 1.000  0 0.000
#> ERR519495     1  0.0000      0.932 1.000  0 0.000
#> ERR519522     1  0.0000      0.932 1.000  0 0.000
#> ERR519523     1  0.0000      0.932 1.000  0 0.000
#> ERR519503     1  0.0000      0.932 1.000  0 0.000
#> ERR519471     1  0.0000      0.932 1.000  0 0.000
#> ERR519500     1  0.0237      0.931 0.996  0 0.004
#> ERR519485     1  0.0000      0.932 1.000  0 0.000
#> ERR519476     2  0.0000      1.000 0.000  1 0.000
#> ERR519502     1  0.3686      0.883 0.860  0 0.140
#> ERR519486     1  0.0000      0.932 1.000  0 0.000
#> ERR519478     1  0.0000      0.932 1.000  0 0.000
#> ERR519497     1  0.3686      0.883 0.860  0 0.140
#> ERR519467     1  0.0000      0.932 1.000  0 0.000
#> ERR519489     1  0.3686      0.883 0.860  0 0.140
#> ERR519494     3  0.0000      0.965 0.000  0 1.000
#> ERR519474     1  0.0000      0.932 1.000  0 0.000
#> ERR519505     1  0.3686      0.883 0.860  0 0.140
#> ERR519517     3  0.0000      0.965 0.000  0 1.000
#> ERR519484     1  0.3686      0.883 0.860  0 0.140
#> ERR519498     1  0.4062      0.862 0.836  0 0.164
#> ERR519490     3  0.0000      0.965 0.000  0 1.000
#> ERR519507     1  0.3619      0.885 0.864  0 0.136
#> ERR519511     1  0.3686      0.883 0.860  0 0.140
#> ERR519468     3  0.3686      0.702 0.140  0 0.860
#> ERR519482     3  0.0000      0.965 0.000  0 1.000
#> ERR519475     2  0.0000      1.000 0.000  1 0.000
#> ERR519496     1  0.0000      0.932 1.000  0 0.000
#> ERR519506     1  0.3267      0.893 0.884  0 0.116
#> ERR519469     1  0.0000      0.932 1.000  0 0.000
#> ERR519480     3  0.0000      0.965 0.000  0 1.000
#> ERR519487     3  0.0000      0.965 0.000  0 1.000
#> ERR519483     1  0.0000      0.932 1.000  0 0.000
#> ERR519477     2  0.0000      1.000 0.000  1 0.000
#> ERR519499     3  0.0000      0.965 0.000  0 1.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1 p2    p3    p4
#> ERR519515     1  0.0000      0.946 1.000  0 0.000 0.000
#> ERR519516     1  0.1940      0.918 0.924  0 0.000 0.076
#> ERR519520     1  0.1118      0.933 0.964  0 0.000 0.036
#> ERR519513     4  0.1940      0.824 0.000  0 0.076 0.924
#> ERR519481     4  0.0000      0.890 0.000  0 0.000 1.000
#> ERR519491     1  0.0000      0.946 1.000  0 0.000 0.000
#> ERR519473     1  0.2216      0.907 0.908  0 0.000 0.092
#> ERR519518     4  0.0000      0.890 0.000  0 0.000 1.000
#> ERR519512     1  0.3726      0.770 0.788  0 0.000 0.212
#> ERR519521     4  0.0000      0.890 0.000  0 0.000 1.000
#> ERR519488     1  0.0000      0.946 1.000  0 0.000 0.000
#> ERR519493     1  0.3266      0.829 0.832  0 0.000 0.168
#> ERR519514     1  0.0000      0.946 1.000  0 0.000 0.000
#> ERR519479     4  0.0188      0.888 0.004  0 0.000 0.996
#> ERR519509     1  0.0000      0.946 1.000  0 0.000 0.000
#> ERR519472     1  0.1792      0.923 0.932  0 0.000 0.068
#> ERR519510     4  0.0188      0.888 0.004  0 0.000 0.996
#> ERR519470     1  0.0000      0.946 1.000  0 0.000 0.000
#> ERR519495     1  0.0000      0.946 1.000  0 0.000 0.000
#> ERR519522     1  0.0000      0.946 1.000  0 0.000 0.000
#> ERR519523     1  0.1389      0.933 0.952  0 0.000 0.048
#> ERR519503     1  0.0000      0.946 1.000  0 0.000 0.000
#> ERR519471     1  0.0000      0.946 1.000  0 0.000 0.000
#> ERR519500     1  0.1557      0.931 0.944  0 0.000 0.056
#> ERR519485     1  0.0000      0.946 1.000  0 0.000 0.000
#> ERR519476     2  0.0000      1.000 0.000  1 0.000 0.000
#> ERR519502     4  0.0000      0.890 0.000  0 0.000 1.000
#> ERR519486     1  0.1118      0.938 0.964  0 0.000 0.036
#> ERR519478     1  0.0000      0.946 1.000  0 0.000 0.000
#> ERR519497     4  0.0000      0.890 0.000  0 0.000 1.000
#> ERR519467     1  0.0000      0.946 1.000  0 0.000 0.000
#> ERR519489     1  0.4746      0.475 0.632  0 0.000 0.368
#> ERR519494     4  0.4605      0.471 0.000  0 0.336 0.664
#> ERR519474     4  0.4999     -0.103 0.492  0 0.000 0.508
#> ERR519505     4  0.0000      0.890 0.000  0 0.000 1.000
#> ERR519517     3  0.0000      1.000 0.000  0 1.000 0.000
#> ERR519484     4  0.0000      0.890 0.000  0 0.000 1.000
#> ERR519498     4  0.1109      0.866 0.004  0 0.028 0.968
#> ERR519490     3  0.0000      1.000 0.000  0 1.000 0.000
#> ERR519507     4  0.3123      0.704 0.156  0 0.000 0.844
#> ERR519511     4  0.0000      0.890 0.000  0 0.000 1.000
#> ERR519468     3  0.0000      1.000 0.000  0 1.000 0.000
#> ERR519482     3  0.0000      1.000 0.000  0 1.000 0.000
#> ERR519475     2  0.0000      1.000 0.000  1 0.000 0.000
#> ERR519496     1  0.0000      0.946 1.000  0 0.000 0.000
#> ERR519506     1  0.1716      0.926 0.936  0 0.000 0.064
#> ERR519469     1  0.1389      0.933 0.952  0 0.000 0.048
#> ERR519480     3  0.0000      1.000 0.000  0 1.000 0.000
#> ERR519487     3  0.0000      1.000 0.000  0 1.000 0.000
#> ERR519483     1  0.0336      0.945 0.992  0 0.000 0.008
#> ERR519477     2  0.0000      1.000 0.000  1 0.000 0.000
#> ERR519499     3  0.0000      1.000 0.000  0 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1 p2    p3    p4    p5
#> ERR519515     1  0.0000      0.868 1.000  0 0.000 0.000 0.000
#> ERR519516     1  0.4793      0.702 0.700  0 0.000 0.068 0.232
#> ERR519520     4  0.0290      0.944 0.008  0 0.000 0.992 0.000
#> ERR519513     5  0.3707      0.510 0.000  0 0.284 0.000 0.716
#> ERR519481     5  0.0000      0.816 0.000  0 0.000 0.000 1.000
#> ERR519491     1  0.0609      0.865 0.980  0 0.000 0.020 0.000
#> ERR519473     1  0.3999      0.617 0.656  0 0.000 0.000 0.344
#> ERR519518     4  0.1043      0.924 0.000  0 0.000 0.960 0.040
#> ERR519512     4  0.0290      0.944 0.008  0 0.000 0.992 0.000
#> ERR519521     4  0.0671      0.937 0.004  0 0.000 0.980 0.016
#> ERR519488     1  0.0290      0.866 0.992  0 0.000 0.008 0.000
#> ERR519493     1  0.4437      0.637 0.664  0 0.000 0.020 0.316
#> ERR519514     1  0.0000      0.868 1.000  0 0.000 0.000 0.000
#> ERR519479     5  0.0898      0.803 0.008  0 0.000 0.020 0.972
#> ERR519509     1  0.0290      0.866 0.992  0 0.000 0.008 0.000
#> ERR519472     1  0.4526      0.653 0.672  0 0.000 0.028 0.300
#> ERR519510     5  0.0324      0.813 0.004  0 0.000 0.004 0.992
#> ERR519470     1  0.0000      0.868 1.000  0 0.000 0.000 0.000
#> ERR519495     1  0.0000      0.868 1.000  0 0.000 0.000 0.000
#> ERR519522     1  0.0290      0.866 0.992  0 0.000 0.008 0.000
#> ERR519523     4  0.0671      0.937 0.016  0 0.000 0.980 0.004
#> ERR519503     1  0.0290      0.866 0.992  0 0.000 0.008 0.000
#> ERR519471     1  0.0000      0.868 1.000  0 0.000 0.000 0.000
#> ERR519500     1  0.4524      0.556 0.644  0 0.000 0.336 0.020
#> ERR519485     1  0.0609      0.865 0.980  0 0.000 0.020 0.000
#> ERR519476     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> ERR519502     5  0.0000      0.816 0.000  0 0.000 0.000 1.000
#> ERR519486     1  0.3151      0.799 0.836  0 0.000 0.020 0.144
#> ERR519478     1  0.0290      0.866 0.992  0 0.000 0.008 0.000
#> ERR519497     4  0.3003      0.758 0.000  0 0.000 0.812 0.188
#> ERR519467     1  0.2471      0.807 0.864  0 0.000 0.136 0.000
#> ERR519489     4  0.0290      0.944 0.008  0 0.000 0.992 0.000
#> ERR519494     5  0.4060      0.414 0.000  0 0.360 0.000 0.640
#> ERR519474     5  0.4829     -0.264 0.480  0 0.000 0.020 0.500
#> ERR519505     5  0.0000      0.816 0.000  0 0.000 0.000 1.000
#> ERR519517     3  0.0000      1.000 0.000  0 1.000 0.000 0.000
#> ERR519484     5  0.0000      0.816 0.000  0 0.000 0.000 1.000
#> ERR519498     5  0.3636      0.482 0.000  0 0.000 0.272 0.728
#> ERR519490     3  0.0000      1.000 0.000  0 1.000 0.000 0.000
#> ERR519507     5  0.1106      0.797 0.024  0 0.000 0.012 0.964
#> ERR519511     5  0.0000      0.816 0.000  0 0.000 0.000 1.000
#> ERR519468     3  0.0000      1.000 0.000  0 1.000 0.000 0.000
#> ERR519482     3  0.0000      1.000 0.000  0 1.000 0.000 0.000
#> ERR519475     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> ERR519496     1  0.0000      0.868 1.000  0 0.000 0.000 0.000
#> ERR519506     1  0.4213      0.656 0.680  0 0.000 0.012 0.308
#> ERR519469     1  0.4404      0.688 0.704  0 0.000 0.032 0.264
#> ERR519480     3  0.0000      1.000 0.000  0 1.000 0.000 0.000
#> ERR519487     3  0.0000      1.000 0.000  0 1.000 0.000 0.000
#> ERR519483     1  0.1012      0.863 0.968  0 0.000 0.020 0.012
#> ERR519477     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> ERR519499     3  0.0000      1.000 0.000  0 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1 p2    p3    p4    p5    p6
#> ERR519515     1  0.0000      0.899 1.000  0 0.000 0.000 0.000 0.000
#> ERR519516     1  0.5873      0.109 0.508  0 0.000 0.028 0.108 0.356
#> ERR519520     4  0.0000      0.866 0.000  0 0.000 1.000 0.000 0.000
#> ERR519513     5  0.2178      0.688 0.000  0 0.132 0.000 0.868 0.000
#> ERR519481     5  0.3804      0.232 0.000  0 0.000 0.000 0.576 0.424
#> ERR519491     1  0.0260      0.897 0.992  0 0.000 0.000 0.000 0.008
#> ERR519473     6  0.1663      0.757 0.000  0 0.000 0.000 0.088 0.912
#> ERR519518     4  0.1765      0.821 0.000  0 0.000 0.904 0.096 0.000
#> ERR519512     4  0.0000      0.866 0.000  0 0.000 1.000 0.000 0.000
#> ERR519521     4  0.0000      0.866 0.000  0 0.000 1.000 0.000 0.000
#> ERR519488     1  0.1556      0.883 0.920  0 0.000 0.000 0.000 0.080
#> ERR519493     5  0.5008      0.442 0.280  0 0.000 0.000 0.612 0.108
#> ERR519514     1  0.0000      0.899 1.000  0 0.000 0.000 0.000 0.000
#> ERR519479     6  0.4072      0.260 0.008  0 0.000 0.000 0.448 0.544
#> ERR519509     1  0.1556      0.883 0.920  0 0.000 0.000 0.000 0.080
#> ERR519472     6  0.1845      0.766 0.052  0 0.000 0.000 0.028 0.920
#> ERR519510     5  0.0000      0.753 0.000  0 0.000 0.000 1.000 0.000
#> ERR519470     1  0.0000      0.899 1.000  0 0.000 0.000 0.000 0.000
#> ERR519495     1  0.3198      0.582 0.740  0 0.000 0.000 0.000 0.260
#> ERR519522     1  0.1556      0.883 0.920  0 0.000 0.000 0.000 0.080
#> ERR519523     4  0.1584      0.819 0.064  0 0.000 0.928 0.000 0.008
#> ERR519503     1  0.1556      0.883 0.920  0 0.000 0.000 0.000 0.080
#> ERR519471     1  0.0000      0.899 1.000  0 0.000 0.000 0.000 0.000
#> ERR519500     6  0.4034      0.540 0.020  0 0.000 0.328 0.000 0.652
#> ERR519485     1  0.0260      0.897 0.992  0 0.000 0.000 0.000 0.008
#> ERR519476     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> ERR519502     5  0.0146      0.752 0.000  0 0.000 0.000 0.996 0.004
#> ERR519486     5  0.4814      0.284 0.412  0 0.000 0.000 0.532 0.056
#> ERR519478     1  0.1387      0.885 0.932  0 0.000 0.000 0.000 0.068
#> ERR519497     4  0.3607      0.505 0.000  0 0.000 0.652 0.348 0.000
#> ERR519467     1  0.2165      0.834 0.884  0 0.000 0.108 0.000 0.008
#> ERR519489     6  0.3804      0.387 0.000  0 0.000 0.424 0.000 0.576
#> ERR519494     5  0.5702      0.358 0.000  0 0.292 0.000 0.512 0.196
#> ERR519474     6  0.3672      0.710 0.056  0 0.000 0.000 0.168 0.776
#> ERR519505     5  0.0000      0.753 0.000  0 0.000 0.000 1.000 0.000
#> ERR519517     3  0.0000      0.998 0.000  0 1.000 0.000 0.000 0.000
#> ERR519484     5  0.1267      0.724 0.000  0 0.000 0.000 0.940 0.060
#> ERR519498     5  0.1714      0.711 0.000  0 0.000 0.092 0.908 0.000
#> ERR519490     3  0.0000      0.998 0.000  0 1.000 0.000 0.000 0.000
#> ERR519507     6  0.1814      0.758 0.000  0 0.000 0.000 0.100 0.900
#> ERR519511     5  0.0000      0.753 0.000  0 0.000 0.000 1.000 0.000
#> ERR519468     3  0.0260      0.991 0.000  0 0.992 0.000 0.000 0.008
#> ERR519482     3  0.0000      0.998 0.000  0 1.000 0.000 0.000 0.000
#> ERR519475     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> ERR519496     1  0.0000      0.899 1.000  0 0.000 0.000 0.000 0.000
#> ERR519506     6  0.3869      0.723 0.100  0 0.000 0.000 0.128 0.772
#> ERR519469     6  0.1926      0.762 0.068  0 0.000 0.000 0.020 0.912
#> ERR519480     3  0.0000      0.998 0.000  0 1.000 0.000 0.000 0.000
#> ERR519487     3  0.0000      0.998 0.000  0 1.000 0.000 0.000 0.000
#> ERR519483     1  0.2118      0.827 0.888  0 0.000 0.000 0.008 0.104
#> ERR519477     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> ERR519499     3  0.0000      0.998 0.000  0 1.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-pam-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-pam-collect-classes

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


SD:mclust**

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

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

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

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

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.1117 0.889   0.889
#> 3 3 0.344           0.664       0.804         2.8877 0.706   0.669
#> 4 4 0.475           0.826       0.849         0.4174 0.767   0.623
#> 5 5 0.528           0.764       0.840         0.0915 0.928   0.833
#> 6 6 0.540           0.667       0.728         0.1486 0.720   0.343

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
#> ERR519515     1       0          1  1  0
#> ERR519516     1       0          1  1  0
#> ERR519520     1       0          1  1  0
#> ERR519513     1       0          1  1  0
#> ERR519481     1       0          1  1  0
#> ERR519491     1       0          1  1  0
#> ERR519473     1       0          1  1  0
#> ERR519518     1       0          1  1  0
#> ERR519512     1       0          1  1  0
#> ERR519521     1       0          1  1  0
#> ERR519488     1       0          1  1  0
#> ERR519493     1       0          1  1  0
#> ERR519514     1       0          1  1  0
#> ERR519479     1       0          1  1  0
#> ERR519509     1       0          1  1  0
#> ERR519472     1       0          1  1  0
#> ERR519510     1       0          1  1  0
#> ERR519470     1       0          1  1  0
#> ERR519495     1       0          1  1  0
#> ERR519522     1       0          1  1  0
#> ERR519523     1       0          1  1  0
#> ERR519503     1       0          1  1  0
#> ERR519471     1       0          1  1  0
#> ERR519500     1       0          1  1  0
#> ERR519485     1       0          1  1  0
#> ERR519476     2       0          1  0  1
#> ERR519502     1       0          1  1  0
#> ERR519486     1       0          1  1  0
#> ERR519478     1       0          1  1  0
#> ERR519497     1       0          1  1  0
#> ERR519467     1       0          1  1  0
#> ERR519489     1       0          1  1  0
#> ERR519494     1       0          1  1  0
#> ERR519474     1       0          1  1  0
#> ERR519505     1       0          1  1  0
#> ERR519517     1       0          1  1  0
#> ERR519484     1       0          1  1  0
#> ERR519498     1       0          1  1  0
#> ERR519490     1       0          1  1  0
#> ERR519507     1       0          1  1  0
#> ERR519511     1       0          1  1  0
#> ERR519468     1       0          1  1  0
#> ERR519482     1       0          1  1  0
#> ERR519475     2       0          1  0  1
#> ERR519496     1       0          1  1  0
#> ERR519506     1       0          1  1  0
#> ERR519469     1       0          1  1  0
#> ERR519480     1       0          1  1  0
#> ERR519487     1       0          1  1  0
#> ERR519483     1       0          1  1  0
#> ERR519477     2       0          1  0  1
#> ERR519499     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
#> ERR519515     1  0.0424      0.665 0.992  0 0.008
#> ERR519516     1  0.0892      0.654 0.980  0 0.020
#> ERR519520     1  0.4702      0.746 0.788  0 0.212
#> ERR519513     1  0.5760      0.680 0.672  0 0.328
#> ERR519481     3  0.6026      0.651 0.376  0 0.624
#> ERR519491     1  0.0892      0.654 0.980  0 0.020
#> ERR519473     3  0.5988      0.665 0.368  0 0.632
#> ERR519518     1  0.4702      0.746 0.788  0 0.212
#> ERR519512     1  0.4702      0.746 0.788  0 0.212
#> ERR519521     1  0.4702      0.746 0.788  0 0.212
#> ERR519488     1  0.4291      0.743 0.820  0 0.180
#> ERR519493     1  0.0892      0.654 0.980  0 0.020
#> ERR519514     1  0.0892      0.654 0.980  0 0.020
#> ERR519479     3  0.6111      0.748 0.396  0 0.604
#> ERR519509     1  0.4291      0.743 0.820  0 0.180
#> ERR519472     3  0.6111      0.748 0.396  0 0.604
#> ERR519510     3  0.6299      0.713 0.476  0 0.524
#> ERR519470     1  0.1411      0.691 0.964  0 0.036
#> ERR519495     3  0.6126      0.743 0.400  0 0.600
#> ERR519522     1  0.4178      0.743 0.828  0 0.172
#> ERR519523     1  0.1529      0.690 0.960  0 0.040
#> ERR519503     1  0.4702      0.746 0.788  0 0.212
#> ERR519471     1  0.0747      0.658 0.984  0 0.016
#> ERR519500     1  0.6244     -0.617 0.560  0 0.440
#> ERR519485     1  0.0424      0.665 0.992  0 0.008
#> ERR519476     2  0.0000      1.000 0.000  1 0.000
#> ERR519502     3  0.6008      0.669 0.372  0 0.628
#> ERR519486     1  0.0892      0.654 0.980  0 0.020
#> ERR519478     1  0.4121      0.738 0.832  0 0.168
#> ERR519497     1  0.4842      0.746 0.776  0 0.224
#> ERR519467     1  0.3482      0.736 0.872  0 0.128
#> ERR519489     1  0.1964      0.687 0.944  0 0.056
#> ERR519494     1  0.6126      0.626 0.600  0 0.400
#> ERR519474     1  0.5926     -0.410 0.644  0 0.356
#> ERR519505     1  0.4702      0.746 0.788  0 0.212
#> ERR519517     1  0.6126      0.626 0.600  0 0.400
#> ERR519484     3  0.5988      0.665 0.368  0 0.632
#> ERR519498     1  0.4702      0.746 0.788  0 0.212
#> ERR519490     1  0.6126      0.626 0.600  0 0.400
#> ERR519507     3  0.5058      0.732 0.244  0 0.756
#> ERR519511     3  0.6026      0.756 0.376  0 0.624
#> ERR519468     1  0.6062      0.639 0.616  0 0.384
#> ERR519482     1  0.6126      0.626 0.600  0 0.400
#> ERR519475     2  0.0000      1.000 0.000  1 0.000
#> ERR519496     1  0.1031      0.649 0.976  0 0.024
#> ERR519506     1  0.4178      0.743 0.828  0 0.172
#> ERR519469     1  0.1753      0.631 0.952  0 0.048
#> ERR519480     1  0.6126      0.626 0.600  0 0.400
#> ERR519487     1  0.6126      0.626 0.600  0 0.400
#> ERR519483     1  0.4121      0.742 0.832  0 0.168
#> ERR519477     2  0.0000      1.000 0.000  1 0.000
#> ERR519499     1  0.6126      0.626 0.600  0 0.400

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1 p2    p3    p4
#> ERR519515     1  0.0000      0.784 1.000  0 0.000 0.000
#> ERR519516     1  0.2921      0.801 0.860  0 0.000 0.140
#> ERR519520     1  0.4332      0.758 0.800  0 0.160 0.040
#> ERR519513     3  0.2011      0.879 0.000  0 0.920 0.080
#> ERR519481     4  0.2759      0.906 0.052  0 0.044 0.904
#> ERR519491     1  0.2345      0.803 0.900  0 0.000 0.100
#> ERR519473     4  0.2840      0.909 0.056  0 0.044 0.900
#> ERR519518     1  0.6723      0.726 0.600  0 0.260 0.140
#> ERR519512     1  0.6324      0.783 0.660  0 0.168 0.172
#> ERR519521     1  0.6531      0.769 0.636  0 0.204 0.160
#> ERR519488     1  0.4244      0.761 0.804  0 0.160 0.036
#> ERR519493     1  0.2921      0.801 0.860  0 0.000 0.140
#> ERR519514     1  0.1211      0.791 0.960  0 0.000 0.040
#> ERR519479     4  0.1867      0.892 0.072  0 0.000 0.928
#> ERR519509     1  0.3803      0.779 0.836  0 0.132 0.032
#> ERR519472     4  0.2011      0.889 0.080  0 0.000 0.920
#> ERR519510     4  0.4661      0.506 0.348  0 0.000 0.652
#> ERR519470     1  0.0469      0.782 0.988  0 0.000 0.012
#> ERR519495     1  0.4817      0.590 0.612  0 0.000 0.388
#> ERR519522     1  0.3335      0.786 0.856  0 0.128 0.016
#> ERR519523     1  0.3790      0.798 0.820  0 0.016 0.164
#> ERR519503     1  0.4332      0.758 0.800  0 0.160 0.040
#> ERR519471     1  0.1211      0.791 0.960  0 0.000 0.040
#> ERR519500     1  0.4500      0.615 0.684  0 0.000 0.316
#> ERR519485     1  0.3356      0.799 0.824  0 0.000 0.176
#> ERR519476     2  0.0000      1.000 0.000  1 0.000 0.000
#> ERR519502     4  0.2996      0.883 0.044  0 0.064 0.892
#> ERR519486     1  0.2921      0.801 0.860  0 0.000 0.140
#> ERR519478     1  0.3166      0.788 0.868  0 0.116 0.016
#> ERR519497     1  0.6531      0.769 0.636  0 0.204 0.160
#> ERR519467     1  0.1677      0.793 0.948  0 0.040 0.012
#> ERR519489     1  0.5355      0.810 0.736  0 0.084 0.180
#> ERR519494     3  0.1940      0.899 0.000  0 0.924 0.076
#> ERR519474     1  0.3975      0.769 0.760  0 0.000 0.240
#> ERR519505     1  0.6275      0.778 0.660  0 0.204 0.136
#> ERR519517     3  0.1022      0.949 0.000  0 0.968 0.032
#> ERR519484     4  0.2840      0.909 0.056  0 0.044 0.900
#> ERR519498     1  0.6531      0.769 0.636  0 0.204 0.160
#> ERR519490     3  0.0592      0.940 0.000  0 0.984 0.016
#> ERR519507     4  0.2751      0.910 0.056  0 0.040 0.904
#> ERR519511     4  0.2450      0.901 0.072  0 0.016 0.912
#> ERR519468     3  0.1118      0.931 0.000  0 0.964 0.036
#> ERR519482     3  0.0000      0.946 0.000  0 1.000 0.000
#> ERR519475     2  0.0000      1.000 0.000  1 0.000 0.000
#> ERR519496     1  0.2921      0.801 0.860  0 0.000 0.140
#> ERR519506     1  0.5615      0.785 0.716  0 0.096 0.188
#> ERR519469     1  0.4500      0.719 0.684  0 0.000 0.316
#> ERR519480     3  0.1022      0.949 0.000  0 0.968 0.032
#> ERR519487     3  0.1022      0.949 0.000  0 0.968 0.032
#> ERR519483     1  0.5144      0.793 0.732  0 0.052 0.216
#> ERR519477     2  0.0000      1.000 0.000  1 0.000 0.000
#> ERR519499     3  0.1022      0.949 0.000  0 0.968 0.032

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1 p2    p3    p4    p5
#> ERR519515     1  0.3912      0.610 0.752  0 0.000 0.020 0.228
#> ERR519516     1  0.1549      0.751 0.944  0 0.000 0.016 0.040
#> ERR519520     1  0.4804      0.700 0.704  0 0.040 0.012 0.244
#> ERR519513     3  0.3452      0.850 0.060  0 0.860 0.036 0.044
#> ERR519481     4  0.1549      0.790 0.040  0 0.016 0.944 0.000
#> ERR519491     1  0.1800      0.751 0.932  0 0.000 0.020 0.048
#> ERR519473     4  0.0963      0.794 0.036  0 0.000 0.964 0.000
#> ERR519518     1  0.5715      0.660 0.672  0 0.216 0.048 0.064
#> ERR519512     1  0.5270      0.710 0.704  0 0.040 0.048 0.208
#> ERR519521     1  0.5637      0.701 0.704  0 0.144 0.048 0.104
#> ERR519488     5  0.1341      1.000 0.056  0 0.000 0.000 0.944
#> ERR519493     1  0.1648      0.751 0.940  0 0.000 0.020 0.040
#> ERR519514     1  0.2012      0.750 0.920  0 0.000 0.020 0.060
#> ERR519479     4  0.3368      0.792 0.156  0 0.000 0.820 0.024
#> ERR519509     5  0.1341      1.000 0.056  0 0.000 0.000 0.944
#> ERR519472     4  0.3602      0.776 0.180  0 0.000 0.796 0.024
#> ERR519510     1  0.4338      0.620 0.696  0 0.000 0.280 0.024
#> ERR519470     1  0.4675      0.496 0.600  0 0.000 0.020 0.380
#> ERR519495     1  0.3197      0.728 0.836  0 0.000 0.140 0.024
#> ERR519522     1  0.4437      0.418 0.532  0 0.004 0.000 0.464
#> ERR519523     1  0.2387      0.770 0.908  0 0.004 0.040 0.048
#> ERR519503     1  0.4900      0.403 0.512  0 0.024 0.000 0.464
#> ERR519471     1  0.2079      0.748 0.916  0 0.000 0.020 0.064
#> ERR519500     1  0.2653      0.742 0.880  0 0.000 0.096 0.024
#> ERR519485     1  0.1648      0.751 0.940  0 0.000 0.020 0.040
#> ERR519476     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> ERR519502     4  0.2193      0.778 0.044  0 0.028 0.920 0.008
#> ERR519486     1  0.0898      0.763 0.972  0 0.000 0.008 0.020
#> ERR519478     1  0.4696      0.442 0.556  0 0.000 0.016 0.428
#> ERR519497     1  0.5495      0.690 0.704  0 0.180 0.048 0.068
#> ERR519467     1  0.3039      0.735 0.808  0 0.000 0.000 0.192
#> ERR519489     1  0.3450      0.765 0.848  0 0.008 0.060 0.084
#> ERR519494     3  0.2591      0.906 0.032  0 0.904 0.020 0.044
#> ERR519474     1  0.2900      0.740 0.864  0 0.000 0.108 0.028
#> ERR519505     1  0.5484      0.690 0.704  0 0.180 0.044 0.072
#> ERR519517     3  0.0404      0.927 0.000  0 0.988 0.000 0.012
#> ERR519484     4  0.1205      0.797 0.040  0 0.004 0.956 0.000
#> ERR519498     1  0.5495      0.690 0.704  0 0.180 0.048 0.068
#> ERR519490     3  0.1569      0.929 0.008  0 0.944 0.004 0.044
#> ERR519507     4  0.3152      0.800 0.136  0 0.000 0.840 0.024
#> ERR519511     4  0.4608      0.517 0.336  0 0.000 0.640 0.024
#> ERR519468     3  0.2278      0.916 0.008  0 0.916 0.032 0.044
#> ERR519482     3  0.1412      0.931 0.008  0 0.952 0.004 0.036
#> ERR519475     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> ERR519496     1  0.1331      0.757 0.952  0 0.000 0.008 0.040
#> ERR519506     1  0.5237      0.716 0.724  0 0.044 0.172 0.060
#> ERR519469     1  0.4370      0.667 0.724  0 0.000 0.236 0.040
#> ERR519480     3  0.0290      0.926 0.000  0 0.992 0.000 0.008
#> ERR519487     3  0.0290      0.926 0.000  0 0.992 0.000 0.008
#> ERR519483     1  0.4816      0.722 0.748  0 0.024 0.168 0.060
#> ERR519477     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> ERR519499     3  0.0290      0.926 0.000  0 0.992 0.000 0.008

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1 p2    p3    p4    p5    p6
#> ERR519515     1  0.2302      0.736 0.872  0 0.000 0.008 0.000 0.120
#> ERR519516     1  0.0820      0.819 0.972  0 0.000 0.012 0.016 0.000
#> ERR519520     4  0.3667      0.697 0.132  0 0.000 0.788 0.000 0.080
#> ERR519513     4  0.3421      0.528 0.000  0 0.116 0.824 0.016 0.044
#> ERR519481     5  0.3702      0.550 0.000  0 0.004 0.264 0.720 0.012
#> ERR519491     1  0.1049      0.822 0.960  0 0.000 0.008 0.000 0.032
#> ERR519473     5  0.3454      0.581 0.000  0 0.004 0.224 0.760 0.012
#> ERR519518     4  0.3755      0.651 0.052  0 0.112 0.812 0.016 0.008
#> ERR519512     4  0.3455      0.717 0.144  0 0.000 0.800 0.000 0.056
#> ERR519521     4  0.2755      0.736 0.140  0 0.004 0.844 0.000 0.012
#> ERR519488     6  0.1480      0.729 0.020  0 0.000 0.040 0.000 0.940
#> ERR519493     1  0.0820      0.819 0.972  0 0.000 0.012 0.016 0.000
#> ERR519514     1  0.0632      0.822 0.976  0 0.000 0.000 0.000 0.024
#> ERR519479     5  0.2118      0.726 0.104  0 0.000 0.008 0.888 0.000
#> ERR519509     6  0.1644      0.736 0.028  0 0.000 0.040 0.000 0.932
#> ERR519472     5  0.2257      0.730 0.116  0 0.000 0.008 0.876 0.000
#> ERR519510     5  0.3206      0.717 0.152  0 0.000 0.028 0.816 0.004
#> ERR519470     1  0.3168      0.656 0.792  0 0.000 0.016 0.000 0.192
#> ERR519495     5  0.3979      0.652 0.256  0 0.000 0.028 0.712 0.004
#> ERR519522     6  0.4831      0.595 0.096  0 0.000 0.268 0.000 0.636
#> ERR519523     4  0.4628      0.643 0.312  0 0.000 0.632 0.052 0.004
#> ERR519503     6  0.3511      0.732 0.024  0 0.000 0.216 0.000 0.760
#> ERR519471     1  0.0632      0.822 0.976  0 0.000 0.000 0.000 0.024
#> ERR519500     5  0.4617      0.537 0.324  0 0.000 0.048 0.624 0.004
#> ERR519485     1  0.0622      0.822 0.980  0 0.000 0.012 0.008 0.000
#> ERR519476     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> ERR519502     5  0.3608      0.541 0.000  0 0.000 0.272 0.716 0.012
#> ERR519486     1  0.4246     -0.142 0.580  0 0.000 0.400 0.020 0.000
#> ERR519478     1  0.3905      0.435 0.668  0 0.000 0.016 0.000 0.316
#> ERR519497     4  0.3900      0.745 0.136  0 0.056 0.788 0.020 0.000
#> ERR519467     4  0.5292      0.488 0.372  0 0.000 0.520 0.000 0.108
#> ERR519489     4  0.4409      0.721 0.212  0 0.000 0.716 0.060 0.012
#> ERR519494     4  0.4741     -0.323 0.000  0 0.420 0.536 0.004 0.040
#> ERR519474     5  0.6063      0.218 0.368  0 0.000 0.216 0.412 0.004
#> ERR519505     4  0.4502      0.735 0.140  0 0.100 0.740 0.020 0.000
#> ERR519517     3  0.0865      0.777 0.000  0 0.964 0.036 0.000 0.000
#> ERR519484     5  0.3398      0.588 0.000  0 0.004 0.216 0.768 0.012
#> ERR519498     4  0.3965      0.743 0.132  0 0.052 0.792 0.016 0.008
#> ERR519490     3  0.4493      0.708 0.000  0 0.612 0.344 0.000 0.044
#> ERR519507     5  0.2006      0.723 0.104  0 0.004 0.000 0.892 0.000
#> ERR519511     5  0.2553      0.730 0.144  0 0.000 0.008 0.848 0.000
#> ERR519468     3  0.4686      0.692 0.000  0 0.588 0.364 0.004 0.044
#> ERR519482     3  0.4424      0.718 0.000  0 0.632 0.324 0.000 0.044
#> ERR519475     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> ERR519496     1  0.1391      0.800 0.944  0 0.000 0.016 0.040 0.000
#> ERR519506     4  0.5444      0.656 0.204  0 0.000 0.616 0.168 0.012
#> ERR519469     4  0.5269      0.571 0.156  0 0.000 0.596 0.248 0.000
#> ERR519480     3  0.0363      0.775 0.000  0 0.988 0.012 0.000 0.000
#> ERR519487     3  0.0146      0.772 0.000  0 0.996 0.004 0.000 0.000
#> ERR519483     4  0.5381      0.649 0.204  0 0.000 0.616 0.172 0.008
#> ERR519477     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> ERR519499     3  0.0146      0.772 0.000  0 0.996 0.004 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-mclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-mclust-collect-classes

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


SD:NMF

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

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

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

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 18140 rows and 52 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.701           0.882       0.946         0.4570 0.538   0.538
#> 3 3 0.450           0.590       0.805         0.4035 0.619   0.394
#> 4 4 0.440           0.594       0.741         0.1449 0.825   0.538
#> 5 5 0.526           0.472       0.724         0.0629 0.921   0.703
#> 6 6 0.593           0.458       0.700         0.0345 0.914   0.650

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
#> ERR519515     1   0.000      0.950 1.000 0.000
#> ERR519516     1   0.000      0.950 1.000 0.000
#> ERR519520     1   0.000      0.950 1.000 0.000
#> ERR519513     2   0.000      0.915 0.000 1.000
#> ERR519481     2   0.745      0.777 0.212 0.788
#> ERR519491     1   0.000      0.950 1.000 0.000
#> ERR519473     2   0.163      0.909 0.024 0.976
#> ERR519518     2   0.000      0.915 0.000 1.000
#> ERR519512     1   0.000      0.950 1.000 0.000
#> ERR519521     1   0.634      0.792 0.840 0.160
#> ERR519488     1   0.000      0.950 1.000 0.000
#> ERR519493     1   0.000      0.950 1.000 0.000
#> ERR519514     1   0.000      0.950 1.000 0.000
#> ERR519479     1   0.000      0.950 1.000 0.000
#> ERR519509     1   0.000      0.950 1.000 0.000
#> ERR519472     1   0.000      0.950 1.000 0.000
#> ERR519510     1   0.388      0.890 0.924 0.076
#> ERR519470     1   0.000      0.950 1.000 0.000
#> ERR519495     1   0.000      0.950 1.000 0.000
#> ERR519522     1   0.000      0.950 1.000 0.000
#> ERR519523     1   0.000      0.950 1.000 0.000
#> ERR519503     1   0.000      0.950 1.000 0.000
#> ERR519471     1   0.000      0.950 1.000 0.000
#> ERR519500     1   0.000      0.950 1.000 0.000
#> ERR519485     1   0.000      0.950 1.000 0.000
#> ERR519476     1   0.000      0.950 1.000 0.000
#> ERR519502     2   0.615      0.835 0.152 0.848
#> ERR519486     1   0.000      0.950 1.000 0.000
#> ERR519478     1   0.000      0.950 1.000 0.000
#> ERR519497     2   0.738      0.781 0.208 0.792
#> ERR519467     1   0.000      0.950 1.000 0.000
#> ERR519489     1   0.518      0.846 0.884 0.116
#> ERR519494     2   0.000      0.915 0.000 1.000
#> ERR519474     1   0.000      0.950 1.000 0.000
#> ERR519505     2   0.913      0.571 0.328 0.672
#> ERR519517     2   0.000      0.915 0.000 1.000
#> ERR519484     2   0.689      0.808 0.184 0.816
#> ERR519498     2   0.204      0.906 0.032 0.968
#> ERR519490     2   0.000      0.915 0.000 1.000
#> ERR519507     1   0.224      0.924 0.964 0.036
#> ERR519511     1   0.767      0.695 0.776 0.224
#> ERR519468     2   0.000      0.915 0.000 1.000
#> ERR519482     2   0.000      0.915 0.000 1.000
#> ERR519475     1   0.891      0.534 0.692 0.308
#> ERR519496     1   0.000      0.950 1.000 0.000
#> ERR519506     1   0.163      0.934 0.976 0.024
#> ERR519469     1   0.991      0.138 0.556 0.444
#> ERR519480     2   0.000      0.915 0.000 1.000
#> ERR519487     2   0.000      0.915 0.000 1.000
#> ERR519483     1   0.456      0.868 0.904 0.096
#> ERR519477     2   0.722      0.777 0.200 0.800
#> ERR519499     2   0.000      0.915 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
#> ERR519515     2  0.1031     0.8006 0.024 0.976 0.000
#> ERR519516     1  0.6026     0.4378 0.624 0.376 0.000
#> ERR519520     2  0.0000     0.7976 0.000 1.000 0.000
#> ERR519513     1  0.6302    -0.4454 0.520 0.000 0.480
#> ERR519481     1  0.0237     0.7160 0.996 0.000 0.004
#> ERR519491     2  0.5497     0.5119 0.292 0.708 0.000
#> ERR519473     1  0.0000     0.7192 1.000 0.000 0.000
#> ERR519518     3  0.6140     0.6334 0.404 0.000 0.596
#> ERR519512     2  0.0747     0.8006 0.016 0.984 0.000
#> ERR519521     1  0.2446     0.7293 0.936 0.052 0.012
#> ERR519488     2  0.0000     0.7976 0.000 1.000 0.000
#> ERR519493     1  0.6008     0.4475 0.628 0.372 0.000
#> ERR519514     2  0.2261     0.7840 0.068 0.932 0.000
#> ERR519479     1  0.1860     0.7376 0.948 0.052 0.000
#> ERR519509     2  0.0000     0.7976 0.000 1.000 0.000
#> ERR519472     1  0.4452     0.6920 0.808 0.192 0.000
#> ERR519510     1  0.1529     0.7351 0.960 0.040 0.000
#> ERR519470     2  0.1163     0.8001 0.028 0.972 0.000
#> ERR519495     1  0.5397     0.6061 0.720 0.280 0.000
#> ERR519522     2  0.0237     0.7991 0.004 0.996 0.000
#> ERR519523     2  0.5968     0.3524 0.364 0.636 0.000
#> ERR519503     2  0.5098     0.5345 0.000 0.752 0.248
#> ERR519471     2  0.2356     0.7817 0.072 0.928 0.000
#> ERR519500     1  0.5529     0.5847 0.704 0.296 0.000
#> ERR519485     2  0.6280     0.0368 0.460 0.540 0.000
#> ERR519476     2  0.8345     0.3077 0.096 0.560 0.344
#> ERR519502     1  0.0237     0.7160 0.996 0.000 0.004
#> ERR519486     2  0.5650     0.4730 0.312 0.688 0.000
#> ERR519478     2  0.0237     0.7991 0.004 0.996 0.000
#> ERR519497     3  0.7413     0.6983 0.204 0.104 0.692
#> ERR519467     2  0.1163     0.8001 0.028 0.972 0.000
#> ERR519489     1  0.5678     0.5674 0.684 0.316 0.000
#> ERR519494     1  0.6299    -0.4442 0.524 0.000 0.476
#> ERR519474     1  0.5760     0.5332 0.672 0.328 0.000
#> ERR519505     2  0.9778    -0.3213 0.236 0.408 0.356
#> ERR519517     3  0.2066     0.7443 0.060 0.000 0.940
#> ERR519484     1  0.0000     0.7192 1.000 0.000 0.000
#> ERR519498     3  0.6205     0.7061 0.336 0.008 0.656
#> ERR519490     3  0.5138     0.7481 0.252 0.000 0.748
#> ERR519507     1  0.0000     0.7192 1.000 0.000 0.000
#> ERR519511     1  0.0237     0.7160 0.996 0.000 0.004
#> ERR519468     3  0.5859     0.6989 0.344 0.000 0.656
#> ERR519482     3  0.5591     0.7272 0.304 0.000 0.696
#> ERR519475     3  0.8865    -0.0455 0.120 0.404 0.476
#> ERR519496     2  0.2537     0.7759 0.080 0.920 0.000
#> ERR519506     1  0.3482     0.7290 0.872 0.128 0.000
#> ERR519469     1  0.1031     0.7309 0.976 0.024 0.000
#> ERR519480     3  0.2625     0.7522 0.084 0.000 0.916
#> ERR519487     3  0.3482     0.7583 0.128 0.000 0.872
#> ERR519483     1  0.4702     0.6776 0.788 0.212 0.000
#> ERR519477     3  0.8677     0.4972 0.288 0.140 0.572
#> ERR519499     3  0.0000     0.7121 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
#> ERR519515     1  0.1004    0.81739 0.972 0.004 0.000 0.024
#> ERR519516     2  0.5807    0.49836 0.160 0.708 0.000 0.132
#> ERR519520     1  0.5041    0.64160 0.728 0.232 0.000 0.040
#> ERR519513     2  0.5985    0.53981 0.000 0.692 0.168 0.140
#> ERR519481     4  0.5713    0.23477 0.000 0.360 0.036 0.604
#> ERR519491     1  0.3542    0.75328 0.852 0.120 0.000 0.028
#> ERR519473     4  0.3810    0.57280 0.000 0.092 0.060 0.848
#> ERR519518     3  0.6949    0.24891 0.000 0.348 0.528 0.124
#> ERR519512     1  0.5233    0.51776 0.648 0.332 0.000 0.020
#> ERR519521     2  0.5516    0.51683 0.056 0.732 0.012 0.200
#> ERR519488     1  0.3161    0.77357 0.864 0.124 0.000 0.012
#> ERR519493     2  0.6111    0.44601 0.256 0.652 0.000 0.092
#> ERR519514     1  0.1256    0.81721 0.964 0.008 0.000 0.028
#> ERR519479     4  0.6275    0.50647 0.084 0.272 0.004 0.640
#> ERR519509     1  0.2197    0.80026 0.916 0.080 0.000 0.004
#> ERR519472     4  0.5427    0.68732 0.164 0.100 0.000 0.736
#> ERR519510     2  0.4234    0.63852 0.032 0.840 0.028 0.100
#> ERR519470     1  0.1256    0.81574 0.964 0.008 0.000 0.028
#> ERR519495     4  0.6179    0.64244 0.320 0.072 0.000 0.608
#> ERR519522     1  0.2053    0.80491 0.924 0.072 0.000 0.004
#> ERR519523     1  0.4174    0.70761 0.816 0.140 0.000 0.044
#> ERR519503     1  0.6388    0.62004 0.700 0.048 0.188 0.064
#> ERR519471     1  0.2385    0.79773 0.920 0.028 0.000 0.052
#> ERR519500     4  0.6774    0.57063 0.160 0.196 0.008 0.636
#> ERR519485     1  0.4332    0.68684 0.800 0.040 0.000 0.160
#> ERR519476     2  0.9867    0.05344 0.264 0.316 0.184 0.236
#> ERR519502     2  0.5199    0.61219 0.024 0.768 0.040 0.168
#> ERR519486     1  0.5925    0.46567 0.648 0.284 0.000 0.068
#> ERR519478     1  0.0336    0.82058 0.992 0.008 0.000 0.000
#> ERR519497     2  0.4692    0.51594 0.020 0.772 0.196 0.012
#> ERR519467     1  0.0336    0.82069 0.992 0.008 0.000 0.000
#> ERR519489     4  0.6941    0.48270 0.192 0.220 0.000 0.588
#> ERR519494     3  0.7109    0.42717 0.000 0.144 0.520 0.336
#> ERR519474     4  0.6067    0.55375 0.376 0.052 0.000 0.572
#> ERR519505     2  0.3204    0.62417 0.064 0.892 0.028 0.016
#> ERR519517     3  0.0937    0.73359 0.000 0.012 0.976 0.012
#> ERR519484     2  0.6196    0.44352 0.016 0.616 0.040 0.328
#> ERR519498     2  0.3006    0.62632 0.012 0.888 0.092 0.008
#> ERR519490     3  0.3271    0.73153 0.000 0.012 0.856 0.132
#> ERR519507     4  0.5644    0.57221 0.060 0.220 0.008 0.712
#> ERR519511     2  0.6334    0.49273 0.024 0.632 0.044 0.300
#> ERR519468     3  0.4345    0.71179 0.004 0.020 0.788 0.188
#> ERR519482     3  0.4281    0.71659 0.000 0.028 0.792 0.180
#> ERR519475     3  0.9832    0.00532 0.176 0.248 0.328 0.248
#> ERR519496     1  0.2125    0.79039 0.920 0.004 0.000 0.076
#> ERR519506     4  0.4700    0.66633 0.208 0.012 0.016 0.764
#> ERR519469     4  0.4959    0.68050 0.180 0.024 0.024 0.772
#> ERR519480     3  0.1510    0.73022 0.000 0.016 0.956 0.028
#> ERR519487     3  0.2928    0.73213 0.000 0.052 0.896 0.052
#> ERR519483     4  0.5636    0.61662 0.288 0.016 0.024 0.672
#> ERR519477     2  0.8897   -0.08863 0.060 0.368 0.360 0.212
#> ERR519499     3  0.1042    0.71745 0.000 0.008 0.972 0.020

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> ERR519515     1  0.1310     0.6790 0.956 0.020 0.000 0.024 0.000
#> ERR519516     5  0.6581     0.1408 0.160 0.016 0.000 0.300 0.524
#> ERR519520     1  0.5580     0.4465 0.624 0.068 0.004 0.008 0.296
#> ERR519513     5  0.5742     0.4358 0.000 0.048 0.284 0.040 0.628
#> ERR519481     4  0.3559     0.4880 0.004 0.008 0.004 0.800 0.184
#> ERR519491     1  0.3410     0.6469 0.860 0.024 0.000 0.052 0.064
#> ERR519473     4  0.1679     0.5716 0.016 0.020 0.004 0.948 0.012
#> ERR519518     3  0.7166     0.2400 0.000 0.036 0.452 0.332 0.180
#> ERR519512     1  0.5508     0.4360 0.612 0.060 0.000 0.012 0.316
#> ERR519521     4  0.6405     0.1010 0.080 0.032 0.000 0.476 0.412
#> ERR519488     1  0.3853     0.6315 0.804 0.036 0.000 0.008 0.152
#> ERR519493     5  0.5448     0.3835 0.300 0.008 0.000 0.068 0.624
#> ERR519514     1  0.1865     0.6769 0.936 0.024 0.000 0.032 0.008
#> ERR519479     4  0.4969     0.4152 0.020 0.032 0.000 0.684 0.264
#> ERR519509     1  0.3233     0.6639 0.852 0.028 0.000 0.008 0.112
#> ERR519472     4  0.2589     0.5725 0.048 0.044 0.000 0.900 0.008
#> ERR519510     5  0.3316     0.6004 0.024 0.012 0.016 0.080 0.868
#> ERR519470     1  0.1893     0.6649 0.928 0.048 0.000 0.024 0.000
#> ERR519495     4  0.5711     0.1764 0.356 0.052 0.000 0.572 0.020
#> ERR519522     1  0.2722     0.6721 0.868 0.004 0.000 0.008 0.120
#> ERR519523     1  0.3062     0.6534 0.868 0.004 0.000 0.048 0.080
#> ERR519503     1  0.5810     0.5385 0.712 0.128 0.072 0.008 0.080
#> ERR519471     1  0.4400     0.4557 0.744 0.196 0.000 0.060 0.000
#> ERR519500     4  0.3376     0.5483 0.032 0.012 0.000 0.848 0.108
#> ERR519485     1  0.5991    -0.2594 0.464 0.452 0.000 0.068 0.016
#> ERR519476     2  0.7394     0.3304 0.164 0.580 0.036 0.056 0.164
#> ERR519502     5  0.4645     0.1748 0.008 0.000 0.004 0.424 0.564
#> ERR519486     1  0.7295    -0.0435 0.460 0.156 0.000 0.056 0.328
#> ERR519478     1  0.1369     0.6927 0.956 0.008 0.000 0.008 0.028
#> ERR519497     5  0.5077     0.5402 0.060 0.076 0.072 0.016 0.776
#> ERR519467     1  0.1282     0.6927 0.952 0.000 0.000 0.004 0.044
#> ERR519489     4  0.6513     0.3930 0.096 0.020 0.044 0.640 0.200
#> ERR519494     3  0.5687     0.5801 0.000 0.008 0.620 0.276 0.096
#> ERR519474     2  0.7033     0.2909 0.352 0.392 0.000 0.244 0.012
#> ERR519505     5  0.3124     0.6130 0.004 0.028 0.084 0.012 0.872
#> ERR519517     3  0.0579     0.7948 0.000 0.008 0.984 0.000 0.008
#> ERR519484     5  0.5136     0.3852 0.008 0.016 0.016 0.328 0.632
#> ERR519498     5  0.3788     0.6073 0.004 0.012 0.144 0.024 0.816
#> ERR519490     3  0.4951     0.7039 0.000 0.092 0.744 0.144 0.020
#> ERR519507     4  0.5388     0.5104 0.028 0.104 0.000 0.712 0.156
#> ERR519511     4  0.4947    -0.1388 0.012 0.004 0.004 0.496 0.484
#> ERR519468     3  0.2244     0.7926 0.000 0.024 0.920 0.040 0.016
#> ERR519482     3  0.3959     0.7549 0.000 0.068 0.816 0.104 0.012
#> ERR519475     2  0.6915     0.3497 0.076 0.652 0.080 0.060 0.132
#> ERR519496     1  0.3701     0.5810 0.824 0.112 0.000 0.060 0.004
#> ERR519506     2  0.6756     0.3960 0.300 0.516 0.004 0.164 0.016
#> ERR519469     4  0.6404     0.0774 0.264 0.168 0.012 0.556 0.000
#> ERR519480     3  0.2378     0.7816 0.000 0.048 0.904 0.000 0.048
#> ERR519487     3  0.2275     0.7826 0.000 0.012 0.912 0.012 0.064
#> ERR519483     2  0.6195     0.3305 0.360 0.508 0.004 0.128 0.000
#> ERR519477     2  0.8214     0.1994 0.036 0.492 0.164 0.100 0.208
#> ERR519499     3  0.0579     0.7944 0.000 0.008 0.984 0.000 0.008

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> ERR519515     1  0.1226     0.6858 0.952 0.004 0.000 0.004 0.000 0.040
#> ERR519516     5  0.7392     0.1054 0.240 0.088 0.000 0.256 0.404 0.012
#> ERR519520     1  0.6197     0.3864 0.544 0.212 0.000 0.016 0.216 0.012
#> ERR519513     5  0.4776     0.2184 0.000 0.028 0.412 0.008 0.548 0.004
#> ERR519481     4  0.3293     0.4179 0.000 0.004 0.004 0.788 0.196 0.008
#> ERR519491     1  0.2757     0.6695 0.884 0.004 0.000 0.024 0.052 0.036
#> ERR519473     4  0.2119     0.5345 0.008 0.004 0.008 0.920 0.016 0.044
#> ERR519518     4  0.7339     0.1186 0.000 0.248 0.128 0.392 0.232 0.000
#> ERR519512     1  0.6492     0.2916 0.500 0.196 0.000 0.020 0.268 0.016
#> ERR519521     4  0.6455     0.2050 0.068 0.088 0.004 0.528 0.304 0.008
#> ERR519488     1  0.2995     0.6728 0.864 0.072 0.000 0.004 0.048 0.012
#> ERR519493     5  0.5091     0.4104 0.248 0.008 0.000 0.048 0.664 0.032
#> ERR519514     1  0.1457     0.6866 0.948 0.004 0.000 0.016 0.004 0.028
#> ERR519479     5  0.6104     0.0853 0.028 0.000 0.000 0.364 0.472 0.136
#> ERR519509     1  0.1989     0.6943 0.916 0.052 0.000 0.004 0.028 0.000
#> ERR519472     4  0.2945     0.5291 0.048 0.004 0.000 0.860 0.004 0.084
#> ERR519510     5  0.1983     0.5344 0.012 0.000 0.012 0.060 0.916 0.000
#> ERR519470     1  0.1411     0.6753 0.936 0.000 0.000 0.004 0.000 0.060
#> ERR519495     1  0.5975    -0.0654 0.480 0.008 0.000 0.376 0.012 0.124
#> ERR519522     1  0.1867     0.6967 0.924 0.036 0.000 0.004 0.036 0.000
#> ERR519523     1  0.2681     0.6782 0.888 0.008 0.000 0.044 0.048 0.012
#> ERR519503     1  0.5900     0.2533 0.496 0.412 0.020 0.016 0.024 0.032
#> ERR519471     1  0.3380     0.4313 0.748 0.004 0.000 0.004 0.000 0.244
#> ERR519500     4  0.2948     0.5245 0.056 0.012 0.000 0.868 0.060 0.004
#> ERR519485     6  0.4636     0.7295 0.336 0.008 0.000 0.020 0.012 0.624
#> ERR519476     2  0.8124     0.4822 0.088 0.368 0.028 0.064 0.100 0.352
#> ERR519502     5  0.4457     0.2169 0.000 0.016 0.008 0.432 0.544 0.000
#> ERR519486     1  0.6497    -0.0232 0.540 0.012 0.020 0.012 0.172 0.244
#> ERR519478     1  0.0914     0.7016 0.968 0.016 0.000 0.000 0.016 0.000
#> ERR519497     5  0.5739     0.3497 0.048 0.272 0.024 0.024 0.620 0.012
#> ERR519467     1  0.1599     0.7021 0.940 0.028 0.000 0.000 0.024 0.008
#> ERR519489     4  0.6130     0.3969 0.068 0.140 0.008 0.636 0.140 0.008
#> ERR519494     3  0.4926     0.5773 0.000 0.032 0.692 0.200 0.076 0.000
#> ERR519474     6  0.4769     0.8217 0.236 0.000 0.000 0.084 0.008 0.672
#> ERR519505     5  0.2930     0.5197 0.000 0.044 0.072 0.004 0.868 0.012
#> ERR519517     3  0.0865     0.7668 0.000 0.036 0.964 0.000 0.000 0.000
#> ERR519484     5  0.4855     0.4590 0.012 0.008 0.012 0.200 0.712 0.056
#> ERR519498     5  0.4922     0.4529 0.008 0.076 0.256 0.004 0.656 0.000
#> ERR519490     2  0.6307    -0.3588 0.000 0.404 0.400 0.176 0.012 0.008
#> ERR519507     4  0.6585     0.0718 0.032 0.000 0.000 0.416 0.316 0.236
#> ERR519511     5  0.4377     0.3795 0.012 0.004 0.000 0.316 0.652 0.016
#> ERR519468     3  0.2168     0.7464 0.000 0.028 0.916 0.004 0.016 0.036
#> ERR519482     3  0.5753     0.3879 0.000 0.264 0.556 0.168 0.012 0.000
#> ERR519475     2  0.7243     0.5045 0.024 0.416 0.056 0.056 0.052 0.396
#> ERR519496     1  0.2963     0.5852 0.828 0.000 0.000 0.016 0.004 0.152
#> ERR519506     6  0.4574     0.7231 0.136 0.004 0.008 0.032 0.060 0.760
#> ERR519469     4  0.7492    -0.3201 0.280 0.020 0.068 0.348 0.000 0.284
#> ERR519480     3  0.3739     0.6596 0.000 0.220 0.752 0.004 0.020 0.004
#> ERR519487     3  0.1405     0.7514 0.000 0.024 0.948 0.000 0.024 0.004
#> ERR519483     6  0.4056     0.8223 0.208 0.008 0.004 0.028 0.004 0.748
#> ERR519477     2  0.8075     0.4822 0.000 0.344 0.140 0.056 0.144 0.316
#> ERR519499     3  0.0891     0.7662 0.000 0.024 0.968 0.000 0.000 0.008

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

consensus_heatmap(res, k = 2)

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

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

collect_plots(res)

plot of chunk CV-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.998       0.999         0.2379 0.762   0.762
#> 3 3 1.000           0.979       0.999         0.0259 0.995   0.994
#> 4 4 0.576           0.611       0.869         0.5020 0.967   0.956
#> 5 5 0.468           0.725       0.817         0.1292 1.000   1.000
#> 6 6 0.496           0.695       0.819         0.0470 0.962   0.947

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
#> ERR519515     1   0.000      1.000 1.000 0.000
#> ERR519516     1   0.000      1.000 1.000 0.000
#> ERR519520     1   0.000      1.000 1.000 0.000
#> ERR519513     1   0.000      1.000 1.000 0.000
#> ERR519481     1   0.000      1.000 1.000 0.000
#> ERR519491     1   0.000      1.000 1.000 0.000
#> ERR519473     1   0.000      1.000 1.000 0.000
#> ERR519518     1   0.000      1.000 1.000 0.000
#> ERR519512     1   0.000      1.000 1.000 0.000
#> ERR519521     1   0.000      1.000 1.000 0.000
#> ERR519488     1   0.000      1.000 1.000 0.000
#> ERR519493     1   0.000      1.000 1.000 0.000
#> ERR519514     1   0.000      1.000 1.000 0.000
#> ERR519479     1   0.000      1.000 1.000 0.000
#> ERR519509     1   0.000      1.000 1.000 0.000
#> ERR519472     1   0.000      1.000 1.000 0.000
#> ERR519510     1   0.000      1.000 1.000 0.000
#> ERR519470     1   0.000      1.000 1.000 0.000
#> ERR519495     1   0.000      1.000 1.000 0.000
#> ERR519522     1   0.000      1.000 1.000 0.000
#> ERR519523     1   0.000      1.000 1.000 0.000
#> ERR519503     1   0.000      1.000 1.000 0.000
#> ERR519471     1   0.000      1.000 1.000 0.000
#> ERR519500     1   0.000      1.000 1.000 0.000
#> ERR519485     1   0.000      1.000 1.000 0.000
#> ERR519476     1   0.000      1.000 1.000 0.000
#> ERR519502     1   0.000      1.000 1.000 0.000
#> ERR519486     1   0.000      1.000 1.000 0.000
#> ERR519478     1   0.000      1.000 1.000 0.000
#> ERR519497     1   0.000      1.000 1.000 0.000
#> ERR519467     1   0.000      1.000 1.000 0.000
#> ERR519489     2   0.000      0.995 0.000 1.000
#> ERR519494     2   0.000      0.995 0.000 1.000
#> ERR519474     1   0.000      1.000 1.000 0.000
#> ERR519505     1   0.000      1.000 1.000 0.000
#> ERR519517     2   0.000      0.995 0.000 1.000
#> ERR519484     1   0.000      1.000 1.000 0.000
#> ERR519498     1   0.000      1.000 1.000 0.000
#> ERR519490     2   0.000      0.995 0.000 1.000
#> ERR519507     1   0.000      1.000 1.000 0.000
#> ERR519511     1   0.000      1.000 1.000 0.000
#> ERR519468     1   0.000      1.000 1.000 0.000
#> ERR519482     1   0.141      0.979 0.980 0.020
#> ERR519475     1   0.000      1.000 1.000 0.000
#> ERR519496     1   0.000      1.000 1.000 0.000
#> ERR519506     1   0.000      1.000 1.000 0.000
#> ERR519469     1   0.000      1.000 1.000 0.000
#> ERR519480     2   0.204      0.967 0.032 0.968
#> ERR519487     2   0.000      0.995 0.000 1.000
#> ERR519483     1   0.000      1.000 1.000 0.000
#> ERR519477     1   0.000      1.000 1.000 0.000
#> ERR519499     2   0.000      0.995 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette   p1   p2 p3
#> ERR519515     1   0.000      0.999 1.00 0.00  0
#> ERR519516     1   0.000      0.999 1.00 0.00  0
#> ERR519520     1   0.000      0.999 1.00 0.00  0
#> ERR519513     1   0.000      0.999 1.00 0.00  0
#> ERR519481     1   0.000      0.999 1.00 0.00  0
#> ERR519491     1   0.000      0.999 1.00 0.00  0
#> ERR519473     1   0.000      0.999 1.00 0.00  0
#> ERR519518     1   0.000      0.999 1.00 0.00  0
#> ERR519512     1   0.000      0.999 1.00 0.00  0
#> ERR519521     1   0.000      0.999 1.00 0.00  0
#> ERR519488     1   0.000      0.999 1.00 0.00  0
#> ERR519493     1   0.000      0.999 1.00 0.00  0
#> ERR519514     1   0.000      0.999 1.00 0.00  0
#> ERR519479     1   0.000      0.999 1.00 0.00  0
#> ERR519509     1   0.000      0.999 1.00 0.00  0
#> ERR519472     1   0.000      0.999 1.00 0.00  0
#> ERR519510     1   0.000      0.999 1.00 0.00  0
#> ERR519470     1   0.000      0.999 1.00 0.00  0
#> ERR519495     1   0.000      0.999 1.00 0.00  0
#> ERR519522     1   0.000      0.999 1.00 0.00  0
#> ERR519523     1   0.000      0.999 1.00 0.00  0
#> ERR519503     1   0.000      0.999 1.00 0.00  0
#> ERR519471     1   0.000      0.999 1.00 0.00  0
#> ERR519500     1   0.000      0.999 1.00 0.00  0
#> ERR519485     1   0.000      0.999 1.00 0.00  0
#> ERR519476     1   0.000      0.999 1.00 0.00  0
#> ERR519502     1   0.000      0.999 1.00 0.00  0
#> ERR519486     1   0.000      0.999 1.00 0.00  0
#> ERR519478     1   0.000      0.999 1.00 0.00  0
#> ERR519497     1   0.000      0.999 1.00 0.00  0
#> ERR519467     1   0.000      0.999 1.00 0.00  0
#> ERR519489     3   0.000      1.000 0.00 0.00  1
#> ERR519494     3   0.000      1.000 0.00 0.00  1
#> ERR519474     1   0.000      0.999 1.00 0.00  0
#> ERR519505     1   0.000      0.999 1.00 0.00  0
#> ERR519517     3   0.000      1.000 0.00 0.00  1
#> ERR519484     1   0.000      0.999 1.00 0.00  0
#> ERR519498     1   0.000      0.999 1.00 0.00  0
#> ERR519490     3   0.000      1.000 0.00 0.00  1
#> ERR519507     1   0.000      0.999 1.00 0.00  0
#> ERR519511     1   0.000      0.999 1.00 0.00  0
#> ERR519468     1   0.000      0.999 1.00 0.00  0
#> ERR519482     1   0.153      0.958 0.96 0.04  0
#> ERR519475     1   0.000      0.999 1.00 0.00  0
#> ERR519496     1   0.000      0.999 1.00 0.00  0
#> ERR519506     1   0.000      0.999 1.00 0.00  0
#> ERR519469     1   0.000      0.999 1.00 0.00  0
#> ERR519480     2   0.000      0.000 0.00 1.00  0
#> ERR519487     3   0.000      1.000 0.00 0.00  1
#> ERR519483     1   0.000      0.999 1.00 0.00  0
#> ERR519477     1   0.000      0.999 1.00 0.00  0
#> ERR519499     3   0.000      1.000 0.00 0.00  1

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3 p4
#> ERR519515     1  0.0336      0.741 0.992 0.008 0.000  0
#> ERR519516     1  0.0469      0.738 0.988 0.012 0.000  0
#> ERR519520     1  0.0336      0.741 0.992 0.008 0.000  0
#> ERR519513     1  0.1716      0.723 0.936 0.064 0.000  0
#> ERR519481     1  0.3356      0.617 0.824 0.176 0.000  0
#> ERR519491     1  0.0336      0.736 0.992 0.008 0.000  0
#> ERR519473     1  0.4431      0.345 0.696 0.304 0.000  0
#> ERR519518     1  0.4431      0.345 0.696 0.304 0.000  0
#> ERR519512     1  0.0336      0.741 0.992 0.008 0.000  0
#> ERR519521     1  0.3356      0.617 0.824 0.176 0.000  0
#> ERR519488     1  0.0336      0.741 0.992 0.008 0.000  0
#> ERR519493     1  0.0336      0.736 0.992 0.008 0.000  0
#> ERR519514     1  0.0336      0.741 0.992 0.008 0.000  0
#> ERR519479     1  0.3356      0.617 0.824 0.176 0.000  0
#> ERR519509     1  0.0336      0.741 0.992 0.008 0.000  0
#> ERR519472     1  0.4250      0.424 0.724 0.276 0.000  0
#> ERR519510     1  0.1792      0.722 0.932 0.068 0.000  0
#> ERR519470     1  0.0336      0.741 0.992 0.008 0.000  0
#> ERR519495     1  0.4431      0.345 0.696 0.304 0.000  0
#> ERR519522     1  0.0336      0.741 0.992 0.008 0.000  0
#> ERR519523     1  0.0336      0.741 0.992 0.008 0.000  0
#> ERR519503     1  0.4431      0.345 0.696 0.304 0.000  0
#> ERR519471     1  0.0336      0.741 0.992 0.008 0.000  0
#> ERR519500     1  0.3873      0.531 0.772 0.228 0.000  0
#> ERR519485     1  0.4431      0.345 0.696 0.304 0.000  0
#> ERR519476     1  0.0817      0.724 0.976 0.024 0.000  0
#> ERR519502     1  0.3486      0.600 0.812 0.188 0.000  0
#> ERR519486     1  0.4431      0.345 0.696 0.304 0.000  0
#> ERR519478     1  0.0336      0.741 0.992 0.008 0.000  0
#> ERR519497     1  0.4431      0.345 0.696 0.304 0.000  0
#> ERR519467     1  0.0817      0.724 0.976 0.024 0.000  0
#> ERR519489     3  0.1474      0.887 0.000 0.052 0.948  0
#> ERR519494     3  0.0000      0.913 0.000 0.000 1.000  0
#> ERR519474     1  0.0469      0.738 0.988 0.012 0.000  0
#> ERR519505     1  0.0817      0.724 0.976 0.024 0.000  0
#> ERR519517     3  0.0000      0.913 0.000 0.000 1.000  0
#> ERR519484     1  0.1792      0.723 0.932 0.068 0.000  0
#> ERR519498     1  0.1716      0.723 0.936 0.064 0.000  0
#> ERR519490     3  0.4877      0.517 0.000 0.408 0.592  0
#> ERR519507     1  0.4134      0.463 0.740 0.260 0.000  0
#> ERR519511     1  0.4431      0.345 0.696 0.304 0.000  0
#> ERR519468     1  0.4431      0.345 0.696 0.304 0.000  0
#> ERR519482     2  0.4933      0.000 0.432 0.568 0.000  0
#> ERR519475     1  0.0817      0.724 0.976 0.024 0.000  0
#> ERR519496     1  0.4431      0.345 0.696 0.304 0.000  0
#> ERR519506     1  0.1302      0.733 0.956 0.044 0.000  0
#> ERR519469     1  0.4431      0.345 0.696 0.304 0.000  0
#> ERR519480     4  0.0000      0.000 0.000 0.000 0.000  1
#> ERR519487     3  0.0000      0.913 0.000 0.000 1.000  0
#> ERR519483     1  0.0817      0.724 0.976 0.024 0.000  0
#> ERR519477     1  0.0817      0.724 0.976 0.024 0.000  0
#> ERR519499     3  0.0000      0.913 0.000 0.000 1.000  0

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1 p2    p3    p4 p5
#> ERR519515     1  0.0290     0.8414 0.992 NA 0.000 0.008  0
#> ERR519516     1  0.0703     0.8382 0.976 NA 0.000 0.024  0
#> ERR519520     1  0.0290     0.8414 0.992 NA 0.000 0.008  0
#> ERR519513     1  0.1571     0.8424 0.936 NA 0.000 0.060  0
#> ERR519481     1  0.3003     0.8098 0.812 NA 0.000 0.188  0
#> ERR519491     1  0.0609     0.8368 0.980 NA 0.000 0.020  0
#> ERR519473     1  0.3816     0.7271 0.696 NA 0.000 0.304  0
#> ERR519518     1  0.4273     0.5304 0.552 NA 0.000 0.448  0
#> ERR519512     1  0.0290     0.8414 0.992 NA 0.000 0.008  0
#> ERR519521     1  0.3003     0.8098 0.812 NA 0.000 0.188  0
#> ERR519488     1  0.0290     0.8414 0.992 NA 0.000 0.008  0
#> ERR519493     1  0.0609     0.8368 0.980 NA 0.000 0.020  0
#> ERR519514     1  0.0290     0.8414 0.992 NA 0.000 0.008  0
#> ERR519479     1  0.3003     0.8098 0.812 NA 0.000 0.188  0
#> ERR519509     1  0.0290     0.8414 0.992 NA 0.000 0.008  0
#> ERR519472     1  0.3730     0.7510 0.712 NA 0.000 0.288  0
#> ERR519510     1  0.1671     0.8413 0.924 NA 0.000 0.076  0
#> ERR519470     1  0.0290     0.8414 0.992 NA 0.000 0.008  0
#> ERR519495     1  0.3816     0.7271 0.696 NA 0.000 0.304  0
#> ERR519522     1  0.0290     0.8414 0.992 NA 0.000 0.008  0
#> ERR519523     1  0.0290     0.8414 0.992 NA 0.000 0.008  0
#> ERR519503     1  0.4273     0.5304 0.552 NA 0.000 0.448  0
#> ERR519471     1  0.0290     0.8414 0.992 NA 0.000 0.008  0
#> ERR519500     1  0.3424     0.7832 0.760 NA 0.000 0.240  0
#> ERR519485     1  0.3816     0.7271 0.696 NA 0.000 0.304  0
#> ERR519476     1  0.1725     0.8168 0.936 NA 0.000 0.020  0
#> ERR519502     1  0.3109     0.8044 0.800 NA 0.000 0.200  0
#> ERR519486     1  0.3816     0.7271 0.696 NA 0.000 0.304  0
#> ERR519478     1  0.2605     0.7391 0.852 NA 0.000 0.148  0
#> ERR519497     1  0.4273     0.5304 0.552 NA 0.000 0.448  0
#> ERR519467     1  0.1725     0.8168 0.936 NA 0.000 0.020  0
#> ERR519489     3  0.0000     0.4216 0.000 NA 1.000 0.000  0
#> ERR519494     3  0.4291     0.7398 0.000 NA 0.536 0.000  0
#> ERR519474     1  0.0703     0.8382 0.976 NA 0.000 0.024  0
#> ERR519505     1  0.1117     0.8315 0.964 NA 0.000 0.020  0
#> ERR519517     3  0.4291     0.7398 0.000 NA 0.536 0.000  0
#> ERR519484     1  0.1732     0.8408 0.920 NA 0.000 0.080  0
#> ERR519498     1  0.1571     0.8424 0.936 NA 0.000 0.060  0
#> ERR519490     3  0.4088    -0.0512 0.000 NA 0.632 0.000  0
#> ERR519507     1  0.3636     0.7627 0.728 NA 0.000 0.272  0
#> ERR519511     1  0.3816     0.7271 0.696 NA 0.000 0.304  0
#> ERR519468     1  0.3816     0.7271 0.696 NA 0.000 0.304  0
#> ERR519482     4  0.1608     0.0000 0.000 NA 0.000 0.928  0
#> ERR519475     1  0.1725     0.8168 0.936 NA 0.000 0.020  0
#> ERR519496     1  0.4273     0.5304 0.552 NA 0.000 0.448  0
#> ERR519506     1  0.1121     0.8449 0.956 NA 0.000 0.044  0
#> ERR519469     1  0.3816     0.7271 0.696 NA 0.000 0.304  0
#> ERR519480     5  0.0000     0.0000 0.000 NA 0.000 0.000  1
#> ERR519487     3  0.4291     0.7398 0.000 NA 0.536 0.000  0
#> ERR519483     1  0.2561     0.8045 0.884 NA 0.000 0.020  0
#> ERR519477     1  0.1725     0.8168 0.936 NA 0.000 0.020  0
#> ERR519499     3  0.4291     0.7398 0.000 NA 0.536 0.000  0

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1 p2    p3    p4    p5    p6
#> ERR519515     1  0.0146      0.786 0.996  0 0.000 0.000 0.004 0.000
#> ERR519516     1  0.0713      0.780 0.972  0 0.000 0.000 0.028 0.000
#> ERR519520     1  0.0146      0.786 0.996  0 0.000 0.000 0.004 0.000
#> ERR519513     1  0.1387      0.791 0.932  0 0.000 0.000 0.068 0.000
#> ERR519481     1  0.3426      0.757 0.808  0 0.000 0.000 0.124 0.068
#> ERR519491     1  0.0632      0.778 0.976  0 0.000 0.000 0.024 0.000
#> ERR519473     1  0.4566      0.674 0.700  0 0.000 0.000 0.160 0.140
#> ERR519518     1  0.5453      0.464 0.556  0 0.000 0.000 0.160 0.284
#> ERR519512     1  0.0146      0.786 0.996  0 0.000 0.000 0.004 0.000
#> ERR519521     1  0.3426      0.757 0.808  0 0.000 0.000 0.124 0.068
#> ERR519488     1  0.0146      0.786 0.996  0 0.000 0.000 0.004 0.000
#> ERR519493     1  0.0632      0.778 0.976  0 0.000 0.000 0.024 0.000
#> ERR519514     1  0.0146      0.786 0.996  0 0.000 0.000 0.004 0.000
#> ERR519479     1  0.3426      0.757 0.808  0 0.000 0.000 0.124 0.068
#> ERR519509     1  0.0146      0.786 0.996  0 0.000 0.000 0.004 0.000
#> ERR519472     1  0.4466      0.696 0.708  0 0.000 0.000 0.176 0.116
#> ERR519510     1  0.1556      0.789 0.920  0 0.000 0.000 0.080 0.000
#> ERR519470     1  0.0146      0.786 0.996  0 0.000 0.000 0.004 0.000
#> ERR519495     1  0.4566      0.674 0.700  0 0.000 0.000 0.160 0.140
#> ERR519522     1  0.0146      0.786 0.996  0 0.000 0.000 0.004 0.000
#> ERR519523     1  0.0146      0.786 0.996  0 0.000 0.000 0.004 0.000
#> ERR519503     1  0.5453      0.464 0.556  0 0.000 0.000 0.160 0.284
#> ERR519471     1  0.0146      0.786 0.996  0 0.000 0.000 0.004 0.000
#> ERR519500     1  0.4003      0.730 0.756  0 0.000 0.000 0.152 0.092
#> ERR519485     1  0.4566      0.674 0.700  0 0.000 0.000 0.160 0.140
#> ERR519476     1  0.1616      0.744 0.932  0 0.000 0.020 0.048 0.000
#> ERR519502     1  0.3563      0.752 0.796  0 0.000 0.000 0.132 0.072
#> ERR519486     1  0.4566      0.674 0.700  0 0.000 0.000 0.160 0.140
#> ERR519478     1  0.2402      0.639 0.856  0 0.000 0.000 0.004 0.140
#> ERR519497     1  0.5453      0.464 0.556  0 0.000 0.000 0.160 0.284
#> ERR519467     1  0.1616      0.744 0.932  0 0.000 0.020 0.048 0.000
#> ERR519489     4  0.5587      0.566 0.000  0 0.272 0.540 0.188 0.000
#> ERR519494     3  0.0000      1.000 0.000  0 1.000 0.000 0.000 0.000
#> ERR519474     1  0.0713      0.780 0.972  0 0.000 0.000 0.028 0.000
#> ERR519505     1  0.1049      0.769 0.960  0 0.000 0.008 0.032 0.000
#> ERR519517     3  0.0000      1.000 0.000  0 1.000 0.000 0.000 0.000
#> ERR519484     1  0.1610      0.788 0.916  0 0.000 0.000 0.084 0.000
#> ERR519498     1  0.1387      0.791 0.932  0 0.000 0.000 0.068 0.000
#> ERR519490     4  0.1267      0.541 0.000  0 0.060 0.940 0.000 0.000
#> ERR519507     1  0.4319      0.708 0.724  0 0.000 0.000 0.168 0.108
#> ERR519511     1  0.4566      0.674 0.700  0 0.000 0.000 0.160 0.140
#> ERR519468     1  0.4566      0.674 0.700  0 0.000 0.000 0.160 0.140
#> ERR519482     6  0.0000      0.000 0.000  0 0.000 0.000 0.000 1.000
#> ERR519475     1  0.1616      0.744 0.932  0 0.000 0.020 0.048 0.000
#> ERR519496     1  0.5453      0.464 0.556  0 0.000 0.000 0.160 0.284
#> ERR519506     1  0.0937      0.793 0.960  0 0.000 0.000 0.040 0.000
#> ERR519469     1  0.4566      0.674 0.700  0 0.000 0.000 0.160 0.140
#> ERR519480     2  0.0000      0.000 0.000  1 0.000 0.000 0.000 0.000
#> ERR519487     3  0.0000      1.000 0.000  0 1.000 0.000 0.000 0.000
#> ERR519483     5  0.4348      0.000 0.320  0 0.000 0.040 0.640 0.000
#> ERR519477     1  0.1616      0.744 0.932  0 0.000 0.020 0.048 0.000
#> ERR519499     3  0.0000      1.000 0.000  0 1.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-hclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-hclust-collect-classes

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


CV:kmeans**

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

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

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

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

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

collect_plots(res)

plot of chunk CV-kmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.2383 0.762   0.762
#> 3 3 0.448           0.681       0.803         1.1225 0.736   0.654
#> 4 4 0.470           0.638       0.817         0.1765 0.795   0.628
#> 5 5 0.476           0.471       0.714         0.1447 0.905   0.766
#> 6 6 0.477           0.581       0.755         0.0919 0.856   0.584

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
#> ERR519515     1       0          1  1  0
#> ERR519516     1       0          1  1  0
#> ERR519520     1       0          1  1  0
#> ERR519513     1       0          1  1  0
#> ERR519481     1       0          1  1  0
#> ERR519491     1       0          1  1  0
#> ERR519473     1       0          1  1  0
#> ERR519518     1       0          1  1  0
#> ERR519512     1       0          1  1  0
#> ERR519521     1       0          1  1  0
#> ERR519488     1       0          1  1  0
#> ERR519493     1       0          1  1  0
#> ERR519514     1       0          1  1  0
#> ERR519479     1       0          1  1  0
#> ERR519509     1       0          1  1  0
#> ERR519472     1       0          1  1  0
#> ERR519510     1       0          1  1  0
#> ERR519470     1       0          1  1  0
#> ERR519495     1       0          1  1  0
#> ERR519522     1       0          1  1  0
#> ERR519523     1       0          1  1  0
#> ERR519503     1       0          1  1  0
#> ERR519471     1       0          1  1  0
#> ERR519500     1       0          1  1  0
#> ERR519485     1       0          1  1  0
#> ERR519476     1       0          1  1  0
#> ERR519502     1       0          1  1  0
#> ERR519486     1       0          1  1  0
#> ERR519478     1       0          1  1  0
#> ERR519497     1       0          1  1  0
#> ERR519467     1       0          1  1  0
#> ERR519489     2       0          1  0  1
#> ERR519494     2       0          1  0  1
#> ERR519474     1       0          1  1  0
#> ERR519505     1       0          1  1  0
#> ERR519517     2       0          1  0  1
#> ERR519484     1       0          1  1  0
#> ERR519498     1       0          1  1  0
#> ERR519490     2       0          1  0  1
#> ERR519507     1       0          1  1  0
#> ERR519511     1       0          1  1  0
#> ERR519468     1       0          1  1  0
#> ERR519482     1       0          1  1  0
#> ERR519475     1       0          1  1  0
#> ERR519496     1       0          1  1  0
#> ERR519506     1       0          1  1  0
#> ERR519469     1       0          1  1  0
#> ERR519480     2       0          1  0  1
#> ERR519487     2       0          1  0  1
#> ERR519483     1       0          1  1  0
#> ERR519477     1       0          1  1  0
#> ERR519499     2       0          1  0  1

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> ERR519515     1  0.0000     0.7696 1.000 0.000 0.000
#> ERR519516     1  0.0000     0.7696 1.000 0.000 0.000
#> ERR519520     1  0.5706     0.4991 0.680 0.320 0.000
#> ERR519513     1  0.6154     0.2334 0.592 0.408 0.000
#> ERR519481     1  0.5785     0.4428 0.668 0.332 0.000
#> ERR519491     1  0.0000     0.7696 1.000 0.000 0.000
#> ERR519473     2  0.6095     0.5725 0.392 0.608 0.000
#> ERR519518     2  0.4062     0.8753 0.164 0.836 0.000
#> ERR519512     1  0.5178     0.5661 0.744 0.256 0.000
#> ERR519521     1  0.5678     0.4803 0.684 0.316 0.000
#> ERR519488     1  0.0237     0.7683 0.996 0.004 0.000
#> ERR519493     1  0.0000     0.7696 1.000 0.000 0.000
#> ERR519514     1  0.0000     0.7696 1.000 0.000 0.000
#> ERR519479     1  0.4291     0.6587 0.820 0.180 0.000
#> ERR519509     1  0.2066     0.7306 0.940 0.060 0.000
#> ERR519472     1  0.6095     0.2867 0.608 0.392 0.000
#> ERR519510     1  0.2165     0.7467 0.936 0.064 0.000
#> ERR519470     1  0.0000     0.7696 1.000 0.000 0.000
#> ERR519495     2  0.5497     0.8229 0.292 0.708 0.000
#> ERR519522     1  0.0237     0.7683 0.996 0.004 0.000
#> ERR519523     1  0.3482     0.7016 0.872 0.128 0.000
#> ERR519503     2  0.4235     0.8840 0.176 0.824 0.000
#> ERR519471     1  0.0000     0.7696 1.000 0.000 0.000
#> ERR519500     1  0.6079     0.3000 0.612 0.388 0.000
#> ERR519485     1  0.4002     0.6572 0.840 0.160 0.000
#> ERR519476     1  0.2066     0.7264 0.940 0.060 0.000
#> ERR519502     1  0.6045     0.3265 0.620 0.380 0.000
#> ERR519486     2  0.5363     0.8437 0.276 0.724 0.000
#> ERR519478     1  0.2625     0.7073 0.916 0.084 0.000
#> ERR519497     2  0.4291     0.8865 0.180 0.820 0.000
#> ERR519467     1  0.0237     0.7683 0.996 0.004 0.000
#> ERR519489     3  0.0000     0.9553 0.000 0.000 1.000
#> ERR519494     3  0.0000     0.9553 0.000 0.000 1.000
#> ERR519474     1  0.0000     0.7696 1.000 0.000 0.000
#> ERR519505     1  0.0237     0.7693 0.996 0.004 0.000
#> ERR519517     3  0.0000     0.9553 0.000 0.000 1.000
#> ERR519484     1  0.0424     0.7686 0.992 0.008 0.000
#> ERR519498     1  0.5706     0.4673 0.680 0.320 0.000
#> ERR519490     3  0.0000     0.9553 0.000 0.000 1.000
#> ERR519507     1  0.6045     0.3245 0.620 0.380 0.000
#> ERR519511     2  0.4750     0.8812 0.216 0.784 0.000
#> ERR519468     2  0.5363     0.8387 0.276 0.724 0.000
#> ERR519482     2  0.4062     0.8753 0.164 0.836 0.000
#> ERR519475     1  0.2066     0.7264 0.940 0.060 0.000
#> ERR519496     2  0.4291     0.8865 0.180 0.820 0.000
#> ERR519506     1  0.0237     0.7693 0.996 0.004 0.000
#> ERR519469     1  0.6299    -0.0753 0.524 0.476 0.000
#> ERR519480     3  0.5926     0.6647 0.000 0.356 0.644
#> ERR519487     3  0.0000     0.9553 0.000 0.000 1.000
#> ERR519483     1  0.6309    -0.3754 0.504 0.496 0.000
#> ERR519477     1  0.2066     0.7264 0.940 0.060 0.000
#> ERR519499     3  0.0000     0.9553 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
#> ERR519515     1  0.1256     0.8150 0.964 0.028 0.000 0.008
#> ERR519516     1  0.0524     0.8148 0.988 0.008 0.000 0.004
#> ERR519520     1  0.5916     0.4927 0.656 0.072 0.000 0.272
#> ERR519513     4  0.5775     0.3935 0.408 0.032 0.000 0.560
#> ERR519481     1  0.5558    -0.0139 0.548 0.020 0.000 0.432
#> ERR519491     1  0.0000     0.8158 1.000 0.000 0.000 0.000
#> ERR519473     4  0.2469     0.6397 0.108 0.000 0.000 0.892
#> ERR519518     4  0.3161     0.5435 0.012 0.124 0.000 0.864
#> ERR519512     1  0.5489     0.5278 0.700 0.060 0.000 0.240
#> ERR519521     1  0.5476     0.1533 0.584 0.020 0.000 0.396
#> ERR519488     1  0.2342     0.8050 0.912 0.080 0.000 0.008
#> ERR519493     1  0.0779     0.8136 0.980 0.016 0.000 0.004
#> ERR519514     1  0.1151     0.8154 0.968 0.024 0.000 0.008
#> ERR519479     1  0.3681     0.6643 0.816 0.008 0.000 0.176
#> ERR519509     1  0.3439     0.7767 0.868 0.084 0.000 0.048
#> ERR519472     4  0.4998     0.2213 0.488 0.000 0.000 0.512
#> ERR519510     1  0.3216     0.7696 0.880 0.044 0.000 0.076
#> ERR519470     1  0.1256     0.8150 0.964 0.028 0.000 0.008
#> ERR519495     4  0.2401     0.6357 0.092 0.004 0.000 0.904
#> ERR519522     1  0.2198     0.8068 0.920 0.072 0.000 0.008
#> ERR519523     1  0.3554     0.7222 0.844 0.020 0.000 0.136
#> ERR519503     4  0.5200     0.5010 0.072 0.184 0.000 0.744
#> ERR519471     1  0.1151     0.8154 0.968 0.024 0.000 0.008
#> ERR519500     4  0.4998     0.2213 0.488 0.000 0.000 0.512
#> ERR519485     1  0.4720     0.3562 0.672 0.004 0.000 0.324
#> ERR519476     1  0.3356     0.7260 0.824 0.176 0.000 0.000
#> ERR519502     4  0.5607     0.1978 0.488 0.020 0.000 0.492
#> ERR519486     4  0.2412     0.6317 0.084 0.008 0.000 0.908
#> ERR519478     1  0.3745     0.7631 0.852 0.088 0.000 0.060
#> ERR519497     4  0.3948     0.5628 0.036 0.136 0.000 0.828
#> ERR519467     1  0.1867     0.8089 0.928 0.072 0.000 0.000
#> ERR519489     3  0.0336     0.9926 0.000 0.000 0.992 0.008
#> ERR519494     3  0.0000     0.9963 0.000 0.000 1.000 0.000
#> ERR519474     1  0.0592     0.8146 0.984 0.016 0.000 0.000
#> ERR519505     1  0.1489     0.8109 0.952 0.044 0.000 0.004
#> ERR519517     3  0.0000     0.9963 0.000 0.000 1.000 0.000
#> ERR519484     1  0.1356     0.8103 0.960 0.032 0.000 0.008
#> ERR519498     1  0.5755     0.2987 0.624 0.044 0.000 0.332
#> ERR519490     3  0.0336     0.9926 0.000 0.000 0.992 0.008
#> ERR519507     4  0.5165     0.2231 0.484 0.004 0.000 0.512
#> ERR519511     4  0.1635     0.6013 0.044 0.008 0.000 0.948
#> ERR519468     4  0.2197     0.6281 0.080 0.004 0.000 0.916
#> ERR519482     4  0.3047     0.5425 0.012 0.116 0.000 0.872
#> ERR519475     1  0.3356     0.7260 0.824 0.176 0.000 0.000
#> ERR519496     4  0.4673     0.5506 0.076 0.132 0.000 0.792
#> ERR519506     1  0.1151     0.8163 0.968 0.024 0.000 0.008
#> ERR519469     4  0.3975     0.6213 0.240 0.000 0.000 0.760
#> ERR519480     2  0.6397     0.0000 0.000 0.648 0.208 0.144
#> ERR519487     3  0.0000     0.9963 0.000 0.000 1.000 0.000
#> ERR519483     4  0.5482     0.4380 0.368 0.024 0.000 0.608
#> ERR519477     1  0.3356     0.7260 0.824 0.176 0.000 0.000
#> ERR519499     3  0.0000     0.9963 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
#> ERR519515     1  0.0162      0.719 0.996 0.000 0.000 0.000 0.004
#> ERR519516     1  0.2732      0.681 0.840 0.000 0.000 0.000 0.160
#> ERR519520     1  0.6231      0.426 0.604 0.056 0.000 0.068 0.272
#> ERR519513     5  0.6736      0.326 0.168 0.028 0.000 0.264 0.540
#> ERR519481     5  0.7304      0.462 0.292 0.024 0.000 0.292 0.392
#> ERR519491     1  0.1270      0.720 0.948 0.000 0.000 0.000 0.052
#> ERR519473     4  0.4787      0.414 0.012 0.004 0.000 0.528 0.456
#> ERR519518     4  0.1282      0.400 0.000 0.004 0.000 0.952 0.044
#> ERR519512     1  0.6592      0.301 0.560 0.044 0.000 0.108 0.288
#> ERR519521     1  0.7619     -0.333 0.380 0.048 0.000 0.256 0.316
#> ERR519488     1  0.3049      0.679 0.876 0.048 0.000 0.012 0.064
#> ERR519493     1  0.2605      0.690 0.852 0.000 0.000 0.000 0.148
#> ERR519514     1  0.0794      0.721 0.972 0.000 0.000 0.000 0.028
#> ERR519479     1  0.4801      0.450 0.668 0.000 0.000 0.048 0.284
#> ERR519509     1  0.3152      0.676 0.872 0.048 0.000 0.016 0.064
#> ERR519472     4  0.6764     -0.307 0.308 0.000 0.000 0.400 0.292
#> ERR519510     1  0.5834     -0.010 0.500 0.032 0.000 0.036 0.432
#> ERR519470     1  0.0162      0.719 0.996 0.000 0.000 0.000 0.004
#> ERR519495     4  0.4877      0.432 0.016 0.004 0.000 0.524 0.456
#> ERR519522     1  0.2519      0.688 0.900 0.036 0.000 0.004 0.060
#> ERR519523     1  0.3012      0.668 0.852 0.000 0.000 0.024 0.124
#> ERR519503     4  0.4911      0.251 0.144 0.012 0.000 0.740 0.104
#> ERR519471     1  0.0794      0.721 0.972 0.000 0.000 0.000 0.028
#> ERR519500     4  0.6783     -0.335 0.316 0.000 0.000 0.388 0.296
#> ERR519485     5  0.6167      0.149 0.348 0.004 0.000 0.128 0.520
#> ERR519476     1  0.4369      0.568 0.740 0.052 0.000 0.000 0.208
#> ERR519502     5  0.7341      0.452 0.268 0.028 0.000 0.304 0.400
#> ERR519486     4  0.4877      0.432 0.016 0.004 0.000 0.524 0.456
#> ERR519478     1  0.3427      0.667 0.860 0.048 0.000 0.028 0.064
#> ERR519497     4  0.3561      0.340 0.008 0.008 0.000 0.796 0.188
#> ERR519467     1  0.2149      0.700 0.916 0.036 0.000 0.000 0.048
#> ERR519489     3  0.0703      0.980 0.000 0.000 0.976 0.000 0.024
#> ERR519494     3  0.0000      0.990 0.000 0.000 1.000 0.000 0.000
#> ERR519474     1  0.1671      0.715 0.924 0.000 0.000 0.000 0.076
#> ERR519505     1  0.5121      0.506 0.648 0.040 0.000 0.012 0.300
#> ERR519517     3  0.0000      0.990 0.000 0.000 1.000 0.000 0.000
#> ERR519484     1  0.5096      0.417 0.636 0.024 0.000 0.020 0.320
#> ERR519498     5  0.6805      0.251 0.400 0.028 0.000 0.132 0.440
#> ERR519490     3  0.0703      0.980 0.000 0.000 0.976 0.000 0.024
#> ERR519507     4  0.6813     -0.347 0.316 0.000 0.000 0.364 0.320
#> ERR519511     4  0.4698      0.432 0.008 0.004 0.000 0.520 0.468
#> ERR519468     4  0.4686      0.437 0.012 0.004 0.000 0.588 0.396
#> ERR519482     4  0.0865      0.404 0.000 0.004 0.000 0.972 0.024
#> ERR519475     1  0.4369      0.568 0.740 0.052 0.000 0.000 0.208
#> ERR519496     4  0.4403      0.307 0.132 0.004 0.000 0.772 0.092
#> ERR519506     1  0.2179      0.710 0.888 0.000 0.000 0.000 0.112
#> ERR519469     4  0.4969      0.384 0.020 0.004 0.000 0.508 0.468
#> ERR519480     2  0.2850      0.000 0.000 0.872 0.092 0.036 0.000
#> ERR519487     3  0.0000      0.990 0.000 0.000 1.000 0.000 0.000
#> ERR519483     5  0.6459     -0.234 0.180 0.004 0.000 0.312 0.504
#> ERR519477     1  0.4369      0.568 0.740 0.052 0.000 0.000 0.208
#> ERR519499     3  0.0000      0.990 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
#> ERR519515     1  0.0520     0.7436 0.984 0.000 0.000 0.008 0.008 0.000
#> ERR519516     1  0.4139     0.3630 0.644 0.008 0.000 0.336 0.012 0.000
#> ERR519520     1  0.6339    -0.0047 0.472 0.080 0.000 0.384 0.048 0.016
#> ERR519513     4  0.4031     0.6698 0.060 0.004 0.000 0.748 0.188 0.000
#> ERR519481     4  0.5307     0.7319 0.128 0.024 0.000 0.652 0.196 0.000
#> ERR519491     1  0.1983     0.7294 0.916 0.012 0.000 0.060 0.012 0.000
#> ERR519473     5  0.2696     0.4713 0.004 0.048 0.000 0.076 0.872 0.000
#> ERR519518     2  0.4977     0.6366 0.000 0.552 0.000 0.076 0.372 0.000
#> ERR519512     4  0.5754     0.2692 0.384 0.020 0.000 0.512 0.072 0.012
#> ERR519521     4  0.5141     0.7410 0.132 0.024 0.000 0.676 0.168 0.000
#> ERR519488     1  0.3405     0.6858 0.832 0.068 0.000 0.084 0.000 0.016
#> ERR519493     1  0.4086     0.4411 0.676 0.012 0.000 0.300 0.012 0.000
#> ERR519514     1  0.0717     0.7433 0.976 0.000 0.000 0.008 0.016 0.000
#> ERR519479     1  0.5477    -0.2115 0.476 0.008 0.000 0.420 0.096 0.000
#> ERR519509     1  0.3460     0.6830 0.828 0.072 0.000 0.084 0.000 0.016
#> ERR519472     5  0.6205     0.1546 0.296 0.020 0.000 0.200 0.484 0.000
#> ERR519510     4  0.3752     0.7829 0.164 0.000 0.000 0.772 0.064 0.000
#> ERR519470     1  0.0520     0.7436 0.984 0.000 0.000 0.008 0.008 0.000
#> ERR519495     5  0.1410     0.4832 0.008 0.004 0.000 0.044 0.944 0.000
#> ERR519522     1  0.2649     0.7130 0.884 0.052 0.000 0.048 0.000 0.016
#> ERR519523     1  0.3368     0.6624 0.828 0.012 0.000 0.108 0.052 0.000
#> ERR519503     2  0.6174     0.5773 0.180 0.528 0.000 0.032 0.260 0.000
#> ERR519471     1  0.0717     0.7433 0.976 0.000 0.000 0.008 0.016 0.000
#> ERR519500     5  0.6243     0.1347 0.296 0.020 0.000 0.208 0.476 0.000
#> ERR519485     5  0.4905     0.3168 0.264 0.004 0.000 0.092 0.640 0.000
#> ERR519476     1  0.4313     0.5678 0.668 0.284 0.000 0.048 0.000 0.000
#> ERR519502     4  0.5260     0.7266 0.120 0.024 0.000 0.656 0.200 0.000
#> ERR519486     5  0.1781     0.4761 0.008 0.008 0.000 0.060 0.924 0.000
#> ERR519478     1  0.3717     0.6674 0.808 0.092 0.000 0.084 0.000 0.016
#> ERR519497     2  0.5956     0.5640 0.004 0.472 0.000 0.208 0.316 0.000
#> ERR519467     1  0.2084     0.7247 0.916 0.024 0.000 0.044 0.000 0.016
#> ERR519489     3  0.1633     0.9508 0.000 0.024 0.932 0.044 0.000 0.000
#> ERR519494     3  0.0000     0.9733 0.000 0.000 1.000 0.000 0.000 0.000
#> ERR519474     1  0.2159     0.7239 0.904 0.012 0.000 0.072 0.012 0.000
#> ERR519505     4  0.3109     0.7249 0.224 0.004 0.000 0.772 0.000 0.000
#> ERR519517     3  0.0000     0.9733 0.000 0.000 1.000 0.000 0.000 0.000
#> ERR519484     4  0.4055     0.7439 0.228 0.008 0.000 0.728 0.036 0.000
#> ERR519498     4  0.3946     0.7834 0.152 0.004 0.000 0.768 0.076 0.000
#> ERR519490     3  0.1716     0.9498 0.000 0.028 0.932 0.036 0.004 0.000
#> ERR519507     5  0.5881     0.1083 0.296 0.000 0.000 0.232 0.472 0.000
#> ERR519511     5  0.2001     0.4689 0.008 0.012 0.000 0.068 0.912 0.000
#> ERR519468     5  0.3079     0.3800 0.004 0.096 0.000 0.056 0.844 0.000
#> ERR519482     2  0.4534     0.6209 0.000 0.580 0.000 0.040 0.380 0.000
#> ERR519475     1  0.4313     0.5678 0.668 0.284 0.000 0.048 0.000 0.000
#> ERR519496     2  0.6043     0.5747 0.124 0.464 0.000 0.028 0.384 0.000
#> ERR519506     1  0.3504     0.6882 0.820 0.016 0.000 0.112 0.052 0.000
#> ERR519469     5  0.2808     0.4745 0.008 0.048 0.000 0.076 0.868 0.000
#> ERR519480     6  0.0458     0.0000 0.000 0.000 0.016 0.000 0.000 0.984
#> ERR519487     3  0.0363     0.9717 0.000 0.000 0.988 0.012 0.000 0.000
#> ERR519483     5  0.5419     0.2757 0.112 0.060 0.000 0.156 0.672 0.000
#> ERR519477     1  0.4313     0.5678 0.668 0.284 0.000 0.048 0.000 0.000
#> ERR519499     3  0.0000     0.9733 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-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 18140 rows and 52 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 0.960           0.936       0.975          0.406 0.599   0.599
#> 3 3 0.590           0.627       0.776          0.454 0.673   0.489
#> 4 4 0.539           0.522       0.759          0.152 0.722   0.425
#> 5 5 0.667           0.685       0.829          0.112 0.827   0.553
#> 6 6 0.715           0.696       0.794          0.053 0.926   0.727

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
#> ERR519515     1   0.000     0.9779 1.000 0.000
#> ERR519516     1   0.000     0.9779 1.000 0.000
#> ERR519520     1   0.000     0.9779 1.000 0.000
#> ERR519513     1   0.000     0.9779 1.000 0.000
#> ERR519481     1   0.000     0.9779 1.000 0.000
#> ERR519491     1   0.000     0.9779 1.000 0.000
#> ERR519473     1   1.000    -0.0708 0.504 0.496
#> ERR519518     2   0.000     0.9580 0.000 1.000
#> ERR519512     1   0.000     0.9779 1.000 0.000
#> ERR519521     1   0.000     0.9779 1.000 0.000
#> ERR519488     1   0.000     0.9779 1.000 0.000
#> ERR519493     1   0.000     0.9779 1.000 0.000
#> ERR519514     1   0.000     0.9779 1.000 0.000
#> ERR519479     1   0.000     0.9779 1.000 0.000
#> ERR519509     1   0.000     0.9779 1.000 0.000
#> ERR519472     1   0.000     0.9779 1.000 0.000
#> ERR519510     1   0.000     0.9779 1.000 0.000
#> ERR519470     1   0.000     0.9779 1.000 0.000
#> ERR519495     2   0.388     0.8997 0.076 0.924
#> ERR519522     1   0.000     0.9779 1.000 0.000
#> ERR519523     1   0.000     0.9779 1.000 0.000
#> ERR519503     2   0.775     0.7076 0.228 0.772
#> ERR519471     1   0.000     0.9779 1.000 0.000
#> ERR519500     1   0.000     0.9779 1.000 0.000
#> ERR519485     1   0.000     0.9779 1.000 0.000
#> ERR519476     1   0.000     0.9779 1.000 0.000
#> ERR519502     1   0.000     0.9779 1.000 0.000
#> ERR519486     2   0.000     0.9580 0.000 1.000
#> ERR519478     1   0.000     0.9779 1.000 0.000
#> ERR519497     1   0.430     0.8867 0.912 0.088
#> ERR519467     1   0.000     0.9779 1.000 0.000
#> ERR519489     2   0.000     0.9580 0.000 1.000
#> ERR519494     2   0.000     0.9580 0.000 1.000
#> ERR519474     1   0.000     0.9779 1.000 0.000
#> ERR519505     1   0.000     0.9779 1.000 0.000
#> ERR519517     2   0.000     0.9580 0.000 1.000
#> ERR519484     1   0.000     0.9779 1.000 0.000
#> ERR519498     1   0.000     0.9779 1.000 0.000
#> ERR519490     2   0.000     0.9580 0.000 1.000
#> ERR519507     1   0.000     0.9779 1.000 0.000
#> ERR519511     2   0.000     0.9580 0.000 1.000
#> ERR519468     2   0.760     0.7307 0.220 0.780
#> ERR519482     2   0.000     0.9580 0.000 1.000
#> ERR519475     1   0.000     0.9779 1.000 0.000
#> ERR519496     1   0.689     0.7618 0.816 0.184
#> ERR519506     1   0.000     0.9779 1.000 0.000
#> ERR519469     1   0.000     0.9779 1.000 0.000
#> ERR519480     2   0.000     0.9580 0.000 1.000
#> ERR519487     2   0.000     0.9580 0.000 1.000
#> ERR519483     1   0.000     0.9779 1.000 0.000
#> ERR519477     1   0.000     0.9779 1.000 0.000
#> ERR519499     2   0.000     0.9580 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
#> ERR519515     1  0.6095      0.762 0.608 0.392 0.000
#> ERR519516     1  0.6215      0.716 0.572 0.428 0.000
#> ERR519520     1  0.2537      0.348 0.920 0.080 0.000
#> ERR519513     2  0.2537      0.638 0.080 0.920 0.000
#> ERR519481     2  0.1964      0.646 0.056 0.944 0.000
#> ERR519491     1  0.6126      0.760 0.600 0.400 0.000
#> ERR519473     2  0.0661      0.636 0.004 0.988 0.008
#> ERR519518     2  0.6632      0.309 0.392 0.596 0.012
#> ERR519512     2  0.3879      0.603 0.152 0.848 0.000
#> ERR519521     2  0.5216      0.529 0.260 0.740 0.000
#> ERR519488     1  0.3412      0.498 0.876 0.124 0.000
#> ERR519493     1  0.6192      0.730 0.580 0.420 0.000
#> ERR519514     1  0.6095      0.762 0.608 0.392 0.000
#> ERR519479     1  0.6309      0.555 0.504 0.496 0.000
#> ERR519509     1  0.1031      0.413 0.976 0.024 0.000
#> ERR519472     2  0.3038      0.625 0.104 0.896 0.000
#> ERR519510     2  0.6140     -0.283 0.404 0.596 0.000
#> ERR519470     1  0.6095      0.762 0.608 0.392 0.000
#> ERR519495     3  0.1643      0.945 0.000 0.044 0.956
#> ERR519522     1  0.6062      0.757 0.616 0.384 0.000
#> ERR519523     1  0.6111      0.761 0.604 0.396 0.000
#> ERR519503     1  0.3998      0.255 0.884 0.056 0.060
#> ERR519471     1  0.6095      0.762 0.608 0.392 0.000
#> ERR519500     2  0.3267      0.616 0.116 0.884 0.000
#> ERR519485     1  0.6111      0.761 0.604 0.396 0.000
#> ERR519476     1  0.6126      0.760 0.600 0.400 0.000
#> ERR519502     2  0.1964      0.646 0.056 0.944 0.000
#> ERR519486     3  0.0000      0.973 0.000 0.000 1.000
#> ERR519478     1  0.1031      0.413 0.976 0.024 0.000
#> ERR519497     2  0.6192      0.328 0.420 0.580 0.000
#> ERR519467     1  0.6095      0.762 0.608 0.392 0.000
#> ERR519489     3  0.0000      0.973 0.000 0.000 1.000
#> ERR519494     3  0.0000      0.973 0.000 0.000 1.000
#> ERR519474     1  0.6126      0.760 0.600 0.400 0.000
#> ERR519505     2  0.6274     -0.464 0.456 0.544 0.000
#> ERR519517     3  0.0000      0.973 0.000 0.000 1.000
#> ERR519484     2  0.6168     -0.312 0.412 0.588 0.000
#> ERR519498     2  0.3482      0.593 0.128 0.872 0.000
#> ERR519490     3  0.0000      0.973 0.000 0.000 1.000
#> ERR519507     2  0.5497      0.218 0.292 0.708 0.000
#> ERR519511     3  0.0000      0.973 0.000 0.000 1.000
#> ERR519468     2  0.3805      0.576 0.024 0.884 0.092
#> ERR519482     3  0.6578      0.746 0.224 0.052 0.724
#> ERR519475     1  0.6126      0.760 0.600 0.400 0.000
#> ERR519496     1  0.1964      0.325 0.944 0.056 0.000
#> ERR519506     1  0.6126      0.760 0.600 0.400 0.000
#> ERR519469     2  0.0237      0.639 0.004 0.996 0.000
#> ERR519480     3  0.0000      0.973 0.000 0.000 1.000
#> ERR519487     3  0.0000      0.973 0.000 0.000 1.000
#> ERR519483     1  0.6859      0.727 0.620 0.356 0.024
#> ERR519477     1  0.6126      0.760 0.600 0.400 0.000
#> ERR519499     3  0.0000      0.973 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
#> ERR519515     1  0.2589    0.65750 0.884 0.116 0.000 0.000
#> ERR519516     1  0.1388    0.69100 0.960 0.028 0.000 0.012
#> ERR519520     2  0.4328    0.47982 0.244 0.748 0.000 0.008
#> ERR519513     1  0.7860   -0.16823 0.396 0.292 0.000 0.312
#> ERR519481     4  0.7818    0.14714 0.356 0.256 0.000 0.388
#> ERR519491     1  0.0188    0.69782 0.996 0.004 0.000 0.000
#> ERR519473     4  0.0000    0.50097 0.000 0.000 0.000 1.000
#> ERR519518     2  0.5090    0.20669 0.000 0.728 0.044 0.228
#> ERR519512     1  0.7148    0.25922 0.496 0.364 0.000 0.140
#> ERR519521     2  0.7781   -0.23052 0.248 0.408 0.000 0.344
#> ERR519488     1  0.4605    0.22957 0.664 0.336 0.000 0.000
#> ERR519493     1  0.1256    0.69202 0.964 0.028 0.000 0.008
#> ERR519514     1  0.2589    0.65750 0.884 0.116 0.000 0.000
#> ERR519479     1  0.3679    0.64027 0.856 0.084 0.000 0.060
#> ERR519509     2  0.4999    0.28915 0.492 0.508 0.000 0.000
#> ERR519472     4  0.5250    0.08844 0.440 0.008 0.000 0.552
#> ERR519510     1  0.6815    0.28508 0.580 0.284 0.000 0.136
#> ERR519470     1  0.2647    0.65459 0.880 0.120 0.000 0.000
#> ERR519495     4  0.4356    0.19751 0.000 0.000 0.292 0.708
#> ERR519522     1  0.3266    0.60436 0.832 0.168 0.000 0.000
#> ERR519523     1  0.2704    0.65563 0.876 0.124 0.000 0.000
#> ERR519503     2  0.5178    0.53933 0.252 0.716 0.020 0.012
#> ERR519471     1  0.2589    0.65750 0.884 0.116 0.000 0.000
#> ERR519500     1  0.6060    0.00536 0.516 0.044 0.000 0.440
#> ERR519485     1  0.2111    0.67496 0.932 0.024 0.000 0.044
#> ERR519476     1  0.0000    0.69820 1.000 0.000 0.000 0.000
#> ERR519502     4  0.7818    0.14714 0.356 0.256 0.000 0.388
#> ERR519486     3  0.0000    0.95038 0.000 0.000 1.000 0.000
#> ERR519478     2  0.4999    0.28915 0.492 0.508 0.000 0.000
#> ERR519497     2  0.2676    0.31198 0.012 0.896 0.000 0.092
#> ERR519467     1  0.2868    0.64115 0.864 0.136 0.000 0.000
#> ERR519489     3  0.0000    0.95038 0.000 0.000 1.000 0.000
#> ERR519494     3  0.0000    0.95038 0.000 0.000 1.000 0.000
#> ERR519474     1  0.0000    0.69820 1.000 0.000 0.000 0.000
#> ERR519505     1  0.6639    0.31599 0.596 0.284 0.000 0.120
#> ERR519517     3  0.0000    0.95038 0.000 0.000 1.000 0.000
#> ERR519484     1  0.6572    0.33213 0.608 0.272 0.000 0.120
#> ERR519498     1  0.7086    0.21230 0.548 0.292 0.000 0.160
#> ERR519490     3  0.0000    0.95038 0.000 0.000 1.000 0.000
#> ERR519507     1  0.5069    0.36612 0.664 0.016 0.000 0.320
#> ERR519511     3  0.0336    0.94380 0.000 0.008 0.992 0.000
#> ERR519468     4  0.1820    0.48091 0.000 0.036 0.020 0.944
#> ERR519482     3  0.6090    0.40085 0.000 0.384 0.564 0.052
#> ERR519475     1  0.0000    0.69820 1.000 0.000 0.000 0.000
#> ERR519496     2  0.4804    0.54270 0.276 0.708 0.000 0.016
#> ERR519506     1  0.0188    0.69826 0.996 0.000 0.000 0.004
#> ERR519469     4  0.0336    0.50069 0.000 0.008 0.000 0.992
#> ERR519480     3  0.0000    0.95038 0.000 0.000 1.000 0.000
#> ERR519487     3  0.0000    0.95038 0.000 0.000 1.000 0.000
#> ERR519483     1  0.4734    0.47766 0.776 0.040 0.004 0.180
#> ERR519477     1  0.0000    0.69820 1.000 0.000 0.000 0.000
#> ERR519499     3  0.0000    0.95038 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
#> ERR519515     1  0.1251     0.7556 0.956 0.036 0.000 0.000 0.008
#> ERR519516     1  0.3684     0.6244 0.720 0.000 0.000 0.000 0.280
#> ERR519520     2  0.5354     0.4711 0.208 0.664 0.000 0.000 0.128
#> ERR519513     5  0.2304     0.8120 0.068 0.004 0.000 0.020 0.908
#> ERR519481     5  0.4651     0.7622 0.064 0.080 0.000 0.068 0.788
#> ERR519491     1  0.1792     0.7664 0.916 0.000 0.000 0.000 0.084
#> ERR519473     4  0.0404     0.7686 0.000 0.000 0.000 0.988 0.012
#> ERR519518     2  0.3794     0.5996 0.000 0.832 0.016 0.080 0.072
#> ERR519512     5  0.7100     0.1469 0.276 0.284 0.000 0.016 0.424
#> ERR519521     5  0.3934     0.7128 0.020 0.092 0.000 0.064 0.824
#> ERR519488     1  0.4878     0.4764 0.676 0.264 0.000 0.000 0.060
#> ERR519493     1  0.2929     0.7234 0.820 0.000 0.000 0.000 0.180
#> ERR519514     1  0.0880     0.7595 0.968 0.032 0.000 0.000 0.000
#> ERR519479     1  0.4492     0.6111 0.712 0.016 0.000 0.016 0.256
#> ERR519509     1  0.5454    -0.0330 0.488 0.452 0.000 0.000 0.060
#> ERR519472     4  0.5617     0.0746 0.404 0.016 0.000 0.536 0.044
#> ERR519510     5  0.2020     0.8082 0.100 0.000 0.000 0.000 0.900
#> ERR519470     1  0.1043     0.7575 0.960 0.040 0.000 0.000 0.000
#> ERR519495     4  0.1557     0.7482 0.000 0.008 0.052 0.940 0.000
#> ERR519522     1  0.3930     0.6402 0.792 0.152 0.000 0.000 0.056
#> ERR519523     1  0.2270     0.7458 0.904 0.076 0.000 0.000 0.020
#> ERR519503     2  0.2020     0.6652 0.100 0.900 0.000 0.000 0.000
#> ERR519471     1  0.1043     0.7575 0.960 0.040 0.000 0.000 0.000
#> ERR519500     1  0.7472     0.1954 0.492 0.080 0.000 0.256 0.172
#> ERR519485     1  0.1990     0.7694 0.920 0.008 0.000 0.004 0.068
#> ERR519476     1  0.2280     0.7586 0.880 0.000 0.000 0.000 0.120
#> ERR519502     5  0.4450     0.7567 0.052 0.084 0.000 0.064 0.800
#> ERR519486     3  0.0000     0.9981 0.000 0.000 1.000 0.000 0.000
#> ERR519478     1  0.5403    -0.0369 0.488 0.456 0.000 0.000 0.056
#> ERR519497     2  0.2450     0.6400 0.000 0.896 0.000 0.028 0.076
#> ERR519467     1  0.2983     0.7094 0.864 0.096 0.000 0.000 0.040
#> ERR519489     3  0.0000     0.9981 0.000 0.000 1.000 0.000 0.000
#> ERR519494     3  0.0000     0.9981 0.000 0.000 1.000 0.000 0.000
#> ERR519474     1  0.2280     0.7572 0.880 0.000 0.000 0.000 0.120
#> ERR519505     5  0.1851     0.8091 0.088 0.000 0.000 0.000 0.912
#> ERR519517     3  0.0000     0.9981 0.000 0.000 1.000 0.000 0.000
#> ERR519484     5  0.2605     0.7690 0.148 0.000 0.000 0.000 0.852
#> ERR519498     5  0.1831     0.8150 0.076 0.000 0.000 0.004 0.920
#> ERR519490     3  0.0000     0.9981 0.000 0.000 1.000 0.000 0.000
#> ERR519507     1  0.5781     0.4661 0.620 0.008 0.000 0.260 0.112
#> ERR519511     3  0.0404     0.9849 0.000 0.000 0.988 0.000 0.012
#> ERR519468     4  0.1990     0.7406 0.000 0.040 0.028 0.928 0.004
#> ERR519482     2  0.5310     0.0886 0.000 0.508 0.448 0.040 0.004
#> ERR519475     1  0.2280     0.7586 0.880 0.000 0.000 0.000 0.120
#> ERR519496     2  0.2773     0.6377 0.164 0.836 0.000 0.000 0.000
#> ERR519506     1  0.2513     0.7585 0.876 0.000 0.000 0.008 0.116
#> ERR519469     4  0.0324     0.7712 0.000 0.004 0.000 0.992 0.004
#> ERR519480     3  0.0000     0.9981 0.000 0.000 1.000 0.000 0.000
#> ERR519487     3  0.0000     0.9981 0.000 0.000 1.000 0.000 0.000
#> ERR519483     1  0.5780     0.5839 0.672 0.028 0.000 0.180 0.120
#> ERR519477     1  0.2280     0.7586 0.880 0.000 0.000 0.000 0.120
#> ERR519499     3  0.0000     0.9981 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
#> ERR519515     1  0.2595     0.6639 0.836 0.000 0.000 0.160 0.000 0.004
#> ERR519516     1  0.3974     0.5670 0.752 0.000 0.000 0.056 0.188 0.004
#> ERR519520     4  0.5327     0.4466 0.096 0.000 0.000 0.668 0.048 0.188
#> ERR519513     5  0.2756     0.8505 0.072 0.008 0.000 0.012 0.880 0.028
#> ERR519481     5  0.3457     0.8022 0.016 0.028 0.000 0.064 0.848 0.044
#> ERR519491     1  0.0935     0.7385 0.964 0.000 0.000 0.032 0.004 0.000
#> ERR519473     2  0.1176     0.7146 0.000 0.956 0.000 0.020 0.024 0.000
#> ERR519518     6  0.2489     0.7158 0.000 0.028 0.016 0.020 0.032 0.904
#> ERR519512     4  0.6437     0.3526 0.096 0.004 0.000 0.572 0.196 0.132
#> ERR519521     5  0.4934     0.6779 0.008 0.028 0.000 0.184 0.708 0.072
#> ERR519488     4  0.4150     0.7231 0.320 0.000 0.000 0.652 0.000 0.028
#> ERR519493     1  0.2290     0.7075 0.892 0.000 0.000 0.020 0.084 0.004
#> ERR519514     1  0.2558     0.6677 0.840 0.000 0.000 0.156 0.000 0.004
#> ERR519479     1  0.5141     0.5910 0.704 0.016 0.000 0.084 0.168 0.028
#> ERR519509     4  0.4344     0.7355 0.304 0.000 0.000 0.652 0.000 0.044
#> ERR519472     2  0.6350    -0.1036 0.416 0.440 0.000 0.084 0.044 0.016
#> ERR519510     5  0.1765     0.8591 0.096 0.000 0.000 0.000 0.904 0.000
#> ERR519470     1  0.2520     0.6697 0.844 0.000 0.000 0.152 0.000 0.004
#> ERR519495     2  0.1262     0.7149 0.000 0.956 0.020 0.008 0.000 0.016
#> ERR519522     4  0.3765     0.5668 0.404 0.000 0.000 0.596 0.000 0.000
#> ERR519523     1  0.3652     0.6122 0.760 0.000 0.000 0.212 0.020 0.008
#> ERR519503     6  0.3163     0.7073 0.004 0.000 0.000 0.232 0.000 0.764
#> ERR519471     1  0.2558     0.6689 0.840 0.000 0.000 0.156 0.000 0.004
#> ERR519500     1  0.7704     0.2156 0.468 0.200 0.000 0.152 0.128 0.052
#> ERR519485     1  0.3706     0.6656 0.808 0.016 0.000 0.132 0.008 0.036
#> ERR519476     1  0.0692     0.7381 0.976 0.000 0.000 0.004 0.020 0.000
#> ERR519502     5  0.3322     0.8013 0.012 0.032 0.000 0.056 0.856 0.044
#> ERR519486     3  0.1148     0.9548 0.000 0.004 0.960 0.020 0.000 0.016
#> ERR519478     4  0.4499     0.7351 0.288 0.000 0.000 0.652 0.000 0.060
#> ERR519497     6  0.3575     0.7292 0.000 0.000 0.000 0.128 0.076 0.796
#> ERR519467     1  0.3765     0.0591 0.596 0.000 0.000 0.404 0.000 0.000
#> ERR519489     3  0.0000     0.9839 0.000 0.000 1.000 0.000 0.000 0.000
#> ERR519494     3  0.0000     0.9839 0.000 0.000 1.000 0.000 0.000 0.000
#> ERR519474     1  0.1003     0.7379 0.964 0.000 0.000 0.016 0.020 0.000
#> ERR519505     5  0.2333     0.8578 0.092 0.000 0.000 0.024 0.884 0.000
#> ERR519517     3  0.0000     0.9839 0.000 0.000 1.000 0.000 0.000 0.000
#> ERR519484     5  0.2668     0.8024 0.168 0.000 0.000 0.004 0.828 0.000
#> ERR519498     5  0.1812     0.8621 0.080 0.000 0.000 0.000 0.912 0.008
#> ERR519490     3  0.0000     0.9839 0.000 0.000 1.000 0.000 0.000 0.000
#> ERR519507     1  0.6173     0.4414 0.608 0.220 0.000 0.092 0.056 0.024
#> ERR519511     3  0.2457     0.9080 0.000 0.008 0.904 0.032 0.028 0.028
#> ERR519468     2  0.3256     0.6522 0.000 0.836 0.020 0.032 0.000 0.112
#> ERR519482     6  0.4320     0.5694 0.000 0.032 0.244 0.012 0.004 0.708
#> ERR519475     1  0.0692     0.7381 0.976 0.000 0.000 0.004 0.020 0.000
#> ERR519496     6  0.4385     0.6166 0.060 0.000 0.000 0.240 0.004 0.696
#> ERR519506     1  0.1780     0.7319 0.932 0.004 0.000 0.036 0.024 0.004
#> ERR519469     2  0.1675     0.7195 0.000 0.936 0.000 0.032 0.008 0.024
#> ERR519480     3  0.0000     0.9839 0.000 0.000 1.000 0.000 0.000 0.000
#> ERR519487     3  0.0000     0.9839 0.000 0.000 1.000 0.000 0.000 0.000
#> ERR519483     1  0.6905     0.3979 0.580 0.092 0.012 0.200 0.044 0.072
#> ERR519477     1  0.0692     0.7381 0.976 0.000 0.000 0.004 0.020 0.000
#> ERR519499     3  0.0000     0.9839 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 18140 rows and 52 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#>   Subgroups are detected by 'pam' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk CV-pam-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.991       0.996          0.215 0.792   0.792
#> 3 3 0.964           0.882       0.969          0.248 0.966   0.957
#> 4 4 0.663           0.894       0.944          0.363 0.905   0.875
#> 5 5 0.488           0.628       0.857          0.318 0.934   0.901
#> 6 6 0.502           0.432       0.752          0.134 0.748   0.614

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
#> ERR519515     1    0.00      0.995 1.000 0.000
#> ERR519516     1    0.00      0.995 1.000 0.000
#> ERR519520     1    0.00      0.995 1.000 0.000
#> ERR519513     1    0.00      0.995 1.000 0.000
#> ERR519481     1    0.00      0.995 1.000 0.000
#> ERR519491     1    0.00      0.995 1.000 0.000
#> ERR519473     1    0.00      0.995 1.000 0.000
#> ERR519518     1    0.00      0.995 1.000 0.000
#> ERR519512     1    0.00      0.995 1.000 0.000
#> ERR519521     1    0.00      0.995 1.000 0.000
#> ERR519488     1    0.00      0.995 1.000 0.000
#> ERR519493     1    0.00      0.995 1.000 0.000
#> ERR519514     1    0.00      0.995 1.000 0.000
#> ERR519479     1    0.00      0.995 1.000 0.000
#> ERR519509     1    0.00      0.995 1.000 0.000
#> ERR519472     1    0.00      0.995 1.000 0.000
#> ERR519510     1    0.00      0.995 1.000 0.000
#> ERR519470     1    0.00      0.995 1.000 0.000
#> ERR519495     1    0.00      0.995 1.000 0.000
#> ERR519522     1    0.00      0.995 1.000 0.000
#> ERR519523     1    0.00      0.995 1.000 0.000
#> ERR519503     1    0.00      0.995 1.000 0.000
#> ERR519471     1    0.00      0.995 1.000 0.000
#> ERR519500     1    0.00      0.995 1.000 0.000
#> ERR519485     1    0.00      0.995 1.000 0.000
#> ERR519476     1    0.00      0.995 1.000 0.000
#> ERR519502     1    0.00      0.995 1.000 0.000
#> ERR519486     1    0.00      0.995 1.000 0.000
#> ERR519478     1    0.00      0.995 1.000 0.000
#> ERR519497     1    0.00      0.995 1.000 0.000
#> ERR519467     1    0.00      0.995 1.000 0.000
#> ERR519489     2    0.00      1.000 0.000 1.000
#> ERR519494     2    0.00      1.000 0.000 1.000
#> ERR519474     1    0.00      0.995 1.000 0.000
#> ERR519505     1    0.00      0.995 1.000 0.000
#> ERR519517     2    0.00      1.000 0.000 1.000
#> ERR519484     1    0.00      0.995 1.000 0.000
#> ERR519498     1    0.00      0.995 1.000 0.000
#> ERR519490     2    0.00      1.000 0.000 1.000
#> ERR519507     1    0.00      0.995 1.000 0.000
#> ERR519511     1    0.00      0.995 1.000 0.000
#> ERR519468     1    0.00      0.995 1.000 0.000
#> ERR519482     1    0.00      0.995 1.000 0.000
#> ERR519475     1    0.00      0.995 1.000 0.000
#> ERR519496     1    0.00      0.995 1.000 0.000
#> ERR519506     1    0.00      0.995 1.000 0.000
#> ERR519469     1    0.00      0.995 1.000 0.000
#> ERR519480     1    0.73      0.744 0.796 0.204
#> ERR519487     2    0.00      1.000 0.000 1.000
#> ERR519483     1    0.00      0.995 1.000 0.000
#> ERR519477     1    0.00      0.995 1.000 0.000
#> ERR519499     2    0.00      1.000 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette  p1  p2 p3
#> ERR519515     1   0.000     0.9545 1.0 0.0  0
#> ERR519516     1   0.000     0.9545 1.0 0.0  0
#> ERR519520     1   0.000     0.9545 1.0 0.0  0
#> ERR519513     1   0.000     0.9545 1.0 0.0  0
#> ERR519481     1   0.000     0.9545 1.0 0.0  0
#> ERR519491     1   0.000     0.9545 1.0 0.0  0
#> ERR519473     1   0.000     0.9545 1.0 0.0  0
#> ERR519518     1   0.000     0.9545 1.0 0.0  0
#> ERR519512     1   0.000     0.9545 1.0 0.0  0
#> ERR519521     1   0.000     0.9545 1.0 0.0  0
#> ERR519488     1   0.000     0.9545 1.0 0.0  0
#> ERR519493     1   0.000     0.9545 1.0 0.0  0
#> ERR519514     1   0.000     0.9545 1.0 0.0  0
#> ERR519479     1   0.000     0.9545 1.0 0.0  0
#> ERR519509     1   0.000     0.9545 1.0 0.0  0
#> ERR519472     1   0.000     0.9545 1.0 0.0  0
#> ERR519510     1   0.000     0.9545 1.0 0.0  0
#> ERR519470     1   0.000     0.9545 1.0 0.0  0
#> ERR519495     1   0.000     0.9545 1.0 0.0  0
#> ERR519522     1   0.000     0.9545 1.0 0.0  0
#> ERR519523     1   0.000     0.9545 1.0 0.0  0
#> ERR519503     1   0.000     0.9545 1.0 0.0  0
#> ERR519471     1   0.000     0.9545 1.0 0.0  0
#> ERR519500     1   0.000     0.9545 1.0 0.0  0
#> ERR519485     1   0.000     0.9545 1.0 0.0  0
#> ERR519476     1   0.613    -0.0797 0.6 0.4  0
#> ERR519502     1   0.000     0.9545 1.0 0.0  0
#> ERR519486     1   0.000     0.9545 1.0 0.0  0
#> ERR519478     1   0.000     0.9545 1.0 0.0  0
#> ERR519497     1   0.000     0.9545 1.0 0.0  0
#> ERR519467     1   0.000     0.9545 1.0 0.0  0
#> ERR519489     3   0.000     1.0000 0.0 0.0  1
#> ERR519494     3   0.000     1.0000 0.0 0.0  1
#> ERR519474     1   0.000     0.9545 1.0 0.0  0
#> ERR519505     1   0.000     0.9545 1.0 0.0  0
#> ERR519517     3   0.000     1.0000 0.0 0.0  1
#> ERR519484     1   0.000     0.9545 1.0 0.0  0
#> ERR519498     1   0.000     0.9545 1.0 0.0  0
#> ERR519490     3   0.000     1.0000 0.0 0.0  1
#> ERR519507     1   0.000     0.9545 1.0 0.0  0
#> ERR519511     1   0.000     0.9545 1.0 0.0  0
#> ERR519468     1   0.000     0.9545 1.0 0.0  0
#> ERR519482     1   0.000     0.9545 1.0 0.0  0
#> ERR519475     1   0.613    -0.0797 0.6 0.4  0
#> ERR519496     1   0.000     0.9545 1.0 0.0  0
#> ERR519506     1   0.000     0.9545 1.0 0.0  0
#> ERR519469     1   0.000     0.9545 1.0 0.0  0
#> ERR519480     2   0.613     0.0000 0.4 0.6  0
#> ERR519487     3   0.000     1.0000 0.0 0.0  1
#> ERR519483     1   0.000     0.9545 1.0 0.0  0
#> ERR519477     1   0.613    -0.0797 0.6 0.4  0
#> ERR519499     3   0.000     1.0000 0.0 0.0  1

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3 p4
#> ERR519515     1  0.0000      0.935 1.000 0.000 0.000  0
#> ERR519516     1  0.0000      0.935 1.000 0.000 0.000  0
#> ERR519520     1  0.3311      0.798 0.828 0.172 0.000  0
#> ERR519513     1  0.0000      0.935 1.000 0.000 0.000  0
#> ERR519481     1  0.0000      0.935 1.000 0.000 0.000  0
#> ERR519491     1  0.0000      0.935 1.000 0.000 0.000  0
#> ERR519473     1  0.0000      0.935 1.000 0.000 0.000  0
#> ERR519518     1  0.3726      0.754 0.788 0.212 0.000  0
#> ERR519512     1  0.1389      0.906 0.952 0.048 0.000  0
#> ERR519521     1  0.2469      0.859 0.892 0.108 0.000  0
#> ERR519488     1  0.2814      0.837 0.868 0.132 0.000  0
#> ERR519493     1  0.0000      0.935 1.000 0.000 0.000  0
#> ERR519514     1  0.0000      0.935 1.000 0.000 0.000  0
#> ERR519479     1  0.0000      0.935 1.000 0.000 0.000  0
#> ERR519509     1  0.3311      0.798 0.828 0.172 0.000  0
#> ERR519472     1  0.0000      0.935 1.000 0.000 0.000  0
#> ERR519510     1  0.0000      0.935 1.000 0.000 0.000  0
#> ERR519470     1  0.0000      0.935 1.000 0.000 0.000  0
#> ERR519495     1  0.0000      0.935 1.000 0.000 0.000  0
#> ERR519522     1  0.0000      0.935 1.000 0.000 0.000  0
#> ERR519523     1  0.0000      0.935 1.000 0.000 0.000  0
#> ERR519503     1  0.3726      0.754 0.788 0.212 0.000  0
#> ERR519471     1  0.0000      0.935 1.000 0.000 0.000  0
#> ERR519500     1  0.0000      0.935 1.000 0.000 0.000  0
#> ERR519485     1  0.0000      0.935 1.000 0.000 0.000  0
#> ERR519476     2  0.4277      1.000 0.280 0.720 0.000  0
#> ERR519502     1  0.0000      0.935 1.000 0.000 0.000  0
#> ERR519486     1  0.0000      0.935 1.000 0.000 0.000  0
#> ERR519478     1  0.3726      0.754 0.788 0.212 0.000  0
#> ERR519497     1  0.3726      0.754 0.788 0.212 0.000  0
#> ERR519467     1  0.0592      0.922 0.984 0.016 0.000  0
#> ERR519489     3  0.0000      0.987 0.000 0.000 1.000  0
#> ERR519494     3  0.0000      0.987 0.000 0.000 1.000  0
#> ERR519474     1  0.1302      0.893 0.956 0.044 0.000  0
#> ERR519505     1  0.1389      0.906 0.952 0.048 0.000  0
#> ERR519517     3  0.0000      0.987 0.000 0.000 1.000  0
#> ERR519484     1  0.0188      0.932 0.996 0.004 0.000  0
#> ERR519498     1  0.0000      0.935 1.000 0.000 0.000  0
#> ERR519490     3  0.1792      0.934 0.000 0.068 0.932  0
#> ERR519507     1  0.0000      0.935 1.000 0.000 0.000  0
#> ERR519511     1  0.1022      0.914 0.968 0.032 0.000  0
#> ERR519468     1  0.0000      0.935 1.000 0.000 0.000  0
#> ERR519482     1  0.3688      0.759 0.792 0.208 0.000  0
#> ERR519475     2  0.4277      1.000 0.280 0.720 0.000  0
#> ERR519496     1  0.3569      0.771 0.804 0.196 0.000  0
#> ERR519506     1  0.0000      0.935 1.000 0.000 0.000  0
#> ERR519469     1  0.0000      0.935 1.000 0.000 0.000  0
#> ERR519480     4  0.0000      0.000 0.000 0.000 0.000  1
#> ERR519487     3  0.0000      0.987 0.000 0.000 1.000  0
#> ERR519483     1  0.0000      0.935 1.000 0.000 0.000  0
#> ERR519477     2  0.4277      1.000 0.280 0.720 0.000  0
#> ERR519499     3  0.0000      0.987 0.000 0.000 1.000  0

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4 p5
#> ERR519515     1  0.0000     0.7937 1.000 0.000 0.000 0.000  0
#> ERR519516     1  0.0000     0.7937 1.000 0.000 0.000 0.000  0
#> ERR519520     1  0.3381     0.6228 0.808 0.176 0.000 0.016  0
#> ERR519513     1  0.4182     0.1965 0.600 0.000 0.000 0.400  0
#> ERR519481     1  0.4182     0.1965 0.600 0.000 0.000 0.400  0
#> ERR519491     1  0.0000     0.7937 1.000 0.000 0.000 0.000  0
#> ERR519473     1  0.0000     0.7937 1.000 0.000 0.000 0.000  0
#> ERR519518     4  0.6622     0.2939 0.364 0.220 0.000 0.416  0
#> ERR519512     1  0.1774     0.7498 0.932 0.052 0.000 0.016  0
#> ERR519521     1  0.5537     0.2959 0.624 0.112 0.000 0.264  0
#> ERR519488     1  0.2920     0.6747 0.852 0.132 0.000 0.016  0
#> ERR519493     1  0.0794     0.7786 0.972 0.000 0.000 0.028  0
#> ERR519514     1  0.0000     0.7937 1.000 0.000 0.000 0.000  0
#> ERR519479     1  0.0290     0.7902 0.992 0.000 0.000 0.008  0
#> ERR519509     1  0.3381     0.6228 0.808 0.176 0.000 0.016  0
#> ERR519472     1  0.0000     0.7937 1.000 0.000 0.000 0.000  0
#> ERR519510     1  0.4182     0.1965 0.600 0.000 0.000 0.400  0
#> ERR519470     1  0.0000     0.7937 1.000 0.000 0.000 0.000  0
#> ERR519495     1  0.0000     0.7937 1.000 0.000 0.000 0.000  0
#> ERR519522     1  0.0000     0.7937 1.000 0.000 0.000 0.000  0
#> ERR519523     1  0.0000     0.7937 1.000 0.000 0.000 0.000  0
#> ERR519503     1  0.3759     0.5603 0.764 0.220 0.000 0.016  0
#> ERR519471     1  0.0000     0.7937 1.000 0.000 0.000 0.000  0
#> ERR519500     1  0.0000     0.7937 1.000 0.000 0.000 0.000  0
#> ERR519485     1  0.0000     0.7937 1.000 0.000 0.000 0.000  0
#> ERR519476     2  0.3274     1.0000 0.220 0.780 0.000 0.000  0
#> ERR519502     1  0.4182     0.1965 0.600 0.000 0.000 0.400  0
#> ERR519486     1  0.2068     0.7227 0.904 0.004 0.000 0.092  0
#> ERR519478     1  0.3727     0.5664 0.768 0.216 0.000 0.016  0
#> ERR519497     4  0.6622     0.2939 0.364 0.220 0.000 0.416  0
#> ERR519467     1  0.0609     0.7812 0.980 0.020 0.000 0.000  0
#> ERR519489     3  0.0000     1.0000 0.000 0.000 1.000 0.000  0
#> ERR519494     3  0.0000     1.0000 0.000 0.000 1.000 0.000  0
#> ERR519474     1  0.1341     0.7521 0.944 0.056 0.000 0.000  0
#> ERR519505     1  0.5250     0.0211 0.536 0.048 0.000 0.416  0
#> ERR519517     3  0.0000     1.0000 0.000 0.000 1.000 0.000  0
#> ERR519484     1  0.4331     0.1874 0.596 0.004 0.000 0.400  0
#> ERR519498     1  0.4182     0.1965 0.600 0.000 0.000 0.400  0
#> ERR519490     4  0.4219    -0.6280 0.000 0.000 0.416 0.584  0
#> ERR519507     1  0.0000     0.7937 1.000 0.000 0.000 0.000  0
#> ERR519511     1  0.5028     0.0911 0.564 0.036 0.000 0.400  0
#> ERR519468     1  0.0000     0.7937 1.000 0.000 0.000 0.000  0
#> ERR519482     1  0.3519     0.5796 0.776 0.216 0.000 0.008  0
#> ERR519475     2  0.3274     1.0000 0.220 0.780 0.000 0.000  0
#> ERR519496     1  0.3109     0.6089 0.800 0.200 0.000 0.000  0
#> ERR519506     1  0.0000     0.7937 1.000 0.000 0.000 0.000  0
#> ERR519469     1  0.0000     0.7937 1.000 0.000 0.000 0.000  0
#> ERR519480     5  0.0000     0.0000 0.000 0.000 0.000 0.000  1
#> ERR519487     3  0.0000     1.0000 0.000 0.000 1.000 0.000  0
#> ERR519483     1  0.0000     0.7937 1.000 0.000 0.000 0.000  0
#> ERR519477     2  0.3274     1.0000 0.220 0.780 0.000 0.000  0
#> ERR519499     3  0.0000     1.0000 0.000 0.000 1.000 0.000  0

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3 p4    p5    p6
#> ERR519515     5  0.3930     0.4475 0.420 0.004 0.000  0 0.576 0.000
#> ERR519516     5  0.3930     0.4475 0.420 0.004 0.000  0 0.576 0.000
#> ERR519520     1  0.2996     0.7761 0.772 0.000 0.000  0 0.228 0.000
#> ERR519513     5  0.0000     0.2339 0.000 0.000 0.000  0 1.000 0.000
#> ERR519481     5  0.0146     0.2332 0.000 0.004 0.000  0 0.996 0.000
#> ERR519491     5  0.3930     0.4475 0.420 0.004 0.000  0 0.576 0.000
#> ERR519473     5  0.3797     0.4480 0.420 0.000 0.000  0 0.580 0.000
#> ERR519518     5  0.3789    -0.3735 0.416 0.000 0.000  0 0.584 0.000
#> ERR519512     1  0.3531     0.6135 0.672 0.000 0.000  0 0.328 0.000
#> ERR519521     5  0.3843    -0.3019 0.452 0.000 0.000  0 0.548 0.000
#> ERR519488     1  0.3592     0.6067 0.656 0.000 0.000  0 0.344 0.000
#> ERR519493     5  0.3872     0.4195 0.392 0.004 0.000  0 0.604 0.000
#> ERR519514     5  0.3930     0.4475 0.420 0.004 0.000  0 0.576 0.000
#> ERR519479     5  0.3782     0.4423 0.412 0.000 0.000  0 0.588 0.000
#> ERR519509     1  0.2996     0.7761 0.772 0.000 0.000  0 0.228 0.000
#> ERR519472     5  0.3797     0.4480 0.420 0.000 0.000  0 0.580 0.000
#> ERR519510     5  0.0000     0.2339 0.000 0.000 0.000  0 1.000 0.000
#> ERR519470     5  0.3930     0.4475 0.420 0.004 0.000  0 0.576 0.000
#> ERR519495     5  0.3797     0.4480 0.420 0.000 0.000  0 0.580 0.000
#> ERR519522     5  0.3930     0.4475 0.420 0.004 0.000  0 0.576 0.000
#> ERR519523     5  0.3930     0.4475 0.420 0.004 0.000  0 0.576 0.000
#> ERR519503     1  0.2491     0.7149 0.836 0.000 0.000  0 0.164 0.000
#> ERR519471     5  0.3930     0.4475 0.420 0.004 0.000  0 0.576 0.000
#> ERR519500     5  0.3797     0.4480 0.420 0.000 0.000  0 0.580 0.000
#> ERR519485     5  0.3797     0.4480 0.420 0.000 0.000  0 0.580 0.000
#> ERR519476     2  0.2762     1.0000 0.000 0.804 0.000  0 0.196 0.000
#> ERR519502     5  0.0000     0.2339 0.000 0.000 0.000  0 1.000 0.000
#> ERR519486     5  0.3592     0.2850 0.344 0.000 0.000  0 0.656 0.000
#> ERR519478     1  0.2697     0.7482 0.812 0.000 0.000  0 0.188 0.000
#> ERR519497     5  0.3789    -0.3735 0.416 0.000 0.000  0 0.584 0.000
#> ERR519467     5  0.4355     0.4055 0.420 0.024 0.000  0 0.556 0.000
#> ERR519489     3  0.2178     0.7842 0.000 0.132 0.868  0 0.000 0.000
#> ERR519494     3  0.0000     0.8580 0.000 0.000 1.000  0 0.000 0.000
#> ERR519474     5  0.4921     0.2978 0.420 0.064 0.000  0 0.516 0.000
#> ERR519505     5  0.2941    -0.0523 0.220 0.000 0.000  0 0.780 0.000
#> ERR519517     3  0.0000     0.8580 0.000 0.000 1.000  0 0.000 0.000
#> ERR519484     5  0.0260     0.2304 0.000 0.008 0.000  0 0.992 0.000
#> ERR519498     5  0.0000     0.2339 0.000 0.000 0.000  0 1.000 0.000
#> ERR519490     3  0.6737     0.1614 0.164 0.064 0.396  0 0.000 0.376
#> ERR519507     5  0.3797     0.4480 0.420 0.000 0.000  0 0.580 0.000
#> ERR519511     5  0.1204     0.1780 0.056 0.000 0.000  0 0.944 0.000
#> ERR519468     5  0.3797     0.4480 0.420 0.000 0.000  0 0.580 0.000
#> ERR519482     6  0.5055     0.0000 0.244 0.000 0.000  0 0.132 0.624
#> ERR519475     2  0.2762     1.0000 0.000 0.804 0.000  0 0.196 0.000
#> ERR519496     1  0.3647     0.4453 0.640 0.000 0.000  0 0.360 0.000
#> ERR519506     5  0.3930     0.4475 0.420 0.004 0.000  0 0.576 0.000
#> ERR519469     5  0.3797     0.4480 0.420 0.000 0.000  0 0.580 0.000
#> ERR519480     4  0.0000     0.0000 0.000 0.000 0.000  1 0.000 0.000
#> ERR519487     3  0.0000     0.8580 0.000 0.000 1.000  0 0.000 0.000
#> ERR519483     5  0.3797     0.4480 0.420 0.000 0.000  0 0.580 0.000
#> ERR519477     2  0.2762     1.0000 0.000 0.804 0.000  0 0.196 0.000
#> ERR519499     3  0.0000     0.8580 0.000 0.000 1.000  0 0.000 0.000

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

consensus_heatmap(res, k = 2)

plot of chunk tab-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 18140 rows and 52 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 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-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.962           0.950       0.980         0.2905 0.708   0.708
#> 3 3 0.350           0.316       0.686         0.7175 0.630   0.508
#> 4 4 0.264           0.592       0.736         0.0516 0.623   0.484
#> 5 5 0.345           0.452       0.739         0.1320 0.780   0.673
#> 6 6 0.331           0.409       0.697         0.1467 0.723   0.492

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
#> ERR519515     1  0.0000      0.987 1.000 0.000
#> ERR519516     1  0.0000      0.987 1.000 0.000
#> ERR519520     1  0.0000      0.987 1.000 0.000
#> ERR519513     1  0.0000      0.987 1.000 0.000
#> ERR519481     1  0.0000      0.987 1.000 0.000
#> ERR519491     1  0.0000      0.987 1.000 0.000
#> ERR519473     1  0.0000      0.987 1.000 0.000
#> ERR519518     2  0.9129      0.539 0.328 0.672
#> ERR519512     1  0.0000      0.987 1.000 0.000
#> ERR519521     1  0.0000      0.987 1.000 0.000
#> ERR519488     1  0.0000      0.987 1.000 0.000
#> ERR519493     1  0.0000      0.987 1.000 0.000
#> ERR519514     1  0.0000      0.987 1.000 0.000
#> ERR519479     1  0.0000      0.987 1.000 0.000
#> ERR519509     1  0.0000      0.987 1.000 0.000
#> ERR519472     1  0.0000      0.987 1.000 0.000
#> ERR519510     1  0.0000      0.987 1.000 0.000
#> ERR519470     1  0.0000      0.987 1.000 0.000
#> ERR519495     1  0.0000      0.987 1.000 0.000
#> ERR519522     1  0.0000      0.987 1.000 0.000
#> ERR519523     1  0.0000      0.987 1.000 0.000
#> ERR519503     1  0.9522      0.345 0.628 0.372
#> ERR519471     1  0.0000      0.987 1.000 0.000
#> ERR519500     1  0.0000      0.987 1.000 0.000
#> ERR519485     1  0.0000      0.987 1.000 0.000
#> ERR519476     1  0.0000      0.987 1.000 0.000
#> ERR519502     1  0.0000      0.987 1.000 0.000
#> ERR519486     1  0.0938      0.976 0.988 0.012
#> ERR519478     1  0.0000      0.987 1.000 0.000
#> ERR519497     1  0.1184      0.972 0.984 0.016
#> ERR519467     1  0.0000      0.987 1.000 0.000
#> ERR519489     2  0.0000      0.930 0.000 1.000
#> ERR519494     2  0.0000      0.930 0.000 1.000
#> ERR519474     1  0.0000      0.987 1.000 0.000
#> ERR519505     1  0.0000      0.987 1.000 0.000
#> ERR519517     2  0.0000      0.930 0.000 1.000
#> ERR519484     1  0.0000      0.987 1.000 0.000
#> ERR519498     1  0.0000      0.987 1.000 0.000
#> ERR519490     2  0.0000      0.930 0.000 1.000
#> ERR519507     1  0.0000      0.987 1.000 0.000
#> ERR519511     1  0.0000      0.987 1.000 0.000
#> ERR519468     1  0.0000      0.987 1.000 0.000
#> ERR519482     2  0.7453      0.737 0.212 0.788
#> ERR519475     1  0.0000      0.987 1.000 0.000
#> ERR519496     1  0.0938      0.976 0.988 0.012
#> ERR519506     1  0.0000      0.987 1.000 0.000
#> ERR519469     1  0.0000      0.987 1.000 0.000
#> ERR519480     2  0.0000      0.930 0.000 1.000
#> ERR519487     2  0.0000      0.930 0.000 1.000
#> ERR519483     1  0.4815      0.871 0.896 0.104
#> ERR519477     1  0.0000      0.987 1.000 0.000
#> ERR519499     2  0.0000      0.930 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
#> ERR519515     1  0.6309     0.1040 0.500 0.500 0.000
#> ERR519516     1  0.6267     0.2036 0.548 0.452 0.000
#> ERR519520     1  0.0592     0.2638 0.988 0.012 0.000
#> ERR519513     1  0.6140     0.2363 0.596 0.404 0.000
#> ERR519481     1  0.5882     0.2680 0.652 0.348 0.000
#> ERR519491     2  0.6308    -0.1823 0.492 0.508 0.000
#> ERR519473     2  0.6302     0.2943 0.480 0.520 0.000
#> ERR519518     1  0.5012     0.2017 0.840 0.080 0.080
#> ERR519512     1  0.5968     0.2650 0.636 0.364 0.000
#> ERR519521     1  0.0237     0.2633 0.996 0.004 0.000
#> ERR519488     1  0.6168     0.0764 0.588 0.412 0.000
#> ERR519493     1  0.6267     0.2070 0.548 0.452 0.000
#> ERR519514     2  0.6309    -0.1798 0.496 0.504 0.000
#> ERR519479     1  0.6154     0.2331 0.592 0.408 0.000
#> ERR519509     1  0.4346     0.1922 0.816 0.184 0.000
#> ERR519472     2  0.6260     0.3147 0.448 0.552 0.000
#> ERR519510     1  0.6180     0.2292 0.584 0.416 0.000
#> ERR519470     1  0.6308     0.1216 0.508 0.492 0.000
#> ERR519495     2  0.5138     0.5185 0.252 0.748 0.000
#> ERR519522     1  0.6295     0.1361 0.528 0.472 0.000
#> ERR519523     1  0.6225     0.2205 0.568 0.432 0.000
#> ERR519503     1  0.5378     0.1214 0.756 0.236 0.008
#> ERR519471     1  0.6307     0.1339 0.512 0.488 0.000
#> ERR519500     1  0.6168     0.1785 0.588 0.412 0.000
#> ERR519485     2  0.4842     0.5253 0.224 0.776 0.000
#> ERR519476     2  0.4953     0.5031 0.176 0.808 0.016
#> ERR519502     1  0.5988     0.2604 0.632 0.368 0.000
#> ERR519486     2  0.6224     0.4869 0.240 0.728 0.032
#> ERR519478     1  0.3482     0.2350 0.872 0.128 0.000
#> ERR519497     1  0.0592     0.2614 0.988 0.012 0.000
#> ERR519467     2  0.6252     0.0458 0.444 0.556 0.000
#> ERR519489     3  0.0000     0.9546 0.000 0.000 1.000
#> ERR519494     3  0.0000     0.9546 0.000 0.000 1.000
#> ERR519474     1  0.6260     0.1979 0.552 0.448 0.000
#> ERR519505     1  0.6299    -0.0397 0.524 0.476 0.000
#> ERR519517     3  0.0000     0.9546 0.000 0.000 1.000
#> ERR519484     1  0.6307    -0.0131 0.512 0.488 0.000
#> ERR519498     1  0.6111     0.2450 0.604 0.396 0.000
#> ERR519490     3  0.8357     0.7157 0.232 0.148 0.620
#> ERR519507     2  0.6309     0.1521 0.496 0.504 0.000
#> ERR519511     2  0.5926     0.4126 0.356 0.644 0.000
#> ERR519468     1  0.6209     0.2519 0.628 0.368 0.004
#> ERR519482     1  0.7775    -0.1813 0.620 0.076 0.304
#> ERR519475     2  0.4953     0.5031 0.176 0.808 0.016
#> ERR519496     1  0.4452     0.1361 0.808 0.192 0.000
#> ERR519506     2  0.6204     0.3217 0.424 0.576 0.000
#> ERR519469     1  0.5968     0.2606 0.636 0.364 0.000
#> ERR519480     3  0.1163     0.9464 0.000 0.028 0.972
#> ERR519487     3  0.0000     0.9546 0.000 0.000 1.000
#> ERR519483     2  0.6099     0.4968 0.228 0.740 0.032
#> ERR519477     2  0.4953     0.5031 0.176 0.808 0.016
#> ERR519499     3  0.0000     0.9546 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
#> ERR519515     1  0.4123      0.682 0.772 0.220 0.000 0.008
#> ERR519516     1  0.4244      0.685 0.800 0.168 0.000 0.032
#> ERR519520     1  0.3306      0.568 0.840 0.004 0.000 0.156
#> ERR519513     1  0.2408      0.680 0.920 0.044 0.000 0.036
#> ERR519481     1  0.3249      0.616 0.852 0.008 0.000 0.140
#> ERR519491     1  0.3768      0.689 0.808 0.184 0.000 0.008
#> ERR519473     1  0.5116      0.605 0.764 0.128 0.000 0.108
#> ERR519518     4  0.5398      0.559 0.404 0.000 0.016 0.580
#> ERR519512     1  0.2593      0.644 0.892 0.004 0.000 0.104
#> ERR519521     1  0.4220      0.448 0.748 0.004 0.000 0.248
#> ERR519488     1  0.5574      0.646 0.668 0.284 0.000 0.048
#> ERR519493     1  0.3718      0.688 0.820 0.168 0.000 0.012
#> ERR519514     1  0.3610      0.702 0.800 0.200 0.000 0.000
#> ERR519479     1  0.2271      0.707 0.916 0.076 0.000 0.008
#> ERR519509     1  0.6617      0.544 0.608 0.264 0.000 0.128
#> ERR519472     1  0.4070      0.651 0.824 0.132 0.000 0.044
#> ERR519510     1  0.2271      0.700 0.916 0.076 0.000 0.008
#> ERR519470     1  0.4391      0.672 0.740 0.252 0.000 0.008
#> ERR519495     1  0.4933      0.595 0.688 0.296 0.000 0.016
#> ERR519522     1  0.5627      0.649 0.692 0.240 0.000 0.068
#> ERR519523     1  0.3161      0.705 0.864 0.124 0.000 0.012
#> ERR519503     4  0.7186      0.415 0.420 0.136 0.000 0.444
#> ERR519471     1  0.4194      0.688 0.800 0.172 0.000 0.028
#> ERR519500     1  0.2408      0.681 0.920 0.036 0.000 0.044
#> ERR519485     1  0.4762      0.594 0.692 0.300 0.004 0.004
#> ERR519476     1  0.8062      0.355 0.472 0.244 0.016 0.268
#> ERR519502     1  0.1940      0.660 0.924 0.000 0.000 0.076
#> ERR519486     1  0.5360      0.577 0.668 0.304 0.024 0.004
#> ERR519478     1  0.7224      0.356 0.548 0.236 0.000 0.216
#> ERR519497     1  0.4543      0.130 0.676 0.000 0.000 0.324
#> ERR519467     1  0.4522      0.659 0.680 0.320 0.000 0.000
#> ERR519489     3  0.1151      0.948 0.000 0.008 0.968 0.024
#> ERR519494     3  0.0188      0.979 0.000 0.004 0.996 0.000
#> ERR519474     1  0.3311      0.696 0.828 0.172 0.000 0.000
#> ERR519505     1  0.4152      0.705 0.808 0.160 0.000 0.032
#> ERR519517     3  0.0672      0.975 0.000 0.008 0.984 0.008
#> ERR519484     1  0.3757      0.708 0.828 0.152 0.000 0.020
#> ERR519498     1  0.2319      0.680 0.924 0.036 0.000 0.040
#> ERR519490     4  0.6477     -0.489 0.000 0.072 0.420 0.508
#> ERR519507     1  0.3024      0.667 0.852 0.148 0.000 0.000
#> ERR519511     1  0.4304      0.599 0.716 0.284 0.000 0.000
#> ERR519468     1  0.3257      0.618 0.844 0.004 0.000 0.152
#> ERR519482     4  0.6407      0.534 0.332 0.000 0.084 0.584
#> ERR519475     1  0.8062      0.355 0.472 0.244 0.016 0.268
#> ERR519496     1  0.6751      0.117 0.592 0.136 0.000 0.272
#> ERR519506     1  0.4741      0.657 0.668 0.328 0.000 0.004
#> ERR519469     1  0.2888      0.630 0.872 0.004 0.000 0.124
#> ERR519480     2  0.7392      0.000 0.000 0.520 0.232 0.248
#> ERR519487     3  0.0188      0.977 0.000 0.004 0.996 0.000
#> ERR519483     1  0.6560      0.545 0.616 0.288 0.008 0.088
#> ERR519477     1  0.8062      0.355 0.472 0.244 0.016 0.268
#> ERR519499     3  0.0376      0.978 0.000 0.004 0.992 0.004

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> ERR519515     1   0.278      0.643 0.864 0.000 0.000 0.016 0.120
#> ERR519516     1   0.427      0.627 0.776 0.000 0.000 0.116 0.108
#> ERR519520     4   0.410      0.248 0.332 0.000 0.000 0.664 0.004
#> ERR519513     1   0.304      0.629 0.808 0.000 0.000 0.192 0.000
#> ERR519481     1   0.430      0.201 0.516 0.000 0.000 0.484 0.000
#> ERR519491     1   0.291      0.644 0.860 0.000 0.000 0.024 0.116
#> ERR519473     1   0.464      0.248 0.528 0.000 0.000 0.460 0.012
#> ERR519518     4   0.511     -0.151 0.020 0.012 0.000 0.556 0.412
#> ERR519512     1   0.432      0.431 0.600 0.000 0.000 0.396 0.004
#> ERR519521     4   0.212      0.111 0.096 0.000 0.000 0.900 0.004
#> ERR519488     1   0.527      0.421 0.680 0.000 0.000 0.172 0.148
#> ERR519493     1   0.306      0.651 0.856 0.000 0.000 0.036 0.108
#> ERR519514     1   0.304      0.656 0.860 0.000 0.000 0.040 0.100
#> ERR519479     1   0.150      0.682 0.940 0.000 0.000 0.056 0.004
#> ERR519509     4   0.630      0.201 0.424 0.000 0.000 0.424 0.152
#> ERR519472     1   0.373      0.573 0.748 0.000 0.000 0.244 0.008
#> ERR519510     1   0.229      0.663 0.888 0.000 0.000 0.108 0.004
#> ERR519470     1   0.336      0.640 0.832 0.000 0.000 0.036 0.132
#> ERR519495     1   0.415      0.634 0.780 0.000 0.000 0.144 0.076
#> ERR519522     1   0.472      0.574 0.736 0.000 0.000 0.124 0.140
#> ERR519523     1   0.285      0.654 0.840 0.000 0.000 0.156 0.004
#> ERR519503     5   0.677     -0.396 0.360 0.000 0.000 0.272 0.368
#> ERR519471     1   0.375      0.646 0.816 0.000 0.000 0.080 0.104
#> ERR519500     1   0.328      0.628 0.804 0.000 0.000 0.188 0.008
#> ERR519485     1   0.395      0.642 0.800 0.000 0.000 0.080 0.120
#> ERR519476     1   0.661      0.256 0.512 0.212 0.000 0.008 0.268
#> ERR519502     1   0.425      0.297 0.568 0.000 0.000 0.432 0.000
#> ERR519486     1   0.418      0.603 0.744 0.000 0.000 0.036 0.220
#> ERR519478     4   0.610      0.211 0.436 0.000 0.000 0.440 0.124
#> ERR519497     4   0.437      0.247 0.372 0.000 0.000 0.620 0.008
#> ERR519467     1   0.249      0.645 0.872 0.000 0.000 0.004 0.124
#> ERR519489     3   0.000      1.000 0.000 0.000 1.000 0.000 0.000
#> ERR519494     3   0.000      1.000 0.000 0.000 1.000 0.000 0.000
#> ERR519474     1   0.346      0.654 0.832 0.000 0.000 0.052 0.116
#> ERR519505     1   0.158      0.680 0.944 0.000 0.000 0.032 0.024
#> ERR519517     3   0.000      1.000 0.000 0.000 1.000 0.000 0.000
#> ERR519484     1   0.112      0.682 0.960 0.000 0.000 0.036 0.004
#> ERR519498     1   0.307      0.621 0.804 0.000 0.000 0.196 0.000
#> ERR519490     5   0.612     -0.427 0.000 0.128 0.412 0.000 0.460
#> ERR519507     1   0.313      0.653 0.848 0.000 0.000 0.120 0.032
#> ERR519511     1   0.384      0.645 0.808 0.000 0.000 0.116 0.076
#> ERR519468     4   0.444     -0.261 0.472 0.000 0.000 0.524 0.004
#> ERR519482     4   0.537     -0.160 0.020 0.024 0.000 0.544 0.412
#> ERR519475     1   0.661      0.256 0.512 0.212 0.000 0.008 0.268
#> ERR519496     4   0.500      0.227 0.364 0.000 0.000 0.596 0.040
#> ERR519506     1   0.181      0.677 0.928 0.000 0.000 0.012 0.060
#> ERR519469     4   0.456     -0.267 0.484 0.000 0.000 0.508 0.008
#> ERR519480     2   0.141      0.000 0.000 0.940 0.000 0.000 0.060
#> ERR519487     3   0.000      1.000 0.000 0.000 1.000 0.000 0.000
#> ERR519483     1   0.508      0.533 0.664 0.004 0.000 0.060 0.272
#> ERR519477     1   0.661      0.256 0.512 0.212 0.000 0.008 0.268
#> ERR519499     3   0.000      1.000 0.000 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> ERR519515     1  0.3409     0.4712 0.700 0.000 0.000 0.000 0.300 0.000
#> ERR519516     1  0.2948     0.5756 0.804 0.008 0.000 0.000 0.188 0.000
#> ERR519520     2  0.6146     0.0942 0.248 0.404 0.000 0.004 0.344 0.000
#> ERR519513     1  0.5058     0.4205 0.600 0.000 0.000 0.108 0.292 0.000
#> ERR519481     5  0.4087     0.4977 0.120 0.012 0.000 0.096 0.772 0.000
#> ERR519491     1  0.0146     0.5939 0.996 0.000 0.000 0.000 0.004 0.000
#> ERR519473     5  0.5305     0.4240 0.404 0.000 0.000 0.104 0.492 0.000
#> ERR519518     4  0.5400     0.5238 0.000 0.264 0.000 0.572 0.164 0.000
#> ERR519512     5  0.5156     0.3599 0.188 0.156 0.000 0.008 0.648 0.000
#> ERR519521     5  0.5228    -0.1062 0.000 0.400 0.000 0.096 0.504 0.000
#> ERR519488     1  0.5351     0.2788 0.592 0.200 0.000 0.000 0.208 0.000
#> ERR519493     1  0.0547     0.5973 0.980 0.000 0.000 0.000 0.020 0.000
#> ERR519514     1  0.1267     0.6000 0.940 0.000 0.000 0.000 0.060 0.000
#> ERR519479     1  0.3104     0.5619 0.788 0.004 0.000 0.004 0.204 0.000
#> ERR519509     1  0.4101     0.1146 0.580 0.408 0.000 0.000 0.012 0.000
#> ERR519472     1  0.3950    -0.1048 0.564 0.000 0.000 0.004 0.432 0.000
#> ERR519510     1  0.2921     0.5834 0.828 0.008 0.000 0.008 0.156 0.000
#> ERR519470     1  0.0458     0.5959 0.984 0.000 0.000 0.000 0.016 0.000
#> ERR519495     1  0.3984     0.2305 0.596 0.008 0.000 0.000 0.396 0.000
#> ERR519522     1  0.3566     0.5315 0.788 0.056 0.000 0.000 0.156 0.000
#> ERR519523     1  0.3986     0.4788 0.608 0.004 0.000 0.004 0.384 0.000
#> ERR519503     1  0.7315    -0.2078 0.380 0.284 0.000 0.120 0.216 0.000
#> ERR519471     1  0.0865     0.5990 0.964 0.000 0.000 0.000 0.036 0.000
#> ERR519500     5  0.3864    -0.0219 0.480 0.000 0.000 0.000 0.520 0.000
#> ERR519485     1  0.2579     0.5648 0.872 0.040 0.000 0.000 0.088 0.000
#> ERR519476     2  0.4994     0.2200 0.412 0.524 0.000 0.000 0.060 0.004
#> ERR519502     5  0.4760     0.5373 0.232 0.020 0.000 0.064 0.684 0.000
#> ERR519486     1  0.3695     0.5224 0.776 0.060 0.000 0.000 0.164 0.000
#> ERR519478     1  0.4379     0.0971 0.576 0.396 0.000 0.000 0.028 0.000
#> ERR519497     2  0.5944     0.0708 0.216 0.400 0.000 0.000 0.384 0.000
#> ERR519467     1  0.1327     0.5961 0.936 0.000 0.000 0.000 0.064 0.000
#> ERR519489     3  0.0000     0.9970 0.000 0.000 1.000 0.000 0.000 0.000
#> ERR519494     3  0.0000     0.9970 0.000 0.000 1.000 0.000 0.000 0.000
#> ERR519474     1  0.1806     0.5970 0.908 0.004 0.000 0.000 0.088 0.000
#> ERR519505     1  0.6501     0.2558 0.468 0.080 0.000 0.108 0.344 0.000
#> ERR519517     3  0.0000     0.9970 0.000 0.000 1.000 0.000 0.000 0.000
#> ERR519484     1  0.4601     0.5072 0.688 0.000 0.000 0.112 0.200 0.000
#> ERR519498     1  0.5391     0.2900 0.456 0.000 0.000 0.112 0.432 0.000
#> ERR519490     4  0.3890    -0.1879 0.000 0.000 0.400 0.596 0.000 0.004
#> ERR519507     1  0.2902     0.5793 0.800 0.004 0.000 0.000 0.196 0.000
#> ERR519511     1  0.3927     0.4956 0.644 0.012 0.000 0.000 0.344 0.000
#> ERR519468     5  0.4926     0.5309 0.240 0.000 0.000 0.120 0.640 0.000
#> ERR519482     4  0.5363     0.5287 0.000 0.240 0.000 0.600 0.156 0.004
#> ERR519475     2  0.4994     0.2200 0.412 0.524 0.000 0.000 0.060 0.004
#> ERR519496     2  0.5943     0.0338 0.380 0.404 0.000 0.000 0.216 0.000
#> ERR519506     1  0.4702     0.4797 0.716 0.120 0.000 0.016 0.148 0.000
#> ERR519469     5  0.5186     0.4675 0.356 0.000 0.000 0.100 0.544 0.000
#> ERR519480     6  0.0000     0.0000 0.000 0.000 0.000 0.000 0.000 1.000
#> ERR519487     3  0.0363     0.9878 0.000 0.000 0.988 0.012 0.000 0.000
#> ERR519483     1  0.6587    -0.0436 0.480 0.292 0.000 0.060 0.168 0.000
#> ERR519477     2  0.5077     0.2140 0.404 0.524 0.000 0.000 0.068 0.004
#> ERR519499     3  0.0000     0.9970 0.000 0.000 1.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-mclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-mclust-collect-classes

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


CV:NMF*

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

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

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

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 18140 rows and 52 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 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-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.910           0.905       0.961         0.3977 0.618   0.618
#> 3 3 0.466           0.645       0.829         0.5575 0.716   0.549
#> 4 4 0.628           0.625       0.832         0.1428 0.883   0.698
#> 5 5 0.577           0.542       0.712         0.0681 0.943   0.825
#> 6 6 0.630           0.551       0.751         0.0492 0.824   0.466

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
#> ERR519515     1   0.000      0.959 1.000 0.000
#> ERR519516     1   0.000      0.959 1.000 0.000
#> ERR519520     1   0.000      0.959 1.000 0.000
#> ERR519513     1   0.295      0.923 0.948 0.052
#> ERR519481     1   0.000      0.959 1.000 0.000
#> ERR519491     1   0.000      0.959 1.000 0.000
#> ERR519473     1   0.000      0.959 1.000 0.000
#> ERR519518     1   0.000      0.959 1.000 0.000
#> ERR519512     1   0.000      0.959 1.000 0.000
#> ERR519521     1   0.000      0.959 1.000 0.000
#> ERR519488     1   0.000      0.959 1.000 0.000
#> ERR519493     1   0.000      0.959 1.000 0.000
#> ERR519514     1   0.767      0.711 0.776 0.224
#> ERR519479     1   0.000      0.959 1.000 0.000
#> ERR519509     1   0.000      0.959 1.000 0.000
#> ERR519472     1   0.204      0.938 0.968 0.032
#> ERR519510     1   0.000      0.959 1.000 0.000
#> ERR519470     1   0.000      0.959 1.000 0.000
#> ERR519495     2   0.775      0.694 0.228 0.772
#> ERR519522     1   0.000      0.959 1.000 0.000
#> ERR519523     1   0.000      0.959 1.000 0.000
#> ERR519503     1   0.000      0.959 1.000 0.000
#> ERR519471     1   0.000      0.959 1.000 0.000
#> ERR519500     1   0.311      0.919 0.944 0.056
#> ERR519485     2   0.295      0.911 0.052 0.948
#> ERR519476     1   0.416      0.892 0.916 0.084
#> ERR519502     1   0.000      0.959 1.000 0.000
#> ERR519486     2   0.000      0.949 0.000 1.000
#> ERR519478     1   0.000      0.959 1.000 0.000
#> ERR519497     1   0.000      0.959 1.000 0.000
#> ERR519467     1   0.000      0.959 1.000 0.000
#> ERR519489     2   0.000      0.949 0.000 1.000
#> ERR519494     2   0.000      0.949 0.000 1.000
#> ERR519474     1   0.000      0.959 1.000 0.000
#> ERR519505     1   0.000      0.959 1.000 0.000
#> ERR519517     2   0.000      0.949 0.000 1.000
#> ERR519484     1   0.000      0.959 1.000 0.000
#> ERR519498     1   0.000      0.959 1.000 0.000
#> ERR519490     2   0.000      0.949 0.000 1.000
#> ERR519507     1   0.987      0.254 0.568 0.432
#> ERR519511     2   0.000      0.949 0.000 1.000
#> ERR519468     1   0.000      0.959 1.000 0.000
#> ERR519482     2   0.871      0.600 0.292 0.708
#> ERR519475     1   0.295      0.921 0.948 0.052
#> ERR519496     1   0.141      0.946 0.980 0.020
#> ERR519506     1   0.358      0.908 0.932 0.068
#> ERR519469     1   0.000      0.959 1.000 0.000
#> ERR519480     2   0.000      0.949 0.000 1.000
#> ERR519487     2   0.000      0.949 0.000 1.000
#> ERR519483     2   0.000      0.949 0.000 1.000
#> ERR519477     1   0.994      0.149 0.544 0.456
#> ERR519499     2   0.000      0.949 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
#> ERR519515     2  0.5016     0.6768 0.240 0.760 0.000
#> ERR519516     1  0.0237     0.7921 0.996 0.004 0.000
#> ERR519520     2  0.5733     0.6481 0.324 0.676 0.000
#> ERR519513     1  0.2297     0.7596 0.944 0.036 0.020
#> ERR519481     1  0.0424     0.7922 0.992 0.008 0.000
#> ERR519491     1  0.5785     0.2331 0.668 0.332 0.000
#> ERR519473     1  0.0237     0.7911 0.996 0.004 0.000
#> ERR519518     1  0.6140     0.1468 0.596 0.404 0.000
#> ERR519512     1  0.3038     0.7110 0.896 0.104 0.000
#> ERR519521     1  0.3816     0.6418 0.852 0.148 0.000
#> ERR519488     2  0.5810     0.6383 0.336 0.664 0.000
#> ERR519493     1  0.0237     0.7921 0.996 0.004 0.000
#> ERR519514     2  0.9872     0.4158 0.320 0.408 0.272
#> ERR519479     1  0.0237     0.7921 0.996 0.004 0.000
#> ERR519509     2  0.5560     0.6618 0.300 0.700 0.000
#> ERR519472     1  0.0424     0.7894 0.992 0.000 0.008
#> ERR519510     1  0.0424     0.7922 0.992 0.008 0.000
#> ERR519470     1  0.6267    -0.2140 0.548 0.452 0.000
#> ERR519495     3  0.5167     0.7024 0.192 0.016 0.792
#> ERR519522     2  0.6045     0.5870 0.380 0.620 0.000
#> ERR519523     2  0.6008     0.5969 0.372 0.628 0.000
#> ERR519503     2  0.2066     0.6280 0.060 0.940 0.000
#> ERR519471     1  0.6168    -0.0718 0.588 0.412 0.000
#> ERR519500     1  0.0892     0.7832 0.980 0.000 0.020
#> ERR519485     3  0.2959     0.8437 0.000 0.100 0.900
#> ERR519476     2  0.6057     0.5378 0.196 0.760 0.044
#> ERR519502     1  0.0424     0.7922 0.992 0.008 0.000
#> ERR519486     3  0.0000     0.9288 0.000 0.000 1.000
#> ERR519478     2  0.5016     0.6771 0.240 0.760 0.000
#> ERR519497     1  0.6280    -0.0979 0.540 0.460 0.000
#> ERR519467     2  0.6045     0.5870 0.380 0.620 0.000
#> ERR519489     3  0.0000     0.9288 0.000 0.000 1.000
#> ERR519494     3  0.0000     0.9288 0.000 0.000 1.000
#> ERR519474     1  0.5327     0.3987 0.728 0.272 0.000
#> ERR519505     1  0.2066     0.7638 0.940 0.060 0.000
#> ERR519517     3  0.0000     0.9288 0.000 0.000 1.000
#> ERR519484     1  0.0592     0.7919 0.988 0.012 0.000
#> ERR519498     1  0.0424     0.7922 0.992 0.008 0.000
#> ERR519490     3  0.0000     0.9288 0.000 0.000 1.000
#> ERR519507     1  0.5733     0.3663 0.676 0.000 0.324
#> ERR519511     3  0.0000     0.9288 0.000 0.000 1.000
#> ERR519468     1  0.0424     0.7909 0.992 0.008 0.000
#> ERR519482     2  0.8882     0.2023 0.316 0.540 0.144
#> ERR519475     2  0.5585     0.5758 0.204 0.772 0.024
#> ERR519496     2  0.2772     0.6387 0.080 0.916 0.004
#> ERR519506     1  0.4196     0.6811 0.864 0.112 0.024
#> ERR519469     1  0.0237     0.7911 0.996 0.004 0.000
#> ERR519480     3  0.5656     0.7187 0.004 0.284 0.712
#> ERR519487     3  0.0000     0.9288 0.000 0.000 1.000
#> ERR519483     3  0.4782     0.8222 0.016 0.164 0.820
#> ERR519477     2  0.9725     0.3514 0.272 0.452 0.276
#> ERR519499     3  0.0000     0.9288 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
#> ERR519515     1  0.2021     0.6745 0.932 0.056 0.000 0.012
#> ERR519516     4  0.0000     0.8327 0.000 0.000 0.000 1.000
#> ERR519520     1  0.0927     0.6913 0.976 0.008 0.000 0.016
#> ERR519513     4  0.2125     0.8193 0.004 0.076 0.000 0.920
#> ERR519481     4  0.1209     0.8325 0.004 0.032 0.000 0.964
#> ERR519491     4  0.4933     0.1640 0.432 0.000 0.000 0.568
#> ERR519473     4  0.0188     0.8321 0.000 0.004 0.000 0.996
#> ERR519518     4  0.7690     0.1105 0.264 0.280 0.000 0.456
#> ERR519512     4  0.4744     0.5964 0.284 0.012 0.000 0.704
#> ERR519521     4  0.4336     0.7265 0.128 0.060 0.000 0.812
#> ERR519488     1  0.1042     0.6909 0.972 0.008 0.000 0.020
#> ERR519493     4  0.0000     0.8327 0.000 0.000 0.000 1.000
#> ERR519514     1  0.6937     0.2428 0.564 0.012 0.332 0.092
#> ERR519479     4  0.0000     0.8327 0.000 0.000 0.000 1.000
#> ERR519509     1  0.0188     0.6864 0.996 0.000 0.000 0.004
#> ERR519472     4  0.0564     0.8309 0.004 0.004 0.004 0.988
#> ERR519510     4  0.1824     0.8255 0.004 0.060 0.000 0.936
#> ERR519470     1  0.4567     0.5138 0.740 0.016 0.000 0.244
#> ERR519495     3  0.4908     0.4018 0.000 0.016 0.692 0.292
#> ERR519522     1  0.1706     0.6887 0.948 0.016 0.000 0.036
#> ERR519523     1  0.2179     0.6831 0.924 0.012 0.000 0.064
#> ERR519503     1  0.3356     0.5749 0.824 0.176 0.000 0.000
#> ERR519471     1  0.5289     0.4013 0.636 0.020 0.000 0.344
#> ERR519500     4  0.2990     0.7951 0.036 0.008 0.056 0.900
#> ERR519485     3  0.2781     0.8324 0.012 0.036 0.912 0.040
#> ERR519476     2  0.5977     0.1216 0.388 0.572 0.004 0.036
#> ERR519502     4  0.1022     0.8328 0.000 0.032 0.000 0.968
#> ERR519486     3  0.0000     0.9269 0.000 0.000 1.000 0.000
#> ERR519478     1  0.1489     0.6752 0.952 0.044 0.000 0.004
#> ERR519497     1  0.7651     0.0430 0.464 0.248 0.000 0.288
#> ERR519467     1  0.1584     0.6898 0.952 0.012 0.000 0.036
#> ERR519489     3  0.0000     0.9269 0.000 0.000 1.000 0.000
#> ERR519494     3  0.0000     0.9269 0.000 0.000 1.000 0.000
#> ERR519474     4  0.5112     0.3135 0.384 0.008 0.000 0.608
#> ERR519505     4  0.4292     0.7705 0.080 0.100 0.000 0.820
#> ERR519517     3  0.0000     0.9269 0.000 0.000 1.000 0.000
#> ERR519484     4  0.1489     0.8302 0.004 0.044 0.000 0.952
#> ERR519498     4  0.2266     0.8159 0.004 0.084 0.000 0.912
#> ERR519490     3  0.0000     0.9269 0.000 0.000 1.000 0.000
#> ERR519507     4  0.4086     0.6323 0.000 0.008 0.216 0.776
#> ERR519511     3  0.0000     0.9269 0.000 0.000 1.000 0.000
#> ERR519468     4  0.1118     0.8332 0.000 0.036 0.000 0.964
#> ERR519482     2  0.5937     0.3845 0.216 0.708 0.032 0.044
#> ERR519475     1  0.6370     0.0884 0.556 0.392 0.024 0.028
#> ERR519496     1  0.3569     0.5583 0.804 0.196 0.000 0.000
#> ERR519506     4  0.6863     0.4967 0.220 0.120 0.020 0.640
#> ERR519469     4  0.0188     0.8321 0.000 0.004 0.000 0.996
#> ERR519480     2  0.4800     0.3074 0.004 0.656 0.340 0.000
#> ERR519487     3  0.0000     0.9269 0.000 0.000 1.000 0.000
#> ERR519483     2  0.6552    -0.0405 0.024 0.476 0.468 0.032
#> ERR519477     1  0.9921    -0.1916 0.292 0.260 0.192 0.256
#> ERR519499     3  0.0000     0.9269 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
#> ERR519515     1  0.2624     0.5755 0.872 0.116 0.000 0.012 0.000
#> ERR519516     4  0.1894     0.6811 0.008 0.072 0.000 0.920 0.000
#> ERR519520     1  0.1041     0.6192 0.964 0.032 0.000 0.004 0.000
#> ERR519513     4  0.4283     0.5878 0.000 0.348 0.000 0.644 0.008
#> ERR519481     4  0.3612     0.6415 0.000 0.228 0.000 0.764 0.008
#> ERR519491     4  0.4557     0.1649 0.404 0.000 0.000 0.584 0.012
#> ERR519473     4  0.0162     0.6700 0.000 0.000 0.000 0.996 0.004
#> ERR519518     2  0.5538     0.5729 0.148 0.680 0.000 0.160 0.012
#> ERR519512     4  0.6347     0.2417 0.408 0.160 0.000 0.432 0.000
#> ERR519521     4  0.5368     0.5261 0.068 0.308 0.000 0.620 0.004
#> ERR519488     1  0.0451     0.6270 0.988 0.000 0.000 0.008 0.004
#> ERR519493     4  0.2230     0.6780 0.000 0.116 0.000 0.884 0.000
#> ERR519514     1  0.6768     0.2178 0.492 0.000 0.308 0.184 0.016
#> ERR519479     4  0.0404     0.6735 0.000 0.012 0.000 0.988 0.000
#> ERR519509     1  0.0451     0.6249 0.988 0.008 0.000 0.004 0.000
#> ERR519472     4  0.0968     0.6650 0.004 0.000 0.012 0.972 0.012
#> ERR519510     4  0.4403     0.5916 0.008 0.340 0.000 0.648 0.004
#> ERR519470     1  0.4305     0.5117 0.748 0.000 0.000 0.200 0.052
#> ERR519495     4  0.4593    -0.1012 0.004 0.000 0.480 0.512 0.004
#> ERR519522     1  0.1485     0.6253 0.948 0.000 0.000 0.032 0.020
#> ERR519523     1  0.2915     0.5942 0.860 0.024 0.000 0.116 0.000
#> ERR519503     1  0.4547     0.0280 0.588 0.400 0.000 0.000 0.012
#> ERR519471     1  0.5084     0.3910 0.616 0.000 0.000 0.332 0.052
#> ERR519500     4  0.3696     0.6022 0.092 0.000 0.040 0.840 0.028
#> ERR519485     3  0.3270     0.7547 0.004 0.000 0.852 0.100 0.044
#> ERR519476     2  0.6806     0.4022 0.252 0.500 0.008 0.004 0.236
#> ERR519502     4  0.3992     0.6230 0.004 0.280 0.000 0.712 0.004
#> ERR519486     3  0.0000     0.9682 0.000 0.000 1.000 0.000 0.000
#> ERR519478     1  0.2179     0.5745 0.888 0.112 0.000 0.000 0.000
#> ERR519497     2  0.5150     0.6134 0.272 0.652 0.000 0.076 0.000
#> ERR519467     1  0.1267     0.6265 0.960 0.004 0.000 0.024 0.012
#> ERR519489     3  0.0000     0.9682 0.000 0.000 1.000 0.000 0.000
#> ERR519494     3  0.0162     0.9686 0.000 0.000 0.996 0.000 0.004
#> ERR519474     4  0.4134     0.4736 0.264 0.008 0.000 0.720 0.008
#> ERR519505     4  0.6342     0.3577 0.112 0.420 0.000 0.456 0.012
#> ERR519517     3  0.0000     0.9682 0.000 0.000 1.000 0.000 0.000
#> ERR519484     4  0.4183     0.6035 0.000 0.324 0.000 0.668 0.008
#> ERR519498     4  0.4341     0.5734 0.000 0.364 0.000 0.628 0.008
#> ERR519490     3  0.0162     0.9686 0.000 0.000 0.996 0.000 0.004
#> ERR519507     4  0.3209     0.5539 0.000 0.000 0.180 0.812 0.008
#> ERR519511     3  0.0290     0.9605 0.000 0.008 0.992 0.000 0.000
#> ERR519468     4  0.2389     0.6748 0.000 0.116 0.000 0.880 0.004
#> ERR519482     2  0.5532     0.5365 0.124 0.708 0.000 0.036 0.132
#> ERR519475     1  0.7111    -0.3886 0.420 0.416 0.020 0.020 0.124
#> ERR519496     1  0.5221    -0.0576 0.552 0.400 0.000 0.000 0.048
#> ERR519506     4  0.7253     0.0764 0.176 0.028 0.012 0.492 0.292
#> ERR519469     4  0.0162     0.6700 0.000 0.000 0.000 0.996 0.004
#> ERR519480     5  0.6389     0.5280 0.008 0.232 0.204 0.000 0.556
#> ERR519487     3  0.0162     0.9686 0.000 0.000 0.996 0.000 0.004
#> ERR519483     5  0.5210     0.5142 0.016 0.064 0.144 0.028 0.748
#> ERR519477     1  0.9989    -0.2976 0.216 0.184 0.192 0.196 0.212
#> ERR519499     3  0.0162     0.9686 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
#> ERR519515     1  0.2730     0.5868 0.808 0.192 0.000 0.000 0.000 0.000
#> ERR519516     5  0.3121     0.2712 0.008 0.004 0.000 0.192 0.796 0.000
#> ERR519520     1  0.0820     0.7301 0.972 0.012 0.000 0.016 0.000 0.000
#> ERR519513     4  0.3584     0.8612 0.000 0.004 0.000 0.688 0.308 0.000
#> ERR519481     5  0.3975    -0.5879 0.000 0.004 0.000 0.452 0.544 0.000
#> ERR519491     5  0.3890     0.2816 0.400 0.000 0.000 0.004 0.596 0.000
#> ERR519473     5  0.0405     0.5777 0.000 0.000 0.000 0.004 0.988 0.008
#> ERR519518     2  0.5505     0.4852 0.068 0.648 0.000 0.208 0.076 0.000
#> ERR519512     1  0.5519     0.0767 0.520 0.000 0.000 0.332 0.148 0.000
#> ERR519521     4  0.5240     0.6147 0.016 0.056 0.000 0.488 0.440 0.000
#> ERR519488     1  0.0000     0.7327 1.000 0.000 0.000 0.000 0.000 0.000
#> ERR519493     5  0.3448     0.1193 0.000 0.004 0.000 0.280 0.716 0.000
#> ERR519514     5  0.6205     0.0433 0.356 0.000 0.272 0.004 0.368 0.000
#> ERR519479     5  0.1080     0.5601 0.004 0.004 0.000 0.032 0.960 0.000
#> ERR519509     1  0.0547     0.7297 0.980 0.020 0.000 0.000 0.000 0.000
#> ERR519472     5  0.1003     0.5876 0.004 0.000 0.028 0.000 0.964 0.004
#> ERR519510     4  0.3371     0.8610 0.000 0.000 0.000 0.708 0.292 0.000
#> ERR519470     1  0.2994     0.6036 0.788 0.000 0.000 0.004 0.208 0.000
#> ERR519495     5  0.3606     0.4673 0.000 0.004 0.264 0.000 0.724 0.008
#> ERR519522     1  0.0806     0.7320 0.972 0.000 0.000 0.008 0.020 0.000
#> ERR519523     1  0.3017     0.6825 0.840 0.052 0.000 0.000 0.108 0.000
#> ERR519503     2  0.3717     0.4258 0.384 0.616 0.000 0.000 0.000 0.000
#> ERR519471     5  0.4635     0.0334 0.476 0.000 0.000 0.024 0.492 0.008
#> ERR519500     5  0.4009     0.5803 0.128 0.004 0.040 0.036 0.792 0.000
#> ERR519485     3  0.2201     0.8763 0.004 0.016 0.912 0.004 0.056 0.008
#> ERR519476     2  0.5889     0.4156 0.180 0.640 0.008 0.120 0.004 0.048
#> ERR519502     4  0.3930     0.7692 0.000 0.004 0.000 0.576 0.420 0.000
#> ERR519486     3  0.0000     0.9846 0.000 0.000 1.000 0.000 0.000 0.000
#> ERR519478     1  0.2300     0.6428 0.856 0.144 0.000 0.000 0.000 0.000
#> ERR519497     2  0.5344     0.4427 0.120 0.532 0.000 0.348 0.000 0.000
#> ERR519467     1  0.1307     0.7273 0.952 0.008 0.000 0.032 0.008 0.000
#> ERR519489     3  0.0000     0.9846 0.000 0.000 1.000 0.000 0.000 0.000
#> ERR519494     3  0.0000     0.9846 0.000 0.000 1.000 0.000 0.000 0.000
#> ERR519474     5  0.4107     0.5120 0.280 0.004 0.000 0.028 0.688 0.000
#> ERR519505     4  0.4715     0.7466 0.080 0.024 0.000 0.712 0.184 0.000
#> ERR519517     3  0.0000     0.9846 0.000 0.000 1.000 0.000 0.000 0.000
#> ERR519484     4  0.3592     0.8457 0.000 0.000 0.000 0.656 0.344 0.000
#> ERR519498     4  0.3595     0.8559 0.000 0.008 0.000 0.704 0.288 0.000
#> ERR519490     3  0.0000     0.9846 0.000 0.000 1.000 0.000 0.000 0.000
#> ERR519507     5  0.2737     0.5434 0.000 0.000 0.160 0.004 0.832 0.004
#> ERR519511     3  0.0146     0.9800 0.000 0.000 0.996 0.004 0.000 0.000
#> ERR519468     5  0.1268     0.5609 0.000 0.004 0.000 0.036 0.952 0.008
#> ERR519482     2  0.4970     0.4968 0.068 0.744 0.000 0.080 0.016 0.092
#> ERR519475     2  0.5954     0.5187 0.264 0.612 0.020 0.060 0.020 0.024
#> ERR519496     2  0.3464     0.5187 0.312 0.688 0.000 0.000 0.000 0.000
#> ERR519506     5  0.6995     0.3397 0.132 0.108 0.000 0.200 0.536 0.024
#> ERR519469     5  0.0665     0.5786 0.000 0.008 0.000 0.004 0.980 0.008
#> ERR519480     6  0.2488     0.0000 0.000 0.044 0.076 0.000 0.000 0.880
#> ERR519487     3  0.0000     0.9846 0.000 0.000 1.000 0.000 0.000 0.000
#> ERR519483     2  0.7680    -0.4319 0.012 0.308 0.092 0.284 0.004 0.300
#> ERR519477     1  0.9858    -0.2581 0.244 0.168 0.152 0.128 0.132 0.176
#> ERR519499     3  0.0000     0.9846 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 18140 rows and 52 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 1.000           1.000       1.000          0.112 0.889   0.889
#> 3 3 0.429           0.609       0.768          3.273 0.729   0.695
#> 4 4 0.420           0.652       0.749          0.349 0.686   0.498
#> 5 5 0.611           0.626       0.782          0.180 0.843   0.548
#> 6 6 0.660           0.682       0.762          0.029 0.975   0.887

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
#> ERR519515     1       0          1  1  0
#> ERR519516     1       0          1  1  0
#> ERR519520     1       0          1  1  0
#> ERR519513     1       0          1  1  0
#> ERR519481     1       0          1  1  0
#> ERR519491     1       0          1  1  0
#> ERR519473     1       0          1  1  0
#> ERR519518     1       0          1  1  0
#> ERR519512     1       0          1  1  0
#> ERR519521     1       0          1  1  0
#> ERR519488     1       0          1  1  0
#> ERR519493     1       0          1  1  0
#> ERR519514     1       0          1  1  0
#> ERR519479     1       0          1  1  0
#> ERR519509     1       0          1  1  0
#> ERR519472     1       0          1  1  0
#> ERR519510     1       0          1  1  0
#> ERR519470     1       0          1  1  0
#> ERR519495     1       0          1  1  0
#> ERR519522     1       0          1  1  0
#> ERR519523     1       0          1  1  0
#> ERR519503     1       0          1  1  0
#> ERR519471     1       0          1  1  0
#> ERR519500     1       0          1  1  0
#> ERR519485     1       0          1  1  0
#> ERR519476     2       0          1  0  1
#> ERR519502     1       0          1  1  0
#> ERR519486     1       0          1  1  0
#> ERR519478     1       0          1  1  0
#> ERR519497     1       0          1  1  0
#> ERR519467     1       0          1  1  0
#> ERR519489     1       0          1  1  0
#> ERR519494     1       0          1  1  0
#> ERR519474     1       0          1  1  0
#> ERR519505     1       0          1  1  0
#> ERR519517     1       0          1  1  0
#> ERR519484     1       0          1  1  0
#> ERR519498     1       0          1  1  0
#> ERR519490     1       0          1  1  0
#> ERR519507     1       0          1  1  0
#> ERR519511     1       0          1  1  0
#> ERR519468     1       0          1  1  0
#> ERR519482     1       0          1  1  0
#> ERR519475     2       0          1  0  1
#> ERR519496     1       0          1  1  0
#> ERR519506     1       0          1  1  0
#> ERR519469     1       0          1  1  0
#> ERR519480     1       0          1  1  0
#> ERR519487     1       0          1  1  0
#> ERR519483     1       0          1  1  0
#> ERR519477     2       0          1  0  1
#> ERR519499     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
#> ERR519515     1  0.5678      0.637 0.684  0 0.316
#> ERR519516     1  0.5098      0.651 0.752  0 0.248
#> ERR519520     1  0.5650      0.643 0.688  0 0.312
#> ERR519513     1  0.4974      0.360 0.764  0 0.236
#> ERR519481     1  0.5650      0.180 0.688  0 0.312
#> ERR519491     1  0.5098      0.651 0.752  0 0.248
#> ERR519473     1  0.5650      0.180 0.688  0 0.312
#> ERR519518     1  0.6225     -0.333 0.568  0 0.432
#> ERR519512     1  0.5650      0.643 0.688  0 0.312
#> ERR519521     1  0.5650      0.180 0.688  0 0.312
#> ERR519488     1  0.5678      0.637 0.684  0 0.316
#> ERR519493     1  0.5098      0.651 0.752  0 0.248
#> ERR519514     1  0.5678      0.637 0.684  0 0.316
#> ERR519479     1  0.2261      0.585 0.932  0 0.068
#> ERR519509     1  0.5678      0.637 0.684  0 0.316
#> ERR519472     1  0.5650      0.180 0.688  0 0.312
#> ERR519510     1  0.2448      0.637 0.924  0 0.076
#> ERR519470     1  0.5678      0.637 0.684  0 0.316
#> ERR519495     1  0.1289      0.616 0.968  0 0.032
#> ERR519522     1  0.5678      0.637 0.684  0 0.316
#> ERR519523     1  0.5650      0.643 0.688  0 0.312
#> ERR519503     1  0.5678      0.637 0.684  0 0.316
#> ERR519471     1  0.5678      0.637 0.684  0 0.316
#> ERR519500     1  0.5560      0.260 0.700  0 0.300
#> ERR519485     1  0.0592      0.627 0.988  0 0.012
#> ERR519476     2  0.0000      1.000 0.000  1 0.000
#> ERR519502     1  0.5650      0.180 0.688  0 0.312
#> ERR519486     1  0.0592      0.627 0.988  0 0.012
#> ERR519478     1  0.5678      0.637 0.684  0 0.316
#> ERR519497     1  0.5678      0.125 0.684  0 0.316
#> ERR519467     1  0.5591      0.641 0.696  0 0.304
#> ERR519489     1  0.5465      0.290 0.712  0 0.288
#> ERR519494     3  0.5678      0.995 0.316  0 0.684
#> ERR519474     1  0.1411      0.610 0.964  0 0.036
#> ERR519505     1  0.4931      0.367 0.768  0 0.232
#> ERR519517     3  0.5678      0.995 0.316  0 0.684
#> ERR519484     1  0.2537      0.575 0.920  0 0.080
#> ERR519498     1  0.4931      0.367 0.768  0 0.232
#> ERR519490     3  0.5678      0.995 0.316  0 0.684
#> ERR519507     1  0.2261      0.585 0.932  0 0.068
#> ERR519511     1  0.2448      0.637 0.924  0 0.076
#> ERR519468     3  0.5760      0.981 0.328  0 0.672
#> ERR519482     3  0.5678      0.995 0.316  0 0.684
#> ERR519475     2  0.0000      1.000 0.000  1 0.000
#> ERR519496     1  0.1289      0.616 0.968  0 0.032
#> ERR519506     1  0.3686      0.509 0.860  0 0.140
#> ERR519469     3  0.5760      0.981 0.328  0 0.672
#> ERR519480     3  0.5678      0.995 0.316  0 0.684
#> ERR519487     3  0.5678      0.995 0.316  0 0.684
#> ERR519483     1  0.3116      0.550 0.892  0 0.108
#> ERR519477     2  0.0000      1.000 0.000  1 0.000
#> ERR519499     3  0.5678      0.995 0.316  0 0.684

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1 p2    p3    p4
#> ERR519515     1  0.0000      0.882 1.000  0 0.000 0.000
#> ERR519516     1  0.4194      0.652 0.764  0 0.008 0.228
#> ERR519520     1  0.3900      0.756 0.816  0 0.020 0.164
#> ERR519513     4  0.4237      0.574 0.152  0 0.040 0.808
#> ERR519481     4  0.5523      0.376 0.024  0 0.380 0.596
#> ERR519491     1  0.4194      0.652 0.764  0 0.008 0.228
#> ERR519473     4  0.5482      0.391 0.024  0 0.368 0.608
#> ERR519518     3  0.4989     -0.132 0.000  0 0.528 0.472
#> ERR519512     1  0.3900      0.756 0.816  0 0.020 0.164
#> ERR519521     4  0.5523      0.376 0.024  0 0.380 0.596
#> ERR519488     1  0.0000      0.882 1.000  0 0.000 0.000
#> ERR519493     1  0.4194      0.652 0.764  0 0.008 0.228
#> ERR519514     1  0.0000      0.882 1.000  0 0.000 0.000
#> ERR519479     4  0.6649      0.618 0.340  0 0.100 0.560
#> ERR519509     1  0.0000      0.882 1.000  0 0.000 0.000
#> ERR519472     4  0.5482      0.391 0.024  0 0.368 0.608
#> ERR519510     4  0.5236      0.493 0.432  0 0.008 0.560
#> ERR519470     1  0.0000      0.882 1.000  0 0.000 0.000
#> ERR519495     4  0.6179      0.568 0.392  0 0.056 0.552
#> ERR519522     1  0.0000      0.882 1.000  0 0.000 0.000
#> ERR519523     1  0.3900      0.756 0.816  0 0.020 0.164
#> ERR519503     1  0.0000      0.882 1.000  0 0.000 0.000
#> ERR519471     1  0.0000      0.882 1.000  0 0.000 0.000
#> ERR519500     4  0.6121      0.416 0.060  0 0.352 0.588
#> ERR519485     4  0.4933      0.491 0.432  0 0.000 0.568
#> ERR519476     2  0.0000      1.000 0.000  1 0.000 0.000
#> ERR519502     4  0.5523      0.376 0.024  0 0.380 0.596
#> ERR519486     4  0.4933      0.491 0.432  0 0.000 0.568
#> ERR519478     1  0.0000      0.882 1.000  0 0.000 0.000
#> ERR519497     4  0.6499      0.423 0.112  0 0.276 0.612
#> ERR519467     1  0.0524      0.877 0.988  0 0.004 0.008
#> ERR519489     4  0.6265      0.436 0.072  0 0.340 0.588
#> ERR519494     3  0.3123      0.680 0.000  0 0.844 0.156
#> ERR519474     4  0.5404      0.617 0.328  0 0.028 0.644
#> ERR519505     4  0.3695      0.593 0.156  0 0.016 0.828
#> ERR519517     3  0.0469      0.783 0.000  0 0.988 0.012
#> ERR519484     4  0.5636      0.598 0.308  0 0.044 0.648
#> ERR519498     4  0.3910      0.595 0.156  0 0.024 0.820
#> ERR519490     3  0.0336      0.777 0.000  0 0.992 0.008
#> ERR519507     4  0.6649      0.618 0.340  0 0.100 0.560
#> ERR519511     4  0.5236      0.493 0.432  0 0.008 0.560
#> ERR519468     3  0.3610      0.661 0.000  0 0.800 0.200
#> ERR519482     3  0.0336      0.777 0.000  0 0.992 0.008
#> ERR519475     2  0.0000      1.000 0.000  1 0.000 0.000
#> ERR519496     4  0.6179      0.568 0.392  0 0.056 0.552
#> ERR519506     4  0.5716      0.621 0.272  0 0.060 0.668
#> ERR519469     3  0.3610      0.661 0.000  0 0.800 0.200
#> ERR519480     3  0.4804      0.369 0.000  0 0.616 0.384
#> ERR519487     3  0.0469      0.783 0.000  0 0.988 0.012
#> ERR519483     4  0.5411      0.593 0.312  0 0.032 0.656
#> ERR519477     2  0.0000      1.000 0.000  1 0.000 0.000
#> ERR519499     3  0.0469      0.783 0.000  0 0.988 0.012

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1 p2    p3    p4    p5
#> ERR519515     1  0.0000     0.9310 1.000  0 0.000 0.000 0.000
#> ERR519516     5  0.4968     0.3213 0.456  0 0.000 0.028 0.516
#> ERR519520     1  0.3979     0.7522 0.780  0 0.016 0.188 0.016
#> ERR519513     4  0.5178    -0.2077 0.000  0 0.040 0.480 0.480
#> ERR519481     4  0.4341     0.5671 0.000  0 0.364 0.628 0.008
#> ERR519491     5  0.4968     0.3213 0.456  0 0.000 0.028 0.516
#> ERR519473     4  0.5687     0.5375 0.000  0 0.316 0.580 0.104
#> ERR519518     3  0.5148    -0.3289 0.000  0 0.528 0.432 0.040
#> ERR519512     1  0.3979     0.7522 0.780  0 0.016 0.188 0.016
#> ERR519521     4  0.4341     0.5671 0.000  0 0.364 0.628 0.008
#> ERR519488     1  0.0000     0.9310 1.000  0 0.000 0.000 0.000
#> ERR519493     5  0.4968     0.3213 0.456  0 0.000 0.028 0.516
#> ERR519514     1  0.0000     0.9310 1.000  0 0.000 0.000 0.000
#> ERR519479     5  0.4138     0.6601 0.028  0 0.056 0.104 0.812
#> ERR519509     1  0.0000     0.9310 1.000  0 0.000 0.000 0.000
#> ERR519472     4  0.5687     0.5375 0.000  0 0.316 0.580 0.104
#> ERR519510     5  0.4269     0.6948 0.116  0 0.000 0.108 0.776
#> ERR519470     1  0.0000     0.9310 1.000  0 0.000 0.000 0.000
#> ERR519495     5  0.4711     0.6894 0.080  0 0.044 0.096 0.780
#> ERR519522     1  0.0000     0.9310 1.000  0 0.000 0.000 0.000
#> ERR519523     1  0.3979     0.7522 0.780  0 0.016 0.188 0.016
#> ERR519503     1  0.0000     0.9310 1.000  0 0.000 0.000 0.000
#> ERR519471     1  0.0000     0.9310 1.000  0 0.000 0.000 0.000
#> ERR519500     4  0.5240     0.5713 0.028  0 0.336 0.616 0.020
#> ERR519485     5  0.2074     0.7051 0.104  0 0.000 0.000 0.896
#> ERR519476     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000
#> ERR519502     4  0.4341     0.5671 0.000  0 0.364 0.628 0.008
#> ERR519486     5  0.2074     0.7051 0.104  0 0.000 0.000 0.896
#> ERR519478     1  0.0000     0.9310 1.000  0 0.000 0.000 0.000
#> ERR519497     4  0.6155     0.3141 0.000  0 0.276 0.548 0.176
#> ERR519467     1  0.0807     0.9160 0.976  0 0.000 0.012 0.012
#> ERR519489     4  0.5430     0.5742 0.028  0 0.324 0.616 0.032
#> ERR519494     3  0.3106     0.6392 0.000  0 0.844 0.132 0.024
#> ERR519474     5  0.5453     0.2312 0.044  0 0.008 0.420 0.528
#> ERR519505     4  0.4562    -0.2030 0.000  0 0.008 0.500 0.492
#> ERR519517     3  0.0404     0.7507 0.000  0 0.988 0.012 0.000
#> ERR519484     5  0.4264     0.5945 0.000  0 0.044 0.212 0.744
#> ERR519498     5  0.4748     0.0492 0.000  0 0.016 0.492 0.492
#> ERR519490     3  0.0290     0.7491 0.000  0 0.992 0.008 0.000
#> ERR519507     5  0.4138     0.6601 0.028  0 0.056 0.104 0.812
#> ERR519511     5  0.4269     0.6948 0.116  0 0.000 0.108 0.776
#> ERR519468     3  0.4521     0.5600 0.000  0 0.748 0.164 0.088
#> ERR519482     3  0.0290     0.7491 0.000  0 0.992 0.008 0.000
#> ERR519475     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000
#> ERR519496     5  0.4711     0.6894 0.080  0 0.044 0.096 0.780
#> ERR519506     5  0.2069     0.6351 0.000  0 0.012 0.076 0.912
#> ERR519469     3  0.4521     0.5600 0.000  0 0.748 0.164 0.088
#> ERR519480     3  0.4551     0.3810 0.000  0 0.616 0.368 0.016
#> ERR519487     3  0.0404     0.7507 0.000  0 0.988 0.012 0.000
#> ERR519483     5  0.2977     0.6583 0.040  0 0.008 0.076 0.876
#> ERR519477     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000
#> ERR519499     3  0.0404     0.7507 0.000  0 0.988 0.012 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
#> ERR519515     1  0.0363      0.925 0.988  0 0.000 0.000 0.012 0.000
#> ERR519516     5  0.4517      0.370 0.444  0 0.000 0.032 0.524 0.000
#> ERR519520     1  0.3877      0.755 0.768  0 0.016 0.188 0.024 0.004
#> ERR519513     6  0.4450      0.840 0.000  0 0.032 0.108 0.104 0.756
#> ERR519481     4  0.3647      0.822 0.000  0 0.360 0.640 0.000 0.000
#> ERR519491     5  0.4517      0.370 0.444  0 0.000 0.032 0.524 0.000
#> ERR519473     4  0.5012      0.766 0.000  0 0.300 0.600 0.100 0.000
#> ERR519518     3  0.4819     -0.504 0.000  0 0.528 0.416 0.000 0.056
#> ERR519512     1  0.3877      0.755 0.768  0 0.016 0.188 0.024 0.004
#> ERR519521     4  0.3647      0.822 0.000  0 0.360 0.640 0.000 0.000
#> ERR519488     1  0.0000      0.924 1.000  0 0.000 0.000 0.000 0.000
#> ERR519493     5  0.4517      0.370 0.444  0 0.000 0.032 0.524 0.000
#> ERR519514     1  0.0363      0.925 0.988  0 0.000 0.000 0.012 0.000
#> ERR519479     5  0.3641      0.620 0.028  0 0.040 0.120 0.812 0.000
#> ERR519509     1  0.0000      0.924 1.000  0 0.000 0.000 0.000 0.000
#> ERR519472     4  0.5012      0.766 0.000  0 0.300 0.600 0.100 0.000
#> ERR519510     5  0.6332      0.461 0.104  0 0.000 0.100 0.556 0.240
#> ERR519470     1  0.0363      0.925 0.988  0 0.000 0.000 0.012 0.000
#> ERR519495     5  0.3987      0.644 0.068  0 0.036 0.100 0.796 0.000
#> ERR519522     1  0.0000      0.924 1.000  0 0.000 0.000 0.000 0.000
#> ERR519523     1  0.3877      0.755 0.768  0 0.016 0.188 0.024 0.004
#> ERR519503     1  0.0000      0.924 1.000  0 0.000 0.000 0.000 0.000
#> ERR519471     1  0.0363      0.925 0.988  0 0.000 0.000 0.012 0.000
#> ERR519500     4  0.4547      0.814 0.020  0 0.332 0.628 0.020 0.000
#> ERR519485     5  0.1714      0.631 0.092  0 0.000 0.000 0.908 0.000
#> ERR519476     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> ERR519502     4  0.3647      0.822 0.000  0 0.360 0.640 0.000 0.000
#> ERR519486     5  0.1714      0.631 0.092  0 0.000 0.000 0.908 0.000
#> ERR519478     1  0.0000      0.924 1.000  0 0.000 0.000 0.000 0.000
#> ERR519497     4  0.7250      0.277 0.000  0 0.276 0.384 0.104 0.236
#> ERR519467     1  0.0993      0.912 0.964  0 0.000 0.012 0.024 0.000
#> ERR519489     4  0.4717      0.809 0.020  0 0.320 0.628 0.032 0.000
#> ERR519494     3  0.3078      0.639 0.000  0 0.836 0.108 0.000 0.056
#> ERR519474     5  0.4499      0.292 0.032  0 0.000 0.428 0.540 0.000
#> ERR519505     6  0.2118      0.887 0.000  0 0.008 0.000 0.104 0.888
#> ERR519517     3  0.0363      0.735 0.000  0 0.988 0.000 0.000 0.012
#> ERR519484     5  0.6333      0.155 0.000  0 0.036 0.176 0.492 0.296
#> ERR519498     6  0.3286      0.875 0.000  0 0.016 0.044 0.104 0.836
#> ERR519490     3  0.0260      0.733 0.000  0 0.992 0.008 0.000 0.000
#> ERR519507     5  0.3641      0.620 0.028  0 0.040 0.120 0.812 0.000
#> ERR519511     5  0.6332      0.461 0.104  0 0.000 0.100 0.556 0.240
#> ERR519468     3  0.4250      0.492 0.000  0 0.736 0.176 0.084 0.004
#> ERR519482     3  0.0260      0.733 0.000  0 0.992 0.008 0.000 0.000
#> ERR519475     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> ERR519496     5  0.3987      0.644 0.068  0 0.036 0.100 0.796 0.000
#> ERR519506     5  0.2311      0.523 0.000  0 0.000 0.016 0.880 0.104
#> ERR519469     3  0.4250      0.492 0.000  0 0.736 0.176 0.084 0.004
#> ERR519480     3  0.4551      0.343 0.000  0 0.608 0.344 0.000 0.048
#> ERR519487     3  0.0363      0.735 0.000  0 0.988 0.000 0.000 0.012
#> ERR519483     5  0.2701      0.549 0.028  0 0.000 0.004 0.864 0.104
#> ERR519477     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> ERR519499     3  0.0363      0.735 0.000  0 0.988 0.000 0.000 0.012

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

consensus_heatmap(res, k = 2)

plot of chunk tab-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 18140 rows and 52 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.483           0.817       0.836         0.3745 0.502   0.502
#> 3 3 0.615           0.803       0.909         0.3684 0.642   0.457
#> 4 4 0.747           0.753       0.893         0.3384 0.677   0.410
#> 5 5 0.619           0.649       0.793         0.1117 0.863   0.597
#> 6 6 0.721           0.626       0.785         0.0587 0.915   0.661

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
#> ERR519515     2   0.000     0.8133 0.000 1.000
#> ERR519516     2   0.552     0.6894 0.128 0.872
#> ERR519520     1   0.929     0.9352 0.656 0.344
#> ERR519513     1   0.844     0.9278 0.728 0.272
#> ERR519481     1   0.900     0.9444 0.684 0.316
#> ERR519491     2   0.141     0.8117 0.020 0.980
#> ERR519473     1   0.895     0.9442 0.688 0.312
#> ERR519518     1   0.895     0.9442 0.688 0.312
#> ERR519512     1   0.929     0.9352 0.656 0.344
#> ERR519521     1   0.929     0.9352 0.656 0.344
#> ERR519488     2   0.000     0.8133 0.000 1.000
#> ERR519493     2   0.141     0.8117 0.020 0.980
#> ERR519514     2   0.141     0.8117 0.020 0.980
#> ERR519479     1   0.952     0.9074 0.628 0.372
#> ERR519509     2   0.000     0.8133 0.000 1.000
#> ERR519472     1   0.929     0.9352 0.656 0.344
#> ERR519510     1   0.929     0.9309 0.656 0.344
#> ERR519470     2   0.000     0.8133 0.000 1.000
#> ERR519495     1   0.999     0.6975 0.520 0.480
#> ERR519522     2   0.000     0.8133 0.000 1.000
#> ERR519523     1   0.929     0.9352 0.656 0.344
#> ERR519503     2   0.118     0.8049 0.016 0.984
#> ERR519471     2   0.163     0.8094 0.024 0.976
#> ERR519500     1   0.929     0.9352 0.656 0.344
#> ERR519485     2   0.141     0.8117 0.020 0.980
#> ERR519476     2   0.925     0.5737 0.340 0.660
#> ERR519502     1   0.900     0.9444 0.684 0.316
#> ERR519486     2   0.584     0.6748 0.140 0.860
#> ERR519478     2   0.000     0.8133 0.000 1.000
#> ERR519497     1   0.900     0.9444 0.684 0.316
#> ERR519467     2   0.343     0.7754 0.064 0.936
#> ERR519489     1   0.929     0.9352 0.656 0.344
#> ERR519494     1   0.844     0.9278 0.728 0.272
#> ERR519474     2   0.909     0.1379 0.324 0.676
#> ERR519505     1   0.904     0.9283 0.680 0.320
#> ERR519517     1   0.844     0.9278 0.728 0.272
#> ERR519484     1   0.921     0.9326 0.664 0.336
#> ERR519498     1   0.895     0.9443 0.688 0.312
#> ERR519490     1   0.844     0.9278 0.728 0.272
#> ERR519507     1   0.929     0.9309 0.656 0.344
#> ERR519511     1   0.929     0.9309 0.656 0.344
#> ERR519468     1   0.844     0.9278 0.728 0.272
#> ERR519482     1   0.844     0.9278 0.728 0.272
#> ERR519475     2   0.925     0.5737 0.340 0.660
#> ERR519496     2   0.584     0.6748 0.140 0.860
#> ERR519506     2   0.946     0.0881 0.364 0.636
#> ERR519469     1   0.925     0.9357 0.660 0.340
#> ERR519480     1   0.844     0.9278 0.728 0.272
#> ERR519487     1   0.844     0.9278 0.728 0.272
#> ERR519483     2   0.900     0.2427 0.316 0.684
#> ERR519477     2   0.925     0.5737 0.340 0.660
#> ERR519499     1   0.844     0.9278 0.728 0.272

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> ERR519515     1  0.0000      0.908 1.000 0.000 0.000
#> ERR519516     1  0.0237      0.907 0.996 0.004 0.000
#> ERR519520     1  0.0983      0.900 0.980 0.004 0.016
#> ERR519513     3  0.0829      0.798 0.012 0.004 0.984
#> ERR519481     3  0.5497      0.663 0.292 0.000 0.708
#> ERR519491     1  0.0000      0.908 1.000 0.000 0.000
#> ERR519473     3  0.0592      0.798 0.012 0.000 0.988
#> ERR519518     3  0.0829      0.798 0.012 0.004 0.984
#> ERR519512     1  0.1989      0.878 0.948 0.004 0.048
#> ERR519521     3  0.5722      0.664 0.292 0.004 0.704
#> ERR519488     1  0.0000      0.908 1.000 0.000 0.000
#> ERR519493     1  0.0000      0.908 1.000 0.000 0.000
#> ERR519514     1  0.0000      0.908 1.000 0.000 0.000
#> ERR519479     1  0.5497      0.591 0.708 0.000 0.292
#> ERR519509     1  0.0000      0.908 1.000 0.000 0.000
#> ERR519472     1  0.4750      0.716 0.784 0.000 0.216
#> ERR519510     1  0.5785      0.566 0.696 0.004 0.300
#> ERR519470     1  0.0000      0.908 1.000 0.000 0.000
#> ERR519495     1  0.0237      0.907 0.996 0.000 0.004
#> ERR519522     1  0.0000      0.908 1.000 0.000 0.000
#> ERR519523     1  0.0983      0.900 0.980 0.004 0.016
#> ERR519503     1  0.0000      0.908 1.000 0.000 0.000
#> ERR519471     1  0.0000      0.908 1.000 0.000 0.000
#> ERR519500     1  0.4233      0.778 0.836 0.004 0.160
#> ERR519485     1  0.0000      0.908 1.000 0.000 0.000
#> ERR519476     2  0.0829      0.995 0.004 0.984 0.012
#> ERR519502     3  0.5722      0.664 0.292 0.004 0.704
#> ERR519486     1  0.0000      0.908 1.000 0.000 0.000
#> ERR519478     1  0.0000      0.908 1.000 0.000 0.000
#> ERR519497     3  0.5722      0.664 0.292 0.004 0.704
#> ERR519467     1  0.0000      0.908 1.000 0.000 0.000
#> ERR519489     1  0.4834      0.731 0.792 0.004 0.204
#> ERR519494     3  0.0592      0.798 0.012 0.000 0.988
#> ERR519474     1  0.0237      0.907 0.996 0.000 0.004
#> ERR519505     3  0.6410      0.386 0.420 0.004 0.576
#> ERR519517     3  0.0829      0.798 0.012 0.004 0.984
#> ERR519484     3  0.6180      0.397 0.416 0.000 0.584
#> ERR519498     3  0.5722      0.664 0.292 0.004 0.704
#> ERR519490     3  0.0592      0.798 0.012 0.000 0.988
#> ERR519507     1  0.5560      0.575 0.700 0.000 0.300
#> ERR519511     1  0.5591      0.566 0.696 0.000 0.304
#> ERR519468     3  0.0592      0.798 0.012 0.000 0.988
#> ERR519482     3  0.0592      0.798 0.012 0.000 0.988
#> ERR519475     2  0.0237      0.998 0.004 0.996 0.000
#> ERR519496     1  0.0237      0.907 0.996 0.000 0.004
#> ERR519506     1  0.5016      0.676 0.760 0.000 0.240
#> ERR519469     3  0.2537      0.779 0.080 0.000 0.920
#> ERR519480     3  0.0592      0.798 0.012 0.000 0.988
#> ERR519487     3  0.0829      0.798 0.012 0.004 0.984
#> ERR519483     1  0.0237      0.907 0.996 0.000 0.004
#> ERR519477     2  0.0237      0.998 0.004 0.996 0.000
#> ERR519499     3  0.0829      0.798 0.012 0.004 0.984

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> ERR519515     1  0.0000    0.90224 1.000 0.000 0.000 0.000
#> ERR519516     1  0.4679    0.45031 0.648 0.000 0.000 0.352
#> ERR519520     1  0.4955    0.06480 0.556 0.000 0.000 0.444
#> ERR519513     3  0.0921    0.89123 0.000 0.000 0.972 0.028
#> ERR519481     4  0.2266    0.79048 0.004 0.000 0.084 0.912
#> ERR519491     1  0.1022    0.89352 0.968 0.000 0.000 0.032
#> ERR519473     4  0.1452    0.81258 0.008 0.000 0.036 0.956
#> ERR519518     3  0.4996    0.04247 0.000 0.000 0.516 0.484
#> ERR519512     4  0.1940    0.79231 0.076 0.000 0.000 0.924
#> ERR519521     4  0.1004    0.81406 0.004 0.000 0.024 0.972
#> ERR519488     1  0.0336    0.90172 0.992 0.000 0.000 0.008
#> ERR519493     1  0.3123    0.77463 0.844 0.000 0.000 0.156
#> ERR519514     1  0.0000    0.90224 1.000 0.000 0.000 0.000
#> ERR519479     4  0.1109    0.81614 0.028 0.000 0.004 0.968
#> ERR519509     1  0.0336    0.90172 0.992 0.000 0.000 0.008
#> ERR519472     4  0.1209    0.81574 0.032 0.000 0.004 0.964
#> ERR519510     4  0.2450    0.80274 0.016 0.000 0.072 0.912
#> ERR519470     1  0.0000    0.90224 1.000 0.000 0.000 0.000
#> ERR519495     4  0.2647    0.77238 0.120 0.000 0.000 0.880
#> ERR519522     1  0.0336    0.90172 0.992 0.000 0.000 0.008
#> ERR519523     4  0.2081    0.78778 0.084 0.000 0.000 0.916
#> ERR519503     1  0.1004    0.88985 0.972 0.000 0.004 0.024
#> ERR519471     1  0.0188    0.90217 0.996 0.000 0.000 0.004
#> ERR519500     4  0.0817    0.81557 0.024 0.000 0.000 0.976
#> ERR519485     1  0.1305    0.89159 0.960 0.000 0.004 0.036
#> ERR519476     2  0.0657    0.99206 0.000 0.984 0.012 0.004
#> ERR519502     4  0.2125    0.79182 0.004 0.000 0.076 0.920
#> ERR519486     1  0.1978    0.86769 0.928 0.000 0.004 0.068
#> ERR519478     1  0.0336    0.90172 0.992 0.000 0.000 0.008
#> ERR519497     4  0.3801    0.66205 0.000 0.000 0.220 0.780
#> ERR519467     1  0.0469    0.90103 0.988 0.000 0.000 0.012
#> ERR519489     4  0.0927    0.81648 0.016 0.000 0.008 0.976
#> ERR519494     3  0.1389    0.89147 0.000 0.000 0.952 0.048
#> ERR519474     4  0.5168   -0.01592 0.496 0.000 0.004 0.500
#> ERR519505     4  0.4936    0.38184 0.004 0.000 0.372 0.624
#> ERR519517     3  0.0817    0.89354 0.000 0.000 0.976 0.024
#> ERR519484     4  0.3636    0.71425 0.008 0.000 0.172 0.820
#> ERR519498     4  0.4804    0.36977 0.000 0.000 0.384 0.616
#> ERR519490     3  0.2216    0.85653 0.000 0.000 0.908 0.092
#> ERR519507     4  0.1388    0.81670 0.028 0.000 0.012 0.960
#> ERR519511     4  0.2002    0.81120 0.020 0.000 0.044 0.936
#> ERR519468     3  0.1637    0.88670 0.000 0.000 0.940 0.060
#> ERR519482     3  0.1637    0.88670 0.000 0.000 0.940 0.060
#> ERR519475     2  0.0000    0.99604 0.000 1.000 0.000 0.000
#> ERR519496     1  0.1022    0.89352 0.968 0.000 0.000 0.032
#> ERR519506     4  0.5535    0.15329 0.420 0.000 0.020 0.560
#> ERR519469     4  0.1356    0.81321 0.008 0.000 0.032 0.960
#> ERR519480     3  0.0592    0.89117 0.000 0.000 0.984 0.016
#> ERR519487     3  0.0817    0.89354 0.000 0.000 0.976 0.024
#> ERR519483     4  0.5292   -0.00894 0.480 0.000 0.008 0.512
#> ERR519477     2  0.0000    0.99604 0.000 1.000 0.000 0.000
#> ERR519499     3  0.0817    0.89354 0.000 0.000 0.976 0.024

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> ERR519515     1  0.0290    0.80653 0.992 0.000 0.000 0.000 0.008
#> ERR519516     1  0.6545    0.13709 0.464 0.000 0.000 0.316 0.220
#> ERR519520     4  0.5202    0.29966 0.348 0.000 0.000 0.596 0.056
#> ERR519513     5  0.4268   -0.00794 0.000 0.000 0.444 0.000 0.556
#> ERR519481     4  0.3241    0.69503 0.000 0.000 0.024 0.832 0.144
#> ERR519491     1  0.4367    0.65773 0.748 0.000 0.000 0.060 0.192
#> ERR519473     4  0.3724    0.68963 0.000 0.000 0.028 0.788 0.184
#> ERR519518     4  0.6092    0.42635 0.000 0.000 0.256 0.564 0.180
#> ERR519512     4  0.1764    0.71632 0.008 0.000 0.000 0.928 0.064
#> ERR519521     4  0.2338    0.69708 0.000 0.000 0.004 0.884 0.112
#> ERR519488     1  0.0000    0.80555 1.000 0.000 0.000 0.000 0.000
#> ERR519493     1  0.5811    0.41747 0.568 0.000 0.000 0.116 0.316
#> ERR519514     1  0.0290    0.80653 0.992 0.000 0.000 0.000 0.008
#> ERR519479     4  0.3561    0.57645 0.000 0.000 0.000 0.740 0.260
#> ERR519509     1  0.0000    0.80555 1.000 0.000 0.000 0.000 0.000
#> ERR519472     4  0.2280    0.70750 0.000 0.000 0.000 0.880 0.120
#> ERR519510     5  0.4420    0.45044 0.000 0.000 0.028 0.280 0.692
#> ERR519470     1  0.0290    0.80653 0.992 0.000 0.000 0.000 0.008
#> ERR519495     4  0.4509    0.53571 0.048 0.000 0.000 0.716 0.236
#> ERR519522     1  0.0162    0.80407 0.996 0.000 0.000 0.000 0.004
#> ERR519523     4  0.2193    0.71531 0.008 0.000 0.000 0.900 0.092
#> ERR519503     1  0.1121    0.78261 0.956 0.000 0.000 0.000 0.044
#> ERR519471     1  0.0912    0.80184 0.972 0.000 0.000 0.012 0.016
#> ERR519500     4  0.0290    0.73138 0.000 0.000 0.000 0.992 0.008
#> ERR519485     1  0.5176    0.42723 0.572 0.000 0.000 0.048 0.380
#> ERR519476     2  0.0510    0.99088 0.000 0.984 0.000 0.000 0.016
#> ERR519502     4  0.3527    0.68455 0.000 0.000 0.024 0.804 0.172
#> ERR519486     1  0.5435    0.30605 0.512 0.000 0.000 0.060 0.428
#> ERR519478     1  0.0000    0.80555 1.000 0.000 0.000 0.000 0.000
#> ERR519497     4  0.4840    0.51489 0.000 0.000 0.056 0.676 0.268
#> ERR519467     1  0.1282    0.77973 0.952 0.000 0.000 0.044 0.004
#> ERR519489     4  0.0290    0.73138 0.000 0.000 0.000 0.992 0.008
#> ERR519494     3  0.2358    0.87823 0.000 0.000 0.888 0.008 0.104
#> ERR519474     5  0.6671    0.33141 0.240 0.000 0.000 0.340 0.420
#> ERR519505     5  0.4676    0.46059 0.000 0.000 0.208 0.072 0.720
#> ERR519517     3  0.1484    0.88744 0.000 0.000 0.944 0.008 0.048
#> ERR519484     5  0.4832    0.48748 0.000 0.000 0.088 0.200 0.712
#> ERR519498     5  0.5490    0.45317 0.000 0.000 0.228 0.128 0.644
#> ERR519490     3  0.3697    0.80953 0.000 0.000 0.820 0.080 0.100
#> ERR519507     4  0.3774    0.55668 0.000 0.000 0.000 0.704 0.296
#> ERR519511     5  0.4696    0.20113 0.000 0.000 0.016 0.428 0.556
#> ERR519468     3  0.2561    0.88585 0.000 0.000 0.884 0.020 0.096
#> ERR519482     3  0.2616    0.87160 0.000 0.000 0.880 0.020 0.100
#> ERR519475     2  0.0000    0.99545 0.000 1.000 0.000 0.000 0.000
#> ERR519496     1  0.4028    0.68267 0.776 0.000 0.000 0.048 0.176
#> ERR519506     5  0.5981    0.41471 0.160 0.000 0.000 0.264 0.576
#> ERR519469     4  0.3409    0.69593 0.000 0.000 0.024 0.816 0.160
#> ERR519480     3  0.0794    0.88844 0.000 0.000 0.972 0.000 0.028
#> ERR519487     3  0.1270    0.88405 0.000 0.000 0.948 0.000 0.052
#> ERR519483     5  0.6315    0.39468 0.212 0.000 0.000 0.260 0.528
#> ERR519477     2  0.0000    0.99545 0.000 1.000 0.000 0.000 0.000
#> ERR519499     3  0.1270    0.88405 0.000 0.000 0.948 0.000 0.052

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> ERR519515     1  0.0858     0.8053 0.968 0.000 0.000 0.000 0.004 0.028
#> ERR519516     1  0.6498     0.1252 0.444 0.000 0.000 0.308 0.032 0.216
#> ERR519520     4  0.4859     0.4580 0.244 0.000 0.004 0.676 0.056 0.020
#> ERR519513     5  0.2282     0.6937 0.000 0.000 0.068 0.012 0.900 0.020
#> ERR519481     4  0.4459     0.6773 0.000 0.000 0.132 0.756 0.044 0.068
#> ERR519491     1  0.4469     0.3620 0.584 0.000 0.000 0.016 0.012 0.388
#> ERR519473     4  0.5445     0.5702 0.000 0.000 0.160 0.632 0.020 0.188
#> ERR519518     4  0.5399     0.4198 0.000 0.000 0.380 0.536 0.048 0.036
#> ERR519512     4  0.1765     0.6957 0.000 0.000 0.000 0.924 0.052 0.024
#> ERR519521     4  0.1726     0.7011 0.000 0.000 0.012 0.932 0.044 0.012
#> ERR519488     1  0.0146     0.8051 0.996 0.000 0.004 0.000 0.000 0.000
#> ERR519493     1  0.5309     0.2189 0.512 0.000 0.000 0.024 0.052 0.412
#> ERR519514     1  0.0972     0.8048 0.964 0.000 0.000 0.000 0.008 0.028
#> ERR519479     6  0.4385     0.2281 0.000 0.000 0.000 0.444 0.024 0.532
#> ERR519509     1  0.0146     0.8051 0.996 0.000 0.004 0.000 0.000 0.000
#> ERR519472     4  0.3799     0.5029 0.000 0.000 0.000 0.704 0.020 0.276
#> ERR519510     5  0.5167     0.4873 0.000 0.000 0.008 0.092 0.600 0.300
#> ERR519470     1  0.0858     0.8053 0.968 0.000 0.000 0.000 0.004 0.028
#> ERR519495     6  0.4644     0.2847 0.008 0.000 0.000 0.412 0.028 0.552
#> ERR519522     1  0.0748     0.7971 0.976 0.000 0.004 0.000 0.004 0.016
#> ERR519523     4  0.2249     0.6889 0.004 0.000 0.000 0.900 0.064 0.032
#> ERR519503     1  0.1219     0.7817 0.948 0.000 0.004 0.000 0.000 0.048
#> ERR519471     1  0.1584     0.7880 0.928 0.000 0.000 0.000 0.008 0.064
#> ERR519500     4  0.1444     0.7057 0.000 0.000 0.000 0.928 0.000 0.072
#> ERR519485     6  0.3489     0.3135 0.288 0.000 0.000 0.000 0.004 0.708
#> ERR519476     2  0.0993     0.9766 0.000 0.964 0.000 0.000 0.024 0.012
#> ERR519502     4  0.3616     0.7014 0.000 0.000 0.088 0.824 0.040 0.048
#> ERR519486     6  0.4599     0.3679 0.252 0.000 0.000 0.012 0.056 0.680
#> ERR519478     1  0.0146     0.8051 0.996 0.000 0.004 0.000 0.000 0.000
#> ERR519497     4  0.4745     0.3794 0.000 0.000 0.028 0.604 0.348 0.020
#> ERR519467     1  0.1793     0.7792 0.932 0.000 0.004 0.040 0.008 0.016
#> ERR519489     4  0.1501     0.7037 0.000 0.000 0.000 0.924 0.000 0.076
#> ERR519494     3  0.1536     0.8277 0.000 0.000 0.940 0.004 0.016 0.040
#> ERR519474     6  0.2937     0.5574 0.096 0.000 0.000 0.056 0.000 0.848
#> ERR519505     5  0.2519     0.7314 0.000 0.000 0.020 0.020 0.888 0.072
#> ERR519517     3  0.2994     0.8369 0.000 0.000 0.788 0.004 0.208 0.000
#> ERR519484     5  0.6030     0.4981 0.000 0.000 0.100 0.064 0.568 0.268
#> ERR519498     5  0.2259     0.7261 0.000 0.000 0.020 0.040 0.908 0.032
#> ERR519490     3  0.1562     0.8162 0.000 0.000 0.940 0.024 0.004 0.032
#> ERR519507     6  0.4546     0.3243 0.000 0.000 0.008 0.396 0.024 0.572
#> ERR519511     6  0.6690    -0.0707 0.000 0.000 0.036 0.244 0.344 0.376
#> ERR519468     3  0.1606     0.8422 0.000 0.000 0.932 0.008 0.056 0.004
#> ERR519482     3  0.1296     0.8244 0.000 0.000 0.952 0.012 0.004 0.032
#> ERR519475     2  0.0000     0.9884 0.000 1.000 0.000 0.000 0.000 0.000
#> ERR519496     1  0.4178     0.2840 0.560 0.000 0.000 0.004 0.008 0.428
#> ERR519506     6  0.2059     0.5321 0.024 0.000 0.008 0.024 0.020 0.924
#> ERR519469     4  0.5310     0.5755 0.000 0.000 0.140 0.648 0.020 0.192
#> ERR519480     3  0.2772     0.8383 0.000 0.000 0.816 0.000 0.180 0.004
#> ERR519487     3  0.2969     0.8309 0.000 0.000 0.776 0.000 0.224 0.000
#> ERR519483     6  0.2094     0.5394 0.032 0.000 0.004 0.028 0.016 0.920
#> ERR519477     2  0.0000     0.9884 0.000 1.000 0.000 0.000 0.000 0.000
#> ERR519499     3  0.2969     0.8309 0.000 0.000 0.776 0.000 0.224 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-kmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-kmeans-collect-classes

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


MAD:skmeans**

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

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

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

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 18140 rows and 52 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.959           0.953       0.980         0.5042 0.497   0.497
#> 3 3 0.790           0.874       0.929         0.3285 0.787   0.592
#> 4 4 0.705           0.787       0.874         0.1113 0.908   0.732
#> 5 5 0.680           0.616       0.792         0.0672 0.917   0.699
#> 6 6 0.719           0.590       0.738         0.0431 0.914   0.626

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
#> ERR519515     2   0.000      0.981 0.000 1.000
#> ERR519516     2   0.000      0.981 0.000 1.000
#> ERR519520     1   0.929      0.486 0.656 0.344
#> ERR519513     1   0.000      0.976 1.000 0.000
#> ERR519481     1   0.000      0.976 1.000 0.000
#> ERR519491     2   0.000      0.981 0.000 1.000
#> ERR519473     1   0.000      0.976 1.000 0.000
#> ERR519518     1   0.000      0.976 1.000 0.000
#> ERR519512     1   0.184      0.951 0.972 0.028
#> ERR519521     1   0.000      0.976 1.000 0.000
#> ERR519488     2   0.000      0.981 0.000 1.000
#> ERR519493     2   0.000      0.981 0.000 1.000
#> ERR519514     2   0.000      0.981 0.000 1.000
#> ERR519479     1   0.000      0.976 1.000 0.000
#> ERR519509     2   0.000      0.981 0.000 1.000
#> ERR519472     1   0.000      0.976 1.000 0.000
#> ERR519510     1   0.000      0.976 1.000 0.000
#> ERR519470     2   0.000      0.981 0.000 1.000
#> ERR519495     2   0.595      0.823 0.144 0.856
#> ERR519522     2   0.000      0.981 0.000 1.000
#> ERR519523     1   0.844      0.629 0.728 0.272
#> ERR519503     2   0.000      0.981 0.000 1.000
#> ERR519471     2   0.000      0.981 0.000 1.000
#> ERR519500     1   0.000      0.976 1.000 0.000
#> ERR519485     2   0.000      0.981 0.000 1.000
#> ERR519476     2   0.000      0.981 0.000 1.000
#> ERR519502     1   0.000      0.976 1.000 0.000
#> ERR519486     2   0.000      0.981 0.000 1.000
#> ERR519478     2   0.000      0.981 0.000 1.000
#> ERR519497     1   0.000      0.976 1.000 0.000
#> ERR519467     2   0.000      0.981 0.000 1.000
#> ERR519489     1   0.000      0.976 1.000 0.000
#> ERR519494     1   0.000      0.976 1.000 0.000
#> ERR519474     2   0.000      0.981 0.000 1.000
#> ERR519505     1   0.000      0.976 1.000 0.000
#> ERR519517     1   0.000      0.976 1.000 0.000
#> ERR519484     1   0.000      0.976 1.000 0.000
#> ERR519498     1   0.000      0.976 1.000 0.000
#> ERR519490     1   0.000      0.976 1.000 0.000
#> ERR519507     1   0.000      0.976 1.000 0.000
#> ERR519511     1   0.000      0.976 1.000 0.000
#> ERR519468     1   0.000      0.976 1.000 0.000
#> ERR519482     1   0.000      0.976 1.000 0.000
#> ERR519475     2   0.000      0.981 0.000 1.000
#> ERR519496     2   0.000      0.981 0.000 1.000
#> ERR519506     2   0.802      0.672 0.244 0.756
#> ERR519469     1   0.000      0.976 1.000 0.000
#> ERR519480     1   0.000      0.976 1.000 0.000
#> ERR519487     1   0.000      0.976 1.000 0.000
#> ERR519483     2   0.000      0.981 0.000 1.000
#> ERR519477     2   0.000      0.981 0.000 1.000
#> ERR519499     1   0.000      0.976 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
#> ERR519515     2  0.0000      0.957 0.000 1.000 0.000
#> ERR519516     2  0.4654      0.755 0.208 0.792 0.000
#> ERR519520     1  0.4353      0.771 0.836 0.156 0.008
#> ERR519513     3  0.0000      0.987 0.000 0.000 1.000
#> ERR519481     1  0.3816      0.801 0.852 0.000 0.148
#> ERR519491     2  0.0000      0.957 0.000 1.000 0.000
#> ERR519473     1  0.2356      0.836 0.928 0.000 0.072
#> ERR519518     3  0.1289      0.970 0.032 0.000 0.968
#> ERR519512     1  0.1453      0.842 0.968 0.008 0.024
#> ERR519521     1  0.1031      0.844 0.976 0.000 0.024
#> ERR519488     2  0.0000      0.957 0.000 1.000 0.000
#> ERR519493     2  0.0424      0.956 0.008 0.992 0.000
#> ERR519514     2  0.0000      0.957 0.000 1.000 0.000
#> ERR519479     1  0.0424      0.840 0.992 0.000 0.008
#> ERR519509     2  0.0000      0.957 0.000 1.000 0.000
#> ERR519472     1  0.1031      0.844 0.976 0.000 0.024
#> ERR519510     1  0.5835      0.585 0.660 0.000 0.340
#> ERR519470     2  0.0000      0.957 0.000 1.000 0.000
#> ERR519495     1  0.4002      0.775 0.840 0.160 0.000
#> ERR519522     2  0.0000      0.957 0.000 1.000 0.000
#> ERR519523     1  0.1411      0.832 0.964 0.036 0.000
#> ERR519503     2  0.0237      0.957 0.004 0.996 0.000
#> ERR519471     2  0.0000      0.957 0.000 1.000 0.000
#> ERR519500     1  0.1031      0.844 0.976 0.000 0.024
#> ERR519485     2  0.0747      0.953 0.016 0.984 0.000
#> ERR519476     2  0.1620      0.944 0.024 0.964 0.012
#> ERR519502     1  0.4062      0.790 0.836 0.000 0.164
#> ERR519486     2  0.0592      0.954 0.012 0.988 0.000
#> ERR519478     2  0.0000      0.957 0.000 1.000 0.000
#> ERR519497     3  0.0592      0.989 0.012 0.000 0.988
#> ERR519467     2  0.1753      0.927 0.048 0.952 0.000
#> ERR519489     1  0.1031      0.844 0.976 0.000 0.024
#> ERR519494     3  0.0237      0.990 0.004 0.000 0.996
#> ERR519474     1  0.5291      0.570 0.732 0.268 0.000
#> ERR519505     3  0.1031      0.964 0.024 0.000 0.976
#> ERR519517     3  0.0592      0.989 0.012 0.000 0.988
#> ERR519484     1  0.6295      0.279 0.528 0.000 0.472
#> ERR519498     3  0.0000      0.987 0.000 0.000 1.000
#> ERR519490     3  0.0592      0.989 0.012 0.000 0.988
#> ERR519507     1  0.2066      0.837 0.940 0.000 0.060
#> ERR519511     1  0.5678      0.621 0.684 0.000 0.316
#> ERR519468     3  0.0592      0.989 0.012 0.000 0.988
#> ERR519482     3  0.0592      0.989 0.012 0.000 0.988
#> ERR519475     2  0.1620      0.944 0.024 0.964 0.012
#> ERR519496     2  0.0000      0.957 0.000 1.000 0.000
#> ERR519506     2  0.8321      0.560 0.148 0.624 0.228
#> ERR519469     1  0.5810      0.530 0.664 0.000 0.336
#> ERR519480     3  0.0237      0.990 0.004 0.000 0.996
#> ERR519487     3  0.0237      0.990 0.004 0.000 0.996
#> ERR519483     2  0.3340      0.872 0.120 0.880 0.000
#> ERR519477     2  0.1620      0.944 0.024 0.964 0.012
#> ERR519499     3  0.0237      0.990 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
#> ERR519515     1  0.0188      0.882 0.996 0.004 0.000 0.000
#> ERR519516     1  0.5035      0.669 0.744 0.052 0.000 0.204
#> ERR519520     1  0.4522      0.541 0.680 0.000 0.000 0.320
#> ERR519513     3  0.0657      0.944 0.000 0.012 0.984 0.004
#> ERR519481     4  0.3182      0.797 0.000 0.028 0.096 0.876
#> ERR519491     1  0.0188      0.882 0.996 0.004 0.000 0.000
#> ERR519473     4  0.3215      0.801 0.000 0.092 0.032 0.876
#> ERR519518     3  0.2060      0.910 0.000 0.016 0.932 0.052
#> ERR519512     4  0.1151      0.795 0.024 0.000 0.008 0.968
#> ERR519521     4  0.0592      0.801 0.000 0.000 0.016 0.984
#> ERR519488     1  0.0469      0.879 0.988 0.012 0.000 0.000
#> ERR519493     1  0.2973      0.775 0.856 0.144 0.000 0.000
#> ERR519514     1  0.0188      0.882 0.996 0.004 0.000 0.000
#> ERR519479     4  0.2589      0.798 0.000 0.116 0.000 0.884
#> ERR519509     1  0.0469      0.879 0.988 0.012 0.000 0.000
#> ERR519472     4  0.2334      0.800 0.000 0.088 0.004 0.908
#> ERR519510     4  0.7325      0.505 0.000 0.208 0.264 0.528
#> ERR519470     1  0.0188      0.882 0.996 0.004 0.000 0.000
#> ERR519495     4  0.5080      0.714 0.144 0.092 0.000 0.764
#> ERR519522     1  0.0188      0.881 0.996 0.004 0.000 0.000
#> ERR519523     4  0.1940      0.769 0.076 0.000 0.000 0.924
#> ERR519503     1  0.4072      0.565 0.748 0.252 0.000 0.000
#> ERR519471     1  0.0188      0.882 0.996 0.004 0.000 0.000
#> ERR519500     4  0.0336      0.801 0.000 0.000 0.008 0.992
#> ERR519485     2  0.4981      0.250 0.464 0.536 0.000 0.000
#> ERR519476     2  0.2814      0.844 0.132 0.868 0.000 0.000
#> ERR519502     4  0.3160      0.793 0.000 0.020 0.108 0.872
#> ERR519486     1  0.4164      0.556 0.736 0.264 0.000 0.000
#> ERR519478     1  0.0188      0.881 0.996 0.004 0.000 0.000
#> ERR519497     3  0.0188      0.949 0.000 0.000 0.996 0.004
#> ERR519467     1  0.2216      0.818 0.908 0.000 0.000 0.092
#> ERR519489     4  0.0336      0.801 0.000 0.000 0.008 0.992
#> ERR519494     3  0.0707      0.947 0.000 0.020 0.980 0.000
#> ERR519474     4  0.6031      0.605 0.144 0.168 0.000 0.688
#> ERR519505     3  0.4855      0.479 0.000 0.352 0.644 0.004
#> ERR519517     3  0.0000      0.949 0.000 0.000 1.000 0.000
#> ERR519484     4  0.7597      0.428 0.000 0.224 0.308 0.468
#> ERR519498     3  0.0524      0.946 0.000 0.008 0.988 0.004
#> ERR519490     3  0.1820      0.921 0.000 0.020 0.944 0.036
#> ERR519507     4  0.3894      0.790 0.004 0.140 0.024 0.832
#> ERR519511     4  0.7088      0.560 0.000 0.228 0.204 0.568
#> ERR519468     3  0.0895      0.944 0.000 0.020 0.976 0.004
#> ERR519482     3  0.1042      0.942 0.000 0.020 0.972 0.008
#> ERR519475     2  0.2814      0.844 0.132 0.868 0.000 0.000
#> ERR519496     1  0.0921      0.870 0.972 0.028 0.000 0.000
#> ERR519506     2  0.0927      0.761 0.008 0.976 0.000 0.016
#> ERR519469     4  0.6411      0.513 0.000 0.092 0.308 0.600
#> ERR519480     3  0.0188      0.949 0.000 0.004 0.996 0.000
#> ERR519487     3  0.0000      0.949 0.000 0.000 1.000 0.000
#> ERR519483     2  0.2796      0.798 0.092 0.892 0.000 0.016
#> ERR519477     2  0.2814      0.844 0.132 0.868 0.000 0.000
#> ERR519499     3  0.0000      0.949 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
#> ERR519515     1  0.0609     0.8354 0.980 0.000 0.000 0.000 0.020
#> ERR519516     1  0.7100     0.4430 0.540 0.064 0.000 0.236 0.160
#> ERR519520     4  0.4588     0.1877 0.380 0.000 0.000 0.604 0.016
#> ERR519513     3  0.4029     0.5327 0.000 0.000 0.680 0.004 0.316
#> ERR519481     4  0.4700     0.5747 0.000 0.000 0.088 0.728 0.184
#> ERR519491     1  0.2674     0.7625 0.856 0.004 0.000 0.000 0.140
#> ERR519473     4  0.4194     0.5884 0.000 0.012 0.004 0.708 0.276
#> ERR519518     3  0.4555     0.5880 0.000 0.000 0.720 0.224 0.056
#> ERR519512     4  0.1179     0.6855 0.016 0.000 0.004 0.964 0.016
#> ERR519521     4  0.0404     0.6936 0.000 0.000 0.000 0.988 0.012
#> ERR519488     1  0.0290     0.8344 0.992 0.008 0.000 0.000 0.000
#> ERR519493     1  0.6259     0.4180 0.540 0.212 0.000 0.000 0.248
#> ERR519514     1  0.0609     0.8354 0.980 0.000 0.000 0.000 0.020
#> ERR519479     5  0.4648    -0.1862 0.000 0.012 0.000 0.464 0.524
#> ERR519509     1  0.0290     0.8344 0.992 0.008 0.000 0.000 0.000
#> ERR519472     4  0.3988     0.6042 0.000 0.016 0.000 0.732 0.252
#> ERR519510     5  0.3759     0.4944 0.000 0.012 0.148 0.028 0.812
#> ERR519470     1  0.0609     0.8354 0.980 0.000 0.000 0.000 0.020
#> ERR519495     4  0.6436     0.2901 0.132 0.016 0.000 0.528 0.324
#> ERR519522     1  0.0290     0.8344 0.992 0.008 0.000 0.000 0.000
#> ERR519523     4  0.1300     0.6827 0.028 0.000 0.000 0.956 0.016
#> ERR519503     1  0.3730     0.4938 0.712 0.288 0.000 0.000 0.000
#> ERR519471     1  0.0898     0.8334 0.972 0.008 0.000 0.000 0.020
#> ERR519500     4  0.0609     0.6971 0.000 0.000 0.000 0.980 0.020
#> ERR519485     2  0.5395     0.3709 0.356 0.576 0.000 0.000 0.068
#> ERR519476     2  0.0898     0.8117 0.020 0.972 0.000 0.000 0.008
#> ERR519502     4  0.4609     0.5795 0.000 0.000 0.104 0.744 0.152
#> ERR519486     1  0.5925     0.2837 0.472 0.104 0.000 0.000 0.424
#> ERR519478     1  0.0290     0.8344 0.992 0.008 0.000 0.000 0.000
#> ERR519497     3  0.3033     0.7888 0.000 0.000 0.864 0.052 0.084
#> ERR519467     1  0.2389     0.7624 0.880 0.000 0.000 0.116 0.004
#> ERR519489     4  0.0566     0.6976 0.000 0.000 0.012 0.984 0.004
#> ERR519494     3  0.1478     0.8440 0.000 0.000 0.936 0.000 0.064
#> ERR519474     5  0.7237     0.0504 0.112 0.076 0.000 0.348 0.464
#> ERR519505     5  0.6708    -0.1442 0.000 0.164 0.396 0.012 0.428
#> ERR519517     3  0.0000     0.8509 0.000 0.000 1.000 0.000 0.000
#> ERR519484     5  0.3314     0.5106 0.000 0.012 0.124 0.020 0.844
#> ERR519498     3  0.4430     0.4559 0.000 0.000 0.628 0.012 0.360
#> ERR519490     3  0.1914     0.8367 0.000 0.000 0.924 0.016 0.060
#> ERR519507     5  0.4723    -0.1565 0.000 0.016 0.000 0.448 0.536
#> ERR519511     5  0.3478     0.5261 0.000 0.016 0.096 0.040 0.848
#> ERR519468     3  0.1357     0.8463 0.000 0.000 0.948 0.004 0.048
#> ERR519482     3  0.1697     0.8411 0.000 0.000 0.932 0.008 0.060
#> ERR519475     2  0.0898     0.8117 0.020 0.972 0.000 0.000 0.008
#> ERR519496     1  0.1106     0.8315 0.964 0.012 0.000 0.000 0.024
#> ERR519506     2  0.3087     0.7427 0.008 0.836 0.000 0.004 0.152
#> ERR519469     4  0.5672     0.5474 0.000 0.012 0.120 0.656 0.212
#> ERR519480     3  0.0162     0.8511 0.000 0.000 0.996 0.000 0.004
#> ERR519487     3  0.0000     0.8509 0.000 0.000 1.000 0.000 0.000
#> ERR519483     2  0.3911     0.7428 0.060 0.796 0.000 0.000 0.144
#> ERR519477     2  0.0898     0.8117 0.020 0.972 0.000 0.000 0.008
#> ERR519499     3  0.0000     0.8509 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
#> ERR519515     1  0.0146     0.8342 0.996 0.000 0.000 0.004 0.000 0.000
#> ERR519516     4  0.7499    -0.1402 0.356 0.180 0.000 0.360 0.032 0.072
#> ERR519520     4  0.4079     0.5145 0.140 0.000 0.000 0.760 0.096 0.004
#> ERR519513     6  0.4242     0.3730 0.000 0.000 0.448 0.016 0.000 0.536
#> ERR519481     5  0.5954     0.2605 0.000 0.000 0.076 0.216 0.604 0.104
#> ERR519491     1  0.3357     0.7505 0.848 0.008 0.000 0.064 0.020 0.060
#> ERR519473     5  0.2721     0.5173 0.000 0.000 0.040 0.088 0.868 0.004
#> ERR519518     3  0.5885     0.4560 0.000 0.000 0.596 0.228 0.128 0.048
#> ERR519512     4  0.3023     0.6313 0.000 0.000 0.000 0.768 0.232 0.000
#> ERR519521     4  0.3489     0.6236 0.000 0.000 0.000 0.708 0.288 0.004
#> ERR519488     1  0.1515     0.8290 0.944 0.020 0.000 0.028 0.000 0.008
#> ERR519493     1  0.7152     0.2621 0.472 0.260 0.000 0.076 0.020 0.172
#> ERR519514     1  0.0146     0.8342 0.996 0.000 0.000 0.004 0.000 0.000
#> ERR519479     5  0.2902     0.5480 0.000 0.000 0.000 0.004 0.800 0.196
#> ERR519509     1  0.1515     0.8290 0.944 0.020 0.000 0.028 0.000 0.008
#> ERR519472     5  0.2278     0.4919 0.000 0.000 0.004 0.128 0.868 0.000
#> ERR519510     6  0.2658     0.6473 0.000 0.000 0.036 0.000 0.100 0.864
#> ERR519470     1  0.0146     0.8342 0.996 0.000 0.000 0.004 0.000 0.000
#> ERR519495     5  0.3891     0.5115 0.112 0.000 0.000 0.036 0.800 0.052
#> ERR519522     1  0.1116     0.8318 0.960 0.004 0.000 0.028 0.000 0.008
#> ERR519523     4  0.3560     0.6338 0.008 0.000 0.000 0.732 0.256 0.004
#> ERR519503     1  0.4108     0.5720 0.704 0.260 0.000 0.028 0.000 0.008
#> ERR519471     1  0.0551     0.8311 0.984 0.008 0.000 0.004 0.000 0.004
#> ERR519500     4  0.3955     0.4494 0.000 0.000 0.000 0.560 0.436 0.004
#> ERR519485     2  0.7878     0.3244 0.292 0.368 0.000 0.200 0.044 0.096
#> ERR519476     2  0.0405     0.7054 0.008 0.988 0.000 0.000 0.000 0.004
#> ERR519502     5  0.6383     0.0794 0.000 0.000 0.064 0.280 0.520 0.136
#> ERR519486     1  0.7934    -0.0619 0.356 0.080 0.000 0.216 0.056 0.292
#> ERR519478     1  0.1116     0.8318 0.960 0.004 0.000 0.028 0.000 0.008
#> ERR519497     3  0.6331     0.2612 0.000 0.000 0.508 0.256 0.036 0.200
#> ERR519467     1  0.2513     0.7669 0.852 0.000 0.000 0.140 0.000 0.008
#> ERR519489     4  0.3899     0.5190 0.000 0.000 0.000 0.592 0.404 0.004
#> ERR519494     3  0.1863     0.8089 0.000 0.000 0.920 0.000 0.036 0.044
#> ERR519474     5  0.7600     0.0996 0.080 0.032 0.000 0.288 0.396 0.204
#> ERR519505     6  0.5399     0.6256 0.000 0.088 0.212 0.048 0.000 0.652
#> ERR519517     3  0.0935     0.8164 0.000 0.000 0.964 0.000 0.004 0.032
#> ERR519484     6  0.3248     0.6306 0.000 0.000 0.052 0.004 0.116 0.828
#> ERR519498     6  0.4594     0.5413 0.000 0.000 0.340 0.052 0.000 0.608
#> ERR519490     3  0.2001     0.8044 0.000 0.000 0.912 0.000 0.048 0.040
#> ERR519507     5  0.3245     0.5509 0.000 0.000 0.004 0.016 0.796 0.184
#> ERR519511     6  0.3522     0.5737 0.000 0.000 0.044 0.000 0.172 0.784
#> ERR519468     3  0.0713     0.8192 0.000 0.000 0.972 0.000 0.028 0.000
#> ERR519482     3  0.1934     0.8068 0.000 0.000 0.916 0.000 0.044 0.040
#> ERR519475     2  0.0405     0.7054 0.008 0.988 0.000 0.000 0.000 0.004
#> ERR519496     1  0.2666     0.7827 0.892 0.008 0.000 0.032 0.044 0.024
#> ERR519506     2  0.6346     0.5999 0.008 0.592 0.000 0.136 0.180 0.084
#> ERR519469     5  0.4389     0.4296 0.000 0.000 0.188 0.100 0.712 0.000
#> ERR519480     3  0.0713     0.8160 0.000 0.000 0.972 0.000 0.000 0.028
#> ERR519487     3  0.0790     0.8144 0.000 0.000 0.968 0.000 0.000 0.032
#> ERR519483     2  0.6762     0.5995 0.032 0.576 0.000 0.144 0.164 0.084
#> ERR519477     2  0.0405     0.7054 0.008 0.988 0.000 0.000 0.000 0.004
#> ERR519499     3  0.0790     0.8144 0.000 0.000 0.968 0.000 0.000 0.032

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

consensus_heatmap(res, k = 2)

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

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

collect_plots(res)

plot of chunk MAD-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.705           0.943       0.940         0.1566 0.889   0.889
#> 3 3 0.627           0.844       0.921         1.9545 0.706   0.669
#> 4 4 0.724           0.882       0.929         0.4021 0.753   0.590
#> 5 5 0.808           0.883       0.927         0.1949 0.760   0.421
#> 6 6 0.855           0.853       0.923         0.0425 0.962   0.832

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
#> ERR519515     1  0.1843      0.942 0.972 0.028
#> ERR519516     1  0.0000      0.947 1.000 0.000
#> ERR519520     1  0.1633      0.943 0.976 0.024
#> ERR519513     1  0.4562      0.930 0.904 0.096
#> ERR519481     1  0.4562      0.930 0.904 0.096
#> ERR519491     1  0.1843      0.942 0.972 0.028
#> ERR519473     1  0.4562      0.930 0.904 0.096
#> ERR519518     1  0.4562      0.930 0.904 0.096
#> ERR519512     1  0.2948      0.943 0.948 0.052
#> ERR519521     1  0.4562      0.930 0.904 0.096
#> ERR519488     1  0.1843      0.942 0.972 0.028
#> ERR519493     1  0.0376      0.946 0.996 0.004
#> ERR519514     1  0.1843      0.942 0.972 0.028
#> ERR519479     1  0.2423      0.945 0.960 0.040
#> ERR519509     1  0.1843      0.942 0.972 0.028
#> ERR519472     1  0.0000      0.947 1.000 0.000
#> ERR519510     1  0.2778      0.944 0.952 0.048
#> ERR519470     1  0.1843      0.942 0.972 0.028
#> ERR519495     1  0.1843      0.942 0.972 0.028
#> ERR519522     1  0.1843      0.942 0.972 0.028
#> ERR519523     1  0.1843      0.942 0.972 0.028
#> ERR519503     1  0.1843      0.942 0.972 0.028
#> ERR519471     1  0.1843      0.942 0.972 0.028
#> ERR519500     1  0.0000      0.947 1.000 0.000
#> ERR519485     1  0.1843      0.942 0.972 0.028
#> ERR519476     2  0.4431      1.000 0.092 0.908
#> ERR519502     1  0.4562      0.930 0.904 0.096
#> ERR519486     1  0.1843      0.942 0.972 0.028
#> ERR519478     1  0.1843      0.942 0.972 0.028
#> ERR519497     1  0.4562      0.930 0.904 0.096
#> ERR519467     1  0.1843      0.942 0.972 0.028
#> ERR519489     1  0.1184      0.947 0.984 0.016
#> ERR519494     1  0.4562      0.930 0.904 0.096
#> ERR519474     1  0.0376      0.946 0.996 0.004
#> ERR519505     1  0.2778      0.944 0.952 0.048
#> ERR519517     1  0.4562      0.930 0.904 0.096
#> ERR519484     1  0.3431      0.940 0.936 0.064
#> ERR519498     1  0.4562      0.930 0.904 0.096
#> ERR519490     1  0.4562      0.930 0.904 0.096
#> ERR519507     1  0.2236      0.946 0.964 0.036
#> ERR519511     1  0.3114      0.942 0.944 0.056
#> ERR519468     1  0.4431      0.931 0.908 0.092
#> ERR519482     1  0.4562      0.930 0.904 0.096
#> ERR519475     2  0.4431      1.000 0.092 0.908
#> ERR519496     1  0.1843      0.942 0.972 0.028
#> ERR519506     1  0.0672      0.947 0.992 0.008
#> ERR519469     1  0.0376      0.946 0.996 0.004
#> ERR519480     1  0.4562      0.930 0.904 0.096
#> ERR519487     1  0.4562      0.930 0.904 0.096
#> ERR519483     1  0.1843      0.942 0.972 0.028
#> ERR519477     2  0.4431      1.000 0.092 0.908
#> ERR519499     1  0.4562      0.930 0.904 0.096

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1 p2    p3
#> ERR519515     1  0.0000      0.882 1.000  0 0.000
#> ERR519516     1  0.0424      0.881 0.992  0 0.008
#> ERR519520     1  0.0237      0.881 0.996  0 0.004
#> ERR519513     3  0.0000      1.000 0.000  0 1.000
#> ERR519481     1  0.6235      0.440 0.564  0 0.436
#> ERR519491     1  0.0000      0.882 1.000  0 0.000
#> ERR519473     1  0.6235      0.440 0.564  0 0.436
#> ERR519518     3  0.0000      1.000 0.000  0 1.000
#> ERR519512     1  0.5650      0.627 0.688  0 0.312
#> ERR519521     1  0.6235      0.440 0.564  0 0.436
#> ERR519488     1  0.0000      0.882 1.000  0 0.000
#> ERR519493     1  0.1289      0.876 0.968  0 0.032
#> ERR519514     1  0.0000      0.882 1.000  0 0.000
#> ERR519479     1  0.3116      0.842 0.892  0 0.108
#> ERR519509     1  0.0000      0.882 1.000  0 0.000
#> ERR519472     1  0.0747      0.880 0.984  0 0.016
#> ERR519510     1  0.3267      0.838 0.884  0 0.116
#> ERR519470     1  0.0000      0.882 1.000  0 0.000
#> ERR519495     1  0.0000      0.882 1.000  0 0.000
#> ERR519522     1  0.0000      0.882 1.000  0 0.000
#> ERR519523     1  0.0000      0.882 1.000  0 0.000
#> ERR519503     1  0.0000      0.882 1.000  0 0.000
#> ERR519471     1  0.0000      0.882 1.000  0 0.000
#> ERR519500     1  0.1031      0.879 0.976  0 0.024
#> ERR519485     1  0.0000      0.882 1.000  0 0.000
#> ERR519476     2  0.0000      1.000 0.000  1 0.000
#> ERR519502     1  0.6235      0.440 0.564  0 0.436
#> ERR519486     1  0.0000      0.882 1.000  0 0.000
#> ERR519478     1  0.0000      0.882 1.000  0 0.000
#> ERR519497     1  0.6235      0.440 0.564  0 0.436
#> ERR519467     1  0.0000      0.882 1.000  0 0.000
#> ERR519489     1  0.2261      0.862 0.932  0 0.068
#> ERR519494     3  0.0000      1.000 0.000  0 1.000
#> ERR519474     1  0.0424      0.881 0.992  0 0.008
#> ERR519505     1  0.3482      0.830 0.872  0 0.128
#> ERR519517     3  0.0000      1.000 0.000  0 1.000
#> ERR519484     1  0.6111      0.515 0.604  0 0.396
#> ERR519498     1  0.6095      0.522 0.608  0 0.392
#> ERR519490     3  0.0000      1.000 0.000  0 1.000
#> ERR519507     1  0.2959      0.847 0.900  0 0.100
#> ERR519511     1  0.4178      0.795 0.828  0 0.172
#> ERR519468     3  0.0000      1.000 0.000  0 1.000
#> ERR519482     3  0.0000      1.000 0.000  0 1.000
#> ERR519475     2  0.0000      1.000 0.000  1 0.000
#> ERR519496     1  0.0000      0.882 1.000  0 0.000
#> ERR519506     1  0.1411      0.874 0.964  0 0.036
#> ERR519469     1  0.1163      0.878 0.972  0 0.028
#> ERR519480     3  0.0000      1.000 0.000  0 1.000
#> ERR519487     3  0.0000      1.000 0.000  0 1.000
#> ERR519483     1  0.0000      0.882 1.000  0 0.000
#> ERR519477     2  0.0000      1.000 0.000  1 0.000
#> ERR519499     3  0.0000      1.000 0.000  0 1.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1 p2    p3    p4
#> ERR519515     1  0.0000      0.908 1.000  0 0.000 0.000
#> ERR519516     1  0.3024      0.870 0.852  0 0.000 0.148
#> ERR519520     1  0.0707      0.905 0.980  0 0.000 0.020
#> ERR519513     4  0.4008      0.722 0.000  0 0.244 0.756
#> ERR519481     4  0.0469      0.907 0.000  0 0.012 0.988
#> ERR519491     1  0.0336      0.908 0.992  0 0.000 0.008
#> ERR519473     1  0.4228      0.805 0.760  0 0.008 0.232
#> ERR519518     3  0.3688      0.728 0.000  0 0.792 0.208
#> ERR519512     1  0.3636      0.859 0.820  0 0.008 0.172
#> ERR519521     4  0.2011      0.875 0.000  0 0.080 0.920
#> ERR519488     1  0.0000      0.908 1.000  0 0.000 0.000
#> ERR519493     1  0.4277      0.746 0.720  0 0.000 0.280
#> ERR519514     1  0.0000      0.908 1.000  0 0.000 0.000
#> ERR519479     4  0.0707      0.903 0.020  0 0.000 0.980
#> ERR519509     1  0.0000      0.908 1.000  0 0.000 0.000
#> ERR519472     1  0.3266      0.861 0.832  0 0.000 0.168
#> ERR519510     4  0.0707      0.903 0.020  0 0.000 0.980
#> ERR519470     1  0.0000      0.908 1.000  0 0.000 0.000
#> ERR519495     1  0.0469      0.908 0.988  0 0.000 0.012
#> ERR519522     1  0.0000      0.908 1.000  0 0.000 0.000
#> ERR519523     1  0.3266      0.864 0.832  0 0.000 0.168
#> ERR519503     1  0.0000      0.908 1.000  0 0.000 0.000
#> ERR519471     1  0.0469      0.908 0.988  0 0.000 0.012
#> ERR519500     1  0.3494      0.859 0.824  0 0.004 0.172
#> ERR519485     1  0.0469      0.908 0.988  0 0.000 0.012
#> ERR519476     2  0.0000      1.000 0.000  1 0.000 0.000
#> ERR519502     4  0.0592      0.907 0.000  0 0.016 0.984
#> ERR519486     1  0.1867      0.875 0.928  0 0.000 0.072
#> ERR519478     1  0.0000      0.908 1.000  0 0.000 0.000
#> ERR519497     4  0.0927      0.909 0.008  0 0.016 0.976
#> ERR519467     1  0.0000      0.908 1.000  0 0.000 0.000
#> ERR519489     1  0.4610      0.798 0.744  0 0.020 0.236
#> ERR519494     3  0.2011      0.867 0.000  0 0.920 0.080
#> ERR519474     1  0.3528      0.849 0.808  0 0.000 0.192
#> ERR519505     4  0.3428      0.807 0.012  0 0.144 0.844
#> ERR519517     3  0.0000      0.919 0.000  0 1.000 0.000
#> ERR519484     4  0.0937      0.910 0.012  0 0.012 0.976
#> ERR519498     4  0.4175      0.756 0.012  0 0.212 0.776
#> ERR519490     3  0.3024      0.784 0.000  0 0.852 0.148
#> ERR519507     4  0.0817      0.900 0.024  0 0.000 0.976
#> ERR519511     4  0.0804      0.909 0.012  0 0.008 0.980
#> ERR519468     3  0.0000      0.919 0.000  0 1.000 0.000
#> ERR519482     3  0.0336      0.916 0.000  0 0.992 0.008
#> ERR519475     2  0.0000      1.000 0.000  1 0.000 0.000
#> ERR519496     1  0.0336      0.908 0.992  0 0.000 0.008
#> ERR519506     1  0.3801      0.824 0.780  0 0.000 0.220
#> ERR519469     1  0.3539      0.858 0.820  0 0.004 0.176
#> ERR519480     3  0.0000      0.919 0.000  0 1.000 0.000
#> ERR519487     3  0.0000      0.919 0.000  0 1.000 0.000
#> ERR519483     1  0.0592      0.908 0.984  0 0.000 0.016
#> ERR519477     2  0.0000      1.000 0.000  1 0.000 0.000
#> ERR519499     3  0.0000      0.919 0.000  0 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1 p2    p3    p4    p5
#> ERR519515     1  0.0000      0.952 1.000  0 0.000 0.000 0.000
#> ERR519516     1  0.3795      0.786 0.780  0 0.000 0.192 0.028
#> ERR519520     4  0.1270      0.847 0.052  0 0.000 0.948 0.000
#> ERR519513     5  0.3177      0.788 0.000  0 0.208 0.000 0.792
#> ERR519481     5  0.0290      0.866 0.000  0 0.000 0.008 0.992
#> ERR519491     1  0.1484      0.940 0.944  0 0.000 0.048 0.008
#> ERR519473     4  0.5848      0.613 0.000  0 0.192 0.608 0.200
#> ERR519518     4  0.2488      0.825 0.000  0 0.004 0.872 0.124
#> ERR519512     4  0.0290      0.861 0.000  0 0.000 0.992 0.008
#> ERR519521     4  0.2685      0.819 0.000  0 0.028 0.880 0.092
#> ERR519488     1  0.0000      0.952 1.000  0 0.000 0.000 0.000
#> ERR519493     5  0.4316      0.770 0.120  0 0.000 0.108 0.772
#> ERR519514     1  0.0000      0.952 1.000  0 0.000 0.000 0.000
#> ERR519479     5  0.1908      0.876 0.000  0 0.000 0.092 0.908
#> ERR519509     1  0.0000      0.952 1.000  0 0.000 0.000 0.000
#> ERR519472     4  0.1608      0.854 0.000  0 0.000 0.928 0.072
#> ERR519510     5  0.1908      0.876 0.000  0 0.000 0.092 0.908
#> ERR519470     1  0.0000      0.952 1.000  0 0.000 0.000 0.000
#> ERR519495     1  0.1331      0.943 0.952  0 0.000 0.040 0.008
#> ERR519522     1  0.0000      0.952 1.000  0 0.000 0.000 0.000
#> ERR519523     4  0.1197      0.863 0.000  0 0.000 0.952 0.048
#> ERR519503     1  0.0000      0.952 1.000  0 0.000 0.000 0.000
#> ERR519471     1  0.1408      0.941 0.948  0 0.000 0.044 0.008
#> ERR519500     4  0.0963      0.867 0.000  0 0.000 0.964 0.036
#> ERR519485     1  0.1697      0.933 0.932  0 0.000 0.060 0.008
#> ERR519476     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> ERR519502     5  0.0290      0.866 0.000  0 0.000 0.008 0.992
#> ERR519486     5  0.3953      0.769 0.148  0 0.000 0.060 0.792
#> ERR519478     1  0.0000      0.952 1.000  0 0.000 0.000 0.000
#> ERR519497     4  0.3424      0.696 0.000  0 0.000 0.760 0.240
#> ERR519467     1  0.1410      0.920 0.940  0 0.000 0.060 0.000
#> ERR519489     4  0.0290      0.861 0.000  0 0.000 0.992 0.008
#> ERR519494     3  0.1608      0.900 0.000  0 0.928 0.000 0.072
#> ERR519474     5  0.2439      0.864 0.004  0 0.000 0.120 0.876
#> ERR519505     5  0.2773      0.817 0.000  0 0.164 0.000 0.836
#> ERR519517     3  0.0000      0.938 0.000  0 1.000 0.000 0.000
#> ERR519484     5  0.0290      0.866 0.000  0 0.000 0.008 0.992
#> ERR519498     5  0.3109      0.795 0.000  0 0.200 0.000 0.800
#> ERR519490     3  0.3053      0.797 0.000  0 0.828 0.008 0.164
#> ERR519507     5  0.1908      0.876 0.000  0 0.000 0.092 0.908
#> ERR519511     5  0.0404      0.867 0.000  0 0.000 0.012 0.988
#> ERR519468     3  0.0000      0.938 0.000  0 1.000 0.000 0.000
#> ERR519482     3  0.2193      0.877 0.000  0 0.900 0.008 0.092
#> ERR519475     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> ERR519496     1  0.1251      0.944 0.956  0 0.000 0.036 0.008
#> ERR519506     5  0.2505      0.872 0.020  0 0.000 0.092 0.888
#> ERR519469     4  0.2233      0.851 0.004  0 0.000 0.892 0.104
#> ERR519480     3  0.0000      0.938 0.000  0 1.000 0.000 0.000
#> ERR519487     3  0.0000      0.938 0.000  0 1.000 0.000 0.000
#> ERR519483     1  0.2563      0.877 0.872  0 0.000 0.120 0.008
#> ERR519477     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> ERR519499     3  0.0000      0.938 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
#> ERR519515     1  0.0000     0.9672 1.000  0 0.000 0.000 0.000 0.000
#> ERR519516     1  0.3393     0.7589 0.784  0 0.000 0.192 0.020 0.004
#> ERR519520     4  0.0260     0.8665 0.008  0 0.000 0.992 0.000 0.000
#> ERR519513     5  0.2793     0.7451 0.000  0 0.200 0.000 0.800 0.000
#> ERR519481     6  0.1075     0.8922 0.000  0 0.000 0.000 0.048 0.952
#> ERR519491     1  0.0405     0.9655 0.988  0 0.000 0.008 0.000 0.004
#> ERR519473     6  0.1556     0.9176 0.000  0 0.000 0.000 0.080 0.920
#> ERR519518     4  0.3522     0.7500 0.000  0 0.000 0.800 0.128 0.072
#> ERR519512     4  0.0000     0.8674 0.000  0 0.000 1.000 0.000 0.000
#> ERR519521     4  0.0260     0.8675 0.000  0 0.000 0.992 0.000 0.008
#> ERR519488     1  0.0146     0.9665 0.996  0 0.000 0.000 0.000 0.004
#> ERR519493     5  0.2261     0.7652 0.104  0 0.000 0.008 0.884 0.004
#> ERR519514     1  0.0000     0.9672 1.000  0 0.000 0.000 0.000 0.000
#> ERR519479     5  0.0363     0.8272 0.000  0 0.000 0.000 0.988 0.012
#> ERR519509     1  0.0146     0.9665 0.996  0 0.000 0.000 0.000 0.004
#> ERR519472     6  0.1588     0.9156 0.004  0 0.000 0.000 0.072 0.924
#> ERR519510     5  0.0260     0.8289 0.000  0 0.000 0.008 0.992 0.000
#> ERR519470     1  0.0000     0.9672 1.000  0 0.000 0.000 0.000 0.000
#> ERR519495     1  0.1584     0.9113 0.928  0 0.000 0.000 0.008 0.064
#> ERR519522     1  0.0146     0.9665 0.996  0 0.000 0.000 0.000 0.004
#> ERR519523     4  0.1226     0.8600 0.004  0 0.000 0.952 0.040 0.004
#> ERR519503     1  0.0146     0.9665 0.996  0 0.000 0.000 0.000 0.004
#> ERR519471     1  0.0405     0.9655 0.988  0 0.000 0.008 0.000 0.004
#> ERR519500     4  0.1327     0.8535 0.000  0 0.000 0.936 0.000 0.064
#> ERR519485     1  0.0405     0.9655 0.988  0 0.000 0.008 0.000 0.004
#> ERR519476     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000 0.000
#> ERR519502     5  0.3607     0.4592 0.000  0 0.000 0.000 0.652 0.348
#> ERR519486     5  0.3152     0.6822 0.196  0 0.000 0.008 0.792 0.004
#> ERR519478     1  0.0000     0.9672 1.000  0 0.000 0.000 0.000 0.000
#> ERR519497     4  0.4687     0.5285 0.000  0 0.000 0.624 0.308 0.068
#> ERR519467     1  0.1863     0.8792 0.896  0 0.000 0.104 0.000 0.000
#> ERR519489     4  0.1327     0.8535 0.000  0 0.000 0.936 0.000 0.064
#> ERR519494     6  0.3707     0.7576 0.000  0 0.080 0.000 0.136 0.784
#> ERR519474     5  0.0881     0.8288 0.008  0 0.000 0.008 0.972 0.012
#> ERR519505     5  0.1663     0.8068 0.000  0 0.088 0.000 0.912 0.000
#> ERR519517     3  0.0000     0.9000 0.000  0 1.000 0.000 0.000 0.000
#> ERR519484     5  0.0000     0.8289 0.000  0 0.000 0.000 1.000 0.000
#> ERR519498     5  0.2793     0.7451 0.000  0 0.200 0.000 0.800 0.000
#> ERR519490     3  0.2980     0.8348 0.000  0 0.800 0.000 0.008 0.192
#> ERR519507     5  0.3847     0.0922 0.000  0 0.000 0.000 0.544 0.456
#> ERR519511     5  0.0000     0.8289 0.000  0 0.000 0.000 1.000 0.000
#> ERR519468     3  0.2378     0.8646 0.000  0 0.848 0.000 0.000 0.152
#> ERR519482     3  0.2730     0.8424 0.000  0 0.808 0.000 0.000 0.192
#> ERR519475     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000 0.000
#> ERR519496     1  0.0405     0.9655 0.988  0 0.000 0.008 0.000 0.004
#> ERR519506     5  0.1867     0.7968 0.020  0 0.000 0.000 0.916 0.064
#> ERR519469     6  0.1644     0.9182 0.004  0 0.000 0.000 0.076 0.920
#> ERR519480     3  0.0000     0.9000 0.000  0 1.000 0.000 0.000 0.000
#> ERR519487     3  0.0000     0.9000 0.000  0 1.000 0.000 0.000 0.000
#> ERR519483     1  0.0405     0.9655 0.988  0 0.000 0.008 0.000 0.004
#> ERR519477     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000 0.000
#> ERR519499     3  0.0000     0.9000 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-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 18140 rows and 52 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 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-mclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.998       0.999         0.1137 0.889   0.889
#> 3 3 0.322           0.473       0.733         3.3337 0.548   0.491
#> 4 4 0.603           0.790       0.866         0.3488 0.687   0.406
#> 5 5 0.546           0.644       0.779         0.0850 0.955   0.851
#> 6 6 0.581           0.478       0.746         0.0637 0.867   0.556

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
#> ERR519515     1  0.0000      0.999 1.000 0.000
#> ERR519516     1  0.0000      0.999 1.000 0.000
#> ERR519520     1  0.0000      0.999 1.000 0.000
#> ERR519513     1  0.0000      0.999 1.000 0.000
#> ERR519481     1  0.0000      0.999 1.000 0.000
#> ERR519491     1  0.0000      0.999 1.000 0.000
#> ERR519473     1  0.0000      0.999 1.000 0.000
#> ERR519518     1  0.0000      0.999 1.000 0.000
#> ERR519512     1  0.0000      0.999 1.000 0.000
#> ERR519521     1  0.0000      0.999 1.000 0.000
#> ERR519488     1  0.3114      0.941 0.944 0.056
#> ERR519493     1  0.0000      0.999 1.000 0.000
#> ERR519514     1  0.0000      0.999 1.000 0.000
#> ERR519479     1  0.0000      0.999 1.000 0.000
#> ERR519509     1  0.0376      0.995 0.996 0.004
#> ERR519472     1  0.0000      0.999 1.000 0.000
#> ERR519510     1  0.0000      0.999 1.000 0.000
#> ERR519470     1  0.0000      0.999 1.000 0.000
#> ERR519495     1  0.0000      0.999 1.000 0.000
#> ERR519522     1  0.0000      0.999 1.000 0.000
#> ERR519523     1  0.0000      0.999 1.000 0.000
#> ERR519503     1  0.0000      0.999 1.000 0.000
#> ERR519471     1  0.0000      0.999 1.000 0.000
#> ERR519500     1  0.0000      0.999 1.000 0.000
#> ERR519485     1  0.0000      0.999 1.000 0.000
#> ERR519476     2  0.0000      1.000 0.000 1.000
#> ERR519502     1  0.0000      0.999 1.000 0.000
#> ERR519486     1  0.0000      0.999 1.000 0.000
#> ERR519478     1  0.0000      0.999 1.000 0.000
#> ERR519497     1  0.0000      0.999 1.000 0.000
#> ERR519467     1  0.0000      0.999 1.000 0.000
#> ERR519489     1  0.0000      0.999 1.000 0.000
#> ERR519494     1  0.0000      0.999 1.000 0.000
#> ERR519474     1  0.0000      0.999 1.000 0.000
#> ERR519505     1  0.0000      0.999 1.000 0.000
#> ERR519517     1  0.0000      0.999 1.000 0.000
#> ERR519484     1  0.0000      0.999 1.000 0.000
#> ERR519498     1  0.0000      0.999 1.000 0.000
#> ERR519490     1  0.0000      0.999 1.000 0.000
#> ERR519507     1  0.0000      0.999 1.000 0.000
#> ERR519511     1  0.0000      0.999 1.000 0.000
#> ERR519468     1  0.0000      0.999 1.000 0.000
#> ERR519482     1  0.0000      0.999 1.000 0.000
#> ERR519475     2  0.0000      1.000 0.000 1.000
#> ERR519496     1  0.0000      0.999 1.000 0.000
#> ERR519506     1  0.0000      0.999 1.000 0.000
#> ERR519469     1  0.0000      0.999 1.000 0.000
#> ERR519480     1  0.0000      0.999 1.000 0.000
#> ERR519487     1  0.0000      0.999 1.000 0.000
#> ERR519483     1  0.0000      0.999 1.000 0.000
#> ERR519477     2  0.0000      1.000 0.000 1.000
#> ERR519499     1  0.0000      0.999 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1 p2    p3
#> ERR519515     1   0.141     0.6469 0.964  0 0.036
#> ERR519516     1   0.304     0.6203 0.896  0 0.104
#> ERR519520     3   0.565     0.5053 0.312  0 0.688
#> ERR519513     3   0.000     0.6629 0.000  0 1.000
#> ERR519481     3   0.630     0.1199 0.484  0 0.516
#> ERR519491     1   0.141     0.6469 0.964  0 0.036
#> ERR519473     3   0.630     0.1199 0.484  0 0.516
#> ERR519518     3   0.412     0.6916 0.168  0 0.832
#> ERR519512     3   0.460     0.6667 0.204  0 0.796
#> ERR519521     3   0.418     0.6889 0.172  0 0.828
#> ERR519488     1   0.312     0.6211 0.892  0 0.108
#> ERR519493     1   0.141     0.6469 0.964  0 0.036
#> ERR519514     1   0.141     0.6469 0.964  0 0.036
#> ERR519479     1   0.630    -0.1257 0.520  0 0.480
#> ERR519509     1   0.226     0.6394 0.932  0 0.068
#> ERR519472     1   0.630    -0.1257 0.520  0 0.480
#> ERR519510     1   0.630    -0.1069 0.528  0 0.472
#> ERR519470     1   0.141     0.6469 0.964  0 0.036
#> ERR519495     1   0.619     0.0163 0.580  0 0.420
#> ERR519522     1   0.604     0.2344 0.620  0 0.380
#> ERR519523     3   0.522     0.5998 0.260  0 0.740
#> ERR519503     1   0.624     0.1207 0.560  0 0.440
#> ERR519471     1   0.141     0.6469 0.964  0 0.036
#> ERR519500     1   0.630    -0.1257 0.520  0 0.480
#> ERR519485     1   0.141     0.6469 0.964  0 0.036
#> ERR519476     2   0.000     1.0000 0.000  1 0.000
#> ERR519502     3   0.630     0.1199 0.484  0 0.516
#> ERR519486     1   0.312     0.6211 0.892  0 0.108
#> ERR519478     1   0.141     0.6469 0.964  0 0.036
#> ERR519497     3   0.412     0.6916 0.168  0 0.832
#> ERR519467     1   0.597     0.2514 0.636  0 0.364
#> ERR519489     3   0.590     0.4367 0.352  0 0.648
#> ERR519494     3   0.236     0.7021 0.072  0 0.928
#> ERR519474     1   0.597     0.1772 0.636  0 0.364
#> ERR519505     3   0.312     0.6995 0.108  0 0.892
#> ERR519517     3   0.000     0.6629 0.000  0 1.000
#> ERR519484     3   0.631     0.1136 0.488  0 0.512
#> ERR519498     3   0.288     0.6969 0.096  0 0.904
#> ERR519490     3   0.236     0.7021 0.072  0 0.928
#> ERR519507     1   0.630    -0.1257 0.520  0 0.480
#> ERR519511     1   0.630    -0.1257 0.520  0 0.480
#> ERR519468     3   0.236     0.7021 0.072  0 0.928
#> ERR519482     3   0.236     0.7021 0.072  0 0.928
#> ERR519475     2   0.000     1.0000 0.000  1 0.000
#> ERR519496     1   0.319     0.6143 0.888  0 0.112
#> ERR519506     3   0.630     0.1501 0.472  0 0.528
#> ERR519469     3   0.412     0.6916 0.168  0 0.832
#> ERR519480     3   0.000     0.6629 0.000  0 1.000
#> ERR519487     3   0.000     0.6629 0.000  0 1.000
#> ERR519483     3   0.631     0.1009 0.492  0 0.508
#> ERR519477     2   0.000     1.0000 0.000  1 0.000
#> ERR519499     3   0.000     0.6629 0.000  0 1.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1 p2    p3    p4
#> ERR519515     1  0.0188      0.900 0.996  0 0.004 0.000
#> ERR519516     1  0.1211      0.897 0.960  0 0.000 0.040
#> ERR519520     1  0.5901      0.479 0.652  0 0.068 0.280
#> ERR519513     3  0.1940      0.703 0.000  0 0.924 0.076
#> ERR519481     4  0.1867      0.848 0.000  0 0.072 0.928
#> ERR519491     1  0.0817      0.900 0.976  0 0.000 0.024
#> ERR519473     4  0.2521      0.867 0.024  0 0.064 0.912
#> ERR519518     4  0.4713      0.253 0.000  0 0.360 0.640
#> ERR519512     4  0.5056      0.725 0.164  0 0.076 0.760
#> ERR519521     4  0.3383      0.844 0.052  0 0.076 0.872
#> ERR519488     1  0.2530      0.870 0.896  0 0.100 0.004
#> ERR519493     1  0.1022      0.900 0.968  0 0.000 0.032
#> ERR519514     1  0.0592      0.902 0.984  0 0.000 0.016
#> ERR519479     4  0.0817      0.864 0.024  0 0.000 0.976
#> ERR519509     1  0.2530      0.870 0.896  0 0.100 0.004
#> ERR519472     4  0.0921      0.863 0.028  0 0.000 0.972
#> ERR519510     4  0.2586      0.864 0.048  0 0.040 0.912
#> ERR519470     1  0.1118      0.894 0.964  0 0.036 0.000
#> ERR519495     4  0.2530      0.799 0.112  0 0.000 0.888
#> ERR519522     1  0.2530      0.870 0.896  0 0.100 0.004
#> ERR519523     4  0.4188      0.795 0.148  0 0.040 0.812
#> ERR519503     1  0.2654      0.862 0.888  0 0.108 0.004
#> ERR519471     1  0.0592      0.902 0.984  0 0.000 0.016
#> ERR519500     4  0.1118      0.860 0.036  0 0.000 0.964
#> ERR519485     1  0.0817      0.900 0.976  0 0.000 0.024
#> ERR519476     2  0.0000      1.000 0.000  1 0.000 0.000
#> ERR519502     4  0.1557      0.854 0.000  0 0.056 0.944
#> ERR519486     1  0.1305      0.900 0.960  0 0.004 0.036
#> ERR519478     1  0.1305      0.894 0.960  0 0.036 0.004
#> ERR519497     4  0.3899      0.819 0.052  0 0.108 0.840
#> ERR519467     1  0.0188      0.901 0.996  0 0.004 0.000
#> ERR519489     4  0.1929      0.873 0.024  0 0.036 0.940
#> ERR519494     3  0.4746      0.610 0.000  0 0.632 0.368
#> ERR519474     4  0.2345      0.847 0.100  0 0.000 0.900
#> ERR519505     3  0.7814      0.257 0.304  0 0.416 0.280
#> ERR519517     3  0.2973      0.728 0.000  0 0.856 0.144
#> ERR519484     4  0.1118      0.854 0.000  0 0.036 0.964
#> ERR519498     3  0.6188      0.259 0.056  0 0.548 0.396
#> ERR519490     3  0.4564      0.669 0.000  0 0.672 0.328
#> ERR519507     4  0.1406      0.866 0.024  0 0.016 0.960
#> ERR519511     4  0.1022      0.856 0.000  0 0.032 0.968
#> ERR519468     3  0.4250      0.711 0.000  0 0.724 0.276
#> ERR519482     3  0.4564      0.669 0.000  0 0.672 0.328
#> ERR519475     2  0.0000      1.000 0.000  1 0.000 0.000
#> ERR519496     1  0.4679      0.418 0.648  0 0.000 0.352
#> ERR519506     4  0.3421      0.856 0.088  0 0.044 0.868
#> ERR519469     4  0.3301      0.858 0.076  0 0.048 0.876
#> ERR519480     3  0.2408      0.720 0.000  0 0.896 0.104
#> ERR519487     3  0.1940      0.703 0.000  0 0.924 0.076
#> ERR519483     4  0.4188      0.805 0.148  0 0.040 0.812
#> ERR519477     2  0.0000      1.000 0.000  1 0.000 0.000
#> ERR519499     3  0.1940      0.703 0.000  0 0.924 0.076

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1 p2    p3    p4    p5
#> ERR519515     1  0.0162     0.7677 0.996  0 0.000 0.000 0.004
#> ERR519516     1  0.1787     0.7629 0.936  0 0.004 0.044 0.016
#> ERR519520     5  0.8385    -0.0935 0.172  0 0.212 0.260 0.356
#> ERR519513     3  0.2648     0.6568 0.000  0 0.848 0.000 0.152
#> ERR519481     4  0.5067     0.7231 0.000  0 0.128 0.700 0.172
#> ERR519491     1  0.0510     0.7748 0.984  0 0.000 0.016 0.000
#> ERR519473     4  0.5456     0.7409 0.028  0 0.120 0.708 0.144
#> ERR519518     4  0.6673     0.1681 0.000  0 0.316 0.432 0.252
#> ERR519512     4  0.7270     0.5924 0.080  0 0.192 0.536 0.192
#> ERR519521     4  0.5814     0.6741 0.008  0 0.176 0.640 0.176
#> ERR519488     5  0.3916     0.6770 0.256  0 0.000 0.012 0.732
#> ERR519493     1  0.1774     0.7600 0.932  0 0.000 0.052 0.016
#> ERR519514     1  0.0404     0.7727 0.988  0 0.000 0.012 0.000
#> ERR519479     4  0.1485     0.7161 0.032  0 0.000 0.948 0.020
#> ERR519509     5  0.4040     0.6516 0.276  0 0.000 0.012 0.712
#> ERR519472     4  0.1648     0.7154 0.040  0 0.000 0.940 0.020
#> ERR519510     4  0.3067     0.7049 0.012  0 0.140 0.844 0.004
#> ERR519470     1  0.2424     0.6669 0.868  0 0.000 0.000 0.132
#> ERR519495     4  0.2130     0.7058 0.080  0 0.000 0.908 0.012
#> ERR519522     5  0.3863     0.6777 0.248  0 0.000 0.012 0.740
#> ERR519523     4  0.5794     0.7248 0.096  0 0.052 0.688 0.164
#> ERR519503     5  0.5355     0.5832 0.316  0 0.044 0.016 0.624
#> ERR519471     1  0.0566     0.7733 0.984  0 0.000 0.012 0.004
#> ERR519500     4  0.2409     0.7139 0.056  0 0.008 0.908 0.028
#> ERR519485     1  0.0609     0.7749 0.980  0 0.000 0.020 0.000
#> ERR519476     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000
#> ERR519502     4  0.4922     0.7196 0.000  0 0.128 0.716 0.156
#> ERR519486     1  0.5719     0.2738 0.596  0 0.000 0.284 0.120
#> ERR519478     1  0.2179     0.6961 0.888  0 0.000 0.000 0.112
#> ERR519497     4  0.6191     0.5649 0.004  0 0.252 0.568 0.176
#> ERR519467     1  0.5854     0.2166 0.596  0 0.000 0.152 0.252
#> ERR519489     4  0.5592     0.7408 0.048  0 0.088 0.704 0.160
#> ERR519494     3  0.6571     0.4104 0.000  0 0.472 0.268 0.260
#> ERR519474     4  0.2248     0.7067 0.088  0 0.000 0.900 0.012
#> ERR519505     3  0.6795     0.2558 0.012  0 0.488 0.224 0.276
#> ERR519517     3  0.1205     0.6662 0.000  0 0.956 0.040 0.004
#> ERR519484     4  0.4233     0.7388 0.008  0 0.084 0.792 0.116
#> ERR519498     3  0.6228     0.3261 0.004  0 0.568 0.228 0.200
#> ERR519490     3  0.6120     0.5406 0.000  0 0.564 0.240 0.196
#> ERR519507     4  0.1967     0.7190 0.036  0 0.012 0.932 0.020
#> ERR519511     4  0.2899     0.7259 0.008  0 0.076 0.880 0.036
#> ERR519468     3  0.4334     0.6548 0.000  0 0.768 0.140 0.092
#> ERR519482     3  0.5911     0.5707 0.000  0 0.596 0.228 0.176
#> ERR519475     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000
#> ERR519496     1  0.4268     0.3472 0.648  0 0.000 0.344 0.008
#> ERR519506     4  0.4892     0.7574 0.052  0 0.052 0.760 0.136
#> ERR519469     4  0.4385     0.7528 0.020  0 0.044 0.776 0.160
#> ERR519480     3  0.1386     0.6723 0.000  0 0.952 0.016 0.032
#> ERR519487     3  0.0609     0.6396 0.000  0 0.980 0.000 0.020
#> ERR519483     4  0.5348     0.7420 0.096  0 0.044 0.728 0.132
#> ERR519477     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000
#> ERR519499     3  0.0609     0.6396 0.000  0 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
#> ERR519515     1  0.0000     0.8519 1.000  0 0.000 0.000 0.000 0.000
#> ERR519516     1  0.1370     0.8462 0.948  0 0.004 0.000 0.036 0.012
#> ERR519520     4  0.7068     0.1684 0.040  0 0.048 0.504 0.224 0.184
#> ERR519513     4  0.1867    -0.0504 0.000  0 0.064 0.916 0.000 0.020
#> ERR519481     5  0.6194     0.3277 0.020  0 0.188 0.316 0.476 0.000
#> ERR519491     1  0.0260     0.8537 0.992  0 0.000 0.000 0.008 0.000
#> ERR519473     5  0.4093     0.4681 0.008  0 0.012 0.324 0.656 0.000
#> ERR519518     4  0.6054     0.0841 0.000  0 0.236 0.484 0.272 0.008
#> ERR519512     4  0.6920     0.0958 0.040  0 0.088 0.500 0.300 0.072
#> ERR519521     4  0.6028    -0.0251 0.032  0 0.092 0.508 0.360 0.008
#> ERR519488     6  0.1686     0.8444 0.064  0 0.000 0.012 0.000 0.924
#> ERR519493     1  0.1010     0.8474 0.960  0 0.000 0.000 0.036 0.004
#> ERR519514     1  0.0146     0.8529 0.996  0 0.000 0.000 0.004 0.000
#> ERR519479     5  0.0260     0.6298 0.008  0 0.000 0.000 0.992 0.000
#> ERR519509     6  0.1501     0.8365 0.076  0 0.000 0.000 0.000 0.924
#> ERR519472     5  0.0260     0.6298 0.008  0 0.000 0.000 0.992 0.000
#> ERR519510     5  0.5058     0.4716 0.020  0 0.092 0.176 0.700 0.012
#> ERR519470     1  0.2562     0.7409 0.828  0 0.000 0.000 0.000 0.172
#> ERR519495     5  0.0547     0.6306 0.020  0 0.000 0.000 0.980 0.000
#> ERR519522     6  0.1983     0.8430 0.072  0 0.000 0.020 0.000 0.908
#> ERR519523     4  0.7113    -0.1610 0.164  0 0.072 0.384 0.368 0.012
#> ERR519503     6  0.4871     0.5462 0.132  0 0.000 0.212 0.000 0.656
#> ERR519471     1  0.0291     0.8525 0.992  0 0.000 0.004 0.004 0.000
#> ERR519500     5  0.2313     0.6007 0.100  0 0.012 0.000 0.884 0.004
#> ERR519485     1  0.0520     0.8513 0.984  0 0.000 0.000 0.008 0.008
#> ERR519476     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000 0.000
#> ERR519502     5  0.6263     0.2439 0.012  0 0.236 0.324 0.428 0.000
#> ERR519486     1  0.5189     0.5122 0.676  0 0.000 0.072 0.200 0.052
#> ERR519478     1  0.2482     0.7663 0.848  0 0.000 0.000 0.004 0.148
#> ERR519497     4  0.6023     0.1264 0.000  0 0.092 0.548 0.300 0.060
#> ERR519467     1  0.5675     0.5055 0.640  0 0.000 0.096 0.072 0.192
#> ERR519489     4  0.6388    -0.2302 0.096  0 0.060 0.420 0.420 0.004
#> ERR519494     3  0.3464     0.5866 0.000  0 0.688 0.312 0.000 0.000
#> ERR519474     5  0.1036     0.6293 0.024  0 0.000 0.004 0.964 0.008
#> ERR519505     4  0.3595     0.2473 0.000  0 0.000 0.796 0.120 0.084
#> ERR519517     4  0.4812    -0.1252 0.000  0 0.344 0.588 0.000 0.068
#> ERR519484     5  0.5461     0.4592 0.004  0 0.196 0.208 0.592 0.000
#> ERR519498     4  0.3332     0.2657 0.000  0 0.000 0.808 0.144 0.048
#> ERR519490     3  0.4311     0.6344 0.004  0 0.708 0.228 0.060 0.000
#> ERR519507     5  0.0653     0.6330 0.012  0 0.004 0.004 0.980 0.000
#> ERR519511     5  0.3560     0.5888 0.064  0 0.040 0.056 0.836 0.004
#> ERR519468     3  0.5040     0.2588 0.000  0 0.552 0.380 0.008 0.060
#> ERR519482     3  0.2793     0.6566 0.000  0 0.800 0.200 0.000 0.000
#> ERR519475     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000 0.000
#> ERR519496     1  0.2894     0.7532 0.852  0 0.000 0.036 0.108 0.004
#> ERR519506     5  0.4580     0.3953 0.028  0 0.004 0.368 0.596 0.004
#> ERR519469     5  0.4868     0.3229 0.004  0 0.044 0.384 0.564 0.004
#> ERR519480     4  0.4515    -0.2214 0.000  0 0.304 0.640 0.000 0.056
#> ERR519487     4  0.4718    -0.1042 0.000  0 0.316 0.616 0.000 0.068
#> ERR519483     5  0.4647     0.3929 0.032  0 0.004 0.368 0.592 0.004
#> ERR519477     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000 0.000
#> ERR519499     4  0.4718    -0.1042 0.000  0 0.316 0.616 0.000 0.068

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 18140 rows and 52 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.737           0.884       0.951         0.5050 0.491   0.491
#> 3 3 0.528           0.764       0.867         0.3154 0.718   0.487
#> 4 4 0.576           0.657       0.812         0.1295 0.835   0.551
#> 5 5 0.592           0.563       0.761         0.0598 0.897   0.625
#> 6 6 0.650           0.551       0.747         0.0341 0.931   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
#> ERR519515     2  0.0000     0.9607 0.000 1.000
#> ERR519516     2  0.0376     0.9576 0.004 0.996
#> ERR519520     2  0.0000     0.9607 0.000 1.000
#> ERR519513     1  0.0000     0.9293 1.000 0.000
#> ERR519481     1  0.0000     0.9293 1.000 0.000
#> ERR519491     2  0.0000     0.9607 0.000 1.000
#> ERR519473     1  0.0000     0.9293 1.000 0.000
#> ERR519518     1  0.0000     0.9293 1.000 0.000
#> ERR519512     2  0.0000     0.9607 0.000 1.000
#> ERR519521     1  0.7883     0.7212 0.764 0.236
#> ERR519488     2  0.0000     0.9607 0.000 1.000
#> ERR519493     2  0.0000     0.9607 0.000 1.000
#> ERR519514     2  0.0000     0.9607 0.000 1.000
#> ERR519479     2  0.9963     0.0348 0.464 0.536
#> ERR519509     2  0.0000     0.9607 0.000 1.000
#> ERR519472     1  0.5946     0.8305 0.856 0.144
#> ERR519510     1  0.9896     0.2606 0.560 0.440
#> ERR519470     2  0.0000     0.9607 0.000 1.000
#> ERR519495     2  0.0000     0.9607 0.000 1.000
#> ERR519522     2  0.0000     0.9607 0.000 1.000
#> ERR519523     2  0.0000     0.9607 0.000 1.000
#> ERR519503     2  0.0000     0.9607 0.000 1.000
#> ERR519471     2  0.0000     0.9607 0.000 1.000
#> ERR519500     2  0.8955     0.4868 0.312 0.688
#> ERR519485     2  0.0000     0.9607 0.000 1.000
#> ERR519476     2  0.0000     0.9607 0.000 1.000
#> ERR519502     1  0.0000     0.9293 1.000 0.000
#> ERR519486     2  0.0000     0.9607 0.000 1.000
#> ERR519478     2  0.0000     0.9607 0.000 1.000
#> ERR519497     1  0.0000     0.9293 1.000 0.000
#> ERR519467     2  0.0000     0.9607 0.000 1.000
#> ERR519489     1  0.5519     0.8345 0.872 0.128
#> ERR519494     1  0.0000     0.9293 1.000 0.000
#> ERR519474     2  0.0376     0.9576 0.004 0.996
#> ERR519505     1  0.0000     0.9293 1.000 0.000
#> ERR519517     1  0.0000     0.9293 1.000 0.000
#> ERR519484     1  0.0000     0.9293 1.000 0.000
#> ERR519498     1  0.0000     0.9293 1.000 0.000
#> ERR519490     1  0.0000     0.9293 1.000 0.000
#> ERR519507     1  0.6438     0.8102 0.836 0.164
#> ERR519511     1  0.7674     0.7386 0.776 0.224
#> ERR519468     1  0.0000     0.9293 1.000 0.000
#> ERR519482     1  0.0000     0.9293 1.000 0.000
#> ERR519475     2  0.3274     0.9022 0.060 0.940
#> ERR519496     2  0.0000     0.9607 0.000 1.000
#> ERR519506     1  0.0000     0.9293 1.000 0.000
#> ERR519469     1  0.0000     0.9293 1.000 0.000
#> ERR519480     1  0.0000     0.9293 1.000 0.000
#> ERR519487     1  0.0000     0.9293 1.000 0.000
#> ERR519483     1  0.6801     0.7779 0.820 0.180
#> ERR519477     1  0.7139     0.7758 0.804 0.196
#> ERR519499     1  0.0000     0.9293 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
#> ERR519515     2  0.1860      0.854 0.052 0.948 0.000
#> ERR519516     1  0.6724      0.131 0.568 0.420 0.012
#> ERR519520     2  0.2165      0.827 0.000 0.936 0.064
#> ERR519513     3  0.2356      0.878 0.072 0.000 0.928
#> ERR519481     1  0.1860      0.827 0.948 0.000 0.052
#> ERR519491     2  0.5678      0.617 0.316 0.684 0.000
#> ERR519473     1  0.1411      0.836 0.964 0.000 0.036
#> ERR519518     3  0.3879      0.846 0.152 0.000 0.848
#> ERR519512     2  0.1411      0.840 0.000 0.964 0.036
#> ERR519521     1  0.4099      0.780 0.852 0.008 0.140
#> ERR519488     2  0.0592      0.848 0.000 0.988 0.012
#> ERR519493     2  0.6095      0.459 0.392 0.608 0.000
#> ERR519514     2  0.3038      0.839 0.104 0.896 0.000
#> ERR519479     1  0.1182      0.843 0.976 0.012 0.012
#> ERR519509     2  0.0237      0.850 0.000 0.996 0.004
#> ERR519472     1  0.1163      0.838 0.972 0.028 0.000
#> ERR519510     1  0.6420      0.568 0.688 0.024 0.288
#> ERR519470     2  0.1529      0.855 0.040 0.960 0.000
#> ERR519495     1  0.3038      0.790 0.896 0.104 0.000
#> ERR519522     2  0.0892      0.855 0.020 0.980 0.000
#> ERR519523     2  0.5760      0.592 0.328 0.672 0.000
#> ERR519503     2  0.4002      0.751 0.000 0.840 0.160
#> ERR519471     2  0.3482      0.828 0.128 0.872 0.000
#> ERR519500     1  0.2096      0.833 0.944 0.052 0.004
#> ERR519485     1  0.6308     -0.166 0.508 0.492 0.000
#> ERR519476     2  0.6389      0.752 0.124 0.768 0.108
#> ERR519502     1  0.4002      0.750 0.840 0.000 0.160
#> ERR519486     2  0.3340      0.835 0.120 0.880 0.000
#> ERR519478     2  0.1031      0.855 0.024 0.976 0.000
#> ERR519497     3  0.1031      0.873 0.024 0.000 0.976
#> ERR519467     2  0.1163      0.856 0.028 0.972 0.000
#> ERR519489     1  0.2804      0.831 0.924 0.016 0.060
#> ERR519494     3  0.5905      0.611 0.352 0.000 0.648
#> ERR519474     1  0.3412      0.770 0.876 0.124 0.000
#> ERR519505     3  0.2301      0.831 0.004 0.060 0.936
#> ERR519517     3  0.1643      0.880 0.044 0.000 0.956
#> ERR519484     1  0.2066      0.825 0.940 0.000 0.060
#> ERR519498     3  0.1453      0.852 0.008 0.024 0.968
#> ERR519490     3  0.5098      0.768 0.248 0.000 0.752
#> ERR519507     1  0.1015      0.842 0.980 0.008 0.012
#> ERR519511     1  0.2945      0.811 0.908 0.004 0.088
#> ERR519468     3  0.3941      0.845 0.156 0.000 0.844
#> ERR519482     3  0.4931      0.786 0.232 0.000 0.768
#> ERR519475     2  0.8030      0.624 0.144 0.652 0.204
#> ERR519496     2  0.4504      0.775 0.196 0.804 0.000
#> ERR519506     1  0.1315      0.840 0.972 0.008 0.020
#> ERR519469     1  0.3989      0.761 0.864 0.012 0.124
#> ERR519480     3  0.2066      0.879 0.060 0.000 0.940
#> ERR519487     3  0.1289      0.878 0.032 0.000 0.968
#> ERR519483     1  0.3263      0.828 0.912 0.048 0.040
#> ERR519477     3  0.7104      0.668 0.140 0.136 0.724
#> ERR519499     3  0.1289      0.878 0.032 0.000 0.968

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> ERR519515     1  0.1174     0.8551 0.968 0.012 0.000 0.020
#> ERR519516     2  0.5954     0.2960 0.052 0.604 0.000 0.344
#> ERR519520     1  0.3764     0.7567 0.816 0.172 0.012 0.000
#> ERR519513     2  0.4697     0.3581 0.000 0.644 0.356 0.000
#> ERR519481     4  0.3547     0.7193 0.000 0.144 0.016 0.840
#> ERR519491     1  0.5650     0.6316 0.716 0.180 0.000 0.104
#> ERR519473     4  0.1151     0.7776 0.000 0.008 0.024 0.968
#> ERR519518     3  0.2546     0.7997 0.000 0.028 0.912 0.060
#> ERR519512     1  0.4034     0.7537 0.796 0.192 0.004 0.008
#> ERR519521     4  0.5509     0.2770 0.004 0.424 0.012 0.560
#> ERR519488     1  0.1576     0.8409 0.948 0.048 0.004 0.000
#> ERR519493     2  0.4656     0.6320 0.072 0.792 0.000 0.136
#> ERR519514     1  0.1406     0.8543 0.960 0.016 0.000 0.024
#> ERR519479     4  0.4098     0.6583 0.012 0.204 0.000 0.784
#> ERR519509     1  0.1022     0.8491 0.968 0.032 0.000 0.000
#> ERR519472     4  0.1042     0.7863 0.008 0.020 0.000 0.972
#> ERR519510     2  0.2676     0.6379 0.000 0.896 0.092 0.012
#> ERR519470     1  0.1174     0.8551 0.968 0.012 0.000 0.020
#> ERR519495     4  0.4592     0.7315 0.128 0.064 0.004 0.804
#> ERR519522     1  0.0895     0.8548 0.976 0.020 0.000 0.004
#> ERR519523     1  0.5576     0.6471 0.720 0.096 0.000 0.184
#> ERR519503     1  0.2363     0.8271 0.920 0.024 0.056 0.000
#> ERR519471     1  0.1356     0.8535 0.960 0.008 0.000 0.032
#> ERR519500     4  0.1229     0.7836 0.004 0.020 0.008 0.968
#> ERR519485     1  0.5540     0.6451 0.720 0.068 0.004 0.208
#> ERR519476     1  0.8230     0.0704 0.428 0.372 0.032 0.168
#> ERR519502     2  0.4353     0.6052 0.000 0.756 0.012 0.232
#> ERR519486     2  0.5359     0.4845 0.288 0.680 0.004 0.028
#> ERR519478     1  0.0524     0.8561 0.988 0.004 0.000 0.008
#> ERR519497     3  0.5407     0.1376 0.012 0.484 0.504 0.000
#> ERR519467     1  0.0927     0.8558 0.976 0.016 0.000 0.008
#> ERR519489     4  0.3436     0.7296 0.008 0.016 0.112 0.864
#> ERR519494     3  0.3577     0.7410 0.000 0.012 0.832 0.156
#> ERR519474     4  0.3959     0.7512 0.092 0.068 0.000 0.840
#> ERR519505     2  0.3610     0.5635 0.000 0.800 0.200 0.000
#> ERR519517     3  0.0657     0.8097 0.000 0.004 0.984 0.012
#> ERR519484     2  0.5073     0.6204 0.000 0.744 0.056 0.200
#> ERR519498     2  0.4103     0.5140 0.000 0.744 0.256 0.000
#> ERR519490     3  0.4295     0.6638 0.000 0.008 0.752 0.240
#> ERR519507     4  0.2940     0.7722 0.008 0.088 0.012 0.892
#> ERR519511     2  0.5835     0.3752 0.000 0.588 0.040 0.372
#> ERR519468     3  0.0817     0.8106 0.000 0.000 0.976 0.024
#> ERR519482     3  0.2589     0.7800 0.000 0.000 0.884 0.116
#> ERR519475     2  0.8857     0.0404 0.356 0.408 0.084 0.152
#> ERR519496     1  0.2246     0.8419 0.928 0.016 0.004 0.052
#> ERR519506     4  0.3562     0.7596 0.084 0.016 0.028 0.872
#> ERR519469     4  0.6094     0.6200 0.084 0.012 0.212 0.692
#> ERR519480     3  0.0469     0.8075 0.000 0.012 0.988 0.000
#> ERR519487     3  0.1118     0.7986 0.000 0.036 0.964 0.000
#> ERR519483     4  0.6358     0.6270 0.164 0.020 0.120 0.696
#> ERR519477     3  0.8075     0.0309 0.048 0.412 0.428 0.112
#> ERR519499     3  0.0336     0.8080 0.000 0.008 0.992 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
#> ERR519515     1  0.0771     0.7823 0.976 0.020 0.000 0.000 0.004
#> ERR519516     5  0.7833    -0.0477 0.068 0.244 0.000 0.332 0.356
#> ERR519520     1  0.5094     0.4145 0.616 0.344 0.004 0.004 0.032
#> ERR519513     5  0.3242     0.5891 0.000 0.012 0.172 0.000 0.816
#> ERR519481     4  0.2102     0.6482 0.000 0.004 0.012 0.916 0.068
#> ERR519491     1  0.4277     0.6379 0.808 0.044 0.000 0.052 0.096
#> ERR519473     4  0.1377     0.6470 0.000 0.020 0.020 0.956 0.004
#> ERR519518     3  0.3441     0.8508 0.000 0.004 0.828 0.140 0.028
#> ERR519512     1  0.5759     0.3824 0.588 0.328 0.000 0.016 0.068
#> ERR519521     4  0.5965     0.4346 0.004 0.220 0.004 0.620 0.152
#> ERR519488     1  0.1892     0.7661 0.916 0.080 0.004 0.000 0.000
#> ERR519493     5  0.3309     0.5841 0.052 0.032 0.000 0.048 0.868
#> ERR519514     1  0.1560     0.7731 0.948 0.028 0.000 0.020 0.004
#> ERR519479     4  0.6186     0.3957 0.004 0.148 0.000 0.548 0.300
#> ERR519509     1  0.1341     0.7805 0.944 0.056 0.000 0.000 0.000
#> ERR519472     4  0.1408     0.6465 0.000 0.044 0.000 0.948 0.008
#> ERR519510     5  0.1220     0.6202 0.004 0.020 0.004 0.008 0.964
#> ERR519470     1  0.0703     0.7811 0.976 0.024 0.000 0.000 0.000
#> ERR519495     4  0.6638     0.1523 0.284 0.128 0.000 0.552 0.036
#> ERR519522     1  0.0880     0.7884 0.968 0.032 0.000 0.000 0.000
#> ERR519523     1  0.3497     0.6838 0.840 0.008 0.000 0.108 0.044
#> ERR519503     1  0.3427     0.6861 0.836 0.056 0.108 0.000 0.000
#> ERR519471     1  0.3282     0.5962 0.804 0.188 0.000 0.008 0.000
#> ERR519500     4  0.0566     0.6512 0.000 0.000 0.012 0.984 0.004
#> ERR519485     2  0.5039     0.4996 0.360 0.604 0.000 0.008 0.028
#> ERR519476     2  0.8175     0.2244 0.328 0.396 0.012 0.108 0.156
#> ERR519502     4  0.4804     0.1110 0.000 0.008 0.008 0.524 0.460
#> ERR519486     5  0.6654    -0.2408 0.172 0.384 0.000 0.008 0.436
#> ERR519478     1  0.0451     0.7885 0.988 0.008 0.000 0.000 0.004
#> ERR519497     5  0.7037     0.2698 0.004 0.296 0.300 0.004 0.396
#> ERR519467     1  0.1124     0.7899 0.960 0.036 0.000 0.004 0.000
#> ERR519489     4  0.3497     0.5949 0.000 0.044 0.108 0.840 0.008
#> ERR519494     3  0.4583     0.7906 0.000 0.008 0.764 0.128 0.100
#> ERR519474     2  0.6752     0.3363 0.136 0.556 0.000 0.264 0.044
#> ERR519505     5  0.2719     0.6230 0.000 0.068 0.048 0.000 0.884
#> ERR519517     3  0.0671     0.8943 0.000 0.016 0.980 0.000 0.004
#> ERR519484     5  0.2452     0.6095 0.000 0.052 0.028 0.012 0.908
#> ERR519498     5  0.3362     0.6187 0.000 0.076 0.080 0.000 0.844
#> ERR519490     3  0.2964     0.8482 0.000 0.004 0.840 0.152 0.004
#> ERR519507     4  0.6288     0.3170 0.000 0.304 0.000 0.516 0.180
#> ERR519511     5  0.4471     0.2990 0.004 0.020 0.000 0.292 0.684
#> ERR519468     3  0.0451     0.8964 0.000 0.000 0.988 0.008 0.004
#> ERR519482     3  0.2488     0.8701 0.000 0.000 0.872 0.124 0.004
#> ERR519475     2  0.9079     0.2077 0.244 0.388 0.072 0.120 0.176
#> ERR519496     1  0.3671     0.4928 0.756 0.236 0.000 0.008 0.000
#> ERR519506     2  0.6867     0.4942 0.152 0.632 0.028 0.056 0.132
#> ERR519469     4  0.7275     0.3026 0.156 0.072 0.208 0.556 0.008
#> ERR519480     3  0.1907     0.8697 0.000 0.028 0.928 0.000 0.044
#> ERR519487     3  0.1357     0.8791 0.000 0.004 0.948 0.000 0.048
#> ERR519483     2  0.4913     0.5036 0.352 0.620 0.016 0.008 0.004
#> ERR519477     5  0.8556     0.2577 0.036 0.180 0.284 0.096 0.404
#> ERR519499     3  0.0671     0.8939 0.000 0.016 0.980 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
#> ERR519515     1  0.1155     0.7976 0.956 0.004 0.000 0.000 0.004 0.036
#> ERR519516     5  0.6162     0.3992 0.060 0.104 0.000 0.308 0.528 0.000
#> ERR519520     1  0.5031     0.4037 0.600 0.332 0.012 0.052 0.004 0.000
#> ERR519513     4  0.4745     0.4591 0.000 0.056 0.248 0.676 0.000 0.020
#> ERR519481     5  0.2244     0.6460 0.000 0.004 0.004 0.100 0.888 0.004
#> ERR519491     1  0.4483     0.6851 0.780 0.016 0.000 0.072 0.048 0.084
#> ERR519473     5  0.1922     0.6324 0.000 0.012 0.040 0.000 0.924 0.024
#> ERR519518     3  0.5687     0.5721 0.000 0.136 0.608 0.012 0.232 0.012
#> ERR519512     1  0.6830     0.0925 0.452 0.352 0.016 0.076 0.104 0.000
#> ERR519521     5  0.4605     0.5870 0.012 0.096 0.008 0.148 0.736 0.000
#> ERR519488     1  0.1226     0.7883 0.952 0.040 0.004 0.000 0.000 0.004
#> ERR519493     4  0.4797     0.5046 0.096 0.024 0.000 0.760 0.068 0.052
#> ERR519514     1  0.1586     0.7952 0.940 0.012 0.000 0.004 0.004 0.040
#> ERR519479     5  0.6546     0.1565 0.008 0.020 0.000 0.348 0.420 0.204
#> ERR519509     1  0.0858     0.7956 0.968 0.028 0.004 0.000 0.000 0.000
#> ERR519472     5  0.2113     0.6266 0.000 0.008 0.000 0.004 0.896 0.092
#> ERR519510     4  0.1294     0.6294 0.000 0.008 0.004 0.956 0.008 0.024
#> ERR519470     1  0.1155     0.7976 0.956 0.004 0.000 0.000 0.004 0.036
#> ERR519495     5  0.7357    -0.0103 0.348 0.044 0.000 0.040 0.376 0.192
#> ERR519522     1  0.0291     0.7997 0.992 0.004 0.004 0.000 0.000 0.000
#> ERR519523     1  0.2873     0.7554 0.872 0.004 0.000 0.044 0.068 0.012
#> ERR519503     1  0.5180     0.5542 0.684 0.180 0.088 0.000 0.000 0.048
#> ERR519471     1  0.4184     0.4463 0.640 0.012 0.004 0.000 0.004 0.340
#> ERR519500     5  0.1498     0.6350 0.004 0.024 0.012 0.000 0.948 0.012
#> ERR519485     6  0.2871     0.6820 0.100 0.012 0.000 0.016 0.008 0.864
#> ERR519476     2  0.7916     0.3746 0.200 0.472 0.004 0.116 0.096 0.112
#> ERR519502     5  0.4332     0.4628 0.000 0.020 0.008 0.344 0.628 0.000
#> ERR519486     6  0.6115     0.3822 0.116 0.032 0.008 0.308 0.000 0.536
#> ERR519478     1  0.0767     0.8010 0.976 0.012 0.000 0.004 0.000 0.008
#> ERR519497     2  0.6783    -0.0700 0.020 0.384 0.208 0.372 0.004 0.012
#> ERR519467     1  0.1180     0.7989 0.960 0.024 0.004 0.004 0.000 0.008
#> ERR519489     5  0.3670     0.5708 0.004 0.088 0.052 0.004 0.828 0.024
#> ERR519494     3  0.4910     0.6681 0.000 0.108 0.736 0.076 0.076 0.004
#> ERR519474     6  0.3161     0.6848 0.028 0.008 0.000 0.016 0.096 0.852
#> ERR519505     4  0.4015     0.5470 0.000 0.120 0.076 0.784 0.000 0.020
#> ERR519517     3  0.1736     0.7181 0.000 0.032 0.936 0.008 0.020 0.004
#> ERR519484     4  0.3597     0.6148 0.000 0.036 0.032 0.844 0.032 0.056
#> ERR519498     4  0.4141     0.5424 0.000 0.092 0.168 0.740 0.000 0.000
#> ERR519490     3  0.5555     0.6354 0.000 0.140 0.660 0.004 0.152 0.044
#> ERR519507     6  0.6370     0.2197 0.008 0.024 0.000 0.168 0.312 0.488
#> ERR519511     4  0.4848     0.3235 0.004 0.028 0.000 0.652 0.284 0.032
#> ERR519468     3  0.2007     0.7086 0.000 0.040 0.924 0.012 0.016 0.008
#> ERR519482     3  0.4665     0.6860 0.000 0.092 0.740 0.004 0.136 0.028
#> ERR519475     2  0.8433     0.3684 0.140 0.452 0.036 0.108 0.084 0.180
#> ERR519496     1  0.3473     0.6828 0.780 0.024 0.000 0.004 0.000 0.192
#> ERR519506     6  0.1842     0.6857 0.012 0.012 0.000 0.036 0.008 0.932
#> ERR519469     3  0.7872     0.1114 0.136 0.044 0.368 0.004 0.336 0.112
#> ERR519480     3  0.3791     0.6827 0.000 0.128 0.800 0.044 0.000 0.028
#> ERR519487     3  0.3054     0.6269 0.000 0.040 0.840 0.116 0.000 0.004
#> ERR519483     6  0.2400     0.6735 0.068 0.012 0.008 0.004 0.008 0.900
#> ERR519477     2  0.8456     0.2033 0.012 0.312 0.240 0.276 0.064 0.096
#> ERR519499     3  0.1294     0.7163 0.004 0.024 0.956 0.008 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-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 18140 rows and 52 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#>   Subgroups are detected by 'hclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk ATC-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.1117 0.889   0.889
#> 3 3 0.669           0.838       0.921         3.8080 0.563   0.508
#> 4 4 0.569           0.687       0.808         0.1560 1.000   1.000
#> 5 5 0.800           0.825       0.908         0.1423 0.814   0.597
#> 6 6 0.779           0.764       0.885         0.0442 0.987   0.955

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

suggest_best_k(res)
#> [1] 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
#> ERR519515     1       0          1  1  0
#> ERR519516     1       0          1  1  0
#> ERR519520     1       0          1  1  0
#> ERR519513     1       0          1  1  0
#> ERR519481     1       0          1  1  0
#> ERR519491     1       0          1  1  0
#> ERR519473     1       0          1  1  0
#> ERR519518     1       0          1  1  0
#> ERR519512     1       0          1  1  0
#> ERR519521     1       0          1  1  0
#> ERR519488     1       0          1  1  0
#> ERR519493     1       0          1  1  0
#> ERR519514     1       0          1  1  0
#> ERR519479     1       0          1  1  0
#> ERR519509     1       0          1  1  0
#> ERR519472     1       0          1  1  0
#> ERR519510     1       0          1  1  0
#> ERR519470     1       0          1  1  0
#> ERR519495     1       0          1  1  0
#> ERR519522     1       0          1  1  0
#> ERR519523     1       0          1  1  0
#> ERR519503     1       0          1  1  0
#> ERR519471     1       0          1  1  0
#> ERR519500     1       0          1  1  0
#> ERR519485     1       0          1  1  0
#> ERR519476     2       0          1  0  1
#> ERR519502     1       0          1  1  0
#> ERR519486     1       0          1  1  0
#> ERR519478     1       0          1  1  0
#> ERR519497     1       0          1  1  0
#> ERR519467     1       0          1  1  0
#> ERR519489     1       0          1  1  0
#> ERR519494     1       0          1  1  0
#> ERR519474     1       0          1  1  0
#> ERR519505     1       0          1  1  0
#> ERR519517     1       0          1  1  0
#> ERR519484     1       0          1  1  0
#> ERR519498     1       0          1  1  0
#> ERR519490     1       0          1  1  0
#> ERR519507     1       0          1  1  0
#> ERR519511     1       0          1  1  0
#> ERR519468     1       0          1  1  0
#> ERR519482     1       0          1  1  0
#> ERR519475     2       0          1  0  1
#> ERR519496     1       0          1  1  0
#> ERR519506     1       0          1  1  0
#> ERR519469     1       0          1  1  0
#> ERR519480     1       0          1  1  0
#> ERR519487     1       0          1  1  0
#> ERR519483     1       0          1  1  0
#> ERR519477     2       0          1  0  1
#> ERR519499     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
#> ERR519515     1  0.0747      0.947 0.984  0 0.016
#> ERR519516     1  0.0000      0.946 1.000  0 0.000
#> ERR519520     3  0.0000      0.838 0.000  0 1.000
#> ERR519513     3  0.0000      0.838 0.000  0 1.000
#> ERR519481     3  0.5591      0.694 0.304  0 0.696
#> ERR519491     1  0.0747      0.947 0.984  0 0.016
#> ERR519473     3  0.0237      0.838 0.004  0 0.996
#> ERR519518     3  0.0000      0.838 0.000  0 1.000
#> ERR519512     3  0.0000      0.838 0.000  0 1.000
#> ERR519521     3  0.0000      0.838 0.000  0 1.000
#> ERR519488     1  0.0000      0.946 1.000  0 0.000
#> ERR519493     1  0.0747      0.947 0.984  0 0.016
#> ERR519514     1  0.0747      0.947 0.984  0 0.016
#> ERR519479     3  0.5706      0.673 0.320  0 0.680
#> ERR519509     1  0.0000      0.946 1.000  0 0.000
#> ERR519472     3  0.5016      0.741 0.240  0 0.760
#> ERR519510     1  0.0747      0.947 0.984  0 0.016
#> ERR519470     1  0.0000      0.946 1.000  0 0.000
#> ERR519495     3  0.5591      0.694 0.304  0 0.696
#> ERR519522     3  0.5591      0.694 0.304  0 0.696
#> ERR519523     3  0.0000      0.838 0.000  0 1.000
#> ERR519503     1  0.6126      0.139 0.600  0 0.400
#> ERR519471     1  0.0000      0.946 1.000  0 0.000
#> ERR519500     3  0.5591      0.694 0.304  0 0.696
#> ERR519485     1  0.0000      0.946 1.000  0 0.000
#> ERR519476     2  0.0000      1.000 0.000  1 0.000
#> ERR519502     3  0.5591      0.694 0.304  0 0.696
#> ERR519486     1  0.4235      0.737 0.824  0 0.176
#> ERR519478     1  0.0747      0.947 0.984  0 0.016
#> ERR519497     3  0.0237      0.838 0.004  0 0.996
#> ERR519467     3  0.5591      0.694 0.304  0 0.696
#> ERR519489     3  0.5591      0.694 0.304  0 0.696
#> ERR519494     3  0.0000      0.838 0.000  0 1.000
#> ERR519474     1  0.0000      0.946 1.000  0 0.000
#> ERR519505     3  0.5882      0.624 0.348  0 0.652
#> ERR519517     3  0.0000      0.838 0.000  0 1.000
#> ERR519484     1  0.0747      0.947 0.984  0 0.016
#> ERR519498     3  0.1289      0.829 0.032  0 0.968
#> ERR519490     3  0.0000      0.838 0.000  0 1.000
#> ERR519507     3  0.5706      0.673 0.320  0 0.680
#> ERR519511     1  0.0747      0.947 0.984  0 0.016
#> ERR519468     3  0.0000      0.838 0.000  0 1.000
#> ERR519482     3  0.0000      0.838 0.000  0 1.000
#> ERR519475     2  0.0000      1.000 0.000  1 0.000
#> ERR519496     1  0.0747      0.947 0.984  0 0.016
#> ERR519506     1  0.0000      0.946 1.000  0 0.000
#> ERR519469     3  0.0237      0.838 0.004  0 0.996
#> ERR519480     3  0.0000      0.838 0.000  0 1.000
#> ERR519487     3  0.0000      0.838 0.000  0 1.000
#> ERR519483     1  0.0000      0.946 1.000  0 0.000
#> ERR519477     2  0.0000      1.000 0.000  1 0.000
#> ERR519499     3  0.0000      0.838 0.000  0 1.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1 p2 p3    p4
#> ERR519515     1   0.000      0.896 1.000  0 NA 0.000
#> ERR519516     1   0.194      0.883 0.924  0 NA 0.000
#> ERR519520     4   0.000      0.661 0.000  0 NA 1.000
#> ERR519513     4   0.147      0.661 0.000  0 NA 0.948
#> ERR519481     4   0.758      0.474 0.308  0 NA 0.472
#> ERR519491     1   0.000      0.896 1.000  0 NA 0.000
#> ERR519473     4   0.209      0.663 0.020  0 NA 0.932
#> ERR519518     4   0.000      0.661 0.000  0 NA 1.000
#> ERR519512     4   0.000      0.661 0.000  0 NA 1.000
#> ERR519521     4   0.000      0.661 0.000  0 NA 1.000
#> ERR519488     1   0.194      0.883 0.924  0 NA 0.000
#> ERR519493     1   0.000      0.896 1.000  0 NA 0.000
#> ERR519514     1   0.000      0.896 1.000  0 NA 0.000
#> ERR519479     4   0.762      0.453 0.324  0 NA 0.456
#> ERR519509     1   0.194      0.883 0.924  0 NA 0.000
#> ERR519472     4   0.579      0.584 0.244  0 NA 0.680
#> ERR519510     1   0.000      0.896 1.000  0 NA 0.000
#> ERR519470     1   0.194      0.883 0.924  0 NA 0.000
#> ERR519495     4   0.758      0.474 0.308  0 NA 0.472
#> ERR519522     4   0.758      0.474 0.308  0 NA 0.472
#> ERR519523     4   0.000      0.661 0.000  0 NA 1.000
#> ERR519503     1   0.687      0.163 0.580  0 NA 0.272
#> ERR519471     1   0.194      0.883 0.924  0 NA 0.000
#> ERR519500     4   0.758      0.474 0.308  0 NA 0.472
#> ERR519485     1   0.194      0.883 0.924  0 NA 0.000
#> ERR519476     2   0.000      1.000 0.000  1 NA 0.000
#> ERR519502     4   0.758      0.474 0.308  0 NA 0.472
#> ERR519486     1   0.473      0.697 0.780  0 NA 0.160
#> ERR519478     1   0.000      0.896 1.000  0 NA 0.000
#> ERR519497     4   0.217      0.662 0.020  0 NA 0.928
#> ERR519467     4   0.758      0.474 0.308  0 NA 0.472
#> ERR519489     4   0.758      0.474 0.308  0 NA 0.472
#> ERR519494     4   0.365      0.579 0.000  0 NA 0.796
#> ERR519474     1   0.194      0.883 0.924  0 NA 0.000
#> ERR519505     4   0.774      0.413 0.328  0 NA 0.428
#> ERR519517     4   0.369      0.577 0.000  0 NA 0.792
#> ERR519484     1   0.000      0.896 1.000  0 NA 0.000
#> ERR519498     4   0.282      0.658 0.036  0 NA 0.900
#> ERR519490     4   0.369      0.577 0.000  0 NA 0.792
#> ERR519507     4   0.762      0.453 0.324  0 NA 0.456
#> ERR519511     1   0.000      0.896 1.000  0 NA 0.000
#> ERR519468     4   0.369      0.577 0.000  0 NA 0.792
#> ERR519482     4   0.369      0.577 0.000  0 NA 0.792
#> ERR519475     2   0.000      1.000 0.000  1 NA 0.000
#> ERR519496     1   0.000      0.896 1.000  0 NA 0.000
#> ERR519506     1   0.297      0.818 0.856  0 NA 0.000
#> ERR519469     4   0.209      0.663 0.020  0 NA 0.932
#> ERR519480     4   0.369      0.577 0.000  0 NA 0.792
#> ERR519487     4   0.369      0.577 0.000  0 NA 0.792
#> ERR519483     1   0.497      0.369 0.544  0 NA 0.000
#> ERR519477     2   0.000      1.000 0.000  1 NA 0.000
#> ERR519499     4   0.369      0.577 0.000  0 NA 0.792

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1 p2    p3    p4    p5
#> ERR519515     1  0.1671      0.924 0.924  0 0.000 0.076 0.000
#> ERR519516     1  0.0000      0.908 1.000  0 0.000 0.000 0.000
#> ERR519520     3  0.3305      0.811 0.000  0 0.776 0.224 0.000
#> ERR519513     3  0.3661      0.775 0.000  0 0.724 0.276 0.000
#> ERR519481     4  0.0162      0.918 0.000  0 0.004 0.996 0.000
#> ERR519491     1  0.1671      0.924 0.924  0 0.000 0.076 0.000
#> ERR519473     3  0.3857      0.736 0.000  0 0.688 0.312 0.000
#> ERR519518     3  0.3305      0.811 0.000  0 0.776 0.224 0.000
#> ERR519512     3  0.3305      0.811 0.000  0 0.776 0.224 0.000
#> ERR519521     3  0.3305      0.811 0.000  0 0.776 0.224 0.000
#> ERR519488     1  0.0000      0.908 1.000  0 0.000 0.000 0.000
#> ERR519493     1  0.1671      0.924 0.924  0 0.000 0.076 0.000
#> ERR519514     1  0.1671      0.924 0.924  0 0.000 0.076 0.000
#> ERR519479     4  0.0404      0.908 0.012  0 0.000 0.988 0.000
#> ERR519509     1  0.0000      0.908 1.000  0 0.000 0.000 0.000
#> ERR519472     4  0.3210      0.620 0.000  0 0.212 0.788 0.000
#> ERR519510     1  0.1671      0.924 0.924  0 0.000 0.076 0.000
#> ERR519470     1  0.0000      0.908 1.000  0 0.000 0.000 0.000
#> ERR519495     4  0.0162      0.918 0.000  0 0.004 0.996 0.000
#> ERR519522     4  0.0162      0.918 0.000  0 0.004 0.996 0.000
#> ERR519523     3  0.3305      0.811 0.000  0 0.776 0.224 0.000
#> ERR519503     4  0.4768      0.344 0.304  0 0.000 0.656 0.040
#> ERR519471     1  0.0000      0.908 1.000  0 0.000 0.000 0.000
#> ERR519500     4  0.0162      0.918 0.000  0 0.004 0.996 0.000
#> ERR519485     1  0.0000      0.908 1.000  0 0.000 0.000 0.000
#> ERR519476     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> ERR519502     4  0.0162      0.918 0.000  0 0.004 0.996 0.000
#> ERR519486     1  0.3300      0.673 0.792  0 0.004 0.204 0.000
#> ERR519478     1  0.1671      0.924 0.924  0 0.000 0.076 0.000
#> ERR519497     3  0.3857      0.738 0.000  0 0.688 0.312 0.000
#> ERR519467     4  0.0162      0.918 0.000  0 0.004 0.996 0.000
#> ERR519489     4  0.0162      0.918 0.000  0 0.004 0.996 0.000
#> ERR519494     3  0.0162      0.786 0.000  0 0.996 0.004 0.000
#> ERR519474     1  0.0000      0.908 1.000  0 0.000 0.000 0.000
#> ERR519505     4  0.1300      0.886 0.016  0 0.000 0.956 0.028
#> ERR519517     3  0.0000      0.785 0.000  0 1.000 0.000 0.000
#> ERR519484     1  0.1671      0.924 0.924  0 0.000 0.076 0.000
#> ERR519498     3  0.4300      0.405 0.000  0 0.524 0.476 0.000
#> ERR519490     3  0.0000      0.785 0.000  0 1.000 0.000 0.000
#> ERR519507     4  0.0404      0.908 0.012  0 0.000 0.988 0.000
#> ERR519511     1  0.1671      0.924 0.924  0 0.000 0.076 0.000
#> ERR519468     3  0.0000      0.785 0.000  0 1.000 0.000 0.000
#> ERR519482     3  0.0000      0.785 0.000  0 1.000 0.000 0.000
#> ERR519475     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> ERR519496     1  0.1671      0.924 0.924  0 0.000 0.076 0.000
#> ERR519506     1  0.3143      0.744 0.796  0 0.000 0.000 0.204
#> ERR519469     3  0.3857      0.736 0.000  0 0.688 0.312 0.000
#> ERR519480     3  0.0162      0.783 0.000  0 0.996 0.000 0.004
#> ERR519487     3  0.0000      0.785 0.000  0 1.000 0.000 0.000
#> ERR519483     5  0.3177      0.000 0.208  0 0.000 0.000 0.792
#> ERR519477     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> ERR519499     3  0.0000      0.785 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
#> ERR519515     1  0.1141      0.907 0.948  0 0.000 0.000 0.052 0.000
#> ERR519516     1  0.0632      0.884 0.976  0 0.000 0.024 0.000 0.000
#> ERR519520     3  0.3315      0.758 0.000  0 0.780 0.000 0.200 0.020
#> ERR519513     3  0.4120      0.692 0.000  0 0.728 0.000 0.068 0.204
#> ERR519481     5  0.0000      0.884 0.000  0 0.000 0.000 1.000 0.000
#> ERR519491     1  0.1141      0.907 0.948  0 0.000 0.000 0.052 0.000
#> ERR519473     3  0.3879      0.685 0.000  0 0.688 0.000 0.292 0.020
#> ERR519518     3  0.3315      0.758 0.000  0 0.780 0.000 0.200 0.020
#> ERR519512     3  0.3315      0.758 0.000  0 0.780 0.000 0.200 0.020
#> ERR519521     3  0.3315      0.758 0.000  0 0.780 0.000 0.200 0.020
#> ERR519488     1  0.0632      0.884 0.976  0 0.000 0.024 0.000 0.000
#> ERR519493     1  0.1141      0.907 0.948  0 0.000 0.000 0.052 0.000
#> ERR519514     1  0.1141      0.907 0.948  0 0.000 0.000 0.052 0.000
#> ERR519479     5  0.0865      0.864 0.036  0 0.000 0.000 0.964 0.000
#> ERR519509     1  0.0632      0.884 0.976  0 0.000 0.024 0.000 0.000
#> ERR519472     5  0.3403      0.611 0.000  0 0.212 0.000 0.768 0.020
#> ERR519510     1  0.1141      0.907 0.948  0 0.000 0.000 0.052 0.000
#> ERR519470     1  0.0632      0.884 0.976  0 0.000 0.024 0.000 0.000
#> ERR519495     5  0.0000      0.884 0.000  0 0.000 0.000 1.000 0.000
#> ERR519522     5  0.0000      0.884 0.000  0 0.000 0.000 1.000 0.000
#> ERR519523     3  0.3315      0.758 0.000  0 0.780 0.000 0.200 0.020
#> ERR519503     5  0.5438      0.211 0.284  0 0.000 0.016 0.592 0.108
#> ERR519471     1  0.0632      0.884 0.976  0 0.000 0.024 0.000 0.000
#> ERR519500     5  0.0000      0.884 0.000  0 0.000 0.000 1.000 0.000
#> ERR519485     1  0.0632      0.884 0.976  0 0.000 0.024 0.000 0.000
#> ERR519476     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> ERR519502     5  0.0000      0.884 0.000  0 0.000 0.000 1.000 0.000
#> ERR519486     1  0.2838      0.457 0.808  0 0.004 0.000 0.188 0.000
#> ERR519478     1  0.1141      0.907 0.948  0 0.000 0.000 0.052 0.000
#> ERR519497     3  0.4587      0.671 0.000  0 0.688 0.000 0.108 0.204
#> ERR519467     5  0.0000      0.884 0.000  0 0.000 0.000 1.000 0.000
#> ERR519489     5  0.0000      0.884 0.000  0 0.000 0.000 1.000 0.000
#> ERR519494     3  0.2340      0.692 0.000  0 0.852 0.148 0.000 0.000
#> ERR519474     1  0.0632      0.884 0.976  0 0.000 0.024 0.000 0.000
#> ERR519505     5  0.4527      0.573 0.024  0 0.000 0.044 0.704 0.228
#> ERR519517     3  0.2482      0.690 0.000  0 0.848 0.148 0.000 0.004
#> ERR519484     1  0.1141      0.907 0.948  0 0.000 0.000 0.052 0.000
#> ERR519498     3  0.6000      0.443 0.016  0 0.528 0.000 0.252 0.204
#> ERR519490     3  0.0146      0.748 0.000  0 0.996 0.000 0.000 0.004
#> ERR519507     5  0.0865      0.864 0.036  0 0.000 0.000 0.964 0.000
#> ERR519511     1  0.1141      0.907 0.948  0 0.000 0.000 0.052 0.000
#> ERR519468     3  0.0146      0.748 0.000  0 0.996 0.000 0.000 0.004
#> ERR519482     3  0.0146      0.748 0.000  0 0.996 0.000 0.000 0.004
#> ERR519475     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> ERR519496     1  0.1141      0.907 0.948  0 0.000 0.000 0.052 0.000
#> ERR519506     6  0.3765      0.000 0.404  0 0.000 0.000 0.000 0.596
#> ERR519469     3  0.3879      0.685 0.000  0 0.688 0.000 0.292 0.020
#> ERR519480     3  0.3432      0.653 0.000  0 0.800 0.148 0.000 0.052
#> ERR519487     3  0.2482      0.690 0.000  0 0.848 0.148 0.000 0.004
#> ERR519483     4  0.3307      0.000 0.044  0 0.000 0.808 0.000 0.148
#> ERR519477     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> ERR519499     3  0.2482      0.690 0.000  0 0.848 0.148 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-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 18140 rows and 52 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 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-kmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.1117 0.889   0.889
#> 3 3 0.962           0.949       0.980         4.0272 0.549   0.493
#> 4 4 0.678           0.805       0.880         0.2222 0.824   0.618
#> 5 5 0.696           0.694       0.808         0.0798 0.959   0.869
#> 6 6 0.691           0.563       0.764         0.0548 0.961   0.856

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette p1 p2
#> ERR519515     1       0          1  1  0
#> ERR519516     1       0          1  1  0
#> ERR519520     1       0          1  1  0
#> ERR519513     1       0          1  1  0
#> ERR519481     1       0          1  1  0
#> ERR519491     1       0          1  1  0
#> ERR519473     1       0          1  1  0
#> ERR519518     1       0          1  1  0
#> ERR519512     1       0          1  1  0
#> ERR519521     1       0          1  1  0
#> ERR519488     1       0          1  1  0
#> ERR519493     1       0          1  1  0
#> ERR519514     1       0          1  1  0
#> ERR519479     1       0          1  1  0
#> ERR519509     1       0          1  1  0
#> ERR519472     1       0          1  1  0
#> ERR519510     1       0          1  1  0
#> ERR519470     1       0          1  1  0
#> ERR519495     1       0          1  1  0
#> ERR519522     1       0          1  1  0
#> ERR519523     1       0          1  1  0
#> ERR519503     1       0          1  1  0
#> ERR519471     1       0          1  1  0
#> ERR519500     1       0          1  1  0
#> ERR519485     1       0          1  1  0
#> ERR519476     2       0          1  0  1
#> ERR519502     1       0          1  1  0
#> ERR519486     1       0          1  1  0
#> ERR519478     1       0          1  1  0
#> ERR519497     1       0          1  1  0
#> ERR519467     1       0          1  1  0
#> ERR519489     1       0          1  1  0
#> ERR519494     1       0          1  1  0
#> ERR519474     1       0          1  1  0
#> ERR519505     1       0          1  1  0
#> ERR519517     1       0          1  1  0
#> ERR519484     1       0          1  1  0
#> ERR519498     1       0          1  1  0
#> ERR519490     1       0          1  1  0
#> ERR519507     1       0          1  1  0
#> ERR519511     1       0          1  1  0
#> ERR519468     1       0          1  1  0
#> ERR519482     1       0          1  1  0
#> ERR519475     2       0          1  0  1
#> ERR519496     1       0          1  1  0
#> ERR519506     1       0          1  1  0
#> ERR519469     1       0          1  1  0
#> ERR519480     1       0          1  1  0
#> ERR519487     1       0          1  1  0
#> ERR519483     1       0          1  1  0
#> ERR519477     2       0          1  0  1
#> ERR519499     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
#> ERR519515     1  0.0000      1.000 1.000  0 0.000
#> ERR519516     1  0.0000      1.000 1.000  0 0.000
#> ERR519520     3  0.0000      0.945 0.000  0 1.000
#> ERR519513     3  0.0000      0.945 0.000  0 1.000
#> ERR519481     3  0.0000      0.945 0.000  0 1.000
#> ERR519491     1  0.0000      1.000 1.000  0 0.000
#> ERR519473     3  0.0000      0.945 0.000  0 1.000
#> ERR519518     3  0.0000      0.945 0.000  0 1.000
#> ERR519512     3  0.0000      0.945 0.000  0 1.000
#> ERR519521     3  0.0000      0.945 0.000  0 1.000
#> ERR519488     1  0.0000      1.000 1.000  0 0.000
#> ERR519493     1  0.0000      1.000 1.000  0 0.000
#> ERR519514     1  0.0000      1.000 1.000  0 0.000
#> ERR519479     1  0.0000      1.000 1.000  0 0.000
#> ERR519509     1  0.0000      1.000 1.000  0 0.000
#> ERR519472     3  0.0237      0.942 0.004  0 0.996
#> ERR519510     1  0.0000      1.000 1.000  0 0.000
#> ERR519470     1  0.0000      1.000 1.000  0 0.000
#> ERR519495     3  0.4399      0.745 0.188  0 0.812
#> ERR519522     3  0.4555      0.729 0.200  0 0.800
#> ERR519523     3  0.0000      0.945 0.000  0 1.000
#> ERR519503     1  0.0000      1.000 1.000  0 0.000
#> ERR519471     1  0.0000      1.000 1.000  0 0.000
#> ERR519500     3  0.6095      0.410 0.392  0 0.608
#> ERR519485     1  0.0000      1.000 1.000  0 0.000
#> ERR519476     2  0.0000      1.000 0.000  1 0.000
#> ERR519502     3  0.0000      0.945 0.000  0 1.000
#> ERR519486     1  0.0000      1.000 1.000  0 0.000
#> ERR519478     1  0.0000      1.000 1.000  0 0.000
#> ERR519497     3  0.0000      0.945 0.000  0 1.000
#> ERR519467     3  0.4605      0.724 0.204  0 0.796
#> ERR519489     3  0.0000      0.945 0.000  0 1.000
#> ERR519494     3  0.0000      0.945 0.000  0 1.000
#> ERR519474     1  0.0000      1.000 1.000  0 0.000
#> ERR519505     1  0.0000      1.000 1.000  0 0.000
#> ERR519517     3  0.0000      0.945 0.000  0 1.000
#> ERR519484     1  0.0000      1.000 1.000  0 0.000
#> ERR519498     3  0.1860      0.897 0.052  0 0.948
#> ERR519490     3  0.0000      0.945 0.000  0 1.000
#> ERR519507     1  0.0000      1.000 1.000  0 0.000
#> ERR519511     1  0.0000      1.000 1.000  0 0.000
#> ERR519468     3  0.0000      0.945 0.000  0 1.000
#> ERR519482     3  0.0000      0.945 0.000  0 1.000
#> ERR519475     2  0.0000      1.000 0.000  1 0.000
#> ERR519496     1  0.0000      1.000 1.000  0 0.000
#> ERR519506     1  0.0000      1.000 1.000  0 0.000
#> ERR519469     3  0.0000      0.945 0.000  0 1.000
#> ERR519480     3  0.0000      0.945 0.000  0 1.000
#> ERR519487     3  0.0000      0.945 0.000  0 1.000
#> ERR519483     1  0.0000      1.000 1.000  0 0.000
#> ERR519477     2  0.0000      1.000 0.000  1 0.000
#> ERR519499     3  0.0000      0.945 0.000  0 1.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1 p2    p3    p4
#> ERR519515     1   0.000      0.875 1.000  0 0.000 0.000
#> ERR519516     1   0.000      0.875 1.000  0 0.000 0.000
#> ERR519520     4   0.483      0.494 0.000  0 0.392 0.608
#> ERR519513     3   0.344      0.805 0.000  0 0.816 0.184
#> ERR519481     4   0.112      0.785 0.000  0 0.036 0.964
#> ERR519491     1   0.234      0.877 0.900  0 0.000 0.100
#> ERR519473     4   0.483      0.494 0.000  0 0.392 0.608
#> ERR519518     3   0.344      0.804 0.000  0 0.816 0.184
#> ERR519512     4   0.483      0.494 0.000  0 0.392 0.608
#> ERR519521     4   0.483      0.494 0.000  0 0.392 0.608
#> ERR519488     1   0.000      0.875 1.000  0 0.000 0.000
#> ERR519493     1   0.234      0.877 0.900  0 0.000 0.100
#> ERR519514     1   0.281      0.868 0.868  0 0.000 0.132
#> ERR519479     4   0.215      0.718 0.088  0 0.000 0.912
#> ERR519509     1   0.000      0.875 1.000  0 0.000 0.000
#> ERR519472     4   0.112      0.785 0.000  0 0.036 0.964
#> ERR519510     1   0.281      0.868 0.868  0 0.000 0.132
#> ERR519470     1   0.000      0.875 1.000  0 0.000 0.000
#> ERR519495     4   0.121      0.777 0.032  0 0.004 0.964
#> ERR519522     4   0.112      0.775 0.036  0 0.000 0.964
#> ERR519523     4   0.483      0.494 0.000  0 0.392 0.608
#> ERR519503     1   0.604      0.563 0.560  0 0.048 0.392
#> ERR519471     1   0.000      0.875 1.000  0 0.000 0.000
#> ERR519500     4   0.140      0.772 0.040  0 0.004 0.956
#> ERR519485     1   0.000      0.875 1.000  0 0.000 0.000
#> ERR519476     2   0.000      1.000 0.000  1 0.000 0.000
#> ERR519502     4   0.112      0.785 0.000  0 0.036 0.964
#> ERR519486     1   0.384      0.789 0.776  0 0.000 0.224
#> ERR519478     1   0.247      0.875 0.892  0 0.000 0.108
#> ERR519497     4   0.441      0.610 0.000  0 0.300 0.700
#> ERR519467     4   0.112      0.775 0.036  0 0.000 0.964
#> ERR519489     4   0.112      0.785 0.000  0 0.036 0.964
#> ERR519494     3   0.147      0.958 0.000  0 0.948 0.052
#> ERR519474     1   0.000      0.875 1.000  0 0.000 0.000
#> ERR519505     1   0.620      0.476 0.508  0 0.052 0.440
#> ERR519517     3   0.147      0.958 0.000  0 0.948 0.052
#> ERR519484     1   0.281      0.868 0.868  0 0.000 0.132
#> ERR519498     4   0.121      0.784 0.004  0 0.032 0.964
#> ERR519490     3   0.147      0.958 0.000  0 0.948 0.052
#> ERR519507     4   0.215      0.718 0.088  0 0.000 0.912
#> ERR519511     1   0.292      0.864 0.860  0 0.000 0.140
#> ERR519468     3   0.147      0.958 0.000  0 0.948 0.052
#> ERR519482     3   0.147      0.958 0.000  0 0.948 0.052
#> ERR519475     2   0.000      1.000 0.000  1 0.000 0.000
#> ERR519496     1   0.292      0.864 0.860  0 0.000 0.140
#> ERR519506     1   0.240      0.828 0.920  0 0.048 0.032
#> ERR519469     4   0.448      0.598 0.000  0 0.312 0.688
#> ERR519480     3   0.147      0.958 0.000  0 0.948 0.052
#> ERR519487     3   0.147      0.958 0.000  0 0.948 0.052
#> ERR519483     1   0.161      0.849 0.952  0 0.016 0.032
#> ERR519477     2   0.000      1.000 0.000  1 0.000 0.000
#> ERR519499     3   0.147      0.958 0.000  0 0.948 0.052

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1 p2    p3    p4    p5
#> ERR519515     1  0.0609      0.795 0.980  0 0.000 0.000 0.020
#> ERR519516     1  0.0162      0.790 0.996  0 0.000 0.000 0.004
#> ERR519520     4  0.6448      0.484 0.000  0 0.272 0.500 0.228
#> ERR519513     3  0.5891      0.458 0.000  0 0.552 0.120 0.328
#> ERR519481     4  0.1168      0.674 0.000  0 0.008 0.960 0.032
#> ERR519491     1  0.3692      0.781 0.812  0 0.000 0.052 0.136
#> ERR519473     4  0.6448      0.482 0.000  0 0.272 0.500 0.228
#> ERR519518     3  0.5950      0.408 0.000  0 0.592 0.188 0.220
#> ERR519512     4  0.6448      0.484 0.000  0 0.272 0.500 0.228
#> ERR519521     4  0.6428      0.487 0.000  0 0.272 0.504 0.224
#> ERR519488     1  0.0510      0.784 0.984  0 0.000 0.000 0.016
#> ERR519493     1  0.3692      0.781 0.812  0 0.000 0.052 0.136
#> ERR519514     1  0.4069      0.767 0.788  0 0.000 0.076 0.136
#> ERR519479     4  0.2915      0.497 0.024  0 0.000 0.860 0.116
#> ERR519509     1  0.0510      0.784 0.984  0 0.000 0.000 0.016
#> ERR519472     4  0.0290      0.667 0.000  0 0.008 0.992 0.000
#> ERR519510     1  0.4334      0.749 0.764  0 0.000 0.080 0.156
#> ERR519470     1  0.0000      0.791 1.000  0 0.000 0.000 0.000
#> ERR519495     4  0.0693      0.656 0.008  0 0.000 0.980 0.012
#> ERR519522     4  0.1331      0.667 0.008  0 0.000 0.952 0.040
#> ERR519523     4  0.6428      0.487 0.000  0 0.272 0.504 0.224
#> ERR519503     5  0.6465      0.653 0.208  0 0.000 0.308 0.484
#> ERR519471     1  0.0880      0.795 0.968  0 0.000 0.000 0.032
#> ERR519500     4  0.0898      0.649 0.008  0 0.000 0.972 0.020
#> ERR519485     1  0.0609      0.783 0.980  0 0.000 0.000 0.020
#> ERR519476     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> ERR519502     4  0.1408      0.674 0.000  0 0.008 0.948 0.044
#> ERR519486     1  0.5590      0.484 0.640  0 0.000 0.204 0.156
#> ERR519478     1  0.3825      0.777 0.804  0 0.000 0.060 0.136
#> ERR519497     4  0.6053      0.564 0.000  0 0.196 0.576 0.228
#> ERR519467     4  0.0693      0.656 0.008  0 0.000 0.980 0.012
#> ERR519489     4  0.0290      0.667 0.000  0 0.008 0.992 0.000
#> ERR519494     3  0.1082      0.870 0.000  0 0.964 0.008 0.028
#> ERR519474     1  0.0510      0.785 0.984  0 0.000 0.000 0.016
#> ERR519505     5  0.5461      0.570 0.096  0 0.000 0.284 0.620
#> ERR519517     3  0.0451      0.873 0.000  0 0.988 0.008 0.004
#> ERR519484     1  0.4334      0.749 0.764  0 0.000 0.080 0.156
#> ERR519498     4  0.4564      0.480 0.004  0 0.008 0.600 0.388
#> ERR519490     3  0.0992      0.870 0.000  0 0.968 0.008 0.024
#> ERR519507     4  0.2915      0.497 0.024  0 0.000 0.860 0.116
#> ERR519511     1  0.4548      0.731 0.748  0 0.000 0.096 0.156
#> ERR519468     3  0.0693      0.873 0.000  0 0.980 0.008 0.012
#> ERR519482     3  0.0579      0.874 0.000  0 0.984 0.008 0.008
#> ERR519475     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> ERR519496     1  0.4322      0.751 0.768  0 0.000 0.088 0.144
#> ERR519506     5  0.4907      0.132 0.488  0 0.000 0.024 0.488
#> ERR519469     4  0.6120      0.556 0.000  0 0.196 0.564 0.240
#> ERR519480     3  0.2464      0.809 0.000  0 0.888 0.016 0.096
#> ERR519487     3  0.0451      0.873 0.000  0 0.988 0.008 0.004
#> ERR519483     1  0.1830      0.723 0.924  0 0.008 0.000 0.068
#> ERR519477     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> ERR519499     3  0.0798      0.871 0.000  0 0.976 0.008 0.016

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1 p2    p3    p4    p5    p6
#> ERR519515     1  0.3352     0.7473 0.816  0 0.000 0.112 0.000 0.072
#> ERR519516     1  0.4267     0.7235 0.732  0 0.000 0.152 0.000 0.116
#> ERR519520     5  0.5392    -0.3945 0.000  0 0.112 0.440 0.448 0.000
#> ERR519513     4  0.5771     0.2100 0.000  0 0.356 0.524 0.036 0.084
#> ERR519481     5  0.0458     0.5965 0.000  0 0.000 0.016 0.984 0.000
#> ERR519491     1  0.0603     0.7440 0.980  0 0.000 0.000 0.016 0.004
#> ERR519473     4  0.5534     0.2949 0.000  0 0.132 0.444 0.424 0.000
#> ERR519518     4  0.5400     0.3951 0.000  0 0.400 0.484 0.116 0.000
#> ERR519512     5  0.5392    -0.3945 0.000  0 0.112 0.440 0.448 0.000
#> ERR519521     5  0.5392    -0.3945 0.000  0 0.112 0.440 0.448 0.000
#> ERR519488     1  0.4533     0.7091 0.704  0 0.000 0.156 0.000 0.140
#> ERR519493     1  0.0603     0.7440 0.980  0 0.000 0.000 0.016 0.004
#> ERR519514     1  0.0972     0.7377 0.964  0 0.000 0.000 0.028 0.008
#> ERR519479     5  0.3906     0.3497 0.216  0 0.000 0.008 0.744 0.032
#> ERR519509     1  0.4533     0.7091 0.704  0 0.000 0.156 0.000 0.140
#> ERR519472     5  0.0000     0.6018 0.000  0 0.000 0.000 1.000 0.000
#> ERR519510     1  0.2002     0.7109 0.916  0 0.000 0.008 0.020 0.056
#> ERR519470     1  0.3953     0.7355 0.764  0 0.000 0.132 0.000 0.104
#> ERR519495     5  0.0458     0.6006 0.016  0 0.000 0.000 0.984 0.000
#> ERR519522     5  0.1151     0.5959 0.012  0 0.000 0.032 0.956 0.000
#> ERR519523     5  0.5392    -0.3945 0.000  0 0.112 0.440 0.448 0.000
#> ERR519503     6  0.5254     0.7286 0.220  0 0.000 0.004 0.156 0.620
#> ERR519471     1  0.3361     0.7436 0.816  0 0.000 0.108 0.000 0.076
#> ERR519500     5  0.1219     0.5824 0.048  0 0.000 0.000 0.948 0.004
#> ERR519485     1  0.4603     0.7070 0.696  0 0.000 0.156 0.000 0.148
#> ERR519476     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000 0.000
#> ERR519502     5  0.0458     0.5965 0.000  0 0.000 0.016 0.984 0.000
#> ERR519486     1  0.3474     0.5767 0.820  0 0.000 0.012 0.112 0.056
#> ERR519478     1  0.0632     0.7425 0.976  0 0.000 0.000 0.024 0.000
#> ERR519497     5  0.5115    -0.3545 0.000  0 0.080 0.456 0.464 0.000
#> ERR519467     5  0.0717     0.5988 0.016  0 0.000 0.008 0.976 0.000
#> ERR519489     5  0.0000     0.6018 0.000  0 0.000 0.000 1.000 0.000
#> ERR519494     3  0.1812     0.8825 0.000  0 0.912 0.080 0.000 0.008
#> ERR519474     1  0.4603     0.7070 0.696  0 0.000 0.156 0.000 0.148
#> ERR519505     6  0.6090     0.6436 0.144  0 0.000 0.136 0.108 0.612
#> ERR519517     3  0.0632     0.9008 0.000  0 0.976 0.000 0.000 0.024
#> ERR519484     1  0.2002     0.7109 0.916  0 0.000 0.008 0.020 0.056
#> ERR519498     5  0.6066    -0.0367 0.032  0 0.000 0.420 0.432 0.116
#> ERR519490     3  0.2357     0.8627 0.000  0 0.872 0.116 0.000 0.012
#> ERR519507     5  0.3878     0.3553 0.212  0 0.000 0.008 0.748 0.032
#> ERR519511     1  0.2563     0.6745 0.884  0 0.000 0.008 0.068 0.040
#> ERR519468     3  0.1967     0.8847 0.000  0 0.904 0.084 0.000 0.012
#> ERR519482     3  0.1913     0.8864 0.000  0 0.908 0.080 0.000 0.012
#> ERR519475     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000 0.000
#> ERR519496     1  0.1794     0.7126 0.924  0 0.000 0.000 0.036 0.040
#> ERR519506     6  0.3915     0.6394 0.288  0 0.000 0.016 0.004 0.692
#> ERR519469     4  0.5350     0.3140 0.000  0 0.108 0.476 0.416 0.000
#> ERR519480     3  0.3384     0.7943 0.000  0 0.812 0.068 0.000 0.120
#> ERR519487     3  0.0632     0.9008 0.000  0 0.976 0.000 0.000 0.024
#> ERR519483     1  0.5844     0.4169 0.488  0 0.000 0.244 0.000 0.268
#> ERR519477     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000 0.000
#> ERR519499     3  0.1151     0.8948 0.000  0 0.956 0.012 0.000 0.032

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

consensus_heatmap(res, k = 2)

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

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

collect_plots(res)

plot of chunk ATC-skmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.992       0.996         0.4975 0.502   0.502
#> 3 3 0.728           0.487       0.780         0.3102 0.922   0.844
#> 4 4 0.647           0.557       0.722         0.0984 0.744   0.445
#> 5 5 0.679           0.664       0.827         0.0668 0.903   0.652
#> 6 6 0.695           0.546       0.761         0.0402 0.965   0.842

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
#> ERR519515     2   0.000      0.993 0.000 1.000
#> ERR519516     2   0.000      0.993 0.000 1.000
#> ERR519520     1   0.000      0.999 1.000 0.000
#> ERR519513     1   0.000      0.999 1.000 0.000
#> ERR519481     1   0.000      0.999 1.000 0.000
#> ERR519491     2   0.000      0.993 0.000 1.000
#> ERR519473     1   0.000      0.999 1.000 0.000
#> ERR519518     1   0.000      0.999 1.000 0.000
#> ERR519512     1   0.000      0.999 1.000 0.000
#> ERR519521     1   0.000      0.999 1.000 0.000
#> ERR519488     2   0.000      0.993 0.000 1.000
#> ERR519493     2   0.000      0.993 0.000 1.000
#> ERR519514     2   0.000      0.993 0.000 1.000
#> ERR519479     1   0.000      0.999 1.000 0.000
#> ERR519509     2   0.000      0.993 0.000 1.000
#> ERR519472     1   0.000      0.999 1.000 0.000
#> ERR519510     2   0.000      0.993 0.000 1.000
#> ERR519470     2   0.000      0.993 0.000 1.000
#> ERR519495     1   0.000      0.999 1.000 0.000
#> ERR519522     1   0.000      0.999 1.000 0.000
#> ERR519523     1   0.000      0.999 1.000 0.000
#> ERR519503     1   0.242      0.958 0.960 0.040
#> ERR519471     2   0.000      0.993 0.000 1.000
#> ERR519500     1   0.000      0.999 1.000 0.000
#> ERR519485     2   0.000      0.993 0.000 1.000
#> ERR519476     2   0.000      0.993 0.000 1.000
#> ERR519502     1   0.000      0.999 1.000 0.000
#> ERR519486     2   0.625      0.816 0.156 0.844
#> ERR519478     2   0.000      0.993 0.000 1.000
#> ERR519497     1   0.000      0.999 1.000 0.000
#> ERR519467     1   0.000      0.999 1.000 0.000
#> ERR519489     1   0.000      0.999 1.000 0.000
#> ERR519494     1   0.000      0.999 1.000 0.000
#> ERR519474     2   0.000      0.993 0.000 1.000
#> ERR519505     1   0.000      0.999 1.000 0.000
#> ERR519517     1   0.000      0.999 1.000 0.000
#> ERR519484     2   0.000      0.993 0.000 1.000
#> ERR519498     1   0.000      0.999 1.000 0.000
#> ERR519490     1   0.000      0.999 1.000 0.000
#> ERR519507     1   0.000      0.999 1.000 0.000
#> ERR519511     2   0.000      0.993 0.000 1.000
#> ERR519468     1   0.000      0.999 1.000 0.000
#> ERR519482     1   0.000      0.999 1.000 0.000
#> ERR519475     2   0.000      0.993 0.000 1.000
#> ERR519496     2   0.000      0.993 0.000 1.000
#> ERR519506     2   0.000      0.993 0.000 1.000
#> ERR519469     1   0.000      0.999 1.000 0.000
#> ERR519480     1   0.000      0.999 1.000 0.000
#> ERR519487     1   0.000      0.999 1.000 0.000
#> ERR519483     2   0.000      0.993 0.000 1.000
#> ERR519477     2   0.000      0.993 0.000 1.000
#> ERR519499     1   0.000      0.999 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> ERR519515     1  0.0000    0.96588 1.000 0.000 0.000
#> ERR519516     1  0.0000    0.96588 1.000 0.000 0.000
#> ERR519520     3  0.0000    0.24780 0.000 0.000 1.000
#> ERR519513     3  0.6215    0.25475 0.000 0.428 0.572
#> ERR519481     3  0.6079    0.07595 0.000 0.388 0.612
#> ERR519491     1  0.1163    0.95409 0.972 0.028 0.000
#> ERR519473     3  0.4452    0.19895 0.000 0.192 0.808
#> ERR519518     3  0.2066    0.24598 0.000 0.060 0.940
#> ERR519512     3  0.0000    0.24780 0.000 0.000 1.000
#> ERR519521     3  0.4555    0.19531 0.000 0.200 0.800
#> ERR519488     1  0.0000    0.96588 1.000 0.000 0.000
#> ERR519493     1  0.1289    0.95204 0.968 0.032 0.000
#> ERR519514     1  0.0000    0.96588 1.000 0.000 0.000
#> ERR519479     2  0.6244    0.00527 0.000 0.560 0.440
#> ERR519509     1  0.0000    0.96588 1.000 0.000 0.000
#> ERR519472     3  0.6079    0.07595 0.000 0.388 0.612
#> ERR519510     1  0.3879    0.86994 0.848 0.152 0.000
#> ERR519470     1  0.0000    0.96588 1.000 0.000 0.000
#> ERR519495     3  0.6079    0.07595 0.000 0.388 0.612
#> ERR519522     3  0.5905    0.09853 0.000 0.352 0.648
#> ERR519523     3  0.4504    0.19747 0.000 0.196 0.804
#> ERR519503     2  0.8837   -0.21643 0.116 0.460 0.424
#> ERR519471     1  0.0000    0.96588 1.000 0.000 0.000
#> ERR519500     3  0.6140    0.04761 0.000 0.404 0.596
#> ERR519485     1  0.0000    0.96588 1.000 0.000 0.000
#> ERR519476     1  0.0000    0.96588 1.000 0.000 0.000
#> ERR519502     3  0.6079    0.07595 0.000 0.388 0.612
#> ERR519486     1  0.6351    0.77894 0.760 0.168 0.072
#> ERR519478     1  0.0237    0.96471 0.996 0.004 0.000
#> ERR519497     3  0.6180    0.25212 0.000 0.416 0.584
#> ERR519467     3  0.6062    0.07942 0.000 0.384 0.616
#> ERR519489     3  0.6062    0.07942 0.000 0.384 0.616
#> ERR519494     3  0.6215    0.25475 0.000 0.428 0.572
#> ERR519474     1  0.0000    0.96588 1.000 0.000 0.000
#> ERR519505     2  0.6111   -0.19072 0.000 0.604 0.396
#> ERR519517     3  0.6215    0.25475 0.000 0.428 0.572
#> ERR519484     1  0.3879    0.86994 0.848 0.152 0.000
#> ERR519498     3  0.6215    0.25475 0.000 0.428 0.572
#> ERR519490     3  0.6215    0.25475 0.000 0.428 0.572
#> ERR519507     2  0.6244    0.00527 0.000 0.560 0.440
#> ERR519511     1  0.3879    0.86994 0.848 0.152 0.000
#> ERR519468     3  0.6215    0.25475 0.000 0.428 0.572
#> ERR519482     3  0.6215    0.25475 0.000 0.428 0.572
#> ERR519475     1  0.0000    0.96588 1.000 0.000 0.000
#> ERR519496     1  0.0237    0.96471 0.996 0.004 0.000
#> ERR519506     1  0.1289    0.94838 0.968 0.032 0.000
#> ERR519469     3  0.6204    0.25428 0.000 0.424 0.576
#> ERR519480     3  0.6215    0.25475 0.000 0.428 0.572
#> ERR519487     3  0.6215    0.25475 0.000 0.428 0.572
#> ERR519483     1  0.0000    0.96588 1.000 0.000 0.000
#> ERR519477     1  0.0000    0.96588 1.000 0.000 0.000
#> ERR519499     3  0.6215    0.25475 0.000 0.428 0.572

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> ERR519515     1  0.4994    -0.3852 0.520 0.480 0.000 0.000
#> ERR519516     2  0.4877     0.6514 0.408 0.592 0.000 0.000
#> ERR519520     3  0.5137    -0.0436 0.000 0.004 0.544 0.452
#> ERR519513     3  0.0376     0.8168 0.004 0.004 0.992 0.000
#> ERR519481     4  0.2011     0.7966 0.000 0.000 0.080 0.920
#> ERR519491     1  0.3074     0.6034 0.848 0.152 0.000 0.000
#> ERR519473     4  0.5132     0.3050 0.000 0.004 0.448 0.548
#> ERR519518     3  0.4677     0.4012 0.000 0.004 0.680 0.316
#> ERR519512     3  0.5137    -0.0436 0.000 0.004 0.544 0.452
#> ERR519521     4  0.5080     0.3850 0.000 0.004 0.420 0.576
#> ERR519488     2  0.4866     0.6568 0.404 0.596 0.000 0.000
#> ERR519493     1  0.3266     0.5958 0.832 0.168 0.000 0.000
#> ERR519514     1  0.4994    -0.3852 0.520 0.480 0.000 0.000
#> ERR519479     4  0.4164     0.5942 0.264 0.000 0.000 0.736
#> ERR519509     2  0.4877     0.6514 0.408 0.592 0.000 0.000
#> ERR519472     4  0.2011     0.7966 0.000 0.000 0.080 0.920
#> ERR519510     1  0.0336     0.5993 0.992 0.000 0.000 0.008
#> ERR519470     2  0.4999     0.3872 0.492 0.508 0.000 0.000
#> ERR519495     4  0.2011     0.7966 0.000 0.000 0.080 0.920
#> ERR519522     4  0.3751     0.7326 0.000 0.004 0.196 0.800
#> ERR519523     4  0.5088     0.3752 0.000 0.004 0.424 0.572
#> ERR519503     3  0.6599     0.3140 0.000 0.432 0.488 0.080
#> ERR519471     2  0.4855     0.6543 0.400 0.600 0.000 0.000
#> ERR519500     4  0.2011     0.7966 0.000 0.000 0.080 0.920
#> ERR519485     2  0.4898     0.6439 0.416 0.584 0.000 0.000
#> ERR519476     2  0.4866     0.6568 0.404 0.596 0.000 0.000
#> ERR519502     4  0.2593     0.7943 0.000 0.004 0.104 0.892
#> ERR519486     1  0.6208     0.3547 0.672 0.216 0.108 0.004
#> ERR519478     1  0.3975     0.5116 0.760 0.240 0.000 0.000
#> ERR519497     3  0.3306     0.6903 0.000 0.004 0.840 0.156
#> ERR519467     4  0.2408     0.7948 0.000 0.000 0.104 0.896
#> ERR519489     4  0.3074     0.7715 0.000 0.000 0.152 0.848
#> ERR519494     3  0.0592     0.8121 0.000 0.000 0.984 0.016
#> ERR519474     2  0.4888     0.6501 0.412 0.588 0.000 0.000
#> ERR519505     2  0.8498    -0.3848 0.116 0.408 0.400 0.076
#> ERR519517     3  0.0000     0.8188 0.000 0.000 1.000 0.000
#> ERR519484     1  0.0524     0.5995 0.988 0.004 0.000 0.008
#> ERR519498     3  0.0657     0.8137 0.012 0.004 0.984 0.000
#> ERR519490     3  0.0000     0.8188 0.000 0.000 1.000 0.000
#> ERR519507     4  0.3907     0.6324 0.232 0.000 0.000 0.768
#> ERR519511     1  0.0779     0.5962 0.980 0.004 0.000 0.016
#> ERR519468     3  0.0000     0.8188 0.000 0.000 1.000 0.000
#> ERR519482     3  0.0000     0.8188 0.000 0.000 1.000 0.000
#> ERR519475     2  0.4866     0.6568 0.404 0.596 0.000 0.000
#> ERR519496     1  0.3873     0.5258 0.772 0.228 0.000 0.000
#> ERR519506     2  0.2329     0.0667 0.012 0.916 0.000 0.072
#> ERR519469     3  0.2921     0.7109 0.000 0.000 0.860 0.140
#> ERR519480     3  0.0000     0.8188 0.000 0.000 1.000 0.000
#> ERR519487     3  0.0000     0.8188 0.000 0.000 1.000 0.000
#> ERR519483     2  0.4877     0.6479 0.408 0.592 0.000 0.000
#> ERR519477     2  0.4866     0.6568 0.404 0.596 0.000 0.000
#> ERR519499     3  0.0000     0.8188 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
#> ERR519515     1  0.3809      0.557 0.736 0.008 0.000 0.000 0.256
#> ERR519516     1  0.0290      0.893 0.992 0.000 0.000 0.000 0.008
#> ERR519520     4  0.5328      0.231 0.000 0.028 0.468 0.492 0.012
#> ERR519513     3  0.2464      0.825 0.000 0.092 0.892 0.004 0.012
#> ERR519481     4  0.0833      0.676 0.000 0.004 0.016 0.976 0.004
#> ERR519491     5  0.4183      0.549 0.324 0.008 0.000 0.000 0.668
#> ERR519473     4  0.4446      0.445 0.000 0.008 0.400 0.592 0.000
#> ERR519518     3  0.4473      0.386 0.000 0.020 0.656 0.324 0.000
#> ERR519512     4  0.5328      0.231 0.000 0.028 0.468 0.492 0.012
#> ERR519521     4  0.5087      0.517 0.000 0.028 0.344 0.616 0.012
#> ERR519488     1  0.0000      0.892 1.000 0.000 0.000 0.000 0.000
#> ERR519493     5  0.4276      0.497 0.380 0.004 0.000 0.000 0.616
#> ERR519514     1  0.3942      0.541 0.728 0.012 0.000 0.000 0.260
#> ERR519479     4  0.4758      0.342 0.000 0.048 0.000 0.676 0.276
#> ERR519509     1  0.0162      0.892 0.996 0.000 0.000 0.000 0.004
#> ERR519472     4  0.0833      0.676 0.000 0.004 0.016 0.976 0.004
#> ERR519510     5  0.4031      0.496 0.064 0.124 0.000 0.008 0.804
#> ERR519470     1  0.2930      0.720 0.832 0.004 0.000 0.000 0.164
#> ERR519495     4  0.0833      0.676 0.000 0.004 0.016 0.976 0.004
#> ERR519522     4  0.4100      0.678 0.000 0.028 0.172 0.784 0.016
#> ERR519523     4  0.5101      0.512 0.000 0.028 0.348 0.612 0.012
#> ERR519503     2  0.3914      0.696 0.016 0.760 0.220 0.004 0.000
#> ERR519471     1  0.0566      0.887 0.984 0.012 0.000 0.000 0.004
#> ERR519500     4  0.0981      0.669 0.000 0.008 0.012 0.972 0.008
#> ERR519485     1  0.1525      0.865 0.948 0.012 0.000 0.004 0.036
#> ERR519476     1  0.0162      0.893 0.996 0.000 0.000 0.000 0.004
#> ERR519502     4  0.2463      0.705 0.000 0.008 0.100 0.888 0.004
#> ERR519486     5  0.7313      0.243 0.260 0.196 0.044 0.004 0.496
#> ERR519478     5  0.4641      0.316 0.456 0.012 0.000 0.000 0.532
#> ERR519497     3  0.4380      0.582 0.000 0.020 0.728 0.240 0.012
#> ERR519467     4  0.3154      0.704 0.000 0.024 0.104 0.860 0.012
#> ERR519489     4  0.3689      0.630 0.000 0.004 0.256 0.740 0.000
#> ERR519494     3  0.1341      0.850 0.000 0.000 0.944 0.056 0.000
#> ERR519474     1  0.1364      0.868 0.952 0.012 0.000 0.000 0.036
#> ERR519505     2  0.2451      0.697 0.000 0.904 0.056 0.004 0.036
#> ERR519517     3  0.0000      0.875 0.000 0.000 1.000 0.000 0.000
#> ERR519484     5  0.4326      0.491 0.084 0.124 0.000 0.008 0.784
#> ERR519498     3  0.3170      0.789 0.000 0.124 0.848 0.004 0.024
#> ERR519490     3  0.0510      0.873 0.000 0.000 0.984 0.016 0.000
#> ERR519507     4  0.4355      0.422 0.000 0.044 0.000 0.732 0.224
#> ERR519511     5  0.2822      0.507 0.036 0.064 0.000 0.012 0.888
#> ERR519468     3  0.0162      0.876 0.000 0.000 0.996 0.004 0.000
#> ERR519482     3  0.0162      0.876 0.000 0.000 0.996 0.004 0.000
#> ERR519475     1  0.0162      0.893 0.996 0.000 0.000 0.000 0.004
#> ERR519496     5  0.4927      0.447 0.388 0.024 0.000 0.004 0.584
#> ERR519506     2  0.3395      0.605 0.236 0.764 0.000 0.000 0.000
#> ERR519469     3  0.3388      0.676 0.000 0.008 0.792 0.200 0.000
#> ERR519480     3  0.0162      0.876 0.000 0.000 0.996 0.004 0.000
#> ERR519487     3  0.0000      0.875 0.000 0.000 1.000 0.000 0.000
#> ERR519483     1  0.1646      0.862 0.944 0.020 0.000 0.004 0.032
#> ERR519477     1  0.0162      0.893 0.996 0.000 0.000 0.000 0.004
#> ERR519499     3  0.0000      0.875 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
#> ERR519515     1  0.3843     -0.092 0.548 0.452 0.000 0.000 0.000 0.000
#> ERR519516     1  0.0547      0.792 0.980 0.020 0.000 0.000 0.000 0.000
#> ERR519520     4  0.4191      0.346 0.000 0.012 0.388 0.596 0.000 0.004
#> ERR519513     3  0.5441      0.628 0.000 0.088 0.716 0.048 0.048 0.100
#> ERR519481     4  0.2793      0.461 0.000 0.000 0.000 0.800 0.200 0.000
#> ERR519491     2  0.5063      0.638 0.284 0.604 0.000 0.000 0.112 0.000
#> ERR519473     4  0.4445      0.382 0.000 0.000 0.396 0.572 0.032 0.000
#> ERR519518     3  0.3966      0.109 0.000 0.000 0.552 0.444 0.000 0.004
#> ERR519512     4  0.4191      0.346 0.000 0.012 0.388 0.596 0.000 0.004
#> ERR519521     4  0.3885      0.505 0.000 0.012 0.300 0.684 0.000 0.004
#> ERR519488     1  0.0458      0.793 0.984 0.016 0.000 0.000 0.000 0.000
#> ERR519493     2  0.5528      0.579 0.348 0.508 0.000 0.000 0.144 0.000
#> ERR519514     1  0.3866     -0.192 0.516 0.484 0.000 0.000 0.000 0.000
#> ERR519479     5  0.4735      0.240 0.000 0.040 0.000 0.416 0.540 0.004
#> ERR519509     1  0.0865      0.784 0.964 0.036 0.000 0.000 0.000 0.000
#> ERR519472     4  0.2730      0.472 0.000 0.000 0.000 0.808 0.192 0.000
#> ERR519510     5  0.4217      0.419 0.016 0.260 0.000 0.000 0.700 0.024
#> ERR519470     1  0.3563      0.284 0.664 0.336 0.000 0.000 0.000 0.000
#> ERR519495     4  0.2793      0.462 0.000 0.000 0.000 0.800 0.200 0.000
#> ERR519522     4  0.3530      0.611 0.000 0.028 0.160 0.800 0.008 0.004
#> ERR519523     4  0.3938      0.491 0.000 0.012 0.312 0.672 0.000 0.004
#> ERR519503     6  0.2257      0.799 0.008 0.000 0.116 0.000 0.000 0.876
#> ERR519471     1  0.1411      0.765 0.936 0.060 0.000 0.000 0.000 0.004
#> ERR519500     4  0.3052      0.439 0.000 0.004 0.000 0.780 0.216 0.000
#> ERR519485     1  0.1895      0.738 0.912 0.072 0.000 0.000 0.016 0.000
#> ERR519476     1  0.0000      0.794 1.000 0.000 0.000 0.000 0.000 0.000
#> ERR519502     4  0.3347      0.580 0.000 0.004 0.068 0.824 0.104 0.000
#> ERR519486     2  0.7545     -0.147 0.180 0.428 0.020 0.000 0.252 0.120
#> ERR519478     2  0.4497      0.586 0.328 0.624 0.000 0.000 0.048 0.000
#> ERR519497     3  0.4226      0.237 0.000 0.012 0.580 0.404 0.000 0.004
#> ERR519467     4  0.3685      0.577 0.000 0.024 0.060 0.832 0.068 0.016
#> ERR519489     4  0.5260      0.452 0.000 0.004 0.348 0.552 0.096 0.000
#> ERR519494     3  0.0713      0.787 0.000 0.000 0.972 0.028 0.000 0.000
#> ERR519474     1  0.1500      0.759 0.936 0.052 0.000 0.000 0.012 0.000
#> ERR519505     6  0.1492      0.792 0.000 0.036 0.000 0.000 0.024 0.940
#> ERR519517     3  0.0000      0.803 0.000 0.000 1.000 0.000 0.000 0.000
#> ERR519484     5  0.4455      0.413 0.028 0.248 0.000 0.000 0.696 0.028
#> ERR519498     3  0.6546      0.528 0.000 0.156 0.612 0.064 0.056 0.112
#> ERR519490     3  0.0260      0.800 0.000 0.000 0.992 0.008 0.000 0.000
#> ERR519507     5  0.4664      0.115 0.000 0.032 0.000 0.476 0.488 0.004
#> ERR519511     5  0.4000      0.373 0.008 0.324 0.000 0.000 0.660 0.008
#> ERR519468     3  0.0000      0.803 0.000 0.000 1.000 0.000 0.000 0.000
#> ERR519482     3  0.0000      0.803 0.000 0.000 1.000 0.000 0.000 0.000
#> ERR519475     1  0.0000      0.794 1.000 0.000 0.000 0.000 0.000 0.000
#> ERR519496     2  0.4939      0.595 0.292 0.612 0.000 0.000 0.096 0.000
#> ERR519506     6  0.2257      0.794 0.116 0.008 0.000 0.000 0.000 0.876
#> ERR519469     3  0.3592      0.376 0.000 0.000 0.656 0.344 0.000 0.000
#> ERR519480     3  0.0000      0.803 0.000 0.000 1.000 0.000 0.000 0.000
#> ERR519487     3  0.0000      0.803 0.000 0.000 1.000 0.000 0.000 0.000
#> ERR519483     1  0.1707      0.752 0.928 0.056 0.000 0.000 0.004 0.012
#> ERR519477     1  0.0000      0.794 1.000 0.000 0.000 0.000 0.000 0.000
#> ERR519499     3  0.0000      0.803 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 18140 rows and 52 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 5.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk ATC-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.112 0.889   0.889
#> 3 3 1.000           0.986       0.995          3.951 0.557   0.501
#> 4 4 1.000           0.950       0.983          0.128 0.926   0.834
#> 5 5 0.918           0.874       0.956          0.209 0.807   0.523
#> 6 6 0.878           0.842       0.953          0.019 0.986   0.942

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette p1 p2
#> ERR519515     1       0          1  1  0
#> ERR519516     1       0          1  1  0
#> ERR519520     1       0          1  1  0
#> ERR519513     1       0          1  1  0
#> ERR519481     1       0          1  1  0
#> ERR519491     1       0          1  1  0
#> ERR519473     1       0          1  1  0
#> ERR519518     1       0          1  1  0
#> ERR519512     1       0          1  1  0
#> ERR519521     1       0          1  1  0
#> ERR519488     1       0          1  1  0
#> ERR519493     1       0          1  1  0
#> ERR519514     1       0          1  1  0
#> ERR519479     1       0          1  1  0
#> ERR519509     1       0          1  1  0
#> ERR519472     1       0          1  1  0
#> ERR519510     1       0          1  1  0
#> ERR519470     1       0          1  1  0
#> ERR519495     1       0          1  1  0
#> ERR519522     1       0          1  1  0
#> ERR519523     1       0          1  1  0
#> ERR519503     1       0          1  1  0
#> ERR519471     1       0          1  1  0
#> ERR519500     1       0          1  1  0
#> ERR519485     1       0          1  1  0
#> ERR519476     2       0          1  0  1
#> ERR519502     1       0          1  1  0
#> ERR519486     1       0          1  1  0
#> ERR519478     1       0          1  1  0
#> ERR519497     1       0          1  1  0
#> ERR519467     1       0          1  1  0
#> ERR519489     1       0          1  1  0
#> ERR519494     1       0          1  1  0
#> ERR519474     1       0          1  1  0
#> ERR519505     1       0          1  1  0
#> ERR519517     1       0          1  1  0
#> ERR519484     1       0          1  1  0
#> ERR519498     1       0          1  1  0
#> ERR519490     1       0          1  1  0
#> ERR519507     1       0          1  1  0
#> ERR519511     1       0          1  1  0
#> ERR519468     1       0          1  1  0
#> ERR519482     1       0          1  1  0
#> ERR519475     2       0          1  0  1
#> ERR519496     1       0          1  1  0
#> ERR519506     1       0          1  1  0
#> ERR519469     1       0          1  1  0
#> ERR519480     1       0          1  1  0
#> ERR519487     1       0          1  1  0
#> ERR519483     1       0          1  1  0
#> ERR519477     2       0          1  0  1
#> ERR519499     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
#> ERR519515     1   0.000      1.000 1.00  0 0.00
#> ERR519516     1   0.000      1.000 1.00  0 0.00
#> ERR519520     3   0.000      0.983 0.00  0 1.00
#> ERR519513     3   0.000      0.983 0.00  0 1.00
#> ERR519481     3   0.000      0.983 0.00  0 1.00
#> ERR519491     1   0.000      1.000 1.00  0 0.00
#> ERR519473     3   0.000      0.983 0.00  0 1.00
#> ERR519518     3   0.000      0.983 0.00  0 1.00
#> ERR519512     3   0.000      0.983 0.00  0 1.00
#> ERR519521     3   0.000      0.983 0.00  0 1.00
#> ERR519488     1   0.000      1.000 1.00  0 0.00
#> ERR519493     1   0.000      1.000 1.00  0 0.00
#> ERR519514     1   0.000      1.000 1.00  0 0.00
#> ERR519479     1   0.000      1.000 1.00  0 0.00
#> ERR519509     1   0.000      1.000 1.00  0 0.00
#> ERR519472     1   0.000      1.000 1.00  0 0.00
#> ERR519510     1   0.000      1.000 1.00  0 0.00
#> ERR519470     1   0.000      1.000 1.00  0 0.00
#> ERR519495     1   0.000      1.000 1.00  0 0.00
#> ERR519522     3   0.000      0.983 0.00  0 1.00
#> ERR519523     3   0.000      0.983 0.00  0 1.00
#> ERR519503     1   0.000      1.000 1.00  0 0.00
#> ERR519471     1   0.000      1.000 1.00  0 0.00
#> ERR519500     1   0.000      1.000 1.00  0 0.00
#> ERR519485     1   0.000      1.000 1.00  0 0.00
#> ERR519476     2   0.000      1.000 0.00  1 0.00
#> ERR519502     3   0.000      0.983 0.00  0 1.00
#> ERR519486     1   0.000      1.000 1.00  0 0.00
#> ERR519478     1   0.000      1.000 1.00  0 0.00
#> ERR519497     3   0.000      0.983 0.00  0 1.00
#> ERR519467     1   0.000      1.000 1.00  0 0.00
#> ERR519489     3   0.502      0.595 0.24  0 0.76
#> ERR519494     3   0.000      0.983 0.00  0 1.00
#> ERR519474     1   0.000      1.000 1.00  0 0.00
#> ERR519505     1   0.000      1.000 1.00  0 0.00
#> ERR519517     3   0.000      0.983 0.00  0 1.00
#> ERR519484     1   0.000      1.000 1.00  0 0.00
#> ERR519498     1   0.000      1.000 1.00  0 0.00
#> ERR519490     3   0.000      0.983 0.00  0 1.00
#> ERR519507     1   0.000      1.000 1.00  0 0.00
#> ERR519511     1   0.000      1.000 1.00  0 0.00
#> ERR519468     3   0.000      0.983 0.00  0 1.00
#> ERR519482     3   0.000      0.983 0.00  0 1.00
#> ERR519475     2   0.000      1.000 0.00  1 0.00
#> ERR519496     1   0.000      1.000 1.00  0 0.00
#> ERR519506     1   0.000      1.000 1.00  0 0.00
#> ERR519469     3   0.000      0.983 0.00  0 1.00
#> ERR519480     3   0.000      0.983 0.00  0 1.00
#> ERR519487     3   0.000      0.983 0.00  0 1.00
#> ERR519483     1   0.000      1.000 1.00  0 0.00
#> ERR519477     2   0.000      1.000 0.00  1 0.00
#> ERR519499     3   0.000      0.983 0.00  0 1.00

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1 p2    p3    p4
#> ERR519515     1  0.0000     0.9972 1.000  0 0.000 0.000
#> ERR519516     1  0.0000     0.9972 1.000  0 0.000 0.000
#> ERR519520     4  0.0336     0.9686 0.000  0 0.008 0.992
#> ERR519513     4  0.0469     0.9665 0.000  0 0.012 0.988
#> ERR519481     4  0.0000     0.9648 0.000  0 0.000 1.000
#> ERR519491     1  0.0000     0.9972 1.000  0 0.000 0.000
#> ERR519473     4  0.0188     0.9674 0.000  0 0.004 0.996
#> ERR519518     4  0.0336     0.9686 0.000  0 0.008 0.992
#> ERR519512     4  0.0336     0.9686 0.000  0 0.008 0.992
#> ERR519521     4  0.0336     0.9686 0.000  0 0.008 0.992
#> ERR519488     1  0.0000     0.9972 1.000  0 0.000 0.000
#> ERR519493     1  0.0000     0.9972 1.000  0 0.000 0.000
#> ERR519514     1  0.0000     0.9972 1.000  0 0.000 0.000
#> ERR519479     1  0.0336     0.9940 0.992  0 0.000 0.008
#> ERR519509     1  0.0000     0.9972 1.000  0 0.000 0.000
#> ERR519472     1  0.0336     0.9940 0.992  0 0.000 0.008
#> ERR519510     1  0.0000     0.9972 1.000  0 0.000 0.000
#> ERR519470     1  0.0000     0.9972 1.000  0 0.000 0.000
#> ERR519495     1  0.0336     0.9940 0.992  0 0.000 0.008
#> ERR519522     4  0.0188     0.9672 0.000  0 0.004 0.996
#> ERR519523     4  0.0336     0.9686 0.000  0 0.008 0.992
#> ERR519503     1  0.0188     0.9957 0.996  0 0.000 0.004
#> ERR519471     1  0.0000     0.9972 1.000  0 0.000 0.000
#> ERR519500     1  0.0336     0.9940 0.992  0 0.000 0.008
#> ERR519485     1  0.0000     0.9972 1.000  0 0.000 0.000
#> ERR519476     2  0.0000     1.0000 0.000  1 0.000 0.000
#> ERR519502     4  0.0000     0.9648 0.000  0 0.000 1.000
#> ERR519486     1  0.0188     0.9957 0.996  0 0.000 0.004
#> ERR519478     1  0.0000     0.9972 1.000  0 0.000 0.000
#> ERR519497     4  0.0336     0.9686 0.000  0 0.008 0.992
#> ERR519467     1  0.0592     0.9867 0.984  0 0.000 0.016
#> ERR519489     4  0.3837     0.5927 0.224  0 0.000 0.776
#> ERR519494     3  0.4994     0.0753 0.000  0 0.520 0.480
#> ERR519474     1  0.0000     0.9972 1.000  0 0.000 0.000
#> ERR519505     1  0.0336     0.9940 0.992  0 0.000 0.008
#> ERR519517     3  0.0000     0.8817 0.000  0 1.000 0.000
#> ERR519484     1  0.0000     0.9972 1.000  0 0.000 0.000
#> ERR519498     1  0.0376     0.9935 0.992  0 0.004 0.004
#> ERR519490     4  0.0469     0.9662 0.000  0 0.012 0.988
#> ERR519507     1  0.0336     0.9940 0.992  0 0.000 0.008
#> ERR519511     1  0.0000     0.9972 1.000  0 0.000 0.000
#> ERR519468     3  0.0000     0.8817 0.000  0 1.000 0.000
#> ERR519482     3  0.0000     0.8817 0.000  0 1.000 0.000
#> ERR519475     2  0.0000     1.0000 0.000  1 0.000 0.000
#> ERR519496     1  0.0000     0.9972 1.000  0 0.000 0.000
#> ERR519506     1  0.0000     0.9972 1.000  0 0.000 0.000
#> ERR519469     4  0.0188     0.9674 0.000  0 0.004 0.996
#> ERR519480     3  0.0000     0.8817 0.000  0 1.000 0.000
#> ERR519487     3  0.0000     0.8817 0.000  0 1.000 0.000
#> ERR519483     1  0.0000     0.9972 1.000  0 0.000 0.000
#> ERR519477     2  0.0000     1.0000 0.000  1 0.000 0.000
#> ERR519499     3  0.0000     0.8817 0.000  0 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1 p2    p3    p4    p5
#> ERR519515     1  0.0000     0.9572 1.000  0 0.000 0.000 0.000
#> ERR519516     1  0.0000     0.9572 1.000  0 0.000 0.000 0.000
#> ERR519520     5  0.0000     0.9447 0.000  0 0.000 0.000 1.000
#> ERR519513     5  0.0162     0.9424 0.000  0 0.004 0.000 0.996
#> ERR519481     4  0.0162     0.9078 0.000  0 0.000 0.996 0.004
#> ERR519491     1  0.0000     0.9572 1.000  0 0.000 0.000 0.000
#> ERR519473     4  0.3177     0.7135 0.000  0 0.000 0.792 0.208
#> ERR519518     5  0.0000     0.9447 0.000  0 0.000 0.000 1.000
#> ERR519512     5  0.0000     0.9447 0.000  0 0.000 0.000 1.000
#> ERR519521     5  0.0000     0.9447 0.000  0 0.000 0.000 1.000
#> ERR519488     1  0.0000     0.9572 1.000  0 0.000 0.000 0.000
#> ERR519493     1  0.0000     0.9572 1.000  0 0.000 0.000 0.000
#> ERR519514     1  0.0000     0.9572 1.000  0 0.000 0.000 0.000
#> ERR519479     4  0.0162     0.9088 0.004  0 0.000 0.996 0.000
#> ERR519509     1  0.0000     0.9572 1.000  0 0.000 0.000 0.000
#> ERR519472     4  0.0162     0.9088 0.004  0 0.000 0.996 0.000
#> ERR519510     1  0.0000     0.9572 1.000  0 0.000 0.000 0.000
#> ERR519470     1  0.0000     0.9572 1.000  0 0.000 0.000 0.000
#> ERR519495     4  0.0162     0.9088 0.004  0 0.000 0.996 0.000
#> ERR519522     5  0.2852     0.7726 0.000  0 0.000 0.172 0.828
#> ERR519523     5  0.0000     0.9447 0.000  0 0.000 0.000 1.000
#> ERR519503     1  0.4307    -0.0693 0.504  0 0.000 0.496 0.000
#> ERR519471     1  0.0000     0.9572 1.000  0 0.000 0.000 0.000
#> ERR519500     4  0.0162     0.9088 0.004  0 0.000 0.996 0.000
#> ERR519485     1  0.0000     0.9572 1.000  0 0.000 0.000 0.000
#> ERR519476     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000
#> ERR519502     4  0.0162     0.9078 0.000  0 0.000 0.996 0.004
#> ERR519486     1  0.2852     0.7511 0.828  0 0.000 0.172 0.000
#> ERR519478     1  0.0000     0.9572 1.000  0 0.000 0.000 0.000
#> ERR519497     5  0.0000     0.9447 0.000  0 0.000 0.000 1.000
#> ERR519467     4  0.0566     0.9025 0.004  0 0.000 0.984 0.012
#> ERR519489     4  0.0162     0.9078 0.000  0 0.000 0.996 0.004
#> ERR519494     3  0.4306     0.0528 0.000  0 0.508 0.000 0.492
#> ERR519474     1  0.0000     0.9572 1.000  0 0.000 0.000 0.000
#> ERR519505     4  0.3913     0.4647 0.324  0 0.000 0.676 0.000
#> ERR519517     3  0.0000     0.8921 0.000  0 1.000 0.000 0.000
#> ERR519484     1  0.0000     0.9572 1.000  0 0.000 0.000 0.000
#> ERR519498     5  0.3160     0.7511 0.004  0 0.000 0.188 0.808
#> ERR519490     5  0.0162     0.9421 0.000  0 0.004 0.000 0.996
#> ERR519507     4  0.0162     0.9088 0.004  0 0.000 0.996 0.000
#> ERR519511     1  0.0000     0.9572 1.000  0 0.000 0.000 0.000
#> ERR519468     3  0.0000     0.8921 0.000  0 1.000 0.000 0.000
#> ERR519482     3  0.0000     0.8921 0.000  0 1.000 0.000 0.000
#> ERR519475     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000
#> ERR519496     1  0.0000     0.9572 1.000  0 0.000 0.000 0.000
#> ERR519506     1  0.0290     0.9498 0.992  0 0.000 0.008 0.000
#> ERR519469     4  0.2966     0.7435 0.000  0 0.000 0.816 0.184
#> ERR519480     3  0.0000     0.8921 0.000  0 1.000 0.000 0.000
#> ERR519487     3  0.0000     0.8921 0.000  0 1.000 0.000 0.000
#> ERR519483     1  0.0162     0.9536 0.996  0 0.000 0.004 0.000
#> ERR519477     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000
#> ERR519499     3  0.0000     0.8921 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
#> ERR519515     1  0.0000     0.9410 1.000  0 0.000 0.000 0.000 0.000
#> ERR519516     1  0.0000     0.9410 1.000  0 0.000 0.000 0.000 0.000
#> ERR519520     4  0.0000     0.9407 0.000  0 0.000 1.000 0.000 0.000
#> ERR519513     4  0.0146     0.9382 0.000  0 0.004 0.996 0.000 0.000
#> ERR519481     5  0.0000     0.9050 0.000  0 0.000 0.000 1.000 0.000
#> ERR519491     1  0.0000     0.9410 1.000  0 0.000 0.000 0.000 0.000
#> ERR519473     5  0.2823     0.6905 0.000  0 0.000 0.204 0.796 0.000
#> ERR519518     4  0.0000     0.9407 0.000  0 0.000 1.000 0.000 0.000
#> ERR519512     4  0.0000     0.9407 0.000  0 0.000 1.000 0.000 0.000
#> ERR519521     4  0.0000     0.9407 0.000  0 0.000 1.000 0.000 0.000
#> ERR519488     1  0.0000     0.9410 1.000  0 0.000 0.000 0.000 0.000
#> ERR519493     1  0.0000     0.9410 1.000  0 0.000 0.000 0.000 0.000
#> ERR519514     1  0.0000     0.9410 1.000  0 0.000 0.000 0.000 0.000
#> ERR519479     5  0.0000     0.9050 0.000  0 0.000 0.000 1.000 0.000
#> ERR519509     1  0.0000     0.9410 1.000  0 0.000 0.000 0.000 0.000
#> ERR519472     5  0.0000     0.9050 0.000  0 0.000 0.000 1.000 0.000
#> ERR519510     1  0.0000     0.9410 1.000  0 0.000 0.000 0.000 0.000
#> ERR519470     1  0.0000     0.9410 1.000  0 0.000 0.000 0.000 0.000
#> ERR519495     5  0.0000     0.9050 0.000  0 0.000 0.000 1.000 0.000
#> ERR519522     4  0.2562     0.7513 0.000  0 0.000 0.828 0.172 0.000
#> ERR519523     4  0.0000     0.9407 0.000  0 0.000 1.000 0.000 0.000
#> ERR519503     1  0.3868    -0.0617 0.504  0 0.000 0.000 0.496 0.000
#> ERR519471     1  0.0000     0.9410 1.000  0 0.000 0.000 0.000 0.000
#> ERR519500     5  0.0000     0.9050 0.000  0 0.000 0.000 1.000 0.000
#> ERR519485     1  0.0000     0.9410 1.000  0 0.000 0.000 0.000 0.000
#> ERR519476     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000 0.000
#> ERR519502     5  0.0000     0.9050 0.000  0 0.000 0.000 1.000 0.000
#> ERR519486     1  0.2562     0.7030 0.828  0 0.000 0.000 0.172 0.000
#> ERR519478     1  0.0000     0.9410 1.000  0 0.000 0.000 0.000 0.000
#> ERR519497     4  0.0000     0.9407 0.000  0 0.000 1.000 0.000 0.000
#> ERR519467     5  0.0363     0.8961 0.000  0 0.000 0.012 0.988 0.000
#> ERR519489     5  0.0000     0.9050 0.000  0 0.000 0.000 1.000 0.000
#> ERR519494     3  0.3868     0.0533 0.000  0 0.508 0.492 0.000 0.000
#> ERR519474     1  0.0000     0.9410 1.000  0 0.000 0.000 0.000 0.000
#> ERR519505     5  0.3515     0.3734 0.324  0 0.000 0.000 0.676 0.000
#> ERR519517     3  0.0000     0.8797 0.000  0 1.000 0.000 0.000 0.000
#> ERR519484     1  0.0000     0.9410 1.000  0 0.000 0.000 0.000 0.000
#> ERR519498     4  0.2697     0.7315 0.000  0 0.000 0.812 0.188 0.000
#> ERR519490     4  0.0146     0.9379 0.000  0 0.004 0.996 0.000 0.000
#> ERR519507     5  0.0000     0.9050 0.000  0 0.000 0.000 1.000 0.000
#> ERR519511     1  0.0000     0.9410 1.000  0 0.000 0.000 0.000 0.000
#> ERR519468     3  0.0000     0.8797 0.000  0 1.000 0.000 0.000 0.000
#> ERR519482     3  0.0000     0.8797 0.000  0 1.000 0.000 0.000 0.000
#> ERR519475     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000 0.000
#> ERR519496     1  0.0000     0.9410 1.000  0 0.000 0.000 0.000 0.000
#> ERR519506     6  0.1910     0.0000 0.108  0 0.000 0.000 0.000 0.892
#> ERR519469     5  0.2631     0.7238 0.000  0 0.000 0.180 0.820 0.000
#> ERR519480     3  0.0000     0.8797 0.000  0 1.000 0.000 0.000 0.000
#> ERR519487     3  0.0000     0.8797 0.000  0 1.000 0.000 0.000 0.000
#> ERR519483     1  0.1910     0.8335 0.892  0 0.000 0.000 0.000 0.108
#> ERR519477     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000 0.000
#> ERR519499     3  0.0000     0.8797 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 18140 rows and 52 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 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-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.743           0.929       0.957          0.291 0.708   0.708
#> 3 3 0.481           0.755       0.879          0.562 0.882   0.837
#> 4 4 0.570           0.854       0.872          0.455 0.643   0.444
#> 5 5 0.659           0.504       0.756          0.043 0.686   0.331
#> 6 6 0.639           0.576       0.779          0.126 0.783   0.421

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
#> ERR519515     1  0.0000      0.970 1.000 0.000
#> ERR519516     1  0.0000      0.970 1.000 0.000
#> ERR519520     1  0.0000      0.970 1.000 0.000
#> ERR519513     1  0.6148      0.825 0.848 0.152
#> ERR519481     1  0.0000      0.970 1.000 0.000
#> ERR519491     1  0.0000      0.970 1.000 0.000
#> ERR519473     1  0.1414      0.959 0.980 0.020
#> ERR519518     1  0.1414      0.959 0.980 0.020
#> ERR519512     1  0.0000      0.970 1.000 0.000
#> ERR519521     1  0.0000      0.970 1.000 0.000
#> ERR519488     1  0.0000      0.970 1.000 0.000
#> ERR519493     1  0.0000      0.970 1.000 0.000
#> ERR519514     1  0.0000      0.970 1.000 0.000
#> ERR519479     1  0.0000      0.970 1.000 0.000
#> ERR519509     1  0.0000      0.970 1.000 0.000
#> ERR519472     1  0.0000      0.970 1.000 0.000
#> ERR519510     1  0.0000      0.970 1.000 0.000
#> ERR519470     1  0.0000      0.970 1.000 0.000
#> ERR519495     1  0.0000      0.970 1.000 0.000
#> ERR519522     1  0.0000      0.970 1.000 0.000
#> ERR519523     1  0.0000      0.970 1.000 0.000
#> ERR519503     1  0.5629      0.858 0.868 0.132
#> ERR519471     1  0.1414      0.959 0.980 0.020
#> ERR519500     1  0.0000      0.970 1.000 0.000
#> ERR519485     1  0.0672      0.966 0.992 0.008
#> ERR519476     2  0.0000      0.867 0.000 1.000
#> ERR519502     1  0.0000      0.970 1.000 0.000
#> ERR519486     1  0.0376      0.968 0.996 0.004
#> ERR519478     1  0.0000      0.970 1.000 0.000
#> ERR519497     1  0.0938      0.964 0.988 0.012
#> ERR519467     1  0.0000      0.970 1.000 0.000
#> ERR519489     1  0.0000      0.970 1.000 0.000
#> ERR519494     1  0.3114      0.931 0.944 0.056
#> ERR519474     1  0.0000      0.970 1.000 0.000
#> ERR519505     1  0.3584      0.923 0.932 0.068
#> ERR519517     2  0.5629      0.894 0.132 0.868
#> ERR519484     1  0.0000      0.970 1.000 0.000
#> ERR519498     1  0.1633      0.956 0.976 0.024
#> ERR519490     1  0.3274      0.927 0.940 0.060
#> ERR519507     1  0.0000      0.970 1.000 0.000
#> ERR519511     1  0.0000      0.970 1.000 0.000
#> ERR519468     2  0.8016      0.800 0.244 0.756
#> ERR519482     2  0.8386      0.768 0.268 0.732
#> ERR519475     2  0.0000      0.867 0.000 1.000
#> ERR519496     1  0.0000      0.970 1.000 0.000
#> ERR519506     1  0.8555      0.624 0.720 0.280
#> ERR519469     1  0.4022      0.912 0.920 0.080
#> ERR519480     2  0.4690      0.892 0.100 0.900
#> ERR519487     2  0.6148      0.889 0.152 0.848
#> ERR519483     1  0.7950      0.689 0.760 0.240
#> ERR519477     2  0.0000      0.867 0.000 1.000
#> ERR519499     2  0.6148      0.889 0.152 0.848

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> ERR519515     1  0.0000    0.84038 1.000 0.000 0.000
#> ERR519516     1  0.0000    0.84038 1.000 0.000 0.000
#> ERR519520     1  0.5363    0.71673 0.724 0.000 0.276
#> ERR519513     1  0.6925    0.31026 0.532 0.016 0.452
#> ERR519481     1  0.4121    0.79467 0.832 0.000 0.168
#> ERR519491     1  0.0237    0.83987 0.996 0.000 0.004
#> ERR519473     1  0.5785    0.64788 0.668 0.000 0.332
#> ERR519518     1  0.5785    0.64788 0.668 0.000 0.332
#> ERR519512     1  0.5465    0.70416 0.712 0.000 0.288
#> ERR519521     1  0.5397    0.71284 0.720 0.000 0.280
#> ERR519488     1  0.0000    0.84038 1.000 0.000 0.000
#> ERR519493     1  0.0000    0.84038 1.000 0.000 0.000
#> ERR519514     1  0.0000    0.84038 1.000 0.000 0.000
#> ERR519479     1  0.0000    0.84038 1.000 0.000 0.000
#> ERR519509     1  0.0000    0.84038 1.000 0.000 0.000
#> ERR519472     1  0.4887    0.76420 0.772 0.000 0.228
#> ERR519510     1  0.0000    0.84038 1.000 0.000 0.000
#> ERR519470     1  0.0000    0.84038 1.000 0.000 0.000
#> ERR519495     1  0.3879    0.80046 0.848 0.000 0.152
#> ERR519522     1  0.4235    0.79395 0.824 0.000 0.176
#> ERR519523     1  0.5465    0.70416 0.712 0.000 0.288
#> ERR519503     1  0.7184    0.00189 0.504 0.024 0.472
#> ERR519471     1  0.0424    0.83939 0.992 0.000 0.008
#> ERR519500     1  0.4702    0.77612 0.788 0.000 0.212
#> ERR519485     1  0.0000    0.84038 1.000 0.000 0.000
#> ERR519476     2  0.0000    1.00000 0.000 1.000 0.000
#> ERR519502     1  0.4750    0.77101 0.784 0.000 0.216
#> ERR519486     1  0.0000    0.84038 1.000 0.000 0.000
#> ERR519478     1  0.0000    0.84038 1.000 0.000 0.000
#> ERR519497     1  0.4750    0.77101 0.784 0.000 0.216
#> ERR519467     1  0.3619    0.80766 0.864 0.000 0.136
#> ERR519489     1  0.4887    0.76417 0.772 0.000 0.228
#> ERR519494     3  0.4399    0.58510 0.188 0.000 0.812
#> ERR519474     1  0.0000    0.84038 1.000 0.000 0.000
#> ERR519505     1  0.5656    0.53555 0.728 0.008 0.264
#> ERR519517     3  0.2261    0.81728 0.000 0.068 0.932
#> ERR519484     1  0.0000    0.84038 1.000 0.000 0.000
#> ERR519498     1  0.4033    0.80788 0.856 0.008 0.136
#> ERR519490     3  0.0237    0.80896 0.004 0.000 0.996
#> ERR519507     1  0.0237    0.83987 0.996 0.000 0.004
#> ERR519511     1  0.0000    0.84038 1.000 0.000 0.000
#> ERR519468     3  0.2165    0.82030 0.000 0.064 0.936
#> ERR519482     3  0.2165    0.82030 0.000 0.064 0.936
#> ERR519475     2  0.0000    1.00000 0.000 1.000 0.000
#> ERR519496     1  0.0000    0.84038 1.000 0.000 0.000
#> ERR519506     1  0.7112    0.12958 0.552 0.024 0.424
#> ERR519469     3  0.6229    0.21946 0.340 0.008 0.652
#> ERR519480     3  0.1643    0.82188 0.000 0.044 0.956
#> ERR519487     3  0.2537    0.80786 0.000 0.080 0.920
#> ERR519483     1  0.2383    0.81166 0.940 0.044 0.016
#> ERR519477     2  0.0000    1.00000 0.000 1.000 0.000
#> ERR519499     3  0.0592    0.81452 0.000 0.012 0.988

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> ERR519515     1  0.0000      0.940 1.000 0.000 0.000 0.000
#> ERR519516     1  0.0000      0.940 1.000 0.000 0.000 0.000
#> ERR519520     4  0.5462      0.880 0.152 0.000 0.112 0.736
#> ERR519513     3  0.5977      0.135 0.040 0.000 0.528 0.432
#> ERR519481     4  0.3172      0.920 0.160 0.000 0.000 0.840
#> ERR519491     1  0.0000      0.940 1.000 0.000 0.000 0.000
#> ERR519473     4  0.5416      0.878 0.148 0.000 0.112 0.740
#> ERR519518     3  0.7113      0.058 0.152 0.000 0.532 0.316
#> ERR519512     4  0.5462      0.880 0.152 0.000 0.112 0.736
#> ERR519521     4  0.5462      0.880 0.152 0.000 0.112 0.736
#> ERR519488     1  0.0000      0.940 1.000 0.000 0.000 0.000
#> ERR519493     1  0.0000      0.940 1.000 0.000 0.000 0.000
#> ERR519514     1  0.0000      0.940 1.000 0.000 0.000 0.000
#> ERR519479     4  0.3172      0.920 0.160 0.000 0.000 0.840
#> ERR519509     1  0.0000      0.940 1.000 0.000 0.000 0.000
#> ERR519472     4  0.3172      0.920 0.160 0.000 0.000 0.840
#> ERR519510     1  0.0000      0.940 1.000 0.000 0.000 0.000
#> ERR519470     1  0.0000      0.940 1.000 0.000 0.000 0.000
#> ERR519495     4  0.3172      0.920 0.160 0.000 0.000 0.840
#> ERR519522     4  0.3172      0.920 0.160 0.000 0.000 0.840
#> ERR519523     4  0.5462      0.880 0.152 0.000 0.112 0.736
#> ERR519503     1  0.5618      0.635 0.668 0.004 0.040 0.288
#> ERR519471     1  0.0000      0.940 1.000 0.000 0.000 0.000
#> ERR519500     4  0.3172      0.920 0.160 0.000 0.000 0.840
#> ERR519485     1  0.0000      0.940 1.000 0.000 0.000 0.000
#> ERR519476     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> ERR519502     4  0.3172      0.920 0.160 0.000 0.000 0.840
#> ERR519486     1  0.1211      0.910 0.960 0.000 0.000 0.040
#> ERR519478     1  0.1118      0.909 0.964 0.000 0.000 0.036
#> ERR519497     4  0.5462      0.880 0.152 0.000 0.112 0.736
#> ERR519467     4  0.3172      0.920 0.160 0.000 0.000 0.840
#> ERR519489     4  0.3172      0.920 0.160 0.000 0.000 0.840
#> ERR519494     3  0.1388      0.806 0.028 0.000 0.960 0.012
#> ERR519474     1  0.0000      0.940 1.000 0.000 0.000 0.000
#> ERR519505     1  0.5530      0.566 0.616 0.004 0.020 0.360
#> ERR519517     3  0.0000      0.838 0.000 0.000 1.000 0.000
#> ERR519484     1  0.0000      0.940 1.000 0.000 0.000 0.000
#> ERR519498     4  0.4410      0.748 0.064 0.000 0.128 0.808
#> ERR519490     3  0.0336      0.834 0.000 0.000 0.992 0.008
#> ERR519507     4  0.3172      0.920 0.160 0.000 0.000 0.840
#> ERR519511     1  0.0188      0.937 0.996 0.000 0.000 0.004
#> ERR519468     3  0.0000      0.838 0.000 0.000 1.000 0.000
#> ERR519482     3  0.0000      0.838 0.000 0.000 1.000 0.000
#> ERR519475     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> ERR519496     1  0.0188      0.937 0.996 0.000 0.000 0.004
#> ERR519506     1  0.4513      0.738 0.796 0.004 0.040 0.160
#> ERR519469     4  0.3377      0.680 0.012 0.000 0.140 0.848
#> ERR519480     3  0.0000      0.838 0.000 0.000 1.000 0.000
#> ERR519487     3  0.0000      0.838 0.000 0.000 1.000 0.000
#> ERR519483     1  0.3105      0.773 0.856 0.004 0.140 0.000
#> ERR519477     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> ERR519499     3  0.0000      0.838 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
#> ERR519515     1  0.0000     0.6850 1.000 0.000 0.000 0.000 0.000
#> ERR519516     1  0.0000     0.6850 1.000 0.000 0.000 0.000 0.000
#> ERR519520     1  0.5513     0.4389 0.524 0.408 0.068 0.000 0.000
#> ERR519513     5  0.3318     0.4949 0.000 0.000 0.192 0.008 0.800
#> ERR519481     1  0.4297     0.4608 0.528 0.472 0.000 0.000 0.000
#> ERR519491     1  0.0000     0.6850 1.000 0.000 0.000 0.000 0.000
#> ERR519473     4  0.5519     0.5292 0.000 0.412 0.068 0.520 0.000
#> ERR519518     4  0.5892     0.5560 0.000 0.372 0.108 0.520 0.000
#> ERR519512     1  0.5513     0.4389 0.524 0.408 0.068 0.000 0.000
#> ERR519521     1  0.5513     0.4389 0.524 0.408 0.068 0.000 0.000
#> ERR519488     1  0.0162     0.6811 0.996 0.000 0.000 0.000 0.004
#> ERR519493     1  0.0000     0.6850 1.000 0.000 0.000 0.000 0.000
#> ERR519514     1  0.0000     0.6850 1.000 0.000 0.000 0.000 0.000
#> ERR519479     1  0.4291     0.4681 0.536 0.464 0.000 0.000 0.000
#> ERR519509     1  0.0000     0.6850 1.000 0.000 0.000 0.000 0.000
#> ERR519472     2  0.5238    -0.4920 0.476 0.480 0.000 0.044 0.000
#> ERR519510     1  0.0000     0.6850 1.000 0.000 0.000 0.000 0.000
#> ERR519470     1  0.0000     0.6850 1.000 0.000 0.000 0.000 0.000
#> ERR519495     1  0.4297     0.4608 0.528 0.472 0.000 0.000 0.000
#> ERR519522     1  0.4291     0.4681 0.536 0.464 0.000 0.000 0.000
#> ERR519523     1  0.5513     0.4389 0.524 0.408 0.068 0.000 0.000
#> ERR519503     4  0.7532     0.1752 0.120 0.156 0.000 0.516 0.208
#> ERR519471     1  0.1908     0.5757 0.908 0.000 0.000 0.092 0.000
#> ERR519500     1  0.4302     0.4508 0.520 0.480 0.000 0.000 0.000
#> ERR519485     5  0.4302     0.4443 0.480 0.000 0.000 0.000 0.520
#> ERR519476     2  0.4302     0.1415 0.000 0.520 0.000 0.480 0.000
#> ERR519502     1  0.4300     0.4557 0.524 0.476 0.000 0.000 0.000
#> ERR519486     5  0.4898     0.5748 0.248 0.068 0.000 0.000 0.684
#> ERR519478     1  0.0000     0.6850 1.000 0.000 0.000 0.000 0.000
#> ERR519497     2  0.7653    -0.3634 0.160 0.408 0.068 0.360 0.004
#> ERR519467     1  0.4297     0.4608 0.528 0.472 0.000 0.000 0.000
#> ERR519489     2  0.6556    -0.1471 0.260 0.476 0.000 0.264 0.000
#> ERR519494     4  0.5216     0.2789 0.000 0.044 0.436 0.520 0.000
#> ERR519474     1  0.0000     0.6850 1.000 0.000 0.000 0.000 0.000
#> ERR519505     5  0.5470     0.3482 0.008 0.080 0.000 0.272 0.640
#> ERR519517     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000
#> ERR519484     1  0.0000     0.6850 1.000 0.000 0.000 0.000 0.000
#> ERR519498     5  0.4218     0.5214 0.000 0.112 0.024 0.060 0.804
#> ERR519490     4  0.4307     0.0984 0.000 0.000 0.500 0.500 0.000
#> ERR519507     1  0.4291     0.4681 0.536 0.464 0.000 0.000 0.000
#> ERR519511     1  0.0000     0.6850 1.000 0.000 0.000 0.000 0.000
#> ERR519468     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000
#> ERR519482     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000
#> ERR519475     2  0.4302     0.1415 0.000 0.520 0.000 0.480 0.000
#> ERR519496     1  0.0000     0.6850 1.000 0.000 0.000 0.000 0.000
#> ERR519506     5  0.6824     0.0935 0.188 0.012 0.000 0.372 0.428
#> ERR519469     4  0.4650     0.4803 0.000 0.468 0.012 0.520 0.000
#> ERR519480     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000
#> ERR519487     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000
#> ERR519483     5  0.5094     0.5987 0.220 0.000 0.076 0.008 0.696
#> ERR519477     2  0.4302     0.1415 0.000 0.520 0.000 0.480 0.000
#> ERR519499     3  0.0000     1.0000 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
#> ERR519515     1  0.2980     0.7235 0.800  0 0.000 0.008 0.192 0.000
#> ERR519516     1  0.3144     0.5980 0.808  0 0.000 0.172 0.016 0.004
#> ERR519520     5  0.4172     0.3577 0.008  0 0.008 0.376 0.608 0.000
#> ERR519513     6  0.2664     0.4329 0.000  0 0.184 0.000 0.000 0.816
#> ERR519481     5  0.0547     0.7324 0.020  0 0.000 0.000 0.980 0.000
#> ERR519491     1  0.2823     0.7199 0.796  0 0.000 0.000 0.204 0.000
#> ERR519473     4  0.3758     0.4724 0.000  0 0.008 0.668 0.324 0.000
#> ERR519518     4  0.4408     0.5064 0.000  0 0.056 0.664 0.280 0.000
#> ERR519512     5  0.4274     0.3418 0.012  0 0.008 0.380 0.600 0.000
#> ERR519521     5  0.4264     0.3604 0.012  0 0.008 0.376 0.604 0.000
#> ERR519488     1  0.2955     0.5910 0.816  0 0.000 0.172 0.008 0.004
#> ERR519493     1  0.2823     0.7199 0.796  0 0.000 0.000 0.204 0.000
#> ERR519514     1  0.2793     0.7212 0.800  0 0.000 0.000 0.200 0.000
#> ERR519479     5  0.2823     0.5605 0.204  0 0.000 0.000 0.796 0.000
#> ERR519509     1  0.4403     0.6381 0.724  0 0.000 0.172 0.100 0.004
#> ERR519472     5  0.0603     0.7176 0.004  0 0.000 0.016 0.980 0.000
#> ERR519510     1  0.0260     0.6817 0.992  0 0.000 0.000 0.008 0.000
#> ERR519470     1  0.3485     0.7201 0.772  0 0.000 0.020 0.204 0.004
#> ERR519495     5  0.0547     0.7324 0.020  0 0.000 0.000 0.980 0.000
#> ERR519522     5  0.0547     0.7324 0.020  0 0.000 0.000 0.980 0.000
#> ERR519523     5  0.4172     0.3577 0.008  0 0.008 0.376 0.608 0.000
#> ERR519503     4  0.6416    -0.1282 0.384  0 0.000 0.444 0.080 0.092
#> ERR519471     1  0.1462     0.6571 0.936  0 0.000 0.056 0.008 0.000
#> ERR519500     5  0.0865     0.7232 0.036  0 0.000 0.000 0.964 0.000
#> ERR519485     1  0.5173     0.3258 0.636  0 0.000 0.172 0.004 0.188
#> ERR519476     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000 0.000
#> ERR519502     5  0.0363     0.7290 0.012  0 0.000 0.000 0.988 0.000
#> ERR519486     1  0.4503     0.3365 0.696  0 0.000 0.000 0.100 0.204
#> ERR519478     1  0.3198     0.6788 0.740  0 0.000 0.000 0.260 0.000
#> ERR519497     4  0.4658     0.4286 0.040  0 0.008 0.612 0.340 0.000
#> ERR519467     5  0.0547     0.7324 0.020  0 0.000 0.000 0.980 0.000
#> ERR519489     5  0.3373     0.2945 0.008  0 0.000 0.248 0.744 0.000
#> ERR519494     4  0.4294    -0.1528 0.000  0 0.428 0.552 0.020 0.000
#> ERR519474     1  0.2810     0.6037 0.832  0 0.000 0.156 0.008 0.004
#> ERR519505     6  0.6073     0.3677 0.088  0 0.000 0.228 0.096 0.588
#> ERR519517     3  0.0000     0.9033 0.000  0 1.000 0.000 0.000 0.000
#> ERR519484     1  0.0260     0.6817 0.992  0 0.000 0.000 0.008 0.000
#> ERR519498     6  0.3529     0.4751 0.000  0 0.016 0.048 0.120 0.816
#> ERR519490     3  0.3864     0.1293 0.000  0 0.520 0.480 0.000 0.000
#> ERR519507     5  0.2762     0.5695 0.196  0 0.000 0.000 0.804 0.000
#> ERR519511     1  0.3330     0.6558 0.716  0 0.000 0.000 0.284 0.000
#> ERR519468     3  0.0000     0.9033 0.000  0 1.000 0.000 0.000 0.000
#> ERR519482     3  0.0000     0.9033 0.000  0 1.000 0.000 0.000 0.000
#> ERR519475     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000 0.000
#> ERR519496     1  0.2941     0.7113 0.780  0 0.000 0.000 0.220 0.000
#> ERR519506     1  0.6122    -0.0615 0.396  0 0.000 0.392 0.008 0.204
#> ERR519469     4  0.3023     0.5094 0.000  0 0.000 0.768 0.232 0.000
#> ERR519480     3  0.0000     0.9033 0.000  0 1.000 0.000 0.000 0.000
#> ERR519487     3  0.0000     0.9033 0.000  0 1.000 0.000 0.000 0.000
#> ERR519483     6  0.6001    -0.1586 0.392  0 0.008 0.176 0.000 0.424
#> ERR519477     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000 0.000
#> ERR519499     3  0.0000     0.9033 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-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 18140 rows and 52 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.633           0.810       0.915         0.4764 0.502   0.502
#> 3 3 0.407           0.633       0.790         0.3014 0.813   0.645
#> 4 4 0.365           0.510       0.730         0.1116 0.865   0.664
#> 5 5 0.388           0.386       0.615         0.0599 0.918   0.762
#> 6 6 0.423           0.375       0.595         0.0781 0.814   0.460

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
#> ERR519515     1  0.0000      0.936 1.000 0.000
#> ERR519516     1  0.0000      0.936 1.000 0.000
#> ERR519520     1  0.7883      0.680 0.764 0.236
#> ERR519513     2  0.0672      0.853 0.008 0.992
#> ERR519481     1  0.0376      0.935 0.996 0.004
#> ERR519491     1  0.0000      0.936 1.000 0.000
#> ERR519473     2  0.5629      0.791 0.132 0.868
#> ERR519518     2  0.2778      0.840 0.048 0.952
#> ERR519512     1  0.9580      0.333 0.620 0.380
#> ERR519521     1  0.1414      0.927 0.980 0.020
#> ERR519488     1  0.0000      0.936 1.000 0.000
#> ERR519493     1  0.0000      0.936 1.000 0.000
#> ERR519514     1  0.0672      0.933 0.992 0.008
#> ERR519479     1  0.0000      0.936 1.000 0.000
#> ERR519509     1  0.0000      0.936 1.000 0.000
#> ERR519472     1  0.8207      0.644 0.744 0.256
#> ERR519510     1  0.0000      0.936 1.000 0.000
#> ERR519470     1  0.0000      0.936 1.000 0.000
#> ERR519495     1  0.0376      0.935 0.996 0.004
#> ERR519522     1  0.0000      0.936 1.000 0.000
#> ERR519523     1  0.3584      0.890 0.932 0.068
#> ERR519503     2  0.0376      0.853 0.004 0.996
#> ERR519471     1  0.7950      0.673 0.760 0.240
#> ERR519500     1  0.2236      0.917 0.964 0.036
#> ERR519485     1  0.0000      0.936 1.000 0.000
#> ERR519476     2  0.9993      0.197 0.484 0.516
#> ERR519502     1  0.7453      0.719 0.788 0.212
#> ERR519486     1  0.3879      0.882 0.924 0.076
#> ERR519478     1  0.0000      0.936 1.000 0.000
#> ERR519497     2  0.8144      0.680 0.252 0.748
#> ERR519467     1  0.0000      0.936 1.000 0.000
#> ERR519489     2  0.8327      0.664 0.264 0.736
#> ERR519494     2  0.0376      0.853 0.004 0.996
#> ERR519474     1  0.0000      0.936 1.000 0.000
#> ERR519505     2  0.9358      0.510 0.352 0.648
#> ERR519517     2  0.0000      0.852 0.000 1.000
#> ERR519484     1  0.0938      0.932 0.988 0.012
#> ERR519498     2  0.8386      0.659 0.268 0.732
#> ERR519490     2  0.0000      0.852 0.000 1.000
#> ERR519507     1  0.0376      0.935 0.996 0.004
#> ERR519511     1  0.0000      0.936 1.000 0.000
#> ERR519468     2  0.0000      0.852 0.000 1.000
#> ERR519482     2  0.0000      0.852 0.000 1.000
#> ERR519475     2  0.9993      0.197 0.484 0.516
#> ERR519496     1  0.0672      0.933 0.992 0.008
#> ERR519506     2  0.1184      0.852 0.016 0.984
#> ERR519469     2  0.1184      0.851 0.016 0.984
#> ERR519480     2  0.0000      0.852 0.000 1.000
#> ERR519487     2  0.0000      0.852 0.000 1.000
#> ERR519483     2  0.2043      0.847 0.032 0.968
#> ERR519477     2  0.9993      0.197 0.484 0.516
#> ERR519499     2  0.0000      0.852 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
#> ERR519515     1  0.1860      0.826 0.948 0.052 0.000
#> ERR519516     1  0.3192      0.786 0.888 0.112 0.000
#> ERR519520     1  0.6100      0.701 0.784 0.120 0.096
#> ERR519513     2  0.6744      0.325 0.032 0.668 0.300
#> ERR519481     1  0.2945      0.800 0.908 0.088 0.004
#> ERR519491     1  0.2625      0.809 0.916 0.084 0.000
#> ERR519473     3  0.7085      0.624 0.096 0.188 0.716
#> ERR519518     3  0.3502      0.776 0.020 0.084 0.896
#> ERR519512     1  0.8532      0.352 0.608 0.168 0.224
#> ERR519521     1  0.2229      0.833 0.944 0.044 0.012
#> ERR519488     1  0.4504      0.702 0.804 0.196 0.000
#> ERR519493     1  0.1860      0.829 0.948 0.052 0.000
#> ERR519514     1  0.0592      0.835 0.988 0.012 0.000
#> ERR519479     1  0.1163      0.833 0.972 0.028 0.000
#> ERR519509     1  0.2537      0.812 0.920 0.080 0.000
#> ERR519472     1  0.8482      0.420 0.616 0.200 0.184
#> ERR519510     1  0.4399      0.698 0.812 0.188 0.000
#> ERR519470     1  0.1753      0.834 0.952 0.048 0.000
#> ERR519495     1  0.3030      0.798 0.904 0.092 0.004
#> ERR519522     1  0.2066      0.825 0.940 0.060 0.000
#> ERR519523     1  0.2492      0.825 0.936 0.048 0.016
#> ERR519503     3  0.4784      0.733 0.004 0.200 0.796
#> ERR519471     1  0.7509      0.423 0.636 0.300 0.064
#> ERR519500     1  0.5692      0.681 0.784 0.176 0.040
#> ERR519485     2  0.5835      0.460 0.340 0.660 0.000
#> ERR519476     2  0.9998      0.298 0.328 0.344 0.328
#> ERR519502     1  0.7672      0.544 0.684 0.156 0.160
#> ERR519486     2  0.6224      0.509 0.296 0.688 0.016
#> ERR519478     1  0.1163      0.835 0.972 0.028 0.000
#> ERR519497     3  0.9215      0.120 0.168 0.332 0.500
#> ERR519467     1  0.2096      0.830 0.944 0.052 0.004
#> ERR519489     3  0.8792      0.358 0.244 0.176 0.580
#> ERR519494     3  0.4136      0.755 0.020 0.116 0.864
#> ERR519474     2  0.6274      0.240 0.456 0.544 0.000
#> ERR519505     2  0.8055      0.336 0.096 0.612 0.292
#> ERR519517     3  0.2796      0.779 0.000 0.092 0.908
#> ERR519484     2  0.6307      0.148 0.488 0.512 0.000
#> ERR519498     2  0.7047      0.451 0.084 0.712 0.204
#> ERR519490     3  0.1163      0.794 0.000 0.028 0.972
#> ERR519507     1  0.1525      0.834 0.964 0.032 0.004
#> ERR519511     1  0.1753      0.827 0.952 0.048 0.000
#> ERR519468     3  0.3267      0.771 0.000 0.116 0.884
#> ERR519482     3  0.3482      0.766 0.000 0.128 0.872
#> ERR519475     2  0.9998      0.298 0.328 0.344 0.328
#> ERR519496     1  0.1753      0.833 0.952 0.048 0.000
#> ERR519506     2  0.7271      0.184 0.040 0.608 0.352
#> ERR519469     3  0.4068      0.758 0.016 0.120 0.864
#> ERR519480     3  0.2165      0.787 0.000 0.064 0.936
#> ERR519487     3  0.3551      0.760 0.000 0.132 0.868
#> ERR519483     2  0.5970      0.463 0.060 0.780 0.160
#> ERR519477     2  0.9998      0.298 0.328 0.344 0.328
#> ERR519499     3  0.1031      0.791 0.000 0.024 0.976

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> ERR519515     1   0.139     0.7710 0.952 0.048 0.000 0.000
#> ERR519516     1   0.326     0.6908 0.844 0.152 0.000 0.004
#> ERR519520     1   0.692     0.5342 0.680 0.160 0.084 0.076
#> ERR519513     2   0.717     0.3354 0.076 0.564 0.328 0.032
#> ERR519481     1   0.455     0.6522 0.732 0.012 0.000 0.256
#> ERR519491     1   0.238     0.7654 0.916 0.068 0.000 0.016
#> ERR519473     4   0.659     0.2831 0.060 0.016 0.336 0.588
#> ERR519518     3   0.516     0.4939 0.040 0.028 0.776 0.156
#> ERR519512     1   0.725     0.4722 0.656 0.128 0.148 0.068
#> ERR519521     1   0.249     0.7599 0.912 0.068 0.000 0.020
#> ERR519488     1   0.455     0.5199 0.732 0.256 0.000 0.012
#> ERR519493     1   0.220     0.7724 0.928 0.048 0.000 0.024
#> ERR519514     1   0.117     0.7811 0.968 0.012 0.000 0.020
#> ERR519479     1   0.397     0.7253 0.804 0.016 0.000 0.180
#> ERR519509     1   0.227     0.7552 0.912 0.084 0.000 0.004
#> ERR519472     4   0.494     0.4295 0.280 0.000 0.020 0.700
#> ERR519510     1   0.409     0.5788 0.764 0.232 0.000 0.004
#> ERR519470     1   0.283     0.7656 0.876 0.004 0.000 0.120
#> ERR519495     1   0.333     0.7552 0.864 0.024 0.000 0.112
#> ERR519522     1   0.182     0.7643 0.936 0.060 0.000 0.004
#> ERR519523     1   0.294     0.7676 0.900 0.052 0.004 0.044
#> ERR519503     4   0.540     0.3787 0.000 0.068 0.212 0.720
#> ERR519471     1   0.737     0.2575 0.516 0.140 0.008 0.336
#> ERR519500     4   0.515     0.1525 0.396 0.008 0.000 0.596
#> ERR519485     2   0.503     0.6259 0.284 0.696 0.004 0.016
#> ERR519476     3   0.999    -0.0149 0.252 0.232 0.268 0.248
#> ERR519502     1   0.680     0.5167 0.652 0.056 0.056 0.236
#> ERR519486     2   0.587     0.6134 0.308 0.644 0.040 0.008
#> ERR519478     1   0.267     0.7735 0.892 0.008 0.000 0.100
#> ERR519497     3   0.883     0.2024 0.172 0.208 0.504 0.116
#> ERR519467     1   0.452     0.6738 0.736 0.012 0.000 0.252
#> ERR519489     4   0.865     0.1583 0.196 0.048 0.352 0.404
#> ERR519494     3   0.548     0.4138 0.016 0.036 0.720 0.228
#> ERR519474     2   0.674     0.5079 0.304 0.576 0.000 0.120
#> ERR519505     4   0.870    -0.0514 0.096 0.364 0.116 0.424
#> ERR519517     3   0.177     0.5894 0.000 0.044 0.944 0.012
#> ERR519484     2   0.566     0.3594 0.436 0.540 0.000 0.024
#> ERR519498     2   0.761     0.4830 0.148 0.576 0.244 0.032
#> ERR519490     3   0.331     0.5217 0.000 0.004 0.840 0.156
#> ERR519507     1   0.412     0.7218 0.796 0.020 0.000 0.184
#> ERR519511     1   0.254     0.7725 0.904 0.012 0.000 0.084
#> ERR519468     3   0.361     0.5714 0.000 0.060 0.860 0.080
#> ERR519482     3   0.256     0.5882 0.000 0.056 0.912 0.032
#> ERR519475     3   0.999    -0.0149 0.252 0.232 0.268 0.248
#> ERR519496     1   0.282     0.7771 0.900 0.036 0.000 0.064
#> ERR519506     4   0.557     0.3950 0.024 0.196 0.044 0.736
#> ERR519469     4   0.597     0.0903 0.008 0.024 0.444 0.524
#> ERR519480     3   0.234     0.5854 0.000 0.020 0.920 0.060
#> ERR519487     3   0.259     0.5771 0.000 0.080 0.904 0.016
#> ERR519483     2   0.519     0.3673 0.028 0.784 0.056 0.132
#> ERR519477     3   0.999    -0.0149 0.252 0.232 0.268 0.248
#> ERR519499     3   0.139     0.5861 0.000 0.012 0.960 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
#> ERR519515     1   0.218     0.6438 0.912 0.008 0.000 0.008 0.072
#> ERR519516     1   0.499     0.3015 0.628 0.016 0.000 0.020 0.336
#> ERR519520     1   0.698     0.3991 0.596 0.012 0.092 0.088 0.212
#> ERR519513     5   0.649     0.3368 0.060 0.036 0.304 0.020 0.580
#> ERR519481     1   0.513     0.4623 0.644 0.024 0.000 0.308 0.024
#> ERR519491     1   0.336     0.6138 0.840 0.012 0.000 0.020 0.128
#> ERR519473     4   0.676     0.0349 0.112 0.020 0.348 0.508 0.012
#> ERR519518     3   0.407     0.5814 0.008 0.008 0.760 0.216 0.008
#> ERR519512     1   0.774     0.3441 0.540 0.020 0.152 0.108 0.180
#> ERR519521     1   0.333     0.6569 0.860 0.008 0.004 0.044 0.084
#> ERR519488     1   0.571     0.0644 0.544 0.048 0.004 0.012 0.392
#> ERR519493     1   0.441     0.4864 0.732 0.012 0.000 0.024 0.232
#> ERR519514     1   0.200     0.6649 0.924 0.000 0.000 0.036 0.040
#> ERR519479     1   0.404     0.6446 0.808 0.032 0.000 0.132 0.028
#> ERR519509     1   0.336     0.5839 0.824 0.012 0.000 0.008 0.156
#> ERR519472     4   0.608    -0.1156 0.432 0.052 0.024 0.488 0.004
#> ERR519510     1   0.571    -0.0553 0.500 0.024 0.004 0.028 0.444
#> ERR519470     1   0.263     0.6632 0.900 0.020 0.000 0.056 0.024
#> ERR519495     1   0.400     0.5807 0.748 0.004 0.000 0.232 0.016
#> ERR519522     1   0.325     0.6205 0.848 0.008 0.000 0.024 0.120
#> ERR519523     1   0.378     0.6520 0.832 0.012 0.012 0.116 0.028
#> ERR519503     4   0.661     0.0261 0.040 0.384 0.068 0.500 0.008
#> ERR519471     1   0.853    -0.1044 0.360 0.180 0.008 0.284 0.168
#> ERR519500     1   0.515     0.1262 0.492 0.012 0.012 0.480 0.004
#> ERR519485     5   0.592     0.3648 0.232 0.156 0.004 0.000 0.608
#> ERR519476     4   0.991     0.2399 0.156 0.208 0.236 0.236 0.164
#> ERR519502     1   0.614     0.3431 0.568 0.008 0.068 0.336 0.020
#> ERR519486     5   0.532     0.4944 0.284 0.028 0.036 0.000 0.652
#> ERR519478     1   0.208     0.6686 0.908 0.008 0.000 0.084 0.000
#> ERR519497     3   0.751    -0.1514 0.120 0.036 0.460 0.032 0.352
#> ERR519467     1   0.541     0.5330 0.696 0.076 0.000 0.200 0.028
#> ERR519489     4   0.736     0.1616 0.224 0.016 0.288 0.456 0.016
#> ERR519494     3   0.483     0.4998 0.004 0.012 0.676 0.288 0.020
#> ERR519474     5   0.726    -0.2596 0.204 0.356 0.000 0.032 0.408
#> ERR519505     5   0.883     0.1540 0.076 0.312 0.068 0.184 0.360
#> ERR519517     3   0.184     0.6817 0.000 0.008 0.932 0.008 0.052
#> ERR519484     5   0.649     0.3215 0.372 0.080 0.004 0.032 0.512
#> ERR519498     5   0.669     0.4211 0.116 0.036 0.244 0.012 0.592
#> ERR519490     3   0.492     0.5740 0.000 0.036 0.728 0.200 0.036
#> ERR519507     1   0.414     0.6405 0.808 0.036 0.000 0.120 0.036
#> ERR519511     1   0.339     0.6461 0.836 0.008 0.000 0.132 0.024
#> ERR519468     3   0.516     0.5940 0.000 0.056 0.748 0.080 0.116
#> ERR519482     3   0.269     0.6814 0.000 0.060 0.896 0.028 0.016
#> ERR519475     4   0.991     0.2399 0.156 0.208 0.236 0.236 0.164
#> ERR519496     1   0.285     0.6679 0.888 0.012 0.000 0.052 0.048
#> ERR519506     4   0.620    -0.0291 0.040 0.444 0.016 0.476 0.024
#> ERR519469     3   0.658     0.1346 0.004 0.176 0.420 0.400 0.000
#> ERR519480     3   0.207     0.6897 0.000 0.032 0.928 0.028 0.012
#> ERR519487     3   0.322     0.6519 0.000 0.020 0.856 0.016 0.108
#> ERR519483     2   0.587     0.0000 0.016 0.540 0.024 0.024 0.396
#> ERR519477     4   0.991     0.2399 0.156 0.208 0.236 0.236 0.164
#> ERR519499     3   0.120     0.6826 0.000 0.000 0.956 0.040 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
#> ERR519515     1   0.428    0.57988 0.732 0.068 0.000 0.008 0.192 0.000
#> ERR519516     1   0.690    0.05535 0.376 0.352 0.000 0.032 0.228 0.012
#> ERR519520     1   0.400    0.52860 0.828 0.056 0.052 0.016 0.028 0.020
#> ERR519513     2   0.512    0.18406 0.088 0.684 0.200 0.020 0.004 0.004
#> ERR519481     5   0.412    0.57345 0.116 0.024 0.004 0.036 0.800 0.020
#> ERR519491     1   0.623    0.23814 0.456 0.192 0.000 0.012 0.336 0.004
#> ERR519473     5   0.780   -0.11909 0.040 0.056 0.332 0.064 0.428 0.080
#> ERR519518     3   0.519    0.53700 0.000 0.044 0.688 0.036 0.208 0.024
#> ERR519512     1   0.511    0.49256 0.752 0.060 0.100 0.024 0.048 0.016
#> ERR519521     5   0.631    0.01186 0.352 0.168 0.000 0.016 0.456 0.008
#> ERR519488     1   0.386    0.47169 0.800 0.136 0.012 0.020 0.000 0.032
#> ERR519493     1   0.655    0.18076 0.408 0.240 0.000 0.004 0.328 0.020
#> ERR519514     1   0.272    0.62443 0.868 0.012 0.000 0.004 0.104 0.012
#> ERR519479     5   0.557    0.50754 0.128 0.124 0.000 0.020 0.684 0.044
#> ERR519509     1   0.409    0.61752 0.784 0.076 0.000 0.012 0.120 0.008
#> ERR519472     5   0.711    0.45487 0.168 0.040 0.040 0.044 0.580 0.128
#> ERR519510     2   0.640    0.23066 0.172 0.540 0.000 0.016 0.244 0.028
#> ERR519470     1   0.350    0.61166 0.808 0.004 0.000 0.000 0.128 0.060
#> ERR519495     5   0.431    0.35658 0.308 0.032 0.000 0.004 0.656 0.000
#> ERR519522     1   0.224    0.62819 0.904 0.024 0.000 0.004 0.064 0.004
#> ERR519523     1   0.454    0.49572 0.672 0.024 0.008 0.008 0.284 0.004
#> ERR519503     6   0.530    0.45017 0.180 0.004 0.084 0.016 0.024 0.692
#> ERR519471     1   0.564    0.14441 0.600 0.052 0.016 0.028 0.004 0.300
#> ERR519500     5   0.610    0.46784 0.208 0.032 0.024 0.044 0.644 0.048
#> ERR519485     2   0.692   -0.25931 0.136 0.424 0.004 0.368 0.056 0.012
#> ERR519476     2   0.993    0.18136 0.144 0.216 0.144 0.144 0.164 0.188
#> ERR519502     5   0.466    0.56655 0.124 0.028 0.052 0.012 0.768 0.016
#> ERR519486     2   0.659    0.16814 0.224 0.576 0.016 0.120 0.052 0.012
#> ERR519478     1   0.427    0.53137 0.696 0.012 0.000 0.012 0.268 0.012
#> ERR519497     3   0.790    0.00134 0.204 0.324 0.356 0.032 0.016 0.068
#> ERR519467     1   0.546    0.50818 0.692 0.020 0.004 0.028 0.108 0.148
#> ERR519489     5   0.691    0.16548 0.060 0.052 0.284 0.068 0.528 0.008
#> ERR519494     3   0.601    0.44450 0.000 0.056 0.592 0.056 0.272 0.024
#> ERR519474     4   0.689    0.41439 0.124 0.200 0.000 0.556 0.084 0.036
#> ERR519505     6   0.706    0.08962 0.096 0.400 0.036 0.020 0.032 0.416
#> ERR519517     3   0.290    0.63747 0.016 0.112 0.856 0.012 0.000 0.004
#> ERR519484     2   0.651    0.19613 0.112 0.596 0.000 0.080 0.184 0.028
#> ERR519498     2   0.501    0.24079 0.168 0.696 0.112 0.004 0.000 0.020
#> ERR519490     3   0.494    0.56469 0.004 0.036 0.740 0.068 0.136 0.016
#> ERR519507     5   0.571    0.51302 0.112 0.132 0.000 0.032 0.680 0.044
#> ERR519511     5   0.488    0.51559 0.140 0.120 0.000 0.012 0.716 0.012
#> ERR519468     3   0.596    0.38882 0.048 0.136 0.636 0.016 0.000 0.164
#> ERR519482     3   0.212    0.66166 0.004 0.028 0.920 0.036 0.008 0.004
#> ERR519475     2   0.993    0.18136 0.144 0.216 0.144 0.144 0.164 0.188
#> ERR519496     1   0.559    0.34510 0.564 0.072 0.000 0.028 0.332 0.004
#> ERR519506     6   0.309    0.38176 0.012 0.056 0.004 0.020 0.036 0.872
#> ERR519469     6   0.731    0.15341 0.108 0.036 0.344 0.012 0.060 0.440
#> ERR519480     3   0.377    0.64307 0.000 0.088 0.824 0.016 0.048 0.024
#> ERR519487     3   0.389    0.60261 0.028 0.164 0.784 0.016 0.004 0.004
#> ERR519483     4   0.379    0.50167 0.028 0.080 0.016 0.832 0.008 0.036
#> ERR519477     2   0.993    0.18136 0.144 0.216 0.144 0.144 0.164 0.188
#> ERR519499     3   0.135    0.66128 0.008 0.004 0.956 0.008 0.020 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-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