cola Report for recount2:SRP049988

Date: 2019-12-26 00:29:15 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 15837 rows and 56 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] 15837    56

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 6 1.000 1.000 1.000 ** 2,3,4,5
SD:kmeans 2 1.000 0.997 0.996 **
SD:skmeans 6 1.000 0.990 0.977 ** 2,5
SD:pam 6 1.000 1.000 1.000 ** 2,3,5
SD:mclust 6 1.000 0.965 0.980 ** 4,5
CV:kmeans 2 1.000 0.983 0.979 **
CV:skmeans 6 1.000 0.989 0.979 **
CV:pam 6 1.000 1.000 1.000 ** 2,3,5
CV:NMF 6 1.000 0.996 0.946 ** 2,3,4,5
MAD:hclust 6 1.000 1.000 1.000 ** 2,3,4,5
MAD:skmeans 6 1.000 0.997 0.993 ** 2,5
MAD:pam 6 1.000 1.000 1.000 ** 2,4,5
MAD:mclust 6 1.000 1.000 1.000 ** 4,5
MAD:NMF 6 1.000 0.999 0.990 ** 2,3,4,5
ATC:hclust 6 1.000 0.984 0.993 ** 2,3
ATC:kmeans 2 1.000 1.000 1.000 **
ATC:pam 6 1.000 0.963 0.985 ** 2,3,4,5
ATC:mclust 3 1.000 0.984 0.984 ** 2
ATC:NMF 2 1.000 1.000 1.000 **
SD:NMF 6 0.965 0.997 0.964 ** 2,4,5
CV:hclust 6 0.933 0.970 0.969 * 2
CV:mclust 6 0.933 0.975 0.975 * 5
ATC:skmeans 6 0.911 0.816 0.751 * 2,3
MAD:kmeans 5 0.717 0.813 0.788

**: 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           1.000       1.000          0.299 0.701   0.701
#> CV:NMF      2 1.000           1.000       1.000          0.299 0.701   0.701
#> MAD:NMF     2 1.000           1.000       1.000          0.300 0.701   0.701
#> ATC:NMF     2 1.000           1.000       1.000          0.299 0.701   0.701
#> SD:skmeans  2 1.000           0.998       0.999          0.300 0.701   0.701
#> CV:skmeans  2 0.751           0.880       0.947          0.353 0.701   0.701
#> MAD:skmeans 2 1.000           1.000       1.000          0.445 0.556   0.556
#> ATC:skmeans 2 1.000           1.000       1.000          0.299 0.701   0.701
#> SD:mclust   2 0.751           0.862       0.941          0.359 0.701   0.701
#> CV:mclust   2 0.751           0.953       0.975          0.324 0.701   0.701
#> MAD:mclust  2 0.751           0.943       0.970          0.330 0.701   0.701
#> ATC:mclust  2 1.000           0.996       0.997          0.302 0.701   0.701
#> SD:kmeans   2 1.000           0.997       0.996          0.299 0.701   0.701
#> CV:kmeans   2 1.000           0.983       0.979          0.296 0.701   0.701
#> MAD:kmeans  2 0.844           0.957       0.963          0.321 0.701   0.701
#> ATC:kmeans  2 1.000           1.000       1.000          0.299 0.701   0.701
#> SD:pam      2 1.000           1.000       1.000          0.299 0.701   0.701
#> CV:pam      2 1.000           1.000       1.000          0.299 0.701   0.701
#> MAD:pam     2 1.000           1.000       1.000          0.299 0.701   0.701
#> ATC:pam     2 1.000           1.000       1.000          0.299 0.701   0.701
#> SD:hclust   2 1.000           1.000       1.000          0.299 0.701   0.701
#> CV:hclust   2 1.000           1.000       1.000          0.299 0.701   0.701
#> MAD:hclust  2 1.000           1.000       1.000          0.299 0.701   0.701
#> ATC:hclust  2 1.000           1.000       1.000          0.299 0.701   0.701
get_stats(res_list, k = 3)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      3 0.862           0.892       0.950          0.795 0.803   0.719
#> CV:NMF      3 0.917           0.966       0.980          0.989 0.688   0.556
#> MAD:NMF     3 0.906           0.965       0.979          1.045 0.688   0.556
#> ATC:NMF     3 0.734           0.884       0.930          0.671 0.766   0.667
#> SD:skmeans  3 0.803           0.921       0.955          0.759 0.803   0.719
#> CV:skmeans  3 0.647           0.941       0.963          0.707 0.688   0.556
#> MAD:skmeans 3 0.657           0.765       0.864          0.452 0.771   0.589
#> ATC:skmeans 3 1.000           0.984       0.993          0.683 0.803   0.719
#> SD:mclust   3 0.575           0.897       0.904          0.579 0.735   0.622
#> CV:mclust   3 0.621           0.836       0.897          0.694 0.803   0.719
#> MAD:mclust  3 0.831           0.871       0.941          0.880 0.688   0.556
#> ATC:mclust  3 1.000           0.984       0.984          0.675 0.803   0.719
#> SD:kmeans   3 0.532           0.737       0.839          0.915 0.688   0.556
#> CV:kmeans   3 0.460           0.739       0.813          0.893 0.688   0.556
#> MAD:kmeans  3 0.418           0.678       0.805          0.817 0.688   0.556
#> ATC:kmeans  3 0.553           0.888       0.911          0.804 0.766   0.667
#> SD:pam      3 1.000           1.000       1.000          0.659 0.803   0.719
#> CV:pam      3 1.000           1.000       1.000          0.659 0.803   0.719
#> MAD:pam     3 0.651           0.748       0.847          0.879 0.803   0.719
#> ATC:pam     3 1.000           0.975       0.984          0.810 0.766   0.667
#> SD:hclust   3 1.000           1.000       1.000          0.659 0.803   0.719
#> CV:hclust   3 0.803           0.957       0.977          0.721 0.803   0.719
#> MAD:hclust  3 1.000           1.000       1.000          0.659 0.803   0.719
#> ATC:hclust  3 1.000           0.992       0.997          0.876 0.735   0.622
get_stats(res_list, k = 4)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      4 1.000           0.985       0.988         0.3387 0.771   0.546
#> CV:NMF      4 1.000           0.999       0.999         0.2166 0.803   0.542
#> MAD:NMF     4 1.000           0.987       0.989         0.1762 0.803   0.542
#> ATC:NMF     4 0.597           0.457       0.765         0.3018 0.735   0.512
#> SD:skmeans  4 0.875           0.939       0.967         0.3709 0.771   0.546
#> CV:skmeans  4 0.803           0.913       0.946         0.1908 0.803   0.542
#> MAD:skmeans 4 0.764           0.866       0.925         0.1263 0.948   0.841
#> ATC:skmeans 4 0.799           0.956       0.924         0.3074 0.782   0.567
#> SD:mclust   4 1.000           0.971       0.986         0.2742 0.777   0.522
#> CV:mclust   4 0.751           0.887       0.921         0.2854 0.771   0.546
#> MAD:mclust  4 1.000           0.998       0.999         0.1685 0.886   0.707
#> ATC:mclust  4 0.677           0.580       0.788         0.3632 0.797   0.598
#> SD:kmeans   4 0.556           0.773       0.765         0.2109 0.803   0.542
#> CV:kmeans   4 0.490           0.653       0.724         0.2081 0.958   0.893
#> MAD:kmeans  4 0.550           0.757       0.773         0.1765 0.803   0.542
#> ATC:kmeans  4 0.577           0.558       0.701         0.2693 0.831   0.639
#> SD:pam      4 0.809           0.940       0.956         0.4463 0.766   0.536
#> CV:pam      4 0.830           0.900       0.925         0.4197 0.766   0.536
#> MAD:pam     4 1.000           0.963       0.986         0.2947 0.766   0.536
#> ATC:pam     4 0.997           0.952       0.979         0.3470 0.800   0.572
#> SD:hclust   4 1.000           0.991       0.993         0.4534 0.771   0.546
#> CV:hclust   4 0.855           0.977       0.973         0.2654 0.844   0.691
#> MAD:hclust  4 1.000           1.000       1.000         0.4598 0.771   0.546
#> ATC:hclust  4 0.972           0.957       0.943         0.0299 0.984   0.964
get_stats(res_list, k = 5)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      5 0.942           0.935       0.938         0.0999 0.844   0.508
#> CV:NMF      5 0.917           0.957       0.963         0.1000 0.844   0.508
#> MAD:NMF     5 0.985           0.980       0.978         0.1031 0.844   0.508
#> ATC:NMF     5 0.565           0.690       0.763         0.0908 0.730   0.406
#> SD:skmeans  5 0.917           0.890       0.907         0.1000 0.844   0.508
#> CV:skmeans  5 0.875           0.869       0.916         0.1059 0.844   0.508
#> MAD:skmeans 5 0.917           0.901       0.937         0.0968 0.844   0.508
#> ATC:skmeans 5 0.821           0.885       0.885         0.1483 0.984   0.945
#> SD:mclust   5 1.000           0.965       0.984         0.1017 0.927   0.736
#> CV:mclust   5 0.908           0.945       0.962         0.1187 0.891   0.628
#> MAD:mclust  5 1.000           1.000       1.000         0.1000 0.927   0.736
#> ATC:mclust  5 0.748           0.875       0.872         0.1381 0.849   0.540
#> SD:kmeans   5 0.655           0.749       0.773         0.0969 0.938   0.774
#> CV:kmeans   5 0.646           0.786       0.766         0.1130 0.840   0.553
#> MAD:kmeans  5 0.717           0.813       0.788         0.1133 0.927   0.736
#> ATC:kmeans  5 0.645           0.742       0.763         0.1077 0.808   0.435
#> SD:pam      5 1.000           0.983       0.992         0.0997 0.938   0.769
#> CV:pam      5 0.981           0.934       0.970         0.1099 0.938   0.769
#> MAD:pam     5 1.000           0.960       0.985         0.0912 0.938   0.769
#> ATC:pam     5 0.989           0.945       0.973         0.0993 0.927   0.728
#> SD:hclust   5 1.000           0.992       0.993         0.1051 0.927   0.736
#> CV:hclust   5 0.886           0.969       0.973         0.2084 0.855   0.582
#> MAD:hclust  5 1.000           1.000       1.000         0.1002 0.927   0.736
#> ATC:hclust  5 1.000           0.975       0.985         0.0396 0.979   0.951
get_stats(res_list, k = 6)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      6 0.965           0.997       0.964         0.0445 0.958   0.795
#> CV:NMF      6 1.000           0.996       0.946         0.0453 0.958   0.795
#> MAD:NMF     6 1.000           0.999       0.991         0.0521 0.958   0.795
#> ATC:NMF     6 0.697           0.826       0.819         0.0869 0.917   0.709
#> SD:skmeans  6 1.000           0.990       0.977         0.0515 0.958   0.795
#> CV:skmeans  6 1.000           0.989       0.979         0.0549 0.958   0.795
#> MAD:skmeans 6 1.000           0.997       0.993         0.0518 0.958   0.795
#> ATC:skmeans 6 0.911           0.816       0.751         0.0720 0.849   0.477
#> SD:mclust   6 1.000           0.965       0.980         0.0454 0.969   0.846
#> CV:mclust   6 0.933           0.975       0.975         0.0586 0.958   0.795
#> MAD:mclust  6 1.000           1.000       1.000         0.0390 0.969   0.846
#> ATC:mclust  6 0.872           0.869       0.898         0.0638 0.958   0.795
#> SD:kmeans   6 0.738           0.909       0.778         0.0612 0.932   0.694
#> CV:kmeans   6 0.708           0.901       0.748         0.0529 0.944   0.735
#> MAD:kmeans  6 0.728           0.887       0.693         0.0495 0.958   0.795
#> ATC:kmeans  6 0.681           0.725       0.754         0.0674 0.930   0.693
#> SD:pam      6 1.000           1.000       1.000         0.0624 0.932   0.690
#> CV:pam      6 1.000           1.000       1.000         0.0724 0.932   0.690
#> MAD:pam     6 1.000           1.000       1.000         0.0560 0.932   0.690
#> ATC:pam     6 1.000           0.963       0.985         0.0496 0.945   0.731
#> SD:hclust   6 1.000           1.000       1.000         0.0521 0.958   0.795
#> CV:hclust   6 0.933           0.970       0.969         0.0623 0.958   0.795
#> MAD:hclust  6 1.000           1.000       1.000         0.0521 0.958   0.795
#> ATC:hclust  6 1.000           0.984       0.993         0.2801 0.829   0.571

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

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

collect_plots(res)

plot of chunk SD-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2     1           1.000       1.000         0.2994 0.701   0.701
#> 3 3     1           1.000       1.000         0.6587 0.803   0.719
#> 4 4     1           0.991       0.993         0.4534 0.771   0.546
#> 5 5     1           0.992       0.993         0.1051 0.927   0.736
#> 6 6     1           1.000       1.000         0.0521 0.958   0.795

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette p1 p2
#> SRR1655002     1       0          1  1  0
#> SRR1655003     1       0          1  1  0
#> SRR1655004     1       0          1  1  0
#> SRR1655005     1       0          1  1  0
#> SRR1655006     1       0          1  1  0
#> SRR1655007     1       0          1  1  0
#> SRR1655008     1       0          1  1  0
#> SRR1655009     1       0          1  1  0
#> SRR1655010     1       0          1  1  0
#> SRR1655011     1       0          1  1  0
#> SRR1655012     2       0          1  0  1
#> SRR1655013     2       0          1  0  1
#> SRR1655014     2       0          1  0  1
#> SRR1655015     2       0          1  0  1
#> SRR1655016     2       0          1  0  1
#> SRR1655017     2       0          1  0  1
#> SRR1655018     2       0          1  0  1
#> SRR1655019     2       0          1  0  1
#> SRR1655020     2       0          1  0  1
#> SRR1655021     2       0          1  0  1
#> SRR1655022     2       0          1  0  1
#> SRR1655023     2       0          1  0  1
#> SRR1655024     2       0          1  0  1
#> SRR1655025     2       0          1  0  1
#> SRR1655026     2       0          1  0  1
#> SRR1655027     2       0          1  0  1
#> SRR1655028     2       0          1  0  1
#> SRR1655029     2       0          1  0  1
#> SRR1655030     2       0          1  0  1
#> SRR1655031     2       0          1  0  1
#> SRR1655032     2       0          1  0  1
#> SRR1655033     2       0          1  0  1
#> SRR1655034     2       0          1  0  1
#> SRR1655035     2       0          1  0  1
#> SRR1655036     2       0          1  0  1
#> SRR1655037     2       0          1  0  1
#> SRR1655038     2       0          1  0  1
#> SRR1655039     2       0          1  0  1
#> SRR1655040     2       0          1  0  1
#> SRR1655041     2       0          1  0  1
#> SRR1655042     2       0          1  0  1
#> SRR1655043     2       0          1  0  1
#> SRR1655044     2       0          1  0  1
#> SRR1655045     2       0          1  0  1
#> SRR1655046     2       0          1  0  1
#> SRR1655047     2       0          1  0  1
#> SRR1655048     2       0          1  0  1
#> SRR1655049     2       0          1  0  1
#> SRR1655050     2       0          1  0  1
#> SRR1655051     2       0          1  0  1
#> SRR1655052     2       0          1  0  1
#> SRR1655053     2       0          1  0  1
#> SRR1655054     2       0          1  0  1
#> SRR1655055     2       0          1  0  1
#> SRR1655056     2       0          1  0  1
#> SRR1655057     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
#> SRR1655002     1       0          1  1  0  0
#> SRR1655003     1       0          1  1  0  0
#> SRR1655004     1       0          1  1  0  0
#> SRR1655005     1       0          1  1  0  0
#> SRR1655006     1       0          1  1  0  0
#> SRR1655007     1       0          1  1  0  0
#> SRR1655008     1       0          1  1  0  0
#> SRR1655009     1       0          1  1  0  0
#> SRR1655010     1       0          1  1  0  0
#> SRR1655011     1       0          1  1  0  0
#> SRR1655012     2       0          1  0  1  0
#> SRR1655013     2       0          1  0  1  0
#> SRR1655014     2       0          1  0  1  0
#> SRR1655015     2       0          1  0  1  0
#> SRR1655016     2       0          1  0  1  0
#> SRR1655017     2       0          1  0  1  0
#> SRR1655018     2       0          1  0  1  0
#> SRR1655019     2       0          1  0  1  0
#> SRR1655020     2       0          1  0  1  0
#> SRR1655021     2       0          1  0  1  0
#> SRR1655022     2       0          1  0  1  0
#> SRR1655023     2       0          1  0  1  0
#> SRR1655024     2       0          1  0  1  0
#> SRR1655025     2       0          1  0  1  0
#> SRR1655026     2       0          1  0  1  0
#> SRR1655027     2       0          1  0  1  0
#> SRR1655028     2       0          1  0  1  0
#> SRR1655029     2       0          1  0  1  0
#> SRR1655030     2       0          1  0  1  0
#> SRR1655031     2       0          1  0  1  0
#> SRR1655032     2       0          1  0  1  0
#> SRR1655033     2       0          1  0  1  0
#> SRR1655034     3       0          1  0  0  1
#> SRR1655035     3       0          1  0  0  1
#> SRR1655036     3       0          1  0  0  1
#> SRR1655037     3       0          1  0  0  1
#> SRR1655038     3       0          1  0  0  1
#> SRR1655039     3       0          1  0  0  1
#> SRR1655040     3       0          1  0  0  1
#> SRR1655041     3       0          1  0  0  1
#> SRR1655042     2       0          1  0  1  0
#> SRR1655043     2       0          1  0  1  0
#> SRR1655044     2       0          1  0  1  0
#> SRR1655045     2       0          1  0  1  0
#> SRR1655046     2       0          1  0  1  0
#> SRR1655047     2       0          1  0  1  0
#> SRR1655048     2       0          1  0  1  0
#> SRR1655049     2       0          1  0  1  0
#> SRR1655050     2       0          1  0  1  0
#> SRR1655051     2       0          1  0  1  0
#> SRR1655052     2       0          1  0  1  0
#> SRR1655053     2       0          1  0  1  0
#> SRR1655054     2       0          1  0  1  0
#> SRR1655055     2       0          1  0  1  0
#> SRR1655056     2       0          1  0  1  0
#> SRR1655057     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
#> SRR1655002     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1655003     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1655004     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1655005     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1655006     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1655007     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1655008     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1655009     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1655010     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1655011     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1655012     2  0.0000      0.998  0 1.000  0 0.000
#> SRR1655013     2  0.0000      0.998  0 1.000  0 0.000
#> SRR1655014     2  0.0000      0.998  0 1.000  0 0.000
#> SRR1655015     2  0.0000      0.998  0 1.000  0 0.000
#> SRR1655016     2  0.0000      0.998  0 1.000  0 0.000
#> SRR1655017     2  0.0000      0.998  0 1.000  0 0.000
#> SRR1655018     2  0.0000      0.998  0 1.000  0 0.000
#> SRR1655019     2  0.0000      0.998  0 1.000  0 0.000
#> SRR1655020     2  0.0000      0.998  0 1.000  0 0.000
#> SRR1655021     2  0.0000      0.998  0 1.000  0 0.000
#> SRR1655022     2  0.0000      0.998  0 1.000  0 0.000
#> SRR1655023     2  0.0000      0.998  0 1.000  0 0.000
#> SRR1655024     2  0.0000      0.998  0 1.000  0 0.000
#> SRR1655025     2  0.0000      0.998  0 1.000  0 0.000
#> SRR1655026     4  0.1302      0.970  0 0.044  0 0.956
#> SRR1655027     4  0.1302      0.970  0 0.044  0 0.956
#> SRR1655028     4  0.1302      0.970  0 0.044  0 0.956
#> SRR1655029     4  0.1302      0.970  0 0.044  0 0.956
#> SRR1655030     4  0.1302      0.970  0 0.044  0 0.956
#> SRR1655031     4  0.1302      0.970  0 0.044  0 0.956
#> SRR1655032     4  0.1302      0.970  0 0.044  0 0.956
#> SRR1655033     4  0.1302      0.970  0 0.044  0 0.956
#> SRR1655034     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1655035     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1655036     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1655037     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1655038     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1655039     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1655040     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1655041     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1655042     2  0.0188      0.997  0 0.996  0 0.004
#> SRR1655043     2  0.0188      0.997  0 0.996  0 0.004
#> SRR1655044     2  0.0188      0.997  0 0.996  0 0.004
#> SRR1655045     2  0.0188      0.997  0 0.996  0 0.004
#> SRR1655046     2  0.0188      0.997  0 0.996  0 0.004
#> SRR1655047     2  0.0188      0.997  0 0.996  0 0.004
#> SRR1655048     2  0.0188      0.997  0 0.996  0 0.004
#> SRR1655049     2  0.0188      0.997  0 0.996  0 0.004
#> SRR1655050     4  0.0000      0.970  0 0.000  0 1.000
#> SRR1655051     4  0.0000      0.970  0 0.000  0 1.000
#> SRR1655052     4  0.0000      0.970  0 0.000  0 1.000
#> SRR1655053     4  0.0000      0.970  0 0.000  0 1.000
#> SRR1655054     4  0.0000      0.970  0 0.000  0 1.000
#> SRR1655055     4  0.0000      0.970  0 0.000  0 1.000
#> SRR1655056     4  0.0000      0.970  0 0.000  0 1.000
#> SRR1655057     4  0.0000      0.970  0 0.000  0 1.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette p1 p2 p3    p4    p5
#> SRR1655002     1    0.00      1.000  1  0  0 0.000 0.000
#> SRR1655003     1    0.00      1.000  1  0  0 0.000 0.000
#> SRR1655004     1    0.00      1.000  1  0  0 0.000 0.000
#> SRR1655005     1    0.00      1.000  1  0  0 0.000 0.000
#> SRR1655006     1    0.00      1.000  1  0  0 0.000 0.000
#> SRR1655007     1    0.00      1.000  1  0  0 0.000 0.000
#> SRR1655008     1    0.00      1.000  1  0  0 0.000 0.000
#> SRR1655009     1    0.00      1.000  1  0  0 0.000 0.000
#> SRR1655010     1    0.00      1.000  1  0  0 0.000 0.000
#> SRR1655011     1    0.00      1.000  1  0  0 0.000 0.000
#> SRR1655012     2    0.00      1.000  0  1  0 0.000 0.000
#> SRR1655013     2    0.00      1.000  0  1  0 0.000 0.000
#> SRR1655014     2    0.00      1.000  0  1  0 0.000 0.000
#> SRR1655015     2    0.00      1.000  0  1  0 0.000 0.000
#> SRR1655016     2    0.00      1.000  0  1  0 0.000 0.000
#> SRR1655017     2    0.00      1.000  0  1  0 0.000 0.000
#> SRR1655018     2    0.00      1.000  0  1  0 0.000 0.000
#> SRR1655019     2    0.00      1.000  0  1  0 0.000 0.000
#> SRR1655020     2    0.00      1.000  0  1  0 0.000 0.000
#> SRR1655021     2    0.00      1.000  0  1  0 0.000 0.000
#> SRR1655022     2    0.00      1.000  0  1  0 0.000 0.000
#> SRR1655023     2    0.00      1.000  0  1  0 0.000 0.000
#> SRR1655024     2    0.00      1.000  0  1  0 0.000 0.000
#> SRR1655025     2    0.00      1.000  0  1  0 0.000 0.000
#> SRR1655026     5    0.12      0.973  0  0  0 0.048 0.952
#> SRR1655027     5    0.12      0.973  0  0  0 0.048 0.952
#> SRR1655028     5    0.12      0.973  0  0  0 0.048 0.952
#> SRR1655029     5    0.12      0.973  0  0  0 0.048 0.952
#> SRR1655030     5    0.12      0.973  0  0  0 0.048 0.952
#> SRR1655031     5    0.12      0.973  0  0  0 0.048 0.952
#> SRR1655032     5    0.12      0.973  0  0  0 0.048 0.952
#> SRR1655033     5    0.12      0.973  0  0  0 0.048 0.952
#> SRR1655034     3    0.00      1.000  0  0  1 0.000 0.000
#> SRR1655035     3    0.00      1.000  0  0  1 0.000 0.000
#> SRR1655036     3    0.00      1.000  0  0  1 0.000 0.000
#> SRR1655037     3    0.00      1.000  0  0  1 0.000 0.000
#> SRR1655038     3    0.00      1.000  0  0  1 0.000 0.000
#> SRR1655039     3    0.00      1.000  0  0  1 0.000 0.000
#> SRR1655040     3    0.00      1.000  0  0  1 0.000 0.000
#> SRR1655041     3    0.00      1.000  0  0  1 0.000 0.000
#> SRR1655042     4    0.00      1.000  0  0  0 1.000 0.000
#> SRR1655043     4    0.00      1.000  0  0  0 1.000 0.000
#> SRR1655044     4    0.00      1.000  0  0  0 1.000 0.000
#> SRR1655045     4    0.00      1.000  0  0  0 1.000 0.000
#> SRR1655046     4    0.00      1.000  0  0  0 1.000 0.000
#> SRR1655047     4    0.00      1.000  0  0  0 1.000 0.000
#> SRR1655048     4    0.00      1.000  0  0  0 1.000 0.000
#> SRR1655049     4    0.00      1.000  0  0  0 1.000 0.000
#> SRR1655050     5    0.00      0.974  0  0  0 0.000 1.000
#> SRR1655051     5    0.00      0.974  0  0  0 0.000 1.000
#> SRR1655052     5    0.00      0.974  0  0  0 0.000 1.000
#> SRR1655053     5    0.00      0.974  0  0  0 0.000 1.000
#> SRR1655054     5    0.00      0.974  0  0  0 0.000 1.000
#> SRR1655055     5    0.00      0.974  0  0  0 0.000 1.000
#> SRR1655056     5    0.00      0.974  0  0  0 0.000 1.000
#> SRR1655057     5    0.00      0.974  0  0  0 0.000 1.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
#> SRR1655002     1       0          1  1  0  0  0  0  0
#> SRR1655003     1       0          1  1  0  0  0  0  0
#> SRR1655004     1       0          1  1  0  0  0  0  0
#> SRR1655005     1       0          1  1  0  0  0  0  0
#> SRR1655006     1       0          1  1  0  0  0  0  0
#> SRR1655007     1       0          1  1  0  0  0  0  0
#> SRR1655008     1       0          1  1  0  0  0  0  0
#> SRR1655009     1       0          1  1  0  0  0  0  0
#> SRR1655010     1       0          1  1  0  0  0  0  0
#> SRR1655011     1       0          1  1  0  0  0  0  0
#> SRR1655012     2       0          1  0  1  0  0  0  0
#> SRR1655013     2       0          1  0  1  0  0  0  0
#> SRR1655014     2       0          1  0  1  0  0  0  0
#> SRR1655015     2       0          1  0  1  0  0  0  0
#> SRR1655016     2       0          1  0  1  0  0  0  0
#> SRR1655017     2       0          1  0  1  0  0  0  0
#> SRR1655018     2       0          1  0  1  0  0  0  0
#> SRR1655019     2       0          1  0  1  0  0  0  0
#> SRR1655020     2       0          1  0  1  0  0  0  0
#> SRR1655021     2       0          1  0  1  0  0  0  0
#> SRR1655022     2       0          1  0  1  0  0  0  0
#> SRR1655023     2       0          1  0  1  0  0  0  0
#> SRR1655024     2       0          1  0  1  0  0  0  0
#> SRR1655025     2       0          1  0  1  0  0  0  0
#> SRR1655026     4       0          1  0  0  0  1  0  0
#> SRR1655027     4       0          1  0  0  0  1  0  0
#> SRR1655028     4       0          1  0  0  0  1  0  0
#> SRR1655029     4       0          1  0  0  0  1  0  0
#> SRR1655030     4       0          1  0  0  0  1  0  0
#> SRR1655031     4       0          1  0  0  0  1  0  0
#> SRR1655032     4       0          1  0  0  0  1  0  0
#> SRR1655033     4       0          1  0  0  0  1  0  0
#> SRR1655034     3       0          1  0  0  1  0  0  0
#> SRR1655035     3       0          1  0  0  1  0  0  0
#> SRR1655036     3       0          1  0  0  1  0  0  0
#> SRR1655037     3       0          1  0  0  1  0  0  0
#> SRR1655038     3       0          1  0  0  1  0  0  0
#> SRR1655039     3       0          1  0  0  1  0  0  0
#> SRR1655040     3       0          1  0  0  1  0  0  0
#> SRR1655041     3       0          1  0  0  1  0  0  0
#> SRR1655042     6       0          1  0  0  0  0  0  1
#> SRR1655043     6       0          1  0  0  0  0  0  1
#> SRR1655044     6       0          1  0  0  0  0  0  1
#> SRR1655045     6       0          1  0  0  0  0  0  1
#> SRR1655046     6       0          1  0  0  0  0  0  1
#> SRR1655047     6       0          1  0  0  0  0  0  1
#> SRR1655048     6       0          1  0  0  0  0  0  1
#> SRR1655049     6       0          1  0  0  0  0  0  1
#> SRR1655050     5       0          1  0  0  0  0  1  0
#> SRR1655051     5       0          1  0  0  0  0  1  0
#> SRR1655052     5       0          1  0  0  0  0  1  0
#> SRR1655053     5       0          1  0  0  0  0  1  0
#> SRR1655054     5       0          1  0  0  0  0  1  0
#> SRR1655055     5       0          1  0  0  0  0  1  0
#> SRR1655056     5       0          1  0  0  0  0  1  0
#> SRR1655057     5       0          1  0  0  0  0  1  0

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

consensus_heatmap(res, k = 2)

plot of chunk tab-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 15837 rows and 56 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.997       0.996         0.2989 0.701   0.701
#> 3 3 0.532           0.737       0.839         0.9145 0.688   0.556
#> 4 4 0.556           0.773       0.765         0.2109 0.803   0.542
#> 5 5 0.655           0.749       0.773         0.0969 0.938   0.774
#> 6 6 0.738           0.909       0.778         0.0612 0.932   0.694

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

suggest_best_k(res)
#> [1] 2

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette    p1    p2
#> SRR1655002     1  0.0938      1.000 0.988 0.012
#> SRR1655003     1  0.0938      1.000 0.988 0.012
#> SRR1655004     1  0.0938      1.000 0.988 0.012
#> SRR1655005     1  0.0938      1.000 0.988 0.012
#> SRR1655006     1  0.0938      1.000 0.988 0.012
#> SRR1655007     1  0.0938      1.000 0.988 0.012
#> SRR1655008     1  0.0938      1.000 0.988 0.012
#> SRR1655009     1  0.0938      1.000 0.988 0.012
#> SRR1655010     1  0.0938      1.000 0.988 0.012
#> SRR1655011     1  0.0938      1.000 0.988 0.012
#> SRR1655012     2  0.0000      0.998 0.000 1.000
#> SRR1655013     2  0.0000      0.998 0.000 1.000
#> SRR1655014     2  0.0000      0.998 0.000 1.000
#> SRR1655015     2  0.0000      0.998 0.000 1.000
#> SRR1655016     2  0.0000      0.998 0.000 1.000
#> SRR1655017     2  0.0000      0.998 0.000 1.000
#> SRR1655018     2  0.0000      0.998 0.000 1.000
#> SRR1655019     2  0.0000      0.998 0.000 1.000
#> SRR1655020     2  0.0000      0.998 0.000 1.000
#> SRR1655021     2  0.0000      0.998 0.000 1.000
#> SRR1655022     2  0.0000      0.998 0.000 1.000
#> SRR1655023     2  0.0000      0.998 0.000 1.000
#> SRR1655024     2  0.0000      0.998 0.000 1.000
#> SRR1655025     2  0.0000      0.998 0.000 1.000
#> SRR1655026     2  0.0000      0.998 0.000 1.000
#> SRR1655027     2  0.0000      0.998 0.000 1.000
#> SRR1655028     2  0.0000      0.998 0.000 1.000
#> SRR1655029     2  0.0000      0.998 0.000 1.000
#> SRR1655030     2  0.0000      0.998 0.000 1.000
#> SRR1655031     2  0.0000      0.998 0.000 1.000
#> SRR1655032     2  0.0000      0.998 0.000 1.000
#> SRR1655033     2  0.0000      0.998 0.000 1.000
#> SRR1655034     2  0.0938      0.990 0.012 0.988
#> SRR1655035     2  0.0938      0.990 0.012 0.988
#> SRR1655036     2  0.0938      0.990 0.012 0.988
#> SRR1655037     2  0.0938      0.990 0.012 0.988
#> SRR1655038     2  0.0938      0.990 0.012 0.988
#> SRR1655039     2  0.0938      0.990 0.012 0.988
#> SRR1655040     2  0.0938      0.990 0.012 0.988
#> SRR1655041     2  0.0938      0.990 0.012 0.988
#> SRR1655042     2  0.0000      0.998 0.000 1.000
#> SRR1655043     2  0.0000      0.998 0.000 1.000
#> SRR1655044     2  0.0000      0.998 0.000 1.000
#> SRR1655045     2  0.0000      0.998 0.000 1.000
#> SRR1655046     2  0.0000      0.998 0.000 1.000
#> SRR1655047     2  0.0000      0.998 0.000 1.000
#> SRR1655048     2  0.0000      0.998 0.000 1.000
#> SRR1655049     2  0.0000      0.998 0.000 1.000
#> SRR1655050     2  0.0000      0.998 0.000 1.000
#> SRR1655051     2  0.0000      0.998 0.000 1.000
#> SRR1655052     2  0.0000      0.998 0.000 1.000
#> SRR1655053     2  0.0000      0.998 0.000 1.000
#> SRR1655054     2  0.0000      0.998 0.000 1.000
#> SRR1655055     2  0.0000      0.998 0.000 1.000
#> SRR1655056     2  0.0000      0.998 0.000 1.000
#> SRR1655057     2  0.0000      0.998 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
#> SRR1655002     1  0.2066      0.972 0.940 0.000 0.060
#> SRR1655003     1  0.0892      0.974 0.980 0.000 0.020
#> SRR1655004     1  0.0000      0.978 1.000 0.000 0.000
#> SRR1655005     1  0.0892      0.974 0.980 0.000 0.020
#> SRR1655006     1  0.1964      0.973 0.944 0.000 0.056
#> SRR1655007     1  0.1289      0.978 0.968 0.000 0.032
#> SRR1655008     1  0.1163      0.976 0.972 0.000 0.028
#> SRR1655009     1  0.1163      0.976 0.972 0.000 0.028
#> SRR1655010     1  0.2356      0.973 0.928 0.000 0.072
#> SRR1655011     1  0.2356      0.973 0.928 0.000 0.072
#> SRR1655012     2  0.2878      0.796 0.000 0.904 0.096
#> SRR1655013     2  0.2878      0.796 0.000 0.904 0.096
#> SRR1655014     2  0.2878      0.796 0.000 0.904 0.096
#> SRR1655015     2  0.2878      0.796 0.000 0.904 0.096
#> SRR1655016     2  0.2878      0.796 0.000 0.904 0.096
#> SRR1655017     2  0.2878      0.796 0.000 0.904 0.096
#> SRR1655018     2  0.2878      0.796 0.000 0.904 0.096
#> SRR1655019     2  0.2878      0.796 0.000 0.904 0.096
#> SRR1655020     2  0.2878      0.796 0.000 0.904 0.096
#> SRR1655021     2  0.2878      0.796 0.000 0.904 0.096
#> SRR1655022     2  0.2878      0.796 0.000 0.904 0.096
#> SRR1655023     2  0.2878      0.796 0.000 0.904 0.096
#> SRR1655024     2  0.2878      0.796 0.000 0.904 0.096
#> SRR1655025     2  0.2878      0.796 0.000 0.904 0.096
#> SRR1655026     2  0.6008      0.216 0.000 0.628 0.372
#> SRR1655027     2  0.6008      0.216 0.000 0.628 0.372
#> SRR1655028     2  0.6008      0.216 0.000 0.628 0.372
#> SRR1655029     2  0.6008      0.216 0.000 0.628 0.372
#> SRR1655030     2  0.6008      0.216 0.000 0.628 0.372
#> SRR1655031     2  0.6008      0.216 0.000 0.628 0.372
#> SRR1655032     2  0.6008      0.216 0.000 0.628 0.372
#> SRR1655033     2  0.6008      0.216 0.000 0.628 0.372
#> SRR1655034     3  0.3267      0.800 0.000 0.116 0.884
#> SRR1655035     3  0.3267      0.800 0.000 0.116 0.884
#> SRR1655036     3  0.3267      0.800 0.000 0.116 0.884
#> SRR1655037     3  0.3267      0.800 0.000 0.116 0.884
#> SRR1655038     3  0.3267      0.800 0.000 0.116 0.884
#> SRR1655039     3  0.3267      0.800 0.000 0.116 0.884
#> SRR1655040     3  0.3267      0.800 0.000 0.116 0.884
#> SRR1655041     3  0.3267      0.800 0.000 0.116 0.884
#> SRR1655042     2  0.0000      0.777 0.000 1.000 0.000
#> SRR1655043     2  0.0000      0.777 0.000 1.000 0.000
#> SRR1655044     2  0.0000      0.777 0.000 1.000 0.000
#> SRR1655045     2  0.0000      0.777 0.000 1.000 0.000
#> SRR1655046     2  0.0000      0.777 0.000 1.000 0.000
#> SRR1655047     2  0.0000      0.777 0.000 1.000 0.000
#> SRR1655048     2  0.0000      0.777 0.000 1.000 0.000
#> SRR1655049     2  0.0000      0.777 0.000 1.000 0.000
#> SRR1655050     3  0.5905      0.757 0.000 0.352 0.648
#> SRR1655051     3  0.5905      0.757 0.000 0.352 0.648
#> SRR1655052     3  0.5905      0.757 0.000 0.352 0.648
#> SRR1655053     3  0.5905      0.757 0.000 0.352 0.648
#> SRR1655054     3  0.5905      0.757 0.000 0.352 0.648
#> SRR1655055     3  0.5905      0.757 0.000 0.352 0.648
#> SRR1655056     3  0.5905      0.757 0.000 0.352 0.648
#> SRR1655057     3  0.5905      0.757 0.000 0.352 0.648

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1655002     1  0.2796      0.946 0.892 0.000 0.016 0.092
#> SRR1655003     1  0.0469      0.954 0.988 0.000 0.000 0.012
#> SRR1655004     1  0.0336      0.955 0.992 0.000 0.000 0.008
#> SRR1655005     1  0.0469      0.954 0.988 0.000 0.000 0.012
#> SRR1655006     1  0.2730      0.947 0.896 0.000 0.016 0.088
#> SRR1655007     1  0.2385      0.955 0.920 0.000 0.028 0.052
#> SRR1655008     1  0.1182      0.954 0.968 0.000 0.016 0.016
#> SRR1655009     1  0.1182      0.954 0.968 0.000 0.016 0.016
#> SRR1655010     1  0.3143      0.947 0.876 0.000 0.024 0.100
#> SRR1655011     1  0.3143      0.947 0.876 0.000 0.024 0.100
#> SRR1655012     2  0.0469      0.809 0.000 0.988 0.000 0.012
#> SRR1655013     2  0.0469      0.809 0.000 0.988 0.000 0.012
#> SRR1655014     2  0.0469      0.809 0.000 0.988 0.000 0.012
#> SRR1655015     2  0.0469      0.809 0.000 0.988 0.000 0.012
#> SRR1655016     2  0.0469      0.809 0.000 0.988 0.000 0.012
#> SRR1655017     2  0.0469      0.809 0.000 0.988 0.000 0.012
#> SRR1655018     2  0.0000      0.812 0.000 1.000 0.000 0.000
#> SRR1655019     2  0.0000      0.812 0.000 1.000 0.000 0.000
#> SRR1655020     2  0.0000      0.812 0.000 1.000 0.000 0.000
#> SRR1655021     2  0.0000      0.812 0.000 1.000 0.000 0.000
#> SRR1655022     2  0.0000      0.812 0.000 1.000 0.000 0.000
#> SRR1655023     2  0.0000      0.812 0.000 1.000 0.000 0.000
#> SRR1655024     2  0.0000      0.812 0.000 1.000 0.000 0.000
#> SRR1655025     2  0.0000      0.812 0.000 1.000 0.000 0.000
#> SRR1655026     4  0.6552      0.697 0.000 0.228 0.144 0.628
#> SRR1655027     4  0.6552      0.697 0.000 0.228 0.144 0.628
#> SRR1655028     4  0.6552      0.697 0.000 0.228 0.144 0.628
#> SRR1655029     4  0.6552      0.697 0.000 0.228 0.144 0.628
#> SRR1655030     4  0.6552      0.697 0.000 0.228 0.144 0.628
#> SRR1655031     4  0.6552      0.697 0.000 0.228 0.144 0.628
#> SRR1655032     4  0.6552      0.697 0.000 0.228 0.144 0.628
#> SRR1655033     4  0.6552      0.697 0.000 0.228 0.144 0.628
#> SRR1655034     3  0.1890      0.975 0.000 0.056 0.936 0.008
#> SRR1655035     3  0.1890      0.975 0.000 0.056 0.936 0.008
#> SRR1655036     3  0.2751      0.978 0.000 0.056 0.904 0.040
#> SRR1655037     3  0.2751      0.978 0.000 0.056 0.904 0.040
#> SRR1655038     3  0.1557      0.977 0.000 0.056 0.944 0.000
#> SRR1655039     3  0.1557      0.977 0.000 0.056 0.944 0.000
#> SRR1655040     3  0.2751      0.978 0.000 0.056 0.904 0.040
#> SRR1655041     3  0.2751      0.978 0.000 0.056 0.904 0.040
#> SRR1655042     2  0.5611      0.516 0.000 0.564 0.024 0.412
#> SRR1655043     2  0.5611      0.516 0.000 0.564 0.024 0.412
#> SRR1655044     2  0.5628      0.503 0.000 0.556 0.024 0.420
#> SRR1655045     2  0.5628      0.503 0.000 0.556 0.024 0.420
#> SRR1655046     2  0.5628      0.503 0.000 0.556 0.024 0.420
#> SRR1655047     2  0.5628      0.503 0.000 0.556 0.024 0.420
#> SRR1655048     2  0.5250      0.626 0.000 0.660 0.024 0.316
#> SRR1655049     2  0.5250      0.626 0.000 0.660 0.024 0.316
#> SRR1655050     4  0.6844      0.595 0.000 0.100 0.444 0.456
#> SRR1655051     4  0.6844      0.595 0.000 0.100 0.444 0.456
#> SRR1655052     4  0.6844      0.595 0.000 0.100 0.444 0.456
#> SRR1655053     4  0.6844      0.595 0.000 0.100 0.444 0.456
#> SRR1655054     4  0.6844      0.595 0.000 0.100 0.444 0.456
#> SRR1655055     4  0.6844      0.595 0.000 0.100 0.444 0.456
#> SRR1655056     4  0.6844      0.595 0.000 0.100 0.444 0.456
#> SRR1655057     4  0.6844      0.595 0.000 0.100 0.444 0.456

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4    p5
#> SRR1655002     1  0.2331      0.913 0.900 0.000 0.020 0.080 0.000
#> SRR1655003     1  0.2796      0.922 0.868 0.000 0.008 0.116 0.008
#> SRR1655004     1  0.2237      0.929 0.904 0.000 0.004 0.084 0.008
#> SRR1655005     1  0.2796      0.922 0.868 0.000 0.008 0.116 0.008
#> SRR1655006     1  0.2144      0.917 0.912 0.000 0.020 0.068 0.000
#> SRR1655007     1  0.0404      0.928 0.988 0.000 0.000 0.000 0.012
#> SRR1655008     1  0.2830      0.924 0.884 0.000 0.016 0.080 0.020
#> SRR1655009     1  0.2830      0.924 0.884 0.000 0.016 0.080 0.020
#> SRR1655010     1  0.1901      0.918 0.928 0.000 0.012 0.056 0.004
#> SRR1655011     1  0.1901      0.918 0.928 0.000 0.012 0.056 0.004
#> SRR1655012     2  0.2835      0.786 0.000 0.868 0.016 0.112 0.004
#> SRR1655013     2  0.2835      0.786 0.000 0.868 0.016 0.112 0.004
#> SRR1655014     2  0.2886      0.784 0.000 0.864 0.016 0.116 0.004
#> SRR1655015     2  0.2886      0.784 0.000 0.864 0.016 0.116 0.004
#> SRR1655016     2  0.2835      0.786 0.000 0.868 0.016 0.112 0.004
#> SRR1655017     2  0.2835      0.786 0.000 0.868 0.016 0.112 0.004
#> SRR1655018     2  0.0566      0.807 0.000 0.984 0.000 0.004 0.012
#> SRR1655019     2  0.0566      0.807 0.000 0.984 0.000 0.004 0.012
#> SRR1655020     2  0.0404      0.808 0.000 0.988 0.000 0.000 0.012
#> SRR1655021     2  0.0404      0.808 0.000 0.988 0.000 0.000 0.012
#> SRR1655022     2  0.0404      0.808 0.000 0.988 0.000 0.000 0.012
#> SRR1655023     2  0.0404      0.808 0.000 0.988 0.000 0.000 0.012
#> SRR1655024     2  0.0404      0.808 0.000 0.988 0.000 0.000 0.012
#> SRR1655025     2  0.0404      0.808 0.000 0.988 0.000 0.000 0.012
#> SRR1655026     5  0.2127      0.551 0.000 0.108 0.000 0.000 0.892
#> SRR1655027     5  0.2127      0.551 0.000 0.108 0.000 0.000 0.892
#> SRR1655028     5  0.2127      0.551 0.000 0.108 0.000 0.000 0.892
#> SRR1655029     5  0.2127      0.551 0.000 0.108 0.000 0.000 0.892
#> SRR1655030     5  0.2127      0.551 0.000 0.108 0.000 0.000 0.892
#> SRR1655031     5  0.2127      0.551 0.000 0.108 0.000 0.000 0.892
#> SRR1655032     5  0.2127      0.551 0.000 0.108 0.000 0.000 0.892
#> SRR1655033     5  0.2127      0.551 0.000 0.108 0.000 0.000 0.892
#> SRR1655034     3  0.2772      0.955 0.000 0.028 0.896 0.032 0.044
#> SRR1655035     3  0.2772      0.955 0.000 0.028 0.896 0.032 0.044
#> SRR1655036     3  0.2853      0.971 0.000 0.028 0.892 0.044 0.036
#> SRR1655037     3  0.2853      0.971 0.000 0.028 0.892 0.044 0.036
#> SRR1655038     3  0.1750      0.968 0.000 0.028 0.936 0.000 0.036
#> SRR1655039     3  0.1750      0.968 0.000 0.028 0.936 0.000 0.036
#> SRR1655040     3  0.2853      0.971 0.000 0.028 0.892 0.044 0.036
#> SRR1655041     3  0.2853      0.971 0.000 0.028 0.892 0.044 0.036
#> SRR1655042     4  0.6792      1.000 0.000 0.296 0.000 0.380 0.324
#> SRR1655043     4  0.6792      1.000 0.000 0.296 0.000 0.380 0.324
#> SRR1655044     4  0.6792      1.000 0.000 0.296 0.000 0.380 0.324
#> SRR1655045     4  0.6792      1.000 0.000 0.296 0.000 0.380 0.324
#> SRR1655046     4  0.6792      1.000 0.000 0.296 0.000 0.380 0.324
#> SRR1655047     4  0.6792      1.000 0.000 0.296 0.000 0.380 0.324
#> SRR1655048     2  0.6856     -0.826 0.000 0.380 0.004 0.368 0.248
#> SRR1655049     2  0.6856     -0.826 0.000 0.380 0.004 0.368 0.248
#> SRR1655050     5  0.7145      0.634 0.000 0.044 0.204 0.244 0.508
#> SRR1655051     5  0.7145      0.634 0.000 0.044 0.204 0.244 0.508
#> SRR1655052     5  0.7163      0.635 0.000 0.044 0.204 0.248 0.504
#> SRR1655053     5  0.7163      0.635 0.000 0.044 0.204 0.248 0.504
#> SRR1655054     5  0.7107      0.635 0.000 0.044 0.204 0.236 0.516
#> SRR1655055     5  0.7107      0.635 0.000 0.044 0.204 0.236 0.516
#> SRR1655056     5  0.7163      0.635 0.000 0.044 0.204 0.248 0.504
#> SRR1655057     5  0.7163      0.635 0.000 0.044 0.204 0.248 0.504

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR1655002     1  0.3217      0.870 0.848 0.000 0.004 0.028 0.096 0.024
#> SRR1655003     1  0.3901      0.888 0.812 0.000 0.008 0.044 0.096 0.040
#> SRR1655004     1  0.3403      0.896 0.848 0.000 0.008 0.040 0.068 0.036
#> SRR1655005     1  0.3901      0.888 0.812 0.000 0.008 0.044 0.096 0.040
#> SRR1655006     1  0.2738      0.879 0.876 0.000 0.004 0.020 0.084 0.016
#> SRR1655007     1  0.0405      0.895 0.988 0.000 0.000 0.000 0.004 0.008
#> SRR1655008     1  0.3424      0.891 0.848 0.000 0.008 0.040 0.060 0.044
#> SRR1655009     1  0.3424      0.891 0.848 0.000 0.008 0.040 0.060 0.044
#> SRR1655010     1  0.2230      0.879 0.904 0.000 0.000 0.016 0.064 0.016
#> SRR1655011     1  0.2230      0.879 0.904 0.000 0.000 0.016 0.064 0.016
#> SRR1655012     2  0.3065      0.794 0.000 0.820 0.000 0.028 0.152 0.000
#> SRR1655013     2  0.3065      0.794 0.000 0.820 0.000 0.028 0.152 0.000
#> SRR1655014     2  0.3102      0.793 0.000 0.816 0.000 0.028 0.156 0.000
#> SRR1655015     2  0.3102      0.793 0.000 0.816 0.000 0.028 0.156 0.000
#> SRR1655016     2  0.3065      0.794 0.000 0.820 0.000 0.028 0.152 0.000
#> SRR1655017     2  0.3065      0.794 0.000 0.820 0.000 0.028 0.152 0.000
#> SRR1655018     2  0.2520      0.839 0.000 0.872 0.000 0.012 0.008 0.108
#> SRR1655019     2  0.2520      0.839 0.000 0.872 0.000 0.012 0.008 0.108
#> SRR1655020     2  0.2408      0.839 0.000 0.876 0.000 0.012 0.004 0.108
#> SRR1655021     2  0.2408      0.839 0.000 0.876 0.000 0.012 0.004 0.108
#> SRR1655022     2  0.2312      0.839 0.000 0.876 0.000 0.012 0.000 0.112
#> SRR1655023     2  0.2312      0.839 0.000 0.876 0.000 0.012 0.000 0.112
#> SRR1655024     2  0.2312      0.839 0.000 0.876 0.000 0.012 0.000 0.112
#> SRR1655025     2  0.2312      0.839 0.000 0.876 0.000 0.012 0.000 0.112
#> SRR1655026     4  0.3646      0.995 0.000 0.052 0.000 0.776 0.000 0.172
#> SRR1655027     4  0.3646      0.995 0.000 0.052 0.000 0.776 0.000 0.172
#> SRR1655028     4  0.3646      0.995 0.000 0.052 0.000 0.776 0.000 0.172
#> SRR1655029     4  0.3646      0.995 0.000 0.052 0.000 0.776 0.000 0.172
#> SRR1655030     4  0.3960      0.986 0.000 0.052 0.000 0.760 0.008 0.180
#> SRR1655031     4  0.3960      0.986 0.000 0.052 0.000 0.760 0.008 0.180
#> SRR1655032     4  0.3646      0.995 0.000 0.052 0.000 0.776 0.000 0.172
#> SRR1655033     4  0.3646      0.995 0.000 0.052 0.000 0.776 0.000 0.172
#> SRR1655034     3  0.1887      0.912 0.000 0.008 0.932 0.020 0.016 0.024
#> SRR1655035     3  0.1887      0.912 0.000 0.008 0.932 0.020 0.016 0.024
#> SRR1655036     3  0.3226      0.929 0.000 0.008 0.860 0.048 0.052 0.032
#> SRR1655037     3  0.3226      0.929 0.000 0.008 0.860 0.048 0.052 0.032
#> SRR1655038     3  0.0767      0.925 0.000 0.008 0.976 0.004 0.000 0.012
#> SRR1655039     3  0.0767      0.925 0.000 0.008 0.976 0.004 0.000 0.012
#> SRR1655040     3  0.3134      0.929 0.000 0.008 0.864 0.048 0.056 0.024
#> SRR1655041     3  0.3134      0.929 0.000 0.008 0.864 0.048 0.056 0.024
#> SRR1655042     6  0.3354      0.959 0.000 0.128 0.000 0.060 0.000 0.812
#> SRR1655043     6  0.3354      0.959 0.000 0.128 0.000 0.060 0.000 0.812
#> SRR1655044     6  0.3370      0.959 0.000 0.124 0.000 0.064 0.000 0.812
#> SRR1655045     6  0.3370      0.959 0.000 0.124 0.000 0.064 0.000 0.812
#> SRR1655046     6  0.3370      0.959 0.000 0.124 0.000 0.064 0.000 0.812
#> SRR1655047     6  0.3370      0.959 0.000 0.124 0.000 0.064 0.000 0.812
#> SRR1655048     6  0.3521      0.889 0.000 0.156 0.000 0.004 0.044 0.796
#> SRR1655049     6  0.3521      0.889 0.000 0.156 0.000 0.004 0.044 0.796
#> SRR1655050     5  0.6260      0.953 0.000 0.008 0.124 0.376 0.464 0.028
#> SRR1655051     5  0.6260      0.953 0.000 0.008 0.124 0.376 0.464 0.028
#> SRR1655052     5  0.5991      0.970 0.000 0.008 0.124 0.312 0.536 0.020
#> SRR1655053     5  0.5991      0.970 0.000 0.008 0.124 0.312 0.536 0.020
#> SRR1655054     5  0.6209      0.967 0.000 0.008 0.124 0.344 0.496 0.028
#> SRR1655055     5  0.6209      0.967 0.000 0.008 0.124 0.344 0.496 0.028
#> SRR1655056     5  0.5991      0.970 0.000 0.008 0.124 0.312 0.536 0.020
#> SRR1655057     5  0.5991      0.970 0.000 0.008 0.124 0.312 0.536 0.020

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

consensus_heatmap(res, k = 2)

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

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

collect_plots(res)

plot of chunk SD-skmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.998       0.999         0.3004 0.701   0.701
#> 3 3 0.803           0.921       0.955         0.7594 0.803   0.719
#> 4 4 0.875           0.939       0.967         0.3709 0.771   0.546
#> 5 5 0.917           0.890       0.907         0.1000 0.844   0.508
#> 6 6 1.000           0.990       0.977         0.0515 0.958   0.795

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 5

There is also optional best \(k\) = 2 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
#> SRR1655002     1  0.0000      1.000 1.000 0.000
#> SRR1655003     1  0.0000      1.000 1.000 0.000
#> SRR1655004     1  0.0000      1.000 1.000 0.000
#> SRR1655005     1  0.0000      1.000 1.000 0.000
#> SRR1655006     1  0.0000      1.000 1.000 0.000
#> SRR1655007     1  0.0000      1.000 1.000 0.000
#> SRR1655008     1  0.0000      1.000 1.000 0.000
#> SRR1655009     1  0.0000      1.000 1.000 0.000
#> SRR1655010     1  0.0000      1.000 1.000 0.000
#> SRR1655011     1  0.0000      1.000 1.000 0.000
#> SRR1655012     2  0.0000      0.999 0.000 1.000
#> SRR1655013     2  0.0000      0.999 0.000 1.000
#> SRR1655014     2  0.0000      0.999 0.000 1.000
#> SRR1655015     2  0.0000      0.999 0.000 1.000
#> SRR1655016     2  0.0000      0.999 0.000 1.000
#> SRR1655017     2  0.0000      0.999 0.000 1.000
#> SRR1655018     2  0.0000      0.999 0.000 1.000
#> SRR1655019     2  0.0000      0.999 0.000 1.000
#> SRR1655020     2  0.0000      0.999 0.000 1.000
#> SRR1655021     2  0.0000      0.999 0.000 1.000
#> SRR1655022     2  0.0000      0.999 0.000 1.000
#> SRR1655023     2  0.0000      0.999 0.000 1.000
#> SRR1655024     2  0.0000      0.999 0.000 1.000
#> SRR1655025     2  0.0000      0.999 0.000 1.000
#> SRR1655026     2  0.0000      0.999 0.000 1.000
#> SRR1655027     2  0.0000      0.999 0.000 1.000
#> SRR1655028     2  0.0000      0.999 0.000 1.000
#> SRR1655029     2  0.0000      0.999 0.000 1.000
#> SRR1655030     2  0.0000      0.999 0.000 1.000
#> SRR1655031     2  0.0000      0.999 0.000 1.000
#> SRR1655032     2  0.0000      0.999 0.000 1.000
#> SRR1655033     2  0.0000      0.999 0.000 1.000
#> SRR1655034     2  0.0672      0.993 0.008 0.992
#> SRR1655035     2  0.0672      0.993 0.008 0.992
#> SRR1655036     2  0.0672      0.993 0.008 0.992
#> SRR1655037     2  0.0672      0.993 0.008 0.992
#> SRR1655038     2  0.0672      0.993 0.008 0.992
#> SRR1655039     2  0.0672      0.993 0.008 0.992
#> SRR1655040     2  0.0672      0.993 0.008 0.992
#> SRR1655041     2  0.0672      0.993 0.008 0.992
#> SRR1655042     2  0.0000      0.999 0.000 1.000
#> SRR1655043     2  0.0000      0.999 0.000 1.000
#> SRR1655044     2  0.0000      0.999 0.000 1.000
#> SRR1655045     2  0.0000      0.999 0.000 1.000
#> SRR1655046     2  0.0000      0.999 0.000 1.000
#> SRR1655047     2  0.0000      0.999 0.000 1.000
#> SRR1655048     2  0.0000      0.999 0.000 1.000
#> SRR1655049     2  0.0000      0.999 0.000 1.000
#> SRR1655050     2  0.0000      0.999 0.000 1.000
#> SRR1655051     2  0.0000      0.999 0.000 1.000
#> SRR1655052     2  0.0000      0.999 0.000 1.000
#> SRR1655053     2  0.0000      0.999 0.000 1.000
#> SRR1655054     2  0.0000      0.999 0.000 1.000
#> SRR1655055     2  0.0000      0.999 0.000 1.000
#> SRR1655056     2  0.0000      0.999 0.000 1.000
#> SRR1655057     2  0.0000      0.999 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
#> SRR1655002     1   0.000      1.000  1 0.000 0.000
#> SRR1655003     1   0.000      1.000  1 0.000 0.000
#> SRR1655004     1   0.000      1.000  1 0.000 0.000
#> SRR1655005     1   0.000      1.000  1 0.000 0.000
#> SRR1655006     1   0.000      1.000  1 0.000 0.000
#> SRR1655007     1   0.000      1.000  1 0.000 0.000
#> SRR1655008     1   0.000      1.000  1 0.000 0.000
#> SRR1655009     1   0.000      1.000  1 0.000 0.000
#> SRR1655010     1   0.000      1.000  1 0.000 0.000
#> SRR1655011     1   0.000      1.000  1 0.000 0.000
#> SRR1655012     2   0.000      0.928  0 1.000 0.000
#> SRR1655013     2   0.000      0.928  0 1.000 0.000
#> SRR1655014     2   0.000      0.928  0 1.000 0.000
#> SRR1655015     2   0.000      0.928  0 1.000 0.000
#> SRR1655016     2   0.000      0.928  0 1.000 0.000
#> SRR1655017     2   0.000      0.928  0 1.000 0.000
#> SRR1655018     2   0.000      0.928  0 1.000 0.000
#> SRR1655019     2   0.000      0.928  0 1.000 0.000
#> SRR1655020     2   0.000      0.928  0 1.000 0.000
#> SRR1655021     2   0.000      0.928  0 1.000 0.000
#> SRR1655022     2   0.000      0.928  0 1.000 0.000
#> SRR1655023     2   0.000      0.928  0 1.000 0.000
#> SRR1655024     2   0.000      0.928  0 1.000 0.000
#> SRR1655025     2   0.000      0.928  0 1.000 0.000
#> SRR1655026     2   0.175      0.915  0 0.952 0.048
#> SRR1655027     2   0.175      0.915  0 0.952 0.048
#> SRR1655028     2   0.175      0.915  0 0.952 0.048
#> SRR1655029     2   0.175      0.915  0 0.952 0.048
#> SRR1655030     2   0.175      0.915  0 0.952 0.048
#> SRR1655031     2   0.175      0.915  0 0.952 0.048
#> SRR1655032     2   0.175      0.915  0 0.952 0.048
#> SRR1655033     2   0.175      0.915  0 0.952 0.048
#> SRR1655034     3   0.000      1.000  0 0.000 1.000
#> SRR1655035     3   0.000      1.000  0 0.000 1.000
#> SRR1655036     3   0.000      1.000  0 0.000 1.000
#> SRR1655037     3   0.000      1.000  0 0.000 1.000
#> SRR1655038     3   0.000      1.000  0 0.000 1.000
#> SRR1655039     3   0.000      1.000  0 0.000 1.000
#> SRR1655040     3   0.000      1.000  0 0.000 1.000
#> SRR1655041     3   0.000      1.000  0 0.000 1.000
#> SRR1655042     2   0.000      0.928  0 1.000 0.000
#> SRR1655043     2   0.000      0.928  0 1.000 0.000
#> SRR1655044     2   0.000      0.928  0 1.000 0.000
#> SRR1655045     2   0.000      0.928  0 1.000 0.000
#> SRR1655046     2   0.000      0.928  0 1.000 0.000
#> SRR1655047     2   0.000      0.928  0 1.000 0.000
#> SRR1655048     2   0.000      0.928  0 1.000 0.000
#> SRR1655049     2   0.000      0.928  0 1.000 0.000
#> SRR1655050     2   0.529      0.729  0 0.732 0.268
#> SRR1655051     2   0.529      0.729  0 0.732 0.268
#> SRR1655052     2   0.529      0.729  0 0.732 0.268
#> SRR1655053     2   0.529      0.729  0 0.732 0.268
#> SRR1655054     2   0.529      0.729  0 0.732 0.268
#> SRR1655055     2   0.529      0.729  0 0.732 0.268
#> SRR1655056     2   0.529      0.729  0 0.732 0.268
#> SRR1655057     2   0.529      0.729  0 0.732 0.268

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette p1    p2    p3    p4
#> SRR1655002     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1655003     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1655004     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1655005     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1655006     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1655007     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1655008     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1655009     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1655010     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1655011     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1655012     2  0.0000      0.904  0 1.000 0.000 0.000
#> SRR1655013     2  0.0000      0.904  0 1.000 0.000 0.000
#> SRR1655014     2  0.0000      0.904  0 1.000 0.000 0.000
#> SRR1655015     2  0.0000      0.904  0 1.000 0.000 0.000
#> SRR1655016     2  0.0000      0.904  0 1.000 0.000 0.000
#> SRR1655017     2  0.0000      0.904  0 1.000 0.000 0.000
#> SRR1655018     2  0.0000      0.904  0 1.000 0.000 0.000
#> SRR1655019     2  0.0000      0.904  0 1.000 0.000 0.000
#> SRR1655020     2  0.0000      0.904  0 1.000 0.000 0.000
#> SRR1655021     2  0.0000      0.904  0 1.000 0.000 0.000
#> SRR1655022     2  0.0000      0.904  0 1.000 0.000 0.000
#> SRR1655023     2  0.0000      0.904  0 1.000 0.000 0.000
#> SRR1655024     2  0.0000      0.904  0 1.000 0.000 0.000
#> SRR1655025     2  0.0000      0.904  0 1.000 0.000 0.000
#> SRR1655026     4  0.0188      0.994  0 0.004 0.000 0.996
#> SRR1655027     4  0.0188      0.994  0 0.004 0.000 0.996
#> SRR1655028     4  0.0188      0.994  0 0.004 0.000 0.996
#> SRR1655029     4  0.0188      0.994  0 0.004 0.000 0.996
#> SRR1655030     4  0.0188      0.994  0 0.004 0.000 0.996
#> SRR1655031     4  0.0188      0.994  0 0.004 0.000 0.996
#> SRR1655032     4  0.0188      0.994  0 0.004 0.000 0.996
#> SRR1655033     4  0.0188      0.994  0 0.004 0.000 0.996
#> SRR1655034     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR1655035     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR1655036     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR1655037     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR1655038     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR1655039     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR1655040     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR1655041     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR1655042     2  0.4277      0.708  0 0.720 0.000 0.280
#> SRR1655043     2  0.4277      0.708  0 0.720 0.000 0.280
#> SRR1655044     2  0.4277      0.708  0 0.720 0.000 0.280
#> SRR1655045     2  0.4277      0.708  0 0.720 0.000 0.280
#> SRR1655046     2  0.4277      0.708  0 0.720 0.000 0.280
#> SRR1655047     2  0.4277      0.708  0 0.720 0.000 0.280
#> SRR1655048     2  0.0817      0.894  0 0.976 0.000 0.024
#> SRR1655049     2  0.0817      0.894  0 0.976 0.000 0.024
#> SRR1655050     4  0.0336      0.994  0 0.000 0.008 0.992
#> SRR1655051     4  0.0336      0.994  0 0.000 0.008 0.992
#> SRR1655052     4  0.0336      0.994  0 0.000 0.008 0.992
#> SRR1655053     4  0.0336      0.994  0 0.000 0.008 0.992
#> SRR1655054     4  0.0336      0.994  0 0.000 0.008 0.992
#> SRR1655055     4  0.0336      0.994  0 0.000 0.008 0.992
#> SRR1655056     4  0.0336      0.994  0 0.000 0.008 0.992
#> SRR1655057     4  0.0336      0.994  0 0.000 0.008 0.992

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette p1    p2 p3    p4    p5
#> SRR1655002     1   0.000      1.000  1 0.000  0 0.000 0.000
#> SRR1655003     1   0.000      1.000  1 0.000  0 0.000 0.000
#> SRR1655004     1   0.000      1.000  1 0.000  0 0.000 0.000
#> SRR1655005     1   0.000      1.000  1 0.000  0 0.000 0.000
#> SRR1655006     1   0.000      1.000  1 0.000  0 0.000 0.000
#> SRR1655007     1   0.000      1.000  1 0.000  0 0.000 0.000
#> SRR1655008     1   0.000      1.000  1 0.000  0 0.000 0.000
#> SRR1655009     1   0.000      1.000  1 0.000  0 0.000 0.000
#> SRR1655010     1   0.000      1.000  1 0.000  0 0.000 0.000
#> SRR1655011     1   0.000      1.000  1 0.000  0 0.000 0.000
#> SRR1655012     2   0.000      1.000  0 1.000  0 0.000 0.000
#> SRR1655013     2   0.000      1.000  0 1.000  0 0.000 0.000
#> SRR1655014     2   0.000      1.000  0 1.000  0 0.000 0.000
#> SRR1655015     2   0.000      1.000  0 1.000  0 0.000 0.000
#> SRR1655016     2   0.000      1.000  0 1.000  0 0.000 0.000
#> SRR1655017     2   0.000      1.000  0 1.000  0 0.000 0.000
#> SRR1655018     2   0.000      1.000  0 1.000  0 0.000 0.000
#> SRR1655019     2   0.000      1.000  0 1.000  0 0.000 0.000
#> SRR1655020     2   0.000      1.000  0 1.000  0 0.000 0.000
#> SRR1655021     2   0.000      1.000  0 1.000  0 0.000 0.000
#> SRR1655022     2   0.000      1.000  0 1.000  0 0.000 0.000
#> SRR1655023     2   0.000      1.000  0 1.000  0 0.000 0.000
#> SRR1655024     2   0.000      1.000  0 1.000  0 0.000 0.000
#> SRR1655025     2   0.000      1.000  0 1.000  0 0.000 0.000
#> SRR1655026     4   0.443      0.534  0 0.004  0 0.540 0.456
#> SRR1655027     4   0.443      0.534  0 0.004  0 0.540 0.456
#> SRR1655028     4   0.443      0.534  0 0.004  0 0.540 0.456
#> SRR1655029     4   0.443      0.534  0 0.004  0 0.540 0.456
#> SRR1655030     4   0.443      0.534  0 0.004  0 0.540 0.456
#> SRR1655031     4   0.443      0.534  0 0.004  0 0.540 0.456
#> SRR1655032     4   0.443      0.534  0 0.004  0 0.540 0.456
#> SRR1655033     4   0.443      0.534  0 0.004  0 0.540 0.456
#> SRR1655034     3   0.000      1.000  0 0.000  1 0.000 0.000
#> SRR1655035     3   0.000      1.000  0 0.000  1 0.000 0.000
#> SRR1655036     3   0.000      1.000  0 0.000  1 0.000 0.000
#> SRR1655037     3   0.000      1.000  0 0.000  1 0.000 0.000
#> SRR1655038     3   0.000      1.000  0 0.000  1 0.000 0.000
#> SRR1655039     3   0.000      1.000  0 0.000  1 0.000 0.000
#> SRR1655040     3   0.000      1.000  0 0.000  1 0.000 0.000
#> SRR1655041     3   0.000      1.000  0 0.000  1 0.000 0.000
#> SRR1655042     4   0.051      0.694  0 0.016  0 0.984 0.000
#> SRR1655043     4   0.051      0.694  0 0.016  0 0.984 0.000
#> SRR1655044     4   0.051      0.694  0 0.016  0 0.984 0.000
#> SRR1655045     4   0.051      0.694  0 0.016  0 0.984 0.000
#> SRR1655046     4   0.051      0.694  0 0.016  0 0.984 0.000
#> SRR1655047     4   0.051      0.694  0 0.016  0 0.984 0.000
#> SRR1655048     4   0.051      0.694  0 0.016  0 0.984 0.000
#> SRR1655049     4   0.051      0.694  0 0.016  0 0.984 0.000
#> SRR1655050     5   0.000      1.000  0 0.000  0 0.000 1.000
#> SRR1655051     5   0.000      1.000  0 0.000  0 0.000 1.000
#> SRR1655052     5   0.000      1.000  0 0.000  0 0.000 1.000
#> SRR1655053     5   0.000      1.000  0 0.000  0 0.000 1.000
#> SRR1655054     5   0.000      1.000  0 0.000  0 0.000 1.000
#> SRR1655055     5   0.000      1.000  0 0.000  0 0.000 1.000
#> SRR1655056     5   0.000      1.000  0 0.000  0 0.000 1.000
#> SRR1655057     5   0.000      1.000  0 0.000  0 0.000 1.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
#> SRR1655002     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR1655003     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR1655004     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR1655005     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR1655006     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR1655007     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR1655008     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR1655009     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR1655010     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR1655011     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR1655012     2  0.1926      0.955  0 0.912  0 0.000 0.068 0.020
#> SRR1655013     2  0.1926      0.955  0 0.912  0 0.000 0.068 0.020
#> SRR1655014     2  0.1926      0.955  0 0.912  0 0.000 0.068 0.020
#> SRR1655015     2  0.1926      0.955  0 0.912  0 0.000 0.068 0.020
#> SRR1655016     2  0.1926      0.955  0 0.912  0 0.000 0.068 0.020
#> SRR1655017     2  0.1926      0.955  0 0.912  0 0.000 0.068 0.020
#> SRR1655018     2  0.0146      0.965  0 0.996  0 0.000 0.000 0.004
#> SRR1655019     2  0.0146      0.965  0 0.996  0 0.000 0.000 0.004
#> SRR1655020     2  0.0000      0.966  0 1.000  0 0.000 0.000 0.000
#> SRR1655021     2  0.0000      0.966  0 1.000  0 0.000 0.000 0.000
#> SRR1655022     2  0.0000      0.966  0 1.000  0 0.000 0.000 0.000
#> SRR1655023     2  0.0000      0.966  0 1.000  0 0.000 0.000 0.000
#> SRR1655024     2  0.0000      0.966  0 1.000  0 0.000 0.000 0.000
#> SRR1655025     2  0.0000      0.966  0 1.000  0 0.000 0.000 0.000
#> SRR1655026     4  0.0000      1.000  0 0.000  0 1.000 0.000 0.000
#> SRR1655027     4  0.0000      1.000  0 0.000  0 1.000 0.000 0.000
#> SRR1655028     4  0.0000      1.000  0 0.000  0 1.000 0.000 0.000
#> SRR1655029     4  0.0000      1.000  0 0.000  0 1.000 0.000 0.000
#> SRR1655030     4  0.0000      1.000  0 0.000  0 1.000 0.000 0.000
#> SRR1655031     4  0.0000      1.000  0 0.000  0 1.000 0.000 0.000
#> SRR1655032     4  0.0000      1.000  0 0.000  0 1.000 0.000 0.000
#> SRR1655033     4  0.0000      1.000  0 0.000  0 1.000 0.000 0.000
#> SRR1655034     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR1655035     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR1655036     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR1655037     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR1655038     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR1655039     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR1655040     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR1655041     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR1655042     6  0.0632      1.000  0 0.000  0 0.024 0.000 0.976
#> SRR1655043     6  0.0632      1.000  0 0.000  0 0.024 0.000 0.976
#> SRR1655044     6  0.0632      1.000  0 0.000  0 0.024 0.000 0.976
#> SRR1655045     6  0.0632      1.000  0 0.000  0 0.024 0.000 0.976
#> SRR1655046     6  0.0632      1.000  0 0.000  0 0.024 0.000 0.976
#> SRR1655047     6  0.0632      1.000  0 0.000  0 0.024 0.000 0.976
#> SRR1655048     6  0.0632      1.000  0 0.000  0 0.024 0.000 0.976
#> SRR1655049     6  0.0632      1.000  0 0.000  0 0.024 0.000 0.976
#> SRR1655050     5  0.1387      1.000  0 0.000  0 0.068 0.932 0.000
#> SRR1655051     5  0.1387      1.000  0 0.000  0 0.068 0.932 0.000
#> SRR1655052     5  0.1387      1.000  0 0.000  0 0.068 0.932 0.000
#> SRR1655053     5  0.1387      1.000  0 0.000  0 0.068 0.932 0.000
#> SRR1655054     5  0.1387      1.000  0 0.000  0 0.068 0.932 0.000
#> SRR1655055     5  0.1387      1.000  0 0.000  0 0.068 0.932 0.000
#> SRR1655056     5  0.1387      1.000  0 0.000  0 0.068 0.932 0.000
#> SRR1655057     5  0.1387      1.000  0 0.000  0 0.068 0.932 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 15837 rows and 56 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#>   Subgroups are detected by 'pam' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 6.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk SD-pam-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.2994 0.701   0.701
#> 3 3 1.000           1.000       1.000         0.6587 0.803   0.719
#> 4 4 0.809           0.940       0.956         0.4463 0.766   0.536
#> 5 5 1.000           0.983       0.992         0.0997 0.938   0.769
#> 6 6 1.000           1.000       1.000         0.0624 0.932   0.690

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
#> SRR1655002     1       0          1  1  0
#> SRR1655003     1       0          1  1  0
#> SRR1655004     1       0          1  1  0
#> SRR1655005     1       0          1  1  0
#> SRR1655006     1       0          1  1  0
#> SRR1655007     1       0          1  1  0
#> SRR1655008     1       0          1  1  0
#> SRR1655009     1       0          1  1  0
#> SRR1655010     1       0          1  1  0
#> SRR1655011     1       0          1  1  0
#> SRR1655012     2       0          1  0  1
#> SRR1655013     2       0          1  0  1
#> SRR1655014     2       0          1  0  1
#> SRR1655015     2       0          1  0  1
#> SRR1655016     2       0          1  0  1
#> SRR1655017     2       0          1  0  1
#> SRR1655018     2       0          1  0  1
#> SRR1655019     2       0          1  0  1
#> SRR1655020     2       0          1  0  1
#> SRR1655021     2       0          1  0  1
#> SRR1655022     2       0          1  0  1
#> SRR1655023     2       0          1  0  1
#> SRR1655024     2       0          1  0  1
#> SRR1655025     2       0          1  0  1
#> SRR1655026     2       0          1  0  1
#> SRR1655027     2       0          1  0  1
#> SRR1655028     2       0          1  0  1
#> SRR1655029     2       0          1  0  1
#> SRR1655030     2       0          1  0  1
#> SRR1655031     2       0          1  0  1
#> SRR1655032     2       0          1  0  1
#> SRR1655033     2       0          1  0  1
#> SRR1655034     2       0          1  0  1
#> SRR1655035     2       0          1  0  1
#> SRR1655036     2       0          1  0  1
#> SRR1655037     2       0          1  0  1
#> SRR1655038     2       0          1  0  1
#> SRR1655039     2       0          1  0  1
#> SRR1655040     2       0          1  0  1
#> SRR1655041     2       0          1  0  1
#> SRR1655042     2       0          1  0  1
#> SRR1655043     2       0          1  0  1
#> SRR1655044     2       0          1  0  1
#> SRR1655045     2       0          1  0  1
#> SRR1655046     2       0          1  0  1
#> SRR1655047     2       0          1  0  1
#> SRR1655048     2       0          1  0  1
#> SRR1655049     2       0          1  0  1
#> SRR1655050     2       0          1  0  1
#> SRR1655051     2       0          1  0  1
#> SRR1655052     2       0          1  0  1
#> SRR1655053     2       0          1  0  1
#> SRR1655054     2       0          1  0  1
#> SRR1655055     2       0          1  0  1
#> SRR1655056     2       0          1  0  1
#> SRR1655057     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
#> SRR1655002     1       0          1  1  0  0
#> SRR1655003     1       0          1  1  0  0
#> SRR1655004     1       0          1  1  0  0
#> SRR1655005     1       0          1  1  0  0
#> SRR1655006     1       0          1  1  0  0
#> SRR1655007     1       0          1  1  0  0
#> SRR1655008     1       0          1  1  0  0
#> SRR1655009     1       0          1  1  0  0
#> SRR1655010     1       0          1  1  0  0
#> SRR1655011     1       0          1  1  0  0
#> SRR1655012     2       0          1  0  1  0
#> SRR1655013     2       0          1  0  1  0
#> SRR1655014     2       0          1  0  1  0
#> SRR1655015     2       0          1  0  1  0
#> SRR1655016     2       0          1  0  1  0
#> SRR1655017     2       0          1  0  1  0
#> SRR1655018     2       0          1  0  1  0
#> SRR1655019     2       0          1  0  1  0
#> SRR1655020     2       0          1  0  1  0
#> SRR1655021     2       0          1  0  1  0
#> SRR1655022     2       0          1  0  1  0
#> SRR1655023     2       0          1  0  1  0
#> SRR1655024     2       0          1  0  1  0
#> SRR1655025     2       0          1  0  1  0
#> SRR1655026     2       0          1  0  1  0
#> SRR1655027     2       0          1  0  1  0
#> SRR1655028     2       0          1  0  1  0
#> SRR1655029     2       0          1  0  1  0
#> SRR1655030     2       0          1  0  1  0
#> SRR1655031     2       0          1  0  1  0
#> SRR1655032     2       0          1  0  1  0
#> SRR1655033     2       0          1  0  1  0
#> SRR1655034     3       0          1  0  0  1
#> SRR1655035     3       0          1  0  0  1
#> SRR1655036     3       0          1  0  0  1
#> SRR1655037     3       0          1  0  0  1
#> SRR1655038     3       0          1  0  0  1
#> SRR1655039     3       0          1  0  0  1
#> SRR1655040     3       0          1  0  0  1
#> SRR1655041     3       0          1  0  0  1
#> SRR1655042     2       0          1  0  1  0
#> SRR1655043     2       0          1  0  1  0
#> SRR1655044     2       0          1  0  1  0
#> SRR1655045     2       0          1  0  1  0
#> SRR1655046     2       0          1  0  1  0
#> SRR1655047     2       0          1  0  1  0
#> SRR1655048     2       0          1  0  1  0
#> SRR1655049     2       0          1  0  1  0
#> SRR1655050     2       0          1  0  1  0
#> SRR1655051     2       0          1  0  1  0
#> SRR1655052     2       0          1  0  1  0
#> SRR1655053     2       0          1  0  1  0
#> SRR1655054     2       0          1  0  1  0
#> SRR1655055     2       0          1  0  1  0
#> SRR1655056     2       0          1  0  1  0
#> SRR1655057     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
#> SRR1655002     1   0.000      1.000  1 0.000  0 0.000
#> SRR1655003     1   0.000      1.000  1 0.000  0 0.000
#> SRR1655004     1   0.000      1.000  1 0.000  0 0.000
#> SRR1655005     1   0.000      1.000  1 0.000  0 0.000
#> SRR1655006     1   0.000      1.000  1 0.000  0 0.000
#> SRR1655007     1   0.000      1.000  1 0.000  0 0.000
#> SRR1655008     1   0.000      1.000  1 0.000  0 0.000
#> SRR1655009     1   0.000      1.000  1 0.000  0 0.000
#> SRR1655010     1   0.000      1.000  1 0.000  0 0.000
#> SRR1655011     1   0.000      1.000  1 0.000  0 0.000
#> SRR1655012     2   0.000      1.000  0 1.000  0 0.000
#> SRR1655013     2   0.000      1.000  0 1.000  0 0.000
#> SRR1655014     2   0.000      1.000  0 1.000  0 0.000
#> SRR1655015     2   0.000      1.000  0 1.000  0 0.000
#> SRR1655016     2   0.000      1.000  0 1.000  0 0.000
#> SRR1655017     2   0.000      1.000  0 1.000  0 0.000
#> SRR1655018     2   0.000      1.000  0 1.000  0 0.000
#> SRR1655019     2   0.000      1.000  0 1.000  0 0.000
#> SRR1655020     2   0.000      1.000  0 1.000  0 0.000
#> SRR1655021     2   0.000      1.000  0 1.000  0 0.000
#> SRR1655022     2   0.000      1.000  0 1.000  0 0.000
#> SRR1655023     2   0.000      1.000  0 1.000  0 0.000
#> SRR1655024     2   0.000      1.000  0 1.000  0 0.000
#> SRR1655025     2   0.000      1.000  0 1.000  0 0.000
#> SRR1655026     4   0.349      0.852  0 0.188  0 0.812
#> SRR1655027     4   0.302      0.864  0 0.148  0 0.852
#> SRR1655028     4   0.201      0.864  0 0.080  0 0.920
#> SRR1655029     4   0.228      0.866  0 0.096  0 0.904
#> SRR1655030     4   0.391      0.825  0 0.232  0 0.768
#> SRR1655031     4   0.398      0.818  0 0.240  0 0.760
#> SRR1655032     4   0.287      0.865  0 0.136  0 0.864
#> SRR1655033     4   0.344      0.854  0 0.184  0 0.816
#> SRR1655034     3   0.000      1.000  0 0.000  1 0.000
#> SRR1655035     3   0.000      1.000  0 0.000  1 0.000
#> SRR1655036     3   0.000      1.000  0 0.000  1 0.000
#> SRR1655037     3   0.000      1.000  0 0.000  1 0.000
#> SRR1655038     3   0.000      1.000  0 0.000  1 0.000
#> SRR1655039     3   0.000      1.000  0 0.000  1 0.000
#> SRR1655040     3   0.000      1.000  0 0.000  1 0.000
#> SRR1655041     3   0.000      1.000  0 0.000  1 0.000
#> SRR1655042     2   0.000      1.000  0 1.000  0 0.000
#> SRR1655043     2   0.000      1.000  0 1.000  0 0.000
#> SRR1655044     4   0.436      0.770  0 0.292  0 0.708
#> SRR1655045     4   0.436      0.770  0 0.292  0 0.708
#> SRR1655046     4   0.436      0.770  0 0.292  0 0.708
#> SRR1655047     4   0.436      0.770  0 0.292  0 0.708
#> SRR1655048     2   0.000      1.000  0 1.000  0 0.000
#> SRR1655049     2   0.000      1.000  0 1.000  0 0.000
#> SRR1655050     4   0.000      0.847  0 0.000  0 1.000
#> SRR1655051     4   0.000      0.847  0 0.000  0 1.000
#> SRR1655052     4   0.000      0.847  0 0.000  0 1.000
#> SRR1655053     4   0.000      0.847  0 0.000  0 1.000
#> SRR1655054     4   0.000      0.847  0 0.000  0 1.000
#> SRR1655055     4   0.000      0.847  0 0.000  0 1.000
#> SRR1655056     4   0.000      0.847  0 0.000  0 1.000
#> SRR1655057     4   0.000      0.847  0 0.000  0 1.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette p1    p2 p3    p4 p5
#> SRR1655002     1   0.000      1.000  1 0.000  0 0.000  0
#> SRR1655003     1   0.000      1.000  1 0.000  0 0.000  0
#> SRR1655004     1   0.000      1.000  1 0.000  0 0.000  0
#> SRR1655005     1   0.000      1.000  1 0.000  0 0.000  0
#> SRR1655006     1   0.000      1.000  1 0.000  0 0.000  0
#> SRR1655007     1   0.000      1.000  1 0.000  0 0.000  0
#> SRR1655008     1   0.000      1.000  1 0.000  0 0.000  0
#> SRR1655009     1   0.000      1.000  1 0.000  0 0.000  0
#> SRR1655010     1   0.000      1.000  1 0.000  0 0.000  0
#> SRR1655011     1   0.000      1.000  1 0.000  0 0.000  0
#> SRR1655012     2   0.000      1.000  0 1.000  0 0.000  0
#> SRR1655013     2   0.000      1.000  0 1.000  0 0.000  0
#> SRR1655014     2   0.000      1.000  0 1.000  0 0.000  0
#> SRR1655015     2   0.000      1.000  0 1.000  0 0.000  0
#> SRR1655016     2   0.000      1.000  0 1.000  0 0.000  0
#> SRR1655017     2   0.000      1.000  0 1.000  0 0.000  0
#> SRR1655018     2   0.000      1.000  0 1.000  0 0.000  0
#> SRR1655019     2   0.000      1.000  0 1.000  0 0.000  0
#> SRR1655020     2   0.000      1.000  0 1.000  0 0.000  0
#> SRR1655021     2   0.000      1.000  0 1.000  0 0.000  0
#> SRR1655022     2   0.000      1.000  0 1.000  0 0.000  0
#> SRR1655023     2   0.000      1.000  0 1.000  0 0.000  0
#> SRR1655024     2   0.000      1.000  0 1.000  0 0.000  0
#> SRR1655025     2   0.000      1.000  0 1.000  0 0.000  0
#> SRR1655026     4   0.000      0.949  0 0.000  0 1.000  0
#> SRR1655027     4   0.000      0.949  0 0.000  0 1.000  0
#> SRR1655028     4   0.000      0.949  0 0.000  0 1.000  0
#> SRR1655029     4   0.000      0.949  0 0.000  0 1.000  0
#> SRR1655030     4   0.000      0.949  0 0.000  0 1.000  0
#> SRR1655031     4   0.000      0.949  0 0.000  0 1.000  0
#> SRR1655032     4   0.000      0.949  0 0.000  0 1.000  0
#> SRR1655033     4   0.000      0.949  0 0.000  0 1.000  0
#> SRR1655034     3   0.000      1.000  0 0.000  1 0.000  0
#> SRR1655035     3   0.000      1.000  0 0.000  1 0.000  0
#> SRR1655036     3   0.000      1.000  0 0.000  1 0.000  0
#> SRR1655037     3   0.000      1.000  0 0.000  1 0.000  0
#> SRR1655038     3   0.000      1.000  0 0.000  1 0.000  0
#> SRR1655039     3   0.000      1.000  0 0.000  1 0.000  0
#> SRR1655040     3   0.000      1.000  0 0.000  1 0.000  0
#> SRR1655041     3   0.000      1.000  0 0.000  1 0.000  0
#> SRR1655042     2   0.000      1.000  0 1.000  0 0.000  0
#> SRR1655043     2   0.000      1.000  0 1.000  0 0.000  0
#> SRR1655044     4   0.112      0.928  0 0.044  0 0.956  0
#> SRR1655045     4   0.112      0.928  0 0.044  0 0.956  0
#> SRR1655046     4   0.293      0.799  0 0.180  0 0.820  0
#> SRR1655047     4   0.300      0.790  0 0.188  0 0.812  0
#> SRR1655048     2   0.000      1.000  0 1.000  0 0.000  0
#> SRR1655049     2   0.000      1.000  0 1.000  0 0.000  0
#> SRR1655050     5   0.000      1.000  0 0.000  0 0.000  1
#> SRR1655051     5   0.000      1.000  0 0.000  0 0.000  1
#> SRR1655052     5   0.000      1.000  0 0.000  0 0.000  1
#> SRR1655053     5   0.000      1.000  0 0.000  0 0.000  1
#> SRR1655054     5   0.000      1.000  0 0.000  0 0.000  1
#> SRR1655055     5   0.000      1.000  0 0.000  0 0.000  1
#> SRR1655056     5   0.000      1.000  0 0.000  0 0.000  1
#> SRR1655057     5   0.000      1.000  0 0.000  0 0.000  1

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1655002     1       0          1  1  0  0  0  0  0
#> SRR1655003     1       0          1  1  0  0  0  0  0
#> SRR1655004     1       0          1  1  0  0  0  0  0
#> SRR1655005     1       0          1  1  0  0  0  0  0
#> SRR1655006     1       0          1  1  0  0  0  0  0
#> SRR1655007     1       0          1  1  0  0  0  0  0
#> SRR1655008     1       0          1  1  0  0  0  0  0
#> SRR1655009     1       0          1  1  0  0  0  0  0
#> SRR1655010     1       0          1  1  0  0  0  0  0
#> SRR1655011     1       0          1  1  0  0  0  0  0
#> SRR1655012     2       0          1  0  1  0  0  0  0
#> SRR1655013     2       0          1  0  1  0  0  0  0
#> SRR1655014     2       0          1  0  1  0  0  0  0
#> SRR1655015     2       0          1  0  1  0  0  0  0
#> SRR1655016     2       0          1  0  1  0  0  0  0
#> SRR1655017     2       0          1  0  1  0  0  0  0
#> SRR1655018     2       0          1  0  1  0  0  0  0
#> SRR1655019     2       0          1  0  1  0  0  0  0
#> SRR1655020     2       0          1  0  1  0  0  0  0
#> SRR1655021     2       0          1  0  1  0  0  0  0
#> SRR1655022     2       0          1  0  1  0  0  0  0
#> SRR1655023     2       0          1  0  1  0  0  0  0
#> SRR1655024     2       0          1  0  1  0  0  0  0
#> SRR1655025     2       0          1  0  1  0  0  0  0
#> SRR1655026     4       0          1  0  0  0  1  0  0
#> SRR1655027     4       0          1  0  0  0  1  0  0
#> SRR1655028     4       0          1  0  0  0  1  0  0
#> SRR1655029     4       0          1  0  0  0  1  0  0
#> SRR1655030     4       0          1  0  0  0  1  0  0
#> SRR1655031     4       0          1  0  0  0  1  0  0
#> SRR1655032     4       0          1  0  0  0  1  0  0
#> SRR1655033     4       0          1  0  0  0  1  0  0
#> SRR1655034     3       0          1  0  0  1  0  0  0
#> SRR1655035     3       0          1  0  0  1  0  0  0
#> SRR1655036     3       0          1  0  0  1  0  0  0
#> SRR1655037     3       0          1  0  0  1  0  0  0
#> SRR1655038     3       0          1  0  0  1  0  0  0
#> SRR1655039     3       0          1  0  0  1  0  0  0
#> SRR1655040     3       0          1  0  0  1  0  0  0
#> SRR1655041     3       0          1  0  0  1  0  0  0
#> SRR1655042     6       0          1  0  0  0  0  0  1
#> SRR1655043     6       0          1  0  0  0  0  0  1
#> SRR1655044     6       0          1  0  0  0  0  0  1
#> SRR1655045     6       0          1  0  0  0  0  0  1
#> SRR1655046     6       0          1  0  0  0  0  0  1
#> SRR1655047     6       0          1  0  0  0  0  0  1
#> SRR1655048     6       0          1  0  0  0  0  0  1
#> SRR1655049     6       0          1  0  0  0  0  0  1
#> SRR1655050     5       0          1  0  0  0  0  1  0
#> SRR1655051     5       0          1  0  0  0  0  1  0
#> SRR1655052     5       0          1  0  0  0  0  1  0
#> SRR1655053     5       0          1  0  0  0  0  1  0
#> SRR1655054     5       0          1  0  0  0  0  1  0
#> SRR1655055     5       0          1  0  0  0  0  1  0
#> SRR1655056     5       0          1  0  0  0  0  1  0
#> SRR1655057     5       0          1  0  0  0  0  1  0

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

consensus_heatmap(res, k = 2)

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

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

collect_plots(res)

plot of chunk SD-mclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.751           0.862       0.941         0.3592 0.701   0.701
#> 3 3 0.575           0.897       0.904         0.5793 0.735   0.622
#> 4 4 1.000           0.971       0.986         0.2742 0.777   0.522
#> 5 5 1.000           0.965       0.984         0.1017 0.927   0.736
#> 6 6 1.000           0.965       0.980         0.0454 0.969   0.846

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette    p1    p2
#> SRR1655002     1   0.000      1.000 1.000 0.000
#> SRR1655003     1   0.000      1.000 1.000 0.000
#> SRR1655004     1   0.000      1.000 1.000 0.000
#> SRR1655005     1   0.000      1.000 1.000 0.000
#> SRR1655006     1   0.000      1.000 1.000 0.000
#> SRR1655007     1   0.000      1.000 1.000 0.000
#> SRR1655008     1   0.000      1.000 1.000 0.000
#> SRR1655009     1   0.000      1.000 1.000 0.000
#> SRR1655010     1   0.000      1.000 1.000 0.000
#> SRR1655011     1   0.000      1.000 1.000 0.000
#> SRR1655012     2   0.000      0.921 0.000 1.000
#> SRR1655013     2   0.000      0.921 0.000 1.000
#> SRR1655014     2   0.000      0.921 0.000 1.000
#> SRR1655015     2   0.000      0.921 0.000 1.000
#> SRR1655016     2   0.000      0.921 0.000 1.000
#> SRR1655017     2   0.000      0.921 0.000 1.000
#> SRR1655018     2   0.000      0.921 0.000 1.000
#> SRR1655019     2   0.000      0.921 0.000 1.000
#> SRR1655020     2   0.000      0.921 0.000 1.000
#> SRR1655021     2   0.000      0.921 0.000 1.000
#> SRR1655022     2   0.000      0.921 0.000 1.000
#> SRR1655023     2   0.000      0.921 0.000 1.000
#> SRR1655024     2   0.000      0.921 0.000 1.000
#> SRR1655025     2   0.000      0.921 0.000 1.000
#> SRR1655026     2   0.000      0.921 0.000 1.000
#> SRR1655027     2   0.000      0.921 0.000 1.000
#> SRR1655028     2   0.000      0.921 0.000 1.000
#> SRR1655029     2   0.000      0.921 0.000 1.000
#> SRR1655030     2   0.000      0.921 0.000 1.000
#> SRR1655031     2   0.000      0.921 0.000 1.000
#> SRR1655032     2   0.000      0.921 0.000 1.000
#> SRR1655033     2   0.000      0.921 0.000 1.000
#> SRR1655034     2   0.978      0.408 0.412 0.588
#> SRR1655035     2   0.978      0.408 0.412 0.588
#> SRR1655036     2   0.978      0.408 0.412 0.588
#> SRR1655037     2   0.978      0.408 0.412 0.588
#> SRR1655038     2   0.978      0.408 0.412 0.588
#> SRR1655039     2   0.978      0.408 0.412 0.588
#> SRR1655040     2   0.978      0.408 0.412 0.588
#> SRR1655041     2   0.978      0.408 0.412 0.588
#> SRR1655042     2   0.000      0.921 0.000 1.000
#> SRR1655043     2   0.000      0.921 0.000 1.000
#> SRR1655044     2   0.000      0.921 0.000 1.000
#> SRR1655045     2   0.000      0.921 0.000 1.000
#> SRR1655046     2   0.000      0.921 0.000 1.000
#> SRR1655047     2   0.000      0.921 0.000 1.000
#> SRR1655048     2   0.000      0.921 0.000 1.000
#> SRR1655049     2   0.000      0.921 0.000 1.000
#> SRR1655050     2   0.000      0.921 0.000 1.000
#> SRR1655051     2   0.000      0.921 0.000 1.000
#> SRR1655052     2   0.000      0.921 0.000 1.000
#> SRR1655053     2   0.000      0.921 0.000 1.000
#> SRR1655054     2   0.000      0.921 0.000 1.000
#> SRR1655055     2   0.000      0.921 0.000 1.000
#> SRR1655056     2   0.000      0.921 0.000 1.000
#> SRR1655057     2   0.000      0.921 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
#> SRR1655002     1  0.0000      1.000  1 0.000 0.000
#> SRR1655003     1  0.0000      1.000  1 0.000 0.000
#> SRR1655004     1  0.0000      1.000  1 0.000 0.000
#> SRR1655005     1  0.0000      1.000  1 0.000 0.000
#> SRR1655006     1  0.0000      1.000  1 0.000 0.000
#> SRR1655007     1  0.0000      1.000  1 0.000 0.000
#> SRR1655008     1  0.0000      1.000  1 0.000 0.000
#> SRR1655009     1  0.0000      1.000  1 0.000 0.000
#> SRR1655010     1  0.0000      1.000  1 0.000 0.000
#> SRR1655011     1  0.0000      1.000  1 0.000 0.000
#> SRR1655012     3  0.3551      0.986  0 0.132 0.868
#> SRR1655013     3  0.3551      0.986  0 0.132 0.868
#> SRR1655014     2  0.4842      0.751  0 0.776 0.224
#> SRR1655015     2  0.4842      0.751  0 0.776 0.224
#> SRR1655016     3  0.3551      0.986  0 0.132 0.868
#> SRR1655017     3  0.3551      0.986  0 0.132 0.868
#> SRR1655018     3  0.3941      0.973  0 0.156 0.844
#> SRR1655019     3  0.3941      0.973  0 0.156 0.844
#> SRR1655020     3  0.3686      0.989  0 0.140 0.860
#> SRR1655021     3  0.3686      0.989  0 0.140 0.860
#> SRR1655022     3  0.3752      0.989  0 0.144 0.856
#> SRR1655023     3  0.3752      0.989  0 0.144 0.856
#> SRR1655024     3  0.3752      0.989  0 0.144 0.856
#> SRR1655025     3  0.3752      0.989  0 0.144 0.856
#> SRR1655026     2  0.1753      0.878  0 0.952 0.048
#> SRR1655027     2  0.1753      0.878  0 0.952 0.048
#> SRR1655028     2  0.1753      0.878  0 0.952 0.048
#> SRR1655029     2  0.1753      0.878  0 0.952 0.048
#> SRR1655030     2  0.1753      0.878  0 0.952 0.048
#> SRR1655031     2  0.1753      0.878  0 0.952 0.048
#> SRR1655032     2  0.1753      0.878  0 0.952 0.048
#> SRR1655033     2  0.1753      0.878  0 0.952 0.048
#> SRR1655034     2  0.3551      0.809  0 0.868 0.132
#> SRR1655035     2  0.3551      0.809  0 0.868 0.132
#> SRR1655036     2  0.3551      0.809  0 0.868 0.132
#> SRR1655037     2  0.3551      0.809  0 0.868 0.132
#> SRR1655038     2  0.3551      0.809  0 0.868 0.132
#> SRR1655039     2  0.3551      0.809  0 0.868 0.132
#> SRR1655040     2  0.3551      0.809  0 0.868 0.132
#> SRR1655041     2  0.3551      0.809  0 0.868 0.132
#> SRR1655042     2  0.4178      0.804  0 0.828 0.172
#> SRR1655043     2  0.4178      0.804  0 0.828 0.172
#> SRR1655044     2  0.4178      0.804  0 0.828 0.172
#> SRR1655045     2  0.4178      0.804  0 0.828 0.172
#> SRR1655046     2  0.4178      0.804  0 0.828 0.172
#> SRR1655047     2  0.4178      0.804  0 0.828 0.172
#> SRR1655048     2  0.4346      0.791  0 0.816 0.184
#> SRR1655049     2  0.4346      0.791  0 0.816 0.184
#> SRR1655050     2  0.0237      0.878  0 0.996 0.004
#> SRR1655051     2  0.0237      0.878  0 0.996 0.004
#> SRR1655052     2  0.0237      0.878  0 0.996 0.004
#> SRR1655053     2  0.0237      0.878  0 0.996 0.004
#> SRR1655054     2  0.0237      0.878  0 0.996 0.004
#> SRR1655055     2  0.0237      0.878  0 0.996 0.004
#> SRR1655056     2  0.0237      0.878  0 0.996 0.004
#> SRR1655057     2  0.0237      0.878  0 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
#> SRR1655002     1   0.000      1.000  1 0.000  0 0.000
#> SRR1655003     1   0.000      1.000  1 0.000  0 0.000
#> SRR1655004     1   0.000      1.000  1 0.000  0 0.000
#> SRR1655005     1   0.000      1.000  1 0.000  0 0.000
#> SRR1655006     1   0.000      1.000  1 0.000  0 0.000
#> SRR1655007     1   0.000      1.000  1 0.000  0 0.000
#> SRR1655008     1   0.000      1.000  1 0.000  0 0.000
#> SRR1655009     1   0.000      1.000  1 0.000  0 0.000
#> SRR1655010     1   0.000      1.000  1 0.000  0 0.000
#> SRR1655011     1   0.000      1.000  1 0.000  0 0.000
#> SRR1655012     2   0.000      0.967  0 1.000  0 0.000
#> SRR1655013     2   0.000      0.967  0 1.000  0 0.000
#> SRR1655014     2   0.000      0.967  0 1.000  0 0.000
#> SRR1655015     2   0.000      0.967  0 1.000  0 0.000
#> SRR1655016     2   0.000      0.967  0 1.000  0 0.000
#> SRR1655017     2   0.000      0.967  0 1.000  0 0.000
#> SRR1655018     2   0.000      0.967  0 1.000  0 0.000
#> SRR1655019     2   0.000      0.967  0 1.000  0 0.000
#> SRR1655020     2   0.000      0.967  0 1.000  0 0.000
#> SRR1655021     2   0.000      0.967  0 1.000  0 0.000
#> SRR1655022     2   0.000      0.967  0 1.000  0 0.000
#> SRR1655023     2   0.000      0.967  0 1.000  0 0.000
#> SRR1655024     2   0.000      0.967  0 1.000  0 0.000
#> SRR1655025     2   0.000      0.967  0 1.000  0 0.000
#> SRR1655026     4   0.000      0.979  0 0.000  0 1.000
#> SRR1655027     4   0.000      0.979  0 0.000  0 1.000
#> SRR1655028     4   0.000      0.979  0 0.000  0 1.000
#> SRR1655029     4   0.000      0.979  0 0.000  0 1.000
#> SRR1655030     4   0.000      0.979  0 0.000  0 1.000
#> SRR1655031     4   0.000      0.979  0 0.000  0 1.000
#> SRR1655032     4   0.000      0.979  0 0.000  0 1.000
#> SRR1655033     4   0.000      0.979  0 0.000  0 1.000
#> SRR1655034     3   0.000      1.000  0 0.000  1 0.000
#> SRR1655035     3   0.000      1.000  0 0.000  1 0.000
#> SRR1655036     3   0.000      1.000  0 0.000  1 0.000
#> SRR1655037     3   0.000      1.000  0 0.000  1 0.000
#> SRR1655038     3   0.000      1.000  0 0.000  1 0.000
#> SRR1655039     3   0.000      1.000  0 0.000  1 0.000
#> SRR1655040     3   0.000      1.000  0 0.000  1 0.000
#> SRR1655041     3   0.000      1.000  0 0.000  1 0.000
#> SRR1655042     4   0.172      0.943  0 0.064  0 0.936
#> SRR1655043     4   0.172      0.943  0 0.064  0 0.936
#> SRR1655044     4   0.172      0.943  0 0.064  0 0.936
#> SRR1655045     4   0.172      0.943  0 0.064  0 0.936
#> SRR1655046     4   0.172      0.943  0 0.064  0 0.936
#> SRR1655047     4   0.172      0.943  0 0.064  0 0.936
#> SRR1655048     2   0.357      0.748  0 0.804  0 0.196
#> SRR1655049     2   0.357      0.748  0 0.804  0 0.196
#> SRR1655050     4   0.000      0.979  0 0.000  0 1.000
#> SRR1655051     4   0.000      0.979  0 0.000  0 1.000
#> SRR1655052     4   0.000      0.979  0 0.000  0 1.000
#> SRR1655053     4   0.000      0.979  0 0.000  0 1.000
#> SRR1655054     4   0.000      0.979  0 0.000  0 1.000
#> SRR1655055     4   0.000      0.979  0 0.000  0 1.000
#> SRR1655056     4   0.000      0.979  0 0.000  0 1.000
#> SRR1655057     4   0.000      0.979  0 0.000  0 1.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette p1    p2 p3    p4 p5
#> SRR1655002     1  0.0000      1.000  1 0.000  0 0.000  0
#> SRR1655003     1  0.0000      1.000  1 0.000  0 0.000  0
#> SRR1655004     1  0.0000      1.000  1 0.000  0 0.000  0
#> SRR1655005     1  0.0000      1.000  1 0.000  0 0.000  0
#> SRR1655006     1  0.0000      1.000  1 0.000  0 0.000  0
#> SRR1655007     1  0.0000      1.000  1 0.000  0 0.000  0
#> SRR1655008     1  0.0000      1.000  1 0.000  0 0.000  0
#> SRR1655009     1  0.0000      1.000  1 0.000  0 0.000  0
#> SRR1655010     1  0.0000      1.000  1 0.000  0 0.000  0
#> SRR1655011     1  0.0000      1.000  1 0.000  0 0.000  0
#> SRR1655012     2  0.0609      0.937  0 0.980  0 0.020  0
#> SRR1655013     2  0.0609      0.937  0 0.980  0 0.020  0
#> SRR1655014     2  0.0794      0.933  0 0.972  0 0.028  0
#> SRR1655015     2  0.0794      0.933  0 0.972  0 0.028  0
#> SRR1655016     2  0.0609      0.937  0 0.980  0 0.020  0
#> SRR1655017     2  0.0609      0.937  0 0.980  0 0.020  0
#> SRR1655018     2  0.0000      0.938  0 1.000  0 0.000  0
#> SRR1655019     2  0.0000      0.938  0 1.000  0 0.000  0
#> SRR1655020     2  0.0000      0.938  0 1.000  0 0.000  0
#> SRR1655021     2  0.0000      0.938  0 1.000  0 0.000  0
#> SRR1655022     2  0.0000      0.938  0 1.000  0 0.000  0
#> SRR1655023     2  0.0000      0.938  0 1.000  0 0.000  0
#> SRR1655024     2  0.0000      0.938  0 1.000  0 0.000  0
#> SRR1655025     2  0.0000      0.938  0 1.000  0 0.000  0
#> SRR1655026     4  0.0000      0.991  0 0.000  0 1.000  0
#> SRR1655027     4  0.0000      0.991  0 0.000  0 1.000  0
#> SRR1655028     4  0.0000      0.991  0 0.000  0 1.000  0
#> SRR1655029     4  0.0000      0.991  0 0.000  0 1.000  0
#> SRR1655030     4  0.0000      0.991  0 0.000  0 1.000  0
#> SRR1655031     4  0.0000      0.991  0 0.000  0 1.000  0
#> SRR1655032     4  0.0000      0.991  0 0.000  0 1.000  0
#> SRR1655033     4  0.0000      0.991  0 0.000  0 1.000  0
#> SRR1655034     3  0.0000      1.000  0 0.000  1 0.000  0
#> SRR1655035     3  0.0000      1.000  0 0.000  1 0.000  0
#> SRR1655036     3  0.0000      1.000  0 0.000  1 0.000  0
#> SRR1655037     3  0.0000      1.000  0 0.000  1 0.000  0
#> SRR1655038     3  0.0000      1.000  0 0.000  1 0.000  0
#> SRR1655039     3  0.0000      1.000  0 0.000  1 0.000  0
#> SRR1655040     3  0.0000      1.000  0 0.000  1 0.000  0
#> SRR1655041     3  0.0000      1.000  0 0.000  1 0.000  0
#> SRR1655042     4  0.0510      0.989  0 0.016  0 0.984  0
#> SRR1655043     4  0.0510      0.989  0 0.016  0 0.984  0
#> SRR1655044     4  0.0510      0.989  0 0.016  0 0.984  0
#> SRR1655045     4  0.0510      0.989  0 0.016  0 0.984  0
#> SRR1655046     4  0.0510      0.989  0 0.016  0 0.984  0
#> SRR1655047     4  0.0510      0.989  0 0.016  0 0.984  0
#> SRR1655048     2  0.3999      0.524  0 0.656  0 0.344  0
#> SRR1655049     2  0.3999      0.524  0 0.656  0 0.344  0
#> SRR1655050     5  0.0000      1.000  0 0.000  0 0.000  1
#> SRR1655051     5  0.0000      1.000  0 0.000  0 0.000  1
#> SRR1655052     5  0.0000      1.000  0 0.000  0 0.000  1
#> SRR1655053     5  0.0000      1.000  0 0.000  0 0.000  1
#> SRR1655054     5  0.0000      1.000  0 0.000  0 0.000  1
#> SRR1655055     5  0.0000      1.000  0 0.000  0 0.000  1
#> SRR1655056     5  0.0000      1.000  0 0.000  0 0.000  1
#> SRR1655057     5  0.0000      1.000  0 0.000  0 0.000  1

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette p1    p2 p3    p4 p5    p6
#> SRR1655002     1  0.0000      1.000  1 0.000  0 0.000  0 0.000
#> SRR1655003     1  0.0000      1.000  1 0.000  0 0.000  0 0.000
#> SRR1655004     1  0.0000      1.000  1 0.000  0 0.000  0 0.000
#> SRR1655005     1  0.0000      1.000  1 0.000  0 0.000  0 0.000
#> SRR1655006     1  0.0000      1.000  1 0.000  0 0.000  0 0.000
#> SRR1655007     1  0.0000      1.000  1 0.000  0 0.000  0 0.000
#> SRR1655008     1  0.0000      1.000  1 0.000  0 0.000  0 0.000
#> SRR1655009     1  0.0000      1.000  1 0.000  0 0.000  0 0.000
#> SRR1655010     1  0.0000      1.000  1 0.000  0 0.000  0 0.000
#> SRR1655011     1  0.0000      1.000  1 0.000  0 0.000  0 0.000
#> SRR1655012     2  0.0547      0.928  0 0.980  0 0.000  0 0.020
#> SRR1655013     2  0.0547      0.928  0 0.980  0 0.000  0 0.020
#> SRR1655014     2  0.0790      0.925  0 0.968  0 0.000  0 0.032
#> SRR1655015     2  0.0790      0.925  0 0.968  0 0.000  0 0.032
#> SRR1655016     2  0.0547      0.928  0 0.980  0 0.000  0 0.020
#> SRR1655017     2  0.0547      0.928  0 0.980  0 0.000  0 0.020
#> SRR1655018     2  0.0865      0.928  0 0.964  0 0.000  0 0.036
#> SRR1655019     2  0.0865      0.928  0 0.964  0 0.000  0 0.036
#> SRR1655020     2  0.0146      0.926  0 0.996  0 0.000  0 0.004
#> SRR1655021     2  0.0146      0.926  0 0.996  0 0.000  0 0.004
#> SRR1655022     2  0.0937      0.927  0 0.960  0 0.000  0 0.040
#> SRR1655023     2  0.0937      0.927  0 0.960  0 0.000  0 0.040
#> SRR1655024     2  0.0937      0.927  0 0.960  0 0.000  0 0.040
#> SRR1655025     2  0.0937      0.927  0 0.960  0 0.000  0 0.040
#> SRR1655026     4  0.0000      1.000  0 0.000  0 1.000  0 0.000
#> SRR1655027     4  0.0000      1.000  0 0.000  0 1.000  0 0.000
#> SRR1655028     4  0.0000      1.000  0 0.000  0 1.000  0 0.000
#> SRR1655029     4  0.0000      1.000  0 0.000  0 1.000  0 0.000
#> SRR1655030     4  0.0000      1.000  0 0.000  0 1.000  0 0.000
#> SRR1655031     4  0.0000      1.000  0 0.000  0 1.000  0 0.000
#> SRR1655032     4  0.0000      1.000  0 0.000  0 1.000  0 0.000
#> SRR1655033     4  0.0000      1.000  0 0.000  0 1.000  0 0.000
#> SRR1655034     3  0.0000      1.000  0 0.000  1 0.000  0 0.000
#> SRR1655035     3  0.0000      1.000  0 0.000  1 0.000  0 0.000
#> SRR1655036     3  0.0000      1.000  0 0.000  1 0.000  0 0.000
#> SRR1655037     3  0.0000      1.000  0 0.000  1 0.000  0 0.000
#> SRR1655038     3  0.0000      1.000  0 0.000  1 0.000  0 0.000
#> SRR1655039     3  0.0000      1.000  0 0.000  1 0.000  0 0.000
#> SRR1655040     3  0.0000      1.000  0 0.000  1 0.000  0 0.000
#> SRR1655041     3  0.0000      1.000  0 0.000  1 0.000  0 0.000
#> SRR1655042     6  0.0146      1.000  0 0.000  0 0.004  0 0.996
#> SRR1655043     6  0.0146      1.000  0 0.000  0 0.004  0 0.996
#> SRR1655044     6  0.0146      1.000  0 0.000  0 0.004  0 0.996
#> SRR1655045     6  0.0146      1.000  0 0.000  0 0.004  0 0.996
#> SRR1655046     6  0.0146      1.000  0 0.000  0 0.004  0 0.996
#> SRR1655047     6  0.0146      1.000  0 0.000  0 0.004  0 0.996
#> SRR1655048     2  0.3672      0.519  0 0.632  0 0.000  0 0.368
#> SRR1655049     2  0.3672      0.519  0 0.632  0 0.000  0 0.368
#> SRR1655050     5  0.0000      1.000  0 0.000  0 0.000  1 0.000
#> SRR1655051     5  0.0000      1.000  0 0.000  0 0.000  1 0.000
#> SRR1655052     5  0.0000      1.000  0 0.000  0 0.000  1 0.000
#> SRR1655053     5  0.0000      1.000  0 0.000  0 0.000  1 0.000
#> SRR1655054     5  0.0000      1.000  0 0.000  0 0.000  1 0.000
#> SRR1655055     5  0.0000      1.000  0 0.000  0 0.000  1 0.000
#> SRR1655056     5  0.0000      1.000  0 0.000  0 0.000  1 0.000
#> SRR1655057     5  0.0000      1.000  0 0.000  0 0.000  1 0.000

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

consensus_heatmap(res, k = 2)

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

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

collect_plots(res)

plot of chunk SD-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           1.000       1.000         0.2994 0.701   0.701
#> 3 3 0.862           0.892       0.950         0.7953 0.803   0.719
#> 4 4 1.000           0.985       0.988         0.3387 0.771   0.546
#> 5 5 0.942           0.935       0.938         0.0999 0.844   0.508
#> 6 6 0.965           0.997       0.964         0.0445 0.958   0.795

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 5

There is also optional best \(k\) = 2 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
#> SRR1655002     1       0          1  1  0
#> SRR1655003     1       0          1  1  0
#> SRR1655004     1       0          1  1  0
#> SRR1655005     1       0          1  1  0
#> SRR1655006     1       0          1  1  0
#> SRR1655007     1       0          1  1  0
#> SRR1655008     1       0          1  1  0
#> SRR1655009     1       0          1  1  0
#> SRR1655010     1       0          1  1  0
#> SRR1655011     1       0          1  1  0
#> SRR1655012     2       0          1  0  1
#> SRR1655013     2       0          1  0  1
#> SRR1655014     2       0          1  0  1
#> SRR1655015     2       0          1  0  1
#> SRR1655016     2       0          1  0  1
#> SRR1655017     2       0          1  0  1
#> SRR1655018     2       0          1  0  1
#> SRR1655019     2       0          1  0  1
#> SRR1655020     2       0          1  0  1
#> SRR1655021     2       0          1  0  1
#> SRR1655022     2       0          1  0  1
#> SRR1655023     2       0          1  0  1
#> SRR1655024     2       0          1  0  1
#> SRR1655025     2       0          1  0  1
#> SRR1655026     2       0          1  0  1
#> SRR1655027     2       0          1  0  1
#> SRR1655028     2       0          1  0  1
#> SRR1655029     2       0          1  0  1
#> SRR1655030     2       0          1  0  1
#> SRR1655031     2       0          1  0  1
#> SRR1655032     2       0          1  0  1
#> SRR1655033     2       0          1  0  1
#> SRR1655034     2       0          1  0  1
#> SRR1655035     2       0          1  0  1
#> SRR1655036     2       0          1  0  1
#> SRR1655037     2       0          1  0  1
#> SRR1655038     2       0          1  0  1
#> SRR1655039     2       0          1  0  1
#> SRR1655040     2       0          1  0  1
#> SRR1655041     2       0          1  0  1
#> SRR1655042     2       0          1  0  1
#> SRR1655043     2       0          1  0  1
#> SRR1655044     2       0          1  0  1
#> SRR1655045     2       0          1  0  1
#> SRR1655046     2       0          1  0  1
#> SRR1655047     2       0          1  0  1
#> SRR1655048     2       0          1  0  1
#> SRR1655049     2       0          1  0  1
#> SRR1655050     2       0          1  0  1
#> SRR1655051     2       0          1  0  1
#> SRR1655052     2       0          1  0  1
#> SRR1655053     2       0          1  0  1
#> SRR1655054     2       0          1  0  1
#> SRR1655055     2       0          1  0  1
#> SRR1655056     2       0          1  0  1
#> SRR1655057     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
#> SRR1655002     1   0.000      1.000  1 0.000 0.000
#> SRR1655003     1   0.000      1.000  1 0.000 0.000
#> SRR1655004     1   0.000      1.000  1 0.000 0.000
#> SRR1655005     1   0.000      1.000  1 0.000 0.000
#> SRR1655006     1   0.000      1.000  1 0.000 0.000
#> SRR1655007     1   0.000      1.000  1 0.000 0.000
#> SRR1655008     1   0.000      1.000  1 0.000 0.000
#> SRR1655009     1   0.000      1.000  1 0.000 0.000
#> SRR1655010     1   0.000      1.000  1 0.000 0.000
#> SRR1655011     1   0.000      1.000  1 0.000 0.000
#> SRR1655012     2   0.000      0.919  0 1.000 0.000
#> SRR1655013     2   0.000      0.919  0 1.000 0.000
#> SRR1655014     2   0.000      0.919  0 1.000 0.000
#> SRR1655015     2   0.000      0.919  0 1.000 0.000
#> SRR1655016     2   0.000      0.919  0 1.000 0.000
#> SRR1655017     2   0.000      0.919  0 1.000 0.000
#> SRR1655018     2   0.000      0.919  0 1.000 0.000
#> SRR1655019     2   0.000      0.919  0 1.000 0.000
#> SRR1655020     2   0.000      0.919  0 1.000 0.000
#> SRR1655021     2   0.000      0.919  0 1.000 0.000
#> SRR1655022     2   0.000      0.919  0 1.000 0.000
#> SRR1655023     2   0.000      0.919  0 1.000 0.000
#> SRR1655024     2   0.000      0.919  0 1.000 0.000
#> SRR1655025     2   0.000      0.919  0 1.000 0.000
#> SRR1655026     2   0.000      0.919  0 1.000 0.000
#> SRR1655027     2   0.000      0.919  0 1.000 0.000
#> SRR1655028     2   0.000      0.919  0 1.000 0.000
#> SRR1655029     2   0.000      0.919  0 1.000 0.000
#> SRR1655030     2   0.000      0.919  0 1.000 0.000
#> SRR1655031     2   0.000      0.919  0 1.000 0.000
#> SRR1655032     2   0.000      0.919  0 1.000 0.000
#> SRR1655033     2   0.000      0.919  0 1.000 0.000
#> SRR1655034     3   0.000      1.000  0 0.000 1.000
#> SRR1655035     3   0.000      1.000  0 0.000 1.000
#> SRR1655036     3   0.000      1.000  0 0.000 1.000
#> SRR1655037     3   0.000      1.000  0 0.000 1.000
#> SRR1655038     3   0.000      1.000  0 0.000 1.000
#> SRR1655039     3   0.000      1.000  0 0.000 1.000
#> SRR1655040     3   0.000      1.000  0 0.000 1.000
#> SRR1655041     3   0.000      1.000  0 0.000 1.000
#> SRR1655042     2   0.000      0.919  0 1.000 0.000
#> SRR1655043     2   0.000      0.919  0 1.000 0.000
#> SRR1655044     2   0.000      0.919  0 1.000 0.000
#> SRR1655045     2   0.000      0.919  0 1.000 0.000
#> SRR1655046     2   0.000      0.919  0 1.000 0.000
#> SRR1655047     2   0.000      0.919  0 1.000 0.000
#> SRR1655048     2   0.000      0.919  0 1.000 0.000
#> SRR1655049     2   0.000      0.919  0 1.000 0.000
#> SRR1655050     2   0.610      0.479  0 0.608 0.392
#> SRR1655051     2   0.613      0.462  0 0.600 0.400
#> SRR1655052     2   0.571      0.603  0 0.680 0.320
#> SRR1655053     2   0.571      0.603  0 0.680 0.320
#> SRR1655054     2   0.573      0.598  0 0.676 0.324
#> SRR1655055     2   0.568      0.609  0 0.684 0.316
#> SRR1655056     2   0.606      0.495  0 0.616 0.384
#> SRR1655057     2   0.590      0.553  0 0.648 0.352

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette p1    p2    p3    p4
#> SRR1655002     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1655003     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1655004     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1655005     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1655006     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1655007     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1655008     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1655009     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1655010     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1655011     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1655012     2  0.0000      0.999  0 1.000 0.000 0.000
#> SRR1655013     2  0.0000      0.999  0 1.000 0.000 0.000
#> SRR1655014     2  0.0000      0.999  0 1.000 0.000 0.000
#> SRR1655015     2  0.0000      0.999  0 1.000 0.000 0.000
#> SRR1655016     2  0.0000      0.999  0 1.000 0.000 0.000
#> SRR1655017     2  0.0000      0.999  0 1.000 0.000 0.000
#> SRR1655018     2  0.0000      0.999  0 1.000 0.000 0.000
#> SRR1655019     2  0.0000      0.999  0 1.000 0.000 0.000
#> SRR1655020     2  0.0000      0.999  0 1.000 0.000 0.000
#> SRR1655021     2  0.0000      0.999  0 1.000 0.000 0.000
#> SRR1655022     2  0.0000      0.999  0 1.000 0.000 0.000
#> SRR1655023     2  0.0000      0.999  0 1.000 0.000 0.000
#> SRR1655024     2  0.0000      0.999  0 1.000 0.000 0.000
#> SRR1655025     2  0.0000      0.999  0 1.000 0.000 0.000
#> SRR1655026     4  0.1867      0.949  0 0.072 0.000 0.928
#> SRR1655027     4  0.1792      0.950  0 0.068 0.000 0.932
#> SRR1655028     4  0.1792      0.950  0 0.068 0.000 0.932
#> SRR1655029     4  0.1792      0.950  0 0.068 0.000 0.932
#> SRR1655030     4  0.1940      0.946  0 0.076 0.000 0.924
#> SRR1655031     4  0.1867      0.949  0 0.072 0.000 0.928
#> SRR1655032     4  0.1940      0.946  0 0.076 0.000 0.924
#> SRR1655033     4  0.1940      0.946  0 0.076 0.000 0.924
#> SRR1655034     3  0.0336      1.000  0 0.000 0.992 0.008
#> SRR1655035     3  0.0336      1.000  0 0.000 0.992 0.008
#> SRR1655036     3  0.0336      1.000  0 0.000 0.992 0.008
#> SRR1655037     3  0.0336      1.000  0 0.000 0.992 0.008
#> SRR1655038     3  0.0336      1.000  0 0.000 0.992 0.008
#> SRR1655039     3  0.0336      1.000  0 0.000 0.992 0.008
#> SRR1655040     3  0.0336      1.000  0 0.000 0.992 0.008
#> SRR1655041     3  0.0336      1.000  0 0.000 0.992 0.008
#> SRR1655042     2  0.0000      0.999  0 1.000 0.000 0.000
#> SRR1655043     2  0.0000      0.999  0 1.000 0.000 0.000
#> SRR1655044     2  0.0188      0.995  0 0.996 0.000 0.004
#> SRR1655045     2  0.0336      0.991  0 0.992 0.000 0.008
#> SRR1655046     2  0.0000      0.999  0 1.000 0.000 0.000
#> SRR1655047     2  0.0000      0.999  0 1.000 0.000 0.000
#> SRR1655048     2  0.0000      0.999  0 1.000 0.000 0.000
#> SRR1655049     2  0.0000      0.999  0 1.000 0.000 0.000
#> SRR1655050     4  0.0000      0.951  0 0.000 0.000 1.000
#> SRR1655051     4  0.0000      0.951  0 0.000 0.000 1.000
#> SRR1655052     4  0.0000      0.951  0 0.000 0.000 1.000
#> SRR1655053     4  0.0000      0.951  0 0.000 0.000 1.000
#> SRR1655054     4  0.0000      0.951  0 0.000 0.000 1.000
#> SRR1655055     4  0.0000      0.951  0 0.000 0.000 1.000
#> SRR1655056     4  0.0000      0.951  0 0.000 0.000 1.000
#> SRR1655057     4  0.0000      0.951  0 0.000 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette p1    p2 p3    p4    p5
#> SRR1655002     1  0.0000      1.000  1 0.000  0 0.000 0.000
#> SRR1655003     1  0.0000      1.000  1 0.000  0 0.000 0.000
#> SRR1655004     1  0.0000      1.000  1 0.000  0 0.000 0.000
#> SRR1655005     1  0.0000      1.000  1 0.000  0 0.000 0.000
#> SRR1655006     1  0.0000      1.000  1 0.000  0 0.000 0.000
#> SRR1655007     1  0.0000      1.000  1 0.000  0 0.000 0.000
#> SRR1655008     1  0.0000      1.000  1 0.000  0 0.000 0.000
#> SRR1655009     1  0.0000      1.000  1 0.000  0 0.000 0.000
#> SRR1655010     1  0.0000      1.000  1 0.000  0 0.000 0.000
#> SRR1655011     1  0.0000      1.000  1 0.000  0 0.000 0.000
#> SRR1655012     2  0.0510      0.996  0 0.984  0 0.016 0.000
#> SRR1655013     2  0.0510      0.996  0 0.984  0 0.016 0.000
#> SRR1655014     2  0.0000      0.987  0 1.000  0 0.000 0.000
#> SRR1655015     2  0.0000      0.987  0 1.000  0 0.000 0.000
#> SRR1655016     2  0.0510      0.996  0 0.984  0 0.016 0.000
#> SRR1655017     2  0.0510      0.996  0 0.984  0 0.016 0.000
#> SRR1655018     2  0.0162      0.990  0 0.996  0 0.004 0.000
#> SRR1655019     2  0.0162      0.990  0 0.996  0 0.004 0.000
#> SRR1655020     2  0.0510      0.996  0 0.984  0 0.016 0.000
#> SRR1655021     2  0.0510      0.996  0 0.984  0 0.016 0.000
#> SRR1655022     2  0.0510      0.996  0 0.984  0 0.016 0.000
#> SRR1655023     2  0.0510      0.996  0 0.984  0 0.016 0.000
#> SRR1655024     2  0.0510      0.996  0 0.984  0 0.016 0.000
#> SRR1655025     2  0.0510      0.996  0 0.984  0 0.016 0.000
#> SRR1655026     4  0.4541      0.748  0 0.032  0 0.680 0.288
#> SRR1655027     4  0.4562      0.744  0 0.032  0 0.676 0.292
#> SRR1655028     4  0.4498      0.753  0 0.032  0 0.688 0.280
#> SRR1655029     4  0.4541      0.748  0 0.032  0 0.680 0.288
#> SRR1655030     4  0.4661      0.722  0 0.032  0 0.656 0.312
#> SRR1655031     4  0.4661      0.722  0 0.032  0 0.656 0.312
#> SRR1655032     4  0.4302      0.768  0 0.032  0 0.720 0.248
#> SRR1655033     4  0.4248      0.770  0 0.032  0 0.728 0.240
#> SRR1655034     3  0.0000      1.000  0 0.000  1 0.000 0.000
#> SRR1655035     3  0.0000      1.000  0 0.000  1 0.000 0.000
#> SRR1655036     3  0.0000      1.000  0 0.000  1 0.000 0.000
#> SRR1655037     3  0.0000      1.000  0 0.000  1 0.000 0.000
#> SRR1655038     3  0.0000      1.000  0 0.000  1 0.000 0.000
#> SRR1655039     3  0.0000      1.000  0 0.000  1 0.000 0.000
#> SRR1655040     3  0.0000      1.000  0 0.000  1 0.000 0.000
#> SRR1655041     3  0.0000      1.000  0 0.000  1 0.000 0.000
#> SRR1655042     4  0.1608      0.809  0 0.072  0 0.928 0.000
#> SRR1655043     4  0.1608      0.809  0 0.072  0 0.928 0.000
#> SRR1655044     4  0.1608      0.809  0 0.072  0 0.928 0.000
#> SRR1655045     4  0.1608      0.809  0 0.072  0 0.928 0.000
#> SRR1655046     4  0.1608      0.809  0 0.072  0 0.928 0.000
#> SRR1655047     4  0.1608      0.809  0 0.072  0 0.928 0.000
#> SRR1655048     4  0.1671      0.807  0 0.076  0 0.924 0.000
#> SRR1655049     4  0.1671      0.807  0 0.076  0 0.924 0.000
#> SRR1655050     5  0.0000      1.000  0 0.000  0 0.000 1.000
#> SRR1655051     5  0.0000      1.000  0 0.000  0 0.000 1.000
#> SRR1655052     5  0.0000      1.000  0 0.000  0 0.000 1.000
#> SRR1655053     5  0.0000      1.000  0 0.000  0 0.000 1.000
#> SRR1655054     5  0.0000      1.000  0 0.000  0 0.000 1.000
#> SRR1655055     5  0.0000      1.000  0 0.000  0 0.000 1.000
#> SRR1655056     5  0.0000      1.000  0 0.000  0 0.000 1.000
#> SRR1655057     5  0.0000      1.000  0 0.000  0 0.000 1.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
#> SRR1655002     1  0.0146      0.998 0.996 0.000 0.000 0.004 0.000 0.000
#> SRR1655003     1  0.0000      0.999 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1655004     1  0.0000      0.999 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1655005     1  0.0000      0.999 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1655006     1  0.0146      0.998 0.996 0.000 0.000 0.004 0.000 0.000
#> SRR1655007     1  0.0000      0.999 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1655008     1  0.0000      0.999 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1655009     1  0.0000      0.999 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1655010     1  0.0146      0.998 0.996 0.000 0.000 0.004 0.000 0.000
#> SRR1655011     1  0.0146      0.998 0.996 0.000 0.000 0.004 0.000 0.000
#> SRR1655012     2  0.0291      0.995 0.000 0.992 0.000 0.004 0.000 0.004
#> SRR1655013     2  0.0291      0.995 0.000 0.992 0.000 0.004 0.000 0.004
#> SRR1655014     2  0.0000      0.995 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1655015     2  0.0000      0.995 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1655016     2  0.0508      0.988 0.000 0.984 0.000 0.012 0.000 0.004
#> SRR1655017     2  0.0405      0.992 0.000 0.988 0.000 0.008 0.000 0.004
#> SRR1655018     2  0.0146      0.992 0.000 0.996 0.000 0.004 0.000 0.000
#> SRR1655019     2  0.0146      0.992 0.000 0.996 0.000 0.004 0.000 0.000
#> SRR1655020     2  0.0146      0.996 0.000 0.996 0.000 0.000 0.000 0.004
#> SRR1655021     2  0.0146      0.996 0.000 0.996 0.000 0.000 0.000 0.004
#> SRR1655022     2  0.0146      0.996 0.000 0.996 0.000 0.000 0.000 0.004
#> SRR1655023     2  0.0146      0.996 0.000 0.996 0.000 0.000 0.000 0.004
#> SRR1655024     2  0.0146      0.996 0.000 0.996 0.000 0.000 0.000 0.004
#> SRR1655025     2  0.0146      0.996 0.000 0.996 0.000 0.000 0.000 0.004
#> SRR1655026     4  0.2474      0.998 0.000 0.080 0.000 0.880 0.040 0.000
#> SRR1655027     4  0.2474      0.998 0.000 0.080 0.000 0.880 0.040 0.000
#> SRR1655028     4  0.2474      0.998 0.000 0.080 0.000 0.880 0.040 0.000
#> SRR1655029     4  0.2474      0.998 0.000 0.080 0.000 0.880 0.040 0.000
#> SRR1655030     4  0.2474      0.998 0.000 0.080 0.000 0.880 0.040 0.000
#> SRR1655031     4  0.2488      0.994 0.000 0.076 0.000 0.880 0.044 0.000
#> SRR1655032     4  0.2617      0.996 0.000 0.080 0.000 0.876 0.040 0.004
#> SRR1655033     4  0.2617      0.996 0.000 0.080 0.000 0.876 0.040 0.004
#> SRR1655034     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1655035     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1655036     3  0.0291      0.995 0.000 0.000 0.992 0.004 0.000 0.004
#> SRR1655037     3  0.0291      0.995 0.000 0.000 0.992 0.004 0.000 0.004
#> SRR1655038     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1655039     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1655040     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1655041     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1655042     6  0.2218      0.997 0.000 0.012 0.000 0.104 0.000 0.884
#> SRR1655043     6  0.2218      0.997 0.000 0.012 0.000 0.104 0.000 0.884
#> SRR1655044     6  0.2218      0.997 0.000 0.012 0.000 0.104 0.000 0.884
#> SRR1655045     6  0.2218      0.997 0.000 0.012 0.000 0.104 0.000 0.884
#> SRR1655046     6  0.2218      0.997 0.000 0.012 0.000 0.104 0.000 0.884
#> SRR1655047     6  0.2218      0.997 0.000 0.012 0.000 0.104 0.000 0.884
#> SRR1655048     6  0.2214      0.992 0.000 0.016 0.000 0.096 0.000 0.888
#> SRR1655049     6  0.2214      0.992 0.000 0.016 0.000 0.096 0.000 0.888
#> SRR1655050     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1655051     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1655052     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1655053     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1655054     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1655055     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1655056     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1655057     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.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 15837 rows and 56 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 1.000           1.000       1.000         0.2994 0.701   0.701
#> 3 3 0.803           0.957       0.977         0.7209 0.803   0.719
#> 4 4 0.855           0.977       0.973         0.2654 0.844   0.691
#> 5 5 0.886           0.969       0.973         0.2084 0.855   0.582
#> 6 6 0.933           0.970       0.969         0.0623 0.958   0.795

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

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
#> SRR1655002     1       0          1  1  0
#> SRR1655003     1       0          1  1  0
#> SRR1655004     1       0          1  1  0
#> SRR1655005     1       0          1  1  0
#> SRR1655006     1       0          1  1  0
#> SRR1655007     1       0          1  1  0
#> SRR1655008     1       0          1  1  0
#> SRR1655009     1       0          1  1  0
#> SRR1655010     1       0          1  1  0
#> SRR1655011     1       0          1  1  0
#> SRR1655012     2       0          1  0  1
#> SRR1655013     2       0          1  0  1
#> SRR1655014     2       0          1  0  1
#> SRR1655015     2       0          1  0  1
#> SRR1655016     2       0          1  0  1
#> SRR1655017     2       0          1  0  1
#> SRR1655018     2       0          1  0  1
#> SRR1655019     2       0          1  0  1
#> SRR1655020     2       0          1  0  1
#> SRR1655021     2       0          1  0  1
#> SRR1655022     2       0          1  0  1
#> SRR1655023     2       0          1  0  1
#> SRR1655024     2       0          1  0  1
#> SRR1655025     2       0          1  0  1
#> SRR1655026     2       0          1  0  1
#> SRR1655027     2       0          1  0  1
#> SRR1655028     2       0          1  0  1
#> SRR1655029     2       0          1  0  1
#> SRR1655030     2       0          1  0  1
#> SRR1655031     2       0          1  0  1
#> SRR1655032     2       0          1  0  1
#> SRR1655033     2       0          1  0  1
#> SRR1655034     2       0          1  0  1
#> SRR1655035     2       0          1  0  1
#> SRR1655036     2       0          1  0  1
#> SRR1655037     2       0          1  0  1
#> SRR1655038     2       0          1  0  1
#> SRR1655039     2       0          1  0  1
#> SRR1655040     2       0          1  0  1
#> SRR1655041     2       0          1  0  1
#> SRR1655042     2       0          1  0  1
#> SRR1655043     2       0          1  0  1
#> SRR1655044     2       0          1  0  1
#> SRR1655045     2       0          1  0  1
#> SRR1655046     2       0          1  0  1
#> SRR1655047     2       0          1  0  1
#> SRR1655048     2       0          1  0  1
#> SRR1655049     2       0          1  0  1
#> SRR1655050     2       0          1  0  1
#> SRR1655051     2       0          1  0  1
#> SRR1655052     2       0          1  0  1
#> SRR1655053     2       0          1  0  1
#> SRR1655054     2       0          1  0  1
#> SRR1655055     2       0          1  0  1
#> SRR1655056     2       0          1  0  1
#> SRR1655057     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
#> SRR1655002     1   0.000      1.000  1 0.000 0.000
#> SRR1655003     1   0.000      1.000  1 0.000 0.000
#> SRR1655004     1   0.000      1.000  1 0.000 0.000
#> SRR1655005     1   0.000      1.000  1 0.000 0.000
#> SRR1655006     1   0.000      1.000  1 0.000 0.000
#> SRR1655007     1   0.000      1.000  1 0.000 0.000
#> SRR1655008     1   0.000      1.000  1 0.000 0.000
#> SRR1655009     1   0.000      1.000  1 0.000 0.000
#> SRR1655010     1   0.000      1.000  1 0.000 0.000
#> SRR1655011     1   0.000      1.000  1 0.000 0.000
#> SRR1655012     2   0.000      0.963  0 1.000 0.000
#> SRR1655013     2   0.000      0.963  0 1.000 0.000
#> SRR1655014     2   0.000      0.963  0 1.000 0.000
#> SRR1655015     2   0.000      0.963  0 1.000 0.000
#> SRR1655016     2   0.000      0.963  0 1.000 0.000
#> SRR1655017     2   0.000      0.963  0 1.000 0.000
#> SRR1655018     2   0.000      0.963  0 1.000 0.000
#> SRR1655019     2   0.000      0.963  0 1.000 0.000
#> SRR1655020     2   0.000      0.963  0 1.000 0.000
#> SRR1655021     2   0.000      0.963  0 1.000 0.000
#> SRR1655022     2   0.000      0.963  0 1.000 0.000
#> SRR1655023     2   0.000      0.963  0 1.000 0.000
#> SRR1655024     2   0.000      0.963  0 1.000 0.000
#> SRR1655025     2   0.000      0.963  0 1.000 0.000
#> SRR1655026     2   0.000      0.963  0 1.000 0.000
#> SRR1655027     2   0.000      0.963  0 1.000 0.000
#> SRR1655028     2   0.000      0.963  0 1.000 0.000
#> SRR1655029     2   0.000      0.963  0 1.000 0.000
#> SRR1655030     2   0.000      0.963  0 1.000 0.000
#> SRR1655031     2   0.000      0.963  0 1.000 0.000
#> SRR1655032     2   0.000      0.963  0 1.000 0.000
#> SRR1655033     2   0.000      0.963  0 1.000 0.000
#> SRR1655034     3   0.000      1.000  0 0.000 1.000
#> SRR1655035     3   0.000      1.000  0 0.000 1.000
#> SRR1655036     3   0.000      1.000  0 0.000 1.000
#> SRR1655037     3   0.000      1.000  0 0.000 1.000
#> SRR1655038     3   0.000      1.000  0 0.000 1.000
#> SRR1655039     3   0.000      1.000  0 0.000 1.000
#> SRR1655040     3   0.000      1.000  0 0.000 1.000
#> SRR1655041     3   0.000      1.000  0 0.000 1.000
#> SRR1655042     2   0.000      0.963  0 1.000 0.000
#> SRR1655043     2   0.000      0.963  0 1.000 0.000
#> SRR1655044     2   0.000      0.963  0 1.000 0.000
#> SRR1655045     2   0.000      0.963  0 1.000 0.000
#> SRR1655046     2   0.000      0.963  0 1.000 0.000
#> SRR1655047     2   0.000      0.963  0 1.000 0.000
#> SRR1655048     2   0.000      0.963  0 1.000 0.000
#> SRR1655049     2   0.000      0.963  0 1.000 0.000
#> SRR1655050     2   0.406      0.841  0 0.836 0.164
#> SRR1655051     2   0.406      0.841  0 0.836 0.164
#> SRR1655052     2   0.406      0.841  0 0.836 0.164
#> SRR1655053     2   0.406      0.841  0 0.836 0.164
#> SRR1655054     2   0.406      0.841  0 0.836 0.164
#> SRR1655055     2   0.406      0.841  0 0.836 0.164
#> SRR1655056     2   0.406      0.841  0 0.836 0.164
#> SRR1655057     2   0.406      0.841  0 0.836 0.164

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette p1    p2 p3    p4
#> SRR1655002     1   0.000      1.000  1 0.000  0 0.000
#> SRR1655003     1   0.000      1.000  1 0.000  0 0.000
#> SRR1655004     1   0.000      1.000  1 0.000  0 0.000
#> SRR1655005     1   0.000      1.000  1 0.000  0 0.000
#> SRR1655006     1   0.000      1.000  1 0.000  0 0.000
#> SRR1655007     1   0.000      1.000  1 0.000  0 0.000
#> SRR1655008     1   0.000      1.000  1 0.000  0 0.000
#> SRR1655009     1   0.000      1.000  1 0.000  0 0.000
#> SRR1655010     1   0.000      1.000  1 0.000  0 0.000
#> SRR1655011     1   0.000      1.000  1 0.000  0 0.000
#> SRR1655012     2   0.187      0.919  0 0.928  0 0.072
#> SRR1655013     2   0.187      0.919  0 0.928  0 0.072
#> SRR1655014     2   0.187      0.919  0 0.928  0 0.072
#> SRR1655015     2   0.187      0.919  0 0.928  0 0.072
#> SRR1655016     2   0.187      0.919  0 0.928  0 0.072
#> SRR1655017     2   0.187      0.919  0 0.928  0 0.072
#> SRR1655018     2   0.000      0.964  0 1.000  0 0.000
#> SRR1655019     2   0.000      0.964  0 1.000  0 0.000
#> SRR1655020     2   0.000      0.964  0 1.000  0 0.000
#> SRR1655021     2   0.000      0.964  0 1.000  0 0.000
#> SRR1655022     2   0.000      0.964  0 1.000  0 0.000
#> SRR1655023     2   0.000      0.964  0 1.000  0 0.000
#> SRR1655024     2   0.000      0.964  0 1.000  0 0.000
#> SRR1655025     2   0.000      0.964  0 1.000  0 0.000
#> SRR1655026     2   0.102      0.968  0 0.968  0 0.032
#> SRR1655027     2   0.102      0.968  0 0.968  0 0.032
#> SRR1655028     2   0.102      0.968  0 0.968  0 0.032
#> SRR1655029     2   0.102      0.968  0 0.968  0 0.032
#> SRR1655030     2   0.102      0.968  0 0.968  0 0.032
#> SRR1655031     2   0.102      0.968  0 0.968  0 0.032
#> SRR1655032     2   0.102      0.968  0 0.968  0 0.032
#> SRR1655033     2   0.102      0.968  0 0.968  0 0.032
#> SRR1655034     3   0.000      1.000  0 0.000  1 0.000
#> SRR1655035     3   0.000      1.000  0 0.000  1 0.000
#> SRR1655036     3   0.000      1.000  0 0.000  1 0.000
#> SRR1655037     3   0.000      1.000  0 0.000  1 0.000
#> SRR1655038     3   0.000      1.000  0 0.000  1 0.000
#> SRR1655039     3   0.000      1.000  0 0.000  1 0.000
#> SRR1655040     3   0.000      1.000  0 0.000  1 0.000
#> SRR1655041     3   0.000      1.000  0 0.000  1 0.000
#> SRR1655042     2   0.102      0.968  0 0.968  0 0.032
#> SRR1655043     2   0.102      0.968  0 0.968  0 0.032
#> SRR1655044     2   0.102      0.968  0 0.968  0 0.032
#> SRR1655045     2   0.102      0.968  0 0.968  0 0.032
#> SRR1655046     2   0.102      0.968  0 0.968  0 0.032
#> SRR1655047     2   0.102      0.968  0 0.968  0 0.032
#> SRR1655048     2   0.102      0.968  0 0.968  0 0.032
#> SRR1655049     2   0.102      0.968  0 0.968  0 0.032
#> SRR1655050     4   0.187      1.000  0 0.072  0 0.928
#> SRR1655051     4   0.187      1.000  0 0.072  0 0.928
#> SRR1655052     4   0.187      1.000  0 0.072  0 0.928
#> SRR1655053     4   0.187      1.000  0 0.072  0 0.928
#> SRR1655054     4   0.187      1.000  0 0.072  0 0.928
#> SRR1655055     4   0.187      1.000  0 0.072  0 0.928
#> SRR1655056     4   0.187      1.000  0 0.072  0 0.928
#> SRR1655057     4   0.187      1.000  0 0.072  0 0.928

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette p1    p2 p3    p4 p5
#> SRR1655002     1     0.0      1.000  1 0.000  0 0.000  0
#> SRR1655003     1     0.0      1.000  1 0.000  0 0.000  0
#> SRR1655004     1     0.0      1.000  1 0.000  0 0.000  0
#> SRR1655005     1     0.0      1.000  1 0.000  0 0.000  0
#> SRR1655006     1     0.0      1.000  1 0.000  0 0.000  0
#> SRR1655007     1     0.0      1.000  1 0.000  0 0.000  0
#> SRR1655008     1     0.0      1.000  1 0.000  0 0.000  0
#> SRR1655009     1     0.0      1.000  1 0.000  0 0.000  0
#> SRR1655010     1     0.0      1.000  1 0.000  0 0.000  0
#> SRR1655011     1     0.0      1.000  1 0.000  0 0.000  0
#> SRR1655012     2     0.0      0.856  0 1.000  0 0.000  0
#> SRR1655013     2     0.0      0.856  0 1.000  0 0.000  0
#> SRR1655014     2     0.0      0.856  0 1.000  0 0.000  0
#> SRR1655015     2     0.0      0.856  0 1.000  0 0.000  0
#> SRR1655016     2     0.0      0.856  0 1.000  0 0.000  0
#> SRR1655017     2     0.0      0.856  0 1.000  0 0.000  0
#> SRR1655018     2     0.3      0.893  0 0.812  0 0.188  0
#> SRR1655019     2     0.3      0.893  0 0.812  0 0.188  0
#> SRR1655020     2     0.3      0.893  0 0.812  0 0.188  0
#> SRR1655021     2     0.3      0.893  0 0.812  0 0.188  0
#> SRR1655022     2     0.3      0.893  0 0.812  0 0.188  0
#> SRR1655023     2     0.3      0.893  0 0.812  0 0.188  0
#> SRR1655024     2     0.3      0.893  0 0.812  0 0.188  0
#> SRR1655025     2     0.3      0.893  0 0.812  0 0.188  0
#> SRR1655026     4     0.0      1.000  0 0.000  0 1.000  0
#> SRR1655027     4     0.0      1.000  0 0.000  0 1.000  0
#> SRR1655028     4     0.0      1.000  0 0.000  0 1.000  0
#> SRR1655029     4     0.0      1.000  0 0.000  0 1.000  0
#> SRR1655030     4     0.0      1.000  0 0.000  0 1.000  0
#> SRR1655031     4     0.0      1.000  0 0.000  0 1.000  0
#> SRR1655032     4     0.0      1.000  0 0.000  0 1.000  0
#> SRR1655033     4     0.0      1.000  0 0.000  0 1.000  0
#> SRR1655034     3     0.0      1.000  0 0.000  1 0.000  0
#> SRR1655035     3     0.0      1.000  0 0.000  1 0.000  0
#> SRR1655036     3     0.0      1.000  0 0.000  1 0.000  0
#> SRR1655037     3     0.0      1.000  0 0.000  1 0.000  0
#> SRR1655038     3     0.0      1.000  0 0.000  1 0.000  0
#> SRR1655039     3     0.0      1.000  0 0.000  1 0.000  0
#> SRR1655040     3     0.0      1.000  0 0.000  1 0.000  0
#> SRR1655041     3     0.0      1.000  0 0.000  1 0.000  0
#> SRR1655042     4     0.0      1.000  0 0.000  0 1.000  0
#> SRR1655043     4     0.0      1.000  0 0.000  0 1.000  0
#> SRR1655044     4     0.0      1.000  0 0.000  0 1.000  0
#> SRR1655045     4     0.0      1.000  0 0.000  0 1.000  0
#> SRR1655046     4     0.0      1.000  0 0.000  0 1.000  0
#> SRR1655047     4     0.0      1.000  0 0.000  0 1.000  0
#> SRR1655048     4     0.0      1.000  0 0.000  0 1.000  0
#> SRR1655049     4     0.0      1.000  0 0.000  0 1.000  0
#> SRR1655050     5     0.0      1.000  0 0.000  0 0.000  1
#> SRR1655051     5     0.0      1.000  0 0.000  0 0.000  1
#> SRR1655052     5     0.0      1.000  0 0.000  0 0.000  1
#> SRR1655053     5     0.0      1.000  0 0.000  0 0.000  1
#> SRR1655054     5     0.0      1.000  0 0.000  0 0.000  1
#> SRR1655055     5     0.0      1.000  0 0.000  0 0.000  1
#> SRR1655056     5     0.0      1.000  0 0.000  0 0.000  1
#> SRR1655057     5     0.0      1.000  0 0.000  0 0.000  1

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette p1    p2 p3    p4 p5    p6
#> SRR1655002     1  0.0000      1.000  1 0.000  0 0.000  0 0.000
#> SRR1655003     1  0.0000      1.000  1 0.000  0 0.000  0 0.000
#> SRR1655004     1  0.0000      1.000  1 0.000  0 0.000  0 0.000
#> SRR1655005     1  0.0000      1.000  1 0.000  0 0.000  0 0.000
#> SRR1655006     1  0.0000      1.000  1 0.000  0 0.000  0 0.000
#> SRR1655007     1  0.0000      1.000  1 0.000  0 0.000  0 0.000
#> SRR1655008     1  0.0000      1.000  1 0.000  0 0.000  0 0.000
#> SRR1655009     1  0.0000      1.000  1 0.000  0 0.000  0 0.000
#> SRR1655010     1  0.0000      1.000  1 0.000  0 0.000  0 0.000
#> SRR1655011     1  0.0000      1.000  1 0.000  0 0.000  0 0.000
#> SRR1655012     2  0.0000      0.868  0 1.000  0 0.000  0 0.000
#> SRR1655013     2  0.0000      0.868  0 1.000  0 0.000  0 0.000
#> SRR1655014     2  0.0363      0.863  0 0.988  0 0.012  0 0.000
#> SRR1655015     2  0.0363      0.863  0 0.988  0 0.012  0 0.000
#> SRR1655016     2  0.0000      0.868  0 1.000  0 0.000  0 0.000
#> SRR1655017     2  0.0000      0.868  0 1.000  0 0.000  0 0.000
#> SRR1655018     2  0.2805      0.894  0 0.812  0 0.004  0 0.184
#> SRR1655019     2  0.2805      0.894  0 0.812  0 0.004  0 0.184
#> SRR1655020     2  0.2805      0.894  0 0.812  0 0.004  0 0.184
#> SRR1655021     2  0.2805      0.894  0 0.812  0 0.004  0 0.184
#> SRR1655022     2  0.2805      0.894  0 0.812  0 0.004  0 0.184
#> SRR1655023     2  0.2805      0.894  0 0.812  0 0.004  0 0.184
#> SRR1655024     2  0.2805      0.894  0 0.812  0 0.004  0 0.184
#> SRR1655025     2  0.2805      0.894  0 0.812  0 0.004  0 0.184
#> SRR1655026     4  0.0363      1.000  0 0.000  0 0.988  0 0.012
#> SRR1655027     4  0.0363      1.000  0 0.000  0 0.988  0 0.012
#> SRR1655028     4  0.0363      1.000  0 0.000  0 0.988  0 0.012
#> SRR1655029     4  0.0363      1.000  0 0.000  0 0.988  0 0.012
#> SRR1655030     4  0.0363      1.000  0 0.000  0 0.988  0 0.012
#> SRR1655031     4  0.0363      1.000  0 0.000  0 0.988  0 0.012
#> SRR1655032     4  0.0363      1.000  0 0.000  0 0.988  0 0.012
#> SRR1655033     4  0.0363      1.000  0 0.000  0 0.988  0 0.012
#> SRR1655034     3  0.0000      1.000  0 0.000  1 0.000  0 0.000
#> SRR1655035     3  0.0000      1.000  0 0.000  1 0.000  0 0.000
#> SRR1655036     3  0.0000      1.000  0 0.000  1 0.000  0 0.000
#> SRR1655037     3  0.0000      1.000  0 0.000  1 0.000  0 0.000
#> SRR1655038     3  0.0000      1.000  0 0.000  1 0.000  0 0.000
#> SRR1655039     3  0.0000      1.000  0 0.000  1 0.000  0 0.000
#> SRR1655040     3  0.0000      1.000  0 0.000  1 0.000  0 0.000
#> SRR1655041     3  0.0000      1.000  0 0.000  1 0.000  0 0.000
#> SRR1655042     6  0.0000      1.000  0 0.000  0 0.000  0 1.000
#> SRR1655043     6  0.0000      1.000  0 0.000  0 0.000  0 1.000
#> SRR1655044     6  0.0000      1.000  0 0.000  0 0.000  0 1.000
#> SRR1655045     6  0.0000      1.000  0 0.000  0 0.000  0 1.000
#> SRR1655046     6  0.0000      1.000  0 0.000  0 0.000  0 1.000
#> SRR1655047     6  0.0000      1.000  0 0.000  0 0.000  0 1.000
#> SRR1655048     6  0.0000      1.000  0 0.000  0 0.000  0 1.000
#> SRR1655049     6  0.0000      1.000  0 0.000  0 0.000  0 1.000
#> SRR1655050     5  0.0000      1.000  0 0.000  0 0.000  1 0.000
#> SRR1655051     5  0.0000      1.000  0 0.000  0 0.000  1 0.000
#> SRR1655052     5  0.0000      1.000  0 0.000  0 0.000  1 0.000
#> SRR1655053     5  0.0000      1.000  0 0.000  0 0.000  1 0.000
#> SRR1655054     5  0.0000      1.000  0 0.000  0 0.000  1 0.000
#> SRR1655055     5  0.0000      1.000  0 0.000  0 0.000  1 0.000
#> SRR1655056     5  0.0000      1.000  0 0.000  0 0.000  1 0.000
#> SRR1655057     5  0.0000      1.000  0 0.000  0 0.000  1 0.000

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

consensus_heatmap(res, k = 2)

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

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

collect_plots(res)

plot of chunk CV-kmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.983       0.979         0.2963 0.701   0.701
#> 3 3 0.460           0.739       0.813         0.8931 0.688   0.556
#> 4 4 0.490           0.653       0.724         0.2081 0.958   0.893
#> 5 5 0.646           0.786       0.766         0.1130 0.840   0.553
#> 6 6 0.708           0.901       0.748         0.0529 0.944   0.735

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
#> SRR1655002     1   0.343      1.000 0.936 0.064
#> SRR1655003     1   0.343      1.000 0.936 0.064
#> SRR1655004     1   0.343      1.000 0.936 0.064
#> SRR1655005     1   0.343      1.000 0.936 0.064
#> SRR1655006     1   0.343      1.000 0.936 0.064
#> SRR1655007     1   0.343      1.000 0.936 0.064
#> SRR1655008     1   0.343      1.000 0.936 0.064
#> SRR1655009     1   0.343      1.000 0.936 0.064
#> SRR1655010     1   0.343      1.000 0.936 0.064
#> SRR1655011     1   0.343      1.000 0.936 0.064
#> SRR1655012     2   0.000      0.988 0.000 1.000
#> SRR1655013     2   0.000      0.988 0.000 1.000
#> SRR1655014     2   0.000      0.988 0.000 1.000
#> SRR1655015     2   0.000      0.988 0.000 1.000
#> SRR1655016     2   0.000      0.988 0.000 1.000
#> SRR1655017     2   0.000      0.988 0.000 1.000
#> SRR1655018     2   0.000      0.988 0.000 1.000
#> SRR1655019     2   0.000      0.988 0.000 1.000
#> SRR1655020     2   0.000      0.988 0.000 1.000
#> SRR1655021     2   0.000      0.988 0.000 1.000
#> SRR1655022     2   0.000      0.988 0.000 1.000
#> SRR1655023     2   0.000      0.988 0.000 1.000
#> SRR1655024     2   0.000      0.988 0.000 1.000
#> SRR1655025     2   0.000      0.988 0.000 1.000
#> SRR1655026     2   0.000      0.988 0.000 1.000
#> SRR1655027     2   0.000      0.988 0.000 1.000
#> SRR1655028     2   0.000      0.988 0.000 1.000
#> SRR1655029     2   0.000      0.988 0.000 1.000
#> SRR1655030     2   0.000      0.988 0.000 1.000
#> SRR1655031     2   0.000      0.988 0.000 1.000
#> SRR1655032     2   0.000      0.988 0.000 1.000
#> SRR1655033     2   0.000      0.988 0.000 1.000
#> SRR1655034     2   0.343      0.941 0.064 0.936
#> SRR1655035     2   0.343      0.941 0.064 0.936
#> SRR1655036     2   0.343      0.941 0.064 0.936
#> SRR1655037     2   0.343      0.941 0.064 0.936
#> SRR1655038     2   0.343      0.941 0.064 0.936
#> SRR1655039     2   0.343      0.941 0.064 0.936
#> SRR1655040     2   0.343      0.941 0.064 0.936
#> SRR1655041     2   0.343      0.941 0.064 0.936
#> SRR1655042     2   0.000      0.988 0.000 1.000
#> SRR1655043     2   0.000      0.988 0.000 1.000
#> SRR1655044     2   0.000      0.988 0.000 1.000
#> SRR1655045     2   0.000      0.988 0.000 1.000
#> SRR1655046     2   0.000      0.988 0.000 1.000
#> SRR1655047     2   0.000      0.988 0.000 1.000
#> SRR1655048     2   0.000      0.988 0.000 1.000
#> SRR1655049     2   0.000      0.988 0.000 1.000
#> SRR1655050     2   0.000      0.988 0.000 1.000
#> SRR1655051     2   0.000      0.988 0.000 1.000
#> SRR1655052     2   0.000      0.988 0.000 1.000
#> SRR1655053     2   0.000      0.988 0.000 1.000
#> SRR1655054     2   0.000      0.988 0.000 1.000
#> SRR1655055     2   0.000      0.988 0.000 1.000
#> SRR1655056     2   0.000      0.988 0.000 1.000
#> SRR1655057     2   0.000      0.988 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1655002     1  0.0000      0.984 1.000 0.000 0.000
#> SRR1655003     1  0.1860      0.980 0.948 0.000 0.052
#> SRR1655004     1  0.0892      0.984 0.980 0.000 0.020
#> SRR1655005     1  0.1753      0.981 0.952 0.000 0.048
#> SRR1655006     1  0.0000      0.984 1.000 0.000 0.000
#> SRR1655007     1  0.1411      0.984 0.964 0.000 0.036
#> SRR1655008     1  0.1753      0.985 0.952 0.000 0.048
#> SRR1655009     1  0.2066      0.982 0.940 0.000 0.060
#> SRR1655010     1  0.0747      0.984 0.984 0.000 0.016
#> SRR1655011     1  0.0747      0.984 0.984 0.000 0.016
#> SRR1655012     2  0.0424      0.772 0.000 0.992 0.008
#> SRR1655013     2  0.0424      0.772 0.000 0.992 0.008
#> SRR1655014     2  0.0424      0.772 0.000 0.992 0.008
#> SRR1655015     2  0.0424      0.772 0.000 0.992 0.008
#> SRR1655016     2  0.0424      0.772 0.000 0.992 0.008
#> SRR1655017     2  0.0424      0.772 0.000 0.992 0.008
#> SRR1655018     2  0.0237      0.774 0.000 0.996 0.004
#> SRR1655019     2  0.0237      0.774 0.000 0.996 0.004
#> SRR1655020     2  0.0237      0.774 0.000 0.996 0.004
#> SRR1655021     2  0.0237      0.774 0.000 0.996 0.004
#> SRR1655022     2  0.0237      0.774 0.000 0.996 0.004
#> SRR1655023     2  0.0237      0.774 0.000 0.996 0.004
#> SRR1655024     2  0.0237      0.774 0.000 0.996 0.004
#> SRR1655025     2  0.0237      0.774 0.000 0.996 0.004
#> SRR1655026     2  0.5968      0.481 0.000 0.636 0.364
#> SRR1655027     2  0.5968      0.481 0.000 0.636 0.364
#> SRR1655028     2  0.5968      0.481 0.000 0.636 0.364
#> SRR1655029     2  0.5968      0.481 0.000 0.636 0.364
#> SRR1655030     2  0.5968      0.481 0.000 0.636 0.364
#> SRR1655031     2  0.5968      0.481 0.000 0.636 0.364
#> SRR1655032     2  0.5968      0.481 0.000 0.636 0.364
#> SRR1655033     2  0.5968      0.481 0.000 0.636 0.364
#> SRR1655034     3  0.3686      0.738 0.000 0.140 0.860
#> SRR1655035     3  0.3686      0.738 0.000 0.140 0.860
#> SRR1655036     3  0.3686      0.738 0.000 0.140 0.860
#> SRR1655037     3  0.3686      0.738 0.000 0.140 0.860
#> SRR1655038     3  0.3686      0.738 0.000 0.140 0.860
#> SRR1655039     3  0.3686      0.738 0.000 0.140 0.860
#> SRR1655040     3  0.3686      0.738 0.000 0.140 0.860
#> SRR1655041     3  0.3686      0.738 0.000 0.140 0.860
#> SRR1655042     2  0.4235      0.748 0.000 0.824 0.176
#> SRR1655043     2  0.4235      0.748 0.000 0.824 0.176
#> SRR1655044     2  0.4235      0.748 0.000 0.824 0.176
#> SRR1655045     2  0.4235      0.748 0.000 0.824 0.176
#> SRR1655046     2  0.4235      0.748 0.000 0.824 0.176
#> SRR1655047     2  0.4235      0.748 0.000 0.824 0.176
#> SRR1655048     2  0.4235      0.748 0.000 0.824 0.176
#> SRR1655049     2  0.4235      0.748 0.000 0.824 0.176
#> SRR1655050     3  0.5926      0.621 0.000 0.356 0.644
#> SRR1655051     3  0.5926      0.621 0.000 0.356 0.644
#> SRR1655052     3  0.5926      0.621 0.000 0.356 0.644
#> SRR1655053     3  0.5926      0.621 0.000 0.356 0.644
#> SRR1655054     3  0.5926      0.621 0.000 0.356 0.644
#> SRR1655055     3  0.5926      0.621 0.000 0.356 0.644
#> SRR1655056     3  0.5926      0.621 0.000 0.356 0.644
#> SRR1655057     3  0.5926      0.621 0.000 0.356 0.644

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1655002     1  0.1792      0.950 0.932 0.000 0.000 0.068
#> SRR1655003     1  0.3335      0.944 0.856 0.000 0.016 0.128
#> SRR1655004     1  0.2611      0.951 0.896 0.000 0.008 0.096
#> SRR1655005     1  0.3335      0.944 0.856 0.000 0.016 0.128
#> SRR1655006     1  0.1792      0.950 0.932 0.000 0.000 0.068
#> SRR1655007     1  0.0927      0.949 0.976 0.000 0.016 0.008
#> SRR1655008     1  0.2197      0.947 0.928 0.000 0.024 0.048
#> SRR1655009     1  0.2466      0.945 0.916 0.000 0.028 0.056
#> SRR1655010     1  0.0469      0.949 0.988 0.000 0.012 0.000
#> SRR1655011     1  0.0469      0.949 0.988 0.000 0.012 0.000
#> SRR1655012     2  0.6653      0.600 0.000 0.548 0.096 0.356
#> SRR1655013     2  0.6653      0.600 0.000 0.548 0.096 0.356
#> SRR1655014     2  0.6653      0.600 0.000 0.548 0.096 0.356
#> SRR1655015     2  0.6653      0.600 0.000 0.548 0.096 0.356
#> SRR1655016     2  0.6653      0.600 0.000 0.548 0.096 0.356
#> SRR1655017     2  0.6653      0.600 0.000 0.548 0.096 0.356
#> SRR1655018     2  0.6336      0.616 0.000 0.608 0.088 0.304
#> SRR1655019     2  0.6336      0.616 0.000 0.608 0.088 0.304
#> SRR1655020     2  0.6336      0.616 0.000 0.608 0.088 0.304
#> SRR1655021     2  0.6336      0.616 0.000 0.608 0.088 0.304
#> SRR1655022     2  0.6336      0.616 0.000 0.608 0.088 0.304
#> SRR1655023     2  0.6336      0.616 0.000 0.608 0.088 0.304
#> SRR1655024     2  0.6336      0.616 0.000 0.608 0.088 0.304
#> SRR1655025     2  0.6336      0.616 0.000 0.608 0.088 0.304
#> SRR1655026     2  0.6637     -0.176 0.000 0.572 0.104 0.324
#> SRR1655027     2  0.6637     -0.176 0.000 0.572 0.104 0.324
#> SRR1655028     2  0.6637     -0.176 0.000 0.572 0.104 0.324
#> SRR1655029     2  0.6637     -0.176 0.000 0.572 0.104 0.324
#> SRR1655030     2  0.6637     -0.176 0.000 0.572 0.104 0.324
#> SRR1655031     2  0.6637     -0.176 0.000 0.572 0.104 0.324
#> SRR1655032     2  0.6637     -0.176 0.000 0.572 0.104 0.324
#> SRR1655033     2  0.6637     -0.176 0.000 0.572 0.104 0.324
#> SRR1655034     3  0.2399      0.982 0.000 0.048 0.920 0.032
#> SRR1655035     3  0.2399      0.982 0.000 0.048 0.920 0.032
#> SRR1655036     3  0.1722      0.978 0.000 0.048 0.944 0.008
#> SRR1655037     3  0.1722      0.978 0.000 0.048 0.944 0.008
#> SRR1655038     3  0.2399      0.982 0.000 0.048 0.920 0.032
#> SRR1655039     3  0.2399      0.982 0.000 0.048 0.920 0.032
#> SRR1655040     3  0.1389      0.981 0.000 0.048 0.952 0.000
#> SRR1655041     3  0.1389      0.981 0.000 0.048 0.952 0.000
#> SRR1655042     2  0.0000      0.518 0.000 1.000 0.000 0.000
#> SRR1655043     2  0.0000      0.518 0.000 1.000 0.000 0.000
#> SRR1655044     2  0.0000      0.518 0.000 1.000 0.000 0.000
#> SRR1655045     2  0.0000      0.518 0.000 1.000 0.000 0.000
#> SRR1655046     2  0.0000      0.518 0.000 1.000 0.000 0.000
#> SRR1655047     2  0.0000      0.518 0.000 1.000 0.000 0.000
#> SRR1655048     2  0.0000      0.518 0.000 1.000 0.000 0.000
#> SRR1655049     2  0.0000      0.518 0.000 1.000 0.000 0.000
#> SRR1655050     4  0.7836      1.000 0.000 0.288 0.304 0.408
#> SRR1655051     4  0.7836      1.000 0.000 0.288 0.304 0.408
#> SRR1655052     4  0.7836      1.000 0.000 0.288 0.304 0.408
#> SRR1655053     4  0.7836      1.000 0.000 0.288 0.304 0.408
#> SRR1655054     4  0.7836      1.000 0.000 0.288 0.304 0.408
#> SRR1655055     4  0.7836      1.000 0.000 0.288 0.304 0.408
#> SRR1655056     4  0.7836      1.000 0.000 0.288 0.304 0.408
#> SRR1655057     4  0.7836      1.000 0.000 0.288 0.304 0.408

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4    p5
#> SRR1655002     1  0.2037      0.943 0.920 0.000 0.012 0.004 0.064
#> SRR1655003     1  0.3407      0.930 0.836 0.000 0.020 0.012 0.132
#> SRR1655004     1  0.2519      0.942 0.884 0.000 0.016 0.000 0.100
#> SRR1655005     1  0.3061      0.934 0.844 0.000 0.020 0.000 0.136
#> SRR1655006     1  0.1942      0.943 0.920 0.000 0.012 0.000 0.068
#> SRR1655007     1  0.1087      0.940 0.968 0.000 0.016 0.008 0.008
#> SRR1655008     1  0.1914      0.939 0.924 0.000 0.016 0.000 0.060
#> SRR1655009     1  0.2079      0.937 0.916 0.000 0.020 0.000 0.064
#> SRR1655010     1  0.0451      0.942 0.988 0.000 0.004 0.008 0.000
#> SRR1655011     1  0.0451      0.942 0.988 0.000 0.004 0.008 0.000
#> SRR1655012     2  0.3242      0.844 0.000 0.816 0.000 0.012 0.172
#> SRR1655013     2  0.3242      0.844 0.000 0.816 0.000 0.012 0.172
#> SRR1655014     2  0.3280      0.844 0.000 0.812 0.000 0.012 0.176
#> SRR1655015     2  0.3280      0.844 0.000 0.812 0.000 0.012 0.176
#> SRR1655016     2  0.3242      0.844 0.000 0.816 0.000 0.012 0.172
#> SRR1655017     2  0.3242      0.844 0.000 0.816 0.000 0.012 0.172
#> SRR1655018     2  0.1043      0.880 0.000 0.960 0.000 0.040 0.000
#> SRR1655019     2  0.1043      0.880 0.000 0.960 0.000 0.040 0.000
#> SRR1655020     2  0.1043      0.880 0.000 0.960 0.000 0.040 0.000
#> SRR1655021     2  0.1043      0.880 0.000 0.960 0.000 0.040 0.000
#> SRR1655022     2  0.1043      0.880 0.000 0.960 0.000 0.040 0.000
#> SRR1655023     2  0.1043      0.880 0.000 0.960 0.000 0.040 0.000
#> SRR1655024     2  0.1043      0.880 0.000 0.960 0.000 0.040 0.000
#> SRR1655025     2  0.1043      0.880 0.000 0.960 0.000 0.040 0.000
#> SRR1655026     4  0.3115      0.543 0.000 0.112 0.036 0.852 0.000
#> SRR1655027     4  0.3115      0.543 0.000 0.112 0.036 0.852 0.000
#> SRR1655028     4  0.3115      0.543 0.000 0.112 0.036 0.852 0.000
#> SRR1655029     4  0.3115      0.543 0.000 0.112 0.036 0.852 0.000
#> SRR1655030     4  0.3115      0.543 0.000 0.112 0.036 0.852 0.000
#> SRR1655031     4  0.3115      0.543 0.000 0.112 0.036 0.852 0.000
#> SRR1655032     4  0.3115      0.543 0.000 0.112 0.036 0.852 0.000
#> SRR1655033     4  0.3115      0.543 0.000 0.112 0.036 0.852 0.000
#> SRR1655034     3  0.3011      0.964 0.000 0.032 0.884 0.048 0.036
#> SRR1655035     3  0.3011      0.964 0.000 0.032 0.884 0.048 0.036
#> SRR1655036     3  0.2450      0.951 0.000 0.032 0.912 0.028 0.028
#> SRR1655037     3  0.2450      0.951 0.000 0.032 0.912 0.028 0.028
#> SRR1655038     3  0.2937      0.964 0.000 0.032 0.888 0.044 0.036
#> SRR1655039     3  0.2937      0.964 0.000 0.032 0.888 0.044 0.036
#> SRR1655040     3  0.1579      0.962 0.000 0.032 0.944 0.024 0.000
#> SRR1655041     3  0.1579      0.962 0.000 0.032 0.944 0.024 0.000
#> SRR1655042     4  0.6935      0.569 0.000 0.340 0.012 0.428 0.220
#> SRR1655043     4  0.6935      0.569 0.000 0.340 0.012 0.428 0.220
#> SRR1655044     4  0.6951      0.568 0.000 0.340 0.012 0.424 0.224
#> SRR1655045     4  0.6951      0.568 0.000 0.340 0.012 0.424 0.224
#> SRR1655046     4  0.6935      0.569 0.000 0.340 0.012 0.428 0.220
#> SRR1655047     4  0.6935      0.569 0.000 0.340 0.012 0.428 0.220
#> SRR1655048     4  0.7009      0.563 0.000 0.344 0.016 0.424 0.216
#> SRR1655049     4  0.7009      0.563 0.000 0.344 0.016 0.424 0.216
#> SRR1655050     4  0.7631     -0.966 0.000 0.052 0.232 0.360 0.356
#> SRR1655051     5  0.7608      0.969 0.000 0.052 0.224 0.360 0.364
#> SRR1655052     5  0.7589      0.993 0.000 0.052 0.224 0.328 0.396
#> SRR1655053     5  0.7589      0.993 0.000 0.052 0.224 0.328 0.396
#> SRR1655054     5  0.7584      0.993 0.000 0.052 0.224 0.324 0.400
#> SRR1655055     5  0.7584      0.993 0.000 0.052 0.224 0.324 0.400
#> SRR1655056     5  0.7584      0.993 0.000 0.052 0.224 0.324 0.400
#> SRR1655057     5  0.7589      0.993 0.000 0.052 0.224 0.328 0.396

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR1655002     1   0.162      0.899 0.936 0.000 0.000 0.040 0.020 0.004
#> SRR1655003     1   0.245      0.885 0.900 0.000 0.004 0.020 0.052 0.024
#> SRR1655004     1   0.000      0.903 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1655005     1   0.199      0.889 0.924 0.000 0.004 0.024 0.036 0.012
#> SRR1655006     1   0.115      0.902 0.956 0.000 0.000 0.032 0.012 0.000
#> SRR1655007     1   0.418      0.900 0.768 0.000 0.008 0.152 0.060 0.012
#> SRR1655008     1   0.386      0.899 0.812 0.000 0.020 0.100 0.056 0.012
#> SRR1655009     1   0.431      0.892 0.780 0.000 0.020 0.112 0.072 0.016
#> SRR1655010     1   0.376      0.900 0.800 0.000 0.008 0.140 0.040 0.012
#> SRR1655011     1   0.376      0.900 0.800 0.000 0.008 0.140 0.040 0.012
#> SRR1655012     2   0.378      0.740 0.000 0.760 0.000 0.188 0.052 0.000
#> SRR1655013     2   0.378      0.740 0.000 0.760 0.000 0.188 0.052 0.000
#> SRR1655014     2   0.405      0.736 0.000 0.756 0.004 0.164 0.076 0.000
#> SRR1655015     2   0.405      0.736 0.000 0.756 0.004 0.164 0.076 0.000
#> SRR1655016     2   0.378      0.740 0.000 0.760 0.000 0.188 0.052 0.000
#> SRR1655017     2   0.378      0.740 0.000 0.760 0.000 0.188 0.052 0.000
#> SRR1655018     2   0.235      0.793 0.000 0.868 0.000 0.000 0.008 0.124
#> SRR1655019     2   0.235      0.793 0.000 0.868 0.000 0.000 0.008 0.124
#> SRR1655020     2   0.223      0.794 0.000 0.872 0.000 0.000 0.004 0.124
#> SRR1655021     2   0.223      0.794 0.000 0.872 0.000 0.000 0.004 0.124
#> SRR1655022     2   0.223      0.794 0.000 0.872 0.000 0.000 0.004 0.124
#> SRR1655023     2   0.223      0.794 0.000 0.872 0.000 0.000 0.004 0.124
#> SRR1655024     2   0.223      0.794 0.000 0.872 0.000 0.000 0.004 0.124
#> SRR1655025     2   0.223      0.794 0.000 0.872 0.000 0.000 0.004 0.124
#> SRR1655026     4   0.752      0.994 0.000 0.072 0.032 0.416 0.216 0.264
#> SRR1655027     4   0.752      0.994 0.000 0.072 0.032 0.416 0.216 0.264
#> SRR1655028     4   0.753      0.994 0.000 0.072 0.032 0.412 0.220 0.264
#> SRR1655029     4   0.753      0.994 0.000 0.072 0.032 0.412 0.220 0.264
#> SRR1655030     4   0.754      0.991 0.000 0.072 0.032 0.408 0.220 0.268
#> SRR1655031     4   0.754      0.991 0.000 0.072 0.032 0.408 0.220 0.268
#> SRR1655032     4   0.754      0.993 0.000 0.072 0.032 0.408 0.220 0.268
#> SRR1655033     4   0.754      0.993 0.000 0.072 0.032 0.408 0.220 0.268
#> SRR1655034     3   0.137      0.911 0.000 0.016 0.952 0.016 0.000 0.016
#> SRR1655035     3   0.137      0.911 0.000 0.016 0.952 0.016 0.000 0.016
#> SRR1655036     3   0.423      0.890 0.000 0.016 0.784 0.120 0.020 0.060
#> SRR1655037     3   0.423      0.890 0.000 0.016 0.784 0.120 0.020 0.060
#> SRR1655038     3   0.117      0.913 0.000 0.016 0.960 0.000 0.016 0.008
#> SRR1655039     3   0.117      0.913 0.000 0.016 0.960 0.000 0.016 0.008
#> SRR1655040     3   0.356      0.909 0.000 0.016 0.840 0.076 0.028 0.040
#> SRR1655041     3   0.356      0.909 0.000 0.016 0.840 0.076 0.028 0.040
#> SRR1655042     6   0.234      0.983 0.000 0.148 0.000 0.000 0.000 0.852
#> SRR1655043     6   0.234      0.983 0.000 0.148 0.000 0.000 0.000 0.852
#> SRR1655044     6   0.259      0.981 0.000 0.148 0.000 0.000 0.008 0.844
#> SRR1655045     6   0.259      0.981 0.000 0.148 0.000 0.000 0.008 0.844
#> SRR1655046     6   0.234      0.983 0.000 0.148 0.000 0.000 0.000 0.852
#> SRR1655047     6   0.234      0.983 0.000 0.148 0.000 0.000 0.000 0.852
#> SRR1655048     6   0.359      0.955 0.000 0.152 0.000 0.028 0.020 0.800
#> SRR1655049     6   0.359      0.955 0.000 0.152 0.000 0.028 0.020 0.800
#> SRR1655050     5   0.610      0.917 0.000 0.024 0.168 0.064 0.636 0.108
#> SRR1655051     5   0.584      0.936 0.000 0.024 0.168 0.048 0.656 0.104
#> SRR1655052     5   0.469      0.974 0.000 0.024 0.168 0.000 0.720 0.088
#> SRR1655053     5   0.469      0.974 0.000 0.024 0.168 0.000 0.720 0.088
#> SRR1655054     5   0.459      0.975 0.000 0.024 0.168 0.000 0.728 0.080
#> SRR1655055     5   0.459      0.975 0.000 0.024 0.168 0.000 0.728 0.080
#> SRR1655056     5   0.459      0.975 0.000 0.024 0.168 0.000 0.728 0.080
#> SRR1655057     5   0.464      0.975 0.000 0.024 0.168 0.000 0.724 0.084

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 15837 rows and 56 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 0.751           0.880       0.947         0.3534 0.701   0.701
#> 3 3 0.647           0.941       0.963         0.7074 0.688   0.556
#> 4 4 0.803           0.913       0.946         0.1908 0.803   0.542
#> 5 5 0.875           0.869       0.916         0.1059 0.844   0.508
#> 6 6 1.000           0.989       0.979         0.0549 0.958   0.795

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
#> SRR1655002     1   0.000      1.000 1.000 0.000
#> SRR1655003     1   0.000      1.000 1.000 0.000
#> SRR1655004     1   0.000      1.000 1.000 0.000
#> SRR1655005     1   0.000      1.000 1.000 0.000
#> SRR1655006     1   0.000      1.000 1.000 0.000
#> SRR1655007     1   0.000      1.000 1.000 0.000
#> SRR1655008     1   0.000      1.000 1.000 0.000
#> SRR1655009     1   0.000      1.000 1.000 0.000
#> SRR1655010     1   0.000      1.000 1.000 0.000
#> SRR1655011     1   0.000      1.000 1.000 0.000
#> SRR1655012     2   0.000      0.929 0.000 1.000
#> SRR1655013     2   0.000      0.929 0.000 1.000
#> SRR1655014     2   0.000      0.929 0.000 1.000
#> SRR1655015     2   0.000      0.929 0.000 1.000
#> SRR1655016     2   0.000      0.929 0.000 1.000
#> SRR1655017     2   0.000      0.929 0.000 1.000
#> SRR1655018     2   0.000      0.929 0.000 1.000
#> SRR1655019     2   0.000      0.929 0.000 1.000
#> SRR1655020     2   0.000      0.929 0.000 1.000
#> SRR1655021     2   0.000      0.929 0.000 1.000
#> SRR1655022     2   0.000      0.929 0.000 1.000
#> SRR1655023     2   0.000      0.929 0.000 1.000
#> SRR1655024     2   0.000      0.929 0.000 1.000
#> SRR1655025     2   0.000      0.929 0.000 1.000
#> SRR1655026     2   0.000      0.929 0.000 1.000
#> SRR1655027     2   0.000      0.929 0.000 1.000
#> SRR1655028     2   0.000      0.929 0.000 1.000
#> SRR1655029     2   0.000      0.929 0.000 1.000
#> SRR1655030     2   0.000      0.929 0.000 1.000
#> SRR1655031     2   0.000      0.929 0.000 1.000
#> SRR1655032     2   0.000      0.929 0.000 1.000
#> SRR1655033     2   0.000      0.929 0.000 1.000
#> SRR1655034     2   0.952      0.500 0.372 0.628
#> SRR1655035     2   0.952      0.500 0.372 0.628
#> SRR1655036     2   0.952      0.500 0.372 0.628
#> SRR1655037     2   0.952      0.500 0.372 0.628
#> SRR1655038     2   0.952      0.500 0.372 0.628
#> SRR1655039     2   0.952      0.500 0.372 0.628
#> SRR1655040     2   0.952      0.500 0.372 0.628
#> SRR1655041     2   0.952      0.500 0.372 0.628
#> SRR1655042     2   0.000      0.929 0.000 1.000
#> SRR1655043     2   0.000      0.929 0.000 1.000
#> SRR1655044     2   0.000      0.929 0.000 1.000
#> SRR1655045     2   0.000      0.929 0.000 1.000
#> SRR1655046     2   0.000      0.929 0.000 1.000
#> SRR1655047     2   0.000      0.929 0.000 1.000
#> SRR1655048     2   0.000      0.929 0.000 1.000
#> SRR1655049     2   0.000      0.929 0.000 1.000
#> SRR1655050     2   0.000      0.929 0.000 1.000
#> SRR1655051     2   0.000      0.929 0.000 1.000
#> SRR1655052     2   0.000      0.929 0.000 1.000
#> SRR1655053     2   0.000      0.929 0.000 1.000
#> SRR1655054     2   0.000      0.929 0.000 1.000
#> SRR1655055     2   0.000      0.929 0.000 1.000
#> SRR1655056     2   0.000      0.929 0.000 1.000
#> SRR1655057     2   0.000      0.929 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
#> SRR1655002     1  0.0000      1.000  1 0.000 0.000
#> SRR1655003     1  0.0000      1.000  1 0.000 0.000
#> SRR1655004     1  0.0000      1.000  1 0.000 0.000
#> SRR1655005     1  0.0000      1.000  1 0.000 0.000
#> SRR1655006     1  0.0000      1.000  1 0.000 0.000
#> SRR1655007     1  0.0000      1.000  1 0.000 0.000
#> SRR1655008     1  0.0000      1.000  1 0.000 0.000
#> SRR1655009     1  0.0000      1.000  1 0.000 0.000
#> SRR1655010     1  0.0000      1.000  1 0.000 0.000
#> SRR1655011     1  0.0000      1.000  1 0.000 0.000
#> SRR1655012     2  0.0424      0.954  0 0.992 0.008
#> SRR1655013     2  0.0424      0.954  0 0.992 0.008
#> SRR1655014     2  0.0424      0.954  0 0.992 0.008
#> SRR1655015     2  0.0424      0.954  0 0.992 0.008
#> SRR1655016     2  0.0424      0.954  0 0.992 0.008
#> SRR1655017     2  0.0424      0.954  0 0.992 0.008
#> SRR1655018     2  0.0424      0.954  0 0.992 0.008
#> SRR1655019     2  0.0424      0.954  0 0.992 0.008
#> SRR1655020     2  0.0424      0.954  0 0.992 0.008
#> SRR1655021     2  0.0424      0.954  0 0.992 0.008
#> SRR1655022     2  0.0424      0.954  0 0.992 0.008
#> SRR1655023     2  0.0424      0.954  0 0.992 0.008
#> SRR1655024     2  0.0424      0.954  0 0.992 0.008
#> SRR1655025     2  0.0424      0.954  0 0.992 0.008
#> SRR1655026     2  0.3619      0.867  0 0.864 0.136
#> SRR1655027     2  0.3619      0.867  0 0.864 0.136
#> SRR1655028     2  0.3619      0.867  0 0.864 0.136
#> SRR1655029     2  0.3619      0.867  0 0.864 0.136
#> SRR1655030     2  0.3619      0.867  0 0.864 0.136
#> SRR1655031     2  0.3619      0.867  0 0.864 0.136
#> SRR1655032     2  0.3619      0.867  0 0.864 0.136
#> SRR1655033     2  0.3619      0.867  0 0.864 0.136
#> SRR1655034     3  0.0000      0.921  0 0.000 1.000
#> SRR1655035     3  0.0000      0.921  0 0.000 1.000
#> SRR1655036     3  0.0000      0.921  0 0.000 1.000
#> SRR1655037     3  0.0000      0.921  0 0.000 1.000
#> SRR1655038     3  0.0000      0.921  0 0.000 1.000
#> SRR1655039     3  0.0000      0.921  0 0.000 1.000
#> SRR1655040     3  0.0000      0.921  0 0.000 1.000
#> SRR1655041     3  0.0000      0.921  0 0.000 1.000
#> SRR1655042     2  0.0000      0.953  0 1.000 0.000
#> SRR1655043     2  0.0000      0.953  0 1.000 0.000
#> SRR1655044     2  0.0000      0.953  0 1.000 0.000
#> SRR1655045     2  0.0000      0.953  0 1.000 0.000
#> SRR1655046     2  0.0000      0.953  0 1.000 0.000
#> SRR1655047     2  0.0000      0.953  0 1.000 0.000
#> SRR1655048     2  0.0000      0.953  0 1.000 0.000
#> SRR1655049     2  0.0000      0.953  0 1.000 0.000
#> SRR1655050     3  0.3192      0.922  0 0.112 0.888
#> SRR1655051     3  0.3192      0.922  0 0.112 0.888
#> SRR1655052     3  0.3192      0.922  0 0.112 0.888
#> SRR1655053     3  0.3192      0.922  0 0.112 0.888
#> SRR1655054     3  0.3192      0.922  0 0.112 0.888
#> SRR1655055     3  0.3192      0.922  0 0.112 0.888
#> SRR1655056     3  0.3192      0.922  0 0.112 0.888
#> SRR1655057     3  0.3192      0.922  0 0.112 0.888

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette p1    p2    p3    p4
#> SRR1655002     1   0.000      1.000  1 0.000 0.000 0.000
#> SRR1655003     1   0.000      1.000  1 0.000 0.000 0.000
#> SRR1655004     1   0.000      1.000  1 0.000 0.000 0.000
#> SRR1655005     1   0.000      1.000  1 0.000 0.000 0.000
#> SRR1655006     1   0.000      1.000  1 0.000 0.000 0.000
#> SRR1655007     1   0.000      1.000  1 0.000 0.000 0.000
#> SRR1655008     1   0.000      1.000  1 0.000 0.000 0.000
#> SRR1655009     1   0.000      1.000  1 0.000 0.000 0.000
#> SRR1655010     1   0.000      1.000  1 0.000 0.000 0.000
#> SRR1655011     1   0.000      1.000  1 0.000 0.000 0.000
#> SRR1655012     2   0.000      0.876  0 1.000 0.000 0.000
#> SRR1655013     2   0.000      0.876  0 1.000 0.000 0.000
#> SRR1655014     2   0.000      0.876  0 1.000 0.000 0.000
#> SRR1655015     2   0.000      0.876  0 1.000 0.000 0.000
#> SRR1655016     2   0.000      0.876  0 1.000 0.000 0.000
#> SRR1655017     2   0.000      0.876  0 1.000 0.000 0.000
#> SRR1655018     2   0.000      0.876  0 1.000 0.000 0.000
#> SRR1655019     2   0.000      0.876  0 1.000 0.000 0.000
#> SRR1655020     2   0.000      0.876  0 1.000 0.000 0.000
#> SRR1655021     2   0.000      0.876  0 1.000 0.000 0.000
#> SRR1655022     2   0.000      0.876  0 1.000 0.000 0.000
#> SRR1655023     2   0.000      0.876  0 1.000 0.000 0.000
#> SRR1655024     2   0.000      0.876  0 1.000 0.000 0.000
#> SRR1655025     2   0.000      0.876  0 1.000 0.000 0.000
#> SRR1655026     4   0.179      0.937  0 0.068 0.000 0.932
#> SRR1655027     4   0.179      0.937  0 0.068 0.000 0.932
#> SRR1655028     4   0.179      0.937  0 0.068 0.000 0.932
#> SRR1655029     4   0.179      0.937  0 0.068 0.000 0.932
#> SRR1655030     4   0.179      0.937  0 0.068 0.000 0.932
#> SRR1655031     4   0.179      0.937  0 0.068 0.000 0.932
#> SRR1655032     4   0.179      0.937  0 0.068 0.000 0.932
#> SRR1655033     4   0.179      0.937  0 0.068 0.000 0.932
#> SRR1655034     3   0.000      1.000  0 0.000 1.000 0.000
#> SRR1655035     3   0.000      1.000  0 0.000 1.000 0.000
#> SRR1655036     3   0.000      1.000  0 0.000 1.000 0.000
#> SRR1655037     3   0.000      1.000  0 0.000 1.000 0.000
#> SRR1655038     3   0.000      1.000  0 0.000 1.000 0.000
#> SRR1655039     3   0.000      1.000  0 0.000 1.000 0.000
#> SRR1655040     3   0.000      1.000  0 0.000 1.000 0.000
#> SRR1655041     3   0.000      1.000  0 0.000 1.000 0.000
#> SRR1655042     2   0.425      0.736  0 0.724 0.000 0.276
#> SRR1655043     2   0.425      0.736  0 0.724 0.000 0.276
#> SRR1655044     2   0.425      0.736  0 0.724 0.000 0.276
#> SRR1655045     2   0.425      0.736  0 0.724 0.000 0.276
#> SRR1655046     2   0.425      0.736  0 0.724 0.000 0.276
#> SRR1655047     2   0.425      0.736  0 0.724 0.000 0.276
#> SRR1655048     2   0.425      0.736  0 0.724 0.000 0.276
#> SRR1655049     2   0.425      0.736  0 0.724 0.000 0.276
#> SRR1655050     4   0.102      0.936  0 0.000 0.032 0.968
#> SRR1655051     4   0.102      0.936  0 0.000 0.032 0.968
#> SRR1655052     4   0.102      0.936  0 0.000 0.032 0.968
#> SRR1655053     4   0.102      0.936  0 0.000 0.032 0.968
#> SRR1655054     4   0.102      0.936  0 0.000 0.032 0.968
#> SRR1655055     4   0.102      0.936  0 0.000 0.032 0.968
#> SRR1655056     4   0.102      0.936  0 0.000 0.032 0.968
#> SRR1655057     4   0.102      0.936  0 0.000 0.032 0.968

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette p1    p2    p3    p4    p5
#> SRR1655002     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1655003     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1655004     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1655005     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1655006     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1655007     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1655008     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1655009     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1655010     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1655011     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1655012     2  0.0000      0.995  0 1.000 0.000 0.000 0.000
#> SRR1655013     2  0.0000      0.995  0 1.000 0.000 0.000 0.000
#> SRR1655014     2  0.0000      0.995  0 1.000 0.000 0.000 0.000
#> SRR1655015     2  0.0000      0.995  0 1.000 0.000 0.000 0.000
#> SRR1655016     2  0.0000      0.995  0 1.000 0.000 0.000 0.000
#> SRR1655017     2  0.0000      0.995  0 1.000 0.000 0.000 0.000
#> SRR1655018     2  0.0290      0.996  0 0.992 0.000 0.008 0.000
#> SRR1655019     2  0.0290      0.996  0 0.992 0.000 0.008 0.000
#> SRR1655020     2  0.0290      0.996  0 0.992 0.000 0.008 0.000
#> SRR1655021     2  0.0290      0.996  0 0.992 0.000 0.008 0.000
#> SRR1655022     2  0.0290      0.996  0 0.992 0.000 0.008 0.000
#> SRR1655023     2  0.0290      0.996  0 0.992 0.000 0.008 0.000
#> SRR1655024     2  0.0290      0.996  0 0.992 0.000 0.008 0.000
#> SRR1655025     2  0.0290      0.996  0 0.992 0.000 0.008 0.000
#> SRR1655026     4  0.4291      0.440  0 0.000 0.000 0.536 0.464
#> SRR1655027     4  0.4291      0.440  0 0.000 0.000 0.536 0.464
#> SRR1655028     4  0.4291      0.440  0 0.000 0.000 0.536 0.464
#> SRR1655029     4  0.4291      0.440  0 0.000 0.000 0.536 0.464
#> SRR1655030     4  0.4291      0.440  0 0.000 0.000 0.536 0.464
#> SRR1655031     4  0.4291      0.440  0 0.000 0.000 0.536 0.464
#> SRR1655032     4  0.4291      0.440  0 0.000 0.000 0.536 0.464
#> SRR1655033     4  0.4291      0.440  0 0.000 0.000 0.536 0.464
#> SRR1655034     3  0.0000      1.000  0 0.000 1.000 0.000 0.000
#> SRR1655035     3  0.0000      1.000  0 0.000 1.000 0.000 0.000
#> SRR1655036     3  0.0000      1.000  0 0.000 1.000 0.000 0.000
#> SRR1655037     3  0.0000      1.000  0 0.000 1.000 0.000 0.000
#> SRR1655038     3  0.0000      1.000  0 0.000 1.000 0.000 0.000
#> SRR1655039     3  0.0000      1.000  0 0.000 1.000 0.000 0.000
#> SRR1655040     3  0.0000      1.000  0 0.000 1.000 0.000 0.000
#> SRR1655041     3  0.0000      1.000  0 0.000 1.000 0.000 0.000
#> SRR1655042     4  0.1965      0.653  0 0.096 0.000 0.904 0.000
#> SRR1655043     4  0.1965      0.653  0 0.096 0.000 0.904 0.000
#> SRR1655044     4  0.1965      0.653  0 0.096 0.000 0.904 0.000
#> SRR1655045     4  0.1965      0.653  0 0.096 0.000 0.904 0.000
#> SRR1655046     4  0.1965      0.653  0 0.096 0.000 0.904 0.000
#> SRR1655047     4  0.1965      0.653  0 0.096 0.000 0.904 0.000
#> SRR1655048     4  0.1965      0.653  0 0.096 0.000 0.904 0.000
#> SRR1655049     4  0.1965      0.653  0 0.096 0.000 0.904 0.000
#> SRR1655050     5  0.0162      1.000  0 0.000 0.004 0.000 0.996
#> SRR1655051     5  0.0162      1.000  0 0.000 0.004 0.000 0.996
#> SRR1655052     5  0.0162      1.000  0 0.000 0.004 0.000 0.996
#> SRR1655053     5  0.0162      1.000  0 0.000 0.004 0.000 0.996
#> SRR1655054     5  0.0162      1.000  0 0.000 0.004 0.000 0.996
#> SRR1655055     5  0.0162      1.000  0 0.000 0.004 0.000 0.996
#> SRR1655056     5  0.0162      1.000  0 0.000 0.004 0.000 0.996
#> SRR1655057     5  0.0162      1.000  0 0.000 0.004 0.000 0.996

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette p1    p2 p3    p4    p5    p6
#> SRR1655002     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR1655003     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR1655004     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR1655005     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR1655006     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR1655007     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR1655008     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR1655009     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR1655010     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR1655011     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR1655012     2  0.1572      0.949  0 0.936  0 0.028 0.000 0.036
#> SRR1655013     2  0.1572      0.949  0 0.936  0 0.028 0.000 0.036
#> SRR1655014     2  0.1572      0.949  0 0.936  0 0.028 0.000 0.036
#> SRR1655015     2  0.1572      0.949  0 0.936  0 0.028 0.000 0.036
#> SRR1655016     2  0.1572      0.949  0 0.936  0 0.028 0.000 0.036
#> SRR1655017     2  0.1572      0.949  0 0.936  0 0.028 0.000 0.036
#> SRR1655018     2  0.0790      0.962  0 0.968  0 0.000 0.000 0.032
#> SRR1655019     2  0.0790      0.962  0 0.968  0 0.000 0.000 0.032
#> SRR1655020     2  0.0790      0.962  0 0.968  0 0.000 0.000 0.032
#> SRR1655021     2  0.0790      0.962  0 0.968  0 0.000 0.000 0.032
#> SRR1655022     2  0.0790      0.962  0 0.968  0 0.000 0.000 0.032
#> SRR1655023     2  0.0790      0.962  0 0.968  0 0.000 0.000 0.032
#> SRR1655024     2  0.0790      0.962  0 0.968  0 0.000 0.000 0.032
#> SRR1655025     2  0.0790      0.962  0 0.968  0 0.000 0.000 0.032
#> SRR1655026     4  0.0713      1.000  0 0.000  0 0.972 0.028 0.000
#> SRR1655027     4  0.0713      1.000  0 0.000  0 0.972 0.028 0.000
#> SRR1655028     4  0.0713      1.000  0 0.000  0 0.972 0.028 0.000
#> SRR1655029     4  0.0713      1.000  0 0.000  0 0.972 0.028 0.000
#> SRR1655030     4  0.0713      1.000  0 0.000  0 0.972 0.028 0.000
#> SRR1655031     4  0.0713      1.000  0 0.000  0 0.972 0.028 0.000
#> SRR1655032     4  0.0713      1.000  0 0.000  0 0.972 0.028 0.000
#> SRR1655033     4  0.0713      1.000  0 0.000  0 0.972 0.028 0.000
#> SRR1655034     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR1655035     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR1655036     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR1655037     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR1655038     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR1655039     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR1655040     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR1655041     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR1655042     6  0.0865      1.000  0 0.000  0 0.036 0.000 0.964
#> SRR1655043     6  0.0865      1.000  0 0.000  0 0.036 0.000 0.964
#> SRR1655044     6  0.0865      1.000  0 0.000  0 0.036 0.000 0.964
#> SRR1655045     6  0.0865      1.000  0 0.000  0 0.036 0.000 0.964
#> SRR1655046     6  0.0865      1.000  0 0.000  0 0.036 0.000 0.964
#> SRR1655047     6  0.0865      1.000  0 0.000  0 0.036 0.000 0.964
#> SRR1655048     6  0.0865      1.000  0 0.000  0 0.036 0.000 0.964
#> SRR1655049     6  0.0865      1.000  0 0.000  0 0.036 0.000 0.964
#> SRR1655050     5  0.0000      1.000  0 0.000  0 0.000 1.000 0.000
#> SRR1655051     5  0.0000      1.000  0 0.000  0 0.000 1.000 0.000
#> SRR1655052     5  0.0000      1.000  0 0.000  0 0.000 1.000 0.000
#> SRR1655053     5  0.0000      1.000  0 0.000  0 0.000 1.000 0.000
#> SRR1655054     5  0.0000      1.000  0 0.000  0 0.000 1.000 0.000
#> SRR1655055     5  0.0000      1.000  0 0.000  0 0.000 1.000 0.000
#> SRR1655056     5  0.0000      1.000  0 0.000  0 0.000 1.000 0.000
#> SRR1655057     5  0.0000      1.000  0 0.000  0 0.000 1.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 15837 rows and 56 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#>   Subgroups are detected by 'pam' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 6.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk CV-pam-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.2994 0.701   0.701
#> 3 3 1.000           1.000       1.000         0.6587 0.803   0.719
#> 4 4 0.830           0.900       0.925         0.4197 0.766   0.536
#> 5 5 0.981           0.934       0.970         0.1099 0.938   0.769
#> 6 6 1.000           1.000       1.000         0.0724 0.932   0.690

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
#> SRR1655002     1       0          1  1  0
#> SRR1655003     1       0          1  1  0
#> SRR1655004     1       0          1  1  0
#> SRR1655005     1       0          1  1  0
#> SRR1655006     1       0          1  1  0
#> SRR1655007     1       0          1  1  0
#> SRR1655008     1       0          1  1  0
#> SRR1655009     1       0          1  1  0
#> SRR1655010     1       0          1  1  0
#> SRR1655011     1       0          1  1  0
#> SRR1655012     2       0          1  0  1
#> SRR1655013     2       0          1  0  1
#> SRR1655014     2       0          1  0  1
#> SRR1655015     2       0          1  0  1
#> SRR1655016     2       0          1  0  1
#> SRR1655017     2       0          1  0  1
#> SRR1655018     2       0          1  0  1
#> SRR1655019     2       0          1  0  1
#> SRR1655020     2       0          1  0  1
#> SRR1655021     2       0          1  0  1
#> SRR1655022     2       0          1  0  1
#> SRR1655023     2       0          1  0  1
#> SRR1655024     2       0          1  0  1
#> SRR1655025     2       0          1  0  1
#> SRR1655026     2       0          1  0  1
#> SRR1655027     2       0          1  0  1
#> SRR1655028     2       0          1  0  1
#> SRR1655029     2       0          1  0  1
#> SRR1655030     2       0          1  0  1
#> SRR1655031     2       0          1  0  1
#> SRR1655032     2       0          1  0  1
#> SRR1655033     2       0          1  0  1
#> SRR1655034     2       0          1  0  1
#> SRR1655035     2       0          1  0  1
#> SRR1655036     2       0          1  0  1
#> SRR1655037     2       0          1  0  1
#> SRR1655038     2       0          1  0  1
#> SRR1655039     2       0          1  0  1
#> SRR1655040     2       0          1  0  1
#> SRR1655041     2       0          1  0  1
#> SRR1655042     2       0          1  0  1
#> SRR1655043     2       0          1  0  1
#> SRR1655044     2       0          1  0  1
#> SRR1655045     2       0          1  0  1
#> SRR1655046     2       0          1  0  1
#> SRR1655047     2       0          1  0  1
#> SRR1655048     2       0          1  0  1
#> SRR1655049     2       0          1  0  1
#> SRR1655050     2       0          1  0  1
#> SRR1655051     2       0          1  0  1
#> SRR1655052     2       0          1  0  1
#> SRR1655053     2       0          1  0  1
#> SRR1655054     2       0          1  0  1
#> SRR1655055     2       0          1  0  1
#> SRR1655056     2       0          1  0  1
#> SRR1655057     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
#> SRR1655002     1       0          1  1  0  0
#> SRR1655003     1       0          1  1  0  0
#> SRR1655004     1       0          1  1  0  0
#> SRR1655005     1       0          1  1  0  0
#> SRR1655006     1       0          1  1  0  0
#> SRR1655007     1       0          1  1  0  0
#> SRR1655008     1       0          1  1  0  0
#> SRR1655009     1       0          1  1  0  0
#> SRR1655010     1       0          1  1  0  0
#> SRR1655011     1       0          1  1  0  0
#> SRR1655012     2       0          1  0  1  0
#> SRR1655013     2       0          1  0  1  0
#> SRR1655014     2       0          1  0  1  0
#> SRR1655015     2       0          1  0  1  0
#> SRR1655016     2       0          1  0  1  0
#> SRR1655017     2       0          1  0  1  0
#> SRR1655018     2       0          1  0  1  0
#> SRR1655019     2       0          1  0  1  0
#> SRR1655020     2       0          1  0  1  0
#> SRR1655021     2       0          1  0  1  0
#> SRR1655022     2       0          1  0  1  0
#> SRR1655023     2       0          1  0  1  0
#> SRR1655024     2       0          1  0  1  0
#> SRR1655025     2       0          1  0  1  0
#> SRR1655026     2       0          1  0  1  0
#> SRR1655027     2       0          1  0  1  0
#> SRR1655028     2       0          1  0  1  0
#> SRR1655029     2       0          1  0  1  0
#> SRR1655030     2       0          1  0  1  0
#> SRR1655031     2       0          1  0  1  0
#> SRR1655032     2       0          1  0  1  0
#> SRR1655033     2       0          1  0  1  0
#> SRR1655034     3       0          1  0  0  1
#> SRR1655035     3       0          1  0  0  1
#> SRR1655036     3       0          1  0  0  1
#> SRR1655037     3       0          1  0  0  1
#> SRR1655038     3       0          1  0  0  1
#> SRR1655039     3       0          1  0  0  1
#> SRR1655040     3       0          1  0  0  1
#> SRR1655041     3       0          1  0  0  1
#> SRR1655042     2       0          1  0  1  0
#> SRR1655043     2       0          1  0  1  0
#> SRR1655044     2       0          1  0  1  0
#> SRR1655045     2       0          1  0  1  0
#> SRR1655046     2       0          1  0  1  0
#> SRR1655047     2       0          1  0  1  0
#> SRR1655048     2       0          1  0  1  0
#> SRR1655049     2       0          1  0  1  0
#> SRR1655050     2       0          1  0  1  0
#> SRR1655051     2       0          1  0  1  0
#> SRR1655052     2       0          1  0  1  0
#> SRR1655053     2       0          1  0  1  0
#> SRR1655054     2       0          1  0  1  0
#> SRR1655055     2       0          1  0  1  0
#> SRR1655056     2       0          1  0  1  0
#> SRR1655057     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
#> SRR1655002     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1655003     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1655004     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1655005     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1655006     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1655007     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1655008     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1655009     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1655010     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1655011     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1655012     2  0.0000      0.993  0 1.000  0 0.000
#> SRR1655013     2  0.0000      0.993  0 1.000  0 0.000
#> SRR1655014     2  0.0000      0.993  0 1.000  0 0.000
#> SRR1655015     2  0.0000      0.993  0 1.000  0 0.000
#> SRR1655016     2  0.0000      0.993  0 1.000  0 0.000
#> SRR1655017     2  0.0000      0.993  0 1.000  0 0.000
#> SRR1655018     2  0.0000      0.993  0 1.000  0 0.000
#> SRR1655019     2  0.0000      0.993  0 1.000  0 0.000
#> SRR1655020     2  0.0000      0.993  0 1.000  0 0.000
#> SRR1655021     2  0.0000      0.993  0 1.000  0 0.000
#> SRR1655022     2  0.0000      0.993  0 1.000  0 0.000
#> SRR1655023     2  0.0000      0.993  0 1.000  0 0.000
#> SRR1655024     2  0.0000      0.993  0 1.000  0 0.000
#> SRR1655025     2  0.0000      0.993  0 1.000  0 0.000
#> SRR1655026     4  0.4500      0.773  0 0.316  0 0.684
#> SRR1655027     4  0.4500      0.773  0 0.316  0 0.684
#> SRR1655028     4  0.4477      0.773  0 0.312  0 0.688
#> SRR1655029     4  0.4500      0.773  0 0.316  0 0.684
#> SRR1655030     4  0.4500      0.773  0 0.316  0 0.684
#> SRR1655031     4  0.4500      0.773  0 0.316  0 0.684
#> SRR1655032     4  0.4500      0.773  0 0.316  0 0.684
#> SRR1655033     4  0.4500      0.773  0 0.316  0 0.684
#> SRR1655034     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1655035     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1655036     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1655037     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1655038     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1655039     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1655040     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1655041     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1655042     2  0.0469      0.979  0 0.988  0 0.012
#> SRR1655043     2  0.2011      0.879  0 0.920  0 0.080
#> SRR1655044     4  0.4843      0.681  0 0.396  0 0.604
#> SRR1655045     4  0.4817      0.692  0 0.388  0 0.612
#> SRR1655046     4  0.4855      0.675  0 0.400  0 0.600
#> SRR1655047     4  0.4866      0.668  0 0.404  0 0.596
#> SRR1655048     2  0.0000      0.993  0 1.000  0 0.000
#> SRR1655049     2  0.0000      0.993  0 1.000  0 0.000
#> SRR1655050     4  0.0000      0.719  0 0.000  0 1.000
#> SRR1655051     4  0.0000      0.719  0 0.000  0 1.000
#> SRR1655052     4  0.0000      0.719  0 0.000  0 1.000
#> SRR1655053     4  0.0000      0.719  0 0.000  0 1.000
#> SRR1655054     4  0.0000      0.719  0 0.000  0 1.000
#> SRR1655055     4  0.0000      0.719  0 0.000  0 1.000
#> SRR1655056     4  0.0000      0.719  0 0.000  0 1.000
#> SRR1655057     4  0.0000      0.719  0 0.000  0 1.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette p1    p2 p3    p4 p5
#> SRR1655002     1  0.0000      1.000  1 0.000  0 0.000  0
#> SRR1655003     1  0.0000      1.000  1 0.000  0 0.000  0
#> SRR1655004     1  0.0000      1.000  1 0.000  0 0.000  0
#> SRR1655005     1  0.0000      1.000  1 0.000  0 0.000  0
#> SRR1655006     1  0.0000      1.000  1 0.000  0 0.000  0
#> SRR1655007     1  0.0000      1.000  1 0.000  0 0.000  0
#> SRR1655008     1  0.0000      1.000  1 0.000  0 0.000  0
#> SRR1655009     1  0.0000      1.000  1 0.000  0 0.000  0
#> SRR1655010     1  0.0000      1.000  1 0.000  0 0.000  0
#> SRR1655011     1  0.0000      1.000  1 0.000  0 0.000  0
#> SRR1655012     2  0.0000      0.994  0 1.000  0 0.000  0
#> SRR1655013     2  0.0000      0.994  0 1.000  0 0.000  0
#> SRR1655014     2  0.0000      0.994  0 1.000  0 0.000  0
#> SRR1655015     2  0.0000      0.994  0 1.000  0 0.000  0
#> SRR1655016     2  0.0000      0.994  0 1.000  0 0.000  0
#> SRR1655017     2  0.0000      0.994  0 1.000  0 0.000  0
#> SRR1655018     2  0.0000      0.994  0 1.000  0 0.000  0
#> SRR1655019     2  0.0000      0.994  0 1.000  0 0.000  0
#> SRR1655020     2  0.0000      0.994  0 1.000  0 0.000  0
#> SRR1655021     2  0.0000      0.994  0 1.000  0 0.000  0
#> SRR1655022     2  0.0000      0.994  0 1.000  0 0.000  0
#> SRR1655023     2  0.0000      0.994  0 1.000  0 0.000  0
#> SRR1655024     2  0.0000      0.994  0 1.000  0 0.000  0
#> SRR1655025     2  0.0000      0.994  0 1.000  0 0.000  0
#> SRR1655026     4  0.0000      0.812  0 0.000  0 1.000  0
#> SRR1655027     4  0.0000      0.812  0 0.000  0 1.000  0
#> SRR1655028     4  0.0000      0.812  0 0.000  0 1.000  0
#> SRR1655029     4  0.0000      0.812  0 0.000  0 1.000  0
#> SRR1655030     4  0.0000      0.812  0 0.000  0 1.000  0
#> SRR1655031     4  0.0000      0.812  0 0.000  0 1.000  0
#> SRR1655032     4  0.0000      0.812  0 0.000  0 1.000  0
#> SRR1655033     4  0.0000      0.812  0 0.000  0 1.000  0
#> SRR1655034     3  0.0000      1.000  0 0.000  1 0.000  0
#> SRR1655035     3  0.0000      1.000  0 0.000  1 0.000  0
#> SRR1655036     3  0.0000      1.000  0 0.000  1 0.000  0
#> SRR1655037     3  0.0000      1.000  0 0.000  1 0.000  0
#> SRR1655038     3  0.0000      1.000  0 0.000  1 0.000  0
#> SRR1655039     3  0.0000      1.000  0 0.000  1 0.000  0
#> SRR1655040     3  0.0000      1.000  0 0.000  1 0.000  0
#> SRR1655041     3  0.0000      1.000  0 0.000  1 0.000  0
#> SRR1655042     2  0.0404      0.981  0 0.988  0 0.012  0
#> SRR1655043     2  0.1671      0.900  0 0.924  0 0.076  0
#> SRR1655044     4  0.4161      0.517  0 0.392  0 0.608  0
#> SRR1655045     4  0.4126      0.535  0 0.380  0 0.620  0
#> SRR1655046     4  0.4182      0.502  0 0.400  0 0.600  0
#> SRR1655047     4  0.4210      0.476  0 0.412  0 0.588  0
#> SRR1655048     2  0.0000      0.994  0 1.000  0 0.000  0
#> SRR1655049     2  0.0000      0.994  0 1.000  0 0.000  0
#> SRR1655050     5  0.0000      1.000  0 0.000  0 0.000  1
#> SRR1655051     5  0.0000      1.000  0 0.000  0 0.000  1
#> SRR1655052     5  0.0000      1.000  0 0.000  0 0.000  1
#> SRR1655053     5  0.0000      1.000  0 0.000  0 0.000  1
#> SRR1655054     5  0.0000      1.000  0 0.000  0 0.000  1
#> SRR1655055     5  0.0000      1.000  0 0.000  0 0.000  1
#> SRR1655056     5  0.0000      1.000  0 0.000  0 0.000  1
#> SRR1655057     5  0.0000      1.000  0 0.000  0 0.000  1

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1655002     1       0          1  1  0  0  0  0  0
#> SRR1655003     1       0          1  1  0  0  0  0  0
#> SRR1655004     1       0          1  1  0  0  0  0  0
#> SRR1655005     1       0          1  1  0  0  0  0  0
#> SRR1655006     1       0          1  1  0  0  0  0  0
#> SRR1655007     1       0          1  1  0  0  0  0  0
#> SRR1655008     1       0          1  1  0  0  0  0  0
#> SRR1655009     1       0          1  1  0  0  0  0  0
#> SRR1655010     1       0          1  1  0  0  0  0  0
#> SRR1655011     1       0          1  1  0  0  0  0  0
#> SRR1655012     2       0          1  0  1  0  0  0  0
#> SRR1655013     2       0          1  0  1  0  0  0  0
#> SRR1655014     2       0          1  0  1  0  0  0  0
#> SRR1655015     2       0          1  0  1  0  0  0  0
#> SRR1655016     2       0          1  0  1  0  0  0  0
#> SRR1655017     2       0          1  0  1  0  0  0  0
#> SRR1655018     2       0          1  0  1  0  0  0  0
#> SRR1655019     2       0          1  0  1  0  0  0  0
#> SRR1655020     2       0          1  0  1  0  0  0  0
#> SRR1655021     2       0          1  0  1  0  0  0  0
#> SRR1655022     2       0          1  0  1  0  0  0  0
#> SRR1655023     2       0          1  0  1  0  0  0  0
#> SRR1655024     2       0          1  0  1  0  0  0  0
#> SRR1655025     2       0          1  0  1  0  0  0  0
#> SRR1655026     4       0          1  0  0  0  1  0  0
#> SRR1655027     4       0          1  0  0  0  1  0  0
#> SRR1655028     4       0          1  0  0  0  1  0  0
#> SRR1655029     4       0          1  0  0  0  1  0  0
#> SRR1655030     4       0          1  0  0  0  1  0  0
#> SRR1655031     4       0          1  0  0  0  1  0  0
#> SRR1655032     4       0          1  0  0  0  1  0  0
#> SRR1655033     4       0          1  0  0  0  1  0  0
#> SRR1655034     3       0          1  0  0  1  0  0  0
#> SRR1655035     3       0          1  0  0  1  0  0  0
#> SRR1655036     3       0          1  0  0  1  0  0  0
#> SRR1655037     3       0          1  0  0  1  0  0  0
#> SRR1655038     3       0          1  0  0  1  0  0  0
#> SRR1655039     3       0          1  0  0  1  0  0  0
#> SRR1655040     3       0          1  0  0  1  0  0  0
#> SRR1655041     3       0          1  0  0  1  0  0  0
#> SRR1655042     6       0          1  0  0  0  0  0  1
#> SRR1655043     6       0          1  0  0  0  0  0  1
#> SRR1655044     6       0          1  0  0  0  0  0  1
#> SRR1655045     6       0          1  0  0  0  0  0  1
#> SRR1655046     6       0          1  0  0  0  0  0  1
#> SRR1655047     6       0          1  0  0  0  0  0  1
#> SRR1655048     6       0          1  0  0  0  0  0  1
#> SRR1655049     6       0          1  0  0  0  0  0  1
#> SRR1655050     5       0          1  0  0  0  0  1  0
#> SRR1655051     5       0          1  0  0  0  0  1  0
#> SRR1655052     5       0          1  0  0  0  0  1  0
#> SRR1655053     5       0          1  0  0  0  0  1  0
#> SRR1655054     5       0          1  0  0  0  0  1  0
#> SRR1655055     5       0          1  0  0  0  0  1  0
#> SRR1655056     5       0          1  0  0  0  0  1  0
#> SRR1655057     5       0          1  0  0  0  0  1  0

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-pam-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-pam-collect-classes

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


CV:mclust*

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

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

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

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

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

collect_plots(res)

plot of chunk CV-mclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.751           0.953       0.975         0.3243 0.701   0.701
#> 3 3 0.621           0.836       0.897         0.6944 0.803   0.719
#> 4 4 0.751           0.887       0.921         0.2854 0.771   0.546
#> 5 5 0.908           0.945       0.962         0.1187 0.891   0.628
#> 6 6 0.933           0.975       0.975         0.0586 0.958   0.795

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] 5

There is also optional best \(k\) = 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
#> SRR1655002     1   0.000      1.000 1.000 0.000
#> SRR1655003     1   0.000      1.000 1.000 0.000
#> SRR1655004     1   0.000      1.000 1.000 0.000
#> SRR1655005     1   0.000      1.000 1.000 0.000
#> SRR1655006     1   0.000      1.000 1.000 0.000
#> SRR1655007     1   0.000      1.000 1.000 0.000
#> SRR1655008     1   0.000      1.000 1.000 0.000
#> SRR1655009     1   0.000      1.000 1.000 0.000
#> SRR1655010     1   0.000      1.000 1.000 0.000
#> SRR1655011     1   0.000      1.000 1.000 0.000
#> SRR1655012     2   0.000      0.968 0.000 1.000
#> SRR1655013     2   0.000      0.968 0.000 1.000
#> SRR1655014     2   0.000      0.968 0.000 1.000
#> SRR1655015     2   0.000      0.968 0.000 1.000
#> SRR1655016     2   0.000      0.968 0.000 1.000
#> SRR1655017     2   0.000      0.968 0.000 1.000
#> SRR1655018     2   0.000      0.968 0.000 1.000
#> SRR1655019     2   0.000      0.968 0.000 1.000
#> SRR1655020     2   0.000      0.968 0.000 1.000
#> SRR1655021     2   0.000      0.968 0.000 1.000
#> SRR1655022     2   0.000      0.968 0.000 1.000
#> SRR1655023     2   0.000      0.968 0.000 1.000
#> SRR1655024     2   0.000      0.968 0.000 1.000
#> SRR1655025     2   0.000      0.968 0.000 1.000
#> SRR1655026     2   0.000      0.968 0.000 1.000
#> SRR1655027     2   0.000      0.968 0.000 1.000
#> SRR1655028     2   0.000      0.968 0.000 1.000
#> SRR1655029     2   0.000      0.968 0.000 1.000
#> SRR1655030     2   0.000      0.968 0.000 1.000
#> SRR1655031     2   0.000      0.968 0.000 1.000
#> SRR1655032     2   0.000      0.968 0.000 1.000
#> SRR1655033     2   0.000      0.968 0.000 1.000
#> SRR1655034     2   0.662      0.825 0.172 0.828
#> SRR1655035     2   0.662      0.825 0.172 0.828
#> SRR1655036     2   0.662      0.825 0.172 0.828
#> SRR1655037     2   0.662      0.825 0.172 0.828
#> SRR1655038     2   0.662      0.825 0.172 0.828
#> SRR1655039     2   0.662      0.825 0.172 0.828
#> SRR1655040     2   0.662      0.825 0.172 0.828
#> SRR1655041     2   0.662      0.825 0.172 0.828
#> SRR1655042     2   0.000      0.968 0.000 1.000
#> SRR1655043     2   0.000      0.968 0.000 1.000
#> SRR1655044     2   0.000      0.968 0.000 1.000
#> SRR1655045     2   0.000      0.968 0.000 1.000
#> SRR1655046     2   0.000      0.968 0.000 1.000
#> SRR1655047     2   0.000      0.968 0.000 1.000
#> SRR1655048     2   0.000      0.968 0.000 1.000
#> SRR1655049     2   0.000      0.968 0.000 1.000
#> SRR1655050     2   0.000      0.968 0.000 1.000
#> SRR1655051     2   0.000      0.968 0.000 1.000
#> SRR1655052     2   0.000      0.968 0.000 1.000
#> SRR1655053     2   0.000      0.968 0.000 1.000
#> SRR1655054     2   0.000      0.968 0.000 1.000
#> SRR1655055     2   0.000      0.968 0.000 1.000
#> SRR1655056     2   0.000      0.968 0.000 1.000
#> SRR1655057     2   0.000      0.968 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
#> SRR1655002     1  0.0000      1.000  1 0.000 0.000
#> SRR1655003     1  0.0000      1.000  1 0.000 0.000
#> SRR1655004     1  0.0000      1.000  1 0.000 0.000
#> SRR1655005     1  0.0000      1.000  1 0.000 0.000
#> SRR1655006     1  0.0000      1.000  1 0.000 0.000
#> SRR1655007     1  0.0000      1.000  1 0.000 0.000
#> SRR1655008     1  0.0000      1.000  1 0.000 0.000
#> SRR1655009     1  0.0000      1.000  1 0.000 0.000
#> SRR1655010     1  0.0000      1.000  1 0.000 0.000
#> SRR1655011     1  0.0000      1.000  1 0.000 0.000
#> SRR1655012     2  0.0000      0.821  0 1.000 0.000
#> SRR1655013     2  0.0000      0.821  0 1.000 0.000
#> SRR1655014     2  0.0000      0.821  0 1.000 0.000
#> SRR1655015     2  0.0000      0.821  0 1.000 0.000
#> SRR1655016     2  0.0000      0.821  0 1.000 0.000
#> SRR1655017     2  0.0000      0.821  0 1.000 0.000
#> SRR1655018     2  0.4002      0.817  0 0.840 0.160
#> SRR1655019     2  0.4002      0.817  0 0.840 0.160
#> SRR1655020     2  0.0237      0.822  0 0.996 0.004
#> SRR1655021     2  0.0000      0.821  0 1.000 0.000
#> SRR1655022     2  0.0000      0.821  0 1.000 0.000
#> SRR1655023     2  0.0000      0.821  0 1.000 0.000
#> SRR1655024     2  0.0000      0.821  0 1.000 0.000
#> SRR1655025     2  0.0000      0.821  0 1.000 0.000
#> SRR1655026     2  0.4654      0.800  0 0.792 0.208
#> SRR1655027     2  0.4654      0.800  0 0.792 0.208
#> SRR1655028     2  0.4654      0.800  0 0.792 0.208
#> SRR1655029     2  0.4654      0.800  0 0.792 0.208
#> SRR1655030     2  0.4654      0.800  0 0.792 0.208
#> SRR1655031     2  0.4654      0.800  0 0.792 0.208
#> SRR1655032     2  0.4654      0.800  0 0.792 0.208
#> SRR1655033     2  0.4654      0.800  0 0.792 0.208
#> SRR1655034     3  0.0000      1.000  0 0.000 1.000
#> SRR1655035     3  0.0000      1.000  0 0.000 1.000
#> SRR1655036     3  0.0000      1.000  0 0.000 1.000
#> SRR1655037     3  0.0000      1.000  0 0.000 1.000
#> SRR1655038     3  0.0000      1.000  0 0.000 1.000
#> SRR1655039     3  0.0000      1.000  0 0.000 1.000
#> SRR1655040     3  0.0000      1.000  0 0.000 1.000
#> SRR1655041     3  0.0000      1.000  0 0.000 1.000
#> SRR1655042     2  0.2448      0.833  0 0.924 0.076
#> SRR1655043     2  0.2448      0.833  0 0.924 0.076
#> SRR1655044     2  0.2448      0.833  0 0.924 0.076
#> SRR1655045     2  0.2448      0.833  0 0.924 0.076
#> SRR1655046     2  0.2448      0.833  0 0.924 0.076
#> SRR1655047     2  0.2448      0.833  0 0.924 0.076
#> SRR1655048     2  0.2448      0.833  0 0.924 0.076
#> SRR1655049     2  0.2448      0.833  0 0.924 0.076
#> SRR1655050     2  0.6252      0.530  0 0.556 0.444
#> SRR1655051     2  0.6252      0.530  0 0.556 0.444
#> SRR1655052     2  0.6252      0.530  0 0.556 0.444
#> SRR1655053     2  0.6252      0.530  0 0.556 0.444
#> SRR1655054     2  0.6252      0.530  0 0.556 0.444
#> SRR1655055     2  0.6252      0.530  0 0.556 0.444
#> SRR1655056     2  0.6252      0.530  0 0.556 0.444
#> SRR1655057     2  0.6252      0.530  0 0.556 0.444

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette p1    p2 p3    p4
#> SRR1655002     1   0.000      1.000  1 0.000  0 0.000
#> SRR1655003     1   0.000      1.000  1 0.000  0 0.000
#> SRR1655004     1   0.000      1.000  1 0.000  0 0.000
#> SRR1655005     1   0.000      1.000  1 0.000  0 0.000
#> SRR1655006     1   0.000      1.000  1 0.000  0 0.000
#> SRR1655007     1   0.000      1.000  1 0.000  0 0.000
#> SRR1655008     1   0.000      1.000  1 0.000  0 0.000
#> SRR1655009     1   0.000      1.000  1 0.000  0 0.000
#> SRR1655010     1   0.000      1.000  1 0.000  0 0.000
#> SRR1655011     1   0.000      1.000  1 0.000  0 0.000
#> SRR1655012     2   0.000      0.963  0 1.000  0 0.000
#> SRR1655013     2   0.000      0.963  0 1.000  0 0.000
#> SRR1655014     2   0.000      0.963  0 1.000  0 0.000
#> SRR1655015     2   0.000      0.963  0 1.000  0 0.000
#> SRR1655016     2   0.000      0.963  0 1.000  0 0.000
#> SRR1655017     2   0.000      0.963  0 1.000  0 0.000
#> SRR1655018     2   0.000      0.963  0 1.000  0 0.000
#> SRR1655019     2   0.000      0.963  0 1.000  0 0.000
#> SRR1655020     2   0.000      0.963  0 1.000  0 0.000
#> SRR1655021     2   0.000      0.963  0 1.000  0 0.000
#> SRR1655022     2   0.000      0.963  0 1.000  0 0.000
#> SRR1655023     2   0.000      0.963  0 1.000  0 0.000
#> SRR1655024     2   0.000      0.963  0 1.000  0 0.000
#> SRR1655025     2   0.000      0.963  0 1.000  0 0.000
#> SRR1655026     4   0.387      0.818  0 0.228  0 0.772
#> SRR1655027     4   0.387      0.818  0 0.228  0 0.772
#> SRR1655028     4   0.387      0.818  0 0.228  0 0.772
#> SRR1655029     4   0.387      0.818  0 0.228  0 0.772
#> SRR1655030     4   0.387      0.818  0 0.228  0 0.772
#> SRR1655031     4   0.387      0.818  0 0.228  0 0.772
#> SRR1655032     4   0.387      0.818  0 0.228  0 0.772
#> SRR1655033     4   0.387      0.818  0 0.228  0 0.772
#> SRR1655034     3   0.000      1.000  0 0.000  1 0.000
#> SRR1655035     3   0.000      1.000  0 0.000  1 0.000
#> SRR1655036     3   0.000      1.000  0 0.000  1 0.000
#> SRR1655037     3   0.000      1.000  0 0.000  1 0.000
#> SRR1655038     3   0.000      1.000  0 0.000  1 0.000
#> SRR1655039     3   0.000      1.000  0 0.000  1 0.000
#> SRR1655040     3   0.000      1.000  0 0.000  1 0.000
#> SRR1655041     3   0.000      1.000  0 0.000  1 0.000
#> SRR1655042     4   0.475      0.699  0 0.368  0 0.632
#> SRR1655043     4   0.475      0.699  0 0.368  0 0.632
#> SRR1655044     4   0.475      0.699  0 0.368  0 0.632
#> SRR1655045     4   0.475      0.699  0 0.368  0 0.632
#> SRR1655046     4   0.475      0.699  0 0.368  0 0.632
#> SRR1655047     4   0.475      0.699  0 0.368  0 0.632
#> SRR1655048     2   0.361      0.662  0 0.800  0 0.200
#> SRR1655049     2   0.361      0.662  0 0.800  0 0.200
#> SRR1655050     4   0.000      0.769  0 0.000  0 1.000
#> SRR1655051     4   0.000      0.769  0 0.000  0 1.000
#> SRR1655052     4   0.000      0.769  0 0.000  0 1.000
#> SRR1655053     4   0.000      0.769  0 0.000  0 1.000
#> SRR1655054     4   0.000      0.769  0 0.000  0 1.000
#> SRR1655055     4   0.000      0.769  0 0.000  0 1.000
#> SRR1655056     4   0.000      0.769  0 0.000  0 1.000
#> SRR1655057     4   0.000      0.769  0 0.000  0 1.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette p1    p2 p3    p4 p5
#> SRR1655002     1   0.000      1.000  1 0.000  0 0.000  0
#> SRR1655003     1   0.000      1.000  1 0.000  0 0.000  0
#> SRR1655004     1   0.000      1.000  1 0.000  0 0.000  0
#> SRR1655005     1   0.000      1.000  1 0.000  0 0.000  0
#> SRR1655006     1   0.000      1.000  1 0.000  0 0.000  0
#> SRR1655007     1   0.000      1.000  1 0.000  0 0.000  0
#> SRR1655008     1   0.000      1.000  1 0.000  0 0.000  0
#> SRR1655009     1   0.000      1.000  1 0.000  0 0.000  0
#> SRR1655010     1   0.000      1.000  1 0.000  0 0.000  0
#> SRR1655011     1   0.000      1.000  1 0.000  0 0.000  0
#> SRR1655012     2   0.000      1.000  0 1.000  0 0.000  0
#> SRR1655013     2   0.000      1.000  0 1.000  0 0.000  0
#> SRR1655014     2   0.000      1.000  0 1.000  0 0.000  0
#> SRR1655015     2   0.000      1.000  0 1.000  0 0.000  0
#> SRR1655016     2   0.000      1.000  0 1.000  0 0.000  0
#> SRR1655017     2   0.000      1.000  0 1.000  0 0.000  0
#> SRR1655018     2   0.000      1.000  0 1.000  0 0.000  0
#> SRR1655019     2   0.000      1.000  0 1.000  0 0.000  0
#> SRR1655020     2   0.000      1.000  0 1.000  0 0.000  0
#> SRR1655021     2   0.000      1.000  0 1.000  0 0.000  0
#> SRR1655022     2   0.000      1.000  0 1.000  0 0.000  0
#> SRR1655023     2   0.000      1.000  0 1.000  0 0.000  0
#> SRR1655024     2   0.000      1.000  0 1.000  0 0.000  0
#> SRR1655025     2   0.000      1.000  0 1.000  0 0.000  0
#> SRR1655026     4   0.000      0.834  0 0.000  0 1.000  0
#> SRR1655027     4   0.000      0.834  0 0.000  0 1.000  0
#> SRR1655028     4   0.000      0.834  0 0.000  0 1.000  0
#> SRR1655029     4   0.000      0.834  0 0.000  0 1.000  0
#> SRR1655030     4   0.000      0.834  0 0.000  0 1.000  0
#> SRR1655031     4   0.000      0.834  0 0.000  0 1.000  0
#> SRR1655032     4   0.000      0.834  0 0.000  0 1.000  0
#> SRR1655033     4   0.000      0.834  0 0.000  0 1.000  0
#> SRR1655034     3   0.000      1.000  0 0.000  1 0.000  0
#> SRR1655035     3   0.000      1.000  0 0.000  1 0.000  0
#> SRR1655036     3   0.000      1.000  0 0.000  1 0.000  0
#> SRR1655037     3   0.000      1.000  0 0.000  1 0.000  0
#> SRR1655038     3   0.000      1.000  0 0.000  1 0.000  0
#> SRR1655039     3   0.000      1.000  0 0.000  1 0.000  0
#> SRR1655040     3   0.000      1.000  0 0.000  1 0.000  0
#> SRR1655041     3   0.000      1.000  0 0.000  1 0.000  0
#> SRR1655042     4   0.342      0.812  0 0.240  0 0.760  0
#> SRR1655043     4   0.342      0.812  0 0.240  0 0.760  0
#> SRR1655044     4   0.342      0.812  0 0.240  0 0.760  0
#> SRR1655045     4   0.342      0.812  0 0.240  0 0.760  0
#> SRR1655046     4   0.342      0.812  0 0.240  0 0.760  0
#> SRR1655047     4   0.342      0.812  0 0.240  0 0.760  0
#> SRR1655048     4   0.397      0.695  0 0.336  0 0.664  0
#> SRR1655049     4   0.397      0.695  0 0.336  0 0.664  0
#> SRR1655050     5   0.000      1.000  0 0.000  0 0.000  1
#> SRR1655051     5   0.000      1.000  0 0.000  0 0.000  1
#> SRR1655052     5   0.000      1.000  0 0.000  0 0.000  1
#> SRR1655053     5   0.000      1.000  0 0.000  0 0.000  1
#> SRR1655054     5   0.000      1.000  0 0.000  0 0.000  1
#> SRR1655055     5   0.000      1.000  0 0.000  0 0.000  1
#> SRR1655056     5   0.000      1.000  0 0.000  0 0.000  1
#> SRR1655057     5   0.000      1.000  0 0.000  0 0.000  1

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette p1    p2 p3 p4 p5    p6
#> SRR1655002     1  0.0000      1.000  1 0.000  0  0  0 0.000
#> SRR1655003     1  0.0000      1.000  1 0.000  0  0  0 0.000
#> SRR1655004     1  0.0000      1.000  1 0.000  0  0  0 0.000
#> SRR1655005     1  0.0000      1.000  1 0.000  0  0  0 0.000
#> SRR1655006     1  0.0000      1.000  1 0.000  0  0  0 0.000
#> SRR1655007     1  0.0000      1.000  1 0.000  0  0  0 0.000
#> SRR1655008     1  0.0000      1.000  1 0.000  0  0  0 0.000
#> SRR1655009     1  0.0000      1.000  1 0.000  0  0  0 0.000
#> SRR1655010     1  0.0000      1.000  1 0.000  0  0  0 0.000
#> SRR1655011     1  0.0000      1.000  1 0.000  0  0  0 0.000
#> SRR1655012     2  0.0547      0.898  0 0.980  0  0  0 0.020
#> SRR1655013     2  0.0547      0.898  0 0.980  0  0  0 0.020
#> SRR1655014     2  0.0000      0.885  0 1.000  0  0  0 0.000
#> SRR1655015     2  0.0000      0.885  0 1.000  0  0  0 0.000
#> SRR1655016     2  0.0547      0.898  0 0.980  0  0  0 0.020
#> SRR1655017     2  0.0547      0.898  0 0.980  0  0  0 0.020
#> SRR1655018     2  0.2454      0.920  0 0.840  0  0  0 0.160
#> SRR1655019     2  0.2454      0.920  0 0.840  0  0  0 0.160
#> SRR1655020     2  0.2454      0.920  0 0.840  0  0  0 0.160
#> SRR1655021     2  0.2454      0.920  0 0.840  0  0  0 0.160
#> SRR1655022     2  0.2454      0.920  0 0.840  0  0  0 0.160
#> SRR1655023     2  0.2454      0.920  0 0.840  0  0  0 0.160
#> SRR1655024     2  0.2454      0.920  0 0.840  0  0  0 0.160
#> SRR1655025     2  0.2454      0.920  0 0.840  0  0  0 0.160
#> SRR1655026     4  0.0000      1.000  0 0.000  0  1  0 0.000
#> SRR1655027     4  0.0000      1.000  0 0.000  0  1  0 0.000
#> SRR1655028     4  0.0000      1.000  0 0.000  0  1  0 0.000
#> SRR1655029     4  0.0000      1.000  0 0.000  0  1  0 0.000
#> SRR1655030     4  0.0000      1.000  0 0.000  0  1  0 0.000
#> SRR1655031     4  0.0000      1.000  0 0.000  0  1  0 0.000
#> SRR1655032     4  0.0000      1.000  0 0.000  0  1  0 0.000
#> SRR1655033     4  0.0000      1.000  0 0.000  0  1  0 0.000
#> SRR1655034     3  0.0000      1.000  0 0.000  1  0  0 0.000
#> SRR1655035     3  0.0000      1.000  0 0.000  1  0  0 0.000
#> SRR1655036     3  0.0000      1.000  0 0.000  1  0  0 0.000
#> SRR1655037     3  0.0000      1.000  0 0.000  1  0  0 0.000
#> SRR1655038     3  0.0000      1.000  0 0.000  1  0  0 0.000
#> SRR1655039     3  0.0000      1.000  0 0.000  1  0  0 0.000
#> SRR1655040     3  0.0000      1.000  0 0.000  1  0  0 0.000
#> SRR1655041     3  0.0000      1.000  0 0.000  1  0  0 0.000
#> SRR1655042     6  0.0000      0.991  0 0.000  0  0  0 1.000
#> SRR1655043     6  0.0000      0.991  0 0.000  0  0  0 1.000
#> SRR1655044     6  0.0000      0.991  0 0.000  0  0  0 1.000
#> SRR1655045     6  0.0000      0.991  0 0.000  0  0  0 1.000
#> SRR1655046     6  0.0000      0.991  0 0.000  0  0  0 1.000
#> SRR1655047     6  0.0000      0.991  0 0.000  0  0  0 1.000
#> SRR1655048     6  0.0713      0.971  0 0.028  0  0  0 0.972
#> SRR1655049     6  0.0713      0.971  0 0.028  0  0  0 0.972
#> SRR1655050     5  0.0000      1.000  0 0.000  0  0  1 0.000
#> SRR1655051     5  0.0000      1.000  0 0.000  0  0  1 0.000
#> SRR1655052     5  0.0000      1.000  0 0.000  0  0  1 0.000
#> SRR1655053     5  0.0000      1.000  0 0.000  0  0  1 0.000
#> SRR1655054     5  0.0000      1.000  0 0.000  0  0  1 0.000
#> SRR1655055     5  0.0000      1.000  0 0.000  0  0  1 0.000
#> SRR1655056     5  0.0000      1.000  0 0.000  0  0  1 0.000
#> SRR1655057     5  0.0000      1.000  0 0.000  0  0  1 0.000

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

consensus_heatmap(res, k = 2)

plot of chunk tab-CV-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 15837 rows and 56 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.2994 0.701   0.701
#> 3 3 0.917           0.966       0.980         0.9893 0.688   0.556
#> 4 4 1.000           0.999       0.999         0.2166 0.803   0.542
#> 5 5 0.917           0.957       0.963         0.1000 0.844   0.508
#> 6 6 1.000           0.996       0.946         0.0453 0.958   0.795

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette p1 p2
#> SRR1655002     1       0          1  1  0
#> SRR1655003     1       0          1  1  0
#> SRR1655004     1       0          1  1  0
#> SRR1655005     1       0          1  1  0
#> SRR1655006     1       0          1  1  0
#> SRR1655007     1       0          1  1  0
#> SRR1655008     1       0          1  1  0
#> SRR1655009     1       0          1  1  0
#> SRR1655010     1       0          1  1  0
#> SRR1655011     1       0          1  1  0
#> SRR1655012     2       0          1  0  1
#> SRR1655013     2       0          1  0  1
#> SRR1655014     2       0          1  0  1
#> SRR1655015     2       0          1  0  1
#> SRR1655016     2       0          1  0  1
#> SRR1655017     2       0          1  0  1
#> SRR1655018     2       0          1  0  1
#> SRR1655019     2       0          1  0  1
#> SRR1655020     2       0          1  0  1
#> SRR1655021     2       0          1  0  1
#> SRR1655022     2       0          1  0  1
#> SRR1655023     2       0          1  0  1
#> SRR1655024     2       0          1  0  1
#> SRR1655025     2       0          1  0  1
#> SRR1655026     2       0          1  0  1
#> SRR1655027     2       0          1  0  1
#> SRR1655028     2       0          1  0  1
#> SRR1655029     2       0          1  0  1
#> SRR1655030     2       0          1  0  1
#> SRR1655031     2       0          1  0  1
#> SRR1655032     2       0          1  0  1
#> SRR1655033     2       0          1  0  1
#> SRR1655034     2       0          1  0  1
#> SRR1655035     2       0          1  0  1
#> SRR1655036     2       0          1  0  1
#> SRR1655037     2       0          1  0  1
#> SRR1655038     2       0          1  0  1
#> SRR1655039     2       0          1  0  1
#> SRR1655040     2       0          1  0  1
#> SRR1655041     2       0          1  0  1
#> SRR1655042     2       0          1  0  1
#> SRR1655043     2       0          1  0  1
#> SRR1655044     2       0          1  0  1
#> SRR1655045     2       0          1  0  1
#> SRR1655046     2       0          1  0  1
#> SRR1655047     2       0          1  0  1
#> SRR1655048     2       0          1  0  1
#> SRR1655049     2       0          1  0  1
#> SRR1655050     2       0          1  0  1
#> SRR1655051     2       0          1  0  1
#> SRR1655052     2       0          1  0  1
#> SRR1655053     2       0          1  0  1
#> SRR1655054     2       0          1  0  1
#> SRR1655055     2       0          1  0  1
#> SRR1655056     2       0          1  0  1
#> SRR1655057     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
#> SRR1655002     1   0.000      1.000  1 0.000 0.000
#> SRR1655003     1   0.000      1.000  1 0.000 0.000
#> SRR1655004     1   0.000      1.000  1 0.000 0.000
#> SRR1655005     1   0.000      1.000  1 0.000 0.000
#> SRR1655006     1   0.000      1.000  1 0.000 0.000
#> SRR1655007     1   0.000      1.000  1 0.000 0.000
#> SRR1655008     1   0.000      1.000  1 0.000 0.000
#> SRR1655009     1   0.000      1.000  1 0.000 0.000
#> SRR1655010     1   0.000      1.000  1 0.000 0.000
#> SRR1655011     1   0.000      1.000  1 0.000 0.000
#> SRR1655012     2   0.000      1.000  0 1.000 0.000
#> SRR1655013     2   0.000      1.000  0 1.000 0.000
#> SRR1655014     2   0.000      1.000  0 1.000 0.000
#> SRR1655015     2   0.000      1.000  0 1.000 0.000
#> SRR1655016     2   0.000      1.000  0 1.000 0.000
#> SRR1655017     2   0.000      1.000  0 1.000 0.000
#> SRR1655018     2   0.000      1.000  0 1.000 0.000
#> SRR1655019     2   0.000      1.000  0 1.000 0.000
#> SRR1655020     2   0.000      1.000  0 1.000 0.000
#> SRR1655021     2   0.000      1.000  0 1.000 0.000
#> SRR1655022     2   0.000      1.000  0 1.000 0.000
#> SRR1655023     2   0.000      1.000  0 1.000 0.000
#> SRR1655024     2   0.000      1.000  0 1.000 0.000
#> SRR1655025     2   0.000      1.000  0 1.000 0.000
#> SRR1655026     2   0.000      1.000  0 1.000 0.000
#> SRR1655027     2   0.000      1.000  0 1.000 0.000
#> SRR1655028     2   0.000      1.000  0 1.000 0.000
#> SRR1655029     2   0.000      1.000  0 1.000 0.000
#> SRR1655030     2   0.000      1.000  0 1.000 0.000
#> SRR1655031     2   0.000      1.000  0 1.000 0.000
#> SRR1655032     2   0.000      1.000  0 1.000 0.000
#> SRR1655033     2   0.000      1.000  0 1.000 0.000
#> SRR1655034     3   0.000      0.899  0 0.000 1.000
#> SRR1655035     3   0.000      0.899  0 0.000 1.000
#> SRR1655036     3   0.000      0.899  0 0.000 1.000
#> SRR1655037     3   0.000      0.899  0 0.000 1.000
#> SRR1655038     3   0.000      0.899  0 0.000 1.000
#> SRR1655039     3   0.000      0.899  0 0.000 1.000
#> SRR1655040     3   0.000      0.899  0 0.000 1.000
#> SRR1655041     3   0.000      0.899  0 0.000 1.000
#> SRR1655042     2   0.000      1.000  0 1.000 0.000
#> SRR1655043     2   0.000      1.000  0 1.000 0.000
#> SRR1655044     2   0.000      1.000  0 1.000 0.000
#> SRR1655045     2   0.000      1.000  0 1.000 0.000
#> SRR1655046     2   0.000      1.000  0 1.000 0.000
#> SRR1655047     2   0.000      1.000  0 1.000 0.000
#> SRR1655048     2   0.000      1.000  0 1.000 0.000
#> SRR1655049     2   0.000      1.000  0 1.000 0.000
#> SRR1655050     3   0.263      0.897  0 0.084 0.916
#> SRR1655051     3   0.312      0.890  0 0.108 0.892
#> SRR1655052     3   0.445      0.827  0 0.192 0.808
#> SRR1655053     3   0.455      0.818  0 0.200 0.800
#> SRR1655054     3   0.388      0.866  0 0.152 0.848
#> SRR1655055     3   0.369      0.874  0 0.140 0.860
#> SRR1655056     3   0.288      0.895  0 0.096 0.904
#> SRR1655057     3   0.406      0.856  0 0.164 0.836

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette p1    p2    p3    p4
#> SRR1655002     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1655003     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1655004     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1655005     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1655006     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1655007     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1655008     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1655009     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1655010     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1655011     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1655012     2  0.0000      1.000  0 1.000 0.000 0.000
#> SRR1655013     2  0.0000      1.000  0 1.000 0.000 0.000
#> SRR1655014     2  0.0000      1.000  0 1.000 0.000 0.000
#> SRR1655015     2  0.0000      1.000  0 1.000 0.000 0.000
#> SRR1655016     2  0.0000      1.000  0 1.000 0.000 0.000
#> SRR1655017     2  0.0000      1.000  0 1.000 0.000 0.000
#> SRR1655018     2  0.0000      1.000  0 1.000 0.000 0.000
#> SRR1655019     2  0.0000      1.000  0 1.000 0.000 0.000
#> SRR1655020     2  0.0000      1.000  0 1.000 0.000 0.000
#> SRR1655021     2  0.0000      1.000  0 1.000 0.000 0.000
#> SRR1655022     2  0.0000      1.000  0 1.000 0.000 0.000
#> SRR1655023     2  0.0000      1.000  0 1.000 0.000 0.000
#> SRR1655024     2  0.0000      1.000  0 1.000 0.000 0.000
#> SRR1655025     2  0.0000      1.000  0 1.000 0.000 0.000
#> SRR1655026     4  0.0188      0.997  0 0.004 0.000 0.996
#> SRR1655027     4  0.0188      0.997  0 0.004 0.000 0.996
#> SRR1655028     4  0.0188      0.997  0 0.004 0.000 0.996
#> SRR1655029     4  0.0188      0.997  0 0.004 0.000 0.996
#> SRR1655030     4  0.0188      0.997  0 0.004 0.000 0.996
#> SRR1655031     4  0.0188      0.997  0 0.004 0.000 0.996
#> SRR1655032     4  0.0188      0.997  0 0.004 0.000 0.996
#> SRR1655033     4  0.0188      0.997  0 0.004 0.000 0.996
#> SRR1655034     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR1655035     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR1655036     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR1655037     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR1655038     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR1655039     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR1655040     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR1655041     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR1655042     2  0.0000      1.000  0 1.000 0.000 0.000
#> SRR1655043     2  0.0000      1.000  0 1.000 0.000 0.000
#> SRR1655044     2  0.0000      1.000  0 1.000 0.000 0.000
#> SRR1655045     2  0.0000      1.000  0 1.000 0.000 0.000
#> SRR1655046     2  0.0000      1.000  0 1.000 0.000 0.000
#> SRR1655047     2  0.0000      1.000  0 1.000 0.000 0.000
#> SRR1655048     2  0.0000      1.000  0 1.000 0.000 0.000
#> SRR1655049     2  0.0000      1.000  0 1.000 0.000 0.000
#> SRR1655050     4  0.0188      0.997  0 0.000 0.004 0.996
#> SRR1655051     4  0.0188      0.997  0 0.000 0.004 0.996
#> SRR1655052     4  0.0188      0.997  0 0.000 0.004 0.996
#> SRR1655053     4  0.0188      0.997  0 0.000 0.004 0.996
#> SRR1655054     4  0.0188      0.997  0 0.000 0.004 0.996
#> SRR1655055     4  0.0188      0.997  0 0.000 0.004 0.996
#> SRR1655056     4  0.0188      0.997  0 0.000 0.004 0.996
#> SRR1655057     4  0.0188      0.997  0 0.000 0.004 0.996

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2 p3    p4    p5
#> SRR1655002     1  0.0000      0.999 1.000 0.000  0 0.000 0.000
#> SRR1655003     1  0.0162      0.998 0.996 0.000  0 0.004 0.000
#> SRR1655004     1  0.0000      0.999 1.000 0.000  0 0.000 0.000
#> SRR1655005     1  0.0162      0.998 0.996 0.000  0 0.004 0.000
#> SRR1655006     1  0.0000      0.999 1.000 0.000  0 0.000 0.000
#> SRR1655007     1  0.0000      0.999 1.000 0.000  0 0.000 0.000
#> SRR1655008     1  0.0162      0.998 0.996 0.000  0 0.004 0.000
#> SRR1655009     1  0.0162      0.998 0.996 0.000  0 0.004 0.000
#> SRR1655010     1  0.0000      0.999 1.000 0.000  0 0.000 0.000
#> SRR1655011     1  0.0000      0.999 1.000 0.000  0 0.000 0.000
#> SRR1655012     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR1655013     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR1655014     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR1655015     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR1655016     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR1655017     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR1655018     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR1655019     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR1655020     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR1655021     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR1655022     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR1655023     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR1655024     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR1655025     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR1655026     4  0.3305      0.839 0.000 0.000  0 0.776 0.224
#> SRR1655027     4  0.3305      0.839 0.000 0.000  0 0.776 0.224
#> SRR1655028     4  0.3305      0.839 0.000 0.000  0 0.776 0.224
#> SRR1655029     4  0.3305      0.839 0.000 0.000  0 0.776 0.224
#> SRR1655030     4  0.3305      0.839 0.000 0.000  0 0.776 0.224
#> SRR1655031     4  0.3305      0.839 0.000 0.000  0 0.776 0.224
#> SRR1655032     4  0.3305      0.839 0.000 0.000  0 0.776 0.224
#> SRR1655033     4  0.3305      0.839 0.000 0.000  0 0.776 0.224
#> SRR1655034     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1655035     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1655036     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1655037     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1655038     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1655039     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1655040     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1655041     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1655042     4  0.0510      0.858 0.000 0.016  0 0.984 0.000
#> SRR1655043     4  0.0510      0.858 0.000 0.016  0 0.984 0.000
#> SRR1655044     4  0.0510      0.858 0.000 0.016  0 0.984 0.000
#> SRR1655045     4  0.0510      0.858 0.000 0.016  0 0.984 0.000
#> SRR1655046     4  0.0510      0.858 0.000 0.016  0 0.984 0.000
#> SRR1655047     4  0.0510      0.858 0.000 0.016  0 0.984 0.000
#> SRR1655048     4  0.0510      0.858 0.000 0.016  0 0.984 0.000
#> SRR1655049     4  0.0510      0.858 0.000 0.016  0 0.984 0.000
#> SRR1655050     5  0.0000      1.000 0.000 0.000  0 0.000 1.000
#> SRR1655051     5  0.0000      1.000 0.000 0.000  0 0.000 1.000
#> SRR1655052     5  0.0000      1.000 0.000 0.000  0 0.000 1.000
#> SRR1655053     5  0.0000      1.000 0.000 0.000  0 0.000 1.000
#> SRR1655054     5  0.0000      1.000 0.000 0.000  0 0.000 1.000
#> SRR1655055     5  0.0000      1.000 0.000 0.000  0 0.000 1.000
#> SRR1655056     5  0.0000      1.000 0.000 0.000  0 0.000 1.000
#> SRR1655057     5  0.0000      1.000 0.000 0.000  0 0.000 1.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
#> SRR1655002     1  0.1267      0.974 0.940 0.000  0 0.060 0.000 0.000
#> SRR1655003     1  0.1007      0.974 0.956 0.000  0 0.044 0.000 0.000
#> SRR1655004     1  0.0260      0.984 0.992 0.000  0 0.008 0.000 0.000
#> SRR1655005     1  0.1007      0.974 0.956 0.000  0 0.044 0.000 0.000
#> SRR1655006     1  0.0458      0.983 0.984 0.000  0 0.016 0.000 0.000
#> SRR1655007     1  0.0547      0.981 0.980 0.000  0 0.020 0.000 0.000
#> SRR1655008     1  0.0000      0.983 1.000 0.000  0 0.000 0.000 0.000
#> SRR1655009     1  0.0000      0.983 1.000 0.000  0 0.000 0.000 0.000
#> SRR1655010     1  0.0458      0.983 0.984 0.000  0 0.016 0.000 0.000
#> SRR1655011     1  0.0458      0.983 0.984 0.000  0 0.016 0.000 0.000
#> SRR1655012     2  0.0146      0.998 0.000 0.996  0 0.004 0.000 0.000
#> SRR1655013     2  0.0146      0.998 0.000 0.996  0 0.004 0.000 0.000
#> SRR1655014     2  0.0146      0.998 0.000 0.996  0 0.004 0.000 0.000
#> SRR1655015     2  0.0146      0.998 0.000 0.996  0 0.004 0.000 0.000
#> SRR1655016     2  0.0146      0.998 0.000 0.996  0 0.004 0.000 0.000
#> SRR1655017     2  0.0146      0.998 0.000 0.996  0 0.004 0.000 0.000
#> SRR1655018     2  0.0000      0.999 0.000 1.000  0 0.000 0.000 0.000
#> SRR1655019     2  0.0000      0.999 0.000 1.000  0 0.000 0.000 0.000
#> SRR1655020     2  0.0000      0.999 0.000 1.000  0 0.000 0.000 0.000
#> SRR1655021     2  0.0000      0.999 0.000 1.000  0 0.000 0.000 0.000
#> SRR1655022     2  0.0000      0.999 0.000 1.000  0 0.000 0.000 0.000
#> SRR1655023     2  0.0000      0.999 0.000 1.000  0 0.000 0.000 0.000
#> SRR1655024     2  0.0000      0.999 0.000 1.000  0 0.000 0.000 0.000
#> SRR1655025     2  0.0000      0.999 0.000 1.000  0 0.000 0.000 0.000
#> SRR1655026     4  0.3167      0.998 0.000 0.000  0 0.832 0.096 0.072
#> SRR1655027     4  0.3167      0.998 0.000 0.000  0 0.832 0.096 0.072
#> SRR1655028     4  0.3172      0.995 0.000 0.000  0 0.832 0.092 0.076
#> SRR1655029     4  0.3167      0.998 0.000 0.000  0 0.832 0.096 0.072
#> SRR1655030     4  0.3167      0.998 0.000 0.000  0 0.832 0.096 0.072
#> SRR1655031     4  0.3167      0.998 0.000 0.000  0 0.832 0.096 0.072
#> SRR1655032     4  0.3172      0.995 0.000 0.000  0 0.832 0.092 0.076
#> SRR1655033     4  0.3167      0.998 0.000 0.000  0 0.832 0.096 0.072
#> SRR1655034     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1655035     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1655036     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1655037     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1655038     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1655039     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1655040     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1655041     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1655042     6  0.0000      1.000 0.000 0.000  0 0.000 0.000 1.000
#> SRR1655043     6  0.0000      1.000 0.000 0.000  0 0.000 0.000 1.000
#> SRR1655044     6  0.0000      1.000 0.000 0.000  0 0.000 0.000 1.000
#> SRR1655045     6  0.0000      1.000 0.000 0.000  0 0.000 0.000 1.000
#> SRR1655046     6  0.0000      1.000 0.000 0.000  0 0.000 0.000 1.000
#> SRR1655047     6  0.0000      1.000 0.000 0.000  0 0.000 0.000 1.000
#> SRR1655048     6  0.0000      1.000 0.000 0.000  0 0.000 0.000 1.000
#> SRR1655049     6  0.0000      1.000 0.000 0.000  0 0.000 0.000 1.000
#> SRR1655050     5  0.0000      1.000 0.000 0.000  0 0.000 1.000 0.000
#> SRR1655051     5  0.0000      1.000 0.000 0.000  0 0.000 1.000 0.000
#> SRR1655052     5  0.0000      1.000 0.000 0.000  0 0.000 1.000 0.000
#> SRR1655053     5  0.0000      1.000 0.000 0.000  0 0.000 1.000 0.000
#> SRR1655054     5  0.0000      1.000 0.000 0.000  0 0.000 1.000 0.000
#> SRR1655055     5  0.0000      1.000 0.000 0.000  0 0.000 1.000 0.000
#> SRR1655056     5  0.0000      1.000 0.000 0.000  0 0.000 1.000 0.000
#> SRR1655057     5  0.0000      1.000 0.000 0.000  0 0.000 1.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 15837 rows and 56 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 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-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               1           1         0.2994 0.701   0.701
#> 3 3     1               1           1         0.6587 0.803   0.719
#> 4 4     1               1           1         0.4598 0.771   0.546
#> 5 5     1               1           1         0.1002 0.927   0.736
#> 6 6     1               1           1         0.0521 0.958   0.795

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette p1 p2
#> SRR1655002     1       0          1  1  0
#> SRR1655003     1       0          1  1  0
#> SRR1655004     1       0          1  1  0
#> SRR1655005     1       0          1  1  0
#> SRR1655006     1       0          1  1  0
#> SRR1655007     1       0          1  1  0
#> SRR1655008     1       0          1  1  0
#> SRR1655009     1       0          1  1  0
#> SRR1655010     1       0          1  1  0
#> SRR1655011     1       0          1  1  0
#> SRR1655012     2       0          1  0  1
#> SRR1655013     2       0          1  0  1
#> SRR1655014     2       0          1  0  1
#> SRR1655015     2       0          1  0  1
#> SRR1655016     2       0          1  0  1
#> SRR1655017     2       0          1  0  1
#> SRR1655018     2       0          1  0  1
#> SRR1655019     2       0          1  0  1
#> SRR1655020     2       0          1  0  1
#> SRR1655021     2       0          1  0  1
#> SRR1655022     2       0          1  0  1
#> SRR1655023     2       0          1  0  1
#> SRR1655024     2       0          1  0  1
#> SRR1655025     2       0          1  0  1
#> SRR1655026     2       0          1  0  1
#> SRR1655027     2       0          1  0  1
#> SRR1655028     2       0          1  0  1
#> SRR1655029     2       0          1  0  1
#> SRR1655030     2       0          1  0  1
#> SRR1655031     2       0          1  0  1
#> SRR1655032     2       0          1  0  1
#> SRR1655033     2       0          1  0  1
#> SRR1655034     2       0          1  0  1
#> SRR1655035     2       0          1  0  1
#> SRR1655036     2       0          1  0  1
#> SRR1655037     2       0          1  0  1
#> SRR1655038     2       0          1  0  1
#> SRR1655039     2       0          1  0  1
#> SRR1655040     2       0          1  0  1
#> SRR1655041     2       0          1  0  1
#> SRR1655042     2       0          1  0  1
#> SRR1655043     2       0          1  0  1
#> SRR1655044     2       0          1  0  1
#> SRR1655045     2       0          1  0  1
#> SRR1655046     2       0          1  0  1
#> SRR1655047     2       0          1  0  1
#> SRR1655048     2       0          1  0  1
#> SRR1655049     2       0          1  0  1
#> SRR1655050     2       0          1  0  1
#> SRR1655051     2       0          1  0  1
#> SRR1655052     2       0          1  0  1
#> SRR1655053     2       0          1  0  1
#> SRR1655054     2       0          1  0  1
#> SRR1655055     2       0          1  0  1
#> SRR1655056     2       0          1  0  1
#> SRR1655057     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
#> SRR1655002     1       0          1  1  0  0
#> SRR1655003     1       0          1  1  0  0
#> SRR1655004     1       0          1  1  0  0
#> SRR1655005     1       0          1  1  0  0
#> SRR1655006     1       0          1  1  0  0
#> SRR1655007     1       0          1  1  0  0
#> SRR1655008     1       0          1  1  0  0
#> SRR1655009     1       0          1  1  0  0
#> SRR1655010     1       0          1  1  0  0
#> SRR1655011     1       0          1  1  0  0
#> SRR1655012     2       0          1  0  1  0
#> SRR1655013     2       0          1  0  1  0
#> SRR1655014     2       0          1  0  1  0
#> SRR1655015     2       0          1  0  1  0
#> SRR1655016     2       0          1  0  1  0
#> SRR1655017     2       0          1  0  1  0
#> SRR1655018     2       0          1  0  1  0
#> SRR1655019     2       0          1  0  1  0
#> SRR1655020     2       0          1  0  1  0
#> SRR1655021     2       0          1  0  1  0
#> SRR1655022     2       0          1  0  1  0
#> SRR1655023     2       0          1  0  1  0
#> SRR1655024     2       0          1  0  1  0
#> SRR1655025     2       0          1  0  1  0
#> SRR1655026     2       0          1  0  1  0
#> SRR1655027     2       0          1  0  1  0
#> SRR1655028     2       0          1  0  1  0
#> SRR1655029     2       0          1  0  1  0
#> SRR1655030     2       0          1  0  1  0
#> SRR1655031     2       0          1  0  1  0
#> SRR1655032     2       0          1  0  1  0
#> SRR1655033     2       0          1  0  1  0
#> SRR1655034     3       0          1  0  0  1
#> SRR1655035     3       0          1  0  0  1
#> SRR1655036     3       0          1  0  0  1
#> SRR1655037     3       0          1  0  0  1
#> SRR1655038     3       0          1  0  0  1
#> SRR1655039     3       0          1  0  0  1
#> SRR1655040     3       0          1  0  0  1
#> SRR1655041     3       0          1  0  0  1
#> SRR1655042     2       0          1  0  1  0
#> SRR1655043     2       0          1  0  1  0
#> SRR1655044     2       0          1  0  1  0
#> SRR1655045     2       0          1  0  1  0
#> SRR1655046     2       0          1  0  1  0
#> SRR1655047     2       0          1  0  1  0
#> SRR1655048     2       0          1  0  1  0
#> SRR1655049     2       0          1  0  1  0
#> SRR1655050     2       0          1  0  1  0
#> SRR1655051     2       0          1  0  1  0
#> SRR1655052     2       0          1  0  1  0
#> SRR1655053     2       0          1  0  1  0
#> SRR1655054     2       0          1  0  1  0
#> SRR1655055     2       0          1  0  1  0
#> SRR1655056     2       0          1  0  1  0
#> SRR1655057     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
#> SRR1655002     1       0          1  1  0  0  0
#> SRR1655003     1       0          1  1  0  0  0
#> SRR1655004     1       0          1  1  0  0  0
#> SRR1655005     1       0          1  1  0  0  0
#> SRR1655006     1       0          1  1  0  0  0
#> SRR1655007     1       0          1  1  0  0  0
#> SRR1655008     1       0          1  1  0  0  0
#> SRR1655009     1       0          1  1  0  0  0
#> SRR1655010     1       0          1  1  0  0  0
#> SRR1655011     1       0          1  1  0  0  0
#> SRR1655012     2       0          1  0  1  0  0
#> SRR1655013     2       0          1  0  1  0  0
#> SRR1655014     2       0          1  0  1  0  0
#> SRR1655015     2       0          1  0  1  0  0
#> SRR1655016     2       0          1  0  1  0  0
#> SRR1655017     2       0          1  0  1  0  0
#> SRR1655018     2       0          1  0  1  0  0
#> SRR1655019     2       0          1  0  1  0  0
#> SRR1655020     2       0          1  0  1  0  0
#> SRR1655021     2       0          1  0  1  0  0
#> SRR1655022     2       0          1  0  1  0  0
#> SRR1655023     2       0          1  0  1  0  0
#> SRR1655024     2       0          1  0  1  0  0
#> SRR1655025     2       0          1  0  1  0  0
#> SRR1655026     4       0          1  0  0  0  1
#> SRR1655027     4       0          1  0  0  0  1
#> SRR1655028     4       0          1  0  0  0  1
#> SRR1655029     4       0          1  0  0  0  1
#> SRR1655030     4       0          1  0  0  0  1
#> SRR1655031     4       0          1  0  0  0  1
#> SRR1655032     4       0          1  0  0  0  1
#> SRR1655033     4       0          1  0  0  0  1
#> SRR1655034     3       0          1  0  0  1  0
#> SRR1655035     3       0          1  0  0  1  0
#> SRR1655036     3       0          1  0  0  1  0
#> SRR1655037     3       0          1  0  0  1  0
#> SRR1655038     3       0          1  0  0  1  0
#> SRR1655039     3       0          1  0  0  1  0
#> SRR1655040     3       0          1  0  0  1  0
#> SRR1655041     3       0          1  0  0  1  0
#> SRR1655042     2       0          1  0  1  0  0
#> SRR1655043     2       0          1  0  1  0  0
#> SRR1655044     2       0          1  0  1  0  0
#> SRR1655045     2       0          1  0  1  0  0
#> SRR1655046     2       0          1  0  1  0  0
#> SRR1655047     2       0          1  0  1  0  0
#> SRR1655048     2       0          1  0  1  0  0
#> SRR1655049     2       0          1  0  1  0  0
#> SRR1655050     4       0          1  0  0  0  1
#> SRR1655051     4       0          1  0  0  0  1
#> SRR1655052     4       0          1  0  0  0  1
#> SRR1655053     4       0          1  0  0  0  1
#> SRR1655054     4       0          1  0  0  0  1
#> SRR1655055     4       0          1  0  0  0  1
#> SRR1655056     4       0          1  0  0  0  1
#> SRR1655057     4       0          1  0  0  0  1

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette p1 p2 p3 p4 p5
#> SRR1655002     1       0          1  1  0  0  0  0
#> SRR1655003     1       0          1  1  0  0  0  0
#> SRR1655004     1       0          1  1  0  0  0  0
#> SRR1655005     1       0          1  1  0  0  0  0
#> SRR1655006     1       0          1  1  0  0  0  0
#> SRR1655007     1       0          1  1  0  0  0  0
#> SRR1655008     1       0          1  1  0  0  0  0
#> SRR1655009     1       0          1  1  0  0  0  0
#> SRR1655010     1       0          1  1  0  0  0  0
#> SRR1655011     1       0          1  1  0  0  0  0
#> SRR1655012     2       0          1  0  1  0  0  0
#> SRR1655013     2       0          1  0  1  0  0  0
#> SRR1655014     2       0          1  0  1  0  0  0
#> SRR1655015     2       0          1  0  1  0  0  0
#> SRR1655016     2       0          1  0  1  0  0  0
#> SRR1655017     2       0          1  0  1  0  0  0
#> SRR1655018     2       0          1  0  1  0  0  0
#> SRR1655019     2       0          1  0  1  0  0  0
#> SRR1655020     2       0          1  0  1  0  0  0
#> SRR1655021     2       0          1  0  1  0  0  0
#> SRR1655022     2       0          1  0  1  0  0  0
#> SRR1655023     2       0          1  0  1  0  0  0
#> SRR1655024     2       0          1  0  1  0  0  0
#> SRR1655025     2       0          1  0  1  0  0  0
#> SRR1655026     5       0          1  0  0  0  0  1
#> SRR1655027     5       0          1  0  0  0  0  1
#> SRR1655028     5       0          1  0  0  0  0  1
#> SRR1655029     5       0          1  0  0  0  0  1
#> SRR1655030     5       0          1  0  0  0  0  1
#> SRR1655031     5       0          1  0  0  0  0  1
#> SRR1655032     5       0          1  0  0  0  0  1
#> SRR1655033     5       0          1  0  0  0  0  1
#> SRR1655034     3       0          1  0  0  1  0  0
#> SRR1655035     3       0          1  0  0  1  0  0
#> SRR1655036     3       0          1  0  0  1  0  0
#> SRR1655037     3       0          1  0  0  1  0  0
#> SRR1655038     3       0          1  0  0  1  0  0
#> SRR1655039     3       0          1  0  0  1  0  0
#> SRR1655040     3       0          1  0  0  1  0  0
#> SRR1655041     3       0          1  0  0  1  0  0
#> SRR1655042     4       0          1  0  0  0  1  0
#> SRR1655043     4       0          1  0  0  0  1  0
#> SRR1655044     4       0          1  0  0  0  1  0
#> SRR1655045     4       0          1  0  0  0  1  0
#> SRR1655046     4       0          1  0  0  0  1  0
#> SRR1655047     4       0          1  0  0  0  1  0
#> SRR1655048     4       0          1  0  0  0  1  0
#> SRR1655049     4       0          1  0  0  0  1  0
#> SRR1655050     5       0          1  0  0  0  0  1
#> SRR1655051     5       0          1  0  0  0  0  1
#> SRR1655052     5       0          1  0  0  0  0  1
#> SRR1655053     5       0          1  0  0  0  0  1
#> SRR1655054     5       0          1  0  0  0  0  1
#> SRR1655055     5       0          1  0  0  0  0  1
#> SRR1655056     5       0          1  0  0  0  0  1
#> SRR1655057     5       0          1  0  0  0  0  1

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1655002     1       0          1  1  0  0  0  0  0
#> SRR1655003     1       0          1  1  0  0  0  0  0
#> SRR1655004     1       0          1  1  0  0  0  0  0
#> SRR1655005     1       0          1  1  0  0  0  0  0
#> SRR1655006     1       0          1  1  0  0  0  0  0
#> SRR1655007     1       0          1  1  0  0  0  0  0
#> SRR1655008     1       0          1  1  0  0  0  0  0
#> SRR1655009     1       0          1  1  0  0  0  0  0
#> SRR1655010     1       0          1  1  0  0  0  0  0
#> SRR1655011     1       0          1  1  0  0  0  0  0
#> SRR1655012     2       0          1  0  1  0  0  0  0
#> SRR1655013     2       0          1  0  1  0  0  0  0
#> SRR1655014     2       0          1  0  1  0  0  0  0
#> SRR1655015     2       0          1  0  1  0  0  0  0
#> SRR1655016     2       0          1  0  1  0  0  0  0
#> SRR1655017     2       0          1  0  1  0  0  0  0
#> SRR1655018     2       0          1  0  1  0  0  0  0
#> SRR1655019     2       0          1  0  1  0  0  0  0
#> SRR1655020     2       0          1  0  1  0  0  0  0
#> SRR1655021     2       0          1  0  1  0  0  0  0
#> SRR1655022     2       0          1  0  1  0  0  0  0
#> SRR1655023     2       0          1  0  1  0  0  0  0
#> SRR1655024     2       0          1  0  1  0  0  0  0
#> SRR1655025     2       0          1  0  1  0  0  0  0
#> SRR1655026     4       0          1  0  0  0  1  0  0
#> SRR1655027     4       0          1  0  0  0  1  0  0
#> SRR1655028     4       0          1  0  0  0  1  0  0
#> SRR1655029     4       0          1  0  0  0  1  0  0
#> SRR1655030     4       0          1  0  0  0  1  0  0
#> SRR1655031     4       0          1  0  0  0  1  0  0
#> SRR1655032     4       0          1  0  0  0  1  0  0
#> SRR1655033     4       0          1  0  0  0  1  0  0
#> SRR1655034     3       0          1  0  0  1  0  0  0
#> SRR1655035     3       0          1  0  0  1  0  0  0
#> SRR1655036     3       0          1  0  0  1  0  0  0
#> SRR1655037     3       0          1  0  0  1  0  0  0
#> SRR1655038     3       0          1  0  0  1  0  0  0
#> SRR1655039     3       0          1  0  0  1  0  0  0
#> SRR1655040     3       0          1  0  0  1  0  0  0
#> SRR1655041     3       0          1  0  0  1  0  0  0
#> SRR1655042     6       0          1  0  0  0  0  0  1
#> SRR1655043     6       0          1  0  0  0  0  0  1
#> SRR1655044     6       0          1  0  0  0  0  0  1
#> SRR1655045     6       0          1  0  0  0  0  0  1
#> SRR1655046     6       0          1  0  0  0  0  0  1
#> SRR1655047     6       0          1  0  0  0  0  0  1
#> SRR1655048     6       0          1  0  0  0  0  0  1
#> SRR1655049     6       0          1  0  0  0  0  0  1
#> SRR1655050     5       0          1  0  0  0  0  1  0
#> SRR1655051     5       0          1  0  0  0  0  1  0
#> SRR1655052     5       0          1  0  0  0  0  1  0
#> SRR1655053     5       0          1  0  0  0  0  1  0
#> SRR1655054     5       0          1  0  0  0  0  1  0
#> SRR1655055     5       0          1  0  0  0  0  1  0
#> SRR1655056     5       0          1  0  0  0  0  1  0
#> SRR1655057     5       0          1  0  0  0  0  1  0

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

consensus_heatmap(res, k = 2)

plot of chunk tab-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 15837 rows and 56 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 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-kmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.844           0.957       0.963         0.3211 0.701   0.701
#> 3 3 0.418           0.678       0.805         0.8175 0.688   0.556
#> 4 4 0.550           0.757       0.773         0.1765 0.803   0.542
#> 5 5 0.717           0.813       0.788         0.1133 0.927   0.736
#> 6 6 0.728           0.887       0.693         0.0495 0.958   0.795

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

suggest_best_k(res)
#> [1] 5

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette    p1    p2
#> SRR1655002     1   0.204      1.000 0.968 0.032
#> SRR1655003     1   0.204      1.000 0.968 0.032
#> SRR1655004     1   0.204      1.000 0.968 0.032
#> SRR1655005     1   0.204      1.000 0.968 0.032
#> SRR1655006     1   0.204      1.000 0.968 0.032
#> SRR1655007     1   0.204      1.000 0.968 0.032
#> SRR1655008     1   0.204      1.000 0.968 0.032
#> SRR1655009     1   0.204      1.000 0.968 0.032
#> SRR1655010     1   0.204      1.000 0.968 0.032
#> SRR1655011     1   0.204      1.000 0.968 0.032
#> SRR1655012     2   0.163      0.963 0.024 0.976
#> SRR1655013     2   0.163      0.963 0.024 0.976
#> SRR1655014     2   0.163      0.963 0.024 0.976
#> SRR1655015     2   0.163      0.963 0.024 0.976
#> SRR1655016     2   0.163      0.963 0.024 0.976
#> SRR1655017     2   0.163      0.963 0.024 0.976
#> SRR1655018     2   0.163      0.963 0.024 0.976
#> SRR1655019     2   0.163      0.963 0.024 0.976
#> SRR1655020     2   0.163      0.963 0.024 0.976
#> SRR1655021     2   0.163      0.963 0.024 0.976
#> SRR1655022     2   0.163      0.963 0.024 0.976
#> SRR1655023     2   0.163      0.963 0.024 0.976
#> SRR1655024     2   0.163      0.963 0.024 0.976
#> SRR1655025     2   0.163      0.963 0.024 0.976
#> SRR1655026     2   0.000      0.960 0.000 1.000
#> SRR1655027     2   0.000      0.960 0.000 1.000
#> SRR1655028     2   0.000      0.960 0.000 1.000
#> SRR1655029     2   0.000      0.960 0.000 1.000
#> SRR1655030     2   0.000      0.960 0.000 1.000
#> SRR1655031     2   0.000      0.960 0.000 1.000
#> SRR1655032     2   0.000      0.960 0.000 1.000
#> SRR1655033     2   0.000      0.960 0.000 1.000
#> SRR1655034     2   0.541      0.892 0.124 0.876
#> SRR1655035     2   0.541      0.892 0.124 0.876
#> SRR1655036     2   0.541      0.892 0.124 0.876
#> SRR1655037     2   0.541      0.892 0.124 0.876
#> SRR1655038     2   0.541      0.892 0.124 0.876
#> SRR1655039     2   0.541      0.892 0.124 0.876
#> SRR1655040     2   0.541      0.892 0.124 0.876
#> SRR1655041     2   0.541      0.892 0.124 0.876
#> SRR1655042     2   0.163      0.963 0.024 0.976
#> SRR1655043     2   0.163      0.963 0.024 0.976
#> SRR1655044     2   0.163      0.963 0.024 0.976
#> SRR1655045     2   0.163      0.963 0.024 0.976
#> SRR1655046     2   0.163      0.963 0.024 0.976
#> SRR1655047     2   0.163      0.963 0.024 0.976
#> SRR1655048     2   0.163      0.963 0.024 0.976
#> SRR1655049     2   0.163      0.963 0.024 0.976
#> SRR1655050     2   0.204      0.949 0.032 0.968
#> SRR1655051     2   0.204      0.949 0.032 0.968
#> SRR1655052     2   0.204      0.949 0.032 0.968
#> SRR1655053     2   0.204      0.949 0.032 0.968
#> SRR1655054     2   0.204      0.949 0.032 0.968
#> SRR1655055     2   0.204      0.949 0.032 0.968
#> SRR1655056     2   0.204      0.949 0.032 0.968
#> SRR1655057     2   0.204      0.949 0.032 0.968

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1655002     1  0.1964      0.978 0.944 0.000 0.056
#> SRR1655003     1  0.0000      0.978 1.000 0.000 0.000
#> SRR1655004     1  0.0000      0.978 1.000 0.000 0.000
#> SRR1655005     1  0.0000      0.978 1.000 0.000 0.000
#> SRR1655006     1  0.1964      0.978 0.944 0.000 0.056
#> SRR1655007     1  0.2066      0.978 0.940 0.000 0.060
#> SRR1655008     1  0.0237      0.978 0.996 0.000 0.004
#> SRR1655009     1  0.0237      0.978 0.996 0.000 0.004
#> SRR1655010     1  0.2066      0.978 0.940 0.000 0.060
#> SRR1655011     1  0.2066      0.978 0.940 0.000 0.060
#> SRR1655012     2  0.1031      0.745 0.000 0.976 0.024
#> SRR1655013     2  0.1031      0.745 0.000 0.976 0.024
#> SRR1655014     2  0.1163      0.743 0.000 0.972 0.028
#> SRR1655015     2  0.1163      0.743 0.000 0.972 0.028
#> SRR1655016     2  0.1031      0.745 0.000 0.976 0.024
#> SRR1655017     2  0.1031      0.745 0.000 0.976 0.024
#> SRR1655018     2  0.1031      0.744 0.000 0.976 0.024
#> SRR1655019     2  0.1031      0.744 0.000 0.976 0.024
#> SRR1655020     2  0.1031      0.744 0.000 0.976 0.024
#> SRR1655021     2  0.1031      0.744 0.000 0.976 0.024
#> SRR1655022     2  0.1031      0.744 0.000 0.976 0.024
#> SRR1655023     2  0.1031      0.744 0.000 0.976 0.024
#> SRR1655024     2  0.1031      0.744 0.000 0.976 0.024
#> SRR1655025     2  0.1031      0.744 0.000 0.976 0.024
#> SRR1655026     2  0.6291      0.273 0.000 0.532 0.468
#> SRR1655027     2  0.6291      0.273 0.000 0.532 0.468
#> SRR1655028     2  0.6291      0.273 0.000 0.532 0.468
#> SRR1655029     2  0.6291      0.273 0.000 0.532 0.468
#> SRR1655030     2  0.6291      0.273 0.000 0.532 0.468
#> SRR1655031     2  0.6291      0.273 0.000 0.532 0.468
#> SRR1655032     2  0.6291      0.273 0.000 0.532 0.468
#> SRR1655033     2  0.6291      0.273 0.000 0.532 0.468
#> SRR1655034     3  0.7256      0.685 0.124 0.164 0.712
#> SRR1655035     3  0.7256      0.685 0.124 0.164 0.712
#> SRR1655036     3  0.7256      0.685 0.124 0.164 0.712
#> SRR1655037     3  0.7256      0.685 0.124 0.164 0.712
#> SRR1655038     3  0.7256      0.685 0.124 0.164 0.712
#> SRR1655039     3  0.7256      0.685 0.124 0.164 0.712
#> SRR1655040     3  0.7256      0.685 0.124 0.164 0.712
#> SRR1655041     3  0.7256      0.685 0.124 0.164 0.712
#> SRR1655042     2  0.4346      0.690 0.000 0.816 0.184
#> SRR1655043     2  0.4346      0.690 0.000 0.816 0.184
#> SRR1655044     2  0.4346      0.690 0.000 0.816 0.184
#> SRR1655045     2  0.4346      0.690 0.000 0.816 0.184
#> SRR1655046     2  0.4346      0.690 0.000 0.816 0.184
#> SRR1655047     2  0.4346      0.690 0.000 0.816 0.184
#> SRR1655048     2  0.1964      0.735 0.000 0.944 0.056
#> SRR1655049     2  0.1964      0.735 0.000 0.944 0.056
#> SRR1655050     3  0.5465      0.562 0.000 0.288 0.712
#> SRR1655051     3  0.5465      0.562 0.000 0.288 0.712
#> SRR1655052     3  0.5465      0.562 0.000 0.288 0.712
#> SRR1655053     3  0.5465      0.562 0.000 0.288 0.712
#> SRR1655054     3  0.5465      0.562 0.000 0.288 0.712
#> SRR1655055     3  0.5465      0.562 0.000 0.288 0.712
#> SRR1655056     3  0.5465      0.562 0.000 0.288 0.712
#> SRR1655057     3  0.5465      0.562 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
#> SRR1655002     1  0.0817      0.944 0.976 0.000 0.024 0.000
#> SRR1655003     1  0.3247      0.945 0.880 0.000 0.060 0.060
#> SRR1655004     1  0.3247      0.945 0.880 0.000 0.060 0.060
#> SRR1655005     1  0.3247      0.945 0.880 0.000 0.060 0.060
#> SRR1655006     1  0.0817      0.944 0.976 0.000 0.024 0.000
#> SRR1655007     1  0.0469      0.944 0.988 0.000 0.000 0.012
#> SRR1655008     1  0.2996      0.945 0.892 0.000 0.044 0.064
#> SRR1655009     1  0.2996      0.945 0.892 0.000 0.044 0.064
#> SRR1655010     1  0.0469      0.944 0.988 0.000 0.000 0.012
#> SRR1655011     1  0.0469      0.944 0.988 0.000 0.000 0.012
#> SRR1655012     2  0.2021      0.756 0.000 0.932 0.056 0.012
#> SRR1655013     2  0.2021      0.756 0.000 0.932 0.056 0.012
#> SRR1655014     2  0.1557      0.753 0.000 0.944 0.056 0.000
#> SRR1655015     2  0.1557      0.753 0.000 0.944 0.056 0.000
#> SRR1655016     2  0.2021      0.756 0.000 0.932 0.056 0.012
#> SRR1655017     2  0.2021      0.756 0.000 0.932 0.056 0.012
#> SRR1655018     2  0.0188      0.770 0.000 0.996 0.000 0.004
#> SRR1655019     2  0.0188      0.770 0.000 0.996 0.000 0.004
#> SRR1655020     2  0.0188      0.770 0.000 0.996 0.000 0.004
#> SRR1655021     2  0.0188      0.770 0.000 0.996 0.000 0.004
#> SRR1655022     2  0.0188      0.770 0.000 0.996 0.000 0.004
#> SRR1655023     2  0.0188      0.770 0.000 0.996 0.000 0.004
#> SRR1655024     2  0.0188      0.770 0.000 0.996 0.000 0.004
#> SRR1655025     2  0.0188      0.770 0.000 0.996 0.000 0.004
#> SRR1655026     4  0.3907      0.715 0.000 0.232 0.000 0.768
#> SRR1655027     4  0.3907      0.715 0.000 0.232 0.000 0.768
#> SRR1655028     4  0.3907      0.715 0.000 0.232 0.000 0.768
#> SRR1655029     4  0.3907      0.715 0.000 0.232 0.000 0.768
#> SRR1655030     4  0.3907      0.715 0.000 0.232 0.000 0.768
#> SRR1655031     4  0.3907      0.715 0.000 0.232 0.000 0.768
#> SRR1655032     4  0.3907      0.715 0.000 0.232 0.000 0.768
#> SRR1655033     4  0.3907      0.715 0.000 0.232 0.000 0.768
#> SRR1655034     3  0.6247      0.971 0.052 0.088 0.728 0.132
#> SRR1655035     3  0.6247      0.971 0.052 0.088 0.728 0.132
#> SRR1655036     3  0.6568      0.977 0.052 0.088 0.700 0.160
#> SRR1655037     3  0.6568      0.977 0.052 0.088 0.700 0.160
#> SRR1655038     3  0.6041      0.976 0.052 0.088 0.744 0.116
#> SRR1655039     3  0.6041      0.976 0.052 0.088 0.744 0.116
#> SRR1655040     3  0.6568      0.977 0.052 0.088 0.700 0.160
#> SRR1655041     3  0.6568      0.977 0.052 0.088 0.700 0.160
#> SRR1655042     2  0.6747      0.343 0.000 0.528 0.100 0.372
#> SRR1655043     2  0.6747      0.343 0.000 0.528 0.100 0.372
#> SRR1655044     2  0.6766      0.326 0.000 0.520 0.100 0.380
#> SRR1655045     2  0.6766      0.326 0.000 0.520 0.100 0.380
#> SRR1655046     2  0.6766      0.326 0.000 0.520 0.100 0.380
#> SRR1655047     2  0.6766      0.326 0.000 0.520 0.100 0.380
#> SRR1655048     2  0.5900      0.571 0.000 0.684 0.096 0.220
#> SRR1655049     2  0.5900      0.571 0.000 0.684 0.096 0.220
#> SRR1655050     4  0.6621      0.703 0.000 0.140 0.244 0.616
#> SRR1655051     4  0.6621      0.703 0.000 0.140 0.244 0.616
#> SRR1655052     4  0.6621      0.703 0.000 0.140 0.244 0.616
#> SRR1655053     4  0.6621      0.703 0.000 0.140 0.244 0.616
#> SRR1655054     4  0.6621      0.703 0.000 0.140 0.244 0.616
#> SRR1655055     4  0.6621      0.703 0.000 0.140 0.244 0.616
#> SRR1655056     4  0.6621      0.703 0.000 0.140 0.244 0.616
#> SRR1655057     4  0.6621      0.703 0.000 0.140 0.244 0.616

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4    p5
#> SRR1655002     1  0.1153      0.918 0.964 0.000 0.008 0.024 0.004
#> SRR1655003     1  0.4213      0.918 0.808 0.000 0.036 0.108 0.048
#> SRR1655004     1  0.4162      0.918 0.812 0.000 0.036 0.104 0.048
#> SRR1655005     1  0.4162      0.918 0.812 0.000 0.036 0.104 0.048
#> SRR1655006     1  0.1153      0.918 0.964 0.000 0.008 0.024 0.004
#> SRR1655007     1  0.0324      0.918 0.992 0.000 0.004 0.000 0.004
#> SRR1655008     1  0.3826      0.918 0.836 0.000 0.032 0.080 0.052
#> SRR1655009     1  0.3826      0.918 0.836 0.000 0.032 0.080 0.052
#> SRR1655010     1  0.0324      0.918 0.992 0.000 0.004 0.000 0.004
#> SRR1655011     1  0.0324      0.918 0.992 0.000 0.004 0.000 0.004
#> SRR1655012     2  0.1399      0.833 0.000 0.952 0.020 0.000 0.028
#> SRR1655013     2  0.1399      0.833 0.000 0.952 0.020 0.000 0.028
#> SRR1655014     2  0.1399      0.833 0.000 0.952 0.020 0.000 0.028
#> SRR1655015     2  0.1399      0.833 0.000 0.952 0.020 0.000 0.028
#> SRR1655016     2  0.1399      0.833 0.000 0.952 0.020 0.000 0.028
#> SRR1655017     2  0.1399      0.833 0.000 0.952 0.020 0.000 0.028
#> SRR1655018     2  0.2648      0.866 0.000 0.848 0.000 0.152 0.000
#> SRR1655019     2  0.2648      0.866 0.000 0.848 0.000 0.152 0.000
#> SRR1655020     2  0.2648      0.866 0.000 0.848 0.000 0.152 0.000
#> SRR1655021     2  0.2648      0.866 0.000 0.848 0.000 0.152 0.000
#> SRR1655022     2  0.2648      0.866 0.000 0.848 0.000 0.152 0.000
#> SRR1655023     2  0.2648      0.866 0.000 0.848 0.000 0.152 0.000
#> SRR1655024     2  0.2648      0.866 0.000 0.848 0.000 0.152 0.000
#> SRR1655025     2  0.2648      0.866 0.000 0.848 0.000 0.152 0.000
#> SRR1655026     5  0.5364      0.588 0.000 0.076 0.004 0.284 0.636
#> SRR1655027     5  0.5364      0.588 0.000 0.076 0.004 0.284 0.636
#> SRR1655028     5  0.5252      0.588 0.000 0.076 0.000 0.292 0.632
#> SRR1655029     5  0.5252      0.588 0.000 0.076 0.000 0.292 0.632
#> SRR1655030     5  0.5364      0.588 0.000 0.076 0.004 0.284 0.636
#> SRR1655031     5  0.5364      0.588 0.000 0.076 0.004 0.284 0.636
#> SRR1655032     5  0.5271      0.587 0.000 0.076 0.000 0.296 0.628
#> SRR1655033     5  0.5271      0.587 0.000 0.076 0.000 0.296 0.628
#> SRR1655034     3  0.3629      0.960 0.032 0.044 0.860 0.012 0.052
#> SRR1655035     3  0.3629      0.960 0.032 0.044 0.860 0.012 0.052
#> SRR1655036     3  0.4097      0.971 0.032 0.044 0.840 0.048 0.036
#> SRR1655037     3  0.4097      0.971 0.032 0.044 0.840 0.048 0.036
#> SRR1655038     3  0.2772      0.970 0.032 0.044 0.896 0.000 0.028
#> SRR1655039     3  0.2772      0.970 0.032 0.044 0.896 0.000 0.028
#> SRR1655040     3  0.3951      0.972 0.032 0.044 0.848 0.040 0.036
#> SRR1655041     3  0.3951      0.972 0.032 0.044 0.848 0.040 0.036
#> SRR1655042     4  0.4850      0.928 0.000 0.224 0.000 0.700 0.076
#> SRR1655043     4  0.4850      0.928 0.000 0.224 0.000 0.700 0.076
#> SRR1655044     4  0.4850      0.928 0.000 0.224 0.000 0.700 0.076
#> SRR1655045     4  0.4850      0.928 0.000 0.224 0.000 0.700 0.076
#> SRR1655046     4  0.4850      0.928 0.000 0.224 0.000 0.700 0.076
#> SRR1655047     4  0.4850      0.928 0.000 0.224 0.000 0.700 0.076
#> SRR1655048     4  0.4201      0.736 0.000 0.328 0.008 0.664 0.000
#> SRR1655049     4  0.4201      0.736 0.000 0.328 0.008 0.664 0.000
#> SRR1655050     5  0.5398      0.618 0.000 0.048 0.248 0.032 0.672
#> SRR1655051     5  0.5398      0.618 0.000 0.048 0.248 0.032 0.672
#> SRR1655052     5  0.5064      0.619 0.000 0.048 0.248 0.016 0.688
#> SRR1655053     5  0.5064      0.619 0.000 0.048 0.248 0.016 0.688
#> SRR1655054     5  0.5321      0.618 0.000 0.048 0.248 0.028 0.676
#> SRR1655055     5  0.5321      0.618 0.000 0.048 0.248 0.028 0.676
#> SRR1655056     5  0.5064      0.619 0.000 0.048 0.248 0.016 0.688
#> SRR1655057     5  0.5064      0.619 0.000 0.048 0.248 0.016 0.688

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR1655002     1  0.4923      0.832 0.668 0.000 0.004 0.000 0.184 0.144
#> SRR1655003     1  0.0146      0.833 0.996 0.000 0.000 0.000 0.000 0.004
#> SRR1655004     1  0.0000      0.833 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1655005     1  0.0000      0.833 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1655006     1  0.4923      0.832 0.668 0.000 0.004 0.000 0.184 0.144
#> SRR1655007     1  0.4934      0.832 0.628 0.000 0.000 0.000 0.264 0.108
#> SRR1655008     1  0.2215      0.831 0.916 0.000 0.020 0.008 0.024 0.032
#> SRR1655009     1  0.2215      0.831 0.916 0.000 0.020 0.008 0.024 0.032
#> SRR1655010     1  0.4934      0.832 0.628 0.000 0.000 0.000 0.264 0.108
#> SRR1655011     1  0.4934      0.832 0.628 0.000 0.000 0.000 0.264 0.108
#> SRR1655012     2  0.0291      0.796 0.000 0.992 0.000 0.004 0.000 0.004
#> SRR1655013     2  0.0291      0.796 0.000 0.992 0.000 0.004 0.000 0.004
#> SRR1655014     2  0.0632      0.796 0.000 0.976 0.000 0.000 0.024 0.000
#> SRR1655015     2  0.0632      0.796 0.000 0.976 0.000 0.000 0.024 0.000
#> SRR1655016     2  0.0291      0.796 0.000 0.992 0.000 0.004 0.000 0.004
#> SRR1655017     2  0.0291      0.796 0.000 0.992 0.000 0.004 0.000 0.004
#> SRR1655018     2  0.4699      0.850 0.000 0.704 0.012 0.000 0.100 0.184
#> SRR1655019     2  0.4699      0.850 0.000 0.704 0.012 0.000 0.100 0.184
#> SRR1655020     2  0.4699      0.850 0.000 0.704 0.012 0.000 0.100 0.184
#> SRR1655021     2  0.4699      0.850 0.000 0.704 0.012 0.000 0.100 0.184
#> SRR1655022     2  0.4647      0.850 0.000 0.704 0.008 0.000 0.104 0.184
#> SRR1655023     2  0.4647      0.850 0.000 0.704 0.008 0.000 0.104 0.184
#> SRR1655024     2  0.4676      0.848 0.000 0.700 0.008 0.000 0.104 0.188
#> SRR1655025     2  0.4676      0.848 0.000 0.700 0.008 0.000 0.104 0.188
#> SRR1655026     4  0.0713      0.999 0.000 0.028 0.000 0.972 0.000 0.000
#> SRR1655027     4  0.0713      0.999 0.000 0.028 0.000 0.972 0.000 0.000
#> SRR1655028     4  0.0713      0.999 0.000 0.028 0.000 0.972 0.000 0.000
#> SRR1655029     4  0.0713      0.999 0.000 0.028 0.000 0.972 0.000 0.000
#> SRR1655030     4  0.0858      0.996 0.000 0.028 0.000 0.968 0.004 0.000
#> SRR1655031     4  0.0858      0.996 0.000 0.028 0.000 0.968 0.004 0.000
#> SRR1655032     4  0.0713      0.999 0.000 0.028 0.000 0.972 0.000 0.000
#> SRR1655033     4  0.0713      0.999 0.000 0.028 0.000 0.972 0.000 0.000
#> SRR1655034     3  0.2921      0.921 0.012 0.016 0.888 0.024 0.024 0.036
#> SRR1655035     3  0.2921      0.921 0.012 0.016 0.888 0.024 0.024 0.036
#> SRR1655036     3  0.3202      0.947 0.012 0.016 0.868 0.016 0.024 0.064
#> SRR1655037     3  0.3202      0.947 0.012 0.016 0.868 0.016 0.024 0.064
#> SRR1655038     3  0.1533      0.941 0.012 0.016 0.948 0.016 0.008 0.000
#> SRR1655039     3  0.1533      0.941 0.012 0.016 0.948 0.016 0.008 0.000
#> SRR1655040     3  0.3202      0.947 0.012 0.016 0.868 0.016 0.024 0.064
#> SRR1655041     3  0.3202      0.947 0.012 0.016 0.868 0.016 0.024 0.064
#> SRR1655042     6  0.5608      0.873 0.000 0.128 0.004 0.388 0.000 0.480
#> SRR1655043     6  0.5608      0.873 0.000 0.128 0.004 0.388 0.000 0.480
#> SRR1655044     6  0.5479      0.874 0.000 0.128 0.000 0.388 0.000 0.484
#> SRR1655045     6  0.5479      0.874 0.000 0.128 0.000 0.388 0.000 0.484
#> SRR1655046     6  0.5479      0.874 0.000 0.128 0.000 0.388 0.000 0.484
#> SRR1655047     6  0.5479      0.874 0.000 0.128 0.000 0.388 0.000 0.484
#> SRR1655048     6  0.6429      0.684 0.000 0.192 0.004 0.200 0.056 0.548
#> SRR1655049     6  0.6429      0.684 0.000 0.192 0.004 0.200 0.056 0.548
#> SRR1655050     5  0.6219      0.950 0.000 0.004 0.108 0.380 0.468 0.040
#> SRR1655051     5  0.6219      0.950 0.000 0.004 0.108 0.380 0.468 0.040
#> SRR1655052     5  0.6514      0.963 0.000 0.004 0.108 0.384 0.440 0.064
#> SRR1655053     5  0.6514      0.963 0.000 0.004 0.108 0.384 0.440 0.064
#> SRR1655054     5  0.5902      0.960 0.000 0.004 0.108 0.376 0.492 0.020
#> SRR1655055     5  0.5902      0.960 0.000 0.004 0.108 0.376 0.492 0.020
#> SRR1655056     5  0.6514      0.963 0.000 0.004 0.108 0.384 0.440 0.064
#> SRR1655057     5  0.6514      0.963 0.000 0.004 0.108 0.384 0.440 0.064

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

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

collect_plots(res)

plot of chunk MAD-skmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4447 0.556   0.556
#> 3 3 0.657           0.765       0.864         0.4519 0.771   0.589
#> 4 4 0.764           0.866       0.925         0.1263 0.948   0.841
#> 5 5 0.917           0.901       0.937         0.0968 0.844   0.508
#> 6 6 1.000           0.997       0.993         0.0518 0.958   0.795

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 5

There is also optional best \(k\) = 2 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
#> SRR1655002     1       0          1  1  0
#> SRR1655003     1       0          1  1  0
#> SRR1655004     1       0          1  1  0
#> SRR1655005     1       0          1  1  0
#> SRR1655006     1       0          1  1  0
#> SRR1655007     1       0          1  1  0
#> SRR1655008     1       0          1  1  0
#> SRR1655009     1       0          1  1  0
#> SRR1655010     1       0          1  1  0
#> SRR1655011     1       0          1  1  0
#> SRR1655012     2       0          1  0  1
#> SRR1655013     2       0          1  0  1
#> SRR1655014     2       0          1  0  1
#> SRR1655015     2       0          1  0  1
#> SRR1655016     2       0          1  0  1
#> SRR1655017     2       0          1  0  1
#> SRR1655018     2       0          1  0  1
#> SRR1655019     2       0          1  0  1
#> SRR1655020     2       0          1  0  1
#> SRR1655021     2       0          1  0  1
#> SRR1655022     2       0          1  0  1
#> SRR1655023     2       0          1  0  1
#> SRR1655024     2       0          1  0  1
#> SRR1655025     2       0          1  0  1
#> SRR1655026     2       0          1  0  1
#> SRR1655027     2       0          1  0  1
#> SRR1655028     2       0          1  0  1
#> SRR1655029     2       0          1  0  1
#> SRR1655030     2       0          1  0  1
#> SRR1655031     2       0          1  0  1
#> SRR1655032     2       0          1  0  1
#> SRR1655033     2       0          1  0  1
#> SRR1655034     1       0          1  1  0
#> SRR1655035     1       0          1  1  0
#> SRR1655036     1       0          1  1  0
#> SRR1655037     1       0          1  1  0
#> SRR1655038     1       0          1  1  0
#> SRR1655039     1       0          1  1  0
#> SRR1655040     1       0          1  1  0
#> SRR1655041     1       0          1  1  0
#> SRR1655042     2       0          1  0  1
#> SRR1655043     2       0          1  0  1
#> SRR1655044     2       0          1  0  1
#> SRR1655045     2       0          1  0  1
#> SRR1655046     2       0          1  0  1
#> SRR1655047     2       0          1  0  1
#> SRR1655048     2       0          1  0  1
#> SRR1655049     2       0          1  0  1
#> SRR1655050     2       0          1  0  1
#> SRR1655051     2       0          1  0  1
#> SRR1655052     2       0          1  0  1
#> SRR1655053     2       0          1  0  1
#> SRR1655054     2       0          1  0  1
#> SRR1655055     2       0          1  0  1
#> SRR1655056     2       0          1  0  1
#> SRR1655057     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
#> SRR1655002     1   0.000      0.771 1.000 0.000 0.000
#> SRR1655003     1   0.000      0.771 1.000 0.000 0.000
#> SRR1655004     1   0.000      0.771 1.000 0.000 0.000
#> SRR1655005     1   0.000      0.771 1.000 0.000 0.000
#> SRR1655006     1   0.000      0.771 1.000 0.000 0.000
#> SRR1655007     1   0.000      0.771 1.000 0.000 0.000
#> SRR1655008     1   0.000      0.771 1.000 0.000 0.000
#> SRR1655009     1   0.000      0.771 1.000 0.000 0.000
#> SRR1655010     1   0.000      0.771 1.000 0.000 0.000
#> SRR1655011     1   0.000      0.771 1.000 0.000 0.000
#> SRR1655012     2   0.000      0.960 0.000 1.000 0.000
#> SRR1655013     2   0.000      0.960 0.000 1.000 0.000
#> SRR1655014     2   0.000      0.960 0.000 1.000 0.000
#> SRR1655015     2   0.000      0.960 0.000 1.000 0.000
#> SRR1655016     2   0.000      0.960 0.000 1.000 0.000
#> SRR1655017     2   0.000      0.960 0.000 1.000 0.000
#> SRR1655018     2   0.000      0.960 0.000 1.000 0.000
#> SRR1655019     2   0.000      0.960 0.000 1.000 0.000
#> SRR1655020     2   0.000      0.960 0.000 1.000 0.000
#> SRR1655021     2   0.000      0.960 0.000 1.000 0.000
#> SRR1655022     2   0.000      0.960 0.000 1.000 0.000
#> SRR1655023     2   0.000      0.960 0.000 1.000 0.000
#> SRR1655024     2   0.000      0.960 0.000 1.000 0.000
#> SRR1655025     2   0.000      0.960 0.000 1.000 0.000
#> SRR1655026     3   0.618      0.546 0.000 0.416 0.584
#> SRR1655027     3   0.618      0.546 0.000 0.416 0.584
#> SRR1655028     3   0.618      0.546 0.000 0.416 0.584
#> SRR1655029     3   0.618      0.546 0.000 0.416 0.584
#> SRR1655030     3   0.618      0.546 0.000 0.416 0.584
#> SRR1655031     3   0.618      0.546 0.000 0.416 0.584
#> SRR1655032     3   0.618      0.546 0.000 0.416 0.584
#> SRR1655033     3   0.618      0.546 0.000 0.416 0.584
#> SRR1655034     1   0.629      0.643 0.536 0.000 0.464
#> SRR1655035     1   0.629      0.643 0.536 0.000 0.464
#> SRR1655036     1   0.629      0.643 0.536 0.000 0.464
#> SRR1655037     1   0.629      0.643 0.536 0.000 0.464
#> SRR1655038     1   0.629      0.643 0.536 0.000 0.464
#> SRR1655039     1   0.629      0.643 0.536 0.000 0.464
#> SRR1655040     1   0.629      0.643 0.536 0.000 0.464
#> SRR1655041     1   0.629      0.643 0.536 0.000 0.464
#> SRR1655042     2   0.296      0.884 0.000 0.900 0.100
#> SRR1655043     2   0.296      0.884 0.000 0.900 0.100
#> SRR1655044     2   0.296      0.884 0.000 0.900 0.100
#> SRR1655045     2   0.296      0.884 0.000 0.900 0.100
#> SRR1655046     2   0.296      0.884 0.000 0.900 0.100
#> SRR1655047     2   0.296      0.884 0.000 0.900 0.100
#> SRR1655048     2   0.000      0.960 0.000 1.000 0.000
#> SRR1655049     2   0.000      0.960 0.000 1.000 0.000
#> SRR1655050     3   0.000      0.617 0.000 0.000 1.000
#> SRR1655051     3   0.000      0.617 0.000 0.000 1.000
#> SRR1655052     3   0.000      0.617 0.000 0.000 1.000
#> SRR1655053     3   0.000      0.617 0.000 0.000 1.000
#> SRR1655054     3   0.000      0.617 0.000 0.000 1.000
#> SRR1655055     3   0.000      0.617 0.000 0.000 1.000
#> SRR1655056     3   0.000      0.617 0.000 0.000 1.000
#> SRR1655057     3   0.000      0.617 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
#> SRR1655002     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1655003     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1655004     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1655005     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1655006     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1655007     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1655008     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1655009     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1655010     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1655011     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1655012     2  0.0000      0.840 0.000 1.000 0.000 0.000
#> SRR1655013     2  0.0000      0.840 0.000 1.000 0.000 0.000
#> SRR1655014     2  0.0000      0.840 0.000 1.000 0.000 0.000
#> SRR1655015     2  0.0000      0.840 0.000 1.000 0.000 0.000
#> SRR1655016     2  0.0000      0.840 0.000 1.000 0.000 0.000
#> SRR1655017     2  0.0000      0.840 0.000 1.000 0.000 0.000
#> SRR1655018     2  0.0000      0.840 0.000 1.000 0.000 0.000
#> SRR1655019     2  0.0000      0.840 0.000 1.000 0.000 0.000
#> SRR1655020     2  0.0000      0.840 0.000 1.000 0.000 0.000
#> SRR1655021     2  0.0000      0.840 0.000 1.000 0.000 0.000
#> SRR1655022     2  0.0000      0.840 0.000 1.000 0.000 0.000
#> SRR1655023     2  0.0000      0.840 0.000 1.000 0.000 0.000
#> SRR1655024     2  0.0000      0.840 0.000 1.000 0.000 0.000
#> SRR1655025     2  0.0000      0.840 0.000 1.000 0.000 0.000
#> SRR1655026     4  0.0707      0.916 0.000 0.020 0.000 0.980
#> SRR1655027     4  0.0707      0.916 0.000 0.020 0.000 0.980
#> SRR1655028     4  0.0707      0.916 0.000 0.020 0.000 0.980
#> SRR1655029     4  0.0707      0.916 0.000 0.020 0.000 0.980
#> SRR1655030     4  0.0707      0.916 0.000 0.020 0.000 0.980
#> SRR1655031     4  0.0707      0.916 0.000 0.020 0.000 0.980
#> SRR1655032     4  0.0707      0.916 0.000 0.020 0.000 0.980
#> SRR1655033     4  0.0707      0.916 0.000 0.020 0.000 0.980
#> SRR1655034     3  0.0188      1.000 0.004 0.000 0.996 0.000
#> SRR1655035     3  0.0188      1.000 0.004 0.000 0.996 0.000
#> SRR1655036     3  0.0188      1.000 0.004 0.000 0.996 0.000
#> SRR1655037     3  0.0188      1.000 0.004 0.000 0.996 0.000
#> SRR1655038     3  0.0188      1.000 0.004 0.000 0.996 0.000
#> SRR1655039     3  0.0188      1.000 0.004 0.000 0.996 0.000
#> SRR1655040     3  0.0188      1.000 0.004 0.000 0.996 0.000
#> SRR1655041     3  0.0188      1.000 0.004 0.000 0.996 0.000
#> SRR1655042     2  0.4972      0.424 0.000 0.544 0.000 0.456
#> SRR1655043     2  0.4972      0.424 0.000 0.544 0.000 0.456
#> SRR1655044     2  0.4972      0.424 0.000 0.544 0.000 0.456
#> SRR1655045     2  0.4972      0.424 0.000 0.544 0.000 0.456
#> SRR1655046     2  0.4972      0.424 0.000 0.544 0.000 0.456
#> SRR1655047     2  0.4972      0.424 0.000 0.544 0.000 0.456
#> SRR1655048     2  0.2589      0.790 0.000 0.884 0.000 0.116
#> SRR1655049     2  0.2589      0.790 0.000 0.884 0.000 0.116
#> SRR1655050     4  0.2589      0.910 0.000 0.000 0.116 0.884
#> SRR1655051     4  0.2589      0.910 0.000 0.000 0.116 0.884
#> SRR1655052     4  0.2589      0.910 0.000 0.000 0.116 0.884
#> SRR1655053     4  0.2589      0.910 0.000 0.000 0.116 0.884
#> SRR1655054     4  0.2589      0.910 0.000 0.000 0.116 0.884
#> SRR1655055     4  0.2589      0.910 0.000 0.000 0.116 0.884
#> SRR1655056     4  0.2589      0.910 0.000 0.000 0.116 0.884
#> SRR1655057     4  0.2589      0.910 0.000 0.000 0.116 0.884

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette p1    p2    p3    p4    p5
#> SRR1655002     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1655003     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1655004     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1655005     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1655006     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1655007     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1655008     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1655009     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1655010     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1655011     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1655012     2  0.0000      1.000  0 1.000 0.000 0.000 0.000
#> SRR1655013     2  0.0000      1.000  0 1.000 0.000 0.000 0.000
#> SRR1655014     2  0.0000      1.000  0 1.000 0.000 0.000 0.000
#> SRR1655015     2  0.0000      1.000  0 1.000 0.000 0.000 0.000
#> SRR1655016     2  0.0000      1.000  0 1.000 0.000 0.000 0.000
#> SRR1655017     2  0.0000      1.000  0 1.000 0.000 0.000 0.000
#> SRR1655018     2  0.0000      1.000  0 1.000 0.000 0.000 0.000
#> SRR1655019     2  0.0000      1.000  0 1.000 0.000 0.000 0.000
#> SRR1655020     2  0.0000      1.000  0 1.000 0.000 0.000 0.000
#> SRR1655021     2  0.0000      1.000  0 1.000 0.000 0.000 0.000
#> SRR1655022     2  0.0000      1.000  0 1.000 0.000 0.000 0.000
#> SRR1655023     2  0.0000      1.000  0 1.000 0.000 0.000 0.000
#> SRR1655024     2  0.0000      1.000  0 1.000 0.000 0.000 0.000
#> SRR1655025     2  0.0000      1.000  0 1.000 0.000 0.000 0.000
#> SRR1655026     4  0.4249      0.593  0 0.000 0.000 0.568 0.432
#> SRR1655027     4  0.4249      0.593  0 0.000 0.000 0.568 0.432
#> SRR1655028     4  0.4249      0.593  0 0.000 0.000 0.568 0.432
#> SRR1655029     4  0.4249      0.593  0 0.000 0.000 0.568 0.432
#> SRR1655030     4  0.4249      0.593  0 0.000 0.000 0.568 0.432
#> SRR1655031     4  0.4249      0.593  0 0.000 0.000 0.568 0.432
#> SRR1655032     4  0.4249      0.593  0 0.000 0.000 0.568 0.432
#> SRR1655033     4  0.4249      0.593  0 0.000 0.000 0.568 0.432
#> SRR1655034     3  0.0000      1.000  0 0.000 1.000 0.000 0.000
#> SRR1655035     3  0.0000      1.000  0 0.000 1.000 0.000 0.000
#> SRR1655036     3  0.0000      1.000  0 0.000 1.000 0.000 0.000
#> SRR1655037     3  0.0000      1.000  0 0.000 1.000 0.000 0.000
#> SRR1655038     3  0.0000      1.000  0 0.000 1.000 0.000 0.000
#> SRR1655039     3  0.0000      1.000  0 0.000 1.000 0.000 0.000
#> SRR1655040     3  0.0000      1.000  0 0.000 1.000 0.000 0.000
#> SRR1655041     3  0.0000      1.000  0 0.000 1.000 0.000 0.000
#> SRR1655042     4  0.0162      0.716  0 0.004 0.000 0.996 0.000
#> SRR1655043     4  0.0162      0.716  0 0.004 0.000 0.996 0.000
#> SRR1655044     4  0.0162      0.716  0 0.004 0.000 0.996 0.000
#> SRR1655045     4  0.0162      0.716  0 0.004 0.000 0.996 0.000
#> SRR1655046     4  0.0162      0.716  0 0.004 0.000 0.996 0.000
#> SRR1655047     4  0.0162      0.716  0 0.004 0.000 0.996 0.000
#> SRR1655048     4  0.0510      0.709  0 0.016 0.000 0.984 0.000
#> SRR1655049     4  0.0510      0.709  0 0.016 0.000 0.984 0.000
#> SRR1655050     5  0.0162      1.000  0 0.000 0.004 0.000 0.996
#> SRR1655051     5  0.0162      1.000  0 0.000 0.004 0.000 0.996
#> SRR1655052     5  0.0162      1.000  0 0.000 0.004 0.000 0.996
#> SRR1655053     5  0.0162      1.000  0 0.000 0.004 0.000 0.996
#> SRR1655054     5  0.0162      1.000  0 0.000 0.004 0.000 0.996
#> SRR1655055     5  0.0162      1.000  0 0.000 0.004 0.000 0.996
#> SRR1655056     5  0.0162      1.000  0 0.000 0.004 0.000 0.996
#> SRR1655057     5  0.0162      1.000  0 0.000 0.004 0.000 0.996

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette p1    p2 p3    p4   p5    p6
#> SRR1655002     1  0.0000      1.000  1 0.000  0 0.000 0.00 0.000
#> SRR1655003     1  0.0000      1.000  1 0.000  0 0.000 0.00 0.000
#> SRR1655004     1  0.0000      1.000  1 0.000  0 0.000 0.00 0.000
#> SRR1655005     1  0.0000      1.000  1 0.000  0 0.000 0.00 0.000
#> SRR1655006     1  0.0000      1.000  1 0.000  0 0.000 0.00 0.000
#> SRR1655007     1  0.0000      1.000  1 0.000  0 0.000 0.00 0.000
#> SRR1655008     1  0.0000      1.000  1 0.000  0 0.000 0.00 0.000
#> SRR1655009     1  0.0000      1.000  1 0.000  0 0.000 0.00 0.000
#> SRR1655010     1  0.0000      1.000  1 0.000  0 0.000 0.00 0.000
#> SRR1655011     1  0.0000      1.000  1 0.000  0 0.000 0.00 0.000
#> SRR1655012     2  0.0806      0.986  0 0.972  0 0.000 0.02 0.008
#> SRR1655013     2  0.0806      0.986  0 0.972  0 0.000 0.02 0.008
#> SRR1655014     2  0.0806      0.986  0 0.972  0 0.000 0.02 0.008
#> SRR1655015     2  0.0806      0.986  0 0.972  0 0.000 0.02 0.008
#> SRR1655016     2  0.0806      0.986  0 0.972  0 0.000 0.02 0.008
#> SRR1655017     2  0.0806      0.986  0 0.972  0 0.000 0.02 0.008
#> SRR1655018     2  0.0000      0.990  0 1.000  0 0.000 0.00 0.000
#> SRR1655019     2  0.0000      0.990  0 1.000  0 0.000 0.00 0.000
#> SRR1655020     2  0.0000      0.990  0 1.000  0 0.000 0.00 0.000
#> SRR1655021     2  0.0000      0.990  0 1.000  0 0.000 0.00 0.000
#> SRR1655022     2  0.0000      0.990  0 1.000  0 0.000 0.00 0.000
#> SRR1655023     2  0.0000      0.990  0 1.000  0 0.000 0.00 0.000
#> SRR1655024     2  0.0000      0.990  0 1.000  0 0.000 0.00 0.000
#> SRR1655025     2  0.0000      0.990  0 1.000  0 0.000 0.00 0.000
#> SRR1655026     4  0.0000      1.000  0 0.000  0 1.000 0.00 0.000
#> SRR1655027     4  0.0000      1.000  0 0.000  0 1.000 0.00 0.000
#> SRR1655028     4  0.0000      1.000  0 0.000  0 1.000 0.00 0.000
#> SRR1655029     4  0.0000      1.000  0 0.000  0 1.000 0.00 0.000
#> SRR1655030     4  0.0000      1.000  0 0.000  0 1.000 0.00 0.000
#> SRR1655031     4  0.0000      1.000  0 0.000  0 1.000 0.00 0.000
#> SRR1655032     4  0.0000      1.000  0 0.000  0 1.000 0.00 0.000
#> SRR1655033     4  0.0000      1.000  0 0.000  0 1.000 0.00 0.000
#> SRR1655034     3  0.0000      1.000  0 0.000  1 0.000 0.00 0.000
#> SRR1655035     3  0.0000      1.000  0 0.000  1 0.000 0.00 0.000
#> SRR1655036     3  0.0000      1.000  0 0.000  1 0.000 0.00 0.000
#> SRR1655037     3  0.0000      1.000  0 0.000  1 0.000 0.00 0.000
#> SRR1655038     3  0.0000      1.000  0 0.000  1 0.000 0.00 0.000
#> SRR1655039     3  0.0000      1.000  0 0.000  1 0.000 0.00 0.000
#> SRR1655040     3  0.0000      1.000  0 0.000  1 0.000 0.00 0.000
#> SRR1655041     3  0.0000      1.000  0 0.000  1 0.000 0.00 0.000
#> SRR1655042     6  0.0260      1.000  0 0.000  0 0.008 0.00 0.992
#> SRR1655043     6  0.0260      1.000  0 0.000  0 0.008 0.00 0.992
#> SRR1655044     6  0.0260      1.000  0 0.000  0 0.008 0.00 0.992
#> SRR1655045     6  0.0260      1.000  0 0.000  0 0.008 0.00 0.992
#> SRR1655046     6  0.0260      1.000  0 0.000  0 0.008 0.00 0.992
#> SRR1655047     6  0.0260      1.000  0 0.000  0 0.008 0.00 0.992
#> SRR1655048     6  0.0260      1.000  0 0.000  0 0.008 0.00 0.992
#> SRR1655049     6  0.0260      1.000  0 0.000  0 0.008 0.00 0.992
#> SRR1655050     5  0.0547      1.000  0 0.000  0 0.020 0.98 0.000
#> SRR1655051     5  0.0547      1.000  0 0.000  0 0.020 0.98 0.000
#> SRR1655052     5  0.0547      1.000  0 0.000  0 0.020 0.98 0.000
#> SRR1655053     5  0.0547      1.000  0 0.000  0 0.020 0.98 0.000
#> SRR1655054     5  0.0547      1.000  0 0.000  0 0.020 0.98 0.000
#> SRR1655055     5  0.0547      1.000  0 0.000  0 0.020 0.98 0.000
#> SRR1655056     5  0.0547      1.000  0 0.000  0 0.020 0.98 0.000
#> SRR1655057     5  0.0547      1.000  0 0.000  0 0.020 0.98 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 15837 rows and 56 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'pam' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 6.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk MAD-pam-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.2994 0.701   0.701
#> 3 3 0.651           0.748       0.847         0.8786 0.803   0.719
#> 4 4 1.000           0.963       0.986         0.2947 0.766   0.536
#> 5 5 1.000           0.960       0.985         0.0912 0.938   0.769
#> 6 6 1.000           1.000       1.000         0.0560 0.932   0.690

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 5

There is also optional best \(k\) = 2 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
#> SRR1655002     1       0          1  1  0
#> SRR1655003     1       0          1  1  0
#> SRR1655004     1       0          1  1  0
#> SRR1655005     1       0          1  1  0
#> SRR1655006     1       0          1  1  0
#> SRR1655007     1       0          1  1  0
#> SRR1655008     1       0          1  1  0
#> SRR1655009     1       0          1  1  0
#> SRR1655010     1       0          1  1  0
#> SRR1655011     1       0          1  1  0
#> SRR1655012     2       0          1  0  1
#> SRR1655013     2       0          1  0  1
#> SRR1655014     2       0          1  0  1
#> SRR1655015     2       0          1  0  1
#> SRR1655016     2       0          1  0  1
#> SRR1655017     2       0          1  0  1
#> SRR1655018     2       0          1  0  1
#> SRR1655019     2       0          1  0  1
#> SRR1655020     2       0          1  0  1
#> SRR1655021     2       0          1  0  1
#> SRR1655022     2       0          1  0  1
#> SRR1655023     2       0          1  0  1
#> SRR1655024     2       0          1  0  1
#> SRR1655025     2       0          1  0  1
#> SRR1655026     2       0          1  0  1
#> SRR1655027     2       0          1  0  1
#> SRR1655028     2       0          1  0  1
#> SRR1655029     2       0          1  0  1
#> SRR1655030     2       0          1  0  1
#> SRR1655031     2       0          1  0  1
#> SRR1655032     2       0          1  0  1
#> SRR1655033     2       0          1  0  1
#> SRR1655034     2       0          1  0  1
#> SRR1655035     2       0          1  0  1
#> SRR1655036     2       0          1  0  1
#> SRR1655037     2       0          1  0  1
#> SRR1655038     2       0          1  0  1
#> SRR1655039     2       0          1  0  1
#> SRR1655040     2       0          1  0  1
#> SRR1655041     2       0          1  0  1
#> SRR1655042     2       0          1  0  1
#> SRR1655043     2       0          1  0  1
#> SRR1655044     2       0          1  0  1
#> SRR1655045     2       0          1  0  1
#> SRR1655046     2       0          1  0  1
#> SRR1655047     2       0          1  0  1
#> SRR1655048     2       0          1  0  1
#> SRR1655049     2       0          1  0  1
#> SRR1655050     2       0          1  0  1
#> SRR1655051     2       0          1  0  1
#> SRR1655052     2       0          1  0  1
#> SRR1655053     2       0          1  0  1
#> SRR1655054     2       0          1  0  1
#> SRR1655055     2       0          1  0  1
#> SRR1655056     2       0          1  0  1
#> SRR1655057     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
#> SRR1655002     1   0.000      1.000  1 0.000 0.000
#> SRR1655003     1   0.000      1.000  1 0.000 0.000
#> SRR1655004     1   0.000      1.000  1 0.000 0.000
#> SRR1655005     1   0.000      1.000  1 0.000 0.000
#> SRR1655006     1   0.000      1.000  1 0.000 0.000
#> SRR1655007     1   0.000      1.000  1 0.000 0.000
#> SRR1655008     1   0.000      1.000  1 0.000 0.000
#> SRR1655009     1   0.000      1.000  1 0.000 0.000
#> SRR1655010     1   0.000      1.000  1 0.000 0.000
#> SRR1655011     1   0.000      1.000  1 0.000 0.000
#> SRR1655012     2   0.000      0.554  0 1.000 0.000
#> SRR1655013     2   0.000      0.554  0 1.000 0.000
#> SRR1655014     2   0.000      0.554  0 1.000 0.000
#> SRR1655015     2   0.000      0.554  0 1.000 0.000
#> SRR1655016     2   0.000      0.554  0 1.000 0.000
#> SRR1655017     2   0.000      0.554  0 1.000 0.000
#> SRR1655018     2   0.000      0.554  0 1.000 0.000
#> SRR1655019     2   0.000      0.554  0 1.000 0.000
#> SRR1655020     2   0.000      0.554  0 1.000 0.000
#> SRR1655021     2   0.000      0.554  0 1.000 0.000
#> SRR1655022     2   0.000      0.554  0 1.000 0.000
#> SRR1655023     2   0.000      0.554  0 1.000 0.000
#> SRR1655024     2   0.000      0.554  0 1.000 0.000
#> SRR1655025     2   0.000      0.554  0 1.000 0.000
#> SRR1655026     2   0.629      0.715  0 0.536 0.464
#> SRR1655027     2   0.629      0.715  0 0.536 0.464
#> SRR1655028     2   0.629      0.715  0 0.536 0.464
#> SRR1655029     2   0.629      0.715  0 0.536 0.464
#> SRR1655030     2   0.629      0.715  0 0.536 0.464
#> SRR1655031     2   0.629      0.715  0 0.536 0.464
#> SRR1655032     2   0.629      0.715  0 0.536 0.464
#> SRR1655033     2   0.629      0.715  0 0.536 0.464
#> SRR1655034     3   0.611      0.930  0 0.396 0.604
#> SRR1655035     3   0.586      0.859  0 0.344 0.656
#> SRR1655036     3   0.625      0.966  0 0.444 0.556
#> SRR1655037     3   0.625      0.966  0 0.444 0.556
#> SRR1655038     3   0.624      0.969  0 0.440 0.560
#> SRR1655039     3   0.624      0.969  0 0.440 0.560
#> SRR1655040     3   0.624      0.969  0 0.440 0.560
#> SRR1655041     3   0.624      0.969  0 0.440 0.560
#> SRR1655042     2   0.216      0.581  0 0.936 0.064
#> SRR1655043     2   0.296      0.596  0 0.900 0.100
#> SRR1655044     2   0.624      0.712  0 0.560 0.440
#> SRR1655045     2   0.624      0.712  0 0.560 0.440
#> SRR1655046     2   0.624      0.712  0 0.560 0.440
#> SRR1655047     2   0.624      0.712  0 0.560 0.440
#> SRR1655048     2   0.000      0.554  0 1.000 0.000
#> SRR1655049     2   0.000      0.554  0 1.000 0.000
#> SRR1655050     2   0.629      0.715  0 0.536 0.464
#> SRR1655051     2   0.629      0.715  0 0.536 0.464
#> SRR1655052     2   0.629      0.715  0 0.536 0.464
#> SRR1655053     2   0.629      0.715  0 0.536 0.464
#> SRR1655054     2   0.629      0.715  0 0.536 0.464
#> SRR1655055     2   0.629      0.715  0 0.536 0.464
#> SRR1655056     2   0.629      0.715  0 0.536 0.464
#> SRR1655057     2   0.629      0.715  0 0.536 0.464

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette p1    p2 p3    p4
#> SRR1655002     1   0.000      1.000  1 0.000  0 0.000
#> SRR1655003     1   0.000      1.000  1 0.000  0 0.000
#> SRR1655004     1   0.000      1.000  1 0.000  0 0.000
#> SRR1655005     1   0.000      1.000  1 0.000  0 0.000
#> SRR1655006     1   0.000      1.000  1 0.000  0 0.000
#> SRR1655007     1   0.000      1.000  1 0.000  0 0.000
#> SRR1655008     1   0.000      1.000  1 0.000  0 0.000
#> SRR1655009     1   0.000      1.000  1 0.000  0 0.000
#> SRR1655010     1   0.000      1.000  1 0.000  0 0.000
#> SRR1655011     1   0.000      1.000  1 0.000  0 0.000
#> SRR1655012     2   0.000      0.944  0 1.000  0 0.000
#> SRR1655013     2   0.000      0.944  0 1.000  0 0.000
#> SRR1655014     2   0.000      0.944  0 1.000  0 0.000
#> SRR1655015     2   0.000      0.944  0 1.000  0 0.000
#> SRR1655016     2   0.000      0.944  0 1.000  0 0.000
#> SRR1655017     2   0.000      0.944  0 1.000  0 0.000
#> SRR1655018     2   0.000      0.944  0 1.000  0 0.000
#> SRR1655019     2   0.000      0.944  0 1.000  0 0.000
#> SRR1655020     2   0.000      0.944  0 1.000  0 0.000
#> SRR1655021     2   0.000      0.944  0 1.000  0 0.000
#> SRR1655022     2   0.000      0.944  0 1.000  0 0.000
#> SRR1655023     2   0.000      0.944  0 1.000  0 0.000
#> SRR1655024     2   0.000      0.944  0 1.000  0 0.000
#> SRR1655025     2   0.000      0.944  0 1.000  0 0.000
#> SRR1655026     4   0.000      1.000  0 0.000  0 1.000
#> SRR1655027     4   0.000      1.000  0 0.000  0 1.000
#> SRR1655028     4   0.000      1.000  0 0.000  0 1.000
#> SRR1655029     4   0.000      1.000  0 0.000  0 1.000
#> SRR1655030     4   0.000      1.000  0 0.000  0 1.000
#> SRR1655031     4   0.000      1.000  0 0.000  0 1.000
#> SRR1655032     4   0.000      1.000  0 0.000  0 1.000
#> SRR1655033     4   0.000      1.000  0 0.000  0 1.000
#> SRR1655034     3   0.000      1.000  0 0.000  1 0.000
#> SRR1655035     3   0.000      1.000  0 0.000  1 0.000
#> SRR1655036     3   0.000      1.000  0 0.000  1 0.000
#> SRR1655037     3   0.000      1.000  0 0.000  1 0.000
#> SRR1655038     3   0.000      1.000  0 0.000  1 0.000
#> SRR1655039     3   0.000      1.000  0 0.000  1 0.000
#> SRR1655040     3   0.000      1.000  0 0.000  1 0.000
#> SRR1655041     3   0.000      1.000  0 0.000  1 0.000
#> SRR1655042     2   0.471      0.464  0 0.640  0 0.360
#> SRR1655043     2   0.489      0.339  0 0.588  0 0.412
#> SRR1655044     4   0.000      1.000  0 0.000  0 1.000
#> SRR1655045     4   0.000      1.000  0 0.000  0 1.000
#> SRR1655046     4   0.000      1.000  0 0.000  0 1.000
#> SRR1655047     4   0.000      1.000  0 0.000  0 1.000
#> SRR1655048     2   0.000      0.944  0 1.000  0 0.000
#> SRR1655049     2   0.000      0.944  0 1.000  0 0.000
#> SRR1655050     4   0.000      1.000  0 0.000  0 1.000
#> SRR1655051     4   0.000      1.000  0 0.000  0 1.000
#> SRR1655052     4   0.000      1.000  0 0.000  0 1.000
#> SRR1655053     4   0.000      1.000  0 0.000  0 1.000
#> SRR1655054     4   0.000      1.000  0 0.000  0 1.000
#> SRR1655055     4   0.000      1.000  0 0.000  0 1.000
#> SRR1655056     4   0.000      1.000  0 0.000  0 1.000
#> SRR1655057     4   0.000      1.000  0 0.000  0 1.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette p1    p2 p3    p4 p5
#> SRR1655002     1   0.000      1.000  1 0.000  0 0.000  0
#> SRR1655003     1   0.000      1.000  1 0.000  0 0.000  0
#> SRR1655004     1   0.000      1.000  1 0.000  0 0.000  0
#> SRR1655005     1   0.000      1.000  1 0.000  0 0.000  0
#> SRR1655006     1   0.000      1.000  1 0.000  0 0.000  0
#> SRR1655007     1   0.000      1.000  1 0.000  0 0.000  0
#> SRR1655008     1   0.000      1.000  1 0.000  0 0.000  0
#> SRR1655009     1   0.000      1.000  1 0.000  0 0.000  0
#> SRR1655010     1   0.000      1.000  1 0.000  0 0.000  0
#> SRR1655011     1   0.000      1.000  1 0.000  0 0.000  0
#> SRR1655012     2   0.000      0.945  0 1.000  0 0.000  0
#> SRR1655013     2   0.000      0.945  0 1.000  0 0.000  0
#> SRR1655014     2   0.000      0.945  0 1.000  0 0.000  0
#> SRR1655015     2   0.000      0.945  0 1.000  0 0.000  0
#> SRR1655016     2   0.000      0.945  0 1.000  0 0.000  0
#> SRR1655017     2   0.000      0.945  0 1.000  0 0.000  0
#> SRR1655018     2   0.000      0.945  0 1.000  0 0.000  0
#> SRR1655019     2   0.000      0.945  0 1.000  0 0.000  0
#> SRR1655020     2   0.000      0.945  0 1.000  0 0.000  0
#> SRR1655021     2   0.000      0.945  0 1.000  0 0.000  0
#> SRR1655022     2   0.000      0.945  0 1.000  0 0.000  0
#> SRR1655023     2   0.000      0.945  0 1.000  0 0.000  0
#> SRR1655024     2   0.000      0.945  0 1.000  0 0.000  0
#> SRR1655025     2   0.000      0.945  0 1.000  0 0.000  0
#> SRR1655026     4   0.000      1.000  0 0.000  0 1.000  0
#> SRR1655027     4   0.000      1.000  0 0.000  0 1.000  0
#> SRR1655028     4   0.000      1.000  0 0.000  0 1.000  0
#> SRR1655029     4   0.000      1.000  0 0.000  0 1.000  0
#> SRR1655030     4   0.000      1.000  0 0.000  0 1.000  0
#> SRR1655031     4   0.000      1.000  0 0.000  0 1.000  0
#> SRR1655032     4   0.000      1.000  0 0.000  0 1.000  0
#> SRR1655033     4   0.000      1.000  0 0.000  0 1.000  0
#> SRR1655034     3   0.000      1.000  0 0.000  1 0.000  0
#> SRR1655035     3   0.000      1.000  0 0.000  1 0.000  0
#> SRR1655036     3   0.000      1.000  0 0.000  1 0.000  0
#> SRR1655037     3   0.000      1.000  0 0.000  1 0.000  0
#> SRR1655038     3   0.000      1.000  0 0.000  1 0.000  0
#> SRR1655039     3   0.000      1.000  0 0.000  1 0.000  0
#> SRR1655040     3   0.000      1.000  0 0.000  1 0.000  0
#> SRR1655041     3   0.000      1.000  0 0.000  1 0.000  0
#> SRR1655042     2   0.423      0.307  0 0.576  0 0.424  0
#> SRR1655043     2   0.423      0.318  0 0.580  0 0.420  0
#> SRR1655044     4   0.000      1.000  0 0.000  0 1.000  0
#> SRR1655045     4   0.000      1.000  0 0.000  0 1.000  0
#> SRR1655046     4   0.000      1.000  0 0.000  0 1.000  0
#> SRR1655047     4   0.000      1.000  0 0.000  0 1.000  0
#> SRR1655048     2   0.000      0.945  0 1.000  0 0.000  0
#> SRR1655049     2   0.000      0.945  0 1.000  0 0.000  0
#> SRR1655050     5   0.000      1.000  0 0.000  0 0.000  1
#> SRR1655051     5   0.000      1.000  0 0.000  0 0.000  1
#> SRR1655052     5   0.000      1.000  0 0.000  0 0.000  1
#> SRR1655053     5   0.000      1.000  0 0.000  0 0.000  1
#> SRR1655054     5   0.000      1.000  0 0.000  0 0.000  1
#> SRR1655055     5   0.000      1.000  0 0.000  0 0.000  1
#> SRR1655056     5   0.000      1.000  0 0.000  0 0.000  1
#> SRR1655057     5   0.000      1.000  0 0.000  0 0.000  1

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1655002     1       0          1  1  0  0  0  0  0
#> SRR1655003     1       0          1  1  0  0  0  0  0
#> SRR1655004     1       0          1  1  0  0  0  0  0
#> SRR1655005     1       0          1  1  0  0  0  0  0
#> SRR1655006     1       0          1  1  0  0  0  0  0
#> SRR1655007     1       0          1  1  0  0  0  0  0
#> SRR1655008     1       0          1  1  0  0  0  0  0
#> SRR1655009     1       0          1  1  0  0  0  0  0
#> SRR1655010     1       0          1  1  0  0  0  0  0
#> SRR1655011     1       0          1  1  0  0  0  0  0
#> SRR1655012     2       0          1  0  1  0  0  0  0
#> SRR1655013     2       0          1  0  1  0  0  0  0
#> SRR1655014     2       0          1  0  1  0  0  0  0
#> SRR1655015     2       0          1  0  1  0  0  0  0
#> SRR1655016     2       0          1  0  1  0  0  0  0
#> SRR1655017     2       0          1  0  1  0  0  0  0
#> SRR1655018     2       0          1  0  1  0  0  0  0
#> SRR1655019     2       0          1  0  1  0  0  0  0
#> SRR1655020     2       0          1  0  1  0  0  0  0
#> SRR1655021     2       0          1  0  1  0  0  0  0
#> SRR1655022     2       0          1  0  1  0  0  0  0
#> SRR1655023     2       0          1  0  1  0  0  0  0
#> SRR1655024     2       0          1  0  1  0  0  0  0
#> SRR1655025     2       0          1  0  1  0  0  0  0
#> SRR1655026     4       0          1  0  0  0  1  0  0
#> SRR1655027     4       0          1  0  0  0  1  0  0
#> SRR1655028     4       0          1  0  0  0  1  0  0
#> SRR1655029     4       0          1  0  0  0  1  0  0
#> SRR1655030     4       0          1  0  0  0  1  0  0
#> SRR1655031     4       0          1  0  0  0  1  0  0
#> SRR1655032     4       0          1  0  0  0  1  0  0
#> SRR1655033     4       0          1  0  0  0  1  0  0
#> SRR1655034     3       0          1  0  0  1  0  0  0
#> SRR1655035     3       0          1  0  0  1  0  0  0
#> SRR1655036     3       0          1  0  0  1  0  0  0
#> SRR1655037     3       0          1  0  0  1  0  0  0
#> SRR1655038     3       0          1  0  0  1  0  0  0
#> SRR1655039     3       0          1  0  0  1  0  0  0
#> SRR1655040     3       0          1  0  0  1  0  0  0
#> SRR1655041     3       0          1  0  0  1  0  0  0
#> SRR1655042     6       0          1  0  0  0  0  0  1
#> SRR1655043     6       0          1  0  0  0  0  0  1
#> SRR1655044     6       0          1  0  0  0  0  0  1
#> SRR1655045     6       0          1  0  0  0  0  0  1
#> SRR1655046     6       0          1  0  0  0  0  0  1
#> SRR1655047     6       0          1  0  0  0  0  0  1
#> SRR1655048     6       0          1  0  0  0  0  0  1
#> SRR1655049     6       0          1  0  0  0  0  0  1
#> SRR1655050     5       0          1  0  0  0  0  1  0
#> SRR1655051     5       0          1  0  0  0  0  1  0
#> SRR1655052     5       0          1  0  0  0  0  1  0
#> SRR1655053     5       0          1  0  0  0  0  1  0
#> SRR1655054     5       0          1  0  0  0  0  1  0
#> SRR1655055     5       0          1  0  0  0  0  1  0
#> SRR1655056     5       0          1  0  0  0  0  1  0
#> SRR1655057     5       0          1  0  0  0  0  1  0

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

consensus_heatmap(res, k = 2)

plot of chunk tab-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 15837 rows and 56 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.751           0.943       0.970          0.330 0.701   0.701
#> 3 3 0.831           0.871       0.941          0.880 0.688   0.556
#> 4 4 1.000           0.998       0.999          0.168 0.886   0.707
#> 5 5 1.000           1.000       1.000          0.100 0.927   0.736
#> 6 6 1.000           1.000       1.000          0.039 0.969   0.846

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette    p1    p2
#> SRR1655002     1   0.000      1.000 1.000 0.000
#> SRR1655003     1   0.000      1.000 1.000 0.000
#> SRR1655004     1   0.000      1.000 1.000 0.000
#> SRR1655005     1   0.000      1.000 1.000 0.000
#> SRR1655006     1   0.000      1.000 1.000 0.000
#> SRR1655007     1   0.000      1.000 1.000 0.000
#> SRR1655008     1   0.000      1.000 1.000 0.000
#> SRR1655009     1   0.000      1.000 1.000 0.000
#> SRR1655010     1   0.000      1.000 1.000 0.000
#> SRR1655011     1   0.000      1.000 1.000 0.000
#> SRR1655012     2   0.000      0.960 0.000 1.000
#> SRR1655013     2   0.000      0.960 0.000 1.000
#> SRR1655014     2   0.000      0.960 0.000 1.000
#> SRR1655015     2   0.000      0.960 0.000 1.000
#> SRR1655016     2   0.000      0.960 0.000 1.000
#> SRR1655017     2   0.000      0.960 0.000 1.000
#> SRR1655018     2   0.000      0.960 0.000 1.000
#> SRR1655019     2   0.000      0.960 0.000 1.000
#> SRR1655020     2   0.000      0.960 0.000 1.000
#> SRR1655021     2   0.000      0.960 0.000 1.000
#> SRR1655022     2   0.000      0.960 0.000 1.000
#> SRR1655023     2   0.000      0.960 0.000 1.000
#> SRR1655024     2   0.000      0.960 0.000 1.000
#> SRR1655025     2   0.000      0.960 0.000 1.000
#> SRR1655026     2   0.141      0.951 0.020 0.980
#> SRR1655027     2   0.141      0.951 0.020 0.980
#> SRR1655028     2   0.141      0.951 0.020 0.980
#> SRR1655029     2   0.141      0.951 0.020 0.980
#> SRR1655030     2   0.141      0.951 0.020 0.980
#> SRR1655031     2   0.141      0.951 0.020 0.980
#> SRR1655032     2   0.141      0.951 0.020 0.980
#> SRR1655033     2   0.141      0.951 0.020 0.980
#> SRR1655034     2   0.706      0.800 0.192 0.808
#> SRR1655035     2   0.706      0.800 0.192 0.808
#> SRR1655036     2   0.706      0.800 0.192 0.808
#> SRR1655037     2   0.706      0.800 0.192 0.808
#> SRR1655038     2   0.706      0.800 0.192 0.808
#> SRR1655039     2   0.706      0.800 0.192 0.808
#> SRR1655040     2   0.706      0.800 0.192 0.808
#> SRR1655041     2   0.706      0.800 0.192 0.808
#> SRR1655042     2   0.000      0.960 0.000 1.000
#> SRR1655043     2   0.000      0.960 0.000 1.000
#> SRR1655044     2   0.000      0.960 0.000 1.000
#> SRR1655045     2   0.000      0.960 0.000 1.000
#> SRR1655046     2   0.000      0.960 0.000 1.000
#> SRR1655047     2   0.000      0.960 0.000 1.000
#> SRR1655048     2   0.000      0.960 0.000 1.000
#> SRR1655049     2   0.000      0.960 0.000 1.000
#> SRR1655050     2   0.000      0.960 0.000 1.000
#> SRR1655051     2   0.000      0.960 0.000 1.000
#> SRR1655052     2   0.000      0.960 0.000 1.000
#> SRR1655053     2   0.000      0.960 0.000 1.000
#> SRR1655054     2   0.000      0.960 0.000 1.000
#> SRR1655055     2   0.000      0.960 0.000 1.000
#> SRR1655056     2   0.000      0.960 0.000 1.000
#> SRR1655057     2   0.000      0.960 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
#> SRR1655002     1  0.0000      1.000  1 0.000 0.000
#> SRR1655003     1  0.0000      1.000  1 0.000 0.000
#> SRR1655004     1  0.0000      1.000  1 0.000 0.000
#> SRR1655005     1  0.0000      1.000  1 0.000 0.000
#> SRR1655006     1  0.0000      1.000  1 0.000 0.000
#> SRR1655007     1  0.0000      1.000  1 0.000 0.000
#> SRR1655008     1  0.0000      1.000  1 0.000 0.000
#> SRR1655009     1  0.0000      1.000  1 0.000 0.000
#> SRR1655010     1  0.0000      1.000  1 0.000 0.000
#> SRR1655011     1  0.0000      1.000  1 0.000 0.000
#> SRR1655012     2  0.0000      0.979  0 1.000 0.000
#> SRR1655013     2  0.0000      0.979  0 1.000 0.000
#> SRR1655014     2  0.0000      0.979  0 1.000 0.000
#> SRR1655015     2  0.0000      0.979  0 1.000 0.000
#> SRR1655016     2  0.0000      0.979  0 1.000 0.000
#> SRR1655017     2  0.0000      0.979  0 1.000 0.000
#> SRR1655018     2  0.1753      0.954  0 0.952 0.048
#> SRR1655019     2  0.1753      0.954  0 0.952 0.048
#> SRR1655020     2  0.0892      0.971  0 0.980 0.020
#> SRR1655021     2  0.0892      0.971  0 0.980 0.020
#> SRR1655022     2  0.0000      0.979  0 1.000 0.000
#> SRR1655023     2  0.0000      0.979  0 1.000 0.000
#> SRR1655024     2  0.0000      0.979  0 1.000 0.000
#> SRR1655025     2  0.0000      0.979  0 1.000 0.000
#> SRR1655026     3  0.1529      0.878  0 0.040 0.960
#> SRR1655027     3  0.1529      0.878  0 0.040 0.960
#> SRR1655028     3  0.1529      0.878  0 0.040 0.960
#> SRR1655029     3  0.1529      0.878  0 0.040 0.960
#> SRR1655030     3  0.2165      0.863  0 0.064 0.936
#> SRR1655031     3  0.2165      0.863  0 0.064 0.936
#> SRR1655032     3  0.1529      0.878  0 0.040 0.960
#> SRR1655033     3  0.1529      0.878  0 0.040 0.960
#> SRR1655034     3  0.0000      0.884  0 0.000 1.000
#> SRR1655035     3  0.0000      0.884  0 0.000 1.000
#> SRR1655036     3  0.0000      0.884  0 0.000 1.000
#> SRR1655037     3  0.0000      0.884  0 0.000 1.000
#> SRR1655038     3  0.0000      0.884  0 0.000 1.000
#> SRR1655039     3  0.0000      0.884  0 0.000 1.000
#> SRR1655040     3  0.0000      0.884  0 0.000 1.000
#> SRR1655041     3  0.0000      0.884  0 0.000 1.000
#> SRR1655042     3  0.6252      0.352  0 0.444 0.556
#> SRR1655043     3  0.6252      0.352  0 0.444 0.556
#> SRR1655044     3  0.6252      0.352  0 0.444 0.556
#> SRR1655045     3  0.6252      0.352  0 0.444 0.556
#> SRR1655046     3  0.6252      0.352  0 0.444 0.556
#> SRR1655047     3  0.6252      0.352  0 0.444 0.556
#> SRR1655048     2  0.2066      0.939  0 0.940 0.060
#> SRR1655049     2  0.2066      0.939  0 0.940 0.060
#> SRR1655050     3  0.0000      0.884  0 0.000 1.000
#> SRR1655051     3  0.0000      0.884  0 0.000 1.000
#> SRR1655052     3  0.0000      0.884  0 0.000 1.000
#> SRR1655053     3  0.0000      0.884  0 0.000 1.000
#> SRR1655054     3  0.0000      0.884  0 0.000 1.000
#> SRR1655055     3  0.0000      0.884  0 0.000 1.000
#> SRR1655056     3  0.0000      0.884  0 0.000 1.000
#> SRR1655057     3  0.0000      0.884  0 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette p1    p2 p3    p4
#> SRR1655002     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1655003     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1655004     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1655005     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1655006     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1655007     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1655008     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1655009     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1655010     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1655011     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1655012     2  0.0000      1.000  0 1.000  0 0.000
#> SRR1655013     2  0.0000      1.000  0 1.000  0 0.000
#> SRR1655014     2  0.0000      1.000  0 1.000  0 0.000
#> SRR1655015     2  0.0000      1.000  0 1.000  0 0.000
#> SRR1655016     2  0.0000      1.000  0 1.000  0 0.000
#> SRR1655017     2  0.0000      1.000  0 1.000  0 0.000
#> SRR1655018     2  0.0000      1.000  0 1.000  0 0.000
#> SRR1655019     2  0.0000      1.000  0 1.000  0 0.000
#> SRR1655020     2  0.0000      1.000  0 1.000  0 0.000
#> SRR1655021     2  0.0000      1.000  0 1.000  0 0.000
#> SRR1655022     2  0.0000      1.000  0 1.000  0 0.000
#> SRR1655023     2  0.0000      1.000  0 1.000  0 0.000
#> SRR1655024     2  0.0000      1.000  0 1.000  0 0.000
#> SRR1655025     2  0.0000      1.000  0 1.000  0 0.000
#> SRR1655026     4  0.0000      0.997  0 0.000  0 1.000
#> SRR1655027     4  0.0000      0.997  0 0.000  0 1.000
#> SRR1655028     4  0.0000      0.997  0 0.000  0 1.000
#> SRR1655029     4  0.0000      0.997  0 0.000  0 1.000
#> SRR1655030     4  0.0000      0.997  0 0.000  0 1.000
#> SRR1655031     4  0.0000      0.997  0 0.000  0 1.000
#> SRR1655032     4  0.0000      0.997  0 0.000  0 1.000
#> SRR1655033     4  0.0000      0.997  0 0.000  0 1.000
#> SRR1655034     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1655035     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1655036     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1655037     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1655038     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1655039     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1655040     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1655041     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1655042     4  0.0921      0.969  0 0.028  0 0.972
#> SRR1655043     4  0.0921      0.969  0 0.028  0 0.972
#> SRR1655044     4  0.0000      0.997  0 0.000  0 1.000
#> SRR1655045     4  0.0000      0.997  0 0.000  0 1.000
#> SRR1655046     4  0.0000      0.997  0 0.000  0 1.000
#> SRR1655047     4  0.0000      0.997  0 0.000  0 1.000
#> SRR1655048     2  0.0000      1.000  0 1.000  0 0.000
#> SRR1655049     2  0.0000      1.000  0 1.000  0 0.000
#> SRR1655050     4  0.0000      0.997  0 0.000  0 1.000
#> SRR1655051     4  0.0000      0.997  0 0.000  0 1.000
#> SRR1655052     4  0.0000      0.997  0 0.000  0 1.000
#> SRR1655053     4  0.0000      0.997  0 0.000  0 1.000
#> SRR1655054     4  0.0000      0.997  0 0.000  0 1.000
#> SRR1655055     4  0.0000      0.997  0 0.000  0 1.000
#> SRR1655056     4  0.0000      0.997  0 0.000  0 1.000
#> SRR1655057     4  0.0000      0.997  0 0.000  0 1.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette p1 p2 p3 p4 p5
#> SRR1655002     1       0          1  1  0  0  0  0
#> SRR1655003     1       0          1  1  0  0  0  0
#> SRR1655004     1       0          1  1  0  0  0  0
#> SRR1655005     1       0          1  1  0  0  0  0
#> SRR1655006     1       0          1  1  0  0  0  0
#> SRR1655007     1       0          1  1  0  0  0  0
#> SRR1655008     1       0          1  1  0  0  0  0
#> SRR1655009     1       0          1  1  0  0  0  0
#> SRR1655010     1       0          1  1  0  0  0  0
#> SRR1655011     1       0          1  1  0  0  0  0
#> SRR1655012     2       0          1  0  1  0  0  0
#> SRR1655013     2       0          1  0  1  0  0  0
#> SRR1655014     2       0          1  0  1  0  0  0
#> SRR1655015     2       0          1  0  1  0  0  0
#> SRR1655016     2       0          1  0  1  0  0  0
#> SRR1655017     2       0          1  0  1  0  0  0
#> SRR1655018     2       0          1  0  1  0  0  0
#> SRR1655019     2       0          1  0  1  0  0  0
#> SRR1655020     2       0          1  0  1  0  0  0
#> SRR1655021     2       0          1  0  1  0  0  0
#> SRR1655022     2       0          1  0  1  0  0  0
#> SRR1655023     2       0          1  0  1  0  0  0
#> SRR1655024     2       0          1  0  1  0  0  0
#> SRR1655025     2       0          1  0  1  0  0  0
#> SRR1655026     4       0          1  0  0  0  1  0
#> SRR1655027     4       0          1  0  0  0  1  0
#> SRR1655028     4       0          1  0  0  0  1  0
#> SRR1655029     4       0          1  0  0  0  1  0
#> SRR1655030     4       0          1  0  0  0  1  0
#> SRR1655031     4       0          1  0  0  0  1  0
#> SRR1655032     4       0          1  0  0  0  1  0
#> SRR1655033     4       0          1  0  0  0  1  0
#> SRR1655034     3       0          1  0  0  1  0  0
#> SRR1655035     3       0          1  0  0  1  0  0
#> SRR1655036     3       0          1  0  0  1  0  0
#> SRR1655037     3       0          1  0  0  1  0  0
#> SRR1655038     3       0          1  0  0  1  0  0
#> SRR1655039     3       0          1  0  0  1  0  0
#> SRR1655040     3       0          1  0  0  1  0  0
#> SRR1655041     3       0          1  0  0  1  0  0
#> SRR1655042     4       0          1  0  0  0  1  0
#> SRR1655043     4       0          1  0  0  0  1  0
#> SRR1655044     4       0          1  0  0  0  1  0
#> SRR1655045     4       0          1  0  0  0  1  0
#> SRR1655046     4       0          1  0  0  0  1  0
#> SRR1655047     4       0          1  0  0  0  1  0
#> SRR1655048     2       0          1  0  1  0  0  0
#> SRR1655049     2       0          1  0  1  0  0  0
#> SRR1655050     5       0          1  0  0  0  0  1
#> SRR1655051     5       0          1  0  0  0  0  1
#> SRR1655052     5       0          1  0  0  0  0  1
#> SRR1655053     5       0          1  0  0  0  0  1
#> SRR1655054     5       0          1  0  0  0  0  1
#> SRR1655055     5       0          1  0  0  0  0  1
#> SRR1655056     5       0          1  0  0  0  0  1
#> SRR1655057     5       0          1  0  0  0  0  1

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1655002     1       0          1  1  0  0  0  0  0
#> SRR1655003     1       0          1  1  0  0  0  0  0
#> SRR1655004     1       0          1  1  0  0  0  0  0
#> SRR1655005     1       0          1  1  0  0  0  0  0
#> SRR1655006     1       0          1  1  0  0  0  0  0
#> SRR1655007     1       0          1  1  0  0  0  0  0
#> SRR1655008     1       0          1  1  0  0  0  0  0
#> SRR1655009     1       0          1  1  0  0  0  0  0
#> SRR1655010     1       0          1  1  0  0  0  0  0
#> SRR1655011     1       0          1  1  0  0  0  0  0
#> SRR1655012     2       0          1  0  1  0  0  0  0
#> SRR1655013     2       0          1  0  1  0  0  0  0
#> SRR1655014     2       0          1  0  1  0  0  0  0
#> SRR1655015     2       0          1  0  1  0  0  0  0
#> SRR1655016     2       0          1  0  1  0  0  0  0
#> SRR1655017     2       0          1  0  1  0  0  0  0
#> SRR1655018     2       0          1  0  1  0  0  0  0
#> SRR1655019     2       0          1  0  1  0  0  0  0
#> SRR1655020     2       0          1  0  1  0  0  0  0
#> SRR1655021     2       0          1  0  1  0  0  0  0
#> SRR1655022     2       0          1  0  1  0  0  0  0
#> SRR1655023     2       0          1  0  1  0  0  0  0
#> SRR1655024     2       0          1  0  1  0  0  0  0
#> SRR1655025     2       0          1  0  1  0  0  0  0
#> SRR1655026     4       0          1  0  0  0  1  0  0
#> SRR1655027     4       0          1  0  0  0  1  0  0
#> SRR1655028     4       0          1  0  0  0  1  0  0
#> SRR1655029     4       0          1  0  0  0  1  0  0
#> SRR1655030     4       0          1  0  0  0  1  0  0
#> SRR1655031     4       0          1  0  0  0  1  0  0
#> SRR1655032     4       0          1  0  0  0  1  0  0
#> SRR1655033     4       0          1  0  0  0  1  0  0
#> SRR1655034     3       0          1  0  0  1  0  0  0
#> SRR1655035     3       0          1  0  0  1  0  0  0
#> SRR1655036     3       0          1  0  0  1  0  0  0
#> SRR1655037     3       0          1  0  0  1  0  0  0
#> SRR1655038     3       0          1  0  0  1  0  0  0
#> SRR1655039     3       0          1  0  0  1  0  0  0
#> SRR1655040     3       0          1  0  0  1  0  0  0
#> SRR1655041     3       0          1  0  0  1  0  0  0
#> SRR1655042     6       0          1  0  0  0  0  0  1
#> SRR1655043     6       0          1  0  0  0  0  0  1
#> SRR1655044     6       0          1  0  0  0  0  0  1
#> SRR1655045     6       0          1  0  0  0  0  0  1
#> SRR1655046     6       0          1  0  0  0  0  0  1
#> SRR1655047     6       0          1  0  0  0  0  0  1
#> SRR1655048     2       0          1  0  1  0  0  0  0
#> SRR1655049     2       0          1  0  1  0  0  0  0
#> SRR1655050     5       0          1  0  0  0  0  1  0
#> SRR1655051     5       0          1  0  0  0  0  1  0
#> SRR1655052     5       0          1  0  0  0  0  1  0
#> SRR1655053     5       0          1  0  0  0  0  1  0
#> SRR1655054     5       0          1  0  0  0  0  1  0
#> SRR1655055     5       0          1  0  0  0  0  1  0
#> SRR1655056     5       0          1  0  0  0  0  1  0
#> SRR1655057     5       0          1  0  0  0  0  1  0

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

consensus_heatmap(res, k = 2)

plot of chunk tab-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 15837 rows and 56 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           1.000       1.000         0.2995 0.701   0.701
#> 3 3 0.906           0.965       0.979         1.0450 0.688   0.556
#> 4 4 1.000           0.987       0.989         0.1762 0.803   0.542
#> 5 5 0.985           0.980       0.978         0.1031 0.844   0.508
#> 6 6 1.000           0.999       0.991         0.0521 0.958   0.795

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette    p1    p2
#> SRR1655002     1  0.0000      1.000 1.000 0.000
#> SRR1655003     1  0.0000      1.000 1.000 0.000
#> SRR1655004     1  0.0000      1.000 1.000 0.000
#> SRR1655005     1  0.0000      1.000 1.000 0.000
#> SRR1655006     1  0.0000      1.000 1.000 0.000
#> SRR1655007     1  0.0000      1.000 1.000 0.000
#> SRR1655008     1  0.0000      1.000 1.000 0.000
#> SRR1655009     1  0.0000      1.000 1.000 0.000
#> SRR1655010     1  0.0000      1.000 1.000 0.000
#> SRR1655011     1  0.0000      1.000 1.000 0.000
#> SRR1655012     2  0.0000      1.000 0.000 1.000
#> SRR1655013     2  0.0000      1.000 0.000 1.000
#> SRR1655014     2  0.0000      1.000 0.000 1.000
#> SRR1655015     2  0.0000      1.000 0.000 1.000
#> SRR1655016     2  0.0000      1.000 0.000 1.000
#> SRR1655017     2  0.0000      1.000 0.000 1.000
#> SRR1655018     2  0.0000      1.000 0.000 1.000
#> SRR1655019     2  0.0000      1.000 0.000 1.000
#> SRR1655020     2  0.0000      1.000 0.000 1.000
#> SRR1655021     2  0.0000      1.000 0.000 1.000
#> SRR1655022     2  0.0000      1.000 0.000 1.000
#> SRR1655023     2  0.0000      1.000 0.000 1.000
#> SRR1655024     2  0.0000      1.000 0.000 1.000
#> SRR1655025     2  0.0000      1.000 0.000 1.000
#> SRR1655026     2  0.0000      1.000 0.000 1.000
#> SRR1655027     2  0.0000      1.000 0.000 1.000
#> SRR1655028     2  0.0000      1.000 0.000 1.000
#> SRR1655029     2  0.0000      1.000 0.000 1.000
#> SRR1655030     2  0.0000      1.000 0.000 1.000
#> SRR1655031     2  0.0000      1.000 0.000 1.000
#> SRR1655032     2  0.0000      1.000 0.000 1.000
#> SRR1655033     2  0.0000      1.000 0.000 1.000
#> SRR1655034     2  0.0376      0.996 0.004 0.996
#> SRR1655035     2  0.0376      0.996 0.004 0.996
#> SRR1655036     2  0.0000      1.000 0.000 1.000
#> SRR1655037     2  0.0000      1.000 0.000 1.000
#> SRR1655038     2  0.0000      1.000 0.000 1.000
#> SRR1655039     2  0.0000      1.000 0.000 1.000
#> SRR1655040     2  0.0000      1.000 0.000 1.000
#> SRR1655041     2  0.0000      1.000 0.000 1.000
#> SRR1655042     2  0.0000      1.000 0.000 1.000
#> SRR1655043     2  0.0000      1.000 0.000 1.000
#> SRR1655044     2  0.0000      1.000 0.000 1.000
#> SRR1655045     2  0.0000      1.000 0.000 1.000
#> SRR1655046     2  0.0000      1.000 0.000 1.000
#> SRR1655047     2  0.0000      1.000 0.000 1.000
#> SRR1655048     2  0.0000      1.000 0.000 1.000
#> SRR1655049     2  0.0000      1.000 0.000 1.000
#> SRR1655050     2  0.0000      1.000 0.000 1.000
#> SRR1655051     2  0.0000      1.000 0.000 1.000
#> SRR1655052     2  0.0000      1.000 0.000 1.000
#> SRR1655053     2  0.0000      1.000 0.000 1.000
#> SRR1655054     2  0.0000      1.000 0.000 1.000
#> SRR1655055     2  0.0000      1.000 0.000 1.000
#> SRR1655056     2  0.0000      1.000 0.000 1.000
#> SRR1655057     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
#> SRR1655002     1  0.0000      1.000  1 0.000 0.000
#> SRR1655003     1  0.0000      1.000  1 0.000 0.000
#> SRR1655004     1  0.0000      1.000  1 0.000 0.000
#> SRR1655005     1  0.0000      1.000  1 0.000 0.000
#> SRR1655006     1  0.0000      1.000  1 0.000 0.000
#> SRR1655007     1  0.0000      1.000  1 0.000 0.000
#> SRR1655008     1  0.0000      1.000  1 0.000 0.000
#> SRR1655009     1  0.0000      1.000  1 0.000 0.000
#> SRR1655010     1  0.0000      1.000  1 0.000 0.000
#> SRR1655011     1  0.0000      1.000  1 0.000 0.000
#> SRR1655012     2  0.0000      0.965  0 1.000 0.000
#> SRR1655013     2  0.0000      0.965  0 1.000 0.000
#> SRR1655014     2  0.0000      0.965  0 1.000 0.000
#> SRR1655015     2  0.0000      0.965  0 1.000 0.000
#> SRR1655016     2  0.0000      0.965  0 1.000 0.000
#> SRR1655017     2  0.0000      0.965  0 1.000 0.000
#> SRR1655018     2  0.0000      0.965  0 1.000 0.000
#> SRR1655019     2  0.0000      0.965  0 1.000 0.000
#> SRR1655020     2  0.0000      0.965  0 1.000 0.000
#> SRR1655021     2  0.0000      0.965  0 1.000 0.000
#> SRR1655022     2  0.0000      0.965  0 1.000 0.000
#> SRR1655023     2  0.0000      0.965  0 1.000 0.000
#> SRR1655024     2  0.0000      0.965  0 1.000 0.000
#> SRR1655025     2  0.0000      0.965  0 1.000 0.000
#> SRR1655026     2  0.3116      0.900  0 0.892 0.108
#> SRR1655027     2  0.3116      0.900  0 0.892 0.108
#> SRR1655028     2  0.3879      0.858  0 0.848 0.152
#> SRR1655029     2  0.4002      0.848  0 0.840 0.160
#> SRR1655030     2  0.3619      0.875  0 0.864 0.136
#> SRR1655031     2  0.3412      0.886  0 0.876 0.124
#> SRR1655032     2  0.2796      0.912  0 0.908 0.092
#> SRR1655033     2  0.2711      0.915  0 0.912 0.088
#> SRR1655034     3  0.0000      0.983  0 0.000 1.000
#> SRR1655035     3  0.0000      0.983  0 0.000 1.000
#> SRR1655036     3  0.0000      0.983  0 0.000 1.000
#> SRR1655037     3  0.0000      0.983  0 0.000 1.000
#> SRR1655038     3  0.0000      0.983  0 0.000 1.000
#> SRR1655039     3  0.0000      0.983  0 0.000 1.000
#> SRR1655040     3  0.0000      0.983  0 0.000 1.000
#> SRR1655041     3  0.0000      0.983  0 0.000 1.000
#> SRR1655042     2  0.0000      0.965  0 1.000 0.000
#> SRR1655043     2  0.0000      0.965  0 1.000 0.000
#> SRR1655044     2  0.0000      0.965  0 1.000 0.000
#> SRR1655045     2  0.0000      0.965  0 1.000 0.000
#> SRR1655046     2  0.0000      0.965  0 1.000 0.000
#> SRR1655047     2  0.0000      0.965  0 1.000 0.000
#> SRR1655048     2  0.0000      0.965  0 1.000 0.000
#> SRR1655049     2  0.0000      0.965  0 1.000 0.000
#> SRR1655050     3  0.0892      0.983  0 0.020 0.980
#> SRR1655051     3  0.0892      0.983  0 0.020 0.980
#> SRR1655052     3  0.1289      0.973  0 0.032 0.968
#> SRR1655053     3  0.1031      0.980  0 0.024 0.976
#> SRR1655054     3  0.1289      0.973  0 0.032 0.968
#> SRR1655055     3  0.0892      0.983  0 0.020 0.980
#> SRR1655056     3  0.0892      0.983  0 0.020 0.980
#> SRR1655057     3  0.1031      0.980  0 0.024 0.976

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette p1    p2    p3    p4
#> SRR1655002     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1655003     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1655004     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1655005     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1655006     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1655007     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1655008     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1655009     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1655010     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1655011     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1655012     2  0.0000      0.997  0 1.000 0.000 0.000
#> SRR1655013     2  0.0000      0.997  0 1.000 0.000 0.000
#> SRR1655014     2  0.0000      0.997  0 1.000 0.000 0.000
#> SRR1655015     2  0.0000      0.997  0 1.000 0.000 0.000
#> SRR1655016     2  0.0000      0.997  0 1.000 0.000 0.000
#> SRR1655017     2  0.0000      0.997  0 1.000 0.000 0.000
#> SRR1655018     2  0.0000      0.997  0 1.000 0.000 0.000
#> SRR1655019     2  0.0000      0.997  0 1.000 0.000 0.000
#> SRR1655020     2  0.0000      0.997  0 1.000 0.000 0.000
#> SRR1655021     2  0.0000      0.997  0 1.000 0.000 0.000
#> SRR1655022     2  0.0000      0.997  0 1.000 0.000 0.000
#> SRR1655023     2  0.0000      0.997  0 1.000 0.000 0.000
#> SRR1655024     2  0.0000      0.997  0 1.000 0.000 0.000
#> SRR1655025     2  0.0000      0.997  0 1.000 0.000 0.000
#> SRR1655026     4  0.1557      0.961  0 0.056 0.000 0.944
#> SRR1655027     4  0.1557      0.961  0 0.056 0.000 0.944
#> SRR1655028     4  0.1557      0.961  0 0.056 0.000 0.944
#> SRR1655029     4  0.1557      0.961  0 0.056 0.000 0.944
#> SRR1655030     4  0.1557      0.961  0 0.056 0.000 0.944
#> SRR1655031     4  0.1557      0.961  0 0.056 0.000 0.944
#> SRR1655032     4  0.1557      0.961  0 0.056 0.000 0.944
#> SRR1655033     4  0.1557      0.961  0 0.056 0.000 0.944
#> SRR1655034     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR1655035     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR1655036     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR1655037     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR1655038     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR1655039     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR1655040     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR1655041     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR1655042     2  0.0336      0.995  0 0.992 0.000 0.008
#> SRR1655043     2  0.0336      0.995  0 0.992 0.000 0.008
#> SRR1655044     2  0.0336      0.995  0 0.992 0.000 0.008
#> SRR1655045     2  0.0336      0.995  0 0.992 0.000 0.008
#> SRR1655046     2  0.0336      0.995  0 0.992 0.000 0.008
#> SRR1655047     2  0.0336      0.995  0 0.992 0.000 0.008
#> SRR1655048     2  0.0336      0.995  0 0.992 0.000 0.008
#> SRR1655049     2  0.0336      0.995  0 0.992 0.000 0.008
#> SRR1655050     4  0.0657      0.960  0 0.004 0.012 0.984
#> SRR1655051     4  0.0657      0.960  0 0.004 0.012 0.984
#> SRR1655052     4  0.0657      0.960  0 0.004 0.012 0.984
#> SRR1655053     4  0.0657      0.960  0 0.004 0.012 0.984
#> SRR1655054     4  0.0657      0.960  0 0.004 0.012 0.984
#> SRR1655055     4  0.0657      0.960  0 0.004 0.012 0.984
#> SRR1655056     4  0.0657      0.960  0 0.004 0.012 0.984
#> SRR1655057     4  0.0657      0.960  0 0.004 0.012 0.984

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette p1    p2 p3    p4    p5
#> SRR1655002     1  0.0000      1.000  1 0.000  0 0.000 0.000
#> SRR1655003     1  0.0000      1.000  1 0.000  0 0.000 0.000
#> SRR1655004     1  0.0000      1.000  1 0.000  0 0.000 0.000
#> SRR1655005     1  0.0000      1.000  1 0.000  0 0.000 0.000
#> SRR1655006     1  0.0000      1.000  1 0.000  0 0.000 0.000
#> SRR1655007     1  0.0000      1.000  1 0.000  0 0.000 0.000
#> SRR1655008     1  0.0000      1.000  1 0.000  0 0.000 0.000
#> SRR1655009     1  0.0000      1.000  1 0.000  0 0.000 0.000
#> SRR1655010     1  0.0000      1.000  1 0.000  0 0.000 0.000
#> SRR1655011     1  0.0000      1.000  1 0.000  0 0.000 0.000
#> SRR1655012     2  0.0404      1.000  0 0.988  0 0.012 0.000
#> SRR1655013     2  0.0404      1.000  0 0.988  0 0.012 0.000
#> SRR1655014     2  0.0404      1.000  0 0.988  0 0.012 0.000
#> SRR1655015     2  0.0404      1.000  0 0.988  0 0.012 0.000
#> SRR1655016     2  0.0404      1.000  0 0.988  0 0.012 0.000
#> SRR1655017     2  0.0404      1.000  0 0.988  0 0.012 0.000
#> SRR1655018     2  0.0404      1.000  0 0.988  0 0.012 0.000
#> SRR1655019     2  0.0404      1.000  0 0.988  0 0.012 0.000
#> SRR1655020     2  0.0404      1.000  0 0.988  0 0.012 0.000
#> SRR1655021     2  0.0404      1.000  0 0.988  0 0.012 0.000
#> SRR1655022     2  0.0404      1.000  0 0.988  0 0.012 0.000
#> SRR1655023     2  0.0404      1.000  0 0.988  0 0.012 0.000
#> SRR1655024     2  0.0404      1.000  0 0.988  0 0.012 0.000
#> SRR1655025     2  0.0404      1.000  0 0.988  0 0.012 0.000
#> SRR1655026     4  0.2329      0.913  0 0.000  0 0.876 0.124
#> SRR1655027     4  0.2377      0.911  0 0.000  0 0.872 0.128
#> SRR1655028     4  0.1965      0.928  0 0.000  0 0.904 0.096
#> SRR1655029     4  0.1908      0.929  0 0.000  0 0.908 0.092
#> SRR1655030     4  0.2377      0.911  0 0.000  0 0.872 0.128
#> SRR1655031     4  0.2377      0.911  0 0.000  0 0.872 0.128
#> SRR1655032     4  0.1571      0.938  0 0.004  0 0.936 0.060
#> SRR1655033     4  0.1571      0.938  0 0.004  0 0.936 0.060
#> SRR1655034     3  0.0000      1.000  0 0.000  1 0.000 0.000
#> SRR1655035     3  0.0000      1.000  0 0.000  1 0.000 0.000
#> SRR1655036     3  0.0000      1.000  0 0.000  1 0.000 0.000
#> SRR1655037     3  0.0000      1.000  0 0.000  1 0.000 0.000
#> SRR1655038     3  0.0000      1.000  0 0.000  1 0.000 0.000
#> SRR1655039     3  0.0000      1.000  0 0.000  1 0.000 0.000
#> SRR1655040     3  0.0000      1.000  0 0.000  1 0.000 0.000
#> SRR1655041     3  0.0000      1.000  0 0.000  1 0.000 0.000
#> SRR1655042     4  0.0703      0.941  0 0.024  0 0.976 0.000
#> SRR1655043     4  0.0703      0.941  0 0.024  0 0.976 0.000
#> SRR1655044     4  0.0703      0.941  0 0.024  0 0.976 0.000
#> SRR1655045     4  0.0703      0.941  0 0.024  0 0.976 0.000
#> SRR1655046     4  0.0703      0.941  0 0.024  0 0.976 0.000
#> SRR1655047     4  0.0703      0.941  0 0.024  0 0.976 0.000
#> SRR1655048     4  0.1197      0.927  0 0.048  0 0.952 0.000
#> SRR1655049     4  0.1197      0.927  0 0.048  0 0.952 0.000
#> SRR1655050     5  0.0000      1.000  0 0.000  0 0.000 1.000
#> SRR1655051     5  0.0000      1.000  0 0.000  0 0.000 1.000
#> SRR1655052     5  0.0000      1.000  0 0.000  0 0.000 1.000
#> SRR1655053     5  0.0000      1.000  0 0.000  0 0.000 1.000
#> SRR1655054     5  0.0000      1.000  0 0.000  0 0.000 1.000
#> SRR1655055     5  0.0000      1.000  0 0.000  0 0.000 1.000
#> SRR1655056     5  0.0000      1.000  0 0.000  0 0.000 1.000
#> SRR1655057     5  0.0000      1.000  0 0.000  0 0.000 1.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
#> SRR1655002     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR1655003     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR1655004     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR1655005     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR1655006     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR1655007     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR1655008     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR1655009     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR1655010     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR1655011     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR1655012     2  0.0000      1.000  0 1.000  0 0.000 0.000 0.000
#> SRR1655013     2  0.0000      1.000  0 1.000  0 0.000 0.000 0.000
#> SRR1655014     2  0.0000      1.000  0 1.000  0 0.000 0.000 0.000
#> SRR1655015     2  0.0000      1.000  0 1.000  0 0.000 0.000 0.000
#> SRR1655016     2  0.0000      1.000  0 1.000  0 0.000 0.000 0.000
#> SRR1655017     2  0.0000      1.000  0 1.000  0 0.000 0.000 0.000
#> SRR1655018     2  0.0000      1.000  0 1.000  0 0.000 0.000 0.000
#> SRR1655019     2  0.0000      1.000  0 1.000  0 0.000 0.000 0.000
#> SRR1655020     2  0.0146      0.997  0 0.996  0 0.000 0.000 0.004
#> SRR1655021     2  0.0000      1.000  0 1.000  0 0.000 0.000 0.000
#> SRR1655022     2  0.0000      1.000  0 1.000  0 0.000 0.000 0.000
#> SRR1655023     2  0.0000      1.000  0 1.000  0 0.000 0.000 0.000
#> SRR1655024     2  0.0000      1.000  0 1.000  0 0.000 0.000 0.000
#> SRR1655025     2  0.0000      1.000  0 1.000  0 0.000 0.000 0.000
#> SRR1655026     4  0.0291      1.000  0 0.004  0 0.992 0.004 0.000
#> SRR1655027     4  0.0291      1.000  0 0.004  0 0.992 0.004 0.000
#> SRR1655028     4  0.0291      1.000  0 0.004  0 0.992 0.004 0.000
#> SRR1655029     4  0.0291      1.000  0 0.004  0 0.992 0.004 0.000
#> SRR1655030     4  0.0291      1.000  0 0.004  0 0.992 0.004 0.000
#> SRR1655031     4  0.0291      1.000  0 0.004  0 0.992 0.004 0.000
#> SRR1655032     4  0.0291      1.000  0 0.004  0 0.992 0.004 0.000
#> SRR1655033     4  0.0291      1.000  0 0.004  0 0.992 0.004 0.000
#> SRR1655034     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR1655035     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR1655036     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR1655037     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR1655038     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR1655039     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR1655040     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR1655041     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR1655042     6  0.1434      0.998  0 0.012  0 0.048 0.000 0.940
#> SRR1655043     6  0.1434      0.998  0 0.012  0 0.048 0.000 0.940
#> SRR1655044     6  0.1434      0.998  0 0.012  0 0.048 0.000 0.940
#> SRR1655045     6  0.1434      0.998  0 0.012  0 0.048 0.000 0.940
#> SRR1655046     6  0.1434      0.998  0 0.012  0 0.048 0.000 0.940
#> SRR1655047     6  0.1434      0.998  0 0.012  0 0.048 0.000 0.940
#> SRR1655048     6  0.1297      0.993  0 0.012  0 0.040 0.000 0.948
#> SRR1655049     6  0.1297      0.993  0 0.012  0 0.040 0.000 0.948
#> SRR1655050     5  0.0000      1.000  0 0.000  0 0.000 1.000 0.000
#> SRR1655051     5  0.0000      1.000  0 0.000  0 0.000 1.000 0.000
#> SRR1655052     5  0.0000      1.000  0 0.000  0 0.000 1.000 0.000
#> SRR1655053     5  0.0000      1.000  0 0.000  0 0.000 1.000 0.000
#> SRR1655054     5  0.0000      1.000  0 0.000  0 0.000 1.000 0.000
#> SRR1655055     5  0.0000      1.000  0 0.000  0 0.000 1.000 0.000
#> SRR1655056     5  0.0000      1.000  0 0.000  0 0.000 1.000 0.000
#> SRR1655057     5  0.0000      1.000  0 0.000  0 0.000 1.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 15837 rows and 56 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#>   Subgroups are detected by 'hclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 6.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk ATC-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.2994 0.701   0.701
#> 3 3 1.000           0.992       0.997         0.8758 0.735   0.622
#> 4 4 0.972           0.957       0.943         0.0299 0.984   0.964
#> 5 5 1.000           0.975       0.985         0.0396 0.979   0.951
#> 6 6 1.000           0.984       0.993         0.2801 0.829   0.571

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette p1 p2
#> SRR1655002     1       0          1  1  0
#> SRR1655003     1       0          1  1  0
#> SRR1655004     1       0          1  1  0
#> SRR1655005     1       0          1  1  0
#> SRR1655006     1       0          1  1  0
#> SRR1655007     1       0          1  1  0
#> SRR1655008     1       0          1  1  0
#> SRR1655009     1       0          1  1  0
#> SRR1655010     1       0          1  1  0
#> SRR1655011     1       0          1  1  0
#> SRR1655012     2       0          1  0  1
#> SRR1655013     2       0          1  0  1
#> SRR1655014     2       0          1  0  1
#> SRR1655015     2       0          1  0  1
#> SRR1655016     2       0          1  0  1
#> SRR1655017     2       0          1  0  1
#> SRR1655018     2       0          1  0  1
#> SRR1655019     2       0          1  0  1
#> SRR1655020     2       0          1  0  1
#> SRR1655021     2       0          1  0  1
#> SRR1655022     2       0          1  0  1
#> SRR1655023     2       0          1  0  1
#> SRR1655024     2       0          1  0  1
#> SRR1655025     2       0          1  0  1
#> SRR1655026     2       0          1  0  1
#> SRR1655027     2       0          1  0  1
#> SRR1655028     2       0          1  0  1
#> SRR1655029     2       0          1  0  1
#> SRR1655030     2       0          1  0  1
#> SRR1655031     2       0          1  0  1
#> SRR1655032     2       0          1  0  1
#> SRR1655033     2       0          1  0  1
#> SRR1655034     2       0          1  0  1
#> SRR1655035     2       0          1  0  1
#> SRR1655036     2       0          1  0  1
#> SRR1655037     2       0          1  0  1
#> SRR1655038     2       0          1  0  1
#> SRR1655039     2       0          1  0  1
#> SRR1655040     2       0          1  0  1
#> SRR1655041     2       0          1  0  1
#> SRR1655042     2       0          1  0  1
#> SRR1655043     2       0          1  0  1
#> SRR1655044     2       0          1  0  1
#> SRR1655045     2       0          1  0  1
#> SRR1655046     2       0          1  0  1
#> SRR1655047     2       0          1  0  1
#> SRR1655048     2       0          1  0  1
#> SRR1655049     2       0          1  0  1
#> SRR1655050     2       0          1  0  1
#> SRR1655051     2       0          1  0  1
#> SRR1655052     2       0          1  0  1
#> SRR1655053     2       0          1  0  1
#> SRR1655054     2       0          1  0  1
#> SRR1655055     2       0          1  0  1
#> SRR1655056     2       0          1  0  1
#> SRR1655057     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
#> SRR1655002     1   0.000      1.000  1 0.00 0.00
#> SRR1655003     1   0.000      1.000  1 0.00 0.00
#> SRR1655004     1   0.000      1.000  1 0.00 0.00
#> SRR1655005     1   0.000      1.000  1 0.00 0.00
#> SRR1655006     1   0.000      1.000  1 0.00 0.00
#> SRR1655007     1   0.000      1.000  1 0.00 0.00
#> SRR1655008     1   0.000      1.000  1 0.00 0.00
#> SRR1655009     1   0.000      1.000  1 0.00 0.00
#> SRR1655010     1   0.000      1.000  1 0.00 0.00
#> SRR1655011     1   0.000      1.000  1 0.00 0.00
#> SRR1655012     2   0.000      1.000  0 1.00 0.00
#> SRR1655013     2   0.000      1.000  0 1.00 0.00
#> SRR1655014     2   0.000      1.000  0 1.00 0.00
#> SRR1655015     2   0.000      1.000  0 1.00 0.00
#> SRR1655016     2   0.000      1.000  0 1.00 0.00
#> SRR1655017     2   0.000      1.000  0 1.00 0.00
#> SRR1655018     3   0.000      0.979  0 0.00 1.00
#> SRR1655019     3   0.000      0.979  0 0.00 1.00
#> SRR1655020     2   0.000      1.000  0 1.00 0.00
#> SRR1655021     2   0.000      1.000  0 1.00 0.00
#> SRR1655022     2   0.000      1.000  0 1.00 0.00
#> SRR1655023     2   0.000      1.000  0 1.00 0.00
#> SRR1655024     2   0.000      1.000  0 1.00 0.00
#> SRR1655025     2   0.000      1.000  0 1.00 0.00
#> SRR1655026     2   0.000      1.000  0 1.00 0.00
#> SRR1655027     2   0.000      1.000  0 1.00 0.00
#> SRR1655028     2   0.000      1.000  0 1.00 0.00
#> SRR1655029     2   0.000      1.000  0 1.00 0.00
#> SRR1655030     3   0.254      0.892  0 0.08 0.92
#> SRR1655031     3   0.254      0.892  0 0.08 0.92
#> SRR1655032     2   0.000      1.000  0 1.00 0.00
#> SRR1655033     2   0.000      1.000  0 1.00 0.00
#> SRR1655034     3   0.000      0.979  0 0.00 1.00
#> SRR1655035     3   0.000      0.979  0 0.00 1.00
#> SRR1655036     3   0.000      0.979  0 0.00 1.00
#> SRR1655037     3   0.000      0.979  0 0.00 1.00
#> SRR1655038     3   0.000      0.979  0 0.00 1.00
#> SRR1655039     3   0.000      0.979  0 0.00 1.00
#> SRR1655040     3   0.000      0.979  0 0.00 1.00
#> SRR1655041     3   0.000      0.979  0 0.00 1.00
#> SRR1655042     2   0.000      1.000  0 1.00 0.00
#> SRR1655043     2   0.000      1.000  0 1.00 0.00
#> SRR1655044     2   0.000      1.000  0 1.00 0.00
#> SRR1655045     2   0.000      1.000  0 1.00 0.00
#> SRR1655046     2   0.000      1.000  0 1.00 0.00
#> SRR1655047     2   0.000      1.000  0 1.00 0.00
#> SRR1655048     2   0.000      1.000  0 1.00 0.00
#> SRR1655049     2   0.000      1.000  0 1.00 0.00
#> SRR1655050     2   0.000      1.000  0 1.00 0.00
#> SRR1655051     2   0.000      1.000  0 1.00 0.00
#> SRR1655052     2   0.000      1.000  0 1.00 0.00
#> SRR1655053     2   0.000      1.000  0 1.00 0.00
#> SRR1655054     2   0.000      1.000  0 1.00 0.00
#> SRR1655055     2   0.000      1.000  0 1.00 0.00
#> SRR1655056     2   0.000      1.000  0 1.00 0.00
#> SRR1655057     2   0.000      1.000  0 1.00 0.00

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette   p1   p2   p3   p4
#> SRR1655002     4  0.0000      0.989 0.00 0.00 0.00 1.00
#> SRR1655003     1  0.4855      1.000 0.60 0.00 0.00 0.40
#> SRR1655004     1  0.4855      1.000 0.60 0.00 0.00 0.40
#> SRR1655005     1  0.4855      1.000 0.60 0.00 0.00 0.40
#> SRR1655006     4  0.0707      0.966 0.02 0.00 0.00 0.98
#> SRR1655007     1  0.4855      1.000 0.60 0.00 0.00 0.40
#> SRR1655008     1  0.4855      1.000 0.60 0.00 0.00 0.40
#> SRR1655009     1  0.4855      1.000 0.60 0.00 0.00 0.40
#> SRR1655010     4  0.0000      0.989 0.00 0.00 0.00 1.00
#> SRR1655011     4  0.0000      0.989 0.00 0.00 0.00 1.00
#> SRR1655012     2  0.0000      1.000 0.00 1.00 0.00 0.00
#> SRR1655013     2  0.0000      1.000 0.00 1.00 0.00 0.00
#> SRR1655014     2  0.0000      1.000 0.00 1.00 0.00 0.00
#> SRR1655015     2  0.0000      1.000 0.00 1.00 0.00 0.00
#> SRR1655016     2  0.0000      1.000 0.00 1.00 0.00 0.00
#> SRR1655017     2  0.0000      1.000 0.00 1.00 0.00 0.00
#> SRR1655018     3  0.0000      0.685 0.00 0.00 1.00 0.00
#> SRR1655019     3  0.0000      0.685 0.00 0.00 1.00 0.00
#> SRR1655020     2  0.0000      1.000 0.00 1.00 0.00 0.00
#> SRR1655021     2  0.0000      1.000 0.00 1.00 0.00 0.00
#> SRR1655022     2  0.0000      1.000 0.00 1.00 0.00 0.00
#> SRR1655023     2  0.0000      1.000 0.00 1.00 0.00 0.00
#> SRR1655024     2  0.0000      1.000 0.00 1.00 0.00 0.00
#> SRR1655025     2  0.0000      1.000 0.00 1.00 0.00 0.00
#> SRR1655026     2  0.0000      1.000 0.00 1.00 0.00 0.00
#> SRR1655027     2  0.0000      1.000 0.00 1.00 0.00 0.00
#> SRR1655028     2  0.0000      1.000 0.00 1.00 0.00 0.00
#> SRR1655029     2  0.0000      1.000 0.00 1.00 0.00 0.00
#> SRR1655030     3  0.2011      0.672 0.00 0.08 0.92 0.00
#> SRR1655031     3  0.2011      0.672 0.00 0.08 0.92 0.00
#> SRR1655032     2  0.0000      1.000 0.00 1.00 0.00 0.00
#> SRR1655033     2  0.0000      1.000 0.00 1.00 0.00 0.00
#> SRR1655034     3  0.4855      0.867 0.40 0.00 0.60 0.00
#> SRR1655035     3  0.4855      0.867 0.40 0.00 0.60 0.00
#> SRR1655036     3  0.4855      0.867 0.40 0.00 0.60 0.00
#> SRR1655037     3  0.4855      0.867 0.40 0.00 0.60 0.00
#> SRR1655038     3  0.4855      0.867 0.40 0.00 0.60 0.00
#> SRR1655039     3  0.4855      0.867 0.40 0.00 0.60 0.00
#> SRR1655040     3  0.4855      0.867 0.40 0.00 0.60 0.00
#> SRR1655041     3  0.4855      0.867 0.40 0.00 0.60 0.00
#> SRR1655042     2  0.0000      1.000 0.00 1.00 0.00 0.00
#> SRR1655043     2  0.0000      1.000 0.00 1.00 0.00 0.00
#> SRR1655044     2  0.0000      1.000 0.00 1.00 0.00 0.00
#> SRR1655045     2  0.0000      1.000 0.00 1.00 0.00 0.00
#> SRR1655046     2  0.0000      1.000 0.00 1.00 0.00 0.00
#> SRR1655047     2  0.0000      1.000 0.00 1.00 0.00 0.00
#> SRR1655048     2  0.0000      1.000 0.00 1.00 0.00 0.00
#> SRR1655049     2  0.0000      1.000 0.00 1.00 0.00 0.00
#> SRR1655050     2  0.0000      1.000 0.00 1.00 0.00 0.00
#> SRR1655051     2  0.0000      1.000 0.00 1.00 0.00 0.00
#> SRR1655052     2  0.0000      1.000 0.00 1.00 0.00 0.00
#> SRR1655053     2  0.0000      1.000 0.00 1.00 0.00 0.00
#> SRR1655054     2  0.0000      1.000 0.00 1.00 0.00 0.00
#> SRR1655055     2  0.0000      1.000 0.00 1.00 0.00 0.00
#> SRR1655056     2  0.0000      1.000 0.00 1.00 0.00 0.00
#> SRR1655057     2  0.0000      1.000 0.00 1.00 0.00 0.00

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4    p5
#> SRR1655002     5  0.0000      0.992 0.000 0.000 0.000 0.000 1.000
#> SRR1655003     1  0.0000      0.959 1.000 0.000 0.000 0.000 0.000
#> SRR1655004     1  0.0000      0.959 1.000 0.000 0.000 0.000 0.000
#> SRR1655005     1  0.0000      0.959 1.000 0.000 0.000 0.000 0.000
#> SRR1655006     5  0.0609      0.977 0.020 0.000 0.000 0.000 0.980
#> SRR1655007     1  0.3074      0.754 0.804 0.000 0.000 0.000 0.196
#> SRR1655008     1  0.0000      0.959 1.000 0.000 0.000 0.000 0.000
#> SRR1655009     1  0.0000      0.959 1.000 0.000 0.000 0.000 0.000
#> SRR1655010     5  0.0000      0.992 0.000 0.000 0.000 0.000 1.000
#> SRR1655011     5  0.0000      0.992 0.000 0.000 0.000 0.000 1.000
#> SRR1655012     4  0.0794      0.981 0.000 0.028 0.000 0.972 0.000
#> SRR1655013     4  0.0794      0.981 0.000 0.028 0.000 0.972 0.000
#> SRR1655014     4  0.0794      0.981 0.000 0.028 0.000 0.972 0.000
#> SRR1655015     4  0.0794      0.981 0.000 0.028 0.000 0.972 0.000
#> SRR1655016     4  0.0794      0.981 0.000 0.028 0.000 0.972 0.000
#> SRR1655017     4  0.0794      0.981 0.000 0.028 0.000 0.972 0.000
#> SRR1655018     2  0.0794      0.881 0.000 0.972 0.028 0.000 0.000
#> SRR1655019     2  0.0794      0.881 0.000 0.972 0.028 0.000 0.000
#> SRR1655020     4  0.0794      0.981 0.000 0.028 0.000 0.972 0.000
#> SRR1655021     4  0.0794      0.981 0.000 0.028 0.000 0.972 0.000
#> SRR1655022     4  0.0794      0.981 0.000 0.028 0.000 0.972 0.000
#> SRR1655023     4  0.0794      0.981 0.000 0.028 0.000 0.972 0.000
#> SRR1655024     4  0.0794      0.981 0.000 0.028 0.000 0.972 0.000
#> SRR1655025     4  0.0794      0.981 0.000 0.028 0.000 0.972 0.000
#> SRR1655026     4  0.0000      0.990 0.000 0.000 0.000 1.000 0.000
#> SRR1655027     4  0.0000      0.990 0.000 0.000 0.000 1.000 0.000
#> SRR1655028     4  0.0000      0.990 0.000 0.000 0.000 1.000 0.000
#> SRR1655029     4  0.0000      0.990 0.000 0.000 0.000 1.000 0.000
#> SRR1655030     2  0.2511      0.883 0.000 0.892 0.028 0.080 0.000
#> SRR1655031     2  0.2511      0.883 0.000 0.892 0.028 0.080 0.000
#> SRR1655032     4  0.0000      0.990 0.000 0.000 0.000 1.000 0.000
#> SRR1655033     4  0.0000      0.990 0.000 0.000 0.000 1.000 0.000
#> SRR1655034     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1655035     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1655036     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1655037     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1655038     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1655039     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1655040     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1655041     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1655042     4  0.0000      0.990 0.000 0.000 0.000 1.000 0.000
#> SRR1655043     4  0.0000      0.990 0.000 0.000 0.000 1.000 0.000
#> SRR1655044     4  0.0000      0.990 0.000 0.000 0.000 1.000 0.000
#> SRR1655045     4  0.0000      0.990 0.000 0.000 0.000 1.000 0.000
#> SRR1655046     4  0.0000      0.990 0.000 0.000 0.000 1.000 0.000
#> SRR1655047     4  0.0000      0.990 0.000 0.000 0.000 1.000 0.000
#> SRR1655048     4  0.0000      0.990 0.000 0.000 0.000 1.000 0.000
#> SRR1655049     4  0.0000      0.990 0.000 0.000 0.000 1.000 0.000
#> SRR1655050     4  0.0000      0.990 0.000 0.000 0.000 1.000 0.000
#> SRR1655051     4  0.0000      0.990 0.000 0.000 0.000 1.000 0.000
#> SRR1655052     4  0.0000      0.990 0.000 0.000 0.000 1.000 0.000
#> SRR1655053     4  0.0000      0.990 0.000 0.000 0.000 1.000 0.000
#> SRR1655054     4  0.0000      0.990 0.000 0.000 0.000 1.000 0.000
#> SRR1655055     4  0.0000      0.990 0.000 0.000 0.000 1.000 0.000
#> SRR1655056     4  0.0000      0.990 0.000 0.000 0.000 1.000 0.000
#> SRR1655057     4  0.0000      0.990 0.000 0.000 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1 p2 p3   p4    p5   p6
#> SRR1655002     5  0.0000      0.992 0.000  0  0 0.00 1.000 0.00
#> SRR1655003     1  0.0000      0.959 1.000  0  0 0.00 0.000 0.00
#> SRR1655004     1  0.0000      0.959 1.000  0  0 0.00 0.000 0.00
#> SRR1655005     1  0.0000      0.959 1.000  0  0 0.00 0.000 0.00
#> SRR1655006     5  0.0547      0.977 0.020  0  0 0.00 0.980 0.00
#> SRR1655007     1  0.2762      0.754 0.804  0  0 0.00 0.196 0.00
#> SRR1655008     1  0.0000      0.959 1.000  0  0 0.00 0.000 0.00
#> SRR1655009     1  0.0000      0.959 1.000  0  0 0.00 0.000 0.00
#> SRR1655010     5  0.0000      0.992 0.000  0  0 0.00 1.000 0.00
#> SRR1655011     5  0.0000      0.992 0.000  0  0 0.00 1.000 0.00
#> SRR1655012     2  0.0000      1.000 0.000  1  0 0.00 0.000 0.00
#> SRR1655013     2  0.0000      1.000 0.000  1  0 0.00 0.000 0.00
#> SRR1655014     2  0.0000      1.000 0.000  1  0 0.00 0.000 0.00
#> SRR1655015     2  0.0000      1.000 0.000  1  0 0.00 0.000 0.00
#> SRR1655016     2  0.0000      1.000 0.000  1  0 0.00 0.000 0.00
#> SRR1655017     2  0.0000      1.000 0.000  1  0 0.00 0.000 0.00
#> SRR1655018     4  0.0000      0.902 0.000  0  0 1.00 0.000 0.00
#> SRR1655019     4  0.0000      0.902 0.000  0  0 1.00 0.000 0.00
#> SRR1655020     2  0.0000      1.000 0.000  1  0 0.00 0.000 0.00
#> SRR1655021     2  0.0000      1.000 0.000  1  0 0.00 0.000 0.00
#> SRR1655022     2  0.0000      1.000 0.000  1  0 0.00 0.000 0.00
#> SRR1655023     2  0.0000      1.000 0.000  1  0 0.00 0.000 0.00
#> SRR1655024     2  0.0000      1.000 0.000  1  0 0.00 0.000 0.00
#> SRR1655025     2  0.0000      1.000 0.000  1  0 0.00 0.000 0.00
#> SRR1655026     6  0.0000      1.000 0.000  0  0 0.00 0.000 1.00
#> SRR1655027     6  0.0000      1.000 0.000  0  0 0.00 0.000 1.00
#> SRR1655028     6  0.0000      1.000 0.000  0  0 0.00 0.000 1.00
#> SRR1655029     6  0.0000      1.000 0.000  0  0 0.00 0.000 1.00
#> SRR1655030     4  0.1556      0.903 0.000  0  0 0.92 0.000 0.08
#> SRR1655031     4  0.1556      0.903 0.000  0  0 0.92 0.000 0.08
#> SRR1655032     6  0.0000      1.000 0.000  0  0 0.00 0.000 1.00
#> SRR1655033     6  0.0000      1.000 0.000  0  0 0.00 0.000 1.00
#> SRR1655034     3  0.0000      1.000 0.000  0  1 0.00 0.000 0.00
#> SRR1655035     3  0.0000      1.000 0.000  0  1 0.00 0.000 0.00
#> SRR1655036     3  0.0000      1.000 0.000  0  1 0.00 0.000 0.00
#> SRR1655037     3  0.0000      1.000 0.000  0  1 0.00 0.000 0.00
#> SRR1655038     3  0.0000      1.000 0.000  0  1 0.00 0.000 0.00
#> SRR1655039     3  0.0000      1.000 0.000  0  1 0.00 0.000 0.00
#> SRR1655040     3  0.0000      1.000 0.000  0  1 0.00 0.000 0.00
#> SRR1655041     3  0.0000      1.000 0.000  0  1 0.00 0.000 0.00
#> SRR1655042     6  0.0000      1.000 0.000  0  0 0.00 0.000 1.00
#> SRR1655043     6  0.0000      1.000 0.000  0  0 0.00 0.000 1.00
#> SRR1655044     6  0.0000      1.000 0.000  0  0 0.00 0.000 1.00
#> SRR1655045     6  0.0000      1.000 0.000  0  0 0.00 0.000 1.00
#> SRR1655046     6  0.0000      1.000 0.000  0  0 0.00 0.000 1.00
#> SRR1655047     6  0.0000      1.000 0.000  0  0 0.00 0.000 1.00
#> SRR1655048     6  0.0000      1.000 0.000  0  0 0.00 0.000 1.00
#> SRR1655049     6  0.0000      1.000 0.000  0  0 0.00 0.000 1.00
#> SRR1655050     6  0.0000      1.000 0.000  0  0 0.00 0.000 1.00
#> SRR1655051     6  0.0000      1.000 0.000  0  0 0.00 0.000 1.00
#> SRR1655052     6  0.0000      1.000 0.000  0  0 0.00 0.000 1.00
#> SRR1655053     6  0.0000      1.000 0.000  0  0 0.00 0.000 1.00
#> SRR1655054     6  0.0000      1.000 0.000  0  0 0.00 0.000 1.00
#> SRR1655055     6  0.0000      1.000 0.000  0  0 0.00 0.000 1.00
#> SRR1655056     6  0.0000      1.000 0.000  0  0 0.00 0.000 1.00
#> SRR1655057     6  0.0000      1.000 0.000  0  0 0.00 0.000 1.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-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 15837 rows and 56 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#>   Subgroups are detected by 'kmeans' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk ATC-kmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.2994 0.701   0.701
#> 3 3 0.553           0.888       0.911         0.8041 0.766   0.667
#> 4 4 0.577           0.558       0.701         0.2693 0.831   0.639
#> 5 5 0.645           0.742       0.763         0.1077 0.808   0.435
#> 6 6 0.681           0.725       0.754         0.0674 0.930   0.693

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
#> SRR1655002     1       0          1  1  0
#> SRR1655003     1       0          1  1  0
#> SRR1655004     1       0          1  1  0
#> SRR1655005     1       0          1  1  0
#> SRR1655006     1       0          1  1  0
#> SRR1655007     1       0          1  1  0
#> SRR1655008     1       0          1  1  0
#> SRR1655009     1       0          1  1  0
#> SRR1655010     1       0          1  1  0
#> SRR1655011     1       0          1  1  0
#> SRR1655012     2       0          1  0  1
#> SRR1655013     2       0          1  0  1
#> SRR1655014     2       0          1  0  1
#> SRR1655015     2       0          1  0  1
#> SRR1655016     2       0          1  0  1
#> SRR1655017     2       0          1  0  1
#> SRR1655018     2       0          1  0  1
#> SRR1655019     2       0          1  0  1
#> SRR1655020     2       0          1  0  1
#> SRR1655021     2       0          1  0  1
#> SRR1655022     2       0          1  0  1
#> SRR1655023     2       0          1  0  1
#> SRR1655024     2       0          1  0  1
#> SRR1655025     2       0          1  0  1
#> SRR1655026     2       0          1  0  1
#> SRR1655027     2       0          1  0  1
#> SRR1655028     2       0          1  0  1
#> SRR1655029     2       0          1  0  1
#> SRR1655030     2       0          1  0  1
#> SRR1655031     2       0          1  0  1
#> SRR1655032     2       0          1  0  1
#> SRR1655033     2       0          1  0  1
#> SRR1655034     2       0          1  0  1
#> SRR1655035     2       0          1  0  1
#> SRR1655036     2       0          1  0  1
#> SRR1655037     2       0          1  0  1
#> SRR1655038     2       0          1  0  1
#> SRR1655039     2       0          1  0  1
#> SRR1655040     2       0          1  0  1
#> SRR1655041     2       0          1  0  1
#> SRR1655042     2       0          1  0  1
#> SRR1655043     2       0          1  0  1
#> SRR1655044     2       0          1  0  1
#> SRR1655045     2       0          1  0  1
#> SRR1655046     2       0          1  0  1
#> SRR1655047     2       0          1  0  1
#> SRR1655048     2       0          1  0  1
#> SRR1655049     2       0          1  0  1
#> SRR1655050     2       0          1  0  1
#> SRR1655051     2       0          1  0  1
#> SRR1655052     2       0          1  0  1
#> SRR1655053     2       0          1  0  1
#> SRR1655054     2       0          1  0  1
#> SRR1655055     2       0          1  0  1
#> SRR1655056     2       0          1  0  1
#> SRR1655057     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
#> SRR1655002     1  0.2625      0.961 0.916 0.000 0.084
#> SRR1655003     1  0.0000      0.974 1.000 0.000 0.000
#> SRR1655004     1  0.0000      0.974 1.000 0.000 0.000
#> SRR1655005     1  0.0000      0.974 1.000 0.000 0.000
#> SRR1655006     1  0.2625      0.961 0.916 0.000 0.084
#> SRR1655007     1  0.0000      0.974 1.000 0.000 0.000
#> SRR1655008     1  0.0000      0.974 1.000 0.000 0.000
#> SRR1655009     1  0.0000      0.974 1.000 0.000 0.000
#> SRR1655010     1  0.2625      0.961 0.916 0.000 0.084
#> SRR1655011     1  0.2625      0.961 0.916 0.000 0.084
#> SRR1655012     2  0.2796      0.888 0.000 0.908 0.092
#> SRR1655013     2  0.2796      0.888 0.000 0.908 0.092
#> SRR1655014     2  0.4452      0.794 0.000 0.808 0.192
#> SRR1655015     2  0.4452      0.794 0.000 0.808 0.192
#> SRR1655016     2  0.2796      0.888 0.000 0.908 0.092
#> SRR1655017     2  0.2796      0.888 0.000 0.908 0.092
#> SRR1655018     3  0.4235      0.919 0.000 0.176 0.824
#> SRR1655019     3  0.4235      0.919 0.000 0.176 0.824
#> SRR1655020     2  0.5968      0.478 0.000 0.636 0.364
#> SRR1655021     2  0.5968      0.478 0.000 0.636 0.364
#> SRR1655022     2  0.2711      0.889 0.000 0.912 0.088
#> SRR1655023     2  0.2711      0.889 0.000 0.912 0.088
#> SRR1655024     2  0.2711      0.889 0.000 0.912 0.088
#> SRR1655025     2  0.2711      0.889 0.000 0.912 0.088
#> SRR1655026     2  0.0592      0.896 0.000 0.988 0.012
#> SRR1655027     2  0.0592      0.896 0.000 0.988 0.012
#> SRR1655028     2  0.0592      0.896 0.000 0.988 0.012
#> SRR1655029     2  0.0592      0.896 0.000 0.988 0.012
#> SRR1655030     2  0.5760      0.531 0.000 0.672 0.328
#> SRR1655031     2  0.5760      0.531 0.000 0.672 0.328
#> SRR1655032     2  0.0592      0.896 0.000 0.988 0.012
#> SRR1655033     2  0.0592      0.896 0.000 0.988 0.012
#> SRR1655034     3  0.3267      0.980 0.000 0.116 0.884
#> SRR1655035     3  0.3267      0.980 0.000 0.116 0.884
#> SRR1655036     3  0.3267      0.980 0.000 0.116 0.884
#> SRR1655037     3  0.3267      0.980 0.000 0.116 0.884
#> SRR1655038     3  0.3267      0.980 0.000 0.116 0.884
#> SRR1655039     3  0.3267      0.980 0.000 0.116 0.884
#> SRR1655040     3  0.3267      0.980 0.000 0.116 0.884
#> SRR1655041     3  0.3267      0.980 0.000 0.116 0.884
#> SRR1655042     2  0.2066      0.897 0.000 0.940 0.060
#> SRR1655043     2  0.2066      0.897 0.000 0.940 0.060
#> SRR1655044     2  0.0892      0.893 0.000 0.980 0.020
#> SRR1655045     2  0.0892      0.893 0.000 0.980 0.020
#> SRR1655046     2  0.2066      0.897 0.000 0.940 0.060
#> SRR1655047     2  0.2066      0.897 0.000 0.940 0.060
#> SRR1655048     2  0.2066      0.897 0.000 0.940 0.060
#> SRR1655049     2  0.2066      0.897 0.000 0.940 0.060
#> SRR1655050     2  0.1753      0.891 0.000 0.952 0.048
#> SRR1655051     2  0.1753      0.891 0.000 0.952 0.048
#> SRR1655052     2  0.1753      0.891 0.000 0.952 0.048
#> SRR1655053     2  0.1753      0.891 0.000 0.952 0.048
#> SRR1655054     2  0.1753      0.891 0.000 0.952 0.048
#> SRR1655055     2  0.1753      0.891 0.000 0.952 0.048
#> SRR1655056     2  0.1753      0.891 0.000 0.952 0.048
#> SRR1655057     2  0.1753      0.891 0.000 0.952 0.048

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1655002     1  0.3219     0.9333 0.868 0.000 0.020 0.112
#> SRR1655003     1  0.0000     0.9540 1.000 0.000 0.000 0.000
#> SRR1655004     1  0.0000     0.9540 1.000 0.000 0.000 0.000
#> SRR1655005     1  0.0000     0.9540 1.000 0.000 0.000 0.000
#> SRR1655006     1  0.3166     0.9331 0.868 0.000 0.016 0.116
#> SRR1655007     1  0.0672     0.9540 0.984 0.000 0.008 0.008
#> SRR1655008     1  0.0672     0.9540 0.984 0.000 0.008 0.008
#> SRR1655009     1  0.0672     0.9540 0.984 0.000 0.008 0.008
#> SRR1655010     1  0.3217     0.9332 0.860 0.000 0.012 0.128
#> SRR1655011     1  0.3217     0.9332 0.860 0.000 0.012 0.128
#> SRR1655012     2  0.1661     0.4815 0.000 0.944 0.052 0.004
#> SRR1655013     2  0.1661     0.4815 0.000 0.944 0.052 0.004
#> SRR1655014     2  0.4424     0.4100 0.000 0.812 0.088 0.100
#> SRR1655015     2  0.4424     0.4100 0.000 0.812 0.088 0.100
#> SRR1655016     2  0.1661     0.4815 0.000 0.944 0.052 0.004
#> SRR1655017     2  0.1661     0.4815 0.000 0.944 0.052 0.004
#> SRR1655018     3  0.5678     0.7558 0.000 0.172 0.716 0.112
#> SRR1655019     3  0.5678     0.7558 0.000 0.172 0.716 0.112
#> SRR1655020     2  0.5811     0.3344 0.000 0.704 0.180 0.116
#> SRR1655021     2  0.5811     0.3344 0.000 0.704 0.180 0.116
#> SRR1655022     2  0.1743     0.4819 0.000 0.940 0.056 0.004
#> SRR1655023     2  0.1743     0.4819 0.000 0.940 0.056 0.004
#> SRR1655024     2  0.2363     0.4761 0.000 0.920 0.056 0.024
#> SRR1655025     2  0.2363     0.4761 0.000 0.920 0.056 0.024
#> SRR1655026     2  0.5000    -0.2130 0.000 0.504 0.000 0.496
#> SRR1655027     2  0.5000    -0.2130 0.000 0.504 0.000 0.496
#> SRR1655028     2  0.5000    -0.2130 0.000 0.504 0.000 0.496
#> SRR1655029     2  0.5000    -0.2130 0.000 0.504 0.000 0.496
#> SRR1655030     4  0.7700    -0.0563 0.000 0.384 0.220 0.396
#> SRR1655031     4  0.7700    -0.0563 0.000 0.384 0.220 0.396
#> SRR1655032     2  0.5000    -0.2130 0.000 0.504 0.000 0.496
#> SRR1655033     2  0.5000    -0.2130 0.000 0.504 0.000 0.496
#> SRR1655034     3  0.1629     0.9369 0.000 0.024 0.952 0.024
#> SRR1655035     3  0.1629     0.9369 0.000 0.024 0.952 0.024
#> SRR1655036     3  0.1151     0.9410 0.000 0.024 0.968 0.008
#> SRR1655037     3  0.1151     0.9410 0.000 0.024 0.968 0.008
#> SRR1655038     3  0.1151     0.9410 0.000 0.024 0.968 0.008
#> SRR1655039     3  0.1151     0.9410 0.000 0.024 0.968 0.008
#> SRR1655040     3  0.1151     0.9410 0.000 0.024 0.968 0.008
#> SRR1655041     3  0.1151     0.9410 0.000 0.024 0.968 0.008
#> SRR1655042     2  0.4866     0.3271 0.000 0.596 0.000 0.404
#> SRR1655043     2  0.4866     0.3271 0.000 0.596 0.000 0.404
#> SRR1655044     2  0.4817     0.3043 0.000 0.612 0.000 0.388
#> SRR1655045     2  0.4817     0.3043 0.000 0.612 0.000 0.388
#> SRR1655046     2  0.4866     0.3271 0.000 0.596 0.000 0.404
#> SRR1655047     2  0.4866     0.3271 0.000 0.596 0.000 0.404
#> SRR1655048     2  0.4817     0.3216 0.000 0.612 0.000 0.388
#> SRR1655049     2  0.4817     0.3216 0.000 0.612 0.000 0.388
#> SRR1655050     4  0.5306     0.7795 0.000 0.348 0.020 0.632
#> SRR1655051     4  0.5306     0.7795 0.000 0.348 0.020 0.632
#> SRR1655052     4  0.5306     0.7795 0.000 0.348 0.020 0.632
#> SRR1655053     4  0.5306     0.7795 0.000 0.348 0.020 0.632
#> SRR1655054     4  0.5306     0.7795 0.000 0.348 0.020 0.632
#> SRR1655055     4  0.5306     0.7795 0.000 0.348 0.020 0.632
#> SRR1655056     4  0.5306     0.7795 0.000 0.348 0.020 0.632
#> SRR1655057     4  0.5306     0.7795 0.000 0.348 0.020 0.632

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4    p5
#> SRR1655002     1  0.4140      0.897 0.792 0.028 0.016 0.160 0.004
#> SRR1655003     1  0.1041      0.926 0.964 0.032 0.000 0.004 0.000
#> SRR1655004     1  0.1124      0.926 0.960 0.036 0.000 0.004 0.000
#> SRR1655005     1  0.1124      0.926 0.960 0.036 0.000 0.004 0.000
#> SRR1655006     1  0.4044      0.897 0.792 0.020 0.016 0.168 0.004
#> SRR1655007     1  0.0162      0.926 0.996 0.000 0.000 0.004 0.000
#> SRR1655008     1  0.0000      0.926 1.000 0.000 0.000 0.000 0.000
#> SRR1655009     1  0.0000      0.926 1.000 0.000 0.000 0.000 0.000
#> SRR1655010     1  0.3668      0.897 0.796 0.012 0.004 0.184 0.004
#> SRR1655011     1  0.3668      0.897 0.796 0.012 0.004 0.184 0.004
#> SRR1655012     2  0.3551      0.853 0.000 0.820 0.000 0.044 0.136
#> SRR1655013     2  0.3551      0.853 0.000 0.820 0.000 0.044 0.136
#> SRR1655014     2  0.2341      0.791 0.000 0.912 0.020 0.012 0.056
#> SRR1655015     2  0.2341      0.791 0.000 0.912 0.020 0.012 0.056
#> SRR1655016     2  0.3551      0.853 0.000 0.820 0.000 0.044 0.136
#> SRR1655017     2  0.3551      0.853 0.000 0.820 0.000 0.044 0.136
#> SRR1655018     3  0.6329      0.414 0.000 0.372 0.492 0.128 0.008
#> SRR1655019     3  0.6329      0.414 0.000 0.372 0.492 0.128 0.008
#> SRR1655020     2  0.4226      0.702 0.000 0.808 0.068 0.096 0.028
#> SRR1655021     2  0.4226      0.702 0.000 0.808 0.068 0.096 0.028
#> SRR1655022     2  0.4343      0.833 0.000 0.768 0.000 0.096 0.136
#> SRR1655023     2  0.4343      0.833 0.000 0.768 0.000 0.096 0.136
#> SRR1655024     2  0.4437      0.825 0.000 0.760 0.000 0.100 0.140
#> SRR1655025     2  0.4437      0.825 0.000 0.760 0.000 0.100 0.140
#> SRR1655026     5  0.6339      0.418 0.000 0.128 0.020 0.284 0.568
#> SRR1655027     5  0.6339      0.418 0.000 0.128 0.020 0.284 0.568
#> SRR1655028     5  0.6339      0.418 0.000 0.128 0.020 0.284 0.568
#> SRR1655029     5  0.6339      0.418 0.000 0.128 0.020 0.284 0.568
#> SRR1655030     4  0.8409      0.185 0.000 0.232 0.168 0.348 0.252
#> SRR1655031     4  0.8409      0.185 0.000 0.232 0.168 0.348 0.252
#> SRR1655032     5  0.6339      0.418 0.000 0.128 0.020 0.284 0.568
#> SRR1655033     5  0.6339      0.418 0.000 0.128 0.020 0.284 0.568
#> SRR1655034     3  0.2040      0.890 0.000 0.032 0.928 0.032 0.008
#> SRR1655035     3  0.2040      0.890 0.000 0.032 0.928 0.032 0.008
#> SRR1655036     3  0.1168      0.894 0.000 0.032 0.960 0.000 0.008
#> SRR1655037     3  0.1168      0.894 0.000 0.032 0.960 0.000 0.008
#> SRR1655038     3  0.1673      0.893 0.000 0.032 0.944 0.016 0.008
#> SRR1655039     3  0.1673      0.893 0.000 0.032 0.944 0.016 0.008
#> SRR1655040     3  0.1168      0.894 0.000 0.032 0.960 0.000 0.008
#> SRR1655041     3  0.1168      0.894 0.000 0.032 0.960 0.000 0.008
#> SRR1655042     4  0.6128      0.798 0.000 0.188 0.000 0.560 0.252
#> SRR1655043     4  0.6128      0.798 0.000 0.188 0.000 0.560 0.252
#> SRR1655044     4  0.6296      0.776 0.000 0.180 0.004 0.548 0.268
#> SRR1655045     4  0.6296      0.776 0.000 0.180 0.004 0.548 0.268
#> SRR1655046     4  0.6128      0.798 0.000 0.188 0.000 0.560 0.252
#> SRR1655047     4  0.6128      0.798 0.000 0.188 0.000 0.560 0.252
#> SRR1655048     4  0.6087      0.784 0.000 0.188 0.000 0.568 0.244
#> SRR1655049     4  0.6087      0.784 0.000 0.188 0.000 0.568 0.244
#> SRR1655050     5  0.1329      0.691 0.000 0.008 0.004 0.032 0.956
#> SRR1655051     5  0.1329      0.691 0.000 0.008 0.004 0.032 0.956
#> SRR1655052     5  0.0613      0.696 0.000 0.008 0.004 0.004 0.984
#> SRR1655053     5  0.0613      0.696 0.000 0.008 0.004 0.004 0.984
#> SRR1655054     5  0.0740      0.696 0.000 0.008 0.004 0.008 0.980
#> SRR1655055     5  0.0740      0.696 0.000 0.008 0.004 0.008 0.980
#> SRR1655056     5  0.0451      0.696 0.000 0.008 0.004 0.000 0.988
#> SRR1655057     5  0.0451      0.696 0.000 0.008 0.004 0.000 0.988

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5 p6
#> SRR1655002     1  0.3330      0.851 0.716 0.000 0.000 0.000 0.000 NA
#> SRR1655003     1  0.1367      0.893 0.944 0.000 0.000 0.044 0.000 NA
#> SRR1655004     1  0.1367      0.893 0.944 0.000 0.000 0.044 0.000 NA
#> SRR1655005     1  0.1367      0.893 0.944 0.000 0.000 0.044 0.000 NA
#> SRR1655006     1  0.3330      0.851 0.716 0.000 0.000 0.000 0.000 NA
#> SRR1655007     1  0.0146      0.893 0.996 0.000 0.000 0.004 0.000 NA
#> SRR1655008     1  0.0000      0.893 1.000 0.000 0.000 0.000 0.000 NA
#> SRR1655009     1  0.0000      0.893 1.000 0.000 0.000 0.000 0.000 NA
#> SRR1655010     1  0.3656      0.851 0.728 0.004 0.000 0.012 0.000 NA
#> SRR1655011     1  0.3656      0.851 0.728 0.004 0.000 0.012 0.000 NA
#> SRR1655012     2  0.2177      0.870 0.000 0.908 0.000 0.032 0.052 NA
#> SRR1655013     2  0.2177      0.870 0.000 0.908 0.000 0.032 0.052 NA
#> SRR1655014     2  0.0924      0.847 0.000 0.972 0.008 0.008 0.004 NA
#> SRR1655015     2  0.0924      0.847 0.000 0.972 0.008 0.008 0.004 NA
#> SRR1655016     2  0.2177      0.870 0.000 0.908 0.000 0.032 0.052 NA
#> SRR1655017     2  0.2177      0.870 0.000 0.908 0.000 0.032 0.052 NA
#> SRR1655018     3  0.7412      0.277 0.000 0.276 0.364 0.104 0.004 NA
#> SRR1655019     3  0.7412      0.277 0.000 0.276 0.364 0.104 0.004 NA
#> SRR1655020     2  0.4375      0.752 0.000 0.752 0.024 0.056 0.004 NA
#> SRR1655021     2  0.4375      0.752 0.000 0.752 0.024 0.056 0.004 NA
#> SRR1655022     2  0.4359      0.851 0.000 0.772 0.000 0.092 0.052 NA
#> SRR1655023     2  0.4359      0.851 0.000 0.772 0.000 0.092 0.052 NA
#> SRR1655024     2  0.4416      0.842 0.000 0.768 0.000 0.096 0.056 NA
#> SRR1655025     2  0.4416      0.842 0.000 0.768 0.000 0.096 0.056 NA
#> SRR1655026     4  0.5576      0.255 0.000 0.040 0.000 0.468 0.440 NA
#> SRR1655027     4  0.5576      0.255 0.000 0.040 0.000 0.468 0.440 NA
#> SRR1655028     4  0.5576      0.255 0.000 0.040 0.000 0.468 0.440 NA
#> SRR1655029     4  0.5576      0.255 0.000 0.040 0.000 0.468 0.440 NA
#> SRR1655030     4  0.7990      0.269 0.000 0.128 0.104 0.460 0.148 NA
#> SRR1655031     4  0.7990      0.269 0.000 0.128 0.104 0.460 0.148 NA
#> SRR1655032     4  0.5576      0.255 0.000 0.040 0.000 0.468 0.440 NA
#> SRR1655033     4  0.5576      0.255 0.000 0.040 0.000 0.468 0.440 NA
#> SRR1655034     3  0.2706      0.829 0.000 0.008 0.876 0.028 0.004 NA
#> SRR1655035     3  0.2706      0.829 0.000 0.008 0.876 0.028 0.004 NA
#> SRR1655036     3  0.0146      0.853 0.000 0.004 0.996 0.000 0.000 NA
#> SRR1655037     3  0.0146      0.853 0.000 0.004 0.996 0.000 0.000 NA
#> SRR1655038     3  0.1194      0.850 0.000 0.004 0.956 0.008 0.000 NA
#> SRR1655039     3  0.1194      0.850 0.000 0.004 0.956 0.008 0.000 NA
#> SRR1655040     3  0.0146      0.853 0.000 0.004 0.996 0.000 0.000 NA
#> SRR1655041     3  0.0146      0.853 0.000 0.004 0.996 0.000 0.000 NA
#> SRR1655042     4  0.6357      0.579 0.000 0.104 0.000 0.572 0.132 NA
#> SRR1655043     4  0.6357      0.579 0.000 0.104 0.000 0.572 0.132 NA
#> SRR1655044     4  0.6284      0.576 0.000 0.092 0.000 0.580 0.144 NA
#> SRR1655045     4  0.6284      0.576 0.000 0.092 0.000 0.580 0.144 NA
#> SRR1655046     4  0.6333      0.579 0.000 0.104 0.000 0.576 0.132 NA
#> SRR1655047     4  0.6333      0.579 0.000 0.104 0.000 0.576 0.132 NA
#> SRR1655048     4  0.6518      0.559 0.000 0.108 0.000 0.544 0.128 NA
#> SRR1655049     4  0.6518      0.559 0.000 0.108 0.000 0.544 0.128 NA
#> SRR1655050     5  0.0858      0.967 0.000 0.004 0.000 0.000 0.968 NA
#> SRR1655051     5  0.0777      0.968 0.000 0.004 0.000 0.000 0.972 NA
#> SRR1655052     5  0.0692      0.978 0.000 0.004 0.000 0.000 0.976 NA
#> SRR1655053     5  0.0692      0.978 0.000 0.004 0.000 0.000 0.976 NA
#> SRR1655054     5  0.0692      0.974 0.000 0.004 0.000 0.000 0.976 NA
#> SRR1655055     5  0.0692      0.974 0.000 0.004 0.000 0.000 0.976 NA
#> SRR1655056     5  0.0858      0.978 0.000 0.004 0.000 0.000 0.968 NA
#> SRR1655057     5  0.0858      0.978 0.000 0.004 0.000 0.000 0.968 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 15837 rows and 56 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.299 0.701   0.701
#> 3 3 1.000           0.984       0.993          0.683 0.803   0.719
#> 4 4 0.799           0.956       0.924          0.307 0.782   0.567
#> 5 5 0.821           0.885       0.885          0.148 0.984   0.945
#> 6 6 0.911           0.816       0.751          0.072 0.849   0.477

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette p1 p2
#> SRR1655002     1       0          1  1  0
#> SRR1655003     1       0          1  1  0
#> SRR1655004     1       0          1  1  0
#> SRR1655005     1       0          1  1  0
#> SRR1655006     1       0          1  1  0
#> SRR1655007     1       0          1  1  0
#> SRR1655008     1       0          1  1  0
#> SRR1655009     1       0          1  1  0
#> SRR1655010     1       0          1  1  0
#> SRR1655011     1       0          1  1  0
#> SRR1655012     2       0          1  0  1
#> SRR1655013     2       0          1  0  1
#> SRR1655014     2       0          1  0  1
#> SRR1655015     2       0          1  0  1
#> SRR1655016     2       0          1  0  1
#> SRR1655017     2       0          1  0  1
#> SRR1655018     2       0          1  0  1
#> SRR1655019     2       0          1  0  1
#> SRR1655020     2       0          1  0  1
#> SRR1655021     2       0          1  0  1
#> SRR1655022     2       0          1  0  1
#> SRR1655023     2       0          1  0  1
#> SRR1655024     2       0          1  0  1
#> SRR1655025     2       0          1  0  1
#> SRR1655026     2       0          1  0  1
#> SRR1655027     2       0          1  0  1
#> SRR1655028     2       0          1  0  1
#> SRR1655029     2       0          1  0  1
#> SRR1655030     2       0          1  0  1
#> SRR1655031     2       0          1  0  1
#> SRR1655032     2       0          1  0  1
#> SRR1655033     2       0          1  0  1
#> SRR1655034     2       0          1  0  1
#> SRR1655035     2       0          1  0  1
#> SRR1655036     2       0          1  0  1
#> SRR1655037     2       0          1  0  1
#> SRR1655038     2       0          1  0  1
#> SRR1655039     2       0          1  0  1
#> SRR1655040     2       0          1  0  1
#> SRR1655041     2       0          1  0  1
#> SRR1655042     2       0          1  0  1
#> SRR1655043     2       0          1  0  1
#> SRR1655044     2       0          1  0  1
#> SRR1655045     2       0          1  0  1
#> SRR1655046     2       0          1  0  1
#> SRR1655047     2       0          1  0  1
#> SRR1655048     2       0          1  0  1
#> SRR1655049     2       0          1  0  1
#> SRR1655050     2       0          1  0  1
#> SRR1655051     2       0          1  0  1
#> SRR1655052     2       0          1  0  1
#> SRR1655053     2       0          1  0  1
#> SRR1655054     2       0          1  0  1
#> SRR1655055     2       0          1  0  1
#> SRR1655056     2       0          1  0  1
#> SRR1655057     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
#> SRR1655002     1    0.00      1.000  1 0.000 0.000
#> SRR1655003     1    0.00      1.000  1 0.000 0.000
#> SRR1655004     1    0.00      1.000  1 0.000 0.000
#> SRR1655005     1    0.00      1.000  1 0.000 0.000
#> SRR1655006     1    0.00      1.000  1 0.000 0.000
#> SRR1655007     1    0.00      1.000  1 0.000 0.000
#> SRR1655008     1    0.00      1.000  1 0.000 0.000
#> SRR1655009     1    0.00      1.000  1 0.000 0.000
#> SRR1655010     1    0.00      1.000  1 0.000 0.000
#> SRR1655011     1    0.00      1.000  1 0.000 0.000
#> SRR1655012     2    0.00      0.989  0 1.000 0.000
#> SRR1655013     2    0.00      0.989  0 1.000 0.000
#> SRR1655014     2    0.00      0.989  0 1.000 0.000
#> SRR1655015     2    0.00      0.989  0 1.000 0.000
#> SRR1655016     2    0.00      0.989  0 1.000 0.000
#> SRR1655017     2    0.00      0.989  0 1.000 0.000
#> SRR1655018     2    0.46      0.751  0 0.796 0.204
#> SRR1655019     2    0.46      0.751  0 0.796 0.204
#> SRR1655020     2    0.00      0.989  0 1.000 0.000
#> SRR1655021     2    0.00      0.989  0 1.000 0.000
#> SRR1655022     2    0.00      0.989  0 1.000 0.000
#> SRR1655023     2    0.00      0.989  0 1.000 0.000
#> SRR1655024     2    0.00      0.989  0 1.000 0.000
#> SRR1655025     2    0.00      0.989  0 1.000 0.000
#> SRR1655026     2    0.00      0.989  0 1.000 0.000
#> SRR1655027     2    0.00      0.989  0 1.000 0.000
#> SRR1655028     2    0.00      0.989  0 1.000 0.000
#> SRR1655029     2    0.00      0.989  0 1.000 0.000
#> SRR1655030     2    0.00      0.989  0 1.000 0.000
#> SRR1655031     2    0.00      0.989  0 1.000 0.000
#> SRR1655032     2    0.00      0.989  0 1.000 0.000
#> SRR1655033     2    0.00      0.989  0 1.000 0.000
#> SRR1655034     3    0.00      1.000  0 0.000 1.000
#> SRR1655035     3    0.00      1.000  0 0.000 1.000
#> SRR1655036     3    0.00      1.000  0 0.000 1.000
#> SRR1655037     3    0.00      1.000  0 0.000 1.000
#> SRR1655038     3    0.00      1.000  0 0.000 1.000
#> SRR1655039     3    0.00      1.000  0 0.000 1.000
#> SRR1655040     3    0.00      1.000  0 0.000 1.000
#> SRR1655041     3    0.00      1.000  0 0.000 1.000
#> SRR1655042     2    0.00      0.989  0 1.000 0.000
#> SRR1655043     2    0.00      0.989  0 1.000 0.000
#> SRR1655044     2    0.00      0.989  0 1.000 0.000
#> SRR1655045     2    0.00      0.989  0 1.000 0.000
#> SRR1655046     2    0.00      0.989  0 1.000 0.000
#> SRR1655047     2    0.00      0.989  0 1.000 0.000
#> SRR1655048     2    0.00      0.989  0 1.000 0.000
#> SRR1655049     2    0.00      0.989  0 1.000 0.000
#> SRR1655050     2    0.00      0.989  0 1.000 0.000
#> SRR1655051     2    0.00      0.989  0 1.000 0.000
#> SRR1655052     2    0.00      0.989  0 1.000 0.000
#> SRR1655053     2    0.00      0.989  0 1.000 0.000
#> SRR1655054     2    0.00      0.989  0 1.000 0.000
#> SRR1655055     2    0.00      0.989  0 1.000 0.000
#> SRR1655056     2    0.00      0.989  0 1.000 0.000
#> SRR1655057     2    0.00      0.989  0 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
#> SRR1655002     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1655003     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1655004     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1655005     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1655006     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1655007     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1655008     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1655009     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1655010     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1655011     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1655012     2  0.4661      0.910  0 0.652  0 0.348
#> SRR1655013     2  0.4661      0.910  0 0.652  0 0.348
#> SRR1655014     2  0.4624      0.908  0 0.660  0 0.340
#> SRR1655015     2  0.4624      0.908  0 0.660  0 0.340
#> SRR1655016     2  0.4661      0.910  0 0.652  0 0.348
#> SRR1655017     2  0.4661      0.910  0 0.652  0 0.348
#> SRR1655018     2  0.0188      0.520  0 0.996  0 0.004
#> SRR1655019     2  0.0188      0.520  0 0.996  0 0.004
#> SRR1655020     2  0.4477      0.890  0 0.688  0 0.312
#> SRR1655021     2  0.4477      0.890  0 0.688  0 0.312
#> SRR1655022     2  0.4661      0.910  0 0.652  0 0.348
#> SRR1655023     2  0.4661      0.910  0 0.652  0 0.348
#> SRR1655024     2  0.4661      0.910  0 0.652  0 0.348
#> SRR1655025     2  0.4661      0.910  0 0.652  0 0.348
#> SRR1655026     4  0.0000      0.989  0 0.000  0 1.000
#> SRR1655027     4  0.0000      0.989  0 0.000  0 1.000
#> SRR1655028     4  0.0000      0.989  0 0.000  0 1.000
#> SRR1655029     4  0.0000      0.989  0 0.000  0 1.000
#> SRR1655030     4  0.1302      0.938  0 0.044  0 0.956
#> SRR1655031     4  0.1302      0.938  0 0.044  0 0.956
#> SRR1655032     4  0.0000      0.989  0 0.000  0 1.000
#> SRR1655033     4  0.0000      0.989  0 0.000  0 1.000
#> SRR1655034     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1655035     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1655036     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1655037     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1655038     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1655039     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1655040     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1655041     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1655042     4  0.0469      0.985  0 0.012  0 0.988
#> SRR1655043     4  0.0469      0.985  0 0.012  0 0.988
#> SRR1655044     4  0.0469      0.985  0 0.012  0 0.988
#> SRR1655045     4  0.0469      0.985  0 0.012  0 0.988
#> SRR1655046     4  0.0469      0.985  0 0.012  0 0.988
#> SRR1655047     4  0.0469      0.985  0 0.012  0 0.988
#> SRR1655048     4  0.0469      0.985  0 0.012  0 0.988
#> SRR1655049     4  0.0469      0.985  0 0.012  0 0.988
#> SRR1655050     4  0.0000      0.989  0 0.000  0 1.000
#> SRR1655051     4  0.0000      0.989  0 0.000  0 1.000
#> SRR1655052     4  0.0000      0.989  0 0.000  0 1.000
#> SRR1655053     4  0.0000      0.989  0 0.000  0 1.000
#> SRR1655054     4  0.0000      0.989  0 0.000  0 1.000
#> SRR1655055     4  0.0000      0.989  0 0.000  0 1.000
#> SRR1655056     4  0.0000      0.989  0 0.000  0 1.000
#> SRR1655057     4  0.0000      0.989  0 0.000  0 1.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette p1    p2    p3    p4    p5
#> SRR1655002     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1655003     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1655004     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1655005     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1655006     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1655007     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1655008     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1655009     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1655010     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1655011     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1655012     2  0.0000      0.998  0 1.000 0.000 0.000 0.000
#> SRR1655013     2  0.0000      0.998  0 1.000 0.000 0.000 0.000
#> SRR1655014     2  0.0000      0.998  0 1.000 0.000 0.000 0.000
#> SRR1655015     2  0.0000      0.998  0 1.000 0.000 0.000 0.000
#> SRR1655016     2  0.0000      0.998  0 1.000 0.000 0.000 0.000
#> SRR1655017     2  0.0000      0.998  0 1.000 0.000 0.000 0.000
#> SRR1655018     5  0.4350      1.000  0 0.408 0.004 0.000 0.588
#> SRR1655019     5  0.4350      1.000  0 0.408 0.004 0.000 0.588
#> SRR1655020     2  0.0162      0.990  0 0.996 0.000 0.004 0.000
#> SRR1655021     2  0.0162      0.990  0 0.996 0.000 0.004 0.000
#> SRR1655022     2  0.0000      0.998  0 1.000 0.000 0.000 0.000
#> SRR1655023     2  0.0000      0.998  0 1.000 0.000 0.000 0.000
#> SRR1655024     2  0.0000      0.998  0 1.000 0.000 0.000 0.000
#> SRR1655025     2  0.0000      0.998  0 1.000 0.000 0.000 0.000
#> SRR1655026     4  0.5010      0.789  0 0.076 0.000 0.676 0.248
#> SRR1655027     4  0.5010      0.789  0 0.076 0.000 0.676 0.248
#> SRR1655028     4  0.5010      0.789  0 0.076 0.000 0.676 0.248
#> SRR1655029     4  0.5010      0.789  0 0.076 0.000 0.676 0.248
#> SRR1655030     4  0.4924      0.783  0 0.060 0.000 0.668 0.272
#> SRR1655031     4  0.4924      0.783  0 0.060 0.000 0.668 0.272
#> SRR1655032     4  0.5010      0.789  0 0.076 0.000 0.676 0.248
#> SRR1655033     4  0.5010      0.789  0 0.076 0.000 0.676 0.248
#> SRR1655034     3  0.0000      1.000  0 0.000 1.000 0.000 0.000
#> SRR1655035     3  0.0000      1.000  0 0.000 1.000 0.000 0.000
#> SRR1655036     3  0.0000      1.000  0 0.000 1.000 0.000 0.000
#> SRR1655037     3  0.0000      1.000  0 0.000 1.000 0.000 0.000
#> SRR1655038     3  0.0000      1.000  0 0.000 1.000 0.000 0.000
#> SRR1655039     3  0.0000      1.000  0 0.000 1.000 0.000 0.000
#> SRR1655040     3  0.0000      1.000  0 0.000 1.000 0.000 0.000
#> SRR1655041     3  0.0000      1.000  0 0.000 1.000 0.000 0.000
#> SRR1655042     4  0.2020      0.681  0 0.100 0.000 0.900 0.000
#> SRR1655043     4  0.2020      0.681  0 0.100 0.000 0.900 0.000
#> SRR1655044     4  0.2020      0.681  0 0.100 0.000 0.900 0.000
#> SRR1655045     4  0.2020      0.681  0 0.100 0.000 0.900 0.000
#> SRR1655046     4  0.2020      0.681  0 0.100 0.000 0.900 0.000
#> SRR1655047     4  0.2020      0.681  0 0.100 0.000 0.900 0.000
#> SRR1655048     4  0.2074      0.680  0 0.104 0.000 0.896 0.000
#> SRR1655049     4  0.2074      0.680  0 0.104 0.000 0.896 0.000
#> SRR1655050     4  0.5036      0.735  0 0.036 0.000 0.560 0.404
#> SRR1655051     4  0.5036      0.735  0 0.036 0.000 0.560 0.404
#> SRR1655052     4  0.5036      0.735  0 0.036 0.000 0.560 0.404
#> SRR1655053     4  0.5036      0.735  0 0.036 0.000 0.560 0.404
#> SRR1655054     4  0.5036      0.735  0 0.036 0.000 0.560 0.404
#> SRR1655055     4  0.5036      0.735  0 0.036 0.000 0.560 0.404
#> SRR1655056     4  0.5036      0.735  0 0.036 0.000 0.560 0.404
#> SRR1655057     4  0.5036      0.735  0 0.036 0.000 0.560 0.404

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette p1    p2    p3    p4    p5    p6
#> SRR1655002     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1655003     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1655004     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1655005     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1655006     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1655007     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1655008     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1655009     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1655010     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1655011     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1655012     2  0.0000      0.988  0 1.000 0.000 0.000 0.000 0.000
#> SRR1655013     2  0.0000      0.988  0 1.000 0.000 0.000 0.000 0.000
#> SRR1655014     2  0.0000      0.988  0 1.000 0.000 0.000 0.000 0.000
#> SRR1655015     2  0.0000      0.988  0 1.000 0.000 0.000 0.000 0.000
#> SRR1655016     2  0.0000      0.988  0 1.000 0.000 0.000 0.000 0.000
#> SRR1655017     2  0.0000      0.988  0 1.000 0.000 0.000 0.000 0.000
#> SRR1655018     3  0.5481      0.192  0 0.072 0.488 0.420 0.000 0.020
#> SRR1655019     3  0.5481      0.192  0 0.072 0.488 0.420 0.000 0.020
#> SRR1655020     2  0.0547      0.988  0 0.980 0.000 0.000 0.000 0.020
#> SRR1655021     2  0.0547      0.988  0 0.980 0.000 0.000 0.000 0.020
#> SRR1655022     2  0.0547      0.988  0 0.980 0.000 0.000 0.000 0.020
#> SRR1655023     2  0.0547      0.988  0 0.980 0.000 0.000 0.000 0.020
#> SRR1655024     2  0.0547      0.988  0 0.980 0.000 0.000 0.000 0.020
#> SRR1655025     2  0.0547      0.988  0 0.980 0.000 0.000 0.000 0.020
#> SRR1655026     4  0.4593      0.991  0 0.044 0.000 0.576 0.000 0.380
#> SRR1655027     4  0.4593      0.991  0 0.044 0.000 0.576 0.000 0.380
#> SRR1655028     4  0.4593      0.991  0 0.044 0.000 0.576 0.000 0.380
#> SRR1655029     4  0.4593      0.991  0 0.044 0.000 0.576 0.000 0.380
#> SRR1655030     4  0.4400      0.972  0 0.032 0.000 0.592 0.000 0.376
#> SRR1655031     4  0.4400      0.972  0 0.032 0.000 0.592 0.000 0.376
#> SRR1655032     4  0.4593      0.991  0 0.044 0.000 0.576 0.000 0.380
#> SRR1655033     4  0.4593      0.991  0 0.044 0.000 0.576 0.000 0.380
#> SRR1655034     5  0.3995     -0.772  0 0.000 0.480 0.000 0.516 0.004
#> SRR1655035     5  0.3995     -0.772  0 0.000 0.480 0.000 0.516 0.004
#> SRR1655036     3  0.3867      0.734  0 0.000 0.512 0.000 0.488 0.000
#> SRR1655037     3  0.3867      0.734  0 0.000 0.512 0.000 0.488 0.000
#> SRR1655038     3  0.3867      0.734  0 0.000 0.512 0.000 0.488 0.000
#> SRR1655039     3  0.3867      0.734  0 0.000 0.512 0.000 0.488 0.000
#> SRR1655040     3  0.3867      0.734  0 0.000 0.512 0.000 0.488 0.000
#> SRR1655041     3  0.3867      0.734  0 0.000 0.512 0.000 0.488 0.000
#> SRR1655042     6  0.0632      1.000  0 0.024 0.000 0.000 0.000 0.976
#> SRR1655043     6  0.0632      1.000  0 0.024 0.000 0.000 0.000 0.976
#> SRR1655044     6  0.0632      1.000  0 0.024 0.000 0.000 0.000 0.976
#> SRR1655045     6  0.0632      1.000  0 0.024 0.000 0.000 0.000 0.976
#> SRR1655046     6  0.0632      1.000  0 0.024 0.000 0.000 0.000 0.976
#> SRR1655047     6  0.0632      1.000  0 0.024 0.000 0.000 0.000 0.976
#> SRR1655048     6  0.0632      1.000  0 0.024 0.000 0.000 0.000 0.976
#> SRR1655049     6  0.0632      1.000  0 0.024 0.000 0.000 0.000 0.976
#> SRR1655050     5  0.5080      0.591  0 0.008 0.000 0.452 0.484 0.056
#> SRR1655051     5  0.5080      0.591  0 0.008 0.000 0.452 0.484 0.056
#> SRR1655052     5  0.5080      0.591  0 0.008 0.000 0.452 0.484 0.056
#> SRR1655053     5  0.5080      0.591  0 0.008 0.000 0.452 0.484 0.056
#> SRR1655054     5  0.5080      0.591  0 0.008 0.000 0.452 0.484 0.056
#> SRR1655055     5  0.5080      0.591  0 0.008 0.000 0.452 0.484 0.056
#> SRR1655056     5  0.5080      0.591  0 0.008 0.000 0.452 0.484 0.056
#> SRR1655057     5  0.5080      0.591  0 0.008 0.000 0.452 0.484 0.056

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

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

collect_plots(res)

plot of chunk ATC-pam-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.2994 0.701   0.701
#> 3 3 1.000           0.975       0.984         0.8099 0.766   0.667
#> 4 4 0.997           0.952       0.979         0.3470 0.800   0.572
#> 5 5 0.989           0.945       0.973         0.0993 0.927   0.728
#> 6 6 1.000           0.963       0.985         0.0496 0.945   0.731

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette p1 p2
#> SRR1655002     1       0          1  1  0
#> SRR1655003     1       0          1  1  0
#> SRR1655004     1       0          1  1  0
#> SRR1655005     1       0          1  1  0
#> SRR1655006     1       0          1  1  0
#> SRR1655007     1       0          1  1  0
#> SRR1655008     1       0          1  1  0
#> SRR1655009     1       0          1  1  0
#> SRR1655010     1       0          1  1  0
#> SRR1655011     1       0          1  1  0
#> SRR1655012     2       0          1  0  1
#> SRR1655013     2       0          1  0  1
#> SRR1655014     2       0          1  0  1
#> SRR1655015     2       0          1  0  1
#> SRR1655016     2       0          1  0  1
#> SRR1655017     2       0          1  0  1
#> SRR1655018     2       0          1  0  1
#> SRR1655019     2       0          1  0  1
#> SRR1655020     2       0          1  0  1
#> SRR1655021     2       0          1  0  1
#> SRR1655022     2       0          1  0  1
#> SRR1655023     2       0          1  0  1
#> SRR1655024     2       0          1  0  1
#> SRR1655025     2       0          1  0  1
#> SRR1655026     2       0          1  0  1
#> SRR1655027     2       0          1  0  1
#> SRR1655028     2       0          1  0  1
#> SRR1655029     2       0          1  0  1
#> SRR1655030     2       0          1  0  1
#> SRR1655031     2       0          1  0  1
#> SRR1655032     2       0          1  0  1
#> SRR1655033     2       0          1  0  1
#> SRR1655034     2       0          1  0  1
#> SRR1655035     2       0          1  0  1
#> SRR1655036     2       0          1  0  1
#> SRR1655037     2       0          1  0  1
#> SRR1655038     2       0          1  0  1
#> SRR1655039     2       0          1  0  1
#> SRR1655040     2       0          1  0  1
#> SRR1655041     2       0          1  0  1
#> SRR1655042     2       0          1  0  1
#> SRR1655043     2       0          1  0  1
#> SRR1655044     2       0          1  0  1
#> SRR1655045     2       0          1  0  1
#> SRR1655046     2       0          1  0  1
#> SRR1655047     2       0          1  0  1
#> SRR1655048     2       0          1  0  1
#> SRR1655049     2       0          1  0  1
#> SRR1655050     2       0          1  0  1
#> SRR1655051     2       0          1  0  1
#> SRR1655052     2       0          1  0  1
#> SRR1655053     2       0          1  0  1
#> SRR1655054     2       0          1  0  1
#> SRR1655055     2       0          1  0  1
#> SRR1655056     2       0          1  0  1
#> SRR1655057     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
#> SRR1655002     1  0.0000      1.000  1 0.000 0.000
#> SRR1655003     1  0.0000      1.000  1 0.000 0.000
#> SRR1655004     1  0.0000      1.000  1 0.000 0.000
#> SRR1655005     1  0.0000      1.000  1 0.000 0.000
#> SRR1655006     1  0.0000      1.000  1 0.000 0.000
#> SRR1655007     1  0.0000      1.000  1 0.000 0.000
#> SRR1655008     1  0.0000      1.000  1 0.000 0.000
#> SRR1655009     1  0.0000      1.000  1 0.000 0.000
#> SRR1655010     1  0.0000      1.000  1 0.000 0.000
#> SRR1655011     1  0.0000      1.000  1 0.000 0.000
#> SRR1655012     2  0.0892      0.976  0 0.980 0.020
#> SRR1655013     2  0.0892      0.976  0 0.980 0.020
#> SRR1655014     2  0.1411      0.965  0 0.964 0.036
#> SRR1655015     2  0.2959      0.905  0 0.900 0.100
#> SRR1655016     2  0.0892      0.976  0 0.980 0.020
#> SRR1655017     2  0.0892      0.976  0 0.980 0.020
#> SRR1655018     3  0.0000      1.000  0 0.000 1.000
#> SRR1655019     3  0.0000      1.000  0 0.000 1.000
#> SRR1655020     2  0.4796      0.754  0 0.780 0.220
#> SRR1655021     2  0.4796      0.754  0 0.780 0.220
#> SRR1655022     2  0.0892      0.976  0 0.980 0.020
#> SRR1655023     2  0.0892      0.976  0 0.980 0.020
#> SRR1655024     2  0.0892      0.976  0 0.980 0.020
#> SRR1655025     2  0.0892      0.976  0 0.980 0.020
#> SRR1655026     2  0.0000      0.975  0 1.000 0.000
#> SRR1655027     2  0.0000      0.975  0 1.000 0.000
#> SRR1655028     2  0.0000      0.975  0 1.000 0.000
#> SRR1655029     2  0.0000      0.975  0 1.000 0.000
#> SRR1655030     2  0.0892      0.976  0 0.980 0.020
#> SRR1655031     2  0.0892      0.976  0 0.980 0.020
#> SRR1655032     2  0.0000      0.975  0 1.000 0.000
#> SRR1655033     2  0.0000      0.975  0 1.000 0.000
#> SRR1655034     3  0.0000      1.000  0 0.000 1.000
#> SRR1655035     3  0.0000      1.000  0 0.000 1.000
#> SRR1655036     3  0.0000      1.000  0 0.000 1.000
#> SRR1655037     3  0.0000      1.000  0 0.000 1.000
#> SRR1655038     3  0.0000      1.000  0 0.000 1.000
#> SRR1655039     3  0.0000      1.000  0 0.000 1.000
#> SRR1655040     3  0.0000      1.000  0 0.000 1.000
#> SRR1655041     3  0.0000      1.000  0 0.000 1.000
#> SRR1655042     2  0.0892      0.976  0 0.980 0.020
#> SRR1655043     2  0.0892      0.976  0 0.980 0.020
#> SRR1655044     2  0.0000      0.975  0 1.000 0.000
#> SRR1655045     2  0.0000      0.975  0 1.000 0.000
#> SRR1655046     2  0.0892      0.976  0 0.980 0.020
#> SRR1655047     2  0.0892      0.976  0 0.980 0.020
#> SRR1655048     2  0.0892      0.976  0 0.980 0.020
#> SRR1655049     2  0.0892      0.976  0 0.980 0.020
#> SRR1655050     2  0.0000      0.975  0 1.000 0.000
#> SRR1655051     2  0.0000      0.975  0 1.000 0.000
#> SRR1655052     2  0.0000      0.975  0 1.000 0.000
#> SRR1655053     2  0.0000      0.975  0 1.000 0.000
#> SRR1655054     2  0.0000      0.975  0 1.000 0.000
#> SRR1655055     2  0.0000      0.975  0 1.000 0.000
#> SRR1655056     2  0.0000      0.975  0 1.000 0.000
#> SRR1655057     2  0.0000      0.975  0 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
#> SRR1655002     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1655003     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1655004     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1655005     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1655006     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1655007     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1655008     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1655009     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1655010     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1655011     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1655012     2  0.0336      0.995  0 0.992 0.000 0.008
#> SRR1655013     2  0.0336      0.995  0 0.992 0.000 0.008
#> SRR1655014     2  0.0000      0.993  0 1.000 0.000 0.000
#> SRR1655015     2  0.0000      0.993  0 1.000 0.000 0.000
#> SRR1655016     2  0.0336      0.995  0 0.992 0.000 0.008
#> SRR1655017     2  0.0336      0.995  0 0.992 0.000 0.008
#> SRR1655018     3  0.4898      0.364  0 0.416 0.584 0.000
#> SRR1655019     3  0.4898      0.364  0 0.416 0.584 0.000
#> SRR1655020     2  0.0000      0.993  0 1.000 0.000 0.000
#> SRR1655021     2  0.0000      0.993  0 1.000 0.000 0.000
#> SRR1655022     2  0.0336      0.995  0 0.992 0.000 0.008
#> SRR1655023     2  0.0336      0.995  0 0.992 0.000 0.008
#> SRR1655024     2  0.0336      0.995  0 0.992 0.000 0.008
#> SRR1655025     2  0.0336      0.995  0 0.992 0.000 0.008
#> SRR1655026     4  0.0000      0.985  0 0.000 0.000 1.000
#> SRR1655027     4  0.0000      0.985  0 0.000 0.000 1.000
#> SRR1655028     4  0.0000      0.985  0 0.000 0.000 1.000
#> SRR1655029     4  0.0000      0.985  0 0.000 0.000 1.000
#> SRR1655030     4  0.0592      0.979  0 0.016 0.000 0.984
#> SRR1655031     4  0.0592      0.979  0 0.016 0.000 0.984
#> SRR1655032     4  0.0000      0.985  0 0.000 0.000 1.000
#> SRR1655033     4  0.0000      0.985  0 0.000 0.000 1.000
#> SRR1655034     3  0.0000      0.895  0 0.000 1.000 0.000
#> SRR1655035     3  0.0000      0.895  0 0.000 1.000 0.000
#> SRR1655036     3  0.0000      0.895  0 0.000 1.000 0.000
#> SRR1655037     3  0.0000      0.895  0 0.000 1.000 0.000
#> SRR1655038     3  0.0000      0.895  0 0.000 1.000 0.000
#> SRR1655039     3  0.0000      0.895  0 0.000 1.000 0.000
#> SRR1655040     3  0.0000      0.895  0 0.000 1.000 0.000
#> SRR1655041     3  0.0000      0.895  0 0.000 1.000 0.000
#> SRR1655042     4  0.1792      0.938  0 0.068 0.000 0.932
#> SRR1655043     4  0.1716      0.942  0 0.064 0.000 0.936
#> SRR1655044     4  0.0336      0.982  0 0.008 0.000 0.992
#> SRR1655045     4  0.0336      0.982  0 0.008 0.000 0.992
#> SRR1655046     4  0.0817      0.976  0 0.024 0.000 0.976
#> SRR1655047     4  0.0817      0.976  0 0.024 0.000 0.976
#> SRR1655048     2  0.0000      0.993  0 1.000 0.000 0.000
#> SRR1655049     2  0.0000      0.993  0 1.000 0.000 0.000
#> SRR1655050     4  0.0000      0.985  0 0.000 0.000 1.000
#> SRR1655051     4  0.0000      0.985  0 0.000 0.000 1.000
#> SRR1655052     4  0.0000      0.985  0 0.000 0.000 1.000
#> SRR1655053     4  0.0000      0.985  0 0.000 0.000 1.000
#> SRR1655054     4  0.0000      0.985  0 0.000 0.000 1.000
#> SRR1655055     4  0.0000      0.985  0 0.000 0.000 1.000
#> SRR1655056     4  0.1211      0.958  0 0.040 0.000 0.960
#> SRR1655057     4  0.1118      0.962  0 0.036 0.000 0.964

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette p1    p2  p3    p4    p5
#> SRR1655002     1   0.000      1.000  1 0.000 0.0 0.000 0.000
#> SRR1655003     1   0.000      1.000  1 0.000 0.0 0.000 0.000
#> SRR1655004     1   0.000      1.000  1 0.000 0.0 0.000 0.000
#> SRR1655005     1   0.000      1.000  1 0.000 0.0 0.000 0.000
#> SRR1655006     1   0.000      1.000  1 0.000 0.0 0.000 0.000
#> SRR1655007     1   0.000      1.000  1 0.000 0.0 0.000 0.000
#> SRR1655008     1   0.000      1.000  1 0.000 0.0 0.000 0.000
#> SRR1655009     1   0.000      1.000  1 0.000 0.0 0.000 0.000
#> SRR1655010     1   0.000      1.000  1 0.000 0.0 0.000 0.000
#> SRR1655011     1   0.000      1.000  1 0.000 0.0 0.000 0.000
#> SRR1655012     2   0.000      0.986  0 1.000 0.0 0.000 0.000
#> SRR1655013     2   0.000      0.986  0 1.000 0.0 0.000 0.000
#> SRR1655014     2   0.029      0.983  0 0.992 0.0 0.008 0.000
#> SRR1655015     2   0.029      0.983  0 0.992 0.0 0.008 0.000
#> SRR1655016     2   0.000      0.986  0 1.000 0.0 0.000 0.000
#> SRR1655017     2   0.000      0.986  0 1.000 0.0 0.000 0.000
#> SRR1655018     3   0.418      0.396  0 0.400 0.6 0.000 0.000
#> SRR1655019     3   0.418      0.396  0 0.400 0.6 0.000 0.000
#> SRR1655020     2   0.029      0.983  0 0.992 0.0 0.008 0.000
#> SRR1655021     2   0.029      0.983  0 0.992 0.0 0.008 0.000
#> SRR1655022     2   0.000      0.986  0 1.000 0.0 0.000 0.000
#> SRR1655023     2   0.000      0.986  0 1.000 0.0 0.000 0.000
#> SRR1655024     2   0.000      0.986  0 1.000 0.0 0.000 0.000
#> SRR1655025     2   0.000      0.986  0 1.000 0.0 0.000 0.000
#> SRR1655026     4   0.156      0.953  0 0.008 0.0 0.940 0.052
#> SRR1655027     4   0.176      0.950  0 0.008 0.0 0.928 0.064
#> SRR1655028     4   0.176      0.950  0 0.008 0.0 0.928 0.064
#> SRR1655029     4   0.176      0.950  0 0.008 0.0 0.928 0.064
#> SRR1655030     4   0.029      0.958  0 0.008 0.0 0.992 0.000
#> SRR1655031     4   0.029      0.958  0 0.008 0.0 0.992 0.000
#> SRR1655032     4   0.176      0.950  0 0.008 0.0 0.928 0.064
#> SRR1655033     4   0.176      0.950  0 0.008 0.0 0.928 0.064
#> SRR1655034     3   0.000      0.894  0 0.000 1.0 0.000 0.000
#> SRR1655035     3   0.000      0.894  0 0.000 1.0 0.000 0.000
#> SRR1655036     3   0.000      0.894  0 0.000 1.0 0.000 0.000
#> SRR1655037     3   0.000      0.894  0 0.000 1.0 0.000 0.000
#> SRR1655038     3   0.000      0.894  0 0.000 1.0 0.000 0.000
#> SRR1655039     3   0.000      0.894  0 0.000 1.0 0.000 0.000
#> SRR1655040     3   0.000      0.894  0 0.000 1.0 0.000 0.000
#> SRR1655041     3   0.000      0.894  0 0.000 1.0 0.000 0.000
#> SRR1655042     4   0.112      0.930  0 0.044 0.0 0.956 0.000
#> SRR1655043     4   0.104      0.933  0 0.040 0.0 0.960 0.000
#> SRR1655044     4   0.000      0.958  0 0.000 0.0 1.000 0.000
#> SRR1655045     4   0.000      0.958  0 0.000 0.0 1.000 0.000
#> SRR1655046     4   0.000      0.958  0 0.000 0.0 1.000 0.000
#> SRR1655047     4   0.000      0.958  0 0.000 0.0 1.000 0.000
#> SRR1655048     2   0.161      0.931  0 0.928 0.0 0.072 0.000
#> SRR1655049     2   0.161      0.931  0 0.928 0.0 0.072 0.000
#> SRR1655050     5   0.000      1.000  0 0.000 0.0 0.000 1.000
#> SRR1655051     5   0.000      1.000  0 0.000 0.0 0.000 1.000
#> SRR1655052     5   0.000      1.000  0 0.000 0.0 0.000 1.000
#> SRR1655053     5   0.000      1.000  0 0.000 0.0 0.000 1.000
#> SRR1655054     5   0.000      1.000  0 0.000 0.0 0.000 1.000
#> SRR1655055     5   0.000      1.000  0 0.000 0.0 0.000 1.000
#> SRR1655056     5   0.000      1.000  0 0.000 0.0 0.000 1.000
#> SRR1655057     5   0.000      1.000  0 0.000 0.0 0.000 1.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
#> SRR1655002     1  0.0000      1.000  1 0.0 0.0 0.000  0 0.000
#> SRR1655003     1  0.0000      1.000  1 0.0 0.0 0.000  0 0.000
#> SRR1655004     1  0.0000      1.000  1 0.0 0.0 0.000  0 0.000
#> SRR1655005     1  0.0000      1.000  1 0.0 0.0 0.000  0 0.000
#> SRR1655006     1  0.0000      1.000  1 0.0 0.0 0.000  0 0.000
#> SRR1655007     1  0.0000      1.000  1 0.0 0.0 0.000  0 0.000
#> SRR1655008     1  0.0000      1.000  1 0.0 0.0 0.000  0 0.000
#> SRR1655009     1  0.0000      1.000  1 0.0 0.0 0.000  0 0.000
#> SRR1655010     1  0.0000      1.000  1 0.0 0.0 0.000  0 0.000
#> SRR1655011     1  0.0000      1.000  1 0.0 0.0 0.000  0 0.000
#> SRR1655012     2  0.0000      1.000  0 1.0 0.0 0.000  0 0.000
#> SRR1655013     2  0.0000      1.000  0 1.0 0.0 0.000  0 0.000
#> SRR1655014     2  0.0000      1.000  0 1.0 0.0 0.000  0 0.000
#> SRR1655015     2  0.0000      1.000  0 1.0 0.0 0.000  0 0.000
#> SRR1655016     2  0.0000      1.000  0 1.0 0.0 0.000  0 0.000
#> SRR1655017     2  0.0000      1.000  0 1.0 0.0 0.000  0 0.000
#> SRR1655018     3  0.3756      0.407  0 0.4 0.6 0.000  0 0.000
#> SRR1655019     3  0.3756      0.407  0 0.4 0.6 0.000  0 0.000
#> SRR1655020     2  0.0000      1.000  0 1.0 0.0 0.000  0 0.000
#> SRR1655021     2  0.0000      1.000  0 1.0 0.0 0.000  0 0.000
#> SRR1655022     2  0.0000      1.000  0 1.0 0.0 0.000  0 0.000
#> SRR1655023     2  0.0000      1.000  0 1.0 0.0 0.000  0 0.000
#> SRR1655024     2  0.0000      1.000  0 1.0 0.0 0.000  0 0.000
#> SRR1655025     2  0.0000      1.000  0 1.0 0.0 0.000  0 0.000
#> SRR1655026     4  0.0000      0.996  0 0.0 0.0 1.000  0 0.000
#> SRR1655027     4  0.0000      0.996  0 0.0 0.0 1.000  0 0.000
#> SRR1655028     4  0.0000      0.996  0 0.0 0.0 1.000  0 0.000
#> SRR1655029     4  0.0000      0.996  0 0.0 0.0 1.000  0 0.000
#> SRR1655030     4  0.0363      0.989  0 0.0 0.0 0.988  0 0.012
#> SRR1655031     4  0.0458      0.986  0 0.0 0.0 0.984  0 0.016
#> SRR1655032     4  0.0000      0.996  0 0.0 0.0 1.000  0 0.000
#> SRR1655033     4  0.0000      0.996  0 0.0 0.0 1.000  0 0.000
#> SRR1655034     3  0.0000      0.898  0 0.0 1.0 0.000  0 0.000
#> SRR1655035     3  0.0000      0.898  0 0.0 1.0 0.000  0 0.000
#> SRR1655036     3  0.0000      0.898  0 0.0 1.0 0.000  0 0.000
#> SRR1655037     3  0.0000      0.898  0 0.0 1.0 0.000  0 0.000
#> SRR1655038     3  0.0000      0.898  0 0.0 1.0 0.000  0 0.000
#> SRR1655039     3  0.0000      0.898  0 0.0 1.0 0.000  0 0.000
#> SRR1655040     3  0.0000      0.898  0 0.0 1.0 0.000  0 0.000
#> SRR1655041     3  0.0000      0.898  0 0.0 1.0 0.000  0 0.000
#> SRR1655042     6  0.0000      1.000  0 0.0 0.0 0.000  0 1.000
#> SRR1655043     6  0.0000      1.000  0 0.0 0.0 0.000  0 1.000
#> SRR1655044     6  0.0000      1.000  0 0.0 0.0 0.000  0 1.000
#> SRR1655045     6  0.0000      1.000  0 0.0 0.0 0.000  0 1.000
#> SRR1655046     6  0.0000      1.000  0 0.0 0.0 0.000  0 1.000
#> SRR1655047     6  0.0000      1.000  0 0.0 0.0 0.000  0 1.000
#> SRR1655048     6  0.0000      1.000  0 0.0 0.0 0.000  0 1.000
#> SRR1655049     6  0.0000      1.000  0 0.0 0.0 0.000  0 1.000
#> SRR1655050     5  0.0000      1.000  0 0.0 0.0 0.000  1 0.000
#> SRR1655051     5  0.0000      1.000  0 0.0 0.0 0.000  1 0.000
#> SRR1655052     5  0.0000      1.000  0 0.0 0.0 0.000  1 0.000
#> SRR1655053     5  0.0000      1.000  0 0.0 0.0 0.000  1 0.000
#> SRR1655054     5  0.0000      1.000  0 0.0 0.0 0.000  1 0.000
#> SRR1655055     5  0.0000      1.000  0 0.0 0.0 0.000  1 0.000
#> SRR1655056     5  0.0000      1.000  0 0.0 0.0 0.000  1 0.000
#> SRR1655057     5  0.0000      1.000  0 0.0 0.0 0.000  1 0.000

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

consensus_heatmap(res, k = 2)

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

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

collect_plots(res)

plot of chunk ATC-mclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.996       0.997         0.3020 0.701   0.701
#> 3 3 1.000           0.984       0.984         0.6748 0.803   0.719
#> 4 4 0.677           0.580       0.788         0.3632 0.797   0.598
#> 5 5 0.748           0.875       0.872         0.1381 0.849   0.540
#> 6 6 0.872           0.869       0.898         0.0638 0.958   0.795

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette    p1    p2
#> SRR1655002     1  0.0000      1.000 1.000 0.000
#> SRR1655003     1  0.0000      1.000 1.000 0.000
#> SRR1655004     1  0.0000      1.000 1.000 0.000
#> SRR1655005     1  0.0000      1.000 1.000 0.000
#> SRR1655006     1  0.0000      1.000 1.000 0.000
#> SRR1655007     1  0.0000      1.000 1.000 0.000
#> SRR1655008     1  0.0000      1.000 1.000 0.000
#> SRR1655009     1  0.0000      1.000 1.000 0.000
#> SRR1655010     1  0.0000      1.000 1.000 0.000
#> SRR1655011     1  0.0000      1.000 1.000 0.000
#> SRR1655012     2  0.0000      0.997 0.000 1.000
#> SRR1655013     2  0.0000      0.997 0.000 1.000
#> SRR1655014     2  0.0000      0.997 0.000 1.000
#> SRR1655015     2  0.0000      0.997 0.000 1.000
#> SRR1655016     2  0.0000      0.997 0.000 1.000
#> SRR1655017     2  0.0000      0.997 0.000 1.000
#> SRR1655018     2  0.0000      0.997 0.000 1.000
#> SRR1655019     2  0.0000      0.997 0.000 1.000
#> SRR1655020     2  0.0000      0.997 0.000 1.000
#> SRR1655021     2  0.0000      0.997 0.000 1.000
#> SRR1655022     2  0.0000      0.997 0.000 1.000
#> SRR1655023     2  0.0000      0.997 0.000 1.000
#> SRR1655024     2  0.0000      0.997 0.000 1.000
#> SRR1655025     2  0.0000      0.997 0.000 1.000
#> SRR1655026     2  0.0000      0.997 0.000 1.000
#> SRR1655027     2  0.0000      0.997 0.000 1.000
#> SRR1655028     2  0.0000      0.997 0.000 1.000
#> SRR1655029     2  0.0000      0.997 0.000 1.000
#> SRR1655030     2  0.0000      0.997 0.000 1.000
#> SRR1655031     2  0.0000      0.997 0.000 1.000
#> SRR1655032     2  0.0000      0.997 0.000 1.000
#> SRR1655033     2  0.0000      0.997 0.000 1.000
#> SRR1655034     2  0.0672      0.993 0.008 0.992
#> SRR1655035     2  0.0672      0.993 0.008 0.992
#> SRR1655036     2  0.0672      0.993 0.008 0.992
#> SRR1655037     2  0.0672      0.993 0.008 0.992
#> SRR1655038     2  0.0672      0.993 0.008 0.992
#> SRR1655039     2  0.0672      0.993 0.008 0.992
#> SRR1655040     2  0.0672      0.993 0.008 0.992
#> SRR1655041     2  0.0672      0.993 0.008 0.992
#> SRR1655042     2  0.0000      0.997 0.000 1.000
#> SRR1655043     2  0.0000      0.997 0.000 1.000
#> SRR1655044     2  0.0000      0.997 0.000 1.000
#> SRR1655045     2  0.0000      0.997 0.000 1.000
#> SRR1655046     2  0.0000      0.997 0.000 1.000
#> SRR1655047     2  0.0000      0.997 0.000 1.000
#> SRR1655048     2  0.0000      0.997 0.000 1.000
#> SRR1655049     2  0.0000      0.997 0.000 1.000
#> SRR1655050     2  0.0938      0.990 0.012 0.988
#> SRR1655051     2  0.0672      0.992 0.008 0.992
#> SRR1655052     2  0.0938      0.990 0.012 0.988
#> SRR1655053     2  0.0938      0.990 0.012 0.988
#> SRR1655054     2  0.0938      0.990 0.012 0.988
#> SRR1655055     2  0.0938      0.990 0.012 0.988
#> SRR1655056     2  0.0938      0.990 0.012 0.988
#> SRR1655057     2  0.0938      0.990 0.012 0.988

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1655002     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1655003     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1655004     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1655005     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1655006     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1655007     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1655008     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1655009     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1655010     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1655011     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1655012     2  0.0424      0.982 0.000 0.992 0.008
#> SRR1655013     2  0.0424      0.982 0.000 0.992 0.008
#> SRR1655014     2  0.0424      0.982 0.000 0.992 0.008
#> SRR1655015     2  0.0424      0.982 0.000 0.992 0.008
#> SRR1655016     2  0.0424      0.982 0.000 0.992 0.008
#> SRR1655017     2  0.0424      0.982 0.000 0.992 0.008
#> SRR1655018     2  0.0424      0.982 0.000 0.992 0.008
#> SRR1655019     2  0.0424      0.982 0.000 0.992 0.008
#> SRR1655020     2  0.0424      0.982 0.000 0.992 0.008
#> SRR1655021     2  0.0424      0.982 0.000 0.992 0.008
#> SRR1655022     2  0.0424      0.982 0.000 0.992 0.008
#> SRR1655023     2  0.0424      0.982 0.000 0.992 0.008
#> SRR1655024     2  0.0592      0.980 0.000 0.988 0.012
#> SRR1655025     2  0.0424      0.982 0.000 0.992 0.008
#> SRR1655026     2  0.0892      0.977 0.000 0.980 0.020
#> SRR1655027     2  0.0747      0.979 0.000 0.984 0.016
#> SRR1655028     2  0.1031      0.976 0.000 0.976 0.024
#> SRR1655029     2  0.0892      0.977 0.000 0.980 0.020
#> SRR1655030     2  0.0000      0.982 0.000 1.000 0.000
#> SRR1655031     2  0.0000      0.982 0.000 1.000 0.000
#> SRR1655032     2  0.1031      0.976 0.000 0.976 0.024
#> SRR1655033     2  0.1031      0.976 0.000 0.976 0.024
#> SRR1655034     3  0.1031      1.000 0.024 0.000 0.976
#> SRR1655035     3  0.1031      1.000 0.024 0.000 0.976
#> SRR1655036     3  0.1031      1.000 0.024 0.000 0.976
#> SRR1655037     3  0.1031      1.000 0.024 0.000 0.976
#> SRR1655038     3  0.1031      1.000 0.024 0.000 0.976
#> SRR1655039     3  0.1031      1.000 0.024 0.000 0.976
#> SRR1655040     3  0.1031      1.000 0.024 0.000 0.976
#> SRR1655041     3  0.1031      1.000 0.024 0.000 0.976
#> SRR1655042     2  0.0000      0.982 0.000 1.000 0.000
#> SRR1655043     2  0.0000      0.982 0.000 1.000 0.000
#> SRR1655044     2  0.0000      0.982 0.000 1.000 0.000
#> SRR1655045     2  0.0000      0.982 0.000 1.000 0.000
#> SRR1655046     2  0.0000      0.982 0.000 1.000 0.000
#> SRR1655047     2  0.0000      0.982 0.000 1.000 0.000
#> SRR1655048     2  0.0237      0.982 0.000 0.996 0.004
#> SRR1655049     2  0.0237      0.982 0.000 0.996 0.004
#> SRR1655050     2  0.2066      0.957 0.000 0.940 0.060
#> SRR1655051     2  0.2066      0.957 0.000 0.940 0.060
#> SRR1655052     2  0.2066      0.957 0.000 0.940 0.060
#> SRR1655053     2  0.2066      0.957 0.000 0.940 0.060
#> SRR1655054     2  0.2066      0.957 0.000 0.940 0.060
#> SRR1655055     2  0.2066      0.957 0.000 0.940 0.060
#> SRR1655056     2  0.2066      0.957 0.000 0.940 0.060
#> SRR1655057     2  0.2066      0.957 0.000 0.940 0.060

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette p1    p2 p3    p4
#> SRR1655002     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1655003     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1655004     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1655005     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1655006     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1655007     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1655008     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1655009     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1655010     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1655011     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1655012     2  0.4817      0.483  0 0.612  0 0.388
#> SRR1655013     2  0.4817      0.483  0 0.612  0 0.388
#> SRR1655014     2  0.4999      0.398  0 0.508  0 0.492
#> SRR1655015     2  0.4999      0.398  0 0.508  0 0.492
#> SRR1655016     2  0.4817      0.483  0 0.612  0 0.388
#> SRR1655017     2  0.4817      0.483  0 0.612  0 0.388
#> SRR1655018     2  0.4999      0.398  0 0.508  0 0.492
#> SRR1655019     2  0.4999      0.398  0 0.508  0 0.492
#> SRR1655020     2  0.4999      0.398  0 0.508  0 0.492
#> SRR1655021     2  0.4999      0.398  0 0.508  0 0.492
#> SRR1655022     4  0.4999     -0.455  0 0.492  0 0.508
#> SRR1655023     4  0.5000     -0.458  0 0.496  0 0.504
#> SRR1655024     4  0.4999     -0.455  0 0.492  0 0.508
#> SRR1655025     4  0.4999     -0.455  0 0.492  0 0.508
#> SRR1655026     2  0.2408      0.418  0 0.896  0 0.104
#> SRR1655027     2  0.2408      0.418  0 0.896  0 0.104
#> SRR1655028     2  0.2530      0.401  0 0.888  0 0.112
#> SRR1655029     2  0.2408      0.409  0 0.896  0 0.104
#> SRR1655030     2  0.0000      0.535  0 1.000  0 0.000
#> SRR1655031     2  0.0000      0.535  0 1.000  0 0.000
#> SRR1655032     2  0.2408      0.408  0 0.896  0 0.104
#> SRR1655033     2  0.2408      0.408  0 0.896  0 0.104
#> SRR1655034     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1655035     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1655036     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1655037     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1655038     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1655039     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1655040     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1655041     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1655042     2  0.1211      0.543  0 0.960  0 0.040
#> SRR1655043     2  0.1211      0.543  0 0.960  0 0.040
#> SRR1655044     2  0.0188      0.532  0 0.996  0 0.004
#> SRR1655045     2  0.0188      0.532  0 0.996  0 0.004
#> SRR1655046     2  0.0000      0.535  0 1.000  0 0.000
#> SRR1655047     2  0.0000      0.535  0 1.000  0 0.000
#> SRR1655048     2  0.4277      0.518  0 0.720  0 0.280
#> SRR1655049     2  0.4277      0.518  0 0.720  0 0.280
#> SRR1655050     4  0.4999      0.525  0 0.492  0 0.508
#> SRR1655051     4  0.4999      0.525  0 0.492  0 0.508
#> SRR1655052     4  0.4999      0.525  0 0.492  0 0.508
#> SRR1655053     4  0.4999      0.525  0 0.492  0 0.508
#> SRR1655054     4  0.4999      0.525  0 0.492  0 0.508
#> SRR1655055     4  0.4999      0.525  0 0.492  0 0.508
#> SRR1655056     4  0.4999      0.525  0 0.492  0 0.508
#> SRR1655057     4  0.4999      0.525  0 0.492  0 0.508

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette p1    p2 p3    p4    p5
#> SRR1655002     1  0.0000      1.000  1 0.000  0 0.000 0.000
#> SRR1655003     1  0.0000      1.000  1 0.000  0 0.000 0.000
#> SRR1655004     1  0.0000      1.000  1 0.000  0 0.000 0.000
#> SRR1655005     1  0.0000      1.000  1 0.000  0 0.000 0.000
#> SRR1655006     1  0.0000      1.000  1 0.000  0 0.000 0.000
#> SRR1655007     1  0.0000      1.000  1 0.000  0 0.000 0.000
#> SRR1655008     1  0.0000      1.000  1 0.000  0 0.000 0.000
#> SRR1655009     1  0.0000      1.000  1 0.000  0 0.000 0.000
#> SRR1655010     1  0.0000      1.000  1 0.000  0 0.000 0.000
#> SRR1655011     1  0.0000      1.000  1 0.000  0 0.000 0.000
#> SRR1655012     2  0.3534      0.833  0 0.744  0 0.256 0.000
#> SRR1655013     2  0.3561      0.833  0 0.740  0 0.260 0.000
#> SRR1655014     2  0.2732      0.822  0 0.840  0 0.160 0.000
#> SRR1655015     2  0.2732      0.822  0 0.840  0 0.160 0.000
#> SRR1655016     2  0.3534      0.833  0 0.744  0 0.256 0.000
#> SRR1655017     2  0.3561      0.833  0 0.740  0 0.260 0.000
#> SRR1655018     2  0.0794      0.766  0 0.972  0 0.028 0.000
#> SRR1655019     2  0.0794      0.766  0 0.972  0 0.028 0.000
#> SRR1655020     2  0.0703      0.770  0 0.976  0 0.024 0.000
#> SRR1655021     2  0.0794      0.771  0 0.972  0 0.028 0.000
#> SRR1655022     2  0.3895      0.796  0 0.680  0 0.320 0.000
#> SRR1655023     2  0.3913      0.796  0 0.676  0 0.324 0.000
#> SRR1655024     2  0.3949      0.805  0 0.696  0 0.300 0.004
#> SRR1655025     2  0.3969      0.803  0 0.692  0 0.304 0.004
#> SRR1655026     4  0.2583      0.799  0 0.004  0 0.864 0.132
#> SRR1655027     4  0.2536      0.800  0 0.004  0 0.868 0.128
#> SRR1655028     4  0.2605      0.795  0 0.000  0 0.852 0.148
#> SRR1655029     4  0.2605      0.795  0 0.000  0 0.852 0.148
#> SRR1655030     4  0.3612      0.642  0 0.268  0 0.732 0.000
#> SRR1655031     4  0.3612      0.642  0 0.268  0 0.732 0.000
#> SRR1655032     4  0.2561      0.796  0 0.000  0 0.856 0.144
#> SRR1655033     4  0.2561      0.796  0 0.000  0 0.856 0.144
#> SRR1655034     3  0.0000      1.000  0 0.000  1 0.000 0.000
#> SRR1655035     3  0.0000      1.000  0 0.000  1 0.000 0.000
#> SRR1655036     3  0.0000      1.000  0 0.000  1 0.000 0.000
#> SRR1655037     3  0.0000      1.000  0 0.000  1 0.000 0.000
#> SRR1655038     3  0.0000      1.000  0 0.000  1 0.000 0.000
#> SRR1655039     3  0.0000      1.000  0 0.000  1 0.000 0.000
#> SRR1655040     3  0.0000      1.000  0 0.000  1 0.000 0.000
#> SRR1655041     3  0.0000      1.000  0 0.000  1 0.000 0.000
#> SRR1655042     4  0.2280      0.743  0 0.120  0 0.880 0.000
#> SRR1655043     4  0.2230      0.745  0 0.116  0 0.884 0.000
#> SRR1655044     4  0.3932      0.795  0 0.064  0 0.796 0.140
#> SRR1655045     4  0.3932      0.795  0 0.064  0 0.796 0.140
#> SRR1655046     4  0.2127      0.755  0 0.108  0 0.892 0.000
#> SRR1655047     4  0.2179      0.754  0 0.112  0 0.888 0.000
#> SRR1655048     4  0.3689      0.537  0 0.256  0 0.740 0.004
#> SRR1655049     4  0.3689      0.537  0 0.256  0 0.740 0.004
#> SRR1655050     5  0.0000      1.000  0 0.000  0 0.000 1.000
#> SRR1655051     5  0.0000      1.000  0 0.000  0 0.000 1.000
#> SRR1655052     5  0.0000      1.000  0 0.000  0 0.000 1.000
#> SRR1655053     5  0.0000      1.000  0 0.000  0 0.000 1.000
#> SRR1655054     5  0.0000      1.000  0 0.000  0 0.000 1.000
#> SRR1655055     5  0.0000      1.000  0 0.000  0 0.000 1.000
#> SRR1655056     5  0.0000      1.000  0 0.000  0 0.000 1.000
#> SRR1655057     5  0.0000      1.000  0 0.000  0 0.000 1.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
#> SRR1655002     1  0.0000      1.000  1 0.000  0 0.000  0 0.000
#> SRR1655003     1  0.0000      1.000  1 0.000  0 0.000  0 0.000
#> SRR1655004     1  0.0000      1.000  1 0.000  0 0.000  0 0.000
#> SRR1655005     1  0.0000      1.000  1 0.000  0 0.000  0 0.000
#> SRR1655006     1  0.0000      1.000  1 0.000  0 0.000  0 0.000
#> SRR1655007     1  0.0000      1.000  1 0.000  0 0.000  0 0.000
#> SRR1655008     1  0.0000      1.000  1 0.000  0 0.000  0 0.000
#> SRR1655009     1  0.0000      1.000  1 0.000  0 0.000  0 0.000
#> SRR1655010     1  0.0000      1.000  1 0.000  0 0.000  0 0.000
#> SRR1655011     1  0.0000      1.000  1 0.000  0 0.000  0 0.000
#> SRR1655012     2  0.3841      0.745  0 0.616  0 0.004  0 0.380
#> SRR1655013     2  0.3841      0.745  0 0.616  0 0.004  0 0.380
#> SRR1655014     2  0.2389      0.760  0 0.864  0 0.008  0 0.128
#> SRR1655015     2  0.2389      0.760  0 0.864  0 0.008  0 0.128
#> SRR1655016     2  0.3841      0.745  0 0.616  0 0.004  0 0.380
#> SRR1655017     2  0.3841      0.745  0 0.616  0 0.004  0 0.380
#> SRR1655018     2  0.0363      0.694  0 0.988  0 0.000  0 0.012
#> SRR1655019     2  0.0363      0.694  0 0.988  0 0.000  0 0.012
#> SRR1655020     2  0.1858      0.747  0 0.904  0 0.004  0 0.092
#> SRR1655021     2  0.1753      0.743  0 0.912  0 0.004  0 0.084
#> SRR1655022     2  0.4101      0.696  0 0.580  0 0.012  0 0.408
#> SRR1655023     2  0.4184      0.696  0 0.576  0 0.016  0 0.408
#> SRR1655024     2  0.3966      0.694  0 0.552  0 0.004  0 0.444
#> SRR1655025     2  0.3966      0.694  0 0.552  0 0.004  0 0.444
#> SRR1655026     4  0.0146      0.912  0 0.000  0 0.996  0 0.004
#> SRR1655027     4  0.0146      0.912  0 0.000  0 0.996  0 0.004
#> SRR1655028     4  0.0146      0.912  0 0.000  0 0.996  0 0.004
#> SRR1655029     4  0.0146      0.912  0 0.000  0 0.996  0 0.004
#> SRR1655030     6  0.4343      0.721  0 0.156  0 0.120  0 0.724
#> SRR1655031     6  0.4343      0.721  0 0.156  0 0.120  0 0.724
#> SRR1655032     4  0.0000      0.910  0 0.000  0 1.000  0 0.000
#> SRR1655033     4  0.0000      0.910  0 0.000  0 1.000  0 0.000
#> SRR1655034     3  0.0000      1.000  0 0.000  1 0.000  0 0.000
#> SRR1655035     3  0.0000      1.000  0 0.000  1 0.000  0 0.000
#> SRR1655036     3  0.0000      1.000  0 0.000  1 0.000  0 0.000
#> SRR1655037     3  0.0000      1.000  0 0.000  1 0.000  0 0.000
#> SRR1655038     3  0.0000      1.000  0 0.000  1 0.000  0 0.000
#> SRR1655039     3  0.0000      1.000  0 0.000  1 0.000  0 0.000
#> SRR1655040     3  0.0000      1.000  0 0.000  1 0.000  0 0.000
#> SRR1655041     3  0.0000      1.000  0 0.000  1 0.000  0 0.000
#> SRR1655042     6  0.1950      0.786  0 0.024  0 0.064  0 0.912
#> SRR1655043     6  0.2039      0.789  0 0.020  0 0.076  0 0.904
#> SRR1655044     4  0.3709      0.664  0 0.040  0 0.756  0 0.204
#> SRR1655045     4  0.3709      0.664  0 0.040  0 0.756  0 0.204
#> SRR1655046     6  0.3898      0.553  0 0.012  0 0.336  0 0.652
#> SRR1655047     6  0.3819      0.594  0 0.012  0 0.316  0 0.672
#> SRR1655048     6  0.1049      0.764  0 0.008  0 0.032  0 0.960
#> SRR1655049     6  0.1049      0.764  0 0.008  0 0.032  0 0.960
#> SRR1655050     5  0.0000      1.000  0 0.000  0 0.000  1 0.000
#> SRR1655051     5  0.0000      1.000  0 0.000  0 0.000  1 0.000
#> SRR1655052     5  0.0000      1.000  0 0.000  0 0.000  1 0.000
#> SRR1655053     5  0.0000      1.000  0 0.000  0 0.000  1 0.000
#> SRR1655054     5  0.0000      1.000  0 0.000  0 0.000  1 0.000
#> SRR1655055     5  0.0000      1.000  0 0.000  0 0.000  1 0.000
#> SRR1655056     5  0.0000      1.000  0 0.000  0 0.000  1 0.000
#> SRR1655057     5  0.0000      1.000  0 0.000  0 0.000  1 0.000

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

consensus_heatmap(res, k = 2)

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

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

collect_plots(res)

plot of chunk ATC-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.2994 0.701   0.701
#> 3 3 0.734           0.884       0.930         0.6715 0.766   0.667
#> 4 4 0.597           0.457       0.765         0.3018 0.735   0.512
#> 5 5 0.565           0.690       0.763         0.0908 0.730   0.406
#> 6 6 0.697           0.826       0.819         0.0869 0.917   0.709

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

suggest_best_k(res)
#> [1] 2

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette p1 p2
#> SRR1655002     1       0          1  1  0
#> SRR1655003     1       0          1  1  0
#> SRR1655004     1       0          1  1  0
#> SRR1655005     1       0          1  1  0
#> SRR1655006     1       0          1  1  0
#> SRR1655007     1       0          1  1  0
#> SRR1655008     1       0          1  1  0
#> SRR1655009     1       0          1  1  0
#> SRR1655010     1       0          1  1  0
#> SRR1655011     1       0          1  1  0
#> SRR1655012     2       0          1  0  1
#> SRR1655013     2       0          1  0  1
#> SRR1655014     2       0          1  0  1
#> SRR1655015     2       0          1  0  1
#> SRR1655016     2       0          1  0  1
#> SRR1655017     2       0          1  0  1
#> SRR1655018     2       0          1  0  1
#> SRR1655019     2       0          1  0  1
#> SRR1655020     2       0          1  0  1
#> SRR1655021     2       0          1  0  1
#> SRR1655022     2       0          1  0  1
#> SRR1655023     2       0          1  0  1
#> SRR1655024     2       0          1  0  1
#> SRR1655025     2       0          1  0  1
#> SRR1655026     2       0          1  0  1
#> SRR1655027     2       0          1  0  1
#> SRR1655028     2       0          1  0  1
#> SRR1655029     2       0          1  0  1
#> SRR1655030     2       0          1  0  1
#> SRR1655031     2       0          1  0  1
#> SRR1655032     2       0          1  0  1
#> SRR1655033     2       0          1  0  1
#> SRR1655034     2       0          1  0  1
#> SRR1655035     2       0          1  0  1
#> SRR1655036     2       0          1  0  1
#> SRR1655037     2       0          1  0  1
#> SRR1655038     2       0          1  0  1
#> SRR1655039     2       0          1  0  1
#> SRR1655040     2       0          1  0  1
#> SRR1655041     2       0          1  0  1
#> SRR1655042     2       0          1  0  1
#> SRR1655043     2       0          1  0  1
#> SRR1655044     2       0          1  0  1
#> SRR1655045     2       0          1  0  1
#> SRR1655046     2       0          1  0  1
#> SRR1655047     2       0          1  0  1
#> SRR1655048     2       0          1  0  1
#> SRR1655049     2       0          1  0  1
#> SRR1655050     2       0          1  0  1
#> SRR1655051     2       0          1  0  1
#> SRR1655052     2       0          1  0  1
#> SRR1655053     2       0          1  0  1
#> SRR1655054     2       0          1  0  1
#> SRR1655055     2       0          1  0  1
#> SRR1655056     2       0          1  0  1
#> SRR1655057     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
#> SRR1655002     1  0.0000     1.0000  1 0.000 0.000
#> SRR1655003     1  0.0000     1.0000  1 0.000 0.000
#> SRR1655004     1  0.0000     1.0000  1 0.000 0.000
#> SRR1655005     1  0.0000     1.0000  1 0.000 0.000
#> SRR1655006     1  0.0000     1.0000  1 0.000 0.000
#> SRR1655007     1  0.0000     1.0000  1 0.000 0.000
#> SRR1655008     1  0.0000     1.0000  1 0.000 0.000
#> SRR1655009     1  0.0000     1.0000  1 0.000 0.000
#> SRR1655010     1  0.0000     1.0000  1 0.000 0.000
#> SRR1655011     1  0.0000     1.0000  1 0.000 0.000
#> SRR1655012     2  0.0000     0.9404  0 1.000 0.000
#> SRR1655013     2  0.0000     0.9404  0 1.000 0.000
#> SRR1655014     2  0.5016     0.5292  0 0.760 0.240
#> SRR1655015     2  0.6008     0.0849  0 0.628 0.372
#> SRR1655016     2  0.0000     0.9404  0 1.000 0.000
#> SRR1655017     2  0.0000     0.9404  0 1.000 0.000
#> SRR1655018     3  0.5706     0.8566  0 0.320 0.680
#> SRR1655019     3  0.5678     0.8629  0 0.316 0.684
#> SRR1655020     2  0.6252    -0.2387  0 0.556 0.444
#> SRR1655021     2  0.6274    -0.2856  0 0.544 0.456
#> SRR1655022     2  0.0000     0.9404  0 1.000 0.000
#> SRR1655023     2  0.0000     0.9404  0 1.000 0.000
#> SRR1655024     2  0.0000     0.9404  0 1.000 0.000
#> SRR1655025     2  0.0000     0.9404  0 1.000 0.000
#> SRR1655026     2  0.0000     0.9404  0 1.000 0.000
#> SRR1655027     2  0.0000     0.9404  0 1.000 0.000
#> SRR1655028     2  0.0000     0.9404  0 1.000 0.000
#> SRR1655029     2  0.0000     0.9404  0 1.000 0.000
#> SRR1655030     2  0.0424     0.9318  0 0.992 0.008
#> SRR1655031     2  0.0237     0.9362  0 0.996 0.004
#> SRR1655032     2  0.0000     0.9404  0 1.000 0.000
#> SRR1655033     2  0.0000     0.9404  0 1.000 0.000
#> SRR1655034     3  0.4504     0.9316  0 0.196 0.804
#> SRR1655035     3  0.4504     0.9316  0 0.196 0.804
#> SRR1655036     3  0.4887     0.9609  0 0.228 0.772
#> SRR1655037     3  0.4887     0.9609  0 0.228 0.772
#> SRR1655038     3  0.4887     0.9609  0 0.228 0.772
#> SRR1655039     3  0.4887     0.9609  0 0.228 0.772
#> SRR1655040     3  0.4887     0.9609  0 0.228 0.772
#> SRR1655041     3  0.4887     0.9609  0 0.228 0.772
#> SRR1655042     2  0.0000     0.9404  0 1.000 0.000
#> SRR1655043     2  0.0000     0.9404  0 1.000 0.000
#> SRR1655044     2  0.0000     0.9404  0 1.000 0.000
#> SRR1655045     2  0.0000     0.9404  0 1.000 0.000
#> SRR1655046     2  0.0000     0.9404  0 1.000 0.000
#> SRR1655047     2  0.0000     0.9404  0 1.000 0.000
#> SRR1655048     2  0.0000     0.9404  0 1.000 0.000
#> SRR1655049     2  0.0000     0.9404  0 1.000 0.000
#> SRR1655050     2  0.0000     0.9404  0 1.000 0.000
#> SRR1655051     2  0.0000     0.9404  0 1.000 0.000
#> SRR1655052     2  0.0000     0.9404  0 1.000 0.000
#> SRR1655053     2  0.0000     0.9404  0 1.000 0.000
#> SRR1655054     2  0.0000     0.9404  0 1.000 0.000
#> SRR1655055     2  0.0000     0.9404  0 1.000 0.000
#> SRR1655056     2  0.0000     0.9404  0 1.000 0.000
#> SRR1655057     2  0.0000     0.9404  0 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
#> SRR1655002     1  0.0000     1.0000  1 0.000 0.000 0.000
#> SRR1655003     1  0.0000     1.0000  1 0.000 0.000 0.000
#> SRR1655004     1  0.0000     1.0000  1 0.000 0.000 0.000
#> SRR1655005     1  0.0000     1.0000  1 0.000 0.000 0.000
#> SRR1655006     1  0.0000     1.0000  1 0.000 0.000 0.000
#> SRR1655007     1  0.0000     1.0000  1 0.000 0.000 0.000
#> SRR1655008     1  0.0000     1.0000  1 0.000 0.000 0.000
#> SRR1655009     1  0.0000     1.0000  1 0.000 0.000 0.000
#> SRR1655010     1  0.0000     1.0000  1 0.000 0.000 0.000
#> SRR1655011     1  0.0000     1.0000  1 0.000 0.000 0.000
#> SRR1655012     2  0.0188     0.6621  0 0.996 0.004 0.000
#> SRR1655013     2  0.0188     0.6621  0 0.996 0.004 0.000
#> SRR1655014     2  0.0524     0.6593  0 0.988 0.008 0.004
#> SRR1655015     2  0.0524     0.6593  0 0.988 0.008 0.004
#> SRR1655016     2  0.0188     0.6609  0 0.996 0.000 0.004
#> SRR1655017     2  0.0000     0.6621  0 1.000 0.000 0.000
#> SRR1655018     2  0.3907     0.5201  0 0.828 0.140 0.032
#> SRR1655019     2  0.4244     0.4967  0 0.804 0.160 0.036
#> SRR1655020     2  0.0657     0.6575  0 0.984 0.012 0.004
#> SRR1655021     2  0.0657     0.6575  0 0.984 0.012 0.004
#> SRR1655022     2  0.0376     0.6611  0 0.992 0.004 0.004
#> SRR1655023     2  0.0376     0.6611  0 0.992 0.004 0.004
#> SRR1655024     2  0.0000     0.6621  0 1.000 0.000 0.000
#> SRR1655025     2  0.0000     0.6621  0 1.000 0.000 0.000
#> SRR1655026     2  0.7602    -0.6916  0 0.420 0.200 0.380
#> SRR1655027     2  0.7558    -0.6647  0 0.428 0.192 0.380
#> SRR1655028     2  0.7510    -0.6420  0 0.436 0.184 0.380
#> SRR1655029     2  0.7534    -0.6525  0 0.432 0.188 0.380
#> SRR1655030     4  0.7913     0.9733  0 0.320 0.320 0.360
#> SRR1655031     4  0.7913     0.9732  0 0.320 0.320 0.360
#> SRR1655032     2  0.7485    -0.6299  0 0.440 0.180 0.380
#> SRR1655033     2  0.7431    -0.6065  0 0.448 0.172 0.380
#> SRR1655034     3  0.2319     0.5539  0 0.040 0.924 0.036
#> SRR1655035     3  0.2319     0.5539  0 0.040 0.924 0.036
#> SRR1655036     3  0.1302     0.5723  0 0.044 0.956 0.000
#> SRR1655037     3  0.1302     0.5723  0 0.044 0.956 0.000
#> SRR1655038     3  0.1211     0.5722  0 0.040 0.960 0.000
#> SRR1655039     3  0.1211     0.5722  0 0.040 0.960 0.000
#> SRR1655040     3  0.1302     0.5723  0 0.044 0.956 0.000
#> SRR1655041     3  0.1302     0.5723  0 0.044 0.956 0.000
#> SRR1655042     2  0.5077     0.4717  0 0.760 0.080 0.160
#> SRR1655043     2  0.4711     0.5080  0 0.784 0.064 0.152
#> SRR1655044     2  0.5664     0.3336  0 0.696 0.076 0.228
#> SRR1655045     2  0.5759     0.3105  0 0.688 0.080 0.232
#> SRR1655046     2  0.5594     0.3902  0 0.716 0.092 0.192
#> SRR1655047     2  0.5705     0.3636  0 0.704 0.092 0.204
#> SRR1655048     2  0.3245     0.5956  0 0.872 0.028 0.100
#> SRR1655049     2  0.3143     0.5987  0 0.876 0.024 0.100
#> SRR1655050     3  0.6867     0.0715  0 0.104 0.484 0.412
#> SRR1655051     3  0.6867     0.0715  0 0.104 0.484 0.412
#> SRR1655052     3  0.6867     0.0715  0 0.104 0.484 0.412
#> SRR1655053     3  0.6822     0.0804  0 0.100 0.488 0.412
#> SRR1655054     3  0.6953     0.0253  0 0.112 0.476 0.412
#> SRR1655055     3  0.6953     0.0253  0 0.112 0.476 0.412
#> SRR1655056     3  0.6867     0.0715  0 0.104 0.484 0.412
#> SRR1655057     3  0.6867     0.0715  0 0.104 0.484 0.412

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4 p5
#> SRR1655002     1  0.0162      0.998 0.996 0.000 0.000 0.000 NA
#> SRR1655003     1  0.0000      0.999 1.000 0.000 0.000 0.000 NA
#> SRR1655004     1  0.0000      0.999 1.000 0.000 0.000 0.000 NA
#> SRR1655005     1  0.0000      0.999 1.000 0.000 0.000 0.000 NA
#> SRR1655006     1  0.0162      0.998 0.996 0.000 0.000 0.000 NA
#> SRR1655007     1  0.0000      0.999 1.000 0.000 0.000 0.000 NA
#> SRR1655008     1  0.0000      0.999 1.000 0.000 0.000 0.000 NA
#> SRR1655009     1  0.0000      0.999 1.000 0.000 0.000 0.000 NA
#> SRR1655010     1  0.0162      0.998 0.996 0.000 0.000 0.000 NA
#> SRR1655011     1  0.0162      0.998 0.996 0.000 0.000 0.000 NA
#> SRR1655012     2  0.0510      0.924 0.000 0.984 0.000 0.016 NA
#> SRR1655013     2  0.0510      0.922 0.000 0.984 0.000 0.016 NA
#> SRR1655014     2  0.0898      0.924 0.000 0.972 0.020 0.008 NA
#> SRR1655015     2  0.0898      0.923 0.000 0.972 0.020 0.008 NA
#> SRR1655016     2  0.0703      0.918 0.000 0.976 0.000 0.024 NA
#> SRR1655017     2  0.0703      0.918 0.000 0.976 0.000 0.024 NA
#> SRR1655018     2  0.3909      0.758 0.000 0.800 0.148 0.048 NA
#> SRR1655019     2  0.4060      0.744 0.000 0.788 0.156 0.052 NA
#> SRR1655020     2  0.1750      0.901 0.000 0.936 0.028 0.036 NA
#> SRR1655021     2  0.1493      0.910 0.000 0.948 0.028 0.024 NA
#> SRR1655022     2  0.0771      0.926 0.000 0.976 0.020 0.004 NA
#> SRR1655023     2  0.0807      0.927 0.000 0.976 0.012 0.012 NA
#> SRR1655024     2  0.0912      0.922 0.000 0.972 0.012 0.016 NA
#> SRR1655025     2  0.1195      0.912 0.000 0.960 0.012 0.028 NA
#> SRR1655026     4  0.5772      0.502 0.000 0.328 0.108 0.564 NA
#> SRR1655027     4  0.5811      0.495 0.000 0.340 0.108 0.552 NA
#> SRR1655028     4  0.5850      0.504 0.000 0.316 0.120 0.564 NA
#> SRR1655029     4  0.5771      0.507 0.000 0.316 0.112 0.572 NA
#> SRR1655030     4  0.6073      0.517 0.000 0.264 0.172 0.564 NA
#> SRR1655031     4  0.6083      0.517 0.000 0.260 0.176 0.564 NA
#> SRR1655032     4  0.5845      0.485 0.000 0.352 0.108 0.540 NA
#> SRR1655033     4  0.5865      0.480 0.000 0.360 0.108 0.532 NA
#> SRR1655034     3  0.2082      0.958 0.000 0.032 0.928 0.024 NA
#> SRR1655035     3  0.1989      0.962 0.000 0.032 0.932 0.020 NA
#> SRR1655036     3  0.1648      0.984 0.000 0.040 0.940 0.020 NA
#> SRR1655037     3  0.1648      0.984 0.000 0.040 0.940 0.020 NA
#> SRR1655038     3  0.1568      0.983 0.000 0.036 0.944 0.020 NA
#> SRR1655039     3  0.1728      0.983 0.000 0.036 0.940 0.020 NA
#> SRR1655040     3  0.1901      0.983 0.000 0.040 0.932 0.024 NA
#> SRR1655041     3  0.1808      0.983 0.000 0.040 0.936 0.020 NA
#> SRR1655042     4  0.6003      0.348 0.000 0.388 0.056 0.528 NA
#> SRR1655043     4  0.6141      0.308 0.000 0.408 0.064 0.500 NA
#> SRR1655044     4  0.5851      0.377 0.000 0.372 0.048 0.552 NA
#> SRR1655045     4  0.5779      0.379 0.000 0.368 0.044 0.560 NA
#> SRR1655046     4  0.5946      0.351 0.000 0.388 0.052 0.532 NA
#> SRR1655047     4  0.5946      0.351 0.000 0.388 0.052 0.532 NA
#> SRR1655048     4  0.5941      0.285 0.000 0.424 0.048 0.500 NA
#> SRR1655049     4  0.5941      0.285 0.000 0.424 0.048 0.500 NA
#> SRR1655050     4  0.6939      0.201 0.000 0.124 0.328 0.500 NA
#> SRR1655051     4  0.6889      0.189 0.000 0.116 0.336 0.500 NA
#> SRR1655052     4  0.6914      0.196 0.000 0.120 0.332 0.500 NA
#> SRR1655053     4  0.6914      0.196 0.000 0.120 0.332 0.500 NA
#> SRR1655054     4  0.6985      0.209 0.000 0.132 0.320 0.500 NA
#> SRR1655055     4  0.6985      0.209 0.000 0.132 0.320 0.500 NA
#> SRR1655056     4  0.6939      0.201 0.000 0.124 0.328 0.500 NA
#> SRR1655057     4  0.6914      0.196 0.000 0.120 0.332 0.500 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
#> SRR1655002     1   0.026      0.996 0.992 0.000 0.000 0.000 0.000 NA
#> SRR1655003     1   0.000      0.997 1.000 0.000 0.000 0.000 0.000 NA
#> SRR1655004     1   0.000      0.997 1.000 0.000 0.000 0.000 0.000 NA
#> SRR1655005     1   0.000      0.997 1.000 0.000 0.000 0.000 0.000 NA
#> SRR1655006     1   0.026      0.996 0.992 0.000 0.000 0.000 0.000 NA
#> SRR1655007     1   0.000      0.997 1.000 0.000 0.000 0.000 0.000 NA
#> SRR1655008     1   0.000      0.997 1.000 0.000 0.000 0.000 0.000 NA
#> SRR1655009     1   0.000      0.997 1.000 0.000 0.000 0.000 0.000 NA
#> SRR1655010     1   0.026      0.996 0.992 0.000 0.000 0.000 0.000 NA
#> SRR1655011     1   0.026      0.996 0.992 0.000 0.000 0.000 0.000 NA
#> SRR1655012     2   0.146      0.893 0.000 0.944 0.004 0.036 0.016 NA
#> SRR1655013     2   0.139      0.895 0.000 0.948 0.004 0.032 0.016 NA
#> SRR1655014     2   0.123      0.883 0.000 0.960 0.012 0.012 0.012 NA
#> SRR1655015     2   0.113      0.884 0.000 0.964 0.008 0.012 0.012 NA
#> SRR1655016     2   0.212      0.878 0.000 0.908 0.008 0.064 0.020 NA
#> SRR1655017     2   0.185      0.885 0.000 0.924 0.008 0.052 0.016 NA
#> SRR1655018     2   0.396      0.772 0.000 0.804 0.076 0.092 0.016 NA
#> SRR1655019     2   0.447      0.744 0.000 0.776 0.072 0.104 0.024 NA
#> SRR1655020     2   0.194      0.866 0.000 0.924 0.012 0.048 0.004 NA
#> SRR1655021     2   0.194      0.866 0.000 0.924 0.012 0.048 0.004 NA
#> SRR1655022     2   0.171      0.894 0.000 0.932 0.004 0.040 0.024 NA
#> SRR1655023     2   0.178      0.893 0.000 0.928 0.004 0.044 0.024 NA
#> SRR1655024     2   0.304      0.842 0.000 0.860 0.020 0.060 0.060 NA
#> SRR1655025     2   0.343      0.806 0.000 0.832 0.020 0.064 0.084 NA
#> SRR1655026     4   0.752      0.491 0.000 0.268 0.084 0.364 0.268 NA
#> SRR1655027     4   0.755      0.494 0.000 0.276 0.088 0.360 0.260 NA
#> SRR1655028     4   0.747      0.489 0.000 0.276 0.076 0.360 0.272 NA
#> SRR1655029     4   0.744      0.480 0.000 0.264 0.072 0.364 0.284 NA
#> SRR1655030     4   0.773      0.432 0.000 0.212 0.120 0.372 0.276 NA
#> SRR1655031     4   0.769      0.450 0.000 0.212 0.120 0.392 0.256 NA
#> SRR1655032     4   0.746      0.471 0.000 0.280 0.072 0.348 0.284 NA
#> SRR1655033     4   0.745      0.482 0.000 0.284 0.072 0.356 0.272 NA
#> SRR1655034     3   0.412      0.938 0.000 0.032 0.772 0.020 0.164 NA
#> SRR1655035     3   0.412      0.938 0.000 0.032 0.772 0.020 0.164 NA
#> SRR1655036     3   0.469      0.967 0.000 0.048 0.724 0.020 0.192 NA
#> SRR1655037     3   0.488      0.965 0.000 0.048 0.712 0.020 0.196 NA
#> SRR1655038     3   0.445      0.966 0.000 0.044 0.732 0.024 0.196 NA
#> SRR1655039     3   0.450      0.963 0.000 0.044 0.724 0.024 0.204 NA
#> SRR1655040     3   0.466      0.968 0.000 0.044 0.724 0.020 0.196 NA
#> SRR1655041     3   0.482      0.967 0.000 0.044 0.716 0.020 0.196 NA
#> SRR1655042     4   0.256      0.619 0.000 0.084 0.008 0.880 0.028 NA
#> SRR1655043     4   0.245      0.620 0.000 0.084 0.004 0.884 0.028 NA
#> SRR1655044     4   0.246      0.626 0.000 0.084 0.000 0.880 0.036 NA
#> SRR1655045     4   0.246      0.626 0.000 0.084 0.000 0.880 0.036 NA
#> SRR1655046     4   0.236      0.625 0.000 0.072 0.004 0.892 0.032 NA
#> SRR1655047     4   0.242      0.624 0.000 0.076 0.004 0.888 0.032 NA
#> SRR1655048     4   0.294      0.614 0.000 0.100 0.012 0.856 0.032 NA
#> SRR1655049     4   0.289      0.613 0.000 0.104 0.008 0.856 0.032 NA
#> SRR1655050     5   0.120      0.989 0.000 0.040 0.008 0.000 0.952 NA
#> SRR1655051     5   0.132      0.982 0.000 0.036 0.016 0.000 0.948 NA
#> SRR1655052     5   0.120      0.989 0.000 0.040 0.008 0.000 0.952 NA
#> SRR1655053     5   0.132      0.982 0.000 0.036 0.016 0.000 0.948 NA
#> SRR1655054     5   0.137      0.975 0.000 0.044 0.000 0.012 0.944 NA
#> SRR1655055     5   0.137      0.975 0.000 0.044 0.000 0.012 0.944 NA
#> SRR1655056     5   0.120      0.989 0.000 0.040 0.008 0.000 0.952 NA
#> SRR1655057     5   0.120      0.989 0.000 0.040 0.008 0.000 0.952 NA

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-NMF-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-NMF-collect-classes

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

Session info

sessionInfo()
#> R version 3.6.0 (2019-04-26)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: CentOS Linux 7 (Core)
#> 
#> Matrix products: default
#> BLAS:   /usr/lib64/libblas.so.3.4.2
#> LAPACK: /usr/lib64/liblapack.so.3.4.2
#> 
#> locale:
#>  [1] LC_CTYPE=en_GB.UTF-8       LC_NUMERIC=C               LC_TIME=en_GB.UTF-8       
#>  [4] LC_COLLATE=en_GB.UTF-8     LC_MONETARY=en_GB.UTF-8    LC_MESSAGES=en_GB.UTF-8   
#>  [7] LC_PAPER=en_GB.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
#> [10] LC_TELEPHONE=C             LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C       
#> 
#> attached base packages:
#> [1] grid      stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] genefilter_1.66.0    ComplexHeatmap_2.3.1 markdown_1.1         knitr_1.26          
#> [5] GetoptLong_0.1.7     cola_1.3.2          
#> 
#> loaded via a namespace (and not attached):
#>  [1] circlize_0.4.8       shape_1.4.4          xfun_0.11            slam_0.1-46         
#>  [5] lattice_0.20-38      splines_3.6.0        colorspace_1.4-1     vctrs_0.2.0         
#>  [9] stats4_3.6.0         blob_1.2.0           XML_3.98-1.20        survival_2.44-1.1   
#> [13] rlang_0.4.2          pillar_1.4.2         DBI_1.0.0            BiocGenerics_0.30.0 
#> [17] bit64_0.9-7          RColorBrewer_1.1-2   matrixStats_0.55.0   stringr_1.4.0       
#> [21] GlobalOptions_0.1.1  evaluate_0.14        memoise_1.1.0        Biobase_2.44.0      
#> [25] IRanges_2.18.3       parallel_3.6.0       AnnotationDbi_1.46.1 highr_0.8           
#> [29] Rcpp_1.0.3           xtable_1.8-4         backports_1.1.5      S4Vectors_0.22.1    
#> [33] annotate_1.62.0      skmeans_0.2-11       bit_1.1-14           microbenchmark_1.4-7
#> [37] brew_1.0-6           impute_1.58.0        rjson_0.2.20         png_0.1-7           
#> [41] digest_0.6.23        stringi_1.4.3        polyclip_1.10-0      clue_0.3-57         
#> [45] tools_3.6.0          bitops_1.0-6         magrittr_1.5         eulerr_6.0.0        
#> [49] RCurl_1.95-4.12      RSQLite_2.1.4        tibble_2.1.3         cluster_2.1.0       
#> [53] crayon_1.3.4         pkgconfig_2.0.3      zeallot_0.1.0        Matrix_1.2-17       
#> [57] xml2_1.2.2           httr_1.4.1           R6_2.4.1             mclust_5.4.5        
#> [61] compiler_3.6.0