cola Report for recount2:SRP037775

Date: 2019-12-25 23:57:32 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 14158 rows and 63 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] 14158    63

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 5 1.000 0.998 0.997 ** 2,3,4
SD:kmeans 2 1.000 1.000 1.000 **
SD:skmeans 3 1.000 0.994 0.992 ** 2
SD:pam 6 1.000 1.000 1.000 ** 2,3,5
SD:mclust 6 1.000 0.999 0.987 ** 2,4,5
SD:NMF 2 1.000 1.000 1.000 **
CV:kmeans 2 1.000 1.000 1.000 **
CV:skmeans 3 1.000 0.994 0.993 ** 2
CV:pam 6 1.000 0.999 0.999 ** 2,3,5
CV:mclust 5 1.000 1.000 1.000 ** 2,3,4
CV:NMF 2 1.000 1.000 1.000 **
MAD:hclust 5 1.000 1.000 1.000 ** 2,3,4
MAD:kmeans 2 1.000 1.000 1.000 **
MAD:skmeans 3 1.000 0.994 0.995 ** 2
MAD:pam 6 1.000 1.000 1.000 ** 2,3,4,5
MAD:mclust 5 1.000 1.000 1.000 ** 2,4
MAD:NMF 2 1.000 1.000 1.000 **
ATC:hclust 6 1.000 1.000 1.000 ** 2,3,4,5
ATC:kmeans 2 1.000 1.000 1.000 **
ATC:skmeans 2 1.000 1.000 1.000 **
ATC:pam 6 1.000 1.000 1.000 ** 2,3,4,5
ATC:mclust 6 1.000 1.000 1.000 ** 2,3,4,5
ATC:NMF 2 1.000 1.000 1.000 **
CV:hclust 4 0.963 0.981 0.950 ** 2,3

**: 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               1           1          0.502 0.498   0.498
#> CV:NMF      2     1               1           1          0.502 0.498   0.498
#> MAD:NMF     2     1               1           1          0.502 0.498   0.498
#> ATC:NMF     2     1               1           1          0.502 0.498   0.498
#> SD:skmeans  2     1               1           1          0.502 0.498   0.498
#> CV:skmeans  2     1               1           1          0.502 0.498   0.498
#> MAD:skmeans 2     1               1           1          0.502 0.498   0.498
#> ATC:skmeans 2     1               1           1          0.502 0.498   0.498
#> SD:mclust   2     1               1           1          0.502 0.498   0.498
#> CV:mclust   2     1               1           1          0.502 0.498   0.498
#> MAD:mclust  2     1               1           1          0.502 0.498   0.498
#> ATC:mclust  2     1               1           1          0.502 0.498   0.498
#> SD:kmeans   2     1               1           1          0.502 0.498   0.498
#> CV:kmeans   2     1               1           1          0.502 0.498   0.498
#> MAD:kmeans  2     1               1           1          0.502 0.498   0.498
#> ATC:kmeans  2     1               1           1          0.502 0.498   0.498
#> SD:pam      2     1               1           1          0.502 0.498   0.498
#> CV:pam      2     1               1           1          0.502 0.498   0.498
#> MAD:pam     2     1               1           1          0.502 0.498   0.498
#> ATC:pam     2     1               1           1          0.502 0.498   0.498
#> SD:hclust   2     1               1           1          0.502 0.498   0.498
#> CV:hclust   2     1               1           1          0.502 0.498   0.498
#> MAD:hclust  2     1               1           1          0.502 0.498   0.498
#> ATC:hclust  2     1               1           1          0.502 0.498   0.498
get_stats(res_list, k = 3)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      3 0.846           0.877       0.874         0.1577 1.000   1.000
#> CV:NMF      3 0.745           0.970       0.895         0.2379 0.846   0.692
#> MAD:NMF     3 0.846           1.000       0.941         0.2299 0.846   0.692
#> ATC:NMF     3 0.846           0.928       0.922         0.0959 1.000   1.000
#> SD:skmeans  3 1.000           0.994       0.992         0.3047 0.846   0.692
#> CV:skmeans  3 1.000           0.994       0.993         0.3045 0.846   0.692
#> MAD:skmeans 3 1.000           0.994       0.995         0.3056 0.846   0.692
#> ATC:skmeans 3 0.844           0.956       0.965         0.3057 0.846   0.692
#> SD:mclust   3 0.880           0.978       0.984         0.2730 0.865   0.729
#> CV:mclust   3 1.000           0.994       0.995         0.2700 0.865   0.729
#> MAD:mclust  3 0.880           0.975       0.983         0.2732 0.865   0.729
#> ATC:mclust  3 1.000           0.996       0.992         0.2009 0.900   0.799
#> SD:kmeans   3 0.667           0.835       0.790         0.2647 0.846   0.692
#> CV:kmeans   3 0.667           0.846       0.807         0.2678 0.846   0.692
#> MAD:kmeans  3 0.667           0.850       0.779         0.2651 0.846   0.692
#> ATC:kmeans  3 0.667           0.595       0.695         0.2583 0.900   0.799
#> SD:pam      3 1.000           1.000       1.000         0.3055 0.846   0.692
#> CV:pam      3 1.000           0.995       0.997         0.3062 0.846   0.692
#> MAD:pam     3 1.000           1.000       1.000         0.3055 0.846   0.692
#> ATC:pam     3 1.000           0.993       0.996         0.3040 0.846   0.692
#> SD:hclust   3 1.000           1.000       1.000         0.3055 0.846   0.692
#> CV:hclust   3 1.000           1.000       1.000         0.3055 0.846   0.692
#> MAD:hclust  3 1.000           1.000       1.000         0.3055 0.846   0.692
#> ATC:hclust  3 1.000           1.000       1.000         0.3055 0.846   0.692
get_stats(res_list, k = 4)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      4 0.746           0.950       0.902         0.1114 0.846   0.692
#> CV:NMF      4 0.788           0.874       0.815         0.1207 1.000   1.000
#> MAD:NMF     4 0.964           0.980       0.965         0.0538 1.000   1.000
#> ATC:NMF     4 0.746           0.944       0.869         0.1344 0.846   0.692
#> SD:skmeans  4 0.820           0.952       0.906         0.0852 0.949   0.853
#> CV:skmeans  4 0.820           0.942       0.888         0.0834 0.949   0.853
#> MAD:skmeans 4 0.820           0.956       0.911         0.0816 0.949   0.853
#> ATC:skmeans 4 0.820           0.951       0.903         0.0772 0.949   0.853
#> SD:mclust   4 1.000           0.998       0.996         0.1055 0.931   0.810
#> CV:mclust   4 1.000           1.000       1.000         0.1074 0.931   0.810
#> MAD:mclust  4 1.000           1.000       1.000         0.1045 0.931   0.810
#> ATC:mclust  4 0.931           0.980       0.981         0.2231 0.865   0.660
#> SD:kmeans   4 0.667           0.853       0.759         0.1145 0.900   0.709
#> CV:kmeans   4 0.668           0.896       0.788         0.1063 0.900   0.709
#> MAD:kmeans  4 0.667           0.837       0.742         0.1165 0.900   0.709
#> ATC:kmeans  4 0.657           0.688       0.730         0.1065 0.746   0.459
#> SD:pam      4 0.849           0.905       0.842         0.1093 0.949   0.853
#> CV:pam      4 0.849           0.973       0.955         0.0860 0.949   0.853
#> MAD:pam     4 1.000           1.000       1.000         0.0772 0.949   0.853
#> ATC:pam     4 1.000           0.990       0.987         0.1513 0.900   0.709
#> SD:hclust   4 1.000           1.000       1.000         0.0772 0.949   0.853
#> CV:hclust   4 0.963           0.981       0.950         0.0526 0.949   0.853
#> MAD:hclust  4 1.000           1.000       1.000         0.0772 0.949   0.853
#> ATC:hclust  4 0.921           0.946       0.913         0.0552 0.971   0.917
get_stats(res_list, k = 5)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      5 0.752           0.935       0.777         0.1003 0.900   0.709
#> CV:NMF      5 0.752           0.867       0.819         0.0812 0.900   0.709
#> MAD:NMF     5 0.821           0.865       0.862         0.0855 1.000   1.000
#> ATC:NMF     5 0.650           0.826       0.806         0.0947 1.000   1.000
#> SD:skmeans  5 0.871           0.897       0.835         0.0756 0.971   0.902
#> CV:skmeans  5 0.867           0.949       0.782         0.0777 0.900   0.659
#> MAD:skmeans 5 0.871           0.892       0.818         0.0798 0.971   0.902
#> ATC:skmeans 5 0.820           0.689       0.710         0.0882 0.814   0.469
#> SD:mclust   5 1.000           0.982       0.972         0.0483 0.971   0.902
#> CV:mclust   5 1.000           1.000       1.000         0.0406 0.971   0.902
#> MAD:mclust  5 1.000           1.000       1.000         0.0406 0.971   0.902
#> ATC:mclust  5 1.000           0.999       0.996         0.0922 0.931   0.737
#> SD:kmeans   5 0.620           0.803       0.735         0.0621 1.000   1.000
#> CV:kmeans   5 0.621           0.827       0.742         0.0633 1.000   1.000
#> MAD:kmeans  5 0.701           0.818       0.764         0.0720 1.000   1.000
#> ATC:kmeans  5 0.627           0.886       0.709         0.0713 0.849   0.522
#> SD:pam      5 1.000           1.000       1.000         0.1089 0.900   0.659
#> CV:pam      5 1.000           0.993       0.979         0.1261 0.900   0.659
#> MAD:pam     5 1.000           0.993       0.989         0.0437 0.971   0.902
#> ATC:pam     5 1.000           0.988       0.982         0.0685 0.949   0.792
#> SD:hclust   5 1.000           0.998       0.997         0.0413 0.971   0.902
#> CV:hclust   5 0.926           0.899       0.914         0.0215 0.993   0.976
#> MAD:hclust  5 1.000           1.000       1.000         0.0406 0.971   0.902
#> ATC:hclust  5 1.000           1.000       1.000         0.0623 0.949   0.840
get_stats(res_list, k = 6)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      6 0.752           0.874       0.828        0.06015 1.000   1.000
#> CV:NMF      6 0.754           0.903       0.836        0.04803 0.949   0.792
#> MAD:NMF     6 0.786           0.839       0.767        0.04758 0.949   0.853
#> ATC:NMF     6 0.680           0.868       0.819        0.07532 0.900   0.709
#> SD:skmeans  6 0.885           0.995       0.959        0.07072 0.900   0.622
#> CV:skmeans  6 0.857           0.980       0.880        0.04675 0.971   0.852
#> MAD:skmeans 6 0.896           0.991       0.923        0.05126 0.900   0.622
#> ATC:skmeans 6 0.893           0.995       0.957        0.06469 0.943   0.742
#> SD:mclust   6 1.000           0.999       0.987        0.12064 0.900   0.622
#> CV:mclust   6 1.000           0.966       0.980        0.00993 0.997   0.988
#> MAD:mclust  6 0.885           0.995       0.946        0.10786 0.900   0.622
#> ATC:mclust  6 1.000           1.000       1.000        0.03653 0.971   0.852
#> SD:kmeans   6 0.665           0.940       0.729        0.05415 0.921   0.675
#> CV:kmeans   6 0.677           0.885       0.757        0.05048 0.949   0.792
#> MAD:kmeans  6 0.654           0.547       0.649        0.04107 0.982   0.925
#> ATC:kmeans  6 0.658           0.870       0.765        0.04587 1.000   1.000
#> SD:pam      6 1.000           1.000       1.000        0.03551 0.971   0.852
#> CV:pam      6 1.000           0.999       0.999        0.04100 0.971   0.852
#> MAD:pam     6 1.000           1.000       1.000        0.13297 0.900   0.622
#> ATC:pam     6 1.000           1.000       1.000        0.03666 0.971   0.852
#> SD:hclust   6 0.896           0.858       0.888        0.06658 0.996   0.985
#> CV:hclust   6 0.974           0.899       0.961        0.03010 0.996   0.986
#> MAD:hclust  6 1.000           0.982       0.999        0.00575 0.996   0.985
#> ATC:hclust  6 1.000           1.000       1.000        0.13640 0.900   0.622

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)
#> Error in valid.viewport(x, y, width, height, just, gp, clip, xscale, yscale, : invalid 'xscale' in viewport

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

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

collect_plots(res)

plot of chunk SD-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.5023 0.498   0.498
#> 3 3 1.000           1.000       1.000         0.3055 0.846   0.692
#> 4 4 1.000           1.000       1.000         0.0772 0.949   0.853
#> 5 5 1.000           0.998       0.997         0.0413 0.971   0.902
#> 6 6 0.896           0.858       0.888         0.0666 0.996   0.985

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette p1 p2
#> SRR1168715     1       0          1  1  0
#> SRR1168716     1       0          1  1  0
#> SRR1168717     1       0          1  1  0
#> SRR1168718     1       0          1  1  0
#> SRR1168719     1       0          1  1  0
#> SRR1168720     1       0          1  1  0
#> SRR1168721     1       0          1  1  0
#> SRR1168722     1       0          1  1  0
#> SRR1168723     1       0          1  1  0
#> SRR1168724     1       0          1  1  0
#> SRR1168725     1       0          1  1  0
#> SRR1168726     1       0          1  1  0
#> SRR1168727     1       0          1  1  0
#> SRR1168728     1       0          1  1  0
#> SRR1168729     1       0          1  1  0
#> SRR1168730     1       0          1  1  0
#> SRR1168731     1       0          1  1  0
#> SRR1168732     1       0          1  1  0
#> SRR1168733     2       0          1  0  1
#> SRR1168734     2       0          1  0  1
#> SRR1168735     2       0          1  0  1
#> SRR1168736     2       0          1  0  1
#> SRR1168737     2       0          1  0  1
#> SRR1168738     2       0          1  0  1
#> SRR1168739     2       0          1  0  1
#> SRR1168740     2       0          1  0  1
#> SRR1168741     2       0          1  0  1
#> SRR1168742     2       0          1  0  1
#> SRR1168743     2       0          1  0  1
#> SRR1168744     2       0          1  0  1
#> SRR1168745     2       0          1  0  1
#> SRR1168746     2       0          1  0  1
#> SRR1168747     2       0          1  0  1
#> SRR1168748     2       0          1  0  1
#> SRR1168749     2       0          1  0  1
#> SRR1168750     2       0          1  0  1
#> SRR1168751     2       0          1  0  1
#> SRR1168752     2       0          1  0  1
#> SRR1168753     2       0          1  0  1
#> SRR1168754     2       0          1  0  1
#> SRR1168755     2       0          1  0  1
#> SRR1168756     2       0          1  0  1
#> SRR1168757     2       0          1  0  1
#> SRR1168758     2       0          1  0  1
#> SRR1168759     2       0          1  0  1
#> SRR1168760     2       0          1  0  1
#> SRR1168761     1       0          1  1  0
#> SRR1168762     1       0          1  1  0
#> SRR1168763     1       0          1  1  0
#> SRR1168764     1       0          1  1  0
#> SRR1168765     1       0          1  1  0
#> SRR1168766     1       0          1  1  0
#> SRR1168767     1       0          1  1  0
#> SRR1168768     1       0          1  1  0
#> SRR1168769     1       0          1  1  0
#> SRR1168770     1       0          1  1  0
#> SRR1168771     1       0          1  1  0
#> SRR1168772     1       0          1  1  0
#> SRR1168773     1       0          1  1  0
#> SRR1168774     1       0          1  1  0
#> SRR1168775     1       0          1  1  0
#> SRR1168776     1       0          1  1  0
#> SRR1168777     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette p1 p2 p3
#> SRR1168715     3       0          1  0  0  1
#> SRR1168716     3       0          1  0  0  1
#> SRR1168717     3       0          1  0  0  1
#> SRR1168718     3       0          1  0  0  1
#> SRR1168719     3       0          1  0  0  1
#> SRR1168720     3       0          1  0  0  1
#> SRR1168721     3       0          1  0  0  1
#> SRR1168722     1       0          1  1  0  0
#> SRR1168723     1       0          1  1  0  0
#> SRR1168724     1       0          1  1  0  0
#> SRR1168725     1       0          1  1  0  0
#> SRR1168726     1       0          1  1  0  0
#> SRR1168727     1       0          1  1  0  0
#> SRR1168728     1       0          1  1  0  0
#> SRR1168729     1       0          1  1  0  0
#> SRR1168730     1       0          1  1  0  0
#> SRR1168731     1       0          1  1  0  0
#> SRR1168732     1       0          1  1  0  0
#> SRR1168733     2       0          1  0  1  0
#> SRR1168734     2       0          1  0  1  0
#> SRR1168735     2       0          1  0  1  0
#> SRR1168736     2       0          1  0  1  0
#> SRR1168737     2       0          1  0  1  0
#> SRR1168738     2       0          1  0  1  0
#> SRR1168739     2       0          1  0  1  0
#> SRR1168740     2       0          1  0  1  0
#> SRR1168741     2       0          1  0  1  0
#> SRR1168742     2       0          1  0  1  0
#> SRR1168743     2       0          1  0  1  0
#> SRR1168744     2       0          1  0  1  0
#> SRR1168745     2       0          1  0  1  0
#> SRR1168746     2       0          1  0  1  0
#> SRR1168747     2       0          1  0  1  0
#> SRR1168748     2       0          1  0  1  0
#> SRR1168749     2       0          1  0  1  0
#> SRR1168750     2       0          1  0  1  0
#> SRR1168751     2       0          1  0  1  0
#> SRR1168752     2       0          1  0  1  0
#> SRR1168753     2       0          1  0  1  0
#> SRR1168754     2       0          1  0  1  0
#> SRR1168755     2       0          1  0  1  0
#> SRR1168756     2       0          1  0  1  0
#> SRR1168757     2       0          1  0  1  0
#> SRR1168758     2       0          1  0  1  0
#> SRR1168759     2       0          1  0  1  0
#> SRR1168760     2       0          1  0  1  0
#> SRR1168761     3       0          1  0  0  1
#> SRR1168762     3       0          1  0  0  1
#> SRR1168763     3       0          1  0  0  1
#> SRR1168764     3       0          1  0  0  1
#> SRR1168765     3       0          1  0  0  1
#> SRR1168766     3       0          1  0  0  1
#> SRR1168767     3       0          1  0  0  1
#> SRR1168768     3       0          1  0  0  1
#> SRR1168769     1       0          1  1  0  0
#> SRR1168770     1       0          1  1  0  0
#> SRR1168771     1       0          1  1  0  0
#> SRR1168772     1       0          1  1  0  0
#> SRR1168773     1       0          1  1  0  0
#> SRR1168774     1       0          1  1  0  0
#> SRR1168775     1       0          1  1  0  0
#> SRR1168776     1       0          1  1  0  0
#> SRR1168777     1       0          1  1  0  0

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette p1 p2 p3 p4
#> SRR1168715     3       0          1  0  0  1  0
#> SRR1168716     3       0          1  0  0  1  0
#> SRR1168717     3       0          1  0  0  1  0
#> SRR1168718     3       0          1  0  0  1  0
#> SRR1168719     3       0          1  0  0  1  0
#> SRR1168720     3       0          1  0  0  1  0
#> SRR1168721     3       0          1  0  0  1  0
#> SRR1168722     1       0          1  1  0  0  0
#> SRR1168723     1       0          1  1  0  0  0
#> SRR1168724     1       0          1  1  0  0  0
#> SRR1168725     1       0          1  1  0  0  0
#> SRR1168726     1       0          1  1  0  0  0
#> SRR1168727     1       0          1  1  0  0  0
#> SRR1168728     1       0          1  1  0  0  0
#> SRR1168729     1       0          1  1  0  0  0
#> SRR1168730     1       0          1  1  0  0  0
#> SRR1168731     1       0          1  1  0  0  0
#> SRR1168732     1       0          1  1  0  0  0
#> SRR1168733     2       0          1  0  1  0  0
#> SRR1168734     2       0          1  0  1  0  0
#> SRR1168735     2       0          1  0  1  0  0
#> SRR1168736     2       0          1  0  1  0  0
#> SRR1168737     2       0          1  0  1  0  0
#> SRR1168738     2       0          1  0  1  0  0
#> SRR1168739     2       0          1  0  1  0  0
#> SRR1168740     2       0          1  0  1  0  0
#> SRR1168741     2       0          1  0  1  0  0
#> SRR1168742     2       0          1  0  1  0  0
#> SRR1168743     2       0          1  0  1  0  0
#> SRR1168744     2       0          1  0  1  0  0
#> SRR1168745     2       0          1  0  1  0  0
#> SRR1168746     2       0          1  0  1  0  0
#> SRR1168747     2       0          1  0  1  0  0
#> SRR1168748     2       0          1  0  1  0  0
#> SRR1168749     2       0          1  0  1  0  0
#> SRR1168750     2       0          1  0  1  0  0
#> SRR1168751     2       0          1  0  1  0  0
#> SRR1168752     2       0          1  0  1  0  0
#> SRR1168753     2       0          1  0  1  0  0
#> SRR1168754     2       0          1  0  1  0  0
#> SRR1168755     2       0          1  0  1  0  0
#> SRR1168756     2       0          1  0  1  0  0
#> SRR1168757     2       0          1  0  1  0  0
#> SRR1168758     2       0          1  0  1  0  0
#> SRR1168759     2       0          1  0  1  0  0
#> SRR1168760     2       0          1  0  1  0  0
#> SRR1168761     3       0          1  0  0  1  0
#> SRR1168762     3       0          1  0  0  1  0
#> SRR1168763     3       0          1  0  0  1  0
#> SRR1168764     3       0          1  0  0  1  0
#> SRR1168765     3       0          1  0  0  1  0
#> SRR1168766     3       0          1  0  0  1  0
#> SRR1168767     3       0          1  0  0  1  0
#> SRR1168768     3       0          1  0  0  1  0
#> SRR1168769     4       0          1  0  0  0  1
#> SRR1168770     4       0          1  0  0  0  1
#> SRR1168771     4       0          1  0  0  0  1
#> SRR1168772     4       0          1  0  0  0  1
#> SRR1168773     4       0          1  0  0  0  1
#> SRR1168774     4       0          1  0  0  0  1
#> SRR1168775     4       0          1  0  0  0  1
#> SRR1168776     4       0          1  0  0  0  1
#> SRR1168777     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
#> SRR1168715     5   0.029      1.000  0 0.000 0.008  0 0.992
#> SRR1168716     5   0.029      1.000  0 0.000 0.008  0 0.992
#> SRR1168717     5   0.029      1.000  0 0.000 0.008  0 0.992
#> SRR1168718     5   0.029      1.000  0 0.000 0.008  0 0.992
#> SRR1168719     5   0.029      1.000  0 0.000 0.008  0 0.992
#> SRR1168720     5   0.029      1.000  0 0.000 0.008  0 0.992
#> SRR1168721     5   0.029      1.000  0 0.000 0.008  0 0.992
#> SRR1168722     1   0.000      1.000  1 0.000 0.000  0 0.000
#> SRR1168723     1   0.000      1.000  1 0.000 0.000  0 0.000
#> SRR1168724     1   0.000      1.000  1 0.000 0.000  0 0.000
#> SRR1168725     1   0.000      1.000  1 0.000 0.000  0 0.000
#> SRR1168726     1   0.000      1.000  1 0.000 0.000  0 0.000
#> SRR1168727     1   0.000      1.000  1 0.000 0.000  0 0.000
#> SRR1168728     1   0.000      1.000  1 0.000 0.000  0 0.000
#> SRR1168729     1   0.000      1.000  1 0.000 0.000  0 0.000
#> SRR1168730     1   0.000      1.000  1 0.000 0.000  0 0.000
#> SRR1168731     1   0.000      1.000  1 0.000 0.000  0 0.000
#> SRR1168732     1   0.000      1.000  1 0.000 0.000  0 0.000
#> SRR1168733     2   0.000      0.996  0 1.000 0.000  0 0.000
#> SRR1168734     2   0.000      0.996  0 1.000 0.000  0 0.000
#> SRR1168735     2   0.000      0.996  0 1.000 0.000  0 0.000
#> SRR1168736     2   0.000      0.996  0 1.000 0.000  0 0.000
#> SRR1168737     2   0.000      0.996  0 1.000 0.000  0 0.000
#> SRR1168738     2   0.000      0.996  0 1.000 0.000  0 0.000
#> SRR1168739     2   0.000      0.996  0 1.000 0.000  0 0.000
#> SRR1168740     2   0.000      0.996  0 1.000 0.000  0 0.000
#> SRR1168741     2   0.000      0.996  0 1.000 0.000  0 0.000
#> SRR1168742     2   0.000      0.996  0 1.000 0.000  0 0.000
#> SRR1168743     2   0.000      0.996  0 1.000 0.000  0 0.000
#> SRR1168744     2   0.000      0.996  0 1.000 0.000  0 0.000
#> SRR1168745     2   0.000      0.996  0 1.000 0.000  0 0.000
#> SRR1168746     2   0.000      0.996  0 1.000 0.000  0 0.000
#> SRR1168747     2   0.029      0.996  0 0.992 0.000  0 0.008
#> SRR1168748     2   0.029      0.996  0 0.992 0.000  0 0.008
#> SRR1168749     2   0.029      0.996  0 0.992 0.000  0 0.008
#> SRR1168750     2   0.029      0.996  0 0.992 0.000  0 0.008
#> SRR1168751     2   0.029      0.996  0 0.992 0.000  0 0.008
#> SRR1168752     2   0.029      0.996  0 0.992 0.000  0 0.008
#> SRR1168753     2   0.029      0.996  0 0.992 0.000  0 0.008
#> SRR1168754     2   0.029      0.996  0 0.992 0.000  0 0.008
#> SRR1168755     2   0.029      0.996  0 0.992 0.000  0 0.008
#> SRR1168756     2   0.029      0.996  0 0.992 0.000  0 0.008
#> SRR1168757     2   0.029      0.996  0 0.992 0.000  0 0.008
#> SRR1168758     2   0.029      0.996  0 0.992 0.000  0 0.008
#> SRR1168759     2   0.029      0.996  0 0.992 0.000  0 0.008
#> SRR1168760     2   0.029      0.996  0 0.992 0.000  0 0.008
#> SRR1168761     3   0.000      1.000  0 0.000 1.000  0 0.000
#> SRR1168762     3   0.000      1.000  0 0.000 1.000  0 0.000
#> SRR1168763     3   0.000      1.000  0 0.000 1.000  0 0.000
#> SRR1168764     3   0.000      1.000  0 0.000 1.000  0 0.000
#> SRR1168765     3   0.000      1.000  0 0.000 1.000  0 0.000
#> SRR1168766     3   0.000      1.000  0 0.000 1.000  0 0.000
#> SRR1168767     3   0.000      1.000  0 0.000 1.000  0 0.000
#> SRR1168768     3   0.000      1.000  0 0.000 1.000  0 0.000
#> SRR1168769     4   0.000      1.000  0 0.000 0.000  1 0.000
#> SRR1168770     4   0.000      1.000  0 0.000 0.000  1 0.000
#> SRR1168771     4   0.000      1.000  0 0.000 0.000  1 0.000
#> SRR1168772     4   0.000      1.000  0 0.000 0.000  1 0.000
#> SRR1168773     4   0.000      1.000  0 0.000 0.000  1 0.000
#> SRR1168774     4   0.000      1.000  0 0.000 0.000  1 0.000
#> SRR1168775     4   0.000      1.000  0 0.000 0.000  1 0.000
#> SRR1168776     4   0.000      1.000  0 0.000 0.000  1 0.000
#> SRR1168777     4   0.000      1.000  0 0.000 0.000  1 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette p1    p2 p3    p4    p5 p6
#> SRR1168715     6   0.000      1.000  0 0.000  0 0.000 0.000  1
#> SRR1168716     6   0.000      1.000  0 0.000  0 0.000 0.000  1
#> SRR1168717     6   0.000      1.000  0 0.000  0 0.000 0.000  1
#> SRR1168718     6   0.000      1.000  0 0.000  0 0.000 0.000  1
#> SRR1168719     6   0.000      1.000  0 0.000  0 0.000 0.000  1
#> SRR1168720     6   0.000      1.000  0 0.000  0 0.000 0.000  1
#> SRR1168721     6   0.000      1.000  0 0.000  0 0.000 0.000  1
#> SRR1168722     1   0.000      1.000  1 0.000  0 0.000 0.000  0
#> SRR1168723     1   0.000      1.000  1 0.000  0 0.000 0.000  0
#> SRR1168724     1   0.000      1.000  1 0.000  0 0.000 0.000  0
#> SRR1168725     1   0.000      1.000  1 0.000  0 0.000 0.000  0
#> SRR1168726     1   0.000      1.000  1 0.000  0 0.000 0.000  0
#> SRR1168727     1   0.000      1.000  1 0.000  0 0.000 0.000  0
#> SRR1168728     1   0.000      1.000  1 0.000  0 0.000 0.000  0
#> SRR1168729     1   0.000      1.000  1 0.000  0 0.000 0.000  0
#> SRR1168730     1   0.000      1.000  1 0.000  0 0.000 0.000  0
#> SRR1168731     1   0.000      1.000  1 0.000  0 0.000 0.000  0
#> SRR1168732     1   0.000      1.000  1 0.000  0 0.000 0.000  0
#> SRR1168733     5   0.386      0.715  0 0.472  0 0.000 0.528  0
#> SRR1168734     5   0.386      0.715  0 0.472  0 0.000 0.528  0
#> SRR1168735     5   0.386      0.715  0 0.472  0 0.000 0.528  0
#> SRR1168736     5   0.386      0.715  0 0.472  0 0.000 0.528  0
#> SRR1168737     5   0.386      0.715  0 0.472  0 0.000 0.528  0
#> SRR1168738     5   0.386      0.715  0 0.472  0 0.000 0.528  0
#> SRR1168739     5   0.386      0.715  0 0.472  0 0.000 0.528  0
#> SRR1168740     5   0.386      0.715  0 0.472  0 0.000 0.528  0
#> SRR1168741     5   0.386      0.715  0 0.472  0 0.000 0.528  0
#> SRR1168742     5   0.386      0.715  0 0.472  0 0.000 0.528  0
#> SRR1168743     5   0.386      0.715  0 0.472  0 0.000 0.528  0
#> SRR1168744     5   0.386      0.715  0 0.472  0 0.000 0.528  0
#> SRR1168745     5   0.386      0.715  0 0.472  0 0.000 0.528  0
#> SRR1168746     5   0.386      0.715  0 0.472  0 0.000 0.528  0
#> SRR1168747     5   0.000      0.715  0 0.000  0 0.000 1.000  0
#> SRR1168748     5   0.000      0.715  0 0.000  0 0.000 1.000  0
#> SRR1168749     5   0.000      0.715  0 0.000  0 0.000 1.000  0
#> SRR1168750     5   0.000      0.715  0 0.000  0 0.000 1.000  0
#> SRR1168751     5   0.000      0.715  0 0.000  0 0.000 1.000  0
#> SRR1168752     5   0.000      0.715  0 0.000  0 0.000 1.000  0
#> SRR1168753     5   0.000      0.715  0 0.000  0 0.000 1.000  0
#> SRR1168754     5   0.000      0.715  0 0.000  0 0.000 1.000  0
#> SRR1168755     5   0.000      0.715  0 0.000  0 0.000 1.000  0
#> SRR1168756     5   0.000      0.715  0 0.000  0 0.000 1.000  0
#> SRR1168757     5   0.000      0.715  0 0.000  0 0.000 1.000  0
#> SRR1168758     5   0.000      0.715  0 0.000  0 0.000 1.000  0
#> SRR1168759     5   0.000      0.715  0 0.000  0 0.000 1.000  0
#> SRR1168760     5   0.000      0.715  0 0.000  0 0.000 1.000  0
#> SRR1168761     3   0.000      1.000  0 0.000  1 0.000 0.000  0
#> SRR1168762     3   0.000      1.000  0 0.000  1 0.000 0.000  0
#> SRR1168763     3   0.000      1.000  0 0.000  1 0.000 0.000  0
#> SRR1168764     3   0.000      1.000  0 0.000  1 0.000 0.000  0
#> SRR1168765     3   0.000      1.000  0 0.000  1 0.000 0.000  0
#> SRR1168766     3   0.000      1.000  0 0.000  1 0.000 0.000  0
#> SRR1168767     3   0.000      1.000  0 0.000  1 0.000 0.000  0
#> SRR1168768     3   0.000      1.000  0 0.000  1 0.000 0.000  0
#> SRR1168769     4   0.000      1.000  0 0.000  0 1.000 0.000  0
#> SRR1168770     4   0.000      1.000  0 0.000  0 1.000 0.000  0
#> SRR1168771     4   0.000      1.000  0 0.000  0 1.000 0.000  0
#> SRR1168772     4   0.000      1.000  0 0.000  0 1.000 0.000  0
#> SRR1168773     4   0.000      1.000  0 0.000  0 1.000 0.000  0
#> SRR1168774     4   0.000      1.000  0 0.000  0 1.000 0.000  0
#> SRR1168775     4   0.000      1.000  0 0.000  0 1.000 0.000  0
#> SRR1168776     4   0.000      1.000  0 0.000  0 1.000 0.000  0
#> SRR1168777     2   0.386      0.000  0 0.528  0 0.472 0.000  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 14158 rows and 63 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           1.000       1.000         0.5023 0.498   0.498
#> 3 3 0.667           0.835       0.790         0.2647 0.846   0.692
#> 4 4 0.667           0.853       0.759         0.1145 0.900   0.709
#> 5 5 0.620           0.803       0.735         0.0621 1.000   1.000
#> 6 6 0.665           0.940       0.729         0.0542 0.921   0.675

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
#> SRR1168715     1       0          1  1  0
#> SRR1168716     1       0          1  1  0
#> SRR1168717     1       0          1  1  0
#> SRR1168718     1       0          1  1  0
#> SRR1168719     1       0          1  1  0
#> SRR1168720     1       0          1  1  0
#> SRR1168721     1       0          1  1  0
#> SRR1168722     1       0          1  1  0
#> SRR1168723     1       0          1  1  0
#> SRR1168724     1       0          1  1  0
#> SRR1168725     1       0          1  1  0
#> SRR1168726     1       0          1  1  0
#> SRR1168727     1       0          1  1  0
#> SRR1168728     1       0          1  1  0
#> SRR1168729     1       0          1  1  0
#> SRR1168730     1       0          1  1  0
#> SRR1168731     1       0          1  1  0
#> SRR1168732     1       0          1  1  0
#> SRR1168733     2       0          1  0  1
#> SRR1168734     2       0          1  0  1
#> SRR1168735     2       0          1  0  1
#> SRR1168736     2       0          1  0  1
#> SRR1168737     2       0          1  0  1
#> SRR1168738     2       0          1  0  1
#> SRR1168739     2       0          1  0  1
#> SRR1168740     2       0          1  0  1
#> SRR1168741     2       0          1  0  1
#> SRR1168742     2       0          1  0  1
#> SRR1168743     2       0          1  0  1
#> SRR1168744     2       0          1  0  1
#> SRR1168745     2       0          1  0  1
#> SRR1168746     2       0          1  0  1
#> SRR1168747     2       0          1  0  1
#> SRR1168748     2       0          1  0  1
#> SRR1168749     2       0          1  0  1
#> SRR1168750     2       0          1  0  1
#> SRR1168751     2       0          1  0  1
#> SRR1168752     2       0          1  0  1
#> SRR1168753     2       0          1  0  1
#> SRR1168754     2       0          1  0  1
#> SRR1168755     2       0          1  0  1
#> SRR1168756     2       0          1  0  1
#> SRR1168757     2       0          1  0  1
#> SRR1168758     2       0          1  0  1
#> SRR1168759     2       0          1  0  1
#> SRR1168760     2       0          1  0  1
#> SRR1168761     1       0          1  1  0
#> SRR1168762     1       0          1  1  0
#> SRR1168763     1       0          1  1  0
#> SRR1168764     1       0          1  1  0
#> SRR1168765     1       0          1  1  0
#> SRR1168766     1       0          1  1  0
#> SRR1168767     1       0          1  1  0
#> SRR1168768     1       0          1  1  0
#> SRR1168769     1       0          1  1  0
#> SRR1168770     1       0          1  1  0
#> SRR1168771     1       0          1  1  0
#> SRR1168772     1       0          1  1  0
#> SRR1168773     1       0          1  1  0
#> SRR1168774     1       0          1  1  0
#> SRR1168775     1       0          1  1  0
#> SRR1168776     1       0          1  1  0
#> SRR1168777     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1168715     3   0.355      0.841 0.132 0.000 0.868
#> SRR1168716     3   0.355      0.841 0.132 0.000 0.868
#> SRR1168717     3   0.355      0.841 0.132 0.000 0.868
#> SRR1168718     3   0.355      0.841 0.132 0.000 0.868
#> SRR1168719     3   0.355      0.841 0.132 0.000 0.868
#> SRR1168720     3   0.355      0.841 0.132 0.000 0.868
#> SRR1168721     3   0.355      0.841 0.132 0.000 0.868
#> SRR1168722     1   0.617      0.830 0.588 0.000 0.412
#> SRR1168723     1   0.617      0.830 0.588 0.000 0.412
#> SRR1168724     1   0.617      0.830 0.588 0.000 0.412
#> SRR1168725     1   0.617      0.830 0.588 0.000 0.412
#> SRR1168726     1   0.617      0.830 0.588 0.000 0.412
#> SRR1168727     1   0.617      0.830 0.588 0.000 0.412
#> SRR1168728     1   0.617      0.830 0.588 0.000 0.412
#> SRR1168729     1   0.617      0.830 0.588 0.000 0.412
#> SRR1168730     1   0.617      0.830 0.588 0.000 0.412
#> SRR1168731     1   0.617      0.830 0.588 0.000 0.412
#> SRR1168732     1   0.617      0.830 0.588 0.000 0.412
#> SRR1168733     2   0.000      0.840 0.000 1.000 0.000
#> SRR1168734     2   0.000      0.840 0.000 1.000 0.000
#> SRR1168735     2   0.000      0.840 0.000 1.000 0.000
#> SRR1168736     2   0.000      0.840 0.000 1.000 0.000
#> SRR1168737     2   0.000      0.840 0.000 1.000 0.000
#> SRR1168738     2   0.000      0.840 0.000 1.000 0.000
#> SRR1168739     2   0.000      0.840 0.000 1.000 0.000
#> SRR1168740     2   0.000      0.840 0.000 1.000 0.000
#> SRR1168741     2   0.000      0.840 0.000 1.000 0.000
#> SRR1168742     2   0.000      0.840 0.000 1.000 0.000
#> SRR1168743     2   0.000      0.840 0.000 1.000 0.000
#> SRR1168744     2   0.000      0.840 0.000 1.000 0.000
#> SRR1168745     2   0.000      0.840 0.000 1.000 0.000
#> SRR1168746     2   0.000      0.840 0.000 1.000 0.000
#> SRR1168747     2   0.593      0.840 0.356 0.644 0.000
#> SRR1168748     2   0.593      0.840 0.356 0.644 0.000
#> SRR1168749     2   0.593      0.840 0.356 0.644 0.000
#> SRR1168750     2   0.593      0.840 0.356 0.644 0.000
#> SRR1168751     2   0.593      0.840 0.356 0.644 0.000
#> SRR1168752     2   0.593      0.840 0.356 0.644 0.000
#> SRR1168753     2   0.593      0.840 0.356 0.644 0.000
#> SRR1168754     2   0.593      0.840 0.356 0.644 0.000
#> SRR1168755     2   0.593      0.840 0.356 0.644 0.000
#> SRR1168756     2   0.593      0.840 0.356 0.644 0.000
#> SRR1168757     2   0.593      0.840 0.356 0.644 0.000
#> SRR1168758     2   0.593      0.840 0.356 0.644 0.000
#> SRR1168759     2   0.593      0.840 0.356 0.644 0.000
#> SRR1168760     2   0.593      0.840 0.356 0.644 0.000
#> SRR1168761     3   0.000      0.863 0.000 0.000 1.000
#> SRR1168762     3   0.000      0.863 0.000 0.000 1.000
#> SRR1168763     3   0.000      0.863 0.000 0.000 1.000
#> SRR1168764     3   0.000      0.863 0.000 0.000 1.000
#> SRR1168765     3   0.000      0.863 0.000 0.000 1.000
#> SRR1168766     3   0.000      0.863 0.000 0.000 1.000
#> SRR1168767     3   0.000      0.863 0.000 0.000 1.000
#> SRR1168768     3   0.000      0.863 0.000 0.000 1.000
#> SRR1168769     1   0.631      0.799 0.512 0.000 0.488
#> SRR1168770     1   0.631      0.799 0.512 0.000 0.488
#> SRR1168771     1   0.631      0.799 0.512 0.000 0.488
#> SRR1168772     1   0.631      0.799 0.512 0.000 0.488
#> SRR1168773     1   0.631      0.799 0.512 0.000 0.488
#> SRR1168774     1   0.631      0.799 0.512 0.000 0.488
#> SRR1168775     1   0.631      0.799 0.512 0.000 0.488
#> SRR1168776     1   0.631      0.799 0.512 0.000 0.488
#> SRR1168777     1   0.631      0.799 0.512 0.000 0.488

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1168715     3  0.2589      0.785 0.116 0.000 0.884 0.000
#> SRR1168716     3  0.2589      0.785 0.116 0.000 0.884 0.000
#> SRR1168717     3  0.2589      0.785 0.116 0.000 0.884 0.000
#> SRR1168718     3  0.2589      0.785 0.116 0.000 0.884 0.000
#> SRR1168719     3  0.2589      0.785 0.116 0.000 0.884 0.000
#> SRR1168720     3  0.2589      0.785 0.116 0.000 0.884 0.000
#> SRR1168721     3  0.2589      0.785 0.116 0.000 0.884 0.000
#> SRR1168722     1  0.3528      0.764 0.808 0.000 0.192 0.000
#> SRR1168723     1  0.3528      0.764 0.808 0.000 0.192 0.000
#> SRR1168724     1  0.3528      0.764 0.808 0.000 0.192 0.000
#> SRR1168725     1  0.3528      0.764 0.808 0.000 0.192 0.000
#> SRR1168726     1  0.3528      0.764 0.808 0.000 0.192 0.000
#> SRR1168727     1  0.3528      0.764 0.808 0.000 0.192 0.000
#> SRR1168728     1  0.3528      0.764 0.808 0.000 0.192 0.000
#> SRR1168729     1  0.3528      0.764 0.808 0.000 0.192 0.000
#> SRR1168730     1  0.3528      0.764 0.808 0.000 0.192 0.000
#> SRR1168731     1  0.3528      0.764 0.808 0.000 0.192 0.000
#> SRR1168732     1  0.3528      0.764 0.808 0.000 0.192 0.000
#> SRR1168733     2  0.5300      0.970 0.012 0.580 0.000 0.408
#> SRR1168734     2  0.6214      0.958 0.056 0.536 0.000 0.408
#> SRR1168735     2  0.5775      0.970 0.032 0.560 0.000 0.408
#> SRR1168736     2  0.5856      0.968 0.036 0.556 0.000 0.408
#> SRR1168737     2  0.5508      0.970 0.020 0.572 0.000 0.408
#> SRR1168738     2  0.6007      0.961 0.044 0.548 0.000 0.408
#> SRR1168739     2  0.5408      0.973 0.016 0.576 0.000 0.408
#> SRR1168740     2  0.5933      0.968 0.040 0.552 0.000 0.408
#> SRR1168741     2  0.5775      0.967 0.032 0.560 0.000 0.408
#> SRR1168742     2  0.5602      0.971 0.024 0.568 0.000 0.408
#> SRR1168743     2  0.5933      0.969 0.040 0.552 0.000 0.408
#> SRR1168744     2  0.6007      0.960 0.044 0.548 0.000 0.408
#> SRR1168745     2  0.5602      0.971 0.024 0.568 0.000 0.408
#> SRR1168746     2  0.5691      0.971 0.028 0.564 0.000 0.408
#> SRR1168747     4  0.1716      0.964 0.064 0.000 0.000 0.936
#> SRR1168748     4  0.1022      0.971 0.032 0.000 0.000 0.968
#> SRR1168749     4  0.0817      0.969 0.024 0.000 0.000 0.976
#> SRR1168750     4  0.0921      0.968 0.028 0.000 0.000 0.972
#> SRR1168751     4  0.1474      0.965 0.052 0.000 0.000 0.948
#> SRR1168752     4  0.1211      0.959 0.040 0.000 0.000 0.960
#> SRR1168753     4  0.1022      0.967 0.032 0.000 0.000 0.968
#> SRR1168754     4  0.0707      0.971 0.020 0.000 0.000 0.980
#> SRR1168755     4  0.1716      0.964 0.064 0.000 0.000 0.936
#> SRR1168756     4  0.1118      0.968 0.036 0.000 0.000 0.964
#> SRR1168757     4  0.1302      0.967 0.044 0.000 0.000 0.956
#> SRR1168758     4  0.0921      0.968 0.028 0.000 0.000 0.972
#> SRR1168759     4  0.1022      0.970 0.032 0.000 0.000 0.968
#> SRR1168760     4  0.0000      0.970 0.000 0.000 0.000 1.000
#> SRR1168761     3  0.3486      0.814 0.000 0.188 0.812 0.000
#> SRR1168762     3  0.3486      0.814 0.000 0.188 0.812 0.000
#> SRR1168763     3  0.3486      0.814 0.000 0.188 0.812 0.000
#> SRR1168764     3  0.3486      0.814 0.000 0.188 0.812 0.000
#> SRR1168765     3  0.3486      0.814 0.000 0.188 0.812 0.000
#> SRR1168766     3  0.3486      0.814 0.000 0.188 0.812 0.000
#> SRR1168767     3  0.3486      0.814 0.000 0.188 0.812 0.000
#> SRR1168768     3  0.3486      0.814 0.000 0.188 0.812 0.000
#> SRR1168769     1  0.7756      0.693 0.436 0.268 0.296 0.000
#> SRR1168770     1  0.7756      0.693 0.436 0.268 0.296 0.000
#> SRR1168771     1  0.7756      0.693 0.436 0.268 0.296 0.000
#> SRR1168772     1  0.7756      0.693 0.436 0.268 0.296 0.000
#> SRR1168773     1  0.7756      0.693 0.436 0.268 0.296 0.000
#> SRR1168774     1  0.7756      0.693 0.436 0.268 0.296 0.000
#> SRR1168775     1  0.7756      0.693 0.436 0.268 0.296 0.000
#> SRR1168776     1  0.7756      0.693 0.436 0.268 0.296 0.000
#> SRR1168777     1  0.7756      0.693 0.436 0.268 0.296 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4 p5
#> SRR1168715     3  0.6679      0.750 0.220 0.000 0.464 0.004 NA
#> SRR1168716     3  0.6679      0.750 0.220 0.000 0.464 0.004 NA
#> SRR1168717     3  0.6545      0.750 0.220 0.000 0.464 0.000 NA
#> SRR1168718     3  0.6545      0.750 0.220 0.000 0.464 0.000 NA
#> SRR1168719     3  0.6679      0.750 0.220 0.000 0.464 0.004 NA
#> SRR1168720     3  0.6545      0.750 0.220 0.000 0.464 0.000 NA
#> SRR1168721     3  0.6939      0.748 0.220 0.000 0.464 0.016 NA
#> SRR1168722     1  0.0162      0.689 0.996 0.000 0.000 0.004 NA
#> SRR1168723     1  0.0404      0.688 0.988 0.000 0.000 0.012 NA
#> SRR1168724     1  0.0510      0.688 0.984 0.000 0.000 0.016 NA
#> SRR1168725     1  0.0162      0.689 0.996 0.000 0.000 0.004 NA
#> SRR1168726     1  0.0290      0.689 0.992 0.000 0.000 0.008 NA
#> SRR1168727     1  0.0000      0.689 1.000 0.000 0.000 0.000 NA
#> SRR1168728     1  0.0404      0.689 0.988 0.000 0.000 0.012 NA
#> SRR1168729     1  0.0290      0.689 0.992 0.000 0.000 0.008 NA
#> SRR1168730     1  0.0290      0.689 0.992 0.000 0.000 0.008 NA
#> SRR1168731     1  0.0162      0.689 0.996 0.000 0.000 0.004 NA
#> SRR1168732     1  0.0404      0.689 0.988 0.000 0.000 0.012 NA
#> SRR1168733     2  0.1106      0.951 0.000 0.964 0.012 0.000 NA
#> SRR1168734     2  0.2770      0.925 0.000 0.880 0.044 0.000 NA
#> SRR1168735     2  0.1579      0.952 0.000 0.944 0.024 0.000 NA
#> SRR1168736     2  0.2362      0.944 0.000 0.900 0.024 0.000 NA
#> SRR1168737     2  0.1668      0.949 0.000 0.940 0.028 0.000 NA
#> SRR1168738     2  0.2153      0.942 0.000 0.916 0.040 0.000 NA
#> SRR1168739     2  0.0404      0.954 0.000 0.988 0.000 0.000 NA
#> SRR1168740     2  0.2388      0.943 0.000 0.900 0.028 0.000 NA
#> SRR1168741     2  0.1310      0.946 0.000 0.956 0.024 0.000 NA
#> SRR1168742     2  0.1661      0.949 0.000 0.940 0.036 0.000 NA
#> SRR1168743     2  0.1753      0.951 0.000 0.936 0.032 0.000 NA
#> SRR1168744     2  0.2304      0.935 0.000 0.908 0.048 0.000 NA
#> SRR1168745     2  0.1012      0.950 0.000 0.968 0.012 0.000 NA
#> SRR1168746     2  0.1364      0.952 0.000 0.952 0.012 0.000 NA
#> SRR1168747     4  0.5729      0.926 0.000 0.264 0.004 0.616 NA
#> SRR1168748     4  0.5087      0.934 0.000 0.264 0.008 0.672 NA
#> SRR1168749     4  0.5210      0.931 0.000 0.264 0.000 0.652 NA
#> SRR1168750     4  0.5148      0.930 0.000 0.264 0.008 0.668 NA
#> SRR1168751     4  0.5412      0.927 0.000 0.264 0.004 0.644 NA
#> SRR1168752     4  0.6581      0.889 0.000 0.264 0.028 0.560 NA
#> SRR1168753     4  0.5775      0.925 0.000 0.264 0.016 0.628 NA
#> SRR1168754     4  0.5404      0.934 0.000 0.264 0.000 0.636 NA
#> SRR1168755     4  0.6176      0.925 0.000 0.264 0.012 0.584 NA
#> SRR1168756     4  0.5508      0.931 0.000 0.264 0.004 0.636 NA
#> SRR1168757     4  0.5310      0.931 0.000 0.264 0.004 0.652 NA
#> SRR1168758     4  0.5264      0.927 0.000 0.264 0.008 0.660 NA
#> SRR1168759     4  0.5554      0.931 0.000 0.264 0.004 0.632 NA
#> SRR1168760     4  0.4751      0.936 0.000 0.264 0.008 0.692 NA
#> SRR1168761     3  0.3152      0.779 0.136 0.000 0.840 0.024 NA
#> SRR1168762     3  0.2471      0.781 0.136 0.000 0.864 0.000 NA
#> SRR1168763     3  0.2471      0.781 0.136 0.000 0.864 0.000 NA
#> SRR1168764     3  0.2629      0.780 0.136 0.000 0.860 0.004 NA
#> SRR1168765     3  0.2629      0.780 0.136 0.000 0.860 0.004 NA
#> SRR1168766     3  0.3061      0.779 0.136 0.000 0.844 0.020 NA
#> SRR1168767     3  0.2471      0.781 0.136 0.000 0.864 0.000 NA
#> SRR1168768     3  0.3061      0.779 0.136 0.000 0.844 0.020 NA
#> SRR1168769     1  0.7753      0.591 0.444 0.000 0.124 0.132 NA
#> SRR1168770     1  0.7710      0.592 0.444 0.000 0.124 0.124 NA
#> SRR1168771     1  0.7773      0.591 0.444 0.000 0.124 0.136 NA
#> SRR1168772     1  0.7732      0.591 0.444 0.000 0.124 0.128 NA
#> SRR1168773     1  0.7710      0.592 0.444 0.000 0.124 0.124 NA
#> SRR1168774     1  0.7826      0.590 0.444 0.000 0.124 0.148 NA
#> SRR1168775     1  0.7710      0.592 0.444 0.000 0.124 0.124 NA
#> SRR1168776     1  0.7857      0.589 0.444 0.000 0.124 0.156 NA
#> SRR1168777     1  0.7932      0.584 0.444 0.000 0.124 0.184 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
#> SRR1168715     6  0.5508      0.981 0.112 0.000 0.412 0.004 0.000 0.472
#> SRR1168716     6  0.5508      0.981 0.112 0.000 0.412 0.004 0.000 0.472
#> SRR1168717     6  0.5637      0.981 0.112 0.000 0.412 0.004 0.004 0.468
#> SRR1168718     6  0.5735      0.980 0.112 0.000 0.412 0.008 0.004 0.464
#> SRR1168719     6  0.5508      0.981 0.112 0.000 0.412 0.004 0.000 0.472
#> SRR1168720     6  0.5735      0.980 0.112 0.000 0.412 0.008 0.004 0.464
#> SRR1168721     6  0.6399      0.939 0.112 0.000 0.412 0.036 0.012 0.428
#> SRR1168722     1  0.1049      0.960 0.960 0.000 0.000 0.000 0.032 0.008
#> SRR1168723     1  0.0520      0.962 0.984 0.000 0.000 0.000 0.008 0.008
#> SRR1168724     1  0.1906      0.931 0.924 0.000 0.000 0.008 0.036 0.032
#> SRR1168725     1  0.1196      0.960 0.952 0.000 0.000 0.000 0.040 0.008
#> SRR1168726     1  0.0405      0.962 0.988 0.000 0.000 0.000 0.008 0.004
#> SRR1168727     1  0.0000      0.963 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1168728     1  0.1675      0.953 0.936 0.000 0.000 0.008 0.032 0.024
#> SRR1168729     1  0.1346      0.951 0.952 0.000 0.000 0.008 0.024 0.016
#> SRR1168730     1  0.0363      0.962 0.988 0.000 0.000 0.000 0.012 0.000
#> SRR1168731     1  0.0622      0.961 0.980 0.000 0.000 0.000 0.012 0.008
#> SRR1168732     1  0.1649      0.949 0.936 0.000 0.000 0.008 0.040 0.016
#> SRR1168733     2  0.1857      0.913 0.000 0.928 0.012 0.032 0.000 0.028
#> SRR1168734     2  0.3354      0.893 0.000 0.796 0.000 0.036 0.000 0.168
#> SRR1168735     2  0.2510      0.916 0.000 0.872 0.000 0.028 0.000 0.100
#> SRR1168736     2  0.2542      0.911 0.000 0.876 0.000 0.044 0.000 0.080
#> SRR1168737     2  0.3151      0.902 0.000 0.848 0.012 0.064 0.000 0.076
#> SRR1168738     2  0.2209      0.909 0.000 0.900 0.004 0.024 0.000 0.072
#> SRR1168739     2  0.1152      0.921 0.000 0.952 0.000 0.004 0.000 0.044
#> SRR1168740     2  0.3453      0.899 0.000 0.804 0.000 0.064 0.000 0.132
#> SRR1168741     2  0.3014      0.901 0.000 0.856 0.012 0.048 0.000 0.084
#> SRR1168742     2  0.2501      0.914 0.000 0.872 0.004 0.016 0.000 0.108
#> SRR1168743     2  0.3315      0.903 0.000 0.832 0.008 0.068 0.000 0.092
#> SRR1168744     2  0.2911      0.899 0.000 0.832 0.000 0.024 0.000 0.144
#> SRR1168745     2  0.1989      0.911 0.000 0.916 0.004 0.028 0.000 0.052
#> SRR1168746     2  0.1624      0.921 0.000 0.936 0.004 0.020 0.000 0.040
#> SRR1168747     5  0.5589      0.900 0.000 0.152 0.004 0.144 0.656 0.044
#> SRR1168748     5  0.4791      0.912 0.000 0.152 0.004 0.064 0.732 0.048
#> SRR1168749     5  0.4095      0.913 0.000 0.152 0.000 0.044 0.772 0.032
#> SRR1168750     5  0.5538      0.901 0.000 0.152 0.008 0.120 0.672 0.048
#> SRR1168751     5  0.5258      0.900 0.000 0.152 0.004 0.136 0.680 0.028
#> SRR1168752     5  0.6489      0.847 0.000 0.152 0.032 0.104 0.612 0.100
#> SRR1168753     5  0.4288      0.908 0.000 0.152 0.000 0.036 0.760 0.052
#> SRR1168754     5  0.5093      0.913 0.000 0.152 0.004 0.088 0.708 0.048
#> SRR1168755     5  0.5029      0.907 0.000 0.152 0.000 0.100 0.704 0.044
#> SRR1168756     5  0.5079      0.910 0.000 0.152 0.012 0.112 0.704 0.020
#> SRR1168757     5  0.5181      0.907 0.000 0.152 0.000 0.088 0.696 0.064
#> SRR1168758     5  0.5231      0.903 0.000 0.152 0.008 0.108 0.696 0.036
#> SRR1168759     5  0.4734      0.912 0.000 0.152 0.000 0.080 0.728 0.040
#> SRR1168760     5  0.4304      0.913 0.000 0.152 0.004 0.044 0.764 0.036
#> SRR1168761     3  0.2263      0.961 0.060 0.000 0.900 0.004 0.036 0.000
#> SRR1168762     3  0.1719      0.970 0.060 0.000 0.924 0.000 0.016 0.000
#> SRR1168763     3  0.1411      0.973 0.060 0.000 0.936 0.000 0.004 0.000
#> SRR1168764     3  0.1524      0.972 0.060 0.000 0.932 0.008 0.000 0.000
#> SRR1168765     3  0.1411      0.973 0.060 0.000 0.936 0.004 0.000 0.000
#> SRR1168766     3  0.2263      0.962 0.060 0.000 0.900 0.004 0.036 0.000
#> SRR1168767     3  0.1524      0.972 0.060 0.000 0.932 0.008 0.000 0.000
#> SRR1168768     3  0.2226      0.962 0.060 0.000 0.904 0.008 0.028 0.000
#> SRR1168769     4  0.5531      0.979 0.380 0.000 0.084 0.520 0.004 0.012
#> SRR1168770     4  0.5311      0.980 0.380 0.000 0.084 0.528 0.000 0.008
#> SRR1168771     4  0.5756      0.974 0.380 0.000 0.084 0.508 0.004 0.024
#> SRR1168772     4  0.5823      0.972 0.380 0.000 0.084 0.504 0.004 0.028
#> SRR1168773     4  0.5079      0.981 0.380 0.000 0.084 0.536 0.000 0.000
#> SRR1168774     4  0.5531      0.979 0.380 0.000 0.084 0.520 0.004 0.012
#> SRR1168775     4  0.5311      0.980 0.380 0.000 0.084 0.528 0.000 0.008
#> SRR1168776     4  0.5311      0.980 0.380 0.000 0.084 0.528 0.000 0.008
#> SRR1168777     4  0.6163      0.957 0.380 0.000 0.084 0.488 0.020 0.028

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

consensus_heatmap(res, k = 2)

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

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

collect_plots(res)

plot of chunk SD-skmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.5023 0.498   0.498
#> 3 3 1.000           0.994       0.992         0.3047 0.846   0.692
#> 4 4 0.820           0.952       0.906         0.0852 0.949   0.853
#> 5 5 0.871           0.897       0.835         0.0756 0.971   0.902
#> 6 6 0.885           0.995       0.959         0.0707 0.900   0.622

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
#> SRR1168715     1       0          1  1  0
#> SRR1168716     1       0          1  1  0
#> SRR1168717     1       0          1  1  0
#> SRR1168718     1       0          1  1  0
#> SRR1168719     1       0          1  1  0
#> SRR1168720     1       0          1  1  0
#> SRR1168721     1       0          1  1  0
#> SRR1168722     1       0          1  1  0
#> SRR1168723     1       0          1  1  0
#> SRR1168724     1       0          1  1  0
#> SRR1168725     1       0          1  1  0
#> SRR1168726     1       0          1  1  0
#> SRR1168727     1       0          1  1  0
#> SRR1168728     1       0          1  1  0
#> SRR1168729     1       0          1  1  0
#> SRR1168730     1       0          1  1  0
#> SRR1168731     1       0          1  1  0
#> SRR1168732     1       0          1  1  0
#> SRR1168733     2       0          1  0  1
#> SRR1168734     2       0          1  0  1
#> SRR1168735     2       0          1  0  1
#> SRR1168736     2       0          1  0  1
#> SRR1168737     2       0          1  0  1
#> SRR1168738     2       0          1  0  1
#> SRR1168739     2       0          1  0  1
#> SRR1168740     2       0          1  0  1
#> SRR1168741     2       0          1  0  1
#> SRR1168742     2       0          1  0  1
#> SRR1168743     2       0          1  0  1
#> SRR1168744     2       0          1  0  1
#> SRR1168745     2       0          1  0  1
#> SRR1168746     2       0          1  0  1
#> SRR1168747     2       0          1  0  1
#> SRR1168748     2       0          1  0  1
#> SRR1168749     2       0          1  0  1
#> SRR1168750     2       0          1  0  1
#> SRR1168751     2       0          1  0  1
#> SRR1168752     2       0          1  0  1
#> SRR1168753     2       0          1  0  1
#> SRR1168754     2       0          1  0  1
#> SRR1168755     2       0          1  0  1
#> SRR1168756     2       0          1  0  1
#> SRR1168757     2       0          1  0  1
#> SRR1168758     2       0          1  0  1
#> SRR1168759     2       0          1  0  1
#> SRR1168760     2       0          1  0  1
#> SRR1168761     1       0          1  1  0
#> SRR1168762     1       0          1  1  0
#> SRR1168763     1       0          1  1  0
#> SRR1168764     1       0          1  1  0
#> SRR1168765     1       0          1  1  0
#> SRR1168766     1       0          1  1  0
#> SRR1168767     1       0          1  1  0
#> SRR1168768     1       0          1  1  0
#> SRR1168769     1       0          1  1  0
#> SRR1168770     1       0          1  1  0
#> SRR1168771     1       0          1  1  0
#> SRR1168772     1       0          1  1  0
#> SRR1168773     1       0          1  1  0
#> SRR1168774     1       0          1  1  0
#> SRR1168775     1       0          1  1  0
#> SRR1168776     1       0          1  1  0
#> SRR1168777     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1168715     3  0.1031      0.991 0.024 0.000 0.976
#> SRR1168716     3  0.1031      0.991 0.024 0.000 0.976
#> SRR1168717     3  0.1031      0.991 0.024 0.000 0.976
#> SRR1168718     3  0.1031      0.991 0.024 0.000 0.976
#> SRR1168719     3  0.1031      0.991 0.024 0.000 0.976
#> SRR1168720     3  0.1031      0.991 0.024 0.000 0.976
#> SRR1168721     3  0.1031      0.991 0.024 0.000 0.976
#> SRR1168722     1  0.0000      0.992 1.000 0.000 0.000
#> SRR1168723     1  0.0000      0.992 1.000 0.000 0.000
#> SRR1168724     1  0.0000      0.992 1.000 0.000 0.000
#> SRR1168725     1  0.0000      0.992 1.000 0.000 0.000
#> SRR1168726     1  0.0000      0.992 1.000 0.000 0.000
#> SRR1168727     1  0.0000      0.992 1.000 0.000 0.000
#> SRR1168728     1  0.0000      0.992 1.000 0.000 0.000
#> SRR1168729     1  0.0000      0.992 1.000 0.000 0.000
#> SRR1168730     1  0.0000      0.992 1.000 0.000 0.000
#> SRR1168731     1  0.0000      0.992 1.000 0.000 0.000
#> SRR1168732     1  0.0000      0.992 1.000 0.000 0.000
#> SRR1168733     2  0.0000      0.997 0.000 1.000 0.000
#> SRR1168734     2  0.0000      0.997 0.000 1.000 0.000
#> SRR1168735     2  0.0000      0.997 0.000 1.000 0.000
#> SRR1168736     2  0.0000      0.997 0.000 1.000 0.000
#> SRR1168737     2  0.0000      0.997 0.000 1.000 0.000
#> SRR1168738     2  0.0000      0.997 0.000 1.000 0.000
#> SRR1168739     2  0.0000      0.997 0.000 1.000 0.000
#> SRR1168740     2  0.0000      0.997 0.000 1.000 0.000
#> SRR1168741     2  0.0000      0.997 0.000 1.000 0.000
#> SRR1168742     2  0.0000      0.997 0.000 1.000 0.000
#> SRR1168743     2  0.0000      0.997 0.000 1.000 0.000
#> SRR1168744     2  0.0000      0.997 0.000 1.000 0.000
#> SRR1168745     2  0.0000      0.997 0.000 1.000 0.000
#> SRR1168746     2  0.0000      0.997 0.000 1.000 0.000
#> SRR1168747     2  0.0424      0.997 0.000 0.992 0.008
#> SRR1168748     2  0.0424      0.997 0.000 0.992 0.008
#> SRR1168749     2  0.0424      0.997 0.000 0.992 0.008
#> SRR1168750     2  0.0424      0.997 0.000 0.992 0.008
#> SRR1168751     2  0.0424      0.997 0.000 0.992 0.008
#> SRR1168752     2  0.0424      0.997 0.000 0.992 0.008
#> SRR1168753     2  0.0424      0.997 0.000 0.992 0.008
#> SRR1168754     2  0.0424      0.997 0.000 0.992 0.008
#> SRR1168755     2  0.0424      0.997 0.000 0.992 0.008
#> SRR1168756     2  0.0424      0.997 0.000 0.992 0.008
#> SRR1168757     2  0.0424      0.997 0.000 0.992 0.008
#> SRR1168758     2  0.0424      0.997 0.000 0.992 0.008
#> SRR1168759     2  0.0424      0.997 0.000 0.992 0.008
#> SRR1168760     2  0.0424      0.997 0.000 0.992 0.008
#> SRR1168761     3  0.0424      0.992 0.008 0.000 0.992
#> SRR1168762     3  0.0424      0.992 0.008 0.000 0.992
#> SRR1168763     3  0.0424      0.992 0.008 0.000 0.992
#> SRR1168764     3  0.0424      0.992 0.008 0.000 0.992
#> SRR1168765     3  0.0424      0.992 0.008 0.000 0.992
#> SRR1168766     3  0.0424      0.992 0.008 0.000 0.992
#> SRR1168767     3  0.0424      0.992 0.008 0.000 0.992
#> SRR1168768     3  0.0424      0.992 0.008 0.000 0.992
#> SRR1168769     1  0.0747      0.991 0.984 0.000 0.016
#> SRR1168770     1  0.0747      0.991 0.984 0.000 0.016
#> SRR1168771     1  0.0747      0.991 0.984 0.000 0.016
#> SRR1168772     1  0.0747      0.991 0.984 0.000 0.016
#> SRR1168773     1  0.0747      0.991 0.984 0.000 0.016
#> SRR1168774     1  0.0747      0.991 0.984 0.000 0.016
#> SRR1168775     1  0.0747      0.991 0.984 0.000 0.016
#> SRR1168776     1  0.0747      0.991 0.984 0.000 0.016
#> SRR1168777     1  0.0747      0.991 0.984 0.000 0.016

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette  p1   p2   p3   p4
#> SRR1168715     3   0.292      0.935 0.0 0.00 0.86 0.14
#> SRR1168716     3   0.292      0.935 0.0 0.00 0.86 0.14
#> SRR1168717     3   0.292      0.935 0.0 0.00 0.86 0.14
#> SRR1168718     3   0.292      0.935 0.0 0.00 0.86 0.14
#> SRR1168719     3   0.292      0.935 0.0 0.00 0.86 0.14
#> SRR1168720     3   0.292      0.935 0.0 0.00 0.86 0.14
#> SRR1168721     3   0.292      0.935 0.0 0.00 0.86 0.14
#> SRR1168722     1   0.000      1.000 1.0 0.00 0.00 0.00
#> SRR1168723     1   0.000      1.000 1.0 0.00 0.00 0.00
#> SRR1168724     1   0.000      1.000 1.0 0.00 0.00 0.00
#> SRR1168725     1   0.000      1.000 1.0 0.00 0.00 0.00
#> SRR1168726     1   0.000      1.000 1.0 0.00 0.00 0.00
#> SRR1168727     1   0.000      1.000 1.0 0.00 0.00 0.00
#> SRR1168728     1   0.000      1.000 1.0 0.00 0.00 0.00
#> SRR1168729     1   0.000      1.000 1.0 0.00 0.00 0.00
#> SRR1168730     1   0.000      1.000 1.0 0.00 0.00 0.00
#> SRR1168731     1   0.000      1.000 1.0 0.00 0.00 0.00
#> SRR1168732     1   0.000      1.000 1.0 0.00 0.00 0.00
#> SRR1168733     2   0.317      0.925 0.0 0.84 0.00 0.16
#> SRR1168734     2   0.317      0.925 0.0 0.84 0.00 0.16
#> SRR1168735     2   0.317      0.925 0.0 0.84 0.00 0.16
#> SRR1168736     2   0.317      0.925 0.0 0.84 0.00 0.16
#> SRR1168737     2   0.317      0.925 0.0 0.84 0.00 0.16
#> SRR1168738     2   0.317      0.925 0.0 0.84 0.00 0.16
#> SRR1168739     2   0.317      0.925 0.0 0.84 0.00 0.16
#> SRR1168740     2   0.317      0.925 0.0 0.84 0.00 0.16
#> SRR1168741     2   0.317      0.925 0.0 0.84 0.00 0.16
#> SRR1168742     2   0.317      0.925 0.0 0.84 0.00 0.16
#> SRR1168743     2   0.317      0.925 0.0 0.84 0.00 0.16
#> SRR1168744     2   0.317      0.925 0.0 0.84 0.00 0.16
#> SRR1168745     2   0.317      0.925 0.0 0.84 0.00 0.16
#> SRR1168746     2   0.317      0.925 0.0 0.84 0.00 0.16
#> SRR1168747     2   0.000      0.925 0.0 1.00 0.00 0.00
#> SRR1168748     2   0.000      0.925 0.0 1.00 0.00 0.00
#> SRR1168749     2   0.000      0.925 0.0 1.00 0.00 0.00
#> SRR1168750     2   0.000      0.925 0.0 1.00 0.00 0.00
#> SRR1168751     2   0.000      0.925 0.0 1.00 0.00 0.00
#> SRR1168752     2   0.000      0.925 0.0 1.00 0.00 0.00
#> SRR1168753     2   0.000      0.925 0.0 1.00 0.00 0.00
#> SRR1168754     2   0.000      0.925 0.0 1.00 0.00 0.00
#> SRR1168755     2   0.000      0.925 0.0 1.00 0.00 0.00
#> SRR1168756     2   0.000      0.925 0.0 1.00 0.00 0.00
#> SRR1168757     2   0.000      0.925 0.0 1.00 0.00 0.00
#> SRR1168758     2   0.000      0.925 0.0 1.00 0.00 0.00
#> SRR1168759     2   0.000      0.925 0.0 1.00 0.00 0.00
#> SRR1168760     2   0.000      0.925 0.0 1.00 0.00 0.00
#> SRR1168761     3   0.000      0.944 0.0 0.00 1.00 0.00
#> SRR1168762     3   0.000      0.944 0.0 0.00 1.00 0.00
#> SRR1168763     3   0.000      0.944 0.0 0.00 1.00 0.00
#> SRR1168764     3   0.000      0.944 0.0 0.00 1.00 0.00
#> SRR1168765     3   0.000      0.944 0.0 0.00 1.00 0.00
#> SRR1168766     3   0.000      0.944 0.0 0.00 1.00 0.00
#> SRR1168767     3   0.000      0.944 0.0 0.00 1.00 0.00
#> SRR1168768     3   0.000      0.944 0.0 0.00 1.00 0.00
#> SRR1168769     4   0.441      1.000 0.3 0.00 0.00 0.70
#> SRR1168770     4   0.441      1.000 0.3 0.00 0.00 0.70
#> SRR1168771     4   0.441      1.000 0.3 0.00 0.00 0.70
#> SRR1168772     4   0.441      1.000 0.3 0.00 0.00 0.70
#> SRR1168773     4   0.441      1.000 0.3 0.00 0.00 0.70
#> SRR1168774     4   0.441      1.000 0.3 0.00 0.00 0.70
#> SRR1168775     4   0.441      1.000 0.3 0.00 0.00 0.70
#> SRR1168776     4   0.441      1.000 0.3 0.00 0.00 0.70
#> SRR1168777     4   0.441      1.000 0.3 0.00 0.00 0.70

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3   p4    p5
#> SRR1168715     5   0.000      1.000 0.000 0.000 0.000 0.00 1.000
#> SRR1168716     5   0.000      1.000 0.000 0.000 0.000 0.00 1.000
#> SRR1168717     5   0.000      1.000 0.000 0.000 0.000 0.00 1.000
#> SRR1168718     5   0.000      1.000 0.000 0.000 0.000 0.00 1.000
#> SRR1168719     5   0.000      1.000 0.000 0.000 0.000 0.00 1.000
#> SRR1168720     5   0.000      1.000 0.000 0.000 0.000 0.00 1.000
#> SRR1168721     5   0.000      1.000 0.000 0.000 0.000 0.00 1.000
#> SRR1168722     1   0.534      1.000 0.564 0.000 0.376 0.06 0.000
#> SRR1168723     1   0.534      1.000 0.564 0.000 0.376 0.06 0.000
#> SRR1168724     1   0.534      1.000 0.564 0.000 0.376 0.06 0.000
#> SRR1168725     1   0.534      1.000 0.564 0.000 0.376 0.06 0.000
#> SRR1168726     1   0.534      1.000 0.564 0.000 0.376 0.06 0.000
#> SRR1168727     1   0.534      1.000 0.564 0.000 0.376 0.06 0.000
#> SRR1168728     1   0.534      1.000 0.564 0.000 0.376 0.06 0.000
#> SRR1168729     1   0.534      1.000 0.564 0.000 0.376 0.06 0.000
#> SRR1168730     1   0.534      1.000 0.564 0.000 0.376 0.06 0.000
#> SRR1168731     1   0.534      1.000 0.564 0.000 0.376 0.06 0.000
#> SRR1168732     1   0.534      1.000 0.564 0.000 0.376 0.06 0.000
#> SRR1168733     2   0.000      0.768 0.000 1.000 0.000 0.00 0.000
#> SRR1168734     2   0.000      0.768 0.000 1.000 0.000 0.00 0.000
#> SRR1168735     2   0.000      0.768 0.000 1.000 0.000 0.00 0.000
#> SRR1168736     2   0.000      0.768 0.000 1.000 0.000 0.00 0.000
#> SRR1168737     2   0.000      0.768 0.000 1.000 0.000 0.00 0.000
#> SRR1168738     2   0.000      0.768 0.000 1.000 0.000 0.00 0.000
#> SRR1168739     2   0.000      0.768 0.000 1.000 0.000 0.00 0.000
#> SRR1168740     2   0.000      0.768 0.000 1.000 0.000 0.00 0.000
#> SRR1168741     2   0.000      0.768 0.000 1.000 0.000 0.00 0.000
#> SRR1168742     2   0.000      0.768 0.000 1.000 0.000 0.00 0.000
#> SRR1168743     2   0.000      0.768 0.000 1.000 0.000 0.00 0.000
#> SRR1168744     2   0.000      0.768 0.000 1.000 0.000 0.00 0.000
#> SRR1168745     2   0.000      0.768 0.000 1.000 0.000 0.00 0.000
#> SRR1168746     2   0.000      0.768 0.000 1.000 0.000 0.00 0.000
#> SRR1168747     2   0.426      0.768 0.436 0.564 0.000 0.00 0.000
#> SRR1168748     2   0.426      0.768 0.436 0.564 0.000 0.00 0.000
#> SRR1168749     2   0.426      0.768 0.436 0.564 0.000 0.00 0.000
#> SRR1168750     2   0.426      0.768 0.436 0.564 0.000 0.00 0.000
#> SRR1168751     2   0.426      0.768 0.436 0.564 0.000 0.00 0.000
#> SRR1168752     2   0.426      0.768 0.436 0.564 0.000 0.00 0.000
#> SRR1168753     2   0.426      0.768 0.436 0.564 0.000 0.00 0.000
#> SRR1168754     2   0.426      0.768 0.436 0.564 0.000 0.00 0.000
#> SRR1168755     2   0.426      0.768 0.436 0.564 0.000 0.00 0.000
#> SRR1168756     2   0.426      0.768 0.436 0.564 0.000 0.00 0.000
#> SRR1168757     2   0.426      0.768 0.436 0.564 0.000 0.00 0.000
#> SRR1168758     2   0.426      0.768 0.436 0.564 0.000 0.00 0.000
#> SRR1168759     2   0.426      0.768 0.436 0.564 0.000 0.00 0.000
#> SRR1168760     2   0.426      0.768 0.436 0.564 0.000 0.00 0.000
#> SRR1168761     3   0.411      1.000 0.000 0.000 0.624 0.00 0.376
#> SRR1168762     3   0.411      1.000 0.000 0.000 0.624 0.00 0.376
#> SRR1168763     3   0.411      1.000 0.000 0.000 0.624 0.00 0.376
#> SRR1168764     3   0.411      1.000 0.000 0.000 0.624 0.00 0.376
#> SRR1168765     3   0.411      1.000 0.000 0.000 0.624 0.00 0.376
#> SRR1168766     3   0.411      1.000 0.000 0.000 0.624 0.00 0.376
#> SRR1168767     3   0.411      1.000 0.000 0.000 0.624 0.00 0.376
#> SRR1168768     3   0.411      1.000 0.000 0.000 0.624 0.00 0.376
#> SRR1168769     4   0.000      1.000 0.000 0.000 0.000 1.00 0.000
#> SRR1168770     4   0.000      1.000 0.000 0.000 0.000 1.00 0.000
#> SRR1168771     4   0.000      1.000 0.000 0.000 0.000 1.00 0.000
#> SRR1168772     4   0.000      1.000 0.000 0.000 0.000 1.00 0.000
#> SRR1168773     4   0.000      1.000 0.000 0.000 0.000 1.00 0.000
#> SRR1168774     4   0.000      1.000 0.000 0.000 0.000 1.00 0.000
#> SRR1168775     4   0.000      1.000 0.000 0.000 0.000 1.00 0.000
#> SRR1168776     4   0.000      1.000 0.000 0.000 0.000 1.00 0.000
#> SRR1168777     4   0.000      1.000 0.000 0.000 0.000 1.00 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette p1    p2    p3    p4    p5    p6
#> SRR1168715     6  0.0260      0.999  0 0.000 0.008 0.000 0.000 0.992
#> SRR1168716     6  0.0260      0.999  0 0.000 0.008 0.000 0.000 0.992
#> SRR1168717     6  0.0260      0.999  0 0.000 0.008 0.000 0.000 0.992
#> SRR1168718     6  0.0260      0.999  0 0.000 0.008 0.000 0.000 0.992
#> SRR1168719     6  0.0260      0.999  0 0.000 0.008 0.000 0.000 0.992
#> SRR1168720     6  0.0260      0.999  0 0.000 0.008 0.000 0.000 0.992
#> SRR1168721     6  0.0000      0.992  0 0.000 0.000 0.000 0.000 1.000
#> SRR1168722     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1168723     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1168724     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1168725     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1168726     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1168727     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1168728     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1168729     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1168730     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1168731     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1168732     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1168733     2  0.0000      1.000  0 1.000 0.000 0.000 0.000 0.000
#> SRR1168734     2  0.0000      1.000  0 1.000 0.000 0.000 0.000 0.000
#> SRR1168735     2  0.0000      1.000  0 1.000 0.000 0.000 0.000 0.000
#> SRR1168736     2  0.0000      1.000  0 1.000 0.000 0.000 0.000 0.000
#> SRR1168737     2  0.0000      1.000  0 1.000 0.000 0.000 0.000 0.000
#> SRR1168738     2  0.0000      1.000  0 1.000 0.000 0.000 0.000 0.000
#> SRR1168739     2  0.0000      1.000  0 1.000 0.000 0.000 0.000 0.000
#> SRR1168740     2  0.0000      1.000  0 1.000 0.000 0.000 0.000 0.000
#> SRR1168741     2  0.0000      1.000  0 1.000 0.000 0.000 0.000 0.000
#> SRR1168742     2  0.0000      1.000  0 1.000 0.000 0.000 0.000 0.000
#> SRR1168743     2  0.0000      1.000  0 1.000 0.000 0.000 0.000 0.000
#> SRR1168744     2  0.0000      1.000  0 1.000 0.000 0.000 0.000 0.000
#> SRR1168745     2  0.0000      1.000  0 1.000 0.000 0.000 0.000 0.000
#> SRR1168746     2  0.0000      1.000  0 1.000 0.000 0.000 0.000 0.000
#> SRR1168747     5  0.2527      1.000  0 0.168 0.000 0.000 0.832 0.000
#> SRR1168748     5  0.2527      1.000  0 0.168 0.000 0.000 0.832 0.000
#> SRR1168749     5  0.2527      1.000  0 0.168 0.000 0.000 0.832 0.000
#> SRR1168750     5  0.2527      1.000  0 0.168 0.000 0.000 0.832 0.000
#> SRR1168751     5  0.2527      1.000  0 0.168 0.000 0.000 0.832 0.000
#> SRR1168752     5  0.2527      1.000  0 0.168 0.000 0.000 0.832 0.000
#> SRR1168753     5  0.2527      1.000  0 0.168 0.000 0.000 0.832 0.000
#> SRR1168754     5  0.2527      1.000  0 0.168 0.000 0.000 0.832 0.000
#> SRR1168755     5  0.2527      1.000  0 0.168 0.000 0.000 0.832 0.000
#> SRR1168756     5  0.2527      1.000  0 0.168 0.000 0.000 0.832 0.000
#> SRR1168757     5  0.2527      1.000  0 0.168 0.000 0.000 0.832 0.000
#> SRR1168758     5  0.2527      1.000  0 0.168 0.000 0.000 0.832 0.000
#> SRR1168759     5  0.2527      1.000  0 0.168 0.000 0.000 0.832 0.000
#> SRR1168760     5  0.2527      1.000  0 0.168 0.000 0.000 0.832 0.000
#> SRR1168761     3  0.0000      1.000  0 0.000 1.000 0.000 0.000 0.000
#> SRR1168762     3  0.0000      1.000  0 0.000 1.000 0.000 0.000 0.000
#> SRR1168763     3  0.0000      1.000  0 0.000 1.000 0.000 0.000 0.000
#> SRR1168764     3  0.0000      1.000  0 0.000 1.000 0.000 0.000 0.000
#> SRR1168765     3  0.0000      1.000  0 0.000 1.000 0.000 0.000 0.000
#> SRR1168766     3  0.0000      1.000  0 0.000 1.000 0.000 0.000 0.000
#> SRR1168767     3  0.0000      1.000  0 0.000 1.000 0.000 0.000 0.000
#> SRR1168768     3  0.0000      1.000  0 0.000 1.000 0.000 0.000 0.000
#> SRR1168769     4  0.0000      0.983  0 0.000 0.000 1.000 0.000 0.000
#> SRR1168770     4  0.0000      0.983  0 0.000 0.000 1.000 0.000 0.000
#> SRR1168771     4  0.0146      0.982  0 0.000 0.000 0.996 0.004 0.000
#> SRR1168772     4  0.0000      0.983  0 0.000 0.000 1.000 0.000 0.000
#> SRR1168773     4  0.0000      0.983  0 0.000 0.000 1.000 0.000 0.000
#> SRR1168774     4  0.0146      0.982  0 0.000 0.000 0.996 0.004 0.000
#> SRR1168775     4  0.0000      0.983  0 0.000 0.000 1.000 0.000 0.000
#> SRR1168776     4  0.0146      0.982  0 0.000 0.000 0.996 0.004 0.000
#> SRR1168777     4  0.2527      0.866  0 0.000 0.000 0.832 0.168 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 14158 rows and 63 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.5023 0.498   0.498
#> 3 3 1.000           1.000       1.000         0.3055 0.846   0.692
#> 4 4 0.849           0.905       0.842         0.1093 0.949   0.853
#> 5 5 1.000           1.000       1.000         0.1089 0.900   0.659
#> 6 6 1.000           1.000       1.000         0.0355 0.971   0.852

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
#> SRR1168715     1       0          1  1  0
#> SRR1168716     1       0          1  1  0
#> SRR1168717     1       0          1  1  0
#> SRR1168718     1       0          1  1  0
#> SRR1168719     1       0          1  1  0
#> SRR1168720     1       0          1  1  0
#> SRR1168721     1       0          1  1  0
#> SRR1168722     1       0          1  1  0
#> SRR1168723     1       0          1  1  0
#> SRR1168724     1       0          1  1  0
#> SRR1168725     1       0          1  1  0
#> SRR1168726     1       0          1  1  0
#> SRR1168727     1       0          1  1  0
#> SRR1168728     1       0          1  1  0
#> SRR1168729     1       0          1  1  0
#> SRR1168730     1       0          1  1  0
#> SRR1168731     1       0          1  1  0
#> SRR1168732     1       0          1  1  0
#> SRR1168733     2       0          1  0  1
#> SRR1168734     2       0          1  0  1
#> SRR1168735     2       0          1  0  1
#> SRR1168736     2       0          1  0  1
#> SRR1168737     2       0          1  0  1
#> SRR1168738     2       0          1  0  1
#> SRR1168739     2       0          1  0  1
#> SRR1168740     2       0          1  0  1
#> SRR1168741     2       0          1  0  1
#> SRR1168742     2       0          1  0  1
#> SRR1168743     2       0          1  0  1
#> SRR1168744     2       0          1  0  1
#> SRR1168745     2       0          1  0  1
#> SRR1168746     2       0          1  0  1
#> SRR1168747     2       0          1  0  1
#> SRR1168748     2       0          1  0  1
#> SRR1168749     2       0          1  0  1
#> SRR1168750     2       0          1  0  1
#> SRR1168751     2       0          1  0  1
#> SRR1168752     2       0          1  0  1
#> SRR1168753     2       0          1  0  1
#> SRR1168754     2       0          1  0  1
#> SRR1168755     2       0          1  0  1
#> SRR1168756     2       0          1  0  1
#> SRR1168757     2       0          1  0  1
#> SRR1168758     2       0          1  0  1
#> SRR1168759     2       0          1  0  1
#> SRR1168760     2       0          1  0  1
#> SRR1168761     1       0          1  1  0
#> SRR1168762     1       0          1  1  0
#> SRR1168763     1       0          1  1  0
#> SRR1168764     1       0          1  1  0
#> SRR1168765     1       0          1  1  0
#> SRR1168766     1       0          1  1  0
#> SRR1168767     1       0          1  1  0
#> SRR1168768     1       0          1  1  0
#> SRR1168769     1       0          1  1  0
#> SRR1168770     1       0          1  1  0
#> SRR1168771     1       0          1  1  0
#> SRR1168772     1       0          1  1  0
#> SRR1168773     1       0          1  1  0
#> SRR1168774     1       0          1  1  0
#> SRR1168775     1       0          1  1  0
#> SRR1168776     1       0          1  1  0
#> SRR1168777     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette p1 p2 p3
#> SRR1168715     3       0          1  0  0  1
#> SRR1168716     3       0          1  0  0  1
#> SRR1168717     3       0          1  0  0  1
#> SRR1168718     3       0          1  0  0  1
#> SRR1168719     3       0          1  0  0  1
#> SRR1168720     3       0          1  0  0  1
#> SRR1168721     3       0          1  0  0  1
#> SRR1168722     1       0          1  1  0  0
#> SRR1168723     1       0          1  1  0  0
#> SRR1168724     1       0          1  1  0  0
#> SRR1168725     1       0          1  1  0  0
#> SRR1168726     1       0          1  1  0  0
#> SRR1168727     1       0          1  1  0  0
#> SRR1168728     1       0          1  1  0  0
#> SRR1168729     1       0          1  1  0  0
#> SRR1168730     1       0          1  1  0  0
#> SRR1168731     1       0          1  1  0  0
#> SRR1168732     1       0          1  1  0  0
#> SRR1168733     2       0          1  0  1  0
#> SRR1168734     2       0          1  0  1  0
#> SRR1168735     2       0          1  0  1  0
#> SRR1168736     2       0          1  0  1  0
#> SRR1168737     2       0          1  0  1  0
#> SRR1168738     2       0          1  0  1  0
#> SRR1168739     2       0          1  0  1  0
#> SRR1168740     2       0          1  0  1  0
#> SRR1168741     2       0          1  0  1  0
#> SRR1168742     2       0          1  0  1  0
#> SRR1168743     2       0          1  0  1  0
#> SRR1168744     2       0          1  0  1  0
#> SRR1168745     2       0          1  0  1  0
#> SRR1168746     2       0          1  0  1  0
#> SRR1168747     2       0          1  0  1  0
#> SRR1168748     2       0          1  0  1  0
#> SRR1168749     2       0          1  0  1  0
#> SRR1168750     2       0          1  0  1  0
#> SRR1168751     2       0          1  0  1  0
#> SRR1168752     2       0          1  0  1  0
#> SRR1168753     2       0          1  0  1  0
#> SRR1168754     2       0          1  0  1  0
#> SRR1168755     2       0          1  0  1  0
#> SRR1168756     2       0          1  0  1  0
#> SRR1168757     2       0          1  0  1  0
#> SRR1168758     2       0          1  0  1  0
#> SRR1168759     2       0          1  0  1  0
#> SRR1168760     2       0          1  0  1  0
#> SRR1168761     3       0          1  0  0  1
#> SRR1168762     3       0          1  0  0  1
#> SRR1168763     3       0          1  0  0  1
#> SRR1168764     3       0          1  0  0  1
#> SRR1168765     3       0          1  0  0  1
#> SRR1168766     3       0          1  0  0  1
#> SRR1168767     3       0          1  0  0  1
#> SRR1168768     3       0          1  0  0  1
#> SRR1168769     1       0          1  1  0  0
#> SRR1168770     1       0          1  1  0  0
#> SRR1168771     1       0          1  1  0  0
#> SRR1168772     1       0          1  1  0  0
#> SRR1168773     1       0          1  1  0  0
#> SRR1168774     1       0          1  1  0  0
#> SRR1168775     1       0          1  1  0  0
#> SRR1168776     1       0          1  1  0  0
#> SRR1168777     1       0          1  1  0  0

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2 p3    p4
#> SRR1168715     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR1168716     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR1168717     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR1168718     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR1168719     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR1168720     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR1168721     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR1168722     1   0.492      1.000 0.576 0.000  0 0.424
#> SRR1168723     1   0.492      1.000 0.576 0.000  0 0.424
#> SRR1168724     1   0.492      1.000 0.576 0.000  0 0.424
#> SRR1168725     1   0.492      1.000 0.576 0.000  0 0.424
#> SRR1168726     1   0.492      1.000 0.576 0.000  0 0.424
#> SRR1168727     1   0.492      1.000 0.576 0.000  0 0.424
#> SRR1168728     1   0.492      1.000 0.576 0.000  0 0.424
#> SRR1168729     1   0.492      1.000 0.576 0.000  0 0.424
#> SRR1168730     1   0.492      1.000 0.576 0.000  0 0.424
#> SRR1168731     1   0.492      1.000 0.576 0.000  0 0.424
#> SRR1168732     1   0.492      1.000 0.576 0.000  0 0.424
#> SRR1168733     2   0.492      0.786 0.424 0.576  0 0.000
#> SRR1168734     2   0.492      0.786 0.424 0.576  0 0.000
#> SRR1168735     2   0.492      0.786 0.424 0.576  0 0.000
#> SRR1168736     2   0.492      0.786 0.424 0.576  0 0.000
#> SRR1168737     2   0.492      0.786 0.424 0.576  0 0.000
#> SRR1168738     2   0.492      0.786 0.424 0.576  0 0.000
#> SRR1168739     2   0.492      0.786 0.424 0.576  0 0.000
#> SRR1168740     2   0.492      0.786 0.424 0.576  0 0.000
#> SRR1168741     2   0.492      0.786 0.424 0.576  0 0.000
#> SRR1168742     2   0.492      0.786 0.424 0.576  0 0.000
#> SRR1168743     2   0.492      0.786 0.424 0.576  0 0.000
#> SRR1168744     2   0.492      0.786 0.424 0.576  0 0.000
#> SRR1168745     2   0.492      0.786 0.424 0.576  0 0.000
#> SRR1168746     2   0.492      0.786 0.424 0.576  0 0.000
#> SRR1168747     2   0.000      0.786 0.000 1.000  0 0.000
#> SRR1168748     2   0.000      0.786 0.000 1.000  0 0.000
#> SRR1168749     2   0.000      0.786 0.000 1.000  0 0.000
#> SRR1168750     2   0.000      0.786 0.000 1.000  0 0.000
#> SRR1168751     2   0.000      0.786 0.000 1.000  0 0.000
#> SRR1168752     2   0.000      0.786 0.000 1.000  0 0.000
#> SRR1168753     2   0.000      0.786 0.000 1.000  0 0.000
#> SRR1168754     2   0.000      0.786 0.000 1.000  0 0.000
#> SRR1168755     2   0.000      0.786 0.000 1.000  0 0.000
#> SRR1168756     2   0.000      0.786 0.000 1.000  0 0.000
#> SRR1168757     2   0.000      0.786 0.000 1.000  0 0.000
#> SRR1168758     2   0.000      0.786 0.000 1.000  0 0.000
#> SRR1168759     2   0.000      0.786 0.000 1.000  0 0.000
#> SRR1168760     2   0.000      0.786 0.000 1.000  0 0.000
#> SRR1168761     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR1168762     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR1168763     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR1168764     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR1168765     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR1168766     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR1168767     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR1168768     3   0.000      1.000 0.000 0.000  1 0.000
#> SRR1168769     4   0.000      1.000 0.000 0.000  0 1.000
#> SRR1168770     4   0.000      1.000 0.000 0.000  0 1.000
#> SRR1168771     4   0.000      1.000 0.000 0.000  0 1.000
#> SRR1168772     4   0.000      1.000 0.000 0.000  0 1.000
#> SRR1168773     4   0.000      1.000 0.000 0.000  0 1.000
#> SRR1168774     4   0.000      1.000 0.000 0.000  0 1.000
#> SRR1168775     4   0.000      1.000 0.000 0.000  0 1.000
#> SRR1168776     4   0.000      1.000 0.000 0.000  0 1.000
#> SRR1168777     4   0.000      1.000 0.000 0.000  0 1.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette p1 p2 p3 p4 p5
#> SRR1168715     3       0          1  0  0  1  0  0
#> SRR1168716     3       0          1  0  0  1  0  0
#> SRR1168717     3       0          1  0  0  1  0  0
#> SRR1168718     3       0          1  0  0  1  0  0
#> SRR1168719     3       0          1  0  0  1  0  0
#> SRR1168720     3       0          1  0  0  1  0  0
#> SRR1168721     3       0          1  0  0  1  0  0
#> SRR1168722     1       0          1  1  0  0  0  0
#> SRR1168723     1       0          1  1  0  0  0  0
#> SRR1168724     1       0          1  1  0  0  0  0
#> SRR1168725     1       0          1  1  0  0  0  0
#> SRR1168726     1       0          1  1  0  0  0  0
#> SRR1168727     1       0          1  1  0  0  0  0
#> SRR1168728     1       0          1  1  0  0  0  0
#> SRR1168729     1       0          1  1  0  0  0  0
#> SRR1168730     1       0          1  1  0  0  0  0
#> SRR1168731     1       0          1  1  0  0  0  0
#> SRR1168732     1       0          1  1  0  0  0  0
#> SRR1168733     2       0          1  0  1  0  0  0
#> SRR1168734     2       0          1  0  1  0  0  0
#> SRR1168735     2       0          1  0  1  0  0  0
#> SRR1168736     2       0          1  0  1  0  0  0
#> SRR1168737     2       0          1  0  1  0  0  0
#> SRR1168738     2       0          1  0  1  0  0  0
#> SRR1168739     2       0          1  0  1  0  0  0
#> SRR1168740     2       0          1  0  1  0  0  0
#> SRR1168741     2       0          1  0  1  0  0  0
#> SRR1168742     2       0          1  0  1  0  0  0
#> SRR1168743     2       0          1  0  1  0  0  0
#> SRR1168744     2       0          1  0  1  0  0  0
#> SRR1168745     2       0          1  0  1  0  0  0
#> SRR1168746     2       0          1  0  1  0  0  0
#> SRR1168747     5       0          1  0  0  0  0  1
#> SRR1168748     5       0          1  0  0  0  0  1
#> SRR1168749     5       0          1  0  0  0  0  1
#> SRR1168750     5       0          1  0  0  0  0  1
#> SRR1168751     5       0          1  0  0  0  0  1
#> SRR1168752     5       0          1  0  0  0  0  1
#> SRR1168753     5       0          1  0  0  0  0  1
#> SRR1168754     5       0          1  0  0  0  0  1
#> SRR1168755     5       0          1  0  0  0  0  1
#> SRR1168756     5       0          1  0  0  0  0  1
#> SRR1168757     5       0          1  0  0  0  0  1
#> SRR1168758     5       0          1  0  0  0  0  1
#> SRR1168759     5       0          1  0  0  0  0  1
#> SRR1168760     5       0          1  0  0  0  0  1
#> SRR1168761     3       0          1  0  0  1  0  0
#> SRR1168762     3       0          1  0  0  1  0  0
#> SRR1168763     3       0          1  0  0  1  0  0
#> SRR1168764     3       0          1  0  0  1  0  0
#> SRR1168765     3       0          1  0  0  1  0  0
#> SRR1168766     3       0          1  0  0  1  0  0
#> SRR1168767     3       0          1  0  0  1  0  0
#> SRR1168768     3       0          1  0  0  1  0  0
#> SRR1168769     4       0          1  0  0  0  1  0
#> SRR1168770     4       0          1  0  0  0  1  0
#> SRR1168771     4       0          1  0  0  0  1  0
#> SRR1168772     4       0          1  0  0  0  1  0
#> SRR1168773     4       0          1  0  0  0  1  0
#> SRR1168774     4       0          1  0  0  0  1  0
#> SRR1168775     4       0          1  0  0  0  1  0
#> SRR1168776     4       0          1  0  0  0  1  0
#> SRR1168777     4       0          1  0  0  0  1  0

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1168715     6       0          1  0  0  0  0  0  1
#> SRR1168716     6       0          1  0  0  0  0  0  1
#> SRR1168717     6       0          1  0  0  0  0  0  1
#> SRR1168718     6       0          1  0  0  0  0  0  1
#> SRR1168719     6       0          1  0  0  0  0  0  1
#> SRR1168720     6       0          1  0  0  0  0  0  1
#> SRR1168721     6       0          1  0  0  0  0  0  1
#> SRR1168722     1       0          1  1  0  0  0  0  0
#> SRR1168723     1       0          1  1  0  0  0  0  0
#> SRR1168724     1       0          1  1  0  0  0  0  0
#> SRR1168725     1       0          1  1  0  0  0  0  0
#> SRR1168726     1       0          1  1  0  0  0  0  0
#> SRR1168727     1       0          1  1  0  0  0  0  0
#> SRR1168728     1       0          1  1  0  0  0  0  0
#> SRR1168729     1       0          1  1  0  0  0  0  0
#> SRR1168730     1       0          1  1  0  0  0  0  0
#> SRR1168731     1       0          1  1  0  0  0  0  0
#> SRR1168732     1       0          1  1  0  0  0  0  0
#> SRR1168733     2       0          1  0  1  0  0  0  0
#> SRR1168734     2       0          1  0  1  0  0  0  0
#> SRR1168735     2       0          1  0  1  0  0  0  0
#> SRR1168736     2       0          1  0  1  0  0  0  0
#> SRR1168737     2       0          1  0  1  0  0  0  0
#> SRR1168738     2       0          1  0  1  0  0  0  0
#> SRR1168739     2       0          1  0  1  0  0  0  0
#> SRR1168740     2       0          1  0  1  0  0  0  0
#> SRR1168741     2       0          1  0  1  0  0  0  0
#> SRR1168742     2       0          1  0  1  0  0  0  0
#> SRR1168743     2       0          1  0  1  0  0  0  0
#> SRR1168744     2       0          1  0  1  0  0  0  0
#> SRR1168745     2       0          1  0  1  0  0  0  0
#> SRR1168746     2       0          1  0  1  0  0  0  0
#> SRR1168747     5       0          1  0  0  0  0  1  0
#> SRR1168748     5       0          1  0  0  0  0  1  0
#> SRR1168749     5       0          1  0  0  0  0  1  0
#> SRR1168750     5       0          1  0  0  0  0  1  0
#> SRR1168751     5       0          1  0  0  0  0  1  0
#> SRR1168752     5       0          1  0  0  0  0  1  0
#> SRR1168753     5       0          1  0  0  0  0  1  0
#> SRR1168754     5       0          1  0  0  0  0  1  0
#> SRR1168755     5       0          1  0  0  0  0  1  0
#> SRR1168756     5       0          1  0  0  0  0  1  0
#> SRR1168757     5       0          1  0  0  0  0  1  0
#> SRR1168758     5       0          1  0  0  0  0  1  0
#> SRR1168759     5       0          1  0  0  0  0  1  0
#> SRR1168760     5       0          1  0  0  0  0  1  0
#> SRR1168761     3       0          1  0  0  1  0  0  0
#> SRR1168762     3       0          1  0  0  1  0  0  0
#> SRR1168763     3       0          1  0  0  1  0  0  0
#> SRR1168764     3       0          1  0  0  1  0  0  0
#> SRR1168765     3       0          1  0  0  1  0  0  0
#> SRR1168766     3       0          1  0  0  1  0  0  0
#> SRR1168767     3       0          1  0  0  1  0  0  0
#> SRR1168768     3       0          1  0  0  1  0  0  0
#> SRR1168769     4       0          1  0  0  0  1  0  0
#> SRR1168770     4       0          1  0  0  0  1  0  0
#> SRR1168771     4       0          1  0  0  0  1  0  0
#> SRR1168772     4       0          1  0  0  0  1  0  0
#> SRR1168773     4       0          1  0  0  0  1  0  0
#> SRR1168774     4       0          1  0  0  0  1  0  0
#> SRR1168775     4       0          1  0  0  0  1  0  0
#> SRR1168776     4       0          1  0  0  0  1  0  0
#> SRR1168777     4       0          1  0  0  0  1  0  0

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

consensus_heatmap(res, k = 2)

plot of chunk tab-SD-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 14158 rows and 63 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  1.00           1.000       1.000         0.5023 0.498   0.498
#> 3 3  0.88           0.978       0.984         0.2730 0.865   0.729
#> 4 4  1.00           0.998       0.996         0.1055 0.931   0.810
#> 5 5  1.00           0.982       0.972         0.0483 0.971   0.902
#> 6 6  1.00           0.999       0.987         0.1206 0.900   0.622

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
#> SRR1168715     1       0          1  1  0
#> SRR1168716     1       0          1  1  0
#> SRR1168717     1       0          1  1  0
#> SRR1168718     1       0          1  1  0
#> SRR1168719     1       0          1  1  0
#> SRR1168720     1       0          1  1  0
#> SRR1168721     1       0          1  1  0
#> SRR1168722     1       0          1  1  0
#> SRR1168723     1       0          1  1  0
#> SRR1168724     1       0          1  1  0
#> SRR1168725     1       0          1  1  0
#> SRR1168726     1       0          1  1  0
#> SRR1168727     1       0          1  1  0
#> SRR1168728     1       0          1  1  0
#> SRR1168729     1       0          1  1  0
#> SRR1168730     1       0          1  1  0
#> SRR1168731     1       0          1  1  0
#> SRR1168732     1       0          1  1  0
#> SRR1168733     2       0          1  0  1
#> SRR1168734     2       0          1  0  1
#> SRR1168735     2       0          1  0  1
#> SRR1168736     2       0          1  0  1
#> SRR1168737     2       0          1  0  1
#> SRR1168738     2       0          1  0  1
#> SRR1168739     2       0          1  0  1
#> SRR1168740     2       0          1  0  1
#> SRR1168741     2       0          1  0  1
#> SRR1168742     2       0          1  0  1
#> SRR1168743     2       0          1  0  1
#> SRR1168744     2       0          1  0  1
#> SRR1168745     2       0          1  0  1
#> SRR1168746     2       0          1  0  1
#> SRR1168747     2       0          1  0  1
#> SRR1168748     2       0          1  0  1
#> SRR1168749     2       0          1  0  1
#> SRR1168750     2       0          1  0  1
#> SRR1168751     2       0          1  0  1
#> SRR1168752     2       0          1  0  1
#> SRR1168753     2       0          1  0  1
#> SRR1168754     2       0          1  0  1
#> SRR1168755     2       0          1  0  1
#> SRR1168756     2       0          1  0  1
#> SRR1168757     2       0          1  0  1
#> SRR1168758     2       0          1  0  1
#> SRR1168759     2       0          1  0  1
#> SRR1168760     2       0          1  0  1
#> SRR1168761     1       0          1  1  0
#> SRR1168762     1       0          1  1  0
#> SRR1168763     1       0          1  1  0
#> SRR1168764     1       0          1  1  0
#> SRR1168765     1       0          1  1  0
#> SRR1168766     1       0          1  1  0
#> SRR1168767     1       0          1  1  0
#> SRR1168768     1       0          1  1  0
#> SRR1168769     1       0          1  1  0
#> SRR1168770     1       0          1  1  0
#> SRR1168771     1       0          1  1  0
#> SRR1168772     1       0          1  1  0
#> SRR1168773     1       0          1  1  0
#> SRR1168774     1       0          1  1  0
#> SRR1168775     1       0          1  1  0
#> SRR1168776     1       0          1  1  0
#> SRR1168777     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1 p2    p3
#> SRR1168715     3  0.0424      0.954 0.008  0 0.992
#> SRR1168716     3  0.0424      0.954 0.008  0 0.992
#> SRR1168717     3  0.0424      0.954 0.008  0 0.992
#> SRR1168718     3  0.0424      0.954 0.008  0 0.992
#> SRR1168719     3  0.0424      0.954 0.008  0 0.992
#> SRR1168720     3  0.0424      0.954 0.008  0 0.992
#> SRR1168721     3  0.0424      0.954 0.008  0 0.992
#> SRR1168722     1  0.0000      1.000 1.000  0 0.000
#> SRR1168723     1  0.0000      1.000 1.000  0 0.000
#> SRR1168724     1  0.0000      1.000 1.000  0 0.000
#> SRR1168725     1  0.0000      1.000 1.000  0 0.000
#> SRR1168726     1  0.0000      1.000 1.000  0 0.000
#> SRR1168727     1  0.0000      1.000 1.000  0 0.000
#> SRR1168728     1  0.0000      1.000 1.000  0 0.000
#> SRR1168729     1  0.0000      1.000 1.000  0 0.000
#> SRR1168730     1  0.0000      1.000 1.000  0 0.000
#> SRR1168731     1  0.0000      1.000 1.000  0 0.000
#> SRR1168732     1  0.0000      1.000 1.000  0 0.000
#> SRR1168733     2  0.0000      1.000 0.000  1 0.000
#> SRR1168734     2  0.0000      1.000 0.000  1 0.000
#> SRR1168735     2  0.0000      1.000 0.000  1 0.000
#> SRR1168736     2  0.0000      1.000 0.000  1 0.000
#> SRR1168737     2  0.0000      1.000 0.000  1 0.000
#> SRR1168738     2  0.0000      1.000 0.000  1 0.000
#> SRR1168739     2  0.0000      1.000 0.000  1 0.000
#> SRR1168740     2  0.0000      1.000 0.000  1 0.000
#> SRR1168741     2  0.0000      1.000 0.000  1 0.000
#> SRR1168742     2  0.0000      1.000 0.000  1 0.000
#> SRR1168743     2  0.0000      1.000 0.000  1 0.000
#> SRR1168744     2  0.0000      1.000 0.000  1 0.000
#> SRR1168745     2  0.0000      1.000 0.000  1 0.000
#> SRR1168746     2  0.0000      1.000 0.000  1 0.000
#> SRR1168747     2  0.0000      1.000 0.000  1 0.000
#> SRR1168748     2  0.0000      1.000 0.000  1 0.000
#> SRR1168749     2  0.0000      1.000 0.000  1 0.000
#> SRR1168750     2  0.0000      1.000 0.000  1 0.000
#> SRR1168751     2  0.0000      1.000 0.000  1 0.000
#> SRR1168752     2  0.0000      1.000 0.000  1 0.000
#> SRR1168753     2  0.0000      1.000 0.000  1 0.000
#> SRR1168754     2  0.0000      1.000 0.000  1 0.000
#> SRR1168755     2  0.0000      1.000 0.000  1 0.000
#> SRR1168756     2  0.0000      1.000 0.000  1 0.000
#> SRR1168757     2  0.0000      1.000 0.000  1 0.000
#> SRR1168758     2  0.0000      1.000 0.000  1 0.000
#> SRR1168759     2  0.0000      1.000 0.000  1 0.000
#> SRR1168760     2  0.0000      1.000 0.000  1 0.000
#> SRR1168761     3  0.0000      0.954 0.000  0 1.000
#> SRR1168762     3  0.0000      0.954 0.000  0 1.000
#> SRR1168763     3  0.0000      0.954 0.000  0 1.000
#> SRR1168764     3  0.0000      0.954 0.000  0 1.000
#> SRR1168765     3  0.0000      0.954 0.000  0 1.000
#> SRR1168766     3  0.0000      0.954 0.000  0 1.000
#> SRR1168767     3  0.0000      0.954 0.000  0 1.000
#> SRR1168768     3  0.0000      0.954 0.000  0 1.000
#> SRR1168769     3  0.3038      0.924 0.104  0 0.896
#> SRR1168770     3  0.3038      0.924 0.104  0 0.896
#> SRR1168771     3  0.3038      0.924 0.104  0 0.896
#> SRR1168772     3  0.3038      0.924 0.104  0 0.896
#> SRR1168773     3  0.3038      0.924 0.104  0 0.896
#> SRR1168774     3  0.3038      0.924 0.104  0 0.896
#> SRR1168775     3  0.3038      0.924 0.104  0 0.896
#> SRR1168776     3  0.3038      0.924 0.104  0 0.896
#> SRR1168777     3  0.3038      0.924 0.104  0 0.896

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1168715     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1168716     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1168717     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1168718     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1168719     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1168720     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1168721     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1168722     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1168723     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1168724     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1168725     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1168726     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1168727     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1168728     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1168729     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1168730     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1168731     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1168732     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1168733     2  0.0469      0.995 0.000 0.988 0.000 0.012
#> SRR1168734     2  0.0469      0.995 0.000 0.988 0.000 0.012
#> SRR1168735     2  0.0469      0.995 0.000 0.988 0.000 0.012
#> SRR1168736     2  0.0469      0.995 0.000 0.988 0.000 0.012
#> SRR1168737     2  0.0469      0.995 0.000 0.988 0.000 0.012
#> SRR1168738     2  0.0469      0.995 0.000 0.988 0.000 0.012
#> SRR1168739     2  0.0469      0.995 0.000 0.988 0.000 0.012
#> SRR1168740     2  0.0469      0.995 0.000 0.988 0.000 0.012
#> SRR1168741     2  0.0469      0.995 0.000 0.988 0.000 0.012
#> SRR1168742     2  0.0469      0.995 0.000 0.988 0.000 0.012
#> SRR1168743     2  0.0469      0.995 0.000 0.988 0.000 0.012
#> SRR1168744     2  0.0469      0.995 0.000 0.988 0.000 0.012
#> SRR1168745     2  0.0469      0.995 0.000 0.988 0.000 0.012
#> SRR1168746     2  0.0469      0.995 0.000 0.988 0.000 0.012
#> SRR1168747     2  0.0000      0.995 0.000 1.000 0.000 0.000
#> SRR1168748     2  0.0000      0.995 0.000 1.000 0.000 0.000
#> SRR1168749     2  0.0000      0.995 0.000 1.000 0.000 0.000
#> SRR1168750     2  0.0000      0.995 0.000 1.000 0.000 0.000
#> SRR1168751     2  0.0000      0.995 0.000 1.000 0.000 0.000
#> SRR1168752     2  0.0000      0.995 0.000 1.000 0.000 0.000
#> SRR1168753     2  0.0000      0.995 0.000 1.000 0.000 0.000
#> SRR1168754     2  0.0000      0.995 0.000 1.000 0.000 0.000
#> SRR1168755     2  0.0000      0.995 0.000 1.000 0.000 0.000
#> SRR1168756     2  0.0000      0.995 0.000 1.000 0.000 0.000
#> SRR1168757     2  0.0000      0.995 0.000 1.000 0.000 0.000
#> SRR1168758     2  0.0000      0.995 0.000 1.000 0.000 0.000
#> SRR1168759     2  0.0000      0.995 0.000 1.000 0.000 0.000
#> SRR1168760     2  0.0000      0.995 0.000 1.000 0.000 0.000
#> SRR1168761     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1168762     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1168763     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1168764     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1168765     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1168766     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1168767     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1168768     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1168769     4  0.0524      1.000 0.004 0.000 0.008 0.988
#> SRR1168770     4  0.0524      1.000 0.004 0.000 0.008 0.988
#> SRR1168771     4  0.0524      1.000 0.004 0.000 0.008 0.988
#> SRR1168772     4  0.0524      1.000 0.004 0.000 0.008 0.988
#> SRR1168773     4  0.0524      1.000 0.004 0.000 0.008 0.988
#> SRR1168774     4  0.0524      1.000 0.004 0.000 0.008 0.988
#> SRR1168775     4  0.0524      1.000 0.004 0.000 0.008 0.988
#> SRR1168776     4  0.0524      1.000 0.004 0.000 0.008 0.988
#> SRR1168777     4  0.0524      1.000 0.004 0.000 0.008 0.988

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette p1    p2    p3 p4    p5
#> SRR1168715     5   0.179       1.00  0 0.000 0.084  0 0.916
#> SRR1168716     5   0.179       1.00  0 0.000 0.084  0 0.916
#> SRR1168717     5   0.179       1.00  0 0.000 0.084  0 0.916
#> SRR1168718     5   0.179       1.00  0 0.000 0.084  0 0.916
#> SRR1168719     5   0.179       1.00  0 0.000 0.084  0 0.916
#> SRR1168720     5   0.179       1.00  0 0.000 0.084  0 0.916
#> SRR1168721     5   0.179       1.00  0 0.000 0.084  0 0.916
#> SRR1168722     1   0.000       1.00  1 0.000 0.000  0 0.000
#> SRR1168723     1   0.000       1.00  1 0.000 0.000  0 0.000
#> SRR1168724     1   0.000       1.00  1 0.000 0.000  0 0.000
#> SRR1168725     1   0.000       1.00  1 0.000 0.000  0 0.000
#> SRR1168726     1   0.000       1.00  1 0.000 0.000  0 0.000
#> SRR1168727     1   0.000       1.00  1 0.000 0.000  0 0.000
#> SRR1168728     1   0.000       1.00  1 0.000 0.000  0 0.000
#> SRR1168729     1   0.000       1.00  1 0.000 0.000  0 0.000
#> SRR1168730     1   0.000       1.00  1 0.000 0.000  0 0.000
#> SRR1168731     1   0.000       1.00  1 0.000 0.000  0 0.000
#> SRR1168732     1   0.000       1.00  1 0.000 0.000  0 0.000
#> SRR1168733     2   0.000       0.96  0 1.000 0.000  0 0.000
#> SRR1168734     2   0.000       0.96  0 1.000 0.000  0 0.000
#> SRR1168735     2   0.000       0.96  0 1.000 0.000  0 0.000
#> SRR1168736     2   0.000       0.96  0 1.000 0.000  0 0.000
#> SRR1168737     2   0.000       0.96  0 1.000 0.000  0 0.000
#> SRR1168738     2   0.000       0.96  0 1.000 0.000  0 0.000
#> SRR1168739     2   0.000       0.96  0 1.000 0.000  0 0.000
#> SRR1168740     2   0.000       0.96  0 1.000 0.000  0 0.000
#> SRR1168741     2   0.000       0.96  0 1.000 0.000  0 0.000
#> SRR1168742     2   0.000       0.96  0 1.000 0.000  0 0.000
#> SRR1168743     2   0.000       0.96  0 1.000 0.000  0 0.000
#> SRR1168744     2   0.000       0.96  0 1.000 0.000  0 0.000
#> SRR1168745     2   0.000       0.96  0 1.000 0.000  0 0.000
#> SRR1168746     2   0.000       0.96  0 1.000 0.000  0 0.000
#> SRR1168747     2   0.179       0.96  0 0.916 0.000  0 0.084
#> SRR1168748     2   0.179       0.96  0 0.916 0.000  0 0.084
#> SRR1168749     2   0.179       0.96  0 0.916 0.000  0 0.084
#> SRR1168750     2   0.179       0.96  0 0.916 0.000  0 0.084
#> SRR1168751     2   0.179       0.96  0 0.916 0.000  0 0.084
#> SRR1168752     2   0.179       0.96  0 0.916 0.000  0 0.084
#> SRR1168753     2   0.179       0.96  0 0.916 0.000  0 0.084
#> SRR1168754     2   0.179       0.96  0 0.916 0.000  0 0.084
#> SRR1168755     2   0.179       0.96  0 0.916 0.000  0 0.084
#> SRR1168756     2   0.179       0.96  0 0.916 0.000  0 0.084
#> SRR1168757     2   0.179       0.96  0 0.916 0.000  0 0.084
#> SRR1168758     2   0.179       0.96  0 0.916 0.000  0 0.084
#> SRR1168759     2   0.179       0.96  0 0.916 0.000  0 0.084
#> SRR1168760     2   0.179       0.96  0 0.916 0.000  0 0.084
#> SRR1168761     3   0.000       1.00  0 0.000 1.000  0 0.000
#> SRR1168762     3   0.000       1.00  0 0.000 1.000  0 0.000
#> SRR1168763     3   0.000       1.00  0 0.000 1.000  0 0.000
#> SRR1168764     3   0.000       1.00  0 0.000 1.000  0 0.000
#> SRR1168765     3   0.000       1.00  0 0.000 1.000  0 0.000
#> SRR1168766     3   0.000       1.00  0 0.000 1.000  0 0.000
#> SRR1168767     3   0.000       1.00  0 0.000 1.000  0 0.000
#> SRR1168768     3   0.000       1.00  0 0.000 1.000  0 0.000
#> SRR1168769     4   0.000       1.00  0 0.000 0.000  1 0.000
#> SRR1168770     4   0.000       1.00  0 0.000 0.000  1 0.000
#> SRR1168771     4   0.000       1.00  0 0.000 0.000  1 0.000
#> SRR1168772     4   0.000       1.00  0 0.000 0.000  1 0.000
#> SRR1168773     4   0.000       1.00  0 0.000 0.000  1 0.000
#> SRR1168774     4   0.000       1.00  0 0.000 0.000  1 0.000
#> SRR1168775     4   0.000       1.00  0 0.000 0.000  1 0.000
#> SRR1168776     4   0.000       1.00  0 0.000 0.000  1 0.000
#> SRR1168777     4   0.000       1.00  0 0.000 0.000  1 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette p1    p2    p3    p4    p5    p6
#> SRR1168715     6  0.0260      0.995  0 0.000 0.000 0.000 0.008 0.992
#> SRR1168716     6  0.0000      0.996  0 0.000 0.000 0.000 0.000 1.000
#> SRR1168717     6  0.0146      0.996  0 0.000 0.000 0.000 0.004 0.996
#> SRR1168718     6  0.0146      0.996  0 0.000 0.000 0.000 0.004 0.996
#> SRR1168719     6  0.0000      0.996  0 0.000 0.000 0.000 0.000 1.000
#> SRR1168720     6  0.0363      0.992  0 0.000 0.000 0.000 0.012 0.988
#> SRR1168721     6  0.0260      0.995  0 0.000 0.000 0.000 0.008 0.992
#> SRR1168722     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1168723     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1168724     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1168725     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1168726     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1168727     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1168728     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1168729     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1168730     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1168731     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1168732     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1168733     2  0.0000      1.000  0 1.000 0.000 0.000 0.000 0.000
#> SRR1168734     2  0.0000      1.000  0 1.000 0.000 0.000 0.000 0.000
#> SRR1168735     2  0.0000      1.000  0 1.000 0.000 0.000 0.000 0.000
#> SRR1168736     2  0.0000      1.000  0 1.000 0.000 0.000 0.000 0.000
#> SRR1168737     2  0.0000      1.000  0 1.000 0.000 0.000 0.000 0.000
#> SRR1168738     2  0.0000      1.000  0 1.000 0.000 0.000 0.000 0.000
#> SRR1168739     2  0.0000      1.000  0 1.000 0.000 0.000 0.000 0.000
#> SRR1168740     2  0.0000      1.000  0 1.000 0.000 0.000 0.000 0.000
#> SRR1168741     2  0.0000      1.000  0 1.000 0.000 0.000 0.000 0.000
#> SRR1168742     2  0.0000      1.000  0 1.000 0.000 0.000 0.000 0.000
#> SRR1168743     2  0.0000      1.000  0 1.000 0.000 0.000 0.000 0.000
#> SRR1168744     2  0.0000      1.000  0 1.000 0.000 0.000 0.000 0.000
#> SRR1168745     2  0.0000      1.000  0 1.000 0.000 0.000 0.000 0.000
#> SRR1168746     2  0.0000      1.000  0 1.000 0.000 0.000 0.000 0.000
#> SRR1168747     5  0.1141      1.000  0 0.052 0.000 0.000 0.948 0.000
#> SRR1168748     5  0.1141      1.000  0 0.052 0.000 0.000 0.948 0.000
#> SRR1168749     5  0.1141      1.000  0 0.052 0.000 0.000 0.948 0.000
#> SRR1168750     5  0.1141      1.000  0 0.052 0.000 0.000 0.948 0.000
#> SRR1168751     5  0.1141      1.000  0 0.052 0.000 0.000 0.948 0.000
#> SRR1168752     5  0.1141      1.000  0 0.052 0.000 0.000 0.948 0.000
#> SRR1168753     5  0.1141      1.000  0 0.052 0.000 0.000 0.948 0.000
#> SRR1168754     5  0.1141      1.000  0 0.052 0.000 0.000 0.948 0.000
#> SRR1168755     5  0.1141      1.000  0 0.052 0.000 0.000 0.948 0.000
#> SRR1168756     5  0.1141      1.000  0 0.052 0.000 0.000 0.948 0.000
#> SRR1168757     5  0.1141      1.000  0 0.052 0.000 0.000 0.948 0.000
#> SRR1168758     5  0.1141      1.000  0 0.052 0.000 0.000 0.948 0.000
#> SRR1168759     5  0.1141      1.000  0 0.052 0.000 0.000 0.948 0.000
#> SRR1168760     5  0.1141      1.000  0 0.052 0.000 0.000 0.948 0.000
#> SRR1168761     3  0.0146      0.997  0 0.000 0.996 0.000 0.004 0.000
#> SRR1168762     3  0.0000      0.998  0 0.000 1.000 0.000 0.000 0.000
#> SRR1168763     3  0.0146      0.997  0 0.000 0.996 0.000 0.004 0.000
#> SRR1168764     3  0.0260      0.996  0 0.000 0.992 0.000 0.008 0.000
#> SRR1168765     3  0.0000      0.998  0 0.000 1.000 0.000 0.000 0.000
#> SRR1168766     3  0.0000      0.998  0 0.000 1.000 0.000 0.000 0.000
#> SRR1168767     3  0.0000      0.998  0 0.000 1.000 0.000 0.000 0.000
#> SRR1168768     3  0.0000      0.998  0 0.000 1.000 0.000 0.000 0.000
#> SRR1168769     4  0.0000      0.997  0 0.000 0.000 1.000 0.000 0.000
#> SRR1168770     4  0.0146      0.996  0 0.000 0.000 0.996 0.004 0.000
#> SRR1168771     4  0.0146      0.996  0 0.000 0.000 0.996 0.004 0.000
#> SRR1168772     4  0.0146      0.995  0 0.000 0.000 0.996 0.004 0.000
#> SRR1168773     4  0.0000      0.997  0 0.000 0.000 1.000 0.000 0.000
#> SRR1168774     4  0.0363      0.993  0 0.000 0.000 0.988 0.012 0.000
#> SRR1168775     4  0.0000      0.997  0 0.000 0.000 1.000 0.000 0.000
#> SRR1168776     4  0.0000      0.997  0 0.000 0.000 1.000 0.000 0.000
#> SRR1168777     4  0.0363      0.993  0 0.000 0.000 0.988 0.012 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 14158 rows and 63 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#>   Subgroups are detected by 'NMF' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk SD-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.5023 0.498   0.498
#> 3 3 0.846           0.877       0.874         0.1577 1.000   1.000
#> 4 4 0.746           0.950       0.902         0.1114 0.846   0.692
#> 5 5 0.752           0.935       0.777         0.1003 0.900   0.709
#> 6 6 0.752           0.874       0.828         0.0602 1.000   1.000

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

suggest_best_k(res)
#> [1] 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
#> SRR1168715     1       0          1  1  0
#> SRR1168716     1       0          1  1  0
#> SRR1168717     1       0          1  1  0
#> SRR1168718     1       0          1  1  0
#> SRR1168719     1       0          1  1  0
#> SRR1168720     1       0          1  1  0
#> SRR1168721     1       0          1  1  0
#> SRR1168722     1       0          1  1  0
#> SRR1168723     1       0          1  1  0
#> SRR1168724     1       0          1  1  0
#> SRR1168725     1       0          1  1  0
#> SRR1168726     1       0          1  1  0
#> SRR1168727     1       0          1  1  0
#> SRR1168728     1       0          1  1  0
#> SRR1168729     1       0          1  1  0
#> SRR1168730     1       0          1  1  0
#> SRR1168731     1       0          1  1  0
#> SRR1168732     1       0          1  1  0
#> SRR1168733     2       0          1  0  1
#> SRR1168734     2       0          1  0  1
#> SRR1168735     2       0          1  0  1
#> SRR1168736     2       0          1  0  1
#> SRR1168737     2       0          1  0  1
#> SRR1168738     2       0          1  0  1
#> SRR1168739     2       0          1  0  1
#> SRR1168740     2       0          1  0  1
#> SRR1168741     2       0          1  0  1
#> SRR1168742     2       0          1  0  1
#> SRR1168743     2       0          1  0  1
#> SRR1168744     2       0          1  0  1
#> SRR1168745     2       0          1  0  1
#> SRR1168746     2       0          1  0  1
#> SRR1168747     2       0          1  0  1
#> SRR1168748     2       0          1  0  1
#> SRR1168749     2       0          1  0  1
#> SRR1168750     2       0          1  0  1
#> SRR1168751     2       0          1  0  1
#> SRR1168752     2       0          1  0  1
#> SRR1168753     2       0          1  0  1
#> SRR1168754     2       0          1  0  1
#> SRR1168755     2       0          1  0  1
#> SRR1168756     2       0          1  0  1
#> SRR1168757     2       0          1  0  1
#> SRR1168758     2       0          1  0  1
#> SRR1168759     2       0          1  0  1
#> SRR1168760     2       0          1  0  1
#> SRR1168761     1       0          1  1  0
#> SRR1168762     1       0          1  1  0
#> SRR1168763     1       0          1  1  0
#> SRR1168764     1       0          1  1  0
#> SRR1168765     1       0          1  1  0
#> SRR1168766     1       0          1  1  0
#> SRR1168767     1       0          1  1  0
#> SRR1168768     1       0          1  1  0
#> SRR1168769     1       0          1  1  0
#> SRR1168770     1       0          1  1  0
#> SRR1168771     1       0          1  1  0
#> SRR1168772     1       0          1  1  0
#> SRR1168773     1       0          1  1  0
#> SRR1168774     1       0          1  1  0
#> SRR1168775     1       0          1  1  0
#> SRR1168776     1       0          1  1  0
#> SRR1168777     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2 p3
#> SRR1168715     1   0.000      0.752 1.000 0.000 NA
#> SRR1168716     1   0.000      0.752 1.000 0.000 NA
#> SRR1168717     1   0.000      0.752 1.000 0.000 NA
#> SRR1168718     1   0.000      0.752 1.000 0.000 NA
#> SRR1168719     1   0.000      0.752 1.000 0.000 NA
#> SRR1168720     1   0.000      0.752 1.000 0.000 NA
#> SRR1168721     1   0.000      0.752 1.000 0.000 NA
#> SRR1168722     1   0.631      0.821 0.512 0.000 NA
#> SRR1168723     1   0.631      0.821 0.512 0.000 NA
#> SRR1168724     1   0.631      0.821 0.512 0.000 NA
#> SRR1168725     1   0.631      0.821 0.512 0.000 NA
#> SRR1168726     1   0.631      0.821 0.512 0.000 NA
#> SRR1168727     1   0.631      0.821 0.512 0.000 NA
#> SRR1168728     1   0.631      0.821 0.512 0.000 NA
#> SRR1168729     1   0.631      0.821 0.512 0.000 NA
#> SRR1168730     1   0.631      0.821 0.512 0.000 NA
#> SRR1168731     1   0.631      0.821 0.512 0.000 NA
#> SRR1168732     1   0.631      0.821 0.512 0.000 NA
#> SRR1168733     2   0.164      0.983 0.000 0.956 NA
#> SRR1168734     2   0.164      0.983 0.000 0.956 NA
#> SRR1168735     2   0.164      0.983 0.000 0.956 NA
#> SRR1168736     2   0.164      0.983 0.000 0.956 NA
#> SRR1168737     2   0.164      0.983 0.000 0.956 NA
#> SRR1168738     2   0.164      0.983 0.000 0.956 NA
#> SRR1168739     2   0.164      0.983 0.000 0.956 NA
#> SRR1168740     2   0.164      0.983 0.000 0.956 NA
#> SRR1168741     2   0.164      0.983 0.000 0.956 NA
#> SRR1168742     2   0.164      0.983 0.000 0.956 NA
#> SRR1168743     2   0.164      0.983 0.000 0.956 NA
#> SRR1168744     2   0.164      0.983 0.000 0.956 NA
#> SRR1168745     2   0.164      0.983 0.000 0.956 NA
#> SRR1168746     2   0.164      0.983 0.000 0.956 NA
#> SRR1168747     2   0.000      0.983 0.000 1.000 NA
#> SRR1168748     2   0.000      0.983 0.000 1.000 NA
#> SRR1168749     2   0.000      0.983 0.000 1.000 NA
#> SRR1168750     2   0.000      0.983 0.000 1.000 NA
#> SRR1168751     2   0.000      0.983 0.000 1.000 NA
#> SRR1168752     2   0.000      0.983 0.000 1.000 NA
#> SRR1168753     2   0.000      0.983 0.000 1.000 NA
#> SRR1168754     2   0.000      0.983 0.000 1.000 NA
#> SRR1168755     2   0.000      0.983 0.000 1.000 NA
#> SRR1168756     2   0.000      0.983 0.000 1.000 NA
#> SRR1168757     2   0.000      0.983 0.000 1.000 NA
#> SRR1168758     2   0.000      0.983 0.000 1.000 NA
#> SRR1168759     2   0.000      0.983 0.000 1.000 NA
#> SRR1168760     2   0.000      0.983 0.000 1.000 NA
#> SRR1168761     1   0.000      0.752 1.000 0.000 NA
#> SRR1168762     1   0.000      0.752 1.000 0.000 NA
#> SRR1168763     1   0.000      0.752 1.000 0.000 NA
#> SRR1168764     1   0.000      0.752 1.000 0.000 NA
#> SRR1168765     1   0.000      0.752 1.000 0.000 NA
#> SRR1168766     1   0.000      0.752 1.000 0.000 NA
#> SRR1168767     1   0.000      0.752 1.000 0.000 NA
#> SRR1168768     1   0.000      0.752 1.000 0.000 NA
#> SRR1168769     1   0.631      0.821 0.512 0.000 NA
#> SRR1168770     1   0.631      0.821 0.512 0.000 NA
#> SRR1168771     1   0.631      0.821 0.512 0.000 NA
#> SRR1168772     1   0.631      0.821 0.512 0.000 NA
#> SRR1168773     1   0.631      0.821 0.512 0.000 NA
#> SRR1168774     1   0.631      0.821 0.512 0.000 NA
#> SRR1168775     1   0.631      0.821 0.512 0.000 NA
#> SRR1168776     1   0.631      0.821 0.512 0.000 NA
#> SRR1168777     1   0.631      0.821 0.512 0.000 NA

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1   p2    p3 p4
#> SRR1168715     3  0.4671      0.966 0.220 0.00 0.752 NA
#> SRR1168716     3  0.4671      0.966 0.220 0.00 0.752 NA
#> SRR1168717     3  0.4671      0.966 0.220 0.00 0.752 NA
#> SRR1168718     3  0.4671      0.966 0.220 0.00 0.752 NA
#> SRR1168719     3  0.4671      0.966 0.220 0.00 0.752 NA
#> SRR1168720     3  0.4671      0.966 0.220 0.00 0.752 NA
#> SRR1168721     3  0.4671      0.966 0.220 0.00 0.752 NA
#> SRR1168722     1  0.0188      0.980 0.996 0.00 0.004 NA
#> SRR1168723     1  0.0188      0.980 0.996 0.00 0.004 NA
#> SRR1168724     1  0.0188      0.980 0.996 0.00 0.004 NA
#> SRR1168725     1  0.0188      0.980 0.996 0.00 0.004 NA
#> SRR1168726     1  0.0000      0.979 1.000 0.00 0.000 NA
#> SRR1168727     1  0.0188      0.980 0.996 0.00 0.004 NA
#> SRR1168728     1  0.0188      0.980 0.996 0.00 0.004 NA
#> SRR1168729     1  0.0188      0.980 0.996 0.00 0.004 NA
#> SRR1168730     1  0.0188      0.980 0.996 0.00 0.004 NA
#> SRR1168731     1  0.0188      0.980 0.996 0.00 0.004 NA
#> SRR1168732     1  0.0188      0.980 0.996 0.00 0.004 NA
#> SRR1168733     2  0.0000      0.920 0.000 1.00 0.000 NA
#> SRR1168734     2  0.0000      0.920 0.000 1.00 0.000 NA
#> SRR1168735     2  0.0000      0.920 0.000 1.00 0.000 NA
#> SRR1168736     2  0.0000      0.920 0.000 1.00 0.000 NA
#> SRR1168737     2  0.0000      0.920 0.000 1.00 0.000 NA
#> SRR1168738     2  0.0000      0.920 0.000 1.00 0.000 NA
#> SRR1168739     2  0.0000      0.920 0.000 1.00 0.000 NA
#> SRR1168740     2  0.0000      0.920 0.000 1.00 0.000 NA
#> SRR1168741     2  0.0000      0.920 0.000 1.00 0.000 NA
#> SRR1168742     2  0.0000      0.920 0.000 1.00 0.000 NA
#> SRR1168743     2  0.0000      0.920 0.000 1.00 0.000 NA
#> SRR1168744     2  0.0000      0.920 0.000 1.00 0.000 NA
#> SRR1168745     2  0.0000      0.920 0.000 1.00 0.000 NA
#> SRR1168746     2  0.0000      0.920 0.000 1.00 0.000 NA
#> SRR1168747     2  0.3400      0.920 0.000 0.82 0.000 NA
#> SRR1168748     2  0.3400      0.920 0.000 0.82 0.000 NA
#> SRR1168749     2  0.3400      0.920 0.000 0.82 0.000 NA
#> SRR1168750     2  0.3400      0.920 0.000 0.82 0.000 NA
#> SRR1168751     2  0.3400      0.920 0.000 0.82 0.000 NA
#> SRR1168752     2  0.3400      0.920 0.000 0.82 0.000 NA
#> SRR1168753     2  0.3400      0.920 0.000 0.82 0.000 NA
#> SRR1168754     2  0.3400      0.920 0.000 0.82 0.000 NA
#> SRR1168755     2  0.3400      0.920 0.000 0.82 0.000 NA
#> SRR1168756     2  0.3400      0.920 0.000 0.82 0.000 NA
#> SRR1168757     2  0.3400      0.920 0.000 0.82 0.000 NA
#> SRR1168758     2  0.3400      0.920 0.000 0.82 0.000 NA
#> SRR1168759     2  0.3400      0.920 0.000 0.82 0.000 NA
#> SRR1168760     2  0.3400      0.920 0.000 0.82 0.000 NA
#> SRR1168761     3  0.3486      0.971 0.188 0.00 0.812 NA
#> SRR1168762     3  0.3486      0.971 0.188 0.00 0.812 NA
#> SRR1168763     3  0.3486      0.971 0.188 0.00 0.812 NA
#> SRR1168764     3  0.3486      0.971 0.188 0.00 0.812 NA
#> SRR1168765     3  0.3486      0.971 0.188 0.00 0.812 NA
#> SRR1168766     3  0.3486      0.971 0.188 0.00 0.812 NA
#> SRR1168767     3  0.3668      0.969 0.188 0.00 0.808 NA
#> SRR1168768     3  0.3486      0.971 0.188 0.00 0.812 NA
#> SRR1168769     1  0.1305      0.975 0.960 0.00 0.004 NA
#> SRR1168770     1  0.1305      0.975 0.960 0.00 0.004 NA
#> SRR1168771     1  0.1305      0.975 0.960 0.00 0.004 NA
#> SRR1168772     1  0.1305      0.975 0.960 0.00 0.004 NA
#> SRR1168773     1  0.1305      0.975 0.960 0.00 0.004 NA
#> SRR1168774     1  0.1305      0.975 0.960 0.00 0.004 NA
#> SRR1168775     1  0.1305      0.975 0.960 0.00 0.004 NA
#> SRR1168776     1  0.1452      0.973 0.956 0.00 0.008 NA
#> SRR1168777     1  0.1209      0.976 0.964 0.00 0.004 NA

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3 p4    p5
#> SRR1168715     3  0.4069      0.912 0.136 0.000 0.788 NA 0.000
#> SRR1168716     3  0.4069      0.912 0.136 0.000 0.788 NA 0.000
#> SRR1168717     3  0.4069      0.912 0.136 0.000 0.788 NA 0.000
#> SRR1168718     3  0.4054      0.910 0.140 0.000 0.788 NA 0.000
#> SRR1168719     3  0.4069      0.912 0.136 0.000 0.788 NA 0.000
#> SRR1168720     3  0.4096      0.908 0.144 0.000 0.784 NA 0.000
#> SRR1168721     3  0.4069      0.912 0.136 0.000 0.788 NA 0.000
#> SRR1168722     1  0.0693      0.885 0.980 0.000 0.012 NA 0.000
#> SRR1168723     1  0.0404      0.887 0.988 0.000 0.012 NA 0.000
#> SRR1168724     1  0.0912      0.883 0.972 0.000 0.016 NA 0.000
#> SRR1168725     1  0.0798      0.884 0.976 0.000 0.016 NA 0.000
#> SRR1168726     1  0.0404      0.887 0.988 0.000 0.012 NA 0.000
#> SRR1168727     1  0.0807      0.884 0.976 0.000 0.012 NA 0.000
#> SRR1168728     1  0.0566      0.886 0.984 0.000 0.012 NA 0.000
#> SRR1168729     1  0.0693      0.885 0.980 0.000 0.012 NA 0.000
#> SRR1168730     1  0.0510      0.886 0.984 0.000 0.016 NA 0.000
#> SRR1168731     1  0.0693      0.885 0.980 0.000 0.012 NA 0.000
#> SRR1168732     1  0.0566      0.886 0.984 0.000 0.012 NA 0.000
#> SRR1168733     2  0.0000      0.987 0.000 1.000 0.000 NA 0.000
#> SRR1168734     2  0.0510      0.980 0.000 0.984 0.000 NA 0.000
#> SRR1168735     2  0.0290      0.987 0.000 0.992 0.000 NA 0.000
#> SRR1168736     2  0.0000      0.987 0.000 1.000 0.000 NA 0.000
#> SRR1168737     2  0.0000      0.987 0.000 1.000 0.000 NA 0.000
#> SRR1168738     2  0.0290      0.987 0.000 0.992 0.000 NA 0.000
#> SRR1168739     2  0.0290      0.986 0.000 0.992 0.000 NA 0.000
#> SRR1168740     2  0.0000      0.987 0.000 1.000 0.000 NA 0.000
#> SRR1168741     2  0.0404      0.984 0.000 0.988 0.000 NA 0.000
#> SRR1168742     2  0.0000      0.987 0.000 1.000 0.000 NA 0.000
#> SRR1168743     2  0.0000      0.987 0.000 1.000 0.000 NA 0.000
#> SRR1168744     2  0.0290      0.987 0.000 0.992 0.000 NA 0.000
#> SRR1168745     2  0.0609      0.976 0.000 0.980 0.000 NA 0.000
#> SRR1168746     2  0.0510      0.981 0.000 0.984 0.000 NA 0.000
#> SRR1168747     5  0.4300      0.991 0.000 0.476 0.000 NA 0.524
#> SRR1168748     5  0.4304      0.993 0.000 0.484 0.000 NA 0.516
#> SRR1168749     5  0.4304      0.993 0.000 0.484 0.000 NA 0.516
#> SRR1168750     5  0.4304      0.993 0.000 0.484 0.000 NA 0.516
#> SRR1168751     5  0.4304      0.993 0.000 0.484 0.000 NA 0.516
#> SRR1168752     5  0.4302      0.994 0.000 0.480 0.000 NA 0.520
#> SRR1168753     5  0.4302      0.992 0.000 0.480 0.000 NA 0.520
#> SRR1168754     5  0.4302      0.994 0.000 0.480 0.000 NA 0.520
#> SRR1168755     5  0.4300      0.991 0.000 0.476 0.000 NA 0.524
#> SRR1168756     5  0.4302      0.994 0.000 0.480 0.000 NA 0.520
#> SRR1168757     5  0.4300      0.991 0.000 0.476 0.000 NA 0.524
#> SRR1168758     5  0.4305      0.987 0.000 0.488 0.000 NA 0.512
#> SRR1168759     5  0.4302      0.994 0.000 0.480 0.000 NA 0.520
#> SRR1168760     5  0.4302      0.994 0.000 0.480 0.000 NA 0.520
#> SRR1168761     3  0.1430      0.924 0.052 0.000 0.944 NA 0.000
#> SRR1168762     3  0.1430      0.924 0.052 0.000 0.944 NA 0.000
#> SRR1168763     3  0.1430      0.925 0.052 0.000 0.944 NA 0.004
#> SRR1168764     3  0.1557      0.923 0.052 0.000 0.940 NA 0.000
#> SRR1168765     3  0.1502      0.922 0.056 0.000 0.940 NA 0.000
#> SRR1168766     3  0.1430      0.925 0.052 0.000 0.944 NA 0.004
#> SRR1168767     3  0.1557      0.923 0.052 0.000 0.940 NA 0.000
#> SRR1168768     3  0.1430      0.925 0.052 0.000 0.944 NA 0.004
#> SRR1168769     1  0.4335      0.854 0.760 0.000 0.072 NA 0.000
#> SRR1168770     1  0.4119      0.860 0.780 0.000 0.068 NA 0.000
#> SRR1168771     1  0.4219      0.858 0.772 0.000 0.072 NA 0.000
#> SRR1168772     1  0.4502      0.845 0.744 0.000 0.076 NA 0.000
#> SRR1168773     1  0.4179      0.860 0.776 0.000 0.072 NA 0.000
#> SRR1168774     1  0.4258      0.857 0.768 0.000 0.072 NA 0.000
#> SRR1168775     1  0.4335      0.854 0.760 0.000 0.072 NA 0.000
#> SRR1168776     1  0.4393      0.852 0.756 0.000 0.076 NA 0.000
#> SRR1168777     1  0.4199      0.859 0.772 0.000 0.068 NA 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
#> SRR1168715     3  0.1814      0.836 0.100 0.000 0.900 NA 0.000 NA
#> SRR1168716     3  0.1814      0.836 0.100 0.000 0.900 NA 0.000 NA
#> SRR1168717     3  0.1863      0.835 0.104 0.000 0.896 NA 0.000 NA
#> SRR1168718     3  0.1863      0.834 0.104 0.000 0.896 NA 0.000 NA
#> SRR1168719     3  0.2070      0.836 0.100 0.000 0.892 NA 0.000 NA
#> SRR1168720     3  0.2003      0.827 0.116 0.000 0.884 NA 0.000 NA
#> SRR1168721     3  0.2266      0.828 0.108 0.000 0.880 NA 0.000 NA
#> SRR1168722     1  0.0405      0.774 0.988 0.000 0.004 NA 0.000 NA
#> SRR1168723     1  0.0508      0.780 0.984 0.000 0.004 NA 0.000 NA
#> SRR1168724     1  0.0520      0.774 0.984 0.000 0.008 NA 0.000 NA
#> SRR1168725     1  0.0405      0.780 0.988 0.000 0.004 NA 0.000 NA
#> SRR1168726     1  0.0405      0.780 0.988 0.000 0.004 NA 0.000 NA
#> SRR1168727     1  0.0146      0.778 0.996 0.000 0.004 NA 0.000 NA
#> SRR1168728     1  0.0291      0.779 0.992 0.000 0.004 NA 0.000 NA
#> SRR1168729     1  0.0291      0.779 0.992 0.000 0.004 NA 0.000 NA
#> SRR1168730     1  0.0622      0.779 0.980 0.000 0.008 NA 0.000 NA
#> SRR1168731     1  0.0146      0.778 0.996 0.000 0.004 NA 0.000 NA
#> SRR1168732     1  0.0291      0.779 0.992 0.000 0.004 NA 0.000 NA
#> SRR1168733     2  0.3859      0.959 0.000 0.692 0.000 NA 0.288 NA
#> SRR1168734     2  0.3470      0.971 0.000 0.740 0.000 NA 0.248 NA
#> SRR1168735     2  0.3608      0.972 0.000 0.716 0.000 NA 0.272 NA
#> SRR1168736     2  0.3541      0.974 0.000 0.728 0.000 NA 0.260 NA
#> SRR1168737     2  0.3582      0.972 0.000 0.732 0.000 NA 0.252 NA
#> SRR1168738     2  0.3445      0.969 0.000 0.744 0.000 NA 0.244 NA
#> SRR1168739     2  0.3175      0.974 0.000 0.744 0.000 NA 0.256 NA
#> SRR1168740     2  0.3309      0.970 0.000 0.720 0.000 NA 0.280 NA
#> SRR1168741     2  0.3650      0.968 0.000 0.708 0.000 NA 0.280 NA
#> SRR1168742     2  0.3650      0.967 0.000 0.708 0.000 NA 0.280 NA
#> SRR1168743     2  0.3615      0.957 0.000 0.700 0.000 NA 0.292 NA
#> SRR1168744     2  0.3421      0.974 0.000 0.736 0.000 NA 0.256 NA
#> SRR1168745     2  0.3445      0.975 0.000 0.732 0.000 NA 0.260 NA
#> SRR1168746     2  0.3445      0.965 0.000 0.744 0.000 NA 0.244 NA
#> SRR1168747     5  0.0000      0.991 0.000 0.000 0.000 NA 1.000 NA
#> SRR1168748     5  0.0260      0.990 0.000 0.008 0.000 NA 0.992 NA
#> SRR1168749     5  0.0291      0.991 0.000 0.004 0.000 NA 0.992 NA
#> SRR1168750     5  0.0405      0.989 0.000 0.004 0.000 NA 0.988 NA
#> SRR1168751     5  0.0405      0.990 0.000 0.004 0.000 NA 0.988 NA
#> SRR1168752     5  0.0713      0.978 0.000 0.000 0.000 NA 0.972 NA
#> SRR1168753     5  0.0146      0.991 0.000 0.000 0.000 NA 0.996 NA
#> SRR1168754     5  0.0000      0.991 0.000 0.000 0.000 NA 1.000 NA
#> SRR1168755     5  0.0363      0.989 0.000 0.000 0.000 NA 0.988 NA
#> SRR1168756     5  0.0146      0.991 0.000 0.000 0.000 NA 0.996 NA
#> SRR1168757     5  0.0146      0.991 0.000 0.004 0.000 NA 0.996 NA
#> SRR1168758     5  0.0405      0.990 0.000 0.008 0.000 NA 0.988 NA
#> SRR1168759     5  0.0260      0.990 0.000 0.000 0.000 NA 0.992 NA
#> SRR1168760     5  0.0520      0.988 0.000 0.008 0.000 NA 0.984 NA
#> SRR1168761     3  0.4201      0.856 0.012 0.000 0.716 NA 0.000 NA
#> SRR1168762     3  0.4124      0.859 0.012 0.000 0.728 NA 0.000 NA
#> SRR1168763     3  0.4176      0.857 0.012 0.000 0.720 NA 0.000 NA
#> SRR1168764     3  0.4201      0.856 0.012 0.000 0.716 NA 0.000 NA
#> SRR1168765     3  0.4150      0.858 0.012 0.000 0.724 NA 0.000 NA
#> SRR1168766     3  0.4201      0.856 0.012 0.000 0.716 NA 0.000 NA
#> SRR1168767     3  0.4150      0.858 0.012 0.000 0.724 NA 0.000 NA
#> SRR1168768     3  0.4124      0.859 0.012 0.000 0.728 NA 0.000 NA
#> SRR1168769     1  0.4172      0.711 0.528 0.000 0.012 NA 0.000 NA
#> SRR1168770     1  0.4157      0.716 0.544 0.000 0.012 NA 0.000 NA
#> SRR1168771     1  0.4161      0.715 0.540 0.000 0.012 NA 0.000 NA
#> SRR1168772     1  0.4172      0.711 0.528 0.000 0.012 NA 0.000 NA
#> SRR1168773     1  0.4169      0.712 0.532 0.000 0.012 NA 0.000 NA
#> SRR1168774     1  0.4161      0.715 0.540 0.000 0.012 NA 0.000 NA
#> SRR1168775     1  0.4177      0.706 0.520 0.000 0.012 NA 0.000 NA
#> SRR1168776     1  0.4183      0.698 0.508 0.000 0.012 NA 0.000 NA
#> SRR1168777     1  0.4169      0.712 0.532 0.000 0.012 NA 0.000 NA

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

consensus_heatmap(res, k = 2)

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

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

collect_plots(res)

plot of chunk CV-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.5023 0.498   0.498
#> 3 3 1.000           1.000       1.000         0.3055 0.846   0.692
#> 4 4 0.963           0.981       0.950         0.0526 0.949   0.853
#> 5 5 0.926           0.899       0.914         0.0215 0.993   0.976
#> 6 6 0.974           0.899       0.961         0.0301 0.996   0.986

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette p1 p2
#> SRR1168715     1       0          1  1  0
#> SRR1168716     1       0          1  1  0
#> SRR1168717     1       0          1  1  0
#> SRR1168718     1       0          1  1  0
#> SRR1168719     1       0          1  1  0
#> SRR1168720     1       0          1  1  0
#> SRR1168721     1       0          1  1  0
#> SRR1168722     1       0          1  1  0
#> SRR1168723     1       0          1  1  0
#> SRR1168724     1       0          1  1  0
#> SRR1168725     1       0          1  1  0
#> SRR1168726     1       0          1  1  0
#> SRR1168727     1       0          1  1  0
#> SRR1168728     1       0          1  1  0
#> SRR1168729     1       0          1  1  0
#> SRR1168730     1       0          1  1  0
#> SRR1168731     1       0          1  1  0
#> SRR1168732     1       0          1  1  0
#> SRR1168733     2       0          1  0  1
#> SRR1168734     2       0          1  0  1
#> SRR1168735     2       0          1  0  1
#> SRR1168736     2       0          1  0  1
#> SRR1168737     2       0          1  0  1
#> SRR1168738     2       0          1  0  1
#> SRR1168739     2       0          1  0  1
#> SRR1168740     2       0          1  0  1
#> SRR1168741     2       0          1  0  1
#> SRR1168742     2       0          1  0  1
#> SRR1168743     2       0          1  0  1
#> SRR1168744     2       0          1  0  1
#> SRR1168745     2       0          1  0  1
#> SRR1168746     2       0          1  0  1
#> SRR1168747     2       0          1  0  1
#> SRR1168748     2       0          1  0  1
#> SRR1168749     2       0          1  0  1
#> SRR1168750     2       0          1  0  1
#> SRR1168751     2       0          1  0  1
#> SRR1168752     2       0          1  0  1
#> SRR1168753     2       0          1  0  1
#> SRR1168754     2       0          1  0  1
#> SRR1168755     2       0          1  0  1
#> SRR1168756     2       0          1  0  1
#> SRR1168757     2       0          1  0  1
#> SRR1168758     2       0          1  0  1
#> SRR1168759     2       0          1  0  1
#> SRR1168760     2       0          1  0  1
#> SRR1168761     1       0          1  1  0
#> SRR1168762     1       0          1  1  0
#> SRR1168763     1       0          1  1  0
#> SRR1168764     1       0          1  1  0
#> SRR1168765     1       0          1  1  0
#> SRR1168766     1       0          1  1  0
#> SRR1168767     1       0          1  1  0
#> SRR1168768     1       0          1  1  0
#> SRR1168769     1       0          1  1  0
#> SRR1168770     1       0          1  1  0
#> SRR1168771     1       0          1  1  0
#> SRR1168772     1       0          1  1  0
#> SRR1168773     1       0          1  1  0
#> SRR1168774     1       0          1  1  0
#> SRR1168775     1       0          1  1  0
#> SRR1168776     1       0          1  1  0
#> SRR1168777     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette p1 p2 p3
#> SRR1168715     3       0          1  0  0  1
#> SRR1168716     3       0          1  0  0  1
#> SRR1168717     3       0          1  0  0  1
#> SRR1168718     3       0          1  0  0  1
#> SRR1168719     3       0          1  0  0  1
#> SRR1168720     3       0          1  0  0  1
#> SRR1168721     3       0          1  0  0  1
#> SRR1168722     1       0          1  1  0  0
#> SRR1168723     1       0          1  1  0  0
#> SRR1168724     1       0          1  1  0  0
#> SRR1168725     1       0          1  1  0  0
#> SRR1168726     1       0          1  1  0  0
#> SRR1168727     1       0          1  1  0  0
#> SRR1168728     1       0          1  1  0  0
#> SRR1168729     1       0          1  1  0  0
#> SRR1168730     1       0          1  1  0  0
#> SRR1168731     1       0          1  1  0  0
#> SRR1168732     1       0          1  1  0  0
#> SRR1168733     2       0          1  0  1  0
#> SRR1168734     2       0          1  0  1  0
#> SRR1168735     2       0          1  0  1  0
#> SRR1168736     2       0          1  0  1  0
#> SRR1168737     2       0          1  0  1  0
#> SRR1168738     2       0          1  0  1  0
#> SRR1168739     2       0          1  0  1  0
#> SRR1168740     2       0          1  0  1  0
#> SRR1168741     2       0          1  0  1  0
#> SRR1168742     2       0          1  0  1  0
#> SRR1168743     2       0          1  0  1  0
#> SRR1168744     2       0          1  0  1  0
#> SRR1168745     2       0          1  0  1  0
#> SRR1168746     2       0          1  0  1  0
#> SRR1168747     2       0          1  0  1  0
#> SRR1168748     2       0          1  0  1  0
#> SRR1168749     2       0          1  0  1  0
#> SRR1168750     2       0          1  0  1  0
#> SRR1168751     2       0          1  0  1  0
#> SRR1168752     2       0          1  0  1  0
#> SRR1168753     2       0          1  0  1  0
#> SRR1168754     2       0          1  0  1  0
#> SRR1168755     2       0          1  0  1  0
#> SRR1168756     2       0          1  0  1  0
#> SRR1168757     2       0          1  0  1  0
#> SRR1168758     2       0          1  0  1  0
#> SRR1168759     2       0          1  0  1  0
#> SRR1168760     2       0          1  0  1  0
#> SRR1168761     3       0          1  0  0  1
#> SRR1168762     3       0          1  0  0  1
#> SRR1168763     3       0          1  0  0  1
#> SRR1168764     3       0          1  0  0  1
#> SRR1168765     3       0          1  0  0  1
#> SRR1168766     3       0          1  0  0  1
#> SRR1168767     3       0          1  0  0  1
#> SRR1168768     3       0          1  0  0  1
#> SRR1168769     1       0          1  1  0  0
#> SRR1168770     1       0          1  1  0  0
#> SRR1168771     1       0          1  1  0  0
#> SRR1168772     1       0          1  1  0  0
#> SRR1168773     1       0          1  1  0  0
#> SRR1168774     1       0          1  1  0  0
#> SRR1168775     1       0          1  1  0  0
#> SRR1168776     1       0          1  1  0  0
#> SRR1168777     1       0          1  1  0  0

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1 p2 p3    p4
#> SRR1168715     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1168716     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1168717     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1168718     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1168719     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1168720     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1168721     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1168722     1  0.4843      1.000 0.604  0  0 0.396
#> SRR1168723     1  0.4843      1.000 0.604  0  0 0.396
#> SRR1168724     1  0.4843      1.000 0.604  0  0 0.396
#> SRR1168725     1  0.4843      1.000 0.604  0  0 0.396
#> SRR1168726     1  0.4843      1.000 0.604  0  0 0.396
#> SRR1168727     1  0.4843      1.000 0.604  0  0 0.396
#> SRR1168728     1  0.4843      1.000 0.604  0  0 0.396
#> SRR1168729     1  0.4843      1.000 0.604  0  0 0.396
#> SRR1168730     1  0.4843      1.000 0.604  0  0 0.396
#> SRR1168731     1  0.4843      1.000 0.604  0  0 0.396
#> SRR1168732     1  0.4843      1.000 0.604  0  0 0.396
#> SRR1168733     2  0.0000      1.000 0.000  1  0 0.000
#> SRR1168734     2  0.0000      1.000 0.000  1  0 0.000
#> SRR1168735     2  0.0000      1.000 0.000  1  0 0.000
#> SRR1168736     2  0.0000      1.000 0.000  1  0 0.000
#> SRR1168737     2  0.0000      1.000 0.000  1  0 0.000
#> SRR1168738     2  0.0000      1.000 0.000  1  0 0.000
#> SRR1168739     2  0.0000      1.000 0.000  1  0 0.000
#> SRR1168740     2  0.0000      1.000 0.000  1  0 0.000
#> SRR1168741     2  0.0000      1.000 0.000  1  0 0.000
#> SRR1168742     2  0.0000      1.000 0.000  1  0 0.000
#> SRR1168743     2  0.0000      1.000 0.000  1  0 0.000
#> SRR1168744     2  0.0000      1.000 0.000  1  0 0.000
#> SRR1168745     2  0.0000      1.000 0.000  1  0 0.000
#> SRR1168746     2  0.0000      1.000 0.000  1  0 0.000
#> SRR1168747     2  0.0000      1.000 0.000  1  0 0.000
#> SRR1168748     2  0.0000      1.000 0.000  1  0 0.000
#> SRR1168749     2  0.0000      1.000 0.000  1  0 0.000
#> SRR1168750     2  0.0000      1.000 0.000  1  0 0.000
#> SRR1168751     2  0.0000      1.000 0.000  1  0 0.000
#> SRR1168752     2  0.0000      1.000 0.000  1  0 0.000
#> SRR1168753     2  0.0000      1.000 0.000  1  0 0.000
#> SRR1168754     2  0.0000      1.000 0.000  1  0 0.000
#> SRR1168755     2  0.0000      1.000 0.000  1  0 0.000
#> SRR1168756     2  0.0000      1.000 0.000  1  0 0.000
#> SRR1168757     2  0.0000      1.000 0.000  1  0 0.000
#> SRR1168758     2  0.0000      1.000 0.000  1  0 0.000
#> SRR1168759     2  0.0000      1.000 0.000  1  0 0.000
#> SRR1168760     2  0.0000      1.000 0.000  1  0 0.000
#> SRR1168761     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1168762     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1168763     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1168764     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1168765     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1168766     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1168767     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1168768     3  0.0000      1.000 0.000  0  1 0.000
#> SRR1168769     4  0.0000      0.917 0.000  0  0 1.000
#> SRR1168770     4  0.0188      0.914 0.004  0  0 0.996
#> SRR1168771     4  0.0000      0.917 0.000  0  0 1.000
#> SRR1168772     4  0.0000      0.917 0.000  0  0 1.000
#> SRR1168773     4  0.0000      0.917 0.000  0  0 1.000
#> SRR1168774     4  0.0188      0.914 0.004  0  0 0.996
#> SRR1168775     4  0.0000      0.917 0.000  0  0 1.000
#> SRR1168776     4  0.0000      0.917 0.000  0  0 1.000
#> SRR1168777     4  0.4843      0.498 0.396  0  0 0.604

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1 p2    p3    p4    p5
#> SRR1168715     3  0.0000      0.640 0.000  0 1.000 0.000 0.000
#> SRR1168716     3  0.0000      0.640 0.000  0 1.000 0.000 0.000
#> SRR1168717     3  0.0000      0.640 0.000  0 1.000 0.000 0.000
#> SRR1168718     3  0.0000      0.640 0.000  0 1.000 0.000 0.000
#> SRR1168719     3  0.0000      0.640 0.000  0 1.000 0.000 0.000
#> SRR1168720     3  0.0000      0.640 0.000  0 1.000 0.000 0.000
#> SRR1168721     5  0.4161      0.000 0.000  0 0.392 0.000 0.608
#> SRR1168722     1  0.4161      1.000 0.608  0 0.000 0.392 0.000
#> SRR1168723     1  0.4161      1.000 0.608  0 0.000 0.392 0.000
#> SRR1168724     1  0.4161      1.000 0.608  0 0.000 0.392 0.000
#> SRR1168725     1  0.4161      1.000 0.608  0 0.000 0.392 0.000
#> SRR1168726     1  0.4161      1.000 0.608  0 0.000 0.392 0.000
#> SRR1168727     1  0.4161      1.000 0.608  0 0.000 0.392 0.000
#> SRR1168728     1  0.4161      1.000 0.608  0 0.000 0.392 0.000
#> SRR1168729     1  0.4161      1.000 0.608  0 0.000 0.392 0.000
#> SRR1168730     1  0.4161      1.000 0.608  0 0.000 0.392 0.000
#> SRR1168731     1  0.4161      1.000 0.608  0 0.000 0.392 0.000
#> SRR1168732     1  0.4161      1.000 0.608  0 0.000 0.392 0.000
#> SRR1168733     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> SRR1168734     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> SRR1168735     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> SRR1168736     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> SRR1168737     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> SRR1168738     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> SRR1168739     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> SRR1168740     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> SRR1168741     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> SRR1168742     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> SRR1168743     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> SRR1168744     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> SRR1168745     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> SRR1168746     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> SRR1168747     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> SRR1168748     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> SRR1168749     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> SRR1168750     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> SRR1168751     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> SRR1168752     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> SRR1168753     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> SRR1168754     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> SRR1168755     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> SRR1168756     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> SRR1168757     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> SRR1168758     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> SRR1168759     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> SRR1168760     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> SRR1168761     3  0.4045      0.785 0.000  0 0.644 0.000 0.356
#> SRR1168762     3  0.4045      0.785 0.000  0 0.644 0.000 0.356
#> SRR1168763     3  0.4045      0.785 0.000  0 0.644 0.000 0.356
#> SRR1168764     3  0.4045      0.785 0.000  0 0.644 0.000 0.356
#> SRR1168765     3  0.4045      0.785 0.000  0 0.644 0.000 0.356
#> SRR1168766     3  0.4045      0.785 0.000  0 0.644 0.000 0.356
#> SRR1168767     3  0.4045      0.785 0.000  0 0.644 0.000 0.356
#> SRR1168768     3  0.4045      0.785 0.000  0 0.644 0.000 0.356
#> SRR1168769     4  0.0000      0.913 0.000  0 0.000 1.000 0.000
#> SRR1168770     4  0.0162      0.912 0.000  0 0.000 0.996 0.004
#> SRR1168771     4  0.0000      0.913 0.000  0 0.000 1.000 0.000
#> SRR1168772     4  0.0000      0.913 0.000  0 0.000 1.000 0.000
#> SRR1168773     4  0.0000      0.913 0.000  0 0.000 1.000 0.000
#> SRR1168774     4  0.0290      0.911 0.000  0 0.000 0.992 0.008
#> SRR1168775     4  0.0162      0.913 0.000  0 0.000 0.996 0.004
#> SRR1168776     4  0.0162      0.913 0.000  0 0.000 0.996 0.004
#> SRR1168777     4  0.5010      0.231 0.392  0 0.000 0.572 0.036

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette p1    p2    p3    p4 p5    p6
#> SRR1168715     3  0.3727      0.610  0 0.000 0.612 0.000  0 0.388
#> SRR1168716     3  0.3727      0.610  0 0.000 0.612 0.000  0 0.388
#> SRR1168717     3  0.3727      0.610  0 0.000 0.612 0.000  0 0.388
#> SRR1168718     3  0.3727      0.610  0 0.000 0.612 0.000  0 0.388
#> SRR1168719     3  0.3727      0.610  0 0.000 0.612 0.000  0 0.388
#> SRR1168720     3  0.3727      0.610  0 0.000 0.612 0.000  0 0.388
#> SRR1168721     6  0.0000      0.000  0 0.000 0.000 0.000  0 1.000
#> SRR1168722     1  0.0000      1.000  1 0.000 0.000 0.000  0 0.000
#> SRR1168723     1  0.0000      1.000  1 0.000 0.000 0.000  0 0.000
#> SRR1168724     1  0.0000      1.000  1 0.000 0.000 0.000  0 0.000
#> SRR1168725     1  0.0000      1.000  1 0.000 0.000 0.000  0 0.000
#> SRR1168726     1  0.0000      1.000  1 0.000 0.000 0.000  0 0.000
#> SRR1168727     1  0.0000      1.000  1 0.000 0.000 0.000  0 0.000
#> SRR1168728     1  0.0000      1.000  1 0.000 0.000 0.000  0 0.000
#> SRR1168729     1  0.0000      1.000  1 0.000 0.000 0.000  0 0.000
#> SRR1168730     1  0.0000      1.000  1 0.000 0.000 0.000  0 0.000
#> SRR1168731     1  0.0000      1.000  1 0.000 0.000 0.000  0 0.000
#> SRR1168732     1  0.0000      1.000  1 0.000 0.000 0.000  0 0.000
#> SRR1168733     5  0.0000      1.000  0 0.000 0.000 0.000  1 0.000
#> SRR1168734     5  0.0000      1.000  0 0.000 0.000 0.000  1 0.000
#> SRR1168735     5  0.0000      1.000  0 0.000 0.000 0.000  1 0.000
#> SRR1168736     5  0.0000      1.000  0 0.000 0.000 0.000  1 0.000
#> SRR1168737     5  0.0000      1.000  0 0.000 0.000 0.000  1 0.000
#> SRR1168738     5  0.0000      1.000  0 0.000 0.000 0.000  1 0.000
#> SRR1168739     5  0.0000      1.000  0 0.000 0.000 0.000  1 0.000
#> SRR1168740     5  0.0000      1.000  0 0.000 0.000 0.000  1 0.000
#> SRR1168741     5  0.0000      1.000  0 0.000 0.000 0.000  1 0.000
#> SRR1168742     5  0.0000      1.000  0 0.000 0.000 0.000  1 0.000
#> SRR1168743     5  0.0000      1.000  0 0.000 0.000 0.000  1 0.000
#> SRR1168744     5  0.0000      1.000  0 0.000 0.000 0.000  1 0.000
#> SRR1168745     5  0.0000      1.000  0 0.000 0.000 0.000  1 0.000
#> SRR1168746     5  0.0000      1.000  0 0.000 0.000 0.000  1 0.000
#> SRR1168747     5  0.0000      1.000  0 0.000 0.000 0.000  1 0.000
#> SRR1168748     5  0.0000      1.000  0 0.000 0.000 0.000  1 0.000
#> SRR1168749     5  0.0000      1.000  0 0.000 0.000 0.000  1 0.000
#> SRR1168750     5  0.0000      1.000  0 0.000 0.000 0.000  1 0.000
#> SRR1168751     5  0.0000      1.000  0 0.000 0.000 0.000  1 0.000
#> SRR1168752     5  0.0000      1.000  0 0.000 0.000 0.000  1 0.000
#> SRR1168753     5  0.0000      1.000  0 0.000 0.000 0.000  1 0.000
#> SRR1168754     5  0.0000      1.000  0 0.000 0.000 0.000  1 0.000
#> SRR1168755     5  0.0000      1.000  0 0.000 0.000 0.000  1 0.000
#> SRR1168756     5  0.0000      1.000  0 0.000 0.000 0.000  1 0.000
#> SRR1168757     5  0.0000      1.000  0 0.000 0.000 0.000  1 0.000
#> SRR1168758     5  0.0000      1.000  0 0.000 0.000 0.000  1 0.000
#> SRR1168759     5  0.0000      1.000  0 0.000 0.000 0.000  1 0.000
#> SRR1168760     5  0.0000      1.000  0 0.000 0.000 0.000  1 0.000
#> SRR1168761     3  0.0000      0.773  0 0.000 1.000 0.000  0 0.000
#> SRR1168762     3  0.0000      0.773  0 0.000 1.000 0.000  0 0.000
#> SRR1168763     3  0.0000      0.773  0 0.000 1.000 0.000  0 0.000
#> SRR1168764     3  0.0000      0.773  0 0.000 1.000 0.000  0 0.000
#> SRR1168765     3  0.0000      0.773  0 0.000 1.000 0.000  0 0.000
#> SRR1168766     3  0.0000      0.773  0 0.000 1.000 0.000  0 0.000
#> SRR1168767     3  0.0000      0.773  0 0.000 1.000 0.000  0 0.000
#> SRR1168768     3  0.0000      0.773  0 0.000 1.000 0.000  0 0.000
#> SRR1168769     4  0.0000      0.980  0 0.000 0.000 1.000  0 0.000
#> SRR1168770     4  0.0260      0.978  0 0.008 0.000 0.992  0 0.000
#> SRR1168771     4  0.0000      0.980  0 0.000 0.000 1.000  0 0.000
#> SRR1168772     4  0.0000      0.980  0 0.000 0.000 1.000  0 0.000
#> SRR1168773     4  0.0000      0.980  0 0.000 0.000 1.000  0 0.000
#> SRR1168774     4  0.1556      0.931  0 0.080 0.000 0.920  0 0.000
#> SRR1168775     4  0.0713      0.972  0 0.028 0.000 0.972  0 0.000
#> SRR1168776     4  0.0713      0.972  0 0.028 0.000 0.972  0 0.000
#> SRR1168777     2  0.0000      0.000  0 1.000 0.000 0.000  0 0.000

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

consensus_heatmap(res, k = 2)

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

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

collect_plots(res)

plot of chunk CV-kmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.5023 0.498   0.498
#> 3 3 0.667           0.846       0.807         0.2678 0.846   0.692
#> 4 4 0.668           0.896       0.788         0.1063 0.900   0.709
#> 5 5 0.621           0.827       0.742         0.0633 1.000   1.000
#> 6 6 0.677           0.885       0.757         0.0505 0.949   0.792

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
#> SRR1168715     1       0          1  1  0
#> SRR1168716     1       0          1  1  0
#> SRR1168717     1       0          1  1  0
#> SRR1168718     1       0          1  1  0
#> SRR1168719     1       0          1  1  0
#> SRR1168720     1       0          1  1  0
#> SRR1168721     1       0          1  1  0
#> SRR1168722     1       0          1  1  0
#> SRR1168723     1       0          1  1  0
#> SRR1168724     1       0          1  1  0
#> SRR1168725     1       0          1  1  0
#> SRR1168726     1       0          1  1  0
#> SRR1168727     1       0          1  1  0
#> SRR1168728     1       0          1  1  0
#> SRR1168729     1       0          1  1  0
#> SRR1168730     1       0          1  1  0
#> SRR1168731     1       0          1  1  0
#> SRR1168732     1       0          1  1  0
#> SRR1168733     2       0          1  0  1
#> SRR1168734     2       0          1  0  1
#> SRR1168735     2       0          1  0  1
#> SRR1168736     2       0          1  0  1
#> SRR1168737     2       0          1  0  1
#> SRR1168738     2       0          1  0  1
#> SRR1168739     2       0          1  0  1
#> SRR1168740     2       0          1  0  1
#> SRR1168741     2       0          1  0  1
#> SRR1168742     2       0          1  0  1
#> SRR1168743     2       0          1  0  1
#> SRR1168744     2       0          1  0  1
#> SRR1168745     2       0          1  0  1
#> SRR1168746     2       0          1  0  1
#> SRR1168747     2       0          1  0  1
#> SRR1168748     2       0          1  0  1
#> SRR1168749     2       0          1  0  1
#> SRR1168750     2       0          1  0  1
#> SRR1168751     2       0          1  0  1
#> SRR1168752     2       0          1  0  1
#> SRR1168753     2       0          1  0  1
#> SRR1168754     2       0          1  0  1
#> SRR1168755     2       0          1  0  1
#> SRR1168756     2       0          1  0  1
#> SRR1168757     2       0          1  0  1
#> SRR1168758     2       0          1  0  1
#> SRR1168759     2       0          1  0  1
#> SRR1168760     2       0          1  0  1
#> SRR1168761     1       0          1  1  0
#> SRR1168762     1       0          1  1  0
#> SRR1168763     1       0          1  1  0
#> SRR1168764     1       0          1  1  0
#> SRR1168765     1       0          1  1  0
#> SRR1168766     1       0          1  1  0
#> SRR1168767     1       0          1  1  0
#> SRR1168768     1       0          1  1  0
#> SRR1168769     1       0          1  1  0
#> SRR1168770     1       0          1  1  0
#> SRR1168771     1       0          1  1  0
#> SRR1168772     1       0          1  1  0
#> SRR1168773     1       0          1  1  0
#> SRR1168774     1       0          1  1  0
#> SRR1168775     1       0          1  1  0
#> SRR1168776     1       0          1  1  0
#> SRR1168777     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1168715     3  0.6299      0.844 0.476 0.000 0.524
#> SRR1168716     3  0.6299      0.844 0.476 0.000 0.524
#> SRR1168717     3  0.6299      0.844 0.476 0.000 0.524
#> SRR1168718     3  0.6299      0.844 0.476 0.000 0.524
#> SRR1168719     3  0.6299      0.844 0.476 0.000 0.524
#> SRR1168720     3  0.6299      0.844 0.476 0.000 0.524
#> SRR1168721     3  0.6299      0.844 0.476 0.000 0.524
#> SRR1168722     1  0.0000      0.842 1.000 0.000 0.000
#> SRR1168723     1  0.0000      0.842 1.000 0.000 0.000
#> SRR1168724     1  0.0000      0.842 1.000 0.000 0.000
#> SRR1168725     1  0.0000      0.842 1.000 0.000 0.000
#> SRR1168726     1  0.0000      0.842 1.000 0.000 0.000
#> SRR1168727     1  0.0000      0.842 1.000 0.000 0.000
#> SRR1168728     1  0.0000      0.842 1.000 0.000 0.000
#> SRR1168729     1  0.0000      0.842 1.000 0.000 0.000
#> SRR1168730     1  0.0000      0.842 1.000 0.000 0.000
#> SRR1168731     1  0.0000      0.842 1.000 0.000 0.000
#> SRR1168732     1  0.0000      0.842 1.000 0.000 0.000
#> SRR1168733     2  0.5678      0.858 0.000 0.684 0.316
#> SRR1168734     2  0.5678      0.858 0.000 0.684 0.316
#> SRR1168735     2  0.5678      0.858 0.000 0.684 0.316
#> SRR1168736     2  0.5678      0.858 0.000 0.684 0.316
#> SRR1168737     2  0.5678      0.858 0.000 0.684 0.316
#> SRR1168738     2  0.5678      0.858 0.000 0.684 0.316
#> SRR1168739     2  0.5678      0.858 0.000 0.684 0.316
#> SRR1168740     2  0.5678      0.858 0.000 0.684 0.316
#> SRR1168741     2  0.5678      0.858 0.000 0.684 0.316
#> SRR1168742     2  0.5678      0.858 0.000 0.684 0.316
#> SRR1168743     2  0.5678      0.858 0.000 0.684 0.316
#> SRR1168744     2  0.5678      0.858 0.000 0.684 0.316
#> SRR1168745     2  0.5678      0.858 0.000 0.684 0.316
#> SRR1168746     2  0.5678      0.858 0.000 0.684 0.316
#> SRR1168747     2  0.0000      0.858 0.000 1.000 0.000
#> SRR1168748     2  0.0000      0.858 0.000 1.000 0.000
#> SRR1168749     2  0.0000      0.858 0.000 1.000 0.000
#> SRR1168750     2  0.0000      0.858 0.000 1.000 0.000
#> SRR1168751     2  0.0000      0.858 0.000 1.000 0.000
#> SRR1168752     2  0.0424      0.854 0.000 0.992 0.008
#> SRR1168753     2  0.0000      0.858 0.000 1.000 0.000
#> SRR1168754     2  0.0000      0.858 0.000 1.000 0.000
#> SRR1168755     2  0.0000      0.858 0.000 1.000 0.000
#> SRR1168756     2  0.0000      0.858 0.000 1.000 0.000
#> SRR1168757     2  0.0000      0.858 0.000 1.000 0.000
#> SRR1168758     2  0.0000      0.858 0.000 1.000 0.000
#> SRR1168759     2  0.0000      0.858 0.000 1.000 0.000
#> SRR1168760     2  0.0000      0.858 0.000 1.000 0.000
#> SRR1168761     3  0.5835      0.868 0.340 0.000 0.660
#> SRR1168762     3  0.5835      0.868 0.340 0.000 0.660
#> SRR1168763     3  0.5835      0.868 0.340 0.000 0.660
#> SRR1168764     3  0.5835      0.868 0.340 0.000 0.660
#> SRR1168765     3  0.5835      0.868 0.340 0.000 0.660
#> SRR1168766     3  0.5835      0.868 0.340 0.000 0.660
#> SRR1168767     3  0.5835      0.868 0.340 0.000 0.660
#> SRR1168768     3  0.5835      0.868 0.340 0.000 0.660
#> SRR1168769     1  0.4504      0.794 0.804 0.000 0.196
#> SRR1168770     1  0.4504      0.794 0.804 0.000 0.196
#> SRR1168771     1  0.4504      0.794 0.804 0.000 0.196
#> SRR1168772     1  0.4504      0.794 0.804 0.000 0.196
#> SRR1168773     1  0.4504      0.794 0.804 0.000 0.196
#> SRR1168774     1  0.4504      0.794 0.804 0.000 0.196
#> SRR1168775     1  0.4504      0.794 0.804 0.000 0.196
#> SRR1168776     1  0.4504      0.794 0.804 0.000 0.196
#> SRR1168777     1  0.4504      0.794 0.804 0.000 0.196

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1168715     3  0.7771      0.879 0.252 0.000 0.420 0.328
#> SRR1168716     3  0.7771      0.879 0.252 0.000 0.420 0.328
#> SRR1168717     3  0.7771      0.879 0.252 0.000 0.420 0.328
#> SRR1168718     3  0.7771      0.879 0.252 0.000 0.420 0.328
#> SRR1168719     3  0.7771      0.879 0.252 0.000 0.420 0.328
#> SRR1168720     3  0.7771      0.879 0.252 0.000 0.420 0.328
#> SRR1168721     3  0.7778      0.877 0.252 0.000 0.416 0.332
#> SRR1168722     1  0.4406      0.826 0.700 0.000 0.300 0.000
#> SRR1168723     1  0.4406      0.826 0.700 0.000 0.300 0.000
#> SRR1168724     1  0.4406      0.826 0.700 0.000 0.300 0.000
#> SRR1168725     1  0.4406      0.826 0.700 0.000 0.300 0.000
#> SRR1168726     1  0.4406      0.826 0.700 0.000 0.300 0.000
#> SRR1168727     1  0.4406      0.826 0.700 0.000 0.300 0.000
#> SRR1168728     1  0.4406      0.826 0.700 0.000 0.300 0.000
#> SRR1168729     1  0.4406      0.826 0.700 0.000 0.300 0.000
#> SRR1168730     1  0.4406      0.826 0.700 0.000 0.300 0.000
#> SRR1168731     1  0.4406      0.826 0.700 0.000 0.300 0.000
#> SRR1168732     1  0.4406      0.826 0.700 0.000 0.300 0.000
#> SRR1168733     2  0.0921      0.967 0.000 0.972 0.028 0.000
#> SRR1168734     2  0.1302      0.966 0.000 0.956 0.044 0.000
#> SRR1168735     2  0.0592      0.970 0.000 0.984 0.016 0.000
#> SRR1168736     2  0.1389      0.966 0.000 0.952 0.048 0.000
#> SRR1168737     2  0.1792      0.963 0.000 0.932 0.068 0.000
#> SRR1168738     2  0.1022      0.968 0.000 0.968 0.032 0.000
#> SRR1168739     2  0.0707      0.969 0.000 0.980 0.020 0.000
#> SRR1168740     2  0.1302      0.967 0.000 0.956 0.044 0.000
#> SRR1168741     2  0.1474      0.961 0.000 0.948 0.052 0.000
#> SRR1168742     2  0.0817      0.968 0.000 0.976 0.024 0.000
#> SRR1168743     2  0.1792      0.962 0.000 0.932 0.068 0.000
#> SRR1168744     2  0.0592      0.968 0.000 0.984 0.016 0.000
#> SRR1168745     2  0.1557      0.960 0.000 0.944 0.056 0.000
#> SRR1168746     2  0.1211      0.965 0.000 0.960 0.040 0.000
#> SRR1168747     4  0.5823      0.966 0.000 0.348 0.044 0.608
#> SRR1168748     4  0.5306      0.969 0.000 0.348 0.020 0.632
#> SRR1168749     4  0.4973      0.971 0.000 0.348 0.008 0.644
#> SRR1168750     4  0.5495      0.971 0.000 0.348 0.028 0.624
#> SRR1168751     4  0.5495      0.971 0.000 0.348 0.028 0.624
#> SRR1168752     4  0.6712      0.928 0.000 0.344 0.104 0.552
#> SRR1168753     4  0.5403      0.972 0.000 0.348 0.024 0.628
#> SRR1168754     4  0.5582      0.969 0.000 0.348 0.032 0.620
#> SRR1168755     4  0.5823      0.967 0.000 0.348 0.044 0.608
#> SRR1168756     4  0.5666      0.970 0.000 0.348 0.036 0.616
#> SRR1168757     4  0.5403      0.972 0.000 0.348 0.024 0.628
#> SRR1168758     4  0.5666      0.967 0.000 0.348 0.036 0.616
#> SRR1168759     4  0.5746      0.969 0.000 0.348 0.040 0.612
#> SRR1168760     4  0.5823      0.969 0.000 0.348 0.044 0.608
#> SRR1168761     3  0.7479      0.895 0.324 0.000 0.480 0.196
#> SRR1168762     3  0.7479      0.895 0.324 0.000 0.480 0.196
#> SRR1168763     3  0.7479      0.895 0.324 0.000 0.480 0.196
#> SRR1168764     3  0.7479      0.895 0.324 0.000 0.480 0.196
#> SRR1168765     3  0.7479      0.895 0.324 0.000 0.480 0.196
#> SRR1168766     3  0.7479      0.895 0.324 0.000 0.480 0.196
#> SRR1168767     3  0.7479      0.895 0.324 0.000 0.480 0.196
#> SRR1168768     3  0.7479      0.895 0.324 0.000 0.480 0.196
#> SRR1168769     1  0.0000      0.775 1.000 0.000 0.000 0.000
#> SRR1168770     1  0.0000      0.775 1.000 0.000 0.000 0.000
#> SRR1168771     1  0.0000      0.775 1.000 0.000 0.000 0.000
#> SRR1168772     1  0.0000      0.775 1.000 0.000 0.000 0.000
#> SRR1168773     1  0.0000      0.775 1.000 0.000 0.000 0.000
#> SRR1168774     1  0.0000      0.775 1.000 0.000 0.000 0.000
#> SRR1168775     1  0.0000      0.775 1.000 0.000 0.000 0.000
#> SRR1168776     1  0.0000      0.775 1.000 0.000 0.000 0.000
#> SRR1168777     1  0.0657      0.763 0.984 0.000 0.004 0.012

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4 p5
#> SRR1168715     3  0.6806      0.801 0.172 0.000 0.604 0.128 NA
#> SRR1168716     3  0.6806      0.801 0.172 0.000 0.604 0.128 NA
#> SRR1168717     3  0.6817      0.800 0.172 0.000 0.604 0.120 NA
#> SRR1168718     3  0.6806      0.801 0.172 0.000 0.604 0.128 NA
#> SRR1168719     3  0.6817      0.800 0.172 0.000 0.604 0.120 NA
#> SRR1168720     3  0.6806      0.801 0.172 0.000 0.604 0.128 NA
#> SRR1168721     3  0.6860      0.798 0.172 0.000 0.600 0.108 NA
#> SRR1168722     1  0.0510      0.727 0.984 0.000 0.000 0.016 NA
#> SRR1168723     1  0.0162      0.727 0.996 0.000 0.000 0.004 NA
#> SRR1168724     1  0.0703      0.726 0.976 0.000 0.000 0.024 NA
#> SRR1168725     1  0.0609      0.727 0.980 0.000 0.000 0.020 NA
#> SRR1168726     1  0.0703      0.727 0.976 0.000 0.000 0.024 NA
#> SRR1168727     1  0.0290      0.728 0.992 0.000 0.000 0.008 NA
#> SRR1168728     1  0.0290      0.727 0.992 0.000 0.000 0.008 NA
#> SRR1168729     1  0.0404      0.727 0.988 0.000 0.000 0.012 NA
#> SRR1168730     1  0.0510      0.728 0.984 0.000 0.000 0.016 NA
#> SRR1168731     1  0.0290      0.727 0.992 0.000 0.000 0.008 NA
#> SRR1168732     1  0.0609      0.727 0.980 0.000 0.000 0.020 NA
#> SRR1168733     2  0.1830      0.938 0.000 0.924 0.008 0.000 NA
#> SRR1168734     2  0.2605      0.928 0.000 0.852 0.000 0.000 NA
#> SRR1168735     2  0.1704      0.943 0.000 0.928 0.004 0.000 NA
#> SRR1168736     2  0.2124      0.936 0.000 0.900 0.004 0.000 NA
#> SRR1168737     2  0.2358      0.937 0.000 0.888 0.008 0.000 NA
#> SRR1168738     2  0.1502      0.943 0.000 0.940 0.004 0.000 NA
#> SRR1168739     2  0.0880      0.943 0.000 0.968 0.000 0.000 NA
#> SRR1168740     2  0.2329      0.929 0.000 0.876 0.000 0.000 NA
#> SRR1168741     2  0.1648      0.936 0.000 0.940 0.020 0.000 NA
#> SRR1168742     2  0.1444      0.939 0.000 0.948 0.012 0.000 NA
#> SRR1168743     2  0.2358      0.936 0.000 0.888 0.008 0.000 NA
#> SRR1168744     2  0.1341      0.941 0.000 0.944 0.000 0.000 NA
#> SRR1168745     2  0.2069      0.934 0.000 0.912 0.012 0.000 NA
#> SRR1168746     2  0.2625      0.937 0.000 0.876 0.016 0.000 NA
#> SRR1168747     4  0.5255      0.940 0.000 0.272 0.036 0.664 NA
#> SRR1168748     4  0.5175      0.940 0.000 0.272 0.036 0.668 NA
#> SRR1168749     4  0.5471      0.940 0.000 0.272 0.044 0.652 NA
#> SRR1168750     4  0.5735      0.937 0.000 0.272 0.056 0.636 NA
#> SRR1168751     4  0.5101      0.945 0.000 0.272 0.024 0.672 NA
#> SRR1168752     4  0.7109      0.855 0.000 0.268 0.056 0.520 NA
#> SRR1168753     4  0.5255      0.947 0.000 0.272 0.028 0.664 NA
#> SRR1168754     4  0.5545      0.942 0.000 0.272 0.036 0.648 NA
#> SRR1168755     4  0.5255      0.947 0.000 0.272 0.036 0.664 NA
#> SRR1168756     4  0.5181      0.945 0.000 0.272 0.028 0.668 NA
#> SRR1168757     4  0.4857      0.943 0.000 0.272 0.024 0.684 NA
#> SRR1168758     4  0.4857      0.947 0.000 0.272 0.020 0.684 NA
#> SRR1168759     4  0.5255      0.945 0.000 0.272 0.028 0.664 NA
#> SRR1168760     4  0.5805      0.940 0.000 0.272 0.040 0.632 NA
#> SRR1168761     3  0.3966      0.824 0.132 0.000 0.796 0.000 NA
#> SRR1168762     3  0.4122      0.824 0.132 0.000 0.796 0.008 NA
#> SRR1168763     3  0.4184      0.824 0.132 0.000 0.792 0.008 NA
#> SRR1168764     3  0.4181      0.824 0.132 0.000 0.788 0.004 NA
#> SRR1168765     3  0.4122      0.824 0.132 0.000 0.796 0.008 NA
#> SRR1168766     3  0.4062      0.824 0.132 0.000 0.796 0.004 NA
#> SRR1168767     3  0.4083      0.824 0.132 0.000 0.788 0.000 NA
#> SRR1168768     3  0.4025      0.824 0.132 0.000 0.792 0.000 NA
#> SRR1168769     1  0.5493      0.637 0.488 0.000 0.052 0.004 NA
#> SRR1168770     1  0.5493      0.637 0.488 0.000 0.052 0.004 NA
#> SRR1168771     1  0.5493      0.637 0.488 0.000 0.052 0.004 NA
#> SRR1168772     1  0.5350      0.636 0.488 0.000 0.052 0.000 NA
#> SRR1168773     1  0.5493      0.637 0.488 0.000 0.052 0.004 NA
#> SRR1168774     1  0.5601      0.636 0.488 0.000 0.052 0.008 NA
#> SRR1168775     1  0.5601      0.636 0.488 0.000 0.052 0.008 NA
#> SRR1168776     1  0.5601      0.636 0.488 0.000 0.052 0.008 NA
#> SRR1168777     1  0.6675      0.613 0.476 0.000 0.048 0.084 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
#> SRR1168715     3  0.1930      0.724 0.036 0.000 0.916 0.048 0.000 NA
#> SRR1168716     3  0.2074      0.725 0.036 0.004 0.912 0.048 0.000 NA
#> SRR1168717     3  0.2144      0.724 0.040 0.004 0.908 0.048 0.000 NA
#> SRR1168718     3  0.2074      0.725 0.036 0.004 0.912 0.048 0.000 NA
#> SRR1168719     3  0.2144      0.724 0.040 0.004 0.908 0.048 0.000 NA
#> SRR1168720     3  0.2074      0.725 0.036 0.004 0.912 0.048 0.000 NA
#> SRR1168721     3  0.3728      0.702 0.088 0.032 0.824 0.048 0.000 NA
#> SRR1168722     1  0.4533      0.964 0.632 0.020 0.000 0.328 0.000 NA
#> SRR1168723     1  0.4275      0.966 0.644 0.008 0.000 0.328 0.000 NA
#> SRR1168724     1  0.5326      0.941 0.584 0.048 0.000 0.328 0.000 NA
#> SRR1168725     1  0.4368      0.965 0.640 0.020 0.000 0.328 0.000 NA
#> SRR1168726     1  0.4794      0.963 0.616 0.040 0.000 0.328 0.000 NA
#> SRR1168727     1  0.4195      0.967 0.648 0.016 0.000 0.328 0.000 NA
#> SRR1168728     1  0.4453      0.961 0.636 0.016 0.000 0.328 0.000 NA
#> SRR1168729     1  0.4421      0.966 0.636 0.028 0.000 0.328 0.000 NA
#> SRR1168730     1  0.4453      0.966 0.636 0.020 0.000 0.328 0.000 NA
#> SRR1168731     1  0.4202      0.966 0.648 0.012 0.000 0.328 0.000 NA
#> SRR1168732     1  0.4368      0.969 0.640 0.012 0.000 0.328 0.000 NA
#> SRR1168733     2  0.4713      0.912 0.008 0.704 0.008 0.000 0.204 NA
#> SRR1168734     2  0.5349      0.907 0.032 0.652 0.000 0.000 0.204 NA
#> SRR1168735     2  0.4876      0.918 0.020 0.688 0.000 0.000 0.204 NA
#> SRR1168736     2  0.5615      0.911 0.044 0.632 0.000 0.000 0.204 NA
#> SRR1168737     2  0.5915      0.898 0.040 0.592 0.000 0.000 0.204 NA
#> SRR1168738     2  0.5467      0.907 0.028 0.636 0.000 0.000 0.204 NA
#> SRR1168739     2  0.4353      0.920 0.012 0.724 0.000 0.000 0.204 NA
#> SRR1168740     2  0.5127      0.909 0.024 0.668 0.000 0.000 0.204 NA
#> SRR1168741     2  0.4941      0.913 0.024 0.700 0.012 0.000 0.204 NA
#> SRR1168742     2  0.4471      0.918 0.020 0.728 0.008 0.000 0.204 NA
#> SRR1168743     2  0.5730      0.902 0.040 0.616 0.000 0.000 0.204 NA
#> SRR1168744     2  0.4317      0.916 0.012 0.732 0.004 0.000 0.204 NA
#> SRR1168745     2  0.5004      0.911 0.024 0.692 0.008 0.000 0.204 NA
#> SRR1168746     2  0.5464      0.912 0.024 0.632 0.000 0.000 0.204 NA
#> SRR1168747     5  0.3519      0.910 0.028 0.000 0.024 0.016 0.836 NA
#> SRR1168748     5  0.3111      0.915 0.024 0.000 0.032 0.016 0.868 NA
#> SRR1168749     5  0.1823      0.923 0.008 0.000 0.028 0.004 0.932 NA
#> SRR1168750     5  0.2735      0.915 0.028 0.000 0.028 0.008 0.888 NA
#> SRR1168751     5  0.3410      0.915 0.024 0.000 0.048 0.012 0.848 NA
#> SRR1168752     5  0.4690      0.790 0.136 0.000 0.004 0.020 0.732 NA
#> SRR1168753     5  0.1843      0.927 0.016 0.000 0.016 0.004 0.932 NA
#> SRR1168754     5  0.1579      0.926 0.020 0.000 0.008 0.004 0.944 NA
#> SRR1168755     5  0.1749      0.926 0.036 0.000 0.008 0.000 0.932 NA
#> SRR1168756     5  0.1180      0.926 0.024 0.000 0.004 0.008 0.960 NA
#> SRR1168757     5  0.2572      0.923 0.024 0.000 0.028 0.016 0.900 NA
#> SRR1168758     5  0.2420      0.925 0.020 0.000 0.008 0.012 0.900 NA
#> SRR1168759     5  0.2319      0.925 0.028 0.000 0.020 0.012 0.912 NA
#> SRR1168760     5  0.2836      0.918 0.036 0.000 0.028 0.004 0.880 NA
#> SRR1168761     3  0.5942      0.747 0.008 0.008 0.480 0.132 0.000 NA
#> SRR1168762     3  0.5942      0.747 0.008 0.008 0.480 0.132 0.000 NA
#> SRR1168763     3  0.5726      0.747 0.000 0.008 0.480 0.132 0.000 NA
#> SRR1168764     3  0.6096      0.746 0.008 0.016 0.480 0.132 0.000 NA
#> SRR1168765     3  0.5726      0.747 0.000 0.008 0.480 0.132 0.000 NA
#> SRR1168766     3  0.6249      0.747 0.016 0.016 0.480 0.132 0.000 NA
#> SRR1168767     3  0.6315      0.747 0.020 0.016 0.480 0.132 0.000 NA
#> SRR1168768     3  0.6315      0.747 0.016 0.020 0.480 0.132 0.000 NA
#> SRR1168769     4  0.1194      0.971 0.000 0.008 0.032 0.956 0.000 NA
#> SRR1168770     4  0.1409      0.971 0.000 0.012 0.032 0.948 0.000 NA
#> SRR1168771     4  0.1049      0.970 0.000 0.008 0.032 0.960 0.000 NA
#> SRR1168772     4  0.0935      0.972 0.000 0.004 0.032 0.964 0.000 NA
#> SRR1168773     4  0.1049      0.971 0.000 0.008 0.032 0.960 0.000 NA
#> SRR1168774     4  0.1699      0.968 0.000 0.016 0.032 0.936 0.000 NA
#> SRR1168775     4  0.1503      0.969 0.000 0.016 0.032 0.944 0.000 NA
#> SRR1168776     4  0.1503      0.970 0.000 0.016 0.032 0.944 0.000 NA
#> SRR1168777     4  0.3557      0.867 0.004 0.040 0.036 0.832 0.000 NA

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

consensus_heatmap(res, k = 2)

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

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

collect_plots(res)

plot of chunk CV-skmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.5023 0.498   0.498
#> 3 3 1.000           0.994       0.993         0.3045 0.846   0.692
#> 4 4 0.820           0.942       0.888         0.0834 0.949   0.853
#> 5 5 0.867           0.949       0.782         0.0777 0.900   0.659
#> 6 6 0.857           0.980       0.880         0.0468 0.971   0.852

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
#> SRR1168715     1       0          1  1  0
#> SRR1168716     1       0          1  1  0
#> SRR1168717     1       0          1  1  0
#> SRR1168718     1       0          1  1  0
#> SRR1168719     1       0          1  1  0
#> SRR1168720     1       0          1  1  0
#> SRR1168721     1       0          1  1  0
#> SRR1168722     1       0          1  1  0
#> SRR1168723     1       0          1  1  0
#> SRR1168724     1       0          1  1  0
#> SRR1168725     1       0          1  1  0
#> SRR1168726     1       0          1  1  0
#> SRR1168727     1       0          1  1  0
#> SRR1168728     1       0          1  1  0
#> SRR1168729     1       0          1  1  0
#> SRR1168730     1       0          1  1  0
#> SRR1168731     1       0          1  1  0
#> SRR1168732     1       0          1  1  0
#> SRR1168733     2       0          1  0  1
#> SRR1168734     2       0          1  0  1
#> SRR1168735     2       0          1  0  1
#> SRR1168736     2       0          1  0  1
#> SRR1168737     2       0          1  0  1
#> SRR1168738     2       0          1  0  1
#> SRR1168739     2       0          1  0  1
#> SRR1168740     2       0          1  0  1
#> SRR1168741     2       0          1  0  1
#> SRR1168742     2       0          1  0  1
#> SRR1168743     2       0          1  0  1
#> SRR1168744     2       0          1  0  1
#> SRR1168745     2       0          1  0  1
#> SRR1168746     2       0          1  0  1
#> SRR1168747     2       0          1  0  1
#> SRR1168748     2       0          1  0  1
#> SRR1168749     2       0          1  0  1
#> SRR1168750     2       0          1  0  1
#> SRR1168751     2       0          1  0  1
#> SRR1168752     2       0          1  0  1
#> SRR1168753     2       0          1  0  1
#> SRR1168754     2       0          1  0  1
#> SRR1168755     2       0          1  0  1
#> SRR1168756     2       0          1  0  1
#> SRR1168757     2       0          1  0  1
#> SRR1168758     2       0          1  0  1
#> SRR1168759     2       0          1  0  1
#> SRR1168760     2       0          1  0  1
#> SRR1168761     1       0          1  1  0
#> SRR1168762     1       0          1  1  0
#> SRR1168763     1       0          1  1  0
#> SRR1168764     1       0          1  1  0
#> SRR1168765     1       0          1  1  0
#> SRR1168766     1       0          1  1  0
#> SRR1168767     1       0          1  1  0
#> SRR1168768     1       0          1  1  0
#> SRR1168769     1       0          1  1  0
#> SRR1168770     1       0          1  1  0
#> SRR1168771     1       0          1  1  0
#> SRR1168772     1       0          1  1  0
#> SRR1168773     1       0          1  1  0
#> SRR1168774     1       0          1  1  0
#> SRR1168775     1       0          1  1  0
#> SRR1168776     1       0          1  1  0
#> SRR1168777     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1168715     3  0.0892      0.993 0.020 0.000 0.980
#> SRR1168716     3  0.0892      0.993 0.020 0.000 0.980
#> SRR1168717     3  0.0892      0.993 0.020 0.000 0.980
#> SRR1168718     3  0.0892      0.993 0.020 0.000 0.980
#> SRR1168719     3  0.0892      0.993 0.020 0.000 0.980
#> SRR1168720     3  0.0892      0.993 0.020 0.000 0.980
#> SRR1168721     3  0.0892      0.993 0.020 0.000 0.980
#> SRR1168722     1  0.0000      0.993 1.000 0.000 0.000
#> SRR1168723     1  0.0000      0.993 1.000 0.000 0.000
#> SRR1168724     1  0.0000      0.993 1.000 0.000 0.000
#> SRR1168725     1  0.0000      0.993 1.000 0.000 0.000
#> SRR1168726     1  0.0000      0.993 1.000 0.000 0.000
#> SRR1168727     1  0.0000      0.993 1.000 0.000 0.000
#> SRR1168728     1  0.0000      0.993 1.000 0.000 0.000
#> SRR1168729     1  0.0000      0.993 1.000 0.000 0.000
#> SRR1168730     1  0.0000      0.993 1.000 0.000 0.000
#> SRR1168731     1  0.0000      0.993 1.000 0.000 0.000
#> SRR1168732     1  0.0000      0.993 1.000 0.000 0.000
#> SRR1168733     2  0.0000      0.997 0.000 1.000 0.000
#> SRR1168734     2  0.0000      0.997 0.000 1.000 0.000
#> SRR1168735     2  0.0000      0.997 0.000 1.000 0.000
#> SRR1168736     2  0.0000      0.997 0.000 1.000 0.000
#> SRR1168737     2  0.0000      0.997 0.000 1.000 0.000
#> SRR1168738     2  0.0000      0.997 0.000 1.000 0.000
#> SRR1168739     2  0.0000      0.997 0.000 1.000 0.000
#> SRR1168740     2  0.0000      0.997 0.000 1.000 0.000
#> SRR1168741     2  0.0000      0.997 0.000 1.000 0.000
#> SRR1168742     2  0.0000      0.997 0.000 1.000 0.000
#> SRR1168743     2  0.0000      0.997 0.000 1.000 0.000
#> SRR1168744     2  0.0000      0.997 0.000 1.000 0.000
#> SRR1168745     2  0.0000      0.997 0.000 1.000 0.000
#> SRR1168746     2  0.0000      0.997 0.000 1.000 0.000
#> SRR1168747     2  0.0424      0.997 0.000 0.992 0.008
#> SRR1168748     2  0.0424      0.997 0.000 0.992 0.008
#> SRR1168749     2  0.0424      0.997 0.000 0.992 0.008
#> SRR1168750     2  0.0424      0.997 0.000 0.992 0.008
#> SRR1168751     2  0.0424      0.997 0.000 0.992 0.008
#> SRR1168752     2  0.0424      0.997 0.000 0.992 0.008
#> SRR1168753     2  0.0424      0.997 0.000 0.992 0.008
#> SRR1168754     2  0.0424      0.997 0.000 0.992 0.008
#> SRR1168755     2  0.0424      0.997 0.000 0.992 0.008
#> SRR1168756     2  0.0424      0.997 0.000 0.992 0.008
#> SRR1168757     2  0.0424      0.997 0.000 0.992 0.008
#> SRR1168758     2  0.0424      0.997 0.000 0.992 0.008
#> SRR1168759     2  0.0424      0.997 0.000 0.992 0.008
#> SRR1168760     2  0.0424      0.997 0.000 0.992 0.008
#> SRR1168761     3  0.0424      0.994 0.008 0.000 0.992
#> SRR1168762     3  0.0424      0.994 0.008 0.000 0.992
#> SRR1168763     3  0.0424      0.994 0.008 0.000 0.992
#> SRR1168764     3  0.0424      0.994 0.008 0.000 0.992
#> SRR1168765     3  0.0424      0.994 0.008 0.000 0.992
#> SRR1168766     3  0.0424      0.994 0.008 0.000 0.992
#> SRR1168767     3  0.0424      0.994 0.008 0.000 0.992
#> SRR1168768     3  0.0424      0.994 0.008 0.000 0.992
#> SRR1168769     1  0.0747      0.991 0.984 0.000 0.016
#> SRR1168770     1  0.0747      0.991 0.984 0.000 0.016
#> SRR1168771     1  0.0747      0.991 0.984 0.000 0.016
#> SRR1168772     1  0.0747      0.991 0.984 0.000 0.016
#> SRR1168773     1  0.0747      0.991 0.984 0.000 0.016
#> SRR1168774     1  0.0747      0.991 0.984 0.000 0.016
#> SRR1168775     1  0.0747      0.991 0.984 0.000 0.016
#> SRR1168776     1  0.0747      0.991 0.984 0.000 0.016
#> SRR1168777     1  0.0747      0.991 0.984 0.000 0.016

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1168715     3  0.3494      0.914 0.004 0.000 0.824 0.172
#> SRR1168716     3  0.3494      0.914 0.004 0.000 0.824 0.172
#> SRR1168717     3  0.3494      0.914 0.004 0.000 0.824 0.172
#> SRR1168718     3  0.3494      0.914 0.004 0.000 0.824 0.172
#> SRR1168719     3  0.3494      0.914 0.004 0.000 0.824 0.172
#> SRR1168720     3  0.3494      0.914 0.004 0.000 0.824 0.172
#> SRR1168721     3  0.3494      0.914 0.004 0.000 0.824 0.172
#> SRR1168722     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1168723     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1168724     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1168725     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1168726     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1168727     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1168728     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1168729     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1168730     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1168731     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1168732     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1168733     2  0.3311      0.919 0.000 0.828 0.000 0.172
#> SRR1168734     2  0.3311      0.919 0.000 0.828 0.000 0.172
#> SRR1168735     2  0.3311      0.919 0.000 0.828 0.000 0.172
#> SRR1168736     2  0.3311      0.919 0.000 0.828 0.000 0.172
#> SRR1168737     2  0.3311      0.919 0.000 0.828 0.000 0.172
#> SRR1168738     2  0.3311      0.919 0.000 0.828 0.000 0.172
#> SRR1168739     2  0.3311      0.919 0.000 0.828 0.000 0.172
#> SRR1168740     2  0.3311      0.919 0.000 0.828 0.000 0.172
#> SRR1168741     2  0.3311      0.919 0.000 0.828 0.000 0.172
#> SRR1168742     2  0.3311      0.919 0.000 0.828 0.000 0.172
#> SRR1168743     2  0.3311      0.919 0.000 0.828 0.000 0.172
#> SRR1168744     2  0.3311      0.919 0.000 0.828 0.000 0.172
#> SRR1168745     2  0.3311      0.919 0.000 0.828 0.000 0.172
#> SRR1168746     2  0.3311      0.919 0.000 0.828 0.000 0.172
#> SRR1168747     2  0.0000      0.919 0.000 1.000 0.000 0.000
#> SRR1168748     2  0.0000      0.919 0.000 1.000 0.000 0.000
#> SRR1168749     2  0.0000      0.919 0.000 1.000 0.000 0.000
#> SRR1168750     2  0.0000      0.919 0.000 1.000 0.000 0.000
#> SRR1168751     2  0.0000      0.919 0.000 1.000 0.000 0.000
#> SRR1168752     2  0.0000      0.919 0.000 1.000 0.000 0.000
#> SRR1168753     2  0.0000      0.919 0.000 1.000 0.000 0.000
#> SRR1168754     2  0.0000      0.919 0.000 1.000 0.000 0.000
#> SRR1168755     2  0.0000      0.919 0.000 1.000 0.000 0.000
#> SRR1168756     2  0.0000      0.919 0.000 1.000 0.000 0.000
#> SRR1168757     2  0.0000      0.919 0.000 1.000 0.000 0.000
#> SRR1168758     2  0.0000      0.919 0.000 1.000 0.000 0.000
#> SRR1168759     2  0.0000      0.919 0.000 1.000 0.000 0.000
#> SRR1168760     2  0.0000      0.919 0.000 1.000 0.000 0.000
#> SRR1168761     3  0.0336      0.925 0.000 0.000 0.992 0.008
#> SRR1168762     3  0.0336      0.925 0.000 0.000 0.992 0.008
#> SRR1168763     3  0.0336      0.925 0.000 0.000 0.992 0.008
#> SRR1168764     3  0.0336      0.925 0.000 0.000 0.992 0.008
#> SRR1168765     3  0.0336      0.925 0.000 0.000 0.992 0.008
#> SRR1168766     3  0.0336      0.925 0.000 0.000 0.992 0.008
#> SRR1168767     3  0.0336      0.925 0.000 0.000 0.992 0.008
#> SRR1168768     3  0.0336      0.925 0.000 0.000 0.992 0.008
#> SRR1168769     4  0.4920      0.983 0.368 0.000 0.004 0.628
#> SRR1168770     4  0.4950      0.984 0.376 0.000 0.004 0.620
#> SRR1168771     4  0.4964      0.981 0.380 0.000 0.004 0.616
#> SRR1168772     4  0.4936      0.985 0.372 0.000 0.004 0.624
#> SRR1168773     4  0.4889      0.978 0.360 0.000 0.004 0.636
#> SRR1168774     4  0.4936      0.985 0.372 0.000 0.004 0.624
#> SRR1168775     4  0.4936      0.985 0.372 0.000 0.004 0.624
#> SRR1168776     4  0.4950      0.984 0.376 0.000 0.004 0.620
#> SRR1168777     4  0.4800      0.954 0.340 0.000 0.004 0.656

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4    p5
#> SRR1168715     3  0.0404      0.784 0.000 0.000 0.988 0.000 0.012
#> SRR1168716     3  0.0162      0.786 0.000 0.000 0.996 0.000 0.004
#> SRR1168717     3  0.0290      0.785 0.000 0.000 0.992 0.000 0.008
#> SRR1168718     3  0.0703      0.778 0.000 0.000 0.976 0.000 0.024
#> SRR1168719     3  0.0290      0.785 0.000 0.000 0.992 0.000 0.008
#> SRR1168720     3  0.0000      0.787 0.000 0.000 1.000 0.000 0.000
#> SRR1168721     3  0.1270      0.763 0.000 0.000 0.948 0.000 0.052
#> SRR1168722     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1168723     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1168724     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1168725     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1168726     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1168727     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1168728     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1168729     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1168730     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1168731     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1168732     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1168733     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1168734     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1168735     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1168736     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1168737     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1168738     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1168739     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1168740     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1168741     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1168742     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1168743     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1168744     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1168745     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1168746     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1168747     5  0.4307      1.000 0.000 0.496 0.000 0.000 0.504
#> SRR1168748     5  0.4307      1.000 0.000 0.496 0.000 0.000 0.504
#> SRR1168749     5  0.4307      1.000 0.000 0.496 0.000 0.000 0.504
#> SRR1168750     5  0.4307      1.000 0.000 0.496 0.000 0.000 0.504
#> SRR1168751     5  0.4307      1.000 0.000 0.496 0.000 0.000 0.504
#> SRR1168752     5  0.4307      1.000 0.000 0.496 0.000 0.000 0.504
#> SRR1168753     5  0.4307      1.000 0.000 0.496 0.000 0.000 0.504
#> SRR1168754     5  0.4307      1.000 0.000 0.496 0.000 0.000 0.504
#> SRR1168755     5  0.4307      1.000 0.000 0.496 0.000 0.000 0.504
#> SRR1168756     5  0.4307      1.000 0.000 0.496 0.000 0.000 0.504
#> SRR1168757     5  0.4307      1.000 0.000 0.496 0.000 0.000 0.504
#> SRR1168758     5  0.4307      1.000 0.000 0.496 0.000 0.000 0.504
#> SRR1168759     5  0.4307      1.000 0.000 0.496 0.000 0.000 0.504
#> SRR1168760     5  0.4307      1.000 0.000 0.496 0.000 0.000 0.504
#> SRR1168761     3  0.5128      0.818 0.000 0.000 0.604 0.052 0.344
#> SRR1168762     3  0.5155      0.816 0.000 0.000 0.596 0.052 0.352
#> SRR1168763     3  0.5142      0.817 0.000 0.000 0.600 0.052 0.348
#> SRR1168764     3  0.5142      0.817 0.000 0.000 0.600 0.052 0.348
#> SRR1168765     3  0.5142      0.817 0.000 0.000 0.600 0.052 0.348
#> SRR1168766     3  0.5155      0.816 0.000 0.000 0.596 0.052 0.352
#> SRR1168767     3  0.5142      0.817 0.000 0.000 0.600 0.052 0.348
#> SRR1168768     3  0.5155      0.816 0.000 0.000 0.596 0.052 0.352
#> SRR1168769     4  0.1965      0.985 0.096 0.000 0.000 0.904 0.000
#> SRR1168770     4  0.1908      0.983 0.092 0.000 0.000 0.908 0.000
#> SRR1168771     4  0.1908      0.983 0.092 0.000 0.000 0.908 0.000
#> SRR1168772     4  0.1965      0.985 0.096 0.000 0.000 0.904 0.000
#> SRR1168773     4  0.1965      0.985 0.096 0.000 0.000 0.904 0.000
#> SRR1168774     4  0.1965      0.985 0.096 0.000 0.000 0.904 0.000
#> SRR1168775     4  0.1965      0.985 0.096 0.000 0.000 0.904 0.000
#> SRR1168776     4  0.1965      0.985 0.096 0.000 0.000 0.904 0.000
#> SRR1168777     4  0.3075      0.888 0.048 0.000 0.000 0.860 0.092

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR1168715     6  0.3508      0.964 0.000 0.004 0.292 0.000 0.000 0.704
#> SRR1168716     6  0.3584      0.958 0.000 0.004 0.308 0.000 0.000 0.688
#> SRR1168717     6  0.3428      0.961 0.000 0.000 0.304 0.000 0.000 0.696
#> SRR1168718     6  0.3390      0.964 0.000 0.000 0.296 0.000 0.000 0.704
#> SRR1168719     6  0.3371      0.963 0.000 0.000 0.292 0.000 0.000 0.708
#> SRR1168720     6  0.3390      0.964 0.000 0.000 0.296 0.000 0.000 0.704
#> SRR1168721     6  0.3141      0.866 0.000 0.012 0.200 0.000 0.000 0.788
#> SRR1168722     1  0.0146      0.998 0.996 0.000 0.000 0.000 0.000 0.004
#> SRR1168723     1  0.0000      0.998 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1168724     1  0.0146      0.998 0.996 0.000 0.000 0.000 0.000 0.004
#> SRR1168725     1  0.0000      0.998 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1168726     1  0.0000      0.998 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1168727     1  0.0000      0.998 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1168728     1  0.0146      0.998 0.996 0.000 0.000 0.000 0.000 0.004
#> SRR1168729     1  0.0146      0.998 0.996 0.000 0.000 0.000 0.000 0.004
#> SRR1168730     1  0.0000      0.998 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1168731     1  0.0000      0.998 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1168732     1  0.0146      0.998 0.996 0.000 0.000 0.000 0.000 0.004
#> SRR1168733     2  0.3288      1.000 0.000 0.724 0.000 0.000 0.276 0.000
#> SRR1168734     2  0.3288      1.000 0.000 0.724 0.000 0.000 0.276 0.000
#> SRR1168735     2  0.3288      1.000 0.000 0.724 0.000 0.000 0.276 0.000
#> SRR1168736     2  0.3288      1.000 0.000 0.724 0.000 0.000 0.276 0.000
#> SRR1168737     2  0.3288      1.000 0.000 0.724 0.000 0.000 0.276 0.000
#> SRR1168738     2  0.3288      1.000 0.000 0.724 0.000 0.000 0.276 0.000
#> SRR1168739     2  0.3288      1.000 0.000 0.724 0.000 0.000 0.276 0.000
#> SRR1168740     2  0.3288      1.000 0.000 0.724 0.000 0.000 0.276 0.000
#> SRR1168741     2  0.3288      1.000 0.000 0.724 0.000 0.000 0.276 0.000
#> SRR1168742     2  0.3288      1.000 0.000 0.724 0.000 0.000 0.276 0.000
#> SRR1168743     2  0.3288      1.000 0.000 0.724 0.000 0.000 0.276 0.000
#> SRR1168744     2  0.3288      1.000 0.000 0.724 0.000 0.000 0.276 0.000
#> SRR1168745     2  0.3288      1.000 0.000 0.724 0.000 0.000 0.276 0.000
#> SRR1168746     2  0.3288      1.000 0.000 0.724 0.000 0.000 0.276 0.000
#> SRR1168747     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1168748     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1168749     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1168750     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1168751     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1168752     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1168753     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1168754     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1168755     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1168756     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1168757     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1168758     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1168759     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1168760     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1168761     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1168762     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1168763     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1168764     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1168765     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1168766     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1168767     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1168768     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1168769     4  0.1010      0.946 0.036 0.004 0.000 0.960 0.000 0.000
#> SRR1168770     4  0.0935      0.946 0.032 0.004 0.000 0.964 0.000 0.000
#> SRR1168771     4  0.1049      0.945 0.032 0.008 0.000 0.960 0.000 0.000
#> SRR1168772     4  0.0865      0.946 0.036 0.000 0.000 0.964 0.000 0.000
#> SRR1168773     4  0.0717      0.936 0.016 0.008 0.000 0.976 0.000 0.000
#> SRR1168774     4  0.1082      0.945 0.040 0.004 0.000 0.956 0.000 0.000
#> SRR1168775     4  0.0937      0.945 0.040 0.000 0.000 0.960 0.000 0.000
#> SRR1168776     4  0.0865      0.946 0.036 0.000 0.000 0.964 0.000 0.000
#> SRR1168777     4  0.5552      0.558 0.000 0.252 0.000 0.552 0.000 0.196

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 14158 rows and 63 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.502 0.498   0.498
#> 3 3 1.000           0.995       0.997          0.306 0.846   0.692
#> 4 4 0.849           0.973       0.955          0.086 0.949   0.853
#> 5 5 1.000           0.993       0.979          0.126 0.900   0.659
#> 6 6 1.000           0.999       0.999          0.041 0.971   0.852

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
#> SRR1168715     1       0          1  1  0
#> SRR1168716     1       0          1  1  0
#> SRR1168717     1       0          1  1  0
#> SRR1168718     1       0          1  1  0
#> SRR1168719     1       0          1  1  0
#> SRR1168720     1       0          1  1  0
#> SRR1168721     1       0          1  1  0
#> SRR1168722     1       0          1  1  0
#> SRR1168723     1       0          1  1  0
#> SRR1168724     1       0          1  1  0
#> SRR1168725     1       0          1  1  0
#> SRR1168726     1       0          1  1  0
#> SRR1168727     1       0          1  1  0
#> SRR1168728     1       0          1  1  0
#> SRR1168729     1       0          1  1  0
#> SRR1168730     1       0          1  1  0
#> SRR1168731     1       0          1  1  0
#> SRR1168732     1       0          1  1  0
#> SRR1168733     2       0          1  0  1
#> SRR1168734     2       0          1  0  1
#> SRR1168735     2       0          1  0  1
#> SRR1168736     2       0          1  0  1
#> SRR1168737     2       0          1  0  1
#> SRR1168738     2       0          1  0  1
#> SRR1168739     2       0          1  0  1
#> SRR1168740     2       0          1  0  1
#> SRR1168741     2       0          1  0  1
#> SRR1168742     2       0          1  0  1
#> SRR1168743     2       0          1  0  1
#> SRR1168744     2       0          1  0  1
#> SRR1168745     2       0          1  0  1
#> SRR1168746     2       0          1  0  1
#> SRR1168747     2       0          1  0  1
#> SRR1168748     2       0          1  0  1
#> SRR1168749     2       0          1  0  1
#> SRR1168750     2       0          1  0  1
#> SRR1168751     2       0          1  0  1
#> SRR1168752     2       0          1  0  1
#> SRR1168753     2       0          1  0  1
#> SRR1168754     2       0          1  0  1
#> SRR1168755     2       0          1  0  1
#> SRR1168756     2       0          1  0  1
#> SRR1168757     2       0          1  0  1
#> SRR1168758     2       0          1  0  1
#> SRR1168759     2       0          1  0  1
#> SRR1168760     2       0          1  0  1
#> SRR1168761     1       0          1  1  0
#> SRR1168762     1       0          1  1  0
#> SRR1168763     1       0          1  1  0
#> SRR1168764     1       0          1  1  0
#> SRR1168765     1       0          1  1  0
#> SRR1168766     1       0          1  1  0
#> SRR1168767     1       0          1  1  0
#> SRR1168768     1       0          1  1  0
#> SRR1168769     1       0          1  1  0
#> SRR1168770     1       0          1  1  0
#> SRR1168771     1       0          1  1  0
#> SRR1168772     1       0          1  1  0
#> SRR1168773     1       0          1  1  0
#> SRR1168774     1       0          1  1  0
#> SRR1168775     1       0          1  1  0
#> SRR1168776     1       0          1  1  0
#> SRR1168777     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1 p2    p3
#> SRR1168715     3  0.0000      1.000 0.000  0 1.000
#> SRR1168716     3  0.0000      1.000 0.000  0 1.000
#> SRR1168717     3  0.0000      1.000 0.000  0 1.000
#> SRR1168718     3  0.0000      1.000 0.000  0 1.000
#> SRR1168719     3  0.0000      1.000 0.000  0 1.000
#> SRR1168720     3  0.0000      1.000 0.000  0 1.000
#> SRR1168721     3  0.0000      1.000 0.000  0 1.000
#> SRR1168722     1  0.0000      0.991 1.000  0 0.000
#> SRR1168723     1  0.0000      0.991 1.000  0 0.000
#> SRR1168724     1  0.0000      0.991 1.000  0 0.000
#> SRR1168725     1  0.0000      0.991 1.000  0 0.000
#> SRR1168726     1  0.0000      0.991 1.000  0 0.000
#> SRR1168727     1  0.0000      0.991 1.000  0 0.000
#> SRR1168728     1  0.0000      0.991 1.000  0 0.000
#> SRR1168729     1  0.0000      0.991 1.000  0 0.000
#> SRR1168730     1  0.0000      0.991 1.000  0 0.000
#> SRR1168731     1  0.0000      0.991 1.000  0 0.000
#> SRR1168732     1  0.0000      0.991 1.000  0 0.000
#> SRR1168733     2  0.0000      1.000 0.000  1 0.000
#> SRR1168734     2  0.0000      1.000 0.000  1 0.000
#> SRR1168735     2  0.0000      1.000 0.000  1 0.000
#> SRR1168736     2  0.0000      1.000 0.000  1 0.000
#> SRR1168737     2  0.0000      1.000 0.000  1 0.000
#> SRR1168738     2  0.0000      1.000 0.000  1 0.000
#> SRR1168739     2  0.0000      1.000 0.000  1 0.000
#> SRR1168740     2  0.0000      1.000 0.000  1 0.000
#> SRR1168741     2  0.0000      1.000 0.000  1 0.000
#> SRR1168742     2  0.0000      1.000 0.000  1 0.000
#> SRR1168743     2  0.0000      1.000 0.000  1 0.000
#> SRR1168744     2  0.0000      1.000 0.000  1 0.000
#> SRR1168745     2  0.0000      1.000 0.000  1 0.000
#> SRR1168746     2  0.0000      1.000 0.000  1 0.000
#> SRR1168747     2  0.0000      1.000 0.000  1 0.000
#> SRR1168748     2  0.0000      1.000 0.000  1 0.000
#> SRR1168749     2  0.0000      1.000 0.000  1 0.000
#> SRR1168750     2  0.0000      1.000 0.000  1 0.000
#> SRR1168751     2  0.0000      1.000 0.000  1 0.000
#> SRR1168752     2  0.0000      1.000 0.000  1 0.000
#> SRR1168753     2  0.0000      1.000 0.000  1 0.000
#> SRR1168754     2  0.0000      1.000 0.000  1 0.000
#> SRR1168755     2  0.0000      1.000 0.000  1 0.000
#> SRR1168756     2  0.0000      1.000 0.000  1 0.000
#> SRR1168757     2  0.0000      1.000 0.000  1 0.000
#> SRR1168758     2  0.0000      1.000 0.000  1 0.000
#> SRR1168759     2  0.0000      1.000 0.000  1 0.000
#> SRR1168760     2  0.0000      1.000 0.000  1 0.000
#> SRR1168761     3  0.0000      1.000 0.000  0 1.000
#> SRR1168762     3  0.0000      1.000 0.000  0 1.000
#> SRR1168763     3  0.0000      1.000 0.000  0 1.000
#> SRR1168764     3  0.0000      1.000 0.000  0 1.000
#> SRR1168765     3  0.0000      1.000 0.000  0 1.000
#> SRR1168766     3  0.0000      1.000 0.000  0 1.000
#> SRR1168767     3  0.0000      1.000 0.000  0 1.000
#> SRR1168768     3  0.0000      1.000 0.000  0 1.000
#> SRR1168769     1  0.0000      0.991 1.000  0 0.000
#> SRR1168770     1  0.0000      0.991 1.000  0 0.000
#> SRR1168771     1  0.0237      0.989 0.996  0 0.004
#> SRR1168772     1  0.0237      0.989 0.996  0 0.004
#> SRR1168773     1  0.1163      0.970 0.972  0 0.028
#> SRR1168774     1  0.0424      0.986 0.992  0 0.008
#> SRR1168775     1  0.0000      0.991 1.000  0 0.000
#> SRR1168776     1  0.2711      0.909 0.912  0 0.088
#> SRR1168777     1  0.1643      0.956 0.956  0 0.044

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1168715     3   0.000      1.000 0.000 0.000 1.000 0.000
#> SRR1168716     3   0.000      1.000 0.000 0.000 1.000 0.000
#> SRR1168717     3   0.000      1.000 0.000 0.000 1.000 0.000
#> SRR1168718     3   0.000      1.000 0.000 0.000 1.000 0.000
#> SRR1168719     3   0.000      1.000 0.000 0.000 1.000 0.000
#> SRR1168720     3   0.000      1.000 0.000 0.000 1.000 0.000
#> SRR1168721     3   0.000      1.000 0.000 0.000 1.000 0.000
#> SRR1168722     1   0.000      1.000 1.000 0.000 0.000 0.000
#> SRR1168723     1   0.000      1.000 1.000 0.000 0.000 0.000
#> SRR1168724     1   0.000      1.000 1.000 0.000 0.000 0.000
#> SRR1168725     1   0.000      1.000 1.000 0.000 0.000 0.000
#> SRR1168726     1   0.000      1.000 1.000 0.000 0.000 0.000
#> SRR1168727     1   0.000      1.000 1.000 0.000 0.000 0.000
#> SRR1168728     1   0.000      1.000 1.000 0.000 0.000 0.000
#> SRR1168729     1   0.000      1.000 1.000 0.000 0.000 0.000
#> SRR1168730     1   0.000      1.000 1.000 0.000 0.000 0.000
#> SRR1168731     1   0.000      1.000 1.000 0.000 0.000 0.000
#> SRR1168732     1   0.000      1.000 1.000 0.000 0.000 0.000
#> SRR1168733     2   0.000      0.942 0.000 1.000 0.000 0.000
#> SRR1168734     2   0.000      0.942 0.000 1.000 0.000 0.000
#> SRR1168735     2   0.000      0.942 0.000 1.000 0.000 0.000
#> SRR1168736     2   0.000      0.942 0.000 1.000 0.000 0.000
#> SRR1168737     2   0.000      0.942 0.000 1.000 0.000 0.000
#> SRR1168738     2   0.000      0.942 0.000 1.000 0.000 0.000
#> SRR1168739     2   0.000      0.942 0.000 1.000 0.000 0.000
#> SRR1168740     2   0.000      0.942 0.000 1.000 0.000 0.000
#> SRR1168741     2   0.000      0.942 0.000 1.000 0.000 0.000
#> SRR1168742     2   0.000      0.942 0.000 1.000 0.000 0.000
#> SRR1168743     2   0.000      0.942 0.000 1.000 0.000 0.000
#> SRR1168744     2   0.000      0.942 0.000 1.000 0.000 0.000
#> SRR1168745     2   0.000      0.942 0.000 1.000 0.000 0.000
#> SRR1168746     2   0.000      0.942 0.000 1.000 0.000 0.000
#> SRR1168747     2   0.270      0.942 0.000 0.876 0.000 0.124
#> SRR1168748     2   0.270      0.942 0.000 0.876 0.000 0.124
#> SRR1168749     2   0.270      0.942 0.000 0.876 0.000 0.124
#> SRR1168750     2   0.270      0.942 0.000 0.876 0.000 0.124
#> SRR1168751     2   0.270      0.942 0.000 0.876 0.000 0.124
#> SRR1168752     2   0.270      0.942 0.000 0.876 0.000 0.124
#> SRR1168753     2   0.270      0.942 0.000 0.876 0.000 0.124
#> SRR1168754     2   0.270      0.942 0.000 0.876 0.000 0.124
#> SRR1168755     2   0.270      0.942 0.000 0.876 0.000 0.124
#> SRR1168756     2   0.270      0.942 0.000 0.876 0.000 0.124
#> SRR1168757     2   0.270      0.942 0.000 0.876 0.000 0.124
#> SRR1168758     2   0.270      0.942 0.000 0.876 0.000 0.124
#> SRR1168759     2   0.270      0.942 0.000 0.876 0.000 0.124
#> SRR1168760     2   0.270      0.942 0.000 0.876 0.000 0.124
#> SRR1168761     3   0.000      1.000 0.000 0.000 1.000 0.000
#> SRR1168762     3   0.000      1.000 0.000 0.000 1.000 0.000
#> SRR1168763     3   0.000      1.000 0.000 0.000 1.000 0.000
#> SRR1168764     3   0.000      1.000 0.000 0.000 1.000 0.000
#> SRR1168765     3   0.000      1.000 0.000 0.000 1.000 0.000
#> SRR1168766     3   0.000      1.000 0.000 0.000 1.000 0.000
#> SRR1168767     3   0.000      1.000 0.000 0.000 1.000 0.000
#> SRR1168768     3   0.000      1.000 0.000 0.000 1.000 0.000
#> SRR1168769     4   0.270      0.998 0.124 0.000 0.000 0.876
#> SRR1168770     4   0.270      0.998 0.124 0.000 0.000 0.876
#> SRR1168771     4   0.270      0.998 0.124 0.000 0.000 0.876
#> SRR1168772     4   0.270      0.998 0.124 0.000 0.000 0.876
#> SRR1168773     4   0.270      0.998 0.124 0.000 0.000 0.876
#> SRR1168774     4   0.283      0.994 0.120 0.000 0.004 0.876
#> SRR1168775     4   0.270      0.998 0.124 0.000 0.000 0.876
#> SRR1168776     4   0.292      0.989 0.116 0.000 0.008 0.876
#> SRR1168777     4   0.270      0.998 0.124 0.000 0.000 0.876

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette p1    p2   p3 p4    p5
#> SRR1168715     3   0.141      0.972  0 0.000 0.94  0 0.060
#> SRR1168716     3   0.141      0.972  0 0.000 0.94  0 0.060
#> SRR1168717     3   0.141      0.972  0 0.000 0.94  0 0.060
#> SRR1168718     3   0.141      0.972  0 0.000 0.94  0 0.060
#> SRR1168719     3   0.141      0.972  0 0.000 0.94  0 0.060
#> SRR1168720     3   0.141      0.972  0 0.000 0.94  0 0.060
#> SRR1168721     3   0.141      0.972  0 0.000 0.94  0 0.060
#> SRR1168722     1   0.000      1.000  1 0.000 0.00  0 0.000
#> SRR1168723     1   0.000      1.000  1 0.000 0.00  0 0.000
#> SRR1168724     1   0.000      1.000  1 0.000 0.00  0 0.000
#> SRR1168725     1   0.000      1.000  1 0.000 0.00  0 0.000
#> SRR1168726     1   0.000      1.000  1 0.000 0.00  0 0.000
#> SRR1168727     1   0.000      1.000  1 0.000 0.00  0 0.000
#> SRR1168728     1   0.000      1.000  1 0.000 0.00  0 0.000
#> SRR1168729     1   0.000      1.000  1 0.000 0.00  0 0.000
#> SRR1168730     1   0.000      1.000  1 0.000 0.00  0 0.000
#> SRR1168731     1   0.000      1.000  1 0.000 0.00  0 0.000
#> SRR1168732     1   0.000      1.000  1 0.000 0.00  0 0.000
#> SRR1168733     2   0.000      1.000  0 1.000 0.00  0 0.000
#> SRR1168734     2   0.000      1.000  0 1.000 0.00  0 0.000
#> SRR1168735     2   0.000      1.000  0 1.000 0.00  0 0.000
#> SRR1168736     2   0.000      1.000  0 1.000 0.00  0 0.000
#> SRR1168737     2   0.000      1.000  0 1.000 0.00  0 0.000
#> SRR1168738     2   0.000      1.000  0 1.000 0.00  0 0.000
#> SRR1168739     2   0.000      1.000  0 1.000 0.00  0 0.000
#> SRR1168740     2   0.000      1.000  0 1.000 0.00  0 0.000
#> SRR1168741     2   0.000      1.000  0 1.000 0.00  0 0.000
#> SRR1168742     2   0.000      1.000  0 1.000 0.00  0 0.000
#> SRR1168743     2   0.000      1.000  0 1.000 0.00  0 0.000
#> SRR1168744     2   0.000      1.000  0 1.000 0.00  0 0.000
#> SRR1168745     2   0.000      1.000  0 1.000 0.00  0 0.000
#> SRR1168746     2   0.000      1.000  0 1.000 0.00  0 0.000
#> SRR1168747     5   0.141      0.997  0 0.060 0.00  0 0.940
#> SRR1168748     5   0.154      0.991  0 0.068 0.00  0 0.932
#> SRR1168749     5   0.141      0.997  0 0.060 0.00  0 0.940
#> SRR1168750     5   0.141      0.997  0 0.060 0.00  0 0.940
#> SRR1168751     5   0.141      0.997  0 0.060 0.00  0 0.940
#> SRR1168752     5   0.173      0.979  0 0.080 0.00  0 0.920
#> SRR1168753     5   0.148      0.994  0 0.064 0.00  0 0.936
#> SRR1168754     5   0.141      0.997  0 0.060 0.00  0 0.940
#> SRR1168755     5   0.141      0.997  0 0.060 0.00  0 0.940
#> SRR1168756     5   0.141      0.997  0 0.060 0.00  0 0.940
#> SRR1168757     5   0.141      0.997  0 0.060 0.00  0 0.940
#> SRR1168758     5   0.141      0.997  0 0.060 0.00  0 0.940
#> SRR1168759     5   0.141      0.997  0 0.060 0.00  0 0.940
#> SRR1168760     5   0.141      0.997  0 0.060 0.00  0 0.940
#> SRR1168761     3   0.000      0.976  0 0.000 1.00  0 0.000
#> SRR1168762     3   0.000      0.976  0 0.000 1.00  0 0.000
#> SRR1168763     3   0.000      0.976  0 0.000 1.00  0 0.000
#> SRR1168764     3   0.000      0.976  0 0.000 1.00  0 0.000
#> SRR1168765     3   0.000      0.976  0 0.000 1.00  0 0.000
#> SRR1168766     3   0.000      0.976  0 0.000 1.00  0 0.000
#> SRR1168767     3   0.000      0.976  0 0.000 1.00  0 0.000
#> SRR1168768     3   0.000      0.976  0 0.000 1.00  0 0.000
#> SRR1168769     4   0.000      1.000  0 0.000 0.00  1 0.000
#> SRR1168770     4   0.000      1.000  0 0.000 0.00  1 0.000
#> SRR1168771     4   0.000      1.000  0 0.000 0.00  1 0.000
#> SRR1168772     4   0.000      1.000  0 0.000 0.00  1 0.000
#> SRR1168773     4   0.000      1.000  0 0.000 0.00  1 0.000
#> SRR1168774     4   0.000      1.000  0 0.000 0.00  1 0.000
#> SRR1168775     4   0.000      1.000  0 0.000 0.00  1 0.000
#> SRR1168776     4   0.000      1.000  0 0.000 0.00  1 0.000
#> SRR1168777     4   0.000      1.000  0 0.000 0.00  1 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette p1    p2 p3 p4    p5 p6
#> SRR1168715     6  0.0000      1.000  0 0.000  0  0 0.000  1
#> SRR1168716     6  0.0000      1.000  0 0.000  0  0 0.000  1
#> SRR1168717     6  0.0000      1.000  0 0.000  0  0 0.000  1
#> SRR1168718     6  0.0000      1.000  0 0.000  0  0 0.000  1
#> SRR1168719     6  0.0000      1.000  0 0.000  0  0 0.000  1
#> SRR1168720     6  0.0000      1.000  0 0.000  0  0 0.000  1
#> SRR1168721     6  0.0000      1.000  0 0.000  0  0 0.000  1
#> SRR1168722     1  0.0000      1.000  1 0.000  0  0 0.000  0
#> SRR1168723     1  0.0000      1.000  1 0.000  0  0 0.000  0
#> SRR1168724     1  0.0000      1.000  1 0.000  0  0 0.000  0
#> SRR1168725     1  0.0000      1.000  1 0.000  0  0 0.000  0
#> SRR1168726     1  0.0000      1.000  1 0.000  0  0 0.000  0
#> SRR1168727     1  0.0000      1.000  1 0.000  0  0 0.000  0
#> SRR1168728     1  0.0000      1.000  1 0.000  0  0 0.000  0
#> SRR1168729     1  0.0000      1.000  1 0.000  0  0 0.000  0
#> SRR1168730     1  0.0000      1.000  1 0.000  0  0 0.000  0
#> SRR1168731     1  0.0000      1.000  1 0.000  0  0 0.000  0
#> SRR1168732     1  0.0000      1.000  1 0.000  0  0 0.000  0
#> SRR1168733     2  0.0000      1.000  0 1.000  0  0 0.000  0
#> SRR1168734     2  0.0000      1.000  0 1.000  0  0 0.000  0
#> SRR1168735     2  0.0000      1.000  0 1.000  0  0 0.000  0
#> SRR1168736     2  0.0000      1.000  0 1.000  0  0 0.000  0
#> SRR1168737     2  0.0000      1.000  0 1.000  0  0 0.000  0
#> SRR1168738     2  0.0000      1.000  0 1.000  0  0 0.000  0
#> SRR1168739     2  0.0000      1.000  0 1.000  0  0 0.000  0
#> SRR1168740     2  0.0000      1.000  0 1.000  0  0 0.000  0
#> SRR1168741     2  0.0000      1.000  0 1.000  0  0 0.000  0
#> SRR1168742     2  0.0000      1.000  0 1.000  0  0 0.000  0
#> SRR1168743     2  0.0000      1.000  0 1.000  0  0 0.000  0
#> SRR1168744     2  0.0000      1.000  0 1.000  0  0 0.000  0
#> SRR1168745     2  0.0000      1.000  0 1.000  0  0 0.000  0
#> SRR1168746     2  0.0000      1.000  0 1.000  0  0 0.000  0
#> SRR1168747     5  0.0000      0.997  0 0.000  0  0 1.000  0
#> SRR1168748     5  0.0260      0.990  0 0.008  0  0 0.992  0
#> SRR1168749     5  0.0000      0.997  0 0.000  0  0 1.000  0
#> SRR1168750     5  0.0000      0.997  0 0.000  0  0 1.000  0
#> SRR1168751     5  0.0000      0.997  0 0.000  0  0 1.000  0
#> SRR1168752     5  0.0547      0.977  0 0.020  0  0 0.980  0
#> SRR1168753     5  0.0146      0.994  0 0.004  0  0 0.996  0
#> SRR1168754     5  0.0000      0.997  0 0.000  0  0 1.000  0
#> SRR1168755     5  0.0000      0.997  0 0.000  0  0 1.000  0
#> SRR1168756     5  0.0000      0.997  0 0.000  0  0 1.000  0
#> SRR1168757     5  0.0000      0.997  0 0.000  0  0 1.000  0
#> SRR1168758     5  0.0000      0.997  0 0.000  0  0 1.000  0
#> SRR1168759     5  0.0000      0.997  0 0.000  0  0 1.000  0
#> SRR1168760     5  0.0000      0.997  0 0.000  0  0 1.000  0
#> SRR1168761     3  0.0000      1.000  0 0.000  1  0 0.000  0
#> SRR1168762     3  0.0000      1.000  0 0.000  1  0 0.000  0
#> SRR1168763     3  0.0000      1.000  0 0.000  1  0 0.000  0
#> SRR1168764     3  0.0000      1.000  0 0.000  1  0 0.000  0
#> SRR1168765     3  0.0000      1.000  0 0.000  1  0 0.000  0
#> SRR1168766     3  0.0000      1.000  0 0.000  1  0 0.000  0
#> SRR1168767     3  0.0000      1.000  0 0.000  1  0 0.000  0
#> SRR1168768     3  0.0000      1.000  0 0.000  1  0 0.000  0
#> SRR1168769     4  0.0000      1.000  0 0.000  0  1 0.000  0
#> SRR1168770     4  0.0000      1.000  0 0.000  0  1 0.000  0
#> SRR1168771     4  0.0000      1.000  0 0.000  0  1 0.000  0
#> SRR1168772     4  0.0000      1.000  0 0.000  0  1 0.000  0
#> SRR1168773     4  0.0000      1.000  0 0.000  0  1 0.000  0
#> SRR1168774     4  0.0000      1.000  0 0.000  0  1 0.000  0
#> SRR1168775     4  0.0000      1.000  0 0.000  0  1 0.000  0
#> SRR1168776     4  0.0000      1.000  0 0.000  0  1 0.000  0
#> SRR1168777     4  0.0000      1.000  0 0.000  0  1 0.000  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 14158 rows and 63 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#>   Subgroups are detected by 'mclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 5.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk CV-mclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2     1           1.000       1.000        0.50229 0.498   0.498
#> 3 3     1           0.994       0.995        0.26999 0.865   0.729
#> 4 4     1           1.000       1.000        0.10736 0.931   0.810
#> 5 5     1           1.000       1.000        0.04055 0.971   0.902
#> 6 6     1           0.966       0.980        0.00993 0.997   0.988

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette p1 p2
#> SRR1168715     1       0          1  1  0
#> SRR1168716     1       0          1  1  0
#> SRR1168717     1       0          1  1  0
#> SRR1168718     1       0          1  1  0
#> SRR1168719     1       0          1  1  0
#> SRR1168720     1       0          1  1  0
#> SRR1168721     1       0          1  1  0
#> SRR1168722     1       0          1  1  0
#> SRR1168723     1       0          1  1  0
#> SRR1168724     1       0          1  1  0
#> SRR1168725     1       0          1  1  0
#> SRR1168726     1       0          1  1  0
#> SRR1168727     1       0          1  1  0
#> SRR1168728     1       0          1  1  0
#> SRR1168729     1       0          1  1  0
#> SRR1168730     1       0          1  1  0
#> SRR1168731     1       0          1  1  0
#> SRR1168732     1       0          1  1  0
#> SRR1168733     2       0          1  0  1
#> SRR1168734     2       0          1  0  1
#> SRR1168735     2       0          1  0  1
#> SRR1168736     2       0          1  0  1
#> SRR1168737     2       0          1  0  1
#> SRR1168738     2       0          1  0  1
#> SRR1168739     2       0          1  0  1
#> SRR1168740     2       0          1  0  1
#> SRR1168741     2       0          1  0  1
#> SRR1168742     2       0          1  0  1
#> SRR1168743     2       0          1  0  1
#> SRR1168744     2       0          1  0  1
#> SRR1168745     2       0          1  0  1
#> SRR1168746     2       0          1  0  1
#> SRR1168747     2       0          1  0  1
#> SRR1168748     2       0          1  0  1
#> SRR1168749     2       0          1  0  1
#> SRR1168750     2       0          1  0  1
#> SRR1168751     2       0          1  0  1
#> SRR1168752     2       0          1  0  1
#> SRR1168753     2       0          1  0  1
#> SRR1168754     2       0          1  0  1
#> SRR1168755     2       0          1  0  1
#> SRR1168756     2       0          1  0  1
#> SRR1168757     2       0          1  0  1
#> SRR1168758     2       0          1  0  1
#> SRR1168759     2       0          1  0  1
#> SRR1168760     2       0          1  0  1
#> SRR1168761     1       0          1  1  0
#> SRR1168762     1       0          1  1  0
#> SRR1168763     1       0          1  1  0
#> SRR1168764     1       0          1  1  0
#> SRR1168765     1       0          1  1  0
#> SRR1168766     1       0          1  1  0
#> SRR1168767     1       0          1  1  0
#> SRR1168768     1       0          1  1  0
#> SRR1168769     1       0          1  1  0
#> SRR1168770     1       0          1  1  0
#> SRR1168771     1       0          1  1  0
#> SRR1168772     1       0          1  1  0
#> SRR1168773     1       0          1  1  0
#> SRR1168774     1       0          1  1  0
#> SRR1168775     1       0          1  1  0
#> SRR1168776     1       0          1  1  0
#> SRR1168777     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1 p2    p3
#> SRR1168715     3   0.000      0.987 0.000  0 1.000
#> SRR1168716     3   0.000      0.987 0.000  0 1.000
#> SRR1168717     3   0.000      0.987 0.000  0 1.000
#> SRR1168718     3   0.000      0.987 0.000  0 1.000
#> SRR1168719     3   0.000      0.987 0.000  0 1.000
#> SRR1168720     3   0.000      0.987 0.000  0 1.000
#> SRR1168721     3   0.000      0.987 0.000  0 1.000
#> SRR1168722     1   0.000      1.000 1.000  0 0.000
#> SRR1168723     1   0.000      1.000 1.000  0 0.000
#> SRR1168724     1   0.000      1.000 1.000  0 0.000
#> SRR1168725     1   0.000      1.000 1.000  0 0.000
#> SRR1168726     1   0.000      1.000 1.000  0 0.000
#> SRR1168727     1   0.000      1.000 1.000  0 0.000
#> SRR1168728     1   0.000      1.000 1.000  0 0.000
#> SRR1168729     1   0.000      1.000 1.000  0 0.000
#> SRR1168730     1   0.000      1.000 1.000  0 0.000
#> SRR1168731     1   0.000      1.000 1.000  0 0.000
#> SRR1168732     1   0.000      1.000 1.000  0 0.000
#> SRR1168733     2   0.000      1.000 0.000  1 0.000
#> SRR1168734     2   0.000      1.000 0.000  1 0.000
#> SRR1168735     2   0.000      1.000 0.000  1 0.000
#> SRR1168736     2   0.000      1.000 0.000  1 0.000
#> SRR1168737     2   0.000      1.000 0.000  1 0.000
#> SRR1168738     2   0.000      1.000 0.000  1 0.000
#> SRR1168739     2   0.000      1.000 0.000  1 0.000
#> SRR1168740     2   0.000      1.000 0.000  1 0.000
#> SRR1168741     2   0.000      1.000 0.000  1 0.000
#> SRR1168742     2   0.000      1.000 0.000  1 0.000
#> SRR1168743     2   0.000      1.000 0.000  1 0.000
#> SRR1168744     2   0.000      1.000 0.000  1 0.000
#> SRR1168745     2   0.000      1.000 0.000  1 0.000
#> SRR1168746     2   0.000      1.000 0.000  1 0.000
#> SRR1168747     2   0.000      1.000 0.000  1 0.000
#> SRR1168748     2   0.000      1.000 0.000  1 0.000
#> SRR1168749     2   0.000      1.000 0.000  1 0.000
#> SRR1168750     2   0.000      1.000 0.000  1 0.000
#> SRR1168751     2   0.000      1.000 0.000  1 0.000
#> SRR1168752     2   0.000      1.000 0.000  1 0.000
#> SRR1168753     2   0.000      1.000 0.000  1 0.000
#> SRR1168754     2   0.000      1.000 0.000  1 0.000
#> SRR1168755     2   0.000      1.000 0.000  1 0.000
#> SRR1168756     2   0.000      1.000 0.000  1 0.000
#> SRR1168757     2   0.000      1.000 0.000  1 0.000
#> SRR1168758     2   0.000      1.000 0.000  1 0.000
#> SRR1168759     2   0.000      1.000 0.000  1 0.000
#> SRR1168760     2   0.000      1.000 0.000  1 0.000
#> SRR1168761     3   0.000      0.987 0.000  0 1.000
#> SRR1168762     3   0.000      0.987 0.000  0 1.000
#> SRR1168763     3   0.000      0.987 0.000  0 1.000
#> SRR1168764     3   0.000      0.987 0.000  0 1.000
#> SRR1168765     3   0.000      0.987 0.000  0 1.000
#> SRR1168766     3   0.000      0.987 0.000  0 1.000
#> SRR1168767     3   0.000      0.987 0.000  0 1.000
#> SRR1168768     3   0.000      0.987 0.000  0 1.000
#> SRR1168769     3   0.129      0.978 0.032  0 0.968
#> SRR1168770     3   0.129      0.978 0.032  0 0.968
#> SRR1168771     3   0.129      0.978 0.032  0 0.968
#> SRR1168772     3   0.129      0.978 0.032  0 0.968
#> SRR1168773     3   0.129      0.978 0.032  0 0.968
#> SRR1168774     3   0.129      0.978 0.032  0 0.968
#> SRR1168775     3   0.129      0.978 0.032  0 0.968
#> SRR1168776     3   0.129      0.978 0.032  0 0.968
#> SRR1168777     3   0.129      0.978 0.032  0 0.968

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette p1 p2 p3 p4
#> SRR1168715     3       0          1  0  0  1  0
#> SRR1168716     3       0          1  0  0  1  0
#> SRR1168717     3       0          1  0  0  1  0
#> SRR1168718     3       0          1  0  0  1  0
#> SRR1168719     3       0          1  0  0  1  0
#> SRR1168720     3       0          1  0  0  1  0
#> SRR1168721     3       0          1  0  0  1  0
#> SRR1168722     1       0          1  1  0  0  0
#> SRR1168723     1       0          1  1  0  0  0
#> SRR1168724     1       0          1  1  0  0  0
#> SRR1168725     1       0          1  1  0  0  0
#> SRR1168726     1       0          1  1  0  0  0
#> SRR1168727     1       0          1  1  0  0  0
#> SRR1168728     1       0          1  1  0  0  0
#> SRR1168729     1       0          1  1  0  0  0
#> SRR1168730     1       0          1  1  0  0  0
#> SRR1168731     1       0          1  1  0  0  0
#> SRR1168732     1       0          1  1  0  0  0
#> SRR1168733     2       0          1  0  1  0  0
#> SRR1168734     2       0          1  0  1  0  0
#> SRR1168735     2       0          1  0  1  0  0
#> SRR1168736     2       0          1  0  1  0  0
#> SRR1168737     2       0          1  0  1  0  0
#> SRR1168738     2       0          1  0  1  0  0
#> SRR1168739     2       0          1  0  1  0  0
#> SRR1168740     2       0          1  0  1  0  0
#> SRR1168741     2       0          1  0  1  0  0
#> SRR1168742     2       0          1  0  1  0  0
#> SRR1168743     2       0          1  0  1  0  0
#> SRR1168744     2       0          1  0  1  0  0
#> SRR1168745     2       0          1  0  1  0  0
#> SRR1168746     2       0          1  0  1  0  0
#> SRR1168747     2       0          1  0  1  0  0
#> SRR1168748     2       0          1  0  1  0  0
#> SRR1168749     2       0          1  0  1  0  0
#> SRR1168750     2       0          1  0  1  0  0
#> SRR1168751     2       0          1  0  1  0  0
#> SRR1168752     2       0          1  0  1  0  0
#> SRR1168753     2       0          1  0  1  0  0
#> SRR1168754     2       0          1  0  1  0  0
#> SRR1168755     2       0          1  0  1  0  0
#> SRR1168756     2       0          1  0  1  0  0
#> SRR1168757     2       0          1  0  1  0  0
#> SRR1168758     2       0          1  0  1  0  0
#> SRR1168759     2       0          1  0  1  0  0
#> SRR1168760     2       0          1  0  1  0  0
#> SRR1168761     3       0          1  0  0  1  0
#> SRR1168762     3       0          1  0  0  1  0
#> SRR1168763     3       0          1  0  0  1  0
#> SRR1168764     3       0          1  0  0  1  0
#> SRR1168765     3       0          1  0  0  1  0
#> SRR1168766     3       0          1  0  0  1  0
#> SRR1168767     3       0          1  0  0  1  0
#> SRR1168768     3       0          1  0  0  1  0
#> SRR1168769     4       0          1  0  0  0  1
#> SRR1168770     4       0          1  0  0  0  1
#> SRR1168771     4       0          1  0  0  0  1
#> SRR1168772     4       0          1  0  0  0  1
#> SRR1168773     4       0          1  0  0  0  1
#> SRR1168774     4       0          1  0  0  0  1
#> SRR1168775     4       0          1  0  0  0  1
#> SRR1168776     4       0          1  0  0  0  1
#> SRR1168777     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
#> SRR1168715     5       0          1  0  0  0  0  1
#> SRR1168716     5       0          1  0  0  0  0  1
#> SRR1168717     5       0          1  0  0  0  0  1
#> SRR1168718     5       0          1  0  0  0  0  1
#> SRR1168719     5       0          1  0  0  0  0  1
#> SRR1168720     5       0          1  0  0  0  0  1
#> SRR1168721     5       0          1  0  0  0  0  1
#> SRR1168722     1       0          1  1  0  0  0  0
#> SRR1168723     1       0          1  1  0  0  0  0
#> SRR1168724     1       0          1  1  0  0  0  0
#> SRR1168725     1       0          1  1  0  0  0  0
#> SRR1168726     1       0          1  1  0  0  0  0
#> SRR1168727     1       0          1  1  0  0  0  0
#> SRR1168728     1       0          1  1  0  0  0  0
#> SRR1168729     1       0          1  1  0  0  0  0
#> SRR1168730     1       0          1  1  0  0  0  0
#> SRR1168731     1       0          1  1  0  0  0  0
#> SRR1168732     1       0          1  1  0  0  0  0
#> SRR1168733     2       0          1  0  1  0  0  0
#> SRR1168734     2       0          1  0  1  0  0  0
#> SRR1168735     2       0          1  0  1  0  0  0
#> SRR1168736     2       0          1  0  1  0  0  0
#> SRR1168737     2       0          1  0  1  0  0  0
#> SRR1168738     2       0          1  0  1  0  0  0
#> SRR1168739     2       0          1  0  1  0  0  0
#> SRR1168740     2       0          1  0  1  0  0  0
#> SRR1168741     2       0          1  0  1  0  0  0
#> SRR1168742     2       0          1  0  1  0  0  0
#> SRR1168743     2       0          1  0  1  0  0  0
#> SRR1168744     2       0          1  0  1  0  0  0
#> SRR1168745     2       0          1  0  1  0  0  0
#> SRR1168746     2       0          1  0  1  0  0  0
#> SRR1168747     2       0          1  0  1  0  0  0
#> SRR1168748     2       0          1  0  1  0  0  0
#> SRR1168749     2       0          1  0  1  0  0  0
#> SRR1168750     2       0          1  0  1  0  0  0
#> SRR1168751     2       0          1  0  1  0  0  0
#> SRR1168752     2       0          1  0  1  0  0  0
#> SRR1168753     2       0          1  0  1  0  0  0
#> SRR1168754     2       0          1  0  1  0  0  0
#> SRR1168755     2       0          1  0  1  0  0  0
#> SRR1168756     2       0          1  0  1  0  0  0
#> SRR1168757     2       0          1  0  1  0  0  0
#> SRR1168758     2       0          1  0  1  0  0  0
#> SRR1168759     2       0          1  0  1  0  0  0
#> SRR1168760     2       0          1  0  1  0  0  0
#> SRR1168761     3       0          1  0  0  1  0  0
#> SRR1168762     3       0          1  0  0  1  0  0
#> SRR1168763     3       0          1  0  0  1  0  0
#> SRR1168764     3       0          1  0  0  1  0  0
#> SRR1168765     3       0          1  0  0  1  0  0
#> SRR1168766     3       0          1  0  0  1  0  0
#> SRR1168767     3       0          1  0  0  1  0  0
#> SRR1168768     3       0          1  0  0  1  0  0
#> SRR1168769     4       0          1  0  0  0  1  0
#> SRR1168770     4       0          1  0  0  0  1  0
#> SRR1168771     4       0          1  0  0  0  1  0
#> SRR1168772     4       0          1  0  0  0  1  0
#> SRR1168773     4       0          1  0  0  0  1  0
#> SRR1168774     4       0          1  0  0  0  1  0
#> SRR1168775     4       0          1  0  0  0  1  0
#> SRR1168776     4       0          1  0  0  0  1  0
#> SRR1168777     4       0          1  0  0  0  1  0

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR1168715     6  0.0363      0.982 0.000 0.012 0.000 0.000 0.000 0.988
#> SRR1168716     6  0.0000      0.987 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR1168717     6  0.0458      0.977 0.000 0.016 0.000 0.000 0.000 0.984
#> SRR1168718     6  0.0260      0.986 0.000 0.008 0.000 0.000 0.000 0.992
#> SRR1168719     6  0.0363      0.985 0.000 0.012 0.000 0.000 0.000 0.988
#> SRR1168720     6  0.0146      0.987 0.000 0.004 0.000 0.000 0.000 0.996
#> SRR1168721     2  0.3607      0.000 0.000 0.652 0.000 0.000 0.000 0.348
#> SRR1168722     1  0.0937      0.970 0.960 0.040 0.000 0.000 0.000 0.000
#> SRR1168723     1  0.0363      0.986 0.988 0.012 0.000 0.000 0.000 0.000
#> SRR1168724     1  0.0260      0.987 0.992 0.008 0.000 0.000 0.000 0.000
#> SRR1168725     1  0.0458      0.986 0.984 0.016 0.000 0.000 0.000 0.000
#> SRR1168726     1  0.0363      0.987 0.988 0.012 0.000 0.000 0.000 0.000
#> SRR1168727     1  0.0146      0.988 0.996 0.004 0.000 0.000 0.000 0.000
#> SRR1168728     1  0.0146      0.988 0.996 0.004 0.000 0.000 0.000 0.000
#> SRR1168729     1  0.0260      0.987 0.992 0.008 0.000 0.000 0.000 0.000
#> SRR1168730     1  0.0865      0.976 0.964 0.036 0.000 0.000 0.000 0.000
#> SRR1168731     1  0.0458      0.987 0.984 0.016 0.000 0.000 0.000 0.000
#> SRR1168732     1  0.0146      0.988 0.996 0.004 0.000 0.000 0.000 0.000
#> SRR1168733     5  0.0000      0.985 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1168734     5  0.0146      0.985 0.000 0.004 0.000 0.000 0.996 0.000
#> SRR1168735     5  0.0000      0.985 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1168736     5  0.0000      0.985 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1168737     5  0.0000      0.985 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1168738     5  0.0000      0.985 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1168739     5  0.0000      0.985 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1168740     5  0.0000      0.985 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1168741     5  0.0000      0.985 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1168742     5  0.0000      0.985 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1168743     5  0.0000      0.985 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1168744     5  0.0000      0.985 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1168745     5  0.0000      0.985 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1168746     5  0.0000      0.985 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1168747     5  0.0865      0.978 0.000 0.036 0.000 0.000 0.964 0.000
#> SRR1168748     5  0.0547      0.983 0.000 0.020 0.000 0.000 0.980 0.000
#> SRR1168749     5  0.0865      0.979 0.000 0.036 0.000 0.000 0.964 0.000
#> SRR1168750     5  0.0865      0.978 0.000 0.036 0.000 0.000 0.964 0.000
#> SRR1168751     5  0.0146      0.985 0.000 0.004 0.000 0.000 0.996 0.000
#> SRR1168752     5  0.1075      0.972 0.000 0.048 0.000 0.000 0.952 0.000
#> SRR1168753     5  0.0260      0.985 0.000 0.008 0.000 0.000 0.992 0.000
#> SRR1168754     5  0.0937      0.977 0.000 0.040 0.000 0.000 0.960 0.000
#> SRR1168755     5  0.0547      0.983 0.000 0.020 0.000 0.000 0.980 0.000
#> SRR1168756     5  0.0937      0.977 0.000 0.040 0.000 0.000 0.960 0.000
#> SRR1168757     5  0.0937      0.977 0.000 0.040 0.000 0.000 0.960 0.000
#> SRR1168758     5  0.0790      0.980 0.000 0.032 0.000 0.000 0.968 0.000
#> SRR1168759     5  0.0937      0.977 0.000 0.040 0.000 0.000 0.960 0.000
#> SRR1168760     5  0.0865      0.978 0.000 0.036 0.000 0.000 0.964 0.000
#> SRR1168761     3  0.0865      0.972 0.000 0.036 0.964 0.000 0.000 0.000
#> SRR1168762     3  0.0000      0.988 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1168763     3  0.0260      0.987 0.000 0.008 0.992 0.000 0.000 0.000
#> SRR1168764     3  0.0000      0.988 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1168765     3  0.0146      0.988 0.000 0.004 0.996 0.000 0.000 0.000
#> SRR1168766     3  0.0146      0.988 0.000 0.004 0.996 0.000 0.000 0.000
#> SRR1168767     3  0.0363      0.986 0.000 0.012 0.988 0.000 0.000 0.000
#> SRR1168768     3  0.0865      0.973 0.000 0.036 0.964 0.000 0.000 0.000
#> SRR1168769     4  0.0260      0.981 0.000 0.008 0.000 0.992 0.000 0.000
#> SRR1168770     4  0.0000      0.983 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1168771     4  0.0000      0.983 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1168772     4  0.0000      0.983 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1168773     4  0.0713      0.971 0.000 0.028 0.000 0.972 0.000 0.000
#> SRR1168774     4  0.0000      0.983 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1168775     4  0.0146      0.982 0.000 0.004 0.000 0.996 0.000 0.000
#> SRR1168776     4  0.0363      0.979 0.000 0.012 0.000 0.988 0.000 0.000
#> SRR1168777     4  0.1814      0.908 0.000 0.100 0.000 0.900 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-mclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-mclust-collect-classes

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


CV:NMF**

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

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

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

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

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

collect_plots(res)

plot of chunk CV-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.5023 0.498   0.498
#> 3 3 0.745           0.970       0.895         0.2379 0.846   0.692
#> 4 4 0.788           0.874       0.815         0.1207 1.000   1.000
#> 5 5 0.752           0.867       0.819         0.0812 0.900   0.709
#> 6 6 0.754           0.903       0.836         0.0480 0.949   0.792

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
#> SRR1168715     1       0          1  1  0
#> SRR1168716     1       0          1  1  0
#> SRR1168717     1       0          1  1  0
#> SRR1168718     1       0          1  1  0
#> SRR1168719     1       0          1  1  0
#> SRR1168720     1       0          1  1  0
#> SRR1168721     1       0          1  1  0
#> SRR1168722     1       0          1  1  0
#> SRR1168723     1       0          1  1  0
#> SRR1168724     1       0          1  1  0
#> SRR1168725     1       0          1  1  0
#> SRR1168726     1       0          1  1  0
#> SRR1168727     1       0          1  1  0
#> SRR1168728     1       0          1  1  0
#> SRR1168729     1       0          1  1  0
#> SRR1168730     1       0          1  1  0
#> SRR1168731     1       0          1  1  0
#> SRR1168732     1       0          1  1  0
#> SRR1168733     2       0          1  0  1
#> SRR1168734     2       0          1  0  1
#> SRR1168735     2       0          1  0  1
#> SRR1168736     2       0          1  0  1
#> SRR1168737     2       0          1  0  1
#> SRR1168738     2       0          1  0  1
#> SRR1168739     2       0          1  0  1
#> SRR1168740     2       0          1  0  1
#> SRR1168741     2       0          1  0  1
#> SRR1168742     2       0          1  0  1
#> SRR1168743     2       0          1  0  1
#> SRR1168744     2       0          1  0  1
#> SRR1168745     2       0          1  0  1
#> SRR1168746     2       0          1  0  1
#> SRR1168747     2       0          1  0  1
#> SRR1168748     2       0          1  0  1
#> SRR1168749     2       0          1  0  1
#> SRR1168750     2       0          1  0  1
#> SRR1168751     2       0          1  0  1
#> SRR1168752     2       0          1  0  1
#> SRR1168753     2       0          1  0  1
#> SRR1168754     2       0          1  0  1
#> SRR1168755     2       0          1  0  1
#> SRR1168756     2       0          1  0  1
#> SRR1168757     2       0          1  0  1
#> SRR1168758     2       0          1  0  1
#> SRR1168759     2       0          1  0  1
#> SRR1168760     2       0          1  0  1
#> SRR1168761     1       0          1  1  0
#> SRR1168762     1       0          1  1  0
#> SRR1168763     1       0          1  1  0
#> SRR1168764     1       0          1  1  0
#> SRR1168765     1       0          1  1  0
#> SRR1168766     1       0          1  1  0
#> SRR1168767     1       0          1  1  0
#> SRR1168768     1       0          1  1  0
#> SRR1168769     1       0          1  1  0
#> SRR1168770     1       0          1  1  0
#> SRR1168771     1       0          1  1  0
#> SRR1168772     1       0          1  1  0
#> SRR1168773     1       0          1  1  0
#> SRR1168774     1       0          1  1  0
#> SRR1168775     1       0          1  1  0
#> SRR1168776     1       0          1  1  0
#> SRR1168777     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1168715     3   0.546      0.998 0.288 0.000 0.712
#> SRR1168716     3   0.546      0.998 0.288 0.000 0.712
#> SRR1168717     3   0.546      0.998 0.288 0.000 0.712
#> SRR1168718     3   0.550      0.994 0.292 0.000 0.708
#> SRR1168719     3   0.546      0.998 0.288 0.000 0.712
#> SRR1168720     3   0.556      0.983 0.300 0.000 0.700
#> SRR1168721     3   0.546      0.998 0.288 0.000 0.712
#> SRR1168722     1   0.000      0.977 1.000 0.000 0.000
#> SRR1168723     1   0.000      0.977 1.000 0.000 0.000
#> SRR1168724     1   0.000      0.977 1.000 0.000 0.000
#> SRR1168725     1   0.000      0.977 1.000 0.000 0.000
#> SRR1168726     1   0.000      0.977 1.000 0.000 0.000
#> SRR1168727     1   0.000      0.977 1.000 0.000 0.000
#> SRR1168728     1   0.000      0.977 1.000 0.000 0.000
#> SRR1168729     1   0.000      0.977 1.000 0.000 0.000
#> SRR1168730     1   0.000      0.977 1.000 0.000 0.000
#> SRR1168731     1   0.000      0.977 1.000 0.000 0.000
#> SRR1168732     1   0.000      0.977 1.000 0.000 0.000
#> SRR1168733     2   0.000      0.955 0.000 1.000 0.000
#> SRR1168734     2   0.000      0.955 0.000 1.000 0.000
#> SRR1168735     2   0.000      0.955 0.000 1.000 0.000
#> SRR1168736     2   0.000      0.955 0.000 1.000 0.000
#> SRR1168737     2   0.000      0.955 0.000 1.000 0.000
#> SRR1168738     2   0.000      0.955 0.000 1.000 0.000
#> SRR1168739     2   0.000      0.955 0.000 1.000 0.000
#> SRR1168740     2   0.000      0.955 0.000 1.000 0.000
#> SRR1168741     2   0.000      0.955 0.000 1.000 0.000
#> SRR1168742     2   0.000      0.955 0.000 1.000 0.000
#> SRR1168743     2   0.000      0.955 0.000 1.000 0.000
#> SRR1168744     2   0.000      0.955 0.000 1.000 0.000
#> SRR1168745     2   0.000      0.955 0.000 1.000 0.000
#> SRR1168746     2   0.000      0.955 0.000 1.000 0.000
#> SRR1168747     2   0.304      0.955 0.000 0.896 0.104
#> SRR1168748     2   0.296      0.955 0.000 0.900 0.100
#> SRR1168749     2   0.312      0.954 0.000 0.892 0.108
#> SRR1168750     2   0.312      0.954 0.000 0.892 0.108
#> SRR1168751     2   0.312      0.954 0.000 0.892 0.108
#> SRR1168752     2   0.304      0.955 0.000 0.896 0.104
#> SRR1168753     2   0.312      0.954 0.000 0.892 0.108
#> SRR1168754     2   0.312      0.954 0.000 0.892 0.108
#> SRR1168755     2   0.312      0.954 0.000 0.892 0.108
#> SRR1168756     2   0.304      0.955 0.000 0.896 0.104
#> SRR1168757     2   0.312      0.954 0.000 0.892 0.108
#> SRR1168758     2   0.304      0.955 0.000 0.896 0.104
#> SRR1168759     2   0.312      0.954 0.000 0.892 0.108
#> SRR1168760     2   0.312      0.954 0.000 0.892 0.108
#> SRR1168761     3   0.546      0.998 0.288 0.000 0.712
#> SRR1168762     3   0.546      0.998 0.288 0.000 0.712
#> SRR1168763     3   0.546      0.998 0.288 0.000 0.712
#> SRR1168764     3   0.546      0.998 0.288 0.000 0.712
#> SRR1168765     3   0.546      0.998 0.288 0.000 0.712
#> SRR1168766     3   0.546      0.998 0.288 0.000 0.712
#> SRR1168767     3   0.546      0.998 0.288 0.000 0.712
#> SRR1168768     3   0.546      0.998 0.288 0.000 0.712
#> SRR1168769     1   0.129      0.969 0.968 0.000 0.032
#> SRR1168770     1   0.129      0.969 0.968 0.000 0.032
#> SRR1168771     1   0.141      0.966 0.964 0.000 0.036
#> SRR1168772     1   0.129      0.969 0.968 0.000 0.032
#> SRR1168773     1   0.186      0.948 0.948 0.000 0.052
#> SRR1168774     1   0.116      0.971 0.972 0.000 0.028
#> SRR1168775     1   0.129      0.969 0.968 0.000 0.032
#> SRR1168776     1   0.186      0.948 0.948 0.000 0.052
#> SRR1168777     1   0.129      0.969 0.968 0.000 0.032

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3 p4
#> SRR1168715     3   0.208      0.946 0.084 0.000 0.916 NA
#> SRR1168716     3   0.208      0.946 0.084 0.000 0.916 NA
#> SRR1168717     3   0.208      0.946 0.084 0.000 0.916 NA
#> SRR1168718     3   0.228      0.941 0.096 0.000 0.904 NA
#> SRR1168719     3   0.215      0.945 0.088 0.000 0.912 NA
#> SRR1168720     3   0.222      0.943 0.092 0.000 0.908 NA
#> SRR1168721     3   0.215      0.945 0.088 0.000 0.912 NA
#> SRR1168722     1   0.000      0.951 1.000 0.000 0.000 NA
#> SRR1168723     1   0.000      0.951 1.000 0.000 0.000 NA
#> SRR1168724     1   0.000      0.951 1.000 0.000 0.000 NA
#> SRR1168725     1   0.000      0.951 1.000 0.000 0.000 NA
#> SRR1168726     1   0.000      0.951 1.000 0.000 0.000 NA
#> SRR1168727     1   0.000      0.951 1.000 0.000 0.000 NA
#> SRR1168728     1   0.000      0.951 1.000 0.000 0.000 NA
#> SRR1168729     1   0.000      0.951 1.000 0.000 0.000 NA
#> SRR1168730     1   0.000      0.951 1.000 0.000 0.000 NA
#> SRR1168731     1   0.000      0.951 1.000 0.000 0.000 NA
#> SRR1168732     1   0.000      0.951 1.000 0.000 0.000 NA
#> SRR1168733     2   0.000      0.787 0.000 1.000 0.000 NA
#> SRR1168734     2   0.000      0.787 0.000 1.000 0.000 NA
#> SRR1168735     2   0.000      0.787 0.000 1.000 0.000 NA
#> SRR1168736     2   0.000      0.787 0.000 1.000 0.000 NA
#> SRR1168737     2   0.000      0.787 0.000 1.000 0.000 NA
#> SRR1168738     2   0.000      0.787 0.000 1.000 0.000 NA
#> SRR1168739     2   0.000      0.787 0.000 1.000 0.000 NA
#> SRR1168740     2   0.000      0.787 0.000 1.000 0.000 NA
#> SRR1168741     2   0.000      0.787 0.000 1.000 0.000 NA
#> SRR1168742     2   0.000      0.787 0.000 1.000 0.000 NA
#> SRR1168743     2   0.000      0.787 0.000 1.000 0.000 NA
#> SRR1168744     2   0.000      0.787 0.000 1.000 0.000 NA
#> SRR1168745     2   0.000      0.787 0.000 1.000 0.000 NA
#> SRR1168746     2   0.000      0.787 0.000 1.000 0.000 NA
#> SRR1168747     2   0.495      0.786 0.000 0.560 0.000 NA
#> SRR1168748     2   0.494      0.786 0.000 0.564 0.000 NA
#> SRR1168749     2   0.495      0.786 0.000 0.560 0.000 NA
#> SRR1168750     2   0.495      0.786 0.000 0.560 0.000 NA
#> SRR1168751     2   0.494      0.786 0.000 0.564 0.000 NA
#> SRR1168752     2   0.494      0.786 0.000 0.564 0.000 NA
#> SRR1168753     2   0.495      0.786 0.000 0.560 0.000 NA
#> SRR1168754     2   0.495      0.786 0.000 0.560 0.000 NA
#> SRR1168755     2   0.495      0.786 0.000 0.560 0.000 NA
#> SRR1168756     2   0.495      0.786 0.000 0.560 0.000 NA
#> SRR1168757     2   0.495      0.786 0.000 0.560 0.000 NA
#> SRR1168758     2   0.495      0.786 0.000 0.560 0.000 NA
#> SRR1168759     2   0.495      0.786 0.000 0.560 0.000 NA
#> SRR1168760     2   0.495      0.786 0.000 0.560 0.000 NA
#> SRR1168761     3   0.389      0.953 0.064 0.000 0.844 NA
#> SRR1168762     3   0.401      0.951 0.064 0.000 0.836 NA
#> SRR1168763     3   0.401      0.951 0.064 0.000 0.836 NA
#> SRR1168764     3   0.401      0.951 0.064 0.000 0.836 NA
#> SRR1168765     3   0.395      0.952 0.064 0.000 0.840 NA
#> SRR1168766     3   0.395      0.952 0.064 0.000 0.840 NA
#> SRR1168767     3   0.395      0.952 0.064 0.000 0.840 NA
#> SRR1168768     3   0.382      0.953 0.064 0.000 0.848 NA
#> SRR1168769     1   0.255      0.938 0.900 0.000 0.008 NA
#> SRR1168770     1   0.280      0.934 0.884 0.000 0.008 NA
#> SRR1168771     1   0.261      0.937 0.896 0.000 0.008 NA
#> SRR1168772     1   0.298      0.928 0.872 0.000 0.008 NA
#> SRR1168773     1   0.316      0.923 0.864 0.000 0.012 NA
#> SRR1168774     1   0.267      0.936 0.892 0.000 0.008 NA
#> SRR1168775     1   0.267      0.936 0.892 0.000 0.008 NA
#> SRR1168776     1   0.350      0.909 0.844 0.000 0.016 NA
#> SRR1168777     1   0.325      0.915 0.852 0.000 0.008 NA

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4 p5
#> SRR1168715     3  0.1469      0.810 0.036 0.000 0.948 0.000 NA
#> SRR1168716     3  0.1469      0.814 0.036 0.000 0.948 0.000 NA
#> SRR1168717     3  0.1124      0.814 0.036 0.000 0.960 0.000 NA
#> SRR1168718     3  0.1661      0.805 0.036 0.000 0.940 0.000 NA
#> SRR1168719     3  0.1469      0.810 0.036 0.000 0.948 0.000 NA
#> SRR1168720     3  0.1568      0.808 0.036 0.000 0.944 0.000 NA
#> SRR1168721     3  0.1750      0.803 0.036 0.000 0.936 0.000 NA
#> SRR1168722     1  0.5213      0.784 0.616 0.000 0.064 0.000 NA
#> SRR1168723     1  0.5425      0.781 0.600 0.000 0.080 0.000 NA
#> SRR1168724     1  0.5584      0.773 0.584 0.000 0.092 0.000 NA
#> SRR1168725     1  0.5375      0.782 0.604 0.000 0.076 0.000 NA
#> SRR1168726     1  0.5425      0.781 0.600 0.000 0.080 0.000 NA
#> SRR1168727     1  0.5615      0.772 0.584 0.000 0.096 0.000 NA
#> SRR1168728     1  0.5425      0.781 0.600 0.000 0.080 0.000 NA
#> SRR1168729     1  0.5584      0.773 0.584 0.000 0.092 0.000 NA
#> SRR1168730     1  0.5252      0.784 0.616 0.000 0.068 0.000 NA
#> SRR1168731     1  0.5156      0.784 0.620 0.000 0.060 0.000 NA
#> SRR1168732     1  0.5322      0.783 0.608 0.000 0.072 0.000 NA
#> SRR1168733     2  0.3942      0.991 0.000 0.728 0.000 0.260 NA
#> SRR1168734     2  0.3715      0.991 0.000 0.736 0.000 0.260 NA
#> SRR1168735     2  0.3835      0.991 0.000 0.732 0.000 0.260 NA
#> SRR1168736     2  0.4090      0.983 0.000 0.716 0.000 0.268 NA
#> SRR1168737     2  0.3835      0.991 0.000 0.732 0.000 0.260 NA
#> SRR1168738     2  0.3715      0.991 0.000 0.736 0.000 0.260 NA
#> SRR1168739     2  0.3715      0.992 0.000 0.736 0.000 0.260 NA
#> SRR1168740     2  0.3741      0.989 0.000 0.732 0.000 0.264 NA
#> SRR1168741     2  0.4132      0.989 0.000 0.720 0.000 0.260 NA
#> SRR1168742     2  0.3835      0.992 0.000 0.732 0.000 0.260 NA
#> SRR1168743     2  0.3715      0.992 0.000 0.736 0.000 0.260 NA
#> SRR1168744     2  0.3861      0.989 0.000 0.728 0.000 0.264 NA
#> SRR1168745     2  0.4040      0.991 0.000 0.724 0.000 0.260 NA
#> SRR1168746     2  0.3835      0.991 0.000 0.732 0.000 0.260 NA
#> SRR1168747     4  0.0807      0.981 0.000 0.012 0.000 0.976 NA
#> SRR1168748     4  0.1469      0.962 0.000 0.036 0.000 0.948 NA
#> SRR1168749     4  0.0693      0.982 0.000 0.012 0.000 0.980 NA
#> SRR1168750     4  0.0290      0.979 0.000 0.000 0.000 0.992 NA
#> SRR1168751     4  0.0912      0.981 0.000 0.012 0.000 0.972 NA
#> SRR1168752     4  0.1211      0.974 0.000 0.016 0.000 0.960 NA
#> SRR1168753     4  0.1211      0.975 0.000 0.024 0.000 0.960 NA
#> SRR1168754     4  0.0579      0.980 0.000 0.008 0.000 0.984 NA
#> SRR1168755     4  0.0000      0.979 0.000 0.000 0.000 1.000 NA
#> SRR1168756     4  0.0798      0.981 0.000 0.016 0.000 0.976 NA
#> SRR1168757     4  0.0566      0.979 0.000 0.004 0.000 0.984 NA
#> SRR1168758     4  0.1211      0.975 0.000 0.024 0.000 0.960 NA
#> SRR1168759     4  0.0693      0.982 0.000 0.012 0.000 0.980 NA
#> SRR1168760     4  0.0566      0.980 0.000 0.004 0.000 0.984 NA
#> SRR1168761     3  0.5312      0.836 0.100 0.000 0.652 0.000 NA
#> SRR1168762     3  0.5423      0.832 0.112 0.000 0.644 0.000 NA
#> SRR1168763     3  0.5309      0.836 0.104 0.000 0.656 0.000 NA
#> SRR1168764     3  0.5508      0.828 0.120 0.000 0.636 0.000 NA
#> SRR1168765     3  0.5358      0.835 0.104 0.000 0.648 0.000 NA
#> SRR1168766     3  0.5354      0.835 0.108 0.000 0.652 0.000 NA
#> SRR1168767     3  0.5447      0.832 0.112 0.000 0.640 0.000 NA
#> SRR1168768     3  0.5211      0.838 0.100 0.000 0.668 0.000 NA
#> SRR1168769     1  0.1568      0.705 0.944 0.000 0.020 0.000 NA
#> SRR1168770     1  0.1281      0.712 0.956 0.000 0.012 0.000 NA
#> SRR1168771     1  0.1386      0.715 0.952 0.000 0.016 0.000 NA
#> SRR1168772     1  0.1740      0.702 0.932 0.000 0.012 0.000 NA
#> SRR1168773     1  0.2550      0.674 0.892 0.004 0.020 0.000 NA
#> SRR1168774     1  0.1117      0.717 0.964 0.000 0.016 0.000 NA
#> SRR1168775     1  0.1211      0.715 0.960 0.000 0.016 0.000 NA
#> SRR1168776     1  0.3236      0.616 0.828 0.000 0.020 0.000 NA
#> SRR1168777     1  0.3234      0.624 0.836 0.008 0.012 0.000 NA

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5 p6
#> SRR1168715     3  0.5815      0.744 0.056 0.000 0.580 0.280 0.000 NA
#> SRR1168716     3  0.5663      0.746 0.048 0.000 0.592 0.280 0.000 NA
#> SRR1168717     3  0.5617      0.746 0.048 0.000 0.596 0.280 0.000 NA
#> SRR1168718     3  0.6047      0.734 0.068 0.000 0.560 0.280 0.000 NA
#> SRR1168719     3  0.5892      0.740 0.068 0.000 0.572 0.284 0.000 NA
#> SRR1168720     3  0.6082      0.731 0.088 0.000 0.560 0.276 0.000 NA
#> SRR1168721     3  0.6235      0.723 0.068 0.000 0.540 0.280 0.000 NA
#> SRR1168722     1  0.0363      0.973 0.988 0.000 0.000 0.012 0.000 NA
#> SRR1168723     1  0.0405      0.979 0.988 0.000 0.000 0.008 0.000 NA
#> SRR1168724     1  0.0603      0.978 0.980 0.000 0.000 0.016 0.000 NA
#> SRR1168725     1  0.0363      0.978 0.988 0.000 0.000 0.012 0.000 NA
#> SRR1168726     1  0.0291      0.979 0.992 0.000 0.000 0.004 0.000 NA
#> SRR1168727     1  0.0692      0.972 0.976 0.000 0.000 0.020 0.000 NA
#> SRR1168728     1  0.0363      0.979 0.988 0.000 0.000 0.012 0.000 NA
#> SRR1168729     1  0.0935      0.974 0.964 0.000 0.000 0.032 0.000 NA
#> SRR1168730     1  0.0713      0.962 0.972 0.000 0.000 0.028 0.000 NA
#> SRR1168731     1  0.0777      0.965 0.972 0.000 0.000 0.024 0.000 NA
#> SRR1168732     1  0.0363      0.979 0.988 0.000 0.000 0.012 0.000 NA
#> SRR1168733     2  0.1434      0.971 0.000 0.940 0.000 0.000 0.012 NA
#> SRR1168734     2  0.0458      0.968 0.000 0.984 0.000 0.000 0.000 NA
#> SRR1168735     2  0.0806      0.970 0.000 0.972 0.000 0.000 0.008 NA
#> SRR1168736     2  0.1418      0.965 0.000 0.944 0.000 0.000 0.024 NA
#> SRR1168737     2  0.0858      0.970 0.000 0.968 0.000 0.000 0.004 NA
#> SRR1168738     2  0.1572      0.956 0.000 0.936 0.000 0.000 0.028 NA
#> SRR1168739     2  0.1092      0.968 0.000 0.960 0.000 0.000 0.020 NA
#> SRR1168740     2  0.0909      0.970 0.000 0.968 0.000 0.000 0.012 NA
#> SRR1168741     2  0.1398      0.962 0.000 0.940 0.000 0.000 0.008 NA
#> SRR1168742     2  0.1219      0.966 0.000 0.948 0.000 0.000 0.004 NA
#> SRR1168743     2  0.1092      0.970 0.000 0.960 0.000 0.000 0.020 NA
#> SRR1168744     2  0.1480      0.966 0.000 0.940 0.000 0.000 0.020 NA
#> SRR1168745     2  0.1584      0.963 0.000 0.928 0.000 0.000 0.008 NA
#> SRR1168746     2  0.0692      0.971 0.000 0.976 0.000 0.000 0.004 NA
#> SRR1168747     5  0.3344      0.962 0.000 0.152 0.000 0.000 0.804 NA
#> SRR1168748     5  0.3894      0.947 0.000 0.168 0.000 0.000 0.760 NA
#> SRR1168749     5  0.2988      0.966 0.000 0.152 0.000 0.000 0.824 NA
#> SRR1168750     5  0.3062      0.965 0.000 0.144 0.000 0.000 0.824 NA
#> SRR1168751     5  0.3307      0.963 0.000 0.148 0.000 0.000 0.808 NA
#> SRR1168752     5  0.3551      0.947 0.000 0.148 0.000 0.000 0.792 NA
#> SRR1168753     5  0.3432      0.963 0.000 0.148 0.000 0.000 0.800 NA
#> SRR1168754     5  0.2750      0.964 0.000 0.136 0.000 0.000 0.844 NA
#> SRR1168755     5  0.2613      0.966 0.000 0.140 0.000 0.000 0.848 NA
#> SRR1168756     5  0.3602      0.961 0.000 0.160 0.000 0.000 0.784 NA
#> SRR1168757     5  0.3276      0.962 0.000 0.132 0.000 0.000 0.816 NA
#> SRR1168758     5  0.3806      0.955 0.000 0.164 0.000 0.000 0.768 NA
#> SRR1168759     5  0.2790      0.964 0.000 0.132 0.000 0.000 0.844 NA
#> SRR1168760     5  0.2868      0.964 0.000 0.132 0.000 0.000 0.840 NA
#> SRR1168761     3  0.1268      0.739 0.000 0.000 0.952 0.036 0.004 NA
#> SRR1168762     3  0.1082      0.736 0.000 0.000 0.956 0.040 0.000 NA
#> SRR1168763     3  0.0603      0.750 0.000 0.000 0.980 0.016 0.000 NA
#> SRR1168764     3  0.1080      0.739 0.000 0.000 0.960 0.032 0.004 NA
#> SRR1168765     3  0.1296      0.742 0.000 0.000 0.948 0.044 0.004 NA
#> SRR1168766     3  0.0692      0.745 0.000 0.000 0.976 0.020 0.004 NA
#> SRR1168767     3  0.1080      0.736 0.000 0.000 0.960 0.032 0.004 NA
#> SRR1168768     3  0.0972      0.752 0.000 0.000 0.964 0.028 0.000 NA
#> SRR1168769     4  0.5558      0.918 0.316 0.000 0.160 0.524 0.000 NA
#> SRR1168770     4  0.5650      0.903 0.344 0.000 0.144 0.508 0.000 NA
#> SRR1168771     4  0.5471      0.907 0.336 0.000 0.140 0.524 0.000 NA
#> SRR1168772     4  0.5504      0.919 0.316 0.000 0.152 0.532 0.000 NA
#> SRR1168773     4  0.5552      0.897 0.252 0.000 0.196 0.552 0.000 NA
#> SRR1168774     4  0.5751      0.918 0.320 0.000 0.168 0.508 0.000 NA
#> SRR1168775     4  0.5490      0.902 0.344 0.000 0.140 0.516 0.000 NA
#> SRR1168776     4  0.5488      0.873 0.220 0.000 0.212 0.568 0.000 NA
#> SRR1168777     4  0.6476      0.825 0.216 0.000 0.200 0.524 0.000 NA

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

consensus_heatmap(res, k = 2)

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

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

collect_plots(res)

plot of chunk MAD-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2     1           1.000       1.000        0.50229 0.498   0.498
#> 3 3     1           1.000       1.000        0.30551 0.846   0.692
#> 4 4     1           1.000       1.000        0.07723 0.949   0.853
#> 5 5     1           1.000       1.000        0.04055 0.971   0.902
#> 6 6     1           0.982       0.999        0.00575 0.996   0.985

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette p1 p2
#> SRR1168715     1       0          1  1  0
#> SRR1168716     1       0          1  1  0
#> SRR1168717     1       0          1  1  0
#> SRR1168718     1       0          1  1  0
#> SRR1168719     1       0          1  1  0
#> SRR1168720     1       0          1  1  0
#> SRR1168721     1       0          1  1  0
#> SRR1168722     1       0          1  1  0
#> SRR1168723     1       0          1  1  0
#> SRR1168724     1       0          1  1  0
#> SRR1168725     1       0          1  1  0
#> SRR1168726     1       0          1  1  0
#> SRR1168727     1       0          1  1  0
#> SRR1168728     1       0          1  1  0
#> SRR1168729     1       0          1  1  0
#> SRR1168730     1       0          1  1  0
#> SRR1168731     1       0          1  1  0
#> SRR1168732     1       0          1  1  0
#> SRR1168733     2       0          1  0  1
#> SRR1168734     2       0          1  0  1
#> SRR1168735     2       0          1  0  1
#> SRR1168736     2       0          1  0  1
#> SRR1168737     2       0          1  0  1
#> SRR1168738     2       0          1  0  1
#> SRR1168739     2       0          1  0  1
#> SRR1168740     2       0          1  0  1
#> SRR1168741     2       0          1  0  1
#> SRR1168742     2       0          1  0  1
#> SRR1168743     2       0          1  0  1
#> SRR1168744     2       0          1  0  1
#> SRR1168745     2       0          1  0  1
#> SRR1168746     2       0          1  0  1
#> SRR1168747     2       0          1  0  1
#> SRR1168748     2       0          1  0  1
#> SRR1168749     2       0          1  0  1
#> SRR1168750     2       0          1  0  1
#> SRR1168751     2       0          1  0  1
#> SRR1168752     2       0          1  0  1
#> SRR1168753     2       0          1  0  1
#> SRR1168754     2       0          1  0  1
#> SRR1168755     2       0          1  0  1
#> SRR1168756     2       0          1  0  1
#> SRR1168757     2       0          1  0  1
#> SRR1168758     2       0          1  0  1
#> SRR1168759     2       0          1  0  1
#> SRR1168760     2       0          1  0  1
#> SRR1168761     1       0          1  1  0
#> SRR1168762     1       0          1  1  0
#> SRR1168763     1       0          1  1  0
#> SRR1168764     1       0          1  1  0
#> SRR1168765     1       0          1  1  0
#> SRR1168766     1       0          1  1  0
#> SRR1168767     1       0          1  1  0
#> SRR1168768     1       0          1  1  0
#> SRR1168769     1       0          1  1  0
#> SRR1168770     1       0          1  1  0
#> SRR1168771     1       0          1  1  0
#> SRR1168772     1       0          1  1  0
#> SRR1168773     1       0          1  1  0
#> SRR1168774     1       0          1  1  0
#> SRR1168775     1       0          1  1  0
#> SRR1168776     1       0          1  1  0
#> SRR1168777     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette p1 p2 p3
#> SRR1168715     3       0          1  0  0  1
#> SRR1168716     3       0          1  0  0  1
#> SRR1168717     3       0          1  0  0  1
#> SRR1168718     3       0          1  0  0  1
#> SRR1168719     3       0          1  0  0  1
#> SRR1168720     3       0          1  0  0  1
#> SRR1168721     3       0          1  0  0  1
#> SRR1168722     1       0          1  1  0  0
#> SRR1168723     1       0          1  1  0  0
#> SRR1168724     1       0          1  1  0  0
#> SRR1168725     1       0          1  1  0  0
#> SRR1168726     1       0          1  1  0  0
#> SRR1168727     1       0          1  1  0  0
#> SRR1168728     1       0          1  1  0  0
#> SRR1168729     1       0          1  1  0  0
#> SRR1168730     1       0          1  1  0  0
#> SRR1168731     1       0          1  1  0  0
#> SRR1168732     1       0          1  1  0  0
#> SRR1168733     2       0          1  0  1  0
#> SRR1168734     2       0          1  0  1  0
#> SRR1168735     2       0          1  0  1  0
#> SRR1168736     2       0          1  0  1  0
#> SRR1168737     2       0          1  0  1  0
#> SRR1168738     2       0          1  0  1  0
#> SRR1168739     2       0          1  0  1  0
#> SRR1168740     2       0          1  0  1  0
#> SRR1168741     2       0          1  0  1  0
#> SRR1168742     2       0          1  0  1  0
#> SRR1168743     2       0          1  0  1  0
#> SRR1168744     2       0          1  0  1  0
#> SRR1168745     2       0          1  0  1  0
#> SRR1168746     2       0          1  0  1  0
#> SRR1168747     2       0          1  0  1  0
#> SRR1168748     2       0          1  0  1  0
#> SRR1168749     2       0          1  0  1  0
#> SRR1168750     2       0          1  0  1  0
#> SRR1168751     2       0          1  0  1  0
#> SRR1168752     2       0          1  0  1  0
#> SRR1168753     2       0          1  0  1  0
#> SRR1168754     2       0          1  0  1  0
#> SRR1168755     2       0          1  0  1  0
#> SRR1168756     2       0          1  0  1  0
#> SRR1168757     2       0          1  0  1  0
#> SRR1168758     2       0          1  0  1  0
#> SRR1168759     2       0          1  0  1  0
#> SRR1168760     2       0          1  0  1  0
#> SRR1168761     3       0          1  0  0  1
#> SRR1168762     3       0          1  0  0  1
#> SRR1168763     3       0          1  0  0  1
#> SRR1168764     3       0          1  0  0  1
#> SRR1168765     3       0          1  0  0  1
#> SRR1168766     3       0          1  0  0  1
#> SRR1168767     3       0          1  0  0  1
#> SRR1168768     3       0          1  0  0  1
#> SRR1168769     1       0          1  1  0  0
#> SRR1168770     1       0          1  1  0  0
#> SRR1168771     1       0          1  1  0  0
#> SRR1168772     1       0          1  1  0  0
#> SRR1168773     1       0          1  1  0  0
#> SRR1168774     1       0          1  1  0  0
#> SRR1168775     1       0          1  1  0  0
#> SRR1168776     1       0          1  1  0  0
#> SRR1168777     1       0          1  1  0  0

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette p1 p2 p3 p4
#> SRR1168715     3       0          1  0  0  1  0
#> SRR1168716     3       0          1  0  0  1  0
#> SRR1168717     3       0          1  0  0  1  0
#> SRR1168718     3       0          1  0  0  1  0
#> SRR1168719     3       0          1  0  0  1  0
#> SRR1168720     3       0          1  0  0  1  0
#> SRR1168721     3       0          1  0  0  1  0
#> SRR1168722     1       0          1  1  0  0  0
#> SRR1168723     1       0          1  1  0  0  0
#> SRR1168724     1       0          1  1  0  0  0
#> SRR1168725     1       0          1  1  0  0  0
#> SRR1168726     1       0          1  1  0  0  0
#> SRR1168727     1       0          1  1  0  0  0
#> SRR1168728     1       0          1  1  0  0  0
#> SRR1168729     1       0          1  1  0  0  0
#> SRR1168730     1       0          1  1  0  0  0
#> SRR1168731     1       0          1  1  0  0  0
#> SRR1168732     1       0          1  1  0  0  0
#> SRR1168733     2       0          1  0  1  0  0
#> SRR1168734     2       0          1  0  1  0  0
#> SRR1168735     2       0          1  0  1  0  0
#> SRR1168736     2       0          1  0  1  0  0
#> SRR1168737     2       0          1  0  1  0  0
#> SRR1168738     2       0          1  0  1  0  0
#> SRR1168739     2       0          1  0  1  0  0
#> SRR1168740     2       0          1  0  1  0  0
#> SRR1168741     2       0          1  0  1  0  0
#> SRR1168742     2       0          1  0  1  0  0
#> SRR1168743     2       0          1  0  1  0  0
#> SRR1168744     2       0          1  0  1  0  0
#> SRR1168745     2       0          1  0  1  0  0
#> SRR1168746     2       0          1  0  1  0  0
#> SRR1168747     2       0          1  0  1  0  0
#> SRR1168748     2       0          1  0  1  0  0
#> SRR1168749     2       0          1  0  1  0  0
#> SRR1168750     2       0          1  0  1  0  0
#> SRR1168751     2       0          1  0  1  0  0
#> SRR1168752     2       0          1  0  1  0  0
#> SRR1168753     2       0          1  0  1  0  0
#> SRR1168754     2       0          1  0  1  0  0
#> SRR1168755     2       0          1  0  1  0  0
#> SRR1168756     2       0          1  0  1  0  0
#> SRR1168757     2       0          1  0  1  0  0
#> SRR1168758     2       0          1  0  1  0  0
#> SRR1168759     2       0          1  0  1  0  0
#> SRR1168760     2       0          1  0  1  0  0
#> SRR1168761     3       0          1  0  0  1  0
#> SRR1168762     3       0          1  0  0  1  0
#> SRR1168763     3       0          1  0  0  1  0
#> SRR1168764     3       0          1  0  0  1  0
#> SRR1168765     3       0          1  0  0  1  0
#> SRR1168766     3       0          1  0  0  1  0
#> SRR1168767     3       0          1  0  0  1  0
#> SRR1168768     3       0          1  0  0  1  0
#> SRR1168769     4       0          1  0  0  0  1
#> SRR1168770     4       0          1  0  0  0  1
#> SRR1168771     4       0          1  0  0  0  1
#> SRR1168772     4       0          1  0  0  0  1
#> SRR1168773     4       0          1  0  0  0  1
#> SRR1168774     4       0          1  0  0  0  1
#> SRR1168775     4       0          1  0  0  0  1
#> SRR1168776     4       0          1  0  0  0  1
#> SRR1168777     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
#> SRR1168715     5       0          1  0  0  0  0  1
#> SRR1168716     5       0          1  0  0  0  0  1
#> SRR1168717     5       0          1  0  0  0  0  1
#> SRR1168718     5       0          1  0  0  0  0  1
#> SRR1168719     5       0          1  0  0  0  0  1
#> SRR1168720     5       0          1  0  0  0  0  1
#> SRR1168721     5       0          1  0  0  0  0  1
#> SRR1168722     1       0          1  1  0  0  0  0
#> SRR1168723     1       0          1  1  0  0  0  0
#> SRR1168724     1       0          1  1  0  0  0  0
#> SRR1168725     1       0          1  1  0  0  0  0
#> SRR1168726     1       0          1  1  0  0  0  0
#> SRR1168727     1       0          1  1  0  0  0  0
#> SRR1168728     1       0          1  1  0  0  0  0
#> SRR1168729     1       0          1  1  0  0  0  0
#> SRR1168730     1       0          1  1  0  0  0  0
#> SRR1168731     1       0          1  1  0  0  0  0
#> SRR1168732     1       0          1  1  0  0  0  0
#> SRR1168733     2       0          1  0  1  0  0  0
#> SRR1168734     2       0          1  0  1  0  0  0
#> SRR1168735     2       0          1  0  1  0  0  0
#> SRR1168736     2       0          1  0  1  0  0  0
#> SRR1168737     2       0          1  0  1  0  0  0
#> SRR1168738     2       0          1  0  1  0  0  0
#> SRR1168739     2       0          1  0  1  0  0  0
#> SRR1168740     2       0          1  0  1  0  0  0
#> SRR1168741     2       0          1  0  1  0  0  0
#> SRR1168742     2       0          1  0  1  0  0  0
#> SRR1168743     2       0          1  0  1  0  0  0
#> SRR1168744     2       0          1  0  1  0  0  0
#> SRR1168745     2       0          1  0  1  0  0  0
#> SRR1168746     2       0          1  0  1  0  0  0
#> SRR1168747     2       0          1  0  1  0  0  0
#> SRR1168748     2       0          1  0  1  0  0  0
#> SRR1168749     2       0          1  0  1  0  0  0
#> SRR1168750     2       0          1  0  1  0  0  0
#> SRR1168751     2       0          1  0  1  0  0  0
#> SRR1168752     2       0          1  0  1  0  0  0
#> SRR1168753     2       0          1  0  1  0  0  0
#> SRR1168754     2       0          1  0  1  0  0  0
#> SRR1168755     2       0          1  0  1  0  0  0
#> SRR1168756     2       0          1  0  1  0  0  0
#> SRR1168757     2       0          1  0  1  0  0  0
#> SRR1168758     2       0          1  0  1  0  0  0
#> SRR1168759     2       0          1  0  1  0  0  0
#> SRR1168760     2       0          1  0  1  0  0  0
#> SRR1168761     3       0          1  0  0  1  0  0
#> SRR1168762     3       0          1  0  0  1  0  0
#> SRR1168763     3       0          1  0  0  1  0  0
#> SRR1168764     3       0          1  0  0  1  0  0
#> SRR1168765     3       0          1  0  0  1  0  0
#> SRR1168766     3       0          1  0  0  1  0  0
#> SRR1168767     3       0          1  0  0  1  0  0
#> SRR1168768     3       0          1  0  0  1  0  0
#> SRR1168769     4       0          1  0  0  0  1  0
#> SRR1168770     4       0          1  0  0  0  1  0
#> SRR1168771     4       0          1  0  0  0  1  0
#> SRR1168772     4       0          1  0  0  0  1  0
#> SRR1168773     4       0          1  0  0  0  1  0
#> SRR1168774     4       0          1  0  0  0  1  0
#> SRR1168775     4       0          1  0  0  0  1  0
#> SRR1168776     4       0          1  0  0  0  1  0
#> SRR1168777     4       0          1  0  0  0  1  0

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette p1    p2 p3    p4 p5    p6
#> SRR1168715     6  0.0000      0.999  0 0.000  0 0.000  0 1.000
#> SRR1168716     6  0.0000      0.999  0 0.000  0 0.000  0 1.000
#> SRR1168717     6  0.0000      0.999  0 0.000  0 0.000  0 1.000
#> SRR1168718     6  0.0000      0.999  0 0.000  0 0.000  0 1.000
#> SRR1168719     6  0.0000      0.999  0 0.000  0 0.000  0 1.000
#> SRR1168720     6  0.0000      0.999  0 0.000  0 0.000  0 1.000
#> SRR1168721     6  0.0146      0.996  0 0.004  0 0.000  0 0.996
#> SRR1168722     1  0.0000      1.000  1 0.000  0 0.000  0 0.000
#> SRR1168723     1  0.0000      1.000  1 0.000  0 0.000  0 0.000
#> SRR1168724     1  0.0000      1.000  1 0.000  0 0.000  0 0.000
#> SRR1168725     1  0.0000      1.000  1 0.000  0 0.000  0 0.000
#> SRR1168726     1  0.0000      1.000  1 0.000  0 0.000  0 0.000
#> SRR1168727     1  0.0000      1.000  1 0.000  0 0.000  0 0.000
#> SRR1168728     1  0.0000      1.000  1 0.000  0 0.000  0 0.000
#> SRR1168729     1  0.0000      1.000  1 0.000  0 0.000  0 0.000
#> SRR1168730     1  0.0000      1.000  1 0.000  0 0.000  0 0.000
#> SRR1168731     1  0.0000      1.000  1 0.000  0 0.000  0 0.000
#> SRR1168732     1  0.0000      1.000  1 0.000  0 0.000  0 0.000
#> SRR1168733     5  0.0000      1.000  0 0.000  0 0.000  1 0.000
#> SRR1168734     5  0.0000      1.000  0 0.000  0 0.000  1 0.000
#> SRR1168735     5  0.0000      1.000  0 0.000  0 0.000  1 0.000
#> SRR1168736     5  0.0000      1.000  0 0.000  0 0.000  1 0.000
#> SRR1168737     5  0.0000      1.000  0 0.000  0 0.000  1 0.000
#> SRR1168738     5  0.0000      1.000  0 0.000  0 0.000  1 0.000
#> SRR1168739     5  0.0000      1.000  0 0.000  0 0.000  1 0.000
#> SRR1168740     5  0.0000      1.000  0 0.000  0 0.000  1 0.000
#> SRR1168741     5  0.0000      1.000  0 0.000  0 0.000  1 0.000
#> SRR1168742     5  0.0000      1.000  0 0.000  0 0.000  1 0.000
#> SRR1168743     5  0.0000      1.000  0 0.000  0 0.000  1 0.000
#> SRR1168744     5  0.0000      1.000  0 0.000  0 0.000  1 0.000
#> SRR1168745     5  0.0000      1.000  0 0.000  0 0.000  1 0.000
#> SRR1168746     5  0.0000      1.000  0 0.000  0 0.000  1 0.000
#> SRR1168747     5  0.0000      1.000  0 0.000  0 0.000  1 0.000
#> SRR1168748     5  0.0000      1.000  0 0.000  0 0.000  1 0.000
#> SRR1168749     5  0.0000      1.000  0 0.000  0 0.000  1 0.000
#> SRR1168750     5  0.0000      1.000  0 0.000  0 0.000  1 0.000
#> SRR1168751     5  0.0000      1.000  0 0.000  0 0.000  1 0.000
#> SRR1168752     5  0.0000      1.000  0 0.000  0 0.000  1 0.000
#> SRR1168753     5  0.0000      1.000  0 0.000  0 0.000  1 0.000
#> SRR1168754     5  0.0000      1.000  0 0.000  0 0.000  1 0.000
#> SRR1168755     5  0.0000      1.000  0 0.000  0 0.000  1 0.000
#> SRR1168756     5  0.0000      1.000  0 0.000  0 0.000  1 0.000
#> SRR1168757     5  0.0000      1.000  0 0.000  0 0.000  1 0.000
#> SRR1168758     5  0.0000      1.000  0 0.000  0 0.000  1 0.000
#> SRR1168759     5  0.0000      1.000  0 0.000  0 0.000  1 0.000
#> SRR1168760     5  0.0000      1.000  0 0.000  0 0.000  1 0.000
#> SRR1168761     3  0.0000      1.000  0 0.000  1 0.000  0 0.000
#> SRR1168762     3  0.0000      1.000  0 0.000  1 0.000  0 0.000
#> SRR1168763     3  0.0000      1.000  0 0.000  1 0.000  0 0.000
#> SRR1168764     3  0.0000      1.000  0 0.000  1 0.000  0 0.000
#> SRR1168765     3  0.0000      1.000  0 0.000  1 0.000  0 0.000
#> SRR1168766     3  0.0000      1.000  0 0.000  1 0.000  0 0.000
#> SRR1168767     3  0.0000      1.000  0 0.000  1 0.000  0 0.000
#> SRR1168768     3  0.0000      1.000  0 0.000  1 0.000  0 0.000
#> SRR1168769     4  0.0000      0.990  0 0.000  0 1.000  0 0.000
#> SRR1168770     4  0.0000      0.990  0 0.000  0 1.000  0 0.000
#> SRR1168771     4  0.0000      0.990  0 0.000  0 1.000  0 0.000
#> SRR1168772     4  0.0000      0.990  0 0.000  0 1.000  0 0.000
#> SRR1168773     4  0.0000      0.990  0 0.000  0 1.000  0 0.000
#> SRR1168774     4  0.0632      0.982  0 0.024  0 0.976  0 0.000
#> SRR1168775     4  0.0632      0.982  0 0.024  0 0.976  0 0.000
#> SRR1168776     4  0.0632      0.982  0 0.024  0 0.976  0 0.000
#> SRR1168777     2  0.0146      0.000  0 0.996  0 0.004  0 0.000

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

consensus_heatmap(res, k = 2)

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

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

collect_plots(res)

plot of chunk MAD-kmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.5023 0.498   0.498
#> 3 3 0.667           0.850       0.779         0.2651 0.846   0.692
#> 4 4 0.667           0.837       0.742         0.1165 0.900   0.709
#> 5 5 0.701           0.818       0.764         0.0720 1.000   1.000
#> 6 6 0.654           0.547       0.649         0.0411 0.982   0.925

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
#> SRR1168715     1       0          1  1  0
#> SRR1168716     1       0          1  1  0
#> SRR1168717     1       0          1  1  0
#> SRR1168718     1       0          1  1  0
#> SRR1168719     1       0          1  1  0
#> SRR1168720     1       0          1  1  0
#> SRR1168721     1       0          1  1  0
#> SRR1168722     1       0          1  1  0
#> SRR1168723     1       0          1  1  0
#> SRR1168724     1       0          1  1  0
#> SRR1168725     1       0          1  1  0
#> SRR1168726     1       0          1  1  0
#> SRR1168727     1       0          1  1  0
#> SRR1168728     1       0          1  1  0
#> SRR1168729     1       0          1  1  0
#> SRR1168730     1       0          1  1  0
#> SRR1168731     1       0          1  1  0
#> SRR1168732     1       0          1  1  0
#> SRR1168733     2       0          1  0  1
#> SRR1168734     2       0          1  0  1
#> SRR1168735     2       0          1  0  1
#> SRR1168736     2       0          1  0  1
#> SRR1168737     2       0          1  0  1
#> SRR1168738     2       0          1  0  1
#> SRR1168739     2       0          1  0  1
#> SRR1168740     2       0          1  0  1
#> SRR1168741     2       0          1  0  1
#> SRR1168742     2       0          1  0  1
#> SRR1168743     2       0          1  0  1
#> SRR1168744     2       0          1  0  1
#> SRR1168745     2       0          1  0  1
#> SRR1168746     2       0          1  0  1
#> SRR1168747     2       0          1  0  1
#> SRR1168748     2       0          1  0  1
#> SRR1168749     2       0          1  0  1
#> SRR1168750     2       0          1  0  1
#> SRR1168751     2       0          1  0  1
#> SRR1168752     2       0          1  0  1
#> SRR1168753     2       0          1  0  1
#> SRR1168754     2       0          1  0  1
#> SRR1168755     2       0          1  0  1
#> SRR1168756     2       0          1  0  1
#> SRR1168757     2       0          1  0  1
#> SRR1168758     2       0          1  0  1
#> SRR1168759     2       0          1  0  1
#> SRR1168760     2       0          1  0  1
#> SRR1168761     1       0          1  1  0
#> SRR1168762     1       0          1  1  0
#> SRR1168763     1       0          1  1  0
#> SRR1168764     1       0          1  1  0
#> SRR1168765     1       0          1  1  0
#> SRR1168766     1       0          1  1  0
#> SRR1168767     1       0          1  1  0
#> SRR1168768     1       0          1  1  0
#> SRR1168769     1       0          1  1  0
#> SRR1168770     1       0          1  1  0
#> SRR1168771     1       0          1  1  0
#> SRR1168772     1       0          1  1  0
#> SRR1168773     1       0          1  1  0
#> SRR1168774     1       0          1  1  0
#> SRR1168775     1       0          1  1  0
#> SRR1168776     1       0          1  1  0
#> SRR1168777     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1168715     3   0.601      0.861 0.372 0.000 0.628
#> SRR1168716     3   0.601      0.861 0.372 0.000 0.628
#> SRR1168717     3   0.601      0.861 0.372 0.000 0.628
#> SRR1168718     3   0.601      0.861 0.372 0.000 0.628
#> SRR1168719     3   0.601      0.861 0.372 0.000 0.628
#> SRR1168720     3   0.601      0.861 0.372 0.000 0.628
#> SRR1168721     3   0.601      0.861 0.372 0.000 0.628
#> SRR1168722     1   0.375      0.872 0.856 0.000 0.144
#> SRR1168723     1   0.375      0.872 0.856 0.000 0.144
#> SRR1168724     1   0.375      0.872 0.856 0.000 0.144
#> SRR1168725     1   0.375      0.872 0.856 0.000 0.144
#> SRR1168726     1   0.375      0.872 0.856 0.000 0.144
#> SRR1168727     1   0.375      0.872 0.856 0.000 0.144
#> SRR1168728     1   0.375      0.872 0.856 0.000 0.144
#> SRR1168729     1   0.375      0.872 0.856 0.000 0.144
#> SRR1168730     1   0.375      0.872 0.856 0.000 0.144
#> SRR1168731     1   0.375      0.872 0.856 0.000 0.144
#> SRR1168732     1   0.375      0.872 0.856 0.000 0.144
#> SRR1168733     2   0.601      0.832 0.000 0.628 0.372
#> SRR1168734     2   0.601      0.832 0.000 0.628 0.372
#> SRR1168735     2   0.601      0.832 0.000 0.628 0.372
#> SRR1168736     2   0.601      0.832 0.000 0.628 0.372
#> SRR1168737     2   0.601      0.832 0.000 0.628 0.372
#> SRR1168738     2   0.601      0.832 0.000 0.628 0.372
#> SRR1168739     2   0.601      0.832 0.000 0.628 0.372
#> SRR1168740     2   0.601      0.832 0.000 0.628 0.372
#> SRR1168741     2   0.601      0.832 0.000 0.628 0.372
#> SRR1168742     2   0.601      0.832 0.000 0.628 0.372
#> SRR1168743     2   0.601      0.832 0.000 0.628 0.372
#> SRR1168744     2   0.601      0.832 0.000 0.628 0.372
#> SRR1168745     2   0.601      0.832 0.000 0.628 0.372
#> SRR1168746     2   0.601      0.832 0.000 0.628 0.372
#> SRR1168747     2   0.000      0.832 0.000 1.000 0.000
#> SRR1168748     2   0.000      0.832 0.000 1.000 0.000
#> SRR1168749     2   0.000      0.832 0.000 1.000 0.000
#> SRR1168750     2   0.000      0.832 0.000 1.000 0.000
#> SRR1168751     2   0.000      0.832 0.000 1.000 0.000
#> SRR1168752     2   0.000      0.832 0.000 1.000 0.000
#> SRR1168753     2   0.000      0.832 0.000 1.000 0.000
#> SRR1168754     2   0.000      0.832 0.000 1.000 0.000
#> SRR1168755     2   0.000      0.832 0.000 1.000 0.000
#> SRR1168756     2   0.000      0.832 0.000 1.000 0.000
#> SRR1168757     2   0.000      0.832 0.000 1.000 0.000
#> SRR1168758     2   0.000      0.832 0.000 1.000 0.000
#> SRR1168759     2   0.000      0.832 0.000 1.000 0.000
#> SRR1168760     2   0.000      0.832 0.000 1.000 0.000
#> SRR1168761     3   0.631      0.880 0.492 0.000 0.508
#> SRR1168762     3   0.631      0.880 0.492 0.000 0.508
#> SRR1168763     3   0.631      0.880 0.492 0.000 0.508
#> SRR1168764     3   0.631      0.880 0.492 0.000 0.508
#> SRR1168765     3   0.631      0.880 0.492 0.000 0.508
#> SRR1168766     3   0.631      0.880 0.492 0.000 0.508
#> SRR1168767     3   0.631      0.880 0.492 0.000 0.508
#> SRR1168768     3   0.631      0.880 0.492 0.000 0.508
#> SRR1168769     1   0.000      0.843 1.000 0.000 0.000
#> SRR1168770     1   0.000      0.843 1.000 0.000 0.000
#> SRR1168771     1   0.000      0.843 1.000 0.000 0.000
#> SRR1168772     1   0.000      0.843 1.000 0.000 0.000
#> SRR1168773     1   0.000      0.843 1.000 0.000 0.000
#> SRR1168774     1   0.000      0.843 1.000 0.000 0.000
#> SRR1168775     1   0.000      0.843 1.000 0.000 0.000
#> SRR1168776     1   0.000      0.843 1.000 0.000 0.000
#> SRR1168777     1   0.000      0.843 1.000 0.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
#> SRR1168715     3  0.7395      0.744 0.344 0.176 0.480 0.000
#> SRR1168716     3  0.7395      0.744 0.344 0.176 0.480 0.000
#> SRR1168717     3  0.7395      0.744 0.344 0.176 0.480 0.000
#> SRR1168718     3  0.7395      0.744 0.344 0.176 0.480 0.000
#> SRR1168719     3  0.7395      0.744 0.344 0.176 0.480 0.000
#> SRR1168720     3  0.7395      0.744 0.344 0.176 0.480 0.000
#> SRR1168721     3  0.7395      0.744 0.344 0.176 0.480 0.000
#> SRR1168722     1  0.0000      0.735 1.000 0.000 0.000 0.000
#> SRR1168723     1  0.0000      0.735 1.000 0.000 0.000 0.000
#> SRR1168724     1  0.0000      0.735 1.000 0.000 0.000 0.000
#> SRR1168725     1  0.0000      0.735 1.000 0.000 0.000 0.000
#> SRR1168726     1  0.0000      0.735 1.000 0.000 0.000 0.000
#> SRR1168727     1  0.0000      0.735 1.000 0.000 0.000 0.000
#> SRR1168728     1  0.0000      0.735 1.000 0.000 0.000 0.000
#> SRR1168729     1  0.0000      0.735 1.000 0.000 0.000 0.000
#> SRR1168730     1  0.0000      0.735 1.000 0.000 0.000 0.000
#> SRR1168731     1  0.0000      0.735 1.000 0.000 0.000 0.000
#> SRR1168732     1  0.0000      0.735 1.000 0.000 0.000 0.000
#> SRR1168733     2  0.5708      0.968 0.000 0.556 0.028 0.416
#> SRR1168734     2  0.5950      0.964 0.000 0.544 0.040 0.416
#> SRR1168735     2  0.5950      0.964 0.000 0.544 0.040 0.416
#> SRR1168736     2  0.6229      0.958 0.000 0.528 0.056 0.416
#> SRR1168737     2  0.5873      0.967 0.000 0.548 0.036 0.416
#> SRR1168738     2  0.5792      0.968 0.000 0.552 0.032 0.416
#> SRR1168739     2  0.5708      0.969 0.000 0.556 0.028 0.416
#> SRR1168740     2  0.6229      0.958 0.000 0.528 0.056 0.416
#> SRR1168741     2  0.5708      0.964 0.000 0.556 0.028 0.416
#> SRR1168742     2  0.5792      0.967 0.000 0.552 0.032 0.416
#> SRR1168743     2  0.5873      0.968 0.000 0.548 0.036 0.416
#> SRR1168744     2  0.5950      0.968 0.000 0.544 0.040 0.416
#> SRR1168745     2  0.5427      0.966 0.000 0.568 0.016 0.416
#> SRR1168746     2  0.5427      0.967 0.000 0.568 0.016 0.416
#> SRR1168747     4  0.0817      0.978 0.000 0.000 0.024 0.976
#> SRR1168748     4  0.0592      0.979 0.000 0.000 0.016 0.984
#> SRR1168749     4  0.0469      0.979 0.000 0.000 0.012 0.988
#> SRR1168750     4  0.0336      0.979 0.000 0.000 0.008 0.992
#> SRR1168751     4  0.0817      0.977 0.000 0.000 0.024 0.976
#> SRR1168752     4  0.1302      0.962 0.000 0.000 0.044 0.956
#> SRR1168753     4  0.1022      0.975 0.000 0.000 0.032 0.968
#> SRR1168754     4  0.0469      0.978 0.000 0.000 0.012 0.988
#> SRR1168755     4  0.0817      0.978 0.000 0.000 0.024 0.976
#> SRR1168756     4  0.0592      0.977 0.000 0.000 0.016 0.984
#> SRR1168757     4  0.0817      0.977 0.000 0.000 0.024 0.976
#> SRR1168758     4  0.0817      0.974 0.000 0.000 0.024 0.976
#> SRR1168759     4  0.0817      0.977 0.000 0.000 0.024 0.976
#> SRR1168760     4  0.0921      0.974 0.000 0.000 0.028 0.972
#> SRR1168761     3  0.3356      0.784 0.176 0.000 0.824 0.000
#> SRR1168762     3  0.3356      0.784 0.176 0.000 0.824 0.000
#> SRR1168763     3  0.3356      0.784 0.176 0.000 0.824 0.000
#> SRR1168764     3  0.3356      0.784 0.176 0.000 0.824 0.000
#> SRR1168765     3  0.3356      0.784 0.176 0.000 0.824 0.000
#> SRR1168766     3  0.3356      0.784 0.176 0.000 0.824 0.000
#> SRR1168767     3  0.3356      0.784 0.176 0.000 0.824 0.000
#> SRR1168768     3  0.3356      0.784 0.176 0.000 0.824 0.000
#> SRR1168769     1  0.6976      0.662 0.580 0.240 0.180 0.000
#> SRR1168770     1  0.6976      0.662 0.580 0.240 0.180 0.000
#> SRR1168771     1  0.6976      0.662 0.580 0.240 0.180 0.000
#> SRR1168772     1  0.6976      0.662 0.580 0.240 0.180 0.000
#> SRR1168773     1  0.6976      0.662 0.580 0.240 0.180 0.000
#> SRR1168774     1  0.6976      0.662 0.580 0.240 0.180 0.000
#> SRR1168775     1  0.6976      0.662 0.580 0.240 0.180 0.000
#> SRR1168776     1  0.6976      0.662 0.580 0.240 0.180 0.000
#> SRR1168777     1  0.6976      0.662 0.580 0.240 0.180 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4    p5
#> SRR1168715     3  0.6361      0.748 0.156 0.000 0.504 0.004 0.336
#> SRR1168716     3  0.6226      0.748 0.156 0.000 0.504 0.000 0.340
#> SRR1168717     3  0.6226      0.748 0.156 0.000 0.504 0.000 0.340
#> SRR1168718     3  0.6226      0.748 0.156 0.000 0.504 0.000 0.340
#> SRR1168719     3  0.6361      0.748 0.156 0.000 0.504 0.004 0.336
#> SRR1168720     3  0.6226      0.748 0.156 0.000 0.504 0.000 0.340
#> SRR1168721     3  0.6698      0.746 0.156 0.000 0.504 0.020 0.320
#> SRR1168722     1  0.0693      0.725 0.980 0.000 0.008 0.000 0.012
#> SRR1168723     1  0.0579      0.725 0.984 0.000 0.008 0.008 0.000
#> SRR1168724     1  0.1369      0.723 0.956 0.000 0.008 0.008 0.028
#> SRR1168725     1  0.0451      0.725 0.988 0.000 0.008 0.000 0.004
#> SRR1168726     1  0.0740      0.725 0.980 0.000 0.008 0.008 0.004
#> SRR1168727     1  0.0290      0.725 0.992 0.000 0.008 0.000 0.000
#> SRR1168728     1  0.0992      0.724 0.968 0.000 0.008 0.000 0.024
#> SRR1168729     1  0.0867      0.725 0.976 0.000 0.008 0.008 0.008
#> SRR1168730     1  0.0579      0.725 0.984 0.000 0.008 0.000 0.008
#> SRR1168731     1  0.0451      0.725 0.988 0.000 0.008 0.004 0.000
#> SRR1168732     1  0.1243      0.723 0.960 0.000 0.008 0.004 0.028
#> SRR1168733     2  0.1410      0.948 0.000 0.940 0.000 0.000 0.060
#> SRR1168734     2  0.1877      0.948 0.000 0.924 0.012 0.000 0.064
#> SRR1168735     2  0.1830      0.947 0.000 0.924 0.008 0.000 0.068
#> SRR1168736     2  0.2351      0.945 0.000 0.896 0.016 0.000 0.088
#> SRR1168737     2  0.2136      0.942 0.000 0.904 0.008 0.000 0.088
#> SRR1168738     2  0.1430      0.951 0.000 0.944 0.004 0.000 0.052
#> SRR1168739     2  0.1270      0.952 0.000 0.948 0.000 0.000 0.052
#> SRR1168740     2  0.2331      0.942 0.000 0.900 0.020 0.000 0.080
#> SRR1168741     2  0.1502      0.944 0.000 0.940 0.004 0.000 0.056
#> SRR1168742     2  0.1282      0.950 0.000 0.952 0.004 0.000 0.044
#> SRR1168743     2  0.1894      0.949 0.000 0.920 0.008 0.000 0.072
#> SRR1168744     2  0.1626      0.950 0.000 0.940 0.016 0.000 0.044
#> SRR1168745     2  0.1544      0.944 0.000 0.932 0.000 0.000 0.068
#> SRR1168746     2  0.1121      0.952 0.000 0.956 0.000 0.000 0.044
#> SRR1168747     4  0.4536      0.938 0.000 0.240 0.000 0.712 0.048
#> SRR1168748     4  0.4777      0.941 0.000 0.240 0.012 0.708 0.040
#> SRR1168749     4  0.4602      0.939 0.000 0.240 0.000 0.708 0.052
#> SRR1168750     4  0.4398      0.940 0.000 0.240 0.000 0.720 0.040
#> SRR1168751     4  0.4536      0.936 0.000 0.240 0.000 0.712 0.048
#> SRR1168752     4  0.6572      0.873 0.000 0.240 0.024 0.564 0.172
#> SRR1168753     4  0.5506      0.929 0.000 0.240 0.004 0.648 0.108
#> SRR1168754     4  0.5057      0.938 0.000 0.240 0.004 0.684 0.072
#> SRR1168755     4  0.5354      0.930 0.000 0.240 0.000 0.652 0.108
#> SRR1168756     4  0.4820      0.939 0.000 0.240 0.004 0.700 0.056
#> SRR1168757     4  0.4552      0.939 0.000 0.240 0.004 0.716 0.040
#> SRR1168758     4  0.5057      0.936 0.000 0.240 0.004 0.684 0.072
#> SRR1168759     4  0.5218      0.935 0.000 0.240 0.004 0.672 0.084
#> SRR1168760     4  0.5593      0.927 0.000 0.240 0.004 0.640 0.116
#> SRR1168761     3  0.1704      0.780 0.068 0.000 0.928 0.004 0.000
#> SRR1168762     3  0.1544      0.780 0.068 0.000 0.932 0.000 0.000
#> SRR1168763     3  0.1544      0.780 0.068 0.000 0.932 0.000 0.000
#> SRR1168764     3  0.1830      0.780 0.068 0.000 0.924 0.008 0.000
#> SRR1168765     3  0.1544      0.780 0.068 0.000 0.932 0.000 0.000
#> SRR1168766     3  0.1544      0.780 0.068 0.000 0.932 0.000 0.000
#> SRR1168767     3  0.1704      0.780 0.068 0.000 0.928 0.004 0.000
#> SRR1168768     3  0.1830      0.780 0.068 0.000 0.924 0.008 0.000
#> SRR1168769     1  0.7810      0.643 0.484 0.000 0.156 0.196 0.164
#> SRR1168770     1  0.7805      0.643 0.484 0.000 0.156 0.200 0.160
#> SRR1168771     1  0.7814      0.642 0.484 0.000 0.156 0.192 0.168
#> SRR1168772     1  0.7817      0.642 0.484 0.000 0.156 0.188 0.172
#> SRR1168773     1  0.7805      0.643 0.484 0.000 0.156 0.200 0.160
#> SRR1168774     1  0.7814      0.643 0.484 0.000 0.156 0.192 0.168
#> SRR1168775     1  0.7810      0.643 0.484 0.000 0.156 0.196 0.164
#> SRR1168776     1  0.7814      0.643 0.484 0.000 0.156 0.192 0.168
#> SRR1168777     1  0.7774      0.634 0.484 0.000 0.156 0.144 0.216

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5 p6
#> SRR1168715     3  0.1219      0.738 0.000 0.000 0.948 0.048 0.000 NA
#> SRR1168716     3  0.1075      0.738 0.000 0.000 0.952 0.048 0.000 NA
#> SRR1168717     3  0.1075      0.738 0.000 0.000 0.952 0.048 0.000 NA
#> SRR1168718     3  0.1075      0.738 0.000 0.000 0.952 0.048 0.000 NA
#> SRR1168719     3  0.1219      0.738 0.000 0.000 0.948 0.048 0.000 NA
#> SRR1168720     3  0.1075      0.738 0.000 0.000 0.952 0.048 0.000 NA
#> SRR1168721     3  0.2394      0.732 0.000 0.032 0.900 0.048 0.000 NA
#> SRR1168722     1  0.6955      0.991 0.352 0.000 0.060 0.348 0.000 NA
#> SRR1168723     4  0.6971     -0.985 0.344 0.000 0.060 0.348 0.000 NA
#> SRR1168724     4  0.7672     -0.829 0.292 0.040 0.060 0.348 0.000 NA
#> SRR1168725     1  0.6963      0.991 0.348 0.000 0.060 0.348 0.000 NA
#> SRR1168726     4  0.6990     -0.975 0.332 0.000 0.060 0.348 0.000 NA
#> SRR1168727     4  0.6971     -0.985 0.344 0.000 0.060 0.348 0.000 NA
#> SRR1168728     4  0.7255     -0.940 0.336 0.012 0.060 0.348 0.000 NA
#> SRR1168729     4  0.7268     -0.936 0.328 0.012 0.060 0.348 0.000 NA
#> SRR1168730     4  0.6984     -0.978 0.336 0.000 0.060 0.348 0.000 NA
#> SRR1168731     4  0.6971     -0.990 0.344 0.000 0.060 0.348 0.000 NA
#> SRR1168732     4  0.7397     -0.907 0.324 0.020 0.060 0.348 0.000 NA
#> SRR1168733     2  0.4709      0.918 0.016 0.724 0.004 0.000 0.152 NA
#> SRR1168734     2  0.4412      0.909 0.072 0.752 0.004 0.000 0.152 NA
#> SRR1168735     2  0.4653      0.909 0.068 0.740 0.004 0.000 0.152 NA
#> SRR1168736     2  0.5122      0.901 0.056 0.712 0.008 0.000 0.152 NA
#> SRR1168737     2  0.5663      0.900 0.016 0.628 0.012 0.000 0.152 NA
#> SRR1168738     2  0.4396      0.917 0.012 0.760 0.020 0.000 0.152 NA
#> SRR1168739     2  0.3779      0.919 0.000 0.784 0.008 0.000 0.152 NA
#> SRR1168740     2  0.5277      0.899 0.080 0.696 0.004 0.000 0.152 NA
#> SRR1168741     2  0.5124      0.906 0.008 0.676 0.008 0.000 0.152 NA
#> SRR1168742     2  0.4996      0.914 0.020 0.700 0.004 0.000 0.152 NA
#> SRR1168743     2  0.5147      0.910 0.040 0.700 0.004 0.000 0.152 NA
#> SRR1168744     2  0.4335      0.919 0.032 0.756 0.000 0.000 0.152 NA
#> SRR1168745     2  0.4983      0.909 0.008 0.708 0.020 0.000 0.152 NA
#> SRR1168746     2  0.4450      0.919 0.008 0.748 0.012 0.000 0.152 NA
#> SRR1168747     5  0.1296      0.926 0.004 0.000 0.004 0.000 0.948 NA
#> SRR1168748     5  0.1745      0.930 0.012 0.000 0.000 0.000 0.920 NA
#> SRR1168749     5  0.1116      0.927 0.008 0.000 0.004 0.000 0.960 NA
#> SRR1168750     5  0.1707      0.928 0.012 0.000 0.004 0.000 0.928 NA
#> SRR1168751     5  0.1116      0.924 0.008 0.000 0.004 0.000 0.960 NA
#> SRR1168752     5  0.4655      0.816 0.104 0.000 0.004 0.000 0.692 NA
#> SRR1168753     5  0.2709      0.916 0.020 0.000 0.000 0.000 0.848 NA
#> SRR1168754     5  0.2446      0.923 0.012 0.000 0.000 0.000 0.864 NA
#> SRR1168755     5  0.2696      0.915 0.028 0.000 0.000 0.000 0.856 NA
#> SRR1168756     5  0.1866      0.924 0.008 0.000 0.000 0.000 0.908 NA
#> SRR1168757     5  0.1572      0.925 0.028 0.000 0.000 0.000 0.936 NA
#> SRR1168758     5  0.2212      0.920 0.008 0.000 0.000 0.000 0.880 NA
#> SRR1168759     5  0.2364      0.917 0.032 0.000 0.004 0.000 0.892 NA
#> SRR1168760     5  0.2048      0.922 0.000 0.000 0.000 0.000 0.880 NA
#> SRR1168761     3  0.6220      0.764 0.372 0.008 0.468 0.128 0.000 NA
#> SRR1168762     3  0.5996      0.764 0.384 0.004 0.468 0.128 0.000 NA
#> SRR1168763     3  0.5871      0.764 0.388 0.000 0.468 0.128 0.000 NA
#> SRR1168764     3  0.6360      0.763 0.364 0.012 0.468 0.128 0.000 NA
#> SRR1168765     3  0.6096      0.764 0.380 0.012 0.468 0.128 0.000 NA
#> SRR1168766     3  0.6279      0.763 0.368 0.008 0.468 0.128 0.000 NA
#> SRR1168767     3  0.6301      0.763 0.368 0.012 0.468 0.128 0.000 NA
#> SRR1168768     3  0.6499      0.763 0.356 0.020 0.468 0.128 0.000 NA
#> SRR1168769     4  0.0000      0.466 0.000 0.000 0.000 1.000 0.000 NA
#> SRR1168770     4  0.0260      0.465 0.000 0.000 0.000 0.992 0.000 NA
#> SRR1168771     4  0.0520      0.464 0.000 0.008 0.000 0.984 0.000 NA
#> SRR1168772     4  0.0717      0.463 0.000 0.016 0.000 0.976 0.000 NA
#> SRR1168773     4  0.0000      0.466 0.000 0.000 0.000 1.000 0.000 NA
#> SRR1168774     4  0.0363      0.465 0.000 0.000 0.000 0.988 0.000 NA
#> SRR1168775     4  0.0260      0.465 0.000 0.008 0.000 0.992 0.000 NA
#> SRR1168776     4  0.0260      0.465 0.000 0.000 0.000 0.992 0.000 NA
#> SRR1168777     4  0.2277      0.424 0.000 0.032 0.000 0.892 0.000 NA

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

consensus_heatmap(res, k = 2)

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

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

collect_plots(res)

plot of chunk MAD-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.5023 0.498   0.498
#> 3 3 1.000           0.994       0.995         0.3056 0.846   0.692
#> 4 4 0.820           0.956       0.911         0.0816 0.949   0.853
#> 5 5 0.871           0.892       0.818         0.0798 0.971   0.902
#> 6 6 0.896           0.991       0.923         0.0513 0.900   0.622

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
#> SRR1168715     1       0          1  1  0
#> SRR1168716     1       0          1  1  0
#> SRR1168717     1       0          1  1  0
#> SRR1168718     1       0          1  1  0
#> SRR1168719     1       0          1  1  0
#> SRR1168720     1       0          1  1  0
#> SRR1168721     1       0          1  1  0
#> SRR1168722     1       0          1  1  0
#> SRR1168723     1       0          1  1  0
#> SRR1168724     1       0          1  1  0
#> SRR1168725     1       0          1  1  0
#> SRR1168726     1       0          1  1  0
#> SRR1168727     1       0          1  1  0
#> SRR1168728     1       0          1  1  0
#> SRR1168729     1       0          1  1  0
#> SRR1168730     1       0          1  1  0
#> SRR1168731     1       0          1  1  0
#> SRR1168732     1       0          1  1  0
#> SRR1168733     2       0          1  0  1
#> SRR1168734     2       0          1  0  1
#> SRR1168735     2       0          1  0  1
#> SRR1168736     2       0          1  0  1
#> SRR1168737     2       0          1  0  1
#> SRR1168738     2       0          1  0  1
#> SRR1168739     2       0          1  0  1
#> SRR1168740     2       0          1  0  1
#> SRR1168741     2       0          1  0  1
#> SRR1168742     2       0          1  0  1
#> SRR1168743     2       0          1  0  1
#> SRR1168744     2       0          1  0  1
#> SRR1168745     2       0          1  0  1
#> SRR1168746     2       0          1  0  1
#> SRR1168747     2       0          1  0  1
#> SRR1168748     2       0          1  0  1
#> SRR1168749     2       0          1  0  1
#> SRR1168750     2       0          1  0  1
#> SRR1168751     2       0          1  0  1
#> SRR1168752     2       0          1  0  1
#> SRR1168753     2       0          1  0  1
#> SRR1168754     2       0          1  0  1
#> SRR1168755     2       0          1  0  1
#> SRR1168756     2       0          1  0  1
#> SRR1168757     2       0          1  0  1
#> SRR1168758     2       0          1  0  1
#> SRR1168759     2       0          1  0  1
#> SRR1168760     2       0          1  0  1
#> SRR1168761     1       0          1  1  0
#> SRR1168762     1       0          1  1  0
#> SRR1168763     1       0          1  1  0
#> SRR1168764     1       0          1  1  0
#> SRR1168765     1       0          1  1  0
#> SRR1168766     1       0          1  1  0
#> SRR1168767     1       0          1  1  0
#> SRR1168768     1       0          1  1  0
#> SRR1168769     1       0          1  1  0
#> SRR1168770     1       0          1  1  0
#> SRR1168771     1       0          1  1  0
#> SRR1168772     1       0          1  1  0
#> SRR1168773     1       0          1  1  0
#> SRR1168774     1       0          1  1  0
#> SRR1168775     1       0          1  1  0
#> SRR1168776     1       0          1  1  0
#> SRR1168777     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette   p1 p2   p3
#> SRR1168715     3  0.0892      0.988 0.02  0 0.98
#> SRR1168716     3  0.0892      0.988 0.02  0 0.98
#> SRR1168717     3  0.0892      0.988 0.02  0 0.98
#> SRR1168718     3  0.0892      0.988 0.02  0 0.98
#> SRR1168719     3  0.0892      0.988 0.02  0 0.98
#> SRR1168720     3  0.0892      0.988 0.02  0 0.98
#> SRR1168721     3  0.0892      0.988 0.02  0 0.98
#> SRR1168722     1  0.0000      0.990 1.00  0 0.00
#> SRR1168723     1  0.0000      0.990 1.00  0 0.00
#> SRR1168724     1  0.0000      0.990 1.00  0 0.00
#> SRR1168725     1  0.0000      0.990 1.00  0 0.00
#> SRR1168726     1  0.0000      0.990 1.00  0 0.00
#> SRR1168727     1  0.0000      0.990 1.00  0 0.00
#> SRR1168728     1  0.0000      0.990 1.00  0 0.00
#> SRR1168729     1  0.0000      0.990 1.00  0 0.00
#> SRR1168730     1  0.0000      0.990 1.00  0 0.00
#> SRR1168731     1  0.0000      0.990 1.00  0 0.00
#> SRR1168732     1  0.0000      0.990 1.00  0 0.00
#> SRR1168733     2  0.0000      1.000 0.00  1 0.00
#> SRR1168734     2  0.0000      1.000 0.00  1 0.00
#> SRR1168735     2  0.0000      1.000 0.00  1 0.00
#> SRR1168736     2  0.0000      1.000 0.00  1 0.00
#> SRR1168737     2  0.0000      1.000 0.00  1 0.00
#> SRR1168738     2  0.0000      1.000 0.00  1 0.00
#> SRR1168739     2  0.0000      1.000 0.00  1 0.00
#> SRR1168740     2  0.0000      1.000 0.00  1 0.00
#> SRR1168741     2  0.0000      1.000 0.00  1 0.00
#> SRR1168742     2  0.0000      1.000 0.00  1 0.00
#> SRR1168743     2  0.0000      1.000 0.00  1 0.00
#> SRR1168744     2  0.0000      1.000 0.00  1 0.00
#> SRR1168745     2  0.0000      1.000 0.00  1 0.00
#> SRR1168746     2  0.0000      1.000 0.00  1 0.00
#> SRR1168747     2  0.0000      1.000 0.00  1 0.00
#> SRR1168748     2  0.0000      1.000 0.00  1 0.00
#> SRR1168749     2  0.0000      1.000 0.00  1 0.00
#> SRR1168750     2  0.0000      1.000 0.00  1 0.00
#> SRR1168751     2  0.0000      1.000 0.00  1 0.00
#> SRR1168752     2  0.0000      1.000 0.00  1 0.00
#> SRR1168753     2  0.0000      1.000 0.00  1 0.00
#> SRR1168754     2  0.0000      1.000 0.00  1 0.00
#> SRR1168755     2  0.0000      1.000 0.00  1 0.00
#> SRR1168756     2  0.0000      1.000 0.00  1 0.00
#> SRR1168757     2  0.0000      1.000 0.00  1 0.00
#> SRR1168758     2  0.0000      1.000 0.00  1 0.00
#> SRR1168759     2  0.0000      1.000 0.00  1 0.00
#> SRR1168760     2  0.0000      1.000 0.00  1 0.00
#> SRR1168761     3  0.0000      0.990 0.00  0 1.00
#> SRR1168762     3  0.0000      0.990 0.00  0 1.00
#> SRR1168763     3  0.0000      0.990 0.00  0 1.00
#> SRR1168764     3  0.0000      0.990 0.00  0 1.00
#> SRR1168765     3  0.0000      0.990 0.00  0 1.00
#> SRR1168766     3  0.0000      0.990 0.00  0 1.00
#> SRR1168767     3  0.0000      0.990 0.00  0 1.00
#> SRR1168768     3  0.0000      0.990 0.00  0 1.00
#> SRR1168769     1  0.0892      0.988 0.98  0 0.02
#> SRR1168770     1  0.0892      0.988 0.98  0 0.02
#> SRR1168771     1  0.0892      0.988 0.98  0 0.02
#> SRR1168772     1  0.0892      0.988 0.98  0 0.02
#> SRR1168773     1  0.0892      0.988 0.98  0 0.02
#> SRR1168774     1  0.0892      0.988 0.98  0 0.02
#> SRR1168775     1  0.0892      0.988 0.98  0 0.02
#> SRR1168776     1  0.0892      0.988 0.98  0 0.02
#> SRR1168777     1  0.0892      0.988 0.98  0 0.02

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2   p3    p4
#> SRR1168715     3   0.000      0.925 0.000 0.000 1.00 0.000
#> SRR1168716     3   0.000      0.925 0.000 0.000 1.00 0.000
#> SRR1168717     3   0.000      0.925 0.000 0.000 1.00 0.000
#> SRR1168718     3   0.000      0.925 0.000 0.000 1.00 0.000
#> SRR1168719     3   0.000      0.925 0.000 0.000 1.00 0.000
#> SRR1168720     3   0.000      0.925 0.000 0.000 1.00 0.000
#> SRR1168721     3   0.000      0.925 0.000 0.000 1.00 0.000
#> SRR1168722     1   0.000      1.000 1.000 0.000 0.00 0.000
#> SRR1168723     1   0.000      1.000 1.000 0.000 0.00 0.000
#> SRR1168724     1   0.000      1.000 1.000 0.000 0.00 0.000
#> SRR1168725     1   0.000      1.000 1.000 0.000 0.00 0.000
#> SRR1168726     1   0.000      1.000 1.000 0.000 0.00 0.000
#> SRR1168727     1   0.000      1.000 1.000 0.000 0.00 0.000
#> SRR1168728     1   0.000      1.000 1.000 0.000 0.00 0.000
#> SRR1168729     1   0.000      1.000 1.000 0.000 0.00 0.000
#> SRR1168730     1   0.000      1.000 1.000 0.000 0.00 0.000
#> SRR1168731     1   0.000      1.000 1.000 0.000 0.00 0.000
#> SRR1168732     1   0.000      1.000 1.000 0.000 0.00 0.000
#> SRR1168733     2   0.000      0.938 0.000 1.000 0.00 0.000
#> SRR1168734     2   0.000      0.938 0.000 1.000 0.00 0.000
#> SRR1168735     2   0.000      0.938 0.000 1.000 0.00 0.000
#> SRR1168736     2   0.000      0.938 0.000 1.000 0.00 0.000
#> SRR1168737     2   0.000      0.938 0.000 1.000 0.00 0.000
#> SRR1168738     2   0.000      0.938 0.000 1.000 0.00 0.000
#> SRR1168739     2   0.000      0.938 0.000 1.000 0.00 0.000
#> SRR1168740     2   0.000      0.938 0.000 1.000 0.00 0.000
#> SRR1168741     2   0.000      0.938 0.000 1.000 0.00 0.000
#> SRR1168742     2   0.000      0.938 0.000 1.000 0.00 0.000
#> SRR1168743     2   0.000      0.938 0.000 1.000 0.00 0.000
#> SRR1168744     2   0.000      0.938 0.000 1.000 0.00 0.000
#> SRR1168745     2   0.000      0.938 0.000 1.000 0.00 0.000
#> SRR1168746     2   0.000      0.938 0.000 1.000 0.00 0.000
#> SRR1168747     2   0.281      0.938 0.000 0.868 0.00 0.132
#> SRR1168748     2   0.281      0.938 0.000 0.868 0.00 0.132
#> SRR1168749     2   0.281      0.938 0.000 0.868 0.00 0.132
#> SRR1168750     2   0.281      0.938 0.000 0.868 0.00 0.132
#> SRR1168751     2   0.281      0.938 0.000 0.868 0.00 0.132
#> SRR1168752     2   0.281      0.938 0.000 0.868 0.00 0.132
#> SRR1168753     2   0.281      0.938 0.000 0.868 0.00 0.132
#> SRR1168754     2   0.281      0.938 0.000 0.868 0.00 0.132
#> SRR1168755     2   0.281      0.938 0.000 0.868 0.00 0.132
#> SRR1168756     2   0.281      0.938 0.000 0.868 0.00 0.132
#> SRR1168757     2   0.281      0.938 0.000 0.868 0.00 0.132
#> SRR1168758     2   0.281      0.938 0.000 0.868 0.00 0.132
#> SRR1168759     2   0.281      0.938 0.000 0.868 0.00 0.132
#> SRR1168760     2   0.281      0.938 0.000 0.868 0.00 0.132
#> SRR1168761     3   0.317      0.935 0.000 0.000 0.84 0.160
#> SRR1168762     3   0.317      0.935 0.000 0.000 0.84 0.160
#> SRR1168763     3   0.317      0.935 0.000 0.000 0.84 0.160
#> SRR1168764     3   0.317      0.935 0.000 0.000 0.84 0.160
#> SRR1168765     3   0.317      0.935 0.000 0.000 0.84 0.160
#> SRR1168766     3   0.317      0.935 0.000 0.000 0.84 0.160
#> SRR1168767     3   0.317      0.935 0.000 0.000 0.84 0.160
#> SRR1168768     3   0.317      0.935 0.000 0.000 0.84 0.160
#> SRR1168769     4   0.436      1.000 0.292 0.000 0.00 0.708
#> SRR1168770     4   0.436      1.000 0.292 0.000 0.00 0.708
#> SRR1168771     4   0.436      1.000 0.292 0.000 0.00 0.708
#> SRR1168772     4   0.436      1.000 0.292 0.000 0.00 0.708
#> SRR1168773     4   0.436      1.000 0.292 0.000 0.00 0.708
#> SRR1168774     4   0.436      1.000 0.292 0.000 0.00 0.708
#> SRR1168775     4   0.436      1.000 0.292 0.000 0.00 0.708
#> SRR1168776     4   0.436      1.000 0.292 0.000 0.00 0.708
#> SRR1168777     4   0.436      1.000 0.292 0.000 0.00 0.708

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4    p5
#> SRR1168715     5   0.000      0.998 0.000 0.000 0.000 0.000 1.000
#> SRR1168716     5   0.000      0.998 0.000 0.000 0.000 0.000 1.000
#> SRR1168717     5   0.000      0.998 0.000 0.000 0.000 0.000 1.000
#> SRR1168718     5   0.000      0.998 0.000 0.000 0.000 0.000 1.000
#> SRR1168719     5   0.000      0.998 0.000 0.000 0.000 0.000 1.000
#> SRR1168720     5   0.000      0.998 0.000 0.000 0.000 0.000 1.000
#> SRR1168721     5   0.029      0.986 0.000 0.000 0.008 0.000 0.992
#> SRR1168722     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1168723     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1168724     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1168725     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1168726     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1168727     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1168728     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1168729     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1168730     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1168731     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1168732     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1168733     2   0.000      0.759 0.000 1.000 0.000 0.000 0.000
#> SRR1168734     2   0.000      0.759 0.000 1.000 0.000 0.000 0.000
#> SRR1168735     2   0.000      0.759 0.000 1.000 0.000 0.000 0.000
#> SRR1168736     2   0.000      0.759 0.000 1.000 0.000 0.000 0.000
#> SRR1168737     2   0.000      0.759 0.000 1.000 0.000 0.000 0.000
#> SRR1168738     2   0.000      0.759 0.000 1.000 0.000 0.000 0.000
#> SRR1168739     2   0.000      0.759 0.000 1.000 0.000 0.000 0.000
#> SRR1168740     2   0.000      0.759 0.000 1.000 0.000 0.000 0.000
#> SRR1168741     2   0.000      0.759 0.000 1.000 0.000 0.000 0.000
#> SRR1168742     2   0.000      0.759 0.000 1.000 0.000 0.000 0.000
#> SRR1168743     2   0.000      0.759 0.000 1.000 0.000 0.000 0.000
#> SRR1168744     2   0.000      0.759 0.000 1.000 0.000 0.000 0.000
#> SRR1168745     2   0.000      0.759 0.000 1.000 0.000 0.000 0.000
#> SRR1168746     2   0.000      0.759 0.000 1.000 0.000 0.000 0.000
#> SRR1168747     2   0.428      0.759 0.000 0.548 0.452 0.000 0.000
#> SRR1168748     2   0.428      0.759 0.000 0.548 0.452 0.000 0.000
#> SRR1168749     2   0.428      0.759 0.000 0.548 0.452 0.000 0.000
#> SRR1168750     2   0.428      0.759 0.000 0.548 0.452 0.000 0.000
#> SRR1168751     2   0.428      0.759 0.000 0.548 0.452 0.000 0.000
#> SRR1168752     2   0.428      0.759 0.000 0.548 0.452 0.000 0.000
#> SRR1168753     2   0.428      0.759 0.000 0.548 0.452 0.000 0.000
#> SRR1168754     2   0.428      0.759 0.000 0.548 0.452 0.000 0.000
#> SRR1168755     2   0.428      0.759 0.000 0.548 0.452 0.000 0.000
#> SRR1168756     2   0.428      0.759 0.000 0.548 0.452 0.000 0.000
#> SRR1168757     2   0.428      0.759 0.000 0.548 0.452 0.000 0.000
#> SRR1168758     2   0.428      0.759 0.000 0.548 0.452 0.000 0.000
#> SRR1168759     2   0.428      0.759 0.000 0.548 0.452 0.000 0.000
#> SRR1168760     2   0.428      0.759 0.000 0.548 0.452 0.000 0.000
#> SRR1168761     3   0.531      1.000 0.000 0.000 0.532 0.052 0.416
#> SRR1168762     3   0.531      1.000 0.000 0.000 0.532 0.052 0.416
#> SRR1168763     3   0.531      1.000 0.000 0.000 0.532 0.052 0.416
#> SRR1168764     3   0.531      1.000 0.000 0.000 0.532 0.052 0.416
#> SRR1168765     3   0.531      1.000 0.000 0.000 0.532 0.052 0.416
#> SRR1168766     3   0.531      1.000 0.000 0.000 0.532 0.052 0.416
#> SRR1168767     3   0.531      1.000 0.000 0.000 0.532 0.052 0.416
#> SRR1168768     3   0.531      1.000 0.000 0.000 0.532 0.052 0.416
#> SRR1168769     4   0.127      0.999 0.052 0.000 0.000 0.948 0.000
#> SRR1168770     4   0.127      0.999 0.052 0.000 0.000 0.948 0.000
#> SRR1168771     4   0.127      0.999 0.052 0.000 0.000 0.948 0.000
#> SRR1168772     4   0.127      0.999 0.052 0.000 0.000 0.948 0.000
#> SRR1168773     4   0.127      0.999 0.052 0.000 0.000 0.948 0.000
#> SRR1168774     4   0.127      0.999 0.052 0.000 0.000 0.948 0.000
#> SRR1168775     4   0.127      0.999 0.052 0.000 0.000 0.948 0.000
#> SRR1168776     4   0.127      0.999 0.052 0.000 0.000 0.948 0.000
#> SRR1168777     4   0.156      0.994 0.052 0.000 0.008 0.940 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
#> SRR1168715     6  0.0937      0.997  0 0.000 0.040 0.000 0.000 0.960
#> SRR1168716     6  0.0937      0.997  0 0.000 0.040 0.000 0.000 0.960
#> SRR1168717     6  0.0937      0.997  0 0.000 0.040 0.000 0.000 0.960
#> SRR1168718     6  0.0937      0.997  0 0.000 0.040 0.000 0.000 0.960
#> SRR1168719     6  0.0937      0.997  0 0.000 0.040 0.000 0.000 0.960
#> SRR1168720     6  0.0937      0.997  0 0.000 0.040 0.000 0.000 0.960
#> SRR1168721     6  0.0632      0.983  0 0.000 0.024 0.000 0.000 0.976
#> SRR1168722     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1168723     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1168724     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1168725     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1168726     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1168727     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1168728     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1168729     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1168730     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1168731     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1168732     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1168733     2  0.0000      1.000  0 1.000 0.000 0.000 0.000 0.000
#> SRR1168734     2  0.0000      1.000  0 1.000 0.000 0.000 0.000 0.000
#> SRR1168735     2  0.0000      1.000  0 1.000 0.000 0.000 0.000 0.000
#> SRR1168736     2  0.0000      1.000  0 1.000 0.000 0.000 0.000 0.000
#> SRR1168737     2  0.0000      1.000  0 1.000 0.000 0.000 0.000 0.000
#> SRR1168738     2  0.0000      1.000  0 1.000 0.000 0.000 0.000 0.000
#> SRR1168739     2  0.0000      1.000  0 1.000 0.000 0.000 0.000 0.000
#> SRR1168740     2  0.0000      1.000  0 1.000 0.000 0.000 0.000 0.000
#> SRR1168741     2  0.0000      1.000  0 1.000 0.000 0.000 0.000 0.000
#> SRR1168742     2  0.0000      1.000  0 1.000 0.000 0.000 0.000 0.000
#> SRR1168743     2  0.0000      1.000  0 1.000 0.000 0.000 0.000 0.000
#> SRR1168744     2  0.0000      1.000  0 1.000 0.000 0.000 0.000 0.000
#> SRR1168745     2  0.0000      1.000  0 1.000 0.000 0.000 0.000 0.000
#> SRR1168746     2  0.0000      1.000  0 1.000 0.000 0.000 0.000 0.000
#> SRR1168747     5  0.3428      1.000  0 0.304 0.000 0.000 0.696 0.000
#> SRR1168748     5  0.3428      1.000  0 0.304 0.000 0.000 0.696 0.000
#> SRR1168749     5  0.3428      1.000  0 0.304 0.000 0.000 0.696 0.000
#> SRR1168750     5  0.3428      1.000  0 0.304 0.000 0.000 0.696 0.000
#> SRR1168751     5  0.3428      1.000  0 0.304 0.000 0.000 0.696 0.000
#> SRR1168752     5  0.3428      1.000  0 0.304 0.000 0.000 0.696 0.000
#> SRR1168753     5  0.3428      1.000  0 0.304 0.000 0.000 0.696 0.000
#> SRR1168754     5  0.3428      1.000  0 0.304 0.000 0.000 0.696 0.000
#> SRR1168755     5  0.3428      1.000  0 0.304 0.000 0.000 0.696 0.000
#> SRR1168756     5  0.3428      1.000  0 0.304 0.000 0.000 0.696 0.000
#> SRR1168757     5  0.3428      1.000  0 0.304 0.000 0.000 0.696 0.000
#> SRR1168758     5  0.3428      1.000  0 0.304 0.000 0.000 0.696 0.000
#> SRR1168759     5  0.3428      1.000  0 0.304 0.000 0.000 0.696 0.000
#> SRR1168760     5  0.3428      1.000  0 0.304 0.000 0.000 0.696 0.000
#> SRR1168761     3  0.0000      1.000  0 0.000 1.000 0.000 0.000 0.000
#> SRR1168762     3  0.0000      1.000  0 0.000 1.000 0.000 0.000 0.000
#> SRR1168763     3  0.0000      1.000  0 0.000 1.000 0.000 0.000 0.000
#> SRR1168764     3  0.0000      1.000  0 0.000 1.000 0.000 0.000 0.000
#> SRR1168765     3  0.0000      1.000  0 0.000 1.000 0.000 0.000 0.000
#> SRR1168766     3  0.0000      1.000  0 0.000 1.000 0.000 0.000 0.000
#> SRR1168767     3  0.0000      1.000  0 0.000 1.000 0.000 0.000 0.000
#> SRR1168768     3  0.0000      1.000  0 0.000 1.000 0.000 0.000 0.000
#> SRR1168769     4  0.0000      0.969  0 0.000 0.000 1.000 0.000 0.000
#> SRR1168770     4  0.0000      0.969  0 0.000 0.000 1.000 0.000 0.000
#> SRR1168771     4  0.0000      0.969  0 0.000 0.000 1.000 0.000 0.000
#> SRR1168772     4  0.0000      0.969  0 0.000 0.000 1.000 0.000 0.000
#> SRR1168773     4  0.0000      0.969  0 0.000 0.000 1.000 0.000 0.000
#> SRR1168774     4  0.0000      0.969  0 0.000 0.000 1.000 0.000 0.000
#> SRR1168775     4  0.0000      0.969  0 0.000 0.000 1.000 0.000 0.000
#> SRR1168776     4  0.0000      0.969  0 0.000 0.000 1.000 0.000 0.000
#> SRR1168777     4  0.4011      0.711  0 0.000 0.000 0.672 0.304 0.024

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-skmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-skmeans-collect-classes

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


MAD:pam**

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

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

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

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 14158 rows and 63 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           1.000       1.000         0.5023 0.498   0.498
#> 3 3     1           1.000       1.000         0.3055 0.846   0.692
#> 4 4     1           1.000       1.000         0.0772 0.949   0.853
#> 5 5     1           0.993       0.989         0.0437 0.971   0.902
#> 6 6     1           1.000       1.000         0.1330 0.900   0.622

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
#> SRR1168715     1       0          1  1  0
#> SRR1168716     1       0          1  1  0
#> SRR1168717     1       0          1  1  0
#> SRR1168718     1       0          1  1  0
#> SRR1168719     1       0          1  1  0
#> SRR1168720     1       0          1  1  0
#> SRR1168721     1       0          1  1  0
#> SRR1168722     1       0          1  1  0
#> SRR1168723     1       0          1  1  0
#> SRR1168724     1       0          1  1  0
#> SRR1168725     1       0          1  1  0
#> SRR1168726     1       0          1  1  0
#> SRR1168727     1       0          1  1  0
#> SRR1168728     1       0          1  1  0
#> SRR1168729     1       0          1  1  0
#> SRR1168730     1       0          1  1  0
#> SRR1168731     1       0          1  1  0
#> SRR1168732     1       0          1  1  0
#> SRR1168733     2       0          1  0  1
#> SRR1168734     2       0          1  0  1
#> SRR1168735     2       0          1  0  1
#> SRR1168736     2       0          1  0  1
#> SRR1168737     2       0          1  0  1
#> SRR1168738     2       0          1  0  1
#> SRR1168739     2       0          1  0  1
#> SRR1168740     2       0          1  0  1
#> SRR1168741     2       0          1  0  1
#> SRR1168742     2       0          1  0  1
#> SRR1168743     2       0          1  0  1
#> SRR1168744     2       0          1  0  1
#> SRR1168745     2       0          1  0  1
#> SRR1168746     2       0          1  0  1
#> SRR1168747     2       0          1  0  1
#> SRR1168748     2       0          1  0  1
#> SRR1168749     2       0          1  0  1
#> SRR1168750     2       0          1  0  1
#> SRR1168751     2       0          1  0  1
#> SRR1168752     2       0          1  0  1
#> SRR1168753     2       0          1  0  1
#> SRR1168754     2       0          1  0  1
#> SRR1168755     2       0          1  0  1
#> SRR1168756     2       0          1  0  1
#> SRR1168757     2       0          1  0  1
#> SRR1168758     2       0          1  0  1
#> SRR1168759     2       0          1  0  1
#> SRR1168760     2       0          1  0  1
#> SRR1168761     1       0          1  1  0
#> SRR1168762     1       0          1  1  0
#> SRR1168763     1       0          1  1  0
#> SRR1168764     1       0          1  1  0
#> SRR1168765     1       0          1  1  0
#> SRR1168766     1       0          1  1  0
#> SRR1168767     1       0          1  1  0
#> SRR1168768     1       0          1  1  0
#> SRR1168769     1       0          1  1  0
#> SRR1168770     1       0          1  1  0
#> SRR1168771     1       0          1  1  0
#> SRR1168772     1       0          1  1  0
#> SRR1168773     1       0          1  1  0
#> SRR1168774     1       0          1  1  0
#> SRR1168775     1       0          1  1  0
#> SRR1168776     1       0          1  1  0
#> SRR1168777     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette p1 p2 p3
#> SRR1168715     3       0          1  0  0  1
#> SRR1168716     3       0          1  0  0  1
#> SRR1168717     3       0          1  0  0  1
#> SRR1168718     3       0          1  0  0  1
#> SRR1168719     3       0          1  0  0  1
#> SRR1168720     3       0          1  0  0  1
#> SRR1168721     3       0          1  0  0  1
#> SRR1168722     1       0          1  1  0  0
#> SRR1168723     1       0          1  1  0  0
#> SRR1168724     1       0          1  1  0  0
#> SRR1168725     1       0          1  1  0  0
#> SRR1168726     1       0          1  1  0  0
#> SRR1168727     1       0          1  1  0  0
#> SRR1168728     1       0          1  1  0  0
#> SRR1168729     1       0          1  1  0  0
#> SRR1168730     1       0          1  1  0  0
#> SRR1168731     1       0          1  1  0  0
#> SRR1168732     1       0          1  1  0  0
#> SRR1168733     2       0          1  0  1  0
#> SRR1168734     2       0          1  0  1  0
#> SRR1168735     2       0          1  0  1  0
#> SRR1168736     2       0          1  0  1  0
#> SRR1168737     2       0          1  0  1  0
#> SRR1168738     2       0          1  0  1  0
#> SRR1168739     2       0          1  0  1  0
#> SRR1168740     2       0          1  0  1  0
#> SRR1168741     2       0          1  0  1  0
#> SRR1168742     2       0          1  0  1  0
#> SRR1168743     2       0          1  0  1  0
#> SRR1168744     2       0          1  0  1  0
#> SRR1168745     2       0          1  0  1  0
#> SRR1168746     2       0          1  0  1  0
#> SRR1168747     2       0          1  0  1  0
#> SRR1168748     2       0          1  0  1  0
#> SRR1168749     2       0          1  0  1  0
#> SRR1168750     2       0          1  0  1  0
#> SRR1168751     2       0          1  0  1  0
#> SRR1168752     2       0          1  0  1  0
#> SRR1168753     2       0          1  0  1  0
#> SRR1168754     2       0          1  0  1  0
#> SRR1168755     2       0          1  0  1  0
#> SRR1168756     2       0          1  0  1  0
#> SRR1168757     2       0          1  0  1  0
#> SRR1168758     2       0          1  0  1  0
#> SRR1168759     2       0          1  0  1  0
#> SRR1168760     2       0          1  0  1  0
#> SRR1168761     3       0          1  0  0  1
#> SRR1168762     3       0          1  0  0  1
#> SRR1168763     3       0          1  0  0  1
#> SRR1168764     3       0          1  0  0  1
#> SRR1168765     3       0          1  0  0  1
#> SRR1168766     3       0          1  0  0  1
#> SRR1168767     3       0          1  0  0  1
#> SRR1168768     3       0          1  0  0  1
#> SRR1168769     1       0          1  1  0  0
#> SRR1168770     1       0          1  1  0  0
#> SRR1168771     1       0          1  1  0  0
#> SRR1168772     1       0          1  1  0  0
#> SRR1168773     1       0          1  1  0  0
#> SRR1168774     1       0          1  1  0  0
#> SRR1168775     1       0          1  1  0  0
#> SRR1168776     1       0          1  1  0  0
#> SRR1168777     1       0          1  1  0  0

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette p1 p2 p3 p4
#> SRR1168715     3       0          1  0  0  1  0
#> SRR1168716     3       0          1  0  0  1  0
#> SRR1168717     3       0          1  0  0  1  0
#> SRR1168718     3       0          1  0  0  1  0
#> SRR1168719     3       0          1  0  0  1  0
#> SRR1168720     3       0          1  0  0  1  0
#> SRR1168721     3       0          1  0  0  1  0
#> SRR1168722     1       0          1  1  0  0  0
#> SRR1168723     1       0          1  1  0  0  0
#> SRR1168724     1       0          1  1  0  0  0
#> SRR1168725     1       0          1  1  0  0  0
#> SRR1168726     1       0          1  1  0  0  0
#> SRR1168727     1       0          1  1  0  0  0
#> SRR1168728     1       0          1  1  0  0  0
#> SRR1168729     1       0          1  1  0  0  0
#> SRR1168730     1       0          1  1  0  0  0
#> SRR1168731     1       0          1  1  0  0  0
#> SRR1168732     1       0          1  1  0  0  0
#> SRR1168733     2       0          1  0  1  0  0
#> SRR1168734     2       0          1  0  1  0  0
#> SRR1168735     2       0          1  0  1  0  0
#> SRR1168736     2       0          1  0  1  0  0
#> SRR1168737     2       0          1  0  1  0  0
#> SRR1168738     2       0          1  0  1  0  0
#> SRR1168739     2       0          1  0  1  0  0
#> SRR1168740     2       0          1  0  1  0  0
#> SRR1168741     2       0          1  0  1  0  0
#> SRR1168742     2       0          1  0  1  0  0
#> SRR1168743     2       0          1  0  1  0  0
#> SRR1168744     2       0          1  0  1  0  0
#> SRR1168745     2       0          1  0  1  0  0
#> SRR1168746     2       0          1  0  1  0  0
#> SRR1168747     2       0          1  0  1  0  0
#> SRR1168748     2       0          1  0  1  0  0
#> SRR1168749     2       0          1  0  1  0  0
#> SRR1168750     2       0          1  0  1  0  0
#> SRR1168751     2       0          1  0  1  0  0
#> SRR1168752     2       0          1  0  1  0  0
#> SRR1168753     2       0          1  0  1  0  0
#> SRR1168754     2       0          1  0  1  0  0
#> SRR1168755     2       0          1  0  1  0  0
#> SRR1168756     2       0          1  0  1  0  0
#> SRR1168757     2       0          1  0  1  0  0
#> SRR1168758     2       0          1  0  1  0  0
#> SRR1168759     2       0          1  0  1  0  0
#> SRR1168760     2       0          1  0  1  0  0
#> SRR1168761     3       0          1  0  0  1  0
#> SRR1168762     3       0          1  0  0  1  0
#> SRR1168763     3       0          1  0  0  1  0
#> SRR1168764     3       0          1  0  0  1  0
#> SRR1168765     3       0          1  0  0  1  0
#> SRR1168766     3       0          1  0  0  1  0
#> SRR1168767     3       0          1  0  0  1  0
#> SRR1168768     3       0          1  0  0  1  0
#> SRR1168769     4       0          1  0  0  0  1
#> SRR1168770     4       0          1  0  0  0  1
#> SRR1168771     4       0          1  0  0  0  1
#> SRR1168772     4       0          1  0  0  0  1
#> SRR1168773     4       0          1  0  0  0  1
#> SRR1168774     4       0          1  0  0  0  1
#> SRR1168775     4       0          1  0  0  0  1
#> SRR1168776     4       0          1  0  0  0  1
#> SRR1168777     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
#> SRR1168715     5   0.088      1.000  0 0.000 0.032  0 0.968
#> SRR1168716     5   0.088      1.000  0 0.000 0.032  0 0.968
#> SRR1168717     5   0.088      1.000  0 0.000 0.032  0 0.968
#> SRR1168718     5   0.088      1.000  0 0.000 0.032  0 0.968
#> SRR1168719     5   0.088      1.000  0 0.000 0.032  0 0.968
#> SRR1168720     5   0.088      1.000  0 0.000 0.032  0 0.968
#> SRR1168721     5   0.088      1.000  0 0.000 0.032  0 0.968
#> SRR1168722     1   0.000      1.000  1 0.000 0.000  0 0.000
#> SRR1168723     1   0.000      1.000  1 0.000 0.000  0 0.000
#> SRR1168724     1   0.000      1.000  1 0.000 0.000  0 0.000
#> SRR1168725     1   0.000      1.000  1 0.000 0.000  0 0.000
#> SRR1168726     1   0.000      1.000  1 0.000 0.000  0 0.000
#> SRR1168727     1   0.000      1.000  1 0.000 0.000  0 0.000
#> SRR1168728     1   0.000      1.000  1 0.000 0.000  0 0.000
#> SRR1168729     1   0.000      1.000  1 0.000 0.000  0 0.000
#> SRR1168730     1   0.000      1.000  1 0.000 0.000  0 0.000
#> SRR1168731     1   0.000      1.000  1 0.000 0.000  0 0.000
#> SRR1168732     1   0.000      1.000  1 0.000 0.000  0 0.000
#> SRR1168733     2   0.000      0.985  0 1.000 0.000  0 0.000
#> SRR1168734     2   0.000      0.985  0 1.000 0.000  0 0.000
#> SRR1168735     2   0.000      0.985  0 1.000 0.000  0 0.000
#> SRR1168736     2   0.000      0.985  0 1.000 0.000  0 0.000
#> SRR1168737     2   0.000      0.985  0 1.000 0.000  0 0.000
#> SRR1168738     2   0.000      0.985  0 1.000 0.000  0 0.000
#> SRR1168739     2   0.000      0.985  0 1.000 0.000  0 0.000
#> SRR1168740     2   0.000      0.985  0 1.000 0.000  0 0.000
#> SRR1168741     2   0.000      0.985  0 1.000 0.000  0 0.000
#> SRR1168742     2   0.000      0.985  0 1.000 0.000  0 0.000
#> SRR1168743     2   0.000      0.985  0 1.000 0.000  0 0.000
#> SRR1168744     2   0.000      0.985  0 1.000 0.000  0 0.000
#> SRR1168745     2   0.000      0.985  0 1.000 0.000  0 0.000
#> SRR1168746     2   0.000      0.985  0 1.000 0.000  0 0.000
#> SRR1168747     2   0.088      0.985  0 0.968 0.000  0 0.032
#> SRR1168748     2   0.088      0.985  0 0.968 0.000  0 0.032
#> SRR1168749     2   0.088      0.985  0 0.968 0.000  0 0.032
#> SRR1168750     2   0.088      0.985  0 0.968 0.000  0 0.032
#> SRR1168751     2   0.088      0.985  0 0.968 0.000  0 0.032
#> SRR1168752     2   0.088      0.985  0 0.968 0.000  0 0.032
#> SRR1168753     2   0.088      0.985  0 0.968 0.000  0 0.032
#> SRR1168754     2   0.088      0.985  0 0.968 0.000  0 0.032
#> SRR1168755     2   0.088      0.985  0 0.968 0.000  0 0.032
#> SRR1168756     2   0.088      0.985  0 0.968 0.000  0 0.032
#> SRR1168757     2   0.088      0.985  0 0.968 0.000  0 0.032
#> SRR1168758     2   0.088      0.985  0 0.968 0.000  0 0.032
#> SRR1168759     2   0.088      0.985  0 0.968 0.000  0 0.032
#> SRR1168760     2   0.088      0.985  0 0.968 0.000  0 0.032
#> SRR1168761     3   0.000      1.000  0 0.000 1.000  0 0.000
#> SRR1168762     3   0.000      1.000  0 0.000 1.000  0 0.000
#> SRR1168763     3   0.000      1.000  0 0.000 1.000  0 0.000
#> SRR1168764     3   0.000      1.000  0 0.000 1.000  0 0.000
#> SRR1168765     3   0.000      1.000  0 0.000 1.000  0 0.000
#> SRR1168766     3   0.000      1.000  0 0.000 1.000  0 0.000
#> SRR1168767     3   0.000      1.000  0 0.000 1.000  0 0.000
#> SRR1168768     3   0.000      1.000  0 0.000 1.000  0 0.000
#> SRR1168769     4   0.000      1.000  0 0.000 0.000  1 0.000
#> SRR1168770     4   0.000      1.000  0 0.000 0.000  1 0.000
#> SRR1168771     4   0.000      1.000  0 0.000 0.000  1 0.000
#> SRR1168772     4   0.000      1.000  0 0.000 0.000  1 0.000
#> SRR1168773     4   0.000      1.000  0 0.000 0.000  1 0.000
#> SRR1168774     4   0.000      1.000  0 0.000 0.000  1 0.000
#> SRR1168775     4   0.000      1.000  0 0.000 0.000  1 0.000
#> SRR1168776     4   0.000      1.000  0 0.000 0.000  1 0.000
#> SRR1168777     4   0.000      1.000  0 0.000 0.000  1 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1168715     6       0          1  0  0  0  0  0  1
#> SRR1168716     6       0          1  0  0  0  0  0  1
#> SRR1168717     6       0          1  0  0  0  0  0  1
#> SRR1168718     6       0          1  0  0  0  0  0  1
#> SRR1168719     6       0          1  0  0  0  0  0  1
#> SRR1168720     6       0          1  0  0  0  0  0  1
#> SRR1168721     6       0          1  0  0  0  0  0  1
#> SRR1168722     1       0          1  1  0  0  0  0  0
#> SRR1168723     1       0          1  1  0  0  0  0  0
#> SRR1168724     1       0          1  1  0  0  0  0  0
#> SRR1168725     1       0          1  1  0  0  0  0  0
#> SRR1168726     1       0          1  1  0  0  0  0  0
#> SRR1168727     1       0          1  1  0  0  0  0  0
#> SRR1168728     1       0          1  1  0  0  0  0  0
#> SRR1168729     1       0          1  1  0  0  0  0  0
#> SRR1168730     1       0          1  1  0  0  0  0  0
#> SRR1168731     1       0          1  1  0  0  0  0  0
#> SRR1168732     1       0          1  1  0  0  0  0  0
#> SRR1168733     2       0          1  0  1  0  0  0  0
#> SRR1168734     2       0          1  0  1  0  0  0  0
#> SRR1168735     2       0          1  0  1  0  0  0  0
#> SRR1168736     2       0          1  0  1  0  0  0  0
#> SRR1168737     2       0          1  0  1  0  0  0  0
#> SRR1168738     2       0          1  0  1  0  0  0  0
#> SRR1168739     2       0          1  0  1  0  0  0  0
#> SRR1168740     2       0          1  0  1  0  0  0  0
#> SRR1168741     2       0          1  0  1  0  0  0  0
#> SRR1168742     2       0          1  0  1  0  0  0  0
#> SRR1168743     2       0          1  0  1  0  0  0  0
#> SRR1168744     2       0          1  0  1  0  0  0  0
#> SRR1168745     2       0          1  0  1  0  0  0  0
#> SRR1168746     2       0          1  0  1  0  0  0  0
#> SRR1168747     5       0          1  0  0  0  0  1  0
#> SRR1168748     5       0          1  0  0  0  0  1  0
#> SRR1168749     5       0          1  0  0  0  0  1  0
#> SRR1168750     5       0          1  0  0  0  0  1  0
#> SRR1168751     5       0          1  0  0  0  0  1  0
#> SRR1168752     5       0          1  0  0  0  0  1  0
#> SRR1168753     5       0          1  0  0  0  0  1  0
#> SRR1168754     5       0          1  0  0  0  0  1  0
#> SRR1168755     5       0          1  0  0  0  0  1  0
#> SRR1168756     5       0          1  0  0  0  0  1  0
#> SRR1168757     5       0          1  0  0  0  0  1  0
#> SRR1168758     5       0          1  0  0  0  0  1  0
#> SRR1168759     5       0          1  0  0  0  0  1  0
#> SRR1168760     5       0          1  0  0  0  0  1  0
#> SRR1168761     3       0          1  0  0  1  0  0  0
#> SRR1168762     3       0          1  0  0  1  0  0  0
#> SRR1168763     3       0          1  0  0  1  0  0  0
#> SRR1168764     3       0          1  0  0  1  0  0  0
#> SRR1168765     3       0          1  0  0  1  0  0  0
#> SRR1168766     3       0          1  0  0  1  0  0  0
#> SRR1168767     3       0          1  0  0  1  0  0  0
#> SRR1168768     3       0          1  0  0  1  0  0  0
#> SRR1168769     4       0          1  0  0  0  1  0  0
#> SRR1168770     4       0          1  0  0  0  1  0  0
#> SRR1168771     4       0          1  0  0  0  1  0  0
#> SRR1168772     4       0          1  0  0  0  1  0  0
#> SRR1168773     4       0          1  0  0  0  1  0  0
#> SRR1168774     4       0          1  0  0  0  1  0  0
#> SRR1168775     4       0          1  0  0  0  1  0  0
#> SRR1168776     4       0          1  0  0  0  1  0  0
#> SRR1168777     4       0          1  0  0  0  1  0  0

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

consensus_heatmap(res, k = 2)

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

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

collect_plots(res)

plot of chunk MAD-mclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.5023 0.498   0.498
#> 3 3 0.880           0.975       0.983         0.2732 0.865   0.729
#> 4 4 1.000           1.000       1.000         0.1045 0.931   0.810
#> 5 5 1.000           1.000       1.000         0.0406 0.971   0.902
#> 6 6 0.885           0.995       0.946         0.1079 0.900   0.622

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette p1 p2
#> SRR1168715     1       0          1  1  0
#> SRR1168716     1       0          1  1  0
#> SRR1168717     1       0          1  1  0
#> SRR1168718     1       0          1  1  0
#> SRR1168719     1       0          1  1  0
#> SRR1168720     1       0          1  1  0
#> SRR1168721     1       0          1  1  0
#> SRR1168722     1       0          1  1  0
#> SRR1168723     1       0          1  1  0
#> SRR1168724     1       0          1  1  0
#> SRR1168725     1       0          1  1  0
#> SRR1168726     1       0          1  1  0
#> SRR1168727     1       0          1  1  0
#> SRR1168728     1       0          1  1  0
#> SRR1168729     1       0          1  1  0
#> SRR1168730     1       0          1  1  0
#> SRR1168731     1       0          1  1  0
#> SRR1168732     1       0          1  1  0
#> SRR1168733     2       0          1  0  1
#> SRR1168734     2       0          1  0  1
#> SRR1168735     2       0          1  0  1
#> SRR1168736     2       0          1  0  1
#> SRR1168737     2       0          1  0  1
#> SRR1168738     2       0          1  0  1
#> SRR1168739     2       0          1  0  1
#> SRR1168740     2       0          1  0  1
#> SRR1168741     2       0          1  0  1
#> SRR1168742     2       0          1  0  1
#> SRR1168743     2       0          1  0  1
#> SRR1168744     2       0          1  0  1
#> SRR1168745     2       0          1  0  1
#> SRR1168746     2       0          1  0  1
#> SRR1168747     2       0          1  0  1
#> SRR1168748     2       0          1  0  1
#> SRR1168749     2       0          1  0  1
#> SRR1168750     2       0          1  0  1
#> SRR1168751     2       0          1  0  1
#> SRR1168752     2       0          1  0  1
#> SRR1168753     2       0          1  0  1
#> SRR1168754     2       0          1  0  1
#> SRR1168755     2       0          1  0  1
#> SRR1168756     2       0          1  0  1
#> SRR1168757     2       0          1  0  1
#> SRR1168758     2       0          1  0  1
#> SRR1168759     2       0          1  0  1
#> SRR1168760     2       0          1  0  1
#> SRR1168761     1       0          1  1  0
#> SRR1168762     1       0          1  1  0
#> SRR1168763     1       0          1  1  0
#> SRR1168764     1       0          1  1  0
#> SRR1168765     1       0          1  1  0
#> SRR1168766     1       0          1  1  0
#> SRR1168767     1       0          1  1  0
#> SRR1168768     1       0          1  1  0
#> SRR1168769     1       0          1  1  0
#> SRR1168770     1       0          1  1  0
#> SRR1168771     1       0          1  1  0
#> SRR1168772     1       0          1  1  0
#> SRR1168773     1       0          1  1  0
#> SRR1168774     1       0          1  1  0
#> SRR1168775     1       0          1  1  0
#> SRR1168776     1       0          1  1  0
#> SRR1168777     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette   p1 p2   p3
#> SRR1168715     3   0.000      0.950 0.00  0 1.00
#> SRR1168716     3   0.000      0.950 0.00  0 1.00
#> SRR1168717     3   0.000      0.950 0.00  0 1.00
#> SRR1168718     3   0.000      0.950 0.00  0 1.00
#> SRR1168719     3   0.000      0.950 0.00  0 1.00
#> SRR1168720     3   0.000      0.950 0.00  0 1.00
#> SRR1168721     3   0.000      0.950 0.00  0 1.00
#> SRR1168722     1   0.000      1.000 1.00  0 0.00
#> SRR1168723     1   0.000      1.000 1.00  0 0.00
#> SRR1168724     1   0.000      1.000 1.00  0 0.00
#> SRR1168725     1   0.000      1.000 1.00  0 0.00
#> SRR1168726     1   0.000      1.000 1.00  0 0.00
#> SRR1168727     1   0.000      1.000 1.00  0 0.00
#> SRR1168728     1   0.000      1.000 1.00  0 0.00
#> SRR1168729     1   0.000      1.000 1.00  0 0.00
#> SRR1168730     1   0.000      1.000 1.00  0 0.00
#> SRR1168731     1   0.000      1.000 1.00  0 0.00
#> SRR1168732     1   0.000      1.000 1.00  0 0.00
#> SRR1168733     2   0.000      1.000 0.00  1 0.00
#> SRR1168734     2   0.000      1.000 0.00  1 0.00
#> SRR1168735     2   0.000      1.000 0.00  1 0.00
#> SRR1168736     2   0.000      1.000 0.00  1 0.00
#> SRR1168737     2   0.000      1.000 0.00  1 0.00
#> SRR1168738     2   0.000      1.000 0.00  1 0.00
#> SRR1168739     2   0.000      1.000 0.00  1 0.00
#> SRR1168740     2   0.000      1.000 0.00  1 0.00
#> SRR1168741     2   0.000      1.000 0.00  1 0.00
#> SRR1168742     2   0.000      1.000 0.00  1 0.00
#> SRR1168743     2   0.000      1.000 0.00  1 0.00
#> SRR1168744     2   0.000      1.000 0.00  1 0.00
#> SRR1168745     2   0.000      1.000 0.00  1 0.00
#> SRR1168746     2   0.000      1.000 0.00  1 0.00
#> SRR1168747     2   0.000      1.000 0.00  1 0.00
#> SRR1168748     2   0.000      1.000 0.00  1 0.00
#> SRR1168749     2   0.000      1.000 0.00  1 0.00
#> SRR1168750     2   0.000      1.000 0.00  1 0.00
#> SRR1168751     2   0.000      1.000 0.00  1 0.00
#> SRR1168752     2   0.000      1.000 0.00  1 0.00
#> SRR1168753     2   0.000      1.000 0.00  1 0.00
#> SRR1168754     2   0.000      1.000 0.00  1 0.00
#> SRR1168755     2   0.000      1.000 0.00  1 0.00
#> SRR1168756     2   0.000      1.000 0.00  1 0.00
#> SRR1168757     2   0.000      1.000 0.00  1 0.00
#> SRR1168758     2   0.000      1.000 0.00  1 0.00
#> SRR1168759     2   0.000      1.000 0.00  1 0.00
#> SRR1168760     2   0.000      1.000 0.00  1 0.00
#> SRR1168761     3   0.000      0.950 0.00  0 1.00
#> SRR1168762     3   0.000      0.950 0.00  0 1.00
#> SRR1168763     3   0.000      0.950 0.00  0 1.00
#> SRR1168764     3   0.000      0.950 0.00  0 1.00
#> SRR1168765     3   0.000      0.950 0.00  0 1.00
#> SRR1168766     3   0.000      0.950 0.00  0 1.00
#> SRR1168767     3   0.000      0.950 0.00  0 1.00
#> SRR1168768     3   0.000      0.950 0.00  0 1.00
#> SRR1168769     3   0.334      0.911 0.12  0 0.88
#> SRR1168770     3   0.334      0.911 0.12  0 0.88
#> SRR1168771     3   0.334      0.911 0.12  0 0.88
#> SRR1168772     3   0.334      0.911 0.12  0 0.88
#> SRR1168773     3   0.334      0.911 0.12  0 0.88
#> SRR1168774     3   0.334      0.911 0.12  0 0.88
#> SRR1168775     3   0.334      0.911 0.12  0 0.88
#> SRR1168776     3   0.334      0.911 0.12  0 0.88
#> SRR1168777     3   0.334      0.911 0.12  0 0.88

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette p1 p2 p3 p4
#> SRR1168715     3       0          1  0  0  1  0
#> SRR1168716     3       0          1  0  0  1  0
#> SRR1168717     3       0          1  0  0  1  0
#> SRR1168718     3       0          1  0  0  1  0
#> SRR1168719     3       0          1  0  0  1  0
#> SRR1168720     3       0          1  0  0  1  0
#> SRR1168721     3       0          1  0  0  1  0
#> SRR1168722     1       0          1  1  0  0  0
#> SRR1168723     1       0          1  1  0  0  0
#> SRR1168724     1       0          1  1  0  0  0
#> SRR1168725     1       0          1  1  0  0  0
#> SRR1168726     1       0          1  1  0  0  0
#> SRR1168727     1       0          1  1  0  0  0
#> SRR1168728     1       0          1  1  0  0  0
#> SRR1168729     1       0          1  1  0  0  0
#> SRR1168730     1       0          1  1  0  0  0
#> SRR1168731     1       0          1  1  0  0  0
#> SRR1168732     1       0          1  1  0  0  0
#> SRR1168733     2       0          1  0  1  0  0
#> SRR1168734     2       0          1  0  1  0  0
#> SRR1168735     2       0          1  0  1  0  0
#> SRR1168736     2       0          1  0  1  0  0
#> SRR1168737     2       0          1  0  1  0  0
#> SRR1168738     2       0          1  0  1  0  0
#> SRR1168739     2       0          1  0  1  0  0
#> SRR1168740     2       0          1  0  1  0  0
#> SRR1168741     2       0          1  0  1  0  0
#> SRR1168742     2       0          1  0  1  0  0
#> SRR1168743     2       0          1  0  1  0  0
#> SRR1168744     2       0          1  0  1  0  0
#> SRR1168745     2       0          1  0  1  0  0
#> SRR1168746     2       0          1  0  1  0  0
#> SRR1168747     2       0          1  0  1  0  0
#> SRR1168748     2       0          1  0  1  0  0
#> SRR1168749     2       0          1  0  1  0  0
#> SRR1168750     2       0          1  0  1  0  0
#> SRR1168751     2       0          1  0  1  0  0
#> SRR1168752     2       0          1  0  1  0  0
#> SRR1168753     2       0          1  0  1  0  0
#> SRR1168754     2       0          1  0  1  0  0
#> SRR1168755     2       0          1  0  1  0  0
#> SRR1168756     2       0          1  0  1  0  0
#> SRR1168757     2       0          1  0  1  0  0
#> SRR1168758     2       0          1  0  1  0  0
#> SRR1168759     2       0          1  0  1  0  0
#> SRR1168760     2       0          1  0  1  0  0
#> SRR1168761     3       0          1  0  0  1  0
#> SRR1168762     3       0          1  0  0  1  0
#> SRR1168763     3       0          1  0  0  1  0
#> SRR1168764     3       0          1  0  0  1  0
#> SRR1168765     3       0          1  0  0  1  0
#> SRR1168766     3       0          1  0  0  1  0
#> SRR1168767     3       0          1  0  0  1  0
#> SRR1168768     3       0          1  0  0  1  0
#> SRR1168769     4       0          1  0  0  0  1
#> SRR1168770     4       0          1  0  0  0  1
#> SRR1168771     4       0          1  0  0  0  1
#> SRR1168772     4       0          1  0  0  0  1
#> SRR1168773     4       0          1  0  0  0  1
#> SRR1168774     4       0          1  0  0  0  1
#> SRR1168775     4       0          1  0  0  0  1
#> SRR1168776     4       0          1  0  0  0  1
#> SRR1168777     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
#> SRR1168715     5       0          1  0  0  0  0  1
#> SRR1168716     5       0          1  0  0  0  0  1
#> SRR1168717     5       0          1  0  0  0  0  1
#> SRR1168718     5       0          1  0  0  0  0  1
#> SRR1168719     5       0          1  0  0  0  0  1
#> SRR1168720     5       0          1  0  0  0  0  1
#> SRR1168721     5       0          1  0  0  0  0  1
#> SRR1168722     1       0          1  1  0  0  0  0
#> SRR1168723     1       0          1  1  0  0  0  0
#> SRR1168724     1       0          1  1  0  0  0  0
#> SRR1168725     1       0          1  1  0  0  0  0
#> SRR1168726     1       0          1  1  0  0  0  0
#> SRR1168727     1       0          1  1  0  0  0  0
#> SRR1168728     1       0          1  1  0  0  0  0
#> SRR1168729     1       0          1  1  0  0  0  0
#> SRR1168730     1       0          1  1  0  0  0  0
#> SRR1168731     1       0          1  1  0  0  0  0
#> SRR1168732     1       0          1  1  0  0  0  0
#> SRR1168733     2       0          1  0  1  0  0  0
#> SRR1168734     2       0          1  0  1  0  0  0
#> SRR1168735     2       0          1  0  1  0  0  0
#> SRR1168736     2       0          1  0  1  0  0  0
#> SRR1168737     2       0          1  0  1  0  0  0
#> SRR1168738     2       0          1  0  1  0  0  0
#> SRR1168739     2       0          1  0  1  0  0  0
#> SRR1168740     2       0          1  0  1  0  0  0
#> SRR1168741     2       0          1  0  1  0  0  0
#> SRR1168742     2       0          1  0  1  0  0  0
#> SRR1168743     2       0          1  0  1  0  0  0
#> SRR1168744     2       0          1  0  1  0  0  0
#> SRR1168745     2       0          1  0  1  0  0  0
#> SRR1168746     2       0          1  0  1  0  0  0
#> SRR1168747     2       0          1  0  1  0  0  0
#> SRR1168748     2       0          1  0  1  0  0  0
#> SRR1168749     2       0          1  0  1  0  0  0
#> SRR1168750     2       0          1  0  1  0  0  0
#> SRR1168751     2       0          1  0  1  0  0  0
#> SRR1168752     2       0          1  0  1  0  0  0
#> SRR1168753     2       0          1  0  1  0  0  0
#> SRR1168754     2       0          1  0  1  0  0  0
#> SRR1168755     2       0          1  0  1  0  0  0
#> SRR1168756     2       0          1  0  1  0  0  0
#> SRR1168757     2       0          1  0  1  0  0  0
#> SRR1168758     2       0          1  0  1  0  0  0
#> SRR1168759     2       0          1  0  1  0  0  0
#> SRR1168760     2       0          1  0  1  0  0  0
#> SRR1168761     3       0          1  0  0  1  0  0
#> SRR1168762     3       0          1  0  0  1  0  0
#> SRR1168763     3       0          1  0  0  1  0  0
#> SRR1168764     3       0          1  0  0  1  0  0
#> SRR1168765     3       0          1  0  0  1  0  0
#> SRR1168766     3       0          1  0  0  1  0  0
#> SRR1168767     3       0          1  0  0  1  0  0
#> SRR1168768     3       0          1  0  0  1  0  0
#> SRR1168769     4       0          1  0  0  0  1  0
#> SRR1168770     4       0          1  0  0  0  1  0
#> SRR1168771     4       0          1  0  0  0  1  0
#> SRR1168772     4       0          1  0  0  0  1  0
#> SRR1168773     4       0          1  0  0  0  1  0
#> SRR1168774     4       0          1  0  0  0  1  0
#> SRR1168775     4       0          1  0  0  0  1  0
#> SRR1168776     4       0          1  0  0  0  1  0
#> SRR1168777     4       0          1  0  0  0  1  0

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1   p2    p3    p4    p5    p6
#> SRR1168715     6  0.0000      0.996 0.000 0.00 0.000 0.000 0.000 1.000
#> SRR1168716     6  0.0146      0.995 0.000 0.00 0.000 0.000 0.004 0.996
#> SRR1168717     6  0.0260      0.995 0.000 0.00 0.000 0.000 0.008 0.992
#> SRR1168718     6  0.0260      0.994 0.000 0.00 0.000 0.000 0.008 0.992
#> SRR1168719     6  0.0000      0.996 0.000 0.00 0.000 0.000 0.000 1.000
#> SRR1168720     6  0.0363      0.993 0.000 0.00 0.000 0.000 0.012 0.988
#> SRR1168721     6  0.0260      0.994 0.000 0.00 0.000 0.000 0.008 0.992
#> SRR1168722     1  0.0260      0.991 0.992 0.00 0.000 0.000 0.008 0.000
#> SRR1168723     1  0.0458      0.987 0.984 0.00 0.000 0.000 0.016 0.000
#> SRR1168724     1  0.0363      0.991 0.988 0.00 0.000 0.000 0.012 0.000
#> SRR1168725     1  0.0547      0.988 0.980 0.00 0.000 0.000 0.020 0.000
#> SRR1168726     1  0.0260      0.990 0.992 0.00 0.000 0.000 0.008 0.000
#> SRR1168727     1  0.0146      0.991 0.996 0.00 0.000 0.000 0.004 0.000
#> SRR1168728     1  0.0790      0.979 0.968 0.00 0.000 0.000 0.032 0.000
#> SRR1168729     1  0.0547      0.988 0.980 0.00 0.000 0.000 0.020 0.000
#> SRR1168730     1  0.0000      0.991 1.000 0.00 0.000 0.000 0.000 0.000
#> SRR1168731     1  0.0363      0.990 0.988 0.00 0.000 0.000 0.012 0.000
#> SRR1168732     1  0.0260      0.991 0.992 0.00 0.000 0.000 0.008 0.000
#> SRR1168733     2  0.0000      1.000 0.000 1.00 0.000 0.000 0.000 0.000
#> SRR1168734     2  0.0000      1.000 0.000 1.00 0.000 0.000 0.000 0.000
#> SRR1168735     2  0.0000      1.000 0.000 1.00 0.000 0.000 0.000 0.000
#> SRR1168736     2  0.0000      1.000 0.000 1.00 0.000 0.000 0.000 0.000
#> SRR1168737     2  0.0000      1.000 0.000 1.00 0.000 0.000 0.000 0.000
#> SRR1168738     2  0.0000      1.000 0.000 1.00 0.000 0.000 0.000 0.000
#> SRR1168739     2  0.0000      1.000 0.000 1.00 0.000 0.000 0.000 0.000
#> SRR1168740     2  0.0000      1.000 0.000 1.00 0.000 0.000 0.000 0.000
#> SRR1168741     2  0.0000      1.000 0.000 1.00 0.000 0.000 0.000 0.000
#> SRR1168742     2  0.0000      1.000 0.000 1.00 0.000 0.000 0.000 0.000
#> SRR1168743     2  0.0000      1.000 0.000 1.00 0.000 0.000 0.000 0.000
#> SRR1168744     2  0.0000      1.000 0.000 1.00 0.000 0.000 0.000 0.000
#> SRR1168745     2  0.0000      1.000 0.000 1.00 0.000 0.000 0.000 0.000
#> SRR1168746     2  0.0000      1.000 0.000 1.00 0.000 0.000 0.000 0.000
#> SRR1168747     5  0.2941      1.000 0.000 0.22 0.000 0.000 0.780 0.000
#> SRR1168748     5  0.2941      1.000 0.000 0.22 0.000 0.000 0.780 0.000
#> SRR1168749     5  0.2941      1.000 0.000 0.22 0.000 0.000 0.780 0.000
#> SRR1168750     5  0.2941      1.000 0.000 0.22 0.000 0.000 0.780 0.000
#> SRR1168751     5  0.2941      1.000 0.000 0.22 0.000 0.000 0.780 0.000
#> SRR1168752     5  0.2941      1.000 0.000 0.22 0.000 0.000 0.780 0.000
#> SRR1168753     5  0.2941      1.000 0.000 0.22 0.000 0.000 0.780 0.000
#> SRR1168754     5  0.2941      1.000 0.000 0.22 0.000 0.000 0.780 0.000
#> SRR1168755     5  0.2941      1.000 0.000 0.22 0.000 0.000 0.780 0.000
#> SRR1168756     5  0.2941      1.000 0.000 0.22 0.000 0.000 0.780 0.000
#> SRR1168757     5  0.2941      1.000 0.000 0.22 0.000 0.000 0.780 0.000
#> SRR1168758     5  0.2941      1.000 0.000 0.22 0.000 0.000 0.780 0.000
#> SRR1168759     5  0.2941      1.000 0.000 0.22 0.000 0.000 0.780 0.000
#> SRR1168760     5  0.2941      1.000 0.000 0.22 0.000 0.000 0.780 0.000
#> SRR1168761     3  0.0146      0.997 0.000 0.00 0.996 0.000 0.004 0.000
#> SRR1168762     3  0.0000      0.998 0.000 0.00 1.000 0.000 0.000 0.000
#> SRR1168763     3  0.0146      0.997 0.000 0.00 0.996 0.000 0.004 0.000
#> SRR1168764     3  0.0000      0.998 0.000 0.00 1.000 0.000 0.000 0.000
#> SRR1168765     3  0.0260      0.995 0.000 0.00 0.992 0.000 0.008 0.000
#> SRR1168766     3  0.0000      0.998 0.000 0.00 1.000 0.000 0.000 0.000
#> SRR1168767     3  0.0000      0.998 0.000 0.00 1.000 0.000 0.000 0.000
#> SRR1168768     3  0.0000      0.998 0.000 0.00 1.000 0.000 0.000 0.000
#> SRR1168769     4  0.0363      0.988 0.000 0.00 0.000 0.988 0.012 0.000
#> SRR1168770     4  0.0790      0.980 0.000 0.00 0.000 0.968 0.032 0.000
#> SRR1168771     4  0.0260      0.990 0.000 0.00 0.000 0.992 0.008 0.000
#> SRR1168772     4  0.0363      0.989 0.000 0.00 0.000 0.988 0.012 0.000
#> SRR1168773     4  0.0363      0.989 0.000 0.00 0.000 0.988 0.012 0.000
#> SRR1168774     4  0.0260      0.990 0.000 0.00 0.000 0.992 0.008 0.000
#> SRR1168775     4  0.0713      0.982 0.000 0.00 0.000 0.972 0.028 0.000
#> SRR1168776     4  0.0000      0.990 0.000 0.00 0.000 1.000 0.000 0.000
#> SRR1168777     4  0.0146      0.990 0.000 0.00 0.000 0.996 0.004 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-mclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-mclust-collect-classes

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


MAD:NMF**

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

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

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

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

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

collect_plots(res)

plot of chunk MAD-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.5023 0.498   0.498
#> 3 3 0.846           1.000       0.941         0.2299 0.846   0.692
#> 4 4 0.964           0.980       0.965         0.0538 1.000   1.000
#> 5 5 0.821           0.865       0.862         0.0855 1.000   1.000
#> 6 6 0.786           0.839       0.767         0.0476 0.949   0.853

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
#> SRR1168715     1       0          1  1  0
#> SRR1168716     1       0          1  1  0
#> SRR1168717     1       0          1  1  0
#> SRR1168718     1       0          1  1  0
#> SRR1168719     1       0          1  1  0
#> SRR1168720     1       0          1  1  0
#> SRR1168721     1       0          1  1  0
#> SRR1168722     1       0          1  1  0
#> SRR1168723     1       0          1  1  0
#> SRR1168724     1       0          1  1  0
#> SRR1168725     1       0          1  1  0
#> SRR1168726     1       0          1  1  0
#> SRR1168727     1       0          1  1  0
#> SRR1168728     1       0          1  1  0
#> SRR1168729     1       0          1  1  0
#> SRR1168730     1       0          1  1  0
#> SRR1168731     1       0          1  1  0
#> SRR1168732     1       0          1  1  0
#> SRR1168733     2       0          1  0  1
#> SRR1168734     2       0          1  0  1
#> SRR1168735     2       0          1  0  1
#> SRR1168736     2       0          1  0  1
#> SRR1168737     2       0          1  0  1
#> SRR1168738     2       0          1  0  1
#> SRR1168739     2       0          1  0  1
#> SRR1168740     2       0          1  0  1
#> SRR1168741     2       0          1  0  1
#> SRR1168742     2       0          1  0  1
#> SRR1168743     2       0          1  0  1
#> SRR1168744     2       0          1  0  1
#> SRR1168745     2       0          1  0  1
#> SRR1168746     2       0          1  0  1
#> SRR1168747     2       0          1  0  1
#> SRR1168748     2       0          1  0  1
#> SRR1168749     2       0          1  0  1
#> SRR1168750     2       0          1  0  1
#> SRR1168751     2       0          1  0  1
#> SRR1168752     2       0          1  0  1
#> SRR1168753     2       0          1  0  1
#> SRR1168754     2       0          1  0  1
#> SRR1168755     2       0          1  0  1
#> SRR1168756     2       0          1  0  1
#> SRR1168757     2       0          1  0  1
#> SRR1168758     2       0          1  0  1
#> SRR1168759     2       0          1  0  1
#> SRR1168760     2       0          1  0  1
#> SRR1168761     1       0          1  1  0
#> SRR1168762     1       0          1  1  0
#> SRR1168763     1       0          1  1  0
#> SRR1168764     1       0          1  1  0
#> SRR1168765     1       0          1  1  0
#> SRR1168766     1       0          1  1  0
#> SRR1168767     1       0          1  1  0
#> SRR1168768     1       0          1  1  0
#> SRR1168769     1       0          1  1  0
#> SRR1168770     1       0          1  1  0
#> SRR1168771     1       0          1  1  0
#> SRR1168772     1       0          1  1  0
#> SRR1168773     1       0          1  1  0
#> SRR1168774     1       0          1  1  0
#> SRR1168775     1       0          1  1  0
#> SRR1168776     1       0          1  1  0
#> SRR1168777     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1 p2    p3
#> SRR1168715     3    0.00          1 0.000  0 1.000
#> SRR1168716     3    0.00          1 0.000  0 1.000
#> SRR1168717     3    0.00          1 0.000  0 1.000
#> SRR1168718     3    0.00          1 0.000  0 1.000
#> SRR1168719     3    0.00          1 0.000  0 1.000
#> SRR1168720     3    0.00          1 0.000  0 1.000
#> SRR1168721     3    0.00          1 0.000  0 1.000
#> SRR1168722     1    0.51          1 0.752  0 0.248
#> SRR1168723     1    0.51          1 0.752  0 0.248
#> SRR1168724     1    0.51          1 0.752  0 0.248
#> SRR1168725     1    0.51          1 0.752  0 0.248
#> SRR1168726     1    0.51          1 0.752  0 0.248
#> SRR1168727     1    0.51          1 0.752  0 0.248
#> SRR1168728     1    0.51          1 0.752  0 0.248
#> SRR1168729     1    0.51          1 0.752  0 0.248
#> SRR1168730     1    0.51          1 0.752  0 0.248
#> SRR1168731     1    0.51          1 0.752  0 0.248
#> SRR1168732     1    0.51          1 0.752  0 0.248
#> SRR1168733     2    0.00          1 0.000  1 0.000
#> SRR1168734     2    0.00          1 0.000  1 0.000
#> SRR1168735     2    0.00          1 0.000  1 0.000
#> SRR1168736     2    0.00          1 0.000  1 0.000
#> SRR1168737     2    0.00          1 0.000  1 0.000
#> SRR1168738     2    0.00          1 0.000  1 0.000
#> SRR1168739     2    0.00          1 0.000  1 0.000
#> SRR1168740     2    0.00          1 0.000  1 0.000
#> SRR1168741     2    0.00          1 0.000  1 0.000
#> SRR1168742     2    0.00          1 0.000  1 0.000
#> SRR1168743     2    0.00          1 0.000  1 0.000
#> SRR1168744     2    0.00          1 0.000  1 0.000
#> SRR1168745     2    0.00          1 0.000  1 0.000
#> SRR1168746     2    0.00          1 0.000  1 0.000
#> SRR1168747     2    0.00          1 0.000  1 0.000
#> SRR1168748     2    0.00          1 0.000  1 0.000
#> SRR1168749     2    0.00          1 0.000  1 0.000
#> SRR1168750     2    0.00          1 0.000  1 0.000
#> SRR1168751     2    0.00          1 0.000  1 0.000
#> SRR1168752     2    0.00          1 0.000  1 0.000
#> SRR1168753     2    0.00          1 0.000  1 0.000
#> SRR1168754     2    0.00          1 0.000  1 0.000
#> SRR1168755     2    0.00          1 0.000  1 0.000
#> SRR1168756     2    0.00          1 0.000  1 0.000
#> SRR1168757     2    0.00          1 0.000  1 0.000
#> SRR1168758     2    0.00          1 0.000  1 0.000
#> SRR1168759     2    0.00          1 0.000  1 0.000
#> SRR1168760     2    0.00          1 0.000  1 0.000
#> SRR1168761     3    0.00          1 0.000  0 1.000
#> SRR1168762     3    0.00          1 0.000  0 1.000
#> SRR1168763     3    0.00          1 0.000  0 1.000
#> SRR1168764     3    0.00          1 0.000  0 1.000
#> SRR1168765     3    0.00          1 0.000  0 1.000
#> SRR1168766     3    0.00          1 0.000  0 1.000
#> SRR1168767     3    0.00          1 0.000  0 1.000
#> SRR1168768     3    0.00          1 0.000  0 1.000
#> SRR1168769     1    0.51          1 0.752  0 0.248
#> SRR1168770     1    0.51          1 0.752  0 0.248
#> SRR1168771     1    0.51          1 0.752  0 0.248
#> SRR1168772     1    0.51          1 0.752  0 0.248
#> SRR1168773     1    0.51          1 0.752  0 0.248
#> SRR1168774     1    0.51          1 0.752  0 0.248
#> SRR1168775     1    0.51          1 0.752  0 0.248
#> SRR1168776     1    0.51          1 0.752  0 0.248
#> SRR1168777     1    0.51          1 0.752  0 0.248

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1168715     3  0.3372      0.964 0.096 0.000 0.868 0.036
#> SRR1168716     3  0.3372      0.964 0.096 0.000 0.868 0.036
#> SRR1168717     3  0.3372      0.964 0.096 0.000 0.868 0.036
#> SRR1168718     3  0.3372      0.964 0.096 0.000 0.868 0.036
#> SRR1168719     3  0.3372      0.964 0.096 0.000 0.868 0.036
#> SRR1168720     3  0.3372      0.964 0.096 0.000 0.868 0.036
#> SRR1168721     3  0.3372      0.964 0.096 0.000 0.868 0.036
#> SRR1168722     1  0.0188      0.979 0.996 0.000 0.004 0.000
#> SRR1168723     1  0.0376      0.979 0.992 0.000 0.004 0.004
#> SRR1168724     1  0.0188      0.979 0.996 0.000 0.004 0.000
#> SRR1168725     1  0.0188      0.979 0.996 0.000 0.004 0.000
#> SRR1168726     1  0.0188      0.979 0.996 0.000 0.004 0.000
#> SRR1168727     1  0.0188      0.979 0.996 0.000 0.004 0.000
#> SRR1168728     1  0.0188      0.979 0.996 0.000 0.004 0.000
#> SRR1168729     1  0.0188      0.979 0.996 0.000 0.004 0.000
#> SRR1168730     1  0.0188      0.979 0.996 0.000 0.004 0.000
#> SRR1168731     1  0.0188      0.979 0.996 0.000 0.004 0.000
#> SRR1168732     1  0.0188      0.979 0.996 0.000 0.004 0.000
#> SRR1168733     2  0.0000      0.990 0.000 1.000 0.000 0.000
#> SRR1168734     2  0.0000      0.990 0.000 1.000 0.000 0.000
#> SRR1168735     2  0.0000      0.990 0.000 1.000 0.000 0.000
#> SRR1168736     2  0.0000      0.990 0.000 1.000 0.000 0.000
#> SRR1168737     2  0.0000      0.990 0.000 1.000 0.000 0.000
#> SRR1168738     2  0.0000      0.990 0.000 1.000 0.000 0.000
#> SRR1168739     2  0.0000      0.990 0.000 1.000 0.000 0.000
#> SRR1168740     2  0.0000      0.990 0.000 1.000 0.000 0.000
#> SRR1168741     2  0.0000      0.990 0.000 1.000 0.000 0.000
#> SRR1168742     2  0.0000      0.990 0.000 1.000 0.000 0.000
#> SRR1168743     2  0.0000      0.990 0.000 1.000 0.000 0.000
#> SRR1168744     2  0.0000      0.990 0.000 1.000 0.000 0.000
#> SRR1168745     2  0.0000      0.990 0.000 1.000 0.000 0.000
#> SRR1168746     2  0.0000      0.990 0.000 1.000 0.000 0.000
#> SRR1168747     2  0.0817      0.990 0.000 0.976 0.000 0.024
#> SRR1168748     2  0.0817      0.990 0.000 0.976 0.000 0.024
#> SRR1168749     2  0.0817      0.990 0.000 0.976 0.000 0.024
#> SRR1168750     2  0.0817      0.990 0.000 0.976 0.000 0.024
#> SRR1168751     2  0.0817      0.990 0.000 0.976 0.000 0.024
#> SRR1168752     2  0.0817      0.990 0.000 0.976 0.000 0.024
#> SRR1168753     2  0.0817      0.990 0.000 0.976 0.000 0.024
#> SRR1168754     2  0.0817      0.990 0.000 0.976 0.000 0.024
#> SRR1168755     2  0.0817      0.990 0.000 0.976 0.000 0.024
#> SRR1168756     2  0.0817      0.990 0.000 0.976 0.000 0.024
#> SRR1168757     2  0.0817      0.990 0.000 0.976 0.000 0.024
#> SRR1168758     2  0.0817      0.990 0.000 0.976 0.000 0.024
#> SRR1168759     2  0.0817      0.990 0.000 0.976 0.000 0.024
#> SRR1168760     2  0.0817      0.990 0.000 0.976 0.000 0.024
#> SRR1168761     3  0.1557      0.969 0.056 0.000 0.944 0.000
#> SRR1168762     3  0.1557      0.969 0.056 0.000 0.944 0.000
#> SRR1168763     3  0.1557      0.969 0.056 0.000 0.944 0.000
#> SRR1168764     3  0.1557      0.969 0.056 0.000 0.944 0.000
#> SRR1168765     3  0.1557      0.969 0.056 0.000 0.944 0.000
#> SRR1168766     3  0.1557      0.969 0.056 0.000 0.944 0.000
#> SRR1168767     3  0.1557      0.969 0.056 0.000 0.944 0.000
#> SRR1168768     3  0.1557      0.969 0.056 0.000 0.944 0.000
#> SRR1168769     1  0.1584      0.974 0.952 0.000 0.012 0.036
#> SRR1168770     1  0.1488      0.975 0.956 0.000 0.012 0.032
#> SRR1168771     1  0.1488      0.975 0.956 0.000 0.012 0.032
#> SRR1168772     1  0.1677      0.972 0.948 0.000 0.012 0.040
#> SRR1168773     1  0.1677      0.972 0.948 0.000 0.012 0.040
#> SRR1168774     1  0.1584      0.974 0.952 0.000 0.012 0.036
#> SRR1168775     1  0.1584      0.974 0.952 0.000 0.012 0.036
#> SRR1168776     1  0.1677      0.972 0.948 0.000 0.012 0.040
#> SRR1168777     1  0.1488      0.975 0.956 0.000 0.012 0.032

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3 p4    p5
#> SRR1168715     3  0.3262      0.924 0.036 0.000 0.840 NA 0.000
#> SRR1168716     3  0.3262      0.924 0.036 0.000 0.840 NA 0.000
#> SRR1168717     3  0.3262      0.924 0.036 0.000 0.840 NA 0.000
#> SRR1168718     3  0.3262      0.924 0.036 0.000 0.840 NA 0.000
#> SRR1168719     3  0.3262      0.924 0.036 0.000 0.840 NA 0.000
#> SRR1168720     3  0.3339      0.922 0.040 0.000 0.836 NA 0.000
#> SRR1168721     3  0.3400      0.919 0.036 0.000 0.828 NA 0.000
#> SRR1168722     1  0.0290      0.859 0.992 0.000 0.000 NA 0.000
#> SRR1168723     1  0.0290      0.861 0.992 0.000 0.000 NA 0.000
#> SRR1168724     1  0.0404      0.858 0.988 0.000 0.000 NA 0.000
#> SRR1168725     1  0.0290      0.859 0.992 0.000 0.000 NA 0.000
#> SRR1168726     1  0.0000      0.861 1.000 0.000 0.000 NA 0.000
#> SRR1168727     1  0.0000      0.861 1.000 0.000 0.000 NA 0.000
#> SRR1168728     1  0.0162      0.860 0.996 0.000 0.000 NA 0.000
#> SRR1168729     1  0.0162      0.860 0.996 0.000 0.000 NA 0.000
#> SRR1168730     1  0.0000      0.861 1.000 0.000 0.000 NA 0.000
#> SRR1168731     1  0.0000      0.861 1.000 0.000 0.000 NA 0.000
#> SRR1168732     1  0.0290      0.859 0.992 0.000 0.000 NA 0.000
#> SRR1168733     2  0.3876      0.849 0.000 0.684 0.000 NA 0.316
#> SRR1168734     2  0.3876      0.849 0.000 0.684 0.000 NA 0.316
#> SRR1168735     2  0.3876      0.849 0.000 0.684 0.000 NA 0.316
#> SRR1168736     2  0.3876      0.849 0.000 0.684 0.000 NA 0.316
#> SRR1168737     2  0.3876      0.849 0.000 0.684 0.000 NA 0.316
#> SRR1168738     2  0.3876      0.849 0.000 0.684 0.000 NA 0.316
#> SRR1168739     2  0.3876      0.849 0.000 0.684 0.000 NA 0.316
#> SRR1168740     2  0.3876      0.849 0.000 0.684 0.000 NA 0.316
#> SRR1168741     2  0.3876      0.849 0.000 0.684 0.000 NA 0.316
#> SRR1168742     2  0.3876      0.849 0.000 0.684 0.000 NA 0.316
#> SRR1168743     2  0.3876      0.849 0.000 0.684 0.000 NA 0.316
#> SRR1168744     2  0.3876      0.849 0.000 0.684 0.000 NA 0.316
#> SRR1168745     2  0.3876      0.849 0.000 0.684 0.000 NA 0.316
#> SRR1168746     2  0.3876      0.849 0.000 0.684 0.000 NA 0.316
#> SRR1168747     2  0.0000      0.849 0.000 1.000 0.000 NA 0.000
#> SRR1168748     2  0.0000      0.849 0.000 1.000 0.000 NA 0.000
#> SRR1168749     2  0.0000      0.849 0.000 1.000 0.000 NA 0.000
#> SRR1168750     2  0.0000      0.849 0.000 1.000 0.000 NA 0.000
#> SRR1168751     2  0.0000      0.849 0.000 1.000 0.000 NA 0.000
#> SRR1168752     2  0.0000      0.849 0.000 1.000 0.000 NA 0.000
#> SRR1168753     2  0.0000      0.849 0.000 1.000 0.000 NA 0.000
#> SRR1168754     2  0.0000      0.849 0.000 1.000 0.000 NA 0.000
#> SRR1168755     2  0.0000      0.849 0.000 1.000 0.000 NA 0.000
#> SRR1168756     2  0.0000      0.849 0.000 1.000 0.000 NA 0.000
#> SRR1168757     2  0.0000      0.849 0.000 1.000 0.000 NA 0.000
#> SRR1168758     2  0.0000      0.849 0.000 1.000 0.000 NA 0.000
#> SRR1168759     2  0.0000      0.849 0.000 1.000 0.000 NA 0.000
#> SRR1168760     2  0.0000      0.849 0.000 1.000 0.000 NA 0.000
#> SRR1168761     3  0.0290      0.931 0.000 0.000 0.992 NA 0.000
#> SRR1168762     3  0.0000      0.932 0.000 0.000 1.000 NA 0.000
#> SRR1168763     3  0.0404      0.931 0.000 0.000 0.988 NA 0.000
#> SRR1168764     3  0.0510      0.928 0.000 0.000 0.984 NA 0.000
#> SRR1168765     3  0.0510      0.930 0.000 0.000 0.984 NA 0.000
#> SRR1168766     3  0.0290      0.931 0.000 0.000 0.992 NA 0.000
#> SRR1168767     3  0.0404      0.930 0.000 0.000 0.988 NA 0.000
#> SRR1168768     3  0.0162      0.931 0.000 0.000 0.996 NA 0.000
#> SRR1168769     1  0.4887      0.819 0.660 0.000 0.052 NA 0.000
#> SRR1168770     1  0.4730      0.826 0.688 0.000 0.052 NA 0.000
#> SRR1168771     1  0.4844      0.822 0.668 0.000 0.052 NA 0.000
#> SRR1168772     1  0.4989      0.813 0.648 0.000 0.056 NA 0.000
#> SRR1168773     1  0.4949      0.817 0.656 0.000 0.056 NA 0.000
#> SRR1168774     1  0.4866      0.820 0.664 0.000 0.052 NA 0.000
#> SRR1168775     1  0.4887      0.819 0.660 0.000 0.052 NA 0.000
#> SRR1168776     1  0.5027      0.809 0.640 0.000 0.056 NA 0.000
#> SRR1168777     1  0.4817      0.824 0.680 0.000 0.056 NA 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
#> SRR1168715     3  0.5564      0.799 0.044 0.000 0.640 0.000 NA 0.196
#> SRR1168716     3  0.5552      0.799 0.044 0.000 0.640 0.000 NA 0.200
#> SRR1168717     3  0.5558      0.800 0.048 0.000 0.644 0.000 NA 0.192
#> SRR1168718     3  0.5643      0.798 0.056 0.000 0.640 0.000 NA 0.188
#> SRR1168719     3  0.5615      0.799 0.052 0.000 0.640 0.000 NA 0.192
#> SRR1168720     3  0.5681      0.797 0.056 0.000 0.636 0.000 NA 0.188
#> SRR1168721     3  0.5677      0.793 0.044 0.000 0.624 0.000 NA 0.208
#> SRR1168722     1  0.0405      0.981 0.988 0.000 0.000 0.008 NA 0.000
#> SRR1168723     1  0.0000      0.983 1.000 0.000 0.000 0.000 NA 0.000
#> SRR1168724     1  0.1262      0.947 0.956 0.000 0.000 0.016 NA 0.020
#> SRR1168725     1  0.0405      0.979 0.988 0.000 0.000 0.004 NA 0.000
#> SRR1168726     1  0.0146      0.982 0.996 0.000 0.000 0.004 NA 0.000
#> SRR1168727     1  0.0363      0.978 0.988 0.000 0.000 0.012 NA 0.000
#> SRR1168728     1  0.0146      0.983 0.996 0.000 0.000 0.004 NA 0.000
#> SRR1168729     1  0.0405      0.983 0.988 0.000 0.000 0.008 NA 0.000
#> SRR1168730     1  0.0260      0.978 0.992 0.000 0.000 0.008 NA 0.000
#> SRR1168731     1  0.0146      0.982 0.996 0.000 0.000 0.004 NA 0.000
#> SRR1168732     1  0.0622      0.976 0.980 0.000 0.000 0.012 NA 0.000
#> SRR1168733     2  0.3862      0.752 0.000 0.524 0.000 0.000 NA 0.476
#> SRR1168734     2  0.3868      0.742 0.000 0.504 0.000 0.000 NA 0.496
#> SRR1168735     2  0.3860      0.754 0.000 0.528 0.000 0.000 NA 0.472
#> SRR1168736     2  0.3847      0.756 0.000 0.544 0.000 0.000 NA 0.456
#> SRR1168737     2  0.3860      0.754 0.000 0.528 0.000 0.000 NA 0.472
#> SRR1168738     2  0.3860      0.754 0.000 0.528 0.000 0.000 NA 0.472
#> SRR1168739     2  0.3866      0.748 0.000 0.516 0.000 0.000 NA 0.484
#> SRR1168740     2  0.3851      0.755 0.000 0.540 0.000 0.000 NA 0.460
#> SRR1168741     2  0.3864      0.750 0.000 0.520 0.000 0.000 NA 0.480
#> SRR1168742     2  0.3857      0.755 0.000 0.532 0.000 0.000 NA 0.468
#> SRR1168743     2  0.3860      0.754 0.000 0.528 0.000 0.000 NA 0.472
#> SRR1168744     2  0.3862      0.752 0.000 0.524 0.000 0.000 NA 0.476
#> SRR1168745     2  0.3864      0.751 0.000 0.520 0.000 0.000 NA 0.480
#> SRR1168746     2  0.3867      0.746 0.000 0.512 0.000 0.000 NA 0.488
#> SRR1168747     2  0.0000      0.762 0.000 1.000 0.000 0.000 NA 0.000
#> SRR1168748     2  0.0000      0.762 0.000 1.000 0.000 0.000 NA 0.000
#> SRR1168749     2  0.0000      0.762 0.000 1.000 0.000 0.000 NA 0.000
#> SRR1168750     2  0.0000      0.762 0.000 1.000 0.000 0.000 NA 0.000
#> SRR1168751     2  0.0000      0.762 0.000 1.000 0.000 0.000 NA 0.000
#> SRR1168752     2  0.0000      0.762 0.000 1.000 0.000 0.000 NA 0.000
#> SRR1168753     2  0.0000      0.762 0.000 1.000 0.000 0.000 NA 0.000
#> SRR1168754     2  0.0000      0.762 0.000 1.000 0.000 0.000 NA 0.000
#> SRR1168755     2  0.0000      0.762 0.000 1.000 0.000 0.000 NA 0.000
#> SRR1168756     2  0.0000      0.762 0.000 1.000 0.000 0.000 NA 0.000
#> SRR1168757     2  0.0000      0.762 0.000 1.000 0.000 0.000 NA 0.000
#> SRR1168758     2  0.0000      0.762 0.000 1.000 0.000 0.000 NA 0.000
#> SRR1168759     2  0.0000      0.762 0.000 1.000 0.000 0.000 NA 0.000
#> SRR1168760     2  0.0000      0.762 0.000 1.000 0.000 0.000 NA 0.000
#> SRR1168761     3  0.0405      0.815 0.004 0.000 0.988 0.008 NA 0.000
#> SRR1168762     3  0.0291      0.816 0.004 0.000 0.992 0.004 NA 0.000
#> SRR1168763     3  0.0405      0.815 0.004 0.000 0.988 0.008 NA 0.000
#> SRR1168764     3  0.0508      0.812 0.004 0.000 0.984 0.012 NA 0.000
#> SRR1168765     3  0.0508      0.812 0.004 0.000 0.984 0.012 NA 0.000
#> SRR1168766     3  0.0405      0.815 0.004 0.000 0.988 0.008 NA 0.000
#> SRR1168767     3  0.0405      0.815 0.004 0.000 0.988 0.008 NA 0.000
#> SRR1168768     3  0.0291      0.816 0.004 0.000 0.992 0.004 NA 0.000
#> SRR1168769     4  0.5541      0.984 0.392 0.000 0.136 0.472 NA 0.000
#> SRR1168770     4  0.5545      0.983 0.396 0.000 0.136 0.468 NA 0.000
#> SRR1168771     4  0.5517      0.982 0.396 0.000 0.132 0.472 NA 0.000
#> SRR1168772     4  0.5521      0.974 0.376 0.000 0.136 0.488 NA 0.000
#> SRR1168773     4  0.5537      0.983 0.388 0.000 0.136 0.476 NA 0.000
#> SRR1168774     4  0.5545      0.983 0.396 0.000 0.136 0.468 NA 0.000
#> SRR1168775     4  0.5545      0.982 0.396 0.000 0.136 0.468 NA 0.000
#> SRR1168776     4  0.5543      0.971 0.372 0.000 0.140 0.488 NA 0.000
#> SRR1168777     4  0.5503      0.979 0.384 0.000 0.132 0.484 NA 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 14158 rows and 63 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.5023 0.498   0.498
#> 3 3 1.000           1.000       1.000         0.3055 0.846   0.692
#> 4 4 0.921           0.946       0.913         0.0552 0.971   0.917
#> 5 5 1.000           1.000       1.000         0.0623 0.949   0.840
#> 6 6 1.000           1.000       1.000         0.1364 0.900   0.622

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
#> SRR1168715     1       0          1  1  0
#> SRR1168716     1       0          1  1  0
#> SRR1168717     1       0          1  1  0
#> SRR1168718     1       0          1  1  0
#> SRR1168719     1       0          1  1  0
#> SRR1168720     1       0          1  1  0
#> SRR1168721     1       0          1  1  0
#> SRR1168722     1       0          1  1  0
#> SRR1168723     1       0          1  1  0
#> SRR1168724     1       0          1  1  0
#> SRR1168725     1       0          1  1  0
#> SRR1168726     1       0          1  1  0
#> SRR1168727     1       0          1  1  0
#> SRR1168728     1       0          1  1  0
#> SRR1168729     1       0          1  1  0
#> SRR1168730     1       0          1  1  0
#> SRR1168731     1       0          1  1  0
#> SRR1168732     1       0          1  1  0
#> SRR1168733     2       0          1  0  1
#> SRR1168734     2       0          1  0  1
#> SRR1168735     2       0          1  0  1
#> SRR1168736     2       0          1  0  1
#> SRR1168737     2       0          1  0  1
#> SRR1168738     2       0          1  0  1
#> SRR1168739     2       0          1  0  1
#> SRR1168740     2       0          1  0  1
#> SRR1168741     2       0          1  0  1
#> SRR1168742     2       0          1  0  1
#> SRR1168743     2       0          1  0  1
#> SRR1168744     2       0          1  0  1
#> SRR1168745     2       0          1  0  1
#> SRR1168746     2       0          1  0  1
#> SRR1168747     2       0          1  0  1
#> SRR1168748     2       0          1  0  1
#> SRR1168749     2       0          1  0  1
#> SRR1168750     2       0          1  0  1
#> SRR1168751     2       0          1  0  1
#> SRR1168752     2       0          1  0  1
#> SRR1168753     2       0          1  0  1
#> SRR1168754     2       0          1  0  1
#> SRR1168755     2       0          1  0  1
#> SRR1168756     2       0          1  0  1
#> SRR1168757     2       0          1  0  1
#> SRR1168758     2       0          1  0  1
#> SRR1168759     2       0          1  0  1
#> SRR1168760     2       0          1  0  1
#> SRR1168761     1       0          1  1  0
#> SRR1168762     1       0          1  1  0
#> SRR1168763     1       0          1  1  0
#> SRR1168764     1       0          1  1  0
#> SRR1168765     1       0          1  1  0
#> SRR1168766     1       0          1  1  0
#> SRR1168767     1       0          1  1  0
#> SRR1168768     1       0          1  1  0
#> SRR1168769     1       0          1  1  0
#> SRR1168770     1       0          1  1  0
#> SRR1168771     1       0          1  1  0
#> SRR1168772     1       0          1  1  0
#> SRR1168773     1       0          1  1  0
#> SRR1168774     1       0          1  1  0
#> SRR1168775     1       0          1  1  0
#> SRR1168776     1       0          1  1  0
#> SRR1168777     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette p1 p2 p3
#> SRR1168715     3       0          1  0  0  1
#> SRR1168716     3       0          1  0  0  1
#> SRR1168717     3       0          1  0  0  1
#> SRR1168718     3       0          1  0  0  1
#> SRR1168719     3       0          1  0  0  1
#> SRR1168720     3       0          1  0  0  1
#> SRR1168721     3       0          1  0  0  1
#> SRR1168722     1       0          1  1  0  0
#> SRR1168723     1       0          1  1  0  0
#> SRR1168724     1       0          1  1  0  0
#> SRR1168725     1       0          1  1  0  0
#> SRR1168726     1       0          1  1  0  0
#> SRR1168727     1       0          1  1  0  0
#> SRR1168728     1       0          1  1  0  0
#> SRR1168729     1       0          1  1  0  0
#> SRR1168730     1       0          1  1  0  0
#> SRR1168731     1       0          1  1  0  0
#> SRR1168732     1       0          1  1  0  0
#> SRR1168733     2       0          1  0  1  0
#> SRR1168734     2       0          1  0  1  0
#> SRR1168735     2       0          1  0  1  0
#> SRR1168736     2       0          1  0  1  0
#> SRR1168737     2       0          1  0  1  0
#> SRR1168738     2       0          1  0  1  0
#> SRR1168739     2       0          1  0  1  0
#> SRR1168740     2       0          1  0  1  0
#> SRR1168741     2       0          1  0  1  0
#> SRR1168742     2       0          1  0  1  0
#> SRR1168743     2       0          1  0  1  0
#> SRR1168744     2       0          1  0  1  0
#> SRR1168745     2       0          1  0  1  0
#> SRR1168746     2       0          1  0  1  0
#> SRR1168747     2       0          1  0  1  0
#> SRR1168748     2       0          1  0  1  0
#> SRR1168749     2       0          1  0  1  0
#> SRR1168750     2       0          1  0  1  0
#> SRR1168751     2       0          1  0  1  0
#> SRR1168752     2       0          1  0  1  0
#> SRR1168753     2       0          1  0  1  0
#> SRR1168754     2       0          1  0  1  0
#> SRR1168755     2       0          1  0  1  0
#> SRR1168756     2       0          1  0  1  0
#> SRR1168757     2       0          1  0  1  0
#> SRR1168758     2       0          1  0  1  0
#> SRR1168759     2       0          1  0  1  0
#> SRR1168760     2       0          1  0  1  0
#> SRR1168761     3       0          1  0  0  1
#> SRR1168762     3       0          1  0  0  1
#> SRR1168763     3       0          1  0  0  1
#> SRR1168764     3       0          1  0  0  1
#> SRR1168765     3       0          1  0  0  1
#> SRR1168766     3       0          1  0  0  1
#> SRR1168767     3       0          1  0  0  1
#> SRR1168768     3       0          1  0  0  1
#> SRR1168769     1       0          1  1  0  0
#> SRR1168770     1       0          1  1  0  0
#> SRR1168771     1       0          1  1  0  0
#> SRR1168772     1       0          1  1  0  0
#> SRR1168773     1       0          1  1  0  0
#> SRR1168774     1       0          1  1  0  0
#> SRR1168775     1       0          1  1  0  0
#> SRR1168776     1       0          1  1  0  0
#> SRR1168777     1       0          1  1  0  0

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1 p2    p3    p4
#> SRR1168715     4   0.464      1.000 0.000  0 0.344 0.656
#> SRR1168716     4   0.464      1.000 0.000  0 0.344 0.656
#> SRR1168717     4   0.464      1.000 0.000  0 0.344 0.656
#> SRR1168718     4   0.464      1.000 0.000  0 0.344 0.656
#> SRR1168719     4   0.464      1.000 0.000  0 0.344 0.656
#> SRR1168720     4   0.464      1.000 0.000  0 0.344 0.656
#> SRR1168721     4   0.464      1.000 0.000  0 0.344 0.656
#> SRR1168722     1   0.464      0.847 0.656  0 0.000 0.344
#> SRR1168723     1   0.464      0.847 0.656  0 0.000 0.344
#> SRR1168724     1   0.464      0.847 0.656  0 0.000 0.344
#> SRR1168725     1   0.464      0.847 0.656  0 0.000 0.344
#> SRR1168726     1   0.464      0.847 0.656  0 0.000 0.344
#> SRR1168727     1   0.464      0.847 0.656  0 0.000 0.344
#> SRR1168728     1   0.464      0.847 0.656  0 0.000 0.344
#> SRR1168729     1   0.464      0.847 0.656  0 0.000 0.344
#> SRR1168730     1   0.464      0.847 0.656  0 0.000 0.344
#> SRR1168731     1   0.464      0.847 0.656  0 0.000 0.344
#> SRR1168732     1   0.464      0.847 0.656  0 0.000 0.344
#> SRR1168733     2   0.000      1.000 0.000  1 0.000 0.000
#> SRR1168734     2   0.000      1.000 0.000  1 0.000 0.000
#> SRR1168735     2   0.000      1.000 0.000  1 0.000 0.000
#> SRR1168736     2   0.000      1.000 0.000  1 0.000 0.000
#> SRR1168737     2   0.000      1.000 0.000  1 0.000 0.000
#> SRR1168738     2   0.000      1.000 0.000  1 0.000 0.000
#> SRR1168739     2   0.000      1.000 0.000  1 0.000 0.000
#> SRR1168740     2   0.000      1.000 0.000  1 0.000 0.000
#> SRR1168741     2   0.000      1.000 0.000  1 0.000 0.000
#> SRR1168742     2   0.000      1.000 0.000  1 0.000 0.000
#> SRR1168743     2   0.000      1.000 0.000  1 0.000 0.000
#> SRR1168744     2   0.000      1.000 0.000  1 0.000 0.000
#> SRR1168745     2   0.000      1.000 0.000  1 0.000 0.000
#> SRR1168746     2   0.000      1.000 0.000  1 0.000 0.000
#> SRR1168747     2   0.000      1.000 0.000  1 0.000 0.000
#> SRR1168748     2   0.000      1.000 0.000  1 0.000 0.000
#> SRR1168749     2   0.000      1.000 0.000  1 0.000 0.000
#> SRR1168750     2   0.000      1.000 0.000  1 0.000 0.000
#> SRR1168751     2   0.000      1.000 0.000  1 0.000 0.000
#> SRR1168752     2   0.000      1.000 0.000  1 0.000 0.000
#> SRR1168753     2   0.000      1.000 0.000  1 0.000 0.000
#> SRR1168754     2   0.000      1.000 0.000  1 0.000 0.000
#> SRR1168755     2   0.000      1.000 0.000  1 0.000 0.000
#> SRR1168756     2   0.000      1.000 0.000  1 0.000 0.000
#> SRR1168757     2   0.000      1.000 0.000  1 0.000 0.000
#> SRR1168758     2   0.000      1.000 0.000  1 0.000 0.000
#> SRR1168759     2   0.000      1.000 0.000  1 0.000 0.000
#> SRR1168760     2   0.000      1.000 0.000  1 0.000 0.000
#> SRR1168761     3   0.000      1.000 0.000  0 1.000 0.000
#> SRR1168762     3   0.000      1.000 0.000  0 1.000 0.000
#> SRR1168763     3   0.000      1.000 0.000  0 1.000 0.000
#> SRR1168764     3   0.000      1.000 0.000  0 1.000 0.000
#> SRR1168765     3   0.000      1.000 0.000  0 1.000 0.000
#> SRR1168766     3   0.000      1.000 0.000  0 1.000 0.000
#> SRR1168767     3   0.000      1.000 0.000  0 1.000 0.000
#> SRR1168768     3   0.000      1.000 0.000  0 1.000 0.000
#> SRR1168769     1   0.000      0.809 1.000  0 0.000 0.000
#> SRR1168770     1   0.000      0.809 1.000  0 0.000 0.000
#> SRR1168771     1   0.000      0.809 1.000  0 0.000 0.000
#> SRR1168772     1   0.000      0.809 1.000  0 0.000 0.000
#> SRR1168773     1   0.000      0.809 1.000  0 0.000 0.000
#> SRR1168774     1   0.000      0.809 1.000  0 0.000 0.000
#> SRR1168775     1   0.000      0.809 1.000  0 0.000 0.000
#> SRR1168776     1   0.000      0.809 1.000  0 0.000 0.000
#> SRR1168777     1   0.000      0.809 1.000  0 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette p1 p2 p3 p4 p5
#> SRR1168715     5       0          1  0  0  0  0  1
#> SRR1168716     5       0          1  0  0  0  0  1
#> SRR1168717     5       0          1  0  0  0  0  1
#> SRR1168718     5       0          1  0  0  0  0  1
#> SRR1168719     5       0          1  0  0  0  0  1
#> SRR1168720     5       0          1  0  0  0  0  1
#> SRR1168721     5       0          1  0  0  0  0  1
#> SRR1168722     1       0          1  1  0  0  0  0
#> SRR1168723     1       0          1  1  0  0  0  0
#> SRR1168724     1       0          1  1  0  0  0  0
#> SRR1168725     1       0          1  1  0  0  0  0
#> SRR1168726     1       0          1  1  0  0  0  0
#> SRR1168727     1       0          1  1  0  0  0  0
#> SRR1168728     1       0          1  1  0  0  0  0
#> SRR1168729     1       0          1  1  0  0  0  0
#> SRR1168730     1       0          1  1  0  0  0  0
#> SRR1168731     1       0          1  1  0  0  0  0
#> SRR1168732     1       0          1  1  0  0  0  0
#> SRR1168733     2       0          1  0  1  0  0  0
#> SRR1168734     2       0          1  0  1  0  0  0
#> SRR1168735     2       0          1  0  1  0  0  0
#> SRR1168736     2       0          1  0  1  0  0  0
#> SRR1168737     2       0          1  0  1  0  0  0
#> SRR1168738     2       0          1  0  1  0  0  0
#> SRR1168739     2       0          1  0  1  0  0  0
#> SRR1168740     2       0          1  0  1  0  0  0
#> SRR1168741     2       0          1  0  1  0  0  0
#> SRR1168742     2       0          1  0  1  0  0  0
#> SRR1168743     2       0          1  0  1  0  0  0
#> SRR1168744     2       0          1  0  1  0  0  0
#> SRR1168745     2       0          1  0  1  0  0  0
#> SRR1168746     2       0          1  0  1  0  0  0
#> SRR1168747     2       0          1  0  1  0  0  0
#> SRR1168748     2       0          1  0  1  0  0  0
#> SRR1168749     2       0          1  0  1  0  0  0
#> SRR1168750     2       0          1  0  1  0  0  0
#> SRR1168751     2       0          1  0  1  0  0  0
#> SRR1168752     2       0          1  0  1  0  0  0
#> SRR1168753     2       0          1  0  1  0  0  0
#> SRR1168754     2       0          1  0  1  0  0  0
#> SRR1168755     2       0          1  0  1  0  0  0
#> SRR1168756     2       0          1  0  1  0  0  0
#> SRR1168757     2       0          1  0  1  0  0  0
#> SRR1168758     2       0          1  0  1  0  0  0
#> SRR1168759     2       0          1  0  1  0  0  0
#> SRR1168760     2       0          1  0  1  0  0  0
#> SRR1168761     3       0          1  0  0  1  0  0
#> SRR1168762     3       0          1  0  0  1  0  0
#> SRR1168763     3       0          1  0  0  1  0  0
#> SRR1168764     3       0          1  0  0  1  0  0
#> SRR1168765     3       0          1  0  0  1  0  0
#> SRR1168766     3       0          1  0  0  1  0  0
#> SRR1168767     3       0          1  0  0  1  0  0
#> SRR1168768     3       0          1  0  0  1  0  0
#> SRR1168769     4       0          1  0  0  0  1  0
#> SRR1168770     4       0          1  0  0  0  1  0
#> SRR1168771     4       0          1  0  0  0  1  0
#> SRR1168772     4       0          1  0  0  0  1  0
#> SRR1168773     4       0          1  0  0  0  1  0
#> SRR1168774     4       0          1  0  0  0  1  0
#> SRR1168775     4       0          1  0  0  0  1  0
#> SRR1168776     4       0          1  0  0  0  1  0
#> SRR1168777     4       0          1  0  0  0  1  0

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1168715     6       0          1  0  0  0  0  0  1
#> SRR1168716     6       0          1  0  0  0  0  0  1
#> SRR1168717     6       0          1  0  0  0  0  0  1
#> SRR1168718     6       0          1  0  0  0  0  0  1
#> SRR1168719     6       0          1  0  0  0  0  0  1
#> SRR1168720     6       0          1  0  0  0  0  0  1
#> SRR1168721     6       0          1  0  0  0  0  0  1
#> SRR1168722     1       0          1  1  0  0  0  0  0
#> SRR1168723     1       0          1  1  0  0  0  0  0
#> SRR1168724     1       0          1  1  0  0  0  0  0
#> SRR1168725     1       0          1  1  0  0  0  0  0
#> SRR1168726     1       0          1  1  0  0  0  0  0
#> SRR1168727     1       0          1  1  0  0  0  0  0
#> SRR1168728     1       0          1  1  0  0  0  0  0
#> SRR1168729     1       0          1  1  0  0  0  0  0
#> SRR1168730     1       0          1  1  0  0  0  0  0
#> SRR1168731     1       0          1  1  0  0  0  0  0
#> SRR1168732     1       0          1  1  0  0  0  0  0
#> SRR1168733     2       0          1  0  1  0  0  0  0
#> SRR1168734     2       0          1  0  1  0  0  0  0
#> SRR1168735     2       0          1  0  1  0  0  0  0
#> SRR1168736     2       0          1  0  1  0  0  0  0
#> SRR1168737     2       0          1  0  1  0  0  0  0
#> SRR1168738     2       0          1  0  1  0  0  0  0
#> SRR1168739     2       0          1  0  1  0  0  0  0
#> SRR1168740     2       0          1  0  1  0  0  0  0
#> SRR1168741     2       0          1  0  1  0  0  0  0
#> SRR1168742     2       0          1  0  1  0  0  0  0
#> SRR1168743     2       0          1  0  1  0  0  0  0
#> SRR1168744     2       0          1  0  1  0  0  0  0
#> SRR1168745     2       0          1  0  1  0  0  0  0
#> SRR1168746     2       0          1  0  1  0  0  0  0
#> SRR1168747     5       0          1  0  0  0  0  1  0
#> SRR1168748     5       0          1  0  0  0  0  1  0
#> SRR1168749     5       0          1  0  0  0  0  1  0
#> SRR1168750     5       0          1  0  0  0  0  1  0
#> SRR1168751     5       0          1  0  0  0  0  1  0
#> SRR1168752     5       0          1  0  0  0  0  1  0
#> SRR1168753     5       0          1  0  0  0  0  1  0
#> SRR1168754     5       0          1  0  0  0  0  1  0
#> SRR1168755     5       0          1  0  0  0  0  1  0
#> SRR1168756     5       0          1  0  0  0  0  1  0
#> SRR1168757     5       0          1  0  0  0  0  1  0
#> SRR1168758     5       0          1  0  0  0  0  1  0
#> SRR1168759     5       0          1  0  0  0  0  1  0
#> SRR1168760     5       0          1  0  0  0  0  1  0
#> SRR1168761     3       0          1  0  0  1  0  0  0
#> SRR1168762     3       0          1  0  0  1  0  0  0
#> SRR1168763     3       0          1  0  0  1  0  0  0
#> SRR1168764     3       0          1  0  0  1  0  0  0
#> SRR1168765     3       0          1  0  0  1  0  0  0
#> SRR1168766     3       0          1  0  0  1  0  0  0
#> SRR1168767     3       0          1  0  0  1  0  0  0
#> SRR1168768     3       0          1  0  0  1  0  0  0
#> SRR1168769     4       0          1  0  0  0  1  0  0
#> SRR1168770     4       0          1  0  0  0  1  0  0
#> SRR1168771     4       0          1  0  0  0  1  0  0
#> SRR1168772     4       0          1  0  0  0  1  0  0
#> SRR1168773     4       0          1  0  0  0  1  0  0
#> SRR1168774     4       0          1  0  0  0  1  0  0
#> SRR1168775     4       0          1  0  0  0  1  0  0
#> SRR1168776     4       0          1  0  0  0  1  0  0
#> SRR1168777     4       0          1  0  0  0  1  0  0

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

consensus_heatmap(res, k = 2)

plot of chunk tab-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 14158 rows and 63 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.5023 0.498   0.498
#> 3 3 0.667           0.595       0.695         0.2583 0.900   0.799
#> 4 4 0.657           0.688       0.730         0.1065 0.746   0.459
#> 5 5 0.627           0.886       0.709         0.0713 0.849   0.522
#> 6 6 0.658           0.870       0.765         0.0459 1.000   1.000

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

suggest_best_k(res)
#> [1] 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
#> SRR1168715     1       0          1  1  0
#> SRR1168716     1       0          1  1  0
#> SRR1168717     1       0          1  1  0
#> SRR1168718     1       0          1  1  0
#> SRR1168719     1       0          1  1  0
#> SRR1168720     1       0          1  1  0
#> SRR1168721     1       0          1  1  0
#> SRR1168722     1       0          1  1  0
#> SRR1168723     1       0          1  1  0
#> SRR1168724     1       0          1  1  0
#> SRR1168725     1       0          1  1  0
#> SRR1168726     1       0          1  1  0
#> SRR1168727     1       0          1  1  0
#> SRR1168728     1       0          1  1  0
#> SRR1168729     1       0          1  1  0
#> SRR1168730     1       0          1  1  0
#> SRR1168731     1       0          1  1  0
#> SRR1168732     1       0          1  1  0
#> SRR1168733     2       0          1  0  1
#> SRR1168734     2       0          1  0  1
#> SRR1168735     2       0          1  0  1
#> SRR1168736     2       0          1  0  1
#> SRR1168737     2       0          1  0  1
#> SRR1168738     2       0          1  0  1
#> SRR1168739     2       0          1  0  1
#> SRR1168740     2       0          1  0  1
#> SRR1168741     2       0          1  0  1
#> SRR1168742     2       0          1  0  1
#> SRR1168743     2       0          1  0  1
#> SRR1168744     2       0          1  0  1
#> SRR1168745     2       0          1  0  1
#> SRR1168746     2       0          1  0  1
#> SRR1168747     2       0          1  0  1
#> SRR1168748     2       0          1  0  1
#> SRR1168749     2       0          1  0  1
#> SRR1168750     2       0          1  0  1
#> SRR1168751     2       0          1  0  1
#> SRR1168752     2       0          1  0  1
#> SRR1168753     2       0          1  0  1
#> SRR1168754     2       0          1  0  1
#> SRR1168755     2       0          1  0  1
#> SRR1168756     2       0          1  0  1
#> SRR1168757     2       0          1  0  1
#> SRR1168758     2       0          1  0  1
#> SRR1168759     2       0          1  0  1
#> SRR1168760     2       0          1  0  1
#> SRR1168761     1       0          1  1  0
#> SRR1168762     1       0          1  1  0
#> SRR1168763     1       0          1  1  0
#> SRR1168764     1       0          1  1  0
#> SRR1168765     1       0          1  1  0
#> SRR1168766     1       0          1  1  0
#> SRR1168767     1       0          1  1  0
#> SRR1168768     1       0          1  1  0
#> SRR1168769     1       0          1  1  0
#> SRR1168770     1       0          1  1  0
#> SRR1168771     1       0          1  1  0
#> SRR1168772     1       0          1  1  0
#> SRR1168773     1       0          1  1  0
#> SRR1168774     1       0          1  1  0
#> SRR1168775     1       0          1  1  0
#> SRR1168776     1       0          1  1  0
#> SRR1168777     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1168715     3   0.625      1.000 0.444 0.000 0.556
#> SRR1168716     3   0.625      1.000 0.444 0.000 0.556
#> SRR1168717     3   0.625      1.000 0.444 0.000 0.556
#> SRR1168718     3   0.625      1.000 0.444 0.000 0.556
#> SRR1168719     3   0.625      1.000 0.444 0.000 0.556
#> SRR1168720     3   0.625      1.000 0.444 0.000 0.556
#> SRR1168721     3   0.625      1.000 0.444 0.000 0.556
#> SRR1168722     1   0.450      0.471 0.804 0.000 0.196
#> SRR1168723     1   0.450      0.471 0.804 0.000 0.196
#> SRR1168724     1   0.450      0.471 0.804 0.000 0.196
#> SRR1168725     1   0.450      0.471 0.804 0.000 0.196
#> SRR1168726     1   0.450      0.471 0.804 0.000 0.196
#> SRR1168727     1   0.450      0.471 0.804 0.000 0.196
#> SRR1168728     1   0.450      0.471 0.804 0.000 0.196
#> SRR1168729     1   0.450      0.471 0.804 0.000 0.196
#> SRR1168730     1   0.450      0.471 0.804 0.000 0.196
#> SRR1168731     1   0.450      0.471 0.804 0.000 0.196
#> SRR1168732     1   0.450      0.471 0.804 0.000 0.196
#> SRR1168733     2   0.610      0.822 0.000 0.608 0.392
#> SRR1168734     2   0.610      0.822 0.000 0.608 0.392
#> SRR1168735     2   0.610      0.822 0.000 0.608 0.392
#> SRR1168736     2   0.610      0.822 0.000 0.608 0.392
#> SRR1168737     2   0.610      0.822 0.000 0.608 0.392
#> SRR1168738     2   0.610      0.822 0.000 0.608 0.392
#> SRR1168739     2   0.610      0.822 0.000 0.608 0.392
#> SRR1168740     2   0.610      0.822 0.000 0.608 0.392
#> SRR1168741     2   0.610      0.822 0.000 0.608 0.392
#> SRR1168742     2   0.610      0.822 0.000 0.608 0.392
#> SRR1168743     2   0.610      0.822 0.000 0.608 0.392
#> SRR1168744     2   0.610      0.822 0.000 0.608 0.392
#> SRR1168745     2   0.610      0.822 0.000 0.608 0.392
#> SRR1168746     2   0.610      0.822 0.000 0.608 0.392
#> SRR1168747     2   0.000      0.822 0.000 1.000 0.000
#> SRR1168748     2   0.000      0.822 0.000 1.000 0.000
#> SRR1168749     2   0.000      0.822 0.000 1.000 0.000
#> SRR1168750     2   0.000      0.822 0.000 1.000 0.000
#> SRR1168751     2   0.000      0.822 0.000 1.000 0.000
#> SRR1168752     2   0.000      0.822 0.000 1.000 0.000
#> SRR1168753     2   0.000      0.822 0.000 1.000 0.000
#> SRR1168754     2   0.000      0.822 0.000 1.000 0.000
#> SRR1168755     2   0.000      0.822 0.000 1.000 0.000
#> SRR1168756     2   0.000      0.822 0.000 1.000 0.000
#> SRR1168757     2   0.000      0.822 0.000 1.000 0.000
#> SRR1168758     2   0.000      0.822 0.000 1.000 0.000
#> SRR1168759     2   0.000      0.822 0.000 1.000 0.000
#> SRR1168760     2   0.000      0.822 0.000 1.000 0.000
#> SRR1168761     1   0.610     -0.309 0.608 0.000 0.392
#> SRR1168762     1   0.610     -0.309 0.608 0.000 0.392
#> SRR1168763     1   0.610     -0.309 0.608 0.000 0.392
#> SRR1168764     1   0.610     -0.309 0.608 0.000 0.392
#> SRR1168765     1   0.610     -0.309 0.608 0.000 0.392
#> SRR1168766     1   0.610     -0.309 0.608 0.000 0.392
#> SRR1168767     1   0.610     -0.309 0.608 0.000 0.392
#> SRR1168768     1   0.610     -0.309 0.608 0.000 0.392
#> SRR1168769     1   0.000      0.525 1.000 0.000 0.000
#> SRR1168770     1   0.000      0.525 1.000 0.000 0.000
#> SRR1168771     1   0.000      0.525 1.000 0.000 0.000
#> SRR1168772     1   0.000      0.525 1.000 0.000 0.000
#> SRR1168773     1   0.000      0.525 1.000 0.000 0.000
#> SRR1168774     1   0.000      0.525 1.000 0.000 0.000
#> SRR1168775     1   0.000      0.525 1.000 0.000 0.000
#> SRR1168776     1   0.000      0.525 1.000 0.000 0.000
#> SRR1168777     1   0.000      0.525 1.000 0.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
#> SRR1168715     1   0.761     -0.253 0.428 0.000 0.368 0.204
#> SRR1168716     1   0.761     -0.253 0.428 0.000 0.368 0.204
#> SRR1168717     1   0.761     -0.253 0.428 0.000 0.368 0.204
#> SRR1168718     1   0.761     -0.253 0.428 0.000 0.368 0.204
#> SRR1168719     1   0.761     -0.253 0.428 0.000 0.368 0.204
#> SRR1168720     1   0.761     -0.253 0.428 0.000 0.368 0.204
#> SRR1168721     1   0.761     -0.253 0.428 0.000 0.368 0.204
#> SRR1168722     1   0.000      0.582 1.000 0.000 0.000 0.000
#> SRR1168723     1   0.000      0.582 1.000 0.000 0.000 0.000
#> SRR1168724     1   0.000      0.582 1.000 0.000 0.000 0.000
#> SRR1168725     1   0.000      0.582 1.000 0.000 0.000 0.000
#> SRR1168726     1   0.000      0.582 1.000 0.000 0.000 0.000
#> SRR1168727     1   0.000      0.582 1.000 0.000 0.000 0.000
#> SRR1168728     1   0.000      0.582 1.000 0.000 0.000 0.000
#> SRR1168729     1   0.000      0.582 1.000 0.000 0.000 0.000
#> SRR1168730     1   0.000      0.582 1.000 0.000 0.000 0.000
#> SRR1168731     1   0.000      0.582 1.000 0.000 0.000 0.000
#> SRR1168732     1   0.000      0.582 1.000 0.000 0.000 0.000
#> SRR1168733     2   0.187      0.939 0.000 0.928 0.072 0.000
#> SRR1168734     2   0.121      0.950 0.000 0.960 0.040 0.000
#> SRR1168735     2   0.179      0.943 0.000 0.932 0.068 0.000
#> SRR1168736     2   0.164      0.942 0.000 0.940 0.060 0.000
#> SRR1168737     2   0.156      0.946 0.000 0.944 0.056 0.000
#> SRR1168738     2   0.112      0.944 0.000 0.964 0.036 0.000
#> SRR1168739     2   0.130      0.943 0.000 0.956 0.044 0.000
#> SRR1168740     2   0.102      0.947 0.000 0.968 0.032 0.000
#> SRR1168741     2   0.201      0.940 0.000 0.920 0.080 0.000
#> SRR1168742     2   0.164      0.945 0.000 0.940 0.060 0.000
#> SRR1168743     2   0.194      0.938 0.000 0.924 0.076 0.000
#> SRR1168744     2   0.121      0.947 0.000 0.960 0.040 0.000
#> SRR1168745     2   0.187      0.943 0.000 0.928 0.072 0.000
#> SRR1168746     2   0.147      0.945 0.000 0.948 0.052 0.000
#> SRR1168747     4   0.600      0.961 0.000 0.404 0.044 0.552
#> SRR1168748     4   0.517      0.978 0.000 0.404 0.008 0.588
#> SRR1168749     4   0.504      0.978 0.000 0.404 0.004 0.592
#> SRR1168750     4   0.568      0.971 0.000 0.404 0.028 0.568
#> SRR1168751     4   0.517      0.977 0.000 0.404 0.008 0.588
#> SRR1168752     4   0.672      0.908 0.000 0.404 0.092 0.504
#> SRR1168753     4   0.540      0.978 0.000 0.404 0.016 0.580
#> SRR1168754     4   0.540      0.976 0.000 0.404 0.016 0.580
#> SRR1168755     4   0.550      0.976 0.000 0.404 0.020 0.576
#> SRR1168756     4   0.550      0.976 0.000 0.404 0.020 0.576
#> SRR1168757     4   0.504      0.978 0.000 0.404 0.004 0.592
#> SRR1168758     4   0.504      0.978 0.000 0.404 0.004 0.592
#> SRR1168759     4   0.504      0.978 0.000 0.404 0.004 0.592
#> SRR1168760     4   0.540      0.976 0.000 0.404 0.016 0.580
#> SRR1168761     3   0.404      1.000 0.248 0.000 0.752 0.000
#> SRR1168762     3   0.404      1.000 0.248 0.000 0.752 0.000
#> SRR1168763     3   0.404      1.000 0.248 0.000 0.752 0.000
#> SRR1168764     3   0.404      1.000 0.248 0.000 0.752 0.000
#> SRR1168765     3   0.404      1.000 0.248 0.000 0.752 0.000
#> SRR1168766     3   0.404      1.000 0.248 0.000 0.752 0.000
#> SRR1168767     3   0.404      1.000 0.248 0.000 0.752 0.000
#> SRR1168768     3   0.404      1.000 0.248 0.000 0.752 0.000
#> SRR1168769     1   0.669      0.433 0.620 0.000 0.180 0.200
#> SRR1168770     1   0.669      0.433 0.620 0.000 0.180 0.200
#> SRR1168771     1   0.669      0.433 0.620 0.000 0.180 0.200
#> SRR1168772     1   0.669      0.433 0.620 0.000 0.180 0.200
#> SRR1168773     1   0.669      0.433 0.620 0.000 0.180 0.200
#> SRR1168774     1   0.669      0.433 0.620 0.000 0.180 0.200
#> SRR1168775     1   0.669      0.433 0.620 0.000 0.180 0.200
#> SRR1168776     1   0.669      0.433 0.620 0.000 0.180 0.200
#> SRR1168777     1   0.669      0.433 0.620 0.000 0.180 0.200

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4    p5
#> SRR1168715     3  0.7765      0.652 0.296 0.116 0.444 0.144 0.000
#> SRR1168716     3  0.7765      0.652 0.296 0.116 0.444 0.144 0.000
#> SRR1168717     3  0.7765      0.652 0.296 0.116 0.444 0.144 0.000
#> SRR1168718     3  0.7765      0.652 0.296 0.116 0.444 0.144 0.000
#> SRR1168719     3  0.7765      0.652 0.296 0.116 0.444 0.144 0.000
#> SRR1168720     3  0.7765      0.652 0.296 0.116 0.444 0.144 0.000
#> SRR1168721     3  0.7810      0.650 0.288 0.124 0.444 0.144 0.000
#> SRR1168722     1  0.4430      0.984 0.540 0.004 0.000 0.456 0.000
#> SRR1168723     1  0.4542      0.983 0.536 0.008 0.000 0.456 0.000
#> SRR1168724     1  0.5403      0.948 0.488 0.056 0.000 0.456 0.000
#> SRR1168725     1  0.4731      0.982 0.528 0.016 0.000 0.456 0.000
#> SRR1168726     1  0.4815      0.980 0.524 0.020 0.000 0.456 0.000
#> SRR1168727     1  0.4641      0.982 0.532 0.012 0.000 0.456 0.000
#> SRR1168728     1  0.4641      0.982 0.532 0.012 0.000 0.456 0.000
#> SRR1168729     1  0.4430      0.984 0.540 0.004 0.000 0.456 0.000
#> SRR1168730     1  0.4815      0.980 0.524 0.020 0.000 0.456 0.000
#> SRR1168731     1  0.4430      0.983 0.540 0.004 0.000 0.456 0.000
#> SRR1168732     1  0.4542      0.983 0.536 0.008 0.000 0.456 0.000
#> SRR1168733     2  0.5240      0.925 0.032 0.676 0.036 0.000 0.256
#> SRR1168734     2  0.5592      0.935 0.068 0.652 0.024 0.000 0.256
#> SRR1168735     2  0.5007      0.928 0.024 0.688 0.032 0.000 0.256
#> SRR1168736     2  0.6074      0.922 0.100 0.616 0.028 0.000 0.256
#> SRR1168737     2  0.5311      0.931 0.040 0.672 0.032 0.000 0.256
#> SRR1168738     2  0.5557      0.926 0.060 0.656 0.028 0.000 0.256
#> SRR1168739     2  0.5563      0.924 0.072 0.652 0.020 0.000 0.256
#> SRR1168740     2  0.4675      0.933 0.020 0.704 0.020 0.000 0.256
#> SRR1168741     2  0.5903      0.925 0.064 0.636 0.044 0.000 0.256
#> SRR1168742     2  0.5857      0.928 0.076 0.636 0.032 0.000 0.256
#> SRR1168743     2  0.5162      0.929 0.028 0.680 0.036 0.000 0.256
#> SRR1168744     2  0.5982      0.924 0.092 0.624 0.028 0.000 0.256
#> SRR1168745     2  0.5946      0.926 0.072 0.632 0.040 0.000 0.256
#> SRR1168746     2  0.6057      0.927 0.092 0.620 0.032 0.000 0.256
#> SRR1168747     5  0.2426      0.938 0.036 0.000 0.064 0.000 0.900
#> SRR1168748     5  0.0865      0.954 0.004 0.000 0.024 0.000 0.972
#> SRR1168749     5  0.1281      0.953 0.032 0.000 0.012 0.000 0.956
#> SRR1168750     5  0.2230      0.944 0.044 0.000 0.044 0.000 0.912
#> SRR1168751     5  0.1211      0.954 0.016 0.000 0.024 0.000 0.960
#> SRR1168752     5  0.4216      0.838 0.120 0.000 0.100 0.000 0.780
#> SRR1168753     5  0.1668      0.952 0.032 0.000 0.028 0.000 0.940
#> SRR1168754     5  0.1830      0.948 0.028 0.000 0.040 0.000 0.932
#> SRR1168755     5  0.1281      0.955 0.012 0.000 0.032 0.000 0.956
#> SRR1168756     5  0.1444      0.953 0.012 0.000 0.040 0.000 0.948
#> SRR1168757     5  0.0955      0.953 0.028 0.000 0.004 0.000 0.968
#> SRR1168758     5  0.0912      0.954 0.016 0.000 0.012 0.000 0.972
#> SRR1168759     5  0.0798      0.953 0.016 0.000 0.008 0.000 0.976
#> SRR1168760     5  0.1386      0.953 0.016 0.000 0.032 0.000 0.952
#> SRR1168761     3  0.3990      0.677 0.000 0.004 0.688 0.308 0.000
#> SRR1168762     3  0.3990      0.677 0.000 0.004 0.688 0.308 0.000
#> SRR1168763     3  0.4108      0.676 0.000 0.008 0.684 0.308 0.000
#> SRR1168764     3  0.4213      0.676 0.000 0.012 0.680 0.308 0.000
#> SRR1168765     3  0.4213      0.676 0.000 0.012 0.680 0.308 0.000
#> SRR1168766     3  0.4108      0.676 0.000 0.008 0.684 0.308 0.000
#> SRR1168767     3  0.3837      0.677 0.000 0.000 0.692 0.308 0.000
#> SRR1168768     3  0.4309      0.675 0.000 0.016 0.676 0.308 0.000
#> SRR1168769     4  0.0000      0.994 0.000 0.000 0.000 1.000 0.000
#> SRR1168770     4  0.0000      0.994 0.000 0.000 0.000 1.000 0.000
#> SRR1168771     4  0.0000      0.994 0.000 0.000 0.000 1.000 0.000
#> SRR1168772     4  0.0000      0.994 0.000 0.000 0.000 1.000 0.000
#> SRR1168773     4  0.0000      0.994 0.000 0.000 0.000 1.000 0.000
#> SRR1168774     4  0.0000      0.994 0.000 0.000 0.000 1.000 0.000
#> SRR1168775     4  0.0000      0.994 0.000 0.000 0.000 1.000 0.000
#> SRR1168776     4  0.0000      0.994 0.000 0.000 0.000 1.000 0.000
#> SRR1168777     4  0.1043      0.950 0.000 0.040 0.000 0.960 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
#> SRR1168715     3  0.5223      0.669 0.092 0.000 0.472 0.000 0.000 NA
#> SRR1168716     3  0.5223      0.669 0.092 0.000 0.472 0.000 0.000 NA
#> SRR1168717     3  0.5223      0.669 0.092 0.000 0.472 0.000 0.000 NA
#> SRR1168718     3  0.5446      0.669 0.092 0.000 0.472 0.008 0.000 NA
#> SRR1168719     3  0.5350      0.669 0.092 0.000 0.472 0.004 0.000 NA
#> SRR1168720     3  0.5446      0.669 0.092 0.000 0.472 0.008 0.000 NA
#> SRR1168721     3  0.6044      0.664 0.092 0.000 0.472 0.012 0.024 NA
#> SRR1168722     1  0.2060      0.963 0.900 0.000 0.084 0.000 0.016 NA
#> SRR1168723     1  0.2384      0.961 0.884 0.000 0.084 0.000 0.032 NA
#> SRR1168724     1  0.4228      0.877 0.796 0.000 0.084 0.020 0.028 NA
#> SRR1168725     1  0.2670      0.960 0.876 0.000 0.084 0.004 0.032 NA
#> SRR1168726     1  0.3118      0.952 0.860 0.000 0.084 0.012 0.024 NA
#> SRR1168727     1  0.2477      0.961 0.888 0.000 0.084 0.008 0.008 NA
#> SRR1168728     1  0.2585      0.962 0.880 0.000 0.084 0.000 0.024 NA
#> SRR1168729     1  0.2290      0.963 0.892 0.000 0.084 0.000 0.020 NA
#> SRR1168730     1  0.2477      0.962 0.888 0.000 0.084 0.008 0.012 NA
#> SRR1168731     1  0.1610      0.965 0.916 0.000 0.084 0.000 0.000 NA
#> SRR1168732     1  0.1753      0.965 0.912 0.000 0.084 0.000 0.004 NA
#> SRR1168733     2  0.2913      0.883 0.004 0.848 0.000 0.116 0.000 NA
#> SRR1168734     2  0.2879      0.906 0.016 0.868 0.000 0.072 0.000 NA
#> SRR1168735     2  0.2871      0.903 0.008 0.852 0.000 0.116 0.000 NA
#> SRR1168736     2  0.3572      0.891 0.020 0.820 0.000 0.100 0.000 NA
#> SRR1168737     2  0.2657      0.899 0.020 0.880 0.000 0.076 0.000 NA
#> SRR1168738     2  0.3167      0.894 0.012 0.836 0.000 0.120 0.000 NA
#> SRR1168739     2  0.3270      0.895 0.028 0.844 0.000 0.088 0.000 NA
#> SRR1168740     2  0.2518      0.903 0.012 0.880 0.000 0.092 0.000 NA
#> SRR1168741     2  0.2651      0.892 0.004 0.872 0.000 0.088 0.000 NA
#> SRR1168742     2  0.2858      0.900 0.000 0.844 0.000 0.124 0.000 NA
#> SRR1168743     2  0.2476      0.892 0.008 0.888 0.000 0.072 0.000 NA
#> SRR1168744     2  0.3142      0.900 0.016 0.848 0.000 0.092 0.000 NA
#> SRR1168745     2  0.2605      0.895 0.000 0.864 0.000 0.108 0.000 NA
#> SRR1168746     2  0.3007      0.901 0.020 0.860 0.000 0.080 0.000 NA
#> SRR1168747     5  0.4770      0.915 0.000 0.164 0.000 0.008 0.696 NA
#> SRR1168748     5  0.3983      0.933 0.012 0.164 0.000 0.008 0.776 NA
#> SRR1168749     5  0.4036      0.931 0.000 0.164 0.000 0.020 0.768 NA
#> SRR1168750     5  0.4837      0.917 0.000 0.164 0.000 0.016 0.700 NA
#> SRR1168751     5  0.3916      0.934 0.008 0.164 0.000 0.012 0.780 NA
#> SRR1168752     5  0.7044      0.768 0.016 0.164 0.000 0.112 0.520 NA
#> SRR1168753     5  0.4549      0.930 0.016 0.164 0.000 0.024 0.748 NA
#> SRR1168754     5  0.4130      0.930 0.000 0.164 0.000 0.016 0.760 NA
#> SRR1168755     5  0.4408      0.930 0.016 0.164 0.000 0.020 0.756 NA
#> SRR1168756     5  0.4293      0.928 0.000 0.164 0.000 0.004 0.736 NA
#> SRR1168757     5  0.3824      0.928 0.000 0.164 0.000 0.016 0.780 NA
#> SRR1168758     5  0.4029      0.930 0.004 0.164 0.000 0.016 0.772 NA
#> SRR1168759     5  0.3908      0.934 0.000 0.164 0.000 0.020 0.776 NA
#> SRR1168760     5  0.4256      0.928 0.000 0.164 0.000 0.012 0.748 NA
#> SRR1168761     3  0.0508      0.698 0.012 0.000 0.984 0.000 0.004 NA
#> SRR1168762     3  0.0767      0.697 0.012 0.000 0.976 0.004 0.008 NA
#> SRR1168763     3  0.0870      0.697 0.012 0.000 0.972 0.004 0.012 NA
#> SRR1168764     3  0.0870      0.698 0.012 0.000 0.972 0.012 0.004 NA
#> SRR1168765     3  0.0881      0.698 0.012 0.000 0.972 0.008 0.008 NA
#> SRR1168766     3  0.0767      0.698 0.012 0.000 0.976 0.008 0.004 NA
#> SRR1168767     3  0.0622      0.698 0.012 0.000 0.980 0.008 0.000 NA
#> SRR1168768     3  0.1332      0.695 0.012 0.000 0.952 0.028 0.008 NA
#> SRR1168769     4  0.5569      0.980 0.280 0.000 0.180 0.540 0.000 NA
#> SRR1168770     4  0.5701      0.980 0.280 0.000 0.180 0.536 0.000 NA
#> SRR1168771     4  0.5701      0.979 0.280 0.000 0.180 0.536 0.000 NA
#> SRR1168772     4  0.5890      0.979 0.280 0.000 0.180 0.528 0.000 NA
#> SRR1168773     4  0.5569      0.980 0.280 0.000 0.180 0.540 0.000 NA
#> SRR1168774     4  0.5701      0.979 0.280 0.000 0.180 0.536 0.000 NA
#> SRR1168775     4  0.5801      0.979 0.280 0.000 0.180 0.532 0.000 NA
#> SRR1168776     4  0.5801      0.979 0.280 0.000 0.180 0.532 0.000 NA
#> SRR1168777     4  0.7624      0.865 0.280 0.000 0.180 0.420 0.052 NA

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-kmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-kmeans-collect-classes

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


ATC:skmeans**

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

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

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

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

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

collect_plots(res)

plot of chunk ATC-skmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.5023 0.498   0.498
#> 3 3 0.844           0.956       0.965         0.3057 0.846   0.692
#> 4 4 0.820           0.951       0.903         0.0772 0.949   0.853
#> 5 5 0.820           0.689       0.710         0.0882 0.814   0.469
#> 6 6 0.893           0.995       0.957         0.0647 0.943   0.742

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
#> SRR1168715     1       0          1  1  0
#> SRR1168716     1       0          1  1  0
#> SRR1168717     1       0          1  1  0
#> SRR1168718     1       0          1  1  0
#> SRR1168719     1       0          1  1  0
#> SRR1168720     1       0          1  1  0
#> SRR1168721     1       0          1  1  0
#> SRR1168722     1       0          1  1  0
#> SRR1168723     1       0          1  1  0
#> SRR1168724     1       0          1  1  0
#> SRR1168725     1       0          1  1  0
#> SRR1168726     1       0          1  1  0
#> SRR1168727     1       0          1  1  0
#> SRR1168728     1       0          1  1  0
#> SRR1168729     1       0          1  1  0
#> SRR1168730     1       0          1  1  0
#> SRR1168731     1       0          1  1  0
#> SRR1168732     1       0          1  1  0
#> SRR1168733     2       0          1  0  1
#> SRR1168734     2       0          1  0  1
#> SRR1168735     2       0          1  0  1
#> SRR1168736     2       0          1  0  1
#> SRR1168737     2       0          1  0  1
#> SRR1168738     2       0          1  0  1
#> SRR1168739     2       0          1  0  1
#> SRR1168740     2       0          1  0  1
#> SRR1168741     2       0          1  0  1
#> SRR1168742     2       0          1  0  1
#> SRR1168743     2       0          1  0  1
#> SRR1168744     2       0          1  0  1
#> SRR1168745     2       0          1  0  1
#> SRR1168746     2       0          1  0  1
#> SRR1168747     2       0          1  0  1
#> SRR1168748     2       0          1  0  1
#> SRR1168749     2       0          1  0  1
#> SRR1168750     2       0          1  0  1
#> SRR1168751     2       0          1  0  1
#> SRR1168752     2       0          1  0  1
#> SRR1168753     2       0          1  0  1
#> SRR1168754     2       0          1  0  1
#> SRR1168755     2       0          1  0  1
#> SRR1168756     2       0          1  0  1
#> SRR1168757     2       0          1  0  1
#> SRR1168758     2       0          1  0  1
#> SRR1168759     2       0          1  0  1
#> SRR1168760     2       0          1  0  1
#> SRR1168761     1       0          1  1  0
#> SRR1168762     1       0          1  1  0
#> SRR1168763     1       0          1  1  0
#> SRR1168764     1       0          1  1  0
#> SRR1168765     1       0          1  1  0
#> SRR1168766     1       0          1  1  0
#> SRR1168767     1       0          1  1  0
#> SRR1168768     1       0          1  1  0
#> SRR1168769     1       0          1  1  0
#> SRR1168770     1       0          1  1  0
#> SRR1168771     1       0          1  1  0
#> SRR1168772     1       0          1  1  0
#> SRR1168773     1       0          1  1  0
#> SRR1168774     1       0          1  1  0
#> SRR1168775     1       0          1  1  0
#> SRR1168776     1       0          1  1  0
#> SRR1168777     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1168715     3  0.3551      0.915 0.132 0.000 0.868
#> SRR1168716     3  0.3551      0.915 0.132 0.000 0.868
#> SRR1168717     3  0.3551      0.915 0.132 0.000 0.868
#> SRR1168718     3  0.3551      0.915 0.132 0.000 0.868
#> SRR1168719     3  0.3551      0.915 0.132 0.000 0.868
#> SRR1168720     3  0.3551      0.915 0.132 0.000 0.868
#> SRR1168721     3  0.3551      0.915 0.132 0.000 0.868
#> SRR1168722     1  0.0000      0.930 1.000 0.000 0.000
#> SRR1168723     1  0.0000      0.930 1.000 0.000 0.000
#> SRR1168724     1  0.0000      0.930 1.000 0.000 0.000
#> SRR1168725     1  0.0000      0.930 1.000 0.000 0.000
#> SRR1168726     1  0.0000      0.930 1.000 0.000 0.000
#> SRR1168727     1  0.0000      0.930 1.000 0.000 0.000
#> SRR1168728     1  0.0000      0.930 1.000 0.000 0.000
#> SRR1168729     1  0.0000      0.930 1.000 0.000 0.000
#> SRR1168730     1  0.0000      0.930 1.000 0.000 0.000
#> SRR1168731     1  0.0000      0.930 1.000 0.000 0.000
#> SRR1168732     1  0.0000      0.930 1.000 0.000 0.000
#> SRR1168733     2  0.0000      0.998 0.000 1.000 0.000
#> SRR1168734     2  0.0000      0.998 0.000 1.000 0.000
#> SRR1168735     2  0.0000      0.998 0.000 1.000 0.000
#> SRR1168736     2  0.0000      0.998 0.000 1.000 0.000
#> SRR1168737     2  0.0000      0.998 0.000 1.000 0.000
#> SRR1168738     2  0.0000      0.998 0.000 1.000 0.000
#> SRR1168739     2  0.0000      0.998 0.000 1.000 0.000
#> SRR1168740     2  0.0000      0.998 0.000 1.000 0.000
#> SRR1168741     2  0.0000      0.998 0.000 1.000 0.000
#> SRR1168742     2  0.0000      0.998 0.000 1.000 0.000
#> SRR1168743     2  0.0000      0.998 0.000 1.000 0.000
#> SRR1168744     2  0.0000      0.998 0.000 1.000 0.000
#> SRR1168745     2  0.0000      0.998 0.000 1.000 0.000
#> SRR1168746     2  0.0000      0.998 0.000 1.000 0.000
#> SRR1168747     2  0.0237      0.998 0.000 0.996 0.004
#> SRR1168748     2  0.0237      0.998 0.000 0.996 0.004
#> SRR1168749     2  0.0237      0.998 0.000 0.996 0.004
#> SRR1168750     2  0.0237      0.998 0.000 0.996 0.004
#> SRR1168751     2  0.0237      0.998 0.000 0.996 0.004
#> SRR1168752     2  0.0237      0.998 0.000 0.996 0.004
#> SRR1168753     2  0.0237      0.998 0.000 0.996 0.004
#> SRR1168754     2  0.0237      0.998 0.000 0.996 0.004
#> SRR1168755     2  0.0237      0.998 0.000 0.996 0.004
#> SRR1168756     2  0.0237      0.998 0.000 0.996 0.004
#> SRR1168757     2  0.0237      0.998 0.000 0.996 0.004
#> SRR1168758     2  0.0237      0.998 0.000 0.996 0.004
#> SRR1168759     2  0.0237      0.998 0.000 0.996 0.004
#> SRR1168760     2  0.0237      0.998 0.000 0.996 0.004
#> SRR1168761     3  0.0237      0.927 0.004 0.000 0.996
#> SRR1168762     3  0.0237      0.927 0.004 0.000 0.996
#> SRR1168763     3  0.0237      0.927 0.004 0.000 0.996
#> SRR1168764     3  0.0237      0.927 0.004 0.000 0.996
#> SRR1168765     3  0.0237      0.927 0.004 0.000 0.996
#> SRR1168766     3  0.0237      0.927 0.004 0.000 0.996
#> SRR1168767     3  0.0237      0.927 0.004 0.000 0.996
#> SRR1168768     3  0.0237      0.927 0.004 0.000 0.996
#> SRR1168769     1  0.3551      0.913 0.868 0.000 0.132
#> SRR1168770     1  0.3551      0.913 0.868 0.000 0.132
#> SRR1168771     1  0.3551      0.913 0.868 0.000 0.132
#> SRR1168772     1  0.3551      0.913 0.868 0.000 0.132
#> SRR1168773     1  0.3551      0.913 0.868 0.000 0.132
#> SRR1168774     1  0.3551      0.913 0.868 0.000 0.132
#> SRR1168775     1  0.3551      0.913 0.868 0.000 0.132
#> SRR1168776     1  0.3551      0.913 0.868 0.000 0.132
#> SRR1168777     1  0.3551      0.913 0.868 0.000 0.132

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1168715     3   0.121      0.873 0.040 0.000 0.960 0.000
#> SRR1168716     3   0.121      0.873 0.040 0.000 0.960 0.000
#> SRR1168717     3   0.121      0.873 0.040 0.000 0.960 0.000
#> SRR1168718     3   0.121      0.873 0.040 0.000 0.960 0.000
#> SRR1168719     3   0.121      0.873 0.040 0.000 0.960 0.000
#> SRR1168720     3   0.121      0.873 0.040 0.000 0.960 0.000
#> SRR1168721     3   0.121      0.873 0.040 0.000 0.960 0.000
#> SRR1168722     1   0.000      1.000 1.000 0.000 0.000 0.000
#> SRR1168723     1   0.000      1.000 1.000 0.000 0.000 0.000
#> SRR1168724     1   0.000      1.000 1.000 0.000 0.000 0.000
#> SRR1168725     1   0.000      1.000 1.000 0.000 0.000 0.000
#> SRR1168726     1   0.000      1.000 1.000 0.000 0.000 0.000
#> SRR1168727     1   0.000      1.000 1.000 0.000 0.000 0.000
#> SRR1168728     1   0.000      1.000 1.000 0.000 0.000 0.000
#> SRR1168729     1   0.000      1.000 1.000 0.000 0.000 0.000
#> SRR1168730     1   0.000      1.000 1.000 0.000 0.000 0.000
#> SRR1168731     1   0.000      1.000 1.000 0.000 0.000 0.000
#> SRR1168732     1   0.000      1.000 1.000 0.000 0.000 0.000
#> SRR1168733     2   0.000      0.952 0.000 1.000 0.000 0.000
#> SRR1168734     2   0.000      0.952 0.000 1.000 0.000 0.000
#> SRR1168735     2   0.000      0.952 0.000 1.000 0.000 0.000
#> SRR1168736     2   0.000      0.952 0.000 1.000 0.000 0.000
#> SRR1168737     2   0.000      0.952 0.000 1.000 0.000 0.000
#> SRR1168738     2   0.000      0.952 0.000 1.000 0.000 0.000
#> SRR1168739     2   0.000      0.952 0.000 1.000 0.000 0.000
#> SRR1168740     2   0.000      0.952 0.000 1.000 0.000 0.000
#> SRR1168741     2   0.000      0.952 0.000 1.000 0.000 0.000
#> SRR1168742     2   0.000      0.952 0.000 1.000 0.000 0.000
#> SRR1168743     2   0.000      0.952 0.000 1.000 0.000 0.000
#> SRR1168744     2   0.000      0.952 0.000 1.000 0.000 0.000
#> SRR1168745     2   0.000      0.952 0.000 1.000 0.000 0.000
#> SRR1168746     2   0.000      0.952 0.000 1.000 0.000 0.000
#> SRR1168747     2   0.253      0.952 0.000 0.896 0.004 0.100
#> SRR1168748     2   0.253      0.952 0.000 0.896 0.004 0.100
#> SRR1168749     2   0.253      0.952 0.000 0.896 0.004 0.100
#> SRR1168750     2   0.253      0.952 0.000 0.896 0.004 0.100
#> SRR1168751     2   0.253      0.952 0.000 0.896 0.004 0.100
#> SRR1168752     2   0.253      0.952 0.000 0.896 0.004 0.100
#> SRR1168753     2   0.253      0.952 0.000 0.896 0.004 0.100
#> SRR1168754     2   0.253      0.952 0.000 0.896 0.004 0.100
#> SRR1168755     2   0.253      0.952 0.000 0.896 0.004 0.100
#> SRR1168756     2   0.253      0.952 0.000 0.896 0.004 0.100
#> SRR1168757     2   0.253      0.952 0.000 0.896 0.004 0.100
#> SRR1168758     2   0.253      0.952 0.000 0.896 0.004 0.100
#> SRR1168759     2   0.253      0.952 0.000 0.896 0.004 0.100
#> SRR1168760     2   0.253      0.952 0.000 0.896 0.004 0.100
#> SRR1168761     3   0.384      0.890 0.000 0.000 0.776 0.224
#> SRR1168762     3   0.384      0.890 0.000 0.000 0.776 0.224
#> SRR1168763     3   0.384      0.890 0.000 0.000 0.776 0.224
#> SRR1168764     3   0.384      0.890 0.000 0.000 0.776 0.224
#> SRR1168765     3   0.384      0.890 0.000 0.000 0.776 0.224
#> SRR1168766     3   0.384      0.890 0.000 0.000 0.776 0.224
#> SRR1168767     3   0.384      0.890 0.000 0.000 0.776 0.224
#> SRR1168768     3   0.384      0.890 0.000 0.000 0.776 0.224
#> SRR1168769     4   0.448      1.000 0.312 0.000 0.000 0.688
#> SRR1168770     4   0.448      1.000 0.312 0.000 0.000 0.688
#> SRR1168771     4   0.448      1.000 0.312 0.000 0.000 0.688
#> SRR1168772     4   0.448      1.000 0.312 0.000 0.000 0.688
#> SRR1168773     4   0.448      1.000 0.312 0.000 0.000 0.688
#> SRR1168774     4   0.448      1.000 0.312 0.000 0.000 0.688
#> SRR1168775     4   0.448      1.000 0.312 0.000 0.000 0.688
#> SRR1168776     4   0.448      1.000 0.312 0.000 0.000 0.688
#> SRR1168777     4   0.448      1.000 0.312 0.000 0.000 0.688

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4    p5
#> SRR1168715     5   0.088      1.000 0.032 0.000 0.000 0.000 0.968
#> SRR1168716     5   0.088      1.000 0.032 0.000 0.000 0.000 0.968
#> SRR1168717     5   0.088      1.000 0.032 0.000 0.000 0.000 0.968
#> SRR1168718     5   0.088      1.000 0.032 0.000 0.000 0.000 0.968
#> SRR1168719     5   0.088      1.000 0.032 0.000 0.000 0.000 0.968
#> SRR1168720     5   0.088      1.000 0.032 0.000 0.000 0.000 0.968
#> SRR1168721     5   0.088      1.000 0.032 0.000 0.000 0.000 0.968
#> SRR1168722     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1168723     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1168724     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1168725     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1168726     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1168727     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1168728     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1168729     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1168730     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1168731     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1168732     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1168733     3   0.430      0.301 0.000 0.476 0.524 0.000 0.000
#> SRR1168734     3   0.430      0.301 0.000 0.476 0.524 0.000 0.000
#> SRR1168735     3   0.430      0.301 0.000 0.476 0.524 0.000 0.000
#> SRR1168736     3   0.430      0.301 0.000 0.476 0.524 0.000 0.000
#> SRR1168737     3   0.430      0.301 0.000 0.476 0.524 0.000 0.000
#> SRR1168738     3   0.430      0.301 0.000 0.476 0.524 0.000 0.000
#> SRR1168739     3   0.430      0.301 0.000 0.476 0.524 0.000 0.000
#> SRR1168740     3   0.430      0.301 0.000 0.476 0.524 0.000 0.000
#> SRR1168741     3   0.430      0.301 0.000 0.476 0.524 0.000 0.000
#> SRR1168742     3   0.430      0.301 0.000 0.476 0.524 0.000 0.000
#> SRR1168743     3   0.430      0.301 0.000 0.476 0.524 0.000 0.000
#> SRR1168744     3   0.430      0.301 0.000 0.476 0.524 0.000 0.000
#> SRR1168745     3   0.430      0.301 0.000 0.476 0.524 0.000 0.000
#> SRR1168746     3   0.430      0.301 0.000 0.476 0.524 0.000 0.000
#> SRR1168747     2   0.000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1168748     2   0.000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1168749     2   0.000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1168750     2   0.000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1168751     2   0.000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1168752     2   0.000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1168753     2   0.000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1168754     2   0.000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1168755     2   0.000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1168756     2   0.000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1168757     2   0.000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1168758     2   0.000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1168759     2   0.000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1168760     2   0.000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1168761     3   0.634     -0.228 0.000 0.000 0.476 0.168 0.356
#> SRR1168762     3   0.634     -0.228 0.000 0.000 0.476 0.168 0.356
#> SRR1168763     3   0.634     -0.228 0.000 0.000 0.476 0.168 0.356
#> SRR1168764     3   0.634     -0.228 0.000 0.000 0.476 0.168 0.356
#> SRR1168765     3   0.634     -0.228 0.000 0.000 0.476 0.168 0.356
#> SRR1168766     3   0.634     -0.228 0.000 0.000 0.476 0.168 0.356
#> SRR1168767     3   0.634     -0.228 0.000 0.000 0.476 0.168 0.356
#> SRR1168768     3   0.634     -0.228 0.000 0.000 0.476 0.168 0.356
#> SRR1168769     4   0.273      1.000 0.160 0.000 0.000 0.840 0.000
#> SRR1168770     4   0.273      1.000 0.160 0.000 0.000 0.840 0.000
#> SRR1168771     4   0.273      1.000 0.160 0.000 0.000 0.840 0.000
#> SRR1168772     4   0.273      1.000 0.160 0.000 0.000 0.840 0.000
#> SRR1168773     4   0.273      1.000 0.160 0.000 0.000 0.840 0.000
#> SRR1168774     4   0.273      1.000 0.160 0.000 0.000 0.840 0.000
#> SRR1168775     4   0.273      1.000 0.160 0.000 0.000 0.840 0.000
#> SRR1168776     4   0.273      1.000 0.160 0.000 0.000 0.840 0.000
#> SRR1168777     4   0.273      1.000 0.160 0.000 0.000 0.840 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
#> SRR1168715     6  0.0363      0.998 0.000 0.000 0.012 0.000 0.000 0.988
#> SRR1168716     6  0.0363      0.998 0.000 0.000 0.012 0.000 0.000 0.988
#> SRR1168717     6  0.0363      0.998 0.000 0.000 0.012 0.000 0.000 0.988
#> SRR1168718     6  0.0363      0.998 0.000 0.000 0.012 0.000 0.000 0.988
#> SRR1168719     6  0.0363      0.998 0.000 0.000 0.012 0.000 0.000 0.988
#> SRR1168720     6  0.0363      0.998 0.000 0.000 0.012 0.000 0.000 0.988
#> SRR1168721     6  0.0000      0.988 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR1168722     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1168723     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1168724     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1168725     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1168726     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1168727     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1168728     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1168729     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1168730     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1168731     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1168732     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1168733     2  0.2562      1.000 0.000 0.828 0.000 0.000 0.172 0.000
#> SRR1168734     2  0.2562      1.000 0.000 0.828 0.000 0.000 0.172 0.000
#> SRR1168735     2  0.2562      1.000 0.000 0.828 0.000 0.000 0.172 0.000
#> SRR1168736     2  0.2562      1.000 0.000 0.828 0.000 0.000 0.172 0.000
#> SRR1168737     2  0.2562      1.000 0.000 0.828 0.000 0.000 0.172 0.000
#> SRR1168738     2  0.2562      1.000 0.000 0.828 0.000 0.000 0.172 0.000
#> SRR1168739     2  0.2562      1.000 0.000 0.828 0.000 0.000 0.172 0.000
#> SRR1168740     2  0.2562      1.000 0.000 0.828 0.000 0.000 0.172 0.000
#> SRR1168741     2  0.2562      1.000 0.000 0.828 0.000 0.000 0.172 0.000
#> SRR1168742     2  0.2562      1.000 0.000 0.828 0.000 0.000 0.172 0.000
#> SRR1168743     2  0.2562      1.000 0.000 0.828 0.000 0.000 0.172 0.000
#> SRR1168744     2  0.2562      1.000 0.000 0.828 0.000 0.000 0.172 0.000
#> SRR1168745     2  0.2562      1.000 0.000 0.828 0.000 0.000 0.172 0.000
#> SRR1168746     2  0.2562      1.000 0.000 0.828 0.000 0.000 0.172 0.000
#> SRR1168747     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1168748     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1168749     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1168750     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1168751     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1168752     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1168753     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1168754     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1168755     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1168756     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1168757     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1168758     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1168759     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1168760     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1168761     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1168762     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1168763     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1168764     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1168765     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1168766     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1168767     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1168768     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1168769     4  0.0146      0.983 0.004 0.000 0.000 0.996 0.000 0.000
#> SRR1168770     4  0.0146      0.983 0.004 0.000 0.000 0.996 0.000 0.000
#> SRR1168771     4  0.0000      0.980 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1168772     4  0.0146      0.983 0.004 0.000 0.000 0.996 0.000 0.000
#> SRR1168773     4  0.0146      0.983 0.004 0.000 0.000 0.996 0.000 0.000
#> SRR1168774     4  0.0146      0.983 0.004 0.000 0.000 0.996 0.000 0.000
#> SRR1168775     4  0.0146      0.983 0.004 0.000 0.000 0.996 0.000 0.000
#> SRR1168776     4  0.0146      0.983 0.004 0.000 0.000 0.996 0.000 0.000
#> SRR1168777     4  0.2562      0.857 0.000 0.172 0.000 0.828 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-skmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-skmeans-collect-classes

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


ATC:pam**

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

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

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

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 14158 rows and 63 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           1.000       1.000         0.5023 0.498   0.498
#> 3 3     1           0.993       0.996         0.3040 0.846   0.692
#> 4 4     1           0.990       0.987         0.1513 0.900   0.709
#> 5 5     1           0.988       0.982         0.0685 0.949   0.792
#> 6 6     1           1.000       1.000         0.0367 0.971   0.852

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
#> SRR1168715     1       0          1  1  0
#> SRR1168716     1       0          1  1  0
#> SRR1168717     1       0          1  1  0
#> SRR1168718     1       0          1  1  0
#> SRR1168719     1       0          1  1  0
#> SRR1168720     1       0          1  1  0
#> SRR1168721     1       0          1  1  0
#> SRR1168722     1       0          1  1  0
#> SRR1168723     1       0          1  1  0
#> SRR1168724     1       0          1  1  0
#> SRR1168725     1       0          1  1  0
#> SRR1168726     1       0          1  1  0
#> SRR1168727     1       0          1  1  0
#> SRR1168728     1       0          1  1  0
#> SRR1168729     1       0          1  1  0
#> SRR1168730     1       0          1  1  0
#> SRR1168731     1       0          1  1  0
#> SRR1168732     1       0          1  1  0
#> SRR1168733     2       0          1  0  1
#> SRR1168734     2       0          1  0  1
#> SRR1168735     2       0          1  0  1
#> SRR1168736     2       0          1  0  1
#> SRR1168737     2       0          1  0  1
#> SRR1168738     2       0          1  0  1
#> SRR1168739     2       0          1  0  1
#> SRR1168740     2       0          1  0  1
#> SRR1168741     2       0          1  0  1
#> SRR1168742     2       0          1  0  1
#> SRR1168743     2       0          1  0  1
#> SRR1168744     2       0          1  0  1
#> SRR1168745     2       0          1  0  1
#> SRR1168746     2       0          1  0  1
#> SRR1168747     2       0          1  0  1
#> SRR1168748     2       0          1  0  1
#> SRR1168749     2       0          1  0  1
#> SRR1168750     2       0          1  0  1
#> SRR1168751     2       0          1  0  1
#> SRR1168752     2       0          1  0  1
#> SRR1168753     2       0          1  0  1
#> SRR1168754     2       0          1  0  1
#> SRR1168755     2       0          1  0  1
#> SRR1168756     2       0          1  0  1
#> SRR1168757     2       0          1  0  1
#> SRR1168758     2       0          1  0  1
#> SRR1168759     2       0          1  0  1
#> SRR1168760     2       0          1  0  1
#> SRR1168761     1       0          1  1  0
#> SRR1168762     1       0          1  1  0
#> SRR1168763     1       0          1  1  0
#> SRR1168764     1       0          1  1  0
#> SRR1168765     1       0          1  1  0
#> SRR1168766     1       0          1  1  0
#> SRR1168767     1       0          1  1  0
#> SRR1168768     1       0          1  1  0
#> SRR1168769     1       0          1  1  0
#> SRR1168770     1       0          1  1  0
#> SRR1168771     1       0          1  1  0
#> SRR1168772     1       0          1  1  0
#> SRR1168773     1       0          1  1  0
#> SRR1168774     1       0          1  1  0
#> SRR1168775     1       0          1  1  0
#> SRR1168776     1       0          1  1  0
#> SRR1168777     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1 p2    p3
#> SRR1168715     3  0.0892      0.976 0.020  0 0.980
#> SRR1168716     3  0.0592      0.980 0.012  0 0.988
#> SRR1168717     3  0.0000      0.984 0.000  0 1.000
#> SRR1168718     3  0.0592      0.981 0.012  0 0.988
#> SRR1168719     3  0.0892      0.977 0.020  0 0.980
#> SRR1168720     3  0.3551      0.859 0.132  0 0.868
#> SRR1168721     3  0.1289      0.967 0.032  0 0.968
#> SRR1168722     1  0.0000      1.000 1.000  0 0.000
#> SRR1168723     1  0.0000      1.000 1.000  0 0.000
#> SRR1168724     1  0.0000      1.000 1.000  0 0.000
#> SRR1168725     1  0.0000      1.000 1.000  0 0.000
#> SRR1168726     1  0.0000      1.000 1.000  0 0.000
#> SRR1168727     1  0.0000      1.000 1.000  0 0.000
#> SRR1168728     1  0.0000      1.000 1.000  0 0.000
#> SRR1168729     1  0.0000      1.000 1.000  0 0.000
#> SRR1168730     1  0.0000      1.000 1.000  0 0.000
#> SRR1168731     1  0.0000      1.000 1.000  0 0.000
#> SRR1168732     1  0.0000      1.000 1.000  0 0.000
#> SRR1168733     2  0.0000      1.000 0.000  1 0.000
#> SRR1168734     2  0.0000      1.000 0.000  1 0.000
#> SRR1168735     2  0.0000      1.000 0.000  1 0.000
#> SRR1168736     2  0.0000      1.000 0.000  1 0.000
#> SRR1168737     2  0.0000      1.000 0.000  1 0.000
#> SRR1168738     2  0.0000      1.000 0.000  1 0.000
#> SRR1168739     2  0.0000      1.000 0.000  1 0.000
#> SRR1168740     2  0.0000      1.000 0.000  1 0.000
#> SRR1168741     2  0.0000      1.000 0.000  1 0.000
#> SRR1168742     2  0.0000      1.000 0.000  1 0.000
#> SRR1168743     2  0.0000      1.000 0.000  1 0.000
#> SRR1168744     2  0.0000      1.000 0.000  1 0.000
#> SRR1168745     2  0.0000      1.000 0.000  1 0.000
#> SRR1168746     2  0.0000      1.000 0.000  1 0.000
#> SRR1168747     2  0.0000      1.000 0.000  1 0.000
#> SRR1168748     2  0.0000      1.000 0.000  1 0.000
#> SRR1168749     2  0.0000      1.000 0.000  1 0.000
#> SRR1168750     2  0.0000      1.000 0.000  1 0.000
#> SRR1168751     2  0.0000      1.000 0.000  1 0.000
#> SRR1168752     2  0.0000      1.000 0.000  1 0.000
#> SRR1168753     2  0.0000      1.000 0.000  1 0.000
#> SRR1168754     2  0.0000      1.000 0.000  1 0.000
#> SRR1168755     2  0.0000      1.000 0.000  1 0.000
#> SRR1168756     2  0.0000      1.000 0.000  1 0.000
#> SRR1168757     2  0.0000      1.000 0.000  1 0.000
#> SRR1168758     2  0.0000      1.000 0.000  1 0.000
#> SRR1168759     2  0.0000      1.000 0.000  1 0.000
#> SRR1168760     2  0.0000      1.000 0.000  1 0.000
#> SRR1168761     3  0.0000      0.984 0.000  0 1.000
#> SRR1168762     3  0.0000      0.984 0.000  0 1.000
#> SRR1168763     3  0.0000      0.984 0.000  0 1.000
#> SRR1168764     3  0.0000      0.984 0.000  0 1.000
#> SRR1168765     3  0.0000      0.984 0.000  0 1.000
#> SRR1168766     3  0.0000      0.984 0.000  0 1.000
#> SRR1168767     3  0.0000      0.984 0.000  0 1.000
#> SRR1168768     3  0.0000      0.984 0.000  0 1.000
#> SRR1168769     1  0.0000      1.000 1.000  0 0.000
#> SRR1168770     1  0.0000      1.000 1.000  0 0.000
#> SRR1168771     1  0.0000      1.000 1.000  0 0.000
#> SRR1168772     1  0.0000      1.000 1.000  0 0.000
#> SRR1168773     1  0.0000      1.000 1.000  0 0.000
#> SRR1168774     1  0.0000      1.000 1.000  0 0.000
#> SRR1168775     1  0.0000      1.000 1.000  0 0.000
#> SRR1168776     1  0.0424      0.992 0.992  0 0.008
#> SRR1168777     1  0.0000      1.000 1.000  0 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1168715     3  0.0707      0.974 0.020 0.000 0.980 0.000
#> SRR1168716     3  0.0469      0.979 0.012 0.000 0.988 0.000
#> SRR1168717     3  0.0000      0.983 0.000 0.000 1.000 0.000
#> SRR1168718     3  0.0469      0.979 0.012 0.000 0.988 0.000
#> SRR1168719     3  0.0707      0.975 0.020 0.000 0.980 0.000
#> SRR1168720     3  0.2814      0.858 0.132 0.000 0.868 0.000
#> SRR1168721     3  0.1022      0.964 0.032 0.000 0.968 0.000
#> SRR1168722     1  0.0000      0.991 1.000 0.000 0.000 0.000
#> SRR1168723     1  0.0000      0.991 1.000 0.000 0.000 0.000
#> SRR1168724     1  0.0000      0.991 1.000 0.000 0.000 0.000
#> SRR1168725     1  0.0000      0.991 1.000 0.000 0.000 0.000
#> SRR1168726     1  0.0000      0.991 1.000 0.000 0.000 0.000
#> SRR1168727     1  0.0000      0.991 1.000 0.000 0.000 0.000
#> SRR1168728     1  0.0000      0.991 1.000 0.000 0.000 0.000
#> SRR1168729     1  0.0000      0.991 1.000 0.000 0.000 0.000
#> SRR1168730     1  0.0000      0.991 1.000 0.000 0.000 0.000
#> SRR1168731     1  0.0000      0.991 1.000 0.000 0.000 0.000
#> SRR1168732     1  0.0000      0.991 1.000 0.000 0.000 0.000
#> SRR1168733     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR1168734     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR1168735     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR1168736     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR1168737     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR1168738     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR1168739     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR1168740     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR1168741     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR1168742     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR1168743     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR1168744     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR1168745     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR1168746     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR1168747     4  0.0817      1.000 0.000 0.024 0.000 0.976
#> SRR1168748     4  0.0817      1.000 0.000 0.024 0.000 0.976
#> SRR1168749     4  0.0817      1.000 0.000 0.024 0.000 0.976
#> SRR1168750     4  0.0817      1.000 0.000 0.024 0.000 0.976
#> SRR1168751     4  0.0817      1.000 0.000 0.024 0.000 0.976
#> SRR1168752     4  0.0817      1.000 0.000 0.024 0.000 0.976
#> SRR1168753     4  0.0817      1.000 0.000 0.024 0.000 0.976
#> SRR1168754     4  0.0817      1.000 0.000 0.024 0.000 0.976
#> SRR1168755     4  0.0817      1.000 0.000 0.024 0.000 0.976
#> SRR1168756     4  0.0817      1.000 0.000 0.024 0.000 0.976
#> SRR1168757     4  0.0817      1.000 0.000 0.024 0.000 0.976
#> SRR1168758     4  0.0817      1.000 0.000 0.024 0.000 0.976
#> SRR1168759     4  0.0817      1.000 0.000 0.024 0.000 0.976
#> SRR1168760     4  0.0817      1.000 0.000 0.024 0.000 0.976
#> SRR1168761     3  0.0000      0.983 0.000 0.000 1.000 0.000
#> SRR1168762     3  0.0000      0.983 0.000 0.000 1.000 0.000
#> SRR1168763     3  0.0000      0.983 0.000 0.000 1.000 0.000
#> SRR1168764     3  0.0000      0.983 0.000 0.000 1.000 0.000
#> SRR1168765     3  0.0000      0.983 0.000 0.000 1.000 0.000
#> SRR1168766     3  0.0000      0.983 0.000 0.000 1.000 0.000
#> SRR1168767     3  0.0000      0.983 0.000 0.000 1.000 0.000
#> SRR1168768     3  0.0000      0.983 0.000 0.000 1.000 0.000
#> SRR1168769     1  0.0817      0.989 0.976 0.000 0.000 0.024
#> SRR1168770     1  0.0817      0.989 0.976 0.000 0.000 0.024
#> SRR1168771     1  0.0817      0.989 0.976 0.000 0.000 0.024
#> SRR1168772     1  0.0817      0.989 0.976 0.000 0.000 0.024
#> SRR1168773     1  0.0817      0.989 0.976 0.000 0.000 0.024
#> SRR1168774     1  0.0817      0.989 0.976 0.000 0.000 0.024
#> SRR1168775     1  0.0817      0.989 0.976 0.000 0.000 0.024
#> SRR1168776     1  0.1151      0.984 0.968 0.000 0.008 0.024
#> SRR1168777     1  0.0817      0.989 0.976 0.000 0.000 0.024

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1 p2    p3    p4 p5
#> SRR1168715     3   0.252      0.937 0.056  0 0.896 0.048  0
#> SRR1168716     3   0.207      0.949 0.032  0 0.920 0.048  0
#> SRR1168717     3   0.120      0.953 0.000  0 0.952 0.048  0
#> SRR1168718     3   0.215      0.948 0.036  0 0.916 0.048  0
#> SRR1168719     3   0.223      0.946 0.040  0 0.912 0.048  0
#> SRR1168720     3   0.339      0.882 0.116  0 0.836 0.048  0
#> SRR1168721     3   0.278      0.925 0.072  0 0.880 0.048  0
#> SRR1168722     1   0.000      1.000 1.000  0 0.000 0.000  0
#> SRR1168723     1   0.000      1.000 1.000  0 0.000 0.000  0
#> SRR1168724     1   0.000      1.000 1.000  0 0.000 0.000  0
#> SRR1168725     1   0.000      1.000 1.000  0 0.000 0.000  0
#> SRR1168726     1   0.000      1.000 1.000  0 0.000 0.000  0
#> SRR1168727     1   0.000      1.000 1.000  0 0.000 0.000  0
#> SRR1168728     1   0.000      1.000 1.000  0 0.000 0.000  0
#> SRR1168729     1   0.000      1.000 1.000  0 0.000 0.000  0
#> SRR1168730     1   0.000      1.000 1.000  0 0.000 0.000  0
#> SRR1168731     1   0.000      1.000 1.000  0 0.000 0.000  0
#> SRR1168732     1   0.000      1.000 1.000  0 0.000 0.000  0
#> SRR1168733     2   0.000      1.000 0.000  1 0.000 0.000  0
#> SRR1168734     2   0.000      1.000 0.000  1 0.000 0.000  0
#> SRR1168735     2   0.000      1.000 0.000  1 0.000 0.000  0
#> SRR1168736     2   0.000      1.000 0.000  1 0.000 0.000  0
#> SRR1168737     2   0.000      1.000 0.000  1 0.000 0.000  0
#> SRR1168738     2   0.000      1.000 0.000  1 0.000 0.000  0
#> SRR1168739     2   0.000      1.000 0.000  1 0.000 0.000  0
#> SRR1168740     2   0.000      1.000 0.000  1 0.000 0.000  0
#> SRR1168741     2   0.000      1.000 0.000  1 0.000 0.000  0
#> SRR1168742     2   0.000      1.000 0.000  1 0.000 0.000  0
#> SRR1168743     2   0.000      1.000 0.000  1 0.000 0.000  0
#> SRR1168744     2   0.000      1.000 0.000  1 0.000 0.000  0
#> SRR1168745     2   0.000      1.000 0.000  1 0.000 0.000  0
#> SRR1168746     2   0.000      1.000 0.000  1 0.000 0.000  0
#> SRR1168747     5   0.000      1.000 0.000  0 0.000 0.000  1
#> SRR1168748     5   0.000      1.000 0.000  0 0.000 0.000  1
#> SRR1168749     5   0.000      1.000 0.000  0 0.000 0.000  1
#> SRR1168750     5   0.000      1.000 0.000  0 0.000 0.000  1
#> SRR1168751     5   0.000      1.000 0.000  0 0.000 0.000  1
#> SRR1168752     5   0.000      1.000 0.000  0 0.000 0.000  1
#> SRR1168753     5   0.000      1.000 0.000  0 0.000 0.000  1
#> SRR1168754     5   0.000      1.000 0.000  0 0.000 0.000  1
#> SRR1168755     5   0.000      1.000 0.000  0 0.000 0.000  1
#> SRR1168756     5   0.000      1.000 0.000  0 0.000 0.000  1
#> SRR1168757     5   0.000      1.000 0.000  0 0.000 0.000  1
#> SRR1168758     5   0.000      1.000 0.000  0 0.000 0.000  1
#> SRR1168759     5   0.000      1.000 0.000  0 0.000 0.000  1
#> SRR1168760     5   0.000      1.000 0.000  0 0.000 0.000  1
#> SRR1168761     3   0.000      0.962 0.000  0 1.000 0.000  0
#> SRR1168762     3   0.000      0.962 0.000  0 1.000 0.000  0
#> SRR1168763     3   0.000      0.962 0.000  0 1.000 0.000  0
#> SRR1168764     3   0.000      0.962 0.000  0 1.000 0.000  0
#> SRR1168765     3   0.000      0.962 0.000  0 1.000 0.000  0
#> SRR1168766     3   0.000      0.962 0.000  0 1.000 0.000  0
#> SRR1168767     3   0.000      0.962 0.000  0 1.000 0.000  0
#> SRR1168768     3   0.000      0.962 0.000  0 1.000 0.000  0
#> SRR1168769     4   0.120      1.000 0.048  0 0.000 0.952  0
#> SRR1168770     4   0.120      1.000 0.048  0 0.000 0.952  0
#> SRR1168771     4   0.120      1.000 0.048  0 0.000 0.952  0
#> SRR1168772     4   0.120      1.000 0.048  0 0.000 0.952  0
#> SRR1168773     4   0.120      1.000 0.048  0 0.000 0.952  0
#> SRR1168774     4   0.120      1.000 0.048  0 0.000 0.952  0
#> SRR1168775     4   0.120      1.000 0.048  0 0.000 0.952  0
#> SRR1168776     4   0.120      1.000 0.048  0 0.000 0.952  0
#> SRR1168777     4   0.120      1.000 0.048  0 0.000 0.952  0

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1168715     6       0          1  0  0  0  0  0  1
#> SRR1168716     6       0          1  0  0  0  0  0  1
#> SRR1168717     6       0          1  0  0  0  0  0  1
#> SRR1168718     6       0          1  0  0  0  0  0  1
#> SRR1168719     6       0          1  0  0  0  0  0  1
#> SRR1168720     6       0          1  0  0  0  0  0  1
#> SRR1168721     6       0          1  0  0  0  0  0  1
#> SRR1168722     1       0          1  1  0  0  0  0  0
#> SRR1168723     1       0          1  1  0  0  0  0  0
#> SRR1168724     1       0          1  1  0  0  0  0  0
#> SRR1168725     1       0          1  1  0  0  0  0  0
#> SRR1168726     1       0          1  1  0  0  0  0  0
#> SRR1168727     1       0          1  1  0  0  0  0  0
#> SRR1168728     1       0          1  1  0  0  0  0  0
#> SRR1168729     1       0          1  1  0  0  0  0  0
#> SRR1168730     1       0          1  1  0  0  0  0  0
#> SRR1168731     1       0          1  1  0  0  0  0  0
#> SRR1168732     1       0          1  1  0  0  0  0  0
#> SRR1168733     2       0          1  0  1  0  0  0  0
#> SRR1168734     2       0          1  0  1  0  0  0  0
#> SRR1168735     2       0          1  0  1  0  0  0  0
#> SRR1168736     2       0          1  0  1  0  0  0  0
#> SRR1168737     2       0          1  0  1  0  0  0  0
#> SRR1168738     2       0          1  0  1  0  0  0  0
#> SRR1168739     2       0          1  0  1  0  0  0  0
#> SRR1168740     2       0          1  0  1  0  0  0  0
#> SRR1168741     2       0          1  0  1  0  0  0  0
#> SRR1168742     2       0          1  0  1  0  0  0  0
#> SRR1168743     2       0          1  0  1  0  0  0  0
#> SRR1168744     2       0          1  0  1  0  0  0  0
#> SRR1168745     2       0          1  0  1  0  0  0  0
#> SRR1168746     2       0          1  0  1  0  0  0  0
#> SRR1168747     5       0          1  0  0  0  0  1  0
#> SRR1168748     5       0          1  0  0  0  0  1  0
#> SRR1168749     5       0          1  0  0  0  0  1  0
#> SRR1168750     5       0          1  0  0  0  0  1  0
#> SRR1168751     5       0          1  0  0  0  0  1  0
#> SRR1168752     5       0          1  0  0  0  0  1  0
#> SRR1168753     5       0          1  0  0  0  0  1  0
#> SRR1168754     5       0          1  0  0  0  0  1  0
#> SRR1168755     5       0          1  0  0  0  0  1  0
#> SRR1168756     5       0          1  0  0  0  0  1  0
#> SRR1168757     5       0          1  0  0  0  0  1  0
#> SRR1168758     5       0          1  0  0  0  0  1  0
#> SRR1168759     5       0          1  0  0  0  0  1  0
#> SRR1168760     5       0          1  0  0  0  0  1  0
#> SRR1168761     3       0          1  0  0  1  0  0  0
#> SRR1168762     3       0          1  0  0  1  0  0  0
#> SRR1168763     3       0          1  0  0  1  0  0  0
#> SRR1168764     3       0          1  0  0  1  0  0  0
#> SRR1168765     3       0          1  0  0  1  0  0  0
#> SRR1168766     3       0          1  0  0  1  0  0  0
#> SRR1168767     3       0          1  0  0  1  0  0  0
#> SRR1168768     3       0          1  0  0  1  0  0  0
#> SRR1168769     4       0          1  0  0  0  1  0  0
#> SRR1168770     4       0          1  0  0  0  1  0  0
#> SRR1168771     4       0          1  0  0  0  1  0  0
#> SRR1168772     4       0          1  0  0  0  1  0  0
#> SRR1168773     4       0          1  0  0  0  1  0  0
#> SRR1168774     4       0          1  0  0  0  1  0  0
#> SRR1168775     4       0          1  0  0  0  1  0  0
#> SRR1168776     4       0          1  0  0  0  1  0  0
#> SRR1168777     4       0          1  0  0  0  1  0  0

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

consensus_heatmap(res, k = 2)

plot of chunk tab-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 14158 rows and 63 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 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-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           1.000       1.000         0.5023 0.498   0.498
#> 3 3 1.000           0.996       0.992         0.2009 0.900   0.799
#> 4 4 0.931           0.980       0.981         0.2231 0.865   0.660
#> 5 5 1.000           0.999       0.996         0.0922 0.931   0.737
#> 6 6 1.000           1.000       1.000         0.0365 0.971   0.852

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
#> SRR1168715     1       0          1  1  0
#> SRR1168716     1       0          1  1  0
#> SRR1168717     1       0          1  1  0
#> SRR1168718     1       0          1  1  0
#> SRR1168719     1       0          1  1  0
#> SRR1168720     1       0          1  1  0
#> SRR1168721     1       0          1  1  0
#> SRR1168722     1       0          1  1  0
#> SRR1168723     1       0          1  1  0
#> SRR1168724     1       0          1  1  0
#> SRR1168725     1       0          1  1  0
#> SRR1168726     1       0          1  1  0
#> SRR1168727     1       0          1  1  0
#> SRR1168728     1       0          1  1  0
#> SRR1168729     1       0          1  1  0
#> SRR1168730     1       0          1  1  0
#> SRR1168731     1       0          1  1  0
#> SRR1168732     1       0          1  1  0
#> SRR1168733     2       0          1  0  1
#> SRR1168734     2       0          1  0  1
#> SRR1168735     2       0          1  0  1
#> SRR1168736     2       0          1  0  1
#> SRR1168737     2       0          1  0  1
#> SRR1168738     2       0          1  0  1
#> SRR1168739     2       0          1  0  1
#> SRR1168740     2       0          1  0  1
#> SRR1168741     2       0          1  0  1
#> SRR1168742     2       0          1  0  1
#> SRR1168743     2       0          1  0  1
#> SRR1168744     2       0          1  0  1
#> SRR1168745     2       0          1  0  1
#> SRR1168746     2       0          1  0  1
#> SRR1168747     2       0          1  0  1
#> SRR1168748     2       0          1  0  1
#> SRR1168749     2       0          1  0  1
#> SRR1168750     2       0          1  0  1
#> SRR1168751     2       0          1  0  1
#> SRR1168752     2       0          1  0  1
#> SRR1168753     2       0          1  0  1
#> SRR1168754     2       0          1  0  1
#> SRR1168755     2       0          1  0  1
#> SRR1168756     2       0          1  0  1
#> SRR1168757     2       0          1  0  1
#> SRR1168758     2       0          1  0  1
#> SRR1168759     2       0          1  0  1
#> SRR1168760     2       0          1  0  1
#> SRR1168761     1       0          1  1  0
#> SRR1168762     1       0          1  1  0
#> SRR1168763     1       0          1  1  0
#> SRR1168764     1       0          1  1  0
#> SRR1168765     1       0          1  1  0
#> SRR1168766     1       0          1  1  0
#> SRR1168767     1       0          1  1  0
#> SRR1168768     1       0          1  1  0
#> SRR1168769     1       0          1  1  0
#> SRR1168770     1       0          1  1  0
#> SRR1168771     1       0          1  1  0
#> SRR1168772     1       0          1  1  0
#> SRR1168773     1       0          1  1  0
#> SRR1168774     1       0          1  1  0
#> SRR1168775     1       0          1  1  0
#> SRR1168776     1       0          1  1  0
#> SRR1168777     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette   p1   p2   p3
#> SRR1168715     1  0.0000      0.995 1.00 0.00 0.00
#> SRR1168716     1  0.0000      0.995 1.00 0.00 0.00
#> SRR1168717     1  0.0000      0.995 1.00 0.00 0.00
#> SRR1168718     1  0.0000      0.995 1.00 0.00 0.00
#> SRR1168719     1  0.0000      0.995 1.00 0.00 0.00
#> SRR1168720     1  0.0000      0.995 1.00 0.00 0.00
#> SRR1168721     1  0.0000      0.995 1.00 0.00 0.00
#> SRR1168722     1  0.0892      0.988 0.98 0.02 0.00
#> SRR1168723     1  0.0892      0.988 0.98 0.02 0.00
#> SRR1168724     1  0.0892      0.988 0.98 0.02 0.00
#> SRR1168725     1  0.0892      0.988 0.98 0.02 0.00
#> SRR1168726     1  0.0892      0.988 0.98 0.02 0.00
#> SRR1168727     1  0.0892      0.988 0.98 0.02 0.00
#> SRR1168728     1  0.0892      0.988 0.98 0.02 0.00
#> SRR1168729     1  0.0892      0.988 0.98 0.02 0.00
#> SRR1168730     1  0.0892      0.988 0.98 0.02 0.00
#> SRR1168731     1  0.0892      0.988 0.98 0.02 0.00
#> SRR1168732     1  0.0892      0.988 0.98 0.02 0.00
#> SRR1168733     2  0.0892      1.000 0.00 0.98 0.02
#> SRR1168734     2  0.0892      1.000 0.00 0.98 0.02
#> SRR1168735     2  0.0892      1.000 0.00 0.98 0.02
#> SRR1168736     2  0.0892      1.000 0.00 0.98 0.02
#> SRR1168737     2  0.0892      1.000 0.00 0.98 0.02
#> SRR1168738     2  0.0892      1.000 0.00 0.98 0.02
#> SRR1168739     2  0.0892      1.000 0.00 0.98 0.02
#> SRR1168740     2  0.0892      1.000 0.00 0.98 0.02
#> SRR1168741     2  0.0892      1.000 0.00 0.98 0.02
#> SRR1168742     2  0.0892      1.000 0.00 0.98 0.02
#> SRR1168743     2  0.0892      1.000 0.00 0.98 0.02
#> SRR1168744     2  0.0892      1.000 0.00 0.98 0.02
#> SRR1168745     2  0.0892      1.000 0.00 0.98 0.02
#> SRR1168746     2  0.0892      1.000 0.00 0.98 0.02
#> SRR1168747     3  0.0000      1.000 0.00 0.00 1.00
#> SRR1168748     3  0.0000      1.000 0.00 0.00 1.00
#> SRR1168749     3  0.0000      1.000 0.00 0.00 1.00
#> SRR1168750     3  0.0000      1.000 0.00 0.00 1.00
#> SRR1168751     3  0.0000      1.000 0.00 0.00 1.00
#> SRR1168752     3  0.0000      1.000 0.00 0.00 1.00
#> SRR1168753     3  0.0000      1.000 0.00 0.00 1.00
#> SRR1168754     3  0.0000      1.000 0.00 0.00 1.00
#> SRR1168755     3  0.0000      1.000 0.00 0.00 1.00
#> SRR1168756     3  0.0000      1.000 0.00 0.00 1.00
#> SRR1168757     3  0.0000      1.000 0.00 0.00 1.00
#> SRR1168758     3  0.0000      1.000 0.00 0.00 1.00
#> SRR1168759     3  0.0000      1.000 0.00 0.00 1.00
#> SRR1168760     3  0.0000      1.000 0.00 0.00 1.00
#> SRR1168761     1  0.0000      0.995 1.00 0.00 0.00
#> SRR1168762     1  0.0000      0.995 1.00 0.00 0.00
#> SRR1168763     1  0.0000      0.995 1.00 0.00 0.00
#> SRR1168764     1  0.0000      0.995 1.00 0.00 0.00
#> SRR1168765     1  0.0000      0.995 1.00 0.00 0.00
#> SRR1168766     1  0.0000      0.995 1.00 0.00 0.00
#> SRR1168767     1  0.0000      0.995 1.00 0.00 0.00
#> SRR1168768     1  0.0000      0.995 1.00 0.00 0.00
#> SRR1168769     1  0.0000      0.995 1.00 0.00 0.00
#> SRR1168770     1  0.0000      0.995 1.00 0.00 0.00
#> SRR1168771     1  0.0000      0.995 1.00 0.00 0.00
#> SRR1168772     1  0.0000      0.995 1.00 0.00 0.00
#> SRR1168773     1  0.0000      0.995 1.00 0.00 0.00
#> SRR1168774     1  0.0000      0.995 1.00 0.00 0.00
#> SRR1168775     1  0.0000      0.995 1.00 0.00 0.00
#> SRR1168776     1  0.0000      0.995 1.00 0.00 0.00
#> SRR1168777     1  0.0000      0.995 1.00 0.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
#> SRR1168715     3  0.0000      0.961 0.000 0.000 1.0 0.000
#> SRR1168716     3  0.0000      0.961 0.000 0.000 1.0 0.000
#> SRR1168717     3  0.0000      0.961 0.000 0.000 1.0 0.000
#> SRR1168718     3  0.0000      0.961 0.000 0.000 1.0 0.000
#> SRR1168719     3  0.0000      0.961 0.000 0.000 1.0 0.000
#> SRR1168720     3  0.0000      0.961 0.000 0.000 1.0 0.000
#> SRR1168721     3  0.0000      0.961 0.000 0.000 1.0 0.000
#> SRR1168722     1  0.0000      1.000 1.000 0.000 0.0 0.000
#> SRR1168723     1  0.0000      1.000 1.000 0.000 0.0 0.000
#> SRR1168724     1  0.0000      1.000 1.000 0.000 0.0 0.000
#> SRR1168725     1  0.0000      1.000 1.000 0.000 0.0 0.000
#> SRR1168726     1  0.0000      1.000 1.000 0.000 0.0 0.000
#> SRR1168727     1  0.0000      1.000 1.000 0.000 0.0 0.000
#> SRR1168728     1  0.0000      1.000 1.000 0.000 0.0 0.000
#> SRR1168729     1  0.0000      1.000 1.000 0.000 0.0 0.000
#> SRR1168730     1  0.0000      1.000 1.000 0.000 0.0 0.000
#> SRR1168731     1  0.0000      1.000 1.000 0.000 0.0 0.000
#> SRR1168732     1  0.0000      1.000 1.000 0.000 0.0 0.000
#> SRR1168733     2  0.0707      1.000 0.000 0.980 0.0 0.020
#> SRR1168734     2  0.0707      1.000 0.000 0.980 0.0 0.020
#> SRR1168735     2  0.0707      1.000 0.000 0.980 0.0 0.020
#> SRR1168736     2  0.0707      1.000 0.000 0.980 0.0 0.020
#> SRR1168737     2  0.0707      1.000 0.000 0.980 0.0 0.020
#> SRR1168738     2  0.0707      1.000 0.000 0.980 0.0 0.020
#> SRR1168739     2  0.0707      1.000 0.000 0.980 0.0 0.020
#> SRR1168740     2  0.0707      1.000 0.000 0.980 0.0 0.020
#> SRR1168741     2  0.0707      1.000 0.000 0.980 0.0 0.020
#> SRR1168742     2  0.0707      1.000 0.000 0.980 0.0 0.020
#> SRR1168743     2  0.0707      1.000 0.000 0.980 0.0 0.020
#> SRR1168744     2  0.0707      1.000 0.000 0.980 0.0 0.020
#> SRR1168745     2  0.0707      1.000 0.000 0.980 0.0 0.020
#> SRR1168746     2  0.0707      1.000 0.000 0.980 0.0 0.020
#> SRR1168747     4  0.0188      0.999 0.000 0.004 0.0 0.996
#> SRR1168748     4  0.0188      0.999 0.000 0.004 0.0 0.996
#> SRR1168749     4  0.0188      0.999 0.000 0.004 0.0 0.996
#> SRR1168750     4  0.0188      0.999 0.000 0.004 0.0 0.996
#> SRR1168751     4  0.0000      0.996 0.000 0.000 0.0 1.000
#> SRR1168752     4  0.0000      0.996 0.000 0.000 0.0 1.000
#> SRR1168753     4  0.0188      0.999 0.000 0.004 0.0 0.996
#> SRR1168754     4  0.0188      0.999 0.000 0.004 0.0 0.996
#> SRR1168755     4  0.0188      0.999 0.000 0.004 0.0 0.996
#> SRR1168756     4  0.0188      0.999 0.000 0.004 0.0 0.996
#> SRR1168757     4  0.0188      0.999 0.000 0.004 0.0 0.996
#> SRR1168758     4  0.0188      0.999 0.000 0.004 0.0 0.996
#> SRR1168759     4  0.0188      0.999 0.000 0.004 0.0 0.996
#> SRR1168760     4  0.0188      0.999 0.000 0.004 0.0 0.996
#> SRR1168761     3  0.0000      0.961 0.000 0.000 1.0 0.000
#> SRR1168762     3  0.0000      0.961 0.000 0.000 1.0 0.000
#> SRR1168763     3  0.0000      0.961 0.000 0.000 1.0 0.000
#> SRR1168764     3  0.0000      0.961 0.000 0.000 1.0 0.000
#> SRR1168765     3  0.0000      0.961 0.000 0.000 1.0 0.000
#> SRR1168766     3  0.0000      0.961 0.000 0.000 1.0 0.000
#> SRR1168767     3  0.0000      0.961 0.000 0.000 1.0 0.000
#> SRR1168768     3  0.0000      0.961 0.000 0.000 1.0 0.000
#> SRR1168769     3  0.2610      0.931 0.088 0.012 0.9 0.000
#> SRR1168770     3  0.2610      0.931 0.088 0.012 0.9 0.000
#> SRR1168771     3  0.2610      0.931 0.088 0.012 0.9 0.000
#> SRR1168772     3  0.2610      0.931 0.088 0.012 0.9 0.000
#> SRR1168773     3  0.2610      0.931 0.088 0.012 0.9 0.000
#> SRR1168774     3  0.2610      0.931 0.088 0.012 0.9 0.000
#> SRR1168775     3  0.2610      0.931 0.088 0.012 0.9 0.000
#> SRR1168776     3  0.2610      0.931 0.088 0.012 0.9 0.000
#> SRR1168777     3  0.2610      0.931 0.088 0.012 0.9 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette p1    p2    p3 p4    p5
#> SRR1168715     3  0.0404      0.995  0 0.000 0.988  0 0.012
#> SRR1168716     3  0.0404      0.995  0 0.000 0.988  0 0.012
#> SRR1168717     3  0.0404      0.995  0 0.000 0.988  0 0.012
#> SRR1168718     3  0.0404      0.995  0 0.000 0.988  0 0.012
#> SRR1168719     3  0.0404      0.995  0 0.000 0.988  0 0.012
#> SRR1168720     3  0.0404      0.995  0 0.000 0.988  0 0.012
#> SRR1168721     3  0.0404      0.995  0 0.000 0.988  0 0.012
#> SRR1168722     1  0.0000      1.000  1 0.000 0.000  0 0.000
#> SRR1168723     1  0.0000      1.000  1 0.000 0.000  0 0.000
#> SRR1168724     1  0.0000      1.000  1 0.000 0.000  0 0.000
#> SRR1168725     1  0.0000      1.000  1 0.000 0.000  0 0.000
#> SRR1168726     1  0.0000      1.000  1 0.000 0.000  0 0.000
#> SRR1168727     1  0.0000      1.000  1 0.000 0.000  0 0.000
#> SRR1168728     1  0.0000      1.000  1 0.000 0.000  0 0.000
#> SRR1168729     1  0.0000      1.000  1 0.000 0.000  0 0.000
#> SRR1168730     1  0.0000      1.000  1 0.000 0.000  0 0.000
#> SRR1168731     1  0.0000      1.000  1 0.000 0.000  0 0.000
#> SRR1168732     1  0.0000      1.000  1 0.000 0.000  0 0.000
#> SRR1168733     2  0.0000      1.000  0 1.000 0.000  0 0.000
#> SRR1168734     2  0.0000      1.000  0 1.000 0.000  0 0.000
#> SRR1168735     2  0.0000      1.000  0 1.000 0.000  0 0.000
#> SRR1168736     2  0.0000      1.000  0 1.000 0.000  0 0.000
#> SRR1168737     2  0.0000      1.000  0 1.000 0.000  0 0.000
#> SRR1168738     2  0.0000      1.000  0 1.000 0.000  0 0.000
#> SRR1168739     2  0.0000      1.000  0 1.000 0.000  0 0.000
#> SRR1168740     2  0.0000      1.000  0 1.000 0.000  0 0.000
#> SRR1168741     2  0.0000      1.000  0 1.000 0.000  0 0.000
#> SRR1168742     2  0.0000      1.000  0 1.000 0.000  0 0.000
#> SRR1168743     2  0.0000      1.000  0 1.000 0.000  0 0.000
#> SRR1168744     2  0.0000      1.000  0 1.000 0.000  0 0.000
#> SRR1168745     2  0.0000      1.000  0 1.000 0.000  0 0.000
#> SRR1168746     2  0.0000      1.000  0 1.000 0.000  0 0.000
#> SRR1168747     5  0.0404      1.000  0 0.012 0.000  0 0.988
#> SRR1168748     5  0.0404      1.000  0 0.012 0.000  0 0.988
#> SRR1168749     5  0.0404      1.000  0 0.012 0.000  0 0.988
#> SRR1168750     5  0.0404      1.000  0 0.012 0.000  0 0.988
#> SRR1168751     5  0.0404      1.000  0 0.012 0.000  0 0.988
#> SRR1168752     5  0.0404      1.000  0 0.012 0.000  0 0.988
#> SRR1168753     5  0.0404      1.000  0 0.012 0.000  0 0.988
#> SRR1168754     5  0.0404      1.000  0 0.012 0.000  0 0.988
#> SRR1168755     5  0.0404      1.000  0 0.012 0.000  0 0.988
#> SRR1168756     5  0.0404      1.000  0 0.012 0.000  0 0.988
#> SRR1168757     5  0.0404      1.000  0 0.012 0.000  0 0.988
#> SRR1168758     5  0.0404      1.000  0 0.012 0.000  0 0.988
#> SRR1168759     5  0.0404      1.000  0 0.012 0.000  0 0.988
#> SRR1168760     5  0.0404      1.000  0 0.012 0.000  0 0.988
#> SRR1168761     3  0.0000      0.995  0 0.000 1.000  0 0.000
#> SRR1168762     3  0.0000      0.995  0 0.000 1.000  0 0.000
#> SRR1168763     3  0.0000      0.995  0 0.000 1.000  0 0.000
#> SRR1168764     3  0.0000      0.995  0 0.000 1.000  0 0.000
#> SRR1168765     3  0.0000      0.995  0 0.000 1.000  0 0.000
#> SRR1168766     3  0.0000      0.995  0 0.000 1.000  0 0.000
#> SRR1168767     3  0.0000      0.995  0 0.000 1.000  0 0.000
#> SRR1168768     3  0.0000      0.995  0 0.000 1.000  0 0.000
#> SRR1168769     4  0.0000      1.000  0 0.000 0.000  1 0.000
#> SRR1168770     4  0.0000      1.000  0 0.000 0.000  1 0.000
#> SRR1168771     4  0.0000      1.000  0 0.000 0.000  1 0.000
#> SRR1168772     4  0.0000      1.000  0 0.000 0.000  1 0.000
#> SRR1168773     4  0.0000      1.000  0 0.000 0.000  1 0.000
#> SRR1168774     4  0.0000      1.000  0 0.000 0.000  1 0.000
#> SRR1168775     4  0.0000      1.000  0 0.000 0.000  1 0.000
#> SRR1168776     4  0.0000      1.000  0 0.000 0.000  1 0.000
#> SRR1168777     4  0.0000      1.000  0 0.000 0.000  1 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1168715     6       0          1  0  0  0  0  0  1
#> SRR1168716     6       0          1  0  0  0  0  0  1
#> SRR1168717     6       0          1  0  0  0  0  0  1
#> SRR1168718     6       0          1  0  0  0  0  0  1
#> SRR1168719     6       0          1  0  0  0  0  0  1
#> SRR1168720     6       0          1  0  0  0  0  0  1
#> SRR1168721     6       0          1  0  0  0  0  0  1
#> SRR1168722     1       0          1  1  0  0  0  0  0
#> SRR1168723     1       0          1  1  0  0  0  0  0
#> SRR1168724     1       0          1  1  0  0  0  0  0
#> SRR1168725     1       0          1  1  0  0  0  0  0
#> SRR1168726     1       0          1  1  0  0  0  0  0
#> SRR1168727     1       0          1  1  0  0  0  0  0
#> SRR1168728     1       0          1  1  0  0  0  0  0
#> SRR1168729     1       0          1  1  0  0  0  0  0
#> SRR1168730     1       0          1  1  0  0  0  0  0
#> SRR1168731     1       0          1  1  0  0  0  0  0
#> SRR1168732     1       0          1  1  0  0  0  0  0
#> SRR1168733     2       0          1  0  1  0  0  0  0
#> SRR1168734     2       0          1  0  1  0  0  0  0
#> SRR1168735     2       0          1  0  1  0  0  0  0
#> SRR1168736     2       0          1  0  1  0  0  0  0
#> SRR1168737     2       0          1  0  1  0  0  0  0
#> SRR1168738     2       0          1  0  1  0  0  0  0
#> SRR1168739     2       0          1  0  1  0  0  0  0
#> SRR1168740     2       0          1  0  1  0  0  0  0
#> SRR1168741     2       0          1  0  1  0  0  0  0
#> SRR1168742     2       0          1  0  1  0  0  0  0
#> SRR1168743     2       0          1  0  1  0  0  0  0
#> SRR1168744     2       0          1  0  1  0  0  0  0
#> SRR1168745     2       0          1  0  1  0  0  0  0
#> SRR1168746     2       0          1  0  1  0  0  0  0
#> SRR1168747     5       0          1  0  0  0  0  1  0
#> SRR1168748     5       0          1  0  0  0  0  1  0
#> SRR1168749     5       0          1  0  0  0  0  1  0
#> SRR1168750     5       0          1  0  0  0  0  1  0
#> SRR1168751     5       0          1  0  0  0  0  1  0
#> SRR1168752     5       0          1  0  0  0  0  1  0
#> SRR1168753     5       0          1  0  0  0  0  1  0
#> SRR1168754     5       0          1  0  0  0  0  1  0
#> SRR1168755     5       0          1  0  0  0  0  1  0
#> SRR1168756     5       0          1  0  0  0  0  1  0
#> SRR1168757     5       0          1  0  0  0  0  1  0
#> SRR1168758     5       0          1  0  0  0  0  1  0
#> SRR1168759     5       0          1  0  0  0  0  1  0
#> SRR1168760     5       0          1  0  0  0  0  1  0
#> SRR1168761     3       0          1  0  0  1  0  0  0
#> SRR1168762     3       0          1  0  0  1  0  0  0
#> SRR1168763     3       0          1  0  0  1  0  0  0
#> SRR1168764     3       0          1  0  0  1  0  0  0
#> SRR1168765     3       0          1  0  0  1  0  0  0
#> SRR1168766     3       0          1  0  0  1  0  0  0
#> SRR1168767     3       0          1  0  0  1  0  0  0
#> SRR1168768     3       0          1  0  0  1  0  0  0
#> SRR1168769     4       0          1  0  0  0  1  0  0
#> SRR1168770     4       0          1  0  0  0  1  0  0
#> SRR1168771     4       0          1  0  0  0  1  0  0
#> SRR1168772     4       0          1  0  0  0  1  0  0
#> SRR1168773     4       0          1  0  0  0  1  0  0
#> SRR1168774     4       0          1  0  0  0  1  0  0
#> SRR1168775     4       0          1  0  0  0  1  0  0
#> SRR1168776     4       0          1  0  0  0  1  0  0
#> SRR1168777     4       0          1  0  0  0  1  0  0

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

consensus_heatmap(res, k = 2)

plot of chunk tab-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 14158 rows and 63 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.5023 0.498   0.498
#> 3 3 0.846           0.928       0.922         0.0959 1.000   1.000
#> 4 4 0.746           0.944       0.869         0.1344 0.846   0.692
#> 5 5 0.650           0.826       0.806         0.0947 1.000   1.000
#> 6 6 0.680           0.868       0.819         0.0753 0.900   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
#> SRR1168715     1       0          1  1  0
#> SRR1168716     1       0          1  1  0
#> SRR1168717     1       0          1  1  0
#> SRR1168718     1       0          1  1  0
#> SRR1168719     1       0          1  1  0
#> SRR1168720     1       0          1  1  0
#> SRR1168721     1       0          1  1  0
#> SRR1168722     1       0          1  1  0
#> SRR1168723     1       0          1  1  0
#> SRR1168724     1       0          1  1  0
#> SRR1168725     1       0          1  1  0
#> SRR1168726     1       0          1  1  0
#> SRR1168727     1       0          1  1  0
#> SRR1168728     1       0          1  1  0
#> SRR1168729     1       0          1  1  0
#> SRR1168730     1       0          1  1  0
#> SRR1168731     1       0          1  1  0
#> SRR1168732     1       0          1  1  0
#> SRR1168733     2       0          1  0  1
#> SRR1168734     2       0          1  0  1
#> SRR1168735     2       0          1  0  1
#> SRR1168736     2       0          1  0  1
#> SRR1168737     2       0          1  0  1
#> SRR1168738     2       0          1  0  1
#> SRR1168739     2       0          1  0  1
#> SRR1168740     2       0          1  0  1
#> SRR1168741     2       0          1  0  1
#> SRR1168742     2       0          1  0  1
#> SRR1168743     2       0          1  0  1
#> SRR1168744     2       0          1  0  1
#> SRR1168745     2       0          1  0  1
#> SRR1168746     2       0          1  0  1
#> SRR1168747     2       0          1  0  1
#> SRR1168748     2       0          1  0  1
#> SRR1168749     2       0          1  0  1
#> SRR1168750     2       0          1  0  1
#> SRR1168751     2       0          1  0  1
#> SRR1168752     2       0          1  0  1
#> SRR1168753     2       0          1  0  1
#> SRR1168754     2       0          1  0  1
#> SRR1168755     2       0          1  0  1
#> SRR1168756     2       0          1  0  1
#> SRR1168757     2       0          1  0  1
#> SRR1168758     2       0          1  0  1
#> SRR1168759     2       0          1  0  1
#> SRR1168760     2       0          1  0  1
#> SRR1168761     1       0          1  1  0
#> SRR1168762     1       0          1  1  0
#> SRR1168763     1       0          1  1  0
#> SRR1168764     1       0          1  1  0
#> SRR1168765     1       0          1  1  0
#> SRR1168766     1       0          1  1  0
#> SRR1168767     1       0          1  1  0
#> SRR1168768     1       0          1  1  0
#> SRR1168769     1       0          1  1  0
#> SRR1168770     1       0          1  1  0
#> SRR1168771     1       0          1  1  0
#> SRR1168772     1       0          1  1  0
#> SRR1168773     1       0          1  1  0
#> SRR1168774     1       0          1  1  0
#> SRR1168775     1       0          1  1  0
#> SRR1168776     1       0          1  1  0
#> SRR1168777     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1168715     1  0.5397      0.864 0.720 0.000 0.280
#> SRR1168716     1  0.5397      0.864 0.720 0.000 0.280
#> SRR1168717     1  0.5397      0.864 0.720 0.000 0.280
#> SRR1168718     1  0.5397      0.864 0.720 0.000 0.280
#> SRR1168719     1  0.5397      0.864 0.720 0.000 0.280
#> SRR1168720     1  0.5397      0.864 0.720 0.000 0.280
#> SRR1168721     1  0.5397      0.864 0.720 0.000 0.280
#> SRR1168722     1  0.0000      0.900 1.000 0.000 0.000
#> SRR1168723     1  0.0000      0.900 1.000 0.000 0.000
#> SRR1168724     1  0.0000      0.900 1.000 0.000 0.000
#> SRR1168725     1  0.0000      0.900 1.000 0.000 0.000
#> SRR1168726     1  0.0000      0.900 1.000 0.000 0.000
#> SRR1168727     1  0.0000      0.900 1.000 0.000 0.000
#> SRR1168728     1  0.0000      0.900 1.000 0.000 0.000
#> SRR1168729     1  0.0000      0.900 1.000 0.000 0.000
#> SRR1168730     1  0.0000      0.900 1.000 0.000 0.000
#> SRR1168731     1  0.0000      0.900 1.000 0.000 0.000
#> SRR1168732     1  0.0000      0.900 1.000 0.000 0.000
#> SRR1168733     2  0.1753      0.982 0.000 0.952 0.048
#> SRR1168734     2  0.1753      0.982 0.000 0.952 0.048
#> SRR1168735     2  0.1753      0.982 0.000 0.952 0.048
#> SRR1168736     2  0.1753      0.982 0.000 0.952 0.048
#> SRR1168737     2  0.1753      0.982 0.000 0.952 0.048
#> SRR1168738     2  0.1753      0.982 0.000 0.952 0.048
#> SRR1168739     2  0.1753      0.982 0.000 0.952 0.048
#> SRR1168740     2  0.1753      0.982 0.000 0.952 0.048
#> SRR1168741     2  0.1753      0.982 0.000 0.952 0.048
#> SRR1168742     2  0.1753      0.982 0.000 0.952 0.048
#> SRR1168743     2  0.1753      0.982 0.000 0.952 0.048
#> SRR1168744     2  0.1753      0.982 0.000 0.952 0.048
#> SRR1168745     2  0.1753      0.982 0.000 0.952 0.048
#> SRR1168746     2  0.1753      0.982 0.000 0.952 0.048
#> SRR1168747     2  0.0000      0.982 0.000 1.000 0.000
#> SRR1168748     2  0.0000      0.982 0.000 1.000 0.000
#> SRR1168749     2  0.0000      0.982 0.000 1.000 0.000
#> SRR1168750     2  0.0000      0.982 0.000 1.000 0.000
#> SRR1168751     2  0.0000      0.982 0.000 1.000 0.000
#> SRR1168752     2  0.0000      0.982 0.000 1.000 0.000
#> SRR1168753     2  0.0000      0.982 0.000 1.000 0.000
#> SRR1168754     2  0.0000      0.982 0.000 1.000 0.000
#> SRR1168755     2  0.0000      0.982 0.000 1.000 0.000
#> SRR1168756     2  0.0000      0.982 0.000 1.000 0.000
#> SRR1168757     2  0.0000      0.982 0.000 1.000 0.000
#> SRR1168758     2  0.0000      0.982 0.000 1.000 0.000
#> SRR1168759     2  0.0000      0.982 0.000 1.000 0.000
#> SRR1168760     2  0.0000      0.982 0.000 1.000 0.000
#> SRR1168761     1  0.5431      0.864 0.716 0.000 0.284
#> SRR1168762     1  0.5431      0.864 0.716 0.000 0.284
#> SRR1168763     1  0.5431      0.864 0.716 0.000 0.284
#> SRR1168764     1  0.5431      0.864 0.716 0.000 0.284
#> SRR1168765     1  0.5431      0.864 0.716 0.000 0.284
#> SRR1168766     1  0.5431      0.864 0.716 0.000 0.284
#> SRR1168767     1  0.5431      0.864 0.716 0.000 0.284
#> SRR1168768     1  0.5431      0.864 0.716 0.000 0.284
#> SRR1168769     1  0.0237      0.900 0.996 0.000 0.004
#> SRR1168770     1  0.0237      0.900 0.996 0.000 0.004
#> SRR1168771     1  0.0237      0.900 0.996 0.000 0.004
#> SRR1168772     1  0.0237      0.900 0.996 0.000 0.004
#> SRR1168773     1  0.0237      0.900 0.996 0.000 0.004
#> SRR1168774     1  0.0237      0.900 0.996 0.000 0.004
#> SRR1168775     1  0.0237      0.900 0.996 0.000 0.004
#> SRR1168776     1  0.0237      0.900 0.996 0.000 0.004
#> SRR1168777     1  0.0237      0.900 0.996 0.000 0.004

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3 p4
#> SRR1168715     3   0.230      0.940 0.064 0.000 0.920 NA
#> SRR1168716     3   0.230      0.940 0.064 0.000 0.920 NA
#> SRR1168717     3   0.230      0.940 0.064 0.000 0.920 NA
#> SRR1168718     3   0.230      0.940 0.064 0.000 0.920 NA
#> SRR1168719     3   0.230      0.940 0.064 0.000 0.920 NA
#> SRR1168720     3   0.230      0.940 0.064 0.000 0.920 NA
#> SRR1168721     3   0.230      0.940 0.064 0.000 0.920 NA
#> SRR1168722     1   0.452      0.980 0.680 0.000 0.320 NA
#> SRR1168723     1   0.452      0.980 0.680 0.000 0.320 NA
#> SRR1168724     1   0.452      0.980 0.680 0.000 0.320 NA
#> SRR1168725     1   0.452      0.980 0.680 0.000 0.320 NA
#> SRR1168726     1   0.452      0.980 0.680 0.000 0.320 NA
#> SRR1168727     1   0.452      0.980 0.680 0.000 0.320 NA
#> SRR1168728     1   0.452      0.980 0.680 0.000 0.320 NA
#> SRR1168729     1   0.452      0.980 0.680 0.000 0.320 NA
#> SRR1168730     1   0.452      0.980 0.680 0.000 0.320 NA
#> SRR1168731     1   0.452      0.980 0.680 0.000 0.320 NA
#> SRR1168732     1   0.452      0.980 0.680 0.000 0.320 NA
#> SRR1168733     2   0.349      0.918 0.000 0.812 0.000 NA
#> SRR1168734     2   0.349      0.918 0.000 0.812 0.000 NA
#> SRR1168735     2   0.349      0.918 0.000 0.812 0.000 NA
#> SRR1168736     2   0.349      0.918 0.000 0.812 0.000 NA
#> SRR1168737     2   0.349      0.918 0.000 0.812 0.000 NA
#> SRR1168738     2   0.349      0.918 0.000 0.812 0.000 NA
#> SRR1168739     2   0.349      0.918 0.000 0.812 0.000 NA
#> SRR1168740     2   0.349      0.918 0.000 0.812 0.000 NA
#> SRR1168741     2   0.349      0.918 0.000 0.812 0.000 NA
#> SRR1168742     2   0.349      0.918 0.000 0.812 0.000 NA
#> SRR1168743     2   0.349      0.918 0.000 0.812 0.000 NA
#> SRR1168744     2   0.349      0.918 0.000 0.812 0.000 NA
#> SRR1168745     2   0.349      0.918 0.000 0.812 0.000 NA
#> SRR1168746     2   0.349      0.918 0.000 0.812 0.000 NA
#> SRR1168747     2   0.000      0.918 0.000 1.000 0.000 NA
#> SRR1168748     2   0.000      0.918 0.000 1.000 0.000 NA
#> SRR1168749     2   0.000      0.918 0.000 1.000 0.000 NA
#> SRR1168750     2   0.000      0.918 0.000 1.000 0.000 NA
#> SRR1168751     2   0.000      0.918 0.000 1.000 0.000 NA
#> SRR1168752     2   0.000      0.918 0.000 1.000 0.000 NA
#> SRR1168753     2   0.000      0.918 0.000 1.000 0.000 NA
#> SRR1168754     2   0.000      0.918 0.000 1.000 0.000 NA
#> SRR1168755     2   0.000      0.918 0.000 1.000 0.000 NA
#> SRR1168756     2   0.000      0.918 0.000 1.000 0.000 NA
#> SRR1168757     2   0.000      0.918 0.000 1.000 0.000 NA
#> SRR1168758     2   0.000      0.918 0.000 1.000 0.000 NA
#> SRR1168759     2   0.000      0.918 0.000 1.000 0.000 NA
#> SRR1168760     2   0.000      0.918 0.000 1.000 0.000 NA
#> SRR1168761     3   0.000      0.950 0.000 0.000 1.000 NA
#> SRR1168762     3   0.000      0.950 0.000 0.000 1.000 NA
#> SRR1168763     3   0.000      0.950 0.000 0.000 1.000 NA
#> SRR1168764     3   0.000      0.950 0.000 0.000 1.000 NA
#> SRR1168765     3   0.000      0.950 0.000 0.000 1.000 NA
#> SRR1168766     3   0.000      0.950 0.000 0.000 1.000 NA
#> SRR1168767     3   0.000      0.950 0.000 0.000 1.000 NA
#> SRR1168768     3   0.000      0.950 0.000 0.000 1.000 NA
#> SRR1168769     1   0.482      0.976 0.652 0.000 0.344 NA
#> SRR1168770     1   0.482      0.976 0.652 0.000 0.344 NA
#> SRR1168771     1   0.482      0.976 0.652 0.000 0.344 NA
#> SRR1168772     1   0.482      0.976 0.652 0.000 0.344 NA
#> SRR1168773     1   0.482      0.976 0.652 0.000 0.344 NA
#> SRR1168774     1   0.482      0.976 0.652 0.000 0.344 NA
#> SRR1168775     1   0.482      0.976 0.652 0.000 0.344 NA
#> SRR1168776     1   0.482      0.976 0.652 0.000 0.344 NA
#> SRR1168777     1   0.482      0.976 0.652 0.000 0.344 NA

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3 p4 p5
#> SRR1168715     3  0.4995      0.878 0.264 0.000 0.668 NA NA
#> SRR1168716     3  0.4995      0.878 0.264 0.000 0.668 NA NA
#> SRR1168717     3  0.4995      0.878 0.264 0.000 0.668 NA NA
#> SRR1168718     3  0.4995      0.878 0.264 0.000 0.668 NA NA
#> SRR1168719     3  0.4995      0.878 0.264 0.000 0.668 NA NA
#> SRR1168720     3  0.4995      0.878 0.264 0.000 0.668 NA NA
#> SRR1168721     3  0.5051      0.875 0.264 0.000 0.664 NA NA
#> SRR1168722     1  0.0963      0.854 0.964 0.000 0.036 NA NA
#> SRR1168723     1  0.0963      0.855 0.964 0.000 0.036 NA NA
#> SRR1168724     1  0.1251      0.850 0.956 0.000 0.036 NA NA
#> SRR1168725     1  0.1124      0.853 0.960 0.000 0.036 NA NA
#> SRR1168726     1  0.0880      0.856 0.968 0.000 0.032 NA NA
#> SRR1168727     1  0.0880      0.856 0.968 0.000 0.032 NA NA
#> SRR1168728     1  0.0880      0.856 0.968 0.000 0.032 NA NA
#> SRR1168729     1  0.0880      0.856 0.968 0.000 0.032 NA NA
#> SRR1168730     1  0.1041      0.855 0.964 0.000 0.032 NA NA
#> SRR1168731     1  0.0880      0.856 0.968 0.000 0.032 NA NA
#> SRR1168732     1  0.0963      0.855 0.964 0.000 0.036 NA NA
#> SRR1168733     2  0.0162      0.784 0.000 0.996 0.000 NA NA
#> SRR1168734     2  0.0290      0.785 0.000 0.992 0.000 NA NA
#> SRR1168735     2  0.0000      0.784 0.000 1.000 0.000 NA NA
#> SRR1168736     2  0.0000      0.784 0.000 1.000 0.000 NA NA
#> SRR1168737     2  0.0000      0.784 0.000 1.000 0.000 NA NA
#> SRR1168738     2  0.0000      0.784 0.000 1.000 0.000 NA NA
#> SRR1168739     2  0.0000      0.784 0.000 1.000 0.000 NA NA
#> SRR1168740     2  0.0000      0.784 0.000 1.000 0.000 NA NA
#> SRR1168741     2  0.0162      0.784 0.000 0.996 0.000 NA NA
#> SRR1168742     2  0.0162      0.784 0.000 0.996 0.000 NA NA
#> SRR1168743     2  0.0000      0.784 0.000 1.000 0.000 NA NA
#> SRR1168744     2  0.0162      0.784 0.000 0.996 0.000 NA NA
#> SRR1168745     2  0.0000      0.784 0.000 1.000 0.000 NA NA
#> SRR1168746     2  0.0162      0.782 0.000 0.996 0.000 NA NA
#> SRR1168747     2  0.4268      0.785 0.000 0.556 0.000 NA NA
#> SRR1168748     2  0.4268      0.785 0.000 0.556 0.000 NA NA
#> SRR1168749     2  0.4268      0.785 0.000 0.556 0.000 NA NA
#> SRR1168750     2  0.4268      0.785 0.000 0.556 0.000 NA NA
#> SRR1168751     2  0.4268      0.785 0.000 0.556 0.000 NA NA
#> SRR1168752     2  0.4268      0.785 0.000 0.556 0.000 NA NA
#> SRR1168753     2  0.4268      0.785 0.000 0.556 0.000 NA NA
#> SRR1168754     2  0.4268      0.785 0.000 0.556 0.000 NA NA
#> SRR1168755     2  0.4268      0.785 0.000 0.556 0.000 NA NA
#> SRR1168756     2  0.4273      0.783 0.000 0.552 0.000 NA NA
#> SRR1168757     2  0.4268      0.785 0.000 0.556 0.000 NA NA
#> SRR1168758     2  0.4268      0.785 0.000 0.556 0.000 NA NA
#> SRR1168759     2  0.4268      0.785 0.000 0.556 0.000 NA NA
#> SRR1168760     2  0.4268      0.785 0.000 0.556 0.000 NA NA
#> SRR1168761     3  0.2848      0.895 0.156 0.000 0.840 NA NA
#> SRR1168762     3  0.2971      0.896 0.156 0.000 0.836 NA NA
#> SRR1168763     3  0.2971      0.893 0.156 0.000 0.836 NA NA
#> SRR1168764     3  0.2848      0.895 0.156 0.000 0.840 NA NA
#> SRR1168765     3  0.2848      0.895 0.156 0.000 0.840 NA NA
#> SRR1168766     3  0.2848      0.895 0.156 0.000 0.840 NA NA
#> SRR1168767     3  0.3129      0.891 0.156 0.000 0.832 NA NA
#> SRR1168768     3  0.2690      0.896 0.156 0.000 0.844 NA NA
#> SRR1168769     1  0.4797      0.822 0.776 0.000 0.092 NA NA
#> SRR1168770     1  0.4797      0.822 0.776 0.000 0.092 NA NA
#> SRR1168771     1  0.4797      0.822 0.776 0.000 0.092 NA NA
#> SRR1168772     1  0.4864      0.819 0.772 0.000 0.092 NA NA
#> SRR1168773     1  0.4797      0.822 0.776 0.000 0.092 NA NA
#> SRR1168774     1  0.4797      0.822 0.776 0.000 0.092 NA NA
#> SRR1168775     1  0.4916      0.816 0.768 0.000 0.096 NA NA
#> SRR1168776     1  0.4916      0.816 0.768 0.000 0.096 NA NA
#> SRR1168777     1  0.4631      0.825 0.788 0.000 0.084 NA 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
#> SRR1168715     3  0.5028      0.832 0.176 0.000 0.656 NA 0.000 0.004
#> SRR1168716     3  0.5028      0.832 0.176 0.000 0.656 NA 0.000 0.004
#> SRR1168717     3  0.4997      0.833 0.176 0.000 0.660 NA 0.000 0.004
#> SRR1168718     3  0.5028      0.832 0.176 0.000 0.656 NA 0.000 0.004
#> SRR1168719     3  0.5028      0.832 0.176 0.000 0.656 NA 0.000 0.004
#> SRR1168720     3  0.5028      0.832 0.176 0.000 0.656 NA 0.000 0.004
#> SRR1168721     3  0.4998      0.830 0.172 0.000 0.660 NA 0.000 0.004
#> SRR1168722     1  0.1036      0.760 0.964 0.000 0.024 NA 0.000 0.008
#> SRR1168723     1  0.0777      0.768 0.972 0.000 0.024 NA 0.000 0.004
#> SRR1168724     1  0.0972      0.761 0.964 0.000 0.028 NA 0.000 0.008
#> SRR1168725     1  0.0713      0.767 0.972 0.000 0.028 NA 0.000 0.000
#> SRR1168726     1  0.0790      0.768 0.968 0.000 0.032 NA 0.000 0.000
#> SRR1168727     1  0.0632      0.767 0.976 0.000 0.024 NA 0.000 0.000
#> SRR1168728     1  0.0632      0.767 0.976 0.000 0.024 NA 0.000 0.000
#> SRR1168729     1  0.0632      0.767 0.976 0.000 0.024 NA 0.000 0.000
#> SRR1168730     1  0.0790      0.767 0.968 0.000 0.032 NA 0.000 0.000
#> SRR1168731     1  0.0777      0.768 0.972 0.000 0.024 NA 0.000 0.004
#> SRR1168732     1  0.0547      0.767 0.980 0.000 0.020 NA 0.000 0.000
#> SRR1168733     2  0.1364      0.966 0.000 0.944 0.000 NA 0.048 0.004
#> SRR1168734     2  0.1082      0.966 0.000 0.956 0.000 NA 0.040 0.000
#> SRR1168735     2  0.1003      0.972 0.000 0.964 0.000 NA 0.028 0.004
#> SRR1168736     2  0.0405      0.963 0.000 0.988 0.000 NA 0.008 0.000
#> SRR1168737     2  0.0951      0.972 0.000 0.968 0.000 NA 0.020 0.004
#> SRR1168738     2  0.0748      0.968 0.000 0.976 0.000 NA 0.016 0.004
#> SRR1168739     2  0.0692      0.973 0.000 0.976 0.000 NA 0.020 0.000
#> SRR1168740     2  0.1049      0.973 0.000 0.960 0.000 NA 0.032 0.008
#> SRR1168741     2  0.1296      0.968 0.000 0.948 0.000 NA 0.044 0.004
#> SRR1168742     2  0.0363      0.965 0.000 0.988 0.000 NA 0.012 0.000
#> SRR1168743     2  0.1124      0.968 0.000 0.956 0.000 NA 0.036 0.008
#> SRR1168744     2  0.1340      0.968 0.000 0.948 0.000 NA 0.040 0.004
#> SRR1168745     2  0.1124      0.971 0.000 0.956 0.000 NA 0.036 0.000
#> SRR1168746     2  0.1116      0.970 0.000 0.960 0.000 NA 0.028 0.004
#> SRR1168747     5  0.3445      0.988 0.000 0.260 0.000 NA 0.732 0.008
#> SRR1168748     5  0.3490      0.986 0.000 0.268 0.000 NA 0.724 0.008
#> SRR1168749     5  0.3468      0.987 0.000 0.264 0.000 NA 0.728 0.008
#> SRR1168750     5  0.3490      0.987 0.000 0.268 0.000 NA 0.724 0.008
#> SRR1168751     5  0.3175      0.987 0.000 0.256 0.000 NA 0.744 0.000
#> SRR1168752     5  0.3702      0.984 0.000 0.264 0.000 NA 0.720 0.012
#> SRR1168753     5  0.3288      0.984 0.000 0.276 0.000 NA 0.724 0.000
#> SRR1168754     5  0.3221      0.988 0.000 0.264 0.000 NA 0.736 0.000
#> SRR1168755     5  0.3360      0.988 0.000 0.264 0.000 NA 0.732 0.000
#> SRR1168756     5  0.3314      0.986 0.000 0.256 0.000 NA 0.740 0.004
#> SRR1168757     5  0.3337      0.987 0.000 0.260 0.000 NA 0.736 0.004
#> SRR1168758     5  0.3426      0.983 0.000 0.276 0.000 NA 0.720 0.004
#> SRR1168759     5  0.3518      0.985 0.000 0.256 0.000 NA 0.732 0.012
#> SRR1168760     5  0.3564      0.988 0.000 0.264 0.000 NA 0.724 0.012
#> SRR1168761     3  0.1556      0.854 0.080 0.000 0.920 NA 0.000 0.000
#> SRR1168762     3  0.1700      0.855 0.080 0.000 0.916 NA 0.000 0.000
#> SRR1168763     3  0.1812      0.856 0.080 0.000 0.912 NA 0.000 0.000
#> SRR1168764     3  0.1843      0.855 0.080 0.000 0.912 NA 0.000 0.004
#> SRR1168765     3  0.1812      0.851 0.080 0.000 0.912 NA 0.000 0.008
#> SRR1168766     3  0.1843      0.854 0.080 0.000 0.912 NA 0.000 0.004
#> SRR1168767     3  0.1812      0.851 0.080 0.000 0.912 NA 0.000 0.008
#> SRR1168768     3  0.1556      0.854 0.080 0.000 0.920 NA 0.000 0.000
#> SRR1168769     1  0.5354      0.693 0.580 0.000 0.160 NA 0.000 0.260
#> SRR1168770     1  0.5325      0.695 0.584 0.000 0.156 NA 0.000 0.260
#> SRR1168771     1  0.5354      0.696 0.580 0.000 0.160 NA 0.000 0.260
#> SRR1168772     1  0.5365      0.692 0.580 0.000 0.164 NA 0.000 0.256
#> SRR1168773     1  0.5336      0.695 0.584 0.000 0.160 NA 0.000 0.256
#> SRR1168774     1  0.5336      0.695 0.584 0.000 0.160 NA 0.000 0.256
#> SRR1168775     1  0.5428      0.684 0.568 0.000 0.168 NA 0.000 0.264
#> SRR1168776     1  0.5411      0.687 0.572 0.000 0.168 NA 0.000 0.260
#> SRR1168777     1  0.5420      0.685 0.572 0.000 0.172 NA 0.000 0.256

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