cola Report for recount2:SRP028336

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

The call of run_all_consensus_partition_methods() was:

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

Dimension of the input matrix:

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

Density distribution

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

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

plot of chunk density-heatmap

Suggest the best k

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

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

suggest_best_k(res_list)
The best k 1-PAC Mean silhouette Concordance Optional k
SD:hclust 3 1.000 1.000 1.000 **
SD:kmeans 2 1.000 0.989 0.984 **
SD:pam 4 1.000 1.000 1.000 ** 2
SD:NMF 4 1.000 1.000 1.000 ** 2
MAD:hclust 5 1.000 0.958 0.985 ** 2
MAD:kmeans 2 1.000 0.980 0.973 **
MAD:skmeans 5 1.000 0.993 0.994 ** 2,3,4
MAD:pam 4 1.000 1.000 1.000 ** 2,3
ATC:kmeans 2 1.000 0.992 0.996 **
ATC:NMF 3 1.000 0.997 0.997 **
ATC:hclust 6 0.990 0.991 0.990 **
CV:hclust 6 0.986 0.981 0.969 ** 3
SD:mclust 5 0.985 0.978 0.985 ** 2,3,4
CV:pam 5 0.981 0.963 0.975 ** 2,3,4
MAD:mclust 6 0.976 0.864 0.927 ** 3,4,5
SD:skmeans 5 0.973 0.974 0.969 ** 2,3,4
CV:mclust 5 0.973 0.944 0.974 ** 2,3,4
ATC:mclust 5 0.954 0.943 0.970 ** 3,4
MAD:NMF 6 0.925 0.915 0.931 * 2,4
CV:skmeans 6 0.916 0.876 0.920 * 2,3,4
ATC:skmeans 6 0.906 0.961 0.960 * 2,3,5
CV:NMF 6 0.903 0.954 0.925 * 2,4
ATC:pam 5 0.903 0.917 0.954 * 2,4
CV:kmeans 2 0.675 0.962 0.956

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

CDF of consensus matrices

Cumulative distribution function curves of consensus matrix for all methods.

collect_plots(res_list, fun = plot_ecdf)

plot of chunk collect-plots

Consensus heatmap

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

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

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

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

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

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

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

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

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

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

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

Membership heatmap

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

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

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

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

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

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

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

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

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

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

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

Signature heatmap

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

Note in following heatmaps, rows are scaled.

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

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

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

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

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

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

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

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

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

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

Statistics table

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

get_stats(res_list, k = 2)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      2 1.000           0.973       0.989          0.483 0.512   0.512
#> CV:NMF      2 1.000           1.000       1.000          0.489 0.512   0.512
#> MAD:NMF     2 1.000           0.999       0.999          0.488 0.512   0.512
#> ATC:NMF     2 0.710           0.925       0.944          0.445 0.512   0.512
#> SD:skmeans  2 1.000           1.000       1.000          0.489 0.512   0.512
#> CV:skmeans  2 1.000           1.000       1.000          0.489 0.512   0.512
#> MAD:skmeans 2 1.000           1.000       1.000          0.489 0.512   0.512
#> ATC:skmeans 2 1.000           1.000       1.000          0.489 0.512   0.512
#> SD:mclust   2 1.000           0.978       0.982          0.489 0.512   0.512
#> CV:mclust   2 1.000           0.992       0.996          0.487 0.512   0.512
#> MAD:mclust  2 0.579           0.837       0.895          0.480 0.528   0.528
#> ATC:mclust  2 0.636           0.884       0.930          0.478 0.528   0.528
#> SD:kmeans   2 1.000           0.989       0.984          0.482 0.512   0.512
#> CV:kmeans   2 0.675           0.962       0.956          0.471 0.512   0.512
#> MAD:kmeans  2 1.000           0.980       0.973          0.478 0.512   0.512
#> ATC:kmeans  2 1.000           0.992       0.996          0.450 0.548   0.548
#> SD:pam      2 1.000           0.993       0.997          0.487 0.512   0.512
#> CV:pam      2 1.000           0.984       0.988          0.481 0.512   0.512
#> MAD:pam     2 1.000           1.000       1.000          0.489 0.512   0.512
#> ATC:pam     2 1.000           0.987       0.993          0.421 0.573   0.573
#> SD:hclust   2 0.675           0.952       0.960          0.456 0.512   0.512
#> CV:hclust   2 0.575           0.891       0.908          0.407 0.512   0.512
#> MAD:hclust  2 1.000           1.000       1.000          0.489 0.512   0.512
#> ATC:hclust  2 0.869           0.972       0.986          0.377 0.636   0.636
get_stats(res_list, k = 3)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      3 0.729           0.808       0.786          0.279 0.785   0.602
#> CV:NMF      3 0.756           0.931       0.829          0.269 0.837   0.682
#> MAD:NMF     3 0.753           0.963       0.929          0.308 0.837   0.682
#> ATC:NMF     3 1.000           0.997       0.997          0.281 0.919   0.841
#> SD:skmeans  3 1.000           0.999       0.998          0.332 0.837   0.682
#> CV:skmeans  3 1.000           0.998       0.995          0.331 0.837   0.682
#> MAD:skmeans 3 1.000           1.000       1.000          0.333 0.837   0.682
#> ATC:skmeans 3 0.949           0.931       0.950          0.190 0.880   0.770
#> SD:mclust   3 1.000           0.997       0.999          0.328 0.785   0.602
#> CV:mclust   3 1.000           0.987       0.994          0.333 0.785   0.602
#> MAD:mclust  3 1.000           1.000       1.000          0.352 0.824   0.666
#> ATC:mclust  3 1.000           1.000       1.000          0.359 0.824   0.666
#> SD:kmeans   3 0.756           0.928       0.813          0.282 0.837   0.682
#> CV:kmeans   3 0.756           0.929       0.847          0.317 0.837   0.682
#> MAD:kmeans  3 0.745           0.939       0.862          0.300 0.837   0.682
#> ATC:kmeans  3 0.670           0.836       0.876          0.355 0.817   0.678
#> SD:pam      3 0.753           0.946       0.883          0.290 0.837   0.682
#> CV:pam      3 1.000           0.995       0.992          0.350 0.837   0.682
#> MAD:pam     3 1.000           0.986       0.993          0.337 0.837   0.682
#> ATC:pam     3 0.633           0.651       0.796          0.424 0.738   0.563
#> SD:hclust   3 1.000           1.000       1.000          0.249 0.919   0.841
#> CV:hclust   3 0.976           0.967       0.985          0.392 0.921   0.845
#> MAD:hclust  3 0.753           0.909       0.915          0.197 0.921   0.845
#> ATC:hclust  3 0.824           0.949       0.969          0.529 0.769   0.638
get_stats(res_list, k = 4)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      4 1.000           1.000       1.000         0.1846 0.894   0.707
#> CV:NMF      4 1.000           1.000       1.000         0.1808 0.919   0.767
#> MAD:NMF     4 1.000           1.000       1.000         0.1462 0.919   0.767
#> ATC:NMF     4 0.793           0.679       0.888         0.1583 0.895   0.760
#> SD:skmeans  4 1.000           0.999       0.998         0.1243 0.919   0.767
#> CV:skmeans  4 1.000           0.999       0.998         0.1263 0.919   0.767
#> MAD:skmeans 4 1.000           0.996       0.983         0.1186 0.919   0.767
#> ATC:skmeans 4 0.809           0.961       0.923         0.2123 0.851   0.636
#> SD:mclust   4 0.959           0.940       0.975         0.1372 0.910   0.743
#> CV:mclust   4 0.973           0.925       0.972         0.1349 0.905   0.730
#> MAD:mclust  4 0.973           0.953       0.975         0.1352 0.910   0.743
#> ATC:mclust  4 1.000           1.000       1.000         0.1392 0.910   0.743
#> SD:kmeans   4 0.673           0.926       0.825         0.1249 0.919   0.767
#> CV:kmeans   4 0.644           0.823       0.746         0.1304 0.921   0.773
#> MAD:kmeans  4 0.654           0.843       0.756         0.1214 0.921   0.773
#> ATC:kmeans  4 0.802           0.958       0.916         0.1660 0.851   0.632
#> SD:pam      4 1.000           1.000       1.000         0.1658 0.919   0.767
#> CV:pam      4 1.000           0.973       0.987         0.1230 0.919   0.767
#> MAD:pam     4 1.000           1.000       1.000         0.1209 0.919   0.767
#> ATC:pam     4 0.920           0.890       0.954         0.2182 0.878   0.678
#> SD:hclust   4 1.000           1.000       1.000         0.0198 0.989   0.974
#> CV:hclust   4 0.985           0.965       0.980         0.0310 0.986   0.969
#> MAD:hclust  4 0.814           0.834       0.891         0.0960 0.964   0.919
#> ATC:hclust  4 0.961           0.971       0.983         0.0657 0.982   0.955
get_stats(res_list, k = 5)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      5 1.000           0.995       0.995         0.0159 0.989   0.958
#> CV:NMF      5 1.000           0.987       0.986         0.0211 0.989   0.958
#> MAD:NMF     5 0.990           0.987       0.988         0.0190 0.989   0.958
#> ATC:NMF     5 0.783           0.929       0.902         0.0773 0.880   0.663
#> SD:skmeans  5 0.973           0.974       0.969         0.0264 0.975   0.907
#> CV:skmeans  5 0.915           0.949       0.945         0.0351 0.989   0.958
#> MAD:skmeans 5 1.000           0.993       0.994         0.0400 0.975   0.907
#> ATC:skmeans 5 0.944           0.942       0.940         0.0547 0.986   0.948
#> SD:mclust   5 0.985           0.978       0.985         0.0426 0.966   0.870
#> CV:mclust   5 0.973           0.944       0.974         0.0438 0.962   0.853
#> MAD:mclust  5 0.985           0.978       0.989         0.0436 0.973   0.896
#> ATC:mclust  5 0.954           0.943       0.970         0.0386 0.966   0.870
#> SD:kmeans   5 0.775           0.864       0.811         0.0807 1.000   1.000
#> CV:kmeans   5 0.785           0.855       0.809         0.0743 0.975   0.912
#> MAD:kmeans  5 0.770           0.848       0.799         0.0761 0.975   0.912
#> ATC:kmeans  5 0.719           0.881       0.870         0.0584 1.000   1.000
#> SD:pam      5 1.000           1.000       1.000         0.0154 0.989   0.958
#> CV:pam      5 0.981           0.963       0.975         0.0287 0.980   0.924
#> MAD:pam     5 1.000           1.000       1.000         0.0154 0.989   0.958
#> ATC:pam     5 0.903           0.917       0.954         0.0506 0.914   0.709
#> SD:hclust   5 0.828           0.877       0.910         0.1169 0.991   0.978
#> CV:hclust   5 0.986           0.979       0.984         0.0145 0.991   0.978
#> MAD:hclust  5 1.000           0.958       0.985         0.1598 0.837   0.612
#> ATC:hclust  5 0.953           0.944       0.961         0.0159 0.993   0.983
get_stats(res_list, k = 6)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      6 0.947           0.938       0.945        0.03607 0.991   0.965
#> CV:NMF      6 0.903           0.954       0.925        0.07663 0.919   0.683
#> MAD:NMF     6 0.925           0.915       0.931        0.05845 0.939   0.762
#> ATC:NMF     6 0.876           0.809       0.869        0.04008 0.986   0.947
#> SD:skmeans  6 1.000           0.985       0.985        0.02937 0.989   0.953
#> CV:skmeans  6 0.916           0.876       0.920        0.04360 0.975   0.903
#> MAD:skmeans 6 0.973           0.971       0.975        0.02454 0.989   0.953
#> ATC:skmeans 6 0.906           0.961       0.960        0.03170 0.984   0.936
#> SD:mclust   6 0.988           0.972       0.983        0.00812 0.995   0.980
#> CV:mclust   6 0.971           0.901       0.921        0.01542 0.995   0.980
#> MAD:mclust  6 0.976           0.864       0.927        0.01084 0.984   0.933
#> ATC:mclust  6 0.995           0.959       0.981        0.01962 0.991   0.960
#> SD:kmeans   6 0.816           0.874       0.812        0.05084 0.919   0.696
#> CV:kmeans   6 0.731           0.872       0.785        0.05213 0.919   0.696
#> MAD:kmeans  6 0.717           0.720       0.743        0.04993 0.928   0.730
#> ATC:kmeans  6 0.814           0.695       0.814        0.03862 0.964   0.865
#> SD:pam      6 1.000           0.999       0.999        0.01241 0.991   0.965
#> CV:pam      6 1.000           0.990       0.995        0.01001 0.995   0.982
#> MAD:pam     6 0.930           0.932       0.948        0.03871 0.991   0.965
#> ATC:pam     6 0.902           0.812       0.895        0.05460 0.989   0.952
#> SD:hclust   6 0.826           0.992       0.967        0.12719 0.837   0.603
#> CV:hclust   6 0.986           0.981       0.969        0.25160 0.837   0.603
#> MAD:hclust  6 0.954           0.901       0.952        0.02253 1.000   1.000
#> ATC:hclust  6 0.990           0.991       0.990        0.02758 0.977   0.941

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

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

collect_plots(res)

plot of chunk SD-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.675           0.952       0.960         0.4562 0.512   0.512
#> 3 3 1.000           1.000       1.000         0.2492 0.919   0.841
#> 4 4 1.000           1.000       1.000         0.0198 0.989   0.974
#> 5 5 0.828           0.877       0.910         0.1169 0.991   0.978
#> 6 6 0.826           0.992       0.967         0.1272 0.837   0.603

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
#> SRR945190     1   0.000      0.888 1.0 0.0
#> SRR945191     1   0.000      0.888 1.0 0.0
#> SRR945192     1   0.000      0.888 1.0 0.0
#> SRR945193     1   0.000      0.888 1.0 0.0
#> SRR945194     1   0.000      0.888 1.0 0.0
#> SRR945195     1   0.000      0.888 1.0 0.0
#> SRR945196     1   0.000      0.888 1.0 0.0
#> SRR945197     1   0.000      0.888 1.0 0.0
#> SRR945200     1   0.000      0.888 1.0 0.0
#> SRR945201     1   0.000      0.888 1.0 0.0
#> SRR945202     1   0.722      0.870 0.8 0.2
#> SRR945203     1   0.722      0.870 0.8 0.2
#> SRR945204     1   0.722      0.870 0.8 0.2
#> SRR945205     1   0.722      0.870 0.8 0.2
#> SRR945198     1   0.000      0.888 1.0 0.0
#> SRR945199     1   0.000      0.888 1.0 0.0
#> SRR945206     1   0.722      0.870 0.8 0.2
#> SRR945207     1   0.722      0.870 0.8 0.2
#> SRR945208     1   0.722      0.870 0.8 0.2
#> SRR945209     1   0.722      0.870 0.8 0.2
#> SRR945212     1   0.722      0.870 0.8 0.2
#> SRR945213     1   0.722      0.870 0.8 0.2
#> SRR945214     2   0.000      1.000 0.0 1.0
#> SRR945215     2   0.000      1.000 0.0 1.0
#> SRR945210     1   0.722      0.870 0.8 0.2
#> SRR945211     1   0.722      0.870 0.8 0.2
#> SRR945218     2   0.000      1.000 0.0 1.0
#> SRR945219     2   0.000      1.000 0.0 1.0
#> SRR945216     2   0.000      1.000 0.0 1.0
#> SRR945217     2   0.000      1.000 0.0 1.0
#> SRR945220     2   0.000      1.000 0.0 1.0
#> SRR945221     2   0.000      1.000 0.0 1.0
#> SRR945222     2   0.000      1.000 0.0 1.0
#> SRR945223     2   0.000      1.000 0.0 1.0
#> SRR945224     2   0.000      1.000 0.0 1.0
#> SRR945225     2   0.000      1.000 0.0 1.0
#> SRR945226     2   0.000      1.000 0.0 1.0
#> SRR945227     2   0.000      1.000 0.0 1.0
#> SRR945228     2   0.000      1.000 0.0 1.0
#> SRR945229     2   0.000      1.000 0.0 1.0
#> SRR945230     2   0.000      1.000 0.0 1.0
#> SRR945231     2   0.000      1.000 0.0 1.0
#> SRR945232     2   0.000      1.000 0.0 1.0
#> SRR945233     2   0.000      1.000 0.0 1.0
#> SRR945234     2   0.000      1.000 0.0 1.0
#> SRR945235     2   0.000      1.000 0.0 1.0
#> SRR945236     2   0.000      1.000 0.0 1.0
#> SRR945237     2   0.000      1.000 0.0 1.0
#> SRR945238     2   0.000      1.000 0.0 1.0
#> SRR945239     2   0.000      1.000 0.0 1.0
#> SRR945240     2   0.000      1.000 0.0 1.0
#> SRR945241     2   0.000      1.000 0.0 1.0
#> SRR945242     2   0.000      1.000 0.0 1.0
#> SRR945243     2   0.000      1.000 0.0 1.0
#> SRR945244     2   0.000      1.000 0.0 1.0
#> SRR945245     2   0.000      1.000 0.0 1.0
#> SRR945246     2   0.000      1.000 0.0 1.0
#> SRR945247     2   0.000      1.000 0.0 1.0
#> SRR945248     2   0.000      1.000 0.0 1.0
#> SRR945249     2   0.000      1.000 0.0 1.0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette p1 p2 p3
#> SRR945190     1       0          1  1  0  0
#> SRR945191     1       0          1  1  0  0
#> SRR945192     1       0          1  1  0  0
#> SRR945193     1       0          1  1  0  0
#> SRR945194     1       0          1  1  0  0
#> SRR945195     1       0          1  1  0  0
#> SRR945196     1       0          1  1  0  0
#> SRR945197     1       0          1  1  0  0
#> SRR945200     1       0          1  1  0  0
#> SRR945201     1       0          1  1  0  0
#> SRR945202     3       0          1  0  0  1
#> SRR945203     3       0          1  0  0  1
#> SRR945204     3       0          1  0  0  1
#> SRR945205     3       0          1  0  0  1
#> SRR945198     1       0          1  1  0  0
#> SRR945199     1       0          1  1  0  0
#> SRR945206     3       0          1  0  0  1
#> SRR945207     3       0          1  0  0  1
#> SRR945208     3       0          1  0  0  1
#> SRR945209     3       0          1  0  0  1
#> SRR945212     3       0          1  0  0  1
#> SRR945213     3       0          1  0  0  1
#> SRR945214     2       0          1  0  1  0
#> SRR945215     2       0          1  0  1  0
#> SRR945210     3       0          1  0  0  1
#> SRR945211     3       0          1  0  0  1
#> SRR945218     2       0          1  0  1  0
#> SRR945219     2       0          1  0  1  0
#> SRR945216     2       0          1  0  1  0
#> SRR945217     2       0          1  0  1  0
#> SRR945220     2       0          1  0  1  0
#> SRR945221     2       0          1  0  1  0
#> SRR945222     2       0          1  0  1  0
#> SRR945223     2       0          1  0  1  0
#> SRR945224     2       0          1  0  1  0
#> SRR945225     2       0          1  0  1  0
#> SRR945226     2       0          1  0  1  0
#> SRR945227     2       0          1  0  1  0
#> SRR945228     2       0          1  0  1  0
#> SRR945229     2       0          1  0  1  0
#> SRR945230     2       0          1  0  1  0
#> SRR945231     2       0          1  0  1  0
#> SRR945232     2       0          1  0  1  0
#> SRR945233     2       0          1  0  1  0
#> SRR945234     2       0          1  0  1  0
#> SRR945235     2       0          1  0  1  0
#> SRR945236     2       0          1  0  1  0
#> SRR945237     2       0          1  0  1  0
#> SRR945238     2       0          1  0  1  0
#> SRR945239     2       0          1  0  1  0
#> SRR945240     2       0          1  0  1  0
#> SRR945241     2       0          1  0  1  0
#> SRR945242     2       0          1  0  1  0
#> SRR945243     2       0          1  0  1  0
#> SRR945244     2       0          1  0  1  0
#> SRR945245     2       0          1  0  1  0
#> SRR945246     2       0          1  0  1  0
#> SRR945247     2       0          1  0  1  0
#> SRR945248     2       0          1  0  1  0
#> SRR945249     2       0          1  0  1  0

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette p1 p2 p3 p4
#> SRR945190     1       0          1  1  0  0  0
#> SRR945191     1       0          1  1  0  0  0
#> SRR945192     1       0          1  1  0  0  0
#> SRR945193     1       0          1  1  0  0  0
#> SRR945194     1       0          1  1  0  0  0
#> SRR945195     1       0          1  1  0  0  0
#> SRR945196     1       0          1  1  0  0  0
#> SRR945197     1       0          1  1  0  0  0
#> SRR945200     1       0          1  1  0  0  0
#> SRR945201     1       0          1  1  0  0  0
#> SRR945202     4       0          1  0  0  0  1
#> SRR945203     4       0          1  0  0  0  1
#> SRR945204     4       0          1  0  0  0  1
#> SRR945205     4       0          1  0  0  0  1
#> SRR945198     1       0          1  1  0  0  0
#> SRR945199     1       0          1  1  0  0  0
#> SRR945206     4       0          1  0  0  0  1
#> SRR945207     4       0          1  0  0  0  1
#> SRR945208     4       0          1  0  0  0  1
#> SRR945209     4       0          1  0  0  0  1
#> SRR945212     4       0          1  0  0  0  1
#> SRR945213     4       0          1  0  0  0  1
#> SRR945214     2       0          1  0  1  0  0
#> SRR945215     2       0          1  0  1  0  0
#> SRR945210     3       0          1  0  0  1  0
#> SRR945211     3       0          1  0  0  1  0
#> SRR945218     2       0          1  0  1  0  0
#> SRR945219     2       0          1  0  1  0  0
#> SRR945216     2       0          1  0  1  0  0
#> SRR945217     2       0          1  0  1  0  0
#> SRR945220     2       0          1  0  1  0  0
#> SRR945221     2       0          1  0  1  0  0
#> SRR945222     2       0          1  0  1  0  0
#> SRR945223     2       0          1  0  1  0  0
#> SRR945224     2       0          1  0  1  0  0
#> SRR945225     2       0          1  0  1  0  0
#> SRR945226     2       0          1  0  1  0  0
#> SRR945227     2       0          1  0  1  0  0
#> SRR945228     2       0          1  0  1  0  0
#> SRR945229     2       0          1  0  1  0  0
#> SRR945230     2       0          1  0  1  0  0
#> SRR945231     2       0          1  0  1  0  0
#> SRR945232     2       0          1  0  1  0  0
#> SRR945233     2       0          1  0  1  0  0
#> SRR945234     2       0          1  0  1  0  0
#> SRR945235     2       0          1  0  1  0  0
#> SRR945236     2       0          1  0  1  0  0
#> SRR945237     2       0          1  0  1  0  0
#> SRR945238     2       0          1  0  1  0  0
#> SRR945239     2       0          1  0  1  0  0
#> SRR945240     2       0          1  0  1  0  0
#> SRR945241     2       0          1  0  1  0  0
#> SRR945242     2       0          1  0  1  0  0
#> SRR945243     2       0          1  0  1  0  0
#> SRR945244     2       0          1  0  1  0  0
#> SRR945245     2       0          1  0  1  0  0
#> SRR945246     2       0          1  0  1  0  0
#> SRR945247     2       0          1  0  1  0  0
#> SRR945248     2       0          1  0  1  0  0
#> SRR945249     2       0          1  0  1  0  0

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4 p5
#> SRR945190     1   0.414      1.000 0.616 0.000 0.384 0.000  0
#> SRR945191     1   0.414      1.000 0.616 0.000 0.384 0.000  0
#> SRR945192     1   0.414      1.000 0.616 0.000 0.384 0.000  0
#> SRR945193     1   0.414      1.000 0.616 0.000 0.384 0.000  0
#> SRR945194     1   0.414      1.000 0.616 0.000 0.384 0.000  0
#> SRR945195     1   0.414      1.000 0.616 0.000 0.384 0.000  0
#> SRR945196     1   0.414      1.000 0.616 0.000 0.384 0.000  0
#> SRR945197     1   0.414      1.000 0.616 0.000 0.384 0.000  0
#> SRR945200     1   0.414      1.000 0.616 0.000 0.384 0.000  0
#> SRR945201     1   0.414      1.000 0.616 0.000 0.384 0.000  0
#> SRR945202     4   0.000      1.000 0.000 0.000 0.000 1.000  0
#> SRR945203     4   0.000      1.000 0.000 0.000 0.000 1.000  0
#> SRR945204     4   0.000      1.000 0.000 0.000 0.000 1.000  0
#> SRR945205     4   0.000      1.000 0.000 0.000 0.000 1.000  0
#> SRR945198     1   0.414      1.000 0.616 0.000 0.384 0.000  0
#> SRR945199     1   0.414      1.000 0.616 0.000 0.384 0.000  0
#> SRR945206     3   0.414      1.000 0.000 0.000 0.616 0.384  0
#> SRR945207     3   0.414      1.000 0.000 0.000 0.616 0.384  0
#> SRR945208     4   0.000      1.000 0.000 0.000 0.000 1.000  0
#> SRR945209     4   0.000      1.000 0.000 0.000 0.000 1.000  0
#> SRR945212     4   0.000      1.000 0.000 0.000 0.000 1.000  0
#> SRR945213     4   0.000      1.000 0.000 0.000 0.000 1.000  0
#> SRR945214     2   0.000      0.857 0.000 1.000 0.000 0.000  0
#> SRR945215     2   0.000      0.857 0.000 1.000 0.000 0.000  0
#> SRR945210     5   0.000      1.000 0.000 0.000 0.000 0.000  1
#> SRR945211     5   0.000      1.000 0.000 0.000 0.000 0.000  1
#> SRR945218     2   0.000      0.857 0.000 1.000 0.000 0.000  0
#> SRR945219     2   0.000      0.857 0.000 1.000 0.000 0.000  0
#> SRR945216     2   0.000      0.857 0.000 1.000 0.000 0.000  0
#> SRR945217     2   0.000      0.857 0.000 1.000 0.000 0.000  0
#> SRR945220     2   0.000      0.857 0.000 1.000 0.000 0.000  0
#> SRR945221     2   0.000      0.857 0.000 1.000 0.000 0.000  0
#> SRR945222     2   0.000      0.857 0.000 1.000 0.000 0.000  0
#> SRR945223     2   0.000      0.857 0.000 1.000 0.000 0.000  0
#> SRR945224     2   0.000      0.857 0.000 1.000 0.000 0.000  0
#> SRR945225     2   0.000      0.857 0.000 1.000 0.000 0.000  0
#> SRR945226     2   0.000      0.857 0.000 1.000 0.000 0.000  0
#> SRR945227     2   0.000      0.857 0.000 1.000 0.000 0.000  0
#> SRR945228     2   0.000      0.857 0.000 1.000 0.000 0.000  0
#> SRR945229     2   0.000      0.857 0.000 1.000 0.000 0.000  0
#> SRR945230     2   0.000      0.857 0.000 1.000 0.000 0.000  0
#> SRR945231     2   0.000      0.857 0.000 1.000 0.000 0.000  0
#> SRR945232     2   0.000      0.857 0.000 1.000 0.000 0.000  0
#> SRR945233     2   0.000      0.857 0.000 1.000 0.000 0.000  0
#> SRR945234     2   0.000      0.857 0.000 1.000 0.000 0.000  0
#> SRR945235     2   0.000      0.857 0.000 1.000 0.000 0.000  0
#> SRR945236     2   0.000      0.857 0.000 1.000 0.000 0.000  0
#> SRR945237     2   0.000      0.857 0.000 1.000 0.000 0.000  0
#> SRR945238     2   0.414      0.671 0.384 0.616 0.000 0.000  0
#> SRR945239     2   0.414      0.671 0.384 0.616 0.000 0.000  0
#> SRR945240     2   0.414      0.671 0.384 0.616 0.000 0.000  0
#> SRR945241     2   0.414      0.671 0.384 0.616 0.000 0.000  0
#> SRR945242     2   0.414      0.671 0.384 0.616 0.000 0.000  0
#> SRR945243     2   0.414      0.671 0.384 0.616 0.000 0.000  0
#> SRR945244     2   0.414      0.671 0.384 0.616 0.000 0.000  0
#> SRR945245     2   0.414      0.671 0.384 0.616 0.000 0.000  0
#> SRR945246     2   0.414      0.671 0.384 0.616 0.000 0.000  0
#> SRR945247     2   0.414      0.671 0.384 0.616 0.000 0.000  0
#> SRR945248     2   0.414      0.671 0.384 0.616 0.000 0.000  0
#> SRR945249     2   0.414      0.671 0.384 0.616 0.000 0.000  0

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette   p1   p2   p3 p4 p5 p6
#> SRR945190     1   0.000      0.976 1.00 0.00 0.00  0  0  0
#> SRR945191     1   0.000      0.976 1.00 0.00 0.00  0  0  0
#> SRR945192     1   0.000      0.976 1.00 0.00 0.00  0  0  0
#> SRR945193     1   0.000      0.976 1.00 0.00 0.00  0  0  0
#> SRR945194     1   0.226      0.869 0.86 0.00 0.14  0  0  0
#> SRR945195     1   0.226      0.869 0.86 0.00 0.14  0  0  0
#> SRR945196     1   0.000      0.976 1.00 0.00 0.00  0  0  0
#> SRR945197     1   0.000      0.976 1.00 0.00 0.00  0  0  0
#> SRR945200     1   0.000      0.976 1.00 0.00 0.00  0  0  0
#> SRR945201     1   0.000      0.976 1.00 0.00 0.00  0  0  0
#> SRR945202     4   0.000      1.000 0.00 0.00 0.00  1  0  0
#> SRR945203     4   0.000      1.000 0.00 0.00 0.00  1  0  0
#> SRR945204     4   0.000      1.000 0.00 0.00 0.00  1  0  0
#> SRR945205     4   0.000      1.000 0.00 0.00 0.00  1  0  0
#> SRR945198     1   0.000      0.976 1.00 0.00 0.00  0  0  0
#> SRR945199     1   0.000      0.976 1.00 0.00 0.00  0  0  0
#> SRR945206     6   0.000      1.000 0.00 0.00 0.00  0  0  1
#> SRR945207     6   0.000      1.000 0.00 0.00 0.00  0  0  1
#> SRR945208     4   0.000      1.000 0.00 0.00 0.00  1  0  0
#> SRR945209     4   0.000      1.000 0.00 0.00 0.00  1  0  0
#> SRR945212     4   0.000      1.000 0.00 0.00 0.00  1  0  0
#> SRR945213     4   0.000      1.000 0.00 0.00 0.00  1  0  0
#> SRR945214     2   0.000      1.000 0.00 1.00 0.00  0  0  0
#> SRR945215     2   0.000      1.000 0.00 1.00 0.00  0  0  0
#> SRR945210     5   0.000      1.000 0.00 0.00 0.00  0  1  0
#> SRR945211     5   0.000      1.000 0.00 0.00 0.00  0  1  0
#> SRR945218     2   0.000      1.000 0.00 1.00 0.00  0  0  0
#> SRR945219     2   0.000      1.000 0.00 1.00 0.00  0  0  0
#> SRR945216     2   0.000      1.000 0.00 1.00 0.00  0  0  0
#> SRR945217     2   0.000      1.000 0.00 1.00 0.00  0  0  0
#> SRR945220     2   0.000      1.000 0.00 1.00 0.00  0  0  0
#> SRR945221     2   0.000      1.000 0.00 1.00 0.00  0  0  0
#> SRR945222     2   0.000      1.000 0.00 1.00 0.00  0  0  0
#> SRR945223     2   0.000      1.000 0.00 1.00 0.00  0  0  0
#> SRR945224     2   0.000      1.000 0.00 1.00 0.00  0  0  0
#> SRR945225     2   0.000      1.000 0.00 1.00 0.00  0  0  0
#> SRR945226     2   0.000      1.000 0.00 1.00 0.00  0  0  0
#> SRR945227     2   0.000      1.000 0.00 1.00 0.00  0  0  0
#> SRR945228     2   0.000      1.000 0.00 1.00 0.00  0  0  0
#> SRR945229     2   0.000      1.000 0.00 1.00 0.00  0  0  0
#> SRR945230     2   0.000      1.000 0.00 1.00 0.00  0  0  0
#> SRR945231     2   0.000      1.000 0.00 1.00 0.00  0  0  0
#> SRR945232     2   0.000      1.000 0.00 1.00 0.00  0  0  0
#> SRR945233     2   0.000      1.000 0.00 1.00 0.00  0  0  0
#> SRR945234     2   0.000      1.000 0.00 1.00 0.00  0  0  0
#> SRR945235     2   0.000      1.000 0.00 1.00 0.00  0  0  0
#> SRR945236     2   0.000      1.000 0.00 1.00 0.00  0  0  0
#> SRR945237     2   0.000      1.000 0.00 1.00 0.00  0  0  0
#> SRR945238     3   0.226      1.000 0.00 0.14 0.86  0  0  0
#> SRR945239     3   0.226      1.000 0.00 0.14 0.86  0  0  0
#> SRR945240     3   0.226      1.000 0.00 0.14 0.86  0  0  0
#> SRR945241     3   0.226      1.000 0.00 0.14 0.86  0  0  0
#> SRR945242     3   0.226      1.000 0.00 0.14 0.86  0  0  0
#> SRR945243     3   0.226      1.000 0.00 0.14 0.86  0  0  0
#> SRR945244     3   0.226      1.000 0.00 0.14 0.86  0  0  0
#> SRR945245     3   0.226      1.000 0.00 0.14 0.86  0  0  0
#> SRR945246     3   0.226      1.000 0.00 0.14 0.86  0  0  0
#> SRR945247     3   0.226      1.000 0.00 0.14 0.86  0  0  0
#> SRR945248     3   0.226      1.000 0.00 0.14 0.86  0  0  0
#> SRR945249     3   0.226      1.000 0.00 0.14 0.86  0  0  0

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

consensus_heatmap(res, k = 2)

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

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

collect_plots(res)

plot of chunk SD-kmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.989       0.984         0.4823 0.512   0.512
#> 3 3 0.756           0.928       0.813         0.2820 0.837   0.682
#> 4 4 0.673           0.926       0.825         0.1249 0.919   0.767
#> 5 5 0.775           0.864       0.811         0.0807 1.000   1.000
#> 6 6 0.816           0.874       0.812         0.0508 0.919   0.696

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
#> SRR945190     1   0.000      1.000 1.00 0.00
#> SRR945191     1   0.000      1.000 1.00 0.00
#> SRR945192     1   0.000      1.000 1.00 0.00
#> SRR945193     1   0.000      1.000 1.00 0.00
#> SRR945194     1   0.000      1.000 1.00 0.00
#> SRR945195     1   0.000      1.000 1.00 0.00
#> SRR945196     1   0.000      1.000 1.00 0.00
#> SRR945197     1   0.000      1.000 1.00 0.00
#> SRR945200     1   0.000      1.000 1.00 0.00
#> SRR945201     1   0.000      1.000 1.00 0.00
#> SRR945202     1   0.000      1.000 1.00 0.00
#> SRR945203     1   0.000      1.000 1.00 0.00
#> SRR945204     1   0.000      1.000 1.00 0.00
#> SRR945205     1   0.000      1.000 1.00 0.00
#> SRR945198     1   0.000      1.000 1.00 0.00
#> SRR945199     1   0.000      1.000 1.00 0.00
#> SRR945206     1   0.000      1.000 1.00 0.00
#> SRR945207     1   0.000      1.000 1.00 0.00
#> SRR945208     1   0.000      1.000 1.00 0.00
#> SRR945209     1   0.000      1.000 1.00 0.00
#> SRR945212     1   0.000      1.000 1.00 0.00
#> SRR945213     1   0.000      1.000 1.00 0.00
#> SRR945214     2   0.242      0.986 0.04 0.96
#> SRR945215     2   0.242      0.986 0.04 0.96
#> SRR945210     1   0.000      1.000 1.00 0.00
#> SRR945211     1   0.000      1.000 1.00 0.00
#> SRR945218     2   0.242      0.986 0.04 0.96
#> SRR945219     2   0.242      0.986 0.04 0.96
#> SRR945216     2   0.242      0.986 0.04 0.96
#> SRR945217     2   0.242      0.986 0.04 0.96
#> SRR945220     2   0.242      0.986 0.04 0.96
#> SRR945221     2   0.242      0.986 0.04 0.96
#> SRR945222     2   0.242      0.986 0.04 0.96
#> SRR945223     2   0.242      0.986 0.04 0.96
#> SRR945224     2   0.242      0.986 0.04 0.96
#> SRR945225     2   0.242      0.986 0.04 0.96
#> SRR945226     2   0.242      0.986 0.04 0.96
#> SRR945227     2   0.242      0.986 0.04 0.96
#> SRR945228     2   0.242      0.986 0.04 0.96
#> SRR945229     2   0.242      0.986 0.04 0.96
#> SRR945230     2   0.242      0.986 0.04 0.96
#> SRR945231     2   0.242      0.986 0.04 0.96
#> SRR945232     2   0.242      0.986 0.04 0.96
#> SRR945233     2   0.242      0.986 0.04 0.96
#> SRR945234     2   0.242      0.986 0.04 0.96
#> SRR945235     2   0.242      0.986 0.04 0.96
#> SRR945236     2   0.242      0.986 0.04 0.96
#> SRR945237     2   0.242      0.986 0.04 0.96
#> SRR945238     2   0.000      0.972 0.00 1.00
#> SRR945239     2   0.000      0.972 0.00 1.00
#> SRR945240     2   0.000      0.972 0.00 1.00
#> SRR945241     2   0.000      0.972 0.00 1.00
#> SRR945242     2   0.000      0.972 0.00 1.00
#> SRR945243     2   0.000      0.972 0.00 1.00
#> SRR945244     2   0.000      0.972 0.00 1.00
#> SRR945245     2   0.000      0.972 0.00 1.00
#> SRR945246     2   0.000      0.972 0.00 1.00
#> SRR945247     2   0.000      0.972 0.00 1.00
#> SRR945248     2   0.000      0.972 0.00 1.00
#> SRR945249     2   0.000      0.972 0.00 1.00

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> SRR945190     1  0.0000      0.818 1.000 0.000 0.000
#> SRR945191     1  0.0000      0.818 1.000 0.000 0.000
#> SRR945192     1  0.0000      0.818 1.000 0.000 0.000
#> SRR945193     1  0.0000      0.818 1.000 0.000 0.000
#> SRR945194     1  0.0892      0.819 0.980 0.000 0.020
#> SRR945195     1  0.0892      0.819 0.980 0.000 0.020
#> SRR945196     1  0.0000      0.818 1.000 0.000 0.000
#> SRR945197     1  0.0000      0.818 1.000 0.000 0.000
#> SRR945200     1  0.0000      0.818 1.000 0.000 0.000
#> SRR945201     1  0.0000      0.818 1.000 0.000 0.000
#> SRR945202     1  0.6140      0.821 0.596 0.000 0.404
#> SRR945203     1  0.6140      0.821 0.596 0.000 0.404
#> SRR945204     1  0.6140      0.821 0.596 0.000 0.404
#> SRR945205     1  0.6140      0.821 0.596 0.000 0.404
#> SRR945198     1  0.0000      0.818 1.000 0.000 0.000
#> SRR945199     1  0.0000      0.818 1.000 0.000 0.000
#> SRR945206     1  0.6140      0.821 0.596 0.000 0.404
#> SRR945207     1  0.6140      0.821 0.596 0.000 0.404
#> SRR945208     1  0.6140      0.821 0.596 0.000 0.404
#> SRR945209     1  0.6140      0.821 0.596 0.000 0.404
#> SRR945212     1  0.6140      0.821 0.596 0.000 0.404
#> SRR945213     1  0.6140      0.821 0.596 0.000 0.404
#> SRR945214     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945215     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945210     1  0.6140      0.821 0.596 0.000 0.404
#> SRR945211     1  0.6140      0.821 0.596 0.000 0.404
#> SRR945218     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945219     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945216     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945217     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945220     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945221     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945222     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945223     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945224     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945225     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945226     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945227     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945228     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945229     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945230     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945231     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945232     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945233     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945234     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945235     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945236     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945237     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945238     3  0.6140      1.000 0.000 0.404 0.596
#> SRR945239     3  0.6140      1.000 0.000 0.404 0.596
#> SRR945240     3  0.6140      1.000 0.000 0.404 0.596
#> SRR945241     3  0.6140      1.000 0.000 0.404 0.596
#> SRR945242     3  0.6140      1.000 0.000 0.404 0.596
#> SRR945243     3  0.6140      1.000 0.000 0.404 0.596
#> SRR945244     3  0.6140      1.000 0.000 0.404 0.596
#> SRR945245     3  0.6140      1.000 0.000 0.404 0.596
#> SRR945246     3  0.6140      1.000 0.000 0.404 0.596
#> SRR945247     3  0.6140      1.000 0.000 0.404 0.596
#> SRR945248     3  0.6140      1.000 0.000 0.404 0.596
#> SRR945249     3  0.6140      1.000 0.000 0.404 0.596

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> SRR945190     1  0.4817      0.964 0.612 0.000 0.000 0.388
#> SRR945191     1  0.4817      0.964 0.612 0.000 0.000 0.388
#> SRR945192     1  0.4817      0.964 0.612 0.000 0.000 0.388
#> SRR945193     1  0.4817      0.964 0.612 0.000 0.000 0.388
#> SRR945194     1  0.6621      0.905 0.508 0.000 0.084 0.408
#> SRR945195     1  0.6621      0.905 0.508 0.000 0.084 0.408
#> SRR945196     1  0.5638      0.960 0.584 0.000 0.028 0.388
#> SRR945197     1  0.5638      0.960 0.584 0.000 0.028 0.388
#> SRR945200     1  0.6101      0.949 0.560 0.000 0.052 0.388
#> SRR945201     1  0.6101      0.949 0.560 0.000 0.052 0.388
#> SRR945202     4  0.0336      0.972 0.000 0.000 0.008 0.992
#> SRR945203     4  0.0336      0.972 0.000 0.000 0.008 0.992
#> SRR945204     4  0.0592      0.970 0.000 0.000 0.016 0.984
#> SRR945205     4  0.0592      0.970 0.000 0.000 0.016 0.984
#> SRR945198     1  0.4817      0.964 0.612 0.000 0.000 0.388
#> SRR945199     1  0.4817      0.964 0.612 0.000 0.000 0.388
#> SRR945206     4  0.1389      0.951 0.000 0.000 0.048 0.952
#> SRR945207     4  0.1389      0.951 0.000 0.000 0.048 0.952
#> SRR945208     4  0.0188      0.972 0.000 0.000 0.004 0.996
#> SRR945209     4  0.0188      0.972 0.000 0.000 0.004 0.996
#> SRR945212     4  0.0188      0.972 0.000 0.000 0.004 0.996
#> SRR945213     4  0.0188      0.972 0.000 0.000 0.004 0.996
#> SRR945214     2  0.3486      0.882 0.188 0.812 0.000 0.000
#> SRR945215     2  0.3486      0.882 0.188 0.812 0.000 0.000
#> SRR945210     4  0.1716      0.944 0.000 0.000 0.064 0.936
#> SRR945211     4  0.1716      0.944 0.000 0.000 0.064 0.936
#> SRR945218     2  0.3400      0.883 0.180 0.820 0.000 0.000
#> SRR945219     2  0.3400      0.883 0.180 0.820 0.000 0.000
#> SRR945216     2  0.3486      0.882 0.188 0.812 0.000 0.000
#> SRR945217     2  0.3486      0.882 0.188 0.812 0.000 0.000
#> SRR945220     2  0.3528      0.881 0.192 0.808 0.000 0.000
#> SRR945221     2  0.3528      0.881 0.192 0.808 0.000 0.000
#> SRR945222     2  0.3400      0.883 0.180 0.820 0.000 0.000
#> SRR945223     2  0.3400      0.883 0.180 0.820 0.000 0.000
#> SRR945224     2  0.3528      0.881 0.192 0.808 0.000 0.000
#> SRR945225     2  0.3528      0.881 0.192 0.808 0.000 0.000
#> SRR945226     2  0.0188      0.876 0.004 0.996 0.000 0.000
#> SRR945227     2  0.0188      0.876 0.004 0.996 0.000 0.000
#> SRR945228     2  0.1637      0.851 0.060 0.940 0.000 0.000
#> SRR945229     2  0.1637      0.851 0.060 0.940 0.000 0.000
#> SRR945230     2  0.2281      0.834 0.096 0.904 0.000 0.000
#> SRR945231     2  0.2281      0.834 0.096 0.904 0.000 0.000
#> SRR945232     2  0.0336      0.876 0.008 0.992 0.000 0.000
#> SRR945233     2  0.0336      0.876 0.008 0.992 0.000 0.000
#> SRR945234     2  0.0000      0.877 0.000 1.000 0.000 0.000
#> SRR945235     2  0.0000      0.877 0.000 1.000 0.000 0.000
#> SRR945236     2  0.1118      0.863 0.036 0.964 0.000 0.000
#> SRR945237     2  0.1118      0.863 0.036 0.964 0.000 0.000
#> SRR945238     3  0.4281      0.975 0.028 0.180 0.792 0.000
#> SRR945239     3  0.4281      0.975 0.028 0.180 0.792 0.000
#> SRR945240     3  0.3400      0.977 0.000 0.180 0.820 0.000
#> SRR945241     3  0.3400      0.977 0.000 0.180 0.820 0.000
#> SRR945242     3  0.4553      0.972 0.040 0.180 0.780 0.000
#> SRR945243     3  0.4553      0.972 0.040 0.180 0.780 0.000
#> SRR945244     3  0.4949      0.973 0.060 0.180 0.760 0.000
#> SRR945245     3  0.4949      0.973 0.060 0.180 0.760 0.000
#> SRR945246     3  0.4079      0.976 0.020 0.180 0.800 0.000
#> SRR945247     3  0.4079      0.976 0.020 0.180 0.800 0.000
#> SRR945248     3  0.4874      0.964 0.056 0.180 0.764 0.000
#> SRR945249     3  0.4874      0.964 0.056 0.180 0.764 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
#> SRR945190     1  0.3890      0.941 0.736 0.000 0.012 0.252 NA
#> SRR945191     1  0.3890      0.941 0.736 0.000 0.012 0.252 NA
#> SRR945192     1  0.3890      0.941 0.736 0.000 0.012 0.252 NA
#> SRR945193     1  0.3890      0.941 0.736 0.000 0.012 0.252 NA
#> SRR945194     1  0.6268      0.855 0.556 0.000 0.004 0.256 NA
#> SRR945195     1  0.6268      0.855 0.556 0.000 0.004 0.256 NA
#> SRR945196     1  0.4896      0.936 0.696 0.000 0.020 0.252 NA
#> SRR945197     1  0.4896      0.936 0.696 0.000 0.020 0.252 NA
#> SRR945200     1  0.5409      0.922 0.656 0.000 0.008 0.252 NA
#> SRR945201     1  0.5409      0.922 0.656 0.000 0.008 0.252 NA
#> SRR945202     4  0.0865      0.954 0.000 0.000 0.004 0.972 NA
#> SRR945203     4  0.0865      0.954 0.000 0.000 0.004 0.972 NA
#> SRR945204     4  0.0992      0.952 0.000 0.000 0.008 0.968 NA
#> SRR945205     4  0.0992      0.952 0.000 0.000 0.008 0.968 NA
#> SRR945198     1  0.3662      0.941 0.744 0.000 0.000 0.252 NA
#> SRR945199     1  0.3662      0.941 0.744 0.000 0.000 0.252 NA
#> SRR945206     4  0.1764      0.934 0.000 0.000 0.008 0.928 NA
#> SRR945207     4  0.1764      0.934 0.000 0.000 0.008 0.928 NA
#> SRR945208     4  0.0579      0.952 0.000 0.000 0.008 0.984 NA
#> SRR945209     4  0.0579      0.952 0.000 0.000 0.008 0.984 NA
#> SRR945212     4  0.0579      0.952 0.000 0.000 0.008 0.984 NA
#> SRR945213     4  0.0579      0.952 0.000 0.000 0.008 0.984 NA
#> SRR945214     2  0.0510      0.781 0.016 0.984 0.000 0.000 NA
#> SRR945215     2  0.0510      0.781 0.016 0.984 0.000 0.000 NA
#> SRR945210     4  0.2612      0.902 0.000 0.000 0.008 0.868 NA
#> SRR945211     4  0.2612      0.902 0.000 0.000 0.008 0.868 NA
#> SRR945218     2  0.0771      0.785 0.004 0.976 0.000 0.000 NA
#> SRR945219     2  0.0771      0.785 0.004 0.976 0.000 0.000 NA
#> SRR945216     2  0.0510      0.781 0.016 0.984 0.000 0.000 NA
#> SRR945217     2  0.0510      0.781 0.016 0.984 0.000 0.000 NA
#> SRR945220     2  0.0404      0.781 0.012 0.988 0.000 0.000 NA
#> SRR945221     2  0.0404      0.781 0.012 0.988 0.000 0.000 NA
#> SRR945222     2  0.0898      0.785 0.008 0.972 0.000 0.000 NA
#> SRR945223     2  0.0898      0.785 0.008 0.972 0.000 0.000 NA
#> SRR945224     2  0.0404      0.781 0.012 0.988 0.000 0.000 NA
#> SRR945225     2  0.0404      0.781 0.012 0.988 0.000 0.000 NA
#> SRR945226     2  0.4114      0.772 0.000 0.624 0.000 0.000 NA
#> SRR945227     2  0.4114      0.772 0.000 0.624 0.000 0.000 NA
#> SRR945228     2  0.4302      0.726 0.000 0.520 0.000 0.000 NA
#> SRR945229     2  0.4302      0.726 0.000 0.520 0.000 0.000 NA
#> SRR945230     2  0.5405      0.683 0.056 0.484 0.000 0.000 NA
#> SRR945231     2  0.5405      0.683 0.056 0.484 0.000 0.000 NA
#> SRR945232     2  0.4114      0.772 0.000 0.624 0.000 0.000 NA
#> SRR945233     2  0.4114      0.772 0.000 0.624 0.000 0.000 NA
#> SRR945234     2  0.4101      0.773 0.000 0.628 0.000 0.000 NA
#> SRR945235     2  0.4101      0.773 0.000 0.628 0.000 0.000 NA
#> SRR945236     2  0.4278      0.742 0.000 0.548 0.000 0.000 NA
#> SRR945237     2  0.4278      0.742 0.000 0.548 0.000 0.000 NA
#> SRR945238     3  0.4345      0.931 0.072 0.060 0.808 0.000 NA
#> SRR945239     3  0.4345      0.931 0.072 0.060 0.808 0.000 NA
#> SRR945240     3  0.2312      0.939 0.016 0.060 0.912 0.000 NA
#> SRR945241     3  0.2312      0.939 0.016 0.060 0.912 0.000 NA
#> SRR945242     3  0.2910      0.932 0.044 0.060 0.884 0.000 NA
#> SRR945243     3  0.2910      0.932 0.044 0.060 0.884 0.000 NA
#> SRR945244     3  0.4616      0.924 0.096 0.060 0.788 0.000 NA
#> SRR945245     3  0.4616      0.924 0.096 0.060 0.788 0.000 NA
#> SRR945246     3  0.2264      0.937 0.004 0.060 0.912 0.000 NA
#> SRR945247     3  0.2264      0.937 0.004 0.060 0.912 0.000 NA
#> SRR945248     3  0.4984      0.910 0.088 0.060 0.764 0.000 NA
#> SRR945249     3  0.4984      0.910 0.088 0.060 0.764 0.000 NA

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4 p5    p6
#> SRR945190     1  0.0622      0.929 0.980 0.000 0.008 0.000 NA 0.000
#> SRR945191     1  0.0622      0.929 0.980 0.000 0.008 0.000 NA 0.000
#> SRR945192     1  0.0405      0.930 0.988 0.000 0.004 0.000 NA 0.000
#> SRR945193     1  0.0405      0.930 0.988 0.000 0.004 0.000 NA 0.000
#> SRR945194     1  0.4696      0.811 0.712 0.000 0.000 0.024 NA 0.188
#> SRR945195     1  0.4696      0.811 0.712 0.000 0.000 0.024 NA 0.188
#> SRR945196     1  0.2122      0.923 0.916 0.000 0.024 0.000 NA 0.028
#> SRR945197     1  0.2122      0.923 0.916 0.000 0.024 0.000 NA 0.028
#> SRR945200     1  0.2687      0.910 0.876 0.000 0.008 0.000 NA 0.072
#> SRR945201     1  0.2687      0.910 0.876 0.000 0.008 0.000 NA 0.072
#> SRR945202     4  0.2404      0.940 0.080 0.000 0.000 0.884 NA 0.000
#> SRR945203     4  0.2404      0.940 0.080 0.000 0.000 0.884 NA 0.000
#> SRR945204     4  0.2893      0.935 0.080 0.000 0.004 0.864 NA 0.004
#> SRR945205     4  0.2893      0.935 0.080 0.000 0.004 0.864 NA 0.004
#> SRR945198     1  0.0260      0.930 0.992 0.000 0.000 0.000 NA 0.000
#> SRR945199     1  0.0260      0.930 0.992 0.000 0.000 0.000 NA 0.000
#> SRR945206     4  0.3661      0.917 0.080 0.000 0.004 0.824 NA 0.024
#> SRR945207     4  0.3661      0.917 0.080 0.000 0.004 0.824 NA 0.024
#> SRR945208     4  0.2169      0.940 0.080 0.000 0.008 0.900 NA 0.012
#> SRR945209     4  0.2169      0.940 0.080 0.000 0.008 0.900 NA 0.012
#> SRR945212     4  0.2169      0.940 0.080 0.000 0.008 0.900 NA 0.012
#> SRR945213     4  0.2169      0.940 0.080 0.000 0.008 0.900 NA 0.012
#> SRR945214     2  0.1082      0.901 0.000 0.956 0.000 0.004 NA 0.000
#> SRR945215     2  0.1082      0.901 0.000 0.956 0.000 0.004 NA 0.000
#> SRR945210     4  0.4492      0.852 0.080 0.000 0.000 0.700 NA 0.004
#> SRR945211     4  0.4492      0.852 0.080 0.000 0.000 0.700 NA 0.004
#> SRR945218     2  0.1588      0.867 0.000 0.924 0.000 0.004 NA 0.072
#> SRR945219     2  0.1588      0.867 0.000 0.924 0.000 0.004 NA 0.072
#> SRR945216     2  0.1082      0.901 0.000 0.956 0.000 0.004 NA 0.000
#> SRR945217     2  0.1082      0.901 0.000 0.956 0.000 0.004 NA 0.000
#> SRR945220     2  0.0806      0.908 0.000 0.972 0.000 0.020 NA 0.000
#> SRR945221     2  0.0806      0.908 0.000 0.972 0.000 0.020 NA 0.000
#> SRR945222     2  0.2196      0.814 0.000 0.884 0.000 0.004 NA 0.108
#> SRR945223     2  0.2196      0.814 0.000 0.884 0.000 0.004 NA 0.108
#> SRR945224     2  0.0891      0.907 0.000 0.968 0.000 0.024 NA 0.000
#> SRR945225     2  0.0891      0.907 0.000 0.968 0.000 0.024 NA 0.000
#> SRR945226     6  0.3843      0.814 0.000 0.452 0.000 0.000 NA 0.548
#> SRR945227     6  0.3843      0.814 0.000 0.452 0.000 0.000 NA 0.548
#> SRR945228     6  0.4092      0.793 0.000 0.344 0.000 0.000 NA 0.636
#> SRR945229     6  0.4092      0.793 0.000 0.344 0.000 0.000 NA 0.636
#> SRR945230     6  0.6242      0.554 0.000 0.304 0.000 0.016 NA 0.460
#> SRR945231     6  0.6242      0.554 0.000 0.304 0.000 0.016 NA 0.460
#> SRR945232     6  0.3986      0.803 0.000 0.464 0.000 0.004 NA 0.532
#> SRR945233     6  0.3986      0.803 0.000 0.464 0.000 0.004 NA 0.532
#> SRR945234     6  0.3847      0.811 0.000 0.456 0.000 0.000 NA 0.544
#> SRR945235     6  0.3847      0.811 0.000 0.456 0.000 0.000 NA 0.544
#> SRR945236     6  0.4047      0.817 0.000 0.384 0.000 0.000 NA 0.604
#> SRR945237     6  0.4047      0.817 0.000 0.384 0.000 0.000 NA 0.604
#> SRR945238     3  0.3491      0.903 0.000 0.044 0.832 0.008 NA 0.016
#> SRR945239     3  0.3491      0.903 0.000 0.044 0.832 0.008 NA 0.016
#> SRR945240     3  0.1007      0.913 0.000 0.044 0.956 0.000 NA 0.000
#> SRR945241     3  0.1007      0.913 0.000 0.044 0.956 0.000 NA 0.000
#> SRR945242     3  0.3660      0.892 0.000 0.044 0.800 0.008 NA 0.004
#> SRR945243     3  0.3660      0.892 0.000 0.044 0.800 0.008 NA 0.004
#> SRR945244     3  0.4107      0.878 0.000 0.044 0.700 0.000 NA 0.000
#> SRR945245     3  0.4107      0.878 0.000 0.044 0.700 0.000 NA 0.000
#> SRR945246     3  0.2214      0.913 0.000 0.044 0.912 0.004 NA 0.012
#> SRR945247     3  0.2214      0.913 0.000 0.044 0.912 0.004 NA 0.012
#> SRR945248     3  0.4317      0.875 0.000 0.044 0.780 0.008 NA 0.052
#> SRR945249     3  0.4308      0.875 0.000 0.044 0.780 0.012 NA 0.040

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

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

collect_plots(res)

plot of chunk SD-skmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4886 0.512   0.512
#> 3 3 1.000           0.999       0.998         0.3322 0.837   0.682
#> 4 4 1.000           0.999       0.998         0.1243 0.919   0.767
#> 5 5 0.973           0.974       0.969         0.0264 0.975   0.907
#> 6 6 1.000           0.985       0.985         0.0294 0.989   0.953

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
#> SRR945190     1       0          1  1  0
#> SRR945191     1       0          1  1  0
#> SRR945192     1       0          1  1  0
#> SRR945193     1       0          1  1  0
#> SRR945194     1       0          1  1  0
#> SRR945195     1       0          1  1  0
#> SRR945196     1       0          1  1  0
#> SRR945197     1       0          1  1  0
#> SRR945200     1       0          1  1  0
#> SRR945201     1       0          1  1  0
#> SRR945202     1       0          1  1  0
#> SRR945203     1       0          1  1  0
#> SRR945204     1       0          1  1  0
#> SRR945205     1       0          1  1  0
#> SRR945198     1       0          1  1  0
#> SRR945199     1       0          1  1  0
#> SRR945206     1       0          1  1  0
#> SRR945207     1       0          1  1  0
#> SRR945208     1       0          1  1  0
#> SRR945209     1       0          1  1  0
#> SRR945212     1       0          1  1  0
#> SRR945213     1       0          1  1  0
#> SRR945214     2       0          1  0  1
#> SRR945215     2       0          1  0  1
#> SRR945210     1       0          1  1  0
#> SRR945211     1       0          1  1  0
#> SRR945218     2       0          1  0  1
#> SRR945219     2       0          1  0  1
#> SRR945216     2       0          1  0  1
#> SRR945217     2       0          1  0  1
#> SRR945220     2       0          1  0  1
#> SRR945221     2       0          1  0  1
#> SRR945222     2       0          1  0  1
#> SRR945223     2       0          1  0  1
#> SRR945224     2       0          1  0  1
#> SRR945225     2       0          1  0  1
#> SRR945226     2       0          1  0  1
#> SRR945227     2       0          1  0  1
#> SRR945228     2       0          1  0  1
#> SRR945229     2       0          1  0  1
#> SRR945230     2       0          1  0  1
#> SRR945231     2       0          1  0  1
#> SRR945232     2       0          1  0  1
#> SRR945233     2       0          1  0  1
#> SRR945234     2       0          1  0  1
#> SRR945235     2       0          1  0  1
#> SRR945236     2       0          1  0  1
#> SRR945237     2       0          1  0  1
#> SRR945238     2       0          1  0  1
#> SRR945239     2       0          1  0  1
#> SRR945240     2       0          1  0  1
#> SRR945241     2       0          1  0  1
#> SRR945242     2       0          1  0  1
#> SRR945243     2       0          1  0  1
#> SRR945244     2       0          1  0  1
#> SRR945245     2       0          1  0  1
#> SRR945246     2       0          1  0  1
#> SRR945247     2       0          1  0  1
#> SRR945248     2       0          1  0  1
#> SRR945249     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
#> SRR945190     1  0.0237      0.998 0.996 0.000 0.004
#> SRR945191     1  0.0237      0.998 0.996 0.000 0.004
#> SRR945192     1  0.0237      0.998 0.996 0.000 0.004
#> SRR945193     1  0.0237      0.998 0.996 0.000 0.004
#> SRR945194     1  0.0237      0.998 0.996 0.000 0.004
#> SRR945195     1  0.0237      0.998 0.996 0.000 0.004
#> SRR945196     1  0.0237      0.998 0.996 0.000 0.004
#> SRR945197     1  0.0237      0.998 0.996 0.000 0.004
#> SRR945200     1  0.0237      0.998 0.996 0.000 0.004
#> SRR945201     1  0.0237      0.998 0.996 0.000 0.004
#> SRR945202     1  0.0000      0.998 1.000 0.000 0.000
#> SRR945203     1  0.0000      0.998 1.000 0.000 0.000
#> SRR945204     1  0.0000      0.998 1.000 0.000 0.000
#> SRR945205     1  0.0000      0.998 1.000 0.000 0.000
#> SRR945198     1  0.0237      0.998 0.996 0.000 0.004
#> SRR945199     1  0.0237      0.998 0.996 0.000 0.004
#> SRR945206     1  0.0000      0.998 1.000 0.000 0.000
#> SRR945207     1  0.0000      0.998 1.000 0.000 0.000
#> SRR945208     1  0.0000      0.998 1.000 0.000 0.000
#> SRR945209     1  0.0000      0.998 1.000 0.000 0.000
#> SRR945212     1  0.0000      0.998 1.000 0.000 0.000
#> SRR945213     1  0.0000      0.998 1.000 0.000 0.000
#> SRR945214     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945215     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945210     1  0.0000      0.998 1.000 0.000 0.000
#> SRR945211     1  0.0000      0.998 1.000 0.000 0.000
#> SRR945218     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945219     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945216     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945217     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945220     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945221     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945222     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945223     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945224     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945225     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945226     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945227     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945228     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945229     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945230     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945231     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945232     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945233     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945234     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945235     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945236     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945237     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945238     3  0.0237      1.000 0.000 0.004 0.996
#> SRR945239     3  0.0237      1.000 0.000 0.004 0.996
#> SRR945240     3  0.0237      1.000 0.000 0.004 0.996
#> SRR945241     3  0.0237      1.000 0.000 0.004 0.996
#> SRR945242     3  0.0237      1.000 0.000 0.004 0.996
#> SRR945243     3  0.0237      1.000 0.000 0.004 0.996
#> SRR945244     3  0.0237      1.000 0.000 0.004 0.996
#> SRR945245     3  0.0237      1.000 0.000 0.004 0.996
#> SRR945246     3  0.0237      1.000 0.000 0.004 0.996
#> SRR945247     3  0.0237      1.000 0.000 0.004 0.996
#> SRR945248     3  0.0237      1.000 0.000 0.004 0.996
#> SRR945249     3  0.0237      1.000 0.000 0.004 0.996

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2 p3    p4
#> SRR945190     1  0.0000      1.000 1.000 0.000  0 0.000
#> SRR945191     1  0.0000      1.000 1.000 0.000  0 0.000
#> SRR945192     1  0.0000      1.000 1.000 0.000  0 0.000
#> SRR945193     1  0.0000      1.000 1.000 0.000  0 0.000
#> SRR945194     1  0.0000      1.000 1.000 0.000  0 0.000
#> SRR945195     1  0.0000      1.000 1.000 0.000  0 0.000
#> SRR945196     1  0.0000      1.000 1.000 0.000  0 0.000
#> SRR945197     1  0.0000      1.000 1.000 0.000  0 0.000
#> SRR945200     1  0.0000      1.000 1.000 0.000  0 0.000
#> SRR945201     1  0.0000      1.000 1.000 0.000  0 0.000
#> SRR945202     4  0.0469      0.999 0.012 0.000  0 0.988
#> SRR945203     4  0.0469      0.999 0.012 0.000  0 0.988
#> SRR945204     4  0.0469      0.999 0.012 0.000  0 0.988
#> SRR945205     4  0.0469      0.999 0.012 0.000  0 0.988
#> SRR945198     1  0.0000      1.000 1.000 0.000  0 0.000
#> SRR945199     1  0.0000      1.000 1.000 0.000  0 0.000
#> SRR945206     4  0.0469      0.999 0.012 0.000  0 0.988
#> SRR945207     4  0.0469      0.999 0.012 0.000  0 0.988
#> SRR945208     4  0.0469      0.999 0.012 0.000  0 0.988
#> SRR945209     4  0.0469      0.999 0.012 0.000  0 0.988
#> SRR945212     4  0.0469      0.999 0.012 0.000  0 0.988
#> SRR945213     4  0.0469      0.999 0.012 0.000  0 0.988
#> SRR945214     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR945215     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR945210     4  0.0188      0.993 0.004 0.000  0 0.996
#> SRR945211     4  0.0188      0.993 0.004 0.000  0 0.996
#> SRR945218     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR945219     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR945216     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR945217     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR945220     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR945221     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR945222     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR945223     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR945224     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR945225     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR945226     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR945227     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR945228     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR945229     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR945230     2  0.0188      0.997 0.000 0.996  0 0.004
#> SRR945231     2  0.0188      0.997 0.000 0.996  0 0.004
#> SRR945232     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR945233     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR945234     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR945235     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR945236     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR945237     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR945238     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR945239     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR945240     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR945241     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR945242     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR945243     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR945244     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR945245     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR945246     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR945247     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR945248     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR945249     3  0.0000      1.000 0.000 0.000  1 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette p1    p2 p3   p4    p5
#> SRR945190     1  0.0000      1.000  1 0.000  0 0.00 0.000
#> SRR945191     1  0.0000      1.000  1 0.000  0 0.00 0.000
#> SRR945192     1  0.0000      1.000  1 0.000  0 0.00 0.000
#> SRR945193     1  0.0000      1.000  1 0.000  0 0.00 0.000
#> SRR945194     1  0.0000      1.000  1 0.000  0 0.00 0.000
#> SRR945195     1  0.0000      1.000  1 0.000  0 0.00 0.000
#> SRR945196     1  0.0000      1.000  1 0.000  0 0.00 0.000
#> SRR945197     1  0.0000      1.000  1 0.000  0 0.00 0.000
#> SRR945200     1  0.0000      1.000  1 0.000  0 0.00 0.000
#> SRR945201     1  0.0000      1.000  1 0.000  0 0.00 0.000
#> SRR945202     4  0.0000      0.930  0 0.000  0 1.00 0.000
#> SRR945203     4  0.0000      0.930  0 0.000  0 1.00 0.000
#> SRR945204     4  0.0000      0.930  0 0.000  0 1.00 0.000
#> SRR945205     4  0.0000      0.930  0 0.000  0 1.00 0.000
#> SRR945198     1  0.0000      1.000  1 0.000  0 0.00 0.000
#> SRR945199     1  0.0000      1.000  1 0.000  0 0.00 0.000
#> SRR945206     4  0.0000      0.930  0 0.000  0 1.00 0.000
#> SRR945207     4  0.0000      0.930  0 0.000  0 1.00 0.000
#> SRR945208     4  0.0000      0.930  0 0.000  0 1.00 0.000
#> SRR945209     4  0.0000      0.930  0 0.000  0 1.00 0.000
#> SRR945212     4  0.0000      0.930  0 0.000  0 1.00 0.000
#> SRR945213     4  0.0000      0.930  0 0.000  0 1.00 0.000
#> SRR945214     2  0.0000      0.999  0 1.000  0 0.00 0.000
#> SRR945215     2  0.0000      0.999  0 1.000  0 0.00 0.000
#> SRR945210     4  0.4287      0.574  0 0.000  0 0.54 0.460
#> SRR945211     4  0.4287      0.574  0 0.000  0 0.54 0.460
#> SRR945218     2  0.0000      0.999  0 1.000  0 0.00 0.000
#> SRR945219     2  0.0000      0.999  0 1.000  0 0.00 0.000
#> SRR945216     2  0.0000      0.999  0 1.000  0 0.00 0.000
#> SRR945217     2  0.0000      0.999  0 1.000  0 0.00 0.000
#> SRR945220     2  0.0000      0.999  0 1.000  0 0.00 0.000
#> SRR945221     2  0.0000      0.999  0 1.000  0 0.00 0.000
#> SRR945222     2  0.0000      0.999  0 1.000  0 0.00 0.000
#> SRR945223     2  0.0000      0.999  0 1.000  0 0.00 0.000
#> SRR945224     2  0.0000      0.999  0 1.000  0 0.00 0.000
#> SRR945225     2  0.0000      0.999  0 1.000  0 0.00 0.000
#> SRR945226     2  0.0000      0.999  0 1.000  0 0.00 0.000
#> SRR945227     2  0.0000      0.999  0 1.000  0 0.00 0.000
#> SRR945228     2  0.0162      0.993  0 0.996  0 0.00 0.004
#> SRR945229     2  0.0162      0.993  0 0.996  0 0.00 0.004
#> SRR945230     5  0.4287      1.000  0 0.460  0 0.00 0.540
#> SRR945231     5  0.4287      1.000  0 0.460  0 0.00 0.540
#> SRR945232     2  0.0000      0.999  0 1.000  0 0.00 0.000
#> SRR945233     2  0.0000      0.999  0 1.000  0 0.00 0.000
#> SRR945234     2  0.0000      0.999  0 1.000  0 0.00 0.000
#> SRR945235     2  0.0000      0.999  0 1.000  0 0.00 0.000
#> SRR945236     2  0.0000      0.999  0 1.000  0 0.00 0.000
#> SRR945237     2  0.0000      0.999  0 1.000  0 0.00 0.000
#> SRR945238     3  0.0000      1.000  0 0.000  1 0.00 0.000
#> SRR945239     3  0.0000      1.000  0 0.000  1 0.00 0.000
#> SRR945240     3  0.0000      1.000  0 0.000  1 0.00 0.000
#> SRR945241     3  0.0000      1.000  0 0.000  1 0.00 0.000
#> SRR945242     3  0.0000      1.000  0 0.000  1 0.00 0.000
#> SRR945243     3  0.0000      1.000  0 0.000  1 0.00 0.000
#> SRR945244     3  0.0000      1.000  0 0.000  1 0.00 0.000
#> SRR945245     3  0.0000      1.000  0 0.000  1 0.00 0.000
#> SRR945246     3  0.0000      1.000  0 0.000  1 0.00 0.000
#> SRR945247     3  0.0000      1.000  0 0.000  1 0.00 0.000
#> SRR945248     3  0.0000      1.000  0 0.000  1 0.00 0.000
#> SRR945249     3  0.0000      1.000  0 0.000  1 0.00 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette p1    p2 p3    p4    p5    p6
#> SRR945190     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR945191     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR945192     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR945193     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR945194     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR945195     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR945196     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR945197     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR945200     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR945201     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR945202     4  0.0000      0.999  0 0.000  0 1.000 0.000 0.000
#> SRR945203     4  0.0000      0.999  0 0.000  0 1.000 0.000 0.000
#> SRR945204     4  0.0000      0.999  0 0.000  0 1.000 0.000 0.000
#> SRR945205     4  0.0000      0.999  0 0.000  0 1.000 0.000 0.000
#> SRR945198     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR945199     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR945206     4  0.0146      0.996  0 0.000  0 0.996 0.004 0.000
#> SRR945207     4  0.0146      0.996  0 0.000  0 0.996 0.004 0.000
#> SRR945208     4  0.0000      0.999  0 0.000  0 1.000 0.000 0.000
#> SRR945209     4  0.0000      0.999  0 0.000  0 1.000 0.000 0.000
#> SRR945212     4  0.0000      0.999  0 0.000  0 1.000 0.000 0.000
#> SRR945213     4  0.0000      0.999  0 0.000  0 1.000 0.000 0.000
#> SRR945214     2  0.0000      0.965  0 1.000  0 0.000 0.000 0.000
#> SRR945215     2  0.0000      0.965  0 1.000  0 0.000 0.000 0.000
#> SRR945210     5  0.1075      1.000  0 0.000  0 0.048 0.952 0.000
#> SRR945211     5  0.1075      1.000  0 0.000  0 0.048 0.952 0.000
#> SRR945218     2  0.0000      0.965  0 1.000  0 0.000 0.000 0.000
#> SRR945219     2  0.0000      0.965  0 1.000  0 0.000 0.000 0.000
#> SRR945216     2  0.0000      0.965  0 1.000  0 0.000 0.000 0.000
#> SRR945217     2  0.0000      0.965  0 1.000  0 0.000 0.000 0.000
#> SRR945220     2  0.0000      0.965  0 1.000  0 0.000 0.000 0.000
#> SRR945221     2  0.0000      0.965  0 1.000  0 0.000 0.000 0.000
#> SRR945222     2  0.0000      0.965  0 1.000  0 0.000 0.000 0.000
#> SRR945223     2  0.0000      0.965  0 1.000  0 0.000 0.000 0.000
#> SRR945224     2  0.0000      0.965  0 1.000  0 0.000 0.000 0.000
#> SRR945225     2  0.0000      0.965  0 1.000  0 0.000 0.000 0.000
#> SRR945226     2  0.1700      0.955  0 0.928  0 0.000 0.048 0.024
#> SRR945227     2  0.1700      0.955  0 0.928  0 0.000 0.048 0.024
#> SRR945228     2  0.2070      0.945  0 0.908  0 0.000 0.048 0.044
#> SRR945229     2  0.2070      0.945  0 0.908  0 0.000 0.048 0.044
#> SRR945230     6  0.0000      1.000  0 0.000  0 0.000 0.000 1.000
#> SRR945231     6  0.0000      1.000  0 0.000  0 0.000 0.000 1.000
#> SRR945232     2  0.1528      0.957  0 0.936  0 0.000 0.048 0.016
#> SRR945233     2  0.1528      0.957  0 0.936  0 0.000 0.048 0.016
#> SRR945234     2  0.1700      0.955  0 0.928  0 0.000 0.048 0.024
#> SRR945235     2  0.1700      0.955  0 0.928  0 0.000 0.048 0.024
#> SRR945236     2  0.1930      0.949  0 0.916  0 0.000 0.048 0.036
#> SRR945237     2  0.1930      0.949  0 0.916  0 0.000 0.048 0.036
#> SRR945238     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR945239     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR945240     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR945241     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR945242     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR945243     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR945244     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR945245     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR945246     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR945247     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR945248     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR945249     3  0.0000      1.000  0 0.000  1 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 15912 rows and 60 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#>   Subgroups are detected by 'pam' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 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           0.993       0.997         0.4871 0.512   0.512
#> 3 3 0.753           0.946       0.883         0.2899 0.837   0.682
#> 4 4 1.000           1.000       1.000         0.1658 0.919   0.767
#> 5 5 1.000           1.000       1.000         0.0154 0.989   0.958
#> 6 6 1.000           0.999       0.999         0.0124 0.991   0.965

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
#> SRR945190     1   0.000      0.991 1.000 0.000
#> SRR945191     1   0.000      0.991 1.000 0.000
#> SRR945192     1   0.000      0.991 1.000 0.000
#> SRR945193     1   0.000      0.991 1.000 0.000
#> SRR945194     1   0.000      0.991 1.000 0.000
#> SRR945195     1   0.000      0.991 1.000 0.000
#> SRR945196     1   0.000      0.991 1.000 0.000
#> SRR945197     1   0.000      0.991 1.000 0.000
#> SRR945200     1   0.000      0.991 1.000 0.000
#> SRR945201     1   0.000      0.991 1.000 0.000
#> SRR945202     1   0.000      0.991 1.000 0.000
#> SRR945203     1   0.000      0.991 1.000 0.000
#> SRR945204     1   0.000      0.991 1.000 0.000
#> SRR945205     1   0.000      0.991 1.000 0.000
#> SRR945198     1   0.000      0.991 1.000 0.000
#> SRR945199     1   0.000      0.991 1.000 0.000
#> SRR945206     1   0.000      0.991 1.000 0.000
#> SRR945207     1   0.000      0.991 1.000 0.000
#> SRR945208     1   0.000      0.991 1.000 0.000
#> SRR945209     1   0.000      0.991 1.000 0.000
#> SRR945212     1   0.000      0.991 1.000 0.000
#> SRR945213     1   0.000      0.991 1.000 0.000
#> SRR945214     2   0.000      1.000 0.000 1.000
#> SRR945215     2   0.000      1.000 0.000 1.000
#> SRR945210     1   0.430      0.906 0.912 0.088
#> SRR945211     1   0.506      0.879 0.888 0.112
#> SRR945218     2   0.000      1.000 0.000 1.000
#> SRR945219     2   0.000      1.000 0.000 1.000
#> SRR945216     2   0.000      1.000 0.000 1.000
#> SRR945217     2   0.000      1.000 0.000 1.000
#> SRR945220     2   0.000      1.000 0.000 1.000
#> SRR945221     2   0.000      1.000 0.000 1.000
#> SRR945222     2   0.000      1.000 0.000 1.000
#> SRR945223     2   0.000      1.000 0.000 1.000
#> SRR945224     2   0.000      1.000 0.000 1.000
#> SRR945225     2   0.000      1.000 0.000 1.000
#> SRR945226     2   0.000      1.000 0.000 1.000
#> SRR945227     2   0.000      1.000 0.000 1.000
#> SRR945228     2   0.000      1.000 0.000 1.000
#> SRR945229     2   0.000      1.000 0.000 1.000
#> SRR945230     2   0.000      1.000 0.000 1.000
#> SRR945231     2   0.000      1.000 0.000 1.000
#> SRR945232     2   0.000      1.000 0.000 1.000
#> SRR945233     2   0.000      1.000 0.000 1.000
#> SRR945234     2   0.000      1.000 0.000 1.000
#> SRR945235     2   0.000      1.000 0.000 1.000
#> SRR945236     2   0.000      1.000 0.000 1.000
#> SRR945237     2   0.000      1.000 0.000 1.000
#> SRR945238     2   0.000      1.000 0.000 1.000
#> SRR945239     2   0.000      1.000 0.000 1.000
#> SRR945240     2   0.000      1.000 0.000 1.000
#> SRR945241     2   0.000      1.000 0.000 1.000
#> SRR945242     2   0.000      1.000 0.000 1.000
#> SRR945243     2   0.000      1.000 0.000 1.000
#> SRR945244     2   0.000      1.000 0.000 1.000
#> SRR945245     2   0.000      1.000 0.000 1.000
#> SRR945246     2   0.000      1.000 0.000 1.000
#> SRR945247     2   0.000      1.000 0.000 1.000
#> SRR945248     2   0.000      1.000 0.000 1.000
#> SRR945249     2   0.000      1.000 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> SRR945190     1   0.546      0.869 0.712 0.000 0.288
#> SRR945191     1   0.546      0.869 0.712 0.000 0.288
#> SRR945192     1   0.546      0.869 0.712 0.000 0.288
#> SRR945193     1   0.546      0.869 0.712 0.000 0.288
#> SRR945194     1   0.546      0.869 0.712 0.000 0.288
#> SRR945195     1   0.546      0.869 0.712 0.000 0.288
#> SRR945196     1   0.546      0.869 0.712 0.000 0.288
#> SRR945197     1   0.546      0.869 0.712 0.000 0.288
#> SRR945200     1   0.546      0.869 0.712 0.000 0.288
#> SRR945201     1   0.546      0.869 0.712 0.000 0.288
#> SRR945202     1   0.000      0.866 1.000 0.000 0.000
#> SRR945203     1   0.000      0.866 1.000 0.000 0.000
#> SRR945204     1   0.000      0.866 1.000 0.000 0.000
#> SRR945205     1   0.000      0.866 1.000 0.000 0.000
#> SRR945198     1   0.546      0.869 0.712 0.000 0.288
#> SRR945199     1   0.546      0.869 0.712 0.000 0.288
#> SRR945206     1   0.000      0.866 1.000 0.000 0.000
#> SRR945207     1   0.000      0.866 1.000 0.000 0.000
#> SRR945208     1   0.000      0.866 1.000 0.000 0.000
#> SRR945209     1   0.000      0.866 1.000 0.000 0.000
#> SRR945212     1   0.000      0.866 1.000 0.000 0.000
#> SRR945213     1   0.000      0.866 1.000 0.000 0.000
#> SRR945214     2   0.000      1.000 0.000 1.000 0.000
#> SRR945215     2   0.000      1.000 0.000 1.000 0.000
#> SRR945210     1   0.103      0.851 0.976 0.000 0.024
#> SRR945211     1   0.207      0.823 0.940 0.000 0.060
#> SRR945218     2   0.000      1.000 0.000 1.000 0.000
#> SRR945219     2   0.000      1.000 0.000 1.000 0.000
#> SRR945216     2   0.000      1.000 0.000 1.000 0.000
#> SRR945217     2   0.000      1.000 0.000 1.000 0.000
#> SRR945220     2   0.000      1.000 0.000 1.000 0.000
#> SRR945221     2   0.000      1.000 0.000 1.000 0.000
#> SRR945222     2   0.000      1.000 0.000 1.000 0.000
#> SRR945223     2   0.000      1.000 0.000 1.000 0.000
#> SRR945224     2   0.000      1.000 0.000 1.000 0.000
#> SRR945225     2   0.000      1.000 0.000 1.000 0.000
#> SRR945226     2   0.000      1.000 0.000 1.000 0.000
#> SRR945227     2   0.000      1.000 0.000 1.000 0.000
#> SRR945228     2   0.000      1.000 0.000 1.000 0.000
#> SRR945229     2   0.000      1.000 0.000 1.000 0.000
#> SRR945230     2   0.000      1.000 0.000 1.000 0.000
#> SRR945231     2   0.000      1.000 0.000 1.000 0.000
#> SRR945232     2   0.000      1.000 0.000 1.000 0.000
#> SRR945233     2   0.000      1.000 0.000 1.000 0.000
#> SRR945234     2   0.000      1.000 0.000 1.000 0.000
#> SRR945235     2   0.000      1.000 0.000 1.000 0.000
#> SRR945236     2   0.000      1.000 0.000 1.000 0.000
#> SRR945237     2   0.000      1.000 0.000 1.000 0.000
#> SRR945238     3   0.546      1.000 0.000 0.288 0.712
#> SRR945239     3   0.546      1.000 0.000 0.288 0.712
#> SRR945240     3   0.546      1.000 0.000 0.288 0.712
#> SRR945241     3   0.546      1.000 0.000 0.288 0.712
#> SRR945242     3   0.546      1.000 0.000 0.288 0.712
#> SRR945243     3   0.546      1.000 0.000 0.288 0.712
#> SRR945244     3   0.546      1.000 0.000 0.288 0.712
#> SRR945245     3   0.546      1.000 0.000 0.288 0.712
#> SRR945246     3   0.546      1.000 0.000 0.288 0.712
#> SRR945247     3   0.546      1.000 0.000 0.288 0.712
#> SRR945248     3   0.546      1.000 0.000 0.288 0.712
#> SRR945249     3   0.546      1.000 0.000 0.288 0.712

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette p1 p2 p3 p4
#> SRR945190     1       0          1  1  0  0  0
#> SRR945191     1       0          1  1  0  0  0
#> SRR945192     1       0          1  1  0  0  0
#> SRR945193     1       0          1  1  0  0  0
#> SRR945194     1       0          1  1  0  0  0
#> SRR945195     1       0          1  1  0  0  0
#> SRR945196     1       0          1  1  0  0  0
#> SRR945197     1       0          1  1  0  0  0
#> SRR945200     1       0          1  1  0  0  0
#> SRR945201     1       0          1  1  0  0  0
#> SRR945202     4       0          1  0  0  0  1
#> SRR945203     4       0          1  0  0  0  1
#> SRR945204     4       0          1  0  0  0  1
#> SRR945205     4       0          1  0  0  0  1
#> SRR945198     1       0          1  1  0  0  0
#> SRR945199     1       0          1  1  0  0  0
#> SRR945206     4       0          1  0  0  0  1
#> SRR945207     4       0          1  0  0  0  1
#> SRR945208     4       0          1  0  0  0  1
#> SRR945209     4       0          1  0  0  0  1
#> SRR945212     4       0          1  0  0  0  1
#> SRR945213     4       0          1  0  0  0  1
#> SRR945214     2       0          1  0  1  0  0
#> SRR945215     2       0          1  0  1  0  0
#> SRR945210     4       0          1  0  0  0  1
#> SRR945211     4       0          1  0  0  0  1
#> SRR945218     2       0          1  0  1  0  0
#> SRR945219     2       0          1  0  1  0  0
#> SRR945216     2       0          1  0  1  0  0
#> SRR945217     2       0          1  0  1  0  0
#> SRR945220     2       0          1  0  1  0  0
#> SRR945221     2       0          1  0  1  0  0
#> SRR945222     2       0          1  0  1  0  0
#> SRR945223     2       0          1  0  1  0  0
#> SRR945224     2       0          1  0  1  0  0
#> SRR945225     2       0          1  0  1  0  0
#> SRR945226     2       0          1  0  1  0  0
#> SRR945227     2       0          1  0  1  0  0
#> SRR945228     2       0          1  0  1  0  0
#> SRR945229     2       0          1  0  1  0  0
#> SRR945230     2       0          1  0  1  0  0
#> SRR945231     2       0          1  0  1  0  0
#> SRR945232     2       0          1  0  1  0  0
#> SRR945233     2       0          1  0  1  0  0
#> SRR945234     2       0          1  0  1  0  0
#> SRR945235     2       0          1  0  1  0  0
#> SRR945236     2       0          1  0  1  0  0
#> SRR945237     2       0          1  0  1  0  0
#> SRR945238     3       0          1  0  0  1  0
#> SRR945239     3       0          1  0  0  1  0
#> SRR945240     3       0          1  0  0  1  0
#> SRR945241     3       0          1  0  0  1  0
#> SRR945242     3       0          1  0  0  1  0
#> SRR945243     3       0          1  0  0  1  0
#> SRR945244     3       0          1  0  0  1  0
#> SRR945245     3       0          1  0  0  1  0
#> SRR945246     3       0          1  0  0  1  0
#> SRR945247     3       0          1  0  0  1  0
#> SRR945248     3       0          1  0  0  1  0
#> SRR945249     3       0          1  0  0  1  0

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette p1 p2 p3 p4 p5
#> SRR945190     1       0          1  1  0  0  0  0
#> SRR945191     1       0          1  1  0  0  0  0
#> SRR945192     1       0          1  1  0  0  0  0
#> SRR945193     1       0          1  1  0  0  0  0
#> SRR945194     1       0          1  1  0  0  0  0
#> SRR945195     1       0          1  1  0  0  0  0
#> SRR945196     1       0          1  1  0  0  0  0
#> SRR945197     1       0          1  1  0  0  0  0
#> SRR945200     1       0          1  1  0  0  0  0
#> SRR945201     1       0          1  1  0  0  0  0
#> SRR945202     4       0          1  0  0  0  1  0
#> SRR945203     4       0          1  0  0  0  1  0
#> SRR945204     4       0          1  0  0  0  1  0
#> SRR945205     4       0          1  0  0  0  1  0
#> SRR945198     1       0          1  1  0  0  0  0
#> SRR945199     1       0          1  1  0  0  0  0
#> SRR945206     4       0          1  0  0  0  1  0
#> SRR945207     4       0          1  0  0  0  1  0
#> SRR945208     4       0          1  0  0  0  1  0
#> SRR945209     4       0          1  0  0  0  1  0
#> SRR945212     4       0          1  0  0  0  1  0
#> SRR945213     4       0          1  0  0  0  1  0
#> SRR945214     2       0          1  0  1  0  0  0
#> SRR945215     2       0          1  0  1  0  0  0
#> SRR945210     5       0          1  0  0  0  0  1
#> SRR945211     5       0          1  0  0  0  0  1
#> SRR945218     2       0          1  0  1  0  0  0
#> SRR945219     2       0          1  0  1  0  0  0
#> SRR945216     2       0          1  0  1  0  0  0
#> SRR945217     2       0          1  0  1  0  0  0
#> SRR945220     2       0          1  0  1  0  0  0
#> SRR945221     2       0          1  0  1  0  0  0
#> SRR945222     2       0          1  0  1  0  0  0
#> SRR945223     2       0          1  0  1  0  0  0
#> SRR945224     2       0          1  0  1  0  0  0
#> SRR945225     2       0          1  0  1  0  0  0
#> SRR945226     2       0          1  0  1  0  0  0
#> SRR945227     2       0          1  0  1  0  0  0
#> SRR945228     2       0          1  0  1  0  0  0
#> SRR945229     2       0          1  0  1  0  0  0
#> SRR945230     2       0          1  0  1  0  0  0
#> SRR945231     2       0          1  0  1  0  0  0
#> SRR945232     2       0          1  0  1  0  0  0
#> SRR945233     2       0          1  0  1  0  0  0
#> SRR945234     2       0          1  0  1  0  0  0
#> SRR945235     2       0          1  0  1  0  0  0
#> SRR945236     2       0          1  0  1  0  0  0
#> SRR945237     2       0          1  0  1  0  0  0
#> SRR945238     3       0          1  0  0  1  0  0
#> SRR945239     3       0          1  0  0  1  0  0
#> SRR945240     3       0          1  0  0  1  0  0
#> SRR945241     3       0          1  0  0  1  0  0
#> SRR945242     3       0          1  0  0  1  0  0
#> SRR945243     3       0          1  0  0  1  0  0
#> SRR945244     3       0          1  0  0  1  0  0
#> SRR945245     3       0          1  0  0  1  0  0
#> SRR945246     3       0          1  0  0  1  0  0
#> SRR945247     3       0          1  0  0  1  0  0
#> SRR945248     3       0          1  0  0  1  0  0
#> SRR945249     3       0          1  0  0  1  0  0

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette p1    p2 p3    p4 p5    p6
#> SRR945190     1  0.0000      1.000  1 0.000  0 0.000  0 0.000
#> SRR945191     1  0.0000      1.000  1 0.000  0 0.000  0 0.000
#> SRR945192     1  0.0000      1.000  1 0.000  0 0.000  0 0.000
#> SRR945193     1  0.0000      1.000  1 0.000  0 0.000  0 0.000
#> SRR945194     1  0.0000      1.000  1 0.000  0 0.000  0 0.000
#> SRR945195     1  0.0000      1.000  1 0.000  0 0.000  0 0.000
#> SRR945196     1  0.0000      1.000  1 0.000  0 0.000  0 0.000
#> SRR945197     1  0.0000      1.000  1 0.000  0 0.000  0 0.000
#> SRR945200     1  0.0000      1.000  1 0.000  0 0.000  0 0.000
#> SRR945201     1  0.0000      1.000  1 0.000  0 0.000  0 0.000
#> SRR945202     4  0.0000      1.000  0 0.000  0 1.000  0 0.000
#> SRR945203     4  0.0000      1.000  0 0.000  0 1.000  0 0.000
#> SRR945204     4  0.0000      1.000  0 0.000  0 1.000  0 0.000
#> SRR945205     4  0.0000      1.000  0 0.000  0 1.000  0 0.000
#> SRR945198     1  0.0000      1.000  1 0.000  0 0.000  0 0.000
#> SRR945199     1  0.0000      1.000  1 0.000  0 0.000  0 0.000
#> SRR945206     6  0.0146      1.000  0 0.000  0 0.004  0 0.996
#> SRR945207     6  0.0146      1.000  0 0.000  0 0.004  0 0.996
#> SRR945208     4  0.0000      1.000  0 0.000  0 1.000  0 0.000
#> SRR945209     4  0.0000      1.000  0 0.000  0 1.000  0 0.000
#> SRR945212     4  0.0000      1.000  0 0.000  0 1.000  0 0.000
#> SRR945213     4  0.0000      1.000  0 0.000  0 1.000  0 0.000
#> SRR945214     2  0.0000      0.998  0 1.000  0 0.000  0 0.000
#> SRR945215     2  0.0000      0.998  0 1.000  0 0.000  0 0.000
#> SRR945210     5  0.0000      1.000  0 0.000  0 0.000  1 0.000
#> SRR945211     5  0.0000      1.000  0 0.000  0 0.000  1 0.000
#> SRR945218     2  0.0000      0.998  0 1.000  0 0.000  0 0.000
#> SRR945219     2  0.0000      0.998  0 1.000  0 0.000  0 0.000
#> SRR945216     2  0.0000      0.998  0 1.000  0 0.000  0 0.000
#> SRR945217     2  0.0000      0.998  0 1.000  0 0.000  0 0.000
#> SRR945220     2  0.0000      0.998  0 1.000  0 0.000  0 0.000
#> SRR945221     2  0.0000      0.998  0 1.000  0 0.000  0 0.000
#> SRR945222     2  0.0000      0.998  0 1.000  0 0.000  0 0.000
#> SRR945223     2  0.0000      0.998  0 1.000  0 0.000  0 0.000
#> SRR945224     2  0.0000      0.998  0 1.000  0 0.000  0 0.000
#> SRR945225     2  0.0000      0.998  0 1.000  0 0.000  0 0.000
#> SRR945226     2  0.0146      0.997  0 0.996  0 0.000  0 0.004
#> SRR945227     2  0.0146      0.997  0 0.996  0 0.000  0 0.004
#> SRR945228     2  0.0146      0.997  0 0.996  0 0.000  0 0.004
#> SRR945229     2  0.0146      0.997  0 0.996  0 0.000  0 0.004
#> SRR945230     2  0.0146      0.997  0 0.996  0 0.000  0 0.004
#> SRR945231     2  0.0146      0.997  0 0.996  0 0.000  0 0.004
#> SRR945232     2  0.0000      0.998  0 1.000  0 0.000  0 0.000
#> SRR945233     2  0.0000      0.998  0 1.000  0 0.000  0 0.000
#> SRR945234     2  0.0000      0.998  0 1.000  0 0.000  0 0.000
#> SRR945235     2  0.0146      0.997  0 0.996  0 0.000  0 0.004
#> SRR945236     2  0.0146      0.997  0 0.996  0 0.000  0 0.004
#> SRR945237     2  0.0146      0.997  0 0.996  0 0.000  0 0.004
#> SRR945238     3  0.0000      1.000  0 0.000  1 0.000  0 0.000
#> SRR945239     3  0.0000      1.000  0 0.000  1 0.000  0 0.000
#> SRR945240     3  0.0000      1.000  0 0.000  1 0.000  0 0.000
#> SRR945241     3  0.0000      1.000  0 0.000  1 0.000  0 0.000
#> SRR945242     3  0.0000      1.000  0 0.000  1 0.000  0 0.000
#> SRR945243     3  0.0000      1.000  0 0.000  1 0.000  0 0.000
#> SRR945244     3  0.0000      1.000  0 0.000  1 0.000  0 0.000
#> SRR945245     3  0.0000      1.000  0 0.000  1 0.000  0 0.000
#> SRR945246     3  0.0000      1.000  0 0.000  1 0.000  0 0.000
#> SRR945247     3  0.0000      1.000  0 0.000  1 0.000  0 0.000
#> SRR945248     3  0.0000      1.000  0 0.000  1 0.000  0 0.000
#> SRR945249     3  0.0000      1.000  0 0.000  1 0.000  0 0.000

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

consensus_heatmap(res, k = 2)

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

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

collect_plots(res)

plot of chunk SD-mclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.978       0.982        0.48873 0.512   0.512
#> 3 3 1.000           0.997       0.999        0.32797 0.785   0.602
#> 4 4 0.959           0.940       0.975        0.13722 0.910   0.743
#> 5 5 0.985           0.978       0.985        0.04261 0.966   0.870
#> 6 6 0.988           0.972       0.983        0.00812 0.995   0.980

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
#> SRR945190     1   0.000      0.980 1.000 0.000
#> SRR945191     1   0.000      0.980 1.000 0.000
#> SRR945192     1   0.000      0.980 1.000 0.000
#> SRR945193     1   0.000      0.980 1.000 0.000
#> SRR945194     1   0.000      0.980 1.000 0.000
#> SRR945195     1   0.000      0.980 1.000 0.000
#> SRR945196     1   0.000      0.980 1.000 0.000
#> SRR945197     1   0.000      0.980 1.000 0.000
#> SRR945200     1   0.000      0.980 1.000 0.000
#> SRR945201     1   0.000      0.980 1.000 0.000
#> SRR945202     1   0.224      0.980 0.964 0.036
#> SRR945203     1   0.224      0.980 0.964 0.036
#> SRR945204     1   0.224      0.980 0.964 0.036
#> SRR945205     1   0.224      0.980 0.964 0.036
#> SRR945198     1   0.000      0.980 1.000 0.000
#> SRR945199     1   0.000      0.980 1.000 0.000
#> SRR945206     1   0.224      0.980 0.964 0.036
#> SRR945207     1   0.224      0.980 0.964 0.036
#> SRR945208     1   0.224      0.980 0.964 0.036
#> SRR945209     1   0.224      0.980 0.964 0.036
#> SRR945212     1   0.224      0.980 0.964 0.036
#> SRR945213     1   0.224      0.980 0.964 0.036
#> SRR945214     2   0.000      0.982 0.000 1.000
#> SRR945215     2   0.000      0.982 0.000 1.000
#> SRR945210     1   0.224      0.980 0.964 0.036
#> SRR945211     1   0.224      0.980 0.964 0.036
#> SRR945218     2   0.000      0.982 0.000 1.000
#> SRR945219     2   0.000      0.982 0.000 1.000
#> SRR945216     2   0.000      0.982 0.000 1.000
#> SRR945217     2   0.000      0.982 0.000 1.000
#> SRR945220     2   0.000      0.982 0.000 1.000
#> SRR945221     2   0.000      0.982 0.000 1.000
#> SRR945222     2   0.000      0.982 0.000 1.000
#> SRR945223     2   0.000      0.982 0.000 1.000
#> SRR945224     2   0.000      0.982 0.000 1.000
#> SRR945225     2   0.000      0.982 0.000 1.000
#> SRR945226     2   0.000      0.982 0.000 1.000
#> SRR945227     2   0.000      0.982 0.000 1.000
#> SRR945228     2   0.000      0.982 0.000 1.000
#> SRR945229     2   0.000      0.982 0.000 1.000
#> SRR945230     2   0.000      0.982 0.000 1.000
#> SRR945231     2   0.000      0.982 0.000 1.000
#> SRR945232     2   0.000      0.982 0.000 1.000
#> SRR945233     2   0.000      0.982 0.000 1.000
#> SRR945234     2   0.000      0.982 0.000 1.000
#> SRR945235     2   0.000      0.982 0.000 1.000
#> SRR945236     2   0.000      0.982 0.000 1.000
#> SRR945237     2   0.000      0.982 0.000 1.000
#> SRR945238     2   0.311      0.963 0.056 0.944
#> SRR945239     2   0.311      0.963 0.056 0.944
#> SRR945240     2   0.311      0.963 0.056 0.944
#> SRR945241     2   0.311      0.963 0.056 0.944
#> SRR945242     2   0.311      0.963 0.056 0.944
#> SRR945243     2   0.311      0.963 0.056 0.944
#> SRR945244     2   0.311      0.963 0.056 0.944
#> SRR945245     2   0.311      0.963 0.056 0.944
#> SRR945246     2   0.311      0.963 0.056 0.944
#> SRR945247     2   0.311      0.963 0.056 0.944
#> SRR945248     2   0.311      0.963 0.056 0.944
#> SRR945249     2   0.311      0.963 0.056 0.944

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2 p3
#> SRR945190     1   0.000      0.997 1.000 0.000  0
#> SRR945191     1   0.000      0.997 1.000 0.000  0
#> SRR945192     1   0.000      0.997 1.000 0.000  0
#> SRR945193     1   0.000      0.997 1.000 0.000  0
#> SRR945194     1   0.000      0.997 1.000 0.000  0
#> SRR945195     1   0.000      0.997 1.000 0.000  0
#> SRR945196     1   0.000      0.997 1.000 0.000  0
#> SRR945197     1   0.000      0.997 1.000 0.000  0
#> SRR945200     1   0.000      0.997 1.000 0.000  0
#> SRR945201     1   0.000      0.997 1.000 0.000  0
#> SRR945202     1   0.000      0.997 1.000 0.000  0
#> SRR945203     1   0.000      0.997 1.000 0.000  0
#> SRR945204     1   0.000      0.997 1.000 0.000  0
#> SRR945205     1   0.000      0.997 1.000 0.000  0
#> SRR945198     1   0.000      0.997 1.000 0.000  0
#> SRR945199     1   0.000      0.997 1.000 0.000  0
#> SRR945206     1   0.000      0.997 1.000 0.000  0
#> SRR945207     1   0.000      0.997 1.000 0.000  0
#> SRR945208     1   0.000      0.997 1.000 0.000  0
#> SRR945209     1   0.000      0.997 1.000 0.000  0
#> SRR945212     1   0.000      0.997 1.000 0.000  0
#> SRR945213     1   0.000      0.997 1.000 0.000  0
#> SRR945214     2   0.000      1.000 0.000 1.000  0
#> SRR945215     2   0.000      1.000 0.000 1.000  0
#> SRR945210     1   0.000      0.997 1.000 0.000  0
#> SRR945211     1   0.000      0.997 1.000 0.000  0
#> SRR945218     2   0.000      1.000 0.000 1.000  0
#> SRR945219     2   0.000      1.000 0.000 1.000  0
#> SRR945216     2   0.000      1.000 0.000 1.000  0
#> SRR945217     2   0.000      1.000 0.000 1.000  0
#> SRR945220     2   0.000      1.000 0.000 1.000  0
#> SRR945221     2   0.000      1.000 0.000 1.000  0
#> SRR945222     2   0.000      1.000 0.000 1.000  0
#> SRR945223     2   0.000      1.000 0.000 1.000  0
#> SRR945224     2   0.000      1.000 0.000 1.000  0
#> SRR945225     2   0.000      1.000 0.000 1.000  0
#> SRR945226     2   0.000      1.000 0.000 1.000  0
#> SRR945227     2   0.000      1.000 0.000 1.000  0
#> SRR945228     2   0.000      1.000 0.000 1.000  0
#> SRR945229     2   0.000      1.000 0.000 1.000  0
#> SRR945230     1   0.141      0.960 0.964 0.036  0
#> SRR945231     1   0.141      0.960 0.964 0.036  0
#> SRR945232     2   0.000      1.000 0.000 1.000  0
#> SRR945233     2   0.000      1.000 0.000 1.000  0
#> SRR945234     2   0.000      1.000 0.000 1.000  0
#> SRR945235     2   0.000      1.000 0.000 1.000  0
#> SRR945236     2   0.000      1.000 0.000 1.000  0
#> SRR945237     2   0.000      1.000 0.000 1.000  0
#> SRR945238     3   0.000      1.000 0.000 0.000  1
#> SRR945239     3   0.000      1.000 0.000 0.000  1
#> SRR945240     3   0.000      1.000 0.000 0.000  1
#> SRR945241     3   0.000      1.000 0.000 0.000  1
#> SRR945242     3   0.000      1.000 0.000 0.000  1
#> SRR945243     3   0.000      1.000 0.000 0.000  1
#> SRR945244     3   0.000      1.000 0.000 0.000  1
#> SRR945245     3   0.000      1.000 0.000 0.000  1
#> SRR945246     3   0.000      1.000 0.000 0.000  1
#> SRR945247     3   0.000      1.000 0.000 0.000  1
#> SRR945248     3   0.000      1.000 0.000 0.000  1
#> SRR945249     3   0.000      1.000 0.000 0.000  1

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2 p3    p4
#> SRR945190     1   0.000      1.000 1.000 0.000  0 0.000
#> SRR945191     1   0.000      1.000 1.000 0.000  0 0.000
#> SRR945192     1   0.000      1.000 1.000 0.000  0 0.000
#> SRR945193     1   0.000      1.000 1.000 0.000  0 0.000
#> SRR945194     4   0.497      0.253 0.452 0.000  0 0.548
#> SRR945195     4   0.497      0.253 0.452 0.000  0 0.548
#> SRR945196     1   0.000      1.000 1.000 0.000  0 0.000
#> SRR945197     1   0.000      1.000 1.000 0.000  0 0.000
#> SRR945200     1   0.000      1.000 1.000 0.000  0 0.000
#> SRR945201     1   0.000      1.000 1.000 0.000  0 0.000
#> SRR945202     4   0.000      0.890 0.000 0.000  0 1.000
#> SRR945203     4   0.000      0.890 0.000 0.000  0 1.000
#> SRR945204     4   0.000      0.890 0.000 0.000  0 1.000
#> SRR945205     4   0.000      0.890 0.000 0.000  0 1.000
#> SRR945198     1   0.000      1.000 1.000 0.000  0 0.000
#> SRR945199     1   0.000      1.000 1.000 0.000  0 0.000
#> SRR945206     4   0.000      0.890 0.000 0.000  0 1.000
#> SRR945207     4   0.000      0.890 0.000 0.000  0 1.000
#> SRR945208     4   0.000      0.890 0.000 0.000  0 1.000
#> SRR945209     4   0.000      0.890 0.000 0.000  0 1.000
#> SRR945212     4   0.000      0.890 0.000 0.000  0 1.000
#> SRR945213     4   0.000      0.890 0.000 0.000  0 1.000
#> SRR945214     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR945215     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR945210     4   0.000      0.890 0.000 0.000  0 1.000
#> SRR945211     4   0.000      0.890 0.000 0.000  0 1.000
#> SRR945218     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR945219     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR945216     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR945217     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR945220     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR945221     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR945222     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR945223     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR945224     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR945225     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR945226     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR945227     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR945228     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR945229     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR945230     4   0.433      0.612 0.000 0.288  0 0.712
#> SRR945231     4   0.433      0.612 0.000 0.288  0 0.712
#> SRR945232     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR945233     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR945234     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR945235     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR945236     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR945237     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR945238     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR945239     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR945240     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR945241     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR945242     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR945243     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR945244     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR945245     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR945246     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR945247     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR945248     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR945249     3   0.000      1.000 0.000 0.000  1 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2 p3    p4    p5
#> SRR945190     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> SRR945191     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> SRR945192     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> SRR945193     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> SRR945194     5  0.3395      0.746 0.236 0.000  0 0.000 0.764
#> SRR945195     5  0.3395      0.746 0.236 0.000  0 0.000 0.764
#> SRR945196     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> SRR945197     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> SRR945200     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> SRR945201     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> SRR945202     4  0.0162      0.994 0.000 0.000  0 0.996 0.004
#> SRR945203     4  0.0162      0.994 0.000 0.000  0 0.996 0.004
#> SRR945204     4  0.0000      0.995 0.000 0.000  0 1.000 0.000
#> SRR945205     4  0.0000      0.995 0.000 0.000  0 1.000 0.000
#> SRR945198     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> SRR945199     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> SRR945206     4  0.0609      0.984 0.000 0.000  0 0.980 0.020
#> SRR945207     4  0.0609      0.984 0.000 0.000  0 0.980 0.020
#> SRR945208     4  0.0000      0.995 0.000 0.000  0 1.000 0.000
#> SRR945209     4  0.0000      0.995 0.000 0.000  0 1.000 0.000
#> SRR945212     4  0.0000      0.995 0.000 0.000  0 1.000 0.000
#> SRR945213     4  0.0000      0.995 0.000 0.000  0 1.000 0.000
#> SRR945214     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR945215     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR945210     5  0.2648      0.799 0.000 0.000  0 0.152 0.848
#> SRR945211     5  0.2648      0.799 0.000 0.000  0 0.152 0.848
#> SRR945218     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR945219     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR945216     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR945217     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR945220     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR945221     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR945222     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR945223     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR945224     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR945225     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR945226     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR945227     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR945228     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR945229     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR945230     5  0.0963      0.832 0.000 0.036  0 0.000 0.964
#> SRR945231     5  0.0963      0.832 0.000 0.036  0 0.000 0.964
#> SRR945232     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR945233     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR945234     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR945235     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR945236     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR945237     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR945238     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR945239     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR945240     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR945241     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR945242     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR945243     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR945244     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR945245     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR945246     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR945247     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR945248     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR945249     3  0.0000      1.000 0.000 0.000  1 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
#> SRR945190     1  0.0000      1.000 1.0 0.000  0 0.000 0.000 0.000
#> SRR945191     1  0.0000      1.000 1.0 0.000  0 0.000 0.000 0.000
#> SRR945192     1  0.0000      1.000 1.0 0.000  0 0.000 0.000 0.000
#> SRR945193     1  0.0000      1.000 1.0 0.000  0 0.000 0.000 0.000
#> SRR945194     5  0.3679      0.651 0.2 0.000  0 0.000 0.760 0.040
#> SRR945195     5  0.3679      0.651 0.2 0.000  0 0.000 0.760 0.040
#> SRR945196     1  0.0000      1.000 1.0 0.000  0 0.000 0.000 0.000
#> SRR945197     1  0.0000      1.000 1.0 0.000  0 0.000 0.000 0.000
#> SRR945200     1  0.0000      1.000 1.0 0.000  0 0.000 0.000 0.000
#> SRR945201     1  0.0000      1.000 1.0 0.000  0 0.000 0.000 0.000
#> SRR945202     4  0.0260      0.987 0.0 0.000  0 0.992 0.008 0.000
#> SRR945203     4  0.0260      0.987 0.0 0.000  0 0.992 0.008 0.000
#> SRR945204     4  0.0000      0.990 0.0 0.000  0 1.000 0.000 0.000
#> SRR945205     4  0.0000      0.990 0.0 0.000  0 1.000 0.000 0.000
#> SRR945198     1  0.0000      1.000 1.0 0.000  0 0.000 0.000 0.000
#> SRR945199     1  0.0000      1.000 1.0 0.000  0 0.000 0.000 0.000
#> SRR945206     4  0.0937      0.967 0.0 0.000  0 0.960 0.040 0.000
#> SRR945207     4  0.0937      0.967 0.0 0.000  0 0.960 0.040 0.000
#> SRR945208     4  0.0000      0.990 0.0 0.000  0 1.000 0.000 0.000
#> SRR945209     4  0.0000      0.990 0.0 0.000  0 1.000 0.000 0.000
#> SRR945212     4  0.0000      0.990 0.0 0.000  0 1.000 0.000 0.000
#> SRR945213     4  0.0000      0.990 0.0 0.000  0 1.000 0.000 0.000
#> SRR945214     2  0.0000      1.000 0.0 1.000  0 0.000 0.000 0.000
#> SRR945215     2  0.0000      1.000 0.0 1.000  0 0.000 0.000 0.000
#> SRR945210     5  0.2762      0.594 0.0 0.000  0 0.000 0.804 0.196
#> SRR945211     5  0.2762      0.594 0.0 0.000  0 0.000 0.804 0.196
#> SRR945218     2  0.0000      1.000 0.0 1.000  0 0.000 0.000 0.000
#> SRR945219     2  0.0000      1.000 0.0 1.000  0 0.000 0.000 0.000
#> SRR945216     2  0.0000      1.000 0.0 1.000  0 0.000 0.000 0.000
#> SRR945217     2  0.0000      1.000 0.0 1.000  0 0.000 0.000 0.000
#> SRR945220     2  0.0000      1.000 0.0 1.000  0 0.000 0.000 0.000
#> SRR945221     2  0.0000      1.000 0.0 1.000  0 0.000 0.000 0.000
#> SRR945222     2  0.0000      1.000 0.0 1.000  0 0.000 0.000 0.000
#> SRR945223     2  0.0000      1.000 0.0 1.000  0 0.000 0.000 0.000
#> SRR945224     2  0.0000      1.000 0.0 1.000  0 0.000 0.000 0.000
#> SRR945225     2  0.0000      1.000 0.0 1.000  0 0.000 0.000 0.000
#> SRR945226     2  0.0000      1.000 0.0 1.000  0 0.000 0.000 0.000
#> SRR945227     2  0.0000      1.000 0.0 1.000  0 0.000 0.000 0.000
#> SRR945228     2  0.0000      1.000 0.0 1.000  0 0.000 0.000 0.000
#> SRR945229     2  0.0000      1.000 0.0 1.000  0 0.000 0.000 0.000
#> SRR945230     6  0.0458      1.000 0.0 0.016  0 0.000 0.000 0.984
#> SRR945231     6  0.0458      1.000 0.0 0.016  0 0.000 0.000 0.984
#> SRR945232     2  0.0000      1.000 0.0 1.000  0 0.000 0.000 0.000
#> SRR945233     2  0.0000      1.000 0.0 1.000  0 0.000 0.000 0.000
#> SRR945234     2  0.0000      1.000 0.0 1.000  0 0.000 0.000 0.000
#> SRR945235     2  0.0000      1.000 0.0 1.000  0 0.000 0.000 0.000
#> SRR945236     2  0.0000      1.000 0.0 1.000  0 0.000 0.000 0.000
#> SRR945237     2  0.0000      1.000 0.0 1.000  0 0.000 0.000 0.000
#> SRR945238     3  0.0000      1.000 0.0 0.000  1 0.000 0.000 0.000
#> SRR945239     3  0.0000      1.000 0.0 0.000  1 0.000 0.000 0.000
#> SRR945240     3  0.0000      1.000 0.0 0.000  1 0.000 0.000 0.000
#> SRR945241     3  0.0000      1.000 0.0 0.000  1 0.000 0.000 0.000
#> SRR945242     3  0.0000      1.000 0.0 0.000  1 0.000 0.000 0.000
#> SRR945243     3  0.0000      1.000 0.0 0.000  1 0.000 0.000 0.000
#> SRR945244     3  0.0000      1.000 0.0 0.000  1 0.000 0.000 0.000
#> SRR945245     3  0.0000      1.000 0.0 0.000  1 0.000 0.000 0.000
#> SRR945246     3  0.0000      1.000 0.0 0.000  1 0.000 0.000 0.000
#> SRR945247     3  0.0000      1.000 0.0 0.000  1 0.000 0.000 0.000
#> SRR945248     3  0.0000      1.000 0.0 0.000  1 0.000 0.000 0.000
#> SRR945249     3  0.0000      1.000 0.0 0.000  1 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-mclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-mclust-collect-classes

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


SD:NMF**

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

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

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

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

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

collect_plots(res)

plot of chunk SD-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.973       0.989         0.4833 0.512   0.512
#> 3 3 0.729           0.808       0.786         0.2793 0.785   0.602
#> 4 4 1.000           1.000       1.000         0.1846 0.894   0.707
#> 5 5 1.000           0.995       0.995         0.0159 0.989   0.958
#> 6 6 0.947           0.938       0.945         0.0361 0.991   0.965

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
#> SRR945190     1   0.000      0.970 1.000 0.000
#> SRR945191     1   0.000      0.970 1.000 0.000
#> SRR945192     1   0.000      0.970 1.000 0.000
#> SRR945193     1   0.000      0.970 1.000 0.000
#> SRR945194     1   0.000      0.970 1.000 0.000
#> SRR945195     1   0.000      0.970 1.000 0.000
#> SRR945196     1   0.000      0.970 1.000 0.000
#> SRR945197     1   0.000      0.970 1.000 0.000
#> SRR945200     1   0.000      0.970 1.000 0.000
#> SRR945201     1   0.000      0.970 1.000 0.000
#> SRR945202     1   0.000      0.970 1.000 0.000
#> SRR945203     1   0.000      0.970 1.000 0.000
#> SRR945204     1   0.000      0.970 1.000 0.000
#> SRR945205     1   0.000      0.970 1.000 0.000
#> SRR945198     1   0.000      0.970 1.000 0.000
#> SRR945199     1   0.000      0.970 1.000 0.000
#> SRR945206     1   0.000      0.970 1.000 0.000
#> SRR945207     1   0.000      0.970 1.000 0.000
#> SRR945208     1   0.000      0.970 1.000 0.000
#> SRR945209     1   0.000      0.970 1.000 0.000
#> SRR945212     1   0.000      0.970 1.000 0.000
#> SRR945213     1   0.000      0.970 1.000 0.000
#> SRR945214     2   0.000      1.000 0.000 1.000
#> SRR945215     2   0.000      1.000 0.000 1.000
#> SRR945210     1   0.917      0.524 0.668 0.332
#> SRR945211     1   0.929      0.498 0.656 0.344
#> SRR945218     2   0.000      1.000 0.000 1.000
#> SRR945219     2   0.000      1.000 0.000 1.000
#> SRR945216     2   0.000      1.000 0.000 1.000
#> SRR945217     2   0.000      1.000 0.000 1.000
#> SRR945220     2   0.000      1.000 0.000 1.000
#> SRR945221     2   0.000      1.000 0.000 1.000
#> SRR945222     2   0.000      1.000 0.000 1.000
#> SRR945223     2   0.000      1.000 0.000 1.000
#> SRR945224     2   0.000      1.000 0.000 1.000
#> SRR945225     2   0.000      1.000 0.000 1.000
#> SRR945226     2   0.000      1.000 0.000 1.000
#> SRR945227     2   0.000      1.000 0.000 1.000
#> SRR945228     2   0.000      1.000 0.000 1.000
#> SRR945229     2   0.000      1.000 0.000 1.000
#> SRR945230     2   0.000      1.000 0.000 1.000
#> SRR945231     2   0.000      1.000 0.000 1.000
#> SRR945232     2   0.000      1.000 0.000 1.000
#> SRR945233     2   0.000      1.000 0.000 1.000
#> SRR945234     2   0.000      1.000 0.000 1.000
#> SRR945235     2   0.000      1.000 0.000 1.000
#> SRR945236     2   0.000      1.000 0.000 1.000
#> SRR945237     2   0.000      1.000 0.000 1.000
#> SRR945238     2   0.000      1.000 0.000 1.000
#> SRR945239     2   0.000      1.000 0.000 1.000
#> SRR945240     2   0.000      1.000 0.000 1.000
#> SRR945241     2   0.000      1.000 0.000 1.000
#> SRR945242     2   0.000      1.000 0.000 1.000
#> SRR945243     2   0.000      1.000 0.000 1.000
#> SRR945244     2   0.000      1.000 0.000 1.000
#> SRR945245     2   0.000      1.000 0.000 1.000
#> SRR945246     2   0.000      1.000 0.000 1.000
#> SRR945247     2   0.000      1.000 0.000 1.000
#> SRR945248     2   0.000      1.000 0.000 1.000
#> SRR945249     2   0.000      1.000 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> SRR945190     1   0.000      0.812 1.000 0.000 0.000
#> SRR945191     1   0.000      0.812 1.000 0.000 0.000
#> SRR945192     1   0.000      0.812 1.000 0.000 0.000
#> SRR945193     1   0.000      0.812 1.000 0.000 0.000
#> SRR945194     1   0.000      0.812 1.000 0.000 0.000
#> SRR945195     1   0.000      0.812 1.000 0.000 0.000
#> SRR945196     1   0.000      0.812 1.000 0.000 0.000
#> SRR945197     1   0.000      0.812 1.000 0.000 0.000
#> SRR945200     1   0.000      0.812 1.000 0.000 0.000
#> SRR945201     1   0.000      0.812 1.000 0.000 0.000
#> SRR945202     1   0.624      0.765 0.560 0.440 0.000
#> SRR945203     1   0.624      0.765 0.560 0.440 0.000
#> SRR945204     1   0.624      0.765 0.560 0.440 0.000
#> SRR945205     1   0.624      0.765 0.560 0.440 0.000
#> SRR945198     1   0.000      0.812 1.000 0.000 0.000
#> SRR945199     1   0.000      0.812 1.000 0.000 0.000
#> SRR945206     1   0.879      0.675 0.448 0.440 0.112
#> SRR945207     1   0.879      0.675 0.448 0.440 0.112
#> SRR945208     1   0.624      0.765 0.560 0.440 0.000
#> SRR945209     1   0.624      0.765 0.560 0.440 0.000
#> SRR945212     1   0.624      0.765 0.560 0.440 0.000
#> SRR945213     1   0.624      0.765 0.560 0.440 0.000
#> SRR945214     2   0.624      0.860 0.000 0.560 0.440
#> SRR945215     2   0.624      0.860 0.000 0.560 0.440
#> SRR945210     2   0.935     -0.683 0.384 0.448 0.168
#> SRR945211     2   0.954     -0.663 0.360 0.444 0.196
#> SRR945218     2   0.624      0.860 0.000 0.560 0.440
#> SRR945219     2   0.624      0.860 0.000 0.560 0.440
#> SRR945216     2   0.624      0.860 0.000 0.560 0.440
#> SRR945217     2   0.624      0.860 0.000 0.560 0.440
#> SRR945220     2   0.624      0.860 0.000 0.560 0.440
#> SRR945221     2   0.624      0.860 0.000 0.560 0.440
#> SRR945222     2   0.624      0.860 0.000 0.560 0.440
#> SRR945223     2   0.624      0.860 0.000 0.560 0.440
#> SRR945224     2   0.624      0.860 0.000 0.560 0.440
#> SRR945225     2   0.624      0.860 0.000 0.560 0.440
#> SRR945226     2   0.624      0.860 0.000 0.560 0.440
#> SRR945227     2   0.624      0.860 0.000 0.560 0.440
#> SRR945228     2   0.624      0.860 0.000 0.560 0.440
#> SRR945229     2   0.624      0.860 0.000 0.560 0.440
#> SRR945230     2   0.624      0.860 0.000 0.560 0.440
#> SRR945231     2   0.624      0.860 0.000 0.560 0.440
#> SRR945232     2   0.624      0.860 0.000 0.560 0.440
#> SRR945233     2   0.624      0.860 0.000 0.560 0.440
#> SRR945234     2   0.624      0.860 0.000 0.560 0.440
#> SRR945235     2   0.624      0.860 0.000 0.560 0.440
#> SRR945236     2   0.624      0.860 0.000 0.560 0.440
#> SRR945237     2   0.624      0.860 0.000 0.560 0.440
#> SRR945238     3   0.000      1.000 0.000 0.000 1.000
#> SRR945239     3   0.000      1.000 0.000 0.000 1.000
#> SRR945240     3   0.000      1.000 0.000 0.000 1.000
#> SRR945241     3   0.000      1.000 0.000 0.000 1.000
#> SRR945242     3   0.000      1.000 0.000 0.000 1.000
#> SRR945243     3   0.000      1.000 0.000 0.000 1.000
#> SRR945244     3   0.000      1.000 0.000 0.000 1.000
#> SRR945245     3   0.000      1.000 0.000 0.000 1.000
#> SRR945246     3   0.000      1.000 0.000 0.000 1.000
#> SRR945247     3   0.000      1.000 0.000 0.000 1.000
#> SRR945248     3   0.000      1.000 0.000 0.000 1.000
#> SRR945249     3   0.000      1.000 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
#> SRR945190     1       0          1  1  0  0  0
#> SRR945191     1       0          1  1  0  0  0
#> SRR945192     1       0          1  1  0  0  0
#> SRR945193     1       0          1  1  0  0  0
#> SRR945194     1       0          1  1  0  0  0
#> SRR945195     1       0          1  1  0  0  0
#> SRR945196     1       0          1  1  0  0  0
#> SRR945197     1       0          1  1  0  0  0
#> SRR945200     1       0          1  1  0  0  0
#> SRR945201     1       0          1  1  0  0  0
#> SRR945202     4       0          1  0  0  0  1
#> SRR945203     4       0          1  0  0  0  1
#> SRR945204     4       0          1  0  0  0  1
#> SRR945205     4       0          1  0  0  0  1
#> SRR945198     1       0          1  1  0  0  0
#> SRR945199     1       0          1  1  0  0  0
#> SRR945206     4       0          1  0  0  0  1
#> SRR945207     4       0          1  0  0  0  1
#> SRR945208     4       0          1  0  0  0  1
#> SRR945209     4       0          1  0  0  0  1
#> SRR945212     4       0          1  0  0  0  1
#> SRR945213     4       0          1  0  0  0  1
#> SRR945214     2       0          1  0  1  0  0
#> SRR945215     2       0          1  0  1  0  0
#> SRR945210     4       0          1  0  0  0  1
#> SRR945211     4       0          1  0  0  0  1
#> SRR945218     2       0          1  0  1  0  0
#> SRR945219     2       0          1  0  1  0  0
#> SRR945216     2       0          1  0  1  0  0
#> SRR945217     2       0          1  0  1  0  0
#> SRR945220     2       0          1  0  1  0  0
#> SRR945221     2       0          1  0  1  0  0
#> SRR945222     2       0          1  0  1  0  0
#> SRR945223     2       0          1  0  1  0  0
#> SRR945224     2       0          1  0  1  0  0
#> SRR945225     2       0          1  0  1  0  0
#> SRR945226     2       0          1  0  1  0  0
#> SRR945227     2       0          1  0  1  0  0
#> SRR945228     2       0          1  0  1  0  0
#> SRR945229     2       0          1  0  1  0  0
#> SRR945230     2       0          1  0  1  0  0
#> SRR945231     2       0          1  0  1  0  0
#> SRR945232     2       0          1  0  1  0  0
#> SRR945233     2       0          1  0  1  0  0
#> SRR945234     2       0          1  0  1  0  0
#> SRR945235     2       0          1  0  1  0  0
#> SRR945236     2       0          1  0  1  0  0
#> SRR945237     2       0          1  0  1  0  0
#> SRR945238     3       0          1  0  0  1  0
#> SRR945239     3       0          1  0  0  1  0
#> SRR945240     3       0          1  0  0  1  0
#> SRR945241     3       0          1  0  0  1  0
#> SRR945242     3       0          1  0  0  1  0
#> SRR945243     3       0          1  0  0  1  0
#> SRR945244     3       0          1  0  0  1  0
#> SRR945245     3       0          1  0  0  1  0
#> SRR945246     3       0          1  0  0  1  0
#> SRR945247     3       0          1  0  0  1  0
#> SRR945248     3       0          1  0  0  1  0
#> SRR945249     3       0          1  0  0  1  0

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette p1    p2    p3    p4    p5
#> SRR945190     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR945191     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR945192     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR945193     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR945194     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR945195     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR945196     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR945197     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR945200     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR945201     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR945202     4  0.0000      0.988  0 0.000 0.000 1.000 0.000
#> SRR945203     4  0.0000      0.988  0 0.000 0.000 1.000 0.000
#> SRR945204     4  0.0000      0.988  0 0.000 0.000 1.000 0.000
#> SRR945205     4  0.0000      0.988  0 0.000 0.000 1.000 0.000
#> SRR945198     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR945199     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR945206     4  0.1270      0.950  0 0.000 0.000 0.948 0.052
#> SRR945207     4  0.1270      0.950  0 0.000 0.000 0.948 0.052
#> SRR945208     4  0.0000      0.988  0 0.000 0.000 1.000 0.000
#> SRR945209     4  0.0000      0.988  0 0.000 0.000 1.000 0.000
#> SRR945212     4  0.0000      0.988  0 0.000 0.000 1.000 0.000
#> SRR945213     4  0.0000      0.988  0 0.000 0.000 1.000 0.000
#> SRR945214     2  0.0000      0.997  0 1.000 0.000 0.000 0.000
#> SRR945215     2  0.0000      0.997  0 1.000 0.000 0.000 0.000
#> SRR945210     5  0.1877      1.000  0 0.000 0.012 0.064 0.924
#> SRR945211     5  0.1877      1.000  0 0.000 0.012 0.064 0.924
#> SRR945218     2  0.0000      0.997  0 1.000 0.000 0.000 0.000
#> SRR945219     2  0.0000      0.997  0 1.000 0.000 0.000 0.000
#> SRR945216     2  0.0000      0.997  0 1.000 0.000 0.000 0.000
#> SRR945217     2  0.0000      0.997  0 1.000 0.000 0.000 0.000
#> SRR945220     2  0.0000      0.997  0 1.000 0.000 0.000 0.000
#> SRR945221     2  0.0000      0.997  0 1.000 0.000 0.000 0.000
#> SRR945222     2  0.0000      0.997  0 1.000 0.000 0.000 0.000
#> SRR945223     2  0.0000      0.997  0 1.000 0.000 0.000 0.000
#> SRR945224     2  0.0000      0.997  0 1.000 0.000 0.000 0.000
#> SRR945225     2  0.0000      0.997  0 1.000 0.000 0.000 0.000
#> SRR945226     2  0.0000      0.997  0 1.000 0.000 0.000 0.000
#> SRR945227     2  0.0000      0.997  0 1.000 0.000 0.000 0.000
#> SRR945228     2  0.0404      0.991  0 0.988 0.000 0.000 0.012
#> SRR945229     2  0.0404      0.991  0 0.988 0.000 0.000 0.012
#> SRR945230     2  0.0404      0.991  0 0.988 0.000 0.000 0.012
#> SRR945231     2  0.0404      0.991  0 0.988 0.000 0.000 0.012
#> SRR945232     2  0.0000      0.997  0 1.000 0.000 0.000 0.000
#> SRR945233     2  0.0000      0.997  0 1.000 0.000 0.000 0.000
#> SRR945234     2  0.0000      0.997  0 1.000 0.000 0.000 0.000
#> SRR945235     2  0.0000      0.997  0 1.000 0.000 0.000 0.000
#> SRR945236     2  0.0404      0.991  0 0.988 0.000 0.000 0.012
#> SRR945237     2  0.0404      0.991  0 0.988 0.000 0.000 0.012
#> SRR945238     3  0.0000      1.000  0 0.000 1.000 0.000 0.000
#> SRR945239     3  0.0000      1.000  0 0.000 1.000 0.000 0.000
#> SRR945240     3  0.0000      1.000  0 0.000 1.000 0.000 0.000
#> SRR945241     3  0.0000      1.000  0 0.000 1.000 0.000 0.000
#> SRR945242     3  0.0000      1.000  0 0.000 1.000 0.000 0.000
#> SRR945243     3  0.0000      1.000  0 0.000 1.000 0.000 0.000
#> SRR945244     3  0.0000      1.000  0 0.000 1.000 0.000 0.000
#> SRR945245     3  0.0000      1.000  0 0.000 1.000 0.000 0.000
#> SRR945246     3  0.0000      1.000  0 0.000 1.000 0.000 0.000
#> SRR945247     3  0.0000      1.000  0 0.000 1.000 0.000 0.000
#> SRR945248     3  0.0000      1.000  0 0.000 1.000 0.000 0.000
#> SRR945249     3  0.0000      1.000  0 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
#> SRR945190     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR945191     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR945192     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR945193     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR945194     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR945195     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR945196     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR945197     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR945200     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR945201     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR945202     4  0.0000      0.986  0 0.000 0.000 1.000 0.000 0.000
#> SRR945203     4  0.0000      0.986  0 0.000 0.000 1.000 0.000 0.000
#> SRR945204     4  0.0000      0.986  0 0.000 0.000 1.000 0.000 0.000
#> SRR945205     4  0.0000      0.986  0 0.000 0.000 1.000 0.000 0.000
#> SRR945198     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR945199     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR945206     6  0.3810      1.000  0 0.000 0.000 0.428 0.000 0.572
#> SRR945207     6  0.3810      1.000  0 0.000 0.000 0.428 0.000 0.572
#> SRR945208     4  0.0363      0.986  0 0.000 0.000 0.988 0.000 0.012
#> SRR945209     4  0.0363      0.986  0 0.000 0.000 0.988 0.000 0.012
#> SRR945212     4  0.0458      0.983  0 0.000 0.000 0.984 0.000 0.016
#> SRR945213     4  0.0458      0.983  0 0.000 0.000 0.984 0.000 0.016
#> SRR945214     2  0.0000      0.902  0 1.000 0.000 0.000 0.000 0.000
#> SRR945215     2  0.0000      0.902  0 1.000 0.000 0.000 0.000 0.000
#> SRR945210     5  0.4102      1.000  0 0.000 0.004 0.012 0.628 0.356
#> SRR945211     5  0.4102      1.000  0 0.000 0.004 0.012 0.628 0.356
#> SRR945218     2  0.0000      0.902  0 1.000 0.000 0.000 0.000 0.000
#> SRR945219     2  0.0000      0.902  0 1.000 0.000 0.000 0.000 0.000
#> SRR945216     2  0.0000      0.902  0 1.000 0.000 0.000 0.000 0.000
#> SRR945217     2  0.0000      0.902  0 1.000 0.000 0.000 0.000 0.000
#> SRR945220     2  0.0000      0.902  0 1.000 0.000 0.000 0.000 0.000
#> SRR945221     2  0.0000      0.902  0 1.000 0.000 0.000 0.000 0.000
#> SRR945222     2  0.0000      0.902  0 1.000 0.000 0.000 0.000 0.000
#> SRR945223     2  0.0000      0.902  0 1.000 0.000 0.000 0.000 0.000
#> SRR945224     2  0.0000      0.902  0 1.000 0.000 0.000 0.000 0.000
#> SRR945225     2  0.0000      0.902  0 1.000 0.000 0.000 0.000 0.000
#> SRR945226     2  0.1327      0.886  0 0.936 0.000 0.000 0.064 0.000
#> SRR945227     2  0.1387      0.885  0 0.932 0.000 0.000 0.068 0.000
#> SRR945228     2  0.3563      0.706  0 0.664 0.000 0.000 0.336 0.000
#> SRR945229     2  0.3563      0.706  0 0.664 0.000 0.000 0.336 0.000
#> SRR945230     2  0.3684      0.668  0 0.628 0.000 0.000 0.372 0.000
#> SRR945231     2  0.3684      0.668  0 0.628 0.000 0.000 0.372 0.000
#> SRR945232     2  0.0363      0.900  0 0.988 0.000 0.000 0.012 0.000
#> SRR945233     2  0.0458      0.900  0 0.984 0.000 0.000 0.016 0.000
#> SRR945234     2  0.1327      0.886  0 0.936 0.000 0.000 0.064 0.000
#> SRR945235     2  0.1327      0.886  0 0.936 0.000 0.000 0.064 0.000
#> SRR945236     2  0.3464      0.727  0 0.688 0.000 0.000 0.312 0.000
#> SRR945237     2  0.3464      0.727  0 0.688 0.000 0.000 0.312 0.000
#> SRR945238     3  0.0000      1.000  0 0.000 1.000 0.000 0.000 0.000
#> SRR945239     3  0.0000      1.000  0 0.000 1.000 0.000 0.000 0.000
#> SRR945240     3  0.0000      1.000  0 0.000 1.000 0.000 0.000 0.000
#> SRR945241     3  0.0000      1.000  0 0.000 1.000 0.000 0.000 0.000
#> SRR945242     3  0.0000      1.000  0 0.000 1.000 0.000 0.000 0.000
#> SRR945243     3  0.0000      1.000  0 0.000 1.000 0.000 0.000 0.000
#> SRR945244     3  0.0000      1.000  0 0.000 1.000 0.000 0.000 0.000
#> SRR945245     3  0.0000      1.000  0 0.000 1.000 0.000 0.000 0.000
#> SRR945246     3  0.0000      1.000  0 0.000 1.000 0.000 0.000 0.000
#> SRR945247     3  0.0000      1.000  0 0.000 1.000 0.000 0.000 0.000
#> SRR945248     3  0.0000      1.000  0 0.000 1.000 0.000 0.000 0.000
#> SRR945249     3  0.0000      1.000  0 0.000 1.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-NMF-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-NMF-collect-classes

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


CV:hclust**

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

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

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

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

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

collect_plots(res)

plot of chunk CV-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.575           0.891       0.908         0.4071 0.512   0.512
#> 3 3 0.976           0.967       0.985         0.3924 0.921   0.845
#> 4 4 0.985           0.965       0.980         0.0310 0.986   0.969
#> 5 5 0.986           0.979       0.984         0.0145 0.991   0.978
#> 6 6 0.986           0.981       0.969         0.2516 0.837   0.603

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> SRR945190     1   0.971      0.713 0.600 0.400
#> SRR945191     1   0.971      0.713 0.600 0.400
#> SRR945192     1   0.971      0.713 0.600 0.400
#> SRR945193     1   0.971      0.713 0.600 0.400
#> SRR945194     1   0.971      0.713 0.600 0.400
#> SRR945195     1   0.971      0.713 0.600 0.400
#> SRR945196     1   0.971      0.713 0.600 0.400
#> SRR945197     1   0.971      0.713 0.600 0.400
#> SRR945200     1   0.971      0.713 0.600 0.400
#> SRR945201     1   0.971      0.713 0.600 0.400
#> SRR945202     1   0.000      0.733 1.000 0.000
#> SRR945203     1   0.000      0.733 1.000 0.000
#> SRR945204     1   0.000      0.733 1.000 0.000
#> SRR945205     1   0.000      0.733 1.000 0.000
#> SRR945198     1   0.971      0.713 0.600 0.400
#> SRR945199     1   0.971      0.713 0.600 0.400
#> SRR945206     1   0.680      0.764 0.820 0.180
#> SRR945207     1   0.680      0.764 0.820 0.180
#> SRR945208     1   0.000      0.733 1.000 0.000
#> SRR945209     1   0.000      0.733 1.000 0.000
#> SRR945212     1   0.000      0.733 1.000 0.000
#> SRR945213     1   0.000      0.733 1.000 0.000
#> SRR945214     2   0.000      1.000 0.000 1.000
#> SRR945215     2   0.000      1.000 0.000 1.000
#> SRR945210     1   0.697      0.764 0.812 0.188
#> SRR945211     1   0.697      0.764 0.812 0.188
#> SRR945218     2   0.000      1.000 0.000 1.000
#> SRR945219     2   0.000      1.000 0.000 1.000
#> SRR945216     2   0.000      1.000 0.000 1.000
#> SRR945217     2   0.000      1.000 0.000 1.000
#> SRR945220     2   0.000      1.000 0.000 1.000
#> SRR945221     2   0.000      1.000 0.000 1.000
#> SRR945222     2   0.000      1.000 0.000 1.000
#> SRR945223     2   0.000      1.000 0.000 1.000
#> SRR945224     2   0.000      1.000 0.000 1.000
#> SRR945225     2   0.000      1.000 0.000 1.000
#> SRR945226     2   0.000      1.000 0.000 1.000
#> SRR945227     2   0.000      1.000 0.000 1.000
#> SRR945228     2   0.000      1.000 0.000 1.000
#> SRR945229     2   0.000      1.000 0.000 1.000
#> SRR945230     2   0.000      1.000 0.000 1.000
#> SRR945231     2   0.000      1.000 0.000 1.000
#> SRR945232     2   0.000      1.000 0.000 1.000
#> SRR945233     2   0.000      1.000 0.000 1.000
#> SRR945234     2   0.000      1.000 0.000 1.000
#> SRR945235     2   0.000      1.000 0.000 1.000
#> SRR945236     2   0.000      1.000 0.000 1.000
#> SRR945237     2   0.000      1.000 0.000 1.000
#> SRR945238     2   0.000      1.000 0.000 1.000
#> SRR945239     2   0.000      1.000 0.000 1.000
#> SRR945240     2   0.000      1.000 0.000 1.000
#> SRR945241     2   0.000      1.000 0.000 1.000
#> SRR945242     2   0.000      1.000 0.000 1.000
#> SRR945243     2   0.000      1.000 0.000 1.000
#> SRR945244     2   0.000      1.000 0.000 1.000
#> SRR945245     2   0.000      1.000 0.000 1.000
#> SRR945246     2   0.000      1.000 0.000 1.000
#> SRR945247     2   0.000      1.000 0.000 1.000
#> SRR945248     2   0.000      1.000 0.000 1.000
#> SRR945249     2   0.000      1.000 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1 p2    p3
#> SRR945190     1   0.000      0.960 1.000  0 0.000
#> SRR945191     1   0.000      0.960 1.000  0 0.000
#> SRR945192     1   0.000      0.960 1.000  0 0.000
#> SRR945193     1   0.000      0.960 1.000  0 0.000
#> SRR945194     1   0.000      0.960 1.000  0 0.000
#> SRR945195     1   0.000      0.960 1.000  0 0.000
#> SRR945196     1   0.000      0.960 1.000  0 0.000
#> SRR945197     1   0.000      0.960 1.000  0 0.000
#> SRR945200     1   0.000      0.960 1.000  0 0.000
#> SRR945201     1   0.000      0.960 1.000  0 0.000
#> SRR945202     3   0.000      0.951 0.000  0 1.000
#> SRR945203     3   0.000      0.951 0.000  0 1.000
#> SRR945204     3   0.000      0.951 0.000  0 1.000
#> SRR945205     3   0.000      0.951 0.000  0 1.000
#> SRR945198     1   0.000      0.960 1.000  0 0.000
#> SRR945199     1   0.000      0.960 1.000  0 0.000
#> SRR945206     3   0.455      0.760 0.200  0 0.800
#> SRR945207     3   0.455      0.760 0.200  0 0.800
#> SRR945208     3   0.000      0.951 0.000  0 1.000
#> SRR945209     3   0.000      0.951 0.000  0 1.000
#> SRR945212     3   0.000      0.951 0.000  0 1.000
#> SRR945213     3   0.000      0.951 0.000  0 1.000
#> SRR945214     2   0.000      1.000 0.000  1 0.000
#> SRR945215     2   0.000      1.000 0.000  1 0.000
#> SRR945210     1   0.497      0.691 0.764  0 0.236
#> SRR945211     1   0.497      0.691 0.764  0 0.236
#> SRR945218     2   0.000      1.000 0.000  1 0.000
#> SRR945219     2   0.000      1.000 0.000  1 0.000
#> SRR945216     2   0.000      1.000 0.000  1 0.000
#> SRR945217     2   0.000      1.000 0.000  1 0.000
#> SRR945220     2   0.000      1.000 0.000  1 0.000
#> SRR945221     2   0.000      1.000 0.000  1 0.000
#> SRR945222     2   0.000      1.000 0.000  1 0.000
#> SRR945223     2   0.000      1.000 0.000  1 0.000
#> SRR945224     2   0.000      1.000 0.000  1 0.000
#> SRR945225     2   0.000      1.000 0.000  1 0.000
#> SRR945226     2   0.000      1.000 0.000  1 0.000
#> SRR945227     2   0.000      1.000 0.000  1 0.000
#> SRR945228     2   0.000      1.000 0.000  1 0.000
#> SRR945229     2   0.000      1.000 0.000  1 0.000
#> SRR945230     2   0.000      1.000 0.000  1 0.000
#> SRR945231     2   0.000      1.000 0.000  1 0.000
#> SRR945232     2   0.000      1.000 0.000  1 0.000
#> SRR945233     2   0.000      1.000 0.000  1 0.000
#> SRR945234     2   0.000      1.000 0.000  1 0.000
#> SRR945235     2   0.000      1.000 0.000  1 0.000
#> SRR945236     2   0.000      1.000 0.000  1 0.000
#> SRR945237     2   0.000      1.000 0.000  1 0.000
#> SRR945238     2   0.000      1.000 0.000  1 0.000
#> SRR945239     2   0.000      1.000 0.000  1 0.000
#> SRR945240     2   0.000      1.000 0.000  1 0.000
#> SRR945241     2   0.000      1.000 0.000  1 0.000
#> SRR945242     2   0.000      1.000 0.000  1 0.000
#> SRR945243     2   0.000      1.000 0.000  1 0.000
#> SRR945244     2   0.000      1.000 0.000  1 0.000
#> SRR945245     2   0.000      1.000 0.000  1 0.000
#> SRR945246     2   0.000      1.000 0.000  1 0.000
#> SRR945247     2   0.000      1.000 0.000  1 0.000
#> SRR945248     2   0.000      1.000 0.000  1 0.000
#> SRR945249     2   0.000      1.000 0.000  1 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette p1 p2    p3    p4
#> SRR945190     1   0.000      1.000  1  0 0.000 0.000
#> SRR945191     1   0.000      1.000  1  0 0.000 0.000
#> SRR945192     1   0.000      1.000  1  0 0.000 0.000
#> SRR945193     1   0.000      1.000  1  0 0.000 0.000
#> SRR945194     1   0.000      1.000  1  0 0.000 0.000
#> SRR945195     1   0.000      1.000  1  0 0.000 0.000
#> SRR945196     1   0.000      1.000  1  0 0.000 0.000
#> SRR945197     1   0.000      1.000  1  0 0.000 0.000
#> SRR945200     1   0.000      1.000  1  0 0.000 0.000
#> SRR945201     1   0.000      1.000  1  0 0.000 0.000
#> SRR945202     4   0.357      0.798  0  0 0.196 0.804
#> SRR945203     4   0.357      0.798  0  0 0.196 0.804
#> SRR945204     4   0.357      0.798  0  0 0.196 0.804
#> SRR945205     4   0.357      0.798  0  0 0.196 0.804
#> SRR945198     1   0.000      1.000  1  0 0.000 0.000
#> SRR945199     1   0.000      1.000  1  0 0.000 0.000
#> SRR945206     4   0.373      0.674  0  0 0.212 0.788
#> SRR945207     4   0.373      0.674  0  0 0.212 0.788
#> SRR945208     4   0.000      0.837  0  0 0.000 1.000
#> SRR945209     4   0.000      0.837  0  0 0.000 1.000
#> SRR945212     4   0.000      0.837  0  0 0.000 1.000
#> SRR945213     4   0.000      0.837  0  0 0.000 1.000
#> SRR945214     2   0.000      1.000  0  1 0.000 0.000
#> SRR945215     2   0.000      1.000  0  1 0.000 0.000
#> SRR945210     3   0.000      1.000  0  0 1.000 0.000
#> SRR945211     3   0.000      1.000  0  0 1.000 0.000
#> SRR945218     2   0.000      1.000  0  1 0.000 0.000
#> SRR945219     2   0.000      1.000  0  1 0.000 0.000
#> SRR945216     2   0.000      1.000  0  1 0.000 0.000
#> SRR945217     2   0.000      1.000  0  1 0.000 0.000
#> SRR945220     2   0.000      1.000  0  1 0.000 0.000
#> SRR945221     2   0.000      1.000  0  1 0.000 0.000
#> SRR945222     2   0.000      1.000  0  1 0.000 0.000
#> SRR945223     2   0.000      1.000  0  1 0.000 0.000
#> SRR945224     2   0.000      1.000  0  1 0.000 0.000
#> SRR945225     2   0.000      1.000  0  1 0.000 0.000
#> SRR945226     2   0.000      1.000  0  1 0.000 0.000
#> SRR945227     2   0.000      1.000  0  1 0.000 0.000
#> SRR945228     2   0.000      1.000  0  1 0.000 0.000
#> SRR945229     2   0.000      1.000  0  1 0.000 0.000
#> SRR945230     2   0.000      1.000  0  1 0.000 0.000
#> SRR945231     2   0.000      1.000  0  1 0.000 0.000
#> SRR945232     2   0.000      1.000  0  1 0.000 0.000
#> SRR945233     2   0.000      1.000  0  1 0.000 0.000
#> SRR945234     2   0.000      1.000  0  1 0.000 0.000
#> SRR945235     2   0.000      1.000  0  1 0.000 0.000
#> SRR945236     2   0.000      1.000  0  1 0.000 0.000
#> SRR945237     2   0.000      1.000  0  1 0.000 0.000
#> SRR945238     2   0.000      1.000  0  1 0.000 0.000
#> SRR945239     2   0.000      1.000  0  1 0.000 0.000
#> SRR945240     2   0.000      1.000  0  1 0.000 0.000
#> SRR945241     2   0.000      1.000  0  1 0.000 0.000
#> SRR945242     2   0.000      1.000  0  1 0.000 0.000
#> SRR945243     2   0.000      1.000  0  1 0.000 0.000
#> SRR945244     2   0.000      1.000  0  1 0.000 0.000
#> SRR945245     2   0.000      1.000  0  1 0.000 0.000
#> SRR945246     2   0.000      1.000  0  1 0.000 0.000
#> SRR945247     2   0.000      1.000  0  1 0.000 0.000
#> SRR945248     2   0.000      1.000  0  1 0.000 0.000
#> SRR945249     2   0.000      1.000  0  1 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette p1    p2    p3    p4    p5
#> SRR945190     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR945191     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR945192     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR945193     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR945194     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR945195     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR945196     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR945197     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR945200     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR945201     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR945202     4  0.3074      0.870  0 0.000 0.196 0.804 0.000
#> SRR945203     4  0.3074      0.870  0 0.000 0.196 0.804 0.000
#> SRR945204     4  0.3074      0.870  0 0.000 0.196 0.804 0.000
#> SRR945205     4  0.3074      0.870  0 0.000 0.196 0.804 0.000
#> SRR945198     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR945199     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR945206     3  0.3462      1.000  0 0.000 0.792 0.196 0.012
#> SRR945207     3  0.3462      1.000  0 0.000 0.792 0.196 0.012
#> SRR945208     4  0.0000      0.861  0 0.000 0.000 1.000 0.000
#> SRR945209     4  0.0000      0.861  0 0.000 0.000 1.000 0.000
#> SRR945212     4  0.0000      0.861  0 0.000 0.000 1.000 0.000
#> SRR945213     4  0.0000      0.861  0 0.000 0.000 1.000 0.000
#> SRR945214     2  0.0000      0.996  0 1.000 0.000 0.000 0.000
#> SRR945215     2  0.0000      0.996  0 1.000 0.000 0.000 0.000
#> SRR945210     5  0.0000      1.000  0 0.000 0.000 0.000 1.000
#> SRR945211     5  0.0000      1.000  0 0.000 0.000 0.000 1.000
#> SRR945218     2  0.0000      0.996  0 1.000 0.000 0.000 0.000
#> SRR945219     2  0.0000      0.996  0 1.000 0.000 0.000 0.000
#> SRR945216     2  0.0000      0.996  0 1.000 0.000 0.000 0.000
#> SRR945217     2  0.0000      0.996  0 1.000 0.000 0.000 0.000
#> SRR945220     2  0.0000      0.996  0 1.000 0.000 0.000 0.000
#> SRR945221     2  0.0000      0.996  0 1.000 0.000 0.000 0.000
#> SRR945222     2  0.0000      0.996  0 1.000 0.000 0.000 0.000
#> SRR945223     2  0.0000      0.996  0 1.000 0.000 0.000 0.000
#> SRR945224     2  0.0000      0.996  0 1.000 0.000 0.000 0.000
#> SRR945225     2  0.0000      0.996  0 1.000 0.000 0.000 0.000
#> SRR945226     2  0.0000      0.996  0 1.000 0.000 0.000 0.000
#> SRR945227     2  0.0000      0.996  0 1.000 0.000 0.000 0.000
#> SRR945228     2  0.0000      0.996  0 1.000 0.000 0.000 0.000
#> SRR945229     2  0.0000      0.996  0 1.000 0.000 0.000 0.000
#> SRR945230     2  0.0000      0.996  0 1.000 0.000 0.000 0.000
#> SRR945231     2  0.0000      0.996  0 1.000 0.000 0.000 0.000
#> SRR945232     2  0.0000      0.996  0 1.000 0.000 0.000 0.000
#> SRR945233     2  0.0000      0.996  0 1.000 0.000 0.000 0.000
#> SRR945234     2  0.0000      0.996  0 1.000 0.000 0.000 0.000
#> SRR945235     2  0.0000      0.996  0 1.000 0.000 0.000 0.000
#> SRR945236     2  0.0000      0.996  0 1.000 0.000 0.000 0.000
#> SRR945237     2  0.0000      0.996  0 1.000 0.000 0.000 0.000
#> SRR945238     2  0.0404      0.992  0 0.988 0.012 0.000 0.000
#> SRR945239     2  0.0404      0.992  0 0.988 0.012 0.000 0.000
#> SRR945240     2  0.0404      0.992  0 0.988 0.012 0.000 0.000
#> SRR945241     2  0.0404      0.992  0 0.988 0.012 0.000 0.000
#> SRR945242     2  0.0404      0.992  0 0.988 0.012 0.000 0.000
#> SRR945243     2  0.0404      0.992  0 0.988 0.012 0.000 0.000
#> SRR945244     2  0.0404      0.992  0 0.988 0.012 0.000 0.000
#> SRR945245     2  0.0404      0.992  0 0.988 0.012 0.000 0.000
#> SRR945246     2  0.0404      0.992  0 0.988 0.012 0.000 0.000
#> SRR945247     2  0.0404      0.992  0 0.988 0.012 0.000 0.000
#> SRR945248     2  0.0404      0.992  0 0.988 0.012 0.000 0.000
#> SRR945249     2  0.0404      0.992  0 0.988 0.012 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
#> SRR945190     1  0.0000      0.993 1.00 0.000 0.000 0.000  0 0.00
#> SRR945191     1  0.0000      0.993 1.00 0.000 0.000 0.000  0 0.00
#> SRR945192     1  0.0000      0.993 1.00 0.000 0.000 0.000  0 0.00
#> SRR945193     1  0.0000      0.993 1.00 0.000 0.000 0.000  0 0.00
#> SRR945194     1  0.0937      0.965 0.96 0.000 0.040 0.000  0 0.00
#> SRR945195     1  0.0937      0.965 0.96 0.000 0.040 0.000  0 0.00
#> SRR945196     1  0.0000      0.993 1.00 0.000 0.000 0.000  0 0.00
#> SRR945197     1  0.0000      0.993 1.00 0.000 0.000 0.000  0 0.00
#> SRR945200     1  0.0000      0.993 1.00 0.000 0.000 0.000  0 0.00
#> SRR945201     1  0.0000      0.993 1.00 0.000 0.000 0.000  0 0.00
#> SRR945202     4  0.0000      0.876 0.00 0.000 0.000 1.000  0 0.00
#> SRR945203     4  0.0000      0.876 0.00 0.000 0.000 1.000  0 0.00
#> SRR945204     4  0.0000      0.876 0.00 0.000 0.000 1.000  0 0.00
#> SRR945205     4  0.0000      0.876 0.00 0.000 0.000 1.000  0 0.00
#> SRR945198     1  0.0000      0.993 1.00 0.000 0.000 0.000  0 0.00
#> SRR945199     1  0.0000      0.993 1.00 0.000 0.000 0.000  0 0.00
#> SRR945206     6  0.0000      1.000 0.00 0.000 0.000 0.000  0 1.00
#> SRR945207     6  0.0000      1.000 0.00 0.000 0.000 0.000  0 1.00
#> SRR945208     4  0.3283      0.869 0.00 0.000 0.036 0.804  0 0.16
#> SRR945209     4  0.3283      0.869 0.00 0.000 0.036 0.804  0 0.16
#> SRR945212     4  0.3283      0.869 0.00 0.000 0.036 0.804  0 0.16
#> SRR945213     4  0.3283      0.869 0.00 0.000 0.036 0.804  0 0.16
#> SRR945214     2  0.0000      1.000 0.00 1.000 0.000 0.000  0 0.00
#> SRR945215     2  0.0000      1.000 0.00 1.000 0.000 0.000  0 0.00
#> SRR945210     5  0.0000      1.000 0.00 0.000 0.000 0.000  1 0.00
#> SRR945211     5  0.0000      1.000 0.00 0.000 0.000 0.000  1 0.00
#> SRR945218     2  0.0000      1.000 0.00 1.000 0.000 0.000  0 0.00
#> SRR945219     2  0.0000      1.000 0.00 1.000 0.000 0.000  0 0.00
#> SRR945216     2  0.0000      1.000 0.00 1.000 0.000 0.000  0 0.00
#> SRR945217     2  0.0000      1.000 0.00 1.000 0.000 0.000  0 0.00
#> SRR945220     2  0.0000      1.000 0.00 1.000 0.000 0.000  0 0.00
#> SRR945221     2  0.0000      1.000 0.00 1.000 0.000 0.000  0 0.00
#> SRR945222     2  0.0000      1.000 0.00 1.000 0.000 0.000  0 0.00
#> SRR945223     2  0.0000      1.000 0.00 1.000 0.000 0.000  0 0.00
#> SRR945224     2  0.0000      1.000 0.00 1.000 0.000 0.000  0 0.00
#> SRR945225     2  0.0000      1.000 0.00 1.000 0.000 0.000  0 0.00
#> SRR945226     2  0.0000      1.000 0.00 1.000 0.000 0.000  0 0.00
#> SRR945227     2  0.0000      1.000 0.00 1.000 0.000 0.000  0 0.00
#> SRR945228     2  0.0000      1.000 0.00 1.000 0.000 0.000  0 0.00
#> SRR945229     2  0.0000      1.000 0.00 1.000 0.000 0.000  0 0.00
#> SRR945230     2  0.0000      1.000 0.00 1.000 0.000 0.000  0 0.00
#> SRR945231     2  0.0000      1.000 0.00 1.000 0.000 0.000  0 0.00
#> SRR945232     2  0.0000      1.000 0.00 1.000 0.000 0.000  0 0.00
#> SRR945233     2  0.0000      1.000 0.00 1.000 0.000 0.000  0 0.00
#> SRR945234     2  0.0000      1.000 0.00 1.000 0.000 0.000  0 0.00
#> SRR945235     2  0.0000      1.000 0.00 1.000 0.000 0.000  0 0.00
#> SRR945236     2  0.0000      1.000 0.00 1.000 0.000 0.000  0 0.00
#> SRR945237     2  0.0000      1.000 0.00 1.000 0.000 0.000  0 0.00
#> SRR945238     3  0.1501      1.000 0.00 0.076 0.924 0.000  0 0.00
#> SRR945239     3  0.1501      1.000 0.00 0.076 0.924 0.000  0 0.00
#> SRR945240     3  0.1501      1.000 0.00 0.076 0.924 0.000  0 0.00
#> SRR945241     3  0.1501      1.000 0.00 0.076 0.924 0.000  0 0.00
#> SRR945242     3  0.1501      1.000 0.00 0.076 0.924 0.000  0 0.00
#> SRR945243     3  0.1501      1.000 0.00 0.076 0.924 0.000  0 0.00
#> SRR945244     3  0.1501      1.000 0.00 0.076 0.924 0.000  0 0.00
#> SRR945245     3  0.1501      1.000 0.00 0.076 0.924 0.000  0 0.00
#> SRR945246     3  0.1501      1.000 0.00 0.076 0.924 0.000  0 0.00
#> SRR945247     3  0.1501      1.000 0.00 0.076 0.924 0.000  0 0.00
#> SRR945248     3  0.1501      1.000 0.00 0.076 0.924 0.000  0 0.00
#> SRR945249     3  0.1501      1.000 0.00 0.076 0.924 0.000  0 0.00

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

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

collect_plots(res)

plot of chunk CV-kmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.675           0.962       0.956         0.4708 0.512   0.512
#> 3 3 0.756           0.929       0.847         0.3166 0.837   0.682
#> 4 4 0.644           0.823       0.746         0.1304 0.921   0.773
#> 5 5 0.785           0.855       0.809         0.0743 0.975   0.912
#> 6 6 0.731           0.872       0.785         0.0521 0.919   0.696

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
#> SRR945190     1   0.278      0.971 0.952 0.048
#> SRR945191     1   0.278      0.971 0.952 0.048
#> SRR945192     1   0.278      0.971 0.952 0.048
#> SRR945193     1   0.278      0.971 0.952 0.048
#> SRR945194     1   0.000      0.973 1.000 0.000
#> SRR945195     1   0.000      0.973 1.000 0.000
#> SRR945196     1   0.278      0.971 0.952 0.048
#> SRR945197     1   0.278      0.971 0.952 0.048
#> SRR945200     1   0.278      0.971 0.952 0.048
#> SRR945201     1   0.278      0.971 0.952 0.048
#> SRR945202     1   0.000      0.973 1.000 0.000
#> SRR945203     1   0.000      0.973 1.000 0.000
#> SRR945204     1   0.000      0.973 1.000 0.000
#> SRR945205     1   0.000      0.973 1.000 0.000
#> SRR945198     1   0.278      0.971 0.952 0.048
#> SRR945199     1   0.278      0.971 0.952 0.048
#> SRR945206     1   0.000      0.973 1.000 0.000
#> SRR945207     1   0.000      0.973 1.000 0.000
#> SRR945208     1   0.000      0.973 1.000 0.000
#> SRR945209     1   0.000      0.973 1.000 0.000
#> SRR945212     1   0.000      0.973 1.000 0.000
#> SRR945213     1   0.000      0.973 1.000 0.000
#> SRR945214     2   0.343      0.967 0.064 0.936
#> SRR945215     2   0.343      0.967 0.064 0.936
#> SRR945210     1   0.260      0.972 0.956 0.044
#> SRR945211     1   0.260      0.972 0.956 0.044
#> SRR945218     2   0.343      0.967 0.064 0.936
#> SRR945219     2   0.343      0.967 0.064 0.936
#> SRR945216     2   0.343      0.967 0.064 0.936
#> SRR945217     2   0.343      0.967 0.064 0.936
#> SRR945220     2   0.343      0.967 0.064 0.936
#> SRR945221     2   0.343      0.967 0.064 0.936
#> SRR945222     2   0.343      0.967 0.064 0.936
#> SRR945223     2   0.343      0.967 0.064 0.936
#> SRR945224     2   0.343      0.967 0.064 0.936
#> SRR945225     2   0.343      0.967 0.064 0.936
#> SRR945226     2   0.343      0.967 0.064 0.936
#> SRR945227     2   0.343      0.967 0.064 0.936
#> SRR945228     2   0.343      0.967 0.064 0.936
#> SRR945229     2   0.343      0.967 0.064 0.936
#> SRR945230     2   0.343      0.967 0.064 0.936
#> SRR945231     2   0.343      0.967 0.064 0.936
#> SRR945232     2   0.343      0.967 0.064 0.936
#> SRR945233     2   0.343      0.967 0.064 0.936
#> SRR945234     2   0.343      0.967 0.064 0.936
#> SRR945235     2   0.343      0.967 0.064 0.936
#> SRR945236     2   0.343      0.967 0.064 0.936
#> SRR945237     2   0.343      0.967 0.064 0.936
#> SRR945238     2   0.260      0.934 0.044 0.956
#> SRR945239     2   0.260      0.934 0.044 0.956
#> SRR945240     2   0.260      0.934 0.044 0.956
#> SRR945241     2   0.260      0.934 0.044 0.956
#> SRR945242     2   0.260      0.934 0.044 0.956
#> SRR945243     2   0.260      0.934 0.044 0.956
#> SRR945244     2   0.260      0.934 0.044 0.956
#> SRR945245     2   0.260      0.934 0.044 0.956
#> SRR945246     2   0.260      0.934 0.044 0.956
#> SRR945247     2   0.260      0.934 0.044 0.956
#> SRR945248     2   0.260      0.934 0.044 0.956
#> SRR945249     2   0.260      0.934 0.044 0.956

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> SRR945190     1   0.134      0.822 0.972 0.012 0.016
#> SRR945191     1   0.134      0.822 0.972 0.012 0.016
#> SRR945192     1   0.134      0.822 0.972 0.012 0.016
#> SRR945193     1   0.134      0.822 0.972 0.012 0.016
#> SRR945194     1   0.200      0.827 0.952 0.012 0.036
#> SRR945195     1   0.200      0.827 0.952 0.012 0.036
#> SRR945196     1   0.134      0.822 0.972 0.012 0.016
#> SRR945197     1   0.134      0.822 0.972 0.012 0.016
#> SRR945200     1   0.134      0.822 0.972 0.012 0.016
#> SRR945201     1   0.134      0.822 0.972 0.012 0.016
#> SRR945202     1   0.655      0.824 0.616 0.012 0.372
#> SRR945203     1   0.655      0.824 0.616 0.012 0.372
#> SRR945204     1   0.655      0.824 0.616 0.012 0.372
#> SRR945205     1   0.655      0.824 0.616 0.012 0.372
#> SRR945198     1   0.134      0.822 0.972 0.012 0.016
#> SRR945199     1   0.134      0.822 0.972 0.012 0.016
#> SRR945206     1   0.655      0.824 0.616 0.012 0.372
#> SRR945207     1   0.655      0.824 0.616 0.012 0.372
#> SRR945208     1   0.655      0.824 0.616 0.012 0.372
#> SRR945209     1   0.655      0.824 0.616 0.012 0.372
#> SRR945212     1   0.655      0.824 0.616 0.012 0.372
#> SRR945213     1   0.655      0.824 0.616 0.012 0.372
#> SRR945214     2   0.000      1.000 0.000 1.000 0.000
#> SRR945215     2   0.000      1.000 0.000 1.000 0.000
#> SRR945210     1   0.642      0.825 0.660 0.016 0.324
#> SRR945211     1   0.642      0.825 0.660 0.016 0.324
#> SRR945218     2   0.000      1.000 0.000 1.000 0.000
#> SRR945219     2   0.000      1.000 0.000 1.000 0.000
#> SRR945216     2   0.000      1.000 0.000 1.000 0.000
#> SRR945217     2   0.000      1.000 0.000 1.000 0.000
#> SRR945220     2   0.000      1.000 0.000 1.000 0.000
#> SRR945221     2   0.000      1.000 0.000 1.000 0.000
#> SRR945222     2   0.000      1.000 0.000 1.000 0.000
#> SRR945223     2   0.000      1.000 0.000 1.000 0.000
#> SRR945224     2   0.000      1.000 0.000 1.000 0.000
#> SRR945225     2   0.000      1.000 0.000 1.000 0.000
#> SRR945226     2   0.000      1.000 0.000 1.000 0.000
#> SRR945227     2   0.000      1.000 0.000 1.000 0.000
#> SRR945228     2   0.000      1.000 0.000 1.000 0.000
#> SRR945229     2   0.000      1.000 0.000 1.000 0.000
#> SRR945230     2   0.000      1.000 0.000 1.000 0.000
#> SRR945231     2   0.000      1.000 0.000 1.000 0.000
#> SRR945232     2   0.000      1.000 0.000 1.000 0.000
#> SRR945233     2   0.000      1.000 0.000 1.000 0.000
#> SRR945234     2   0.000      1.000 0.000 1.000 0.000
#> SRR945235     2   0.000      1.000 0.000 1.000 0.000
#> SRR945236     2   0.000      1.000 0.000 1.000 0.000
#> SRR945237     2   0.000      1.000 0.000 1.000 0.000
#> SRR945238     3   0.689      0.996 0.028 0.340 0.632
#> SRR945239     3   0.689      0.996 0.028 0.340 0.632
#> SRR945240     3   0.689      0.996 0.028 0.340 0.632
#> SRR945241     3   0.689      0.996 0.028 0.340 0.632
#> SRR945242     3   0.689      0.996 0.028 0.340 0.632
#> SRR945243     3   0.689      0.996 0.028 0.340 0.632
#> SRR945244     3   0.700      0.996 0.032 0.340 0.628
#> SRR945245     3   0.700      0.996 0.032 0.340 0.628
#> SRR945246     3   0.700      0.996 0.032 0.340 0.628
#> SRR945247     3   0.700      0.996 0.032 0.340 0.628
#> SRR945248     3   0.677      0.996 0.024 0.340 0.636
#> SRR945249     3   0.677      0.996 0.024 0.340 0.636

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> SRR945190     1  0.6165      0.994 0.532 0.016 0.024 0.428
#> SRR945191     1  0.6165      0.994 0.532 0.016 0.024 0.428
#> SRR945192     1  0.6165      0.994 0.532 0.016 0.024 0.428
#> SRR945193     1  0.6165      0.994 0.532 0.016 0.024 0.428
#> SRR945194     4  0.6900     -0.821 0.444 0.008 0.080 0.468
#> SRR945195     4  0.6900     -0.821 0.444 0.008 0.080 0.468
#> SRR945196     1  0.6252      0.991 0.528 0.016 0.028 0.428
#> SRR945197     1  0.6252      0.991 0.528 0.016 0.028 0.428
#> SRR945200     1  0.6413      0.983 0.520 0.016 0.036 0.428
#> SRR945201     1  0.6413      0.983 0.520 0.016 0.036 0.428
#> SRR945202     4  0.0804      0.818 0.000 0.008 0.012 0.980
#> SRR945203     4  0.0804      0.818 0.000 0.008 0.012 0.980
#> SRR945204     4  0.1151      0.816 0.000 0.008 0.024 0.968
#> SRR945205     4  0.1151      0.816 0.000 0.008 0.024 0.968
#> SRR945198     1  0.6165      0.994 0.532 0.016 0.024 0.428
#> SRR945199     1  0.6165      0.994 0.532 0.016 0.024 0.428
#> SRR945206     4  0.1151      0.813 0.000 0.008 0.024 0.968
#> SRR945207     4  0.1151      0.813 0.000 0.008 0.024 0.968
#> SRR945208     4  0.0672      0.818 0.000 0.008 0.008 0.984
#> SRR945209     4  0.0672      0.818 0.000 0.008 0.008 0.984
#> SRR945212     4  0.0672      0.818 0.000 0.008 0.008 0.984
#> SRR945213     4  0.0672      0.818 0.000 0.008 0.008 0.984
#> SRR945214     2  0.0000      0.842 0.000 1.000 0.000 0.000
#> SRR945215     2  0.0000      0.842 0.000 1.000 0.000 0.000
#> SRR945210     4  0.4096      0.703 0.052 0.016 0.084 0.848
#> SRR945211     4  0.4096      0.703 0.052 0.016 0.084 0.848
#> SRR945218     2  0.0000      0.842 0.000 1.000 0.000 0.000
#> SRR945219     2  0.0000      0.842 0.000 1.000 0.000 0.000
#> SRR945216     2  0.0000      0.842 0.000 1.000 0.000 0.000
#> SRR945217     2  0.0000      0.842 0.000 1.000 0.000 0.000
#> SRR945220     2  0.0469      0.838 0.012 0.988 0.000 0.000
#> SRR945221     2  0.0469      0.838 0.012 0.988 0.000 0.000
#> SRR945222     2  0.0000      0.842 0.000 1.000 0.000 0.000
#> SRR945223     2  0.0000      0.842 0.000 1.000 0.000 0.000
#> SRR945224     2  0.0469      0.838 0.012 0.988 0.000 0.000
#> SRR945225     2  0.0469      0.838 0.012 0.988 0.000 0.000
#> SRR945226     2  0.4193      0.837 0.268 0.732 0.000 0.000
#> SRR945227     2  0.4193      0.837 0.268 0.732 0.000 0.000
#> SRR945228     2  0.4454      0.822 0.308 0.692 0.000 0.000
#> SRR945229     2  0.4454      0.822 0.308 0.692 0.000 0.000
#> SRR945230     2  0.4564      0.815 0.328 0.672 0.000 0.000
#> SRR945231     2  0.4564      0.815 0.328 0.672 0.000 0.000
#> SRR945232     2  0.4193      0.837 0.268 0.732 0.000 0.000
#> SRR945233     2  0.4193      0.837 0.268 0.732 0.000 0.000
#> SRR945234     2  0.4193      0.837 0.268 0.732 0.000 0.000
#> SRR945235     2  0.4193      0.837 0.268 0.732 0.000 0.000
#> SRR945236     2  0.4454      0.822 0.308 0.692 0.000 0.000
#> SRR945237     2  0.4454      0.822 0.308 0.692 0.000 0.000
#> SRR945238     3  0.4998      0.958 0.088 0.128 0.780 0.004
#> SRR945239     3  0.4998      0.958 0.088 0.128 0.780 0.004
#> SRR945240     3  0.4199      0.964 0.044 0.128 0.824 0.004
#> SRR945241     3  0.4199      0.964 0.044 0.128 0.824 0.004
#> SRR945242     3  0.3519      0.961 0.016 0.128 0.852 0.004
#> SRR945243     3  0.3519      0.961 0.016 0.128 0.852 0.004
#> SRR945244     3  0.4100      0.960 0.048 0.128 0.824 0.000
#> SRR945245     3  0.4100      0.960 0.048 0.128 0.824 0.000
#> SRR945246     3  0.2944      0.964 0.000 0.128 0.868 0.004
#> SRR945247     3  0.2944      0.964 0.000 0.128 0.868 0.004
#> SRR945248     3  0.5181      0.953 0.100 0.128 0.768 0.004
#> SRR945249     3  0.5181      0.953 0.100 0.128 0.768 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
#> SRR945190     1  0.0510      0.950 0.984 0.000 0.016 0.000 NA
#> SRR945191     1  0.0510      0.950 0.984 0.000 0.016 0.000 NA
#> SRR945192     1  0.0510      0.950 0.984 0.000 0.016 0.000 NA
#> SRR945193     1  0.0510      0.950 0.984 0.000 0.016 0.000 NA
#> SRR945194     1  0.4508      0.776 0.784 0.000 0.032 0.056 NA
#> SRR945195     1  0.4508      0.776 0.784 0.000 0.032 0.056 NA
#> SRR945196     1  0.0807      0.949 0.976 0.000 0.012 0.000 NA
#> SRR945197     1  0.0807      0.949 0.976 0.000 0.012 0.000 NA
#> SRR945200     1  0.1117      0.943 0.964 0.000 0.020 0.000 NA
#> SRR945201     1  0.1117      0.943 0.964 0.000 0.020 0.000 NA
#> SRR945202     4  0.4933      0.903 0.200 0.000 0.004 0.712 NA
#> SRR945203     4  0.4933      0.903 0.200 0.000 0.004 0.712 NA
#> SRR945204     4  0.5052      0.900 0.200 0.000 0.008 0.708 NA
#> SRR945205     4  0.5052      0.900 0.200 0.000 0.008 0.708 NA
#> SRR945198     1  0.0579      0.950 0.984 0.000 0.008 0.000 NA
#> SRR945199     1  0.0579      0.950 0.984 0.000 0.008 0.000 NA
#> SRR945206     4  0.4998      0.890 0.200 0.000 0.008 0.712 NA
#> SRR945207     4  0.4998      0.890 0.200 0.000 0.008 0.712 NA
#> SRR945208     4  0.3740      0.902 0.196 0.000 0.008 0.784 NA
#> SRR945209     4  0.3740      0.902 0.196 0.000 0.008 0.784 NA
#> SRR945212     4  0.3740      0.902 0.196 0.000 0.008 0.784 NA
#> SRR945213     4  0.3740      0.902 0.196 0.000 0.008 0.784 NA
#> SRR945214     2  0.4575      0.778 0.004 0.596 0.000 0.008 NA
#> SRR945215     2  0.4575      0.778 0.004 0.596 0.000 0.008 NA
#> SRR945210     4  0.6760      0.764 0.236 0.004 0.004 0.488 NA
#> SRR945211     4  0.6760      0.764 0.236 0.004 0.004 0.488 NA
#> SRR945218     2  0.4734      0.779 0.000 0.604 0.000 0.024 NA
#> SRR945219     2  0.4734      0.779 0.000 0.604 0.000 0.024 NA
#> SRR945216     2  0.4575      0.778 0.004 0.596 0.000 0.008 NA
#> SRR945217     2  0.4575      0.778 0.004 0.596 0.000 0.008 NA
#> SRR945220     2  0.5058      0.774 0.000 0.584 0.004 0.032 NA
#> SRR945221     2  0.5058      0.774 0.000 0.584 0.004 0.032 NA
#> SRR945222     2  0.4651      0.780 0.000 0.608 0.000 0.020 NA
#> SRR945223     2  0.4651      0.780 0.000 0.608 0.000 0.020 NA
#> SRR945224     2  0.5058      0.774 0.000 0.584 0.004 0.032 NA
#> SRR945225     2  0.5058      0.774 0.000 0.584 0.004 0.032 NA
#> SRR945226     2  0.0162      0.781 0.000 0.996 0.000 0.004 NA
#> SRR945227     2  0.0162      0.781 0.000 0.996 0.000 0.004 NA
#> SRR945228     2  0.1106      0.776 0.000 0.964 0.000 0.024 NA
#> SRR945229     2  0.1106      0.776 0.000 0.964 0.000 0.024 NA
#> SRR945230     2  0.2437      0.766 0.000 0.904 0.004 0.060 NA
#> SRR945231     2  0.2437      0.766 0.000 0.904 0.004 0.060 NA
#> SRR945232     2  0.0162      0.781 0.000 0.996 0.000 0.004 NA
#> SRR945233     2  0.0162      0.781 0.000 0.996 0.000 0.004 NA
#> SRR945234     2  0.0162      0.781 0.000 0.996 0.000 0.004 NA
#> SRR945235     2  0.0162      0.781 0.000 0.996 0.000 0.004 NA
#> SRR945236     2  0.1106      0.776 0.000 0.964 0.000 0.024 NA
#> SRR945237     2  0.1106      0.776 0.000 0.964 0.000 0.024 NA
#> SRR945238     3  0.3123      0.922 0.004 0.068 0.876 0.012 NA
#> SRR945239     3  0.3123      0.922 0.004 0.068 0.876 0.012 NA
#> SRR945240     3  0.2804      0.930 0.004 0.068 0.892 0.016 NA
#> SRR945241     3  0.2804      0.930 0.004 0.068 0.892 0.016 NA
#> SRR945242     3  0.4843      0.926 0.004 0.068 0.776 0.044 NA
#> SRR945243     3  0.4843      0.926 0.004 0.068 0.776 0.044 NA
#> SRR945244     3  0.4790      0.926 0.004 0.068 0.784 0.056 NA
#> SRR945245     3  0.4790      0.926 0.004 0.068 0.784 0.056 NA
#> SRR945246     3  0.4638      0.930 0.004 0.068 0.792 0.044 NA
#> SRR945247     3  0.4638      0.930 0.004 0.068 0.792 0.044 NA
#> SRR945248     3  0.3375      0.919 0.004 0.068 0.864 0.016 NA
#> SRR945249     3  0.3375      0.919 0.004 0.068 0.864 0.016 NA

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4 p5    p6
#> SRR945190     1  0.0363      0.938 0.988 0.012 0.000 0.000 NA 0.000
#> SRR945191     1  0.0363      0.938 0.988 0.012 0.000 0.000 NA 0.000
#> SRR945192     1  0.0363      0.938 0.988 0.012 0.000 0.000 NA 0.000
#> SRR945193     1  0.0363      0.938 0.988 0.012 0.000 0.000 NA 0.000
#> SRR945194     1  0.4080      0.735 0.724 0.008 0.000 0.036 NA 0.000
#> SRR945195     1  0.4080      0.735 0.724 0.008 0.000 0.036 NA 0.000
#> SRR945196     1  0.0603      0.934 0.980 0.004 0.000 0.000 NA 0.000
#> SRR945197     1  0.0603      0.934 0.980 0.004 0.000 0.000 NA 0.000
#> SRR945200     1  0.1152      0.924 0.952 0.004 0.000 0.000 NA 0.000
#> SRR945201     1  0.1152      0.924 0.952 0.004 0.000 0.000 NA 0.000
#> SRR945202     4  0.5598      0.854 0.160 0.080 0.008 0.672 NA 0.000
#> SRR945203     4  0.5598      0.854 0.160 0.080 0.008 0.672 NA 0.000
#> SRR945204     4  0.5588      0.852 0.160 0.068 0.008 0.672 NA 0.000
#> SRR945205     4  0.5588      0.852 0.160 0.068 0.008 0.672 NA 0.000
#> SRR945198     1  0.0000      0.938 1.000 0.000 0.000 0.000 NA 0.000
#> SRR945199     1  0.0000      0.938 1.000 0.000 0.000 0.000 NA 0.000
#> SRR945206     4  0.5096      0.840 0.160 0.036 0.020 0.716 NA 0.000
#> SRR945207     4  0.5096      0.840 0.160 0.036 0.020 0.716 NA 0.000
#> SRR945208     4  0.2848      0.861 0.160 0.004 0.000 0.828 NA 0.000
#> SRR945209     4  0.2848      0.861 0.160 0.004 0.000 0.828 NA 0.000
#> SRR945212     4  0.2848      0.861 0.160 0.004 0.000 0.828 NA 0.000
#> SRR945213     4  0.2848      0.861 0.160 0.004 0.000 0.828 NA 0.000
#> SRR945214     2  0.4569      0.881 0.000 0.624 0.000 0.008 NA 0.332
#> SRR945215     2  0.4569      0.881 0.000 0.624 0.000 0.008 NA 0.332
#> SRR945210     4  0.7594      0.663 0.184 0.240 0.000 0.380 NA 0.004
#> SRR945211     4  0.7598      0.663 0.184 0.236 0.000 0.380 NA 0.004
#> SRR945218     2  0.5108      0.883 0.000 0.576 0.000 0.036 NA 0.356
#> SRR945219     2  0.5108      0.883 0.000 0.576 0.000 0.036 NA 0.356
#> SRR945216     2  0.4569      0.881 0.000 0.624 0.000 0.008 NA 0.332
#> SRR945217     2  0.4569      0.881 0.000 0.624 0.000 0.008 NA 0.332
#> SRR945220     2  0.5465      0.865 0.000 0.564 0.000 0.016 NA 0.324
#> SRR945221     2  0.5465      0.865 0.000 0.564 0.000 0.016 NA 0.324
#> SRR945222     2  0.4810      0.877 0.000 0.588 0.000 0.040 NA 0.360
#> SRR945223     2  0.4810      0.877 0.000 0.588 0.000 0.040 NA 0.360
#> SRR945224     2  0.5422      0.866 0.000 0.564 0.000 0.012 NA 0.324
#> SRR945225     2  0.5422      0.866 0.000 0.564 0.000 0.012 NA 0.324
#> SRR945226     6  0.1655      0.876 0.000 0.052 0.000 0.008 NA 0.932
#> SRR945227     6  0.1655      0.876 0.000 0.052 0.000 0.008 NA 0.932
#> SRR945228     6  0.1594      0.873 0.000 0.000 0.000 0.016 NA 0.932
#> SRR945229     6  0.1594      0.873 0.000 0.000 0.000 0.016 NA 0.932
#> SRR945230     6  0.3689      0.773 0.000 0.024 0.000 0.040 NA 0.804
#> SRR945231     6  0.3689      0.773 0.000 0.024 0.000 0.040 NA 0.804
#> SRR945232     6  0.1655      0.876 0.000 0.052 0.000 0.008 NA 0.932
#> SRR945233     6  0.1655      0.876 0.000 0.052 0.000 0.008 NA 0.932
#> SRR945234     6  0.1398      0.878 0.000 0.052 0.000 0.000 NA 0.940
#> SRR945235     6  0.1398      0.878 0.000 0.052 0.000 0.000 NA 0.940
#> SRR945236     6  0.1528      0.875 0.000 0.000 0.000 0.016 NA 0.936
#> SRR945237     6  0.1528      0.875 0.000 0.000 0.000 0.016 NA 0.936
#> SRR945238     3  0.3755      0.897 0.000 0.012 0.768 0.000 NA 0.028
#> SRR945239     3  0.3755      0.897 0.000 0.012 0.768 0.000 NA 0.028
#> SRR945240     3  0.2926      0.910 0.000 0.000 0.844 0.004 NA 0.028
#> SRR945241     3  0.2926      0.910 0.000 0.000 0.844 0.004 NA 0.028
#> SRR945242     3  0.2018      0.905 0.000 0.004 0.924 0.016 NA 0.028
#> SRR945243     3  0.2018      0.905 0.000 0.004 0.924 0.016 NA 0.028
#> SRR945244     3  0.2681      0.898 0.000 0.000 0.880 0.020 NA 0.028
#> SRR945245     3  0.2681      0.898 0.000 0.000 0.880 0.020 NA 0.028
#> SRR945246     3  0.1401      0.910 0.000 0.004 0.948 0.020 NA 0.028
#> SRR945247     3  0.1426      0.910 0.000 0.008 0.948 0.016 NA 0.028
#> SRR945248     3  0.3640      0.894 0.000 0.000 0.764 0.004 NA 0.028
#> SRR945249     3  0.3640      0.894 0.000 0.000 0.764 0.004 NA 0.028

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

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

collect_plots(res)

plot of chunk CV-skmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4886 0.512   0.512
#> 3 3 1.000           0.998       0.995         0.3308 0.837   0.682
#> 4 4 1.000           0.999       0.998         0.1263 0.919   0.767
#> 5 5 0.915           0.949       0.945         0.0351 0.989   0.958
#> 6 6 0.916           0.876       0.920         0.0436 0.975   0.903

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette p1 p2
#> SRR945190     1       0          1  1  0
#> SRR945191     1       0          1  1  0
#> SRR945192     1       0          1  1  0
#> SRR945193     1       0          1  1  0
#> SRR945194     1       0          1  1  0
#> SRR945195     1       0          1  1  0
#> SRR945196     1       0          1  1  0
#> SRR945197     1       0          1  1  0
#> SRR945200     1       0          1  1  0
#> SRR945201     1       0          1  1  0
#> SRR945202     1       0          1  1  0
#> SRR945203     1       0          1  1  0
#> SRR945204     1       0          1  1  0
#> SRR945205     1       0          1  1  0
#> SRR945198     1       0          1  1  0
#> SRR945199     1       0          1  1  0
#> SRR945206     1       0          1  1  0
#> SRR945207     1       0          1  1  0
#> SRR945208     1       0          1  1  0
#> SRR945209     1       0          1  1  0
#> SRR945212     1       0          1  1  0
#> SRR945213     1       0          1  1  0
#> SRR945214     2       0          1  0  1
#> SRR945215     2       0          1  0  1
#> SRR945210     1       0          1  1  0
#> SRR945211     1       0          1  1  0
#> SRR945218     2       0          1  0  1
#> SRR945219     2       0          1  0  1
#> SRR945216     2       0          1  0  1
#> SRR945217     2       0          1  0  1
#> SRR945220     2       0          1  0  1
#> SRR945221     2       0          1  0  1
#> SRR945222     2       0          1  0  1
#> SRR945223     2       0          1  0  1
#> SRR945224     2       0          1  0  1
#> SRR945225     2       0          1  0  1
#> SRR945226     2       0          1  0  1
#> SRR945227     2       0          1  0  1
#> SRR945228     2       0          1  0  1
#> SRR945229     2       0          1  0  1
#> SRR945230     2       0          1  0  1
#> SRR945231     2       0          1  0  1
#> SRR945232     2       0          1  0  1
#> SRR945233     2       0          1  0  1
#> SRR945234     2       0          1  0  1
#> SRR945235     2       0          1  0  1
#> SRR945236     2       0          1  0  1
#> SRR945237     2       0          1  0  1
#> SRR945238     2       0          1  0  1
#> SRR945239     2       0          1  0  1
#> SRR945240     2       0          1  0  1
#> SRR945241     2       0          1  0  1
#> SRR945242     2       0          1  0  1
#> SRR945243     2       0          1  0  1
#> SRR945244     2       0          1  0  1
#> SRR945245     2       0          1  0  1
#> SRR945246     2       0          1  0  1
#> SRR945247     2       0          1  0  1
#> SRR945248     2       0          1  0  1
#> SRR945249     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
#> SRR945190     1  0.0592      0.995 0.988 0.000 0.012
#> SRR945191     1  0.0592      0.995 0.988 0.000 0.012
#> SRR945192     1  0.0592      0.995 0.988 0.000 0.012
#> SRR945193     1  0.0592      0.995 0.988 0.000 0.012
#> SRR945194     1  0.0592      0.995 0.988 0.000 0.012
#> SRR945195     1  0.0592      0.995 0.988 0.000 0.012
#> SRR945196     1  0.0592      0.995 0.988 0.000 0.012
#> SRR945197     1  0.0592      0.995 0.988 0.000 0.012
#> SRR945200     1  0.0592      0.995 0.988 0.000 0.012
#> SRR945201     1  0.0592      0.995 0.988 0.000 0.012
#> SRR945202     1  0.0000      0.995 1.000 0.000 0.000
#> SRR945203     1  0.0000      0.995 1.000 0.000 0.000
#> SRR945204     1  0.0000      0.995 1.000 0.000 0.000
#> SRR945205     1  0.0000      0.995 1.000 0.000 0.000
#> SRR945198     1  0.0592      0.995 0.988 0.000 0.012
#> SRR945199     1  0.0592      0.995 0.988 0.000 0.012
#> SRR945206     1  0.0000      0.995 1.000 0.000 0.000
#> SRR945207     1  0.0000      0.995 1.000 0.000 0.000
#> SRR945208     1  0.0000      0.995 1.000 0.000 0.000
#> SRR945209     1  0.0000      0.995 1.000 0.000 0.000
#> SRR945212     1  0.0000      0.995 1.000 0.000 0.000
#> SRR945213     1  0.0000      0.995 1.000 0.000 0.000
#> SRR945214     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945215     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945210     1  0.0000      0.995 1.000 0.000 0.000
#> SRR945211     1  0.0000      0.995 1.000 0.000 0.000
#> SRR945218     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945219     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945216     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945217     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945220     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945221     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945222     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945223     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945224     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945225     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945226     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945227     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945228     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945229     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945230     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945231     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945232     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945233     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945234     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945235     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945236     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945237     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945238     3  0.0592      1.000 0.000 0.012 0.988
#> SRR945239     3  0.0592      1.000 0.000 0.012 0.988
#> SRR945240     3  0.0592      1.000 0.000 0.012 0.988
#> SRR945241     3  0.0592      1.000 0.000 0.012 0.988
#> SRR945242     3  0.0592      1.000 0.000 0.012 0.988
#> SRR945243     3  0.0592      1.000 0.000 0.012 0.988
#> SRR945244     3  0.0592      1.000 0.000 0.012 0.988
#> SRR945245     3  0.0592      1.000 0.000 0.012 0.988
#> SRR945246     3  0.0592      1.000 0.000 0.012 0.988
#> SRR945247     3  0.0592      1.000 0.000 0.012 0.988
#> SRR945248     3  0.0592      1.000 0.000 0.012 0.988
#> SRR945249     3  0.0592      1.000 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
#> SRR945190     1  0.0188      0.999 0.996 0.000  0 0.004
#> SRR945191     1  0.0188      0.999 0.996 0.000  0 0.004
#> SRR945192     1  0.0188      0.999 0.996 0.000  0 0.004
#> SRR945193     1  0.0188      0.999 0.996 0.000  0 0.004
#> SRR945194     1  0.0336      0.996 0.992 0.000  0 0.008
#> SRR945195     1  0.0336      0.996 0.992 0.000  0 0.008
#> SRR945196     1  0.0188      0.999 0.996 0.000  0 0.004
#> SRR945197     1  0.0188      0.999 0.996 0.000  0 0.004
#> SRR945200     1  0.0188      0.999 0.996 0.000  0 0.004
#> SRR945201     1  0.0188      0.999 0.996 0.000  0 0.004
#> SRR945202     4  0.0000      1.000 0.000 0.000  0 1.000
#> SRR945203     4  0.0000      1.000 0.000 0.000  0 1.000
#> SRR945204     4  0.0000      1.000 0.000 0.000  0 1.000
#> SRR945205     4  0.0000      1.000 0.000 0.000  0 1.000
#> SRR945198     1  0.0188      0.999 0.996 0.000  0 0.004
#> SRR945199     1  0.0188      0.999 0.996 0.000  0 0.004
#> SRR945206     4  0.0000      1.000 0.000 0.000  0 1.000
#> SRR945207     4  0.0000      1.000 0.000 0.000  0 1.000
#> SRR945208     4  0.0000      1.000 0.000 0.000  0 1.000
#> SRR945209     4  0.0000      1.000 0.000 0.000  0 1.000
#> SRR945212     4  0.0000      1.000 0.000 0.000  0 1.000
#> SRR945213     4  0.0000      1.000 0.000 0.000  0 1.000
#> SRR945214     2  0.0000      0.998 0.000 1.000  0 0.000
#> SRR945215     2  0.0000      0.998 0.000 1.000  0 0.000
#> SRR945210     4  0.0000      1.000 0.000 0.000  0 1.000
#> SRR945211     4  0.0000      1.000 0.000 0.000  0 1.000
#> SRR945218     2  0.0000      0.998 0.000 1.000  0 0.000
#> SRR945219     2  0.0000      0.998 0.000 1.000  0 0.000
#> SRR945216     2  0.0000      0.998 0.000 1.000  0 0.000
#> SRR945217     2  0.0000      0.998 0.000 1.000  0 0.000
#> SRR945220     2  0.0000      0.998 0.000 1.000  0 0.000
#> SRR945221     2  0.0000      0.998 0.000 1.000  0 0.000
#> SRR945222     2  0.0000      0.998 0.000 1.000  0 0.000
#> SRR945223     2  0.0000      0.998 0.000 1.000  0 0.000
#> SRR945224     2  0.0000      0.998 0.000 1.000  0 0.000
#> SRR945225     2  0.0000      0.998 0.000 1.000  0 0.000
#> SRR945226     2  0.0188      0.998 0.004 0.996  0 0.000
#> SRR945227     2  0.0188      0.998 0.004 0.996  0 0.000
#> SRR945228     2  0.0188      0.998 0.004 0.996  0 0.000
#> SRR945229     2  0.0188      0.998 0.004 0.996  0 0.000
#> SRR945230     2  0.0188      0.998 0.004 0.996  0 0.000
#> SRR945231     2  0.0188      0.998 0.004 0.996  0 0.000
#> SRR945232     2  0.0188      0.998 0.004 0.996  0 0.000
#> SRR945233     2  0.0188      0.998 0.004 0.996  0 0.000
#> SRR945234     2  0.0188      0.998 0.004 0.996  0 0.000
#> SRR945235     2  0.0188      0.998 0.004 0.996  0 0.000
#> SRR945236     2  0.0188      0.998 0.004 0.996  0 0.000
#> SRR945237     2  0.0188      0.998 0.004 0.996  0 0.000
#> SRR945238     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR945239     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR945240     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR945241     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR945242     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR945243     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR945244     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR945245     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR945246     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR945247     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR945248     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR945249     3  0.0000      1.000 0.000 0.000  1 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette p1    p2 p3    p4    p5
#> SRR945190     1   0.000      1.000  1 0.000  0 0.000 0.000
#> SRR945191     1   0.000      1.000  1 0.000  0 0.000 0.000
#> SRR945192     1   0.000      1.000  1 0.000  0 0.000 0.000
#> SRR945193     1   0.000      1.000  1 0.000  0 0.000 0.000
#> SRR945194     1   0.000      1.000  1 0.000  0 0.000 0.000
#> SRR945195     1   0.000      1.000  1 0.000  0 0.000 0.000
#> SRR945196     1   0.000      1.000  1 0.000  0 0.000 0.000
#> SRR945197     1   0.000      1.000  1 0.000  0 0.000 0.000
#> SRR945200     1   0.000      1.000  1 0.000  0 0.000 0.000
#> SRR945201     1   0.000      1.000  1 0.000  0 0.000 0.000
#> SRR945202     4   0.104      0.956  0 0.000  0 0.960 0.040
#> SRR945203     4   0.104      0.956  0 0.000  0 0.960 0.040
#> SRR945204     4   0.104      0.956  0 0.000  0 0.960 0.040
#> SRR945205     4   0.104      0.956  0 0.000  0 0.960 0.040
#> SRR945198     1   0.000      1.000  1 0.000  0 0.000 0.000
#> SRR945199     1   0.000      1.000  1 0.000  0 0.000 0.000
#> SRR945206     4   0.000      0.972  0 0.000  0 1.000 0.000
#> SRR945207     4   0.000      0.972  0 0.000  0 1.000 0.000
#> SRR945208     4   0.000      0.972  0 0.000  0 1.000 0.000
#> SRR945209     4   0.000      0.972  0 0.000  0 1.000 0.000
#> SRR945212     4   0.000      0.972  0 0.000  0 1.000 0.000
#> SRR945213     4   0.000      0.972  0 0.000  0 1.000 0.000
#> SRR945214     2   0.000      0.903  0 1.000  0 0.000 0.000
#> SRR945215     2   0.000      0.903  0 1.000  0 0.000 0.000
#> SRR945210     5   0.402      1.000  0 0.000  0 0.348 0.652
#> SRR945211     5   0.402      1.000  0 0.000  0 0.348 0.652
#> SRR945218     2   0.000      0.903  0 1.000  0 0.000 0.000
#> SRR945219     2   0.000      0.903  0 1.000  0 0.000 0.000
#> SRR945216     2   0.000      0.903  0 1.000  0 0.000 0.000
#> SRR945217     2   0.000      0.903  0 1.000  0 0.000 0.000
#> SRR945220     2   0.000      0.903  0 1.000  0 0.000 0.000
#> SRR945221     2   0.000      0.903  0 1.000  0 0.000 0.000
#> SRR945222     2   0.000      0.903  0 1.000  0 0.000 0.000
#> SRR945223     2   0.000      0.903  0 1.000  0 0.000 0.000
#> SRR945224     2   0.000      0.903  0 1.000  0 0.000 0.000
#> SRR945225     2   0.000      0.903  0 1.000  0 0.000 0.000
#> SRR945226     2   0.277      0.896  0 0.836  0 0.000 0.164
#> SRR945227     2   0.277      0.896  0 0.836  0 0.000 0.164
#> SRR945228     2   0.281      0.894  0 0.832  0 0.000 0.168
#> SRR945229     2   0.281      0.894  0 0.832  0 0.000 0.168
#> SRR945230     2   0.402      0.742  0 0.652  0 0.000 0.348
#> SRR945231     2   0.402      0.742  0 0.652  0 0.000 0.348
#> SRR945232     2   0.277      0.896  0 0.836  0 0.000 0.164
#> SRR945233     2   0.277      0.896  0 0.836  0 0.000 0.164
#> SRR945234     2   0.277      0.896  0 0.836  0 0.000 0.164
#> SRR945235     2   0.277      0.896  0 0.836  0 0.000 0.164
#> SRR945236     2   0.281      0.894  0 0.832  0 0.000 0.168
#> SRR945237     2   0.281      0.894  0 0.832  0 0.000 0.168
#> SRR945238     3   0.000      1.000  0 0.000  1 0.000 0.000
#> SRR945239     3   0.000      1.000  0 0.000  1 0.000 0.000
#> SRR945240     3   0.000      1.000  0 0.000  1 0.000 0.000
#> SRR945241     3   0.000      1.000  0 0.000  1 0.000 0.000
#> SRR945242     3   0.000      1.000  0 0.000  1 0.000 0.000
#> SRR945243     3   0.000      1.000  0 0.000  1 0.000 0.000
#> SRR945244     3   0.000      1.000  0 0.000  1 0.000 0.000
#> SRR945245     3   0.000      1.000  0 0.000  1 0.000 0.000
#> SRR945246     3   0.000      1.000  0 0.000  1 0.000 0.000
#> SRR945247     3   0.000      1.000  0 0.000  1 0.000 0.000
#> SRR945248     3   0.000      1.000  0 0.000  1 0.000 0.000
#> SRR945249     3   0.000      1.000  0 0.000  1 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
#> SRR945190     1  0.0000      0.999 1.000 0.000  0 0.000 0.000 0.000
#> SRR945191     1  0.0000      0.999 1.000 0.000  0 0.000 0.000 0.000
#> SRR945192     1  0.0000      0.999 1.000 0.000  0 0.000 0.000 0.000
#> SRR945193     1  0.0000      0.999 1.000 0.000  0 0.000 0.000 0.000
#> SRR945194     1  0.0146      0.996 0.996 0.000  0 0.000 0.000 0.004
#> SRR945195     1  0.0146      0.996 0.996 0.000  0 0.000 0.000 0.004
#> SRR945196     1  0.0000      0.999 1.000 0.000  0 0.000 0.000 0.000
#> SRR945197     1  0.0000      0.999 1.000 0.000  0 0.000 0.000 0.000
#> SRR945200     1  0.0000      0.999 1.000 0.000  0 0.000 0.000 0.000
#> SRR945201     1  0.0000      0.999 1.000 0.000  0 0.000 0.000 0.000
#> SRR945202     4  0.1829      0.938 0.000 0.000  0 0.920 0.056 0.024
#> SRR945203     4  0.1829      0.938 0.000 0.000  0 0.920 0.056 0.024
#> SRR945204     4  0.1829      0.938 0.000 0.000  0 0.920 0.056 0.024
#> SRR945205     4  0.1829      0.938 0.000 0.000  0 0.920 0.056 0.024
#> SRR945198     1  0.0000      0.999 1.000 0.000  0 0.000 0.000 0.000
#> SRR945199     1  0.0000      0.999 1.000 0.000  0 0.000 0.000 0.000
#> SRR945206     4  0.0865      0.939 0.000 0.000  0 0.964 0.000 0.036
#> SRR945207     4  0.0865      0.939 0.000 0.000  0 0.964 0.000 0.036
#> SRR945208     4  0.0000      0.954 0.000 0.000  0 1.000 0.000 0.000
#> SRR945209     4  0.0000      0.954 0.000 0.000  0 1.000 0.000 0.000
#> SRR945212     4  0.0000      0.954 0.000 0.000  0 1.000 0.000 0.000
#> SRR945213     4  0.0000      0.954 0.000 0.000  0 1.000 0.000 0.000
#> SRR945214     2  0.3706      0.755 0.000 0.620  0 0.000 0.380 0.000
#> SRR945215     2  0.3706      0.755 0.000 0.620  0 0.000 0.380 0.000
#> SRR945210     5  0.4076      1.000 0.000 0.000  0 0.016 0.620 0.364
#> SRR945211     5  0.4076      1.000 0.000 0.000  0 0.016 0.620 0.364
#> SRR945218     2  0.3706      0.755 0.000 0.620  0 0.000 0.380 0.000
#> SRR945219     2  0.3706      0.755 0.000 0.620  0 0.000 0.380 0.000
#> SRR945216     2  0.3706      0.755 0.000 0.620  0 0.000 0.380 0.000
#> SRR945217     2  0.3706      0.755 0.000 0.620  0 0.000 0.380 0.000
#> SRR945220     2  0.3706      0.755 0.000 0.620  0 0.000 0.380 0.000
#> SRR945221     2  0.3706      0.755 0.000 0.620  0 0.000 0.380 0.000
#> SRR945222     2  0.3706      0.755 0.000 0.620  0 0.000 0.380 0.000
#> SRR945223     2  0.3706      0.755 0.000 0.620  0 0.000 0.380 0.000
#> SRR945224     2  0.3706      0.755 0.000 0.620  0 0.000 0.380 0.000
#> SRR945225     2  0.3706      0.755 0.000 0.620  0 0.000 0.380 0.000
#> SRR945226     2  0.0000      0.620 0.000 1.000  0 0.000 0.000 0.000
#> SRR945227     2  0.0000      0.620 0.000 1.000  0 0.000 0.000 0.000
#> SRR945228     2  0.0713      0.587 0.000 0.972  0 0.000 0.000 0.028
#> SRR945229     2  0.0713      0.587 0.000 0.972  0 0.000 0.000 0.028
#> SRR945230     6  0.3756      1.000 0.000 0.400  0 0.000 0.000 0.600
#> SRR945231     6  0.3756      1.000 0.000 0.400  0 0.000 0.000 0.600
#> SRR945232     2  0.0000      0.620 0.000 1.000  0 0.000 0.000 0.000
#> SRR945233     2  0.0000      0.620 0.000 1.000  0 0.000 0.000 0.000
#> SRR945234     2  0.0000      0.620 0.000 1.000  0 0.000 0.000 0.000
#> SRR945235     2  0.0000      0.620 0.000 1.000  0 0.000 0.000 0.000
#> SRR945236     2  0.0713      0.587 0.000 0.972  0 0.000 0.000 0.028
#> SRR945237     2  0.0713      0.587 0.000 0.972  0 0.000 0.000 0.028
#> SRR945238     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR945239     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR945240     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR945241     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR945242     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR945243     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR945244     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR945245     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR945246     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR945247     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR945248     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR945249     3  0.0000      1.000 0.000 0.000  1 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 15912 rows and 60 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#>   Subgroups are detected by 'pam' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 5.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk CV-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.984       0.988         0.4809 0.512   0.512
#> 3 3 1.000           0.995       0.992         0.3496 0.837   0.682
#> 4 4 1.000           0.973       0.987         0.1230 0.919   0.767
#> 5 5 0.981           0.963       0.975         0.0287 0.980   0.924
#> 6 6 1.000           0.990       0.995         0.0100 0.995   0.982

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
#> SRR945190     1   0.000      0.970 1.000 0.000
#> SRR945191     1   0.000      0.970 1.000 0.000
#> SRR945192     1   0.000      0.970 1.000 0.000
#> SRR945193     1   0.000      0.970 1.000 0.000
#> SRR945194     1   0.000      0.970 1.000 0.000
#> SRR945195     1   0.000      0.970 1.000 0.000
#> SRR945196     1   0.000      0.970 1.000 0.000
#> SRR945197     1   0.000      0.970 1.000 0.000
#> SRR945200     1   0.000      0.970 1.000 0.000
#> SRR945201     1   0.000      0.970 1.000 0.000
#> SRR945202     1   0.260      0.966 0.956 0.044
#> SRR945203     1   0.260      0.966 0.956 0.044
#> SRR945204     1   0.278      0.956 0.952 0.048
#> SRR945205     1   0.278      0.956 0.952 0.048
#> SRR945198     1   0.000      0.970 1.000 0.000
#> SRR945199     1   0.000      0.970 1.000 0.000
#> SRR945206     1   0.260      0.966 0.956 0.044
#> SRR945207     1   0.260      0.966 0.956 0.044
#> SRR945208     1   0.260      0.966 0.956 0.044
#> SRR945209     1   0.260      0.966 0.956 0.044
#> SRR945212     1   0.260      0.966 0.956 0.044
#> SRR945213     1   0.242      0.966 0.960 0.040
#> SRR945214     2   0.000      1.000 0.000 1.000
#> SRR945215     2   0.000      1.000 0.000 1.000
#> SRR945210     1   0.552      0.889 0.872 0.128
#> SRR945211     1   0.552      0.889 0.872 0.128
#> SRR945218     2   0.000      1.000 0.000 1.000
#> SRR945219     2   0.000      1.000 0.000 1.000
#> SRR945216     2   0.000      1.000 0.000 1.000
#> SRR945217     2   0.000      1.000 0.000 1.000
#> SRR945220     2   0.000      1.000 0.000 1.000
#> SRR945221     2   0.000      1.000 0.000 1.000
#> SRR945222     2   0.000      1.000 0.000 1.000
#> SRR945223     2   0.000      1.000 0.000 1.000
#> SRR945224     2   0.000      1.000 0.000 1.000
#> SRR945225     2   0.000      1.000 0.000 1.000
#> SRR945226     2   0.000      1.000 0.000 1.000
#> SRR945227     2   0.000      1.000 0.000 1.000
#> SRR945228     2   0.000      1.000 0.000 1.000
#> SRR945229     2   0.000      1.000 0.000 1.000
#> SRR945230     2   0.000      1.000 0.000 1.000
#> SRR945231     2   0.000      1.000 0.000 1.000
#> SRR945232     2   0.000      1.000 0.000 1.000
#> SRR945233     2   0.000      1.000 0.000 1.000
#> SRR945234     2   0.000      1.000 0.000 1.000
#> SRR945235     2   0.000      1.000 0.000 1.000
#> SRR945236     2   0.000      1.000 0.000 1.000
#> SRR945237     2   0.000      1.000 0.000 1.000
#> SRR945238     2   0.000      1.000 0.000 1.000
#> SRR945239     2   0.000      1.000 0.000 1.000
#> SRR945240     2   0.000      1.000 0.000 1.000
#> SRR945241     2   0.000      1.000 0.000 1.000
#> SRR945242     2   0.000      1.000 0.000 1.000
#> SRR945243     2   0.000      1.000 0.000 1.000
#> SRR945244     2   0.000      1.000 0.000 1.000
#> SRR945245     2   0.000      1.000 0.000 1.000
#> SRR945246     2   0.000      1.000 0.000 1.000
#> SRR945247     2   0.000      1.000 0.000 1.000
#> SRR945248     2   0.000      1.000 0.000 1.000
#> SRR945249     2   0.000      1.000 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2   p3
#> SRR945190     1  0.0000      0.990 1.000 0.000 0.00
#> SRR945191     1  0.0000      0.990 1.000 0.000 0.00
#> SRR945192     1  0.0000      0.990 1.000 0.000 0.00
#> SRR945193     1  0.0000      0.990 1.000 0.000 0.00
#> SRR945194     1  0.0000      0.990 1.000 0.000 0.00
#> SRR945195     1  0.0000      0.990 1.000 0.000 0.00
#> SRR945196     1  0.0000      0.990 1.000 0.000 0.00
#> SRR945197     1  0.0000      0.990 1.000 0.000 0.00
#> SRR945200     1  0.0000      0.990 1.000 0.000 0.00
#> SRR945201     1  0.0000      0.990 1.000 0.000 0.00
#> SRR945202     1  0.0892      0.989 0.980 0.000 0.02
#> SRR945203     1  0.0892      0.989 0.980 0.000 0.02
#> SRR945204     1  0.0892      0.989 0.980 0.000 0.02
#> SRR945205     1  0.0892      0.989 0.980 0.000 0.02
#> SRR945198     1  0.0000      0.990 1.000 0.000 0.00
#> SRR945199     1  0.0000      0.990 1.000 0.000 0.00
#> SRR945206     1  0.0892      0.989 0.980 0.000 0.02
#> SRR945207     1  0.0892      0.989 0.980 0.000 0.02
#> SRR945208     1  0.0892      0.989 0.980 0.000 0.02
#> SRR945209     1  0.0892      0.989 0.980 0.000 0.02
#> SRR945212     1  0.0892      0.989 0.980 0.000 0.02
#> SRR945213     1  0.0892      0.989 0.980 0.000 0.02
#> SRR945214     2  0.0000      1.000 0.000 1.000 0.00
#> SRR945215     2  0.0000      1.000 0.000 1.000 0.00
#> SRR945210     1  0.1163      0.969 0.972 0.028 0.00
#> SRR945211     1  0.1289      0.965 0.968 0.032 0.00
#> SRR945218     2  0.0000      1.000 0.000 1.000 0.00
#> SRR945219     2  0.0000      1.000 0.000 1.000 0.00
#> SRR945216     2  0.0000      1.000 0.000 1.000 0.00
#> SRR945217     2  0.0000      1.000 0.000 1.000 0.00
#> SRR945220     2  0.0000      1.000 0.000 1.000 0.00
#> SRR945221     2  0.0000      1.000 0.000 1.000 0.00
#> SRR945222     2  0.0000      1.000 0.000 1.000 0.00
#> SRR945223     2  0.0000      1.000 0.000 1.000 0.00
#> SRR945224     2  0.0000      1.000 0.000 1.000 0.00
#> SRR945225     2  0.0000      1.000 0.000 1.000 0.00
#> SRR945226     2  0.0000      1.000 0.000 1.000 0.00
#> SRR945227     2  0.0000      1.000 0.000 1.000 0.00
#> SRR945228     2  0.0000      1.000 0.000 1.000 0.00
#> SRR945229     2  0.0000      1.000 0.000 1.000 0.00
#> SRR945230     2  0.0000      1.000 0.000 1.000 0.00
#> SRR945231     2  0.0000      1.000 0.000 1.000 0.00
#> SRR945232     2  0.0000      1.000 0.000 1.000 0.00
#> SRR945233     2  0.0000      1.000 0.000 1.000 0.00
#> SRR945234     2  0.0000      1.000 0.000 1.000 0.00
#> SRR945235     2  0.0000      1.000 0.000 1.000 0.00
#> SRR945236     2  0.0000      1.000 0.000 1.000 0.00
#> SRR945237     2  0.0000      1.000 0.000 1.000 0.00
#> SRR945238     3  0.0892      1.000 0.000 0.020 0.98
#> SRR945239     3  0.0892      1.000 0.000 0.020 0.98
#> SRR945240     3  0.0892      1.000 0.000 0.020 0.98
#> SRR945241     3  0.0892      1.000 0.000 0.020 0.98
#> SRR945242     3  0.0892      1.000 0.000 0.020 0.98
#> SRR945243     3  0.0892      1.000 0.000 0.020 0.98
#> SRR945244     3  0.0892      1.000 0.000 0.020 0.98
#> SRR945245     3  0.0892      1.000 0.000 0.020 0.98
#> SRR945246     3  0.0892      1.000 0.000 0.020 0.98
#> SRR945247     3  0.0892      1.000 0.000 0.020 0.98
#> SRR945248     3  0.0892      1.000 0.000 0.020 0.98
#> SRR945249     3  0.0892      1.000 0.000 0.020 0.98

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1  p2 p3    p4
#> SRR945190     1   0.000      1.000 1.000 0.0  0 0.000
#> SRR945191     1   0.000      1.000 1.000 0.0  0 0.000
#> SRR945192     1   0.000      1.000 1.000 0.0  0 0.000
#> SRR945193     1   0.000      1.000 1.000 0.0  0 0.000
#> SRR945194     1   0.000      1.000 1.000 0.0  0 0.000
#> SRR945195     1   0.000      1.000 1.000 0.0  0 0.000
#> SRR945196     1   0.000      1.000 1.000 0.0  0 0.000
#> SRR945197     1   0.000      1.000 1.000 0.0  0 0.000
#> SRR945200     1   0.000      1.000 1.000 0.0  0 0.000
#> SRR945201     1   0.000      1.000 1.000 0.0  0 0.000
#> SRR945202     4   0.000      0.930 0.000 0.0  0 1.000
#> SRR945203     4   0.000      0.930 0.000 0.0  0 1.000
#> SRR945204     4   0.000      0.930 0.000 0.0  0 1.000
#> SRR945205     4   0.000      0.930 0.000 0.0  0 1.000
#> SRR945198     1   0.000      1.000 1.000 0.0  0 0.000
#> SRR945199     1   0.000      1.000 1.000 0.0  0 0.000
#> SRR945206     4   0.000      0.930 0.000 0.0  0 1.000
#> SRR945207     4   0.000      0.930 0.000 0.0  0 1.000
#> SRR945208     4   0.000      0.930 0.000 0.0  0 1.000
#> SRR945209     4   0.000      0.930 0.000 0.0  0 1.000
#> SRR945212     4   0.000      0.930 0.000 0.0  0 1.000
#> SRR945213     4   0.000      0.930 0.000 0.0  0 1.000
#> SRR945214     2   0.000      1.000 0.000 1.0  0 0.000
#> SRR945215     2   0.000      1.000 0.000 1.0  0 0.000
#> SRR945210     4   0.682      0.552 0.196 0.2  0 0.604
#> SRR945211     4   0.685      0.547 0.200 0.2  0 0.600
#> SRR945218     2   0.000      1.000 0.000 1.0  0 0.000
#> SRR945219     2   0.000      1.000 0.000 1.0  0 0.000
#> SRR945216     2   0.000      1.000 0.000 1.0  0 0.000
#> SRR945217     2   0.000      1.000 0.000 1.0  0 0.000
#> SRR945220     2   0.000      1.000 0.000 1.0  0 0.000
#> SRR945221     2   0.000      1.000 0.000 1.0  0 0.000
#> SRR945222     2   0.000      1.000 0.000 1.0  0 0.000
#> SRR945223     2   0.000      1.000 0.000 1.0  0 0.000
#> SRR945224     2   0.000      1.000 0.000 1.0  0 0.000
#> SRR945225     2   0.000      1.000 0.000 1.0  0 0.000
#> SRR945226     2   0.000      1.000 0.000 1.0  0 0.000
#> SRR945227     2   0.000      1.000 0.000 1.0  0 0.000
#> SRR945228     2   0.000      1.000 0.000 1.0  0 0.000
#> SRR945229     2   0.000      1.000 0.000 1.0  0 0.000
#> SRR945230     2   0.000      1.000 0.000 1.0  0 0.000
#> SRR945231     2   0.000      1.000 0.000 1.0  0 0.000
#> SRR945232     2   0.000      1.000 0.000 1.0  0 0.000
#> SRR945233     2   0.000      1.000 0.000 1.0  0 0.000
#> SRR945234     2   0.000      1.000 0.000 1.0  0 0.000
#> SRR945235     2   0.000      1.000 0.000 1.0  0 0.000
#> SRR945236     2   0.000      1.000 0.000 1.0  0 0.000
#> SRR945237     2   0.000      1.000 0.000 1.0  0 0.000
#> SRR945238     3   0.000      1.000 0.000 0.0  1 0.000
#> SRR945239     3   0.000      1.000 0.000 0.0  1 0.000
#> SRR945240     3   0.000      1.000 0.000 0.0  1 0.000
#> SRR945241     3   0.000      1.000 0.000 0.0  1 0.000
#> SRR945242     3   0.000      1.000 0.000 0.0  1 0.000
#> SRR945243     3   0.000      1.000 0.000 0.0  1 0.000
#> SRR945244     3   0.000      1.000 0.000 0.0  1 0.000
#> SRR945245     3   0.000      1.000 0.000 0.0  1 0.000
#> SRR945246     3   0.000      1.000 0.000 0.0  1 0.000
#> SRR945247     3   0.000      1.000 0.000 0.0  1 0.000
#> SRR945248     3   0.000      1.000 0.000 0.0  1 0.000
#> SRR945249     3   0.000      1.000 0.000 0.0  1 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette p1 p2 p3    p4    p5
#> SRR945190     1   0.000      1.000  1  0  0 0.000 0.000
#> SRR945191     1   0.000      1.000  1  0  0 0.000 0.000
#> SRR945192     1   0.000      1.000  1  0  0 0.000 0.000
#> SRR945193     1   0.000      1.000  1  0  0 0.000 0.000
#> SRR945194     1   0.000      1.000  1  0  0 0.000 0.000
#> SRR945195     1   0.000      1.000  1  0  0 0.000 0.000
#> SRR945196     1   0.000      1.000  1  0  0 0.000 0.000
#> SRR945197     1   0.000      1.000  1  0  0 0.000 0.000
#> SRR945200     1   0.000      1.000  1  0  0 0.000 0.000
#> SRR945201     1   0.000      1.000  1  0  0 0.000 0.000
#> SRR945202     5   0.373      0.816  0  0  0 0.288 0.712
#> SRR945203     5   0.373      0.816  0  0  0 0.288 0.712
#> SRR945204     5   0.373      0.816  0  0  0 0.288 0.712
#> SRR945205     5   0.373      0.816  0  0  0 0.288 0.712
#> SRR945198     1   0.000      1.000  1  0  0 0.000 0.000
#> SRR945199     1   0.000      1.000  1  0  0 0.000 0.000
#> SRR945206     4   0.285      0.767  0  0  0 0.828 0.172
#> SRR945207     4   0.285      0.767  0  0  0 0.828 0.172
#> SRR945208     4   0.000      0.903  0  0  0 1.000 0.000
#> SRR945209     4   0.000      0.903  0  0  0 1.000 0.000
#> SRR945212     4   0.000      0.903  0  0  0 1.000 0.000
#> SRR945213     4   0.000      0.903  0  0  0 1.000 0.000
#> SRR945214     2   0.000      1.000  0  1  0 0.000 0.000
#> SRR945215     2   0.000      1.000  0  1  0 0.000 0.000
#> SRR945210     5   0.000      0.697  0  0  0 0.000 1.000
#> SRR945211     5   0.000      0.697  0  0  0 0.000 1.000
#> SRR945218     2   0.000      1.000  0  1  0 0.000 0.000
#> SRR945219     2   0.000      1.000  0  1  0 0.000 0.000
#> SRR945216     2   0.000      1.000  0  1  0 0.000 0.000
#> SRR945217     2   0.000      1.000  0  1  0 0.000 0.000
#> SRR945220     2   0.000      1.000  0  1  0 0.000 0.000
#> SRR945221     2   0.000      1.000  0  1  0 0.000 0.000
#> SRR945222     2   0.000      1.000  0  1  0 0.000 0.000
#> SRR945223     2   0.000      1.000  0  1  0 0.000 0.000
#> SRR945224     2   0.000      1.000  0  1  0 0.000 0.000
#> SRR945225     2   0.000      1.000  0  1  0 0.000 0.000
#> SRR945226     2   0.000      1.000  0  1  0 0.000 0.000
#> SRR945227     2   0.000      1.000  0  1  0 0.000 0.000
#> SRR945228     2   0.000      1.000  0  1  0 0.000 0.000
#> SRR945229     2   0.000      1.000  0  1  0 0.000 0.000
#> SRR945230     2   0.000      1.000  0  1  0 0.000 0.000
#> SRR945231     2   0.000      1.000  0  1  0 0.000 0.000
#> SRR945232     2   0.000      1.000  0  1  0 0.000 0.000
#> SRR945233     2   0.000      1.000  0  1  0 0.000 0.000
#> SRR945234     2   0.000      1.000  0  1  0 0.000 0.000
#> SRR945235     2   0.000      1.000  0  1  0 0.000 0.000
#> SRR945236     2   0.000      1.000  0  1  0 0.000 0.000
#> SRR945237     2   0.000      1.000  0  1  0 0.000 0.000
#> SRR945238     3   0.000      1.000  0  0  1 0.000 0.000
#> SRR945239     3   0.000      1.000  0  0  1 0.000 0.000
#> SRR945240     3   0.000      1.000  0  0  1 0.000 0.000
#> SRR945241     3   0.000      1.000  0  0  1 0.000 0.000
#> SRR945242     3   0.000      1.000  0  0  1 0.000 0.000
#> SRR945243     3   0.000      1.000  0  0  1 0.000 0.000
#> SRR945244     3   0.000      1.000  0  0  1 0.000 0.000
#> SRR945245     3   0.000      1.000  0  0  1 0.000 0.000
#> SRR945246     3   0.000      1.000  0  0  1 0.000 0.000
#> SRR945247     3   0.000      1.000  0  0  1 0.000 0.000
#> SRR945248     3   0.000      1.000  0  0  1 0.000 0.000
#> SRR945249     3   0.000      1.000  0  0  1 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
#> SRR945190     1   0.000      1.000  1  0  0 0.000  0 0.000
#> SRR945191     1   0.000      1.000  1  0  0 0.000  0 0.000
#> SRR945192     1   0.000      1.000  1  0  0 0.000  0 0.000
#> SRR945193     1   0.000      1.000  1  0  0 0.000  0 0.000
#> SRR945194     1   0.000      1.000  1  0  0 0.000  0 0.000
#> SRR945195     1   0.000      1.000  1  0  0 0.000  0 0.000
#> SRR945196     1   0.000      1.000  1  0  0 0.000  0 0.000
#> SRR945197     1   0.000      1.000  1  0  0 0.000  0 0.000
#> SRR945200     1   0.000      1.000  1  0  0 0.000  0 0.000
#> SRR945201     1   0.000      1.000  1  0  0 0.000  0 0.000
#> SRR945202     6   0.000      1.000  0  0  0 0.000  0 1.000
#> SRR945203     6   0.000      1.000  0  0  0 0.000  0 1.000
#> SRR945204     6   0.000      1.000  0  0  0 0.000  0 1.000
#> SRR945205     6   0.000      1.000  0  0  0 0.000  0 1.000
#> SRR945198     1   0.000      1.000  1  0  0 0.000  0 0.000
#> SRR945199     1   0.000      1.000  1  0  0 0.000  0 0.000
#> SRR945206     4   0.238      0.854  0  0  0 0.848  0 0.152
#> SRR945207     4   0.238      0.854  0  0  0 0.848  0 0.152
#> SRR945208     4   0.000      0.930  0  0  0 1.000  0 0.000
#> SRR945209     4   0.000      0.930  0  0  0 1.000  0 0.000
#> SRR945212     4   0.000      0.930  0  0  0 1.000  0 0.000
#> SRR945213     4   0.000      0.930  0  0  0 1.000  0 0.000
#> SRR945214     2   0.000      1.000  0  1  0 0.000  0 0.000
#> SRR945215     2   0.000      1.000  0  1  0 0.000  0 0.000
#> SRR945210     5   0.000      1.000  0  0  0 0.000  1 0.000
#> SRR945211     5   0.000      1.000  0  0  0 0.000  1 0.000
#> SRR945218     2   0.000      1.000  0  1  0 0.000  0 0.000
#> SRR945219     2   0.000      1.000  0  1  0 0.000  0 0.000
#> SRR945216     2   0.000      1.000  0  1  0 0.000  0 0.000
#> SRR945217     2   0.000      1.000  0  1  0 0.000  0 0.000
#> SRR945220     2   0.000      1.000  0  1  0 0.000  0 0.000
#> SRR945221     2   0.000      1.000  0  1  0 0.000  0 0.000
#> SRR945222     2   0.000      1.000  0  1  0 0.000  0 0.000
#> SRR945223     2   0.000      1.000  0  1  0 0.000  0 0.000
#> SRR945224     2   0.000      1.000  0  1  0 0.000  0 0.000
#> SRR945225     2   0.000      1.000  0  1  0 0.000  0 0.000
#> SRR945226     2   0.000      1.000  0  1  0 0.000  0 0.000
#> SRR945227     2   0.000      1.000  0  1  0 0.000  0 0.000
#> SRR945228     2   0.000      1.000  0  1  0 0.000  0 0.000
#> SRR945229     2   0.000      1.000  0  1  0 0.000  0 0.000
#> SRR945230     2   0.000      1.000  0  1  0 0.000  0 0.000
#> SRR945231     2   0.000      1.000  0  1  0 0.000  0 0.000
#> SRR945232     2   0.000      1.000  0  1  0 0.000  0 0.000
#> SRR945233     2   0.000      1.000  0  1  0 0.000  0 0.000
#> SRR945234     2   0.000      1.000  0  1  0 0.000  0 0.000
#> SRR945235     2   0.000      1.000  0  1  0 0.000  0 0.000
#> SRR945236     2   0.000      1.000  0  1  0 0.000  0 0.000
#> SRR945237     2   0.000      1.000  0  1  0 0.000  0 0.000
#> SRR945238     3   0.000      1.000  0  0  1 0.000  0 0.000
#> SRR945239     3   0.000      1.000  0  0  1 0.000  0 0.000
#> SRR945240     3   0.000      1.000  0  0  1 0.000  0 0.000
#> SRR945241     3   0.000      1.000  0  0  1 0.000  0 0.000
#> SRR945242     3   0.000      1.000  0  0  1 0.000  0 0.000
#> SRR945243     3   0.000      1.000  0  0  1 0.000  0 0.000
#> SRR945244     3   0.000      1.000  0  0  1 0.000  0 0.000
#> SRR945245     3   0.000      1.000  0  0  1 0.000  0 0.000
#> SRR945246     3   0.000      1.000  0  0  1 0.000  0 0.000
#> SRR945247     3   0.000      1.000  0  0  1 0.000  0 0.000
#> SRR945248     3   0.000      1.000  0  0  1 0.000  0 0.000
#> SRR945249     3   0.000      1.000  0  0  1 0.000  0 0.000

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

consensus_heatmap(res, k = 2)

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

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

collect_plots(res)

plot of chunk CV-mclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.992       0.996         0.4871 0.512   0.512
#> 3 3 1.000           0.987       0.994         0.3331 0.785   0.602
#> 4 4 0.973           0.925       0.972         0.1349 0.905   0.730
#> 5 5 0.973           0.944       0.974         0.0438 0.962   0.853
#> 6 6 0.971           0.901       0.921         0.0154 0.995   0.980

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
#> SRR945190     1  0.0000      0.992 1.000 0.000
#> SRR945191     1  0.0000      0.992 1.000 0.000
#> SRR945192     1  0.0000      0.992 1.000 0.000
#> SRR945193     1  0.0000      0.992 1.000 0.000
#> SRR945194     1  0.0000      0.992 1.000 0.000
#> SRR945195     1  0.0000      0.992 1.000 0.000
#> SRR945196     1  0.0000      0.992 1.000 0.000
#> SRR945197     1  0.0000      0.992 1.000 0.000
#> SRR945200     1  0.0000      0.992 1.000 0.000
#> SRR945201     1  0.0000      0.992 1.000 0.000
#> SRR945202     1  0.0000      0.992 1.000 0.000
#> SRR945203     1  0.0000      0.992 1.000 0.000
#> SRR945204     1  0.0000      0.992 1.000 0.000
#> SRR945205     1  0.0000      0.992 1.000 0.000
#> SRR945198     1  0.0000      0.992 1.000 0.000
#> SRR945199     1  0.0000      0.992 1.000 0.000
#> SRR945206     1  0.0000      0.992 1.000 0.000
#> SRR945207     1  0.0000      0.992 1.000 0.000
#> SRR945208     1  0.0000      0.992 1.000 0.000
#> SRR945209     1  0.0000      0.992 1.000 0.000
#> SRR945212     1  0.0000      0.992 1.000 0.000
#> SRR945213     1  0.0000      0.992 1.000 0.000
#> SRR945214     2  0.0000      0.998 0.000 1.000
#> SRR945215     2  0.0000      0.998 0.000 1.000
#> SRR945210     1  0.4562      0.898 0.904 0.096
#> SRR945211     1  0.4562      0.898 0.904 0.096
#> SRR945218     2  0.0000      0.998 0.000 1.000
#> SRR945219     2  0.0000      0.998 0.000 1.000
#> SRR945216     2  0.0000      0.998 0.000 1.000
#> SRR945217     2  0.0000      0.998 0.000 1.000
#> SRR945220     2  0.0000      0.998 0.000 1.000
#> SRR945221     2  0.0000      0.998 0.000 1.000
#> SRR945222     2  0.0000      0.998 0.000 1.000
#> SRR945223     2  0.0000      0.998 0.000 1.000
#> SRR945224     2  0.0000      0.998 0.000 1.000
#> SRR945225     2  0.0000      0.998 0.000 1.000
#> SRR945226     2  0.0000      0.998 0.000 1.000
#> SRR945227     2  0.0000      0.998 0.000 1.000
#> SRR945228     2  0.0000      0.998 0.000 1.000
#> SRR945229     2  0.0000      0.998 0.000 1.000
#> SRR945230     2  0.0376      0.997 0.004 0.996
#> SRR945231     2  0.0376      0.997 0.004 0.996
#> SRR945232     2  0.0000      0.998 0.000 1.000
#> SRR945233     2  0.0000      0.998 0.000 1.000
#> SRR945234     2  0.0000      0.998 0.000 1.000
#> SRR945235     2  0.0000      0.998 0.000 1.000
#> SRR945236     2  0.0000      0.998 0.000 1.000
#> SRR945237     2  0.0000      0.998 0.000 1.000
#> SRR945238     2  0.0376      0.997 0.004 0.996
#> SRR945239     2  0.0376      0.997 0.004 0.996
#> SRR945240     2  0.0376      0.997 0.004 0.996
#> SRR945241     2  0.0376      0.997 0.004 0.996
#> SRR945242     2  0.0376      0.997 0.004 0.996
#> SRR945243     2  0.0376      0.997 0.004 0.996
#> SRR945244     2  0.0376      0.997 0.004 0.996
#> SRR945245     2  0.0376      0.997 0.004 0.996
#> SRR945246     2  0.0376      0.997 0.004 0.996
#> SRR945247     2  0.0376      0.997 0.004 0.996
#> SRR945248     2  0.0376      0.997 0.004 0.996
#> SRR945249     2  0.0376      0.997 0.004 0.996

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2 p3
#> SRR945190     1   0.000      0.984 1.000 0.000  0
#> SRR945191     1   0.000      0.984 1.000 0.000  0
#> SRR945192     1   0.000      0.984 1.000 0.000  0
#> SRR945193     1   0.000      0.984 1.000 0.000  0
#> SRR945194     1   0.000      0.984 1.000 0.000  0
#> SRR945195     1   0.000      0.984 1.000 0.000  0
#> SRR945196     1   0.000      0.984 1.000 0.000  0
#> SRR945197     1   0.000      0.984 1.000 0.000  0
#> SRR945200     1   0.000      0.984 1.000 0.000  0
#> SRR945201     1   0.000      0.984 1.000 0.000  0
#> SRR945202     1   0.000      0.984 1.000 0.000  0
#> SRR945203     1   0.000      0.984 1.000 0.000  0
#> SRR945204     1   0.000      0.984 1.000 0.000  0
#> SRR945205     1   0.000      0.984 1.000 0.000  0
#> SRR945198     1   0.000      0.984 1.000 0.000  0
#> SRR945199     1   0.000      0.984 1.000 0.000  0
#> SRR945206     1   0.000      0.984 1.000 0.000  0
#> SRR945207     1   0.000      0.984 1.000 0.000  0
#> SRR945208     1   0.000      0.984 1.000 0.000  0
#> SRR945209     1   0.000      0.984 1.000 0.000  0
#> SRR945212     1   0.000      0.984 1.000 0.000  0
#> SRR945213     1   0.000      0.984 1.000 0.000  0
#> SRR945214     2   0.000      1.000 0.000 1.000  0
#> SRR945215     2   0.000      1.000 0.000 1.000  0
#> SRR945210     1   0.000      0.984 1.000 0.000  0
#> SRR945211     1   0.000      0.984 1.000 0.000  0
#> SRR945218     2   0.000      1.000 0.000 1.000  0
#> SRR945219     2   0.000      1.000 0.000 1.000  0
#> SRR945216     2   0.000      1.000 0.000 1.000  0
#> SRR945217     2   0.000      1.000 0.000 1.000  0
#> SRR945220     2   0.000      1.000 0.000 1.000  0
#> SRR945221     2   0.000      1.000 0.000 1.000  0
#> SRR945222     2   0.000      1.000 0.000 1.000  0
#> SRR945223     2   0.000      1.000 0.000 1.000  0
#> SRR945224     2   0.000      1.000 0.000 1.000  0
#> SRR945225     2   0.000      1.000 0.000 1.000  0
#> SRR945226     2   0.000      1.000 0.000 1.000  0
#> SRR945227     2   0.000      1.000 0.000 1.000  0
#> SRR945228     2   0.000      1.000 0.000 1.000  0
#> SRR945229     2   0.000      1.000 0.000 1.000  0
#> SRR945230     1   0.418      0.795 0.828 0.172  0
#> SRR945231     1   0.418      0.795 0.828 0.172  0
#> SRR945232     2   0.000      1.000 0.000 1.000  0
#> SRR945233     2   0.000      1.000 0.000 1.000  0
#> SRR945234     2   0.000      1.000 0.000 1.000  0
#> SRR945235     2   0.000      1.000 0.000 1.000  0
#> SRR945236     2   0.000      1.000 0.000 1.000  0
#> SRR945237     2   0.000      1.000 0.000 1.000  0
#> SRR945238     3   0.000      1.000 0.000 0.000  1
#> SRR945239     3   0.000      1.000 0.000 0.000  1
#> SRR945240     3   0.000      1.000 0.000 0.000  1
#> SRR945241     3   0.000      1.000 0.000 0.000  1
#> SRR945242     3   0.000      1.000 0.000 0.000  1
#> SRR945243     3   0.000      1.000 0.000 0.000  1
#> SRR945244     3   0.000      1.000 0.000 0.000  1
#> SRR945245     3   0.000      1.000 0.000 0.000  1
#> SRR945246     3   0.000      1.000 0.000 0.000  1
#> SRR945247     3   0.000      1.000 0.000 0.000  1
#> SRR945248     3   0.000      1.000 0.000 0.000  1
#> SRR945249     3   0.000      1.000 0.000 0.000  1

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2 p3    p4
#> SRR945190     1   0.000      0.927 1.000 0.000  0 0.000
#> SRR945191     1   0.000      0.927 1.000 0.000  0 0.000
#> SRR945192     1   0.000      0.927 1.000 0.000  0 0.000
#> SRR945193     1   0.000      0.927 1.000 0.000  0 0.000
#> SRR945194     1   0.476      0.445 0.628 0.000  0 0.372
#> SRR945195     1   0.476      0.445 0.628 0.000  0 0.372
#> SRR945196     1   0.000      0.927 1.000 0.000  0 0.000
#> SRR945197     1   0.000      0.927 1.000 0.000  0 0.000
#> SRR945200     1   0.000      0.927 1.000 0.000  0 0.000
#> SRR945201     1   0.000      0.927 1.000 0.000  0 0.000
#> SRR945202     4   0.000      0.906 0.000 0.000  0 1.000
#> SRR945203     4   0.000      0.906 0.000 0.000  0 1.000
#> SRR945204     4   0.000      0.906 0.000 0.000  0 1.000
#> SRR945205     4   0.000      0.906 0.000 0.000  0 1.000
#> SRR945198     1   0.000      0.927 1.000 0.000  0 0.000
#> SRR945199     1   0.000      0.927 1.000 0.000  0 0.000
#> SRR945206     4   0.000      0.906 0.000 0.000  0 1.000
#> SRR945207     4   0.000      0.906 0.000 0.000  0 1.000
#> SRR945208     4   0.000      0.906 0.000 0.000  0 1.000
#> SRR945209     4   0.000      0.906 0.000 0.000  0 1.000
#> SRR945212     4   0.000      0.906 0.000 0.000  0 1.000
#> SRR945213     4   0.000      0.906 0.000 0.000  0 1.000
#> SRR945214     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR945215     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR945210     4   0.000      0.906 0.000 0.000  0 1.000
#> SRR945211     4   0.000      0.906 0.000 0.000  0 1.000
#> SRR945218     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR945219     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR945216     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR945217     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR945220     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR945221     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR945222     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR945223     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR945224     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR945225     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR945226     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR945227     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR945228     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR945229     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR945230     4   0.497      0.236 0.000 0.456  0 0.544
#> SRR945231     4   0.497      0.236 0.000 0.456  0 0.544
#> SRR945232     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR945233     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR945234     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR945235     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR945236     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR945237     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR945238     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR945239     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR945240     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR945241     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR945242     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR945243     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR945244     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR945245     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR945246     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR945247     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR945248     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR945249     3   0.000      1.000 0.000 0.000  1 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2 p3    p4    p5
#> SRR945190     1   0.000      1.000 1.000 0.000  0 0.000 0.000
#> SRR945191     1   0.000      1.000 1.000 0.000  0 0.000 0.000
#> SRR945192     1   0.000      1.000 1.000 0.000  0 0.000 0.000
#> SRR945193     1   0.000      1.000 1.000 0.000  0 0.000 0.000
#> SRR945194     5   0.382      0.529 0.304 0.000  0 0.000 0.696
#> SRR945195     5   0.382      0.529 0.304 0.000  0 0.000 0.696
#> SRR945196     1   0.000      1.000 1.000 0.000  0 0.000 0.000
#> SRR945197     1   0.000      1.000 1.000 0.000  0 0.000 0.000
#> SRR945200     1   0.000      1.000 1.000 0.000  0 0.000 0.000
#> SRR945201     1   0.000      1.000 1.000 0.000  0 0.000 0.000
#> SRR945202     4   0.000      0.959 0.000 0.000  0 1.000 0.000
#> SRR945203     4   0.000      0.959 0.000 0.000  0 1.000 0.000
#> SRR945204     4   0.000      0.959 0.000 0.000  0 1.000 0.000
#> SRR945205     4   0.000      0.959 0.000 0.000  0 1.000 0.000
#> SRR945198     1   0.000      1.000 1.000 0.000  0 0.000 0.000
#> SRR945199     1   0.000      1.000 1.000 0.000  0 0.000 0.000
#> SRR945206     4   0.269      0.810 0.000 0.000  0 0.844 0.156
#> SRR945207     4   0.269      0.810 0.000 0.000  0 0.844 0.156
#> SRR945208     4   0.000      0.959 0.000 0.000  0 1.000 0.000
#> SRR945209     4   0.000      0.959 0.000 0.000  0 1.000 0.000
#> SRR945212     4   0.000      0.959 0.000 0.000  0 1.000 0.000
#> SRR945213     4   0.000      0.959 0.000 0.000  0 1.000 0.000
#> SRR945214     2   0.000      1.000 0.000 1.000  0 0.000 0.000
#> SRR945215     2   0.000      1.000 0.000 1.000  0 0.000 0.000
#> SRR945210     5   0.391      0.454 0.000 0.000  0 0.324 0.676
#> SRR945211     5   0.391      0.454 0.000 0.000  0 0.324 0.676
#> SRR945218     2   0.000      1.000 0.000 1.000  0 0.000 0.000
#> SRR945219     2   0.000      1.000 0.000 1.000  0 0.000 0.000
#> SRR945216     2   0.000      1.000 0.000 1.000  0 0.000 0.000
#> SRR945217     2   0.000      1.000 0.000 1.000  0 0.000 0.000
#> SRR945220     2   0.000      1.000 0.000 1.000  0 0.000 0.000
#> SRR945221     2   0.000      1.000 0.000 1.000  0 0.000 0.000
#> SRR945222     2   0.000      1.000 0.000 1.000  0 0.000 0.000
#> SRR945223     2   0.000      1.000 0.000 1.000  0 0.000 0.000
#> SRR945224     2   0.000      1.000 0.000 1.000  0 0.000 0.000
#> SRR945225     2   0.000      1.000 0.000 1.000  0 0.000 0.000
#> SRR945226     2   0.000      1.000 0.000 1.000  0 0.000 0.000
#> SRR945227     2   0.000      1.000 0.000 1.000  0 0.000 0.000
#> SRR945228     2   0.000      1.000 0.000 1.000  0 0.000 0.000
#> SRR945229     2   0.000      1.000 0.000 1.000  0 0.000 0.000
#> SRR945230     5   0.029      0.703 0.000 0.008  0 0.000 0.992
#> SRR945231     5   0.029      0.703 0.000 0.008  0 0.000 0.992
#> SRR945232     2   0.000      1.000 0.000 1.000  0 0.000 0.000
#> SRR945233     2   0.000      1.000 0.000 1.000  0 0.000 0.000
#> SRR945234     2   0.000      1.000 0.000 1.000  0 0.000 0.000
#> SRR945235     2   0.000      1.000 0.000 1.000  0 0.000 0.000
#> SRR945236     2   0.000      1.000 0.000 1.000  0 0.000 0.000
#> SRR945237     2   0.000      1.000 0.000 1.000  0 0.000 0.000
#> SRR945238     3   0.000      1.000 0.000 0.000  1 0.000 0.000
#> SRR945239     3   0.000      1.000 0.000 0.000  1 0.000 0.000
#> SRR945240     3   0.000      1.000 0.000 0.000  1 0.000 0.000
#> SRR945241     3   0.000      1.000 0.000 0.000  1 0.000 0.000
#> SRR945242     3   0.000      1.000 0.000 0.000  1 0.000 0.000
#> SRR945243     3   0.000      1.000 0.000 0.000  1 0.000 0.000
#> SRR945244     3   0.000      1.000 0.000 0.000  1 0.000 0.000
#> SRR945245     3   0.000      1.000 0.000 0.000  1 0.000 0.000
#> SRR945246     3   0.000      1.000 0.000 0.000  1 0.000 0.000
#> SRR945247     3   0.000      1.000 0.000 0.000  1 0.000 0.000
#> SRR945248     3   0.000      1.000 0.000 0.000  1 0.000 0.000
#> SRR945249     3   0.000      1.000 0.000 0.000  1 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
#> SRR945190     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> SRR945191     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> SRR945192     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> SRR945193     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> SRR945194     5  0.4917      0.232 0.076 0.000  0 0.000 0.576 0.348
#> SRR945195     5  0.4917      0.232 0.076 0.000  0 0.000 0.576 0.348
#> SRR945196     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> SRR945197     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> SRR945200     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> SRR945201     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> SRR945202     4  0.1267      0.757 0.000 0.000  0 0.940 0.060 0.000
#> SRR945203     4  0.1267      0.757 0.000 0.000  0 0.940 0.060 0.000
#> SRR945204     4  0.3101      0.714 0.000 0.000  0 0.756 0.244 0.000
#> SRR945205     4  0.3101      0.714 0.000 0.000  0 0.756 0.244 0.000
#> SRR945198     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> SRR945199     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> SRR945206     4  0.4408      0.450 0.000 0.000  0 0.664 0.280 0.056
#> SRR945207     4  0.4408      0.450 0.000 0.000  0 0.664 0.280 0.056
#> SRR945208     4  0.2697      0.744 0.000 0.000  0 0.812 0.188 0.000
#> SRR945209     4  0.2697      0.744 0.000 0.000  0 0.812 0.188 0.000
#> SRR945212     4  0.0713      0.766 0.000 0.000  0 0.972 0.028 0.000
#> SRR945213     4  0.0713      0.766 0.000 0.000  0 0.972 0.028 0.000
#> SRR945214     2  0.0000      0.995 0.000 1.000  0 0.000 0.000 0.000
#> SRR945215     2  0.0000      0.995 0.000 1.000  0 0.000 0.000 0.000
#> SRR945210     5  0.5597      0.438 0.000 0.000  0 0.252 0.544 0.204
#> SRR945211     5  0.5597      0.438 0.000 0.000  0 0.252 0.544 0.204
#> SRR945218     2  0.0363      0.993 0.000 0.988  0 0.000 0.000 0.012
#> SRR945219     2  0.0363      0.993 0.000 0.988  0 0.000 0.000 0.012
#> SRR945216     2  0.0000      0.995 0.000 1.000  0 0.000 0.000 0.000
#> SRR945217     2  0.0000      0.995 0.000 1.000  0 0.000 0.000 0.000
#> SRR945220     2  0.0146      0.994 0.000 0.996  0 0.000 0.000 0.004
#> SRR945221     2  0.0000      0.995 0.000 1.000  0 0.000 0.000 0.000
#> SRR945222     2  0.0000      0.995 0.000 1.000  0 0.000 0.000 0.000
#> SRR945223     2  0.0000      0.995 0.000 1.000  0 0.000 0.000 0.000
#> SRR945224     2  0.0146      0.994 0.000 0.996  0 0.000 0.000 0.004
#> SRR945225     2  0.0146      0.994 0.000 0.996  0 0.000 0.000 0.004
#> SRR945226     2  0.0146      0.994 0.000 0.996  0 0.000 0.000 0.004
#> SRR945227     2  0.0146      0.994 0.000 0.996  0 0.000 0.000 0.004
#> SRR945228     2  0.0363      0.992 0.000 0.988  0 0.000 0.000 0.012
#> SRR945229     2  0.0363      0.992 0.000 0.988  0 0.000 0.000 0.012
#> SRR945230     6  0.0000      1.000 0.000 0.000  0 0.000 0.000 1.000
#> SRR945231     6  0.0000      1.000 0.000 0.000  0 0.000 0.000 1.000
#> SRR945232     2  0.0260      0.994 0.000 0.992  0 0.000 0.000 0.008
#> SRR945233     2  0.0260      0.994 0.000 0.992  0 0.000 0.000 0.008
#> SRR945234     2  0.0363      0.992 0.000 0.988  0 0.000 0.000 0.012
#> SRR945235     2  0.0363      0.992 0.000 0.988  0 0.000 0.000 0.012
#> SRR945236     2  0.0363      0.992 0.000 0.988  0 0.000 0.000 0.012
#> SRR945237     2  0.0363      0.992 0.000 0.988  0 0.000 0.000 0.012
#> SRR945238     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR945239     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR945240     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR945241     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR945242     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR945243     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR945244     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR945245     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR945246     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR945247     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR945248     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR945249     3  0.0000      1.000 0.000 0.000  1 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 15912 rows and 60 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#>   Subgroups are detected by 'NMF' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 6.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk CV-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4886 0.512   0.512
#> 3 3 0.756           0.931       0.829         0.2695 0.837   0.682
#> 4 4 1.000           1.000       1.000         0.1808 0.919   0.767
#> 5 5 1.000           0.987       0.986         0.0211 0.989   0.958
#> 6 6 0.903           0.954       0.925         0.0766 0.919   0.683

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette p1 p2
#> SRR945190     1       0          1  1  0
#> SRR945191     1       0          1  1  0
#> SRR945192     1       0          1  1  0
#> SRR945193     1       0          1  1  0
#> SRR945194     1       0          1  1  0
#> SRR945195     1       0          1  1  0
#> SRR945196     1       0          1  1  0
#> SRR945197     1       0          1  1  0
#> SRR945200     1       0          1  1  0
#> SRR945201     1       0          1  1  0
#> SRR945202     1       0          1  1  0
#> SRR945203     1       0          1  1  0
#> SRR945204     1       0          1  1  0
#> SRR945205     1       0          1  1  0
#> SRR945198     1       0          1  1  0
#> SRR945199     1       0          1  1  0
#> SRR945206     1       0          1  1  0
#> SRR945207     1       0          1  1  0
#> SRR945208     1       0          1  1  0
#> SRR945209     1       0          1  1  0
#> SRR945212     1       0          1  1  0
#> SRR945213     1       0          1  1  0
#> SRR945214     2       0          1  0  1
#> SRR945215     2       0          1  0  1
#> SRR945210     1       0          1  1  0
#> SRR945211     1       0          1  1  0
#> SRR945218     2       0          1  0  1
#> SRR945219     2       0          1  0  1
#> SRR945216     2       0          1  0  1
#> SRR945217     2       0          1  0  1
#> SRR945220     2       0          1  0  1
#> SRR945221     2       0          1  0  1
#> SRR945222     2       0          1  0  1
#> SRR945223     2       0          1  0  1
#> SRR945224     2       0          1  0  1
#> SRR945225     2       0          1  0  1
#> SRR945226     2       0          1  0  1
#> SRR945227     2       0          1  0  1
#> SRR945228     2       0          1  0  1
#> SRR945229     2       0          1  0  1
#> SRR945230     2       0          1  0  1
#> SRR945231     2       0          1  0  1
#> SRR945232     2       0          1  0  1
#> SRR945233     2       0          1  0  1
#> SRR945234     2       0          1  0  1
#> SRR945235     2       0          1  0  1
#> SRR945236     2       0          1  0  1
#> SRR945237     2       0          1  0  1
#> SRR945238     2       0          1  0  1
#> SRR945239     2       0          1  0  1
#> SRR945240     2       0          1  0  1
#> SRR945241     2       0          1  0  1
#> SRR945242     2       0          1  0  1
#> SRR945243     2       0          1  0  1
#> SRR945244     2       0          1  0  1
#> SRR945245     2       0          1  0  1
#> SRR945246     2       0          1  0  1
#> SRR945247     2       0          1  0  1
#> SRR945248     2       0          1  0  1
#> SRR945249     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
#> SRR945190     1   0.000      0.829 1.00 0.00 0.00
#> SRR945191     1   0.000      0.829 1.00 0.00 0.00
#> SRR945192     1   0.000      0.829 1.00 0.00 0.00
#> SRR945193     1   0.000      0.829 1.00 0.00 0.00
#> SRR945194     1   0.000      0.829 1.00 0.00 0.00
#> SRR945195     1   0.000      0.829 1.00 0.00 0.00
#> SRR945196     1   0.000      0.829 1.00 0.00 0.00
#> SRR945197     1   0.000      0.829 1.00 0.00 0.00
#> SRR945200     1   0.000      0.829 1.00 0.00 0.00
#> SRR945201     1   0.000      0.829 1.00 0.00 0.00
#> SRR945202     1   0.604      0.829 0.62 0.00 0.38
#> SRR945203     1   0.604      0.829 0.62 0.00 0.38
#> SRR945204     1   0.604      0.829 0.62 0.00 0.38
#> SRR945205     1   0.604      0.829 0.62 0.00 0.38
#> SRR945198     1   0.000      0.829 1.00 0.00 0.00
#> SRR945199     1   0.000      0.829 1.00 0.00 0.00
#> SRR945206     1   0.604      0.829 0.62 0.00 0.38
#> SRR945207     1   0.604      0.829 0.62 0.00 0.38
#> SRR945208     1   0.604      0.829 0.62 0.00 0.38
#> SRR945209     1   0.604      0.829 0.62 0.00 0.38
#> SRR945212     1   0.604      0.829 0.62 0.00 0.38
#> SRR945213     1   0.604      0.829 0.62 0.00 0.38
#> SRR945214     2   0.000      1.000 0.00 1.00 0.00
#> SRR945215     2   0.000      1.000 0.00 1.00 0.00
#> SRR945210     1   0.604      0.829 0.62 0.00 0.38
#> SRR945211     1   0.604      0.829 0.62 0.00 0.38
#> SRR945218     2   0.000      1.000 0.00 1.00 0.00
#> SRR945219     2   0.000      1.000 0.00 1.00 0.00
#> SRR945216     2   0.000      1.000 0.00 1.00 0.00
#> SRR945217     2   0.000      1.000 0.00 1.00 0.00
#> SRR945220     2   0.000      1.000 0.00 1.00 0.00
#> SRR945221     2   0.000      1.000 0.00 1.00 0.00
#> SRR945222     2   0.000      1.000 0.00 1.00 0.00
#> SRR945223     2   0.000      1.000 0.00 1.00 0.00
#> SRR945224     2   0.000      1.000 0.00 1.00 0.00
#> SRR945225     2   0.000      1.000 0.00 1.00 0.00
#> SRR945226     2   0.000      1.000 0.00 1.00 0.00
#> SRR945227     2   0.000      1.000 0.00 1.00 0.00
#> SRR945228     2   0.000      1.000 0.00 1.00 0.00
#> SRR945229     2   0.000      1.000 0.00 1.00 0.00
#> SRR945230     2   0.000      1.000 0.00 1.00 0.00
#> SRR945231     2   0.000      1.000 0.00 1.00 0.00
#> SRR945232     2   0.000      1.000 0.00 1.00 0.00
#> SRR945233     2   0.000      1.000 0.00 1.00 0.00
#> SRR945234     2   0.000      1.000 0.00 1.00 0.00
#> SRR945235     2   0.000      1.000 0.00 1.00 0.00
#> SRR945236     2   0.000      1.000 0.00 1.00 0.00
#> SRR945237     2   0.000      1.000 0.00 1.00 0.00
#> SRR945238     3   0.604      1.000 0.00 0.38 0.62
#> SRR945239     3   0.604      1.000 0.00 0.38 0.62
#> SRR945240     3   0.604      1.000 0.00 0.38 0.62
#> SRR945241     3   0.604      1.000 0.00 0.38 0.62
#> SRR945242     3   0.604      1.000 0.00 0.38 0.62
#> SRR945243     3   0.604      1.000 0.00 0.38 0.62
#> SRR945244     3   0.604      1.000 0.00 0.38 0.62
#> SRR945245     3   0.604      1.000 0.00 0.38 0.62
#> SRR945246     3   0.604      1.000 0.00 0.38 0.62
#> SRR945247     3   0.604      1.000 0.00 0.38 0.62
#> SRR945248     3   0.604      1.000 0.00 0.38 0.62
#> SRR945249     3   0.604      1.000 0.00 0.38 0.62

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette p1 p2 p3 p4
#> SRR945190     1       0          1  1  0  0  0
#> SRR945191     1       0          1  1  0  0  0
#> SRR945192     1       0          1  1  0  0  0
#> SRR945193     1       0          1  1  0  0  0
#> SRR945194     1       0          1  1  0  0  0
#> SRR945195     1       0          1  1  0  0  0
#> SRR945196     1       0          1  1  0  0  0
#> SRR945197     1       0          1  1  0  0  0
#> SRR945200     1       0          1  1  0  0  0
#> SRR945201     1       0          1  1  0  0  0
#> SRR945202     4       0          1  0  0  0  1
#> SRR945203     4       0          1  0  0  0  1
#> SRR945204     4       0          1  0  0  0  1
#> SRR945205     4       0          1  0  0  0  1
#> SRR945198     1       0          1  1  0  0  0
#> SRR945199     1       0          1  1  0  0  0
#> SRR945206     4       0          1  0  0  0  1
#> SRR945207     4       0          1  0  0  0  1
#> SRR945208     4       0          1  0  0  0  1
#> SRR945209     4       0          1  0  0  0  1
#> SRR945212     4       0          1  0  0  0  1
#> SRR945213     4       0          1  0  0  0  1
#> SRR945214     2       0          1  0  1  0  0
#> SRR945215     2       0          1  0  1  0  0
#> SRR945210     4       0          1  0  0  0  1
#> SRR945211     4       0          1  0  0  0  1
#> SRR945218     2       0          1  0  1  0  0
#> SRR945219     2       0          1  0  1  0  0
#> SRR945216     2       0          1  0  1  0  0
#> SRR945217     2       0          1  0  1  0  0
#> SRR945220     2       0          1  0  1  0  0
#> SRR945221     2       0          1  0  1  0  0
#> SRR945222     2       0          1  0  1  0  0
#> SRR945223     2       0          1  0  1  0  0
#> SRR945224     2       0          1  0  1  0  0
#> SRR945225     2       0          1  0  1  0  0
#> SRR945226     2       0          1  0  1  0  0
#> SRR945227     2       0          1  0  1  0  0
#> SRR945228     2       0          1  0  1  0  0
#> SRR945229     2       0          1  0  1  0  0
#> SRR945230     2       0          1  0  1  0  0
#> SRR945231     2       0          1  0  1  0  0
#> SRR945232     2       0          1  0  1  0  0
#> SRR945233     2       0          1  0  1  0  0
#> SRR945234     2       0          1  0  1  0  0
#> SRR945235     2       0          1  0  1  0  0
#> SRR945236     2       0          1  0  1  0  0
#> SRR945237     2       0          1  0  1  0  0
#> SRR945238     3       0          1  0  0  1  0
#> SRR945239     3       0          1  0  0  1  0
#> SRR945240     3       0          1  0  0  1  0
#> SRR945241     3       0          1  0  0  1  0
#> SRR945242     3       0          1  0  0  1  0
#> SRR945243     3       0          1  0  0  1  0
#> SRR945244     3       0          1  0  0  1  0
#> SRR945245     3       0          1  0  0  1  0
#> SRR945246     3       0          1  0  0  1  0
#> SRR945247     3       0          1  0  0  1  0
#> SRR945248     3       0          1  0  0  1  0
#> SRR945249     3       0          1  0  0  1  0

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette p1    p2 p3    p4    p5
#> SRR945190     1   0.000      1.000  1 0.000  0 0.000 0.000
#> SRR945191     1   0.000      1.000  1 0.000  0 0.000 0.000
#> SRR945192     1   0.000      1.000  1 0.000  0 0.000 0.000
#> SRR945193     1   0.000      1.000  1 0.000  0 0.000 0.000
#> SRR945194     1   0.000      1.000  1 0.000  0 0.000 0.000
#> SRR945195     1   0.000      1.000  1 0.000  0 0.000 0.000
#> SRR945196     1   0.000      1.000  1 0.000  0 0.000 0.000
#> SRR945197     1   0.000      1.000  1 0.000  0 0.000 0.000
#> SRR945200     1   0.000      1.000  1 0.000  0 0.000 0.000
#> SRR945201     1   0.000      1.000  1 0.000  0 0.000 0.000
#> SRR945202     4   0.029      0.992  0 0.000  0 0.992 0.008
#> SRR945203     4   0.029      0.992  0 0.000  0 0.992 0.008
#> SRR945204     4   0.051      0.987  0 0.000  0 0.984 0.016
#> SRR945205     4   0.051      0.987  0 0.000  0 0.984 0.016
#> SRR945198     1   0.000      1.000  1 0.000  0 0.000 0.000
#> SRR945199     1   0.000      1.000  1 0.000  0 0.000 0.000
#> SRR945206     4   0.029      0.990  0 0.000  0 0.992 0.008
#> SRR945207     4   0.029      0.990  0 0.000  0 0.992 0.008
#> SRR945208     4   0.000      0.993  0 0.000  0 1.000 0.000
#> SRR945209     4   0.000      0.993  0 0.000  0 1.000 0.000
#> SRR945212     4   0.000      0.993  0 0.000  0 1.000 0.000
#> SRR945213     4   0.000      0.993  0 0.000  0 1.000 0.000
#> SRR945214     2   0.000      0.972  0 1.000  0 0.000 0.000
#> SRR945215     2   0.000      0.972  0 1.000  0 0.000 0.000
#> SRR945210     5   0.141      1.000  0 0.000  0 0.060 0.940
#> SRR945211     5   0.141      1.000  0 0.000  0 0.060 0.940
#> SRR945218     2   0.000      0.972  0 1.000  0 0.000 0.000
#> SRR945219     2   0.000      0.972  0 1.000  0 0.000 0.000
#> SRR945216     2   0.000      0.972  0 1.000  0 0.000 0.000
#> SRR945217     2   0.000      0.972  0 1.000  0 0.000 0.000
#> SRR945220     2   0.000      0.972  0 1.000  0 0.000 0.000
#> SRR945221     2   0.000      0.972  0 1.000  0 0.000 0.000
#> SRR945222     2   0.000      0.972  0 1.000  0 0.000 0.000
#> SRR945223     2   0.000      0.972  0 1.000  0 0.000 0.000
#> SRR945224     2   0.000      0.972  0 1.000  0 0.000 0.000
#> SRR945225     2   0.000      0.972  0 1.000  0 0.000 0.000
#> SRR945226     2   0.127      0.971  0 0.948  0 0.000 0.052
#> SRR945227     2   0.127      0.971  0 0.948  0 0.000 0.052
#> SRR945228     2   0.141      0.969  0 0.940  0 0.000 0.060
#> SRR945229     2   0.141      0.969  0 0.940  0 0.000 0.060
#> SRR945230     2   0.141      0.969  0 0.940  0 0.000 0.060
#> SRR945231     2   0.141      0.969  0 0.940  0 0.000 0.060
#> SRR945232     2   0.127      0.971  0 0.948  0 0.000 0.052
#> SRR945233     2   0.134      0.970  0 0.944  0 0.000 0.056
#> SRR945234     2   0.134      0.970  0 0.944  0 0.000 0.056
#> SRR945235     2   0.134      0.970  0 0.944  0 0.000 0.056
#> SRR945236     2   0.141      0.969  0 0.940  0 0.000 0.060
#> SRR945237     2   0.141      0.969  0 0.940  0 0.000 0.060
#> SRR945238     3   0.000      1.000  0 0.000  1 0.000 0.000
#> SRR945239     3   0.000      1.000  0 0.000  1 0.000 0.000
#> SRR945240     3   0.000      1.000  0 0.000  1 0.000 0.000
#> SRR945241     3   0.000      1.000  0 0.000  1 0.000 0.000
#> SRR945242     3   0.000      1.000  0 0.000  1 0.000 0.000
#> SRR945243     3   0.000      1.000  0 0.000  1 0.000 0.000
#> SRR945244     3   0.000      1.000  0 0.000  1 0.000 0.000
#> SRR945245     3   0.000      1.000  0 0.000  1 0.000 0.000
#> SRR945246     3   0.000      1.000  0 0.000  1 0.000 0.000
#> SRR945247     3   0.000      1.000  0 0.000  1 0.000 0.000
#> SRR945248     3   0.000      1.000  0 0.000  1 0.000 0.000
#> SRR945249     3   0.000      1.000  0 0.000  1 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
#> SRR945190     1   0.000      0.999 1.000 0.000  0 0.000 0.000 0.000
#> SRR945191     1   0.000      0.999 1.000 0.000  0 0.000 0.000 0.000
#> SRR945192     1   0.000      0.999 1.000 0.000  0 0.000 0.000 0.000
#> SRR945193     1   0.000      0.999 1.000 0.000  0 0.000 0.000 0.000
#> SRR945194     1   0.026      0.993 0.992 0.000  0 0.000 0.000 0.008
#> SRR945195     1   0.026      0.993 0.992 0.000  0 0.000 0.000 0.008
#> SRR945196     1   0.000      0.999 1.000 0.000  0 0.000 0.000 0.000
#> SRR945197     1   0.000      0.999 1.000 0.000  0 0.000 0.000 0.000
#> SRR945200     1   0.000      0.999 1.000 0.000  0 0.000 0.000 0.000
#> SRR945201     1   0.000      0.999 1.000 0.000  0 0.000 0.000 0.000
#> SRR945202     4   0.140      0.924 0.000 0.000  0 0.940 0.008 0.052
#> SRR945203     4   0.140      0.924 0.000 0.000  0 0.940 0.008 0.052
#> SRR945204     4   0.159      0.921 0.000 0.000  0 0.932 0.016 0.052
#> SRR945205     4   0.159      0.921 0.000 0.000  0 0.932 0.016 0.052
#> SRR945198     1   0.000      0.999 1.000 0.000  0 0.000 0.000 0.000
#> SRR945199     1   0.000      0.999 1.000 0.000  0 0.000 0.000 0.000
#> SRR945206     4   0.301      0.806 0.000 0.000  0 0.804 0.012 0.184
#> SRR945207     4   0.301      0.806 0.000 0.000  0 0.804 0.012 0.184
#> SRR945208     4   0.000      0.930 0.000 0.000  0 1.000 0.000 0.000
#> SRR945209     4   0.000      0.930 0.000 0.000  0 1.000 0.000 0.000
#> SRR945212     4   0.026      0.928 0.000 0.000  0 0.992 0.000 0.008
#> SRR945213     4   0.026      0.928 0.000 0.000  0 0.992 0.000 0.008
#> SRR945214     2   0.000      1.000 0.000 1.000  0 0.000 0.000 0.000
#> SRR945215     2   0.000      1.000 0.000 1.000  0 0.000 0.000 0.000
#> SRR945210     5   0.000      1.000 0.000 0.000  0 0.000 1.000 0.000
#> SRR945211     5   0.000      1.000 0.000 0.000  0 0.000 1.000 0.000
#> SRR945218     2   0.000      1.000 0.000 1.000  0 0.000 0.000 0.000
#> SRR945219     2   0.000      1.000 0.000 1.000  0 0.000 0.000 0.000
#> SRR945216     2   0.000      1.000 0.000 1.000  0 0.000 0.000 0.000
#> SRR945217     2   0.000      1.000 0.000 1.000  0 0.000 0.000 0.000
#> SRR945220     2   0.000      1.000 0.000 1.000  0 0.000 0.000 0.000
#> SRR945221     2   0.000      1.000 0.000 1.000  0 0.000 0.000 0.000
#> SRR945222     2   0.000      1.000 0.000 1.000  0 0.000 0.000 0.000
#> SRR945223     2   0.000      1.000 0.000 1.000  0 0.000 0.000 0.000
#> SRR945224     2   0.000      1.000 0.000 1.000  0 0.000 0.000 0.000
#> SRR945225     2   0.000      1.000 0.000 1.000  0 0.000 0.000 0.000
#> SRR945226     6   0.367      0.864 0.000 0.368  0 0.000 0.000 0.632
#> SRR945227     6   0.368      0.861 0.000 0.372  0 0.000 0.000 0.628
#> SRR945228     6   0.310      0.887 0.000 0.244  0 0.000 0.000 0.756
#> SRR945229     6   0.310      0.887 0.000 0.244  0 0.000 0.000 0.756
#> SRR945230     6   0.310      0.887 0.000 0.244  0 0.000 0.000 0.756
#> SRR945231     6   0.310      0.887 0.000 0.244  0 0.000 0.000 0.756
#> SRR945232     6   0.386      0.719 0.000 0.468  0 0.000 0.000 0.532
#> SRR945233     6   0.383      0.771 0.000 0.440  0 0.000 0.000 0.560
#> SRR945234     6   0.365      0.869 0.000 0.360  0 0.000 0.000 0.640
#> SRR945235     6   0.365      0.869 0.000 0.360  0 0.000 0.000 0.640
#> SRR945236     6   0.310      0.887 0.000 0.244  0 0.000 0.000 0.756
#> SRR945237     6   0.310      0.887 0.000 0.244  0 0.000 0.000 0.756
#> SRR945238     3   0.000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR945239     3   0.000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR945240     3   0.000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR945241     3   0.000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR945242     3   0.000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR945243     3   0.000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR945244     3   0.000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR945245     3   0.000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR945246     3   0.000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR945247     3   0.000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR945248     3   0.000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR945249     3   0.000      1.000 0.000 0.000  1 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 15912 rows and 60 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'hclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 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-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4886 0.512   0.512
#> 3 3 0.753           0.909       0.915         0.1974 0.921   0.845
#> 4 4 0.814           0.834       0.891         0.0960 0.964   0.919
#> 5 5 1.000           0.958       0.985         0.1598 0.837   0.612
#> 6 6 0.954           0.901       0.952         0.0225 1.000   1.000

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

suggest_best_k(res)
#> [1] 5
#> 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
#> SRR945190     1       0          1  1  0
#> SRR945191     1       0          1  1  0
#> SRR945192     1       0          1  1  0
#> SRR945193     1       0          1  1  0
#> SRR945194     1       0          1  1  0
#> SRR945195     1       0          1  1  0
#> SRR945196     1       0          1  1  0
#> SRR945197     1       0          1  1  0
#> SRR945200     1       0          1  1  0
#> SRR945201     1       0          1  1  0
#> SRR945202     1       0          1  1  0
#> SRR945203     1       0          1  1  0
#> SRR945204     1       0          1  1  0
#> SRR945205     1       0          1  1  0
#> SRR945198     1       0          1  1  0
#> SRR945199     1       0          1  1  0
#> SRR945206     1       0          1  1  0
#> SRR945207     1       0          1  1  0
#> SRR945208     1       0          1  1  0
#> SRR945209     1       0          1  1  0
#> SRR945212     1       0          1  1  0
#> SRR945213     1       0          1  1  0
#> SRR945214     2       0          1  0  1
#> SRR945215     2       0          1  0  1
#> SRR945210     1       0          1  1  0
#> SRR945211     1       0          1  1  0
#> SRR945218     2       0          1  0  1
#> SRR945219     2       0          1  0  1
#> SRR945216     2       0          1  0  1
#> SRR945217     2       0          1  0  1
#> SRR945220     2       0          1  0  1
#> SRR945221     2       0          1  0  1
#> SRR945222     2       0          1  0  1
#> SRR945223     2       0          1  0  1
#> SRR945224     2       0          1  0  1
#> SRR945225     2       0          1  0  1
#> SRR945226     2       0          1  0  1
#> SRR945227     2       0          1  0  1
#> SRR945228     2       0          1  0  1
#> SRR945229     2       0          1  0  1
#> SRR945230     2       0          1  0  1
#> SRR945231     2       0          1  0  1
#> SRR945232     2       0          1  0  1
#> SRR945233     2       0          1  0  1
#> SRR945234     2       0          1  0  1
#> SRR945235     2       0          1  0  1
#> SRR945236     2       0          1  0  1
#> SRR945237     2       0          1  0  1
#> SRR945238     2       0          1  0  1
#> SRR945239     2       0          1  0  1
#> SRR945240     2       0          1  0  1
#> SRR945241     2       0          1  0  1
#> SRR945242     2       0          1  0  1
#> SRR945243     2       0          1  0  1
#> SRR945244     2       0          1  0  1
#> SRR945245     2       0          1  0  1
#> SRR945246     2       0          1  0  1
#> SRR945247     2       0          1  0  1
#> SRR945248     2       0          1  0  1
#> SRR945249     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
#> SRR945190     3   0.455      1.000 0.200 0.0 0.800
#> SRR945191     3   0.455      1.000 0.200 0.0 0.800
#> SRR945192     3   0.455      1.000 0.200 0.0 0.800
#> SRR945193     3   0.455      1.000 0.200 0.0 0.800
#> SRR945194     1   0.593      0.260 0.644 0.0 0.356
#> SRR945195     1   0.593      0.260 0.644 0.0 0.356
#> SRR945196     3   0.455      1.000 0.200 0.0 0.800
#> SRR945197     3   0.455      1.000 0.200 0.0 0.800
#> SRR945200     3   0.455      1.000 0.200 0.0 0.800
#> SRR945201     3   0.455      1.000 0.200 0.0 0.800
#> SRR945202     1   0.000      0.929 1.000 0.0 0.000
#> SRR945203     1   0.000      0.929 1.000 0.0 0.000
#> SRR945204     1   0.000      0.929 1.000 0.0 0.000
#> SRR945205     1   0.000      0.929 1.000 0.0 0.000
#> SRR945198     3   0.455      1.000 0.200 0.0 0.800
#> SRR945199     3   0.455      1.000 0.200 0.0 0.800
#> SRR945206     1   0.000      0.929 1.000 0.0 0.000
#> SRR945207     1   0.000      0.929 1.000 0.0 0.000
#> SRR945208     1   0.000      0.929 1.000 0.0 0.000
#> SRR945209     1   0.000      0.929 1.000 0.0 0.000
#> SRR945212     1   0.000      0.929 1.000 0.0 0.000
#> SRR945213     1   0.000      0.929 1.000 0.0 0.000
#> SRR945214     2   0.000      0.937 0.000 1.0 0.000
#> SRR945215     2   0.000      0.937 0.000 1.0 0.000
#> SRR945210     1   0.000      0.929 1.000 0.0 0.000
#> SRR945211     1   0.000      0.929 1.000 0.0 0.000
#> SRR945218     2   0.000      0.937 0.000 1.0 0.000
#> SRR945219     2   0.000      0.937 0.000 1.0 0.000
#> SRR945216     2   0.000      0.937 0.000 1.0 0.000
#> SRR945217     2   0.000      0.937 0.000 1.0 0.000
#> SRR945220     2   0.000      0.937 0.000 1.0 0.000
#> SRR945221     2   0.000      0.937 0.000 1.0 0.000
#> SRR945222     2   0.000      0.937 0.000 1.0 0.000
#> SRR945223     2   0.000      0.937 0.000 1.0 0.000
#> SRR945224     2   0.000      0.937 0.000 1.0 0.000
#> SRR945225     2   0.000      0.937 0.000 1.0 0.000
#> SRR945226     2   0.000      0.937 0.000 1.0 0.000
#> SRR945227     2   0.000      0.937 0.000 1.0 0.000
#> SRR945228     2   0.000      0.937 0.000 1.0 0.000
#> SRR945229     2   0.000      0.937 0.000 1.0 0.000
#> SRR945230     2   0.000      0.937 0.000 1.0 0.000
#> SRR945231     2   0.000      0.937 0.000 1.0 0.000
#> SRR945232     2   0.000      0.937 0.000 1.0 0.000
#> SRR945233     2   0.000      0.937 0.000 1.0 0.000
#> SRR945234     2   0.000      0.937 0.000 1.0 0.000
#> SRR945235     2   0.000      0.937 0.000 1.0 0.000
#> SRR945236     2   0.000      0.937 0.000 1.0 0.000
#> SRR945237     2   0.000      0.937 0.000 1.0 0.000
#> SRR945238     2   0.455      0.867 0.000 0.8 0.200
#> SRR945239     2   0.455      0.867 0.000 0.8 0.200
#> SRR945240     2   0.455      0.867 0.000 0.8 0.200
#> SRR945241     2   0.455      0.867 0.000 0.8 0.200
#> SRR945242     2   0.455      0.867 0.000 0.8 0.200
#> SRR945243     2   0.455      0.867 0.000 0.8 0.200
#> SRR945244     2   0.455      0.867 0.000 0.8 0.200
#> SRR945245     2   0.455      0.867 0.000 0.8 0.200
#> SRR945246     2   0.455      0.867 0.000 0.8 0.200
#> SRR945247     2   0.455      0.867 0.000 0.8 0.200
#> SRR945248     2   0.455      0.867 0.000 0.8 0.200
#> SRR945249     2   0.455      0.867 0.000 0.8 0.200

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1  p2  p3    p4
#> SRR945190     1  0.0000      0.899 1.000 0.0 0.0 0.000
#> SRR945191     1  0.0000      0.899 1.000 0.0 0.0 0.000
#> SRR945192     1  0.0000      0.899 1.000 0.0 0.0 0.000
#> SRR945193     1  0.0000      0.899 1.000 0.0 0.0 0.000
#> SRR945194     1  0.4955      0.279 0.556 0.0 0.0 0.444
#> SRR945195     1  0.4955      0.279 0.556 0.0 0.0 0.444
#> SRR945196     1  0.0000      0.899 1.000 0.0 0.0 0.000
#> SRR945197     1  0.0000      0.899 1.000 0.0 0.0 0.000
#> SRR945200     1  0.0000      0.899 1.000 0.0 0.0 0.000
#> SRR945201     1  0.0000      0.899 1.000 0.0 0.0 0.000
#> SRR945202     4  0.0336      1.000 0.008 0.0 0.0 0.992
#> SRR945203     4  0.0336      1.000 0.008 0.0 0.0 0.992
#> SRR945204     4  0.0336      1.000 0.008 0.0 0.0 0.992
#> SRR945205     4  0.0336      1.000 0.008 0.0 0.0 0.992
#> SRR945198     1  0.0000      0.899 1.000 0.0 0.0 0.000
#> SRR945199     1  0.0000      0.899 1.000 0.0 0.0 0.000
#> SRR945206     4  0.0336      1.000 0.008 0.0 0.0 0.992
#> SRR945207     4  0.0336      1.000 0.008 0.0 0.0 0.992
#> SRR945208     4  0.0336      1.000 0.008 0.0 0.0 0.992
#> SRR945209     4  0.0336      1.000 0.008 0.0 0.0 0.992
#> SRR945212     4  0.0336      1.000 0.008 0.0 0.0 0.992
#> SRR945213     4  0.0336      1.000 0.008 0.0 0.0 0.992
#> SRR945214     2  0.0000      0.854 0.000 1.0 0.0 0.000
#> SRR945215     2  0.0000      0.854 0.000 1.0 0.0 0.000
#> SRR945210     3  0.4855      1.000 0.000 0.0 0.6 0.400
#> SRR945211     3  0.4855      1.000 0.000 0.0 0.6 0.400
#> SRR945218     2  0.0000      0.854 0.000 1.0 0.0 0.000
#> SRR945219     2  0.0000      0.854 0.000 1.0 0.0 0.000
#> SRR945216     2  0.0000      0.854 0.000 1.0 0.0 0.000
#> SRR945217     2  0.0000      0.854 0.000 1.0 0.0 0.000
#> SRR945220     2  0.0000      0.854 0.000 1.0 0.0 0.000
#> SRR945221     2  0.0000      0.854 0.000 1.0 0.0 0.000
#> SRR945222     2  0.0000      0.854 0.000 1.0 0.0 0.000
#> SRR945223     2  0.0000      0.854 0.000 1.0 0.0 0.000
#> SRR945224     2  0.0000      0.854 0.000 1.0 0.0 0.000
#> SRR945225     2  0.0000      0.854 0.000 1.0 0.0 0.000
#> SRR945226     2  0.0000      0.854 0.000 1.0 0.0 0.000
#> SRR945227     2  0.0000      0.854 0.000 1.0 0.0 0.000
#> SRR945228     2  0.0000      0.854 0.000 1.0 0.0 0.000
#> SRR945229     2  0.0000      0.854 0.000 1.0 0.0 0.000
#> SRR945230     2  0.0000      0.854 0.000 1.0 0.0 0.000
#> SRR945231     2  0.0000      0.854 0.000 1.0 0.0 0.000
#> SRR945232     2  0.0000      0.854 0.000 1.0 0.0 0.000
#> SRR945233     2  0.0000      0.854 0.000 1.0 0.0 0.000
#> SRR945234     2  0.0000      0.854 0.000 1.0 0.0 0.000
#> SRR945235     2  0.0000      0.854 0.000 1.0 0.0 0.000
#> SRR945236     2  0.0000      0.854 0.000 1.0 0.0 0.000
#> SRR945237     2  0.0000      0.854 0.000 1.0 0.0 0.000
#> SRR945238     2  0.4855      0.665 0.000 0.6 0.4 0.000
#> SRR945239     2  0.4855      0.665 0.000 0.6 0.4 0.000
#> SRR945240     2  0.4855      0.665 0.000 0.6 0.4 0.000
#> SRR945241     2  0.4855      0.665 0.000 0.6 0.4 0.000
#> SRR945242     2  0.4855      0.665 0.000 0.6 0.4 0.000
#> SRR945243     2  0.4855      0.665 0.000 0.6 0.4 0.000
#> SRR945244     2  0.4855      0.665 0.000 0.6 0.4 0.000
#> SRR945245     2  0.4855      0.665 0.000 0.6 0.4 0.000
#> SRR945246     2  0.4855      0.665 0.000 0.6 0.4 0.000
#> SRR945247     2  0.4855      0.665 0.000 0.6 0.4 0.000
#> SRR945248     2  0.4855      0.665 0.000 0.6 0.4 0.000
#> SRR945249     2  0.4855      0.665 0.000 0.6 0.4 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
#> SRR945190     1   0.000      0.893 1.000  0  0 0.000  0
#> SRR945191     1   0.000      0.893 1.000  0  0 0.000  0
#> SRR945192     1   0.000      0.893 1.000  0  0 0.000  0
#> SRR945193     1   0.000      0.893 1.000  0  0 0.000  0
#> SRR945194     1   0.427      0.274 0.556  0  0 0.444  0
#> SRR945195     1   0.427      0.274 0.556  0  0 0.444  0
#> SRR945196     1   0.000      0.893 1.000  0  0 0.000  0
#> SRR945197     1   0.000      0.893 1.000  0  0 0.000  0
#> SRR945200     1   0.000      0.893 1.000  0  0 0.000  0
#> SRR945201     1   0.000      0.893 1.000  0  0 0.000  0
#> SRR945202     4   0.000      1.000 0.000  0  0 1.000  0
#> SRR945203     4   0.000      1.000 0.000  0  0 1.000  0
#> SRR945204     4   0.000      1.000 0.000  0  0 1.000  0
#> SRR945205     4   0.000      1.000 0.000  0  0 1.000  0
#> SRR945198     1   0.000      0.893 1.000  0  0 0.000  0
#> SRR945199     1   0.000      0.893 1.000  0  0 0.000  0
#> SRR945206     4   0.000      1.000 0.000  0  0 1.000  0
#> SRR945207     4   0.000      1.000 0.000  0  0 1.000  0
#> SRR945208     4   0.000      1.000 0.000  0  0 1.000  0
#> SRR945209     4   0.000      1.000 0.000  0  0 1.000  0
#> SRR945212     4   0.000      1.000 0.000  0  0 1.000  0
#> SRR945213     4   0.000      1.000 0.000  0  0 1.000  0
#> SRR945214     2   0.000      1.000 0.000  1  0 0.000  0
#> SRR945215     2   0.000      1.000 0.000  1  0 0.000  0
#> SRR945210     5   0.000      1.000 0.000  0  0 0.000  1
#> SRR945211     5   0.000      1.000 0.000  0  0 0.000  1
#> SRR945218     2   0.000      1.000 0.000  1  0 0.000  0
#> SRR945219     2   0.000      1.000 0.000  1  0 0.000  0
#> SRR945216     2   0.000      1.000 0.000  1  0 0.000  0
#> SRR945217     2   0.000      1.000 0.000  1  0 0.000  0
#> SRR945220     2   0.000      1.000 0.000  1  0 0.000  0
#> SRR945221     2   0.000      1.000 0.000  1  0 0.000  0
#> SRR945222     2   0.000      1.000 0.000  1  0 0.000  0
#> SRR945223     2   0.000      1.000 0.000  1  0 0.000  0
#> SRR945224     2   0.000      1.000 0.000  1  0 0.000  0
#> SRR945225     2   0.000      1.000 0.000  1  0 0.000  0
#> SRR945226     2   0.000      1.000 0.000  1  0 0.000  0
#> SRR945227     2   0.000      1.000 0.000  1  0 0.000  0
#> SRR945228     2   0.000      1.000 0.000  1  0 0.000  0
#> SRR945229     2   0.000      1.000 0.000  1  0 0.000  0
#> SRR945230     2   0.000      1.000 0.000  1  0 0.000  0
#> SRR945231     2   0.000      1.000 0.000  1  0 0.000  0
#> SRR945232     2   0.000      1.000 0.000  1  0 0.000  0
#> SRR945233     2   0.000      1.000 0.000  1  0 0.000  0
#> SRR945234     2   0.000      1.000 0.000  1  0 0.000  0
#> SRR945235     2   0.000      1.000 0.000  1  0 0.000  0
#> SRR945236     2   0.000      1.000 0.000  1  0 0.000  0
#> SRR945237     2   0.000      1.000 0.000  1  0 0.000  0
#> SRR945238     3   0.000      1.000 0.000  0  1 0.000  0
#> SRR945239     3   0.000      1.000 0.000  0  1 0.000  0
#> SRR945240     3   0.000      1.000 0.000  0  1 0.000  0
#> SRR945241     3   0.000      1.000 0.000  0  1 0.000  0
#> SRR945242     3   0.000      1.000 0.000  0  1 0.000  0
#> SRR945243     3   0.000      1.000 0.000  0  1 0.000  0
#> SRR945244     3   0.000      1.000 0.000  0  1 0.000  0
#> SRR945245     3   0.000      1.000 0.000  0  1 0.000  0
#> SRR945246     3   0.000      1.000 0.000  0  1 0.000  0
#> SRR945247     3   0.000      1.000 0.000  0  1 0.000  0
#> SRR945248     3   0.000      1.000 0.000  0  1 0.000  0
#> SRR945249     3   0.000      1.000 0.000  0  1 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
#> SRR945190     1   0.000      0.915 1.000 0.000  0 0.000  0 NA
#> SRR945191     1   0.000      0.915 1.000 0.000  0 0.000  0 NA
#> SRR945192     1   0.000      0.915 1.000 0.000  0 0.000  0 NA
#> SRR945193     1   0.000      0.915 1.000 0.000  0 0.000  0 NA
#> SRR945194     1   0.383      0.448 0.556 0.000  0 0.000  0 NA
#> SRR945195     1   0.383      0.448 0.556 0.000  0 0.000  0 NA
#> SRR945196     1   0.000      0.915 1.000 0.000  0 0.000  0 NA
#> SRR945197     1   0.000      0.915 1.000 0.000  0 0.000  0 NA
#> SRR945200     1   0.000      0.915 1.000 0.000  0 0.000  0 NA
#> SRR945201     1   0.000      0.915 1.000 0.000  0 0.000  0 NA
#> SRR945202     4   0.000      0.817 0.000 0.000  0 1.000  0 NA
#> SRR945203     4   0.000      0.817 0.000 0.000  0 1.000  0 NA
#> SRR945204     4   0.383      0.445 0.000 0.000  0 0.556  0 NA
#> SRR945205     4   0.383      0.445 0.000 0.000  0 0.556  0 NA
#> SRR945198     1   0.000      0.915 1.000 0.000  0 0.000  0 NA
#> SRR945199     1   0.000      0.915 1.000 0.000  0 0.000  0 NA
#> SRR945206     4   0.350      0.601 0.000 0.000  0 0.680  0 NA
#> SRR945207     4   0.350      0.601 0.000 0.000  0 0.680  0 NA
#> SRR945208     4   0.000      0.817 0.000 0.000  0 1.000  0 NA
#> SRR945209     4   0.000      0.817 0.000 0.000  0 1.000  0 NA
#> SRR945212     4   0.000      0.817 0.000 0.000  0 1.000  0 NA
#> SRR945213     4   0.000      0.817 0.000 0.000  0 1.000  0 NA
#> SRR945214     2   0.000      0.980 0.000 1.000  0 0.000  0 NA
#> SRR945215     2   0.000      0.980 0.000 1.000  0 0.000  0 NA
#> SRR945210     5   0.000      1.000 0.000 0.000  0 0.000  1 NA
#> SRR945211     5   0.000      1.000 0.000 0.000  0 0.000  1 NA
#> SRR945218     2   0.000      0.980 0.000 1.000  0 0.000  0 NA
#> SRR945219     2   0.000      0.980 0.000 1.000  0 0.000  0 NA
#> SRR945216     2   0.000      0.980 0.000 1.000  0 0.000  0 NA
#> SRR945217     2   0.000      0.980 0.000 1.000  0 0.000  0 NA
#> SRR945220     2   0.000      0.980 0.000 1.000  0 0.000  0 NA
#> SRR945221     2   0.000      0.980 0.000 1.000  0 0.000  0 NA
#> SRR945222     2   0.000      0.980 0.000 1.000  0 0.000  0 NA
#> SRR945223     2   0.000      0.980 0.000 1.000  0 0.000  0 NA
#> SRR945224     2   0.000      0.980 0.000 1.000  0 0.000  0 NA
#> SRR945225     2   0.000      0.980 0.000 1.000  0 0.000  0 NA
#> SRR945226     2   0.000      0.980 0.000 1.000  0 0.000  0 NA
#> SRR945227     2   0.000      0.980 0.000 1.000  0 0.000  0 NA
#> SRR945228     2   0.000      0.980 0.000 1.000  0 0.000  0 NA
#> SRR945229     2   0.000      0.980 0.000 1.000  0 0.000  0 NA
#> SRR945230     2   0.305      0.731 0.000 0.764  0 0.000  0 NA
#> SRR945231     2   0.305      0.731 0.000 0.764  0 0.000  0 NA
#> SRR945232     2   0.000      0.980 0.000 1.000  0 0.000  0 NA
#> SRR945233     2   0.000      0.980 0.000 1.000  0 0.000  0 NA
#> SRR945234     2   0.000      0.980 0.000 1.000  0 0.000  0 NA
#> SRR945235     2   0.000      0.980 0.000 1.000  0 0.000  0 NA
#> SRR945236     2   0.000      0.980 0.000 1.000  0 0.000  0 NA
#> SRR945237     2   0.000      0.980 0.000 1.000  0 0.000  0 NA
#> SRR945238     3   0.000      1.000 0.000 0.000  1 0.000  0 NA
#> SRR945239     3   0.000      1.000 0.000 0.000  1 0.000  0 NA
#> SRR945240     3   0.000      1.000 0.000 0.000  1 0.000  0 NA
#> SRR945241     3   0.000      1.000 0.000 0.000  1 0.000  0 NA
#> SRR945242     3   0.000      1.000 0.000 0.000  1 0.000  0 NA
#> SRR945243     3   0.000      1.000 0.000 0.000  1 0.000  0 NA
#> SRR945244     3   0.000      1.000 0.000 0.000  1 0.000  0 NA
#> SRR945245     3   0.000      1.000 0.000 0.000  1 0.000  0 NA
#> SRR945246     3   0.000      1.000 0.000 0.000  1 0.000  0 NA
#> SRR945247     3   0.000      1.000 0.000 0.000  1 0.000  0 NA
#> SRR945248     3   0.000      1.000 0.000 0.000  1 0.000  0 NA
#> SRR945249     3   0.000      1.000 0.000 0.000  1 0.000  0 NA

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-hclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-hclust-collect-classes

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


MAD:kmeans**

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

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

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

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

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

collect_plots(res)

plot of chunk MAD-kmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.980       0.973         0.4777 0.512   0.512
#> 3 3 0.745           0.939       0.862         0.2999 0.837   0.682
#> 4 4 0.654           0.843       0.756         0.1214 0.921   0.773
#> 5 5 0.770           0.848       0.799         0.0761 0.975   0.912
#> 6 6 0.717           0.720       0.743         0.0499 0.928   0.730

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

suggest_best_k(res)
#> [1] 2

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> SRR945190     1   0.000      1.000 1.000 0.000
#> SRR945191     1   0.000      1.000 1.000 0.000
#> SRR945192     1   0.000      1.000 1.000 0.000
#> SRR945193     1   0.000      1.000 1.000 0.000
#> SRR945194     1   0.000      1.000 1.000 0.000
#> SRR945195     1   0.000      1.000 1.000 0.000
#> SRR945196     1   0.000      1.000 1.000 0.000
#> SRR945197     1   0.000      1.000 1.000 0.000
#> SRR945200     1   0.000      1.000 1.000 0.000
#> SRR945201     1   0.000      1.000 1.000 0.000
#> SRR945202     1   0.000      1.000 1.000 0.000
#> SRR945203     1   0.000      1.000 1.000 0.000
#> SRR945204     1   0.000      1.000 1.000 0.000
#> SRR945205     1   0.000      1.000 1.000 0.000
#> SRR945198     1   0.000      1.000 1.000 0.000
#> SRR945199     1   0.000      1.000 1.000 0.000
#> SRR945206     1   0.000      1.000 1.000 0.000
#> SRR945207     1   0.000      1.000 1.000 0.000
#> SRR945208     1   0.000      1.000 1.000 0.000
#> SRR945209     1   0.000      1.000 1.000 0.000
#> SRR945212     1   0.000      1.000 1.000 0.000
#> SRR945213     1   0.000      1.000 1.000 0.000
#> SRR945214     2   0.358      0.975 0.068 0.932
#> SRR945215     2   0.358      0.975 0.068 0.932
#> SRR945210     1   0.000      1.000 1.000 0.000
#> SRR945211     1   0.000      1.000 1.000 0.000
#> SRR945218     2   0.358      0.975 0.068 0.932
#> SRR945219     2   0.358      0.975 0.068 0.932
#> SRR945216     2   0.358      0.975 0.068 0.932
#> SRR945217     2   0.358      0.975 0.068 0.932
#> SRR945220     2   0.358      0.975 0.068 0.932
#> SRR945221     2   0.358      0.975 0.068 0.932
#> SRR945222     2   0.358      0.975 0.068 0.932
#> SRR945223     2   0.358      0.975 0.068 0.932
#> SRR945224     2   0.358      0.975 0.068 0.932
#> SRR945225     2   0.358      0.975 0.068 0.932
#> SRR945226     2   0.358      0.975 0.068 0.932
#> SRR945227     2   0.358      0.975 0.068 0.932
#> SRR945228     2   0.358      0.975 0.068 0.932
#> SRR945229     2   0.358      0.975 0.068 0.932
#> SRR945230     2   0.358      0.975 0.068 0.932
#> SRR945231     2   0.358      0.975 0.068 0.932
#> SRR945232     2   0.358      0.975 0.068 0.932
#> SRR945233     2   0.358      0.975 0.068 0.932
#> SRR945234     2   0.358      0.975 0.068 0.932
#> SRR945235     2   0.358      0.975 0.068 0.932
#> SRR945236     2   0.358      0.975 0.068 0.932
#> SRR945237     2   0.358      0.975 0.068 0.932
#> SRR945238     2   0.000      0.951 0.000 1.000
#> SRR945239     2   0.000      0.951 0.000 1.000
#> SRR945240     2   0.000      0.951 0.000 1.000
#> SRR945241     2   0.000      0.951 0.000 1.000
#> SRR945242     2   0.000      0.951 0.000 1.000
#> SRR945243     2   0.000      0.951 0.000 1.000
#> SRR945244     2   0.000      0.951 0.000 1.000
#> SRR945245     2   0.000      0.951 0.000 1.000
#> SRR945246     2   0.000      0.951 0.000 1.000
#> SRR945247     2   0.000      0.951 0.000 1.000
#> SRR945248     2   0.000      0.951 0.000 1.000
#> SRR945249     2   0.000      0.951 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
#> SRR945190     1  0.5882      0.839 0.652 0.00 0.348
#> SRR945191     1  0.5882      0.839 0.652 0.00 0.348
#> SRR945192     1  0.5882      0.839 0.652 0.00 0.348
#> SRR945193     1  0.5882      0.839 0.652 0.00 0.348
#> SRR945194     1  0.4931      0.851 0.768 0.00 0.232
#> SRR945195     1  0.4931      0.851 0.768 0.00 0.232
#> SRR945196     1  0.5882      0.839 0.652 0.00 0.348
#> SRR945197     1  0.5882      0.839 0.652 0.00 0.348
#> SRR945200     1  0.5882      0.839 0.652 0.00 0.348
#> SRR945201     1  0.5882      0.839 0.652 0.00 0.348
#> SRR945202     1  0.0000      0.857 1.000 0.00 0.000
#> SRR945203     1  0.0000      0.857 1.000 0.00 0.000
#> SRR945204     1  0.0000      0.857 1.000 0.00 0.000
#> SRR945205     1  0.0000      0.857 1.000 0.00 0.000
#> SRR945198     1  0.5882      0.839 0.652 0.00 0.348
#> SRR945199     1  0.5882      0.839 0.652 0.00 0.348
#> SRR945206     1  0.0237      0.855 0.996 0.00 0.004
#> SRR945207     1  0.0237      0.855 0.996 0.00 0.004
#> SRR945208     1  0.0000      0.857 1.000 0.00 0.000
#> SRR945209     1  0.0000      0.857 1.000 0.00 0.000
#> SRR945212     1  0.0000      0.857 1.000 0.00 0.000
#> SRR945213     1  0.0000      0.857 1.000 0.00 0.000
#> SRR945214     2  0.0000      1.000 0.000 1.00 0.000
#> SRR945215     2  0.0000      1.000 0.000 1.00 0.000
#> SRR945210     1  0.0424      0.854 0.992 0.00 0.008
#> SRR945211     1  0.0424      0.854 0.992 0.00 0.008
#> SRR945218     2  0.0000      1.000 0.000 1.00 0.000
#> SRR945219     2  0.0000      1.000 0.000 1.00 0.000
#> SRR945216     2  0.0000      1.000 0.000 1.00 0.000
#> SRR945217     2  0.0000      1.000 0.000 1.00 0.000
#> SRR945220     2  0.0000      1.000 0.000 1.00 0.000
#> SRR945221     2  0.0000      1.000 0.000 1.00 0.000
#> SRR945222     2  0.0000      1.000 0.000 1.00 0.000
#> SRR945223     2  0.0000      1.000 0.000 1.00 0.000
#> SRR945224     2  0.0000      1.000 0.000 1.00 0.000
#> SRR945225     2  0.0000      1.000 0.000 1.00 0.000
#> SRR945226     2  0.0000      1.000 0.000 1.00 0.000
#> SRR945227     2  0.0000      1.000 0.000 1.00 0.000
#> SRR945228     2  0.0000      1.000 0.000 1.00 0.000
#> SRR945229     2  0.0000      1.000 0.000 1.00 0.000
#> SRR945230     2  0.0000      1.000 0.000 1.00 0.000
#> SRR945231     2  0.0000      1.000 0.000 1.00 0.000
#> SRR945232     2  0.0000      1.000 0.000 1.00 0.000
#> SRR945233     2  0.0000      1.000 0.000 1.00 0.000
#> SRR945234     2  0.0000      1.000 0.000 1.00 0.000
#> SRR945235     2  0.0000      1.000 0.000 1.00 0.000
#> SRR945236     2  0.0000      1.000 0.000 1.00 0.000
#> SRR945237     2  0.0000      1.000 0.000 1.00 0.000
#> SRR945238     3  0.5948      1.000 0.000 0.36 0.640
#> SRR945239     3  0.5948      1.000 0.000 0.36 0.640
#> SRR945240     3  0.5948      1.000 0.000 0.36 0.640
#> SRR945241     3  0.5948      1.000 0.000 0.36 0.640
#> SRR945242     3  0.5948      1.000 0.000 0.36 0.640
#> SRR945243     3  0.5948      1.000 0.000 0.36 0.640
#> SRR945244     3  0.5948      1.000 0.000 0.36 0.640
#> SRR945245     3  0.5948      1.000 0.000 0.36 0.640
#> SRR945246     3  0.5948      1.000 0.000 0.36 0.640
#> SRR945247     3  0.5948      1.000 0.000 0.36 0.640
#> SRR945248     3  0.5948      1.000 0.000 0.36 0.640
#> SRR945249     3  0.5948      1.000 0.000 0.36 0.640

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> SRR945190     1  0.5132      0.971 0.548 0.000 0.004 0.448
#> SRR945191     1  0.5132      0.971 0.548 0.000 0.004 0.448
#> SRR945192     1  0.5132      0.971 0.548 0.000 0.004 0.448
#> SRR945193     1  0.5132      0.971 0.548 0.000 0.004 0.448
#> SRR945194     4  0.6398     -0.557 0.344 0.000 0.080 0.576
#> SRR945195     4  0.6398     -0.557 0.344 0.000 0.080 0.576
#> SRR945196     1  0.5996      0.957 0.512 0.000 0.040 0.448
#> SRR945197     1  0.5996      0.957 0.512 0.000 0.040 0.448
#> SRR945200     1  0.5996      0.957 0.512 0.000 0.040 0.448
#> SRR945201     1  0.5996      0.957 0.512 0.000 0.040 0.448
#> SRR945202     4  0.0469      0.854 0.000 0.000 0.012 0.988
#> SRR945203     4  0.0469      0.854 0.000 0.000 0.012 0.988
#> SRR945204     4  0.0592      0.853 0.000 0.000 0.016 0.984
#> SRR945205     4  0.0592      0.853 0.000 0.000 0.016 0.984
#> SRR945198     1  0.4961      0.971 0.552 0.000 0.000 0.448
#> SRR945199     1  0.4961      0.971 0.552 0.000 0.000 0.448
#> SRR945206     4  0.1109      0.845 0.004 0.000 0.028 0.968
#> SRR945207     4  0.1109      0.845 0.004 0.000 0.028 0.968
#> SRR945208     4  0.0469      0.854 0.000 0.000 0.012 0.988
#> SRR945209     4  0.0469      0.854 0.000 0.000 0.012 0.988
#> SRR945212     4  0.0469      0.854 0.000 0.000 0.012 0.988
#> SRR945213     4  0.0469      0.854 0.000 0.000 0.012 0.988
#> SRR945214     2  0.3649      0.857 0.204 0.796 0.000 0.000
#> SRR945215     2  0.3649      0.857 0.204 0.796 0.000 0.000
#> SRR945210     4  0.1867      0.821 0.000 0.000 0.072 0.928
#> SRR945211     4  0.1867      0.821 0.000 0.000 0.072 0.928
#> SRR945218     2  0.3569      0.857 0.196 0.804 0.000 0.000
#> SRR945219     2  0.3569      0.857 0.196 0.804 0.000 0.000
#> SRR945216     2  0.3649      0.857 0.204 0.796 0.000 0.000
#> SRR945217     2  0.3649      0.857 0.204 0.796 0.000 0.000
#> SRR945220     2  0.3688      0.856 0.208 0.792 0.000 0.000
#> SRR945221     2  0.3688      0.856 0.208 0.792 0.000 0.000
#> SRR945222     2  0.3649      0.857 0.204 0.796 0.000 0.000
#> SRR945223     2  0.3649      0.857 0.204 0.796 0.000 0.000
#> SRR945224     2  0.3688      0.856 0.208 0.792 0.000 0.000
#> SRR945225     2  0.3688      0.856 0.208 0.792 0.000 0.000
#> SRR945226     2  0.0817      0.843 0.024 0.976 0.000 0.000
#> SRR945227     2  0.0817      0.843 0.024 0.976 0.000 0.000
#> SRR945228     2  0.2589      0.799 0.116 0.884 0.000 0.000
#> SRR945229     2  0.2589      0.799 0.116 0.884 0.000 0.000
#> SRR945230     2  0.3306      0.771 0.156 0.840 0.004 0.000
#> SRR945231     2  0.3306      0.771 0.156 0.840 0.004 0.000
#> SRR945232     2  0.0592      0.847 0.016 0.984 0.000 0.000
#> SRR945233     2  0.0592      0.847 0.016 0.984 0.000 0.000
#> SRR945234     2  0.0469      0.847 0.012 0.988 0.000 0.000
#> SRR945235     2  0.0469      0.847 0.012 0.988 0.000 0.000
#> SRR945236     2  0.2216      0.814 0.092 0.908 0.000 0.000
#> SRR945237     2  0.2216      0.814 0.092 0.908 0.000 0.000
#> SRR945238     3  0.4677      0.976 0.048 0.176 0.776 0.000
#> SRR945239     3  0.4677      0.976 0.048 0.176 0.776 0.000
#> SRR945240     3  0.3539      0.981 0.004 0.176 0.820 0.000
#> SRR945241     3  0.3539      0.981 0.004 0.176 0.820 0.000
#> SRR945242     3  0.3808      0.980 0.012 0.176 0.812 0.000
#> SRR945243     3  0.3808      0.980 0.012 0.176 0.812 0.000
#> SRR945244     3  0.4511      0.978 0.040 0.176 0.784 0.000
#> SRR945245     3  0.4511      0.978 0.040 0.176 0.784 0.000
#> SRR945246     3  0.3681      0.980 0.008 0.176 0.816 0.000
#> SRR945247     3  0.3681      0.980 0.008 0.176 0.816 0.000
#> SRR945248     3  0.4756      0.974 0.052 0.176 0.772 0.000
#> SRR945249     3  0.4756      0.974 0.052 0.176 0.772 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
#> SRR945190     1  0.4216      0.908 0.720 0.000 0.008 0.260 NA
#> SRR945191     1  0.4216      0.908 0.720 0.000 0.008 0.260 NA
#> SRR945192     1  0.4313      0.908 0.716 0.000 0.008 0.260 NA
#> SRR945193     1  0.4313      0.908 0.716 0.000 0.008 0.260 NA
#> SRR945194     1  0.6732      0.683 0.460 0.000 0.028 0.388 NA
#> SRR945195     1  0.6732      0.683 0.460 0.000 0.028 0.388 NA
#> SRR945196     1  0.4854      0.904 0.680 0.000 0.000 0.260 NA
#> SRR945197     1  0.4854      0.904 0.680 0.000 0.000 0.260 NA
#> SRR945200     1  0.5694      0.888 0.628 0.000 0.008 0.260 NA
#> SRR945201     1  0.5694      0.888 0.628 0.000 0.008 0.260 NA
#> SRR945202     4  0.0671      0.937 0.000 0.000 0.004 0.980 NA
#> SRR945203     4  0.0671      0.937 0.000 0.000 0.004 0.980 NA
#> SRR945204     4  0.1430      0.925 0.000 0.000 0.004 0.944 NA
#> SRR945205     4  0.1430      0.925 0.000 0.000 0.004 0.944 NA
#> SRR945198     1  0.3989      0.909 0.728 0.000 0.004 0.260 NA
#> SRR945199     1  0.3989      0.909 0.728 0.000 0.004 0.260 NA
#> SRR945206     4  0.1281      0.930 0.000 0.000 0.032 0.956 NA
#> SRR945207     4  0.1281      0.930 0.000 0.000 0.032 0.956 NA
#> SRR945208     4  0.0671      0.936 0.000 0.000 0.004 0.980 NA
#> SRR945209     4  0.0671      0.936 0.000 0.000 0.004 0.980 NA
#> SRR945212     4  0.0798      0.935 0.000 0.000 0.008 0.976 NA
#> SRR945213     4  0.0798      0.935 0.000 0.000 0.008 0.976 NA
#> SRR945214     2  0.0290      0.778 0.008 0.992 0.000 0.000 NA
#> SRR945215     2  0.0290      0.778 0.008 0.992 0.000 0.000 NA
#> SRR945210     4  0.3488      0.826 0.008 0.000 0.008 0.804 NA
#> SRR945211     4  0.3488      0.826 0.008 0.000 0.008 0.804 NA
#> SRR945218     2  0.1661      0.785 0.024 0.940 0.000 0.000 NA
#> SRR945219     2  0.1661      0.785 0.024 0.940 0.000 0.000 NA
#> SRR945216     2  0.0290      0.778 0.008 0.992 0.000 0.000 NA
#> SRR945217     2  0.0290      0.778 0.008 0.992 0.000 0.000 NA
#> SRR945220     2  0.0162      0.778 0.000 0.996 0.000 0.000 NA
#> SRR945221     2  0.0162      0.778 0.000 0.996 0.000 0.000 NA
#> SRR945222     2  0.2193      0.787 0.028 0.912 0.000 0.000 NA
#> SRR945223     2  0.2193      0.787 0.028 0.912 0.000 0.000 NA
#> SRR945224     2  0.0162      0.778 0.000 0.996 0.000 0.000 NA
#> SRR945225     2  0.0162      0.778 0.000 0.996 0.000 0.000 NA
#> SRR945226     2  0.4551      0.773 0.016 0.616 0.000 0.000 NA
#> SRR945227     2  0.4551      0.773 0.016 0.616 0.000 0.000 NA
#> SRR945228     2  0.4735      0.727 0.016 0.524 0.000 0.000 NA
#> SRR945229     2  0.4735      0.727 0.016 0.524 0.000 0.000 NA
#> SRR945230     2  0.5844      0.679 0.096 0.484 0.000 0.000 NA
#> SRR945231     2  0.5844      0.679 0.096 0.484 0.000 0.000 NA
#> SRR945232     2  0.4525      0.775 0.016 0.624 0.000 0.000 NA
#> SRR945233     2  0.4525      0.775 0.016 0.624 0.000 0.000 NA
#> SRR945234     2  0.4654      0.776 0.024 0.628 0.000 0.000 NA
#> SRR945235     2  0.4654      0.776 0.024 0.628 0.000 0.000 NA
#> SRR945236     2  0.4291      0.737 0.000 0.536 0.000 0.000 NA
#> SRR945237     2  0.4291      0.737 0.000 0.536 0.000 0.000 NA
#> SRR945238     3  0.4831      0.930 0.080 0.076 0.776 0.000 NA
#> SRR945239     3  0.4831      0.930 0.080 0.076 0.776 0.000 NA
#> SRR945240     3  0.1991      0.943 0.004 0.076 0.916 0.000 NA
#> SRR945241     3  0.1991      0.943 0.004 0.076 0.916 0.000 NA
#> SRR945242     3  0.3137      0.939 0.024 0.076 0.872 0.000 NA
#> SRR945243     3  0.3137      0.939 0.024 0.076 0.872 0.000 NA
#> SRR945244     3  0.4525      0.936 0.072 0.076 0.796 0.000 NA
#> SRR945245     3  0.4525      0.936 0.072 0.076 0.796 0.000 NA
#> SRR945246     3  0.2758      0.937 0.012 0.076 0.888 0.000 NA
#> SRR945247     3  0.2758      0.937 0.012 0.076 0.888 0.000 NA
#> SRR945248     3  0.4806      0.927 0.044 0.076 0.772 0.000 NA
#> SRR945249     3  0.4806      0.927 0.044 0.076 0.772 0.000 NA

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5 p6
#> SRR945190     1  0.3354      0.894 0.792 0.000 0.000 0.184 0.016 NA
#> SRR945191     1  0.3354      0.894 0.792 0.000 0.000 0.184 0.016 NA
#> SRR945192     1  0.3264      0.894 0.796 0.000 0.000 0.184 0.012 NA
#> SRR945193     1  0.3264      0.894 0.796 0.000 0.000 0.184 0.012 NA
#> SRR945194     1  0.6514      0.578 0.448 0.000 0.000 0.348 0.152 NA
#> SRR945195     1  0.6514      0.578 0.448 0.000 0.000 0.348 0.152 NA
#> SRR945196     1  0.4636      0.886 0.728 0.000 0.016 0.184 0.060 NA
#> SRR945197     1  0.4636      0.886 0.728 0.000 0.016 0.184 0.060 NA
#> SRR945200     1  0.4789      0.878 0.708 0.000 0.004 0.184 0.088 NA
#> SRR945201     1  0.4789      0.878 0.708 0.000 0.004 0.184 0.088 NA
#> SRR945202     4  0.1710      0.902 0.012 0.000 0.008 0.940 0.020 NA
#> SRR945203     4  0.1710      0.902 0.012 0.000 0.008 0.940 0.020 NA
#> SRR945204     4  0.2639      0.876 0.000 0.000 0.008 0.880 0.048 NA
#> SRR945205     4  0.2639      0.876 0.000 0.000 0.008 0.880 0.048 NA
#> SRR945198     1  0.2946      0.895 0.808 0.000 0.004 0.184 0.004 NA
#> SRR945199     1  0.2946      0.895 0.808 0.000 0.004 0.184 0.004 NA
#> SRR945206     4  0.2596      0.883 0.012 0.000 0.008 0.892 0.056 NA
#> SRR945207     4  0.2582      0.883 0.012 0.000 0.008 0.892 0.060 NA
#> SRR945208     4  0.1086      0.902 0.012 0.000 0.000 0.964 0.012 NA
#> SRR945209     4  0.1086      0.902 0.012 0.000 0.000 0.964 0.012 NA
#> SRR945212     4  0.1086      0.902 0.012 0.000 0.000 0.964 0.012 NA
#> SRR945213     4  0.1086      0.902 0.012 0.000 0.000 0.964 0.012 NA
#> SRR945214     5  0.4817      0.932 0.040 0.404 0.000 0.000 0.548 NA
#> SRR945215     5  0.4817      0.932 0.040 0.404 0.000 0.000 0.548 NA
#> SRR945210     4  0.4389      0.783 0.008 0.000 0.000 0.728 0.084 NA
#> SRR945211     4  0.4389      0.783 0.008 0.000 0.000 0.728 0.084 NA
#> SRR945218     2  0.4325     -0.710 0.020 0.524 0.000 0.000 0.456 NA
#> SRR945219     2  0.4325     -0.710 0.020 0.524 0.000 0.000 0.456 NA
#> SRR945216     5  0.4817      0.932 0.040 0.404 0.000 0.000 0.548 NA
#> SRR945217     5  0.4817      0.932 0.040 0.404 0.000 0.000 0.548 NA
#> SRR945220     5  0.3944      0.931 0.000 0.428 0.000 0.000 0.568 NA
#> SRR945221     5  0.3944      0.931 0.000 0.428 0.000 0.000 0.568 NA
#> SRR945222     2  0.4543     -0.408 0.028 0.624 0.000 0.000 0.336 NA
#> SRR945223     2  0.4543     -0.408 0.028 0.624 0.000 0.000 0.336 NA
#> SRR945224     5  0.3944      0.931 0.000 0.428 0.000 0.000 0.568 NA
#> SRR945225     5  0.3944      0.931 0.000 0.428 0.000 0.000 0.568 NA
#> SRR945226     2  0.0405      0.615 0.008 0.988 0.000 0.000 0.004 NA
#> SRR945227     2  0.0405      0.615 0.008 0.988 0.000 0.000 0.004 NA
#> SRR945228     2  0.3053      0.589 0.012 0.812 0.000 0.000 0.004 NA
#> SRR945229     2  0.3053      0.589 0.012 0.812 0.000 0.000 0.004 NA
#> SRR945230     2  0.4072      0.409 0.000 0.544 0.000 0.000 0.008 NA
#> SRR945231     2  0.4072      0.409 0.000 0.544 0.000 0.000 0.008 NA
#> SRR945232     2  0.1686      0.572 0.012 0.924 0.000 0.000 0.064 NA
#> SRR945233     2  0.1686      0.572 0.012 0.924 0.000 0.000 0.064 NA
#> SRR945234     2  0.0665      0.609 0.004 0.980 0.000 0.000 0.008 NA
#> SRR945235     2  0.0665      0.609 0.004 0.980 0.000 0.000 0.008 NA
#> SRR945236     2  0.2313      0.615 0.012 0.884 0.000 0.000 0.004 NA
#> SRR945237     2  0.2313      0.615 0.012 0.884 0.000 0.000 0.004 NA
#> SRR945238     3  0.4663      0.882 0.052 0.040 0.748 0.000 0.012 NA
#> SRR945239     3  0.4663      0.882 0.052 0.040 0.748 0.000 0.012 NA
#> SRR945240     3  0.0937      0.903 0.000 0.040 0.960 0.000 0.000 NA
#> SRR945241     3  0.0937      0.903 0.000 0.040 0.960 0.000 0.000 NA
#> SRR945242     3  0.3504      0.890 0.020 0.040 0.848 0.000 0.036 NA
#> SRR945243     3  0.3504      0.890 0.020 0.040 0.848 0.000 0.036 NA
#> SRR945244     3  0.5243      0.878 0.060 0.040 0.712 0.000 0.032 NA
#> SRR945245     3  0.5243      0.878 0.060 0.040 0.712 0.000 0.032 NA
#> SRR945246     3  0.2239      0.900 0.004 0.040 0.912 0.000 0.028 NA
#> SRR945247     3  0.2239      0.900 0.004 0.040 0.912 0.000 0.028 NA
#> SRR945248     3  0.4686      0.872 0.032 0.040 0.740 0.000 0.020 NA
#> SRR945249     3  0.4686      0.872 0.032 0.040 0.740 0.000 0.020 NA

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

consensus_heatmap(res, k = 2)

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

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4886 0.512   0.512
#> 3 3 1.000           1.000       1.000         0.3327 0.837   0.682
#> 4 4 1.000           0.996       0.983         0.1186 0.919   0.767
#> 5 5 1.000           0.993       0.994         0.0400 0.975   0.907
#> 6 6 0.973           0.971       0.975         0.0245 0.989   0.953

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
#> SRR945190     1       0          1  1  0
#> SRR945191     1       0          1  1  0
#> SRR945192     1       0          1  1  0
#> SRR945193     1       0          1  1  0
#> SRR945194     1       0          1  1  0
#> SRR945195     1       0          1  1  0
#> SRR945196     1       0          1  1  0
#> SRR945197     1       0          1  1  0
#> SRR945200     1       0          1  1  0
#> SRR945201     1       0          1  1  0
#> SRR945202     1       0          1  1  0
#> SRR945203     1       0          1  1  0
#> SRR945204     1       0          1  1  0
#> SRR945205     1       0          1  1  0
#> SRR945198     1       0          1  1  0
#> SRR945199     1       0          1  1  0
#> SRR945206     1       0          1  1  0
#> SRR945207     1       0          1  1  0
#> SRR945208     1       0          1  1  0
#> SRR945209     1       0          1  1  0
#> SRR945212     1       0          1  1  0
#> SRR945213     1       0          1  1  0
#> SRR945214     2       0          1  0  1
#> SRR945215     2       0          1  0  1
#> SRR945210     1       0          1  1  0
#> SRR945211     1       0          1  1  0
#> SRR945218     2       0          1  0  1
#> SRR945219     2       0          1  0  1
#> SRR945216     2       0          1  0  1
#> SRR945217     2       0          1  0  1
#> SRR945220     2       0          1  0  1
#> SRR945221     2       0          1  0  1
#> SRR945222     2       0          1  0  1
#> SRR945223     2       0          1  0  1
#> SRR945224     2       0          1  0  1
#> SRR945225     2       0          1  0  1
#> SRR945226     2       0          1  0  1
#> SRR945227     2       0          1  0  1
#> SRR945228     2       0          1  0  1
#> SRR945229     2       0          1  0  1
#> SRR945230     2       0          1  0  1
#> SRR945231     2       0          1  0  1
#> SRR945232     2       0          1  0  1
#> SRR945233     2       0          1  0  1
#> SRR945234     2       0          1  0  1
#> SRR945235     2       0          1  0  1
#> SRR945236     2       0          1  0  1
#> SRR945237     2       0          1  0  1
#> SRR945238     2       0          1  0  1
#> SRR945239     2       0          1  0  1
#> SRR945240     2       0          1  0  1
#> SRR945241     2       0          1  0  1
#> SRR945242     2       0          1  0  1
#> SRR945243     2       0          1  0  1
#> SRR945244     2       0          1  0  1
#> SRR945245     2       0          1  0  1
#> SRR945246     2       0          1  0  1
#> SRR945247     2       0          1  0  1
#> SRR945248     2       0          1  0  1
#> SRR945249     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
#> SRR945190     1       0          1  1  0  0
#> SRR945191     1       0          1  1  0  0
#> SRR945192     1       0          1  1  0  0
#> SRR945193     1       0          1  1  0  0
#> SRR945194     1       0          1  1  0  0
#> SRR945195     1       0          1  1  0  0
#> SRR945196     1       0          1  1  0  0
#> SRR945197     1       0          1  1  0  0
#> SRR945200     1       0          1  1  0  0
#> SRR945201     1       0          1  1  0  0
#> SRR945202     1       0          1  1  0  0
#> SRR945203     1       0          1  1  0  0
#> SRR945204     1       0          1  1  0  0
#> SRR945205     1       0          1  1  0  0
#> SRR945198     1       0          1  1  0  0
#> SRR945199     1       0          1  1  0  0
#> SRR945206     1       0          1  1  0  0
#> SRR945207     1       0          1  1  0  0
#> SRR945208     1       0          1  1  0  0
#> SRR945209     1       0          1  1  0  0
#> SRR945212     1       0          1  1  0  0
#> SRR945213     1       0          1  1  0  0
#> SRR945214     2       0          1  0  1  0
#> SRR945215     2       0          1  0  1  0
#> SRR945210     1       0          1  1  0  0
#> SRR945211     1       0          1  1  0  0
#> SRR945218     2       0          1  0  1  0
#> SRR945219     2       0          1  0  1  0
#> SRR945216     2       0          1  0  1  0
#> SRR945217     2       0          1  0  1  0
#> SRR945220     2       0          1  0  1  0
#> SRR945221     2       0          1  0  1  0
#> SRR945222     2       0          1  0  1  0
#> SRR945223     2       0          1  0  1  0
#> SRR945224     2       0          1  0  1  0
#> SRR945225     2       0          1  0  1  0
#> SRR945226     2       0          1  0  1  0
#> SRR945227     2       0          1  0  1  0
#> SRR945228     2       0          1  0  1  0
#> SRR945229     2       0          1  0  1  0
#> SRR945230     2       0          1  0  1  0
#> SRR945231     2       0          1  0  1  0
#> SRR945232     2       0          1  0  1  0
#> SRR945233     2       0          1  0  1  0
#> SRR945234     2       0          1  0  1  0
#> SRR945235     2       0          1  0  1  0
#> SRR945236     2       0          1  0  1  0
#> SRR945237     2       0          1  0  1  0
#> SRR945238     3       0          1  0  0  1
#> SRR945239     3       0          1  0  0  1
#> SRR945240     3       0          1  0  0  1
#> SRR945241     3       0          1  0  0  1
#> SRR945242     3       0          1  0  0  1
#> SRR945243     3       0          1  0  0  1
#> SRR945244     3       0          1  0  0  1
#> SRR945245     3       0          1  0  0  1
#> SRR945246     3       0          1  0  0  1
#> SRR945247     3       0          1  0  0  1
#> SRR945248     3       0          1  0  0  1
#> SRR945249     3       0          1  0  0  1

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2 p3    p4
#> SRR945190     1  0.1867      1.000 0.928 0.000  0 0.072
#> SRR945191     1  0.1867      1.000 0.928 0.000  0 0.072
#> SRR945192     1  0.1867      1.000 0.928 0.000  0 0.072
#> SRR945193     1  0.1867      1.000 0.928 0.000  0 0.072
#> SRR945194     1  0.1867      1.000 0.928 0.000  0 0.072
#> SRR945195     1  0.1867      1.000 0.928 0.000  0 0.072
#> SRR945196     1  0.1867      1.000 0.928 0.000  0 0.072
#> SRR945197     1  0.1867      1.000 0.928 0.000  0 0.072
#> SRR945200     1  0.1867      1.000 0.928 0.000  0 0.072
#> SRR945201     1  0.1867      1.000 0.928 0.000  0 0.072
#> SRR945202     4  0.0000      0.999 0.000 0.000  0 1.000
#> SRR945203     4  0.0000      0.999 0.000 0.000  0 1.000
#> SRR945204     4  0.0000      0.999 0.000 0.000  0 1.000
#> SRR945205     4  0.0000      0.999 0.000 0.000  0 1.000
#> SRR945198     1  0.1867      1.000 0.928 0.000  0 0.072
#> SRR945199     1  0.1867      1.000 0.928 0.000  0 0.072
#> SRR945206     4  0.0000      0.999 0.000 0.000  0 1.000
#> SRR945207     4  0.0000      0.999 0.000 0.000  0 1.000
#> SRR945208     4  0.0000      0.999 0.000 0.000  0 1.000
#> SRR945209     4  0.0000      0.999 0.000 0.000  0 1.000
#> SRR945212     4  0.0000      0.999 0.000 0.000  0 1.000
#> SRR945213     4  0.0000      0.999 0.000 0.000  0 1.000
#> SRR945214     2  0.0000      0.995 0.000 1.000  0 0.000
#> SRR945215     2  0.0000      0.995 0.000 1.000  0 0.000
#> SRR945210     4  0.0188      0.996 0.004 0.000  0 0.996
#> SRR945211     4  0.0188      0.996 0.004 0.000  0 0.996
#> SRR945218     2  0.0000      0.995 0.000 1.000  0 0.000
#> SRR945219     2  0.0000      0.995 0.000 1.000  0 0.000
#> SRR945216     2  0.0000      0.995 0.000 1.000  0 0.000
#> SRR945217     2  0.0000      0.995 0.000 1.000  0 0.000
#> SRR945220     2  0.0000      0.995 0.000 1.000  0 0.000
#> SRR945221     2  0.0000      0.995 0.000 1.000  0 0.000
#> SRR945222     2  0.0000      0.995 0.000 1.000  0 0.000
#> SRR945223     2  0.0000      0.995 0.000 1.000  0 0.000
#> SRR945224     2  0.0000      0.995 0.000 1.000  0 0.000
#> SRR945225     2  0.0000      0.995 0.000 1.000  0 0.000
#> SRR945226     2  0.0000      0.995 0.000 1.000  0 0.000
#> SRR945227     2  0.0000      0.995 0.000 1.000  0 0.000
#> SRR945228     2  0.0000      0.995 0.000 1.000  0 0.000
#> SRR945229     2  0.0000      0.995 0.000 1.000  0 0.000
#> SRR945230     2  0.1867      0.941 0.072 0.928  0 0.000
#> SRR945231     2  0.1867      0.941 0.072 0.928  0 0.000
#> SRR945232     2  0.0000      0.995 0.000 1.000  0 0.000
#> SRR945233     2  0.0000      0.995 0.000 1.000  0 0.000
#> SRR945234     2  0.0000      0.995 0.000 1.000  0 0.000
#> SRR945235     2  0.0000      0.995 0.000 1.000  0 0.000
#> SRR945236     2  0.0000      0.995 0.000 1.000  0 0.000
#> SRR945237     2  0.0000      0.995 0.000 1.000  0 0.000
#> SRR945238     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR945239     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR945240     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR945241     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR945242     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR945243     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR945244     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR945245     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR945246     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR945247     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR945248     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR945249     3  0.0000      1.000 0.000 0.000  1 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2 p3    p4    p5
#> SRR945190     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> SRR945191     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> SRR945192     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> SRR945193     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> SRR945194     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> SRR945195     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> SRR945196     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> SRR945197     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> SRR945200     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> SRR945201     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> SRR945202     4  0.0162      0.988 0.004 0.000  0 0.996 0.000
#> SRR945203     4  0.0162      0.988 0.004 0.000  0 0.996 0.000
#> SRR945204     4  0.0671      0.981 0.004 0.000  0 0.980 0.016
#> SRR945205     4  0.0671      0.981 0.004 0.000  0 0.980 0.016
#> SRR945198     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> SRR945199     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> SRR945206     4  0.0162      0.988 0.004 0.000  0 0.996 0.000
#> SRR945207     4  0.0162      0.988 0.004 0.000  0 0.996 0.000
#> SRR945208     4  0.0162      0.988 0.004 0.000  0 0.996 0.000
#> SRR945209     4  0.0162      0.988 0.004 0.000  0 0.996 0.000
#> SRR945212     4  0.0162      0.988 0.004 0.000  0 0.996 0.000
#> SRR945213     4  0.0162      0.988 0.004 0.000  0 0.996 0.000
#> SRR945214     2  0.0000      0.995 0.000 1.000  0 0.000 0.000
#> SRR945215     2  0.0000      0.995 0.000 1.000  0 0.000 0.000
#> SRR945210     4  0.1549      0.952 0.016 0.000  0 0.944 0.040
#> SRR945211     4  0.1549      0.952 0.016 0.000  0 0.944 0.040
#> SRR945218     2  0.0000      0.995 0.000 1.000  0 0.000 0.000
#> SRR945219     2  0.0000      0.995 0.000 1.000  0 0.000 0.000
#> SRR945216     2  0.0000      0.995 0.000 1.000  0 0.000 0.000
#> SRR945217     2  0.0000      0.995 0.000 1.000  0 0.000 0.000
#> SRR945220     2  0.0000      0.995 0.000 1.000  0 0.000 0.000
#> SRR945221     2  0.0000      0.995 0.000 1.000  0 0.000 0.000
#> SRR945222     2  0.0000      0.995 0.000 1.000  0 0.000 0.000
#> SRR945223     2  0.0000      0.995 0.000 1.000  0 0.000 0.000
#> SRR945224     2  0.0000      0.995 0.000 1.000  0 0.000 0.000
#> SRR945225     2  0.0000      0.995 0.000 1.000  0 0.000 0.000
#> SRR945226     2  0.0000      0.995 0.000 1.000  0 0.000 0.000
#> SRR945227     2  0.0000      0.995 0.000 1.000  0 0.000 0.000
#> SRR945228     2  0.0794      0.974 0.000 0.972  0 0.000 0.028
#> SRR945229     2  0.0794      0.974 0.000 0.972  0 0.000 0.028
#> SRR945230     5  0.1043      1.000 0.000 0.040  0 0.000 0.960
#> SRR945231     5  0.1043      1.000 0.000 0.040  0 0.000 0.960
#> SRR945232     2  0.0000      0.995 0.000 1.000  0 0.000 0.000
#> SRR945233     2  0.0000      0.995 0.000 1.000  0 0.000 0.000
#> SRR945234     2  0.0000      0.995 0.000 1.000  0 0.000 0.000
#> SRR945235     2  0.0000      0.995 0.000 1.000  0 0.000 0.000
#> SRR945236     2  0.0703      0.978 0.000 0.976  0 0.000 0.024
#> SRR945237     2  0.0703      0.978 0.000 0.976  0 0.000 0.024
#> SRR945238     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR945239     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR945240     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR945241     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR945242     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR945243     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR945244     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR945245     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR945246     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR945247     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR945248     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR945249     3  0.0000      1.000 0.000 0.000  1 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
#> SRR945190     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR945191     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR945192     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR945193     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR945194     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR945195     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR945196     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR945197     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR945200     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR945201     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR945202     4  0.0000      0.969  0 0.000  0 1.000 0.000 0.000
#> SRR945203     4  0.0000      0.969  0 0.000  0 1.000 0.000 0.000
#> SRR945204     4  0.2092      0.861  0 0.000  0 0.876 0.124 0.000
#> SRR945205     4  0.2092      0.861  0 0.000  0 0.876 0.124 0.000
#> SRR945198     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR945199     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR945206     4  0.0000      0.969  0 0.000  0 1.000 0.000 0.000
#> SRR945207     4  0.0000      0.969  0 0.000  0 1.000 0.000 0.000
#> SRR945208     4  0.0000      0.969  0 0.000  0 1.000 0.000 0.000
#> SRR945209     4  0.0000      0.969  0 0.000  0 1.000 0.000 0.000
#> SRR945212     4  0.0000      0.969  0 0.000  0 1.000 0.000 0.000
#> SRR945213     4  0.0000      0.969  0 0.000  0 1.000 0.000 0.000
#> SRR945214     2  0.0458      0.954  0 0.984  0 0.000 0.016 0.000
#> SRR945215     2  0.0458      0.954  0 0.984  0 0.000 0.016 0.000
#> SRR945210     5  0.1610      1.000  0 0.000  0 0.084 0.916 0.000
#> SRR945211     5  0.1610      1.000  0 0.000  0 0.084 0.916 0.000
#> SRR945218     2  0.0458      0.954  0 0.984  0 0.000 0.016 0.000
#> SRR945219     2  0.0458      0.954  0 0.984  0 0.000 0.016 0.000
#> SRR945216     2  0.0458      0.954  0 0.984  0 0.000 0.016 0.000
#> SRR945217     2  0.0458      0.954  0 0.984  0 0.000 0.016 0.000
#> SRR945220     2  0.0458      0.954  0 0.984  0 0.000 0.016 0.000
#> SRR945221     2  0.0458      0.954  0 0.984  0 0.000 0.016 0.000
#> SRR945222     2  0.0713      0.953  0 0.972  0 0.000 0.028 0.000
#> SRR945223     2  0.0713      0.953  0 0.972  0 0.000 0.028 0.000
#> SRR945224     2  0.0458      0.954  0 0.984  0 0.000 0.016 0.000
#> SRR945225     2  0.0458      0.954  0 0.984  0 0.000 0.016 0.000
#> SRR945226     2  0.1531      0.943  0 0.928  0 0.000 0.068 0.004
#> SRR945227     2  0.1531      0.943  0 0.928  0 0.000 0.068 0.004
#> SRR945228     2  0.2629      0.911  0 0.872  0 0.000 0.068 0.060
#> SRR945229     2  0.2629      0.911  0 0.872  0 0.000 0.068 0.060
#> SRR945230     6  0.0000      1.000  0 0.000  0 0.000 0.000 1.000
#> SRR945231     6  0.0000      1.000  0 0.000  0 0.000 0.000 1.000
#> SRR945232     2  0.0935      0.951  0 0.964  0 0.000 0.032 0.004
#> SRR945233     2  0.0935      0.951  0 0.964  0 0.000 0.032 0.004
#> SRR945234     2  0.1531      0.943  0 0.928  0 0.000 0.068 0.004
#> SRR945235     2  0.1531      0.943  0 0.928  0 0.000 0.068 0.004
#> SRR945236     2  0.2506      0.917  0 0.880  0 0.000 0.068 0.052
#> SRR945237     2  0.2506      0.917  0 0.880  0 0.000 0.068 0.052
#> SRR945238     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR945239     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR945240     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR945241     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR945242     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR945243     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR945244     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR945245     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR945246     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR945247     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR945248     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR945249     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-skmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-skmeans-collect-classes

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


MAD:pam**

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

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

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

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

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

collect_plots(res)

plot of chunk MAD-pam-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2  1.00           1.000       1.000         0.4886 0.512   0.512
#> 3 3  1.00           0.986       0.993         0.3373 0.837   0.682
#> 4 4  1.00           1.000       1.000         0.1209 0.919   0.767
#> 5 5  1.00           1.000       1.000         0.0154 0.989   0.958
#> 6 6  0.93           0.932       0.948         0.0387 0.991   0.965

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> SRR945190     1  0.0000      1.000 1.000 0.000
#> SRR945191     1  0.0000      1.000 1.000 0.000
#> SRR945192     1  0.0000      1.000 1.000 0.000
#> SRR945193     1  0.0000      1.000 1.000 0.000
#> SRR945194     1  0.0000      1.000 1.000 0.000
#> SRR945195     1  0.0000      1.000 1.000 0.000
#> SRR945196     1  0.0000      1.000 1.000 0.000
#> SRR945197     1  0.0000      1.000 1.000 0.000
#> SRR945200     1  0.0000      1.000 1.000 0.000
#> SRR945201     1  0.0000      1.000 1.000 0.000
#> SRR945202     1  0.0000      1.000 1.000 0.000
#> SRR945203     1  0.0000      1.000 1.000 0.000
#> SRR945204     1  0.0000      1.000 1.000 0.000
#> SRR945205     1  0.0000      1.000 1.000 0.000
#> SRR945198     1  0.0000      1.000 1.000 0.000
#> SRR945199     1  0.0000      1.000 1.000 0.000
#> SRR945206     1  0.0000      1.000 1.000 0.000
#> SRR945207     1  0.0000      1.000 1.000 0.000
#> SRR945208     1  0.0000      1.000 1.000 0.000
#> SRR945209     1  0.0000      1.000 1.000 0.000
#> SRR945212     1  0.0000      1.000 1.000 0.000
#> SRR945213     1  0.0000      1.000 1.000 0.000
#> SRR945214     2  0.0000      1.000 0.000 1.000
#> SRR945215     2  0.0000      1.000 0.000 1.000
#> SRR945210     1  0.0376      0.996 0.996 0.004
#> SRR945211     1  0.0000      1.000 1.000 0.000
#> SRR945218     2  0.0000      1.000 0.000 1.000
#> SRR945219     2  0.0000      1.000 0.000 1.000
#> SRR945216     2  0.0000      1.000 0.000 1.000
#> SRR945217     2  0.0000      1.000 0.000 1.000
#> SRR945220     2  0.0000      1.000 0.000 1.000
#> SRR945221     2  0.0000      1.000 0.000 1.000
#> SRR945222     2  0.0000      1.000 0.000 1.000
#> SRR945223     2  0.0000      1.000 0.000 1.000
#> SRR945224     2  0.0000      1.000 0.000 1.000
#> SRR945225     2  0.0000      1.000 0.000 1.000
#> SRR945226     2  0.0000      1.000 0.000 1.000
#> SRR945227     2  0.0000      1.000 0.000 1.000
#> SRR945228     2  0.0000      1.000 0.000 1.000
#> SRR945229     2  0.0000      1.000 0.000 1.000
#> SRR945230     2  0.0000      1.000 0.000 1.000
#> SRR945231     2  0.0000      1.000 0.000 1.000
#> SRR945232     2  0.0000      1.000 0.000 1.000
#> SRR945233     2  0.0000      1.000 0.000 1.000
#> SRR945234     2  0.0000      1.000 0.000 1.000
#> SRR945235     2  0.0000      1.000 0.000 1.000
#> SRR945236     2  0.0000      1.000 0.000 1.000
#> SRR945237     2  0.0000      1.000 0.000 1.000
#> SRR945238     2  0.0000      1.000 0.000 1.000
#> SRR945239     2  0.0000      1.000 0.000 1.000
#> SRR945240     2  0.0000      1.000 0.000 1.000
#> SRR945241     2  0.0000      1.000 0.000 1.000
#> SRR945242     2  0.0000      1.000 0.000 1.000
#> SRR945243     2  0.0000      1.000 0.000 1.000
#> SRR945244     2  0.0000      1.000 0.000 1.000
#> SRR945245     2  0.0000      1.000 0.000 1.000
#> SRR945246     2  0.0000      1.000 0.000 1.000
#> SRR945247     2  0.0000      1.000 0.000 1.000
#> SRR945248     2  0.0000      1.000 0.000 1.000
#> SRR945249     2  0.0000      1.000 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette  p1 p2  p3
#> SRR945190     1   0.000      0.982 1.0  0 0.0
#> SRR945191     1   0.000      0.982 1.0  0 0.0
#> SRR945192     1   0.000      0.982 1.0  0 0.0
#> SRR945193     1   0.000      0.982 1.0  0 0.0
#> SRR945194     1   0.000      0.982 1.0  0 0.0
#> SRR945195     1   0.000      0.982 1.0  0 0.0
#> SRR945196     1   0.000      0.982 1.0  0 0.0
#> SRR945197     1   0.000      0.982 1.0  0 0.0
#> SRR945200     1   0.000      0.982 1.0  0 0.0
#> SRR945201     1   0.000      0.982 1.0  0 0.0
#> SRR945202     1   0.000      0.982 1.0  0 0.0
#> SRR945203     1   0.000      0.982 1.0  0 0.0
#> SRR945204     1   0.000      0.982 1.0  0 0.0
#> SRR945205     1   0.000      0.982 1.0  0 0.0
#> SRR945198     1   0.000      0.982 1.0  0 0.0
#> SRR945199     1   0.000      0.982 1.0  0 0.0
#> SRR945206     1   0.000      0.982 1.0  0 0.0
#> SRR945207     1   0.000      0.982 1.0  0 0.0
#> SRR945208     1   0.000      0.982 1.0  0 0.0
#> SRR945209     1   0.000      0.982 1.0  0 0.0
#> SRR945212     1   0.000      0.982 1.0  0 0.0
#> SRR945213     1   0.000      0.982 1.0  0 0.0
#> SRR945214     2   0.000      1.000 0.0  1 0.0
#> SRR945215     2   0.000      1.000 0.0  1 0.0
#> SRR945210     1   0.455      0.761 0.8  0 0.2
#> SRR945211     1   0.455      0.761 0.8  0 0.2
#> SRR945218     2   0.000      1.000 0.0  1 0.0
#> SRR945219     2   0.000      1.000 0.0  1 0.0
#> SRR945216     2   0.000      1.000 0.0  1 0.0
#> SRR945217     2   0.000      1.000 0.0  1 0.0
#> SRR945220     2   0.000      1.000 0.0  1 0.0
#> SRR945221     2   0.000      1.000 0.0  1 0.0
#> SRR945222     2   0.000      1.000 0.0  1 0.0
#> SRR945223     2   0.000      1.000 0.0  1 0.0
#> SRR945224     2   0.000      1.000 0.0  1 0.0
#> SRR945225     2   0.000      1.000 0.0  1 0.0
#> SRR945226     2   0.000      1.000 0.0  1 0.0
#> SRR945227     2   0.000      1.000 0.0  1 0.0
#> SRR945228     2   0.000      1.000 0.0  1 0.0
#> SRR945229     2   0.000      1.000 0.0  1 0.0
#> SRR945230     2   0.000      1.000 0.0  1 0.0
#> SRR945231     2   0.000      1.000 0.0  1 0.0
#> SRR945232     2   0.000      1.000 0.0  1 0.0
#> SRR945233     2   0.000      1.000 0.0  1 0.0
#> SRR945234     2   0.000      1.000 0.0  1 0.0
#> SRR945235     2   0.000      1.000 0.0  1 0.0
#> SRR945236     2   0.000      1.000 0.0  1 0.0
#> SRR945237     2   0.000      1.000 0.0  1 0.0
#> SRR945238     3   0.000      1.000 0.0  0 1.0
#> SRR945239     3   0.000      1.000 0.0  0 1.0
#> SRR945240     3   0.000      1.000 0.0  0 1.0
#> SRR945241     3   0.000      1.000 0.0  0 1.0
#> SRR945242     3   0.000      1.000 0.0  0 1.0
#> SRR945243     3   0.000      1.000 0.0  0 1.0
#> SRR945244     3   0.000      1.000 0.0  0 1.0
#> SRR945245     3   0.000      1.000 0.0  0 1.0
#> SRR945246     3   0.000      1.000 0.0  0 1.0
#> SRR945247     3   0.000      1.000 0.0  0 1.0
#> SRR945248     3   0.000      1.000 0.0  0 1.0
#> SRR945249     3   0.000      1.000 0.0  0 1.0

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette p1 p2 p3 p4
#> SRR945190     1       0          1  1  0  0  0
#> SRR945191     1       0          1  1  0  0  0
#> SRR945192     1       0          1  1  0  0  0
#> SRR945193     1       0          1  1  0  0  0
#> SRR945194     1       0          1  1  0  0  0
#> SRR945195     1       0          1  1  0  0  0
#> SRR945196     1       0          1  1  0  0  0
#> SRR945197     1       0          1  1  0  0  0
#> SRR945200     1       0          1  1  0  0  0
#> SRR945201     1       0          1  1  0  0  0
#> SRR945202     4       0          1  0  0  0  1
#> SRR945203     4       0          1  0  0  0  1
#> SRR945204     4       0          1  0  0  0  1
#> SRR945205     4       0          1  0  0  0  1
#> SRR945198     1       0          1  1  0  0  0
#> SRR945199     1       0          1  1  0  0  0
#> SRR945206     4       0          1  0  0  0  1
#> SRR945207     4       0          1  0  0  0  1
#> SRR945208     4       0          1  0  0  0  1
#> SRR945209     4       0          1  0  0  0  1
#> SRR945212     4       0          1  0  0  0  1
#> SRR945213     4       0          1  0  0  0  1
#> SRR945214     2       0          1  0  1  0  0
#> SRR945215     2       0          1  0  1  0  0
#> SRR945210     4       0          1  0  0  0  1
#> SRR945211     4       0          1  0  0  0  1
#> SRR945218     2       0          1  0  1  0  0
#> SRR945219     2       0          1  0  1  0  0
#> SRR945216     2       0          1  0  1  0  0
#> SRR945217     2       0          1  0  1  0  0
#> SRR945220     2       0          1  0  1  0  0
#> SRR945221     2       0          1  0  1  0  0
#> SRR945222     2       0          1  0  1  0  0
#> SRR945223     2       0          1  0  1  0  0
#> SRR945224     2       0          1  0  1  0  0
#> SRR945225     2       0          1  0  1  0  0
#> SRR945226     2       0          1  0  1  0  0
#> SRR945227     2       0          1  0  1  0  0
#> SRR945228     2       0          1  0  1  0  0
#> SRR945229     2       0          1  0  1  0  0
#> SRR945230     2       0          1  0  1  0  0
#> SRR945231     2       0          1  0  1  0  0
#> SRR945232     2       0          1  0  1  0  0
#> SRR945233     2       0          1  0  1  0  0
#> SRR945234     2       0          1  0  1  0  0
#> SRR945235     2       0          1  0  1  0  0
#> SRR945236     2       0          1  0  1  0  0
#> SRR945237     2       0          1  0  1  0  0
#> SRR945238     3       0          1  0  0  1  0
#> SRR945239     3       0          1  0  0  1  0
#> SRR945240     3       0          1  0  0  1  0
#> SRR945241     3       0          1  0  0  1  0
#> SRR945242     3       0          1  0  0  1  0
#> SRR945243     3       0          1  0  0  1  0
#> SRR945244     3       0          1  0  0  1  0
#> SRR945245     3       0          1  0  0  1  0
#> SRR945246     3       0          1  0  0  1  0
#> SRR945247     3       0          1  0  0  1  0
#> SRR945248     3       0          1  0  0  1  0
#> SRR945249     3       0          1  0  0  1  0

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette p1 p2 p3 p4 p5
#> SRR945190     1       0          1  1  0  0  0  0
#> SRR945191     1       0          1  1  0  0  0  0
#> SRR945192     1       0          1  1  0  0  0  0
#> SRR945193     1       0          1  1  0  0  0  0
#> SRR945194     1       0          1  1  0  0  0  0
#> SRR945195     1       0          1  1  0  0  0  0
#> SRR945196     1       0          1  1  0  0  0  0
#> SRR945197     1       0          1  1  0  0  0  0
#> SRR945200     1       0          1  1  0  0  0  0
#> SRR945201     1       0          1  1  0  0  0  0
#> SRR945202     4       0          1  0  0  0  1  0
#> SRR945203     4       0          1  0  0  0  1  0
#> SRR945204     4       0          1  0  0  0  1  0
#> SRR945205     4       0          1  0  0  0  1  0
#> SRR945198     1       0          1  1  0  0  0  0
#> SRR945199     1       0          1  1  0  0  0  0
#> SRR945206     4       0          1  0  0  0  1  0
#> SRR945207     4       0          1  0  0  0  1  0
#> SRR945208     4       0          1  0  0  0  1  0
#> SRR945209     4       0          1  0  0  0  1  0
#> SRR945212     4       0          1  0  0  0  1  0
#> SRR945213     4       0          1  0  0  0  1  0
#> SRR945214     2       0          1  0  1  0  0  0
#> SRR945215     2       0          1  0  1  0  0  0
#> SRR945210     5       0          1  0  0  0  0  1
#> SRR945211     5       0          1  0  0  0  0  1
#> SRR945218     2       0          1  0  1  0  0  0
#> SRR945219     2       0          1  0  1  0  0  0
#> SRR945216     2       0          1  0  1  0  0  0
#> SRR945217     2       0          1  0  1  0  0  0
#> SRR945220     2       0          1  0  1  0  0  0
#> SRR945221     2       0          1  0  1  0  0  0
#> SRR945222     2       0          1  0  1  0  0  0
#> SRR945223     2       0          1  0  1  0  0  0
#> SRR945224     2       0          1  0  1  0  0  0
#> SRR945225     2       0          1  0  1  0  0  0
#> SRR945226     2       0          1  0  1  0  0  0
#> SRR945227     2       0          1  0  1  0  0  0
#> SRR945228     2       0          1  0  1  0  0  0
#> SRR945229     2       0          1  0  1  0  0  0
#> SRR945230     2       0          1  0  1  0  0  0
#> SRR945231     2       0          1  0  1  0  0  0
#> SRR945232     2       0          1  0  1  0  0  0
#> SRR945233     2       0          1  0  1  0  0  0
#> SRR945234     2       0          1  0  1  0  0  0
#> SRR945235     2       0          1  0  1  0  0  0
#> SRR945236     2       0          1  0  1  0  0  0
#> SRR945237     2       0          1  0  1  0  0  0
#> SRR945238     3       0          1  0  0  1  0  0
#> SRR945239     3       0          1  0  0  1  0  0
#> SRR945240     3       0          1  0  0  1  0  0
#> SRR945241     3       0          1  0  0  1  0  0
#> SRR945242     3       0          1  0  0  1  0  0
#> SRR945243     3       0          1  0  0  1  0  0
#> SRR945244     3       0          1  0  0  1  0  0
#> SRR945245     3       0          1  0  0  1  0  0
#> SRR945246     3       0          1  0  0  1  0  0
#> SRR945247     3       0          1  0  0  1  0  0
#> SRR945248     3       0          1  0  0  1  0  0
#> SRR945249     3       0          1  0  0  1  0  0

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette p1    p2 p3   p4    p5    p6
#> SRR945190     1  0.0000      1.000  1 0.000  0 0.00 0.000 0.000
#> SRR945191     1  0.0000      1.000  1 0.000  0 0.00 0.000 0.000
#> SRR945192     1  0.0000      1.000  1 0.000  0 0.00 0.000 0.000
#> SRR945193     1  0.0000      1.000  1 0.000  0 0.00 0.000 0.000
#> SRR945194     1  0.0000      1.000  1 0.000  0 0.00 0.000 0.000
#> SRR945195     1  0.0000      1.000  1 0.000  0 0.00 0.000 0.000
#> SRR945196     1  0.0000      1.000  1 0.000  0 0.00 0.000 0.000
#> SRR945197     1  0.0000      1.000  1 0.000  0 0.00 0.000 0.000
#> SRR945200     1  0.0000      1.000  1 0.000  0 0.00 0.000 0.000
#> SRR945201     1  0.0000      1.000  1 0.000  0 0.00 0.000 0.000
#> SRR945202     4  0.0000      1.000  0 0.000  0 1.00 0.000 0.000
#> SRR945203     4  0.0000      1.000  0 0.000  0 1.00 0.000 0.000
#> SRR945204     4  0.0000      1.000  0 0.000  0 1.00 0.000 0.000
#> SRR945205     4  0.0000      1.000  0 0.000  0 1.00 0.000 0.000
#> SRR945198     1  0.0000      1.000  1 0.000  0 0.00 0.000 0.000
#> SRR945199     1  0.0000      1.000  1 0.000  0 0.00 0.000 0.000
#> SRR945206     6  0.3706      1.000  0 0.000  0 0.38 0.000 0.620
#> SRR945207     6  0.3706      1.000  0 0.000  0 0.38 0.000 0.620
#> SRR945208     4  0.0000      1.000  0 0.000  0 1.00 0.000 0.000
#> SRR945209     4  0.0000      1.000  0 0.000  0 1.00 0.000 0.000
#> SRR945212     4  0.0000      1.000  0 0.000  0 1.00 0.000 0.000
#> SRR945213     4  0.0000      1.000  0 0.000  0 1.00 0.000 0.000
#> SRR945214     2  0.0260      0.895  0 0.992  0 0.00 0.000 0.008
#> SRR945215     2  0.0260      0.895  0 0.992  0 0.00 0.000 0.008
#> SRR945210     5  0.3684      1.000  0 0.000  0 0.00 0.628 0.372
#> SRR945211     5  0.3684      1.000  0 0.000  0 0.00 0.628 0.372
#> SRR945218     2  0.0000      0.896  0 1.000  0 0.00 0.000 0.000
#> SRR945219     2  0.0000      0.896  0 1.000  0 0.00 0.000 0.000
#> SRR945216     2  0.0260      0.895  0 0.992  0 0.00 0.000 0.008
#> SRR945217     2  0.0260      0.895  0 0.992  0 0.00 0.000 0.008
#> SRR945220     2  0.0260      0.895  0 0.992  0 0.00 0.000 0.008
#> SRR945221     2  0.0260      0.895  0 0.992  0 0.00 0.000 0.008
#> SRR945222     2  0.0000      0.896  0 1.000  0 0.00 0.000 0.000
#> SRR945223     2  0.0000      0.896  0 1.000  0 0.00 0.000 0.000
#> SRR945224     2  0.0260      0.895  0 0.992  0 0.00 0.000 0.008
#> SRR945225     2  0.0000      0.896  0 1.000  0 0.00 0.000 0.000
#> SRR945226     2  0.0146      0.895  0 0.996  0 0.00 0.004 0.000
#> SRR945227     2  0.0146      0.895  0 0.996  0 0.00 0.004 0.000
#> SRR945228     2  0.3684      0.633  0 0.628  0 0.00 0.372 0.000
#> SRR945229     2  0.3684      0.633  0 0.628  0 0.00 0.372 0.000
#> SRR945230     2  0.3684      0.633  0 0.628  0 0.00 0.372 0.000
#> SRR945231     2  0.3684      0.633  0 0.628  0 0.00 0.372 0.000
#> SRR945232     2  0.0000      0.896  0 1.000  0 0.00 0.000 0.000
#> SRR945233     2  0.0000      0.896  0 1.000  0 0.00 0.000 0.000
#> SRR945234     2  0.0000      0.896  0 1.000  0 0.00 0.000 0.000
#> SRR945235     2  0.0000      0.896  0 1.000  0 0.00 0.000 0.000
#> SRR945236     2  0.3684      0.633  0 0.628  0 0.00 0.372 0.000
#> SRR945237     2  0.3684      0.633  0 0.628  0 0.00 0.372 0.000
#> SRR945238     3  0.0000      1.000  0 0.000  1 0.00 0.000 0.000
#> SRR945239     3  0.0000      1.000  0 0.000  1 0.00 0.000 0.000
#> SRR945240     3  0.0000      1.000  0 0.000  1 0.00 0.000 0.000
#> SRR945241     3  0.0000      1.000  0 0.000  1 0.00 0.000 0.000
#> SRR945242     3  0.0000      1.000  0 0.000  1 0.00 0.000 0.000
#> SRR945243     3  0.0000      1.000  0 0.000  1 0.00 0.000 0.000
#> SRR945244     3  0.0000      1.000  0 0.000  1 0.00 0.000 0.000
#> SRR945245     3  0.0000      1.000  0 0.000  1 0.00 0.000 0.000
#> SRR945246     3  0.0000      1.000  0 0.000  1 0.00 0.000 0.000
#> SRR945247     3  0.0000      1.000  0 0.000  1 0.00 0.000 0.000
#> SRR945248     3  0.0000      1.000  0 0.000  1 0.00 0.000 0.000
#> SRR945249     3  0.0000      1.000  0 0.000  1 0.00 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 15912 rows and 60 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'mclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 6.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk MAD-mclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.579           0.837       0.895         0.4801 0.528   0.528
#> 3 3 1.000           1.000       1.000         0.3516 0.824   0.666
#> 4 4 0.973           0.953       0.975         0.1352 0.910   0.743
#> 5 5 0.985           0.978       0.989         0.0436 0.973   0.896
#> 6 6 0.976           0.864       0.927         0.0108 0.984   0.933

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> SRR945190     1   0.985      0.804 0.572 0.428
#> SRR945191     1   0.985      0.804 0.572 0.428
#> SRR945192     1   0.985      0.804 0.572 0.428
#> SRR945193     1   0.985      0.804 0.572 0.428
#> SRR945194     1   0.985      0.804 0.572 0.428
#> SRR945195     1   0.985      0.804 0.572 0.428
#> SRR945196     1   0.985      0.804 0.572 0.428
#> SRR945197     1   0.985      0.804 0.572 0.428
#> SRR945200     1   0.985      0.804 0.572 0.428
#> SRR945201     1   0.985      0.804 0.572 0.428
#> SRR945202     1   0.936      0.811 0.648 0.352
#> SRR945203     1   0.936      0.811 0.648 0.352
#> SRR945204     1   0.936      0.811 0.648 0.352
#> SRR945205     1   0.936      0.811 0.648 0.352
#> SRR945198     1   0.985      0.804 0.572 0.428
#> SRR945199     1   0.985      0.804 0.572 0.428
#> SRR945206     1   0.936      0.811 0.648 0.352
#> SRR945207     1   0.936      0.811 0.648 0.352
#> SRR945208     1   0.936      0.811 0.648 0.352
#> SRR945209     1   0.936      0.811 0.648 0.352
#> SRR945212     1   0.936      0.811 0.648 0.352
#> SRR945213     1   0.936      0.811 0.648 0.352
#> SRR945214     2   0.917      1.000 0.332 0.668
#> SRR945215     2   0.917      1.000 0.332 0.668
#> SRR945210     1   0.936      0.811 0.648 0.352
#> SRR945211     1   0.936      0.811 0.648 0.352
#> SRR945218     2   0.917      1.000 0.332 0.668
#> SRR945219     2   0.917      1.000 0.332 0.668
#> SRR945216     2   0.917      1.000 0.332 0.668
#> SRR945217     2   0.917      1.000 0.332 0.668
#> SRR945220     2   0.917      1.000 0.332 0.668
#> SRR945221     2   0.917      1.000 0.332 0.668
#> SRR945222     2   0.917      1.000 0.332 0.668
#> SRR945223     2   0.917      1.000 0.332 0.668
#> SRR945224     2   0.917      1.000 0.332 0.668
#> SRR945225     2   0.917      1.000 0.332 0.668
#> SRR945226     2   0.917      1.000 0.332 0.668
#> SRR945227     2   0.917      1.000 0.332 0.668
#> SRR945228     2   0.917      1.000 0.332 0.668
#> SRR945229     2   0.917      1.000 0.332 0.668
#> SRR945230     1   0.518      0.529 0.884 0.116
#> SRR945231     1   0.518      0.529 0.884 0.116
#> SRR945232     2   0.917      1.000 0.332 0.668
#> SRR945233     2   0.917      1.000 0.332 0.668
#> SRR945234     2   0.917      1.000 0.332 0.668
#> SRR945235     2   0.917      1.000 0.332 0.668
#> SRR945236     2   0.917      1.000 0.332 0.668
#> SRR945237     2   0.917      1.000 0.332 0.668
#> SRR945238     1   0.000      0.648 1.000 0.000
#> SRR945239     1   0.000      0.648 1.000 0.000
#> SRR945240     1   0.000      0.648 1.000 0.000
#> SRR945241     1   0.000      0.648 1.000 0.000
#> SRR945242     1   0.000      0.648 1.000 0.000
#> SRR945243     1   0.000      0.648 1.000 0.000
#> SRR945244     1   0.000      0.648 1.000 0.000
#> SRR945245     1   0.000      0.648 1.000 0.000
#> SRR945246     1   0.000      0.648 1.000 0.000
#> SRR945247     1   0.000      0.648 1.000 0.000
#> SRR945248     1   0.000      0.648 1.000 0.000
#> SRR945249     1   0.000      0.648 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
#> SRR945190     1       0          1  1  0  0
#> SRR945191     1       0          1  1  0  0
#> SRR945192     1       0          1  1  0  0
#> SRR945193     1       0          1  1  0  0
#> SRR945194     1       0          1  1  0  0
#> SRR945195     1       0          1  1  0  0
#> SRR945196     1       0          1  1  0  0
#> SRR945197     1       0          1  1  0  0
#> SRR945200     1       0          1  1  0  0
#> SRR945201     1       0          1  1  0  0
#> SRR945202     1       0          1  1  0  0
#> SRR945203     1       0          1  1  0  0
#> SRR945204     1       0          1  1  0  0
#> SRR945205     1       0          1  1  0  0
#> SRR945198     1       0          1  1  0  0
#> SRR945199     1       0          1  1  0  0
#> SRR945206     1       0          1  1  0  0
#> SRR945207     1       0          1  1  0  0
#> SRR945208     1       0          1  1  0  0
#> SRR945209     1       0          1  1  0  0
#> SRR945212     1       0          1  1  0  0
#> SRR945213     1       0          1  1  0  0
#> SRR945214     2       0          1  0  1  0
#> SRR945215     2       0          1  0  1  0
#> SRR945210     1       0          1  1  0  0
#> SRR945211     1       0          1  1  0  0
#> SRR945218     2       0          1  0  1  0
#> SRR945219     2       0          1  0  1  0
#> SRR945216     2       0          1  0  1  0
#> SRR945217     2       0          1  0  1  0
#> SRR945220     2       0          1  0  1  0
#> SRR945221     2       0          1  0  1  0
#> SRR945222     2       0          1  0  1  0
#> SRR945223     2       0          1  0  1  0
#> SRR945224     2       0          1  0  1  0
#> SRR945225     2       0          1  0  1  0
#> SRR945226     2       0          1  0  1  0
#> SRR945227     2       0          1  0  1  0
#> SRR945228     2       0          1  0  1  0
#> SRR945229     2       0          1  0  1  0
#> SRR945230     1       0          1  1  0  0
#> SRR945231     1       0          1  1  0  0
#> SRR945232     2       0          1  0  1  0
#> SRR945233     2       0          1  0  1  0
#> SRR945234     2       0          1  0  1  0
#> SRR945235     2       0          1  0  1  0
#> SRR945236     2       0          1  0  1  0
#> SRR945237     2       0          1  0  1  0
#> SRR945238     3       0          1  0  0  1
#> SRR945239     3       0          1  0  0  1
#> SRR945240     3       0          1  0  0  1
#> SRR945241     3       0          1  0  0  1
#> SRR945242     3       0          1  0  0  1
#> SRR945243     3       0          1  0  0  1
#> SRR945244     3       0          1  0  0  1
#> SRR945245     3       0          1  0  0  1
#> SRR945246     3       0          1  0  0  1
#> SRR945247     3       0          1  0  0  1
#> SRR945248     3       0          1  0  0  1
#> SRR945249     3       0          1  0  0  1

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2 p3    p4
#> SRR945190     1   0.000      1.000 1.000 0.000  0 0.000
#> SRR945191     1   0.000      1.000 1.000 0.000  0 0.000
#> SRR945192     1   0.000      1.000 1.000 0.000  0 0.000
#> SRR945193     1   0.000      1.000 1.000 0.000  0 0.000
#> SRR945194     4   0.443      0.641 0.304 0.000  0 0.696
#> SRR945195     4   0.443      0.641 0.304 0.000  0 0.696
#> SRR945196     1   0.000      1.000 1.000 0.000  0 0.000
#> SRR945197     1   0.000      1.000 1.000 0.000  0 0.000
#> SRR945200     1   0.000      1.000 1.000 0.000  0 0.000
#> SRR945201     1   0.000      1.000 1.000 0.000  0 0.000
#> SRR945202     4   0.000      0.891 0.000 0.000  0 1.000
#> SRR945203     4   0.000      0.891 0.000 0.000  0 1.000
#> SRR945204     4   0.000      0.891 0.000 0.000  0 1.000
#> SRR945205     4   0.000      0.891 0.000 0.000  0 1.000
#> SRR945198     1   0.000      1.000 1.000 0.000  0 0.000
#> SRR945199     1   0.000      1.000 1.000 0.000  0 0.000
#> SRR945206     4   0.000      0.891 0.000 0.000  0 1.000
#> SRR945207     4   0.000      0.891 0.000 0.000  0 1.000
#> SRR945208     4   0.194      0.873 0.076 0.000  0 0.924
#> SRR945209     4   0.194      0.873 0.076 0.000  0 0.924
#> SRR945212     4   0.194      0.873 0.076 0.000  0 0.924
#> SRR945213     4   0.194      0.873 0.076 0.000  0 0.924
#> SRR945214     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR945215     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR945210     4   0.000      0.891 0.000 0.000  0 1.000
#> SRR945211     4   0.000      0.891 0.000 0.000  0 1.000
#> SRR945218     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR945219     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR945216     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR945217     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR945220     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR945221     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR945222     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR945223     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR945224     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR945225     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR945226     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR945227     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR945228     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR945229     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR945230     4   0.488      0.633 0.016 0.288  0 0.696
#> SRR945231     4   0.488      0.633 0.016 0.288  0 0.696
#> SRR945232     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR945233     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR945234     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR945235     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR945236     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR945237     2   0.000      1.000 0.000 1.000  0 0.000
#> SRR945238     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR945239     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR945240     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR945241     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR945242     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR945243     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR945244     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR945245     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR945246     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR945247     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR945248     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR945249     3   0.000      1.000 0.000 0.000  1 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette p1    p2 p3    p4    p5
#> SRR945190     1  0.0000      1.000  1 0.000  0 0.000 0.000
#> SRR945191     1  0.0000      1.000  1 0.000  0 0.000 0.000
#> SRR945192     1  0.0000      1.000  1 0.000  0 0.000 0.000
#> SRR945193     1  0.0000      1.000  1 0.000  0 0.000 0.000
#> SRR945194     5  0.0000      1.000  0 0.000  0 0.000 1.000
#> SRR945195     5  0.0000      1.000  0 0.000  0 0.000 1.000
#> SRR945196     1  0.0000      1.000  1 0.000  0 0.000 0.000
#> SRR945197     1  0.0000      1.000  1 0.000  0 0.000 0.000
#> SRR945200     1  0.0000      1.000  1 0.000  0 0.000 0.000
#> SRR945201     1  0.0000      1.000  1 0.000  0 0.000 0.000
#> SRR945202     4  0.0000      0.936  0 0.000  0 1.000 0.000
#> SRR945203     4  0.0000      0.936  0 0.000  0 1.000 0.000
#> SRR945204     4  0.0000      0.936  0 0.000  0 1.000 0.000
#> SRR945205     4  0.0000      0.936  0 0.000  0 1.000 0.000
#> SRR945198     1  0.0000      1.000  1 0.000  0 0.000 0.000
#> SRR945199     1  0.0000      1.000  1 0.000  0 0.000 0.000
#> SRR945206     4  0.0000      0.936  0 0.000  0 1.000 0.000
#> SRR945207     4  0.0000      0.936  0 0.000  0 1.000 0.000
#> SRR945208     4  0.0000      0.936  0 0.000  0 1.000 0.000
#> SRR945209     4  0.0000      0.936  0 0.000  0 1.000 0.000
#> SRR945212     4  0.2732      0.819  0 0.000  0 0.840 0.160
#> SRR945213     4  0.2732      0.819  0 0.000  0 0.840 0.160
#> SRR945214     2  0.0000      0.998  0 1.000  0 0.000 0.000
#> SRR945215     2  0.0000      0.998  0 1.000  0 0.000 0.000
#> SRR945210     4  0.2813      0.810  0 0.000  0 0.832 0.168
#> SRR945211     4  0.2813      0.810  0 0.000  0 0.832 0.168
#> SRR945218     2  0.0000      0.998  0 1.000  0 0.000 0.000
#> SRR945219     2  0.0000      0.998  0 1.000  0 0.000 0.000
#> SRR945216     2  0.0000      0.998  0 1.000  0 0.000 0.000
#> SRR945217     2  0.0000      0.998  0 1.000  0 0.000 0.000
#> SRR945220     2  0.0162      0.996  0 0.996  0 0.000 0.004
#> SRR945221     2  0.0162      0.996  0 0.996  0 0.000 0.004
#> SRR945222     2  0.0000      0.998  0 1.000  0 0.000 0.000
#> SRR945223     2  0.0000      0.998  0 1.000  0 0.000 0.000
#> SRR945224     2  0.0000      0.998  0 1.000  0 0.000 0.000
#> SRR945225     2  0.0000      0.998  0 1.000  0 0.000 0.000
#> SRR945226     2  0.0000      0.998  0 1.000  0 0.000 0.000
#> SRR945227     2  0.0000      0.998  0 1.000  0 0.000 0.000
#> SRR945228     2  0.0404      0.989  0 0.988  0 0.000 0.012
#> SRR945229     2  0.0290      0.992  0 0.992  0 0.000 0.008
#> SRR945230     5  0.0000      1.000  0 0.000  0 0.000 1.000
#> SRR945231     5  0.0000      1.000  0 0.000  0 0.000 1.000
#> SRR945232     2  0.0000      0.998  0 1.000  0 0.000 0.000
#> SRR945233     2  0.0000      0.998  0 1.000  0 0.000 0.000
#> SRR945234     2  0.0000      0.998  0 1.000  0 0.000 0.000
#> SRR945235     2  0.0162      0.996  0 0.996  0 0.000 0.004
#> SRR945236     2  0.0000      0.998  0 1.000  0 0.000 0.000
#> SRR945237     2  0.0000      0.998  0 1.000  0 0.000 0.000
#> SRR945238     3  0.0000      1.000  0 0.000  1 0.000 0.000
#> SRR945239     3  0.0000      1.000  0 0.000  1 0.000 0.000
#> SRR945240     3  0.0000      1.000  0 0.000  1 0.000 0.000
#> SRR945241     3  0.0000      1.000  0 0.000  1 0.000 0.000
#> SRR945242     3  0.0000      1.000  0 0.000  1 0.000 0.000
#> SRR945243     3  0.0000      1.000  0 0.000  1 0.000 0.000
#> SRR945244     3  0.0000      1.000  0 0.000  1 0.000 0.000
#> SRR945245     3  0.0000      1.000  0 0.000  1 0.000 0.000
#> SRR945246     3  0.0000      1.000  0 0.000  1 0.000 0.000
#> SRR945247     3  0.0000      1.000  0 0.000  1 0.000 0.000
#> SRR945248     3  0.0000      1.000  0 0.000  1 0.000 0.000
#> SRR945249     3  0.0000      1.000  0 0.000  1 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
#> SRR945190     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR945191     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR945192     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR945193     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR945194     5  0.3717     -0.230  0 0.000  0 0.000 0.616 0.384
#> SRR945195     5  0.3717     -0.230  0 0.000  0 0.000 0.616 0.384
#> SRR945196     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR945197     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR945200     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR945201     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR945202     4  0.3076      0.753  0 0.000  0 0.760 0.240 0.000
#> SRR945203     4  0.3076      0.753  0 0.000  0 0.760 0.240 0.000
#> SRR945204     4  0.1007      0.682  0 0.000  0 0.956 0.044 0.000
#> SRR945205     4  0.1007      0.682  0 0.000  0 0.956 0.044 0.000
#> SRR945198     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR945199     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR945206     4  0.3076      0.753  0 0.000  0 0.760 0.240 0.000
#> SRR945207     4  0.3076      0.753  0 0.000  0 0.760 0.240 0.000
#> SRR945208     4  0.0000      0.708  0 0.000  0 1.000 0.000 0.000
#> SRR945209     4  0.0000      0.708  0 0.000  0 1.000 0.000 0.000
#> SRR945212     4  0.3756      0.609  0 0.000  0 0.600 0.400 0.000
#> SRR945213     4  0.3756      0.609  0 0.000  0 0.600 0.400 0.000
#> SRR945214     2  0.0000      0.998  0 1.000  0 0.000 0.000 0.000
#> SRR945215     2  0.0000      0.998  0 1.000  0 0.000 0.000 0.000
#> SRR945210     5  0.3847     -0.316  0 0.000  0 0.456 0.544 0.000
#> SRR945211     5  0.3847     -0.316  0 0.000  0 0.456 0.544 0.000
#> SRR945218     2  0.0000      0.998  0 1.000  0 0.000 0.000 0.000
#> SRR945219     2  0.0000      0.998  0 1.000  0 0.000 0.000 0.000
#> SRR945216     2  0.0000      0.998  0 1.000  0 0.000 0.000 0.000
#> SRR945217     2  0.0000      0.998  0 1.000  0 0.000 0.000 0.000
#> SRR945220     2  0.0146      0.996  0 0.996  0 0.000 0.000 0.004
#> SRR945221     2  0.0146      0.996  0 0.996  0 0.000 0.000 0.004
#> SRR945222     2  0.0000      0.998  0 1.000  0 0.000 0.000 0.000
#> SRR945223     2  0.0000      0.998  0 1.000  0 0.000 0.000 0.000
#> SRR945224     2  0.0000      0.998  0 1.000  0 0.000 0.000 0.000
#> SRR945225     2  0.0000      0.998  0 1.000  0 0.000 0.000 0.000
#> SRR945226     2  0.0000      0.998  0 1.000  0 0.000 0.000 0.000
#> SRR945227     2  0.0000      0.998  0 1.000  0 0.000 0.000 0.000
#> SRR945228     2  0.0363      0.988  0 0.988  0 0.000 0.000 0.012
#> SRR945229     2  0.0260      0.992  0 0.992  0 0.000 0.000 0.008
#> SRR945230     6  0.0000      1.000  0 0.000  0 0.000 0.000 1.000
#> SRR945231     6  0.0000      1.000  0 0.000  0 0.000 0.000 1.000
#> SRR945232     2  0.0000      0.998  0 1.000  0 0.000 0.000 0.000
#> SRR945233     2  0.0000      0.998  0 1.000  0 0.000 0.000 0.000
#> SRR945234     2  0.0000      0.998  0 1.000  0 0.000 0.000 0.000
#> SRR945235     2  0.0146      0.996  0 0.996  0 0.000 0.000 0.004
#> SRR945236     2  0.0000      0.998  0 1.000  0 0.000 0.000 0.000
#> SRR945237     2  0.0000      0.998  0 1.000  0 0.000 0.000 0.000
#> SRR945238     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR945239     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR945240     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR945241     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR945242     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR945243     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR945244     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR945245     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR945246     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR945247     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR945248     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR945249     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-mclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-mclust-collect-classes

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


MAD:NMF*

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

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

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

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

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

collect_plots(res)

plot of chunk MAD-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.999       0.999         0.4884 0.512   0.512
#> 3 3 0.753           0.963       0.929         0.3084 0.837   0.682
#> 4 4 1.000           1.000       1.000         0.1462 0.919   0.767
#> 5 5 0.990           0.987       0.988         0.0190 0.989   0.958
#> 6 6 0.925           0.915       0.931         0.0585 0.939   0.762

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> SRR945190     1   0.000      0.999 1.000 0.000
#> SRR945191     1   0.000      0.999 1.000 0.000
#> SRR945192     1   0.000      0.999 1.000 0.000
#> SRR945193     1   0.000      0.999 1.000 0.000
#> SRR945194     1   0.000      0.999 1.000 0.000
#> SRR945195     1   0.000      0.999 1.000 0.000
#> SRR945196     1   0.000      0.999 1.000 0.000
#> SRR945197     1   0.000      0.999 1.000 0.000
#> SRR945200     1   0.000      0.999 1.000 0.000
#> SRR945201     1   0.000      0.999 1.000 0.000
#> SRR945202     1   0.000      0.999 1.000 0.000
#> SRR945203     1   0.000      0.999 1.000 0.000
#> SRR945204     1   0.000      0.999 1.000 0.000
#> SRR945205     1   0.000      0.999 1.000 0.000
#> SRR945198     1   0.000      0.999 1.000 0.000
#> SRR945199     1   0.000      0.999 1.000 0.000
#> SRR945206     1   0.000      0.999 1.000 0.000
#> SRR945207     1   0.000      0.999 1.000 0.000
#> SRR945208     1   0.000      0.999 1.000 0.000
#> SRR945209     1   0.000      0.999 1.000 0.000
#> SRR945212     1   0.000      0.999 1.000 0.000
#> SRR945213     1   0.000      0.999 1.000 0.000
#> SRR945214     2   0.000      1.000 0.000 1.000
#> SRR945215     2   0.000      1.000 0.000 1.000
#> SRR945210     1   0.118      0.984 0.984 0.016
#> SRR945211     1   0.118      0.984 0.984 0.016
#> SRR945218     2   0.000      1.000 0.000 1.000
#> SRR945219     2   0.000      1.000 0.000 1.000
#> SRR945216     2   0.000      1.000 0.000 1.000
#> SRR945217     2   0.000      1.000 0.000 1.000
#> SRR945220     2   0.000      1.000 0.000 1.000
#> SRR945221     2   0.000      1.000 0.000 1.000
#> SRR945222     2   0.000      1.000 0.000 1.000
#> SRR945223     2   0.000      1.000 0.000 1.000
#> SRR945224     2   0.000      1.000 0.000 1.000
#> SRR945225     2   0.000      1.000 0.000 1.000
#> SRR945226     2   0.000      1.000 0.000 1.000
#> SRR945227     2   0.000      1.000 0.000 1.000
#> SRR945228     2   0.000      1.000 0.000 1.000
#> SRR945229     2   0.000      1.000 0.000 1.000
#> SRR945230     2   0.000      1.000 0.000 1.000
#> SRR945231     2   0.000      1.000 0.000 1.000
#> SRR945232     2   0.000      1.000 0.000 1.000
#> SRR945233     2   0.000      1.000 0.000 1.000
#> SRR945234     2   0.000      1.000 0.000 1.000
#> SRR945235     2   0.000      1.000 0.000 1.000
#> SRR945236     2   0.000      1.000 0.000 1.000
#> SRR945237     2   0.000      1.000 0.000 1.000
#> SRR945238     2   0.000      1.000 0.000 1.000
#> SRR945239     2   0.000      1.000 0.000 1.000
#> SRR945240     2   0.000      1.000 0.000 1.000
#> SRR945241     2   0.000      1.000 0.000 1.000
#> SRR945242     2   0.000      1.000 0.000 1.000
#> SRR945243     2   0.000      1.000 0.000 1.000
#> SRR945244     2   0.000      1.000 0.000 1.000
#> SRR945245     2   0.000      1.000 0.000 1.000
#> SRR945246     2   0.000      1.000 0.000 1.000
#> SRR945247     2   0.000      1.000 0.000 1.000
#> SRR945248     2   0.000      1.000 0.000 1.000
#> SRR945249     2   0.000      1.000 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> SRR945190     1   0.412      0.919 0.832 0.000 0.168
#> SRR945191     1   0.412      0.919 0.832 0.000 0.168
#> SRR945192     1   0.412      0.919 0.832 0.000 0.168
#> SRR945193     1   0.412      0.919 0.832 0.000 0.168
#> SRR945194     1   0.412      0.919 0.832 0.000 0.168
#> SRR945195     1   0.412      0.919 0.832 0.000 0.168
#> SRR945196     1   0.412      0.919 0.832 0.000 0.168
#> SRR945197     1   0.412      0.919 0.832 0.000 0.168
#> SRR945200     1   0.412      0.919 0.832 0.000 0.168
#> SRR945201     1   0.412      0.919 0.832 0.000 0.168
#> SRR945202     1   0.000      0.913 1.000 0.000 0.000
#> SRR945203     1   0.000      0.913 1.000 0.000 0.000
#> SRR945204     1   0.000      0.913 1.000 0.000 0.000
#> SRR945205     1   0.000      0.913 1.000 0.000 0.000
#> SRR945198     1   0.412      0.919 0.832 0.000 0.168
#> SRR945199     1   0.412      0.919 0.832 0.000 0.168
#> SRR945206     1   0.000      0.913 1.000 0.000 0.000
#> SRR945207     1   0.000      0.913 1.000 0.000 0.000
#> SRR945208     1   0.000      0.913 1.000 0.000 0.000
#> SRR945209     1   0.000      0.913 1.000 0.000 0.000
#> SRR945212     1   0.000      0.913 1.000 0.000 0.000
#> SRR945213     1   0.000      0.913 1.000 0.000 0.000
#> SRR945214     2   0.000      1.000 0.000 1.000 0.000
#> SRR945215     2   0.000      1.000 0.000 1.000 0.000
#> SRR945210     1   0.364      0.809 0.872 0.004 0.124
#> SRR945211     1   0.364      0.809 0.872 0.004 0.124
#> SRR945218     2   0.000      1.000 0.000 1.000 0.000
#> SRR945219     2   0.000      1.000 0.000 1.000 0.000
#> SRR945216     2   0.000      1.000 0.000 1.000 0.000
#> SRR945217     2   0.000      1.000 0.000 1.000 0.000
#> SRR945220     2   0.000      1.000 0.000 1.000 0.000
#> SRR945221     2   0.000      1.000 0.000 1.000 0.000
#> SRR945222     2   0.000      1.000 0.000 1.000 0.000
#> SRR945223     2   0.000      1.000 0.000 1.000 0.000
#> SRR945224     2   0.000      1.000 0.000 1.000 0.000
#> SRR945225     2   0.000      1.000 0.000 1.000 0.000
#> SRR945226     2   0.000      1.000 0.000 1.000 0.000
#> SRR945227     2   0.000      1.000 0.000 1.000 0.000
#> SRR945228     2   0.000      1.000 0.000 1.000 0.000
#> SRR945229     2   0.000      1.000 0.000 1.000 0.000
#> SRR945230     2   0.000      1.000 0.000 1.000 0.000
#> SRR945231     2   0.000      1.000 0.000 1.000 0.000
#> SRR945232     2   0.000      1.000 0.000 1.000 0.000
#> SRR945233     2   0.000      1.000 0.000 1.000 0.000
#> SRR945234     2   0.000      1.000 0.000 1.000 0.000
#> SRR945235     2   0.000      1.000 0.000 1.000 0.000
#> SRR945236     2   0.000      1.000 0.000 1.000 0.000
#> SRR945237     2   0.000      1.000 0.000 1.000 0.000
#> SRR945238     3   0.412      1.000 0.000 0.168 0.832
#> SRR945239     3   0.412      1.000 0.000 0.168 0.832
#> SRR945240     3   0.412      1.000 0.000 0.168 0.832
#> SRR945241     3   0.412      1.000 0.000 0.168 0.832
#> SRR945242     3   0.412      1.000 0.000 0.168 0.832
#> SRR945243     3   0.412      1.000 0.000 0.168 0.832
#> SRR945244     3   0.412      1.000 0.000 0.168 0.832
#> SRR945245     3   0.412      1.000 0.000 0.168 0.832
#> SRR945246     3   0.412      1.000 0.000 0.168 0.832
#> SRR945247     3   0.412      1.000 0.000 0.168 0.832
#> SRR945248     3   0.412      1.000 0.000 0.168 0.832
#> SRR945249     3   0.412      1.000 0.000 0.168 0.832

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette p1 p2 p3 p4
#> SRR945190     1       0          1  1  0  0  0
#> SRR945191     1       0          1  1  0  0  0
#> SRR945192     1       0          1  1  0  0  0
#> SRR945193     1       0          1  1  0  0  0
#> SRR945194     1       0          1  1  0  0  0
#> SRR945195     1       0          1  1  0  0  0
#> SRR945196     1       0          1  1  0  0  0
#> SRR945197     1       0          1  1  0  0  0
#> SRR945200     1       0          1  1  0  0  0
#> SRR945201     1       0          1  1  0  0  0
#> SRR945202     4       0          1  0  0  0  1
#> SRR945203     4       0          1  0  0  0  1
#> SRR945204     4       0          1  0  0  0  1
#> SRR945205     4       0          1  0  0  0  1
#> SRR945198     1       0          1  1  0  0  0
#> SRR945199     1       0          1  1  0  0  0
#> SRR945206     4       0          1  0  0  0  1
#> SRR945207     4       0          1  0  0  0  1
#> SRR945208     4       0          1  0  0  0  1
#> SRR945209     4       0          1  0  0  0  1
#> SRR945212     4       0          1  0  0  0  1
#> SRR945213     4       0          1  0  0  0  1
#> SRR945214     2       0          1  0  1  0  0
#> SRR945215     2       0          1  0  1  0  0
#> SRR945210     4       0          1  0  0  0  1
#> SRR945211     4       0          1  0  0  0  1
#> SRR945218     2       0          1  0  1  0  0
#> SRR945219     2       0          1  0  1  0  0
#> SRR945216     2       0          1  0  1  0  0
#> SRR945217     2       0          1  0  1  0  0
#> SRR945220     2       0          1  0  1  0  0
#> SRR945221     2       0          1  0  1  0  0
#> SRR945222     2       0          1  0  1  0  0
#> SRR945223     2       0          1  0  1  0  0
#> SRR945224     2       0          1  0  1  0  0
#> SRR945225     2       0          1  0  1  0  0
#> SRR945226     2       0          1  0  1  0  0
#> SRR945227     2       0          1  0  1  0  0
#> SRR945228     2       0          1  0  1  0  0
#> SRR945229     2       0          1  0  1  0  0
#> SRR945230     2       0          1  0  1  0  0
#> SRR945231     2       0          1  0  1  0  0
#> SRR945232     2       0          1  0  1  0  0
#> SRR945233     2       0          1  0  1  0  0
#> SRR945234     2       0          1  0  1  0  0
#> SRR945235     2       0          1  0  1  0  0
#> SRR945236     2       0          1  0  1  0  0
#> SRR945237     2       0          1  0  1  0  0
#> SRR945238     3       0          1  0  0  1  0
#> SRR945239     3       0          1  0  0  1  0
#> SRR945240     3       0          1  0  0  1  0
#> SRR945241     3       0          1  0  0  1  0
#> SRR945242     3       0          1  0  0  1  0
#> SRR945243     3       0          1  0  0  1  0
#> SRR945244     3       0          1  0  0  1  0
#> SRR945245     3       0          1  0  0  1  0
#> SRR945246     3       0          1  0  0  1  0
#> SRR945247     3       0          1  0  0  1  0
#> SRR945248     3       0          1  0  0  1  0
#> SRR945249     3       0          1  0  0  1  0

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette p1    p2 p3    p4    p5
#> SRR945190     1  0.0000      1.000  1 0.000  0 0.000 0.000
#> SRR945191     1  0.0000      1.000  1 0.000  0 0.000 0.000
#> SRR945192     1  0.0000      1.000  1 0.000  0 0.000 0.000
#> SRR945193     1  0.0000      1.000  1 0.000  0 0.000 0.000
#> SRR945194     1  0.0000      1.000  1 0.000  0 0.000 0.000
#> SRR945195     1  0.0000      1.000  1 0.000  0 0.000 0.000
#> SRR945196     1  0.0000      1.000  1 0.000  0 0.000 0.000
#> SRR945197     1  0.0000      1.000  1 0.000  0 0.000 0.000
#> SRR945200     1  0.0000      1.000  1 0.000  0 0.000 0.000
#> SRR945201     1  0.0000      1.000  1 0.000  0 0.000 0.000
#> SRR945202     4  0.0290      0.978  0 0.000  0 0.992 0.008
#> SRR945203     4  0.0290      0.978  0 0.000  0 0.992 0.008
#> SRR945204     4  0.0794      0.967  0 0.000  0 0.972 0.028
#> SRR945205     4  0.0794      0.967  0 0.000  0 0.972 0.028
#> SRR945198     1  0.0000      1.000  1 0.000  0 0.000 0.000
#> SRR945199     1  0.0000      1.000  1 0.000  0 0.000 0.000
#> SRR945206     4  0.1197      0.948  0 0.000  0 0.952 0.048
#> SRR945207     4  0.1197      0.948  0 0.000  0 0.952 0.048
#> SRR945208     4  0.0000      0.979  0 0.000  0 1.000 0.000
#> SRR945209     4  0.0000      0.979  0 0.000  0 1.000 0.000
#> SRR945212     4  0.0000      0.979  0 0.000  0 1.000 0.000
#> SRR945213     4  0.0000      0.979  0 0.000  0 1.000 0.000
#> SRR945214     2  0.0000      0.986  0 1.000  0 0.000 0.000
#> SRR945215     2  0.0000      0.986  0 1.000  0 0.000 0.000
#> SRR945210     5  0.2074      1.000  0 0.000  0 0.104 0.896
#> SRR945211     5  0.2074      1.000  0 0.000  0 0.104 0.896
#> SRR945218     2  0.0000      0.986  0 1.000  0 0.000 0.000
#> SRR945219     2  0.0000      0.986  0 1.000  0 0.000 0.000
#> SRR945216     2  0.0000      0.986  0 1.000  0 0.000 0.000
#> SRR945217     2  0.0000      0.986  0 1.000  0 0.000 0.000
#> SRR945220     2  0.0000      0.986  0 1.000  0 0.000 0.000
#> SRR945221     2  0.0000      0.986  0 1.000  0 0.000 0.000
#> SRR945222     2  0.0000      0.986  0 1.000  0 0.000 0.000
#> SRR945223     2  0.0000      0.986  0 1.000  0 0.000 0.000
#> SRR945224     2  0.0000      0.986  0 1.000  0 0.000 0.000
#> SRR945225     2  0.0000      0.986  0 1.000  0 0.000 0.000
#> SRR945226     2  0.0404      0.984  0 0.988  0 0.000 0.012
#> SRR945227     2  0.0510      0.982  0 0.984  0 0.000 0.016
#> SRR945228     2  0.1197      0.967  0 0.952  0 0.000 0.048
#> SRR945229     2  0.1197      0.967  0 0.952  0 0.000 0.048
#> SRR945230     2  0.1197      0.967  0 0.952  0 0.000 0.048
#> SRR945231     2  0.1197      0.967  0 0.952  0 0.000 0.048
#> SRR945232     2  0.0000      0.986  0 1.000  0 0.000 0.000
#> SRR945233     2  0.0000      0.986  0 1.000  0 0.000 0.000
#> SRR945234     2  0.0404      0.984  0 0.988  0 0.000 0.012
#> SRR945235     2  0.0404      0.984  0 0.988  0 0.000 0.012
#> SRR945236     2  0.1197      0.967  0 0.952  0 0.000 0.048
#> SRR945237     2  0.1197      0.967  0 0.952  0 0.000 0.048
#> SRR945238     3  0.0000      1.000  0 0.000  1 0.000 0.000
#> SRR945239     3  0.0000      1.000  0 0.000  1 0.000 0.000
#> SRR945240     3  0.0000      1.000  0 0.000  1 0.000 0.000
#> SRR945241     3  0.0000      1.000  0 0.000  1 0.000 0.000
#> SRR945242     3  0.0000      1.000  0 0.000  1 0.000 0.000
#> SRR945243     3  0.0000      1.000  0 0.000  1 0.000 0.000
#> SRR945244     3  0.0000      1.000  0 0.000  1 0.000 0.000
#> SRR945245     3  0.0000      1.000  0 0.000  1 0.000 0.000
#> SRR945246     3  0.0000      1.000  0 0.000  1 0.000 0.000
#> SRR945247     3  0.0000      1.000  0 0.000  1 0.000 0.000
#> SRR945248     3  0.0000      1.000  0 0.000  1 0.000 0.000
#> SRR945249     3  0.0000      1.000  0 0.000  1 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
#> SRR945190     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR945191     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR945192     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR945193     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR945194     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR945195     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR945196     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR945197     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR945200     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR945201     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR945202     4  0.0291      0.929  0 0.000  0 0.992 0.004 0.004
#> SRR945203     4  0.0291      0.929  0 0.000  0 0.992 0.004 0.004
#> SRR945204     4  0.0405      0.927  0 0.000  0 0.988 0.008 0.004
#> SRR945205     4  0.0405      0.927  0 0.000  0 0.988 0.008 0.004
#> SRR945198     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR945199     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR945206     4  0.3729      0.690  0 0.000  0 0.692 0.012 0.296
#> SRR945207     4  0.3729      0.690  0 0.000  0 0.692 0.012 0.296
#> SRR945208     4  0.0000      0.930  0 0.000  0 1.000 0.000 0.000
#> SRR945209     4  0.0000      0.930  0 0.000  0 1.000 0.000 0.000
#> SRR945212     4  0.0000      0.930  0 0.000  0 1.000 0.000 0.000
#> SRR945213     4  0.0000      0.930  0 0.000  0 1.000 0.000 0.000
#> SRR945214     2  0.0363      0.872  0 0.988  0 0.000 0.000 0.012
#> SRR945215     2  0.0363      0.872  0 0.988  0 0.000 0.000 0.012
#> SRR945210     5  0.0363      1.000  0 0.000  0 0.012 0.988 0.000
#> SRR945211     5  0.0363      1.000  0 0.000  0 0.012 0.988 0.000
#> SRR945218     2  0.0146      0.878  0 0.996  0 0.000 0.000 0.004
#> SRR945219     2  0.0260      0.878  0 0.992  0 0.000 0.000 0.008
#> SRR945216     2  0.0363      0.872  0 0.988  0 0.000 0.000 0.012
#> SRR945217     2  0.0363      0.872  0 0.988  0 0.000 0.000 0.012
#> SRR945220     2  0.0000      0.878  0 1.000  0 0.000 0.000 0.000
#> SRR945221     2  0.0000      0.878  0 1.000  0 0.000 0.000 0.000
#> SRR945222     2  0.0790      0.868  0 0.968  0 0.000 0.000 0.032
#> SRR945223     2  0.0790      0.868  0 0.968  0 0.000 0.000 0.032
#> SRR945224     2  0.0000      0.878  0 1.000  0 0.000 0.000 0.000
#> SRR945225     2  0.0000      0.878  0 1.000  0 0.000 0.000 0.000
#> SRR945226     2  0.3175      0.482  0 0.744  0 0.000 0.000 0.256
#> SRR945227     2  0.3221      0.456  0 0.736  0 0.000 0.000 0.264
#> SRR945228     6  0.3672      0.988  0 0.368  0 0.000 0.000 0.632
#> SRR945229     6  0.3672      0.988  0 0.368  0 0.000 0.000 0.632
#> SRR945230     6  0.3659      0.985  0 0.364  0 0.000 0.000 0.636
#> SRR945231     6  0.3659      0.985  0 0.364  0 0.000 0.000 0.636
#> SRR945232     2  0.1204      0.849  0 0.944  0 0.000 0.000 0.056
#> SRR945233     2  0.1327      0.841  0 0.936  0 0.000 0.000 0.064
#> SRR945234     2  0.3023      0.551  0 0.768  0 0.000 0.000 0.232
#> SRR945235     2  0.3050      0.541  0 0.764  0 0.000 0.000 0.236
#> SRR945236     6  0.3706      0.978  0 0.380  0 0.000 0.000 0.620
#> SRR945237     6  0.3706      0.978  0 0.380  0 0.000 0.000 0.620
#> SRR945238     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR945239     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR945240     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR945241     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR945242     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR945243     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR945244     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR945245     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR945246     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR945247     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR945248     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR945249     3  0.0000      1.000  0 0.000  1 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-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 15912 rows and 60 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#>   Subgroups are detected by 'hclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 6.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk ATC-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.869           0.972       0.986         0.3771 0.636   0.636
#> 3 3 0.824           0.949       0.969         0.5295 0.769   0.638
#> 4 4 0.961           0.971       0.983         0.0657 0.982   0.955
#> 5 5 0.953           0.944       0.961         0.0159 0.993   0.983
#> 6 6 0.990           0.991       0.990         0.0276 0.977   0.941

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

suggest_best_k(res)
#> [1] 6

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> SRR945190     1   0.000      1.000 1.000 0.000
#> SRR945191     1   0.000      1.000 1.000 0.000
#> SRR945192     1   0.000      1.000 1.000 0.000
#> SRR945193     1   0.000      1.000 1.000 0.000
#> SRR945194     1   0.000      1.000 1.000 0.000
#> SRR945195     1   0.000      1.000 1.000 0.000
#> SRR945196     1   0.000      1.000 1.000 0.000
#> SRR945197     1   0.000      1.000 1.000 0.000
#> SRR945200     1   0.000      1.000 1.000 0.000
#> SRR945201     1   0.000      1.000 1.000 0.000
#> SRR945202     2   0.574      0.859 0.136 0.864
#> SRR945203     2   0.574      0.859 0.136 0.864
#> SRR945204     2   0.000      0.981 0.000 1.000
#> SRR945205     2   0.000      0.981 0.000 1.000
#> SRR945198     1   0.000      1.000 1.000 0.000
#> SRR945199     1   0.000      1.000 1.000 0.000
#> SRR945206     2   0.000      0.981 0.000 1.000
#> SRR945207     2   0.000      0.981 0.000 1.000
#> SRR945208     2   0.574      0.859 0.136 0.864
#> SRR945209     2   0.574      0.859 0.136 0.864
#> SRR945212     1   0.000      1.000 1.000 0.000
#> SRR945213     1   0.000      1.000 1.000 0.000
#> SRR945214     2   0.000      0.981 0.000 1.000
#> SRR945215     2   0.000      0.981 0.000 1.000
#> SRR945210     2   0.000      0.981 0.000 1.000
#> SRR945211     2   0.000      0.981 0.000 1.000
#> SRR945218     2   0.000      0.981 0.000 1.000
#> SRR945219     2   0.000      0.981 0.000 1.000
#> SRR945216     2   0.000      0.981 0.000 1.000
#> SRR945217     2   0.000      0.981 0.000 1.000
#> SRR945220     2   0.000      0.981 0.000 1.000
#> SRR945221     2   0.000      0.981 0.000 1.000
#> SRR945222     2   0.000      0.981 0.000 1.000
#> SRR945223     2   0.000      0.981 0.000 1.000
#> SRR945224     2   0.000      0.981 0.000 1.000
#> SRR945225     2   0.000      0.981 0.000 1.000
#> SRR945226     2   0.000      0.981 0.000 1.000
#> SRR945227     2   0.000      0.981 0.000 1.000
#> SRR945228     2   0.000      0.981 0.000 1.000
#> SRR945229     2   0.000      0.981 0.000 1.000
#> SRR945230     2   0.625      0.836 0.156 0.844
#> SRR945231     2   0.625      0.836 0.156 0.844
#> SRR945232     2   0.000      0.981 0.000 1.000
#> SRR945233     2   0.000      0.981 0.000 1.000
#> SRR945234     2   0.000      0.981 0.000 1.000
#> SRR945235     2   0.000      0.981 0.000 1.000
#> SRR945236     2   0.000      0.981 0.000 1.000
#> SRR945237     2   0.000      0.981 0.000 1.000
#> SRR945238     2   0.000      0.981 0.000 1.000
#> SRR945239     2   0.000      0.981 0.000 1.000
#> SRR945240     2   0.000      0.981 0.000 1.000
#> SRR945241     2   0.000      0.981 0.000 1.000
#> SRR945242     2   0.000      0.981 0.000 1.000
#> SRR945243     2   0.000      0.981 0.000 1.000
#> SRR945244     2   0.000      0.981 0.000 1.000
#> SRR945245     2   0.000      0.981 0.000 1.000
#> SRR945246     2   0.000      0.981 0.000 1.000
#> SRR945247     2   0.000      0.981 0.000 1.000
#> SRR945248     2   0.000      0.981 0.000 1.000
#> SRR945249     2   0.000      0.981 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
#> SRR945190     1  0.0000      0.961 1.000 0.000 0.000
#> SRR945191     1  0.0000      0.961 1.000 0.000 0.000
#> SRR945192     1  0.0000      0.961 1.000 0.000 0.000
#> SRR945193     1  0.0000      0.961 1.000 0.000 0.000
#> SRR945194     1  0.3619      0.894 0.864 0.000 0.136
#> SRR945195     1  0.3619      0.894 0.864 0.000 0.136
#> SRR945196     1  0.0000      0.961 1.000 0.000 0.000
#> SRR945197     1  0.0000      0.961 1.000 0.000 0.000
#> SRR945200     1  0.0000      0.961 1.000 0.000 0.000
#> SRR945201     1  0.0000      0.961 1.000 0.000 0.000
#> SRR945202     3  0.0000      0.827 0.000 0.000 1.000
#> SRR945203     3  0.0000      0.827 0.000 0.000 1.000
#> SRR945204     3  0.5058      0.786 0.000 0.244 0.756
#> SRR945205     3  0.5058      0.786 0.000 0.244 0.756
#> SRR945198     1  0.0000      0.961 1.000 0.000 0.000
#> SRR945199     1  0.0000      0.961 1.000 0.000 0.000
#> SRR945206     3  0.3619      0.832 0.000 0.136 0.864
#> SRR945207     3  0.3619      0.832 0.000 0.136 0.864
#> SRR945208     3  0.0000      0.827 0.000 0.000 1.000
#> SRR945209     3  0.0000      0.827 0.000 0.000 1.000
#> SRR945212     1  0.3619      0.894 0.864 0.000 0.136
#> SRR945213     1  0.3619      0.894 0.864 0.000 0.136
#> SRR945214     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945215     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945210     3  0.5058      0.786 0.000 0.244 0.756
#> SRR945211     3  0.5058      0.786 0.000 0.244 0.756
#> SRR945218     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945219     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945216     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945217     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945220     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945221     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945222     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945223     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945224     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945225     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945226     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945227     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945228     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945229     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945230     3  0.0892      0.817 0.020 0.000 0.980
#> SRR945231     3  0.0892      0.817 0.020 0.000 0.980
#> SRR945232     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945233     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945234     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945235     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945236     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945237     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945238     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945239     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945240     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945241     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945242     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945243     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945244     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945245     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945246     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945247     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945248     2  0.0000      1.000 0.000 1.000 0.000
#> SRR945249     2  0.0000      1.000 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1 p2    p3    p4
#> SRR945190     1  0.0000      0.949 1.000  0 0.000 0.000
#> SRR945191     1  0.0000      0.949 1.000  0 0.000 0.000
#> SRR945192     1  0.0000      0.949 1.000  0 0.000 0.000
#> SRR945193     1  0.0000      0.949 1.000  0 0.000 0.000
#> SRR945194     1  0.3123      0.866 0.844  0 0.000 0.156
#> SRR945195     1  0.3123      0.866 0.844  0 0.000 0.156
#> SRR945196     1  0.0000      0.949 1.000  0 0.000 0.000
#> SRR945197     1  0.0000      0.949 1.000  0 0.000 0.000
#> SRR945200     1  0.0000      0.949 1.000  0 0.000 0.000
#> SRR945201     1  0.0000      0.949 1.000  0 0.000 0.000
#> SRR945202     4  0.0707      0.945 0.000  0 0.020 0.980
#> SRR945203     4  0.0707      0.945 0.000  0 0.020 0.980
#> SRR945204     3  0.0000      1.000 0.000  0 1.000 0.000
#> SRR945205     3  0.0000      1.000 0.000  0 1.000 0.000
#> SRR945198     1  0.0000      0.949 1.000  0 0.000 0.000
#> SRR945199     1  0.0000      0.949 1.000  0 0.000 0.000
#> SRR945206     4  0.3123      0.836 0.000  0 0.156 0.844
#> SRR945207     4  0.3123      0.836 0.000  0 0.156 0.844
#> SRR945208     4  0.0707      0.945 0.000  0 0.020 0.980
#> SRR945209     4  0.0707      0.945 0.000  0 0.020 0.980
#> SRR945212     1  0.3123      0.866 0.844  0 0.000 0.156
#> SRR945213     1  0.3123      0.866 0.844  0 0.000 0.156
#> SRR945214     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR945215     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR945210     3  0.0000      1.000 0.000  0 1.000 0.000
#> SRR945211     3  0.0000      1.000 0.000  0 1.000 0.000
#> SRR945218     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR945219     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR945216     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR945217     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR945220     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR945221     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR945222     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR945223     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR945224     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR945225     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR945226     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR945227     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR945228     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR945229     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR945230     4  0.0000      0.935 0.000  0 0.000 1.000
#> SRR945231     4  0.0000      0.935 0.000  0 0.000 1.000
#> SRR945232     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR945233     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR945234     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR945235     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR945236     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR945237     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR945238     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR945239     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR945240     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR945241     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR945242     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR945243     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR945244     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR945245     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR945246     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR945247     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR945248     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR945249     2  0.0000      1.000 0.000  1 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1 p2    p3    p4 p5
#> SRR945190     1   0.000      0.885 1.000  0 0.000 0.000  0
#> SRR945191     1   0.000      0.885 1.000  0 0.000 0.000  0
#> SRR945192     1   0.000      0.885 1.000  0 0.000 0.000  0
#> SRR945193     1   0.000      0.885 1.000  0 0.000 0.000  0
#> SRR945194     1   0.405      0.640 0.644  0 0.356 0.000  0
#> SRR945195     1   0.405      0.640 0.644  0 0.356 0.000  0
#> SRR945196     1   0.000      0.885 1.000  0 0.000 0.000  0
#> SRR945197     1   0.000      0.885 1.000  0 0.000 0.000  0
#> SRR945200     1   0.000      0.885 1.000  0 0.000 0.000  0
#> SRR945201     1   0.000      0.885 1.000  0 0.000 0.000  0
#> SRR945202     4   0.247      0.900 0.000  0 0.136 0.864  0
#> SRR945203     4   0.247      0.900 0.000  0 0.136 0.864  0
#> SRR945204     5   0.000      1.000 0.000  0 0.000 0.000  1
#> SRR945205     5   0.000      1.000 0.000  0 0.000 0.000  1
#> SRR945198     1   0.000      0.885 1.000  0 0.000 0.000  0
#> SRR945199     1   0.000      0.885 1.000  0 0.000 0.000  0
#> SRR945206     4   0.000      0.806 0.000  0 0.000 1.000  0
#> SRR945207     4   0.000      0.806 0.000  0 0.000 1.000  0
#> SRR945208     4   0.247      0.900 0.000  0 0.136 0.864  0
#> SRR945209     4   0.247      0.900 0.000  0 0.136 0.864  0
#> SRR945212     1   0.405      0.640 0.644  0 0.356 0.000  0
#> SRR945213     1   0.405      0.640 0.644  0 0.356 0.000  0
#> SRR945214     2   0.000      1.000 0.000  1 0.000 0.000  0
#> SRR945215     2   0.000      1.000 0.000  1 0.000 0.000  0
#> SRR945210     5   0.000      1.000 0.000  0 0.000 0.000  1
#> SRR945211     5   0.000      1.000 0.000  0 0.000 0.000  1
#> SRR945218     2   0.000      1.000 0.000  1 0.000 0.000  0
#> SRR945219     2   0.000      1.000 0.000  1 0.000 0.000  0
#> SRR945216     2   0.000      1.000 0.000  1 0.000 0.000  0
#> SRR945217     2   0.000      1.000 0.000  1 0.000 0.000  0
#> SRR945220     2   0.000      1.000 0.000  1 0.000 0.000  0
#> SRR945221     2   0.000      1.000 0.000  1 0.000 0.000  0
#> SRR945222     2   0.000      1.000 0.000  1 0.000 0.000  0
#> SRR945223     2   0.000      1.000 0.000  1 0.000 0.000  0
#> SRR945224     2   0.000      1.000 0.000  1 0.000 0.000  0
#> SRR945225     2   0.000      1.000 0.000  1 0.000 0.000  0
#> SRR945226     2   0.000      1.000 0.000  1 0.000 0.000  0
#> SRR945227     2   0.000      1.000 0.000  1 0.000 0.000  0
#> SRR945228     2   0.000      1.000 0.000  1 0.000 0.000  0
#> SRR945229     2   0.000      1.000 0.000  1 0.000 0.000  0
#> SRR945230     3   0.311      1.000 0.000  0 0.800 0.200  0
#> SRR945231     3   0.311      1.000 0.000  0 0.800 0.200  0
#> SRR945232     2   0.000      1.000 0.000  1 0.000 0.000  0
#> SRR945233     2   0.000      1.000 0.000  1 0.000 0.000  0
#> SRR945234     2   0.000      1.000 0.000  1 0.000 0.000  0
#> SRR945235     2   0.000      1.000 0.000  1 0.000 0.000  0
#> SRR945236     2   0.000      1.000 0.000  1 0.000 0.000  0
#> SRR945237     2   0.000      1.000 0.000  1 0.000 0.000  0
#> SRR945238     2   0.000      1.000 0.000  1 0.000 0.000  0
#> SRR945239     2   0.000      1.000 0.000  1 0.000 0.000  0
#> SRR945240     2   0.000      1.000 0.000  1 0.000 0.000  0
#> SRR945241     2   0.000      1.000 0.000  1 0.000 0.000  0
#> SRR945242     2   0.000      1.000 0.000  1 0.000 0.000  0
#> SRR945243     2   0.000      1.000 0.000  1 0.000 0.000  0
#> SRR945244     2   0.000      1.000 0.000  1 0.000 0.000  0
#> SRR945245     2   0.000      1.000 0.000  1 0.000 0.000  0
#> SRR945246     2   0.000      1.000 0.000  1 0.000 0.000  0
#> SRR945247     2   0.000      1.000 0.000  1 0.000 0.000  0
#> SRR945248     2   0.000      1.000 0.000  1 0.000 0.000  0
#> SRR945249     2   0.000      1.000 0.000  1 0.000 0.000  0

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette p1 p2    p3    p4 p5    p6
#> SRR945190     1   0.000      1.000  1  0 0.000 0.000  0 0.000
#> SRR945191     1   0.000      1.000  1  0 0.000 0.000  0 0.000
#> SRR945192     1   0.000      1.000  1  0 0.000 0.000  0 0.000
#> SRR945193     1   0.000      1.000  1  0 0.000 0.000  0 0.000
#> SRR945194     3   0.000      1.000  0  0 1.000 0.000  0 0.000
#> SRR945195     3   0.000      1.000  0  0 1.000 0.000  0 0.000
#> SRR945196     1   0.000      1.000  1  0 0.000 0.000  0 0.000
#> SRR945197     1   0.000      1.000  1  0 0.000 0.000  0 0.000
#> SRR945200     1   0.000      1.000  1  0 0.000 0.000  0 0.000
#> SRR945201     1   0.000      1.000  1  0 0.000 0.000  0 0.000
#> SRR945202     4   0.257      0.933  0  0 0.136 0.852  0 0.012
#> SRR945203     4   0.257      0.933  0  0 0.136 0.852  0 0.012
#> SRR945204     5   0.000      1.000  0  0 0.000 0.000  1 0.000
#> SRR945205     5   0.000      1.000  0  0 0.000 0.000  1 0.000
#> SRR945198     1   0.000      1.000  1  0 0.000 0.000  0 0.000
#> SRR945199     1   0.000      1.000  1  0 0.000 0.000  0 0.000
#> SRR945206     4   0.000      0.861  0  0 0.000 1.000  0 0.000
#> SRR945207     4   0.000      0.861  0  0 0.000 1.000  0 0.000
#> SRR945208     4   0.257      0.933  0  0 0.136 0.852  0 0.012
#> SRR945209     4   0.257      0.933  0  0 0.136 0.852  0 0.012
#> SRR945212     3   0.000      1.000  0  0 1.000 0.000  0 0.000
#> SRR945213     3   0.000      1.000  0  0 1.000 0.000  0 0.000
#> SRR945214     2   0.000      1.000  0  1 0.000 0.000  0 0.000
#> SRR945215     2   0.000      1.000  0  1 0.000 0.000  0 0.000
#> SRR945210     5   0.000      1.000  0  0 0.000 0.000  1 0.000
#> SRR945211     5   0.000      1.000  0  0 0.000 0.000  1 0.000
#> SRR945218     2   0.000      1.000  0  1 0.000 0.000  0 0.000
#> SRR945219     2   0.000      1.000  0  1 0.000 0.000  0 0.000
#> SRR945216     2   0.000      1.000  0  1 0.000 0.000  0 0.000
#> SRR945217     2   0.000      1.000  0  1 0.000 0.000  0 0.000
#> SRR945220     2   0.000      1.000  0  1 0.000 0.000  0 0.000
#> SRR945221     2   0.000      1.000  0  1 0.000 0.000  0 0.000
#> SRR945222     2   0.000      1.000  0  1 0.000 0.000  0 0.000
#> SRR945223     2   0.000      1.000  0  1 0.000 0.000  0 0.000
#> SRR945224     2   0.000      1.000  0  1 0.000 0.000  0 0.000
#> SRR945225     2   0.000      1.000  0  1 0.000 0.000  0 0.000
#> SRR945226     2   0.000      1.000  0  1 0.000 0.000  0 0.000
#> SRR945227     2   0.000      1.000  0  1 0.000 0.000  0 0.000
#> SRR945228     2   0.000      1.000  0  1 0.000 0.000  0 0.000
#> SRR945229     2   0.000      1.000  0  1 0.000 0.000  0 0.000
#> SRR945230     6   0.000      1.000  0  0 0.000 0.000  0 1.000
#> SRR945231     6   0.000      1.000  0  0 0.000 0.000  0 1.000
#> SRR945232     2   0.000      1.000  0  1 0.000 0.000  0 0.000
#> SRR945233     2   0.000      1.000  0  1 0.000 0.000  0 0.000
#> SRR945234     2   0.000      1.000  0  1 0.000 0.000  0 0.000
#> SRR945235     2   0.000      1.000  0  1 0.000 0.000  0 0.000
#> SRR945236     2   0.000      1.000  0  1 0.000 0.000  0 0.000
#> SRR945237     2   0.000      1.000  0  1 0.000 0.000  0 0.000
#> SRR945238     2   0.000      1.000  0  1 0.000 0.000  0 0.000
#> SRR945239     2   0.000      1.000  0  1 0.000 0.000  0 0.000
#> SRR945240     2   0.000      1.000  0  1 0.000 0.000  0 0.000
#> SRR945241     2   0.000      1.000  0  1 0.000 0.000  0 0.000
#> SRR945242     2   0.000      1.000  0  1 0.000 0.000  0 0.000
#> SRR945243     2   0.000      1.000  0  1 0.000 0.000  0 0.000
#> SRR945244     2   0.000      1.000  0  1 0.000 0.000  0 0.000
#> SRR945245     2   0.000      1.000  0  1 0.000 0.000  0 0.000
#> SRR945246     2   0.000      1.000  0  1 0.000 0.000  0 0.000
#> SRR945247     2   0.000      1.000  0  1 0.000 0.000  0 0.000
#> SRR945248     2   0.000      1.000  0  1 0.000 0.000  0 0.000
#> SRR945249     2   0.000      1.000  0  1 0.000 0.000  0 0.000

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

consensus_heatmap(res, k = 2)

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

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

collect_plots(res)

plot of chunk ATC-kmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.992       0.996         0.4504 0.548   0.548
#> 3 3 0.670           0.836       0.876         0.3546 0.817   0.678
#> 4 4 0.802           0.958       0.916         0.1660 0.851   0.632
#> 5 5 0.719           0.881       0.870         0.0584 1.000   1.000
#> 6 6 0.814           0.695       0.814         0.0386 0.964   0.865

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
#> SRR945190     1   0.000      0.989 1.00 0.00
#> SRR945191     1   0.000      0.989 1.00 0.00
#> SRR945192     1   0.000      0.989 1.00 0.00
#> SRR945193     1   0.000      0.989 1.00 0.00
#> SRR945194     1   0.000      0.989 1.00 0.00
#> SRR945195     1   0.000      0.989 1.00 0.00
#> SRR945196     1   0.000      0.989 1.00 0.00
#> SRR945197     1   0.000      0.989 1.00 0.00
#> SRR945200     1   0.000      0.989 1.00 0.00
#> SRR945201     1   0.000      0.989 1.00 0.00
#> SRR945202     1   0.000      0.989 1.00 0.00
#> SRR945203     1   0.000      0.989 1.00 0.00
#> SRR945204     2   0.000      0.999 0.00 1.00
#> SRR945205     2   0.000      0.999 0.00 1.00
#> SRR945198     1   0.000      0.989 1.00 0.00
#> SRR945199     1   0.000      0.989 1.00 0.00
#> SRR945206     1   0.469      0.894 0.90 0.10
#> SRR945207     1   0.469      0.894 0.90 0.10
#> SRR945208     1   0.000      0.989 1.00 0.00
#> SRR945209     1   0.000      0.989 1.00 0.00
#> SRR945212     1   0.000      0.989 1.00 0.00
#> SRR945213     1   0.000      0.989 1.00 0.00
#> SRR945214     2   0.000      0.999 0.00 1.00
#> SRR945215     2   0.000      0.999 0.00 1.00
#> SRR945210     2   0.000      0.999 0.00 1.00
#> SRR945211     2   0.000      0.999 0.00 1.00
#> SRR945218     2   0.000      0.999 0.00 1.00
#> SRR945219     2   0.000      0.999 0.00 1.00
#> SRR945216     2   0.000      0.999 0.00 1.00
#> SRR945217     2   0.000      0.999 0.00 1.00
#> SRR945220     2   0.000      0.999 0.00 1.00
#> SRR945221     2   0.000      0.999 0.00 1.00
#> SRR945222     2   0.000      0.999 0.00 1.00
#> SRR945223     2   0.000      0.999 0.00 1.00
#> SRR945224     2   0.000      0.999 0.00 1.00
#> SRR945225     2   0.000      0.999 0.00 1.00
#> SRR945226     2   0.000      0.999 0.00 1.00
#> SRR945227     2   0.000      0.999 0.00 1.00
#> SRR945228     2   0.000      0.999 0.00 1.00
#> SRR945229     2   0.000      0.999 0.00 1.00
#> SRR945230     2   0.141      0.980 0.02 0.98
#> SRR945231     2   0.141      0.980 0.02 0.98
#> SRR945232     2   0.000      0.999 0.00 1.00
#> SRR945233     2   0.000      0.999 0.00 1.00
#> SRR945234     2   0.000      0.999 0.00 1.00
#> SRR945235     2   0.000      0.999 0.00 1.00
#> SRR945236     2   0.000      0.999 0.00 1.00
#> SRR945237     2   0.000      0.999 0.00 1.00
#> SRR945238     2   0.000      0.999 0.00 1.00
#> SRR945239     2   0.000      0.999 0.00 1.00
#> SRR945240     2   0.000      0.999 0.00 1.00
#> SRR945241     2   0.000      0.999 0.00 1.00
#> SRR945242     2   0.000      0.999 0.00 1.00
#> SRR945243     2   0.000      0.999 0.00 1.00
#> SRR945244     2   0.000      0.999 0.00 1.00
#> SRR945245     2   0.000      0.999 0.00 1.00
#> SRR945246     2   0.000      0.999 0.00 1.00
#> SRR945247     2   0.000      0.999 0.00 1.00
#> SRR945248     2   0.000      0.999 0.00 1.00
#> SRR945249     2   0.000      0.999 0.00 1.00

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> SRR945190     1  0.0000      0.978 1.000 0.000 0.000
#> SRR945191     1  0.0000      0.978 1.000 0.000 0.000
#> SRR945192     1  0.0000      0.978 1.000 0.000 0.000
#> SRR945193     1  0.0000      0.978 1.000 0.000 0.000
#> SRR945194     1  0.3192      0.863 0.888 0.000 0.112
#> SRR945195     1  0.3192      0.863 0.888 0.000 0.112
#> SRR945196     1  0.0000      0.978 1.000 0.000 0.000
#> SRR945197     1  0.0000      0.978 1.000 0.000 0.000
#> SRR945200     1  0.0000      0.978 1.000 0.000 0.000
#> SRR945201     1  0.0000      0.978 1.000 0.000 0.000
#> SRR945202     3  0.5988      0.653 0.304 0.008 0.688
#> SRR945203     3  0.5988      0.653 0.304 0.008 0.688
#> SRR945204     3  0.4931      0.771 0.000 0.232 0.768
#> SRR945205     3  0.4931      0.771 0.000 0.232 0.768
#> SRR945198     1  0.0000      0.978 1.000 0.000 0.000
#> SRR945199     1  0.0000      0.978 1.000 0.000 0.000
#> SRR945206     3  0.7272      0.742 0.204 0.096 0.700
#> SRR945207     3  0.7272      0.742 0.204 0.096 0.700
#> SRR945208     3  0.5988      0.653 0.304 0.008 0.688
#> SRR945209     3  0.5988      0.653 0.304 0.008 0.688
#> SRR945212     1  0.0424      0.973 0.992 0.000 0.008
#> SRR945213     1  0.0424      0.973 0.992 0.000 0.008
#> SRR945214     2  0.0000      0.867 0.000 1.000 0.000
#> SRR945215     2  0.0000      0.867 0.000 1.000 0.000
#> SRR945210     3  0.5138      0.742 0.000 0.252 0.748
#> SRR945211     3  0.5138      0.742 0.000 0.252 0.748
#> SRR945218     2  0.0000      0.867 0.000 1.000 0.000
#> SRR945219     2  0.0000      0.867 0.000 1.000 0.000
#> SRR945216     2  0.0000      0.867 0.000 1.000 0.000
#> SRR945217     2  0.0000      0.867 0.000 1.000 0.000
#> SRR945220     2  0.0000      0.867 0.000 1.000 0.000
#> SRR945221     2  0.0000      0.867 0.000 1.000 0.000
#> SRR945222     2  0.1163      0.859 0.000 0.972 0.028
#> SRR945223     2  0.1163      0.859 0.000 0.972 0.028
#> SRR945224     2  0.0000      0.867 0.000 1.000 0.000
#> SRR945225     2  0.0000      0.867 0.000 1.000 0.000
#> SRR945226     2  0.0000      0.867 0.000 1.000 0.000
#> SRR945227     2  0.0000      0.867 0.000 1.000 0.000
#> SRR945228     2  0.0000      0.867 0.000 1.000 0.000
#> SRR945229     2  0.0000      0.867 0.000 1.000 0.000
#> SRR945230     3  0.5650      0.737 0.000 0.312 0.688
#> SRR945231     3  0.5650      0.737 0.000 0.312 0.688
#> SRR945232     2  0.0000      0.867 0.000 1.000 0.000
#> SRR945233     2  0.0000      0.867 0.000 1.000 0.000
#> SRR945234     2  0.0000      0.867 0.000 1.000 0.000
#> SRR945235     2  0.0000      0.867 0.000 1.000 0.000
#> SRR945236     2  0.0000      0.867 0.000 1.000 0.000
#> SRR945237     2  0.0000      0.867 0.000 1.000 0.000
#> SRR945238     2  0.5650      0.756 0.000 0.688 0.312
#> SRR945239     2  0.5650      0.756 0.000 0.688 0.312
#> SRR945240     2  0.5650      0.756 0.000 0.688 0.312
#> SRR945241     2  0.5650      0.756 0.000 0.688 0.312
#> SRR945242     2  0.5650      0.756 0.000 0.688 0.312
#> SRR945243     2  0.5650      0.756 0.000 0.688 0.312
#> SRR945244     2  0.5650      0.756 0.000 0.688 0.312
#> SRR945245     2  0.5650      0.756 0.000 0.688 0.312
#> SRR945246     2  0.5650      0.756 0.000 0.688 0.312
#> SRR945247     2  0.5650      0.756 0.000 0.688 0.312
#> SRR945248     2  0.5650      0.756 0.000 0.688 0.312
#> SRR945249     2  0.5650      0.756 0.000 0.688 0.312

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> SRR945190     1  0.0000      0.938 1.000 0.000 0.000 0.000
#> SRR945191     1  0.0000      0.938 1.000 0.000 0.000 0.000
#> SRR945192     1  0.0000      0.938 1.000 0.000 0.000 0.000
#> SRR945193     1  0.0000      0.938 1.000 0.000 0.000 0.000
#> SRR945194     1  0.5582      0.782 0.724 0.000 0.168 0.108
#> SRR945195     1  0.5582      0.782 0.724 0.000 0.168 0.108
#> SRR945196     1  0.0000      0.938 1.000 0.000 0.000 0.000
#> SRR945197     1  0.0000      0.938 1.000 0.000 0.000 0.000
#> SRR945200     1  0.0000      0.938 1.000 0.000 0.000 0.000
#> SRR945201     1  0.0000      0.938 1.000 0.000 0.000 0.000
#> SRR945202     4  0.1151      0.932 0.008 0.000 0.024 0.968
#> SRR945203     4  0.1151      0.932 0.008 0.000 0.024 0.968
#> SRR945204     4  0.1824      0.931 0.000 0.004 0.060 0.936
#> SRR945205     4  0.1824      0.931 0.000 0.004 0.060 0.936
#> SRR945198     1  0.0000      0.938 1.000 0.000 0.000 0.000
#> SRR945199     1  0.0000      0.938 1.000 0.000 0.000 0.000
#> SRR945206     4  0.0712      0.936 0.004 0.004 0.008 0.984
#> SRR945207     4  0.0712      0.936 0.004 0.004 0.008 0.984
#> SRR945208     4  0.2675      0.902 0.008 0.000 0.100 0.892
#> SRR945209     4  0.2675      0.902 0.008 0.000 0.100 0.892
#> SRR945212     1  0.4462      0.840 0.792 0.000 0.164 0.044
#> SRR945213     1  0.4462      0.840 0.792 0.000 0.164 0.044
#> SRR945214     2  0.0000      0.996 0.000 1.000 0.000 0.000
#> SRR945215     2  0.0000      0.996 0.000 1.000 0.000 0.000
#> SRR945210     4  0.2984      0.915 0.000 0.028 0.084 0.888
#> SRR945211     4  0.2984      0.915 0.000 0.028 0.084 0.888
#> SRR945218     2  0.0000      0.996 0.000 1.000 0.000 0.000
#> SRR945219     2  0.0000      0.996 0.000 1.000 0.000 0.000
#> SRR945216     2  0.0000      0.996 0.000 1.000 0.000 0.000
#> SRR945217     2  0.0000      0.996 0.000 1.000 0.000 0.000
#> SRR945220     2  0.0000      0.996 0.000 1.000 0.000 0.000
#> SRR945221     2  0.0000      0.996 0.000 1.000 0.000 0.000
#> SRR945222     2  0.0188      0.996 0.000 0.996 0.000 0.004
#> SRR945223     2  0.0188      0.996 0.000 0.996 0.000 0.004
#> SRR945224     2  0.0188      0.994 0.000 0.996 0.004 0.000
#> SRR945225     2  0.0188      0.994 0.000 0.996 0.004 0.000
#> SRR945226     2  0.0188      0.996 0.000 0.996 0.000 0.004
#> SRR945227     2  0.0188      0.996 0.000 0.996 0.000 0.004
#> SRR945228     2  0.0524      0.990 0.000 0.988 0.008 0.004
#> SRR945229     2  0.0524      0.990 0.000 0.988 0.008 0.004
#> SRR945230     4  0.3970      0.890 0.000 0.076 0.084 0.840
#> SRR945231     4  0.3970      0.890 0.000 0.076 0.084 0.840
#> SRR945232     2  0.0188      0.994 0.000 0.996 0.004 0.000
#> SRR945233     2  0.0188      0.994 0.000 0.996 0.004 0.000
#> SRR945234     2  0.0188      0.996 0.000 0.996 0.000 0.004
#> SRR945235     2  0.0188      0.996 0.000 0.996 0.000 0.004
#> SRR945236     2  0.0188      0.996 0.000 0.996 0.000 0.004
#> SRR945237     2  0.0188      0.996 0.000 0.996 0.000 0.004
#> SRR945238     3  0.4252      0.998 0.000 0.252 0.744 0.004
#> SRR945239     3  0.4252      0.998 0.000 0.252 0.744 0.004
#> SRR945240     3  0.4072      0.999 0.000 0.252 0.748 0.000
#> SRR945241     3  0.4072      0.999 0.000 0.252 0.748 0.000
#> SRR945242     3  0.4072      0.999 0.000 0.252 0.748 0.000
#> SRR945243     3  0.4072      0.999 0.000 0.252 0.748 0.000
#> SRR945244     3  0.4072      0.999 0.000 0.252 0.748 0.000
#> SRR945245     3  0.4072      0.999 0.000 0.252 0.748 0.000
#> SRR945246     3  0.4072      0.999 0.000 0.252 0.748 0.000
#> SRR945247     3  0.4072      0.999 0.000 0.252 0.748 0.000
#> SRR945248     3  0.4252      0.998 0.000 0.252 0.744 0.004
#> SRR945249     3  0.4252      0.998 0.000 0.252 0.744 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
#> SRR945190     1  0.0451      0.881 0.988 0.000 0.008 0.000 NA
#> SRR945191     1  0.0451      0.881 0.988 0.000 0.008 0.000 NA
#> SRR945192     1  0.0162      0.881 0.996 0.000 0.000 0.000 NA
#> SRR945193     1  0.0162      0.881 0.996 0.000 0.000 0.000 NA
#> SRR945194     1  0.5799      0.555 0.548 0.000 0.012 0.068 NA
#> SRR945195     1  0.5799      0.555 0.548 0.000 0.012 0.068 NA
#> SRR945196     1  0.0865      0.876 0.972 0.000 0.024 0.000 NA
#> SRR945197     1  0.0865      0.876 0.972 0.000 0.024 0.000 NA
#> SRR945200     1  0.0000      0.881 1.000 0.000 0.000 0.000 NA
#> SRR945201     1  0.0000      0.881 1.000 0.000 0.000 0.000 NA
#> SRR945202     4  0.3109      0.842 0.000 0.000 0.000 0.800 NA
#> SRR945203     4  0.3109      0.842 0.000 0.000 0.000 0.800 NA
#> SRR945204     4  0.1310      0.817 0.000 0.000 0.020 0.956 NA
#> SRR945205     4  0.1310      0.817 0.000 0.000 0.020 0.956 NA
#> SRR945198     1  0.0451      0.881 0.988 0.000 0.008 0.000 NA
#> SRR945199     1  0.0451      0.881 0.988 0.000 0.008 0.000 NA
#> SRR945206     4  0.3409      0.845 0.000 0.000 0.032 0.824 NA
#> SRR945207     4  0.3409      0.845 0.000 0.000 0.032 0.824 NA
#> SRR945208     4  0.3730      0.812 0.000 0.000 0.000 0.712 NA
#> SRR945209     4  0.3730      0.812 0.000 0.000 0.000 0.712 NA
#> SRR945212     1  0.4996      0.682 0.652 0.000 0.012 0.032 NA
#> SRR945213     1  0.4996      0.682 0.652 0.000 0.012 0.032 NA
#> SRR945214     2  0.2536      0.929 0.000 0.868 0.004 0.000 NA
#> SRR945215     2  0.2536      0.929 0.000 0.868 0.004 0.000 NA
#> SRR945210     4  0.3666      0.774 0.000 0.020 0.048 0.840 NA
#> SRR945211     4  0.3666      0.774 0.000 0.020 0.048 0.840 NA
#> SRR945218     2  0.1544      0.943 0.000 0.932 0.000 0.000 NA
#> SRR945219     2  0.1544      0.943 0.000 0.932 0.000 0.000 NA
#> SRR945216     2  0.2536      0.929 0.000 0.868 0.004 0.000 NA
#> SRR945217     2  0.2536      0.929 0.000 0.868 0.004 0.000 NA
#> SRR945220     2  0.1544      0.943 0.000 0.932 0.000 0.000 NA
#> SRR945221     2  0.1544      0.943 0.000 0.932 0.000 0.000 NA
#> SRR945222     2  0.2719      0.926 0.000 0.852 0.004 0.000 NA
#> SRR945223     2  0.2719      0.926 0.000 0.852 0.004 0.000 NA
#> SRR945224     2  0.0000      0.940 0.000 1.000 0.000 0.000 NA
#> SRR945225     2  0.0000      0.940 0.000 1.000 0.000 0.000 NA
#> SRR945226     2  0.0162      0.940 0.000 0.996 0.000 0.000 NA
#> SRR945227     2  0.0162      0.940 0.000 0.996 0.000 0.000 NA
#> SRR945228     2  0.0404      0.939 0.000 0.988 0.000 0.000 NA
#> SRR945229     2  0.0404      0.939 0.000 0.988 0.000 0.000 NA
#> SRR945230     4  0.5678      0.724 0.000 0.028 0.036 0.556 NA
#> SRR945231     4  0.5678      0.724 0.000 0.028 0.036 0.556 NA
#> SRR945232     2  0.0000      0.940 0.000 1.000 0.000 0.000 NA
#> SRR945233     2  0.0000      0.940 0.000 1.000 0.000 0.000 NA
#> SRR945234     2  0.2629      0.929 0.000 0.860 0.004 0.000 NA
#> SRR945235     2  0.2629      0.929 0.000 0.860 0.004 0.000 NA
#> SRR945236     2  0.0510      0.938 0.000 0.984 0.000 0.000 NA
#> SRR945237     2  0.0510      0.938 0.000 0.984 0.000 0.000 NA
#> SRR945238     3  0.4548      0.930 0.000 0.120 0.752 0.000 NA
#> SRR945239     3  0.4548      0.930 0.000 0.120 0.752 0.000 NA
#> SRR945240     3  0.2280      0.956 0.000 0.120 0.880 0.000 NA
#> SRR945241     3  0.2280      0.956 0.000 0.120 0.880 0.000 NA
#> SRR945242     3  0.2439      0.956 0.000 0.120 0.876 0.000 NA
#> SRR945243     3  0.2439      0.956 0.000 0.120 0.876 0.000 NA
#> SRR945244     3  0.3437      0.953 0.000 0.120 0.832 0.000 NA
#> SRR945245     3  0.3437      0.953 0.000 0.120 0.832 0.000 NA
#> SRR945246     3  0.2439      0.956 0.000 0.120 0.876 0.000 NA
#> SRR945247     3  0.2439      0.956 0.000 0.120 0.876 0.000 NA
#> SRR945248     3  0.4796      0.920 0.000 0.120 0.728 0.000 NA
#> SRR945249     3  0.4796      0.920 0.000 0.120 0.728 0.000 NA

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5 p6
#> SRR945190     1  0.0405     0.8795 0.988 0.000 0.000 0.000 0.004 NA
#> SRR945191     1  0.0405     0.8795 0.988 0.000 0.000 0.000 0.004 NA
#> SRR945192     1  0.1620     0.8712 0.940 0.000 0.024 0.000 0.012 NA
#> SRR945193     1  0.1620     0.8712 0.940 0.000 0.024 0.000 0.012 NA
#> SRR945194     4  0.6020    -0.1392 0.372 0.000 0.000 0.420 0.004 NA
#> SRR945195     4  0.6020    -0.1392 0.372 0.000 0.000 0.420 0.004 NA
#> SRR945196     1  0.2252     0.8615 0.908 0.000 0.028 0.000 0.020 NA
#> SRR945197     1  0.2252     0.8615 0.908 0.000 0.028 0.000 0.020 NA
#> SRR945200     1  0.0146     0.8799 0.996 0.000 0.000 0.000 0.004 NA
#> SRR945201     1  0.0146     0.8799 0.996 0.000 0.000 0.000 0.004 NA
#> SRR945202     4  0.2302     0.2835 0.000 0.000 0.000 0.872 0.120 NA
#> SRR945203     4  0.2302     0.2835 0.000 0.000 0.000 0.872 0.120 NA
#> SRR945204     4  0.4537    -0.6372 0.000 0.000 0.004 0.492 0.480 NA
#> SRR945205     4  0.4537    -0.6372 0.000 0.000 0.004 0.492 0.480 NA
#> SRR945198     1  0.0405     0.8795 0.988 0.000 0.000 0.000 0.004 NA
#> SRR945199     1  0.0405     0.8795 0.988 0.000 0.000 0.000 0.004 NA
#> SRR945206     4  0.3698     0.2044 0.000 0.000 0.020 0.788 0.164 NA
#> SRR945207     4  0.3698     0.2044 0.000 0.000 0.020 0.788 0.164 NA
#> SRR945208     4  0.0363     0.3362 0.000 0.000 0.000 0.988 0.000 NA
#> SRR945209     4  0.0363     0.3362 0.000 0.000 0.000 0.988 0.000 NA
#> SRR945212     1  0.5789     0.3389 0.496 0.000 0.000 0.288 0.000 NA
#> SRR945213     1  0.5789     0.3389 0.496 0.000 0.000 0.288 0.000 NA
#> SRR945214     2  0.3584     0.8509 0.000 0.740 0.012 0.000 0.004 NA
#> SRR945215     2  0.3584     0.8509 0.000 0.740 0.012 0.000 0.004 NA
#> SRR945210     5  0.4397     1.0000 0.000 0.020 0.012 0.336 0.632 NA
#> SRR945211     5  0.4397     1.0000 0.000 0.020 0.012 0.336 0.632 NA
#> SRR945218     2  0.2212     0.8897 0.000 0.880 0.000 0.000 0.008 NA
#> SRR945219     2  0.2212     0.8897 0.000 0.880 0.000 0.000 0.008 NA
#> SRR945216     2  0.3584     0.8509 0.000 0.740 0.012 0.000 0.004 NA
#> SRR945217     2  0.3584     0.8509 0.000 0.740 0.012 0.000 0.004 NA
#> SRR945220     2  0.2212     0.8897 0.000 0.880 0.000 0.000 0.008 NA
#> SRR945221     2  0.2212     0.8897 0.000 0.880 0.000 0.000 0.008 NA
#> SRR945222     2  0.3853     0.8428 0.000 0.708 0.012 0.000 0.008 NA
#> SRR945223     2  0.3853     0.8428 0.000 0.708 0.012 0.000 0.008 NA
#> SRR945224     2  0.0146     0.8856 0.000 0.996 0.000 0.000 0.004 NA
#> SRR945225     2  0.0146     0.8856 0.000 0.996 0.000 0.000 0.004 NA
#> SRR945226     2  0.0000     0.8854 0.000 1.000 0.000 0.000 0.000 NA
#> SRR945227     2  0.0000     0.8854 0.000 1.000 0.000 0.000 0.000 NA
#> SRR945228     2  0.0777     0.8810 0.000 0.972 0.004 0.000 0.000 NA
#> SRR945229     2  0.0777     0.8810 0.000 0.972 0.004 0.000 0.000 NA
#> SRR945230     4  0.6343     0.0259 0.000 0.008 0.008 0.416 0.360 NA
#> SRR945231     4  0.6343     0.0259 0.000 0.008 0.008 0.416 0.360 NA
#> SRR945232     2  0.0000     0.8854 0.000 1.000 0.000 0.000 0.000 NA
#> SRR945233     2  0.0000     0.8854 0.000 1.000 0.000 0.000 0.000 NA
#> SRR945234     2  0.3775     0.8574 0.000 0.744 0.012 0.000 0.016 NA
#> SRR945235     2  0.3775     0.8574 0.000 0.744 0.012 0.000 0.016 NA
#> SRR945236     2  0.1320     0.8808 0.000 0.948 0.000 0.000 0.016 NA
#> SRR945237     2  0.1320     0.8808 0.000 0.948 0.000 0.000 0.016 NA
#> SRR945238     3  0.4350     0.8979 0.000 0.068 0.772 0.000 0.056 NA
#> SRR945239     3  0.4350     0.8979 0.000 0.068 0.772 0.000 0.056 NA
#> SRR945240     3  0.1643     0.9270 0.000 0.068 0.924 0.000 0.008 NA
#> SRR945241     3  0.1643     0.9270 0.000 0.068 0.924 0.000 0.008 NA
#> SRR945242     3  0.2282     0.9258 0.000 0.068 0.900 0.000 0.012 NA
#> SRR945243     3  0.2282     0.9258 0.000 0.068 0.900 0.000 0.012 NA
#> SRR945244     3  0.3182     0.9228 0.000 0.068 0.852 0.000 0.024 NA
#> SRR945245     3  0.3182     0.9228 0.000 0.068 0.852 0.000 0.024 NA
#> SRR945246     3  0.1900     0.9269 0.000 0.068 0.916 0.000 0.008 NA
#> SRR945247     3  0.1900     0.9269 0.000 0.068 0.916 0.000 0.008 NA
#> SRR945248     3  0.4994     0.8604 0.000 0.068 0.700 0.000 0.052 NA
#> SRR945249     3  0.4994     0.8604 0.000 0.068 0.700 0.000 0.052 NA

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-kmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-kmeans-collect-classes

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


ATC:skmeans*

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

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

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

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

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

collect_plots(res)

plot of chunk ATC-skmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4886 0.512   0.512
#> 3 3 0.949           0.931       0.950         0.1902 0.880   0.770
#> 4 4 0.809           0.961       0.923         0.2123 0.851   0.636
#> 5 5 0.944           0.942       0.940         0.0547 0.986   0.948
#> 6 6 0.906           0.961       0.960         0.0317 0.984   0.936

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette p1 p2
#> SRR945190     1       0          1  1  0
#> SRR945191     1       0          1  1  0
#> SRR945192     1       0          1  1  0
#> SRR945193     1       0          1  1  0
#> SRR945194     1       0          1  1  0
#> SRR945195     1       0          1  1  0
#> SRR945196     1       0          1  1  0
#> SRR945197     1       0          1  1  0
#> SRR945200     1       0          1  1  0
#> SRR945201     1       0          1  1  0
#> SRR945202     1       0          1  1  0
#> SRR945203     1       0          1  1  0
#> SRR945204     1       0          1  1  0
#> SRR945205     1       0          1  1  0
#> SRR945198     1       0          1  1  0
#> SRR945199     1       0          1  1  0
#> SRR945206     1       0          1  1  0
#> SRR945207     1       0          1  1  0
#> SRR945208     1       0          1  1  0
#> SRR945209     1       0          1  1  0
#> SRR945212     1       0          1  1  0
#> SRR945213     1       0          1  1  0
#> SRR945214     2       0          1  0  1
#> SRR945215     2       0          1  0  1
#> SRR945210     2       0          1  0  1
#> SRR945211     2       0          1  0  1
#> SRR945218     2       0          1  0  1
#> SRR945219     2       0          1  0  1
#> SRR945216     2       0          1  0  1
#> SRR945217     2       0          1  0  1
#> SRR945220     2       0          1  0  1
#> SRR945221     2       0          1  0  1
#> SRR945222     2       0          1  0  1
#> SRR945223     2       0          1  0  1
#> SRR945224     2       0          1  0  1
#> SRR945225     2       0          1  0  1
#> SRR945226     2       0          1  0  1
#> SRR945227     2       0          1  0  1
#> SRR945228     2       0          1  0  1
#> SRR945229     2       0          1  0  1
#> SRR945230     1       0          1  1  0
#> SRR945231     1       0          1  1  0
#> SRR945232     2       0          1  0  1
#> SRR945233     2       0          1  0  1
#> SRR945234     2       0          1  0  1
#> SRR945235     2       0          1  0  1
#> SRR945236     2       0          1  0  1
#> SRR945237     2       0          1  0  1
#> SRR945238     2       0          1  0  1
#> SRR945239     2       0          1  0  1
#> SRR945240     2       0          1  0  1
#> SRR945241     2       0          1  0  1
#> SRR945242     2       0          1  0  1
#> SRR945243     2       0          1  0  1
#> SRR945244     2       0          1  0  1
#> SRR945245     2       0          1  0  1
#> SRR945246     2       0          1  0  1
#> SRR945247     2       0          1  0  1
#> SRR945248     2       0          1  0  1
#> SRR945249     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
#> SRR945190     1   0.000      1.000 1.000 0.000 0.000
#> SRR945191     1   0.000      1.000 1.000 0.000 0.000
#> SRR945192     1   0.000      1.000 1.000 0.000 0.000
#> SRR945193     1   0.000      1.000 1.000 0.000 0.000
#> SRR945194     1   0.000      1.000 1.000 0.000 0.000
#> SRR945195     1   0.000      1.000 1.000 0.000 0.000
#> SRR945196     1   0.000      1.000 1.000 0.000 0.000
#> SRR945197     1   0.000      1.000 1.000 0.000 0.000
#> SRR945200     1   0.000      1.000 1.000 0.000 0.000
#> SRR945201     1   0.000      1.000 1.000 0.000 0.000
#> SRR945202     3   0.624      0.594 0.440 0.000 0.560
#> SRR945203     3   0.624      0.594 0.440 0.000 0.560
#> SRR945204     3   0.186      0.735 0.052 0.000 0.948
#> SRR945205     3   0.186      0.735 0.052 0.000 0.948
#> SRR945198     1   0.000      1.000 1.000 0.000 0.000
#> SRR945199     1   0.000      1.000 1.000 0.000 0.000
#> SRR945206     3   0.497      0.737 0.236 0.000 0.764
#> SRR945207     3   0.497      0.737 0.236 0.000 0.764
#> SRR945208     3   0.629      0.553 0.464 0.000 0.536
#> SRR945209     3   0.629      0.553 0.464 0.000 0.536
#> SRR945212     1   0.000      1.000 1.000 0.000 0.000
#> SRR945213     1   0.000      1.000 1.000 0.000 0.000
#> SRR945214     2   0.000      0.982 0.000 1.000 0.000
#> SRR945215     2   0.000      0.982 0.000 1.000 0.000
#> SRR945210     3   0.000      0.711 0.000 0.000 1.000
#> SRR945211     3   0.000      0.711 0.000 0.000 1.000
#> SRR945218     2   0.000      0.982 0.000 1.000 0.000
#> SRR945219     2   0.000      0.982 0.000 1.000 0.000
#> SRR945216     2   0.000      0.982 0.000 1.000 0.000
#> SRR945217     2   0.000      0.982 0.000 1.000 0.000
#> SRR945220     2   0.000      0.982 0.000 1.000 0.000
#> SRR945221     2   0.000      0.982 0.000 1.000 0.000
#> SRR945222     2   0.000      0.982 0.000 1.000 0.000
#> SRR945223     2   0.000      0.982 0.000 1.000 0.000
#> SRR945224     2   0.000      0.982 0.000 1.000 0.000
#> SRR945225     2   0.000      0.982 0.000 1.000 0.000
#> SRR945226     2   0.000      0.982 0.000 1.000 0.000
#> SRR945227     2   0.000      0.982 0.000 1.000 0.000
#> SRR945228     2   0.000      0.982 0.000 1.000 0.000
#> SRR945229     2   0.000      0.982 0.000 1.000 0.000
#> SRR945230     1   0.000      1.000 1.000 0.000 0.000
#> SRR945231     1   0.000      1.000 1.000 0.000 0.000
#> SRR945232     2   0.000      0.982 0.000 1.000 0.000
#> SRR945233     2   0.000      0.982 0.000 1.000 0.000
#> SRR945234     2   0.000      0.982 0.000 1.000 0.000
#> SRR945235     2   0.000      0.982 0.000 1.000 0.000
#> SRR945236     2   0.000      0.982 0.000 1.000 0.000
#> SRR945237     2   0.000      0.982 0.000 1.000 0.000
#> SRR945238     2   0.186      0.967 0.000 0.948 0.052
#> SRR945239     2   0.186      0.967 0.000 0.948 0.052
#> SRR945240     2   0.186      0.967 0.000 0.948 0.052
#> SRR945241     2   0.186      0.967 0.000 0.948 0.052
#> SRR945242     2   0.186      0.967 0.000 0.948 0.052
#> SRR945243     2   0.186      0.967 0.000 0.948 0.052
#> SRR945244     2   0.186      0.967 0.000 0.948 0.052
#> SRR945245     2   0.186      0.967 0.000 0.948 0.052
#> SRR945246     2   0.186      0.967 0.000 0.948 0.052
#> SRR945247     2   0.186      0.967 0.000 0.948 0.052
#> SRR945248     2   0.186      0.967 0.000 0.948 0.052
#> SRR945249     2   0.186      0.967 0.000 0.948 0.052

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> SRR945190     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> SRR945191     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> SRR945192     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> SRR945193     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> SRR945194     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> SRR945195     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> SRR945196     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> SRR945197     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> SRR945200     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> SRR945201     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> SRR945202     4  0.6612      0.761 0.256 0.000 0.132 0.612
#> SRR945203     4  0.6612      0.761 0.256 0.000 0.132 0.612
#> SRR945204     4  0.0000      0.799 0.000 0.000 0.000 1.000
#> SRR945205     4  0.0000      0.799 0.000 0.000 0.000 1.000
#> SRR945198     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> SRR945199     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> SRR945206     4  0.5234      0.821 0.096 0.000 0.152 0.752
#> SRR945207     4  0.5234      0.821 0.096 0.000 0.152 0.752
#> SRR945208     4  0.6773      0.732 0.284 0.000 0.132 0.584
#> SRR945209     4  0.6773      0.732 0.284 0.000 0.132 0.584
#> SRR945212     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> SRR945213     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> SRR945214     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR945215     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR945210     4  0.0469      0.796 0.000 0.000 0.012 0.988
#> SRR945211     4  0.0469      0.796 0.000 0.000 0.012 0.988
#> SRR945218     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR945219     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR945216     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR945217     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR945220     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR945221     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR945222     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR945223     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR945224     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR945225     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR945226     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR945227     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR945228     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR945229     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR945230     1  0.1022      0.966 0.968 0.000 0.032 0.000
#> SRR945231     1  0.1022      0.966 0.968 0.000 0.032 0.000
#> SRR945232     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR945233     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR945234     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR945235     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR945236     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR945237     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR945238     3  0.3569      1.000 0.000 0.196 0.804 0.000
#> SRR945239     3  0.3569      1.000 0.000 0.196 0.804 0.000
#> SRR945240     3  0.3569      1.000 0.000 0.196 0.804 0.000
#> SRR945241     3  0.3569      1.000 0.000 0.196 0.804 0.000
#> SRR945242     3  0.3569      1.000 0.000 0.196 0.804 0.000
#> SRR945243     3  0.3569      1.000 0.000 0.196 0.804 0.000
#> SRR945244     3  0.3569      1.000 0.000 0.196 0.804 0.000
#> SRR945245     3  0.3569      1.000 0.000 0.196 0.804 0.000
#> SRR945246     3  0.3569      1.000 0.000 0.196 0.804 0.000
#> SRR945247     3  0.3569      1.000 0.000 0.196 0.804 0.000
#> SRR945248     3  0.3569      1.000 0.000 0.196 0.804 0.000
#> SRR945249     3  0.3569      1.000 0.000 0.196 0.804 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
#> SRR945190     1  0.0000      0.947 1.000 0.000 0.000 0.000 0.000
#> SRR945191     1  0.0000      0.947 1.000 0.000 0.000 0.000 0.000
#> SRR945192     1  0.0000      0.947 1.000 0.000 0.000 0.000 0.000
#> SRR945193     1  0.0000      0.947 1.000 0.000 0.000 0.000 0.000
#> SRR945194     1  0.0000      0.947 1.000 0.000 0.000 0.000 0.000
#> SRR945195     1  0.0000      0.947 1.000 0.000 0.000 0.000 0.000
#> SRR945196     1  0.0000      0.947 1.000 0.000 0.000 0.000 0.000
#> SRR945197     1  0.0000      0.947 1.000 0.000 0.000 0.000 0.000
#> SRR945200     1  0.0000      0.947 1.000 0.000 0.000 0.000 0.000
#> SRR945201     1  0.0000      0.947 1.000 0.000 0.000 0.000 0.000
#> SRR945202     4  0.5704      0.817 0.148 0.000 0.000 0.620 0.232
#> SRR945203     4  0.5704      0.817 0.148 0.000 0.000 0.620 0.232
#> SRR945204     5  0.1121      0.963 0.000 0.000 0.000 0.044 0.956
#> SRR945205     5  0.1121      0.963 0.000 0.000 0.000 0.044 0.956
#> SRR945198     1  0.0000      0.947 1.000 0.000 0.000 0.000 0.000
#> SRR945199     1  0.0000      0.947 1.000 0.000 0.000 0.000 0.000
#> SRR945206     4  0.4843      0.718 0.048 0.000 0.000 0.660 0.292
#> SRR945207     4  0.4843      0.718 0.048 0.000 0.000 0.660 0.292
#> SRR945208     4  0.5641      0.752 0.268 0.000 0.000 0.612 0.120
#> SRR945209     4  0.5641      0.752 0.268 0.000 0.000 0.612 0.120
#> SRR945212     1  0.0162      0.944 0.996 0.000 0.000 0.004 0.000
#> SRR945213     1  0.0162      0.944 0.996 0.000 0.000 0.004 0.000
#> SRR945214     2  0.0000      0.989 0.000 1.000 0.000 0.000 0.000
#> SRR945215     2  0.0000      0.989 0.000 1.000 0.000 0.000 0.000
#> SRR945210     5  0.0000      0.964 0.000 0.000 0.000 0.000 1.000
#> SRR945211     5  0.0000      0.964 0.000 0.000 0.000 0.000 1.000
#> SRR945218     2  0.0000      0.989 0.000 1.000 0.000 0.000 0.000
#> SRR945219     2  0.0000      0.989 0.000 1.000 0.000 0.000 0.000
#> SRR945216     2  0.0000      0.989 0.000 1.000 0.000 0.000 0.000
#> SRR945217     2  0.0000      0.989 0.000 1.000 0.000 0.000 0.000
#> SRR945220     2  0.0000      0.989 0.000 1.000 0.000 0.000 0.000
#> SRR945221     2  0.0000      0.989 0.000 1.000 0.000 0.000 0.000
#> SRR945222     2  0.0000      0.989 0.000 1.000 0.000 0.000 0.000
#> SRR945223     2  0.0000      0.989 0.000 1.000 0.000 0.000 0.000
#> SRR945224     2  0.0000      0.989 0.000 1.000 0.000 0.000 0.000
#> SRR945225     2  0.0000      0.989 0.000 1.000 0.000 0.000 0.000
#> SRR945226     2  0.0703      0.987 0.000 0.976 0.000 0.024 0.000
#> SRR945227     2  0.0703      0.987 0.000 0.976 0.000 0.024 0.000
#> SRR945228     2  0.0703      0.987 0.000 0.976 0.000 0.024 0.000
#> SRR945229     2  0.0703      0.987 0.000 0.976 0.000 0.024 0.000
#> SRR945230     1  0.4956      0.561 0.636 0.000 0.048 0.316 0.000
#> SRR945231     1  0.4956      0.561 0.636 0.000 0.048 0.316 0.000
#> SRR945232     2  0.0703      0.987 0.000 0.976 0.000 0.024 0.000
#> SRR945233     2  0.0703      0.987 0.000 0.976 0.000 0.024 0.000
#> SRR945234     2  0.0703      0.987 0.000 0.976 0.000 0.024 0.000
#> SRR945235     2  0.0703      0.987 0.000 0.976 0.000 0.024 0.000
#> SRR945236     2  0.0703      0.987 0.000 0.976 0.000 0.024 0.000
#> SRR945237     2  0.0703      0.987 0.000 0.976 0.000 0.024 0.000
#> SRR945238     3  0.1197      1.000 0.000 0.048 0.952 0.000 0.000
#> SRR945239     3  0.1197      1.000 0.000 0.048 0.952 0.000 0.000
#> SRR945240     3  0.1197      1.000 0.000 0.048 0.952 0.000 0.000
#> SRR945241     3  0.1197      1.000 0.000 0.048 0.952 0.000 0.000
#> SRR945242     3  0.1197      1.000 0.000 0.048 0.952 0.000 0.000
#> SRR945243     3  0.1197      1.000 0.000 0.048 0.952 0.000 0.000
#> SRR945244     3  0.1197      1.000 0.000 0.048 0.952 0.000 0.000
#> SRR945245     3  0.1197      1.000 0.000 0.048 0.952 0.000 0.000
#> SRR945246     3  0.1197      1.000 0.000 0.048 0.952 0.000 0.000
#> SRR945247     3  0.1197      1.000 0.000 0.048 0.952 0.000 0.000
#> SRR945248     3  0.1197      1.000 0.000 0.048 0.952 0.000 0.000
#> SRR945249     3  0.1197      1.000 0.000 0.048 0.952 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
#> SRR945190     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR945191     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR945192     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR945193     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR945194     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR945195     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR945196     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR945197     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR945200     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR945201     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR945202     4  0.2219      0.897 0.136 0.000 0.000 0.864 0.000 0.000
#> SRR945203     4  0.2219      0.897 0.136 0.000 0.000 0.864 0.000 0.000
#> SRR945204     5  0.2723      0.918 0.000 0.000 0.016 0.128 0.852 0.004
#> SRR945205     5  0.2723      0.918 0.000 0.000 0.016 0.128 0.852 0.004
#> SRR945198     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR945199     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR945206     4  0.0810      0.803 0.004 0.000 0.004 0.976 0.008 0.008
#> SRR945207     4  0.0810      0.803 0.004 0.000 0.004 0.976 0.008 0.008
#> SRR945208     4  0.2416      0.885 0.156 0.000 0.000 0.844 0.000 0.000
#> SRR945209     4  0.2416      0.885 0.156 0.000 0.000 0.844 0.000 0.000
#> SRR945212     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR945213     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR945214     2  0.0000      0.953 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR945215     2  0.0000      0.953 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR945210     5  0.0790      0.918 0.000 0.000 0.000 0.032 0.968 0.000
#> SRR945211     5  0.0790      0.918 0.000 0.000 0.000 0.032 0.968 0.000
#> SRR945218     2  0.0000      0.953 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR945219     2  0.0000      0.953 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR945216     2  0.0000      0.953 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR945217     2  0.0000      0.953 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR945220     2  0.0000      0.953 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR945221     2  0.0000      0.953 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR945222     2  0.0000      0.953 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR945223     2  0.0000      0.953 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR945224     2  0.0000      0.953 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR945225     2  0.0000      0.953 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR945226     2  0.2402      0.939 0.000 0.896 0.000 0.012 0.032 0.060
#> SRR945227     2  0.2402      0.939 0.000 0.896 0.000 0.012 0.032 0.060
#> SRR945228     2  0.2462      0.938 0.000 0.892 0.000 0.012 0.032 0.064
#> SRR945229     2  0.2462      0.938 0.000 0.892 0.000 0.012 0.032 0.064
#> SRR945230     6  0.1444      1.000 0.072 0.000 0.000 0.000 0.000 0.928
#> SRR945231     6  0.1444      1.000 0.072 0.000 0.000 0.000 0.000 0.928
#> SRR945232     2  0.2402      0.939 0.000 0.896 0.000 0.012 0.032 0.060
#> SRR945233     2  0.2402      0.939 0.000 0.896 0.000 0.012 0.032 0.060
#> SRR945234     2  0.2113      0.943 0.000 0.912 0.000 0.008 0.032 0.048
#> SRR945235     2  0.2113      0.943 0.000 0.912 0.000 0.008 0.032 0.048
#> SRR945236     2  0.2462      0.938 0.000 0.892 0.000 0.012 0.032 0.064
#> SRR945237     2  0.2462      0.938 0.000 0.892 0.000 0.012 0.032 0.064
#> SRR945238     3  0.0547      1.000 0.000 0.020 0.980 0.000 0.000 0.000
#> SRR945239     3  0.0547      1.000 0.000 0.020 0.980 0.000 0.000 0.000
#> SRR945240     3  0.0547      1.000 0.000 0.020 0.980 0.000 0.000 0.000
#> SRR945241     3  0.0547      1.000 0.000 0.020 0.980 0.000 0.000 0.000
#> SRR945242     3  0.0547      1.000 0.000 0.020 0.980 0.000 0.000 0.000
#> SRR945243     3  0.0547      1.000 0.000 0.020 0.980 0.000 0.000 0.000
#> SRR945244     3  0.0547      1.000 0.000 0.020 0.980 0.000 0.000 0.000
#> SRR945245     3  0.0547      1.000 0.000 0.020 0.980 0.000 0.000 0.000
#> SRR945246     3  0.0547      1.000 0.000 0.020 0.980 0.000 0.000 0.000
#> SRR945247     3  0.0547      1.000 0.000 0.020 0.980 0.000 0.000 0.000
#> SRR945248     3  0.0547      1.000 0.000 0.020 0.980 0.000 0.000 0.000
#> SRR945249     3  0.0547      1.000 0.000 0.020 0.980 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 15912 rows and 60 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#>   Subgroups are detected by 'pam' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 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           0.987       0.993         0.4213 0.573   0.573
#> 3 3 0.633           0.651       0.796         0.4239 0.738   0.563
#> 4 4 0.920           0.890       0.954         0.2182 0.878   0.678
#> 5 5 0.903           0.917       0.954         0.0506 0.914   0.709
#> 6 6 0.902           0.812       0.895         0.0546 0.989   0.952

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> SRR945190     1   0.000      0.975 1.000 0.000
#> SRR945191     1   0.000      0.975 1.000 0.000
#> SRR945192     1   0.000      0.975 1.000 0.000
#> SRR945193     1   0.000      0.975 1.000 0.000
#> SRR945194     1   0.000      0.975 1.000 0.000
#> SRR945195     1   0.000      0.975 1.000 0.000
#> SRR945196     1   0.000      0.975 1.000 0.000
#> SRR945197     1   0.000      0.975 1.000 0.000
#> SRR945200     1   0.000      0.975 1.000 0.000
#> SRR945201     1   0.000      0.975 1.000 0.000
#> SRR945202     1   0.662      0.814 0.828 0.172
#> SRR945203     1   0.541      0.874 0.876 0.124
#> SRR945204     2   0.000      1.000 0.000 1.000
#> SRR945205     2   0.000      1.000 0.000 1.000
#> SRR945198     1   0.000      0.975 1.000 0.000
#> SRR945199     1   0.000      0.975 1.000 0.000
#> SRR945206     2   0.000      1.000 0.000 1.000
#> SRR945207     2   0.000      1.000 0.000 1.000
#> SRR945208     1   0.388      0.922 0.924 0.076
#> SRR945209     1   0.295      0.941 0.948 0.052
#> SRR945212     1   0.000      0.975 1.000 0.000
#> SRR945213     1   0.000      0.975 1.000 0.000
#> SRR945214     2   0.000      1.000 0.000 1.000
#> SRR945215     2   0.000      1.000 0.000 1.000
#> SRR945210     2   0.000      1.000 0.000 1.000
#> SRR945211     2   0.000      1.000 0.000 1.000
#> SRR945218     2   0.000      1.000 0.000 1.000
#> SRR945219     2   0.000      1.000 0.000 1.000
#> SRR945216     2   0.000      1.000 0.000 1.000
#> SRR945217     2   0.000      1.000 0.000 1.000
#> SRR945220     2   0.000      1.000 0.000 1.000
#> SRR945221     2   0.000      1.000 0.000 1.000
#> SRR945222     2   0.000      1.000 0.000 1.000
#> SRR945223     2   0.000      1.000 0.000 1.000
#> SRR945224     2   0.000      1.000 0.000 1.000
#> SRR945225     2   0.000      1.000 0.000 1.000
#> SRR945226     2   0.000      1.000 0.000 1.000
#> SRR945227     2   0.000      1.000 0.000 1.000
#> SRR945228     2   0.000      1.000 0.000 1.000
#> SRR945229     2   0.000      1.000 0.000 1.000
#> SRR945230     2   0.000      1.000 0.000 1.000
#> SRR945231     2   0.000      1.000 0.000 1.000
#> SRR945232     2   0.000      1.000 0.000 1.000
#> SRR945233     2   0.000      1.000 0.000 1.000
#> SRR945234     2   0.000      1.000 0.000 1.000
#> SRR945235     2   0.000      1.000 0.000 1.000
#> SRR945236     2   0.000      1.000 0.000 1.000
#> SRR945237     2   0.000      1.000 0.000 1.000
#> SRR945238     2   0.000      1.000 0.000 1.000
#> SRR945239     2   0.000      1.000 0.000 1.000
#> SRR945240     2   0.000      1.000 0.000 1.000
#> SRR945241     2   0.000      1.000 0.000 1.000
#> SRR945242     2   0.000      1.000 0.000 1.000
#> SRR945243     2   0.000      1.000 0.000 1.000
#> SRR945244     2   0.000      1.000 0.000 1.000
#> SRR945245     2   0.000      1.000 0.000 1.000
#> SRR945246     2   0.000      1.000 0.000 1.000
#> SRR945247     2   0.000      1.000 0.000 1.000
#> SRR945248     2   0.000      1.000 0.000 1.000
#> SRR945249     2   0.000      1.000 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> SRR945190     1   0.000     0.9116 1.000 0.000 0.000
#> SRR945191     1   0.000     0.9116 1.000 0.000 0.000
#> SRR945192     1   0.000     0.9116 1.000 0.000 0.000
#> SRR945193     1   0.000     0.9116 1.000 0.000 0.000
#> SRR945194     1   0.553     0.7617 0.704 0.000 0.296
#> SRR945195     1   0.553     0.7617 0.704 0.000 0.296
#> SRR945196     1   0.000     0.9116 1.000 0.000 0.000
#> SRR945197     1   0.000     0.9116 1.000 0.000 0.000
#> SRR945200     1   0.000     0.9116 1.000 0.000 0.000
#> SRR945201     1   0.000     0.9116 1.000 0.000 0.000
#> SRR945202     3   0.915    -0.1866 0.144 0.412 0.444
#> SRR945203     3   0.941    -0.1413 0.176 0.380 0.444
#> SRR945204     2   0.625     0.3409 0.000 0.556 0.444
#> SRR945205     2   0.625     0.3409 0.000 0.556 0.444
#> SRR945198     1   0.000     0.9116 1.000 0.000 0.000
#> SRR945199     1   0.000     0.9116 1.000 0.000 0.000
#> SRR945206     2   0.625     0.3409 0.000 0.556 0.444
#> SRR945207     2   0.625     0.3409 0.000 0.556 0.444
#> SRR945208     3   0.962    -0.0982 0.212 0.344 0.444
#> SRR945209     3   0.972    -0.0989 0.244 0.312 0.444
#> SRR945212     1   0.553     0.7617 0.704 0.000 0.296
#> SRR945213     1   0.553     0.7617 0.704 0.000 0.296
#> SRR945214     2   0.000     0.7905 0.000 1.000 0.000
#> SRR945215     2   0.000     0.7905 0.000 1.000 0.000
#> SRR945210     2   0.630    -0.1340 0.000 0.528 0.472
#> SRR945211     2   0.617     0.0818 0.000 0.588 0.412
#> SRR945218     2   0.000     0.7905 0.000 1.000 0.000
#> SRR945219     2   0.000     0.7905 0.000 1.000 0.000
#> SRR945216     2   0.000     0.7905 0.000 1.000 0.000
#> SRR945217     2   0.000     0.7905 0.000 1.000 0.000
#> SRR945220     2   0.000     0.7905 0.000 1.000 0.000
#> SRR945221     2   0.000     0.7905 0.000 1.000 0.000
#> SRR945222     2   0.000     0.7905 0.000 1.000 0.000
#> SRR945223     2   0.000     0.7905 0.000 1.000 0.000
#> SRR945224     2   0.000     0.7905 0.000 1.000 0.000
#> SRR945225     2   0.000     0.7905 0.000 1.000 0.000
#> SRR945226     2   0.000     0.7905 0.000 1.000 0.000
#> SRR945227     2   0.000     0.7905 0.000 1.000 0.000
#> SRR945228     2   0.000     0.7905 0.000 1.000 0.000
#> SRR945229     2   0.000     0.7905 0.000 1.000 0.000
#> SRR945230     2   0.615     0.3702 0.000 0.592 0.408
#> SRR945231     2   0.620     0.3579 0.000 0.576 0.424
#> SRR945232     2   0.000     0.7905 0.000 1.000 0.000
#> SRR945233     2   0.000     0.7905 0.000 1.000 0.000
#> SRR945234     2   0.000     0.7905 0.000 1.000 0.000
#> SRR945235     2   0.000     0.7905 0.000 1.000 0.000
#> SRR945236     2   0.000     0.7905 0.000 1.000 0.000
#> SRR945237     2   0.000     0.7905 0.000 1.000 0.000
#> SRR945238     3   0.625     0.6659 0.000 0.444 0.556
#> SRR945239     3   0.625     0.6659 0.000 0.444 0.556
#> SRR945240     3   0.625     0.6659 0.000 0.444 0.556
#> SRR945241     3   0.625     0.6659 0.000 0.444 0.556
#> SRR945242     3   0.625     0.6659 0.000 0.444 0.556
#> SRR945243     3   0.625     0.6659 0.000 0.444 0.556
#> SRR945244     3   0.625     0.6659 0.000 0.444 0.556
#> SRR945245     3   0.625     0.6659 0.000 0.444 0.556
#> SRR945246     3   0.625     0.6659 0.000 0.444 0.556
#> SRR945247     3   0.625     0.6659 0.000 0.444 0.556
#> SRR945248     3   0.625     0.6659 0.000 0.444 0.556
#> SRR945249     3   0.625     0.6659 0.000 0.444 0.556

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2   p3    p4
#> SRR945190     1   0.000      0.883 1.000 0.000 0.00 0.000
#> SRR945191     1   0.000      0.883 1.000 0.000 0.00 0.000
#> SRR945192     1   0.000      0.883 1.000 0.000 0.00 0.000
#> SRR945193     1   0.000      0.883 1.000 0.000 0.00 0.000
#> SRR945194     1   0.464      0.610 0.656 0.000 0.00 0.344
#> SRR945195     1   0.464      0.610 0.656 0.000 0.00 0.344
#> SRR945196     1   0.000      0.883 1.000 0.000 0.00 0.000
#> SRR945197     1   0.000      0.883 1.000 0.000 0.00 0.000
#> SRR945200     1   0.000      0.883 1.000 0.000 0.00 0.000
#> SRR945201     1   0.000      0.883 1.000 0.000 0.00 0.000
#> SRR945202     4   0.000      0.888 0.000 0.000 0.00 1.000
#> SRR945203     4   0.000      0.888 0.000 0.000 0.00 1.000
#> SRR945204     4   0.000      0.888 0.000 0.000 0.00 1.000
#> SRR945205     4   0.000      0.888 0.000 0.000 0.00 1.000
#> SRR945198     1   0.000      0.883 1.000 0.000 0.00 0.000
#> SRR945199     1   0.000      0.883 1.000 0.000 0.00 0.000
#> SRR945206     4   0.000      0.888 0.000 0.000 0.00 1.000
#> SRR945207     4   0.000      0.888 0.000 0.000 0.00 1.000
#> SRR945208     4   0.000      0.888 0.000 0.000 0.00 1.000
#> SRR945209     4   0.000      0.888 0.000 0.000 0.00 1.000
#> SRR945212     1   0.464      0.610 0.656 0.000 0.00 0.344
#> SRR945213     1   0.464      0.610 0.656 0.000 0.00 0.344
#> SRR945214     2   0.000      0.964 0.000 1.000 0.00 0.000
#> SRR945215     2   0.000      0.964 0.000 1.000 0.00 0.000
#> SRR945210     4   0.519      0.520 0.000 0.324 0.02 0.656
#> SRR945211     4   0.519      0.520 0.000 0.324 0.02 0.656
#> SRR945218     2   0.000      0.964 0.000 1.000 0.00 0.000
#> SRR945219     2   0.000      0.964 0.000 1.000 0.00 0.000
#> SRR945216     2   0.000      0.964 0.000 1.000 0.00 0.000
#> SRR945217     2   0.000      0.964 0.000 1.000 0.00 0.000
#> SRR945220     2   0.000      0.964 0.000 1.000 0.00 0.000
#> SRR945221     2   0.000      0.964 0.000 1.000 0.00 0.000
#> SRR945222     2   0.000      0.964 0.000 1.000 0.00 0.000
#> SRR945223     2   0.000      0.964 0.000 1.000 0.00 0.000
#> SRR945224     2   0.000      0.964 0.000 1.000 0.00 0.000
#> SRR945225     2   0.000      0.964 0.000 1.000 0.00 0.000
#> SRR945226     2   0.000      0.964 0.000 1.000 0.00 0.000
#> SRR945227     2   0.000      0.964 0.000 1.000 0.00 0.000
#> SRR945228     2   0.000      0.964 0.000 1.000 0.00 0.000
#> SRR945229     2   0.000      0.964 0.000 1.000 0.00 0.000
#> SRR945230     2   0.458      0.462 0.000 0.668 0.00 0.332
#> SRR945231     2   0.482      0.339 0.000 0.612 0.00 0.388
#> SRR945232     2   0.000      0.964 0.000 1.000 0.00 0.000
#> SRR945233     2   0.000      0.964 0.000 1.000 0.00 0.000
#> SRR945234     2   0.000      0.964 0.000 1.000 0.00 0.000
#> SRR945235     2   0.000      0.964 0.000 1.000 0.00 0.000
#> SRR945236     2   0.000      0.964 0.000 1.000 0.00 0.000
#> SRR945237     2   0.000      0.964 0.000 1.000 0.00 0.000
#> SRR945238     3   0.000      1.000 0.000 0.000 1.00 0.000
#> SRR945239     3   0.000      1.000 0.000 0.000 1.00 0.000
#> SRR945240     3   0.000      1.000 0.000 0.000 1.00 0.000
#> SRR945241     3   0.000      1.000 0.000 0.000 1.00 0.000
#> SRR945242     3   0.000      1.000 0.000 0.000 1.00 0.000
#> SRR945243     3   0.000      1.000 0.000 0.000 1.00 0.000
#> SRR945244     3   0.000      1.000 0.000 0.000 1.00 0.000
#> SRR945245     3   0.000      1.000 0.000 0.000 1.00 0.000
#> SRR945246     3   0.000      1.000 0.000 0.000 1.00 0.000
#> SRR945247     3   0.000      1.000 0.000 0.000 1.00 0.000
#> SRR945248     3   0.000      1.000 0.000 0.000 1.00 0.000
#> SRR945249     3   0.000      1.000 0.000 0.000 1.00 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2 p3    p4    p5
#> SRR945190     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> SRR945191     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> SRR945192     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> SRR945193     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> SRR945194     4  0.0000      0.880 0.000 0.000  0 1.000 0.000
#> SRR945195     4  0.0162      0.876 0.004 0.000  0 0.996 0.000
#> SRR945196     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> SRR945197     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> SRR945200     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> SRR945201     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> SRR945202     4  0.0000      0.880 0.000 0.000  0 1.000 0.000
#> SRR945203     4  0.0000      0.880 0.000 0.000  0 1.000 0.000
#> SRR945204     5  0.2561      0.840 0.000 0.000  0 0.144 0.856
#> SRR945205     5  0.2648      0.835 0.000 0.000  0 0.152 0.848
#> SRR945198     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> SRR945199     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> SRR945206     4  0.0000      0.880 0.000 0.000  0 1.000 0.000
#> SRR945207     4  0.0000      0.880 0.000 0.000  0 1.000 0.000
#> SRR945208     4  0.0000      0.880 0.000 0.000  0 1.000 0.000
#> SRR945209     4  0.0000      0.880 0.000 0.000  0 1.000 0.000
#> SRR945212     4  0.0000      0.880 0.000 0.000  0 1.000 0.000
#> SRR945213     4  0.0000      0.880 0.000 0.000  0 1.000 0.000
#> SRR945214     2  0.2561      0.900 0.000 0.856  0 0.000 0.144
#> SRR945215     2  0.2561      0.900 0.000 0.856  0 0.000 0.144
#> SRR945210     5  0.2561      0.855 0.000 0.144  0 0.000 0.856
#> SRR945211     5  0.2561      0.855 0.000 0.144  0 0.000 0.856
#> SRR945218     2  0.2561      0.900 0.000 0.856  0 0.000 0.144
#> SRR945219     2  0.0000      0.932 0.000 1.000  0 0.000 0.000
#> SRR945216     2  0.2561      0.900 0.000 0.856  0 0.000 0.144
#> SRR945217     2  0.2561      0.900 0.000 0.856  0 0.000 0.144
#> SRR945220     2  0.0000      0.932 0.000 1.000  0 0.000 0.000
#> SRR945221     2  0.0000      0.932 0.000 1.000  0 0.000 0.000
#> SRR945222     2  0.2561      0.900 0.000 0.856  0 0.000 0.144
#> SRR945223     2  0.2561      0.900 0.000 0.856  0 0.000 0.144
#> SRR945224     2  0.0000      0.932 0.000 1.000  0 0.000 0.000
#> SRR945225     2  0.0000      0.932 0.000 1.000  0 0.000 0.000
#> SRR945226     2  0.0000      0.932 0.000 1.000  0 0.000 0.000
#> SRR945227     2  0.0000      0.932 0.000 1.000  0 0.000 0.000
#> SRR945228     2  0.0000      0.932 0.000 1.000  0 0.000 0.000
#> SRR945229     2  0.0000      0.932 0.000 1.000  0 0.000 0.000
#> SRR945230     4  0.4300      0.224 0.000 0.476  0 0.524 0.000
#> SRR945231     4  0.4114      0.379 0.000 0.376  0 0.624 0.000
#> SRR945232     2  0.0000      0.932 0.000 1.000  0 0.000 0.000
#> SRR945233     2  0.0000      0.932 0.000 1.000  0 0.000 0.000
#> SRR945234     2  0.2561      0.900 0.000 0.856  0 0.000 0.144
#> SRR945235     2  0.2561      0.900 0.000 0.856  0 0.000 0.144
#> SRR945236     2  0.0000      0.932 0.000 1.000  0 0.000 0.000
#> SRR945237     2  0.0000      0.932 0.000 1.000  0 0.000 0.000
#> SRR945238     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR945239     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR945240     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR945241     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR945242     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR945243     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR945244     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR945245     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR945246     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR945247     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR945248     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR945249     3  0.0000      1.000 0.000 0.000  1 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
#> SRR945190     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> SRR945191     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> SRR945192     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> SRR945193     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> SRR945194     4  0.0000      0.999 0.000 0.000  0 1.000 0.000 0.000
#> SRR945195     4  0.0146      0.995 0.004 0.000  0 0.996 0.000 0.000
#> SRR945196     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> SRR945197     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> SRR945200     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> SRR945201     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> SRR945202     4  0.0000      0.999 0.000 0.000  0 1.000 0.000 0.000
#> SRR945203     4  0.0000      0.999 0.000 0.000  0 1.000 0.000 0.000
#> SRR945204     5  0.3482      0.997 0.000 0.000  0 0.000 0.684 0.316
#> SRR945205     5  0.3690      0.990 0.000 0.000  0 0.008 0.684 0.308
#> SRR945198     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> SRR945199     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> SRR945206     4  0.0000      0.999 0.000 0.000  0 1.000 0.000 0.000
#> SRR945207     4  0.0000      0.999 0.000 0.000  0 1.000 0.000 0.000
#> SRR945208     4  0.0000      0.999 0.000 0.000  0 1.000 0.000 0.000
#> SRR945209     4  0.0000      0.999 0.000 0.000  0 1.000 0.000 0.000
#> SRR945212     4  0.0000      0.999 0.000 0.000  0 1.000 0.000 0.000
#> SRR945213     4  0.0000      0.999 0.000 0.000  0 1.000 0.000 0.000
#> SRR945214     2  0.3266      0.579 0.000 0.728  0 0.000 0.000 0.272
#> SRR945215     2  0.3266      0.579 0.000 0.728  0 0.000 0.000 0.272
#> SRR945210     5  0.3482      0.997 0.000 0.000  0 0.000 0.684 0.316
#> SRR945211     5  0.3482      0.997 0.000 0.000  0 0.000 0.684 0.316
#> SRR945218     2  0.3266      0.579 0.000 0.728  0 0.000 0.000 0.272
#> SRR945219     2  0.0000      0.547 0.000 1.000  0 0.000 0.000 0.000
#> SRR945216     2  0.3266      0.579 0.000 0.728  0 0.000 0.000 0.272
#> SRR945217     2  0.3266      0.579 0.000 0.728  0 0.000 0.000 0.272
#> SRR945220     2  0.0000      0.547 0.000 1.000  0 0.000 0.000 0.000
#> SRR945221     2  0.0000      0.547 0.000 1.000  0 0.000 0.000 0.000
#> SRR945222     2  0.3266      0.579 0.000 0.728  0 0.000 0.000 0.272
#> SRR945223     2  0.3266      0.579 0.000 0.728  0 0.000 0.000 0.272
#> SRR945224     2  0.3482      0.388 0.000 0.684  0 0.000 0.316 0.000
#> SRR945225     2  0.3482      0.388 0.000 0.684  0 0.000 0.316 0.000
#> SRR945226     2  0.3482      0.388 0.000 0.684  0 0.000 0.316 0.000
#> SRR945227     2  0.3482      0.388 0.000 0.684  0 0.000 0.316 0.000
#> SRR945228     2  0.3482      0.388 0.000 0.684  0 0.000 0.316 0.000
#> SRR945229     2  0.3482      0.388 0.000 0.684  0 0.000 0.316 0.000
#> SRR945230     6  0.6875      1.000 0.000 0.208  0 0.064 0.316 0.412
#> SRR945231     6  0.6875      1.000 0.000 0.208  0 0.064 0.316 0.412
#> SRR945232     2  0.3482      0.388 0.000 0.684  0 0.000 0.316 0.000
#> SRR945233     2  0.3482      0.388 0.000 0.684  0 0.000 0.316 0.000
#> SRR945234     2  0.3266      0.579 0.000 0.728  0 0.000 0.000 0.272
#> SRR945235     2  0.3266      0.579 0.000 0.728  0 0.000 0.000 0.272
#> SRR945236     2  0.3482      0.388 0.000 0.684  0 0.000 0.316 0.000
#> SRR945237     2  0.3482      0.388 0.000 0.684  0 0.000 0.316 0.000
#> SRR945238     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR945239     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR945240     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR945241     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR945242     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR945243     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR945244     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR945245     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR945246     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR945247     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR945248     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR945249     3  0.0000      1.000 0.000 0.000  1 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 15912 rows and 60 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#>   Subgroups are detected by 'mclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 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-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.636           0.884       0.930         0.4776 0.528   0.528
#> 3 3 1.000           1.000       1.000         0.3588 0.824   0.666
#> 4 4 1.000           1.000       1.000         0.1392 0.910   0.743
#> 5 5 0.954           0.943       0.970         0.0386 0.966   0.870
#> 6 6 0.995           0.959       0.981         0.0196 0.991   0.960

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

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

There is also optional best \(k\) = 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
#> SRR945190     1   0.000      0.873 1.0 0.0
#> SRR945191     1   0.000      0.873 1.0 0.0
#> SRR945192     1   0.000      0.873 1.0 0.0
#> SRR945193     1   0.000      0.873 1.0 0.0
#> SRR945194     1   0.000      0.873 1.0 0.0
#> SRR945195     1   0.000      0.873 1.0 0.0
#> SRR945196     1   0.000      0.873 1.0 0.0
#> SRR945197     1   0.000      0.873 1.0 0.0
#> SRR945200     1   0.000      0.873 1.0 0.0
#> SRR945201     1   0.000      0.873 1.0 0.0
#> SRR945202     1   0.000      0.873 1.0 0.0
#> SRR945203     1   0.000      0.873 1.0 0.0
#> SRR945204     1   0.000      0.873 1.0 0.0
#> SRR945205     1   0.000      0.873 1.0 0.0
#> SRR945198     1   0.000      0.873 1.0 0.0
#> SRR945199     1   0.000      0.873 1.0 0.0
#> SRR945206     1   0.000      0.873 1.0 0.0
#> SRR945207     1   0.000      0.873 1.0 0.0
#> SRR945208     1   0.000      0.873 1.0 0.0
#> SRR945209     1   0.000      0.873 1.0 0.0
#> SRR945212     1   0.000      0.873 1.0 0.0
#> SRR945213     1   0.000      0.873 1.0 0.0
#> SRR945214     2   0.000      1.000 0.0 1.0
#> SRR945215     2   0.000      1.000 0.0 1.0
#> SRR945210     1   0.000      0.873 1.0 0.0
#> SRR945211     1   0.000      0.873 1.0 0.0
#> SRR945218     2   0.000      1.000 0.0 1.0
#> SRR945219     2   0.000      1.000 0.0 1.0
#> SRR945216     2   0.000      1.000 0.0 1.0
#> SRR945217     2   0.000      1.000 0.0 1.0
#> SRR945220     2   0.000      1.000 0.0 1.0
#> SRR945221     2   0.000      1.000 0.0 1.0
#> SRR945222     2   0.000      1.000 0.0 1.0
#> SRR945223     2   0.000      1.000 0.0 1.0
#> SRR945224     2   0.000      1.000 0.0 1.0
#> SRR945225     2   0.000      1.000 0.0 1.0
#> SRR945226     2   0.000      1.000 0.0 1.0
#> SRR945227     2   0.000      1.000 0.0 1.0
#> SRR945228     2   0.000      1.000 0.0 1.0
#> SRR945229     2   0.000      1.000 0.0 1.0
#> SRR945230     1   0.881      0.722 0.7 0.3
#> SRR945231     1   0.881      0.722 0.7 0.3
#> SRR945232     2   0.000      1.000 0.0 1.0
#> SRR945233     2   0.000      1.000 0.0 1.0
#> SRR945234     2   0.000      1.000 0.0 1.0
#> SRR945235     2   0.000      1.000 0.0 1.0
#> SRR945236     2   0.000      1.000 0.0 1.0
#> SRR945237     2   0.000      1.000 0.0 1.0
#> SRR945238     1   0.881      0.722 0.7 0.3
#> SRR945239     1   0.881      0.722 0.7 0.3
#> SRR945240     1   0.881      0.722 0.7 0.3
#> SRR945241     1   0.881      0.722 0.7 0.3
#> SRR945242     1   0.881      0.722 0.7 0.3
#> SRR945243     1   0.881      0.722 0.7 0.3
#> SRR945244     1   0.881      0.722 0.7 0.3
#> SRR945245     1   0.881      0.722 0.7 0.3
#> SRR945246     1   0.881      0.722 0.7 0.3
#> SRR945247     1   0.881      0.722 0.7 0.3
#> SRR945248     1   0.881      0.722 0.7 0.3
#> SRR945249     1   0.881      0.722 0.7 0.3

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette p1 p2 p3
#> SRR945190     1       0          1  1  0  0
#> SRR945191     1       0          1  1  0  0
#> SRR945192     1       0          1  1  0  0
#> SRR945193     1       0          1  1  0  0
#> SRR945194     1       0          1  1  0  0
#> SRR945195     1       0          1  1  0  0
#> SRR945196     1       0          1  1  0  0
#> SRR945197     1       0          1  1  0  0
#> SRR945200     1       0          1  1  0  0
#> SRR945201     1       0          1  1  0  0
#> SRR945202     1       0          1  1  0  0
#> SRR945203     1       0          1  1  0  0
#> SRR945204     1       0          1  1  0  0
#> SRR945205     1       0          1  1  0  0
#> SRR945198     1       0          1  1  0  0
#> SRR945199     1       0          1  1  0  0
#> SRR945206     1       0          1  1  0  0
#> SRR945207     1       0          1  1  0  0
#> SRR945208     1       0          1  1  0  0
#> SRR945209     1       0          1  1  0  0
#> SRR945212     1       0          1  1  0  0
#> SRR945213     1       0          1  1  0  0
#> SRR945214     2       0          1  0  1  0
#> SRR945215     2       0          1  0  1  0
#> SRR945210     1       0          1  1  0  0
#> SRR945211     1       0          1  1  0  0
#> SRR945218     2       0          1  0  1  0
#> SRR945219     2       0          1  0  1  0
#> SRR945216     2       0          1  0  1  0
#> SRR945217     2       0          1  0  1  0
#> SRR945220     2       0          1  0  1  0
#> SRR945221     2       0          1  0  1  0
#> SRR945222     2       0          1  0  1  0
#> SRR945223     2       0          1  0  1  0
#> SRR945224     2       0          1  0  1  0
#> SRR945225     2       0          1  0  1  0
#> SRR945226     2       0          1  0  1  0
#> SRR945227     2       0          1  0  1  0
#> SRR945228     2       0          1  0  1  0
#> SRR945229     2       0          1  0  1  0
#> SRR945230     1       0          1  1  0  0
#> SRR945231     1       0          1  1  0  0
#> SRR945232     2       0          1  0  1  0
#> SRR945233     2       0          1  0  1  0
#> SRR945234     2       0          1  0  1  0
#> SRR945235     2       0          1  0  1  0
#> SRR945236     2       0          1  0  1  0
#> SRR945237     2       0          1  0  1  0
#> SRR945238     3       0          1  0  0  1
#> SRR945239     3       0          1  0  0  1
#> SRR945240     3       0          1  0  0  1
#> SRR945241     3       0          1  0  0  1
#> SRR945242     3       0          1  0  0  1
#> SRR945243     3       0          1  0  0  1
#> SRR945244     3       0          1  0  0  1
#> SRR945245     3       0          1  0  0  1
#> SRR945246     3       0          1  0  0  1
#> SRR945247     3       0          1  0  0  1
#> SRR945248     3       0          1  0  0  1
#> SRR945249     3       0          1  0  0  1

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette p1 p2 p3 p4
#> SRR945190     1       0          1  1  0  0  0
#> SRR945191     1       0          1  1  0  0  0
#> SRR945192     1       0          1  1  0  0  0
#> SRR945193     1       0          1  1  0  0  0
#> SRR945194     4       0          1  0  0  0  1
#> SRR945195     4       0          1  0  0  0  1
#> SRR945196     1       0          1  1  0  0  0
#> SRR945197     1       0          1  1  0  0  0
#> SRR945200     1       0          1  1  0  0  0
#> SRR945201     1       0          1  1  0  0  0
#> SRR945202     4       0          1  0  0  0  1
#> SRR945203     4       0          1  0  0  0  1
#> SRR945204     4       0          1  0  0  0  1
#> SRR945205     4       0          1  0  0  0  1
#> SRR945198     1       0          1  1  0  0  0
#> SRR945199     1       0          1  1  0  0  0
#> SRR945206     4       0          1  0  0  0  1
#> SRR945207     4       0          1  0  0  0  1
#> SRR945208     4       0          1  0  0  0  1
#> SRR945209     4       0          1  0  0  0  1
#> SRR945212     4       0          1  0  0  0  1
#> SRR945213     4       0          1  0  0  0  1
#> SRR945214     2       0          1  0  1  0  0
#> SRR945215     2       0          1  0  1  0  0
#> SRR945210     4       0          1  0  0  0  1
#> SRR945211     4       0          1  0  0  0  1
#> SRR945218     2       0          1  0  1  0  0
#> SRR945219     2       0          1  0  1  0  0
#> SRR945216     2       0          1  0  1  0  0
#> SRR945217     2       0          1  0  1  0  0
#> SRR945220     2       0          1  0  1  0  0
#> SRR945221     2       0          1  0  1  0  0
#> SRR945222     2       0          1  0  1  0  0
#> SRR945223     2       0          1  0  1  0  0
#> SRR945224     2       0          1  0  1  0  0
#> SRR945225     2       0          1  0  1  0  0
#> SRR945226     2       0          1  0  1  0  0
#> SRR945227     2       0          1  0  1  0  0
#> SRR945228     2       0          1  0  1  0  0
#> SRR945229     2       0          1  0  1  0  0
#> SRR945230     4       0          1  0  0  0  1
#> SRR945231     4       0          1  0  0  0  1
#> SRR945232     2       0          1  0  1  0  0
#> SRR945233     2       0          1  0  1  0  0
#> SRR945234     2       0          1  0  1  0  0
#> SRR945235     2       0          1  0  1  0  0
#> SRR945236     2       0          1  0  1  0  0
#> SRR945237     2       0          1  0  1  0  0
#> SRR945238     3       0          1  0  0  1  0
#> SRR945239     3       0          1  0  0  1  0
#> SRR945240     3       0          1  0  0  1  0
#> SRR945241     3       0          1  0  0  1  0
#> SRR945242     3       0          1  0  0  1  0
#> SRR945243     3       0          1  0  0  1  0
#> SRR945244     3       0          1  0  0  1  0
#> SRR945245     3       0          1  0  0  1  0
#> SRR945246     3       0          1  0  0  1  0
#> SRR945247     3       0          1  0  0  1  0
#> SRR945248     3       0          1  0  0  1  0
#> SRR945249     3       0          1  0  0  1  0

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2 p3    p4    p5
#> SRR945190     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> SRR945191     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> SRR945192     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> SRR945193     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> SRR945194     5  0.3612      0.644 0.268 0.000  0 0.000 0.732
#> SRR945195     5  0.3612      0.644 0.268 0.000  0 0.000 0.732
#> SRR945196     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> SRR945197     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> SRR945200     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> SRR945201     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> SRR945202     4  0.0000      0.917 0.000 0.000  0 1.000 0.000
#> SRR945203     4  0.0000      0.917 0.000 0.000  0 1.000 0.000
#> SRR945204     4  0.0000      0.917 0.000 0.000  0 1.000 0.000
#> SRR945205     4  0.0000      0.917 0.000 0.000  0 1.000 0.000
#> SRR945198     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> SRR945199     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> SRR945206     4  0.0000      0.917 0.000 0.000  0 1.000 0.000
#> SRR945207     4  0.0000      0.917 0.000 0.000  0 1.000 0.000
#> SRR945208     4  0.4101      0.579 0.000 0.000  0 0.628 0.372
#> SRR945209     4  0.4101      0.579 0.000 0.000  0 0.628 0.372
#> SRR945212     5  0.0000      0.710 0.000 0.000  0 0.000 1.000
#> SRR945213     5  0.0000      0.710 0.000 0.000  0 0.000 1.000
#> SRR945214     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR945215     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR945210     4  0.0404      0.911 0.000 0.000  0 0.988 0.012
#> SRR945211     4  0.0404      0.911 0.000 0.000  0 0.988 0.012
#> SRR945218     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR945219     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR945216     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR945217     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR945220     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR945221     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR945222     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR945223     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR945224     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR945225     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR945226     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR945227     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR945228     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR945229     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR945230     5  0.3480      0.681 0.000 0.248  0 0.000 0.752
#> SRR945231     5  0.3480      0.681 0.000 0.248  0 0.000 0.752
#> SRR945232     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR945233     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR945234     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR945235     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR945236     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR945237     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR945238     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR945239     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR945240     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR945241     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR945242     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR945243     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR945244     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR945245     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR945246     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR945247     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR945248     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR945249     3  0.0000      1.000 0.000 0.000  1 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
#> SRR945190     1   0.000      1.000  1  0  0 0.000 0.000 0.000
#> SRR945191     1   0.000      1.000  1  0  0 0.000 0.000 0.000
#> SRR945192     1   0.000      1.000  1  0  0 0.000 0.000 0.000
#> SRR945193     1   0.000      1.000  1  0  0 0.000 0.000 0.000
#> SRR945194     6   0.000      1.000  0  0  0 0.000 0.000 1.000
#> SRR945195     6   0.000      1.000  0  0  0 0.000 0.000 1.000
#> SRR945196     1   0.000      1.000  1  0  0 0.000 0.000 0.000
#> SRR945197     1   0.000      1.000  1  0  0 0.000 0.000 0.000
#> SRR945200     1   0.000      1.000  1  0  0 0.000 0.000 0.000
#> SRR945201     1   0.000      1.000  1  0  0 0.000 0.000 0.000
#> SRR945202     4   0.133      0.791  0  0  0 0.936 0.064 0.000
#> SRR945203     4   0.133      0.791  0  0  0 0.936 0.064 0.000
#> SRR945204     4   0.234      0.749  0  0  0 0.852 0.148 0.000
#> SRR945205     4   0.234      0.749  0  0  0 0.852 0.148 0.000
#> SRR945198     1   0.000      1.000  1  0  0 0.000 0.000 0.000
#> SRR945199     1   0.000      1.000  1  0  0 0.000 0.000 0.000
#> SRR945206     4   0.000      0.787  0  0  0 1.000 0.000 0.000
#> SRR945207     4   0.000      0.787  0  0  0 1.000 0.000 0.000
#> SRR945208     4   0.368      0.442  0  0  0 0.628 0.000 0.372
#> SRR945209     4   0.368      0.442  0  0  0 0.628 0.000 0.372
#> SRR945212     6   0.000      1.000  0  0  0 0.000 0.000 1.000
#> SRR945213     6   0.000      1.000  0  0  0 0.000 0.000 1.000
#> SRR945214     2   0.000      1.000  0  1  0 0.000 0.000 0.000
#> SRR945215     2   0.000      1.000  0  1  0 0.000 0.000 0.000
#> SRR945210     5   0.000      1.000  0  0  0 0.000 1.000 0.000
#> SRR945211     5   0.000      1.000  0  0  0 0.000 1.000 0.000
#> SRR945218     2   0.000      1.000  0  1  0 0.000 0.000 0.000
#> SRR945219     2   0.000      1.000  0  1  0 0.000 0.000 0.000
#> SRR945216     2   0.000      1.000  0  1  0 0.000 0.000 0.000
#> SRR945217     2   0.000      1.000  0  1  0 0.000 0.000 0.000
#> SRR945220     2   0.000      1.000  0  1  0 0.000 0.000 0.000
#> SRR945221     2   0.000      1.000  0  1  0 0.000 0.000 0.000
#> SRR945222     2   0.000      1.000  0  1  0 0.000 0.000 0.000
#> SRR945223     2   0.000      1.000  0  1  0 0.000 0.000 0.000
#> SRR945224     2   0.000      1.000  0  1  0 0.000 0.000 0.000
#> SRR945225     2   0.000      1.000  0  1  0 0.000 0.000 0.000
#> SRR945226     2   0.000      1.000  0  1  0 0.000 0.000 0.000
#> SRR945227     2   0.000      1.000  0  1  0 0.000 0.000 0.000
#> SRR945228     2   0.000      1.000  0  1  0 0.000 0.000 0.000
#> SRR945229     2   0.000      1.000  0  1  0 0.000 0.000 0.000
#> SRR945230     6   0.000      1.000  0  0  0 0.000 0.000 1.000
#> SRR945231     6   0.000      1.000  0  0  0 0.000 0.000 1.000
#> SRR945232     2   0.000      1.000  0  1  0 0.000 0.000 0.000
#> SRR945233     2   0.000      1.000  0  1  0 0.000 0.000 0.000
#> SRR945234     2   0.000      1.000  0  1  0 0.000 0.000 0.000
#> SRR945235     2   0.000      1.000  0  1  0 0.000 0.000 0.000
#> SRR945236     2   0.000      1.000  0  1  0 0.000 0.000 0.000
#> SRR945237     2   0.000      1.000  0  1  0 0.000 0.000 0.000
#> SRR945238     3   0.000      1.000  0  0  1 0.000 0.000 0.000
#> SRR945239     3   0.000      1.000  0  0  1 0.000 0.000 0.000
#> SRR945240     3   0.000      1.000  0  0  1 0.000 0.000 0.000
#> SRR945241     3   0.000      1.000  0  0  1 0.000 0.000 0.000
#> SRR945242     3   0.000      1.000  0  0  1 0.000 0.000 0.000
#> SRR945243     3   0.000      1.000  0  0  1 0.000 0.000 0.000
#> SRR945244     3   0.000      1.000  0  0  1 0.000 0.000 0.000
#> SRR945245     3   0.000      1.000  0  0  1 0.000 0.000 0.000
#> SRR945246     3   0.000      1.000  0  0  1 0.000 0.000 0.000
#> SRR945247     3   0.000      1.000  0  0  1 0.000 0.000 0.000
#> SRR945248     3   0.000      1.000  0  0  1 0.000 0.000 0.000
#> SRR945249     3   0.000      1.000  0  0  1 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 15912 rows and 60 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#>   Subgroups are detected by 'NMF' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 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-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.710           0.925       0.944         0.4450 0.512   0.512
#> 3 3 1.000           0.997       0.997         0.2812 0.919   0.841
#> 4 4 0.793           0.679       0.888         0.1583 0.895   0.760
#> 5 5 0.783           0.929       0.902         0.0773 0.880   0.663
#> 6 6 0.876           0.809       0.869         0.0401 0.986   0.947

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
#> SRR945190     1  0.0376      0.845 0.996 0.004
#> SRR945191     1  0.0376      0.845 0.996 0.004
#> SRR945192     1  0.0376      0.845 0.996 0.004
#> SRR945193     1  0.0376      0.845 0.996 0.004
#> SRR945194     1  0.0000      0.844 1.000 0.000
#> SRR945195     1  0.0000      0.844 1.000 0.000
#> SRR945196     1  0.0376      0.845 0.996 0.004
#> SRR945197     1  0.0376      0.845 0.996 0.004
#> SRR945200     1  0.0376      0.845 0.996 0.004
#> SRR945201     1  0.0376      0.845 0.996 0.004
#> SRR945202     1  0.8499      0.792 0.724 0.276
#> SRR945203     1  0.8499      0.792 0.724 0.276
#> SRR945204     1  0.8499      0.792 0.724 0.276
#> SRR945205     1  0.8499      0.792 0.724 0.276
#> SRR945198     1  0.0376      0.845 0.996 0.004
#> SRR945199     1  0.0376      0.845 0.996 0.004
#> SRR945206     1  0.8499      0.792 0.724 0.276
#> SRR945207     1  0.8499      0.792 0.724 0.276
#> SRR945208     1  0.8499      0.792 0.724 0.276
#> SRR945209     1  0.8499      0.792 0.724 0.276
#> SRR945212     1  0.7883      0.808 0.764 0.236
#> SRR945213     1  0.7815      0.809 0.768 0.232
#> SRR945214     2  0.0000      0.998 0.000 1.000
#> SRR945215     2  0.0000      0.998 0.000 1.000
#> SRR945210     1  0.8861      0.756 0.696 0.304
#> SRR945211     1  0.8861      0.756 0.696 0.304
#> SRR945218     2  0.0000      0.998 0.000 1.000
#> SRR945219     2  0.0000      0.998 0.000 1.000
#> SRR945216     2  0.0000      0.998 0.000 1.000
#> SRR945217     2  0.0000      0.998 0.000 1.000
#> SRR945220     2  0.0000      0.998 0.000 1.000
#> SRR945221     2  0.0000      0.998 0.000 1.000
#> SRR945222     2  0.0000      0.998 0.000 1.000
#> SRR945223     2  0.0000      0.998 0.000 1.000
#> SRR945224     2  0.0000      0.998 0.000 1.000
#> SRR945225     2  0.0000      0.998 0.000 1.000
#> SRR945226     2  0.0000      0.998 0.000 1.000
#> SRR945227     2  0.0000      0.998 0.000 1.000
#> SRR945228     2  0.0000      0.998 0.000 1.000
#> SRR945229     2  0.0000      0.998 0.000 1.000
#> SRR945230     2  0.0000      0.998 0.000 1.000
#> SRR945231     2  0.0000      0.998 0.000 1.000
#> SRR945232     2  0.0000      0.998 0.000 1.000
#> SRR945233     2  0.0000      0.998 0.000 1.000
#> SRR945234     2  0.0000      0.998 0.000 1.000
#> SRR945235     2  0.0000      0.998 0.000 1.000
#> SRR945236     2  0.0376      0.997 0.004 0.996
#> SRR945237     2  0.0376      0.997 0.004 0.996
#> SRR945238     2  0.0376      0.997 0.004 0.996
#> SRR945239     2  0.0376      0.997 0.004 0.996
#> SRR945240     2  0.0376      0.997 0.004 0.996
#> SRR945241     2  0.0376      0.997 0.004 0.996
#> SRR945242     2  0.0376      0.997 0.004 0.996
#> SRR945243     2  0.0376      0.997 0.004 0.996
#> SRR945244     2  0.0376      0.997 0.004 0.996
#> SRR945245     2  0.0376      0.997 0.004 0.996
#> SRR945246     2  0.0376      0.997 0.004 0.996
#> SRR945247     2  0.0376      0.997 0.004 0.996
#> SRR945248     2  0.0376      0.997 0.004 0.996
#> SRR945249     2  0.0376      0.997 0.004 0.996

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> SRR945190     1  0.0000      0.996 1.000 0.000 0.000
#> SRR945191     1  0.0000      0.996 1.000 0.000 0.000
#> SRR945192     1  0.0000      0.996 1.000 0.000 0.000
#> SRR945193     1  0.0000      0.996 1.000 0.000 0.000
#> SRR945194     1  0.0892      0.981 0.980 0.000 0.020
#> SRR945195     1  0.0892      0.981 0.980 0.000 0.020
#> SRR945196     1  0.0000      0.996 1.000 0.000 0.000
#> SRR945197     1  0.0000      0.996 1.000 0.000 0.000
#> SRR945200     1  0.0000      0.996 1.000 0.000 0.000
#> SRR945201     1  0.0000      0.996 1.000 0.000 0.000
#> SRR945202     3  0.0237      0.999 0.004 0.000 0.996
#> SRR945203     3  0.0237      0.999 0.004 0.000 0.996
#> SRR945204     3  0.0237      0.999 0.004 0.000 0.996
#> SRR945205     3  0.0237      0.999 0.004 0.000 0.996
#> SRR945198     1  0.0000      0.996 1.000 0.000 0.000
#> SRR945199     1  0.0000      0.996 1.000 0.000 0.000
#> SRR945206     3  0.0237      0.999 0.004 0.000 0.996
#> SRR945207     3  0.0237      0.999 0.004 0.000 0.996
#> SRR945208     3  0.0237      0.999 0.004 0.000 0.996
#> SRR945209     3  0.0237      0.999 0.004 0.000 0.996
#> SRR945212     3  0.0237      0.999 0.004 0.000 0.996
#> SRR945213     3  0.0237      0.999 0.004 0.000 0.996
#> SRR945214     2  0.0000      0.998 0.000 1.000 0.000
#> SRR945215     2  0.0000      0.998 0.000 1.000 0.000
#> SRR945210     3  0.0000      0.995 0.000 0.000 1.000
#> SRR945211     3  0.0000      0.995 0.000 0.000 1.000
#> SRR945218     2  0.0000      0.998 0.000 1.000 0.000
#> SRR945219     2  0.0000      0.998 0.000 1.000 0.000
#> SRR945216     2  0.0000      0.998 0.000 1.000 0.000
#> SRR945217     2  0.0000      0.998 0.000 1.000 0.000
#> SRR945220     2  0.0000      0.998 0.000 1.000 0.000
#> SRR945221     2  0.0000      0.998 0.000 1.000 0.000
#> SRR945222     2  0.0237      0.998 0.000 0.996 0.004
#> SRR945223     2  0.0237      0.998 0.000 0.996 0.004
#> SRR945224     2  0.0000      0.998 0.000 1.000 0.000
#> SRR945225     2  0.0000      0.998 0.000 1.000 0.000
#> SRR945226     2  0.0000      0.998 0.000 1.000 0.000
#> SRR945227     2  0.0000      0.998 0.000 1.000 0.000
#> SRR945228     2  0.0000      0.998 0.000 1.000 0.000
#> SRR945229     2  0.0000      0.998 0.000 1.000 0.000
#> SRR945230     2  0.0000      0.998 0.000 1.000 0.000
#> SRR945231     2  0.0000      0.998 0.000 1.000 0.000
#> SRR945232     2  0.0000      0.998 0.000 1.000 0.000
#> SRR945233     2  0.0000      0.998 0.000 1.000 0.000
#> SRR945234     2  0.0237      0.998 0.000 0.996 0.004
#> SRR945235     2  0.0237      0.998 0.000 0.996 0.004
#> SRR945236     2  0.0237      0.998 0.000 0.996 0.004
#> SRR945237     2  0.0237      0.998 0.000 0.996 0.004
#> SRR945238     2  0.0237      0.998 0.000 0.996 0.004
#> SRR945239     2  0.0237      0.998 0.000 0.996 0.004
#> SRR945240     2  0.0237      0.998 0.000 0.996 0.004
#> SRR945241     2  0.0237      0.998 0.000 0.996 0.004
#> SRR945242     2  0.0237      0.998 0.000 0.996 0.004
#> SRR945243     2  0.0237      0.998 0.000 0.996 0.004
#> SRR945244     2  0.0237      0.998 0.000 0.996 0.004
#> SRR945245     2  0.0237      0.998 0.000 0.996 0.004
#> SRR945246     2  0.0237      0.998 0.000 0.996 0.004
#> SRR945247     2  0.0237      0.998 0.000 0.996 0.004
#> SRR945248     2  0.0237      0.998 0.000 0.996 0.004
#> SRR945249     2  0.0237      0.998 0.000 0.996 0.004

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> SRR945190     1  0.0000     0.9493 1.000 0.000 0.000 0.000
#> SRR945191     1  0.0000     0.9493 1.000 0.000 0.000 0.000
#> SRR945192     1  0.0000     0.9493 1.000 0.000 0.000 0.000
#> SRR945193     1  0.0000     0.9493 1.000 0.000 0.000 0.000
#> SRR945194     1  0.4304     0.6234 0.716 0.000 0.000 0.284
#> SRR945195     1  0.3975     0.6943 0.760 0.000 0.000 0.240
#> SRR945196     1  0.0000     0.9493 1.000 0.000 0.000 0.000
#> SRR945197     1  0.0000     0.9493 1.000 0.000 0.000 0.000
#> SRR945200     1  0.0000     0.9493 1.000 0.000 0.000 0.000
#> SRR945201     1  0.0000     0.9493 1.000 0.000 0.000 0.000
#> SRR945202     4  0.2081     0.9438 0.000 0.000 0.084 0.916
#> SRR945203     4  0.2011     0.9450 0.000 0.000 0.080 0.920
#> SRR945204     4  0.2760     0.9264 0.000 0.000 0.128 0.872
#> SRR945205     4  0.2760     0.9264 0.000 0.000 0.128 0.872
#> SRR945198     1  0.0000     0.9493 1.000 0.000 0.000 0.000
#> SRR945199     1  0.0000     0.9493 1.000 0.000 0.000 0.000
#> SRR945206     4  0.0817     0.9556 0.000 0.000 0.024 0.976
#> SRR945207     4  0.0817     0.9556 0.000 0.000 0.024 0.976
#> SRR945208     4  0.0000     0.9581 0.000 0.000 0.000 1.000
#> SRR945209     4  0.0000     0.9581 0.000 0.000 0.000 1.000
#> SRR945212     4  0.0592     0.9551 0.000 0.000 0.016 0.984
#> SRR945213     4  0.0592     0.9551 0.000 0.000 0.016 0.984
#> SRR945214     2  0.0000     0.8330 0.000 1.000 0.000 0.000
#> SRR945215     2  0.0000     0.8330 0.000 1.000 0.000 0.000
#> SRR945210     3  0.3569     0.0739 0.000 0.000 0.804 0.196
#> SRR945211     3  0.3569     0.0739 0.000 0.000 0.804 0.196
#> SRR945218     2  0.0000     0.8330 0.000 1.000 0.000 0.000
#> SRR945219     2  0.0000     0.8330 0.000 1.000 0.000 0.000
#> SRR945216     2  0.0000     0.8330 0.000 1.000 0.000 0.000
#> SRR945217     2  0.0000     0.8330 0.000 1.000 0.000 0.000
#> SRR945220     2  0.0000     0.8330 0.000 1.000 0.000 0.000
#> SRR945221     2  0.0000     0.8330 0.000 1.000 0.000 0.000
#> SRR945222     2  0.0000     0.8330 0.000 1.000 0.000 0.000
#> SRR945223     2  0.0000     0.8330 0.000 1.000 0.000 0.000
#> SRR945224     2  0.0000     0.8330 0.000 1.000 0.000 0.000
#> SRR945225     2  0.0000     0.8330 0.000 1.000 0.000 0.000
#> SRR945226     2  0.0000     0.8330 0.000 1.000 0.000 0.000
#> SRR945227     2  0.0000     0.8330 0.000 1.000 0.000 0.000
#> SRR945228     2  0.0000     0.8330 0.000 1.000 0.000 0.000
#> SRR945229     2  0.0000     0.8330 0.000 1.000 0.000 0.000
#> SRR945230     2  0.0672     0.8146 0.000 0.984 0.008 0.008
#> SRR945231     2  0.0804     0.8096 0.000 0.980 0.008 0.012
#> SRR945232     2  0.0000     0.8330 0.000 1.000 0.000 0.000
#> SRR945233     2  0.0000     0.8330 0.000 1.000 0.000 0.000
#> SRR945234     2  0.0000     0.8330 0.000 1.000 0.000 0.000
#> SRR945235     2  0.0000     0.8330 0.000 1.000 0.000 0.000
#> SRR945236     2  0.0000     0.8330 0.000 1.000 0.000 0.000
#> SRR945237     2  0.0000     0.8330 0.000 1.000 0.000 0.000
#> SRR945238     3  0.4998     0.3983 0.000 0.488 0.512 0.000
#> SRR945239     3  0.5000     0.3748 0.000 0.496 0.504 0.000
#> SRR945240     3  0.4994     0.4148 0.000 0.480 0.520 0.000
#> SRR945241     2  0.4989    -0.3742 0.000 0.528 0.472 0.000
#> SRR945242     2  0.4972    -0.3200 0.000 0.544 0.456 0.000
#> SRR945243     2  0.4898    -0.1771 0.000 0.584 0.416 0.000
#> SRR945244     2  0.4916    -0.2067 0.000 0.576 0.424 0.000
#> SRR945245     2  0.4866    -0.1329 0.000 0.596 0.404 0.000
#> SRR945246     3  0.4643     0.5615 0.000 0.344 0.656 0.000
#> SRR945247     3  0.4661     0.5604 0.000 0.348 0.652 0.000
#> SRR945248     2  0.4996    -0.4159 0.000 0.516 0.484 0.000
#> SRR945249     2  0.4981    -0.3482 0.000 0.536 0.464 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
#> SRR945190     1  0.0000      0.946 1.000 0.000 0.000 0.000 0.000
#> SRR945191     1  0.0000      0.946 1.000 0.000 0.000 0.000 0.000
#> SRR945192     1  0.0000      0.946 1.000 0.000 0.000 0.000 0.000
#> SRR945193     1  0.0000      0.946 1.000 0.000 0.000 0.000 0.000
#> SRR945194     1  0.4299      0.679 0.744 0.000 0.008 0.220 0.028
#> SRR945195     1  0.4056      0.710 0.768 0.000 0.008 0.200 0.024
#> SRR945196     1  0.0727      0.935 0.980 0.000 0.004 0.004 0.012
#> SRR945197     1  0.0162      0.944 0.996 0.000 0.000 0.000 0.004
#> SRR945200     1  0.0000      0.946 1.000 0.000 0.000 0.000 0.000
#> SRR945201     1  0.0000      0.946 1.000 0.000 0.000 0.000 0.000
#> SRR945202     4  0.2732      0.819 0.000 0.000 0.000 0.840 0.160
#> SRR945203     4  0.2732      0.819 0.000 0.000 0.000 0.840 0.160
#> SRR945204     4  0.3582      0.776 0.000 0.000 0.008 0.768 0.224
#> SRR945205     4  0.3551      0.779 0.000 0.000 0.008 0.772 0.220
#> SRR945198     1  0.0000      0.946 1.000 0.000 0.000 0.000 0.000
#> SRR945199     1  0.0000      0.946 1.000 0.000 0.000 0.000 0.000
#> SRR945206     4  0.4469      0.734 0.000 0.000 0.096 0.756 0.148
#> SRR945207     4  0.4469      0.734 0.000 0.000 0.096 0.756 0.148
#> SRR945208     4  0.0162      0.841 0.000 0.000 0.000 0.996 0.004
#> SRR945209     4  0.0290      0.840 0.000 0.000 0.008 0.992 0.000
#> SRR945212     4  0.2171      0.824 0.000 0.000 0.024 0.912 0.064
#> SRR945213     4  0.2171      0.824 0.000 0.000 0.024 0.912 0.064
#> SRR945214     2  0.0000      0.993 0.000 1.000 0.000 0.000 0.000
#> SRR945215     2  0.0000      0.993 0.000 1.000 0.000 0.000 0.000
#> SRR945210     5  0.4693      1.000 0.000 0.000 0.244 0.056 0.700
#> SRR945211     5  0.4693      1.000 0.000 0.000 0.244 0.056 0.700
#> SRR945218     2  0.0162      0.992 0.000 0.996 0.000 0.000 0.004
#> SRR945219     2  0.0000      0.993 0.000 1.000 0.000 0.000 0.000
#> SRR945216     2  0.0000      0.993 0.000 1.000 0.000 0.000 0.000
#> SRR945217     2  0.0000      0.993 0.000 1.000 0.000 0.000 0.000
#> SRR945220     2  0.0000      0.993 0.000 1.000 0.000 0.000 0.000
#> SRR945221     2  0.0000      0.993 0.000 1.000 0.000 0.000 0.000
#> SRR945222     2  0.0290      0.988 0.000 0.992 0.008 0.000 0.000
#> SRR945223     2  0.0290      0.988 0.000 0.992 0.008 0.000 0.000
#> SRR945224     2  0.0162      0.992 0.000 0.996 0.000 0.000 0.004
#> SRR945225     2  0.0162      0.992 0.000 0.996 0.000 0.000 0.004
#> SRR945226     2  0.0000      0.993 0.000 1.000 0.000 0.000 0.000
#> SRR945227     2  0.0000      0.993 0.000 1.000 0.000 0.000 0.000
#> SRR945228     2  0.0162      0.992 0.000 0.996 0.000 0.000 0.004
#> SRR945229     2  0.0162      0.992 0.000 0.996 0.000 0.000 0.004
#> SRR945230     2  0.1012      0.966 0.000 0.968 0.012 0.000 0.020
#> SRR945231     2  0.1211      0.958 0.000 0.960 0.016 0.000 0.024
#> SRR945232     2  0.0000      0.993 0.000 1.000 0.000 0.000 0.000
#> SRR945233     2  0.0000      0.993 0.000 1.000 0.000 0.000 0.000
#> SRR945234     2  0.0404      0.984 0.000 0.988 0.012 0.000 0.000
#> SRR945235     2  0.0404      0.984 0.000 0.988 0.012 0.000 0.000
#> SRR945236     2  0.0000      0.993 0.000 1.000 0.000 0.000 0.000
#> SRR945237     2  0.0000      0.993 0.000 1.000 0.000 0.000 0.000
#> SRR945238     3  0.3519      0.941 0.000 0.216 0.776 0.000 0.008
#> SRR945239     3  0.3242      0.944 0.000 0.216 0.784 0.000 0.000
#> SRR945240     3  0.3242      0.944 0.000 0.216 0.784 0.000 0.000
#> SRR945241     3  0.3336      0.949 0.000 0.228 0.772 0.000 0.000
#> SRR945242     3  0.3424      0.949 0.000 0.240 0.760 0.000 0.000
#> SRR945243     3  0.3689      0.937 0.000 0.256 0.740 0.000 0.004
#> SRR945244     3  0.3561      0.934 0.000 0.260 0.740 0.000 0.000
#> SRR945245     3  0.3661      0.910 0.000 0.276 0.724 0.000 0.000
#> SRR945246     3  0.3280      0.881 0.000 0.176 0.812 0.000 0.012
#> SRR945247     3  0.3171      0.883 0.000 0.176 0.816 0.000 0.008
#> SRR945248     3  0.3424      0.949 0.000 0.240 0.760 0.000 0.000
#> SRR945249     3  0.3452      0.948 0.000 0.244 0.756 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
#> SRR945190     1  0.0000      0.936 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR945191     1  0.0000      0.936 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR945192     1  0.0000      0.936 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR945193     1  0.0000      0.936 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR945194     1  0.3705      0.710 0.748 0.000 0.000 0.224 0.004 0.024
#> SRR945195     1  0.3420      0.713 0.748 0.000 0.000 0.240 0.000 0.012
#> SRR945196     1  0.2699      0.875 0.888 0.000 0.028 0.004 0.048 0.032
#> SRR945197     1  0.1764      0.905 0.936 0.000 0.012 0.004 0.024 0.024
#> SRR945200     1  0.0000      0.936 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR945201     1  0.0000      0.936 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR945202     6  0.6197      0.420 0.000 0.000 0.012 0.352 0.208 0.428
#> SRR945203     6  0.6185      0.425 0.000 0.000 0.012 0.356 0.204 0.428
#> SRR945204     4  0.6234     -0.305 0.000 0.000 0.004 0.360 0.296 0.340
#> SRR945205     4  0.6222     -0.318 0.000 0.000 0.004 0.372 0.288 0.336
#> SRR945198     1  0.0000      0.936 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR945199     1  0.0000      0.936 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR945206     4  0.0000      0.220 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR945207     4  0.0146      0.219 0.000 0.000 0.000 0.996 0.000 0.004
#> SRR945208     4  0.4072     -0.444 0.000 0.000 0.000 0.544 0.008 0.448
#> SRR945209     4  0.4072     -0.444 0.000 0.000 0.000 0.544 0.008 0.448
#> SRR945212     6  0.3843      0.395 0.000 0.000 0.000 0.452 0.000 0.548
#> SRR945213     6  0.3828      0.405 0.000 0.000 0.000 0.440 0.000 0.560
#> SRR945214     2  0.0146      0.988 0.000 0.996 0.000 0.000 0.004 0.000
#> SRR945215     2  0.0000      0.988 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR945210     5  0.2306      0.998 0.000 0.000 0.092 0.004 0.888 0.016
#> SRR945211     5  0.2393      0.998 0.000 0.000 0.092 0.004 0.884 0.020
#> SRR945218     2  0.0146      0.988 0.000 0.996 0.000 0.000 0.004 0.000
#> SRR945219     2  0.0000      0.988 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR945216     2  0.0146      0.988 0.000 0.996 0.000 0.000 0.004 0.000
#> SRR945217     2  0.0000      0.988 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR945220     2  0.0000      0.988 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR945221     2  0.0000      0.988 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR945222     2  0.0260      0.986 0.000 0.992 0.008 0.000 0.000 0.000
#> SRR945223     2  0.0260      0.986 0.000 0.992 0.008 0.000 0.000 0.000
#> SRR945224     2  0.0000      0.988 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR945225     2  0.0260      0.988 0.000 0.992 0.000 0.000 0.000 0.008
#> SRR945226     2  0.0363      0.987 0.000 0.988 0.000 0.000 0.000 0.012
#> SRR945227     2  0.0363      0.987 0.000 0.988 0.000 0.000 0.000 0.012
#> SRR945228     2  0.0777      0.981 0.000 0.972 0.004 0.000 0.000 0.024
#> SRR945229     2  0.0891      0.979 0.000 0.968 0.008 0.000 0.000 0.024
#> SRR945230     2  0.1082      0.969 0.000 0.956 0.004 0.000 0.000 0.040
#> SRR945231     2  0.1296      0.962 0.000 0.948 0.004 0.000 0.004 0.044
#> SRR945232     2  0.0622      0.986 0.000 0.980 0.008 0.000 0.000 0.012
#> SRR945233     2  0.0622      0.986 0.000 0.980 0.008 0.000 0.000 0.012
#> SRR945234     2  0.0363      0.984 0.000 0.988 0.012 0.000 0.000 0.000
#> SRR945235     2  0.0458      0.981 0.000 0.984 0.016 0.000 0.000 0.000
#> SRR945236     2  0.0363      0.987 0.000 0.988 0.000 0.000 0.000 0.012
#> SRR945237     2  0.0363      0.987 0.000 0.988 0.000 0.000 0.000 0.012
#> SRR945238     3  0.1908      0.980 0.000 0.096 0.900 0.000 0.004 0.000
#> SRR945239     3  0.1908      0.980 0.000 0.096 0.900 0.000 0.004 0.000
#> SRR945240     3  0.1806      0.975 0.000 0.088 0.908 0.000 0.004 0.000
#> SRR945241     3  0.1714      0.979 0.000 0.092 0.908 0.000 0.000 0.000
#> SRR945242     3  0.1714      0.979 0.000 0.092 0.908 0.000 0.000 0.000
#> SRR945243     3  0.1765      0.980 0.000 0.096 0.904 0.000 0.000 0.000
#> SRR945244     3  0.1910      0.969 0.000 0.108 0.892 0.000 0.000 0.000
#> SRR945245     3  0.2003      0.958 0.000 0.116 0.884 0.000 0.000 0.000
#> SRR945246     3  0.1584      0.943 0.000 0.064 0.928 0.000 0.008 0.000
#> SRR945247     3  0.1584      0.943 0.000 0.064 0.928 0.000 0.008 0.000
#> SRR945248     3  0.2006      0.974 0.000 0.104 0.892 0.000 0.004 0.000
#> SRR945249     3  0.1765      0.980 0.000 0.096 0.904 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-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