cola Report for recount2:SRP034712

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

The call of run_all_consensus_partition_methods() was:

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

Dimension of the input matrix:

mat = get_matrix(res_list)
dim(mat)
#> [1] 18325    52

Density distribution

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

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

plot of chunk density-heatmap

Suggest the best k

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

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

suggest_best_k(res_list)
The best k 1-PAC Mean silhouette Concordance Optional k
SD:mclust 2 1.000 1.000 1.000 **
CV:kmeans 2 1.000 0.954 0.977 **
CV:skmeans 3 1.000 0.977 0.991 ** 2
CV:NMF 2 1.000 0.971 0.988 **
MAD:skmeans 3 1.000 0.972 0.985 ** 2
MAD:pam 3 1.000 0.972 0.988 ** 2
MAD:mclust 2 1.000 1.000 1.000 **
ATC:hclust 6 1.000 0.968 0.993 ** 3,4
ATC:kmeans 2 1.000 0.953 0.983 **
ATC:pam 6 1.000 0.972 0.995 ** 2,4,5
ATC:mclust 5 1.000 0.969 0.980 ** 2,3
ATC:NMF 3 1.000 0.944 0.978 ** 2
ATC:skmeans 4 0.990 0.970 0.978 ** 2
MAD:NMF 3 0.949 0.944 0.970 * 2
CV:hclust 2 0.922 0.967 0.982 *
MAD:kmeans 2 0.919 0.898 0.960 *
SD:skmeans 3 0.918 0.925 0.964 * 2
CV:mclust 6 0.898 0.890 0.938
MAD:hclust 2 0.883 0.928 0.958
SD:pam 3 0.878 0.891 0.958
SD:hclust 5 0.847 0.900 0.953
SD:kmeans 6 0.799 0.867 0.879
SD:NMF 2 0.704 0.923 0.961
CV:pam 5 0.562 0.785 0.941

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

CDF of consensus matrices

Cumulative distribution function curves of consensus matrix for all methods.

collect_plots(res_list, fun = plot_ecdf)

plot of chunk collect-plots

Consensus heatmap

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

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

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

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

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

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

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

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

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

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

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

Membership heatmap

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

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

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

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

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

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

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

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

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

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

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

Signature heatmap

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

Note in following heatmaps, rows are scaled.

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

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

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

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

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

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

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

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

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

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

Statistics table

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

get_stats(res_list, k = 2)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      2 0.704           0.923       0.961         0.5001 0.502   0.502
#> CV:NMF      2 1.000           0.971       0.988         0.5095 0.490   0.490
#> MAD:NMF     2 1.000           0.997       0.998         0.4986 0.502   0.502
#> ATC:NMF     2 1.000           0.982       0.990         0.4995 0.502   0.502
#> SD:skmeans  2 1.000           0.977       0.991         0.4958 0.502   0.502
#> CV:skmeans  2 1.000           0.993       0.995         0.4987 0.502   0.502
#> MAD:skmeans 2 1.000           0.991       0.996         0.4928 0.509   0.509
#> ATC:skmeans 2 1.000           0.986       0.994         0.4889 0.509   0.509
#> SD:mclust   2 1.000           1.000       1.000         0.3623 0.638   0.638
#> CV:mclust   2 0.463           0.882       0.905         0.4639 0.497   0.497
#> MAD:mclust  2 1.000           1.000       1.000         0.3626 0.638   0.638
#> ATC:mclust  2 1.000           0.997       0.998         0.3636 0.638   0.638
#> SD:kmeans   2 0.506           0.865       0.913         0.4662 0.517   0.517
#> CV:kmeans   2 1.000           0.954       0.977         0.4800 0.517   0.517
#> MAD:kmeans  2 0.919           0.898       0.960         0.4702 0.551   0.551
#> ATC:kmeans  2 1.000           0.953       0.983         0.4357 0.551   0.551
#> SD:pam      2 0.809           0.890       0.956         0.4754 0.527   0.527
#> CV:pam      2 0.571           0.886       0.947         0.1041 0.962   0.962
#> MAD:pam     2 1.000           0.983       0.992         0.4649 0.538   0.538
#> ATC:pam     2 1.000           0.999       1.000         0.4496 0.551   0.551
#> SD:hclust   2 0.290           0.797       0.798         0.3855 0.509   0.509
#> CV:hclust   2 0.922           0.967       0.982         0.0993 0.889   0.889
#> MAD:hclust  2 0.883           0.928       0.958         0.4914 0.497   0.497
#> ATC:hclust  2 0.792           0.952       0.973         0.4744 0.509   0.509
get_stats(res_list, k = 3)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      3 0.766           0.874       0.931          0.319 0.818   0.649
#> CV:NMF      3 0.800           0.826       0.883          0.228 0.889   0.777
#> MAD:NMF     3 0.949           0.944       0.970          0.317 0.818   0.649
#> ATC:NMF     3 1.000           0.944       0.978          0.215 0.695   0.494
#> SD:skmeans  3 0.918           0.925       0.964          0.321 0.818   0.649
#> CV:skmeans  3 1.000           0.977       0.991          0.352 0.778   0.576
#> MAD:skmeans 3 1.000           0.972       0.985          0.317 0.842   0.689
#> ATC:skmeans 3 0.856           0.951       0.956          0.268 0.798   0.628
#> SD:mclust   3 0.636           0.818       0.913          0.641 0.759   0.623
#> CV:mclust   3 0.575           0.731       0.857          0.343 0.618   0.385
#> MAD:mclust  3 0.627           0.864       0.913          0.676 0.759   0.623
#> ATC:mclust  3 0.953           0.986       0.993          0.639 0.714   0.570
#> SD:kmeans   3 0.538           0.546       0.717          0.380 0.687   0.472
#> CV:kmeans   3 0.614           0.744       0.785          0.257 0.876   0.770
#> MAD:kmeans  3 0.536           0.385       0.640          0.308 0.784   0.639
#> ATC:kmeans  3 0.775           0.916       0.921          0.355 0.774   0.618
#> SD:pam      3 0.878           0.891       0.958          0.218 0.889   0.792
#> CV:pam      3 0.583           0.891       0.956          0.295 0.962   0.961
#> MAD:pam     3 1.000           0.972       0.988          0.213 0.889   0.797
#> ATC:pam     3 0.899           0.910       0.961          0.380 0.837   0.705
#> SD:hclust   3 0.605           0.723       0.864          0.467 0.985   0.970
#> CV:hclust   3 0.883           0.920       0.972          0.670 0.929   0.920
#> MAD:hclust  3 0.821           0.853       0.940          0.123 0.979   0.958
#> ATC:hclust  3 0.923           0.974       0.958          0.165 0.932   0.867
get_stats(res_list, k = 4)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      4 0.696           0.719       0.862         0.0925 0.913   0.759
#> CV:NMF      4 0.719           0.908       0.879         0.1451 0.900   0.747
#> MAD:NMF     4 0.821           0.833       0.925         0.0634 0.939   0.832
#> ATC:NMF     4 0.781           0.727       0.894         0.1382 0.898   0.755
#> SD:skmeans  4 0.793           0.845       0.892         0.1100 0.913   0.754
#> CV:skmeans  4 0.730           0.691       0.822         0.1066 0.947   0.839
#> MAD:skmeans 4 0.875           0.897       0.935         0.1160 0.913   0.754
#> ATC:skmeans 4 0.990           0.970       0.978         0.1359 0.914   0.775
#> SD:mclust   4 0.837           0.918       0.955         0.1425 0.907   0.773
#> CV:mclust   4 0.801           0.930       0.931         0.1826 0.778   0.473
#> MAD:mclust  4 0.885           0.832       0.923         0.0927 0.916   0.793
#> ATC:mclust  4 0.860           0.882       0.937         0.0866 0.949   0.876
#> SD:kmeans   4 0.644           0.772       0.844         0.1128 0.863   0.641
#> CV:kmeans   4 0.597           0.580       0.715         0.1112 0.861   0.687
#> MAD:kmeans  4 0.695           0.855       0.881         0.1421 0.780   0.531
#> ATC:kmeans  4 0.704           0.942       0.928         0.1528 0.896   0.744
#> SD:pam      4 0.754           0.839       0.927         0.0666 0.978   0.949
#> CV:pam      4 0.583           0.868       0.955         0.2871 0.963   0.960
#> MAD:pam     4 0.851           0.791       0.912         0.1264 0.977   0.949
#> ATC:pam     4 1.000           0.992       0.995         0.1270 0.902   0.751
#> SD:hclust   4 0.726           0.860       0.914         0.1846 0.821   0.637
#> CV:hclust   4 0.820           0.893       0.950         0.2615 0.997   0.996
#> MAD:hclust  4 0.864           0.882       0.952         0.0781 0.943   0.881
#> ATC:hclust  4 1.000           0.976       0.997         0.0554 0.977   0.949
get_stats(res_list, k = 5)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      5 0.679           0.675       0.833         0.0665 0.900   0.680
#> CV:NMF      5 0.801           0.695       0.839         0.1064 0.923   0.738
#> MAD:NMF     5 0.707           0.757       0.856         0.0777 0.919   0.752
#> ATC:NMF     5 0.720           0.791       0.881         0.0607 0.887   0.674
#> SD:skmeans  5 0.804           0.845       0.889         0.0762 0.948   0.815
#> CV:skmeans  5 0.713           0.617       0.757         0.0616 0.930   0.757
#> MAD:skmeans 5 0.807           0.803       0.865         0.0787 0.948   0.815
#> ATC:skmeans 5 0.862           0.772       0.898         0.0849 0.968   0.895
#> SD:mclust   5 0.782           0.852       0.903         0.1273 0.910   0.724
#> CV:mclust   5 0.825           0.870       0.921         0.0780 0.934   0.743
#> MAD:mclust  5 0.689           0.700       0.800         0.1618 0.885   0.647
#> ATC:mclust  5 1.000           0.969       0.980         0.1330 0.882   0.682
#> SD:kmeans   5 0.711           0.739       0.831         0.0647 0.962   0.859
#> CV:kmeans   5 0.588           0.660       0.744         0.0758 0.833   0.537
#> MAD:kmeans  5 0.762           0.458       0.736         0.0832 0.920   0.740
#> ATC:kmeans  5 0.878           0.827       0.922         0.0782 0.983   0.945
#> SD:pam      5 0.741           0.807       0.912         0.0495 0.979   0.948
#> CV:pam      5 0.562           0.785       0.941         0.2261 0.929   0.920
#> MAD:pam     5 0.787           0.707       0.841         0.0534 0.942   0.864
#> ATC:pam     5 1.000           0.995       0.997         0.0391 0.973   0.910
#> SD:hclust   5 0.847           0.900       0.953         0.0567 0.962   0.878
#> CV:hclust   5 0.820           0.899       0.975         0.0544 0.999   0.999
#> MAD:hclust  5 0.811           0.855       0.899         0.0988 0.923   0.817
#> ATC:hclust  5 0.836           0.896       0.906         0.1749 0.867   0.683
get_stats(res_list, k = 6)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      6 0.766           0.710       0.835         0.0359 0.957   0.829
#> CV:NMF      6 0.776           0.626       0.772         0.0437 0.937   0.722
#> MAD:NMF     6 0.726           0.767       0.865         0.0372 0.956   0.830
#> ATC:NMF     6 0.728           0.654       0.831         0.0522 0.943   0.799
#> SD:skmeans  6 0.873           0.668       0.822         0.0631 0.922   0.679
#> CV:skmeans  6 0.713           0.596       0.734         0.0406 0.894   0.577
#> MAD:skmeans 6 0.826           0.755       0.861         0.0590 0.925   0.682
#> ATC:skmeans 6 0.813           0.731       0.868         0.0455 0.942   0.789
#> SD:mclust   6 0.826           0.713       0.855         0.0784 0.937   0.732
#> CV:mclust   6 0.898           0.890       0.938         0.0242 0.975   0.876
#> MAD:mclust  6 0.751           0.725       0.819         0.0683 0.944   0.747
#> ATC:mclust  6 0.876           0.869       0.922         0.1130 0.912   0.662
#> SD:kmeans   6 0.799           0.867       0.879         0.0484 0.942   0.762
#> CV:kmeans   6 0.591           0.694       0.801         0.0472 0.955   0.825
#> MAD:kmeans  6 0.846           0.861       0.889         0.0497 0.893   0.609
#> ATC:kmeans  6 0.833           0.802       0.848         0.0551 0.928   0.749
#> SD:pam      6 0.679           0.757       0.888         0.0495 0.980   0.947
#> CV:pam      6 0.633           0.812       0.950         0.1633 0.999   0.999
#> MAD:pam     6 0.758           0.592       0.841         0.0398 0.922   0.807
#> ATC:pam     6 1.000           0.972       0.995         0.0239 0.983   0.940
#> SD:hclust   6 0.821           0.845       0.930         0.0154 0.998   0.995
#> CV:hclust   6 0.619           0.813       0.919         0.5486 0.814   0.773
#> MAD:hclust  6 0.801           0.820       0.916         0.0250 0.998   0.996
#> ATC:hclust  6 1.000           0.968       0.993         0.1050 0.957   0.850

Following heatmap plots the partition for each combination of methods and the lightness correspond to the silhouette scores for samples in each method. On top the consensus subgroup is inferred from all methods by taking the mean silhouette scores as weight.

collect_stats(res_list, k = 2)

plot of chunk tab-collect-stats-from-consensus-partition-list-1

collect_stats(res_list, k = 3)

plot of chunk tab-collect-stats-from-consensus-partition-list-2

collect_stats(res_list, k = 4)

plot of chunk tab-collect-stats-from-consensus-partition-list-3

collect_stats(res_list, k = 5)

plot of chunk tab-collect-stats-from-consensus-partition-list-4

collect_stats(res_list, k = 6)

plot of chunk tab-collect-stats-from-consensus-partition-list-5

Partition from all methods

Collect partitions from all methods:

collect_classes(res_list, k = 2)

plot of chunk tab-collect-classes-from-consensus-partition-list-1

collect_classes(res_list, k = 3)

plot of chunk tab-collect-classes-from-consensus-partition-list-2

collect_classes(res_list, k = 4)

plot of chunk tab-collect-classes-from-consensus-partition-list-3

collect_classes(res_list, k = 5)

plot of chunk tab-collect-classes-from-consensus-partition-list-4

collect_classes(res_list, k = 6)

plot of chunk tab-collect-classes-from-consensus-partition-list-5

Top rows overlap

Overlap of top rows from different top-row methods:

top_rows_overlap(res_list, top_n = 1000, method = "euler")

plot of chunk tab-top-rows-overlap-by-euler-1

top_rows_overlap(res_list, top_n = 2000, method = "euler")

plot of chunk tab-top-rows-overlap-by-euler-2

top_rows_overlap(res_list, top_n = 3000, method = "euler")

plot of chunk tab-top-rows-overlap-by-euler-3

top_rows_overlap(res_list, top_n = 4000, method = "euler")

plot of chunk tab-top-rows-overlap-by-euler-4

top_rows_overlap(res_list, top_n = 5000, method = "euler")

plot of chunk tab-top-rows-overlap-by-euler-5

Also visualize the correspondance of rankings between different top-row methods:

top_rows_overlap(res_list, top_n = 1000, method = "correspondance")

plot of chunk tab-top-rows-overlap-by-correspondance-1

top_rows_overlap(res_list, top_n = 2000, method = "correspondance")

plot of chunk tab-top-rows-overlap-by-correspondance-2

top_rows_overlap(res_list, top_n = 3000, method = "correspondance")

plot of chunk tab-top-rows-overlap-by-correspondance-3

top_rows_overlap(res_list, top_n = 4000, method = "correspondance")

plot of chunk tab-top-rows-overlap-by-correspondance-4

top_rows_overlap(res_list, top_n = 5000, method = "correspondance")

plot of chunk tab-top-rows-overlap-by-correspondance-5

Heatmaps of the top rows:

top_rows_heatmap(res_list, top_n = 1000)

plot of chunk tab-top-rows-heatmap-1

top_rows_heatmap(res_list, top_n = 2000)

plot of chunk tab-top-rows-heatmap-2

top_rows_heatmap(res_list, top_n = 3000)

plot of chunk tab-top-rows-heatmap-3

top_rows_heatmap(res_list, top_n = 4000)

plot of chunk tab-top-rows-heatmap-4

top_rows_heatmap(res_list, top_n = 5000)

plot of chunk tab-top-rows-heatmap-5

Results for each method


SD:hclust

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

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

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

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 18325 rows and 52 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#>   Subgroups are detected by 'hclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 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 0.290           0.797       0.798         0.3855 0.509   0.509
#> 3 3 0.605           0.723       0.864         0.4673 0.985   0.970
#> 4 4 0.726           0.860       0.914         0.1846 0.821   0.637
#> 5 5 0.847           0.900       0.953         0.0567 0.962   0.878
#> 6 6 0.821           0.845       0.930         0.0154 0.998   0.995

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

suggest_best_k(res)
#> [1] 5

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette    p1    p2
#> SRR1058003     1   0.634      0.690 0.840 0.160
#> SRR1058004     1   0.644      0.688 0.836 0.164
#> SRR1058006     1   0.781      0.740 0.768 0.232
#> SRR1058005     1   0.644      0.688 0.836 0.164
#> SRR1058007     2   0.714      0.939 0.196 0.804
#> SRR1058008     2   0.714      0.939 0.196 0.804
#> SRR1058009     2   0.714      0.939 0.196 0.804
#> SRR1058010     2   0.706      0.935 0.192 0.808
#> SRR1058011     2   0.714      0.939 0.196 0.804
#> SRR1058012     2   0.644      0.499 0.164 0.836
#> SRR1058013     2   0.714      0.939 0.196 0.804
#> SRR1058014     2   0.714      0.939 0.196 0.804
#> SRR1058015     1   0.738      0.758 0.792 0.208
#> SRR1058016     2   0.714      0.939 0.196 0.804
#> SRR1058017     2   0.714      0.939 0.196 0.804
#> SRR1058018     1   0.738      0.758 0.792 0.208
#> SRR1058019     2   0.714      0.939 0.196 0.804
#> SRR1058020     2   0.714      0.939 0.196 0.804
#> SRR1058021     1   0.738      0.758 0.792 0.208
#> SRR1058022     2   0.714      0.939 0.196 0.804
#> SRR1058023     1   0.738      0.758 0.792 0.208
#> SRR1058024     2   0.714      0.939 0.196 0.804
#> SRR1058025     2   0.714      0.939 0.196 0.804
#> SRR1058026     2   0.430      0.807 0.088 0.912
#> SRR1058027     2   0.430      0.807 0.088 0.912
#> SRR1058028     2   0.430      0.807 0.088 0.912
#> SRR1058029     2   0.714      0.939 0.196 0.804
#> SRR1058030     2   0.714      0.939 0.196 0.804
#> SRR1058031     2   0.714      0.939 0.196 0.804
#> SRR1058032     1   0.644      0.688 0.836 0.164
#> SRR1058033     1   0.644      0.688 0.836 0.164
#> SRR1058034     1   0.644      0.688 0.836 0.164
#> SRR1058035     1   0.738      0.758 0.792 0.208
#> SRR1058036     1   0.738      0.758 0.792 0.208
#> SRR1058037     1   0.738      0.758 0.792 0.208
#> SRR1058038     1   0.738      0.758 0.792 0.208
#> SRR1058039     1   0.738      0.758 0.792 0.208
#> SRR1058040     1   0.738      0.758 0.792 0.208
#> SRR1058041     1   0.738      0.758 0.792 0.208
#> SRR1058042     1   0.738      0.758 0.792 0.208
#> SRR1058043     1   0.738      0.758 0.792 0.208
#> SRR1058044     1   0.738      0.758 0.792 0.208
#> SRR1058045     1   0.738      0.758 0.792 0.208
#> SRR1058046     1   0.738      0.758 0.792 0.208
#> SRR1058047     1   0.653      0.685 0.832 0.168
#> SRR1058048     1   0.745      0.696 0.788 0.212
#> SRR1058049     1   0.745      0.696 0.788 0.212
#> SRR1058050     1   0.745      0.696 0.788 0.212
#> SRR1058051     1   0.653      0.685 0.832 0.168
#> SRR1058052     1   0.745      0.696 0.788 0.212
#> SRR1058053     1   0.745      0.696 0.788 0.212
#> SRR1058054     1   0.745      0.696 0.788 0.212

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1058003     1  0.5988      0.567 0.632 0.000 0.368
#> SRR1058004     1  0.6796      0.567 0.612 0.020 0.368
#> SRR1058006     1  0.1753      0.650 0.952 0.000 0.048
#> SRR1058005     1  0.6796      0.567 0.612 0.020 0.368
#> SRR1058007     2  0.0000      0.978 0.000 1.000 0.000
#> SRR1058008     2  0.0000      0.978 0.000 1.000 0.000
#> SRR1058009     2  0.0000      0.978 0.000 1.000 0.000
#> SRR1058010     2  0.0475      0.972 0.004 0.992 0.004
#> SRR1058011     2  0.0000      0.978 0.000 1.000 0.000
#> SRR1058012     3  0.6008      0.000 0.372 0.000 0.628
#> SRR1058013     2  0.0000      0.978 0.000 1.000 0.000
#> SRR1058014     2  0.0000      0.978 0.000 1.000 0.000
#> SRR1058015     1  0.0000      0.666 1.000 0.000 0.000
#> SRR1058016     2  0.0000      0.978 0.000 1.000 0.000
#> SRR1058017     2  0.0000      0.978 0.000 1.000 0.000
#> SRR1058018     1  0.0000      0.666 1.000 0.000 0.000
#> SRR1058019     2  0.0000      0.978 0.000 1.000 0.000
#> SRR1058020     2  0.0000      0.978 0.000 1.000 0.000
#> SRR1058021     1  0.0000      0.666 1.000 0.000 0.000
#> SRR1058022     2  0.0000      0.978 0.000 1.000 0.000
#> SRR1058023     1  0.0000      0.666 1.000 0.000 0.000
#> SRR1058024     2  0.0000      0.978 0.000 1.000 0.000
#> SRR1058025     2  0.0000      0.978 0.000 1.000 0.000
#> SRR1058026     2  0.3500      0.869 0.004 0.880 0.116
#> SRR1058027     2  0.3500      0.869 0.004 0.880 0.116
#> SRR1058028     2  0.3500      0.869 0.004 0.880 0.116
#> SRR1058029     2  0.0000      0.978 0.000 1.000 0.000
#> SRR1058030     2  0.0000      0.978 0.000 1.000 0.000
#> SRR1058031     2  0.0000      0.978 0.000 1.000 0.000
#> SRR1058032     1  0.6796      0.567 0.612 0.020 0.368
#> SRR1058033     1  0.6796      0.567 0.612 0.020 0.368
#> SRR1058034     1  0.6796      0.567 0.612 0.020 0.368
#> SRR1058035     1  0.0000      0.666 1.000 0.000 0.000
#> SRR1058036     1  0.0000      0.666 1.000 0.000 0.000
#> SRR1058037     1  0.0000      0.666 1.000 0.000 0.000
#> SRR1058038     1  0.0000      0.666 1.000 0.000 0.000
#> SRR1058039     1  0.0000      0.666 1.000 0.000 0.000
#> SRR1058040     1  0.0000      0.666 1.000 0.000 0.000
#> SRR1058041     1  0.0000      0.666 1.000 0.000 0.000
#> SRR1058042     1  0.0000      0.666 1.000 0.000 0.000
#> SRR1058043     1  0.0000      0.666 1.000 0.000 0.000
#> SRR1058044     1  0.0000      0.666 1.000 0.000 0.000
#> SRR1058045     1  0.0000      0.666 1.000 0.000 0.000
#> SRR1058046     1  0.0000      0.666 1.000 0.000 0.000
#> SRR1058047     1  0.8887      0.496 0.504 0.128 0.368
#> SRR1058048     1  0.9223      0.448 0.504 0.324 0.172
#> SRR1058049     1  0.9223      0.448 0.504 0.324 0.172
#> SRR1058050     1  0.9223      0.448 0.504 0.324 0.172
#> SRR1058051     1  0.8887      0.496 0.504 0.128 0.368
#> SRR1058052     1  0.9223      0.448 0.504 0.324 0.172
#> SRR1058053     1  0.9223      0.448 0.504 0.324 0.172
#> SRR1058054     1  0.9223      0.448 0.504 0.324 0.172

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1058003     3  0.2868      0.698 0.136 0.000 0.864 0.000
#> SRR1058004     3  0.3278      0.734 0.116 0.020 0.864 0.000
#> SRR1058006     1  0.1389      0.924 0.952 0.000 0.048 0.000
#> SRR1058005     3  0.3278      0.734 0.116 0.020 0.864 0.000
#> SRR1058007     2  0.0000      0.934 0.000 1.000 0.000 0.000
#> SRR1058008     2  0.0000      0.934 0.000 1.000 0.000 0.000
#> SRR1058009     2  0.0000      0.934 0.000 1.000 0.000 0.000
#> SRR1058010     2  0.0376      0.929 0.004 0.992 0.000 0.004
#> SRR1058011     2  0.0000      0.934 0.000 1.000 0.000 0.000
#> SRR1058012     4  0.3688      0.000 0.208 0.000 0.000 0.792
#> SRR1058013     2  0.0000      0.934 0.000 1.000 0.000 0.000
#> SRR1058014     2  0.0000      0.934 0.000 1.000 0.000 0.000
#> SRR1058015     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> SRR1058016     2  0.0000      0.934 0.000 1.000 0.000 0.000
#> SRR1058017     2  0.0000      0.934 0.000 1.000 0.000 0.000
#> SRR1058018     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> SRR1058019     2  0.0000      0.934 0.000 1.000 0.000 0.000
#> SRR1058020     2  0.0921      0.919 0.000 0.972 0.000 0.028
#> SRR1058021     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> SRR1058022     2  0.0000      0.934 0.000 1.000 0.000 0.000
#> SRR1058023     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> SRR1058024     2  0.1022      0.917 0.000 0.968 0.000 0.032
#> SRR1058025     2  0.1022      0.917 0.000 0.968 0.000 0.032
#> SRR1058026     2  0.6341      0.562 0.000 0.652 0.136 0.212
#> SRR1058027     2  0.6341      0.562 0.000 0.652 0.136 0.212
#> SRR1058028     2  0.6341      0.562 0.000 0.652 0.136 0.212
#> SRR1058029     2  0.0000      0.934 0.000 1.000 0.000 0.000
#> SRR1058030     2  0.0000      0.934 0.000 1.000 0.000 0.000
#> SRR1058031     2  0.0000      0.934 0.000 1.000 0.000 0.000
#> SRR1058032     3  0.3278      0.734 0.116 0.020 0.864 0.000
#> SRR1058033     3  0.3278      0.734 0.116 0.020 0.864 0.000
#> SRR1058034     3  0.3278      0.734 0.116 0.020 0.864 0.000
#> SRR1058035     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> SRR1058036     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> SRR1058037     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> SRR1058038     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> SRR1058039     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> SRR1058040     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> SRR1058041     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> SRR1058042     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> SRR1058043     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> SRR1058044     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> SRR1058045     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> SRR1058046     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> SRR1058047     3  0.3088      0.760 0.008 0.128 0.864 0.000
#> SRR1058048     3  0.4857      0.742 0.008 0.324 0.668 0.000
#> SRR1058049     3  0.4857      0.742 0.008 0.324 0.668 0.000
#> SRR1058050     3  0.4857      0.742 0.008 0.324 0.668 0.000
#> SRR1058051     3  0.3088      0.760 0.008 0.128 0.864 0.000
#> SRR1058052     3  0.4857      0.742 0.008 0.324 0.668 0.000
#> SRR1058053     3  0.4857      0.742 0.008 0.324 0.668 0.000
#> SRR1058054     3  0.4857      0.742 0.008 0.324 0.668 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
#> SRR1058003     3  0.1121      0.728 0.044 0.000 0.956 0.000 0.000
#> SRR1058004     3  0.0703      0.745 0.024 0.000 0.976 0.000 0.000
#> SRR1058006     1  0.1197      0.941 0.952 0.000 0.048 0.000 0.000
#> SRR1058005     3  0.0703      0.745 0.024 0.000 0.976 0.000 0.000
#> SRR1058007     2  0.0000      0.993 0.000 1.000 0.000 0.000 0.000
#> SRR1058008     2  0.0000      0.993 0.000 1.000 0.000 0.000 0.000
#> SRR1058009     2  0.0000      0.993 0.000 1.000 0.000 0.000 0.000
#> SRR1058010     2  0.0290      0.986 0.000 0.992 0.000 0.000 0.008
#> SRR1058011     2  0.0000      0.993 0.000 1.000 0.000 0.000 0.000
#> SRR1058012     5  0.0000      0.000 0.000 0.000 0.000 0.000 1.000
#> SRR1058013     2  0.0000      0.993 0.000 1.000 0.000 0.000 0.000
#> SRR1058014     2  0.0000      0.993 0.000 1.000 0.000 0.000 0.000
#> SRR1058015     1  0.0000      0.996 1.000 0.000 0.000 0.000 0.000
#> SRR1058016     2  0.0000      0.993 0.000 1.000 0.000 0.000 0.000
#> SRR1058017     2  0.0000      0.993 0.000 1.000 0.000 0.000 0.000
#> SRR1058018     1  0.0000      0.996 1.000 0.000 0.000 0.000 0.000
#> SRR1058019     2  0.0000      0.993 0.000 1.000 0.000 0.000 0.000
#> SRR1058020     2  0.0794      0.970 0.000 0.972 0.000 0.028 0.000
#> SRR1058021     1  0.0000      0.996 1.000 0.000 0.000 0.000 0.000
#> SRR1058022     2  0.0000      0.993 0.000 1.000 0.000 0.000 0.000
#> SRR1058023     1  0.0000      0.996 1.000 0.000 0.000 0.000 0.000
#> SRR1058024     2  0.0880      0.966 0.000 0.968 0.000 0.032 0.000
#> SRR1058025     2  0.0880      0.966 0.000 0.968 0.000 0.032 0.000
#> SRR1058026     4  0.0162      0.926 0.000 0.000 0.004 0.996 0.000
#> SRR1058027     4  0.0000      0.926 0.000 0.000 0.000 1.000 0.000
#> SRR1058028     4  0.2012      0.853 0.000 0.060 0.020 0.920 0.000
#> SRR1058029     2  0.0000      0.993 0.000 1.000 0.000 0.000 0.000
#> SRR1058030     2  0.0000      0.993 0.000 1.000 0.000 0.000 0.000
#> SRR1058031     2  0.0000      0.993 0.000 1.000 0.000 0.000 0.000
#> SRR1058032     3  0.0703      0.745 0.024 0.000 0.976 0.000 0.000
#> SRR1058033     3  0.0703      0.745 0.024 0.000 0.976 0.000 0.000
#> SRR1058034     3  0.0703      0.745 0.024 0.000 0.976 0.000 0.000
#> SRR1058035     1  0.0000      0.996 1.000 0.000 0.000 0.000 0.000
#> SRR1058036     1  0.0000      0.996 1.000 0.000 0.000 0.000 0.000
#> SRR1058037     1  0.0000      0.996 1.000 0.000 0.000 0.000 0.000
#> SRR1058038     1  0.0000      0.996 1.000 0.000 0.000 0.000 0.000
#> SRR1058039     1  0.0000      0.996 1.000 0.000 0.000 0.000 0.000
#> SRR1058040     1  0.0000      0.996 1.000 0.000 0.000 0.000 0.000
#> SRR1058041     1  0.0000      0.996 1.000 0.000 0.000 0.000 0.000
#> SRR1058042     1  0.0000      0.996 1.000 0.000 0.000 0.000 0.000
#> SRR1058043     1  0.0000      0.996 1.000 0.000 0.000 0.000 0.000
#> SRR1058044     1  0.0000      0.996 1.000 0.000 0.000 0.000 0.000
#> SRR1058045     1  0.0000      0.996 1.000 0.000 0.000 0.000 0.000
#> SRR1058046     1  0.0000      0.996 1.000 0.000 0.000 0.000 0.000
#> SRR1058047     3  0.2127      0.770 0.000 0.108 0.892 0.000 0.000
#> SRR1058048     3  0.3837      0.739 0.000 0.308 0.692 0.000 0.000
#> SRR1058049     3  0.3837      0.739 0.000 0.308 0.692 0.000 0.000
#> SRR1058050     3  0.3837      0.739 0.000 0.308 0.692 0.000 0.000
#> SRR1058051     3  0.2127      0.770 0.000 0.108 0.892 0.000 0.000
#> SRR1058052     3  0.3837      0.739 0.000 0.308 0.692 0.000 0.000
#> SRR1058053     3  0.3837      0.739 0.000 0.308 0.692 0.000 0.000
#> SRR1058054     3  0.3837      0.739 0.000 0.308 0.692 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR1058003     3  0.2744      0.664 0.016 0.000 0.840 0.000 0.144 0.000
#> SRR1058004     3  0.1863      0.691 0.000 0.000 0.896 0.000 0.104 0.000
#> SRR1058006     1  0.1297      0.945 0.948 0.000 0.012 0.000 0.040 0.000
#> SRR1058005     3  0.1863      0.691 0.000 0.000 0.896 0.000 0.104 0.000
#> SRR1058007     2  0.0000      0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1058008     2  0.0000      0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1058009     2  0.0000      0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1058010     2  0.2632      0.786 0.000 0.832 0.000 0.004 0.164 0.000
#> SRR1058011     2  0.0000      0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1058012     4  0.0000      0.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1058013     2  0.0000      0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1058014     2  0.0000      0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1058015     1  0.0000      0.997 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058016     2  0.0146      0.978 0.000 0.996 0.004 0.000 0.000 0.000
#> SRR1058017     2  0.0260      0.975 0.000 0.992 0.008 0.000 0.000 0.000
#> SRR1058018     1  0.0000      0.997 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058019     2  0.0000      0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1058020     2  0.0713      0.961 0.000 0.972 0.000 0.000 0.000 0.028
#> SRR1058021     1  0.0000      0.997 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058022     2  0.0000      0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1058023     1  0.0000      0.997 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058024     2  0.0790      0.958 0.000 0.968 0.000 0.000 0.000 0.032
#> SRR1058025     2  0.0790      0.958 0.000 0.968 0.000 0.000 0.000 0.032
#> SRR1058026     5  0.3482      0.000 0.000 0.000 0.000 0.000 0.684 0.316
#> SRR1058027     6  0.3309      0.337 0.000 0.000 0.000 0.000 0.280 0.720
#> SRR1058028     6  0.0000      0.513 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR1058029     2  0.0000      0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1058030     2  0.0000      0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1058031     2  0.0000      0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1058032     3  0.1863      0.691 0.000 0.000 0.896 0.000 0.104 0.000
#> SRR1058033     3  0.1863      0.691 0.000 0.000 0.896 0.000 0.104 0.000
#> SRR1058034     3  0.1863      0.691 0.000 0.000 0.896 0.000 0.104 0.000
#> SRR1058035     1  0.0000      0.997 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058036     1  0.0000      0.997 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058037     1  0.0000      0.997 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058038     1  0.0000      0.997 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058039     1  0.0000      0.997 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058040     1  0.0000      0.997 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058041     1  0.0000      0.997 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058042     1  0.0000      0.997 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058043     1  0.0000      0.997 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058044     1  0.0000      0.997 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058045     1  0.0000      0.997 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058046     1  0.0000      0.997 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058047     3  0.1814      0.726 0.000 0.100 0.900 0.000 0.000 0.000
#> SRR1058048     3  0.3409      0.707 0.000 0.300 0.700 0.000 0.000 0.000
#> SRR1058049     3  0.3409      0.707 0.000 0.300 0.700 0.000 0.000 0.000
#> SRR1058050     3  0.3409      0.707 0.000 0.300 0.700 0.000 0.000 0.000
#> SRR1058051     3  0.1814      0.726 0.000 0.100 0.900 0.000 0.000 0.000
#> SRR1058052     3  0.3409      0.707 0.000 0.300 0.700 0.000 0.000 0.000
#> SRR1058053     3  0.3409      0.707 0.000 0.300 0.700 0.000 0.000 0.000
#> SRR1058054     3  0.3409      0.707 0.000 0.300 0.700 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-hclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-hclust-collect-classes

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


SD:kmeans

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

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

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

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 18325 rows and 52 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#>   Subgroups are detected by 'kmeans' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 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-kmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.506           0.865       0.913         0.4662 0.517   0.517
#> 3 3 0.538           0.546       0.717         0.3799 0.687   0.472
#> 4 4 0.644           0.772       0.844         0.1128 0.863   0.641
#> 5 5 0.711           0.739       0.831         0.0647 0.962   0.859
#> 6 6 0.799           0.867       0.879         0.0484 0.942   0.762

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

suggest_best_k(res)
#> [1] 6

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette    p1    p2
#> SRR1058003     1  0.6973      0.712 0.812 0.188
#> SRR1058004     2  0.6148      0.854 0.152 0.848
#> SRR1058006     1  0.9580      0.578 0.620 0.380
#> SRR1058005     2  0.6148      0.854 0.152 0.848
#> SRR1058007     2  0.0672      0.929 0.008 0.992
#> SRR1058008     2  0.0672      0.929 0.008 0.992
#> SRR1058009     2  0.0672      0.929 0.008 0.992
#> SRR1058010     2  0.0000      0.928 0.000 1.000
#> SRR1058011     2  0.0000      0.928 0.000 1.000
#> SRR1058012     2  0.8909      0.412 0.308 0.692
#> SRR1058013     2  0.0672      0.929 0.008 0.992
#> SRR1058014     2  0.0672      0.929 0.008 0.992
#> SRR1058015     1  0.9686      0.557 0.604 0.396
#> SRR1058016     2  0.0000      0.928 0.000 1.000
#> SRR1058017     2  0.0000      0.928 0.000 1.000
#> SRR1058018     1  0.6247      0.889 0.844 0.156
#> SRR1058019     2  0.0672      0.929 0.008 0.992
#> SRR1058020     2  0.0000      0.928 0.000 1.000
#> SRR1058021     2  0.9909     -0.098 0.444 0.556
#> SRR1058022     2  0.0672      0.929 0.008 0.992
#> SRR1058023     1  0.6247      0.889 0.844 0.156
#> SRR1058024     2  0.0000      0.928 0.000 1.000
#> SRR1058025     2  0.0000      0.928 0.000 1.000
#> SRR1058026     2  0.0000      0.928 0.000 1.000
#> SRR1058027     2  0.0000      0.928 0.000 1.000
#> SRR1058028     2  0.0000      0.928 0.000 1.000
#> SRR1058029     2  0.0672      0.929 0.008 0.992
#> SRR1058030     2  0.0672      0.929 0.008 0.992
#> SRR1058031     2  0.0672      0.929 0.008 0.992
#> SRR1058032     1  0.0000      0.861 1.000 0.000
#> SRR1058033     1  0.0000      0.861 1.000 0.000
#> SRR1058034     1  0.0000      0.861 1.000 0.000
#> SRR1058035     1  0.4690      0.927 0.900 0.100
#> SRR1058036     1  0.4690      0.927 0.900 0.100
#> SRR1058037     1  0.4690      0.927 0.900 0.100
#> SRR1058038     1  0.4690      0.927 0.900 0.100
#> SRR1058039     1  0.4690      0.927 0.900 0.100
#> SRR1058040     1  0.4690      0.927 0.900 0.100
#> SRR1058041     1  0.4690      0.927 0.900 0.100
#> SRR1058042     1  0.4690      0.927 0.900 0.100
#> SRR1058043     1  0.4939      0.922 0.892 0.108
#> SRR1058044     1  0.4690      0.927 0.900 0.100
#> SRR1058045     1  0.4690      0.927 0.900 0.100
#> SRR1058046     1  0.4690      0.927 0.900 0.100
#> SRR1058047     2  0.6247      0.851 0.156 0.844
#> SRR1058048     2  0.4562      0.895 0.096 0.904
#> SRR1058049     2  0.4562      0.895 0.096 0.904
#> SRR1058050     2  0.4562      0.895 0.096 0.904
#> SRR1058051     2  0.6247      0.851 0.156 0.844
#> SRR1058052     2  0.4562      0.895 0.096 0.904
#> SRR1058053     2  0.4562      0.895 0.096 0.904
#> SRR1058054     2  0.4562      0.895 0.096 0.904

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1058003     2  0.9053     0.2215 0.224 0.556 0.220
#> SRR1058004     3  0.2063     0.7340 0.008 0.044 0.948
#> SRR1058006     2  0.6255     0.3713 0.300 0.684 0.016
#> SRR1058005     3  0.2063     0.7340 0.008 0.044 0.948
#> SRR1058007     2  0.6307    -0.0211 0.000 0.512 0.488
#> SRR1058008     2  0.6307    -0.0211 0.000 0.512 0.488
#> SRR1058009     2  0.6204     0.1347 0.000 0.576 0.424
#> SRR1058010     2  0.2165     0.5431 0.000 0.936 0.064
#> SRR1058011     2  0.6215     0.1237 0.000 0.572 0.428
#> SRR1058012     2  0.4139     0.4931 0.124 0.860 0.016
#> SRR1058013     2  0.6252     0.0941 0.000 0.556 0.444
#> SRR1058014     2  0.6252     0.0941 0.000 0.556 0.444
#> SRR1058015     2  0.6224     0.3781 0.296 0.688 0.016
#> SRR1058016     2  0.2625     0.5344 0.000 0.916 0.084
#> SRR1058017     2  0.6204     0.1299 0.000 0.576 0.424
#> SRR1058018     2  0.6848     0.1109 0.416 0.568 0.016
#> SRR1058019     2  0.6307    -0.0211 0.000 0.512 0.488
#> SRR1058020     2  0.2448     0.5387 0.000 0.924 0.076
#> SRR1058021     2  0.5639     0.4596 0.232 0.752 0.016
#> SRR1058022     2  0.6307    -0.0211 0.000 0.512 0.488
#> SRR1058023     2  0.6848     0.1109 0.416 0.568 0.016
#> SRR1058024     2  0.2261     0.5420 0.000 0.932 0.068
#> SRR1058025     2  0.1643     0.5460 0.000 0.956 0.044
#> SRR1058026     2  0.1411     0.5459 0.000 0.964 0.036
#> SRR1058027     2  0.1411     0.5459 0.000 0.964 0.036
#> SRR1058028     2  0.1411     0.5459 0.000 0.964 0.036
#> SRR1058029     3  0.6309    -0.0320 0.000 0.496 0.504
#> SRR1058030     3  0.6309    -0.0320 0.000 0.496 0.504
#> SRR1058031     2  0.6307    -0.0211 0.000 0.512 0.488
#> SRR1058032     1  0.4978     0.7948 0.780 0.004 0.216
#> SRR1058033     1  0.5070     0.7869 0.772 0.004 0.224
#> SRR1058034     1  0.5070     0.7869 0.772 0.004 0.224
#> SRR1058035     1  0.0000     0.9516 1.000 0.000 0.000
#> SRR1058036     1  0.0000     0.9516 1.000 0.000 0.000
#> SRR1058037     1  0.0000     0.9516 1.000 0.000 0.000
#> SRR1058038     1  0.0000     0.9516 1.000 0.000 0.000
#> SRR1058039     1  0.0000     0.9516 1.000 0.000 0.000
#> SRR1058040     1  0.0000     0.9516 1.000 0.000 0.000
#> SRR1058041     1  0.0000     0.9516 1.000 0.000 0.000
#> SRR1058042     1  0.0000     0.9516 1.000 0.000 0.000
#> SRR1058043     1  0.0237     0.9481 0.996 0.000 0.004
#> SRR1058044     1  0.0000     0.9516 1.000 0.000 0.000
#> SRR1058045     1  0.0000     0.9516 1.000 0.000 0.000
#> SRR1058046     1  0.0000     0.9516 1.000 0.000 0.000
#> SRR1058047     3  0.0747     0.7246 0.016 0.000 0.984
#> SRR1058048     3  0.4411     0.7968 0.016 0.140 0.844
#> SRR1058049     3  0.4411     0.7968 0.016 0.140 0.844
#> SRR1058050     3  0.4411     0.7968 0.016 0.140 0.844
#> SRR1058051     3  0.0747     0.7246 0.016 0.000 0.984
#> SRR1058052     3  0.4411     0.7968 0.016 0.140 0.844
#> SRR1058053     3  0.4411     0.7968 0.016 0.140 0.844
#> SRR1058054     3  0.4411     0.7968 0.016 0.140 0.844

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1058003     4  0.6851      0.469 0.048 0.044 0.304 0.604
#> SRR1058004     3  0.5690      0.509 0.000 0.196 0.708 0.096
#> SRR1058006     4  0.5678      0.846 0.172 0.112 0.000 0.716
#> SRR1058005     3  0.5690      0.509 0.000 0.196 0.708 0.096
#> SRR1058007     2  0.2036      0.868 0.000 0.936 0.032 0.032
#> SRR1058008     2  0.2036      0.868 0.000 0.936 0.032 0.032
#> SRR1058009     2  0.1936      0.869 0.000 0.940 0.032 0.028
#> SRR1058010     2  0.3577      0.801 0.000 0.832 0.012 0.156
#> SRR1058011     2  0.1724      0.871 0.000 0.948 0.020 0.032
#> SRR1058012     4  0.3681      0.711 0.036 0.104 0.004 0.856
#> SRR1058013     2  0.1936      0.869 0.000 0.940 0.032 0.028
#> SRR1058014     2  0.1936      0.869 0.000 0.940 0.032 0.028
#> SRR1058015     4  0.5272      0.850 0.172 0.084 0.000 0.744
#> SRR1058016     2  0.2179      0.862 0.000 0.924 0.012 0.064
#> SRR1058017     2  0.1706      0.871 0.000 0.948 0.016 0.036
#> SRR1058018     4  0.5136      0.824 0.224 0.048 0.000 0.728
#> SRR1058019     2  0.0895      0.868 0.000 0.976 0.020 0.004
#> SRR1058020     2  0.1211      0.861 0.000 0.960 0.000 0.040
#> SRR1058021     4  0.5719      0.831 0.152 0.132 0.000 0.716
#> SRR1058022     2  0.0895      0.868 0.000 0.976 0.020 0.004
#> SRR1058023     4  0.5136      0.824 0.224 0.048 0.000 0.728
#> SRR1058024     2  0.1557      0.853 0.000 0.944 0.000 0.056
#> SRR1058025     2  0.2760      0.801 0.000 0.872 0.000 0.128
#> SRR1058026     2  0.5161      0.443 0.000 0.592 0.008 0.400
#> SRR1058027     2  0.5161      0.443 0.000 0.592 0.008 0.400
#> SRR1058028     2  0.4673      0.635 0.000 0.700 0.008 0.292
#> SRR1058029     2  0.1209      0.863 0.000 0.964 0.032 0.004
#> SRR1058030     2  0.1209      0.863 0.000 0.964 0.032 0.004
#> SRR1058031     2  0.1109      0.865 0.000 0.968 0.028 0.004
#> SRR1058032     1  0.6626      0.417 0.528 0.000 0.384 0.088
#> SRR1058033     1  0.6635      0.414 0.524 0.000 0.388 0.088
#> SRR1058034     1  0.6635      0.414 0.524 0.000 0.388 0.088
#> SRR1058035     1  0.0000      0.876 1.000 0.000 0.000 0.000
#> SRR1058036     1  0.0000      0.876 1.000 0.000 0.000 0.000
#> SRR1058037     1  0.0000      0.876 1.000 0.000 0.000 0.000
#> SRR1058038     1  0.0000      0.876 1.000 0.000 0.000 0.000
#> SRR1058039     1  0.0000      0.876 1.000 0.000 0.000 0.000
#> SRR1058040     1  0.0000      0.876 1.000 0.000 0.000 0.000
#> SRR1058041     1  0.0000      0.876 1.000 0.000 0.000 0.000
#> SRR1058042     1  0.0000      0.876 1.000 0.000 0.000 0.000
#> SRR1058043     1  0.0000      0.876 1.000 0.000 0.000 0.000
#> SRR1058044     1  0.0000      0.876 1.000 0.000 0.000 0.000
#> SRR1058045     1  0.0000      0.876 1.000 0.000 0.000 0.000
#> SRR1058046     1  0.0000      0.876 1.000 0.000 0.000 0.000
#> SRR1058047     3  0.0927      0.607 0.000 0.008 0.976 0.016
#> SRR1058048     3  0.4535      0.781 0.000 0.292 0.704 0.004
#> SRR1058049     3  0.4431      0.783 0.000 0.304 0.696 0.000
#> SRR1058050     3  0.4431      0.783 0.000 0.304 0.696 0.000
#> SRR1058051     3  0.1510      0.626 0.000 0.028 0.956 0.016
#> SRR1058052     3  0.4535      0.781 0.000 0.292 0.704 0.004
#> SRR1058053     3  0.4431      0.783 0.000 0.304 0.696 0.000
#> SRR1058054     3  0.4431      0.783 0.000 0.304 0.696 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
#> SRR1058003     5  0.6504      0.324 0.000 0.004 0.172 0.352 0.472
#> SRR1058004     3  0.6914      0.232 0.000 0.232 0.388 0.372 0.008
#> SRR1058006     5  0.3086      0.748 0.048 0.060 0.000 0.016 0.876
#> SRR1058005     3  0.6914      0.232 0.000 0.232 0.388 0.372 0.008
#> SRR1058007     2  0.1538      0.892 0.000 0.948 0.008 0.036 0.008
#> SRR1058008     2  0.1538      0.892 0.000 0.948 0.008 0.036 0.008
#> SRR1058009     2  0.1455      0.896 0.000 0.952 0.008 0.032 0.008
#> SRR1058010     2  0.3478      0.820 0.000 0.844 0.032 0.108 0.016
#> SRR1058011     2  0.1843      0.894 0.000 0.932 0.008 0.052 0.008
#> SRR1058012     5  0.5099     -0.184 0.004 0.000 0.028 0.440 0.528
#> SRR1058013     2  0.1369      0.895 0.000 0.956 0.008 0.028 0.008
#> SRR1058014     2  0.1369      0.895 0.000 0.956 0.008 0.028 0.008
#> SRR1058015     5  0.2149      0.749 0.048 0.036 0.000 0.000 0.916
#> SRR1058016     2  0.1502      0.888 0.000 0.940 0.000 0.056 0.004
#> SRR1058017     2  0.1270      0.890 0.000 0.948 0.000 0.052 0.000
#> SRR1058018     5  0.2570      0.751 0.084 0.028 0.000 0.000 0.888
#> SRR1058019     2  0.1386      0.895 0.000 0.952 0.016 0.032 0.000
#> SRR1058020     2  0.2833      0.849 0.000 0.864 0.012 0.120 0.004
#> SRR1058021     5  0.3086      0.748 0.048 0.060 0.000 0.016 0.876
#> SRR1058022     2  0.1386      0.895 0.000 0.952 0.016 0.032 0.000
#> SRR1058023     5  0.2570      0.751 0.084 0.028 0.000 0.000 0.888
#> SRR1058024     2  0.2833      0.849 0.000 0.864 0.012 0.120 0.004
#> SRR1058025     2  0.3067      0.840 0.000 0.856 0.012 0.120 0.012
#> SRR1058026     4  0.5986      0.898 0.000 0.168 0.008 0.616 0.208
#> SRR1058027     4  0.5986      0.898 0.000 0.168 0.008 0.616 0.208
#> SRR1058028     4  0.5781      0.816 0.000 0.268 0.008 0.616 0.108
#> SRR1058029     2  0.2139      0.877 0.000 0.916 0.052 0.032 0.000
#> SRR1058030     2  0.2139      0.877 0.000 0.916 0.052 0.032 0.000
#> SRR1058031     2  0.2139      0.877 0.000 0.916 0.052 0.032 0.000
#> SRR1058032     1  0.6897      0.229 0.388 0.000 0.272 0.336 0.004
#> SRR1058033     1  0.6897      0.229 0.388 0.000 0.272 0.336 0.004
#> SRR1058034     1  0.6897      0.229 0.388 0.000 0.272 0.336 0.004
#> SRR1058035     1  0.0162      0.854 0.996 0.000 0.000 0.004 0.000
#> SRR1058036     1  0.0162      0.854 0.996 0.000 0.000 0.004 0.000
#> SRR1058037     1  0.0162      0.854 0.996 0.000 0.000 0.004 0.000
#> SRR1058038     1  0.0000      0.856 1.000 0.000 0.000 0.000 0.000
#> SRR1058039     1  0.0000      0.856 1.000 0.000 0.000 0.000 0.000
#> SRR1058040     1  0.0000      0.856 1.000 0.000 0.000 0.000 0.000
#> SRR1058041     1  0.0000      0.856 1.000 0.000 0.000 0.000 0.000
#> SRR1058042     1  0.0000      0.856 1.000 0.000 0.000 0.000 0.000
#> SRR1058043     1  0.0000      0.856 1.000 0.000 0.000 0.000 0.000
#> SRR1058044     1  0.0000      0.856 1.000 0.000 0.000 0.000 0.000
#> SRR1058045     1  0.0000      0.856 1.000 0.000 0.000 0.000 0.000
#> SRR1058046     1  0.0000      0.856 1.000 0.000 0.000 0.000 0.000
#> SRR1058047     3  0.2325      0.594 0.000 0.028 0.904 0.068 0.000
#> SRR1058048     3  0.3336      0.736 0.000 0.228 0.772 0.000 0.000
#> SRR1058049     3  0.3491      0.737 0.000 0.228 0.768 0.004 0.000
#> SRR1058050     3  0.3491      0.737 0.000 0.228 0.768 0.004 0.000
#> SRR1058051     3  0.2409      0.597 0.000 0.032 0.900 0.068 0.000
#> SRR1058052     3  0.3336      0.736 0.000 0.228 0.772 0.000 0.000
#> SRR1058053     3  0.3491      0.737 0.000 0.228 0.768 0.004 0.000
#> SRR1058054     3  0.3491      0.737 0.000 0.228 0.768 0.004 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR1058003     4  0.4031      0.380 0.000 0.000 0.008 0.652 0.332 0.008
#> SRR1058004     4  0.5020      0.651 0.000 0.124 0.124 0.716 0.012 0.024
#> SRR1058006     5  0.1026      0.980 0.008 0.004 0.000 0.012 0.968 0.008
#> SRR1058005     4  0.5020      0.651 0.000 0.124 0.124 0.716 0.012 0.024
#> SRR1058007     2  0.2138      0.853 0.000 0.912 0.008 0.060 0.008 0.012
#> SRR1058008     2  0.2138      0.853 0.000 0.912 0.008 0.060 0.008 0.012
#> SRR1058009     2  0.1155      0.865 0.000 0.956 0.004 0.036 0.004 0.000
#> SRR1058010     2  0.3132      0.818 0.000 0.856 0.036 0.084 0.004 0.020
#> SRR1058011     2  0.1644      0.855 0.000 0.920 0.000 0.076 0.004 0.000
#> SRR1058012     6  0.6181      0.523 0.000 0.004 0.052 0.136 0.236 0.572
#> SRR1058013     2  0.1268      0.866 0.000 0.952 0.008 0.036 0.004 0.000
#> SRR1058014     2  0.1268      0.866 0.000 0.952 0.008 0.036 0.004 0.000
#> SRR1058015     5  0.0551      0.987 0.008 0.004 0.000 0.000 0.984 0.004
#> SRR1058016     2  0.1578      0.859 0.000 0.936 0.000 0.048 0.004 0.012
#> SRR1058017     2  0.1434      0.860 0.000 0.940 0.000 0.048 0.000 0.012
#> SRR1058018     5  0.0653      0.987 0.012 0.004 0.000 0.000 0.980 0.004
#> SRR1058019     2  0.3552      0.851 0.000 0.832 0.064 0.052 0.000 0.052
#> SRR1058020     2  0.3840      0.811 0.000 0.776 0.004 0.068 0.000 0.152
#> SRR1058021     5  0.0767      0.984 0.008 0.004 0.000 0.012 0.976 0.000
#> SRR1058022     2  0.3552      0.851 0.000 0.832 0.064 0.052 0.000 0.052
#> SRR1058023     5  0.0653      0.987 0.012 0.004 0.000 0.000 0.980 0.004
#> SRR1058024     2  0.3840      0.811 0.000 0.776 0.004 0.068 0.000 0.152
#> SRR1058025     2  0.3840      0.811 0.000 0.776 0.004 0.068 0.000 0.152
#> SRR1058026     6  0.1565      0.863 0.000 0.028 0.004 0.000 0.028 0.940
#> SRR1058027     6  0.1565      0.863 0.000 0.028 0.004 0.000 0.028 0.940
#> SRR1058028     6  0.1606      0.838 0.000 0.056 0.004 0.008 0.000 0.932
#> SRR1058029     2  0.3821      0.842 0.000 0.812 0.084 0.052 0.000 0.052
#> SRR1058030     2  0.3821      0.842 0.000 0.812 0.084 0.052 0.000 0.052
#> SRR1058031     2  0.3821      0.842 0.000 0.812 0.084 0.052 0.000 0.052
#> SRR1058032     4  0.4745      0.743 0.232 0.000 0.076 0.680 0.000 0.012
#> SRR1058033     4  0.4745      0.743 0.232 0.000 0.076 0.680 0.000 0.012
#> SRR1058034     4  0.4745      0.743 0.232 0.000 0.076 0.680 0.000 0.012
#> SRR1058035     1  0.0405      0.990 0.988 0.000 0.008 0.000 0.000 0.004
#> SRR1058036     1  0.0405      0.990 0.988 0.000 0.008 0.000 0.000 0.004
#> SRR1058037     1  0.0405      0.990 0.988 0.000 0.008 0.000 0.000 0.004
#> SRR1058038     1  0.0000      0.996 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058039     1  0.0000      0.996 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058040     1  0.0000      0.996 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058041     1  0.0000      0.996 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058042     1  0.0000      0.996 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058043     1  0.0405      0.988 0.988 0.000 0.008 0.004 0.000 0.000
#> SRR1058044     1  0.0000      0.996 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058045     1  0.0000      0.996 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058046     1  0.0000      0.996 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058047     3  0.3636      0.690 0.000 0.008 0.780 0.188 0.008 0.016
#> SRR1058048     3  0.1610      0.916 0.000 0.084 0.916 0.000 0.000 0.000
#> SRR1058049     3  0.1610      0.916 0.000 0.084 0.916 0.000 0.000 0.000
#> SRR1058050     3  0.1610      0.916 0.000 0.084 0.916 0.000 0.000 0.000
#> SRR1058051     3  0.3604      0.696 0.000 0.008 0.784 0.184 0.008 0.016
#> SRR1058052     3  0.1610      0.916 0.000 0.084 0.916 0.000 0.000 0.000
#> SRR1058053     3  0.1610      0.916 0.000 0.084 0.916 0.000 0.000 0.000
#> SRR1058054     3  0.1610      0.916 0.000 0.084 0.916 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

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

collect_plots(res)

plot of chunk SD-skmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.977       0.991         0.4958 0.502   0.502
#> 3 3 0.918           0.925       0.964         0.3214 0.818   0.649
#> 4 4 0.793           0.845       0.892         0.1100 0.913   0.754
#> 5 5 0.804           0.845       0.889         0.0762 0.948   0.815
#> 6 6 0.873           0.668       0.822         0.0631 0.922   0.679

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
#> SRR1058003     1   0.000      0.981 1.000 0.000
#> SRR1058004     2   0.000      0.998 0.000 1.000
#> SRR1058006     1   0.000      0.981 1.000 0.000
#> SRR1058005     2   0.000      0.998 0.000 1.000
#> SRR1058007     2   0.000      0.998 0.000 1.000
#> SRR1058008     2   0.000      0.998 0.000 1.000
#> SRR1058009     2   0.000      0.998 0.000 1.000
#> SRR1058010     2   0.000      0.998 0.000 1.000
#> SRR1058011     2   0.000      0.998 0.000 1.000
#> SRR1058012     1   0.969      0.341 0.604 0.396
#> SRR1058013     2   0.000      0.998 0.000 1.000
#> SRR1058014     2   0.000      0.998 0.000 1.000
#> SRR1058015     1   0.000      0.981 1.000 0.000
#> SRR1058016     2   0.000      0.998 0.000 1.000
#> SRR1058017     2   0.000      0.998 0.000 1.000
#> SRR1058018     1   0.000      0.981 1.000 0.000
#> SRR1058019     2   0.000      0.998 0.000 1.000
#> SRR1058020     2   0.000      0.998 0.000 1.000
#> SRR1058021     1   0.000      0.981 1.000 0.000
#> SRR1058022     2   0.000      0.998 0.000 1.000
#> SRR1058023     1   0.000      0.981 1.000 0.000
#> SRR1058024     2   0.000      0.998 0.000 1.000
#> SRR1058025     2   0.000      0.998 0.000 1.000
#> SRR1058026     2   0.295      0.944 0.052 0.948
#> SRR1058027     2   0.000      0.998 0.000 1.000
#> SRR1058028     2   0.000      0.998 0.000 1.000
#> SRR1058029     2   0.000      0.998 0.000 1.000
#> SRR1058030     2   0.000      0.998 0.000 1.000
#> SRR1058031     2   0.000      0.998 0.000 1.000
#> SRR1058032     1   0.000      0.981 1.000 0.000
#> SRR1058033     1   0.000      0.981 1.000 0.000
#> SRR1058034     1   0.000      0.981 1.000 0.000
#> SRR1058035     1   0.000      0.981 1.000 0.000
#> SRR1058036     1   0.000      0.981 1.000 0.000
#> SRR1058037     1   0.000      0.981 1.000 0.000
#> SRR1058038     1   0.000      0.981 1.000 0.000
#> SRR1058039     1   0.000      0.981 1.000 0.000
#> SRR1058040     1   0.000      0.981 1.000 0.000
#> SRR1058041     1   0.000      0.981 1.000 0.000
#> SRR1058042     1   0.000      0.981 1.000 0.000
#> SRR1058043     1   0.000      0.981 1.000 0.000
#> SRR1058044     1   0.000      0.981 1.000 0.000
#> SRR1058045     1   0.000      0.981 1.000 0.000
#> SRR1058046     1   0.000      0.981 1.000 0.000
#> SRR1058047     2   0.000      0.998 0.000 1.000
#> SRR1058048     2   0.000      0.998 0.000 1.000
#> SRR1058049     2   0.000      0.998 0.000 1.000
#> SRR1058050     2   0.000      0.998 0.000 1.000
#> SRR1058051     2   0.000      0.998 0.000 1.000
#> SRR1058052     2   0.000      0.998 0.000 1.000
#> SRR1058053     2   0.000      0.998 0.000 1.000
#> SRR1058054     2   0.000      0.998 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1058003     1  0.2625      0.867 0.916 0.000 0.084
#> SRR1058004     3  0.0000      0.995 0.000 0.000 1.000
#> SRR1058006     1  0.1529      0.898 0.960 0.040 0.000
#> SRR1058005     3  0.0000      0.995 0.000 0.000 1.000
#> SRR1058007     2  0.0592      0.977 0.000 0.988 0.012
#> SRR1058008     2  0.0892      0.973 0.000 0.980 0.020
#> SRR1058009     2  0.0424      0.979 0.000 0.992 0.008
#> SRR1058010     2  0.0237      0.976 0.000 0.996 0.004
#> SRR1058011     2  0.0424      0.979 0.000 0.992 0.008
#> SRR1058012     2  0.4931      0.689 0.232 0.768 0.000
#> SRR1058013     2  0.0424      0.979 0.000 0.992 0.008
#> SRR1058014     2  0.0424      0.979 0.000 0.992 0.008
#> SRR1058015     1  0.3116      0.836 0.892 0.108 0.000
#> SRR1058016     2  0.0000      0.978 0.000 1.000 0.000
#> SRR1058017     2  0.0424      0.979 0.000 0.992 0.008
#> SRR1058018     1  0.0424      0.919 0.992 0.008 0.000
#> SRR1058019     2  0.0424      0.979 0.000 0.992 0.008
#> SRR1058020     2  0.0000      0.978 0.000 1.000 0.000
#> SRR1058021     1  0.5905      0.452 0.648 0.352 0.000
#> SRR1058022     2  0.0424      0.979 0.000 0.992 0.008
#> SRR1058023     1  0.0424      0.919 0.992 0.008 0.000
#> SRR1058024     2  0.0000      0.978 0.000 1.000 0.000
#> SRR1058025     2  0.0000      0.978 0.000 1.000 0.000
#> SRR1058026     2  0.0000      0.978 0.000 1.000 0.000
#> SRR1058027     2  0.0000      0.978 0.000 1.000 0.000
#> SRR1058028     2  0.0000      0.978 0.000 1.000 0.000
#> SRR1058029     2  0.1529      0.955 0.000 0.960 0.040
#> SRR1058030     2  0.1643      0.951 0.000 0.956 0.044
#> SRR1058031     2  0.0592      0.977 0.000 0.988 0.012
#> SRR1058032     1  0.5254      0.668 0.736 0.000 0.264
#> SRR1058033     1  0.5327      0.657 0.728 0.000 0.272
#> SRR1058034     1  0.5327      0.657 0.728 0.000 0.272
#> SRR1058035     1  0.0000      0.922 1.000 0.000 0.000
#> SRR1058036     1  0.0000      0.922 1.000 0.000 0.000
#> SRR1058037     1  0.0000      0.922 1.000 0.000 0.000
#> SRR1058038     1  0.0000      0.922 1.000 0.000 0.000
#> SRR1058039     1  0.0000      0.922 1.000 0.000 0.000
#> SRR1058040     1  0.0000      0.922 1.000 0.000 0.000
#> SRR1058041     1  0.0000      0.922 1.000 0.000 0.000
#> SRR1058042     1  0.0000      0.922 1.000 0.000 0.000
#> SRR1058043     1  0.0000      0.922 1.000 0.000 0.000
#> SRR1058044     1  0.0000      0.922 1.000 0.000 0.000
#> SRR1058045     1  0.0000      0.922 1.000 0.000 0.000
#> SRR1058046     1  0.0000      0.922 1.000 0.000 0.000
#> SRR1058047     3  0.0000      0.995 0.000 0.000 1.000
#> SRR1058048     3  0.0237      0.996 0.000 0.004 0.996
#> SRR1058049     3  0.0424      0.995 0.000 0.008 0.992
#> SRR1058050     3  0.0424      0.995 0.000 0.008 0.992
#> SRR1058051     3  0.0000      0.995 0.000 0.000 1.000
#> SRR1058052     3  0.0237      0.996 0.000 0.004 0.996
#> SRR1058053     3  0.0424      0.995 0.000 0.008 0.992
#> SRR1058054     3  0.0424      0.995 0.000 0.008 0.992

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1058003     4  0.5085      0.520 0.376 0.000 0.008 0.616
#> SRR1058004     3  0.6584      0.633 0.336 0.096 0.568 0.000
#> SRR1058006     4  0.3024      0.760 0.148 0.000 0.000 0.852
#> SRR1058005     3  0.6584      0.633 0.336 0.096 0.568 0.000
#> SRR1058007     2  0.0967      0.946 0.016 0.976 0.004 0.004
#> SRR1058008     2  0.1191      0.943 0.024 0.968 0.004 0.004
#> SRR1058009     2  0.0524      0.950 0.000 0.988 0.004 0.008
#> SRR1058010     2  0.1118      0.946 0.000 0.964 0.000 0.036
#> SRR1058011     2  0.0336      0.949 0.000 0.992 0.000 0.008
#> SRR1058012     4  0.3528      0.665 0.000 0.192 0.000 0.808
#> SRR1058013     2  0.0376      0.949 0.000 0.992 0.004 0.004
#> SRR1058014     2  0.0376      0.949 0.000 0.992 0.004 0.004
#> SRR1058015     4  0.0336      0.808 0.008 0.000 0.000 0.992
#> SRR1058016     2  0.0817      0.948 0.000 0.976 0.000 0.024
#> SRR1058017     2  0.0592      0.949 0.000 0.984 0.000 0.016
#> SRR1058018     4  0.0592      0.797 0.016 0.000 0.000 0.984
#> SRR1058019     2  0.0817      0.945 0.000 0.976 0.024 0.000
#> SRR1058020     2  0.1022      0.946 0.000 0.968 0.000 0.032
#> SRR1058021     4  0.0188      0.806 0.000 0.004 0.000 0.996
#> SRR1058022     2  0.1022      0.942 0.000 0.968 0.032 0.000
#> SRR1058023     4  0.0469      0.801 0.012 0.000 0.000 0.988
#> SRR1058024     2  0.1302      0.942 0.000 0.956 0.000 0.044
#> SRR1058025     2  0.1792      0.928 0.000 0.932 0.000 0.068
#> SRR1058026     2  0.2814      0.872 0.000 0.868 0.000 0.132
#> SRR1058027     2  0.2647      0.884 0.000 0.880 0.000 0.120
#> SRR1058028     2  0.1637      0.933 0.000 0.940 0.000 0.060
#> SRR1058029     2  0.2589      0.883 0.000 0.884 0.116 0.000
#> SRR1058030     2  0.2530      0.886 0.000 0.888 0.112 0.000
#> SRR1058031     2  0.2216      0.903 0.000 0.908 0.092 0.000
#> SRR1058032     1  0.1389      0.496 0.952 0.000 0.048 0.000
#> SRR1058033     1  0.1389      0.496 0.952 0.000 0.048 0.000
#> SRR1058034     1  0.1389      0.496 0.952 0.000 0.048 0.000
#> SRR1058035     1  0.4605      0.882 0.664 0.000 0.000 0.336
#> SRR1058036     1  0.4605      0.882 0.664 0.000 0.000 0.336
#> SRR1058037     1  0.4605      0.882 0.664 0.000 0.000 0.336
#> SRR1058038     1  0.4605      0.882 0.664 0.000 0.000 0.336
#> SRR1058039     1  0.4605      0.882 0.664 0.000 0.000 0.336
#> SRR1058040     1  0.4605      0.882 0.664 0.000 0.000 0.336
#> SRR1058041     1  0.4605      0.882 0.664 0.000 0.000 0.336
#> SRR1058042     1  0.4605      0.882 0.664 0.000 0.000 0.336
#> SRR1058043     1  0.4605      0.882 0.664 0.000 0.000 0.336
#> SRR1058044     1  0.4605      0.882 0.664 0.000 0.000 0.336
#> SRR1058045     1  0.4605      0.882 0.664 0.000 0.000 0.336
#> SRR1058046     1  0.4605      0.882 0.664 0.000 0.000 0.336
#> SRR1058047     3  0.3311      0.810 0.172 0.000 0.828 0.000
#> SRR1058048     3  0.0336      0.872 0.000 0.008 0.992 0.000
#> SRR1058049     3  0.0336      0.872 0.000 0.008 0.992 0.000
#> SRR1058050     3  0.0336      0.872 0.000 0.008 0.992 0.000
#> SRR1058051     3  0.3266      0.812 0.168 0.000 0.832 0.000
#> SRR1058052     3  0.0336      0.872 0.000 0.008 0.992 0.000
#> SRR1058053     3  0.0336      0.872 0.000 0.008 0.992 0.000
#> SRR1058054     3  0.0336      0.872 0.000 0.008 0.992 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4    p5
#> SRR1058003     4   0.297      0.736 0.000 0.000 0.000 0.816 0.184
#> SRR1058004     4   0.175      0.795 0.000 0.036 0.028 0.936 0.000
#> SRR1058006     5   0.201      0.938 0.060 0.000 0.000 0.020 0.920
#> SRR1058005     4   0.167      0.797 0.000 0.032 0.028 0.940 0.000
#> SRR1058007     2   0.275      0.811 0.000 0.856 0.000 0.136 0.008
#> SRR1058008     2   0.280      0.810 0.000 0.852 0.000 0.140 0.008
#> SRR1058009     2   0.241      0.823 0.000 0.892 0.000 0.092 0.016
#> SRR1058010     2   0.279      0.800 0.000 0.880 0.000 0.068 0.052
#> SRR1058011     2   0.207      0.823 0.000 0.912 0.000 0.076 0.012
#> SRR1058012     5   0.406      0.800 0.040 0.096 0.000 0.044 0.820
#> SRR1058013     2   0.272      0.816 0.000 0.864 0.000 0.124 0.012
#> SRR1058014     2   0.267      0.817 0.000 0.868 0.000 0.120 0.012
#> SRR1058015     5   0.134      0.940 0.056 0.000 0.000 0.000 0.944
#> SRR1058016     2   0.184      0.816 0.000 0.932 0.000 0.036 0.032
#> SRR1058017     2   0.108      0.819 0.000 0.964 0.000 0.028 0.008
#> SRR1058018     5   0.173      0.943 0.080 0.000 0.000 0.000 0.920
#> SRR1058019     2   0.356      0.816 0.000 0.848 0.036 0.088 0.028
#> SRR1058020     2   0.251      0.796 0.000 0.892 0.000 0.028 0.080
#> SRR1058021     5   0.170      0.946 0.068 0.004 0.000 0.000 0.928
#> SRR1058022     2   0.354      0.816 0.000 0.848 0.032 0.092 0.028
#> SRR1058023     5   0.173      0.943 0.080 0.000 0.000 0.000 0.920
#> SRR1058024     2   0.318      0.782 0.000 0.852 0.000 0.048 0.100
#> SRR1058025     2   0.417      0.697 0.000 0.756 0.000 0.044 0.200
#> SRR1058026     2   0.529      0.222 0.000 0.496 0.000 0.048 0.456
#> SRR1058027     2   0.528      0.268 0.000 0.512 0.000 0.048 0.440
#> SRR1058028     2   0.488      0.565 0.000 0.652 0.000 0.048 0.300
#> SRR1058029     2   0.486      0.777 0.000 0.760 0.120 0.092 0.028
#> SRR1058030     2   0.491      0.775 0.000 0.756 0.120 0.096 0.028
#> SRR1058031     2   0.457      0.792 0.000 0.784 0.096 0.092 0.028
#> SRR1058032     4   0.320      0.848 0.168 0.000 0.012 0.820 0.000
#> SRR1058033     4   0.320      0.848 0.168 0.000 0.012 0.820 0.000
#> SRR1058034     4   0.320      0.848 0.168 0.000 0.012 0.820 0.000
#> SRR1058035     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1058036     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1058037     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1058038     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1058039     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1058040     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1058041     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1058042     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1058043     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1058044     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1058045     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1058046     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1058047     3   0.348      0.693 0.000 0.000 0.752 0.248 0.000
#> SRR1058048     3   0.000      0.920 0.000 0.000 1.000 0.000 0.000
#> SRR1058049     3   0.000      0.920 0.000 0.000 1.000 0.000 0.000
#> SRR1058050     3   0.000      0.920 0.000 0.000 1.000 0.000 0.000
#> SRR1058051     3   0.345      0.699 0.000 0.000 0.756 0.244 0.000
#> SRR1058052     3   0.000      0.920 0.000 0.000 1.000 0.000 0.000
#> SRR1058053     3   0.000      0.920 0.000 0.000 1.000 0.000 0.000
#> SRR1058054     3   0.000      0.920 0.000 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR1058003     4  0.2219     0.8355 0.000 0.000 0.000 0.864 0.136 0.000
#> SRR1058004     4  0.0520     0.9257 0.000 0.008 0.000 0.984 0.000 0.008
#> SRR1058006     5  0.0951     0.9702 0.004 0.000 0.000 0.008 0.968 0.020
#> SRR1058005     4  0.0520     0.9257 0.000 0.008 0.000 0.984 0.000 0.008
#> SRR1058007     2  0.4927     0.4428 0.000 0.560 0.000 0.044 0.012 0.384
#> SRR1058008     2  0.4943     0.4384 0.000 0.552 0.000 0.044 0.012 0.392
#> SRR1058009     2  0.4896     0.3909 0.000 0.508 0.000 0.036 0.012 0.444
#> SRR1058010     6  0.3111     0.1255 0.000 0.156 0.000 0.016 0.008 0.820
#> SRR1058011     6  0.4744    -0.4272 0.000 0.440 0.000 0.032 0.008 0.520
#> SRR1058012     6  0.3995    -0.0979 0.000 0.004 0.000 0.000 0.480 0.516
#> SRR1058013     2  0.4582     0.4318 0.000 0.552 0.000 0.024 0.008 0.416
#> SRR1058014     2  0.4751     0.4268 0.000 0.536 0.000 0.028 0.012 0.424
#> SRR1058015     5  0.0603     0.9754 0.004 0.000 0.000 0.000 0.980 0.016
#> SRR1058016     6  0.3724     0.0137 0.000 0.268 0.000 0.012 0.004 0.716
#> SRR1058017     2  0.4314     0.2138 0.000 0.500 0.000 0.012 0.004 0.484
#> SRR1058018     5  0.0692     0.9773 0.020 0.000 0.000 0.000 0.976 0.004
#> SRR1058019     2  0.1257     0.4678 0.000 0.952 0.028 0.000 0.000 0.020
#> SRR1058020     2  0.4315    -0.3900 0.000 0.492 0.000 0.004 0.012 0.492
#> SRR1058021     5  0.0363     0.9729 0.000 0.000 0.000 0.000 0.988 0.012
#> SRR1058022     2  0.1723     0.4704 0.000 0.928 0.036 0.000 0.000 0.036
#> SRR1058023     5  0.0692     0.9773 0.020 0.000 0.000 0.000 0.976 0.004
#> SRR1058024     2  0.4444    -0.3402 0.000 0.536 0.000 0.000 0.028 0.436
#> SRR1058025     6  0.4763     0.3890 0.000 0.412 0.000 0.000 0.052 0.536
#> SRR1058026     6  0.4725     0.4619 0.000 0.332 0.000 0.000 0.064 0.604
#> SRR1058027     6  0.4660     0.4601 0.000 0.344 0.000 0.000 0.056 0.600
#> SRR1058028     6  0.4514     0.4457 0.000 0.372 0.000 0.000 0.040 0.588
#> SRR1058029     2  0.1444     0.4683 0.000 0.928 0.072 0.000 0.000 0.000
#> SRR1058030     2  0.1732     0.4690 0.000 0.920 0.072 0.004 0.000 0.004
#> SRR1058031     2  0.1349     0.4692 0.000 0.940 0.056 0.000 0.000 0.004
#> SRR1058032     4  0.1141     0.9391 0.052 0.000 0.000 0.948 0.000 0.000
#> SRR1058033     4  0.1141     0.9391 0.052 0.000 0.000 0.948 0.000 0.000
#> SRR1058034     4  0.1141     0.9391 0.052 0.000 0.000 0.948 0.000 0.000
#> SRR1058035     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058036     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058037     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058038     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058039     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058040     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058041     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058042     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058043     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058044     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058045     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058046     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058047     3  0.3076     0.7245 0.000 0.000 0.760 0.240 0.000 0.000
#> SRR1058048     3  0.0000     0.9276 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1058049     3  0.0000     0.9276 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1058050     3  0.0000     0.9276 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1058051     3  0.3023     0.7348 0.000 0.000 0.768 0.232 0.000 0.000
#> SRR1058052     3  0.0000     0.9276 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1058053     3  0.0000     0.9276 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1058054     3  0.0000     0.9276 0.000 0.000 1.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-skmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-skmeans-collect-classes

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


SD:pam

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

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

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

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 18325 rows and 52 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#>   Subgroups are detected by 'pam' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 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-pam-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.809           0.890       0.956         0.4754 0.527   0.527
#> 3 3 0.878           0.891       0.958         0.2185 0.889   0.792
#> 4 4 0.754           0.839       0.927         0.0666 0.978   0.949
#> 5 5 0.741           0.807       0.912         0.0495 0.979   0.948
#> 6 6 0.679           0.757       0.888         0.0495 0.980   0.947

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

suggest_best_k(res)
#> [1] 3

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette    p1    p2
#> SRR1058003     2  0.9522      0.423 0.372 0.628
#> SRR1058004     2  0.0000      0.953 0.000 1.000
#> SRR1058006     2  0.9635      0.387 0.388 0.612
#> SRR1058005     2  0.0000      0.953 0.000 1.000
#> SRR1058007     2  0.0000      0.953 0.000 1.000
#> SRR1058008     2  0.0000      0.953 0.000 1.000
#> SRR1058009     2  0.0000      0.953 0.000 1.000
#> SRR1058010     2  0.0000      0.953 0.000 1.000
#> SRR1058011     2  0.0000      0.953 0.000 1.000
#> SRR1058012     2  0.9608      0.397 0.384 0.616
#> SRR1058013     2  0.0000      0.953 0.000 1.000
#> SRR1058014     2  0.0000      0.953 0.000 1.000
#> SRR1058015     1  0.9795      0.235 0.584 0.416
#> SRR1058016     2  0.0000      0.953 0.000 1.000
#> SRR1058017     2  0.0000      0.953 0.000 1.000
#> SRR1058018     1  0.0000      0.944 1.000 0.000
#> SRR1058019     2  0.0000      0.953 0.000 1.000
#> SRR1058020     2  0.0000      0.953 0.000 1.000
#> SRR1058021     1  0.6801      0.760 0.820 0.180
#> SRR1058022     2  0.0000      0.953 0.000 1.000
#> SRR1058023     1  0.0000      0.944 1.000 0.000
#> SRR1058024     2  0.0000      0.953 0.000 1.000
#> SRR1058025     2  0.0000      0.953 0.000 1.000
#> SRR1058026     2  0.6148      0.801 0.152 0.848
#> SRR1058027     2  0.4562      0.865 0.096 0.904
#> SRR1058028     2  0.0000      0.953 0.000 1.000
#> SRR1058029     2  0.0000      0.953 0.000 1.000
#> SRR1058030     2  0.0000      0.953 0.000 1.000
#> SRR1058031     2  0.0000      0.953 0.000 1.000
#> SRR1058032     1  0.0938      0.936 0.988 0.012
#> SRR1058033     1  0.7219      0.743 0.800 0.200
#> SRR1058034     1  0.5059      0.850 0.888 0.112
#> SRR1058035     1  0.0000      0.944 1.000 0.000
#> SRR1058036     1  0.0000      0.944 1.000 0.000
#> SRR1058037     1  0.0000      0.944 1.000 0.000
#> SRR1058038     1  0.0000      0.944 1.000 0.000
#> SRR1058039     1  0.0000      0.944 1.000 0.000
#> SRR1058040     1  0.0000      0.944 1.000 0.000
#> SRR1058041     1  0.0000      0.944 1.000 0.000
#> SRR1058042     1  0.0000      0.944 1.000 0.000
#> SRR1058043     1  0.0000      0.944 1.000 0.000
#> SRR1058044     1  0.0000      0.944 1.000 0.000
#> SRR1058045     1  0.0000      0.944 1.000 0.000
#> SRR1058046     1  0.0000      0.944 1.000 0.000
#> SRR1058047     2  0.0000      0.953 0.000 1.000
#> SRR1058048     2  0.0000      0.953 0.000 1.000
#> SRR1058049     2  0.0000      0.953 0.000 1.000
#> SRR1058050     2  0.0000      0.953 0.000 1.000
#> SRR1058051     2  0.0000      0.953 0.000 1.000
#> SRR1058052     2  0.0000      0.953 0.000 1.000
#> SRR1058053     2  0.0000      0.953 0.000 1.000
#> SRR1058054     2  0.0000      0.953 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2   p3
#> SRR1058003     3   0.000      1.000 0.000 0.000 1.00
#> SRR1058004     3   0.000      1.000 0.000 0.000 1.00
#> SRR1058006     2   0.621      0.266 0.428 0.572 0.00
#> SRR1058005     3   0.000      1.000 0.000 0.000 1.00
#> SRR1058007     2   0.000      0.942 0.000 1.000 0.00
#> SRR1058008     2   0.000      0.942 0.000 1.000 0.00
#> SRR1058009     2   0.000      0.942 0.000 1.000 0.00
#> SRR1058010     2   0.000      0.942 0.000 1.000 0.00
#> SRR1058011     2   0.000      0.942 0.000 1.000 0.00
#> SRR1058012     2   0.613      0.346 0.400 0.600 0.00
#> SRR1058013     2   0.000      0.942 0.000 1.000 0.00
#> SRR1058014     2   0.000      0.942 0.000 1.000 0.00
#> SRR1058015     1   0.618      0.225 0.584 0.416 0.00
#> SRR1058016     2   0.000      0.942 0.000 1.000 0.00
#> SRR1058017     2   0.000      0.942 0.000 1.000 0.00
#> SRR1058018     1   0.000      0.940 1.000 0.000 0.00
#> SRR1058019     2   0.000      0.942 0.000 1.000 0.00
#> SRR1058020     2   0.000      0.942 0.000 1.000 0.00
#> SRR1058021     1   0.460      0.679 0.796 0.204 0.00
#> SRR1058022     2   0.000      0.942 0.000 1.000 0.00
#> SRR1058023     1   0.000      0.940 1.000 0.000 0.00
#> SRR1058024     2   0.000      0.942 0.000 1.000 0.00
#> SRR1058025     2   0.000      0.942 0.000 1.000 0.00
#> SRR1058026     2   0.382      0.807 0.148 0.852 0.00
#> SRR1058027     2   0.271      0.868 0.088 0.912 0.00
#> SRR1058028     2   0.000      0.942 0.000 1.000 0.00
#> SRR1058029     2   0.000      0.942 0.000 1.000 0.00
#> SRR1058030     2   0.000      0.942 0.000 1.000 0.00
#> SRR1058031     2   0.000      0.942 0.000 1.000 0.00
#> SRR1058032     3   0.000      1.000 0.000 0.000 1.00
#> SRR1058033     3   0.000      1.000 0.000 0.000 1.00
#> SRR1058034     3   0.000      1.000 0.000 0.000 1.00
#> SRR1058035     1   0.000      0.940 1.000 0.000 0.00
#> SRR1058036     1   0.000      0.940 1.000 0.000 0.00
#> SRR1058037     1   0.000      0.940 1.000 0.000 0.00
#> SRR1058038     1   0.000      0.940 1.000 0.000 0.00
#> SRR1058039     1   0.000      0.940 1.000 0.000 0.00
#> SRR1058040     1   0.000      0.940 1.000 0.000 0.00
#> SRR1058041     1   0.000      0.940 1.000 0.000 0.00
#> SRR1058042     1   0.000      0.940 1.000 0.000 0.00
#> SRR1058043     1   0.000      0.940 1.000 0.000 0.00
#> SRR1058044     1   0.000      0.940 1.000 0.000 0.00
#> SRR1058045     1   0.000      0.940 1.000 0.000 0.00
#> SRR1058046     1   0.000      0.940 1.000 0.000 0.00
#> SRR1058047     2   0.540      0.639 0.000 0.720 0.28
#> SRR1058048     2   0.000      0.942 0.000 1.000 0.00
#> SRR1058049     2   0.000      0.942 0.000 1.000 0.00
#> SRR1058050     2   0.000      0.942 0.000 1.000 0.00
#> SRR1058051     2   0.455      0.753 0.000 0.800 0.20
#> SRR1058052     2   0.000      0.942 0.000 1.000 0.00
#> SRR1058053     2   0.000      0.942 0.000 1.000 0.00
#> SRR1058054     2   0.000      0.942 0.000 1.000 0.00

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1058003     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> SRR1058004     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> SRR1058006     2  0.4916      0.281 0.424 0.576 0.000 0.000
#> SRR1058005     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> SRR1058007     2  0.3569      0.839 0.000 0.804 0.196 0.000
#> SRR1058008     2  0.3569      0.839 0.000 0.804 0.196 0.000
#> SRR1058009     2  0.3569      0.839 0.000 0.804 0.196 0.000
#> SRR1058010     2  0.3569      0.839 0.000 0.804 0.196 0.000
#> SRR1058011     2  0.3569      0.839 0.000 0.804 0.196 0.000
#> SRR1058012     3  0.4098      0.000 0.204 0.012 0.784 0.000
#> SRR1058013     2  0.3356      0.846 0.000 0.824 0.176 0.000
#> SRR1058014     2  0.3569      0.839 0.000 0.804 0.196 0.000
#> SRR1058015     1  0.4843      0.123 0.604 0.396 0.000 0.000
#> SRR1058016     2  0.3569      0.839 0.000 0.804 0.196 0.000
#> SRR1058017     2  0.3569      0.839 0.000 0.804 0.196 0.000
#> SRR1058018     1  0.0000      0.912 1.000 0.000 0.000 0.000
#> SRR1058019     2  0.0469      0.890 0.000 0.988 0.012 0.000
#> SRR1058020     2  0.0469      0.890 0.000 0.988 0.012 0.000
#> SRR1058021     1  0.3942      0.440 0.764 0.236 0.000 0.000
#> SRR1058022     2  0.0469      0.890 0.000 0.988 0.012 0.000
#> SRR1058023     1  0.0000      0.912 1.000 0.000 0.000 0.000
#> SRR1058024     2  0.0469      0.890 0.000 0.988 0.012 0.000
#> SRR1058025     2  0.0469      0.890 0.000 0.988 0.012 0.000
#> SRR1058026     2  0.3498      0.775 0.160 0.832 0.008 0.000
#> SRR1058027     2  0.0672      0.887 0.008 0.984 0.008 0.000
#> SRR1058028     2  0.0469      0.890 0.000 0.988 0.012 0.000
#> SRR1058029     2  0.0469      0.890 0.000 0.988 0.012 0.000
#> SRR1058030     2  0.0469      0.890 0.000 0.988 0.012 0.000
#> SRR1058031     2  0.0469      0.890 0.000 0.988 0.012 0.000
#> SRR1058032     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> SRR1058033     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> SRR1058034     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> SRR1058035     1  0.0000      0.912 1.000 0.000 0.000 0.000
#> SRR1058036     1  0.0000      0.912 1.000 0.000 0.000 0.000
#> SRR1058037     1  0.0000      0.912 1.000 0.000 0.000 0.000
#> SRR1058038     1  0.0000      0.912 1.000 0.000 0.000 0.000
#> SRR1058039     1  0.0000      0.912 1.000 0.000 0.000 0.000
#> SRR1058040     1  0.0000      0.912 1.000 0.000 0.000 0.000
#> SRR1058041     1  0.0000      0.912 1.000 0.000 0.000 0.000
#> SRR1058042     1  0.0000      0.912 1.000 0.000 0.000 0.000
#> SRR1058043     1  0.0000      0.912 1.000 0.000 0.000 0.000
#> SRR1058044     1  0.0000      0.912 1.000 0.000 0.000 0.000
#> SRR1058045     1  0.0000      0.912 1.000 0.000 0.000 0.000
#> SRR1058046     1  0.0000      0.912 1.000 0.000 0.000 0.000
#> SRR1058047     2  0.4250      0.690 0.000 0.724 0.000 0.276
#> SRR1058048     2  0.0000      0.891 0.000 1.000 0.000 0.000
#> SRR1058049     2  0.0000      0.891 0.000 1.000 0.000 0.000
#> SRR1058050     2  0.0000      0.891 0.000 1.000 0.000 0.000
#> SRR1058051     2  0.3610      0.785 0.000 0.800 0.000 0.200
#> SRR1058052     2  0.0000      0.891 0.000 1.000 0.000 0.000
#> SRR1058053     2  0.0000      0.891 0.000 1.000 0.000 0.000
#> SRR1058054     2  0.0000      0.891 0.000 1.000 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
#> SRR1058003     4   0.000      1.000 0.000 0.000 0.000 1.000 0.000
#> SRR1058004     4   0.000      1.000 0.000 0.000 0.000 1.000 0.000
#> SRR1058006     2   0.434      0.333 0.404 0.592 0.000 0.000 0.004
#> SRR1058005     4   0.000      1.000 0.000 0.000 0.000 1.000 0.000
#> SRR1058007     2   0.318      0.805 0.000 0.792 0.000 0.000 0.208
#> SRR1058008     2   0.318      0.805 0.000 0.792 0.000 0.000 0.208
#> SRR1058009     2   0.318      0.805 0.000 0.792 0.000 0.000 0.208
#> SRR1058010     2   0.345      0.804 0.000 0.784 0.008 0.000 0.208
#> SRR1058011     2   0.356      0.804 0.000 0.780 0.012 0.000 0.208
#> SRR1058012     5   0.369      0.000 0.180 0.000 0.028 0.000 0.792
#> SRR1058013     2   0.297      0.815 0.000 0.816 0.000 0.000 0.184
#> SRR1058014     2   0.314      0.808 0.000 0.796 0.000 0.000 0.204
#> SRR1058015     1   0.420      0.133 0.592 0.408 0.000 0.000 0.000
#> SRR1058016     2   0.318      0.805 0.000 0.792 0.000 0.000 0.208
#> SRR1058017     2   0.345      0.804 0.000 0.784 0.008 0.000 0.208
#> SRR1058018     1   0.000      0.918 1.000 0.000 0.000 0.000 0.000
#> SRR1058019     2   0.148      0.839 0.000 0.936 0.064 0.000 0.000
#> SRR1058020     2   0.112      0.848 0.000 0.960 0.036 0.000 0.004
#> SRR1058021     1   0.318      0.524 0.792 0.208 0.000 0.000 0.000
#> SRR1058022     2   0.164      0.840 0.000 0.932 0.064 0.000 0.004
#> SRR1058023     1   0.000      0.918 1.000 0.000 0.000 0.000 0.000
#> SRR1058024     2   0.164      0.840 0.000 0.932 0.064 0.000 0.004
#> SRR1058025     2   0.164      0.840 0.000 0.932 0.064 0.000 0.004
#> SRR1058026     3   0.241      0.000 0.016 0.092 0.892 0.000 0.000
#> SRR1058027     2   0.297      0.786 0.000 0.816 0.184 0.000 0.000
#> SRR1058028     2   0.154      0.840 0.000 0.932 0.068 0.000 0.000
#> SRR1058029     2   0.161      0.838 0.000 0.928 0.072 0.000 0.000
#> SRR1058030     2   0.161      0.838 0.000 0.928 0.072 0.000 0.000
#> SRR1058031     2   0.161      0.838 0.000 0.928 0.072 0.000 0.000
#> SRR1058032     4   0.000      1.000 0.000 0.000 0.000 1.000 0.000
#> SRR1058033     4   0.000      1.000 0.000 0.000 0.000 1.000 0.000
#> SRR1058034     4   0.000      1.000 0.000 0.000 0.000 1.000 0.000
#> SRR1058035     1   0.000      0.918 1.000 0.000 0.000 0.000 0.000
#> SRR1058036     1   0.000      0.918 1.000 0.000 0.000 0.000 0.000
#> SRR1058037     1   0.000      0.918 1.000 0.000 0.000 0.000 0.000
#> SRR1058038     1   0.000      0.918 1.000 0.000 0.000 0.000 0.000
#> SRR1058039     1   0.000      0.918 1.000 0.000 0.000 0.000 0.000
#> SRR1058040     1   0.000      0.918 1.000 0.000 0.000 0.000 0.000
#> SRR1058041     1   0.000      0.918 1.000 0.000 0.000 0.000 0.000
#> SRR1058042     1   0.000      0.918 1.000 0.000 0.000 0.000 0.000
#> SRR1058043     1   0.000      0.918 1.000 0.000 0.000 0.000 0.000
#> SRR1058044     1   0.000      0.918 1.000 0.000 0.000 0.000 0.000
#> SRR1058045     1   0.000      0.918 1.000 0.000 0.000 0.000 0.000
#> SRR1058046     1   0.000      0.918 1.000 0.000 0.000 0.000 0.000
#> SRR1058047     2   0.414      0.649 0.000 0.708 0.016 0.276 0.000
#> SRR1058048     2   0.051      0.852 0.000 0.984 0.016 0.000 0.000
#> SRR1058049     2   0.051      0.852 0.000 0.984 0.016 0.000 0.000
#> SRR1058050     2   0.051      0.852 0.000 0.984 0.016 0.000 0.000
#> SRR1058051     2   0.360      0.751 0.000 0.784 0.016 0.200 0.000
#> SRR1058052     2   0.051      0.852 0.000 0.984 0.016 0.000 0.000
#> SRR1058053     2   0.051      0.852 0.000 0.984 0.016 0.000 0.000
#> SRR1058054     2   0.051      0.852 0.000 0.984 0.016 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3   p4    p5    p6
#> SRR1058003     4  0.0000      1.000 0.000 0.000 0.000 1.00 0.000 0.000
#> SRR1058004     4  0.0000      1.000 0.000 0.000 0.000 1.00 0.000 0.000
#> SRR1058006     2  0.5162      0.275 0.372 0.552 0.012 0.00 0.000 0.064
#> SRR1058005     4  0.0000      1.000 0.000 0.000 0.000 1.00 0.000 0.000
#> SRR1058007     2  0.3288      0.727 0.000 0.724 0.000 0.00 0.000 0.276
#> SRR1058008     2  0.3288      0.727 0.000 0.724 0.000 0.00 0.000 0.276
#> SRR1058009     2  0.3288      0.727 0.000 0.724 0.000 0.00 0.000 0.276
#> SRR1058010     2  0.3351      0.725 0.000 0.712 0.000 0.00 0.000 0.288
#> SRR1058011     2  0.3351      0.725 0.000 0.712 0.000 0.00 0.000 0.288
#> SRR1058012     3  0.0000      0.000 0.000 0.000 1.000 0.00 0.000 0.000
#> SRR1058013     2  0.3151      0.739 0.000 0.748 0.000 0.00 0.000 0.252
#> SRR1058014     2  0.3266      0.729 0.000 0.728 0.000 0.00 0.000 0.272
#> SRR1058015     1  0.4344      0.143 0.568 0.412 0.012 0.00 0.000 0.008
#> SRR1058016     2  0.3288      0.727 0.000 0.724 0.000 0.00 0.000 0.276
#> SRR1058017     2  0.3266      0.728 0.000 0.728 0.000 0.00 0.000 0.272
#> SRR1058018     1  0.0622      0.919 0.980 0.000 0.012 0.00 0.000 0.008
#> SRR1058019     2  0.2048      0.750 0.000 0.880 0.000 0.00 0.000 0.120
#> SRR1058020     2  0.1663      0.786 0.000 0.912 0.000 0.00 0.000 0.088
#> SRR1058021     1  0.2805      0.649 0.812 0.184 0.000 0.00 0.000 0.004
#> SRR1058022     2  0.2562      0.757 0.000 0.828 0.000 0.00 0.000 0.172
#> SRR1058023     1  0.0622      0.919 0.980 0.000 0.012 0.00 0.000 0.008
#> SRR1058024     2  0.2562      0.757 0.000 0.828 0.000 0.00 0.000 0.172
#> SRR1058025     2  0.2597      0.756 0.000 0.824 0.000 0.00 0.000 0.176
#> SRR1058026     5  0.0000      0.000 0.000 0.000 0.000 0.00 1.000 0.000
#> SRR1058027     6  0.5303      0.000 0.000 0.196 0.000 0.00 0.204 0.600
#> SRR1058028     2  0.2191      0.750 0.000 0.876 0.000 0.00 0.004 0.120
#> SRR1058029     2  0.1957      0.748 0.000 0.888 0.000 0.00 0.000 0.112
#> SRR1058030     2  0.1957      0.748 0.000 0.888 0.000 0.00 0.000 0.112
#> SRR1058031     2  0.1957      0.748 0.000 0.888 0.000 0.00 0.000 0.112
#> SRR1058032     4  0.0000      1.000 0.000 0.000 0.000 1.00 0.000 0.000
#> SRR1058033     4  0.0000      1.000 0.000 0.000 0.000 1.00 0.000 0.000
#> SRR1058034     4  0.0000      1.000 0.000 0.000 0.000 1.00 0.000 0.000
#> SRR1058035     1  0.0000      0.932 1.000 0.000 0.000 0.00 0.000 0.000
#> SRR1058036     1  0.0000      0.932 1.000 0.000 0.000 0.00 0.000 0.000
#> SRR1058037     1  0.0000      0.932 1.000 0.000 0.000 0.00 0.000 0.000
#> SRR1058038     1  0.0000      0.932 1.000 0.000 0.000 0.00 0.000 0.000
#> SRR1058039     1  0.0000      0.932 1.000 0.000 0.000 0.00 0.000 0.000
#> SRR1058040     1  0.0000      0.932 1.000 0.000 0.000 0.00 0.000 0.000
#> SRR1058041     1  0.0000      0.932 1.000 0.000 0.000 0.00 0.000 0.000
#> SRR1058042     1  0.0000      0.932 1.000 0.000 0.000 0.00 0.000 0.000
#> SRR1058043     1  0.0000      0.932 1.000 0.000 0.000 0.00 0.000 0.000
#> SRR1058044     1  0.0000      0.932 1.000 0.000 0.000 0.00 0.000 0.000
#> SRR1058045     1  0.0000      0.932 1.000 0.000 0.000 0.00 0.000 0.000
#> SRR1058046     1  0.0000      0.932 1.000 0.000 0.000 0.00 0.000 0.000
#> SRR1058047     2  0.3650      0.551 0.000 0.708 0.000 0.28 0.000 0.012
#> SRR1058048     2  0.0363      0.785 0.000 0.988 0.000 0.00 0.000 0.012
#> SRR1058049     2  0.0363      0.785 0.000 0.988 0.000 0.00 0.000 0.012
#> SRR1058050     2  0.0363      0.785 0.000 0.988 0.000 0.00 0.000 0.012
#> SRR1058051     2  0.3141      0.670 0.000 0.788 0.000 0.20 0.000 0.012
#> SRR1058052     2  0.0363      0.785 0.000 0.988 0.000 0.00 0.000 0.012
#> SRR1058053     2  0.0363      0.785 0.000 0.988 0.000 0.00 0.000 0.012
#> SRR1058054     2  0.0363      0.785 0.000 0.988 0.000 0.00 0.000 0.012

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

consensus_heatmap(res, k = 2)

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

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

collect_plots(res)

plot of chunk SD-mclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.3623 0.638   0.638
#> 3 3 0.636           0.818       0.913         0.6407 0.759   0.623
#> 4 4 0.837           0.918       0.955         0.1425 0.907   0.773
#> 5 5 0.782           0.852       0.903         0.1273 0.910   0.724
#> 6 6 0.826           0.713       0.855         0.0784 0.937   0.732

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
#> SRR1058003     2  0.0000      1.000 0.000 1.000
#> SRR1058004     2  0.0000      1.000 0.000 1.000
#> SRR1058006     2  0.0000      1.000 0.000 1.000
#> SRR1058005     2  0.0000      1.000 0.000 1.000
#> SRR1058007     2  0.0000      1.000 0.000 1.000
#> SRR1058008     2  0.0000      1.000 0.000 1.000
#> SRR1058009     2  0.0000      1.000 0.000 1.000
#> SRR1058010     2  0.0000      1.000 0.000 1.000
#> SRR1058011     2  0.0000      1.000 0.000 1.000
#> SRR1058012     2  0.0000      1.000 0.000 1.000
#> SRR1058013     2  0.0000      1.000 0.000 1.000
#> SRR1058014     2  0.0000      1.000 0.000 1.000
#> SRR1058015     2  0.0000      1.000 0.000 1.000
#> SRR1058016     2  0.0000      1.000 0.000 1.000
#> SRR1058017     2  0.0000      1.000 0.000 1.000
#> SRR1058018     2  0.0000      1.000 0.000 1.000
#> SRR1058019     2  0.0000      1.000 0.000 1.000
#> SRR1058020     2  0.0000      1.000 0.000 1.000
#> SRR1058021     2  0.0000      1.000 0.000 1.000
#> SRR1058022     2  0.0000      1.000 0.000 1.000
#> SRR1058023     2  0.0000      1.000 0.000 1.000
#> SRR1058024     2  0.0000      1.000 0.000 1.000
#> SRR1058025     2  0.0000      1.000 0.000 1.000
#> SRR1058026     2  0.0000      1.000 0.000 1.000
#> SRR1058027     2  0.0000      1.000 0.000 1.000
#> SRR1058028     2  0.0000      1.000 0.000 1.000
#> SRR1058029     2  0.0000      1.000 0.000 1.000
#> SRR1058030     2  0.0000      1.000 0.000 1.000
#> SRR1058031     2  0.0000      1.000 0.000 1.000
#> SRR1058032     2  0.0000      1.000 0.000 1.000
#> SRR1058033     2  0.0000      1.000 0.000 1.000
#> SRR1058034     2  0.0000      1.000 0.000 1.000
#> SRR1058035     1  0.0376      0.997 0.996 0.004
#> SRR1058036     1  0.0376      0.997 0.996 0.004
#> SRR1058037     1  0.0376      0.997 0.996 0.004
#> SRR1058038     1  0.0000      0.999 1.000 0.000
#> SRR1058039     1  0.0000      0.999 1.000 0.000
#> SRR1058040     1  0.0000      0.999 1.000 0.000
#> SRR1058041     1  0.0000      0.999 1.000 0.000
#> SRR1058042     1  0.0000      0.999 1.000 0.000
#> SRR1058043     1  0.0376      0.997 0.996 0.004
#> SRR1058044     1  0.0000      0.999 1.000 0.000
#> SRR1058045     1  0.0000      0.999 1.000 0.000
#> SRR1058046     1  0.0000      0.999 1.000 0.000
#> SRR1058047     2  0.0000      1.000 0.000 1.000
#> SRR1058048     2  0.0000      1.000 0.000 1.000
#> SRR1058049     2  0.0000      1.000 0.000 1.000
#> SRR1058050     2  0.0000      1.000 0.000 1.000
#> SRR1058051     2  0.0000      1.000 0.000 1.000
#> SRR1058052     2  0.0000      1.000 0.000 1.000
#> SRR1058053     2  0.0000      1.000 0.000 1.000
#> SRR1058054     2  0.0000      1.000 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette p1    p2    p3
#> SRR1058003     2  0.4555      0.730  0 0.800 0.200
#> SRR1058004     2  0.4555      0.730  0 0.800 0.200
#> SRR1058006     2  0.4555      0.730  0 0.800 0.200
#> SRR1058005     2  0.4555      0.730  0 0.800 0.200
#> SRR1058007     2  0.0424      0.873  0 0.992 0.008
#> SRR1058008     2  0.0237      0.873  0 0.996 0.004
#> SRR1058009     2  0.0424      0.873  0 0.992 0.008
#> SRR1058010     2  0.0237      0.873  0 0.996 0.004
#> SRR1058011     2  0.0424      0.873  0 0.992 0.008
#> SRR1058012     2  0.2711      0.825  0 0.912 0.088
#> SRR1058013     2  0.0424      0.873  0 0.992 0.008
#> SRR1058014     2  0.0424      0.873  0 0.992 0.008
#> SRR1058015     2  0.4555      0.730  0 0.800 0.200
#> SRR1058016     2  0.0424      0.873  0 0.992 0.008
#> SRR1058017     2  0.0424      0.873  0 0.992 0.008
#> SRR1058018     2  0.4555      0.730  0 0.800 0.200
#> SRR1058019     2  0.4346      0.701  0 0.816 0.184
#> SRR1058020     2  0.0000      0.873  0 1.000 0.000
#> SRR1058021     2  0.4555      0.730  0 0.800 0.200
#> SRR1058022     2  0.0424      0.873  0 0.992 0.008
#> SRR1058023     2  0.4555      0.730  0 0.800 0.200
#> SRR1058024     2  0.0000      0.873  0 1.000 0.000
#> SRR1058025     2  0.0000      0.873  0 1.000 0.000
#> SRR1058026     2  0.0000      0.873  0 1.000 0.000
#> SRR1058027     2  0.0000      0.873  0 1.000 0.000
#> SRR1058028     2  0.0000      0.873  0 1.000 0.000
#> SRR1058029     2  0.4399      0.696  0 0.812 0.188
#> SRR1058030     2  0.4399      0.696  0 0.812 0.188
#> SRR1058031     2  0.4399      0.696  0 0.812 0.188
#> SRR1058032     3  0.6126      0.542  0 0.400 0.600
#> SRR1058033     3  0.6126      0.542  0 0.400 0.600
#> SRR1058034     3  0.6126      0.542  0 0.400 0.600
#> SRR1058035     1  0.0000      1.000  1 0.000 0.000
#> SRR1058036     1  0.0000      1.000  1 0.000 0.000
#> SRR1058037     1  0.0000      1.000  1 0.000 0.000
#> SRR1058038     1  0.0000      1.000  1 0.000 0.000
#> SRR1058039     1  0.0000      1.000  1 0.000 0.000
#> SRR1058040     1  0.0000      1.000  1 0.000 0.000
#> SRR1058041     1  0.0000      1.000  1 0.000 0.000
#> SRR1058042     1  0.0000      1.000  1 0.000 0.000
#> SRR1058043     1  0.0000      1.000  1 0.000 0.000
#> SRR1058044     1  0.0000      1.000  1 0.000 0.000
#> SRR1058045     1  0.0000      1.000  1 0.000 0.000
#> SRR1058046     1  0.0000      1.000  1 0.000 0.000
#> SRR1058047     3  0.6126      0.542  0 0.400 0.600
#> SRR1058048     3  0.0000      0.736  0 0.000 1.000
#> SRR1058049     3  0.0000      0.736  0 0.000 1.000
#> SRR1058050     3  0.0000      0.736  0 0.000 1.000
#> SRR1058051     3  0.6126      0.542  0 0.400 0.600
#> SRR1058052     3  0.0000      0.736  0 0.000 1.000
#> SRR1058053     3  0.0000      0.736  0 0.000 1.000
#> SRR1058054     3  0.0000      0.736  0 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette   p1    p2    p3    p4
#> SRR1058003     4  0.3400      0.775 0.00 0.180 0.000 0.820
#> SRR1058004     4  0.3266      0.786 0.00 0.168 0.000 0.832
#> SRR1058006     2  0.1637      0.911 0.00 0.940 0.000 0.060
#> SRR1058005     4  0.3266      0.786 0.00 0.168 0.000 0.832
#> SRR1058007     2  0.0188      0.942 0.00 0.996 0.004 0.000
#> SRR1058008     2  0.0188      0.942 0.00 0.996 0.004 0.000
#> SRR1058009     2  0.0188      0.942 0.00 0.996 0.004 0.000
#> SRR1058010     2  0.0000      0.942 0.00 1.000 0.000 0.000
#> SRR1058011     2  0.0188      0.942 0.00 0.996 0.004 0.000
#> SRR1058012     2  0.0469      0.937 0.00 0.988 0.000 0.012
#> SRR1058013     2  0.0188      0.942 0.00 0.996 0.004 0.000
#> SRR1058014     2  0.0188      0.942 0.00 0.996 0.004 0.000
#> SRR1058015     2  0.1637      0.911 0.00 0.940 0.000 0.060
#> SRR1058016     2  0.0000      0.942 0.00 1.000 0.000 0.000
#> SRR1058017     2  0.0188      0.942 0.00 0.996 0.004 0.000
#> SRR1058018     2  0.1637      0.911 0.00 0.940 0.000 0.060
#> SRR1058019     2  0.3400      0.810 0.00 0.820 0.180 0.000
#> SRR1058020     2  0.0000      0.942 0.00 1.000 0.000 0.000
#> SRR1058021     2  0.1637      0.911 0.00 0.940 0.000 0.060
#> SRR1058022     2  0.3024      0.840 0.00 0.852 0.148 0.000
#> SRR1058023     2  0.1637      0.911 0.00 0.940 0.000 0.060
#> SRR1058024     2  0.0000      0.942 0.00 1.000 0.000 0.000
#> SRR1058025     2  0.0000      0.942 0.00 1.000 0.000 0.000
#> SRR1058026     2  0.0000      0.942 0.00 1.000 0.000 0.000
#> SRR1058027     2  0.0000      0.942 0.00 1.000 0.000 0.000
#> SRR1058028     2  0.0000      0.942 0.00 1.000 0.000 0.000
#> SRR1058029     2  0.3610      0.789 0.00 0.800 0.200 0.000
#> SRR1058030     2  0.4072      0.719 0.00 0.748 0.252 0.000
#> SRR1058031     2  0.3610      0.789 0.00 0.800 0.200 0.000
#> SRR1058032     4  0.0000      0.817 0.00 0.000 0.000 1.000
#> SRR1058033     4  0.0000      0.817 0.00 0.000 0.000 1.000
#> SRR1058034     4  0.0000      0.817 0.00 0.000 0.000 1.000
#> SRR1058035     1  0.0000      0.997 1.00 0.000 0.000 0.000
#> SRR1058036     1  0.0000      0.997 1.00 0.000 0.000 0.000
#> SRR1058037     1  0.0000      0.997 1.00 0.000 0.000 0.000
#> SRR1058038     1  0.0000      0.997 1.00 0.000 0.000 0.000
#> SRR1058039     1  0.0000      0.997 1.00 0.000 0.000 0.000
#> SRR1058040     1  0.0000      0.997 1.00 0.000 0.000 0.000
#> SRR1058041     1  0.0000      0.997 1.00 0.000 0.000 0.000
#> SRR1058042     1  0.0000      0.997 1.00 0.000 0.000 0.000
#> SRR1058043     1  0.1211      0.963 0.96 0.000 0.000 0.040
#> SRR1058044     1  0.0000      0.997 1.00 0.000 0.000 0.000
#> SRR1058045     1  0.0000      0.997 1.00 0.000 0.000 0.000
#> SRR1058046     1  0.0000      0.997 1.00 0.000 0.000 0.000
#> SRR1058047     4  0.3837      0.716 0.00 0.000 0.224 0.776
#> SRR1058048     3  0.0000      1.000 0.00 0.000 1.000 0.000
#> SRR1058049     3  0.0000      1.000 0.00 0.000 1.000 0.000
#> SRR1058050     3  0.0000      1.000 0.00 0.000 1.000 0.000
#> SRR1058051     4  0.3837      0.716 0.00 0.000 0.224 0.776
#> SRR1058052     3  0.0000      1.000 0.00 0.000 1.000 0.000
#> SRR1058053     3  0.0000      1.000 0.00 0.000 1.000 0.000
#> SRR1058054     3  0.0000      1.000 0.00 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette p1    p2    p3    p4    p5
#> SRR1058003     4  0.2813      0.781  0 0.000 0.000 0.832 0.168
#> SRR1058004     4  0.2124      0.850  0 0.004 0.000 0.900 0.096
#> SRR1058006     5  0.3039      0.936  0 0.192 0.000 0.000 0.808
#> SRR1058005     4  0.2249      0.848  0 0.008 0.000 0.896 0.096
#> SRR1058007     2  0.3274      0.736  0 0.780 0.000 0.000 0.220
#> SRR1058008     2  0.3274      0.736  0 0.780 0.000 0.000 0.220
#> SRR1058009     2  0.2891      0.759  0 0.824 0.000 0.000 0.176
#> SRR1058010     2  0.1121      0.775  0 0.956 0.000 0.000 0.044
#> SRR1058011     2  0.1197      0.785  0 0.952 0.000 0.000 0.048
#> SRR1058012     5  0.0609      0.720  0 0.020 0.000 0.000 0.980
#> SRR1058013     2  0.0404      0.784  0 0.988 0.000 0.000 0.012
#> SRR1058014     2  0.2891      0.758  0 0.824 0.000 0.000 0.176
#> SRR1058015     5  0.3039      0.936  0 0.192 0.000 0.000 0.808
#> SRR1058016     2  0.0510      0.781  0 0.984 0.000 0.000 0.016
#> SRR1058017     2  0.1341      0.786  0 0.944 0.000 0.000 0.056
#> SRR1058018     5  0.3039      0.936  0 0.192 0.000 0.000 0.808
#> SRR1058019     2  0.0579      0.774  0 0.984 0.008 0.000 0.008
#> SRR1058020     2  0.3274      0.736  0 0.780 0.000 0.000 0.220
#> SRR1058021     5  0.3143      0.921  0 0.204 0.000 0.000 0.796
#> SRR1058022     2  0.0451      0.776  0 0.988 0.008 0.000 0.004
#> SRR1058023     5  0.3039      0.936  0 0.192 0.000 0.000 0.808
#> SRR1058024     2  0.3305      0.735  0 0.776 0.000 0.000 0.224
#> SRR1058025     2  0.3452      0.713  0 0.756 0.000 0.000 0.244
#> SRR1058026     2  0.4262      0.531  0 0.560 0.000 0.000 0.440
#> SRR1058027     2  0.4262      0.531  0 0.560 0.000 0.000 0.440
#> SRR1058028     2  0.4262      0.531  0 0.560 0.000 0.000 0.440
#> SRR1058029     2  0.0693      0.772  0 0.980 0.012 0.000 0.008
#> SRR1058030     2  0.3551      0.519  0 0.772 0.220 0.000 0.008
#> SRR1058031     2  0.0693      0.772  0 0.980 0.012 0.000 0.008
#> SRR1058032     4  0.0000      0.873  0 0.000 0.000 1.000 0.000
#> SRR1058033     4  0.0000      0.873  0 0.000 0.000 1.000 0.000
#> SRR1058034     4  0.0000      0.873  0 0.000 0.000 1.000 0.000
#> SRR1058035     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1058036     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1058037     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1058038     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1058039     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1058040     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1058041     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1058042     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1058043     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1058044     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1058045     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1058046     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1058047     4  0.3039      0.764  0 0.000 0.192 0.808 0.000
#> SRR1058048     3  0.0000      1.000  0 0.000 1.000 0.000 0.000
#> SRR1058049     3  0.0000      1.000  0 0.000 1.000 0.000 0.000
#> SRR1058050     3  0.0000      1.000  0 0.000 1.000 0.000 0.000
#> SRR1058051     4  0.3039      0.764  0 0.000 0.192 0.808 0.000
#> SRR1058052     3  0.0000      1.000  0 0.000 1.000 0.000 0.000
#> SRR1058053     3  0.0000      1.000  0 0.000 1.000 0.000 0.000
#> SRR1058054     3  0.0000      1.000  0 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR1058003     4  0.2520      0.742 0.000 0.000 0.000 0.844 0.152 0.004
#> SRR1058004     4  0.1714      0.808 0.000 0.000 0.000 0.908 0.000 0.092
#> SRR1058006     5  0.2302      0.788 0.000 0.000 0.000 0.120 0.872 0.008
#> SRR1058005     4  0.1714      0.808 0.000 0.000 0.000 0.908 0.000 0.092
#> SRR1058007     2  0.5040      0.407 0.000 0.636 0.000 0.000 0.152 0.212
#> SRR1058008     2  0.5015      0.407 0.000 0.640 0.000 0.000 0.152 0.208
#> SRR1058009     2  0.5015      0.411 0.000 0.640 0.000 0.000 0.152 0.208
#> SRR1058010     2  0.1944      0.489 0.000 0.924 0.000 0.016 0.024 0.036
#> SRR1058011     2  0.1934      0.498 0.000 0.916 0.000 0.000 0.044 0.040
#> SRR1058012     5  0.4057      0.398 0.000 0.008 0.000 0.000 0.556 0.436
#> SRR1058013     2  0.4910      0.419 0.000 0.656 0.000 0.000 0.152 0.192
#> SRR1058014     2  0.5040      0.407 0.000 0.636 0.000 0.000 0.152 0.212
#> SRR1058015     5  0.0146      0.885 0.000 0.000 0.000 0.000 0.996 0.004
#> SRR1058016     2  0.1297      0.494 0.000 0.948 0.000 0.000 0.012 0.040
#> SRR1058017     2  0.2609      0.472 0.000 0.868 0.000 0.000 0.036 0.096
#> SRR1058018     5  0.0000      0.886 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1058019     2  0.5383      0.251 0.000 0.580 0.172 0.000 0.000 0.248
#> SRR1058020     6  0.4150      0.392 0.000 0.392 0.000 0.000 0.016 0.592
#> SRR1058021     5  0.0146      0.885 0.000 0.004 0.000 0.000 0.996 0.000
#> SRR1058022     2  0.6876      0.264 0.000 0.484 0.156 0.000 0.112 0.248
#> SRR1058023     5  0.0000      0.886 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1058024     6  0.4333      0.419 0.000 0.376 0.000 0.000 0.028 0.596
#> SRR1058025     6  0.4088      0.441 0.000 0.368 0.000 0.000 0.016 0.616
#> SRR1058026     6  0.0000      0.629 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR1058027     6  0.0000      0.629 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR1058028     6  0.0146      0.628 0.000 0.004 0.000 0.000 0.000 0.996
#> SRR1058029     2  0.5410      0.248 0.000 0.576 0.176 0.000 0.000 0.248
#> SRR1058030     2  0.5728      0.138 0.000 0.452 0.380 0.000 0.000 0.168
#> SRR1058031     2  0.5417      0.251 0.000 0.576 0.180 0.000 0.000 0.244
#> SRR1058032     4  0.0000      0.839 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1058033     4  0.0000      0.839 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1058034     4  0.0000      0.839 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1058035     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058036     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058037     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058038     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058039     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058040     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058041     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058042     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058043     1  0.0146      0.996 0.996 0.000 0.000 0.000 0.004 0.000
#> SRR1058044     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058045     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058046     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058047     4  0.3482      0.595 0.000 0.000 0.316 0.684 0.000 0.000
#> SRR1058048     3  0.0260      0.990 0.000 0.008 0.992 0.000 0.000 0.000
#> SRR1058049     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1058050     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1058051     4  0.3725      0.593 0.000 0.000 0.316 0.676 0.000 0.008
#> SRR1058052     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1058053     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1058054     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

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

collect_plots(res)

plot of chunk SD-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.704           0.923       0.961         0.5001 0.502   0.502
#> 3 3 0.766           0.874       0.931         0.3186 0.818   0.649
#> 4 4 0.696           0.719       0.862         0.0925 0.913   0.759
#> 5 5 0.679           0.675       0.833         0.0665 0.900   0.680
#> 6 6 0.766           0.710       0.835         0.0359 0.957   0.829

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
#> SRR1058003     1  0.7219      0.781 0.800 0.200
#> SRR1058004     2  0.0000      0.955 0.000 1.000
#> SRR1058006     1  0.0000      0.958 1.000 0.000
#> SRR1058005     2  0.0000      0.955 0.000 1.000
#> SRR1058007     2  0.0000      0.955 0.000 1.000
#> SRR1058008     2  0.0000      0.955 0.000 1.000
#> SRR1058009     2  0.0000      0.955 0.000 1.000
#> SRR1058010     2  0.0000      0.955 0.000 1.000
#> SRR1058011     2  0.0000      0.955 0.000 1.000
#> SRR1058012     1  0.0000      0.958 1.000 0.000
#> SRR1058013     2  0.0000      0.955 0.000 1.000
#> SRR1058014     2  0.0000      0.955 0.000 1.000
#> SRR1058015     1  0.0000      0.958 1.000 0.000
#> SRR1058016     2  0.0000      0.955 0.000 1.000
#> SRR1058017     2  0.0000      0.955 0.000 1.000
#> SRR1058018     1  0.0000      0.958 1.000 0.000
#> SRR1058019     2  0.0000      0.955 0.000 1.000
#> SRR1058020     2  0.6438      0.822 0.164 0.836
#> SRR1058021     1  0.0000      0.958 1.000 0.000
#> SRR1058022     2  0.0376      0.953 0.004 0.996
#> SRR1058023     1  0.0000      0.958 1.000 0.000
#> SRR1058024     2  0.7219      0.786 0.200 0.800
#> SRR1058025     2  0.7219      0.786 0.200 0.800
#> SRR1058026     2  0.7815      0.747 0.232 0.768
#> SRR1058027     2  0.7299      0.782 0.204 0.796
#> SRR1058028     2  0.7219      0.786 0.200 0.800
#> SRR1058029     2  0.0000      0.955 0.000 1.000
#> SRR1058030     2  0.0000      0.955 0.000 1.000
#> SRR1058031     2  0.0376      0.953 0.004 0.996
#> SRR1058032     1  0.7219      0.781 0.800 0.200
#> SRR1058033     1  0.7219      0.781 0.800 0.200
#> SRR1058034     1  0.7219      0.781 0.800 0.200
#> SRR1058035     1  0.0000      0.958 1.000 0.000
#> SRR1058036     1  0.0000      0.958 1.000 0.000
#> SRR1058037     1  0.0000      0.958 1.000 0.000
#> SRR1058038     1  0.0000      0.958 1.000 0.000
#> SRR1058039     1  0.0000      0.958 1.000 0.000
#> SRR1058040     1  0.0000      0.958 1.000 0.000
#> SRR1058041     1  0.0000      0.958 1.000 0.000
#> SRR1058042     1  0.0000      0.958 1.000 0.000
#> SRR1058043     1  0.0000      0.958 1.000 0.000
#> SRR1058044     1  0.0000      0.958 1.000 0.000
#> SRR1058045     1  0.0000      0.958 1.000 0.000
#> SRR1058046     1  0.0000      0.958 1.000 0.000
#> SRR1058047     2  0.0000      0.955 0.000 1.000
#> SRR1058048     2  0.0000      0.955 0.000 1.000
#> SRR1058049     2  0.0000      0.955 0.000 1.000
#> SRR1058050     2  0.0000      0.955 0.000 1.000
#> SRR1058051     2  0.0000      0.955 0.000 1.000
#> SRR1058052     2  0.0000      0.955 0.000 1.000
#> SRR1058053     2  0.0000      0.955 0.000 1.000
#> SRR1058054     2  0.0000      0.955 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1058003     1  0.3482      0.836 0.872 0.000 0.128
#> SRR1058004     3  0.0000      0.996 0.000 0.000 1.000
#> SRR1058006     1  0.0000      0.934 1.000 0.000 0.000
#> SRR1058005     3  0.0000      0.996 0.000 0.000 1.000
#> SRR1058007     2  0.6079      0.540 0.000 0.612 0.388
#> SRR1058008     2  0.6309      0.251 0.000 0.500 0.500
#> SRR1058009     2  0.4121      0.845 0.000 0.832 0.168
#> SRR1058010     2  0.3551      0.866 0.000 0.868 0.132
#> SRR1058011     2  0.4842      0.794 0.000 0.776 0.224
#> SRR1058012     1  0.5465      0.625 0.712 0.288 0.000
#> SRR1058013     2  0.4346      0.834 0.000 0.816 0.184
#> SRR1058014     2  0.4235      0.840 0.000 0.824 0.176
#> SRR1058015     1  0.0592      0.928 0.988 0.012 0.000
#> SRR1058016     2  0.1031      0.888 0.000 0.976 0.024
#> SRR1058017     2  0.2711      0.882 0.000 0.912 0.088
#> SRR1058018     1  0.0237      0.932 0.996 0.004 0.000
#> SRR1058019     2  0.0892      0.887 0.000 0.980 0.020
#> SRR1058020     2  0.0237      0.883 0.000 0.996 0.004
#> SRR1058021     2  0.2448      0.831 0.076 0.924 0.000
#> SRR1058022     2  0.1529      0.889 0.000 0.960 0.040
#> SRR1058023     1  0.0592      0.928 0.988 0.012 0.000
#> SRR1058024     2  0.0000      0.882 0.000 1.000 0.000
#> SRR1058025     2  0.0000      0.882 0.000 1.000 0.000
#> SRR1058026     2  0.0000      0.882 0.000 1.000 0.000
#> SRR1058027     2  0.0000      0.882 0.000 1.000 0.000
#> SRR1058028     2  0.0000      0.882 0.000 1.000 0.000
#> SRR1058029     2  0.3482      0.870 0.000 0.872 0.128
#> SRR1058030     2  0.3340      0.873 0.000 0.880 0.120
#> SRR1058031     2  0.1529      0.889 0.000 0.960 0.040
#> SRR1058032     1  0.3340      0.844 0.880 0.000 0.120
#> SRR1058033     1  0.5988      0.474 0.632 0.000 0.368
#> SRR1058034     1  0.5760      0.556 0.672 0.000 0.328
#> SRR1058035     1  0.0000      0.934 1.000 0.000 0.000
#> SRR1058036     1  0.0000      0.934 1.000 0.000 0.000
#> SRR1058037     1  0.0000      0.934 1.000 0.000 0.000
#> SRR1058038     1  0.0000      0.934 1.000 0.000 0.000
#> SRR1058039     1  0.0000      0.934 1.000 0.000 0.000
#> SRR1058040     1  0.0000      0.934 1.000 0.000 0.000
#> SRR1058041     1  0.0000      0.934 1.000 0.000 0.000
#> SRR1058042     1  0.0000      0.934 1.000 0.000 0.000
#> SRR1058043     1  0.0000      0.934 1.000 0.000 0.000
#> SRR1058044     1  0.0000      0.934 1.000 0.000 0.000
#> SRR1058045     1  0.0000      0.934 1.000 0.000 0.000
#> SRR1058046     1  0.0000      0.934 1.000 0.000 0.000
#> SRR1058047     3  0.0000      0.996 0.000 0.000 1.000
#> SRR1058048     3  0.0000      0.996 0.000 0.000 1.000
#> SRR1058049     3  0.0000      0.996 0.000 0.000 1.000
#> SRR1058050     3  0.0747      0.982 0.000 0.016 0.984
#> SRR1058051     3  0.0000      0.996 0.000 0.000 1.000
#> SRR1058052     3  0.0000      0.996 0.000 0.000 1.000
#> SRR1058053     3  0.0000      0.996 0.000 0.000 1.000
#> SRR1058054     3  0.0747      0.982 0.000 0.016 0.984

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1058003     1  0.6850      0.393 0.556 0.356 0.016 0.072
#> SRR1058004     3  0.5792      0.310 0.000 0.416 0.552 0.032
#> SRR1058006     2  0.5975      0.386 0.264 0.664 0.004 0.068
#> SRR1058005     3  0.5511      0.455 0.000 0.332 0.636 0.032
#> SRR1058007     2  0.1970      0.735 0.000 0.932 0.008 0.060
#> SRR1058008     2  0.2124      0.729 0.000 0.924 0.008 0.068
#> SRR1058009     2  0.0188      0.774 0.000 0.996 0.000 0.004
#> SRR1058010     2  0.0707      0.779 0.000 0.980 0.000 0.020
#> SRR1058011     2  0.1890      0.783 0.000 0.936 0.008 0.056
#> SRR1058012     1  0.4194      0.639 0.764 0.228 0.000 0.008
#> SRR1058013     2  0.1576      0.783 0.000 0.948 0.004 0.048
#> SRR1058014     2  0.0336      0.775 0.000 0.992 0.000 0.008
#> SRR1058015     1  0.5186      0.500 0.640 0.344 0.000 0.016
#> SRR1058016     2  0.2530      0.776 0.000 0.896 0.004 0.100
#> SRR1058017     2  0.3991      0.738 0.000 0.808 0.020 0.172
#> SRR1058018     1  0.0804      0.860 0.980 0.012 0.000 0.008
#> SRR1058019     2  0.4353      0.692 0.000 0.756 0.012 0.232
#> SRR1058020     2  0.4250      0.655 0.000 0.724 0.000 0.276
#> SRR1058021     2  0.3873      0.660 0.096 0.844 0.000 0.060
#> SRR1058022     2  0.3946      0.743 0.000 0.812 0.020 0.168
#> SRR1058023     1  0.1151      0.854 0.968 0.024 0.000 0.008
#> SRR1058024     2  0.4277      0.627 0.000 0.720 0.000 0.280
#> SRR1058025     2  0.3569      0.733 0.000 0.804 0.000 0.196
#> SRR1058026     4  0.1867      0.787 0.000 0.072 0.000 0.928
#> SRR1058027     4  0.1867      0.787 0.000 0.072 0.000 0.928
#> SRR1058028     4  0.1867      0.787 0.000 0.072 0.000 0.928
#> SRR1058029     4  0.6834      0.633 0.000 0.164 0.240 0.596
#> SRR1058030     4  0.7659      0.339 0.000 0.332 0.224 0.444
#> SRR1058031     2  0.5500      0.131 0.000 0.520 0.016 0.464
#> SRR1058032     1  0.5051      0.625 0.724 0.004 0.244 0.028
#> SRR1058033     1  0.5933      0.214 0.516 0.004 0.452 0.028
#> SRR1058034     1  0.5862      0.333 0.560 0.004 0.408 0.028
#> SRR1058035     1  0.0000      0.868 1.000 0.000 0.000 0.000
#> SRR1058036     1  0.0000      0.868 1.000 0.000 0.000 0.000
#> SRR1058037     1  0.0000      0.868 1.000 0.000 0.000 0.000
#> SRR1058038     1  0.0000      0.868 1.000 0.000 0.000 0.000
#> SRR1058039     1  0.0000      0.868 1.000 0.000 0.000 0.000
#> SRR1058040     1  0.0000      0.868 1.000 0.000 0.000 0.000
#> SRR1058041     1  0.0000      0.868 1.000 0.000 0.000 0.000
#> SRR1058042     1  0.0000      0.868 1.000 0.000 0.000 0.000
#> SRR1058043     1  0.0000      0.868 1.000 0.000 0.000 0.000
#> SRR1058044     1  0.0000      0.868 1.000 0.000 0.000 0.000
#> SRR1058045     1  0.0000      0.868 1.000 0.000 0.000 0.000
#> SRR1058046     1  0.0000      0.868 1.000 0.000 0.000 0.000
#> SRR1058047     3  0.0336      0.868 0.000 0.000 0.992 0.008
#> SRR1058048     3  0.0188      0.872 0.000 0.004 0.996 0.000
#> SRR1058049     3  0.0188      0.872 0.000 0.004 0.996 0.000
#> SRR1058050     3  0.0188      0.870 0.000 0.000 0.996 0.004
#> SRR1058051     3  0.0188      0.869 0.000 0.000 0.996 0.004
#> SRR1058052     3  0.0188      0.872 0.000 0.004 0.996 0.000
#> SRR1058053     3  0.0188      0.872 0.000 0.004 0.996 0.000
#> SRR1058054     3  0.0804      0.857 0.000 0.012 0.980 0.008

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4    p5
#> SRR1058003     5  0.4746     0.6417 0.124 0.100 0.016 0.000 0.760
#> SRR1058004     5  0.5715     0.5591 0.000 0.152 0.228 0.000 0.620
#> SRR1058006     5  0.4677     0.6431 0.036 0.236 0.000 0.012 0.716
#> SRR1058005     5  0.5632     0.5524 0.000 0.140 0.232 0.000 0.628
#> SRR1058007     2  0.2293     0.8047 0.000 0.900 0.016 0.000 0.084
#> SRR1058008     2  0.3724     0.7024 0.000 0.788 0.028 0.000 0.184
#> SRR1058009     2  0.1357     0.8180 0.000 0.948 0.004 0.000 0.048
#> SRR1058010     2  0.1124     0.8232 0.000 0.960 0.000 0.004 0.036
#> SRR1058011     2  0.0807     0.8258 0.000 0.976 0.012 0.000 0.012
#> SRR1058012     1  0.6712     0.3026 0.576 0.192 0.000 0.040 0.192
#> SRR1058013     2  0.0955     0.8236 0.000 0.968 0.004 0.000 0.028
#> SRR1058014     2  0.2052     0.7991 0.000 0.912 0.004 0.004 0.080
#> SRR1058015     5  0.6431     0.5892 0.224 0.188 0.000 0.016 0.572
#> SRR1058016     2  0.0992     0.8265 0.000 0.968 0.000 0.008 0.024
#> SRR1058017     2  0.2760     0.8012 0.000 0.892 0.028 0.064 0.016
#> SRR1058018     1  0.6164    -0.1918 0.476 0.064 0.000 0.028 0.432
#> SRR1058019     2  0.3609     0.7717 0.000 0.836 0.036 0.112 0.016
#> SRR1058020     2  0.3333     0.7246 0.000 0.788 0.000 0.208 0.004
#> SRR1058021     5  0.4938     0.5611 0.008 0.332 0.000 0.028 0.632
#> SRR1058022     2  0.2429     0.8094 0.000 0.900 0.020 0.076 0.004
#> SRR1058023     5  0.5973     0.3113 0.368 0.052 0.000 0.032 0.548
#> SRR1058024     2  0.3696     0.7155 0.000 0.772 0.000 0.212 0.016
#> SRR1058025     2  0.3012     0.8034 0.000 0.860 0.000 0.104 0.036
#> SRR1058026     4  0.1907     0.6982 0.000 0.028 0.000 0.928 0.044
#> SRR1058027     4  0.1753     0.7039 0.000 0.032 0.000 0.936 0.032
#> SRR1058028     4  0.3513     0.6831 0.000 0.180 0.000 0.800 0.020
#> SRR1058029     4  0.6747     0.2365 0.000 0.368 0.192 0.432 0.008
#> SRR1058030     2  0.6418    -0.0978 0.000 0.484 0.140 0.368 0.008
#> SRR1058031     2  0.4601     0.6155 0.000 0.720 0.032 0.236 0.012
#> SRR1058032     1  0.6196     0.1588 0.508 0.000 0.152 0.000 0.340
#> SRR1058033     1  0.6783    -0.0378 0.380 0.000 0.336 0.000 0.284
#> SRR1058034     1  0.6764    -0.0971 0.372 0.000 0.268 0.000 0.360
#> SRR1058035     1  0.0162     0.8009 0.996 0.000 0.000 0.000 0.004
#> SRR1058036     1  0.0000     0.8038 1.000 0.000 0.000 0.000 0.000
#> SRR1058037     1  0.0000     0.8038 1.000 0.000 0.000 0.000 0.000
#> SRR1058038     1  0.0000     0.8038 1.000 0.000 0.000 0.000 0.000
#> SRR1058039     1  0.0000     0.8038 1.000 0.000 0.000 0.000 0.000
#> SRR1058040     1  0.0000     0.8038 1.000 0.000 0.000 0.000 0.000
#> SRR1058041     1  0.0000     0.8038 1.000 0.000 0.000 0.000 0.000
#> SRR1058042     1  0.0000     0.8038 1.000 0.000 0.000 0.000 0.000
#> SRR1058043     1  0.0000     0.8038 1.000 0.000 0.000 0.000 0.000
#> SRR1058044     1  0.0000     0.8038 1.000 0.000 0.000 0.000 0.000
#> SRR1058045     1  0.0000     0.8038 1.000 0.000 0.000 0.000 0.000
#> SRR1058046     1  0.0000     0.8038 1.000 0.000 0.000 0.000 0.000
#> SRR1058047     3  0.2286     0.8655 0.000 0.004 0.888 0.000 0.108
#> SRR1058048     3  0.0609     0.9606 0.000 0.020 0.980 0.000 0.000
#> SRR1058049     3  0.0566     0.9642 0.004 0.012 0.984 0.000 0.000
#> SRR1058050     3  0.0404     0.9671 0.000 0.012 0.988 0.000 0.000
#> SRR1058051     3  0.1124     0.9397 0.000 0.004 0.960 0.000 0.036
#> SRR1058052     3  0.0798     0.9652 0.000 0.016 0.976 0.000 0.008
#> SRR1058053     3  0.0566     0.9670 0.000 0.012 0.984 0.000 0.004
#> SRR1058054     3  0.0404     0.9671 0.000 0.012 0.988 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR1058003     5  0.1542      0.582 0.016 0.024 0.000 0.016 0.944 0.000
#> SRR1058004     5  0.2917      0.529 0.000 0.040 0.104 0.004 0.852 0.000
#> SRR1058006     5  0.4632      0.674 0.004 0.092 0.000 0.216 0.688 0.000
#> SRR1058005     5  0.2822      0.528 0.000 0.032 0.108 0.004 0.856 0.000
#> SRR1058007     2  0.2506      0.780 0.000 0.880 0.000 0.052 0.068 0.000
#> SRR1058008     2  0.3585      0.677 0.000 0.780 0.000 0.048 0.172 0.000
#> SRR1058009     2  0.2587      0.785 0.000 0.868 0.004 0.108 0.020 0.000
#> SRR1058010     2  0.2308      0.786 0.000 0.880 0.000 0.108 0.008 0.004
#> SRR1058011     2  0.1307      0.796 0.000 0.952 0.000 0.032 0.008 0.008
#> SRR1058012     4  0.6260      0.000 0.272 0.104 0.000 0.564 0.024 0.036
#> SRR1058013     2  0.1672      0.798 0.000 0.932 0.004 0.048 0.016 0.000
#> SRR1058014     2  0.2856      0.766 0.000 0.856 0.000 0.076 0.068 0.000
#> SRR1058015     5  0.5866      0.652 0.032 0.084 0.004 0.316 0.560 0.004
#> SRR1058016     2  0.1816      0.802 0.000 0.928 0.004 0.048 0.016 0.004
#> SRR1058017     2  0.2292      0.786 0.000 0.908 0.008 0.048 0.008 0.028
#> SRR1058018     5  0.6661      0.585 0.096 0.052 0.012 0.320 0.508 0.012
#> SRR1058019     2  0.2663      0.791 0.000 0.888 0.024 0.012 0.012 0.064
#> SRR1058020     2  0.3510      0.737 0.000 0.772 0.000 0.016 0.008 0.204
#> SRR1058021     5  0.5459      0.651 0.000 0.112 0.000 0.280 0.592 0.016
#> SRR1058022     2  0.2002      0.802 0.000 0.920 0.004 0.012 0.012 0.052
#> SRR1058023     5  0.6561      0.620 0.060 0.060 0.016 0.328 0.520 0.016
#> SRR1058024     2  0.3811      0.702 0.000 0.732 0.004 0.016 0.004 0.244
#> SRR1058025     2  0.4700      0.737 0.000 0.748 0.004 0.108 0.044 0.096
#> SRR1058026     6  0.1327      0.839 0.000 0.000 0.000 0.064 0.000 0.936
#> SRR1058027     6  0.1116      0.850 0.000 0.008 0.000 0.028 0.004 0.960
#> SRR1058028     6  0.3565      0.756 0.000 0.096 0.000 0.092 0.004 0.808
#> SRR1058029     2  0.6443      0.210 0.000 0.452 0.208 0.008 0.016 0.316
#> SRR1058030     2  0.6091      0.311 0.000 0.500 0.212 0.004 0.008 0.276
#> SRR1058031     2  0.4837      0.659 0.000 0.700 0.052 0.016 0.016 0.216
#> SRR1058032     1  0.4417      0.252 0.556 0.000 0.028 0.000 0.416 0.000
#> SRR1058033     1  0.5385      0.126 0.468 0.000 0.112 0.000 0.420 0.000
#> SRR1058034     1  0.5190      0.111 0.460 0.000 0.088 0.000 0.452 0.000
#> SRR1058035     1  0.0146      0.832 0.996 0.000 0.000 0.000 0.004 0.000
#> SRR1058036     1  0.0000      0.834 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058037     1  0.0146      0.832 0.996 0.000 0.000 0.000 0.004 0.000
#> SRR1058038     1  0.0000      0.834 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058039     1  0.0000      0.834 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058040     1  0.0000      0.834 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058041     1  0.0000      0.834 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058042     1  0.0000      0.834 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058043     1  0.0291      0.826 0.992 0.000 0.000 0.004 0.004 0.000
#> SRR1058044     1  0.0000      0.834 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058045     1  0.0000      0.834 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058046     1  0.0000      0.834 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058047     3  0.3023      0.716 0.000 0.000 0.768 0.000 0.232 0.000
#> SRR1058048     3  0.0603      0.939 0.000 0.016 0.980 0.000 0.004 0.000
#> SRR1058049     3  0.0291      0.936 0.000 0.004 0.992 0.004 0.000 0.000
#> SRR1058050     3  0.0291      0.936 0.000 0.004 0.992 0.004 0.000 0.000
#> SRR1058051     3  0.1956      0.887 0.000 0.008 0.908 0.004 0.080 0.000
#> SRR1058052     3  0.0717      0.938 0.000 0.016 0.976 0.000 0.008 0.000
#> SRR1058053     3  0.0547      0.937 0.000 0.020 0.980 0.000 0.000 0.000
#> SRR1058054     3  0.0363      0.938 0.000 0.012 0.988 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-NMF-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-NMF-collect-classes

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


CV:hclust*

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

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

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

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

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

collect_plots(res)

plot of chunk CV-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.922           0.967       0.982         0.0993 0.889   0.889
#> 3 3 0.883           0.920       0.972         0.6700 0.929   0.920
#> 4 4 0.820           0.893       0.950         0.2615 0.997   0.996
#> 5 5 0.820           0.899       0.975         0.0544 0.999   0.999
#> 6 6 0.619           0.813       0.919         0.5486 0.814   0.773

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
#> SRR1058003     1  0.0000      0.672 1.000 0.000
#> SRR1058004     1  0.9044      0.762 0.680 0.320
#> SRR1058006     2  0.0000      0.992 0.000 1.000
#> SRR1058005     1  0.9044      0.762 0.680 0.320
#> SRR1058007     2  0.0000      0.992 0.000 1.000
#> SRR1058008     2  0.8144      0.545 0.252 0.748
#> SRR1058009     2  0.0000      0.992 0.000 1.000
#> SRR1058010     2  0.0000      0.992 0.000 1.000
#> SRR1058011     2  0.0000      0.992 0.000 1.000
#> SRR1058012     2  0.0000      0.992 0.000 1.000
#> SRR1058013     2  0.0000      0.992 0.000 1.000
#> SRR1058014     2  0.0000      0.992 0.000 1.000
#> SRR1058015     2  0.0000      0.992 0.000 1.000
#> SRR1058016     2  0.0000      0.992 0.000 1.000
#> SRR1058017     2  0.0000      0.992 0.000 1.000
#> SRR1058018     2  0.0000      0.992 0.000 1.000
#> SRR1058019     2  0.0000      0.992 0.000 1.000
#> SRR1058020     2  0.0000      0.992 0.000 1.000
#> SRR1058021     2  0.2778      0.932 0.048 0.952
#> SRR1058022     2  0.0000      0.992 0.000 1.000
#> SRR1058023     2  0.0938      0.978 0.012 0.988
#> SRR1058024     2  0.0000      0.992 0.000 1.000
#> SRR1058025     2  0.0000      0.992 0.000 1.000
#> SRR1058026     2  0.0000      0.992 0.000 1.000
#> SRR1058027     2  0.0000      0.992 0.000 1.000
#> SRR1058028     2  0.0000      0.992 0.000 1.000
#> SRR1058029     2  0.0000      0.992 0.000 1.000
#> SRR1058030     2  0.0000      0.992 0.000 1.000
#> SRR1058031     2  0.0000      0.992 0.000 1.000
#> SRR1058032     2  0.0000      0.992 0.000 1.000
#> SRR1058033     2  0.0000      0.992 0.000 1.000
#> SRR1058034     2  0.0000      0.992 0.000 1.000
#> SRR1058035     2  0.0000      0.992 0.000 1.000
#> SRR1058036     2  0.0000      0.992 0.000 1.000
#> SRR1058037     2  0.0000      0.992 0.000 1.000
#> SRR1058038     2  0.0000      0.992 0.000 1.000
#> SRR1058039     2  0.0000      0.992 0.000 1.000
#> SRR1058040     2  0.0000      0.992 0.000 1.000
#> SRR1058041     2  0.0000      0.992 0.000 1.000
#> SRR1058042     2  0.0000      0.992 0.000 1.000
#> SRR1058043     2  0.0000      0.992 0.000 1.000
#> SRR1058044     2  0.0000      0.992 0.000 1.000
#> SRR1058045     2  0.0000      0.992 0.000 1.000
#> SRR1058046     2  0.0000      0.992 0.000 1.000
#> SRR1058047     2  0.0000      0.992 0.000 1.000
#> SRR1058048     2  0.0000      0.992 0.000 1.000
#> SRR1058049     2  0.0000      0.992 0.000 1.000
#> SRR1058050     2  0.0000      0.992 0.000 1.000
#> SRR1058051     2  0.0000      0.992 0.000 1.000
#> SRR1058052     2  0.0000      0.992 0.000 1.000
#> SRR1058053     2  0.0000      0.992 0.000 1.000
#> SRR1058054     2  0.0000      0.992 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2   p3
#> SRR1058003     3  0.0000     0.4944 0.000 0.000 1.00
#> SRR1058004     3  0.8153     0.7011 0.216 0.144 0.64
#> SRR1058006     2  0.0237     0.9893 0.004 0.996 0.00
#> SRR1058005     3  0.8153     0.7011 0.216 0.144 0.64
#> SRR1058007     2  0.0424     0.9849 0.008 0.992 0.00
#> SRR1058008     1  0.0000    -0.3701 1.000 0.000 0.00
#> SRR1058009     2  0.0000     0.9933 0.000 1.000 0.00
#> SRR1058010     2  0.0000     0.9933 0.000 1.000 0.00
#> SRR1058011     2  0.0000     0.9933 0.000 1.000 0.00
#> SRR1058012     2  0.0000     0.9933 0.000 1.000 0.00
#> SRR1058013     2  0.0000     0.9933 0.000 1.000 0.00
#> SRR1058014     2  0.1753     0.9367 0.048 0.952 0.00
#> SRR1058015     2  0.0237     0.9893 0.004 0.996 0.00
#> SRR1058016     2  0.0000     0.9933 0.000 1.000 0.00
#> SRR1058017     2  0.0000     0.9933 0.000 1.000 0.00
#> SRR1058018     2  0.1753     0.9367 0.048 0.952 0.00
#> SRR1058019     2  0.0000     0.9933 0.000 1.000 0.00
#> SRR1058020     2  0.0000     0.9933 0.000 1.000 0.00
#> SRR1058021     1  0.6126    -0.0679 0.600 0.400 0.00
#> SRR1058022     2  0.0000     0.9933 0.000 1.000 0.00
#> SRR1058023     2  0.3551     0.8084 0.132 0.868 0.00
#> SRR1058024     2  0.0000     0.9933 0.000 1.000 0.00
#> SRR1058025     2  0.0000     0.9933 0.000 1.000 0.00
#> SRR1058026     2  0.0000     0.9933 0.000 1.000 0.00
#> SRR1058027     2  0.0000     0.9933 0.000 1.000 0.00
#> SRR1058028     2  0.0000     0.9933 0.000 1.000 0.00
#> SRR1058029     2  0.0000     0.9933 0.000 1.000 0.00
#> SRR1058030     2  0.0000     0.9933 0.000 1.000 0.00
#> SRR1058031     2  0.0000     0.9933 0.000 1.000 0.00
#> SRR1058032     2  0.0000     0.9933 0.000 1.000 0.00
#> SRR1058033     2  0.0000     0.9933 0.000 1.000 0.00
#> SRR1058034     2  0.0000     0.9933 0.000 1.000 0.00
#> SRR1058035     2  0.0000     0.9933 0.000 1.000 0.00
#> SRR1058036     2  0.0000     0.9933 0.000 1.000 0.00
#> SRR1058037     2  0.0000     0.9933 0.000 1.000 0.00
#> SRR1058038     2  0.0000     0.9933 0.000 1.000 0.00
#> SRR1058039     2  0.0000     0.9933 0.000 1.000 0.00
#> SRR1058040     2  0.0000     0.9933 0.000 1.000 0.00
#> SRR1058041     2  0.0000     0.9933 0.000 1.000 0.00
#> SRR1058042     2  0.0000     0.9933 0.000 1.000 0.00
#> SRR1058043     2  0.0000     0.9933 0.000 1.000 0.00
#> SRR1058044     2  0.0000     0.9933 0.000 1.000 0.00
#> SRR1058045     2  0.0000     0.9933 0.000 1.000 0.00
#> SRR1058046     2  0.0000     0.9933 0.000 1.000 0.00
#> SRR1058047     2  0.0000     0.9933 0.000 1.000 0.00
#> SRR1058048     2  0.0000     0.9933 0.000 1.000 0.00
#> SRR1058049     2  0.0000     0.9933 0.000 1.000 0.00
#> SRR1058050     2  0.0000     0.9933 0.000 1.000 0.00
#> SRR1058051     2  0.0000     0.9933 0.000 1.000 0.00
#> SRR1058052     2  0.0000     0.9933 0.000 1.000 0.00
#> SRR1058053     2  0.0000     0.9933 0.000 1.000 0.00
#> SRR1058054     2  0.0000     0.9933 0.000 1.000 0.00

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1058003     4  0.7646    -0.2504 0.384 0.000 0.208 0.408
#> SRR1058004     1  0.0336     1.0000 0.992 0.008 0.000 0.000
#> SRR1058006     2  0.3048     0.8447 0.016 0.876 0.108 0.000
#> SRR1058005     1  0.0336     1.0000 0.992 0.008 0.000 0.000
#> SRR1058007     2  0.1174     0.9483 0.012 0.968 0.020 0.000
#> SRR1058008     4  0.6897     0.0136 0.180 0.000 0.228 0.592
#> SRR1058009     2  0.0188     0.9732 0.000 0.996 0.004 0.000
#> SRR1058010     2  0.0188     0.9732 0.000 0.996 0.004 0.000
#> SRR1058011     2  0.0188     0.9732 0.000 0.996 0.004 0.000
#> SRR1058012     2  0.0188     0.9732 0.000 0.996 0.004 0.000
#> SRR1058013     2  0.0188     0.9732 0.000 0.996 0.004 0.000
#> SRR1058014     2  0.3695     0.7777 0.016 0.828 0.156 0.000
#> SRR1058015     2  0.3048     0.8447 0.016 0.876 0.108 0.000
#> SRR1058016     2  0.0188     0.9732 0.000 0.996 0.004 0.000
#> SRR1058017     2  0.0188     0.9732 0.000 0.996 0.004 0.000
#> SRR1058018     2  0.3695     0.7777 0.016 0.828 0.156 0.000
#> SRR1058019     2  0.0188     0.9732 0.000 0.996 0.004 0.000
#> SRR1058020     2  0.0376     0.9706 0.004 0.992 0.004 0.000
#> SRR1058021     3  0.4724     0.0000 0.076 0.136 0.788 0.000
#> SRR1058022     2  0.0376     0.9689 0.004 0.992 0.004 0.000
#> SRR1058023     2  0.4737     0.5903 0.020 0.728 0.252 0.000
#> SRR1058024     2  0.1677     0.9278 0.012 0.948 0.040 0.000
#> SRR1058025     2  0.0376     0.9689 0.004 0.992 0.004 0.000
#> SRR1058026     2  0.0188     0.9732 0.000 0.996 0.004 0.000
#> SRR1058027     2  0.0188     0.9732 0.000 0.996 0.004 0.000
#> SRR1058028     2  0.0188     0.9732 0.000 0.996 0.004 0.000
#> SRR1058029     2  0.0188     0.9732 0.000 0.996 0.004 0.000
#> SRR1058030     2  0.0188     0.9732 0.000 0.996 0.004 0.000
#> SRR1058031     2  0.0188     0.9732 0.000 0.996 0.004 0.000
#> SRR1058032     2  0.0000     0.9741 0.000 1.000 0.000 0.000
#> SRR1058033     2  0.0000     0.9741 0.000 1.000 0.000 0.000
#> SRR1058034     2  0.0000     0.9741 0.000 1.000 0.000 0.000
#> SRR1058035     2  0.0000     0.9741 0.000 1.000 0.000 0.000
#> SRR1058036     2  0.0000     0.9741 0.000 1.000 0.000 0.000
#> SRR1058037     2  0.0000     0.9741 0.000 1.000 0.000 0.000
#> SRR1058038     2  0.0000     0.9741 0.000 1.000 0.000 0.000
#> SRR1058039     2  0.0000     0.9741 0.000 1.000 0.000 0.000
#> SRR1058040     2  0.0000     0.9741 0.000 1.000 0.000 0.000
#> SRR1058041     2  0.0000     0.9741 0.000 1.000 0.000 0.000
#> SRR1058042     2  0.0000     0.9741 0.000 1.000 0.000 0.000
#> SRR1058043     2  0.0000     0.9741 0.000 1.000 0.000 0.000
#> SRR1058044     2  0.0000     0.9741 0.000 1.000 0.000 0.000
#> SRR1058045     2  0.0000     0.9741 0.000 1.000 0.000 0.000
#> SRR1058046     2  0.0000     0.9741 0.000 1.000 0.000 0.000
#> SRR1058047     2  0.0000     0.9741 0.000 1.000 0.000 0.000
#> SRR1058048     2  0.0000     0.9741 0.000 1.000 0.000 0.000
#> SRR1058049     2  0.0000     0.9741 0.000 1.000 0.000 0.000
#> SRR1058050     2  0.0000     0.9741 0.000 1.000 0.000 0.000
#> SRR1058051     2  0.0000     0.9741 0.000 1.000 0.000 0.000
#> SRR1058052     2  0.0000     0.9741 0.000 1.000 0.000 0.000
#> SRR1058053     2  0.0000     0.9741 0.000 1.000 0.000 0.000
#> SRR1058054     2  0.0000     0.9741 0.000 1.000 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
#> SRR1058003     3  0.0162      0.000 0.000 0.000 0.996 0.004 0.000
#> SRR1058004     4  0.0162      1.000 0.000 0.004 0.000 0.996 0.000
#> SRR1058006     2  0.2904      0.860 0.008 0.868 0.004 0.008 0.112
#> SRR1058005     4  0.0162      1.000 0.000 0.004 0.000 0.996 0.000
#> SRR1058007     2  0.1116      0.951 0.004 0.964 0.000 0.004 0.028
#> SRR1058008     1  0.0404      0.000 0.988 0.000 0.000 0.012 0.000
#> SRR1058009     2  0.0451      0.971 0.004 0.988 0.000 0.000 0.008
#> SRR1058010     2  0.0451      0.971 0.004 0.988 0.000 0.000 0.008
#> SRR1058011     2  0.0451      0.971 0.004 0.988 0.000 0.000 0.008
#> SRR1058012     2  0.0451      0.971 0.004 0.988 0.000 0.000 0.008
#> SRR1058013     2  0.0451      0.971 0.004 0.988 0.000 0.000 0.008
#> SRR1058014     2  0.3450      0.804 0.008 0.820 0.004 0.008 0.160
#> SRR1058015     2  0.2904      0.860 0.008 0.868 0.004 0.008 0.112
#> SRR1058016     2  0.0566      0.970 0.004 0.984 0.000 0.000 0.012
#> SRR1058017     2  0.0451      0.971 0.004 0.988 0.000 0.000 0.008
#> SRR1058018     2  0.3450      0.804 0.008 0.820 0.004 0.008 0.160
#> SRR1058019     2  0.0671      0.968 0.004 0.980 0.000 0.000 0.016
#> SRR1058020     2  0.0613      0.969 0.004 0.984 0.000 0.004 0.008
#> SRR1058021     5  0.0324      0.000 0.000 0.004 0.000 0.004 0.992
#> SRR1058022     2  0.0324      0.970 0.004 0.992 0.000 0.004 0.000
#> SRR1058023     2  0.4313      0.639 0.008 0.712 0.004 0.008 0.268
#> SRR1058024     2  0.1856      0.928 0.008 0.936 0.004 0.008 0.044
#> SRR1058025     2  0.0324      0.970 0.004 0.992 0.000 0.000 0.004
#> SRR1058026     2  0.0451      0.971 0.004 0.988 0.000 0.000 0.008
#> SRR1058027     2  0.0451      0.971 0.004 0.988 0.000 0.000 0.008
#> SRR1058028     2  0.0451      0.971 0.004 0.988 0.000 0.000 0.008
#> SRR1058029     2  0.0451      0.971 0.004 0.988 0.000 0.000 0.008
#> SRR1058030     2  0.0451      0.971 0.004 0.988 0.000 0.000 0.008
#> SRR1058031     2  0.0451      0.971 0.004 0.988 0.000 0.000 0.008
#> SRR1058032     2  0.0000      0.973 0.000 1.000 0.000 0.000 0.000
#> SRR1058033     2  0.0000      0.973 0.000 1.000 0.000 0.000 0.000
#> SRR1058034     2  0.0000      0.973 0.000 1.000 0.000 0.000 0.000
#> SRR1058035     2  0.0000      0.973 0.000 1.000 0.000 0.000 0.000
#> SRR1058036     2  0.0000      0.973 0.000 1.000 0.000 0.000 0.000
#> SRR1058037     2  0.0000      0.973 0.000 1.000 0.000 0.000 0.000
#> SRR1058038     2  0.0000      0.973 0.000 1.000 0.000 0.000 0.000
#> SRR1058039     2  0.0000      0.973 0.000 1.000 0.000 0.000 0.000
#> SRR1058040     2  0.0000      0.973 0.000 1.000 0.000 0.000 0.000
#> SRR1058041     2  0.0000      0.973 0.000 1.000 0.000 0.000 0.000
#> SRR1058042     2  0.0000      0.973 0.000 1.000 0.000 0.000 0.000
#> SRR1058043     2  0.0000      0.973 0.000 1.000 0.000 0.000 0.000
#> SRR1058044     2  0.0000      0.973 0.000 1.000 0.000 0.000 0.000
#> SRR1058045     2  0.0000      0.973 0.000 1.000 0.000 0.000 0.000
#> SRR1058046     2  0.0000      0.973 0.000 1.000 0.000 0.000 0.000
#> SRR1058047     2  0.0000      0.973 0.000 1.000 0.000 0.000 0.000
#> SRR1058048     2  0.0000      0.973 0.000 1.000 0.000 0.000 0.000
#> SRR1058049     2  0.0000      0.973 0.000 1.000 0.000 0.000 0.000
#> SRR1058050     2  0.0000      0.973 0.000 1.000 0.000 0.000 0.000
#> SRR1058051     2  0.0000      0.973 0.000 1.000 0.000 0.000 0.000
#> SRR1058052     2  0.0000      0.973 0.000 1.000 0.000 0.000 0.000
#> SRR1058053     2  0.0000      0.973 0.000 1.000 0.000 0.000 0.000
#> SRR1058054     2  0.0000      0.973 0.000 1.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2 p3 p4    p5 p6
#> SRR1058003     3  0.0000      0.000 0.000 0.000  1  0 0.000  0
#> SRR1058004     4  0.0000      1.000 0.000 0.000  0  1 0.000  0
#> SRR1058006     5  0.3868      0.731 0.000 0.496  0  0 0.504  0
#> SRR1058005     4  0.0000      1.000 0.000 0.000  0  1 0.000  0
#> SRR1058007     2  0.3050      0.438 0.000 0.764  0  0 0.236  0
#> SRR1058008     6  0.0000      0.000 0.000 0.000  0  0 0.000  1
#> SRR1058009     2  0.1007      0.912 0.000 0.956  0  0 0.044  0
#> SRR1058010     2  0.1007      0.912 0.000 0.956  0  0 0.044  0
#> SRR1058011     2  0.1007      0.912 0.000 0.956  0  0 0.044  0
#> SRR1058012     2  0.0790      0.920 0.000 0.968  0  0 0.032  0
#> SRR1058013     2  0.1075      0.909 0.000 0.952  0  0 0.048  0
#> SRR1058014     5  0.4561      0.812 0.036 0.428  0  0 0.536  0
#> SRR1058015     5  0.3866      0.753 0.000 0.484  0  0 0.516  0
#> SRR1058016     2  0.1765      0.853 0.000 0.904  0  0 0.096  0
#> SRR1058017     2  0.1501      0.880 0.000 0.924  0  0 0.076  0
#> SRR1058018     5  0.4555      0.811 0.036 0.424  0  0 0.540  0
#> SRR1058019     2  0.3351      0.368 0.000 0.712  0  0 0.288  0
#> SRR1058020     2  0.3420      0.486 0.012 0.748  0  0 0.240  0
#> SRR1058021     1  0.0363      0.000 0.988 0.000  0  0 0.012  0
#> SRR1058022     2  0.2135      0.761 0.000 0.872  0  0 0.128  0
#> SRR1058023     5  0.4933      0.551 0.104 0.272  0  0 0.624  0
#> SRR1058024     5  0.3515      0.582 0.000 0.324  0  0 0.676  0
#> SRR1058025     2  0.2491      0.669 0.000 0.836  0  0 0.164  0
#> SRR1058026     2  0.0790      0.920 0.000 0.968  0  0 0.032  0
#> SRR1058027     2  0.0790      0.920 0.000 0.968  0  0 0.032  0
#> SRR1058028     2  0.0790      0.920 0.000 0.968  0  0 0.032  0
#> SRR1058029     2  0.0790      0.920 0.000 0.968  0  0 0.032  0
#> SRR1058030     2  0.0790      0.920 0.000 0.968  0  0 0.032  0
#> SRR1058031     2  0.0790      0.920 0.000 0.968  0  0 0.032  0
#> SRR1058032     2  0.0000      0.935 0.000 1.000  0  0 0.000  0
#> SRR1058033     2  0.0000      0.935 0.000 1.000  0  0 0.000  0
#> SRR1058034     2  0.0000      0.935 0.000 1.000  0  0 0.000  0
#> SRR1058035     2  0.0000      0.935 0.000 1.000  0  0 0.000  0
#> SRR1058036     2  0.0000      0.935 0.000 1.000  0  0 0.000  0
#> SRR1058037     2  0.0000      0.935 0.000 1.000  0  0 0.000  0
#> SRR1058038     2  0.0000      0.935 0.000 1.000  0  0 0.000  0
#> SRR1058039     2  0.0000      0.935 0.000 1.000  0  0 0.000  0
#> SRR1058040     2  0.0000      0.935 0.000 1.000  0  0 0.000  0
#> SRR1058041     2  0.0000      0.935 0.000 1.000  0  0 0.000  0
#> SRR1058042     2  0.0000      0.935 0.000 1.000  0  0 0.000  0
#> SRR1058043     2  0.0000      0.935 0.000 1.000  0  0 0.000  0
#> SRR1058044     2  0.0000      0.935 0.000 1.000  0  0 0.000  0
#> SRR1058045     2  0.0000      0.935 0.000 1.000  0  0 0.000  0
#> SRR1058046     2  0.0000      0.935 0.000 1.000  0  0 0.000  0
#> SRR1058047     2  0.0000      0.935 0.000 1.000  0  0 0.000  0
#> SRR1058048     2  0.0000      0.935 0.000 1.000  0  0 0.000  0
#> SRR1058049     2  0.0000      0.935 0.000 1.000  0  0 0.000  0
#> SRR1058050     2  0.0000      0.935 0.000 1.000  0  0 0.000  0
#> SRR1058051     2  0.0000      0.935 0.000 1.000  0  0 0.000  0
#> SRR1058052     2  0.0000      0.935 0.000 1.000  0  0 0.000  0
#> SRR1058053     2  0.0000      0.935 0.000 1.000  0  0 0.000  0
#> SRR1058054     2  0.0000      0.935 0.000 1.000  0  0 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-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 18325 rows and 52 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#>   Subgroups are detected by 'kmeans' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk CV-kmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.954       0.977         0.4800 0.517   0.517
#> 3 3 0.614           0.744       0.785         0.2570 0.876   0.770
#> 4 4 0.597           0.580       0.715         0.1112 0.861   0.687
#> 5 5 0.588           0.660       0.744         0.0758 0.833   0.537
#> 6 6 0.591           0.694       0.801         0.0472 0.955   0.825

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
#> SRR1058003     2  0.0000     0.9711 0.000 1.000
#> SRR1058004     2  0.0000     0.9711 0.000 1.000
#> SRR1058006     2  0.0000     0.9711 0.000 1.000
#> SRR1058005     2  0.0000     0.9711 0.000 1.000
#> SRR1058007     2  0.0000     0.9711 0.000 1.000
#> SRR1058008     2  0.0000     0.9711 0.000 1.000
#> SRR1058009     1  0.4562     0.8955 0.904 0.096
#> SRR1058010     1  0.1184     0.9727 0.984 0.016
#> SRR1058011     2  0.9998     0.0354 0.492 0.508
#> SRR1058012     1  0.0000     0.9795 1.000 0.000
#> SRR1058013     2  0.0376     0.9703 0.004 0.996
#> SRR1058014     2  0.0000     0.9711 0.000 1.000
#> SRR1058015     2  0.0000     0.9711 0.000 1.000
#> SRR1058016     2  0.0938     0.9646 0.012 0.988
#> SRR1058017     2  0.0938     0.9646 0.012 0.988
#> SRR1058018     2  0.0000     0.9711 0.000 1.000
#> SRR1058019     2  0.0376     0.9703 0.004 0.996
#> SRR1058020     2  0.0376     0.9703 0.004 0.996
#> SRR1058021     2  0.0000     0.9711 0.000 1.000
#> SRR1058022     2  0.0376     0.9703 0.004 0.996
#> SRR1058023     2  0.0000     0.9711 0.000 1.000
#> SRR1058024     2  0.0376     0.9703 0.004 0.996
#> SRR1058025     2  0.0672     0.9677 0.008 0.992
#> SRR1058026     1  0.0000     0.9795 1.000 0.000
#> SRR1058027     1  0.0000     0.9795 1.000 0.000
#> SRR1058028     1  0.0000     0.9795 1.000 0.000
#> SRR1058029     1  0.0000     0.9795 1.000 0.000
#> SRR1058030     1  0.0000     0.9795 1.000 0.000
#> SRR1058031     1  0.0000     0.9795 1.000 0.000
#> SRR1058032     1  0.2236     0.9739 0.964 0.036
#> SRR1058033     1  0.0938     0.9785 0.988 0.012
#> SRR1058034     1  0.0938     0.9785 0.988 0.012
#> SRR1058035     1  0.2236     0.9739 0.964 0.036
#> SRR1058036     1  0.2603     0.9706 0.956 0.044
#> SRR1058037     1  0.2603     0.9706 0.956 0.044
#> SRR1058038     1  0.2603     0.9706 0.956 0.044
#> SRR1058039     1  0.2236     0.9739 0.964 0.036
#> SRR1058040     1  0.2423     0.9724 0.960 0.040
#> SRR1058041     1  0.2603     0.9706 0.956 0.044
#> SRR1058042     1  0.2603     0.9706 0.956 0.044
#> SRR1058043     1  0.2603     0.9706 0.956 0.044
#> SRR1058044     1  0.0938     0.9785 0.988 0.012
#> SRR1058045     1  0.2603     0.9706 0.956 0.044
#> SRR1058046     1  0.2603     0.9706 0.956 0.044
#> SRR1058047     1  0.0000     0.9795 1.000 0.000
#> SRR1058048     1  0.0000     0.9795 1.000 0.000
#> SRR1058049     1  0.0000     0.9795 1.000 0.000
#> SRR1058050     1  0.0000     0.9795 1.000 0.000
#> SRR1058051     1  0.0000     0.9795 1.000 0.000
#> SRR1058052     1  0.0000     0.9795 1.000 0.000
#> SRR1058053     1  0.0000     0.9795 1.000 0.000
#> SRR1058054     1  0.0000     0.9795 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1058003     3  0.5650      0.920 0.000 0.312 0.688
#> SRR1058004     3  0.5363      0.892 0.000 0.276 0.724
#> SRR1058006     2  0.3551      0.618 0.000 0.868 0.132
#> SRR1058005     3  0.5810      0.885 0.000 0.336 0.664
#> SRR1058007     2  0.3116      0.653 0.000 0.892 0.108
#> SRR1058008     3  0.5678      0.920 0.000 0.316 0.684
#> SRR1058009     2  0.6244      0.265 0.440 0.560 0.000
#> SRR1058010     2  0.6180      0.292 0.416 0.584 0.000
#> SRR1058011     2  0.5254      0.442 0.264 0.736 0.000
#> SRR1058012     1  0.3619      0.730 0.864 0.136 0.000
#> SRR1058013     2  0.0000      0.745 0.000 1.000 0.000
#> SRR1058014     2  0.4504      0.516 0.000 0.804 0.196
#> SRR1058015     2  0.2165      0.702 0.000 0.936 0.064
#> SRR1058016     2  0.0000      0.745 0.000 1.000 0.000
#> SRR1058017     2  0.0424      0.745 0.000 0.992 0.008
#> SRR1058018     2  0.4504      0.516 0.000 0.804 0.196
#> SRR1058019     2  0.0424      0.745 0.000 0.992 0.008
#> SRR1058020     2  0.0237      0.745 0.000 0.996 0.004
#> SRR1058021     3  0.6140      0.819 0.000 0.404 0.596
#> SRR1058022     2  0.0000      0.745 0.000 1.000 0.000
#> SRR1058023     2  0.4555      0.507 0.000 0.800 0.200
#> SRR1058024     2  0.0424      0.745 0.000 0.992 0.008
#> SRR1058025     2  0.0000      0.745 0.000 1.000 0.000
#> SRR1058026     1  0.3752      0.721 0.856 0.144 0.000
#> SRR1058027     1  0.3619      0.730 0.864 0.136 0.000
#> SRR1058028     1  0.3619      0.730 0.864 0.136 0.000
#> SRR1058029     1  0.3551      0.734 0.868 0.132 0.000
#> SRR1058030     1  0.3551      0.734 0.868 0.132 0.000
#> SRR1058031     1  0.3551      0.734 0.868 0.132 0.000
#> SRR1058032     1  0.5650      0.796 0.688 0.000 0.312
#> SRR1058033     1  0.5650      0.796 0.688 0.000 0.312
#> SRR1058034     1  0.5650      0.796 0.688 0.000 0.312
#> SRR1058035     1  0.5291      0.820 0.732 0.000 0.268
#> SRR1058036     1  0.5291      0.820 0.732 0.000 0.268
#> SRR1058037     1  0.5291      0.820 0.732 0.000 0.268
#> SRR1058038     1  0.5291      0.820 0.732 0.000 0.268
#> SRR1058039     1  0.5291      0.820 0.732 0.000 0.268
#> SRR1058040     1  0.5291      0.820 0.732 0.000 0.268
#> SRR1058041     1  0.5291      0.820 0.732 0.000 0.268
#> SRR1058042     1  0.5291      0.820 0.732 0.000 0.268
#> SRR1058043     1  0.5291      0.820 0.732 0.000 0.268
#> SRR1058044     1  0.5291      0.820 0.732 0.000 0.268
#> SRR1058045     1  0.5291      0.820 0.732 0.000 0.268
#> SRR1058046     1  0.5291      0.820 0.732 0.000 0.268
#> SRR1058047     1  0.1643      0.794 0.956 0.000 0.044
#> SRR1058048     1  0.0000      0.805 1.000 0.000 0.000
#> SRR1058049     1  0.0000      0.805 1.000 0.000 0.000
#> SRR1058050     1  0.0000      0.805 1.000 0.000 0.000
#> SRR1058051     1  0.1643      0.794 0.956 0.000 0.044
#> SRR1058052     1  0.0000      0.805 1.000 0.000 0.000
#> SRR1058053     1  0.0000      0.805 1.000 0.000 0.000
#> SRR1058054     1  0.0000      0.805 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
#> SRR1058003     4  0.5453     0.8041 0.000 0.032 0.320 0.648
#> SRR1058004     4  0.4799     0.8214 0.000 0.032 0.224 0.744
#> SRR1058006     2  0.2125     0.7621 0.000 0.920 0.004 0.076
#> SRR1058005     4  0.5799     0.8041 0.000 0.068 0.264 0.668
#> SRR1058007     2  0.0817     0.7925 0.000 0.976 0.000 0.024
#> SRR1058008     4  0.1545     0.7833 0.000 0.040 0.008 0.952
#> SRR1058009     2  0.6465     0.2945 0.080 0.556 0.364 0.000
#> SRR1058010     3  0.6197    -0.0561 0.052 0.440 0.508 0.000
#> SRR1058011     2  0.3870     0.7288 0.004 0.788 0.208 0.000
#> SRR1058012     3  0.5510     0.8459 0.376 0.024 0.600 0.000
#> SRR1058013     2  0.2760     0.7957 0.000 0.872 0.128 0.000
#> SRR1058014     2  0.4155     0.5926 0.000 0.756 0.004 0.240
#> SRR1058015     2  0.0779     0.7963 0.000 0.980 0.004 0.016
#> SRR1058016     2  0.2973     0.7881 0.000 0.856 0.144 0.000
#> SRR1058017     2  0.3123     0.7803 0.000 0.844 0.156 0.000
#> SRR1058018     2  0.4155     0.5926 0.000 0.756 0.004 0.240
#> SRR1058019     2  0.1398     0.8117 0.000 0.956 0.040 0.004
#> SRR1058020     2  0.1474     0.8135 0.000 0.948 0.052 0.000
#> SRR1058021     4  0.4857     0.4533 0.000 0.324 0.008 0.668
#> SRR1058022     2  0.1637     0.8125 0.000 0.940 0.060 0.000
#> SRR1058023     2  0.4188     0.5868 0.000 0.752 0.004 0.244
#> SRR1058024     2  0.0336     0.8033 0.000 0.992 0.008 0.000
#> SRR1058025     2  0.3074     0.7840 0.000 0.848 0.152 0.000
#> SRR1058026     3  0.5659     0.8345 0.368 0.032 0.600 0.000
#> SRR1058027     3  0.5510     0.8459 0.376 0.024 0.600 0.000
#> SRR1058028     3  0.5510     0.8459 0.376 0.024 0.600 0.000
#> SRR1058029     3  0.5510     0.8459 0.376 0.024 0.600 0.000
#> SRR1058030     3  0.5510     0.8459 0.376 0.024 0.600 0.000
#> SRR1058031     3  0.5510     0.8459 0.376 0.024 0.600 0.000
#> SRR1058032     1  0.2797     0.6449 0.900 0.000 0.068 0.032
#> SRR1058033     1  0.2943     0.6442 0.892 0.000 0.076 0.032
#> SRR1058034     1  0.2943     0.6442 0.892 0.000 0.076 0.032
#> SRR1058035     1  0.0000     0.7103 1.000 0.000 0.000 0.000
#> SRR1058036     1  0.0000     0.7103 1.000 0.000 0.000 0.000
#> SRR1058037     1  0.0000     0.7103 1.000 0.000 0.000 0.000
#> SRR1058038     1  0.0000     0.7103 1.000 0.000 0.000 0.000
#> SRR1058039     1  0.0000     0.7103 1.000 0.000 0.000 0.000
#> SRR1058040     1  0.0000     0.7103 1.000 0.000 0.000 0.000
#> SRR1058041     1  0.0000     0.7103 1.000 0.000 0.000 0.000
#> SRR1058042     1  0.0000     0.7103 1.000 0.000 0.000 0.000
#> SRR1058043     1  0.0000     0.7103 1.000 0.000 0.000 0.000
#> SRR1058044     1  0.0000     0.7103 1.000 0.000 0.000 0.000
#> SRR1058045     1  0.0000     0.7103 1.000 0.000 0.000 0.000
#> SRR1058046     1  0.0000     0.7103 1.000 0.000 0.000 0.000
#> SRR1058047     1  0.5861    -0.1525 0.492 0.000 0.476 0.032
#> SRR1058048     1  0.4948    -0.1766 0.560 0.000 0.440 0.000
#> SRR1058049     1  0.4948    -0.1766 0.560 0.000 0.440 0.000
#> SRR1058050     1  0.4948    -0.1766 0.560 0.000 0.440 0.000
#> SRR1058051     1  0.5861    -0.1525 0.492 0.000 0.476 0.032
#> SRR1058052     1  0.4948    -0.1766 0.560 0.000 0.440 0.000
#> SRR1058053     1  0.4948    -0.1766 0.560 0.000 0.440 0.000
#> SRR1058054     1  0.4948    -0.1766 0.560 0.000 0.440 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
#> SRR1058003     4  0.2554      0.805 0.036 0.000 0.000 0.892 0.072
#> SRR1058004     4  0.3366      0.849 0.000 0.000 0.000 0.768 0.232
#> SRR1058006     2  0.4101      0.136 0.004 0.664 0.000 0.000 0.332
#> SRR1058005     4  0.3769      0.841 0.032 0.000 0.000 0.788 0.180
#> SRR1058007     2  0.2522      0.623 0.012 0.880 0.000 0.000 0.108
#> SRR1058008     5  0.4676     -0.292 0.072 0.000 0.000 0.208 0.720
#> SRR1058009     2  0.4135      0.481 0.004 0.656 0.340 0.000 0.000
#> SRR1058010     3  0.4448     -0.226 0.004 0.480 0.516 0.000 0.000
#> SRR1058011     2  0.3422      0.665 0.004 0.792 0.200 0.000 0.004
#> SRR1058012     3  0.1043      0.750 0.000 0.040 0.960 0.000 0.000
#> SRR1058013     2  0.2909      0.707 0.012 0.848 0.140 0.000 0.000
#> SRR1058014     2  0.4561     -0.489 0.000 0.504 0.000 0.008 0.488
#> SRR1058015     2  0.3266      0.494 0.004 0.796 0.000 0.000 0.200
#> SRR1058016     2  0.3280      0.699 0.004 0.824 0.160 0.000 0.012
#> SRR1058017     2  0.3409      0.706 0.000 0.824 0.144 0.000 0.032
#> SRR1058018     5  0.4562      0.291 0.000 0.496 0.000 0.008 0.496
#> SRR1058019     2  0.2381      0.693 0.004 0.908 0.036 0.000 0.052
#> SRR1058020     2  0.2124      0.709 0.020 0.924 0.044 0.000 0.012
#> SRR1058021     5  0.3264      0.333 0.004 0.132 0.000 0.024 0.840
#> SRR1058022     2  0.1843      0.714 0.008 0.932 0.052 0.000 0.008
#> SRR1058023     5  0.4811      0.320 0.008 0.472 0.000 0.008 0.512
#> SRR1058024     2  0.2464      0.629 0.016 0.888 0.000 0.000 0.096
#> SRR1058025     2  0.2770      0.714 0.008 0.864 0.124 0.000 0.004
#> SRR1058026     3  0.1410      0.734 0.000 0.060 0.940 0.000 0.000
#> SRR1058027     3  0.0963      0.753 0.000 0.036 0.964 0.000 0.000
#> SRR1058028     3  0.0963      0.753 0.000 0.036 0.964 0.000 0.000
#> SRR1058029     3  0.0000      0.760 0.000 0.000 1.000 0.000 0.000
#> SRR1058030     3  0.0162      0.760 0.000 0.004 0.996 0.000 0.000
#> SRR1058031     3  0.0404      0.759 0.000 0.012 0.988 0.000 0.000
#> SRR1058032     1  0.5240      0.725 0.732 0.000 0.152 0.068 0.048
#> SRR1058033     1  0.5374      0.714 0.720 0.000 0.160 0.072 0.048
#> SRR1058034     1  0.5374      0.714 0.720 0.000 0.160 0.072 0.048
#> SRR1058035     1  0.3395      0.933 0.764 0.000 0.236 0.000 0.000
#> SRR1058036     1  0.3395      0.933 0.764 0.000 0.236 0.000 0.000
#> SRR1058037     1  0.3395      0.933 0.764 0.000 0.236 0.000 0.000
#> SRR1058038     1  0.3395      0.933 0.764 0.000 0.236 0.000 0.000
#> SRR1058039     1  0.3395      0.933 0.764 0.000 0.236 0.000 0.000
#> SRR1058040     1  0.3550      0.932 0.760 0.000 0.236 0.000 0.004
#> SRR1058041     1  0.3550      0.932 0.760 0.000 0.236 0.000 0.004
#> SRR1058042     1  0.3550      0.932 0.760 0.000 0.236 0.000 0.004
#> SRR1058043     1  0.3550      0.932 0.760 0.000 0.236 0.000 0.004
#> SRR1058044     1  0.3395      0.933 0.764 0.000 0.236 0.000 0.000
#> SRR1058045     1  0.3395      0.933 0.764 0.000 0.236 0.000 0.000
#> SRR1058046     1  0.3395      0.933 0.764 0.000 0.236 0.000 0.000
#> SRR1058047     3  0.6202      0.528 0.280 0.000 0.600 0.072 0.048
#> SRR1058048     3  0.3246      0.701 0.184 0.000 0.808 0.008 0.000
#> SRR1058049     3  0.3246      0.701 0.184 0.000 0.808 0.008 0.000
#> SRR1058050     3  0.3246      0.701 0.184 0.000 0.808 0.008 0.000
#> SRR1058051     3  0.6036      0.544 0.280 0.000 0.612 0.060 0.048
#> SRR1058052     3  0.3246      0.701 0.184 0.000 0.808 0.008 0.000
#> SRR1058053     3  0.3246      0.701 0.184 0.000 0.808 0.008 0.000
#> SRR1058054     3  0.3246      0.701 0.184 0.000 0.808 0.008 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR1058003     4  0.4361     0.5150 0.036 0.004 0.004 0.680 0.000 0.276
#> SRR1058004     4  0.1663     0.7017 0.000 0.000 0.000 0.912 0.088 0.000
#> SRR1058006     5  0.4592     0.5117 0.004 0.404 0.000 0.004 0.564 0.024
#> SRR1058005     4  0.3161     0.6935 0.024 0.004 0.000 0.856 0.080 0.036
#> SRR1058007     2  0.3221     0.5152 0.000 0.792 0.000 0.000 0.188 0.020
#> SRR1058008     6  0.5744     0.0000 0.000 0.000 0.000 0.168 0.408 0.424
#> SRR1058009     2  0.3784     0.5308 0.000 0.680 0.308 0.000 0.000 0.012
#> SRR1058010     2  0.4205     0.3931 0.000 0.564 0.420 0.000 0.000 0.016
#> SRR1058011     2  0.3020     0.6680 0.000 0.824 0.156 0.000 0.008 0.012
#> SRR1058012     3  0.1967     0.7531 0.000 0.084 0.904 0.000 0.000 0.012
#> SRR1058013     2  0.2405     0.6900 0.000 0.880 0.100 0.000 0.004 0.016
#> SRR1058014     5  0.3575     0.7502 0.000 0.284 0.000 0.008 0.708 0.000
#> SRR1058015     2  0.4711    -0.2956 0.004 0.524 0.004 0.000 0.440 0.028
#> SRR1058016     2  0.3286     0.6840 0.000 0.832 0.116 0.000 0.036 0.016
#> SRR1058017     2  0.3442     0.6751 0.000 0.824 0.104 0.000 0.060 0.012
#> SRR1058018     5  0.3398     0.7550 0.000 0.252 0.000 0.008 0.740 0.000
#> SRR1058019     2  0.3454     0.5821 0.004 0.808 0.004 0.000 0.148 0.036
#> SRR1058020     2  0.3050     0.6441 0.004 0.860 0.012 0.000 0.048 0.076
#> SRR1058021     5  0.3123     0.0014 0.016 0.024 0.000 0.016 0.860 0.084
#> SRR1058022     2  0.2045     0.6622 0.000 0.916 0.016 0.000 0.052 0.016
#> SRR1058023     5  0.3692     0.7537 0.000 0.244 0.000 0.008 0.736 0.012
#> SRR1058024     2  0.4144     0.5016 0.004 0.744 0.004 0.000 0.192 0.056
#> SRR1058025     2  0.2335     0.6862 0.000 0.904 0.044 0.000 0.024 0.028
#> SRR1058026     3  0.2170     0.7329 0.000 0.100 0.888 0.000 0.000 0.012
#> SRR1058027     3  0.1888     0.7678 0.004 0.068 0.916 0.000 0.000 0.012
#> SRR1058028     3  0.1888     0.7678 0.004 0.068 0.916 0.000 0.000 0.012
#> SRR1058029     3  0.0405     0.7999 0.008 0.004 0.988 0.000 0.000 0.000
#> SRR1058030     3  0.0405     0.7999 0.008 0.004 0.988 0.000 0.000 0.000
#> SRR1058031     3  0.0806     0.7948 0.008 0.020 0.972 0.000 0.000 0.000
#> SRR1058032     1  0.4526     0.6696 0.728 0.000 0.076 0.020 0.000 0.176
#> SRR1058033     1  0.4854     0.6421 0.696 0.000 0.096 0.020 0.000 0.188
#> SRR1058034     1  0.4854     0.6421 0.696 0.000 0.096 0.020 0.000 0.188
#> SRR1058035     1  0.2482     0.9230 0.848 0.000 0.148 0.000 0.004 0.000
#> SRR1058036     1  0.2340     0.9236 0.852 0.000 0.148 0.000 0.000 0.000
#> SRR1058037     1  0.2340     0.9236 0.852 0.000 0.148 0.000 0.000 0.000
#> SRR1058038     1  0.2340     0.9236 0.852 0.000 0.148 0.000 0.000 0.000
#> SRR1058039     1  0.2482     0.9230 0.848 0.000 0.148 0.000 0.004 0.000
#> SRR1058040     1  0.2482     0.9230 0.848 0.000 0.148 0.000 0.004 0.000
#> SRR1058041     1  0.2340     0.9236 0.852 0.000 0.148 0.000 0.000 0.000
#> SRR1058042     1  0.2340     0.9236 0.852 0.000 0.148 0.000 0.000 0.000
#> SRR1058043     1  0.2482     0.9230 0.848 0.000 0.148 0.000 0.004 0.000
#> SRR1058044     1  0.2624     0.9208 0.844 0.000 0.148 0.000 0.004 0.004
#> SRR1058045     1  0.2340     0.9236 0.852 0.000 0.148 0.000 0.000 0.000
#> SRR1058046     1  0.2340     0.9236 0.852 0.000 0.148 0.000 0.000 0.000
#> SRR1058047     3  0.5426     0.6130 0.220 0.000 0.596 0.004 0.000 0.180
#> SRR1058048     3  0.3101     0.7994 0.148 0.000 0.820 0.000 0.000 0.032
#> SRR1058049     3  0.3101     0.7994 0.148 0.000 0.820 0.000 0.000 0.032
#> SRR1058050     3  0.3101     0.7994 0.148 0.000 0.820 0.000 0.000 0.032
#> SRR1058051     3  0.5426     0.6130 0.220 0.000 0.596 0.004 0.000 0.180
#> SRR1058052     3  0.3101     0.7994 0.148 0.000 0.820 0.000 0.000 0.032
#> SRR1058053     3  0.3101     0.7994 0.148 0.000 0.820 0.000 0.000 0.032
#> SRR1058054     3  0.3101     0.7994 0.148 0.000 0.820 0.000 0.000 0.032

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

consensus_heatmap(res, k = 2)

plot of chunk tab-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 18325 rows and 52 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#>   Subgroups are detected by 'skmeans' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 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           0.993       0.995         0.4987 0.502   0.502
#> 3 3 1.000           0.977       0.991         0.3519 0.778   0.576
#> 4 4 0.730           0.691       0.822         0.1066 0.947   0.839
#> 5 5 0.713           0.617       0.757         0.0616 0.930   0.757
#> 6 6 0.713           0.596       0.734         0.0406 0.894   0.577

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
#> SRR1058003     2  0.0000      0.997 0.000 1.000
#> SRR1058004     2  0.0000      0.997 0.000 1.000
#> SRR1058006     2  0.0000      0.997 0.000 1.000
#> SRR1058005     2  0.0000      0.997 0.000 1.000
#> SRR1058007     2  0.0000      0.997 0.000 1.000
#> SRR1058008     2  0.0000      0.997 0.000 1.000
#> SRR1058009     2  0.1414      0.985 0.020 0.980
#> SRR1058010     2  0.1184      0.988 0.016 0.984
#> SRR1058011     2  0.0938      0.991 0.012 0.988
#> SRR1058012     1  0.0000      0.993 1.000 0.000
#> SRR1058013     2  0.0376      0.996 0.004 0.996
#> SRR1058014     2  0.0000      0.997 0.000 1.000
#> SRR1058015     2  0.0000      0.997 0.000 1.000
#> SRR1058016     2  0.0376      0.996 0.004 0.996
#> SRR1058017     2  0.0376      0.996 0.004 0.996
#> SRR1058018     2  0.0000      0.997 0.000 1.000
#> SRR1058019     2  0.0376      0.996 0.004 0.996
#> SRR1058020     2  0.0376      0.996 0.004 0.996
#> SRR1058021     2  0.0000      0.997 0.000 1.000
#> SRR1058022     2  0.0000      0.997 0.000 1.000
#> SRR1058023     2  0.0000      0.997 0.000 1.000
#> SRR1058024     2  0.0376      0.996 0.004 0.996
#> SRR1058025     2  0.0376      0.996 0.004 0.996
#> SRR1058026     1  0.3584      0.928 0.932 0.068
#> SRR1058027     1  0.0376      0.992 0.996 0.004
#> SRR1058028     1  0.0000      0.993 1.000 0.000
#> SRR1058029     1  0.0000      0.993 1.000 0.000
#> SRR1058030     1  0.0000      0.993 1.000 0.000
#> SRR1058031     1  0.0000      0.993 1.000 0.000
#> SRR1058032     1  0.0376      0.993 0.996 0.004
#> SRR1058033     1  0.0376      0.993 0.996 0.004
#> SRR1058034     1  0.0376      0.993 0.996 0.004
#> SRR1058035     1  0.0376      0.993 0.996 0.004
#> SRR1058036     1  0.0938      0.991 0.988 0.012
#> SRR1058037     1  0.0938      0.991 0.988 0.012
#> SRR1058038     1  0.0938      0.991 0.988 0.012
#> SRR1058039     1  0.0376      0.993 0.996 0.004
#> SRR1058040     1  0.0672      0.992 0.992 0.008
#> SRR1058041     1  0.0938      0.991 0.988 0.012
#> SRR1058042     1  0.0938      0.991 0.988 0.012
#> SRR1058043     1  0.0938      0.991 0.988 0.012
#> SRR1058044     1  0.0376      0.993 0.996 0.004
#> SRR1058045     1  0.0938      0.991 0.988 0.012
#> SRR1058046     1  0.0938      0.991 0.988 0.012
#> SRR1058047     1  0.0000      0.993 1.000 0.000
#> SRR1058048     1  0.0000      0.993 1.000 0.000
#> SRR1058049     1  0.0000      0.993 1.000 0.000
#> SRR1058050     1  0.0000      0.993 1.000 0.000
#> SRR1058051     1  0.0000      0.993 1.000 0.000
#> SRR1058052     1  0.0000      0.993 1.000 0.000
#> SRR1058053     1  0.0000      0.993 1.000 0.000
#> SRR1058054     1  0.0000      0.993 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1   p2    p3
#> SRR1058003     2  0.0000      0.997 0.000 1.00 0.000
#> SRR1058004     2  0.0000      0.997 0.000 1.00 0.000
#> SRR1058006     2  0.0000      0.997 0.000 1.00 0.000
#> SRR1058005     2  0.0000      0.997 0.000 1.00 0.000
#> SRR1058007     2  0.0000      0.997 0.000 1.00 0.000
#> SRR1058008     2  0.0000      0.997 0.000 1.00 0.000
#> SRR1058009     3  0.6169      0.433 0.004 0.36 0.636
#> SRR1058010     3  0.1529      0.937 0.000 0.04 0.960
#> SRR1058011     2  0.2066      0.934 0.000 0.94 0.060
#> SRR1058012     3  0.0000      0.973 0.000 0.00 1.000
#> SRR1058013     2  0.0000      0.997 0.000 1.00 0.000
#> SRR1058014     2  0.0000      0.997 0.000 1.00 0.000
#> SRR1058015     2  0.0000      0.997 0.000 1.00 0.000
#> SRR1058016     2  0.0000      0.997 0.000 1.00 0.000
#> SRR1058017     2  0.0000      0.997 0.000 1.00 0.000
#> SRR1058018     2  0.0000      0.997 0.000 1.00 0.000
#> SRR1058019     2  0.0000      0.997 0.000 1.00 0.000
#> SRR1058020     2  0.0000      0.997 0.000 1.00 0.000
#> SRR1058021     2  0.0000      0.997 0.000 1.00 0.000
#> SRR1058022     2  0.0000      0.997 0.000 1.00 0.000
#> SRR1058023     2  0.0000      0.997 0.000 1.00 0.000
#> SRR1058024     2  0.0000      0.997 0.000 1.00 0.000
#> SRR1058025     2  0.0000      0.997 0.000 1.00 0.000
#> SRR1058026     3  0.0000      0.973 0.000 0.00 1.000
#> SRR1058027     3  0.0000      0.973 0.000 0.00 1.000
#> SRR1058028     3  0.0000      0.973 0.000 0.00 1.000
#> SRR1058029     3  0.0000      0.973 0.000 0.00 1.000
#> SRR1058030     3  0.0000      0.973 0.000 0.00 1.000
#> SRR1058031     3  0.0000      0.973 0.000 0.00 1.000
#> SRR1058032     1  0.0000      0.999 1.000 0.00 0.000
#> SRR1058033     1  0.0237      0.995 0.996 0.00 0.004
#> SRR1058034     1  0.0747      0.984 0.984 0.00 0.016
#> SRR1058035     1  0.0000      0.999 1.000 0.00 0.000
#> SRR1058036     1  0.0000      0.999 1.000 0.00 0.000
#> SRR1058037     1  0.0000      0.999 1.000 0.00 0.000
#> SRR1058038     1  0.0000      0.999 1.000 0.00 0.000
#> SRR1058039     1  0.0000      0.999 1.000 0.00 0.000
#> SRR1058040     1  0.0000      0.999 1.000 0.00 0.000
#> SRR1058041     1  0.0000      0.999 1.000 0.00 0.000
#> SRR1058042     1  0.0000      0.999 1.000 0.00 0.000
#> SRR1058043     1  0.0000      0.999 1.000 0.00 0.000
#> SRR1058044     1  0.0000      0.999 1.000 0.00 0.000
#> SRR1058045     1  0.0000      0.999 1.000 0.00 0.000
#> SRR1058046     1  0.0000      0.999 1.000 0.00 0.000
#> SRR1058047     3  0.0000      0.973 0.000 0.00 1.000
#> SRR1058048     3  0.0000      0.973 0.000 0.00 1.000
#> SRR1058049     3  0.0000      0.973 0.000 0.00 1.000
#> SRR1058050     3  0.0000      0.973 0.000 0.00 1.000
#> SRR1058051     3  0.0000      0.973 0.000 0.00 1.000
#> SRR1058052     3  0.0000      0.973 0.000 0.00 1.000
#> SRR1058053     3  0.0000      0.973 0.000 0.00 1.000
#> SRR1058054     3  0.0000      0.973 0.000 0.00 1.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1058003     2  0.0469    0.82740 0.000 0.988 0.000 0.012
#> SRR1058004     2  0.1867    0.78843 0.000 0.928 0.000 0.072
#> SRR1058006     2  0.0921    0.83133 0.000 0.972 0.000 0.028
#> SRR1058005     2  0.3528    0.65190 0.000 0.808 0.000 0.192
#> SRR1058007     2  0.1867    0.82665 0.000 0.928 0.000 0.072
#> SRR1058008     2  0.0188    0.82818 0.000 0.996 0.000 0.004
#> SRR1058009     4  0.5855    0.53592 0.000 0.100 0.208 0.692
#> SRR1058010     4  0.5417    0.31047 0.000 0.040 0.284 0.676
#> SRR1058011     4  0.5519    0.54245 0.000 0.264 0.052 0.684
#> SRR1058012     3  0.4989    0.32180 0.000 0.000 0.528 0.472
#> SRR1058013     2  0.4697    0.45960 0.000 0.644 0.000 0.356
#> SRR1058014     2  0.0817    0.83060 0.000 0.976 0.000 0.024
#> SRR1058015     2  0.2760    0.79150 0.000 0.872 0.000 0.128
#> SRR1058016     2  0.4948    0.15222 0.000 0.560 0.000 0.440
#> SRR1058017     4  0.5151    0.00824 0.000 0.464 0.004 0.532
#> SRR1058018     2  0.0188    0.82918 0.000 0.996 0.000 0.004
#> SRR1058019     2  0.3444    0.75232 0.000 0.816 0.000 0.184
#> SRR1058020     2  0.3726    0.72539 0.000 0.788 0.000 0.212
#> SRR1058021     2  0.0188    0.82982 0.000 0.996 0.000 0.004
#> SRR1058022     2  0.3172    0.78735 0.000 0.840 0.000 0.160
#> SRR1058023     2  0.0469    0.82955 0.000 0.988 0.000 0.012
#> SRR1058024     2  0.2814    0.79758 0.000 0.868 0.000 0.132
#> SRR1058025     2  0.4804    0.42426 0.000 0.616 0.000 0.384
#> SRR1058026     3  0.5132    0.37708 0.000 0.004 0.548 0.448
#> SRR1058027     3  0.4898    0.44336 0.000 0.000 0.584 0.416
#> SRR1058028     3  0.4877    0.46032 0.000 0.000 0.592 0.408
#> SRR1058029     3  0.3024    0.71354 0.000 0.000 0.852 0.148
#> SRR1058030     3  0.3266    0.70387 0.000 0.000 0.832 0.168
#> SRR1058031     3  0.4008    0.64770 0.000 0.000 0.756 0.244
#> SRR1058032     1  0.6494    0.60705 0.632 0.000 0.136 0.232
#> SRR1058033     1  0.7371    0.46218 0.524 0.000 0.244 0.232
#> SRR1058034     1  0.7660    0.32319 0.452 0.000 0.316 0.232
#> SRR1058035     1  0.0000    0.90303 1.000 0.000 0.000 0.000
#> SRR1058036     1  0.0000    0.90303 1.000 0.000 0.000 0.000
#> SRR1058037     1  0.0000    0.90303 1.000 0.000 0.000 0.000
#> SRR1058038     1  0.0000    0.90303 1.000 0.000 0.000 0.000
#> SRR1058039     1  0.0000    0.90303 1.000 0.000 0.000 0.000
#> SRR1058040     1  0.0000    0.90303 1.000 0.000 0.000 0.000
#> SRR1058041     1  0.0000    0.90303 1.000 0.000 0.000 0.000
#> SRR1058042     1  0.0000    0.90303 1.000 0.000 0.000 0.000
#> SRR1058043     1  0.0000    0.90303 1.000 0.000 0.000 0.000
#> SRR1058044     1  0.0188    0.90014 0.996 0.000 0.004 0.000
#> SRR1058045     1  0.0000    0.90303 1.000 0.000 0.000 0.000
#> SRR1058046     1  0.0000    0.90303 1.000 0.000 0.000 0.000
#> SRR1058047     3  0.3907    0.56634 0.000 0.000 0.768 0.232
#> SRR1058048     3  0.0000    0.75442 0.000 0.000 1.000 0.000
#> SRR1058049     3  0.0000    0.75442 0.000 0.000 1.000 0.000
#> SRR1058050     3  0.0000    0.75442 0.000 0.000 1.000 0.000
#> SRR1058051     3  0.3801    0.57881 0.000 0.000 0.780 0.220
#> SRR1058052     3  0.0000    0.75442 0.000 0.000 1.000 0.000
#> SRR1058053     3  0.0000    0.75442 0.000 0.000 1.000 0.000
#> SRR1058054     3  0.0000    0.75442 0.000 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4    p5
#> SRR1058003     5  0.2409     0.7392 0.000 0.032 0.000 0.068 0.900
#> SRR1058004     5  0.3081     0.6884 0.000 0.012 0.000 0.156 0.832
#> SRR1058006     5  0.3526     0.7398 0.000 0.072 0.000 0.096 0.832
#> SRR1058005     5  0.4475     0.5933 0.000 0.032 0.000 0.276 0.692
#> SRR1058007     5  0.4545     0.7180 0.000 0.132 0.000 0.116 0.752
#> SRR1058008     5  0.1774     0.7433 0.000 0.016 0.000 0.052 0.932
#> SRR1058009     2  0.4668     0.4939 0.004 0.784 0.084 0.100 0.028
#> SRR1058010     2  0.4543     0.4286 0.000 0.760 0.172 0.052 0.016
#> SRR1058011     2  0.5295     0.3513 0.000 0.704 0.016 0.180 0.100
#> SRR1058012     2  0.5406    -0.2171 0.000 0.476 0.468 0.056 0.000
#> SRR1058013     5  0.6420     0.3731 0.000 0.324 0.000 0.192 0.484
#> SRR1058014     5  0.2654     0.7506 0.000 0.048 0.000 0.064 0.888
#> SRR1058015     5  0.4964     0.6818 0.000 0.156 0.000 0.132 0.712
#> SRR1058016     2  0.6374    -0.1354 0.000 0.468 0.000 0.172 0.360
#> SRR1058017     2  0.6454    -0.0783 0.000 0.488 0.004 0.168 0.340
#> SRR1058018     5  0.2171     0.7488 0.000 0.024 0.000 0.064 0.912
#> SRR1058019     5  0.5904     0.5983 0.000 0.196 0.000 0.204 0.600
#> SRR1058020     5  0.6166     0.5352 0.000 0.272 0.000 0.180 0.548
#> SRR1058021     5  0.1502     0.7483 0.000 0.004 0.000 0.056 0.940
#> SRR1058022     5  0.6102     0.5668 0.000 0.232 0.000 0.200 0.568
#> SRR1058023     5  0.2790     0.7505 0.000 0.052 0.000 0.068 0.880
#> SRR1058024     5  0.5379     0.6648 0.000 0.164 0.000 0.168 0.668
#> SRR1058025     5  0.6782     0.2017 0.000 0.372 0.004 0.224 0.400
#> SRR1058026     2  0.5699    -0.1937 0.000 0.476 0.452 0.068 0.004
#> SRR1058027     3  0.5773     0.1798 0.000 0.396 0.512 0.092 0.000
#> SRR1058028     3  0.5550     0.2141 0.000 0.400 0.528 0.072 0.000
#> SRR1058029     3  0.3090     0.6645 0.000 0.104 0.856 0.040 0.000
#> SRR1058030     3  0.3875     0.6175 0.000 0.160 0.792 0.048 0.000
#> SRR1058031     3  0.4674     0.5314 0.000 0.232 0.708 0.060 0.000
#> SRR1058032     4  0.5454     0.6858 0.404 0.000 0.064 0.532 0.000
#> SRR1058033     4  0.6243     0.8392 0.284 0.000 0.184 0.532 0.000
#> SRR1058034     4  0.6304     0.7711 0.220 0.000 0.248 0.532 0.000
#> SRR1058035     1  0.0865     0.9674 0.972 0.004 0.000 0.024 0.000
#> SRR1058036     1  0.0404     0.9801 0.988 0.000 0.000 0.012 0.000
#> SRR1058037     1  0.0000     0.9811 1.000 0.000 0.000 0.000 0.000
#> SRR1058038     1  0.0162     0.9810 0.996 0.000 0.000 0.004 0.000
#> SRR1058039     1  0.0510     0.9760 0.984 0.000 0.000 0.016 0.000
#> SRR1058040     1  0.0324     0.9804 0.992 0.004 0.000 0.004 0.000
#> SRR1058041     1  0.0324     0.9812 0.992 0.004 0.000 0.004 0.000
#> SRR1058042     1  0.0162     0.9813 0.996 0.004 0.000 0.000 0.000
#> SRR1058043     1  0.0807     0.9659 0.976 0.012 0.000 0.012 0.000
#> SRR1058044     1  0.1386     0.9394 0.952 0.000 0.016 0.032 0.000
#> SRR1058045     1  0.0451     0.9803 0.988 0.004 0.000 0.008 0.000
#> SRR1058046     1  0.0290     0.9808 0.992 0.000 0.000 0.008 0.000
#> SRR1058047     3  0.4291    -0.0826 0.000 0.000 0.536 0.464 0.000
#> SRR1058048     3  0.0000     0.7336 0.000 0.000 1.000 0.000 0.000
#> SRR1058049     3  0.0000     0.7336 0.000 0.000 1.000 0.000 0.000
#> SRR1058050     3  0.0000     0.7336 0.000 0.000 1.000 0.000 0.000
#> SRR1058051     3  0.4210     0.0615 0.000 0.000 0.588 0.412 0.000
#> SRR1058052     3  0.0000     0.7336 0.000 0.000 1.000 0.000 0.000
#> SRR1058053     3  0.0000     0.7336 0.000 0.000 1.000 0.000 0.000
#> SRR1058054     3  0.0000     0.7336 0.000 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR1058003     5  0.3763     0.5916 0.000 0.080 0.000 0.060 0.816 0.044
#> SRR1058004     5  0.4037     0.5510 0.000 0.056 0.000 0.120 0.788 0.036
#> SRR1058006     5  0.4813     0.5305 0.000 0.220 0.000 0.040 0.692 0.048
#> SRR1058005     5  0.5447     0.3467 0.000 0.068 0.000 0.276 0.612 0.044
#> SRR1058007     5  0.5000     0.4651 0.000 0.276 0.000 0.036 0.644 0.044
#> SRR1058008     5  0.1938     0.6329 0.000 0.052 0.000 0.020 0.920 0.008
#> SRR1058009     6  0.7148    -0.1277 0.004 0.356 0.088 0.096 0.024 0.432
#> SRR1058010     6  0.6509     0.2336 0.000 0.260 0.120 0.052 0.020 0.548
#> SRR1058011     2  0.6697     0.2172 0.000 0.460 0.020 0.088 0.068 0.364
#> SRR1058012     6  0.5150     0.4680 0.000 0.052 0.364 0.020 0.000 0.564
#> SRR1058013     2  0.6613     0.1759 0.000 0.408 0.000 0.060 0.384 0.148
#> SRR1058014     5  0.3350     0.6117 0.000 0.124 0.000 0.040 0.824 0.012
#> SRR1058015     5  0.5647     0.2889 0.000 0.348 0.000 0.064 0.544 0.044
#> SRR1058016     2  0.6925     0.3612 0.000 0.404 0.000 0.060 0.268 0.268
#> SRR1058017     2  0.7230     0.3788 0.000 0.384 0.008 0.072 0.228 0.308
#> SRR1058018     5  0.3659     0.5922 0.000 0.180 0.000 0.028 0.780 0.012
#> SRR1058019     2  0.5578     0.1581 0.000 0.520 0.000 0.024 0.376 0.080
#> SRR1058020     2  0.6253     0.1933 0.000 0.448 0.000 0.060 0.396 0.096
#> SRR1058021     5  0.2376     0.6358 0.000 0.096 0.000 0.012 0.884 0.008
#> SRR1058022     2  0.6084     0.1793 0.000 0.500 0.000 0.048 0.352 0.100
#> SRR1058023     5  0.3219     0.6212 0.000 0.168 0.000 0.016 0.808 0.008
#> SRR1058024     5  0.6051     0.0229 0.000 0.388 0.000 0.056 0.476 0.080
#> SRR1058025     2  0.6651     0.3805 0.000 0.476 0.000 0.056 0.208 0.260
#> SRR1058026     6  0.5335     0.4841 0.008 0.040 0.332 0.032 0.000 0.588
#> SRR1058027     6  0.5048     0.4192 0.000 0.024 0.388 0.036 0.000 0.552
#> SRR1058028     6  0.4635     0.3277 0.000 0.020 0.444 0.012 0.000 0.524
#> SRR1058029     3  0.3152     0.6338 0.000 0.004 0.792 0.008 0.000 0.196
#> SRR1058030     3  0.4361     0.5051 0.000 0.040 0.716 0.020 0.000 0.224
#> SRR1058031     3  0.4113     0.3391 0.000 0.016 0.668 0.008 0.000 0.308
#> SRR1058032     4  0.4044     0.6935 0.180 0.000 0.076 0.744 0.000 0.000
#> SRR1058033     4  0.4125     0.7484 0.128 0.000 0.124 0.748 0.000 0.000
#> SRR1058034     4  0.4162     0.7510 0.120 0.000 0.136 0.744 0.000 0.000
#> SRR1058035     1  0.2101     0.9253 0.908 0.008 0.004 0.072 0.000 0.008
#> SRR1058036     1  0.0603     0.9673 0.980 0.004 0.000 0.016 0.000 0.000
#> SRR1058037     1  0.1194     0.9606 0.956 0.004 0.000 0.032 0.000 0.008
#> SRR1058038     1  0.0260     0.9669 0.992 0.000 0.000 0.008 0.000 0.000
#> SRR1058039     1  0.1053     0.9628 0.964 0.012 0.000 0.020 0.000 0.004
#> SRR1058040     1  0.1180     0.9628 0.960 0.012 0.000 0.016 0.000 0.012
#> SRR1058041     1  0.0146     0.9673 0.996 0.000 0.000 0.004 0.000 0.000
#> SRR1058042     1  0.0363     0.9679 0.988 0.000 0.000 0.012 0.000 0.000
#> SRR1058043     1  0.0964     0.9595 0.968 0.004 0.000 0.012 0.000 0.016
#> SRR1058044     1  0.3176     0.8686 0.856 0.012 0.056 0.068 0.000 0.008
#> SRR1058045     1  0.0146     0.9670 0.996 0.000 0.000 0.000 0.000 0.004
#> SRR1058046     1  0.0405     0.9679 0.988 0.000 0.000 0.008 0.000 0.004
#> SRR1058047     4  0.3782     0.5751 0.000 0.000 0.412 0.588 0.000 0.000
#> SRR1058048     3  0.0000     0.8502 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1058049     3  0.0000     0.8502 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1058050     3  0.0000     0.8502 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1058051     4  0.3860     0.4736 0.000 0.000 0.472 0.528 0.000 0.000
#> SRR1058052     3  0.0000     0.8502 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1058053     3  0.0000     0.8502 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1058054     3  0.0000     0.8502 0.000 0.000 1.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-skmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-skmeans-collect-classes

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


CV:pam

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

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

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

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

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

collect_plots(res)

plot of chunk CV-pam-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.571           0.886       0.947          0.104 0.962   0.962
#> 3 3 0.583           0.891       0.956          0.295 0.962   0.961
#> 4 4 0.583           0.868       0.955          0.287 0.963   0.960
#> 5 5 0.562           0.785       0.941          0.226 0.929   0.920
#> 6 6 0.633           0.812       0.950          0.163 0.999   0.999

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

suggest_best_k(res)
#> [1] 5

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette    p1    p2
#> SRR1058003     1   0.529      0.000 0.880 0.120
#> SRR1058004     2   0.634      0.841 0.160 0.840
#> SRR1058006     2   0.000      0.935 0.000 1.000
#> SRR1058005     2   0.634      0.841 0.160 0.840
#> SRR1058007     2   0.000      0.935 0.000 1.000
#> SRR1058008     2   0.855      0.672 0.280 0.720
#> SRR1058009     2   0.000      0.935 0.000 1.000
#> SRR1058010     2   0.000      0.935 0.000 1.000
#> SRR1058011     2   0.000      0.935 0.000 1.000
#> SRR1058012     2   0.000      0.935 0.000 1.000
#> SRR1058013     2   0.000      0.935 0.000 1.000
#> SRR1058014     2   0.000      0.935 0.000 1.000
#> SRR1058015     2   0.000      0.935 0.000 1.000
#> SRR1058016     2   0.000      0.935 0.000 1.000
#> SRR1058017     2   0.000      0.935 0.000 1.000
#> SRR1058018     2   0.000      0.935 0.000 1.000
#> SRR1058019     2   0.000      0.935 0.000 1.000
#> SRR1058020     2   0.000      0.935 0.000 1.000
#> SRR1058021     2   0.634      0.841 0.160 0.840
#> SRR1058022     2   0.000      0.935 0.000 1.000
#> SRR1058023     2   0.634      0.841 0.160 0.840
#> SRR1058024     2   0.000      0.935 0.000 1.000
#> SRR1058025     2   0.000      0.935 0.000 1.000
#> SRR1058026     2   0.000      0.935 0.000 1.000
#> SRR1058027     2   0.000      0.935 0.000 1.000
#> SRR1058028     2   0.000      0.935 0.000 1.000
#> SRR1058029     2   0.000      0.935 0.000 1.000
#> SRR1058030     2   0.000      0.935 0.000 1.000
#> SRR1058031     2   0.000      0.935 0.000 1.000
#> SRR1058032     2   0.634      0.841 0.160 0.840
#> SRR1058033     2   0.634      0.841 0.160 0.840
#> SRR1058034     2   0.634      0.841 0.160 0.840
#> SRR1058035     2   0.000      0.935 0.000 1.000
#> SRR1058036     2   0.634      0.841 0.160 0.840
#> SRR1058037     2   0.634      0.841 0.160 0.840
#> SRR1058038     2   0.634      0.841 0.160 0.840
#> SRR1058039     2   0.000      0.935 0.000 1.000
#> SRR1058040     2   0.000      0.935 0.000 1.000
#> SRR1058041     2   0.625      0.844 0.156 0.844
#> SRR1058042     2   0.634      0.841 0.160 0.840
#> SRR1058043     2   0.529      0.867 0.120 0.880
#> SRR1058044     2   0.000      0.935 0.000 1.000
#> SRR1058045     2   0.634      0.841 0.160 0.840
#> SRR1058046     2   0.634      0.841 0.160 0.840
#> SRR1058047     2   0.000      0.935 0.000 1.000
#> SRR1058048     2   0.000      0.935 0.000 1.000
#> SRR1058049     2   0.000      0.935 0.000 1.000
#> SRR1058050     2   0.000      0.935 0.000 1.000
#> SRR1058051     2   0.000      0.935 0.000 1.000
#> SRR1058052     2   0.000      0.935 0.000 1.000
#> SRR1058053     2   0.000      0.935 0.000 1.000
#> SRR1058054     2   0.000      0.935 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1058003     1   0.000      0.000 1.000 0.000 0.000
#> SRR1058004     2   0.388      0.871 0.152 0.848 0.000
#> SRR1058006     2   0.000      0.950 0.000 1.000 0.000
#> SRR1058005     2   0.388      0.871 0.152 0.848 0.000
#> SRR1058007     2   0.000      0.950 0.000 1.000 0.000
#> SRR1058008     3   0.103      0.000 0.000 0.024 0.976
#> SRR1058009     2   0.000      0.950 0.000 1.000 0.000
#> SRR1058010     2   0.000      0.950 0.000 1.000 0.000
#> SRR1058011     2   0.000      0.950 0.000 1.000 0.000
#> SRR1058012     2   0.000      0.950 0.000 1.000 0.000
#> SRR1058013     2   0.000      0.950 0.000 1.000 0.000
#> SRR1058014     2   0.000      0.950 0.000 1.000 0.000
#> SRR1058015     2   0.000      0.950 0.000 1.000 0.000
#> SRR1058016     2   0.000      0.950 0.000 1.000 0.000
#> SRR1058017     2   0.000      0.950 0.000 1.000 0.000
#> SRR1058018     2   0.000      0.950 0.000 1.000 0.000
#> SRR1058019     2   0.000      0.950 0.000 1.000 0.000
#> SRR1058020     2   0.000      0.950 0.000 1.000 0.000
#> SRR1058021     2   0.487      0.850 0.152 0.824 0.024
#> SRR1058022     2   0.000      0.950 0.000 1.000 0.000
#> SRR1058023     2   0.388      0.871 0.152 0.848 0.000
#> SRR1058024     2   0.000      0.950 0.000 1.000 0.000
#> SRR1058025     2   0.000      0.950 0.000 1.000 0.000
#> SRR1058026     2   0.000      0.950 0.000 1.000 0.000
#> SRR1058027     2   0.000      0.950 0.000 1.000 0.000
#> SRR1058028     2   0.000      0.950 0.000 1.000 0.000
#> SRR1058029     2   0.000      0.950 0.000 1.000 0.000
#> SRR1058030     2   0.000      0.950 0.000 1.000 0.000
#> SRR1058031     2   0.000      0.950 0.000 1.000 0.000
#> SRR1058032     2   0.388      0.871 0.152 0.848 0.000
#> SRR1058033     2   0.388      0.871 0.152 0.848 0.000
#> SRR1058034     2   0.388      0.871 0.152 0.848 0.000
#> SRR1058035     2   0.000      0.950 0.000 1.000 0.000
#> SRR1058036     2   0.388      0.871 0.152 0.848 0.000
#> SRR1058037     2   0.388      0.871 0.152 0.848 0.000
#> SRR1058038     2   0.388      0.871 0.152 0.848 0.000
#> SRR1058039     2   0.000      0.950 0.000 1.000 0.000
#> SRR1058040     2   0.000      0.950 0.000 1.000 0.000
#> SRR1058041     2   0.388      0.871 0.152 0.848 0.000
#> SRR1058042     2   0.388      0.871 0.152 0.848 0.000
#> SRR1058043     2   0.334      0.890 0.120 0.880 0.000
#> SRR1058044     2   0.000      0.950 0.000 1.000 0.000
#> SRR1058045     2   0.388      0.871 0.152 0.848 0.000
#> SRR1058046     2   0.388      0.871 0.152 0.848 0.000
#> SRR1058047     2   0.000      0.950 0.000 1.000 0.000
#> SRR1058048     2   0.000      0.950 0.000 1.000 0.000
#> SRR1058049     2   0.000      0.950 0.000 1.000 0.000
#> SRR1058050     2   0.000      0.950 0.000 1.000 0.000
#> SRR1058051     2   0.000      0.950 0.000 1.000 0.000
#> SRR1058052     2   0.000      0.950 0.000 1.000 0.000
#> SRR1058053     2   0.000      0.950 0.000 1.000 0.000
#> SRR1058054     2   0.000      0.950 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette p1    p2    p3   p4
#> SRR1058003     4   0.317      0.000  0 0.000 0.160 0.84
#> SRR1058004     2   0.327      0.853  0 0.832 0.168 0.00
#> SRR1058006     2   0.000      0.948  0 1.000 0.000 0.00
#> SRR1058005     2   0.327      0.853  0 0.832 0.168 0.00
#> SRR1058007     2   0.000      0.948  0 1.000 0.000 0.00
#> SRR1058008     1   0.000      0.000  1 0.000 0.000 0.00
#> SRR1058009     2   0.000      0.948  0 1.000 0.000 0.00
#> SRR1058010     2   0.000      0.948  0 1.000 0.000 0.00
#> SRR1058011     2   0.000      0.948  0 1.000 0.000 0.00
#> SRR1058012     2   0.000      0.948  0 1.000 0.000 0.00
#> SRR1058013     2   0.000      0.948  0 1.000 0.000 0.00
#> SRR1058014     2   0.000      0.948  0 1.000 0.000 0.00
#> SRR1058015     2   0.000      0.948  0 1.000 0.000 0.00
#> SRR1058016     2   0.000      0.948  0 1.000 0.000 0.00
#> SRR1058017     2   0.000      0.948  0 1.000 0.000 0.00
#> SRR1058018     2   0.000      0.948  0 1.000 0.000 0.00
#> SRR1058019     2   0.000      0.948  0 1.000 0.000 0.00
#> SRR1058020     2   0.000      0.948  0 1.000 0.000 0.00
#> SRR1058021     3   0.317      0.000  0 0.000 0.840 0.16
#> SRR1058022     2   0.000      0.948  0 1.000 0.000 0.00
#> SRR1058023     2   0.327      0.853  0 0.832 0.168 0.00
#> SRR1058024     2   0.000      0.948  0 1.000 0.000 0.00
#> SRR1058025     2   0.000      0.948  0 1.000 0.000 0.00
#> SRR1058026     2   0.000      0.948  0 1.000 0.000 0.00
#> SRR1058027     2   0.000      0.948  0 1.000 0.000 0.00
#> SRR1058028     2   0.000      0.948  0 1.000 0.000 0.00
#> SRR1058029     2   0.000      0.948  0 1.000 0.000 0.00
#> SRR1058030     2   0.000      0.948  0 1.000 0.000 0.00
#> SRR1058031     2   0.000      0.948  0 1.000 0.000 0.00
#> SRR1058032     2   0.327      0.853  0 0.832 0.168 0.00
#> SRR1058033     2   0.327      0.853  0 0.832 0.168 0.00
#> SRR1058034     2   0.327      0.853  0 0.832 0.168 0.00
#> SRR1058035     2   0.000      0.948  0 1.000 0.000 0.00
#> SRR1058036     2   0.327      0.853  0 0.832 0.168 0.00
#> SRR1058037     2   0.327      0.853  0 0.832 0.168 0.00
#> SRR1058038     2   0.327      0.853  0 0.832 0.168 0.00
#> SRR1058039     2   0.000      0.948  0 1.000 0.000 0.00
#> SRR1058040     2   0.000      0.948  0 1.000 0.000 0.00
#> SRR1058041     2   0.327      0.853  0 0.832 0.168 0.00
#> SRR1058042     2   0.327      0.853  0 0.832 0.168 0.00
#> SRR1058043     2   0.281      0.876  0 0.868 0.132 0.00
#> SRR1058044     2   0.000      0.948  0 1.000 0.000 0.00
#> SRR1058045     2   0.327      0.853  0 0.832 0.168 0.00
#> SRR1058046     2   0.327      0.853  0 0.832 0.168 0.00
#> SRR1058047     2   0.000      0.948  0 1.000 0.000 0.00
#> SRR1058048     2   0.000      0.948  0 1.000 0.000 0.00
#> SRR1058049     2   0.000      0.948  0 1.000 0.000 0.00
#> SRR1058050     2   0.000      0.948  0 1.000 0.000 0.00
#> SRR1058051     2   0.000      0.948  0 1.000 0.000 0.00
#> SRR1058052     2   0.000      0.948  0 1.000 0.000 0.00
#> SRR1058053     2   0.000      0.948  0 1.000 0.000 0.00
#> SRR1058054     2   0.000      0.948  0 1.000 0.000 0.00

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette p1    p2 p3 p4    p5
#> SRR1058003     4  0.0000      0.000  0 0.000  0  1 0.000
#> SRR1058004     5  0.4101      0.617  0 0.372  0  0 0.628
#> SRR1058006     2  0.0000      0.908  0 1.000  0  0 0.000
#> SRR1058005     2  0.3074      0.631  0 0.804  0  0 0.196
#> SRR1058007     2  0.0000      0.908  0 1.000  0  0 0.000
#> SRR1058008     1  0.0000      0.000  1 0.000  0  0 0.000
#> SRR1058009     2  0.0000      0.908  0 1.000  0  0 0.000
#> SRR1058010     2  0.0000      0.908  0 1.000  0  0 0.000
#> SRR1058011     2  0.0000      0.908  0 1.000  0  0 0.000
#> SRR1058012     2  0.0000      0.908  0 1.000  0  0 0.000
#> SRR1058013     2  0.0000      0.908  0 1.000  0  0 0.000
#> SRR1058014     2  0.0000      0.908  0 1.000  0  0 0.000
#> SRR1058015     2  0.0000      0.908  0 1.000  0  0 0.000
#> SRR1058016     2  0.0000      0.908  0 1.000  0  0 0.000
#> SRR1058017     2  0.0000      0.908  0 1.000  0  0 0.000
#> SRR1058018     2  0.0000      0.908  0 1.000  0  0 0.000
#> SRR1058019     2  0.0000      0.908  0 1.000  0  0 0.000
#> SRR1058020     2  0.0000      0.908  0 1.000  0  0 0.000
#> SRR1058021     3  0.0000      0.000  0 0.000  1  0 0.000
#> SRR1058022     2  0.0000      0.908  0 1.000  0  0 0.000
#> SRR1058023     5  0.4268      0.610  0 0.444  0  0 0.556
#> SRR1058024     2  0.0000      0.908  0 1.000  0  0 0.000
#> SRR1058025     2  0.0000      0.908  0 1.000  0  0 0.000
#> SRR1058026     2  0.0000      0.908  0 1.000  0  0 0.000
#> SRR1058027     2  0.0000      0.908  0 1.000  0  0 0.000
#> SRR1058028     2  0.0000      0.908  0 1.000  0  0 0.000
#> SRR1058029     2  0.0000      0.908  0 1.000  0  0 0.000
#> SRR1058030     2  0.0000      0.908  0 1.000  0  0 0.000
#> SRR1058031     2  0.0000      0.908  0 1.000  0  0 0.000
#> SRR1058032     2  0.3074      0.631  0 0.804  0  0 0.196
#> SRR1058033     2  0.3074      0.631  0 0.804  0  0 0.196
#> SRR1058034     2  0.3074      0.631  0 0.804  0  0 0.196
#> SRR1058035     2  0.0000      0.908  0 1.000  0  0 0.000
#> SRR1058036     2  0.2966      0.654  0 0.816  0  0 0.184
#> SRR1058037     2  0.2966      0.654  0 0.816  0  0 0.184
#> SRR1058038     2  0.2966      0.654  0 0.816  0  0 0.184
#> SRR1058039     2  0.0000      0.908  0 1.000  0  0 0.000
#> SRR1058040     2  0.0000      0.908  0 1.000  0  0 0.000
#> SRR1058041     2  0.2929      0.662  0 0.820  0  0 0.180
#> SRR1058042     2  0.2966      0.654  0 0.816  0  0 0.184
#> SRR1058043     2  0.2561      0.721  0 0.856  0  0 0.144
#> SRR1058044     2  0.0000      0.908  0 1.000  0  0 0.000
#> SRR1058045     2  0.2966      0.654  0 0.816  0  0 0.184
#> SRR1058046     2  0.2966      0.654  0 0.816  0  0 0.184
#> SRR1058047     2  0.0404      0.894  0 0.988  0  0 0.012
#> SRR1058048     2  0.0000      0.908  0 1.000  0  0 0.000
#> SRR1058049     2  0.0000      0.908  0 1.000  0  0 0.000
#> SRR1058050     2  0.0000      0.908  0 1.000  0  0 0.000
#> SRR1058051     2  0.0404      0.894  0 0.988  0  0 0.012
#> SRR1058052     2  0.0000      0.908  0 1.000  0  0 0.000
#> SRR1058053     2  0.0000      0.908  0 1.000  0  0 0.000
#> SRR1058054     2  0.0000      0.908  0 1.000  0  0 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
#> SRR1058003     4  0.2730      0.000  0 0.000 0.192 0.808  0 0.000
#> SRR1058004     3  0.2730      0.000  0 0.000 0.808 0.192  0 0.000
#> SRR1058006     2  0.0000      0.938  0 1.000 0.000 0.000  0 0.000
#> SRR1058005     2  0.4915      0.645  0 0.692 0.024 0.192  0 0.092
#> SRR1058007     2  0.0000      0.938  0 1.000 0.000 0.000  0 0.000
#> SRR1058008     1  0.0000      0.000  1 0.000 0.000 0.000  0 0.000
#> SRR1058009     2  0.0000      0.938  0 1.000 0.000 0.000  0 0.000
#> SRR1058010     2  0.0000      0.938  0 1.000 0.000 0.000  0 0.000
#> SRR1058011     2  0.0000      0.938  0 1.000 0.000 0.000  0 0.000
#> SRR1058012     2  0.0000      0.938  0 1.000 0.000 0.000  0 0.000
#> SRR1058013     2  0.0000      0.938  0 1.000 0.000 0.000  0 0.000
#> SRR1058014     2  0.0000      0.938  0 1.000 0.000 0.000  0 0.000
#> SRR1058015     2  0.0000      0.938  0 1.000 0.000 0.000  0 0.000
#> SRR1058016     2  0.0000      0.938  0 1.000 0.000 0.000  0 0.000
#> SRR1058017     2  0.0000      0.938  0 1.000 0.000 0.000  0 0.000
#> SRR1058018     2  0.0000      0.938  0 1.000 0.000 0.000  0 0.000
#> SRR1058019     2  0.0000      0.938  0 1.000 0.000 0.000  0 0.000
#> SRR1058020     2  0.0260      0.933  0 0.992 0.000 0.000  0 0.008
#> SRR1058021     5  0.0000      0.000  0 0.000 0.000 0.000  1 0.000
#> SRR1058022     2  0.0000      0.938  0 1.000 0.000 0.000  0 0.000
#> SRR1058023     6  0.1957      0.000  0 0.112 0.000 0.000  0 0.888
#> SRR1058024     2  0.0363      0.930  0 0.988 0.000 0.000  0 0.012
#> SRR1058025     2  0.0000      0.938  0 1.000 0.000 0.000  0 0.000
#> SRR1058026     2  0.0000      0.938  0 1.000 0.000 0.000  0 0.000
#> SRR1058027     2  0.0000      0.938  0 1.000 0.000 0.000  0 0.000
#> SRR1058028     2  0.0000      0.938  0 1.000 0.000 0.000  0 0.000
#> SRR1058029     2  0.0000      0.938  0 1.000 0.000 0.000  0 0.000
#> SRR1058030     2  0.0000      0.938  0 1.000 0.000 0.000  0 0.000
#> SRR1058031     2  0.0000      0.938  0 1.000 0.000 0.000  0 0.000
#> SRR1058032     2  0.3333      0.778  0 0.784 0.024 0.192  0 0.000
#> SRR1058033     2  0.3333      0.778  0 0.784 0.024 0.192  0 0.000
#> SRR1058034     2  0.3333      0.778  0 0.784 0.024 0.192  0 0.000
#> SRR1058035     2  0.0000      0.938  0 1.000 0.000 0.000  0 0.000
#> SRR1058036     2  0.2730      0.801  0 0.808 0.000 0.192  0 0.000
#> SRR1058037     2  0.2730      0.801  0 0.808 0.000 0.192  0 0.000
#> SRR1058038     2  0.2730      0.801  0 0.808 0.000 0.192  0 0.000
#> SRR1058039     2  0.0000      0.938  0 1.000 0.000 0.000  0 0.000
#> SRR1058040     2  0.0000      0.938  0 1.000 0.000 0.000  0 0.000
#> SRR1058041     2  0.2597      0.815  0 0.824 0.000 0.176  0 0.000
#> SRR1058042     2  0.2730      0.801  0 0.808 0.000 0.192  0 0.000
#> SRR1058043     2  0.2219      0.846  0 0.864 0.000 0.136  0 0.000
#> SRR1058044     2  0.0000      0.938  0 1.000 0.000 0.000  0 0.000
#> SRR1058045     2  0.2730      0.801  0 0.808 0.000 0.192  0 0.000
#> SRR1058046     2  0.2730      0.801  0 0.808 0.000 0.192  0 0.000
#> SRR1058047     2  0.0632      0.922  0 0.976 0.024 0.000  0 0.000
#> SRR1058048     2  0.0000      0.938  0 1.000 0.000 0.000  0 0.000
#> SRR1058049     2  0.0000      0.938  0 1.000 0.000 0.000  0 0.000
#> SRR1058050     2  0.0000      0.938  0 1.000 0.000 0.000  0 0.000
#> SRR1058051     2  0.0632      0.922  0 0.976 0.024 0.000  0 0.000
#> SRR1058052     2  0.0000      0.938  0 1.000 0.000 0.000  0 0.000
#> SRR1058053     2  0.0000      0.938  0 1.000 0.000 0.000  0 0.000
#> SRR1058054     2  0.0000      0.938  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-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 18325 rows and 52 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#>   Subgroups are detected by 'mclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 6.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk CV-mclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.463           0.882       0.905         0.4639 0.497   0.497
#> 3 3 0.575           0.731       0.857         0.3429 0.618   0.385
#> 4 4 0.801           0.930       0.931         0.1826 0.778   0.473
#> 5 5 0.825           0.870       0.921         0.0780 0.934   0.743
#> 6 6 0.898           0.890       0.938         0.0242 0.975   0.876

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

suggest_best_k(res)
#> [1] 6

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette    p1    p2
#> SRR1058003     2   0.689      0.820 0.184 0.816
#> SRR1058004     2   0.689      0.820 0.184 0.816
#> SRR1058006     2   0.000      0.954 0.000 1.000
#> SRR1058005     2   0.689      0.820 0.184 0.816
#> SRR1058007     2   0.000      0.954 0.000 1.000
#> SRR1058008     2   0.574      0.861 0.136 0.864
#> SRR1058009     2   0.000      0.954 0.000 1.000
#> SRR1058010     2   0.000      0.954 0.000 1.000
#> SRR1058011     2   0.000      0.954 0.000 1.000
#> SRR1058012     2   0.000      0.954 0.000 1.000
#> SRR1058013     2   0.000      0.954 0.000 1.000
#> SRR1058014     2   0.343      0.918 0.064 0.936
#> SRR1058015     2   0.343      0.918 0.064 0.936
#> SRR1058016     2   0.000      0.954 0.000 1.000
#> SRR1058017     2   0.000      0.954 0.000 1.000
#> SRR1058018     2   0.388      0.908 0.076 0.924
#> SRR1058019     2   0.000      0.954 0.000 1.000
#> SRR1058020     2   0.000      0.954 0.000 1.000
#> SRR1058021     2   0.518      0.870 0.116 0.884
#> SRR1058022     2   0.000      0.954 0.000 1.000
#> SRR1058023     2   0.373      0.912 0.072 0.928
#> SRR1058024     2   0.224      0.935 0.036 0.964
#> SRR1058025     2   0.000      0.954 0.000 1.000
#> SRR1058026     2   0.000      0.954 0.000 1.000
#> SRR1058027     2   0.000      0.954 0.000 1.000
#> SRR1058028     2   0.000      0.954 0.000 1.000
#> SRR1058029     2   0.000      0.954 0.000 1.000
#> SRR1058030     2   0.000      0.954 0.000 1.000
#> SRR1058031     2   0.000      0.954 0.000 1.000
#> SRR1058032     1   0.653      0.813 0.832 0.168
#> SRR1058033     1   0.653      0.813 0.832 0.168
#> SRR1058034     1   0.653      0.813 0.832 0.168
#> SRR1058035     1   0.373      0.870 0.928 0.072
#> SRR1058036     1   0.373      0.870 0.928 0.072
#> SRR1058037     1   0.373      0.870 0.928 0.072
#> SRR1058038     1   0.373      0.870 0.928 0.072
#> SRR1058039     1   0.373      0.870 0.928 0.072
#> SRR1058040     1   0.373      0.870 0.928 0.072
#> SRR1058041     1   0.373      0.870 0.928 0.072
#> SRR1058042     1   0.373      0.870 0.928 0.072
#> SRR1058043     1   0.373      0.870 0.928 0.072
#> SRR1058044     1   0.373      0.870 0.928 0.072
#> SRR1058045     1   0.373      0.870 0.928 0.072
#> SRR1058046     1   0.373      0.870 0.928 0.072
#> SRR1058047     1   0.662      0.811 0.828 0.172
#> SRR1058048     1   0.932      0.742 0.652 0.348
#> SRR1058049     1   0.936      0.739 0.648 0.352
#> SRR1058050     1   0.936      0.739 0.648 0.352
#> SRR1058051     1   0.662      0.811 0.828 0.172
#> SRR1058052     1   0.936      0.739 0.648 0.352
#> SRR1058053     1   0.936      0.739 0.648 0.352
#> SRR1058054     1   0.936      0.739 0.648 0.352

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1058003     3  0.0475     0.5974 0.004 0.004 0.992
#> SRR1058004     3  0.0475     0.5974 0.004 0.004 0.992
#> SRR1058006     3  0.6291     0.2438 0.000 0.468 0.532
#> SRR1058005     3  0.0475     0.5974 0.004 0.004 0.992
#> SRR1058007     2  0.4178     0.7045 0.000 0.828 0.172
#> SRR1058008     3  0.5070     0.5934 0.004 0.224 0.772
#> SRR1058009     2  0.1636     0.8513 0.020 0.964 0.016
#> SRR1058010     2  0.1129     0.8484 0.004 0.976 0.020
#> SRR1058011     2  0.0747     0.8476 0.000 0.984 0.016
#> SRR1058012     2  0.1411     0.8504 0.036 0.964 0.000
#> SRR1058013     2  0.2066     0.8318 0.000 0.940 0.060
#> SRR1058014     3  0.6081     0.5023 0.004 0.344 0.652
#> SRR1058015     2  0.4293     0.7125 0.004 0.832 0.164
#> SRR1058016     2  0.1031     0.8464 0.000 0.976 0.024
#> SRR1058017     2  0.1163     0.8454 0.000 0.972 0.028
#> SRR1058018     3  0.6081     0.5044 0.004 0.344 0.652
#> SRR1058019     2  0.1964     0.8342 0.000 0.944 0.056
#> SRR1058020     2  0.2066     0.8318 0.000 0.940 0.060
#> SRR1058021     3  0.5831     0.5588 0.008 0.284 0.708
#> SRR1058022     2  0.2066     0.8318 0.000 0.940 0.060
#> SRR1058023     3  0.6033     0.5138 0.004 0.336 0.660
#> SRR1058024     2  0.2537     0.8187 0.000 0.920 0.080
#> SRR1058025     2  0.1964     0.8342 0.000 0.944 0.056
#> SRR1058026     2  0.1289     0.8507 0.032 0.968 0.000
#> SRR1058027     2  0.1411     0.8504 0.036 0.964 0.000
#> SRR1058028     2  0.1411     0.8504 0.036 0.964 0.000
#> SRR1058029     2  0.2066     0.8388 0.060 0.940 0.000
#> SRR1058030     2  0.1643     0.8473 0.044 0.956 0.000
#> SRR1058031     2  0.1411     0.8504 0.036 0.964 0.000
#> SRR1058032     3  0.6683     0.0383 0.492 0.008 0.500
#> SRR1058033     3  0.6683     0.0383 0.492 0.008 0.500
#> SRR1058034     3  0.6683     0.0383 0.492 0.008 0.500
#> SRR1058035     1  0.0000     0.9962 1.000 0.000 0.000
#> SRR1058036     1  0.0237     0.9973 0.996 0.000 0.004
#> SRR1058037     1  0.0237     0.9973 0.996 0.000 0.004
#> SRR1058038     1  0.0237     0.9973 0.996 0.000 0.004
#> SRR1058039     1  0.0000     0.9962 1.000 0.000 0.000
#> SRR1058040     1  0.0237     0.9973 0.996 0.000 0.004
#> SRR1058041     1  0.0000     0.9962 1.000 0.000 0.000
#> SRR1058042     1  0.0000     0.9962 1.000 0.000 0.000
#> SRR1058043     1  0.0237     0.9973 0.996 0.000 0.004
#> SRR1058044     1  0.0237     0.9928 0.996 0.000 0.004
#> SRR1058045     1  0.0237     0.9973 0.996 0.000 0.004
#> SRR1058046     1  0.0237     0.9973 0.996 0.000 0.004
#> SRR1058047     3  0.9463     0.3615 0.244 0.256 0.500
#> SRR1058048     2  0.6287     0.6411 0.272 0.704 0.024
#> SRR1058049     2  0.6027     0.6488 0.272 0.712 0.016
#> SRR1058050     2  0.5884     0.6516 0.272 0.716 0.012
#> SRR1058051     3  0.9463     0.3615 0.244 0.256 0.500
#> SRR1058052     2  0.5327     0.6588 0.272 0.728 0.000
#> SRR1058053     2  0.5327     0.6588 0.272 0.728 0.000
#> SRR1058054     2  0.5327     0.6588 0.272 0.728 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1058003     4  0.0188      0.985 0.000 0.000 0.004 0.996
#> SRR1058004     4  0.0188      0.985 0.000 0.000 0.004 0.996
#> SRR1058006     2  0.0921      0.925 0.000 0.972 0.028 0.000
#> SRR1058005     4  0.0188      0.985 0.000 0.000 0.004 0.996
#> SRR1058007     2  0.1576      0.931 0.000 0.948 0.048 0.004
#> SRR1058008     2  0.3749      0.802 0.000 0.840 0.032 0.128
#> SRR1058009     2  0.3311      0.876 0.000 0.828 0.172 0.000
#> SRR1058010     2  0.2973      0.903 0.000 0.856 0.144 0.000
#> SRR1058011     2  0.3024      0.902 0.000 0.852 0.148 0.000
#> SRR1058012     3  0.2412      0.876 0.008 0.084 0.908 0.000
#> SRR1058013     2  0.2081      0.933 0.000 0.916 0.084 0.000
#> SRR1058014     2  0.1004      0.912 0.000 0.972 0.004 0.024
#> SRR1058015     2  0.1584      0.908 0.000 0.952 0.036 0.012
#> SRR1058016     2  0.2216      0.932 0.000 0.908 0.092 0.000
#> SRR1058017     2  0.2081      0.934 0.000 0.916 0.084 0.000
#> SRR1058018     2  0.1610      0.900 0.000 0.952 0.032 0.016
#> SRR1058019     2  0.2281      0.932 0.000 0.904 0.096 0.000
#> SRR1058020     2  0.2469      0.926 0.000 0.892 0.108 0.000
#> SRR1058021     2  0.2313      0.882 0.000 0.924 0.044 0.032
#> SRR1058022     2  0.2149      0.932 0.000 0.912 0.088 0.000
#> SRR1058023     2  0.1913      0.893 0.000 0.940 0.040 0.020
#> SRR1058024     2  0.2918      0.930 0.000 0.876 0.116 0.008
#> SRR1058025     2  0.2011      0.934 0.000 0.920 0.080 0.000
#> SRR1058026     3  0.2216      0.871 0.000 0.092 0.908 0.000
#> SRR1058027     3  0.2149      0.873 0.000 0.088 0.912 0.000
#> SRR1058028     3  0.2401      0.876 0.004 0.092 0.904 0.000
#> SRR1058029     3  0.1716      0.876 0.000 0.064 0.936 0.000
#> SRR1058030     3  0.2149      0.873 0.000 0.088 0.912 0.000
#> SRR1058031     3  0.2125      0.877 0.004 0.076 0.920 0.000
#> SRR1058032     4  0.0524      0.985 0.008 0.000 0.004 0.988
#> SRR1058033     4  0.0524      0.985 0.008 0.000 0.004 0.988
#> SRR1058034     4  0.0524      0.985 0.008 0.000 0.004 0.988
#> SRR1058035     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1058036     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1058037     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1058038     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1058039     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1058040     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1058041     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1058042     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1058043     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1058044     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1058045     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1058046     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1058047     4  0.1211      0.972 0.000 0.000 0.040 0.960
#> SRR1058048     3  0.3219      0.847 0.164 0.000 0.836 0.000
#> SRR1058049     3  0.3219      0.847 0.164 0.000 0.836 0.000
#> SRR1058050     3  0.3123      0.853 0.156 0.000 0.844 0.000
#> SRR1058051     4  0.1637      0.959 0.000 0.000 0.060 0.940
#> SRR1058052     3  0.3024      0.858 0.148 0.000 0.852 0.000
#> SRR1058053     3  0.3123      0.853 0.156 0.000 0.844 0.000
#> SRR1058054     3  0.2973      0.859 0.144 0.000 0.856 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
#> SRR1058003     4  0.0865      0.952 0.000 0.000 0.004 0.972 0.024
#> SRR1058004     4  0.0865      0.952 0.000 0.000 0.004 0.972 0.024
#> SRR1058006     5  0.4210      0.537 0.000 0.412 0.000 0.000 0.588
#> SRR1058005     4  0.0865      0.952 0.000 0.000 0.004 0.972 0.024
#> SRR1058007     5  0.4440      0.418 0.000 0.468 0.004 0.000 0.528
#> SRR1058008     5  0.2408      0.747 0.000 0.092 0.000 0.016 0.892
#> SRR1058009     2  0.3013      0.765 0.000 0.832 0.160 0.000 0.008
#> SRR1058010     2  0.3794      0.761 0.000 0.800 0.152 0.000 0.048
#> SRR1058011     2  0.2439      0.811 0.000 0.876 0.120 0.000 0.004
#> SRR1058012     3  0.2516      0.892 0.000 0.140 0.860 0.000 0.000
#> SRR1058013     2  0.1768      0.841 0.000 0.924 0.004 0.000 0.072
#> SRR1058014     5  0.2605      0.750 0.000 0.148 0.000 0.000 0.852
#> SRR1058015     5  0.4294      0.293 0.000 0.468 0.000 0.000 0.532
#> SRR1058016     2  0.0579      0.868 0.000 0.984 0.008 0.000 0.008
#> SRR1058017     2  0.0162      0.867 0.000 0.996 0.000 0.000 0.004
#> SRR1058018     5  0.1908      0.750 0.000 0.092 0.000 0.000 0.908
#> SRR1058019     2  0.1205      0.861 0.000 0.956 0.004 0.000 0.040
#> SRR1058020     2  0.2249      0.826 0.000 0.896 0.008 0.000 0.096
#> SRR1058021     5  0.0162      0.727 0.000 0.004 0.000 0.000 0.996
#> SRR1058022     2  0.2017      0.839 0.000 0.912 0.008 0.000 0.080
#> SRR1058023     5  0.0963      0.742 0.000 0.036 0.000 0.000 0.964
#> SRR1058024     2  0.2719      0.785 0.000 0.852 0.004 0.000 0.144
#> SRR1058025     2  0.1485      0.868 0.000 0.948 0.032 0.000 0.020
#> SRR1058026     3  0.2773      0.867 0.000 0.164 0.836 0.000 0.000
#> SRR1058027     3  0.2471      0.895 0.000 0.136 0.864 0.000 0.000
#> SRR1058028     3  0.2471      0.895 0.000 0.136 0.864 0.000 0.000
#> SRR1058029     3  0.1544      0.909 0.000 0.068 0.932 0.000 0.000
#> SRR1058030     3  0.2471      0.896 0.000 0.136 0.864 0.000 0.000
#> SRR1058031     3  0.2280      0.902 0.000 0.120 0.880 0.000 0.000
#> SRR1058032     4  0.0579      0.956 0.008 0.000 0.008 0.984 0.000
#> SRR1058033     4  0.0579      0.956 0.008 0.000 0.008 0.984 0.000
#> SRR1058034     4  0.0693      0.955 0.008 0.000 0.012 0.980 0.000
#> SRR1058035     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1058036     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1058037     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1058038     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1058039     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1058040     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1058041     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1058042     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1058043     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1058044     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1058045     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1058046     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1058047     4  0.1197      0.938 0.000 0.000 0.048 0.952 0.000
#> SRR1058048     3  0.0510      0.903 0.016 0.000 0.984 0.000 0.000
#> SRR1058049     3  0.0404      0.905 0.012 0.000 0.988 0.000 0.000
#> SRR1058050     3  0.0404      0.905 0.012 0.000 0.988 0.000 0.000
#> SRR1058051     4  0.2732      0.839 0.000 0.000 0.160 0.840 0.000
#> SRR1058052     3  0.0404      0.905 0.012 0.000 0.988 0.000 0.000
#> SRR1058053     3  0.0404      0.905 0.012 0.000 0.988 0.000 0.000
#> SRR1058054     3  0.0290      0.905 0.008 0.000 0.992 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette p1    p2    p3    p4    p5    p6
#> SRR1058003     4  0.1663      1.000  0 0.000 0.088 0.912 0.000 0.000
#> SRR1058004     4  0.1663      1.000  0 0.000 0.088 0.912 0.000 0.000
#> SRR1058006     5  0.3804      0.434  0 0.424 0.000 0.000 0.576 0.000
#> SRR1058005     4  0.1663      1.000  0 0.000 0.088 0.912 0.000 0.000
#> SRR1058007     5  0.3868      0.262  0 0.492 0.000 0.000 0.508 0.000
#> SRR1058008     5  0.0717      0.728  0 0.000 0.008 0.016 0.976 0.000
#> SRR1058009     2  0.3133      0.690  0 0.780 0.000 0.000 0.008 0.212
#> SRR1058010     2  0.3247      0.766  0 0.808 0.000 0.000 0.036 0.156
#> SRR1058011     2  0.2070      0.825  0 0.892 0.000 0.000 0.008 0.100
#> SRR1058012     6  0.0146      0.948  0 0.004 0.000 0.000 0.000 0.996
#> SRR1058013     2  0.1141      0.858  0 0.948 0.000 0.000 0.052 0.000
#> SRR1058014     5  0.1910      0.761  0 0.108 0.000 0.000 0.892 0.000
#> SRR1058015     2  0.3647      0.349  0 0.640 0.000 0.000 0.360 0.000
#> SRR1058016     2  0.0146      0.877  0 0.996 0.000 0.000 0.000 0.004
#> SRR1058017     2  0.0146      0.877  0 0.996 0.000 0.000 0.000 0.004
#> SRR1058018     5  0.2260      0.748  0 0.140 0.000 0.000 0.860 0.000
#> SRR1058019     2  0.0146      0.877  0 0.996 0.000 0.000 0.004 0.000
#> SRR1058020     2  0.0790      0.871  0 0.968 0.000 0.000 0.032 0.000
#> SRR1058021     5  0.0260      0.735  0 0.000 0.000 0.008 0.992 0.000
#> SRR1058022     2  0.0937      0.866  0 0.960 0.000 0.000 0.040 0.000
#> SRR1058023     5  0.0790      0.753  0 0.032 0.000 0.000 0.968 0.000
#> SRR1058024     2  0.1075      0.866  0 0.952 0.000 0.000 0.048 0.000
#> SRR1058025     2  0.0603      0.878  0 0.980 0.000 0.000 0.004 0.016
#> SRR1058026     6  0.0458      0.940  0 0.016 0.000 0.000 0.000 0.984
#> SRR1058027     6  0.0146      0.948  0 0.004 0.000 0.000 0.000 0.996
#> SRR1058028     6  0.0000      0.948  0 0.000 0.000 0.000 0.000 1.000
#> SRR1058029     6  0.0000      0.948  0 0.000 0.000 0.000 0.000 1.000
#> SRR1058030     6  0.0260      0.946  0 0.008 0.000 0.000 0.000 0.992
#> SRR1058031     6  0.0146      0.948  0 0.004 0.000 0.000 0.000 0.996
#> SRR1058032     3  0.0146      0.997  0 0.000 0.996 0.004 0.000 0.000
#> SRR1058033     3  0.0146      0.997  0 0.000 0.996 0.004 0.000 0.000
#> SRR1058034     3  0.0146      0.997  0 0.000 0.996 0.004 0.000 0.000
#> SRR1058035     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1058036     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1058037     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1058038     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1058039     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1058040     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1058041     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1058042     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1058043     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1058044     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1058045     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1058046     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR1058047     3  0.0000      0.996  0 0.000 1.000 0.000 0.000 0.000
#> SRR1058048     6  0.2062      0.943  0 0.000 0.004 0.088 0.008 0.900
#> SRR1058049     6  0.2062      0.943  0 0.000 0.004 0.088 0.008 0.900
#> SRR1058050     6  0.2062      0.943  0 0.000 0.004 0.088 0.008 0.900
#> SRR1058051     3  0.0000      0.996  0 0.000 1.000 0.000 0.000 0.000
#> SRR1058052     6  0.2062      0.943  0 0.000 0.004 0.088 0.008 0.900
#> SRR1058053     6  0.2062      0.943  0 0.000 0.004 0.088 0.008 0.900
#> SRR1058054     6  0.2062      0.943  0 0.000 0.004 0.088 0.008 0.900

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

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

collect_plots(res)

plot of chunk CV-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.971       0.988         0.5095 0.490   0.490
#> 3 3 0.800           0.826       0.883         0.2282 0.889   0.777
#> 4 4 0.719           0.908       0.879         0.1451 0.900   0.747
#> 5 5 0.801           0.695       0.839         0.1064 0.923   0.738
#> 6 6 0.776           0.626       0.772         0.0437 0.937   0.722

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
#> SRR1058003     2  0.0000      1.000 0.000 1.000
#> SRR1058004     2  0.0000      1.000 0.000 1.000
#> SRR1058006     2  0.0000      1.000 0.000 1.000
#> SRR1058005     2  0.0000      1.000 0.000 1.000
#> SRR1058007     2  0.0000      1.000 0.000 1.000
#> SRR1058008     2  0.0000      1.000 0.000 1.000
#> SRR1058009     2  0.0000      1.000 0.000 1.000
#> SRR1058010     2  0.0000      1.000 0.000 1.000
#> SRR1058011     2  0.0000      1.000 0.000 1.000
#> SRR1058012     2  0.0000      1.000 0.000 1.000
#> SRR1058013     2  0.0000      1.000 0.000 1.000
#> SRR1058014     2  0.0000      1.000 0.000 1.000
#> SRR1058015     2  0.0000      1.000 0.000 1.000
#> SRR1058016     2  0.0000      1.000 0.000 1.000
#> SRR1058017     2  0.0000      1.000 0.000 1.000
#> SRR1058018     2  0.0000      1.000 0.000 1.000
#> SRR1058019     2  0.0000      1.000 0.000 1.000
#> SRR1058020     2  0.0000      1.000 0.000 1.000
#> SRR1058021     2  0.0000      1.000 0.000 1.000
#> SRR1058022     2  0.0000      1.000 0.000 1.000
#> SRR1058023     2  0.0000      1.000 0.000 1.000
#> SRR1058024     2  0.0000      1.000 0.000 1.000
#> SRR1058025     2  0.0000      1.000 0.000 1.000
#> SRR1058026     2  0.0000      1.000 0.000 1.000
#> SRR1058027     2  0.0938      0.988 0.012 0.988
#> SRR1058028     2  0.0000      1.000 0.000 1.000
#> SRR1058029     1  0.0938      0.965 0.988 0.012
#> SRR1058030     1  0.8386      0.645 0.732 0.268
#> SRR1058031     1  0.9286      0.495 0.656 0.344
#> SRR1058032     1  0.0000      0.975 1.000 0.000
#> SRR1058033     1  0.0000      0.975 1.000 0.000
#> SRR1058034     1  0.0000      0.975 1.000 0.000
#> SRR1058035     1  0.0000      0.975 1.000 0.000
#> SRR1058036     1  0.0000      0.975 1.000 0.000
#> SRR1058037     1  0.0000      0.975 1.000 0.000
#> SRR1058038     1  0.0000      0.975 1.000 0.000
#> SRR1058039     1  0.0000      0.975 1.000 0.000
#> SRR1058040     1  0.0000      0.975 1.000 0.000
#> SRR1058041     1  0.0000      0.975 1.000 0.000
#> SRR1058042     1  0.0000      0.975 1.000 0.000
#> SRR1058043     1  0.0000      0.975 1.000 0.000
#> SRR1058044     1  0.0000      0.975 1.000 0.000
#> SRR1058045     1  0.0000      0.975 1.000 0.000
#> SRR1058046     1  0.0000      0.975 1.000 0.000
#> SRR1058047     1  0.0000      0.975 1.000 0.000
#> SRR1058048     1  0.0000      0.975 1.000 0.000
#> SRR1058049     1  0.0000      0.975 1.000 0.000
#> SRR1058050     1  0.0000      0.975 1.000 0.000
#> SRR1058051     1  0.0000      0.975 1.000 0.000
#> SRR1058052     1  0.0000      0.975 1.000 0.000
#> SRR1058053     1  0.0000      0.975 1.000 0.000
#> SRR1058054     1  0.0000      0.975 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1058003     2  0.2066      0.943 0.000 0.940 0.060
#> SRR1058004     2  0.4469      0.840 0.076 0.864 0.060
#> SRR1058006     2  0.0892      0.960 0.000 0.980 0.020
#> SRR1058005     2  0.4628      0.822 0.088 0.856 0.056
#> SRR1058007     2  0.1031      0.959 0.000 0.976 0.024
#> SRR1058008     2  0.1289      0.956 0.000 0.968 0.032
#> SRR1058009     2  0.0892      0.960 0.000 0.980 0.020
#> SRR1058010     2  0.1031      0.959 0.000 0.976 0.024
#> SRR1058011     2  0.0424      0.960 0.000 0.992 0.008
#> SRR1058012     2  0.1031      0.961 0.000 0.976 0.024
#> SRR1058013     2  0.1411      0.956 0.000 0.964 0.036
#> SRR1058014     2  0.0592      0.960 0.000 0.988 0.012
#> SRR1058015     2  0.1031      0.959 0.000 0.976 0.024
#> SRR1058016     2  0.1753      0.952 0.000 0.952 0.048
#> SRR1058017     2  0.0424      0.960 0.000 0.992 0.008
#> SRR1058018     2  0.0592      0.960 0.000 0.988 0.012
#> SRR1058019     2  0.2261      0.942 0.000 0.932 0.068
#> SRR1058020     2  0.1643      0.954 0.000 0.956 0.044
#> SRR1058021     2  0.0747      0.960 0.000 0.984 0.016
#> SRR1058022     2  0.1860      0.950 0.000 0.948 0.052
#> SRR1058023     2  0.0424      0.960 0.000 0.992 0.008
#> SRR1058024     2  0.1529      0.957 0.000 0.960 0.040
#> SRR1058025     2  0.1860      0.948 0.000 0.948 0.052
#> SRR1058026     3  0.6168      0.475 0.000 0.412 0.588
#> SRR1058027     3  0.7163      0.603 0.040 0.332 0.628
#> SRR1058028     3  0.6994      0.573 0.028 0.360 0.612
#> SRR1058029     3  0.6330      0.601 0.396 0.004 0.600
#> SRR1058030     3  0.6917      0.637 0.368 0.024 0.608
#> SRR1058031     3  0.6908      0.658 0.308 0.036 0.656
#> SRR1058032     1  0.4555      0.777 0.800 0.000 0.200
#> SRR1058033     1  0.0592      0.734 0.988 0.000 0.012
#> SRR1058034     1  0.0592      0.734 0.988 0.000 0.012
#> SRR1058035     1  0.5968      0.805 0.636 0.000 0.364
#> SRR1058036     1  0.5968      0.805 0.636 0.000 0.364
#> SRR1058037     1  0.5968      0.805 0.636 0.000 0.364
#> SRR1058038     1  0.5968      0.805 0.636 0.000 0.364
#> SRR1058039     1  0.5968      0.805 0.636 0.000 0.364
#> SRR1058040     1  0.5968      0.805 0.636 0.000 0.364
#> SRR1058041     1  0.5968      0.805 0.636 0.000 0.364
#> SRR1058042     1  0.5968      0.805 0.636 0.000 0.364
#> SRR1058043     1  0.5968      0.805 0.636 0.000 0.364
#> SRR1058044     1  0.5968      0.805 0.636 0.000 0.364
#> SRR1058045     1  0.5968      0.805 0.636 0.000 0.364
#> SRR1058046     1  0.5968      0.805 0.636 0.000 0.364
#> SRR1058047     1  0.0424      0.726 0.992 0.000 0.008
#> SRR1058048     1  0.0237      0.733 0.996 0.000 0.004
#> SRR1058049     1  0.0000      0.731 1.000 0.000 0.000
#> SRR1058050     1  0.0000      0.731 1.000 0.000 0.000
#> SRR1058051     1  0.0424      0.726 0.992 0.000 0.008
#> SRR1058052     1  0.0237      0.728 0.996 0.000 0.004
#> SRR1058053     1  0.0237      0.728 0.996 0.000 0.004
#> SRR1058054     1  0.2537      0.636 0.920 0.000 0.080

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1058003     2  0.5495      0.828 0.148 0.764 0.036 0.052
#> SRR1058004     2  0.7029      0.534 0.140 0.572 0.284 0.004
#> SRR1058006     2  0.2089      0.884 0.048 0.932 0.000 0.020
#> SRR1058005     2  0.7287      0.410 0.140 0.504 0.352 0.004
#> SRR1058007     2  0.1913      0.887 0.020 0.940 0.000 0.040
#> SRR1058008     2  0.3108      0.873 0.112 0.872 0.000 0.016
#> SRR1058009     2  0.3919      0.867 0.056 0.840 0.000 0.104
#> SRR1058010     2  0.5103      0.854 0.092 0.792 0.020 0.096
#> SRR1058011     2  0.1913      0.888 0.040 0.940 0.000 0.020
#> SRR1058012     2  0.2675      0.885 0.044 0.908 0.000 0.048
#> SRR1058013     2  0.4344      0.865 0.076 0.816 0.000 0.108
#> SRR1058014     2  0.1022      0.888 0.032 0.968 0.000 0.000
#> SRR1058015     2  0.1520      0.887 0.020 0.956 0.000 0.024
#> SRR1058016     2  0.3972      0.869 0.080 0.840 0.000 0.080
#> SRR1058017     2  0.1890      0.888 0.056 0.936 0.000 0.008
#> SRR1058018     2  0.1677      0.889 0.040 0.948 0.000 0.012
#> SRR1058019     2  0.4015      0.868 0.052 0.832 0.000 0.116
#> SRR1058020     2  0.4286      0.850 0.052 0.812 0.000 0.136
#> SRR1058021     2  0.2335      0.884 0.060 0.920 0.000 0.020
#> SRR1058022     2  0.4224      0.873 0.076 0.824 0.000 0.100
#> SRR1058023     2  0.1059      0.886 0.012 0.972 0.000 0.016
#> SRR1058024     2  0.2522      0.880 0.016 0.908 0.000 0.076
#> SRR1058025     2  0.3840      0.870 0.052 0.844 0.000 0.104
#> SRR1058026     4  0.2981      0.881 0.016 0.092 0.004 0.888
#> SRR1058027     4  0.1124      0.921 0.012 0.012 0.004 0.972
#> SRR1058028     4  0.0804      0.920 0.008 0.012 0.000 0.980
#> SRR1058029     4  0.3249      0.858 0.000 0.008 0.140 0.852
#> SRR1058030     4  0.2675      0.895 0.000 0.008 0.100 0.892
#> SRR1058031     4  0.1296      0.922 0.004 0.004 0.028 0.964
#> SRR1058032     3  0.1557      0.950 0.056 0.000 0.944 0.000
#> SRR1058033     3  0.0592      0.963 0.016 0.000 0.984 0.000
#> SRR1058034     3  0.0469      0.962 0.012 0.000 0.988 0.000
#> SRR1058035     1  0.3444      0.999 0.816 0.000 0.184 0.000
#> SRR1058036     1  0.3444      0.999 0.816 0.000 0.184 0.000
#> SRR1058037     1  0.3444      0.999 0.816 0.000 0.184 0.000
#> SRR1058038     1  0.3444      0.999 0.816 0.000 0.184 0.000
#> SRR1058039     1  0.3444      0.999 0.816 0.000 0.184 0.000
#> SRR1058040     1  0.3444      0.999 0.816 0.000 0.184 0.000
#> SRR1058041     1  0.3444      0.999 0.816 0.000 0.184 0.000
#> SRR1058042     1  0.3444      0.999 0.816 0.000 0.184 0.000
#> SRR1058043     1  0.3356      0.988 0.824 0.000 0.176 0.000
#> SRR1058044     1  0.3444      0.999 0.816 0.000 0.184 0.000
#> SRR1058045     1  0.3444      0.999 0.816 0.000 0.184 0.000
#> SRR1058046     1  0.3444      0.999 0.816 0.000 0.184 0.000
#> SRR1058047     3  0.0188      0.957 0.004 0.000 0.996 0.000
#> SRR1058048     3  0.1637      0.955 0.060 0.000 0.940 0.000
#> SRR1058049     3  0.1557      0.957 0.056 0.000 0.944 0.000
#> SRR1058050     3  0.1854      0.958 0.048 0.000 0.940 0.012
#> SRR1058051     3  0.0469      0.949 0.012 0.000 0.988 0.000
#> SRR1058052     3  0.1118      0.966 0.036 0.000 0.964 0.000
#> SRR1058053     3  0.1118      0.966 0.036 0.000 0.964 0.000
#> SRR1058054     3  0.2197      0.941 0.024 0.000 0.928 0.048

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4    p5
#> SRR1058003     5  0.4727    0.36226 0.000 0.260 0.036 0.008 0.696
#> SRR1058004     5  0.5575    0.26236 0.000 0.080 0.320 0.004 0.596
#> SRR1058006     5  0.1357    0.53790 0.000 0.048 0.000 0.004 0.948
#> SRR1058005     5  0.5793    0.20611 0.000 0.072 0.392 0.008 0.528
#> SRR1058007     5  0.4374    0.32251 0.000 0.272 0.000 0.028 0.700
#> SRR1058008     5  0.3732    0.42946 0.000 0.208 0.008 0.008 0.776
#> SRR1058009     2  0.3596    0.57292 0.000 0.776 0.000 0.012 0.212
#> SRR1058010     2  0.4273    0.53817 0.000 0.732 0.008 0.020 0.240
#> SRR1058011     2  0.4251    0.44948 0.000 0.624 0.000 0.004 0.372
#> SRR1058012     5  0.4288    0.14635 0.000 0.384 0.000 0.004 0.612
#> SRR1058013     2  0.4875    0.39550 0.000 0.576 0.004 0.020 0.400
#> SRR1058014     5  0.2976    0.51761 0.000 0.132 0.004 0.012 0.852
#> SRR1058015     5  0.2583    0.50516 0.000 0.132 0.000 0.004 0.864
#> SRR1058016     5  0.4911    0.05121 0.000 0.356 0.004 0.028 0.612
#> SRR1058017     5  0.3890    0.31788 0.000 0.252 0.000 0.012 0.736
#> SRR1058018     5  0.1731    0.52903 0.000 0.060 0.004 0.004 0.932
#> SRR1058019     2  0.5571    0.44292 0.000 0.544 0.004 0.064 0.388
#> SRR1058020     2  0.5281    0.37496 0.000 0.564 0.004 0.044 0.388
#> SRR1058021     5  0.1442    0.53374 0.000 0.032 0.004 0.012 0.952
#> SRR1058022     5  0.5193    0.17337 0.000 0.364 0.000 0.052 0.584
#> SRR1058023     5  0.2424    0.51134 0.000 0.132 0.000 0.000 0.868
#> SRR1058024     5  0.5201    0.00904 0.000 0.424 0.000 0.044 0.532
#> SRR1058025     5  0.5359    0.17138 0.000 0.412 0.000 0.056 0.532
#> SRR1058026     4  0.3868    0.82006 0.000 0.140 0.000 0.800 0.060
#> SRR1058027     4  0.2305    0.89372 0.000 0.092 0.000 0.896 0.012
#> SRR1058028     4  0.2077    0.89554 0.000 0.084 0.000 0.908 0.008
#> SRR1058029     4  0.1892    0.86803 0.000 0.000 0.080 0.916 0.004
#> SRR1058030     4  0.1331    0.89579 0.000 0.008 0.040 0.952 0.000
#> SRR1058031     4  0.0727    0.90425 0.000 0.012 0.004 0.980 0.004
#> SRR1058032     3  0.1197    0.95395 0.048 0.000 0.952 0.000 0.000
#> SRR1058033     3  0.0880    0.96273 0.032 0.000 0.968 0.000 0.000
#> SRR1058034     3  0.0794    0.96219 0.028 0.000 0.972 0.000 0.000
#> SRR1058035     1  0.0000    1.00000 1.000 0.000 0.000 0.000 0.000
#> SRR1058036     1  0.0000    1.00000 1.000 0.000 0.000 0.000 0.000
#> SRR1058037     1  0.0000    1.00000 1.000 0.000 0.000 0.000 0.000
#> SRR1058038     1  0.0000    1.00000 1.000 0.000 0.000 0.000 0.000
#> SRR1058039     1  0.0000    1.00000 1.000 0.000 0.000 0.000 0.000
#> SRR1058040     1  0.0000    1.00000 1.000 0.000 0.000 0.000 0.000
#> SRR1058041     1  0.0000    1.00000 1.000 0.000 0.000 0.000 0.000
#> SRR1058042     1  0.0000    1.00000 1.000 0.000 0.000 0.000 0.000
#> SRR1058043     1  0.0000    1.00000 1.000 0.000 0.000 0.000 0.000
#> SRR1058044     1  0.0000    1.00000 1.000 0.000 0.000 0.000 0.000
#> SRR1058045     1  0.0000    1.00000 1.000 0.000 0.000 0.000 0.000
#> SRR1058046     1  0.0000    1.00000 1.000 0.000 0.000 0.000 0.000
#> SRR1058047     3  0.0510    0.95914 0.016 0.000 0.984 0.000 0.000
#> SRR1058048     3  0.1568    0.96476 0.036 0.000 0.944 0.020 0.000
#> SRR1058049     3  0.2153    0.95499 0.040 0.000 0.916 0.044 0.000
#> SRR1058050     3  0.2511    0.93756 0.028 0.000 0.892 0.080 0.000
#> SRR1058051     3  0.0404    0.95625 0.012 0.000 0.988 0.000 0.000
#> SRR1058052     3  0.1399    0.96557 0.028 0.000 0.952 0.020 0.000
#> SRR1058053     3  0.1750    0.96266 0.028 0.000 0.936 0.036 0.000
#> SRR1058054     3  0.2597    0.92807 0.024 0.000 0.884 0.092 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
#> SRR1058003     5  0.5001     0.3264 0.000 0.040 0.012 0.344 0.596 0.008
#> SRR1058004     5  0.5112     0.3700 0.000 0.000 0.236 0.128 0.632 0.004
#> SRR1058006     5  0.3766     0.3992 0.000 0.212 0.000 0.040 0.748 0.000
#> SRR1058005     5  0.6319     0.2546 0.000 0.032 0.320 0.152 0.492 0.004
#> SRR1058007     2  0.5121     0.1182 0.000 0.492 0.000 0.060 0.440 0.008
#> SRR1058008     5  0.3187     0.4818 0.000 0.012 0.000 0.188 0.796 0.004
#> SRR1058009     2  0.5103    -0.2374 0.000 0.616 0.000 0.296 0.072 0.016
#> SRR1058010     4  0.5687     0.3909 0.000 0.300 0.000 0.540 0.152 0.008
#> SRR1058011     2  0.4340     0.1565 0.000 0.720 0.000 0.104 0.176 0.000
#> SRR1058012     2  0.6233     0.0466 0.000 0.372 0.000 0.312 0.312 0.004
#> SRR1058013     4  0.5987     0.3977 0.000 0.264 0.000 0.516 0.208 0.012
#> SRR1058014     5  0.3928     0.4346 0.000 0.160 0.000 0.080 0.760 0.000
#> SRR1058015     5  0.4634     0.2912 0.000 0.264 0.000 0.080 0.656 0.000
#> SRR1058016     5  0.5964     0.0114 0.000 0.188 0.000 0.320 0.484 0.008
#> SRR1058017     5  0.5349     0.2211 0.000 0.172 0.000 0.216 0.608 0.004
#> SRR1058018     5  0.2203     0.4897 0.000 0.084 0.000 0.016 0.896 0.004
#> SRR1058019     2  0.6134     0.1302 0.000 0.492 0.000 0.112 0.352 0.044
#> SRR1058020     4  0.6344     0.2428 0.000 0.324 0.000 0.460 0.188 0.028
#> SRR1058021     5  0.2249     0.4981 0.000 0.064 0.000 0.032 0.900 0.004
#> SRR1058022     2  0.5886     0.2624 0.000 0.508 0.000 0.088 0.364 0.040
#> SRR1058023     5  0.4131     0.3071 0.000 0.272 0.000 0.040 0.688 0.000
#> SRR1058024     2  0.5342     0.3526 0.000 0.632 0.000 0.116 0.232 0.020
#> SRR1058025     2  0.6861     0.1403 0.000 0.392 0.000 0.308 0.248 0.052
#> SRR1058026     6  0.5313     0.6102 0.000 0.032 0.000 0.288 0.068 0.612
#> SRR1058027     6  0.3884     0.7532 0.000 0.052 0.000 0.184 0.004 0.760
#> SRR1058028     6  0.3037     0.7745 0.000 0.016 0.000 0.160 0.004 0.820
#> SRR1058029     6  0.2333     0.7608 0.000 0.000 0.092 0.024 0.000 0.884
#> SRR1058030     6  0.1563     0.7885 0.000 0.012 0.056 0.000 0.000 0.932
#> SRR1058031     6  0.1116     0.8010 0.000 0.008 0.004 0.028 0.000 0.960
#> SRR1058032     3  0.1152     0.8912 0.044 0.000 0.952 0.004 0.000 0.000
#> SRR1058033     3  0.0405     0.9176 0.004 0.000 0.988 0.008 0.000 0.000
#> SRR1058034     3  0.0405     0.9176 0.004 0.000 0.988 0.008 0.000 0.000
#> SRR1058035     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058036     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058037     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058038     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058039     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058040     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058041     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058042     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058043     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058044     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058045     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058046     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058047     3  0.0000     0.9216 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1058048     3  0.1327     0.9264 0.000 0.000 0.936 0.000 0.000 0.064
#> SRR1058049     3  0.1910     0.9133 0.000 0.000 0.892 0.000 0.000 0.108
#> SRR1058050     3  0.2416     0.8803 0.000 0.000 0.844 0.000 0.000 0.156
#> SRR1058051     3  0.0000     0.9216 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1058052     3  0.1327     0.9264 0.000 0.000 0.936 0.000 0.000 0.064
#> SRR1058053     3  0.1910     0.9133 0.000 0.000 0.892 0.000 0.000 0.108
#> SRR1058054     3  0.2664     0.8536 0.000 0.000 0.816 0.000 0.000 0.184

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

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

collect_plots(res)

plot of chunk MAD-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.883           0.928       0.958         0.4914 0.497   0.497
#> 3 3 0.821           0.853       0.940         0.1227 0.979   0.958
#> 4 4 0.864           0.882       0.952         0.0781 0.943   0.881
#> 5 5 0.811           0.855       0.899         0.0988 0.923   0.817
#> 6 6 0.801           0.820       0.916         0.0250 0.998   0.996

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
#> SRR1058003     1  0.1843      0.962 0.972 0.028
#> SRR1058004     1  0.9775      0.379 0.588 0.412
#> SRR1058006     1  0.1843      0.962 0.972 0.028
#> SRR1058005     1  0.9775      0.379 0.588 0.412
#> SRR1058007     2  0.0000      0.972 0.000 1.000
#> SRR1058008     2  0.0000      0.972 0.000 1.000
#> SRR1058009     2  0.0000      0.972 0.000 1.000
#> SRR1058010     2  0.0000      0.972 0.000 1.000
#> SRR1058011     2  0.0000      0.972 0.000 1.000
#> SRR1058012     2  0.9522      0.456 0.372 0.628
#> SRR1058013     2  0.0000      0.972 0.000 1.000
#> SRR1058014     2  0.0000      0.972 0.000 1.000
#> SRR1058015     1  0.1843      0.962 0.972 0.028
#> SRR1058016     2  0.0000      0.972 0.000 1.000
#> SRR1058017     2  0.0000      0.972 0.000 1.000
#> SRR1058018     1  0.1843      0.962 0.972 0.028
#> SRR1058019     2  0.0000      0.972 0.000 1.000
#> SRR1058020     2  0.0376      0.969 0.004 0.996
#> SRR1058021     1  0.1843      0.962 0.972 0.028
#> SRR1058022     2  0.0000      0.972 0.000 1.000
#> SRR1058023     1  0.1843      0.962 0.972 0.028
#> SRR1058024     2  0.0376      0.969 0.004 0.996
#> SRR1058025     2  0.0376      0.969 0.004 0.996
#> SRR1058026     2  0.5629      0.858 0.132 0.868
#> SRR1058027     2  0.5629      0.858 0.132 0.868
#> SRR1058028     2  0.5629      0.858 0.132 0.868
#> SRR1058029     2  0.0000      0.972 0.000 1.000
#> SRR1058030     2  0.0000      0.972 0.000 1.000
#> SRR1058031     2  0.0000      0.972 0.000 1.000
#> SRR1058032     1  0.2043      0.959 0.968 0.032
#> SRR1058033     1  0.2043      0.959 0.968 0.032
#> SRR1058034     1  0.2043      0.959 0.968 0.032
#> SRR1058035     1  0.1843      0.962 0.972 0.028
#> SRR1058036     1  0.1843      0.962 0.972 0.028
#> SRR1058037     1  0.1843      0.962 0.972 0.028
#> SRR1058038     1  0.1843      0.962 0.972 0.028
#> SRR1058039     1  0.1843      0.962 0.972 0.028
#> SRR1058040     1  0.1843      0.962 0.972 0.028
#> SRR1058041     1  0.1843      0.962 0.972 0.028
#> SRR1058042     1  0.1843      0.962 0.972 0.028
#> SRR1058043     1  0.1843      0.962 0.972 0.028
#> SRR1058044     1  0.1843      0.962 0.972 0.028
#> SRR1058045     1  0.1843      0.962 0.972 0.028
#> SRR1058046     1  0.1843      0.962 0.972 0.028
#> SRR1058047     2  0.0000      0.972 0.000 1.000
#> SRR1058048     2  0.0000      0.972 0.000 1.000
#> SRR1058049     2  0.0000      0.972 0.000 1.000
#> SRR1058050     2  0.0000      0.972 0.000 1.000
#> SRR1058051     2  0.0000      0.972 0.000 1.000
#> SRR1058052     2  0.0000      0.972 0.000 1.000
#> SRR1058053     2  0.0000      0.972 0.000 1.000
#> SRR1058054     2  0.0000      0.972 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1058003     1  0.0000      0.936 1.000 0.000 0.000
#> SRR1058004     1  0.6373      0.174 0.588 0.408 0.004
#> SRR1058006     1  0.0000      0.936 1.000 0.000 0.000
#> SRR1058005     1  0.6373      0.174 0.588 0.408 0.004
#> SRR1058007     2  0.0000      0.923 0.000 1.000 0.000
#> SRR1058008     2  0.0000      0.923 0.000 1.000 0.000
#> SRR1058009     2  0.0000      0.923 0.000 1.000 0.000
#> SRR1058010     2  0.0000      0.923 0.000 1.000 0.000
#> SRR1058011     2  0.0000      0.923 0.000 1.000 0.000
#> SRR1058012     3  0.4399      0.000 0.188 0.000 0.812
#> SRR1058013     2  0.0000      0.923 0.000 1.000 0.000
#> SRR1058014     2  0.0000      0.923 0.000 1.000 0.000
#> SRR1058015     1  0.0000      0.936 1.000 0.000 0.000
#> SRR1058016     2  0.0000      0.923 0.000 1.000 0.000
#> SRR1058017     2  0.0000      0.923 0.000 1.000 0.000
#> SRR1058018     1  0.0000      0.936 1.000 0.000 0.000
#> SRR1058019     2  0.3038      0.890 0.000 0.896 0.104
#> SRR1058020     2  0.3116      0.887 0.000 0.892 0.108
#> SRR1058021     1  0.0000      0.936 1.000 0.000 0.000
#> SRR1058022     2  0.2959      0.891 0.000 0.900 0.100
#> SRR1058023     1  0.0000      0.936 1.000 0.000 0.000
#> SRR1058024     2  0.3116      0.887 0.000 0.892 0.108
#> SRR1058025     2  0.3116      0.887 0.000 0.892 0.108
#> SRR1058026     2  0.6126      0.533 0.000 0.600 0.400
#> SRR1058027     2  0.6126      0.533 0.000 0.600 0.400
#> SRR1058028     2  0.6126      0.533 0.000 0.600 0.400
#> SRR1058029     2  0.3038      0.890 0.000 0.896 0.104
#> SRR1058030     2  0.3038      0.890 0.000 0.896 0.104
#> SRR1058031     2  0.3038      0.890 0.000 0.896 0.104
#> SRR1058032     1  0.0237      0.932 0.996 0.000 0.004
#> SRR1058033     1  0.0237      0.932 0.996 0.000 0.004
#> SRR1058034     1  0.0237      0.932 0.996 0.000 0.004
#> SRR1058035     1  0.0000      0.936 1.000 0.000 0.000
#> SRR1058036     1  0.0000      0.936 1.000 0.000 0.000
#> SRR1058037     1  0.0000      0.936 1.000 0.000 0.000
#> SRR1058038     1  0.0000      0.936 1.000 0.000 0.000
#> SRR1058039     1  0.0000      0.936 1.000 0.000 0.000
#> SRR1058040     1  0.0000      0.936 1.000 0.000 0.000
#> SRR1058041     1  0.0000      0.936 1.000 0.000 0.000
#> SRR1058042     1  0.0000      0.936 1.000 0.000 0.000
#> SRR1058043     1  0.0000      0.936 1.000 0.000 0.000
#> SRR1058044     1  0.0000      0.936 1.000 0.000 0.000
#> SRR1058045     1  0.0000      0.936 1.000 0.000 0.000
#> SRR1058046     1  0.0000      0.936 1.000 0.000 0.000
#> SRR1058047     2  0.0237      0.922 0.000 0.996 0.004
#> SRR1058048     2  0.0237      0.922 0.000 0.996 0.004
#> SRR1058049     2  0.0237      0.922 0.000 0.996 0.004
#> SRR1058050     2  0.0237      0.922 0.000 0.996 0.004
#> SRR1058051     2  0.0237      0.922 0.000 0.996 0.004
#> SRR1058052     2  0.0237      0.922 0.000 0.996 0.004
#> SRR1058053     2  0.0237      0.922 0.000 0.996 0.004
#> SRR1058054     2  0.0237      0.922 0.000 0.996 0.004

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1058003     1  0.1510      0.910 0.956 0.000 0.016 0.028
#> SRR1058004     1  0.6314      0.254 0.544 0.408 0.020 0.028
#> SRR1058006     1  0.0000      0.937 1.000 0.000 0.000 0.000
#> SRR1058005     1  0.6314      0.254 0.544 0.408 0.020 0.028
#> SRR1058007     2  0.0000      0.941 0.000 1.000 0.000 0.000
#> SRR1058008     2  0.0000      0.941 0.000 1.000 0.000 0.000
#> SRR1058009     2  0.0000      0.941 0.000 1.000 0.000 0.000
#> SRR1058010     2  0.0000      0.941 0.000 1.000 0.000 0.000
#> SRR1058011     2  0.0000      0.941 0.000 1.000 0.000 0.000
#> SRR1058012     3  0.0779      0.000 0.004 0.000 0.980 0.016
#> SRR1058013     2  0.0000      0.941 0.000 1.000 0.000 0.000
#> SRR1058014     2  0.0000      0.941 0.000 1.000 0.000 0.000
#> SRR1058015     1  0.0000      0.937 1.000 0.000 0.000 0.000
#> SRR1058016     2  0.0000      0.941 0.000 1.000 0.000 0.000
#> SRR1058017     2  0.0000      0.941 0.000 1.000 0.000 0.000
#> SRR1058018     1  0.0000      0.937 1.000 0.000 0.000 0.000
#> SRR1058019     2  0.3074      0.865 0.000 0.848 0.000 0.152
#> SRR1058020     2  0.3123      0.861 0.000 0.844 0.000 0.156
#> SRR1058021     1  0.0000      0.937 1.000 0.000 0.000 0.000
#> SRR1058022     2  0.3024      0.867 0.000 0.852 0.000 0.148
#> SRR1058023     1  0.0000      0.937 1.000 0.000 0.000 0.000
#> SRR1058024     2  0.3123      0.861 0.000 0.844 0.000 0.156
#> SRR1058025     2  0.3123      0.861 0.000 0.844 0.000 0.156
#> SRR1058026     4  0.0921      0.969 0.000 0.028 0.000 0.972
#> SRR1058027     4  0.0921      0.969 0.000 0.028 0.000 0.972
#> SRR1058028     4  0.1474      0.938 0.000 0.052 0.000 0.948
#> SRR1058029     2  0.3074      0.865 0.000 0.848 0.000 0.152
#> SRR1058030     2  0.3074      0.865 0.000 0.848 0.000 0.152
#> SRR1058031     2  0.3074      0.865 0.000 0.848 0.000 0.152
#> SRR1058032     1  0.1624      0.908 0.952 0.000 0.020 0.028
#> SRR1058033     1  0.1624      0.908 0.952 0.000 0.020 0.028
#> SRR1058034     1  0.1624      0.908 0.952 0.000 0.020 0.028
#> SRR1058035     1  0.0000      0.937 1.000 0.000 0.000 0.000
#> SRR1058036     1  0.0000      0.937 1.000 0.000 0.000 0.000
#> SRR1058037     1  0.0000      0.937 1.000 0.000 0.000 0.000
#> SRR1058038     1  0.0000      0.937 1.000 0.000 0.000 0.000
#> SRR1058039     1  0.0000      0.937 1.000 0.000 0.000 0.000
#> SRR1058040     1  0.0000      0.937 1.000 0.000 0.000 0.000
#> SRR1058041     1  0.0000      0.937 1.000 0.000 0.000 0.000
#> SRR1058042     1  0.0000      0.937 1.000 0.000 0.000 0.000
#> SRR1058043     1  0.0000      0.937 1.000 0.000 0.000 0.000
#> SRR1058044     1  0.0000      0.937 1.000 0.000 0.000 0.000
#> SRR1058045     1  0.0000      0.937 1.000 0.000 0.000 0.000
#> SRR1058046     1  0.0000      0.937 1.000 0.000 0.000 0.000
#> SRR1058047     2  0.0188      0.941 0.000 0.996 0.004 0.000
#> SRR1058048     2  0.0188      0.941 0.000 0.996 0.004 0.000
#> SRR1058049     2  0.0188      0.941 0.000 0.996 0.004 0.000
#> SRR1058050     2  0.0188      0.941 0.000 0.996 0.004 0.000
#> SRR1058051     2  0.0188      0.941 0.000 0.996 0.004 0.000
#> SRR1058052     2  0.0188      0.941 0.000 0.996 0.004 0.000
#> SRR1058053     2  0.0188      0.941 0.000 0.996 0.004 0.000
#> SRR1058054     2  0.0188      0.941 0.000 0.996 0.004 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
#> SRR1058003     4  0.4015      0.641 0.348 0.000 0.000 0.652  0
#> SRR1058004     4  0.3999      0.283 0.000 0.344 0.000 0.656  0
#> SRR1058006     1  0.0880      0.956 0.968 0.000 0.000 0.032  0
#> SRR1058005     4  0.3999      0.283 0.000 0.344 0.000 0.656  0
#> SRR1058007     2  0.1410      0.899 0.000 0.940 0.000 0.060  0
#> SRR1058008     2  0.1410      0.899 0.000 0.940 0.000 0.060  0
#> SRR1058009     2  0.0000      0.905 0.000 1.000 0.000 0.000  0
#> SRR1058010     2  0.0162      0.905 0.000 0.996 0.000 0.004  0
#> SRR1058011     2  0.0162      0.905 0.000 0.996 0.000 0.004  0
#> SRR1058012     5  0.0000      0.000 0.000 0.000 0.000 0.000  1
#> SRR1058013     2  0.0000      0.905 0.000 1.000 0.000 0.000  0
#> SRR1058014     2  0.0000      0.905 0.000 1.000 0.000 0.000  0
#> SRR1058015     1  0.0000      0.997 1.000 0.000 0.000 0.000  0
#> SRR1058016     2  0.0162      0.905 0.000 0.996 0.000 0.004  0
#> SRR1058017     2  0.0290      0.904 0.000 0.992 0.000 0.008  0
#> SRR1058018     1  0.0000      0.997 1.000 0.000 0.000 0.000  0
#> SRR1058019     2  0.3013      0.837 0.000 0.832 0.160 0.008  0
#> SRR1058020     2  0.3053      0.833 0.000 0.828 0.164 0.008  0
#> SRR1058021     1  0.0000      0.997 1.000 0.000 0.000 0.000  0
#> SRR1058022     2  0.2971      0.839 0.000 0.836 0.156 0.008  0
#> SRR1058023     1  0.0000      0.997 1.000 0.000 0.000 0.000  0
#> SRR1058024     2  0.3053      0.833 0.000 0.828 0.164 0.008  0
#> SRR1058025     2  0.3053      0.833 0.000 0.828 0.164 0.008  0
#> SRR1058026     3  0.3143      0.788 0.000 0.000 0.796 0.204  0
#> SRR1058027     3  0.1478      0.836 0.000 0.000 0.936 0.064  0
#> SRR1058028     3  0.2104      0.767 0.000 0.024 0.916 0.060  0
#> SRR1058029     2  0.3013      0.837 0.000 0.832 0.160 0.008  0
#> SRR1058030     2  0.3013      0.837 0.000 0.832 0.160 0.008  0
#> SRR1058031     2  0.3013      0.837 0.000 0.832 0.160 0.008  0
#> SRR1058032     4  0.3983      0.650 0.340 0.000 0.000 0.660  0
#> SRR1058033     4  0.3983      0.650 0.340 0.000 0.000 0.660  0
#> SRR1058034     4  0.3983      0.650 0.340 0.000 0.000 0.660  0
#> SRR1058035     1  0.0000      0.997 1.000 0.000 0.000 0.000  0
#> SRR1058036     1  0.0000      0.997 1.000 0.000 0.000 0.000  0
#> SRR1058037     1  0.0000      0.997 1.000 0.000 0.000 0.000  0
#> SRR1058038     1  0.0000      0.997 1.000 0.000 0.000 0.000  0
#> SRR1058039     1  0.0000      0.997 1.000 0.000 0.000 0.000  0
#> SRR1058040     1  0.0000      0.997 1.000 0.000 0.000 0.000  0
#> SRR1058041     1  0.0000      0.997 1.000 0.000 0.000 0.000  0
#> SRR1058042     1  0.0000      0.997 1.000 0.000 0.000 0.000  0
#> SRR1058043     1  0.0000      0.997 1.000 0.000 0.000 0.000  0
#> SRR1058044     1  0.0000      0.997 1.000 0.000 0.000 0.000  0
#> SRR1058045     1  0.0000      0.997 1.000 0.000 0.000 0.000  0
#> SRR1058046     1  0.0000      0.997 1.000 0.000 0.000 0.000  0
#> SRR1058047     2  0.1544      0.898 0.000 0.932 0.000 0.068  0
#> SRR1058048     2  0.1544      0.898 0.000 0.932 0.000 0.068  0
#> SRR1058049     2  0.1544      0.898 0.000 0.932 0.000 0.068  0
#> SRR1058050     2  0.1544      0.898 0.000 0.932 0.000 0.068  0
#> SRR1058051     2  0.1544      0.898 0.000 0.932 0.000 0.068  0
#> SRR1058052     2  0.1544      0.898 0.000 0.932 0.000 0.068  0
#> SRR1058053     2  0.1544      0.898 0.000 0.932 0.000 0.068  0
#> SRR1058054     2  0.1544      0.898 0.000 0.932 0.000 0.068  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
#> SRR1058003     4  0.1958     0.6612 0.100 0.000 0.004 0.896  0 0.000
#> SRR1058004     4  0.4712     0.4072 0.000 0.344 0.060 0.596  0 0.000
#> SRR1058006     1  0.1152     0.9517 0.952 0.000 0.004 0.044  0 0.000
#> SRR1058005     4  0.4712     0.4072 0.000 0.344 0.060 0.596  0 0.000
#> SRR1058007     2  0.1349     0.8929 0.000 0.940 0.056 0.004  0 0.000
#> SRR1058008     2  0.1349     0.8929 0.000 0.940 0.056 0.004  0 0.000
#> SRR1058009     2  0.0146     0.8996 0.000 0.996 0.000 0.000  0 0.004
#> SRR1058010     2  0.0000     0.8997 0.000 1.000 0.000 0.000  0 0.000
#> SRR1058011     2  0.0000     0.8997 0.000 1.000 0.000 0.000  0 0.000
#> SRR1058012     5  0.0000     0.0000 0.000 0.000 0.000 0.000  1 0.000
#> SRR1058013     2  0.0146     0.8996 0.000 0.996 0.000 0.000  0 0.004
#> SRR1058014     2  0.0146     0.8996 0.000 0.996 0.000 0.000  0 0.004
#> SRR1058015     1  0.0405     0.9880 0.988 0.000 0.004 0.008  0 0.000
#> SRR1058016     2  0.0363     0.8983 0.000 0.988 0.000 0.000  0 0.012
#> SRR1058017     2  0.0458     0.8975 0.000 0.984 0.000 0.000  0 0.016
#> SRR1058018     1  0.0405     0.9880 0.988 0.000 0.004 0.008  0 0.000
#> SRR1058019     2  0.2597     0.8328 0.000 0.824 0.000 0.000  0 0.176
#> SRR1058020     2  0.2631     0.8297 0.000 0.820 0.000 0.000  0 0.180
#> SRR1058021     1  0.0405     0.9880 0.988 0.000 0.004 0.008  0 0.000
#> SRR1058022     2  0.2562     0.8351 0.000 0.828 0.000 0.000  0 0.172
#> SRR1058023     1  0.0405     0.9880 0.988 0.000 0.004 0.008  0 0.000
#> SRR1058024     2  0.2631     0.8297 0.000 0.820 0.000 0.000  0 0.180
#> SRR1058025     2  0.2631     0.8297 0.000 0.820 0.000 0.000  0 0.180
#> SRR1058026     3  0.1327     0.0000 0.000 0.000 0.936 0.000  0 0.064
#> SRR1058027     6  0.5173     0.0846 0.000 0.000 0.388 0.092  0 0.520
#> SRR1058028     6  0.0458     0.3986 0.000 0.000 0.016 0.000  0 0.984
#> SRR1058029     2  0.2597     0.8328 0.000 0.824 0.000 0.000  0 0.176
#> SRR1058030     2  0.2597     0.8328 0.000 0.824 0.000 0.000  0 0.176
#> SRR1058031     2  0.2597     0.8328 0.000 0.824 0.000 0.000  0 0.176
#> SRR1058032     4  0.1765     0.6693 0.096 0.000 0.000 0.904  0 0.000
#> SRR1058033     4  0.1765     0.6693 0.096 0.000 0.000 0.904  0 0.000
#> SRR1058034     4  0.1765     0.6693 0.096 0.000 0.000 0.904  0 0.000
#> SRR1058035     1  0.0000     0.9938 1.000 0.000 0.000 0.000  0 0.000
#> SRR1058036     1  0.0000     0.9938 1.000 0.000 0.000 0.000  0 0.000
#> SRR1058037     1  0.0000     0.9938 1.000 0.000 0.000 0.000  0 0.000
#> SRR1058038     1  0.0000     0.9938 1.000 0.000 0.000 0.000  0 0.000
#> SRR1058039     1  0.0000     0.9938 1.000 0.000 0.000 0.000  0 0.000
#> SRR1058040     1  0.0000     0.9938 1.000 0.000 0.000 0.000  0 0.000
#> SRR1058041     1  0.0000     0.9938 1.000 0.000 0.000 0.000  0 0.000
#> SRR1058042     1  0.0000     0.9938 1.000 0.000 0.000 0.000  0 0.000
#> SRR1058043     1  0.0000     0.9938 1.000 0.000 0.000 0.000  0 0.000
#> SRR1058044     1  0.0000     0.9938 1.000 0.000 0.000 0.000  0 0.000
#> SRR1058045     1  0.0000     0.9938 1.000 0.000 0.000 0.000  0 0.000
#> SRR1058046     1  0.0000     0.9938 1.000 0.000 0.000 0.000  0 0.000
#> SRR1058047     2  0.1524     0.8917 0.000 0.932 0.060 0.008  0 0.000
#> SRR1058048     2  0.1524     0.8917 0.000 0.932 0.060 0.008  0 0.000
#> SRR1058049     2  0.1524     0.8917 0.000 0.932 0.060 0.008  0 0.000
#> SRR1058050     2  0.1524     0.8917 0.000 0.932 0.060 0.008  0 0.000
#> SRR1058051     2  0.1524     0.8917 0.000 0.932 0.060 0.008  0 0.000
#> SRR1058052     2  0.1524     0.8917 0.000 0.932 0.060 0.008  0 0.000
#> SRR1058053     2  0.1524     0.8917 0.000 0.932 0.060 0.008  0 0.000
#> SRR1058054     2  0.1524     0.8917 0.000 0.932 0.060 0.008  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 18325 rows and 52 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'kmeans' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk MAD-kmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.919           0.898       0.960         0.4702 0.551   0.551
#> 3 3 0.536           0.385       0.640         0.3084 0.784   0.639
#> 4 4 0.695           0.855       0.881         0.1421 0.780   0.531
#> 5 5 0.762           0.458       0.736         0.0832 0.920   0.740
#> 6 6 0.846           0.861       0.889         0.0497 0.893   0.609

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
#> SRR1058003     2  0.9996      0.150 0.488 0.512
#> SRR1058004     2  0.0000      0.937 0.000 1.000
#> SRR1058006     2  0.9954      0.237 0.460 0.540
#> SRR1058005     2  0.0000      0.937 0.000 1.000
#> SRR1058007     2  0.0000      0.937 0.000 1.000
#> SRR1058008     2  0.0000      0.937 0.000 1.000
#> SRR1058009     2  0.0000      0.937 0.000 1.000
#> SRR1058010     2  0.0000      0.937 0.000 1.000
#> SRR1058011     2  0.0000      0.937 0.000 1.000
#> SRR1058012     2  0.7219      0.731 0.200 0.800
#> SRR1058013     2  0.0000      0.937 0.000 1.000
#> SRR1058014     2  0.0000      0.937 0.000 1.000
#> SRR1058015     2  0.9954      0.237 0.460 0.540
#> SRR1058016     2  0.0000      0.937 0.000 1.000
#> SRR1058017     2  0.0000      0.937 0.000 1.000
#> SRR1058018     1  0.0376      0.996 0.996 0.004
#> SRR1058019     2  0.0000      0.937 0.000 1.000
#> SRR1058020     2  0.0000      0.937 0.000 1.000
#> SRR1058021     2  0.9944      0.248 0.456 0.544
#> SRR1058022     2  0.0000      0.937 0.000 1.000
#> SRR1058023     1  0.0376      0.996 0.996 0.004
#> SRR1058024     2  0.0000      0.937 0.000 1.000
#> SRR1058025     2  0.0000      0.937 0.000 1.000
#> SRR1058026     2  0.0000      0.937 0.000 1.000
#> SRR1058027     2  0.0000      0.937 0.000 1.000
#> SRR1058028     2  0.0000      0.937 0.000 1.000
#> SRR1058029     2  0.0000      0.937 0.000 1.000
#> SRR1058030     2  0.0000      0.937 0.000 1.000
#> SRR1058031     2  0.0000      0.937 0.000 1.000
#> SRR1058032     1  0.0000      0.999 1.000 0.000
#> SRR1058033     1  0.0000      0.999 1.000 0.000
#> SRR1058034     1  0.0000      0.999 1.000 0.000
#> SRR1058035     1  0.0000      0.999 1.000 0.000
#> SRR1058036     1  0.0000      0.999 1.000 0.000
#> SRR1058037     1  0.0000      0.999 1.000 0.000
#> SRR1058038     1  0.0000      0.999 1.000 0.000
#> SRR1058039     1  0.0000      0.999 1.000 0.000
#> SRR1058040     1  0.0000      0.999 1.000 0.000
#> SRR1058041     1  0.0000      0.999 1.000 0.000
#> SRR1058042     1  0.0000      0.999 1.000 0.000
#> SRR1058043     1  0.0000      0.999 1.000 0.000
#> SRR1058044     1  0.0000      0.999 1.000 0.000
#> SRR1058045     1  0.0000      0.999 1.000 0.000
#> SRR1058046     1  0.0000      0.999 1.000 0.000
#> SRR1058047     2  0.0000      0.937 0.000 1.000
#> SRR1058048     2  0.0000      0.937 0.000 1.000
#> SRR1058049     2  0.0000      0.937 0.000 1.000
#> SRR1058050     2  0.0000      0.937 0.000 1.000
#> SRR1058051     2  0.0000      0.937 0.000 1.000
#> SRR1058052     2  0.0000      0.937 0.000 1.000
#> SRR1058053     2  0.0000      0.937 0.000 1.000
#> SRR1058054     2  0.0000      0.937 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1058003     1  0.8561    -0.0784 0.528 0.368 0.104
#> SRR1058004     2  0.6082     0.5830 0.012 0.692 0.296
#> SRR1058006     1  0.7130    -0.1501 0.544 0.432 0.024
#> SRR1058005     2  0.6082     0.5830 0.012 0.692 0.296
#> SRR1058007     2  0.1163     0.7599 0.000 0.972 0.028
#> SRR1058008     2  0.1163     0.7599 0.000 0.972 0.028
#> SRR1058009     2  0.1337     0.7602 0.016 0.972 0.012
#> SRR1058010     2  0.3293     0.7397 0.088 0.900 0.012
#> SRR1058011     2  0.0592     0.7614 0.000 0.988 0.012
#> SRR1058012     2  0.6307     0.2243 0.488 0.512 0.000
#> SRR1058013     2  0.1015     0.7612 0.008 0.980 0.012
#> SRR1058014     2  0.1015     0.7612 0.008 0.980 0.012
#> SRR1058015     1  0.6260    -0.1684 0.552 0.448 0.000
#> SRR1058016     2  0.2772     0.7426 0.080 0.916 0.004
#> SRR1058017     2  0.0892     0.7608 0.000 0.980 0.020
#> SRR1058018     1  0.5968     0.0099 0.636 0.364 0.000
#> SRR1058019     2  0.1411     0.7600 0.000 0.964 0.036
#> SRR1058020     2  0.3752     0.7361 0.096 0.884 0.020
#> SRR1058021     1  0.6305    -0.2430 0.516 0.484 0.000
#> SRR1058022     2  0.1411     0.7600 0.000 0.964 0.036
#> SRR1058023     1  0.5968     0.0099 0.636 0.364 0.000
#> SRR1058024     2  0.4921     0.6999 0.164 0.816 0.020
#> SRR1058025     2  0.5092     0.6923 0.176 0.804 0.020
#> SRR1058026     2  0.5774     0.6381 0.232 0.748 0.020
#> SRR1058027     2  0.5731     0.6425 0.228 0.752 0.020
#> SRR1058028     2  0.5092     0.6923 0.176 0.804 0.020
#> SRR1058029     2  0.3267     0.7282 0.000 0.884 0.116
#> SRR1058030     2  0.3267     0.7282 0.000 0.884 0.116
#> SRR1058031     2  0.2625     0.7446 0.000 0.916 0.084
#> SRR1058032     3  0.6307    -0.2617 0.488 0.000 0.512
#> SRR1058033     3  0.6307    -0.2617 0.488 0.000 0.512
#> SRR1058034     3  0.6307    -0.2617 0.488 0.000 0.512
#> SRR1058035     1  0.6215     0.3301 0.572 0.000 0.428
#> SRR1058036     1  0.6215     0.3301 0.572 0.000 0.428
#> SRR1058037     1  0.6215     0.3301 0.572 0.000 0.428
#> SRR1058038     1  0.6215     0.3301 0.572 0.000 0.428
#> SRR1058039     1  0.6215     0.3301 0.572 0.000 0.428
#> SRR1058040     1  0.6215     0.3301 0.572 0.000 0.428
#> SRR1058041     1  0.6215     0.3301 0.572 0.000 0.428
#> SRR1058042     1  0.6215     0.3301 0.572 0.000 0.428
#> SRR1058043     1  0.6215     0.3301 0.572 0.000 0.428
#> SRR1058044     1  0.6215     0.3301 0.572 0.000 0.428
#> SRR1058045     1  0.6215     0.3301 0.572 0.000 0.428
#> SRR1058046     1  0.6215     0.3301 0.572 0.000 0.428
#> SRR1058047     3  0.6235    -0.3541 0.000 0.436 0.564
#> SRR1058048     2  0.6280     0.3604 0.000 0.540 0.460
#> SRR1058049     2  0.6280     0.3671 0.000 0.540 0.460
#> SRR1058050     2  0.6280     0.3671 0.000 0.540 0.460
#> SRR1058051     3  0.6286    -0.3926 0.000 0.464 0.536
#> SRR1058052     2  0.6280     0.3604 0.000 0.540 0.460
#> SRR1058053     2  0.6280     0.3671 0.000 0.540 0.460
#> SRR1058054     2  0.6280     0.3671 0.000 0.540 0.460

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1058003     4  0.4795      0.714 0.016 0.060 0.120 0.804
#> SRR1058004     2  0.7158      0.209 0.000 0.512 0.340 0.148
#> SRR1058006     4  0.3597      0.901 0.016 0.148 0.000 0.836
#> SRR1058005     2  0.7158      0.209 0.000 0.512 0.340 0.148
#> SRR1058007     2  0.0937      0.881 0.000 0.976 0.012 0.012
#> SRR1058008     2  0.1059      0.879 0.000 0.972 0.016 0.012
#> SRR1058009     2  0.0937      0.881 0.000 0.976 0.012 0.012
#> SRR1058010     2  0.1833      0.877 0.000 0.944 0.024 0.032
#> SRR1058011     2  0.1059      0.880 0.000 0.972 0.012 0.016
#> SRR1058012     4  0.4722      0.825 0.004 0.144 0.060 0.792
#> SRR1058013     2  0.0937      0.881 0.000 0.976 0.012 0.012
#> SRR1058014     2  0.0937      0.881 0.000 0.976 0.012 0.012
#> SRR1058015     4  0.4289      0.904 0.032 0.172 0.000 0.796
#> SRR1058016     2  0.1109      0.881 0.000 0.968 0.004 0.028
#> SRR1058017     2  0.0657      0.882 0.000 0.984 0.004 0.012
#> SRR1058018     4  0.4565      0.896 0.064 0.140 0.000 0.796
#> SRR1058019     2  0.0188      0.881 0.000 0.996 0.000 0.004
#> SRR1058020     2  0.1936      0.856 0.000 0.940 0.028 0.032
#> SRR1058021     4  0.3893      0.888 0.008 0.196 0.000 0.796
#> SRR1058022     2  0.0188      0.881 0.000 0.996 0.000 0.004
#> SRR1058023     4  0.4485      0.904 0.052 0.152 0.000 0.796
#> SRR1058024     2  0.2466      0.838 0.000 0.916 0.028 0.056
#> SRR1058025     2  0.2466      0.838 0.000 0.916 0.028 0.056
#> SRR1058026     2  0.5292      0.674 0.000 0.744 0.088 0.168
#> SRR1058027     2  0.5292      0.674 0.000 0.744 0.088 0.168
#> SRR1058028     2  0.4710      0.733 0.000 0.792 0.088 0.120
#> SRR1058029     2  0.0376      0.880 0.000 0.992 0.004 0.004
#> SRR1058030     2  0.0376      0.880 0.000 0.992 0.004 0.004
#> SRR1058031     2  0.0376      0.880 0.000 0.992 0.004 0.004
#> SRR1058032     1  0.5581      0.736 0.728 0.000 0.132 0.140
#> SRR1058033     1  0.5581      0.736 0.728 0.000 0.132 0.140
#> SRR1058034     1  0.5581      0.736 0.728 0.000 0.132 0.140
#> SRR1058035     1  0.0000      0.943 1.000 0.000 0.000 0.000
#> SRR1058036     1  0.0000      0.943 1.000 0.000 0.000 0.000
#> SRR1058037     1  0.0000      0.943 1.000 0.000 0.000 0.000
#> SRR1058038     1  0.0000      0.943 1.000 0.000 0.000 0.000
#> SRR1058039     1  0.0000      0.943 1.000 0.000 0.000 0.000
#> SRR1058040     1  0.0000      0.943 1.000 0.000 0.000 0.000
#> SRR1058041     1  0.0000      0.943 1.000 0.000 0.000 0.000
#> SRR1058042     1  0.0000      0.943 1.000 0.000 0.000 0.000
#> SRR1058043     1  0.0000      0.943 1.000 0.000 0.000 0.000
#> SRR1058044     1  0.0000      0.943 1.000 0.000 0.000 0.000
#> SRR1058045     1  0.0000      0.943 1.000 0.000 0.000 0.000
#> SRR1058046     1  0.0000      0.943 1.000 0.000 0.000 0.000
#> SRR1058047     3  0.2704      0.853 0.000 0.124 0.876 0.000
#> SRR1058048     3  0.3801      0.960 0.000 0.220 0.780 0.000
#> SRR1058049     3  0.4088      0.964 0.000 0.232 0.764 0.004
#> SRR1058050     3  0.4088      0.964 0.000 0.232 0.764 0.004
#> SRR1058051     3  0.3486      0.937 0.000 0.188 0.812 0.000
#> SRR1058052     3  0.3801      0.960 0.000 0.220 0.780 0.000
#> SRR1058053     3  0.4088      0.964 0.000 0.232 0.764 0.004
#> SRR1058054     3  0.4088      0.964 0.000 0.232 0.764 0.004

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4    p5
#> SRR1058003     5  0.4437      0.503 0.004 0.000 0.000 0.464 0.532
#> SRR1058004     4  0.7070     -0.227 0.088 0.352 0.060 0.492 0.008
#> SRR1058006     5  0.0865      0.851 0.004 0.024 0.000 0.000 0.972
#> SRR1058005     4  0.7070     -0.227 0.088 0.352 0.060 0.492 0.008
#> SRR1058007     2  0.2857      0.823 0.112 0.868 0.008 0.000 0.012
#> SRR1058008     2  0.2857      0.823 0.112 0.868 0.008 0.000 0.012
#> SRR1058009     2  0.2699      0.828 0.100 0.880 0.008 0.000 0.012
#> SRR1058010     2  0.3714      0.812 0.100 0.832 0.056 0.000 0.012
#> SRR1058011     2  0.2699      0.828 0.100 0.880 0.008 0.000 0.012
#> SRR1058012     5  0.5580      0.566 0.336 0.000 0.088 0.000 0.576
#> SRR1058013     2  0.2699      0.828 0.100 0.880 0.008 0.000 0.012
#> SRR1058014     2  0.2699      0.828 0.100 0.880 0.008 0.000 0.012
#> SRR1058015     5  0.0880      0.853 0.000 0.032 0.000 0.000 0.968
#> SRR1058016     2  0.1518      0.840 0.048 0.944 0.004 0.000 0.004
#> SRR1058017     2  0.1357      0.841 0.048 0.948 0.004 0.000 0.000
#> SRR1058018     5  0.1117      0.851 0.016 0.020 0.000 0.000 0.964
#> SRR1058019     2  0.0510      0.840 0.000 0.984 0.016 0.000 0.000
#> SRR1058020     2  0.0865      0.838 0.004 0.972 0.024 0.000 0.000
#> SRR1058021     5  0.1041      0.853 0.004 0.032 0.000 0.000 0.964
#> SRR1058022     2  0.0510      0.840 0.000 0.984 0.016 0.000 0.000
#> SRR1058023     5  0.1117      0.851 0.016 0.020 0.000 0.000 0.964
#> SRR1058024     2  0.1653      0.827 0.024 0.944 0.028 0.000 0.004
#> SRR1058025     2  0.1893      0.824 0.024 0.936 0.028 0.000 0.012
#> SRR1058026     2  0.7288      0.224 0.384 0.424 0.124 0.000 0.068
#> SRR1058027     2  0.7288      0.224 0.384 0.424 0.124 0.000 0.068
#> SRR1058028     2  0.6728      0.298 0.384 0.464 0.124 0.000 0.028
#> SRR1058029     2  0.0703      0.838 0.000 0.976 0.024 0.000 0.000
#> SRR1058030     2  0.0703      0.838 0.000 0.976 0.024 0.000 0.000
#> SRR1058031     2  0.0703      0.838 0.000 0.976 0.024 0.000 0.000
#> SRR1058032     4  0.0162      0.128 0.000 0.000 0.000 0.996 0.004
#> SRR1058033     4  0.0162      0.128 0.000 0.000 0.000 0.996 0.004
#> SRR1058034     4  0.0162      0.128 0.000 0.000 0.000 0.996 0.004
#> SRR1058035     4  0.4452     -0.989 0.496 0.000 0.004 0.500 0.000
#> SRR1058036     4  0.4452     -0.989 0.496 0.000 0.004 0.500 0.000
#> SRR1058037     4  0.4452     -0.989 0.496 0.000 0.004 0.500 0.000
#> SRR1058038     1  0.4307      1.000 0.500 0.000 0.000 0.500 0.000
#> SRR1058039     1  0.4307      1.000 0.500 0.000 0.000 0.500 0.000
#> SRR1058040     4  0.4307     -1.000 0.500 0.000 0.000 0.500 0.000
#> SRR1058041     4  0.4307     -1.000 0.500 0.000 0.000 0.500 0.000
#> SRR1058042     1  0.4307      1.000 0.500 0.000 0.000 0.500 0.000
#> SRR1058043     4  0.4307     -1.000 0.500 0.000 0.000 0.500 0.000
#> SRR1058044     4  0.4307     -1.000 0.500 0.000 0.000 0.500 0.000
#> SRR1058045     1  0.4307      1.000 0.500 0.000 0.000 0.500 0.000
#> SRR1058046     4  0.4307     -1.000 0.500 0.000 0.000 0.500 0.000
#> SRR1058047     3  0.3202      0.886 0.004 0.056 0.860 0.080 0.000
#> SRR1058048     3  0.2389      0.967 0.000 0.116 0.880 0.004 0.000
#> SRR1058049     3  0.2329      0.969 0.000 0.124 0.876 0.000 0.000
#> SRR1058050     3  0.2329      0.969 0.000 0.124 0.876 0.000 0.000
#> SRR1058051     3  0.3141      0.937 0.004 0.096 0.860 0.040 0.000
#> SRR1058052     3  0.2389      0.967 0.000 0.116 0.880 0.004 0.000
#> SRR1058053     3  0.2329      0.969 0.000 0.124 0.876 0.000 0.000
#> SRR1058054     3  0.2329      0.969 0.000 0.124 0.876 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR1058003     4  0.3820      0.327 0.000 0.004 0.000 0.660 0.332 0.004
#> SRR1058004     4  0.3986      0.524 0.000 0.168 0.024 0.776 0.008 0.024
#> SRR1058006     5  0.0951      0.984 0.000 0.020 0.000 0.008 0.968 0.004
#> SRR1058005     4  0.3986      0.524 0.000 0.168 0.024 0.776 0.008 0.024
#> SRR1058007     2  0.3194      0.787 0.000 0.824 0.004 0.144 0.004 0.024
#> SRR1058008     2  0.3194      0.787 0.000 0.824 0.004 0.144 0.004 0.024
#> SRR1058009     2  0.2196      0.820 0.000 0.884 0.004 0.108 0.004 0.000
#> SRR1058010     2  0.3242      0.796 0.000 0.832 0.024 0.128 0.004 0.012
#> SRR1058011     2  0.2377      0.816 0.000 0.868 0.004 0.124 0.004 0.000
#> SRR1058012     6  0.6112      0.382 0.000 0.004 0.032 0.140 0.280 0.544
#> SRR1058013     2  0.2149      0.821 0.000 0.888 0.004 0.104 0.004 0.000
#> SRR1058014     2  0.2149      0.821 0.000 0.888 0.004 0.104 0.004 0.000
#> SRR1058015     5  0.0806      0.993 0.000 0.020 0.000 0.000 0.972 0.008
#> SRR1058016     2  0.1881      0.832 0.000 0.924 0.004 0.052 0.004 0.016
#> SRR1058017     2  0.1370      0.833 0.000 0.948 0.000 0.036 0.004 0.012
#> SRR1058018     5  0.0806      0.993 0.000 0.020 0.000 0.000 0.972 0.008
#> SRR1058019     2  0.2442      0.827 0.000 0.852 0.000 0.004 0.000 0.144
#> SRR1058020     2  0.2669      0.820 0.000 0.836 0.000 0.008 0.000 0.156
#> SRR1058021     5  0.0547      0.989 0.000 0.020 0.000 0.000 0.980 0.000
#> SRR1058022     2  0.2442      0.827 0.000 0.852 0.000 0.004 0.000 0.144
#> SRR1058023     5  0.0806      0.993 0.000 0.020 0.000 0.000 0.972 0.008
#> SRR1058024     2  0.2915      0.801 0.000 0.808 0.000 0.008 0.000 0.184
#> SRR1058025     2  0.3056      0.798 0.000 0.804 0.000 0.008 0.004 0.184
#> SRR1058026     6  0.1152      0.839 0.000 0.044 0.000 0.000 0.004 0.952
#> SRR1058027     6  0.1152      0.839 0.000 0.044 0.000 0.000 0.004 0.952
#> SRR1058028     6  0.1757      0.816 0.000 0.076 0.000 0.008 0.000 0.916
#> SRR1058029     2  0.2794      0.823 0.000 0.840 0.012 0.004 0.000 0.144
#> SRR1058030     2  0.2794      0.823 0.000 0.840 0.012 0.004 0.000 0.144
#> SRR1058031     2  0.2794      0.823 0.000 0.840 0.012 0.004 0.000 0.144
#> SRR1058032     4  0.3905      0.662 0.316 0.000 0.000 0.668 0.000 0.016
#> SRR1058033     4  0.3905      0.662 0.316 0.000 0.000 0.668 0.000 0.016
#> SRR1058034     4  0.3905      0.662 0.316 0.000 0.000 0.668 0.000 0.016
#> SRR1058035     1  0.0146      0.995 0.996 0.000 0.004 0.000 0.000 0.000
#> SRR1058036     1  0.0146      0.995 0.996 0.000 0.004 0.000 0.000 0.000
#> SRR1058037     1  0.0146      0.995 0.996 0.000 0.004 0.000 0.000 0.000
#> SRR1058038     1  0.0000      0.997 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058039     1  0.0000      0.997 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058040     1  0.0000      0.997 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058041     1  0.0000      0.997 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058042     1  0.0000      0.997 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058043     1  0.0725      0.974 0.976 0.000 0.012 0.012 0.000 0.000
#> SRR1058044     1  0.0000      0.997 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058045     1  0.0000      0.997 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058046     1  0.0000      0.997 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058047     3  0.1492      0.948 0.000 0.024 0.940 0.036 0.000 0.000
#> SRR1058048     3  0.1141      0.983 0.000 0.052 0.948 0.000 0.000 0.000
#> SRR1058049     3  0.1204      0.984 0.000 0.056 0.944 0.000 0.000 0.000
#> SRR1058050     3  0.1204      0.984 0.000 0.056 0.944 0.000 0.000 0.000
#> SRR1058051     3  0.1492      0.964 0.000 0.036 0.940 0.024 0.000 0.000
#> SRR1058052     3  0.1141      0.983 0.000 0.052 0.948 0.000 0.000 0.000
#> SRR1058053     3  0.1204      0.984 0.000 0.056 0.944 0.000 0.000 0.000
#> SRR1058054     3  0.1204      0.984 0.000 0.056 0.944 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

plot of chunk tab-MAD-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 18325 rows and 52 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'skmeans' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 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           0.991       0.996         0.4928 0.509   0.509
#> 3 3 1.000           0.972       0.985         0.3173 0.842   0.689
#> 4 4 0.875           0.897       0.935         0.1160 0.913   0.754
#> 5 5 0.807           0.803       0.865         0.0787 0.948   0.815
#> 6 6 0.826           0.755       0.861         0.0590 0.925   0.682

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
#> SRR1058003     1   0.000      1.000 1.0 0.0
#> SRR1058004     2   0.000      0.993 0.0 1.0
#> SRR1058006     1   0.000      1.000 1.0 0.0
#> SRR1058005     2   0.000      0.993 0.0 1.0
#> SRR1058007     2   0.000      0.993 0.0 1.0
#> SRR1058008     2   0.000      0.993 0.0 1.0
#> SRR1058009     2   0.000      0.993 0.0 1.0
#> SRR1058010     2   0.000      0.993 0.0 1.0
#> SRR1058011     2   0.000      0.993 0.0 1.0
#> SRR1058012     2   0.722      0.750 0.2 0.8
#> SRR1058013     2   0.000      0.993 0.0 1.0
#> SRR1058014     2   0.000      0.993 0.0 1.0
#> SRR1058015     1   0.000      1.000 1.0 0.0
#> SRR1058016     2   0.000      0.993 0.0 1.0
#> SRR1058017     2   0.000      0.993 0.0 1.0
#> SRR1058018     1   0.000      1.000 1.0 0.0
#> SRR1058019     2   0.000      0.993 0.0 1.0
#> SRR1058020     2   0.000      0.993 0.0 1.0
#> SRR1058021     1   0.000      1.000 1.0 0.0
#> SRR1058022     2   0.000      0.993 0.0 1.0
#> SRR1058023     1   0.000      1.000 1.0 0.0
#> SRR1058024     2   0.000      0.993 0.0 1.0
#> SRR1058025     2   0.000      0.993 0.0 1.0
#> SRR1058026     2   0.000      0.993 0.0 1.0
#> SRR1058027     2   0.000      0.993 0.0 1.0
#> SRR1058028     2   0.000      0.993 0.0 1.0
#> SRR1058029     2   0.000      0.993 0.0 1.0
#> SRR1058030     2   0.000      0.993 0.0 1.0
#> SRR1058031     2   0.000      0.993 0.0 1.0
#> SRR1058032     1   0.000      1.000 1.0 0.0
#> SRR1058033     1   0.000      1.000 1.0 0.0
#> SRR1058034     1   0.000      1.000 1.0 0.0
#> SRR1058035     1   0.000      1.000 1.0 0.0
#> SRR1058036     1   0.000      1.000 1.0 0.0
#> SRR1058037     1   0.000      1.000 1.0 0.0
#> SRR1058038     1   0.000      1.000 1.0 0.0
#> SRR1058039     1   0.000      1.000 1.0 0.0
#> SRR1058040     1   0.000      1.000 1.0 0.0
#> SRR1058041     1   0.000      1.000 1.0 0.0
#> SRR1058042     1   0.000      1.000 1.0 0.0
#> SRR1058043     1   0.000      1.000 1.0 0.0
#> SRR1058044     1   0.000      1.000 1.0 0.0
#> SRR1058045     1   0.000      1.000 1.0 0.0
#> SRR1058046     1   0.000      1.000 1.0 0.0
#> SRR1058047     2   0.000      0.993 0.0 1.0
#> SRR1058048     2   0.000      0.993 0.0 1.0
#> SRR1058049     2   0.000      0.993 0.0 1.0
#> SRR1058050     2   0.000      0.993 0.0 1.0
#> SRR1058051     2   0.000      0.993 0.0 1.0
#> SRR1058052     2   0.000      0.993 0.0 1.0
#> SRR1058053     2   0.000      0.993 0.0 1.0
#> SRR1058054     2   0.000      0.993 0.0 1.0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1058003     1  0.0237      0.983 0.996 0.004 0.000
#> SRR1058004     3  0.1643      0.958 0.000 0.044 0.956
#> SRR1058006     1  0.1163      0.965 0.972 0.028 0.000
#> SRR1058005     3  0.1643      0.958 0.000 0.044 0.956
#> SRR1058007     2  0.0592      0.980 0.000 0.988 0.012
#> SRR1058008     2  0.0592      0.980 0.000 0.988 0.012
#> SRR1058009     2  0.0592      0.980 0.000 0.988 0.012
#> SRR1058010     2  0.0237      0.979 0.000 0.996 0.004
#> SRR1058011     2  0.0592      0.980 0.000 0.988 0.012
#> SRR1058012     2  0.4178      0.770 0.172 0.828 0.000
#> SRR1058013     2  0.0592      0.980 0.000 0.988 0.012
#> SRR1058014     2  0.0592      0.980 0.000 0.988 0.012
#> SRR1058015     1  0.3038      0.887 0.896 0.104 0.000
#> SRR1058016     2  0.0424      0.980 0.000 0.992 0.008
#> SRR1058017     2  0.0592      0.980 0.000 0.988 0.012
#> SRR1058018     1  0.0592      0.978 0.988 0.012 0.000
#> SRR1058019     2  0.0592      0.980 0.000 0.988 0.012
#> SRR1058020     2  0.0000      0.977 0.000 1.000 0.000
#> SRR1058021     1  0.3482      0.858 0.872 0.128 0.000
#> SRR1058022     2  0.0592      0.980 0.000 0.988 0.012
#> SRR1058023     1  0.0592      0.978 0.988 0.012 0.000
#> SRR1058024     2  0.0000      0.977 0.000 1.000 0.000
#> SRR1058025     2  0.0000      0.977 0.000 1.000 0.000
#> SRR1058026     2  0.0000      0.977 0.000 1.000 0.000
#> SRR1058027     2  0.0000      0.977 0.000 1.000 0.000
#> SRR1058028     2  0.0000      0.977 0.000 1.000 0.000
#> SRR1058029     2  0.1753      0.952 0.000 0.952 0.048
#> SRR1058030     2  0.1860      0.949 0.000 0.948 0.052
#> SRR1058031     2  0.1031      0.972 0.000 0.976 0.024
#> SRR1058032     1  0.0000      0.985 1.000 0.000 0.000
#> SRR1058033     1  0.0000      0.985 1.000 0.000 0.000
#> SRR1058034     1  0.0000      0.985 1.000 0.000 0.000
#> SRR1058035     1  0.0000      0.985 1.000 0.000 0.000
#> SRR1058036     1  0.0000      0.985 1.000 0.000 0.000
#> SRR1058037     1  0.0000      0.985 1.000 0.000 0.000
#> SRR1058038     1  0.0000      0.985 1.000 0.000 0.000
#> SRR1058039     1  0.0000      0.985 1.000 0.000 0.000
#> SRR1058040     1  0.0000      0.985 1.000 0.000 0.000
#> SRR1058041     1  0.0000      0.985 1.000 0.000 0.000
#> SRR1058042     1  0.0000      0.985 1.000 0.000 0.000
#> SRR1058043     1  0.0000      0.985 1.000 0.000 0.000
#> SRR1058044     1  0.0000      0.985 1.000 0.000 0.000
#> SRR1058045     1  0.0000      0.985 1.000 0.000 0.000
#> SRR1058046     1  0.0000      0.985 1.000 0.000 0.000
#> SRR1058047     3  0.0000      0.990 0.000 0.000 1.000
#> SRR1058048     3  0.0000      0.990 0.000 0.000 1.000
#> SRR1058049     3  0.0000      0.990 0.000 0.000 1.000
#> SRR1058050     3  0.0000      0.990 0.000 0.000 1.000
#> SRR1058051     3  0.0000      0.990 0.000 0.000 1.000
#> SRR1058052     3  0.0000      0.990 0.000 0.000 1.000
#> SRR1058053     3  0.0000      0.990 0.000 0.000 1.000
#> SRR1058054     3  0.0000      0.990 0.000 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1058003     4  0.1940      0.800 0.076 0.000 0.000 0.924
#> SRR1058004     3  0.7407      0.429 0.000 0.288 0.508 0.204
#> SRR1058006     4  0.0921      0.800 0.028 0.000 0.000 0.972
#> SRR1058005     3  0.7337      0.450 0.000 0.272 0.524 0.204
#> SRR1058007     2  0.1474      0.948 0.000 0.948 0.000 0.052
#> SRR1058008     2  0.1637      0.943 0.000 0.940 0.000 0.060
#> SRR1058009     2  0.0817      0.959 0.000 0.976 0.000 0.024
#> SRR1058010     2  0.1302      0.959 0.000 0.956 0.000 0.044
#> SRR1058011     2  0.0921      0.960 0.000 0.972 0.000 0.028
#> SRR1058012     4  0.4532      0.750 0.052 0.156 0.000 0.792
#> SRR1058013     2  0.0817      0.959 0.000 0.976 0.000 0.024
#> SRR1058014     2  0.1211      0.956 0.000 0.960 0.000 0.040
#> SRR1058015     4  0.3881      0.872 0.172 0.016 0.000 0.812
#> SRR1058016     2  0.0592      0.962 0.000 0.984 0.000 0.016
#> SRR1058017     2  0.0336      0.962 0.000 0.992 0.000 0.008
#> SRR1058018     4  0.3873      0.848 0.228 0.000 0.000 0.772
#> SRR1058019     2  0.0188      0.961 0.000 0.996 0.000 0.004
#> SRR1058020     2  0.0469      0.961 0.000 0.988 0.000 0.012
#> SRR1058021     4  0.4057      0.870 0.160 0.028 0.000 0.812
#> SRR1058022     2  0.0188      0.961 0.000 0.996 0.000 0.004
#> SRR1058023     4  0.3837      0.851 0.224 0.000 0.000 0.776
#> SRR1058024     2  0.1302      0.950 0.000 0.956 0.000 0.044
#> SRR1058025     2  0.1940      0.925 0.000 0.924 0.000 0.076
#> SRR1058026     2  0.2921      0.859 0.000 0.860 0.000 0.140
#> SRR1058027     2  0.2647      0.883 0.000 0.880 0.000 0.120
#> SRR1058028     2  0.1792      0.931 0.000 0.932 0.000 0.068
#> SRR1058029     2  0.0524      0.960 0.000 0.988 0.008 0.004
#> SRR1058030     2  0.0657      0.959 0.000 0.984 0.012 0.004
#> SRR1058031     2  0.0376      0.961 0.000 0.992 0.004 0.004
#> SRR1058032     1  0.3074      0.829 0.848 0.000 0.000 0.152
#> SRR1058033     1  0.3074      0.829 0.848 0.000 0.000 0.152
#> SRR1058034     1  0.3074      0.829 0.848 0.000 0.000 0.152
#> SRR1058035     1  0.0000      0.960 1.000 0.000 0.000 0.000
#> SRR1058036     1  0.0000      0.960 1.000 0.000 0.000 0.000
#> SRR1058037     1  0.0000      0.960 1.000 0.000 0.000 0.000
#> SRR1058038     1  0.0000      0.960 1.000 0.000 0.000 0.000
#> SRR1058039     1  0.0000      0.960 1.000 0.000 0.000 0.000
#> SRR1058040     1  0.0000      0.960 1.000 0.000 0.000 0.000
#> SRR1058041     1  0.0000      0.960 1.000 0.000 0.000 0.000
#> SRR1058042     1  0.0000      0.960 1.000 0.000 0.000 0.000
#> SRR1058043     1  0.0000      0.960 1.000 0.000 0.000 0.000
#> SRR1058044     1  0.0000      0.960 1.000 0.000 0.000 0.000
#> SRR1058045     1  0.0000      0.960 1.000 0.000 0.000 0.000
#> SRR1058046     1  0.0000      0.960 1.000 0.000 0.000 0.000
#> SRR1058047     3  0.0000      0.883 0.000 0.000 1.000 0.000
#> SRR1058048     3  0.0000      0.883 0.000 0.000 1.000 0.000
#> SRR1058049     3  0.0000      0.883 0.000 0.000 1.000 0.000
#> SRR1058050     3  0.0000      0.883 0.000 0.000 1.000 0.000
#> SRR1058051     3  0.0000      0.883 0.000 0.000 1.000 0.000
#> SRR1058052     3  0.0000      0.883 0.000 0.000 1.000 0.000
#> SRR1058053     3  0.0000      0.883 0.000 0.000 1.000 0.000
#> SRR1058054     3  0.0000      0.883 0.000 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4    p5
#> SRR1058003     4  0.4294     -0.148 0.000 0.000 0.000 0.532 0.468
#> SRR1058004     4  0.0880      0.416 0.000 0.032 0.000 0.968 0.000
#> SRR1058006     5  0.1571      0.865 0.004 0.000 0.000 0.060 0.936
#> SRR1058005     4  0.0880      0.416 0.000 0.032 0.000 0.968 0.000
#> SRR1058007     2  0.5143      0.673 0.000 0.532 0.000 0.428 0.040
#> SRR1058008     2  0.5157      0.666 0.000 0.520 0.000 0.440 0.040
#> SRR1058009     2  0.5056      0.714 0.000 0.596 0.000 0.360 0.044
#> SRR1058010     2  0.5004      0.723 0.000 0.672 0.000 0.256 0.072
#> SRR1058011     2  0.5006      0.728 0.000 0.624 0.000 0.328 0.048
#> SRR1058012     5  0.3616      0.696 0.000 0.164 0.000 0.032 0.804
#> SRR1058013     2  0.4990      0.713 0.000 0.600 0.000 0.360 0.040
#> SRR1058014     2  0.5048      0.706 0.000 0.580 0.000 0.380 0.040
#> SRR1058015     5  0.0794      0.898 0.028 0.000 0.000 0.000 0.972
#> SRR1058016     2  0.3601      0.777 0.000 0.820 0.000 0.128 0.052
#> SRR1058017     2  0.3238      0.796 0.000 0.836 0.000 0.136 0.028
#> SRR1058018     5  0.1732      0.884 0.080 0.000 0.000 0.000 0.920
#> SRR1058019     2  0.2690      0.788 0.000 0.844 0.000 0.156 0.000
#> SRR1058020     2  0.1399      0.766 0.000 0.952 0.000 0.020 0.028
#> SRR1058021     5  0.1682      0.902 0.044 0.012 0.000 0.004 0.940
#> SRR1058022     2  0.2813      0.788 0.000 0.832 0.000 0.168 0.000
#> SRR1058023     5  0.1544      0.895 0.068 0.000 0.000 0.000 0.932
#> SRR1058024     2  0.1668      0.761 0.000 0.940 0.000 0.032 0.028
#> SRR1058025     2  0.1741      0.750 0.000 0.936 0.000 0.024 0.040
#> SRR1058026     2  0.3366      0.652 0.000 0.828 0.000 0.032 0.140
#> SRR1058027     2  0.2769      0.706 0.000 0.876 0.000 0.032 0.092
#> SRR1058028     2  0.2139      0.738 0.000 0.916 0.000 0.032 0.052
#> SRR1058029     2  0.3053      0.785 0.000 0.828 0.008 0.164 0.000
#> SRR1058030     2  0.3093      0.784 0.000 0.824 0.008 0.168 0.000
#> SRR1058031     2  0.2806      0.788 0.000 0.844 0.004 0.152 0.000
#> SRR1058032     4  0.4304      0.376 0.484 0.000 0.000 0.516 0.000
#> SRR1058033     4  0.4304      0.376 0.484 0.000 0.000 0.516 0.000
#> SRR1058034     4  0.4304      0.376 0.484 0.000 0.000 0.516 0.000
#> SRR1058035     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1058036     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1058037     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1058038     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1058039     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1058040     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1058041     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1058042     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1058043     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1058044     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1058045     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1058046     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1058047     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1058048     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1058049     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1058050     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1058051     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1058052     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1058053     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1058054     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR1058003     4  0.2996      0.639 0.000 0.000 0.000 0.772 0.228 0.000
#> SRR1058004     4  0.2362      0.756 0.000 0.136 0.000 0.860 0.004 0.000
#> SRR1058006     5  0.0632      0.864 0.000 0.000 0.000 0.024 0.976 0.000
#> SRR1058005     4  0.2320      0.759 0.000 0.132 0.000 0.864 0.004 0.000
#> SRR1058007     2  0.2265      0.668 0.000 0.896 0.000 0.076 0.004 0.024
#> SRR1058008     2  0.2485      0.669 0.000 0.884 0.000 0.084 0.008 0.024
#> SRR1058009     2  0.2586      0.711 0.000 0.868 0.000 0.032 0.000 0.100
#> SRR1058010     2  0.3952      0.497 0.000 0.672 0.000 0.020 0.000 0.308
#> SRR1058011     2  0.2350      0.715 0.000 0.880 0.000 0.020 0.000 0.100
#> SRR1058012     5  0.5364      0.287 0.000 0.060 0.000 0.020 0.472 0.448
#> SRR1058013     2  0.2436      0.711 0.000 0.880 0.000 0.032 0.000 0.088
#> SRR1058014     2  0.2679      0.715 0.000 0.868 0.000 0.032 0.004 0.096
#> SRR1058015     5  0.0405      0.877 0.004 0.000 0.000 0.000 0.988 0.008
#> SRR1058016     2  0.3778      0.538 0.000 0.696 0.000 0.016 0.000 0.288
#> SRR1058017     2  0.4049      0.366 0.000 0.648 0.000 0.020 0.000 0.332
#> SRR1058018     5  0.0363      0.877 0.012 0.000 0.000 0.000 0.988 0.000
#> SRR1058019     6  0.5029      0.346 0.000 0.452 0.000 0.060 0.004 0.484
#> SRR1058020     6  0.3780      0.543 0.000 0.248 0.000 0.020 0.004 0.728
#> SRR1058021     5  0.0405      0.876 0.004 0.000 0.000 0.000 0.988 0.008
#> SRR1058022     2  0.4934     -0.369 0.000 0.488 0.000 0.052 0.004 0.456
#> SRR1058023     5  0.0363      0.877 0.012 0.000 0.000 0.000 0.988 0.000
#> SRR1058024     6  0.3593      0.581 0.000 0.208 0.000 0.024 0.004 0.764
#> SRR1058025     6  0.2847      0.595 0.000 0.120 0.000 0.016 0.012 0.852
#> SRR1058026     6  0.2332      0.525 0.000 0.040 0.000 0.020 0.036 0.904
#> SRR1058027     6  0.2366      0.528 0.000 0.056 0.000 0.020 0.024 0.900
#> SRR1058028     6  0.1787      0.570 0.000 0.068 0.000 0.008 0.004 0.920
#> SRR1058029     6  0.5253      0.368 0.000 0.444 0.008 0.060 0.004 0.484
#> SRR1058030     6  0.5344      0.336 0.000 0.460 0.012 0.060 0.004 0.464
#> SRR1058031     6  0.5255      0.361 0.000 0.448 0.008 0.060 0.004 0.480
#> SRR1058032     4  0.2631      0.816 0.180 0.000 0.000 0.820 0.000 0.000
#> SRR1058033     4  0.2631      0.816 0.180 0.000 0.000 0.820 0.000 0.000
#> SRR1058034     4  0.2597      0.818 0.176 0.000 0.000 0.824 0.000 0.000
#> SRR1058035     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058036     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058037     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058038     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058039     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058040     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058041     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058042     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058043     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058044     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058045     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058046     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058047     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1058048     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1058049     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1058050     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1058051     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1058052     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1058053     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1058054     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.983       0.992         0.4649 0.538   0.538
#> 3 3 1.000           0.972       0.988         0.2130 0.889   0.797
#> 4 4 0.851           0.791       0.912         0.1264 0.977   0.949
#> 5 5 0.787           0.707       0.841         0.0534 0.942   0.864
#> 6 6 0.758           0.592       0.841         0.0398 0.922   0.807

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
#> SRR1058003     2  0.3879      0.920 0.076 0.924
#> SRR1058004     2  0.0000      0.990 0.000 1.000
#> SRR1058006     2  0.3114      0.940 0.056 0.944
#> SRR1058005     2  0.0000      0.990 0.000 1.000
#> SRR1058007     2  0.0000      0.990 0.000 1.000
#> SRR1058008     2  0.0000      0.990 0.000 1.000
#> SRR1058009     2  0.0000      0.990 0.000 1.000
#> SRR1058010     2  0.0000      0.990 0.000 1.000
#> SRR1058011     2  0.0000      0.990 0.000 1.000
#> SRR1058012     2  0.0938      0.980 0.012 0.988
#> SRR1058013     2  0.0000      0.990 0.000 1.000
#> SRR1058014     2  0.0000      0.990 0.000 1.000
#> SRR1058015     2  0.7219      0.760 0.200 0.800
#> SRR1058016     2  0.0000      0.990 0.000 1.000
#> SRR1058017     2  0.0000      0.990 0.000 1.000
#> SRR1058018     1  0.0000      0.996 1.000 0.000
#> SRR1058019     2  0.0000      0.990 0.000 1.000
#> SRR1058020     2  0.0000      0.990 0.000 1.000
#> SRR1058021     1  0.3584      0.928 0.932 0.068
#> SRR1058022     2  0.0000      0.990 0.000 1.000
#> SRR1058023     1  0.0000      0.996 1.000 0.000
#> SRR1058024     2  0.0000      0.990 0.000 1.000
#> SRR1058025     2  0.0000      0.990 0.000 1.000
#> SRR1058026     2  0.0000      0.990 0.000 1.000
#> SRR1058027     2  0.0000      0.990 0.000 1.000
#> SRR1058028     2  0.0000      0.990 0.000 1.000
#> SRR1058029     2  0.0000      0.990 0.000 1.000
#> SRR1058030     2  0.0000      0.990 0.000 1.000
#> SRR1058031     2  0.0000      0.990 0.000 1.000
#> SRR1058032     1  0.0000      0.996 1.000 0.000
#> SRR1058033     1  0.0376      0.992 0.996 0.004
#> SRR1058034     1  0.0000      0.996 1.000 0.000
#> SRR1058035     1  0.0000      0.996 1.000 0.000
#> SRR1058036     1  0.0000      0.996 1.000 0.000
#> SRR1058037     1  0.0000      0.996 1.000 0.000
#> SRR1058038     1  0.0000      0.996 1.000 0.000
#> SRR1058039     1  0.0000      0.996 1.000 0.000
#> SRR1058040     1  0.0000      0.996 1.000 0.000
#> SRR1058041     1  0.0000      0.996 1.000 0.000
#> SRR1058042     1  0.0000      0.996 1.000 0.000
#> SRR1058043     1  0.0000      0.996 1.000 0.000
#> SRR1058044     1  0.0000      0.996 1.000 0.000
#> SRR1058045     1  0.0000      0.996 1.000 0.000
#> SRR1058046     1  0.0000      0.996 1.000 0.000
#> SRR1058047     2  0.0000      0.990 0.000 1.000
#> SRR1058048     2  0.0000      0.990 0.000 1.000
#> SRR1058049     2  0.0000      0.990 0.000 1.000
#> SRR1058050     2  0.0000      0.990 0.000 1.000
#> SRR1058051     2  0.0000      0.990 0.000 1.000
#> SRR1058052     2  0.0000      0.990 0.000 1.000
#> SRR1058053     2  0.0000      0.990 0.000 1.000
#> SRR1058054     2  0.0000      0.990 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1058003     3   0.000      1.000 0.000 0.000 1.000
#> SRR1058004     3   0.000      1.000 0.000 0.000 1.000
#> SRR1058006     2   0.460      0.749 0.000 0.796 0.204
#> SRR1058005     3   0.000      1.000 0.000 0.000 1.000
#> SRR1058007     2   0.000      0.984 0.000 1.000 0.000
#> SRR1058008     2   0.000      0.984 0.000 1.000 0.000
#> SRR1058009     2   0.000      0.984 0.000 1.000 0.000
#> SRR1058010     2   0.000      0.984 0.000 1.000 0.000
#> SRR1058011     2   0.000      0.984 0.000 1.000 0.000
#> SRR1058012     2   0.103      0.961 0.024 0.976 0.000
#> SRR1058013     2   0.000      0.984 0.000 1.000 0.000
#> SRR1058014     2   0.000      0.984 0.000 1.000 0.000
#> SRR1058015     2   0.484      0.711 0.224 0.776 0.000
#> SRR1058016     2   0.000      0.984 0.000 1.000 0.000
#> SRR1058017     2   0.000      0.984 0.000 1.000 0.000
#> SRR1058018     1   0.000      0.985 1.000 0.000 0.000
#> SRR1058019     2   0.000      0.984 0.000 1.000 0.000
#> SRR1058020     2   0.000      0.984 0.000 1.000 0.000
#> SRR1058021     1   0.382      0.768 0.852 0.148 0.000
#> SRR1058022     2   0.000      0.984 0.000 1.000 0.000
#> SRR1058023     1   0.000      0.985 1.000 0.000 0.000
#> SRR1058024     2   0.000      0.984 0.000 1.000 0.000
#> SRR1058025     2   0.000      0.984 0.000 1.000 0.000
#> SRR1058026     2   0.000      0.984 0.000 1.000 0.000
#> SRR1058027     2   0.000      0.984 0.000 1.000 0.000
#> SRR1058028     2   0.000      0.984 0.000 1.000 0.000
#> SRR1058029     2   0.000      0.984 0.000 1.000 0.000
#> SRR1058030     2   0.000      0.984 0.000 1.000 0.000
#> SRR1058031     2   0.000      0.984 0.000 1.000 0.000
#> SRR1058032     3   0.000      1.000 0.000 0.000 1.000
#> SRR1058033     3   0.000      1.000 0.000 0.000 1.000
#> SRR1058034     3   0.000      1.000 0.000 0.000 1.000
#> SRR1058035     1   0.000      0.985 1.000 0.000 0.000
#> SRR1058036     1   0.000      0.985 1.000 0.000 0.000
#> SRR1058037     1   0.000      0.985 1.000 0.000 0.000
#> SRR1058038     1   0.000      0.985 1.000 0.000 0.000
#> SRR1058039     1   0.000      0.985 1.000 0.000 0.000
#> SRR1058040     1   0.000      0.985 1.000 0.000 0.000
#> SRR1058041     1   0.000      0.985 1.000 0.000 0.000
#> SRR1058042     1   0.000      0.985 1.000 0.000 0.000
#> SRR1058043     1   0.000      0.985 1.000 0.000 0.000
#> SRR1058044     1   0.000      0.985 1.000 0.000 0.000
#> SRR1058045     1   0.000      0.985 1.000 0.000 0.000
#> SRR1058046     1   0.000      0.985 1.000 0.000 0.000
#> SRR1058047     2   0.000      0.984 0.000 1.000 0.000
#> SRR1058048     2   0.000      0.984 0.000 1.000 0.000
#> SRR1058049     2   0.000      0.984 0.000 1.000 0.000
#> SRR1058050     2   0.000      0.984 0.000 1.000 0.000
#> SRR1058051     2   0.000      0.984 0.000 1.000 0.000
#> SRR1058052     2   0.000      0.984 0.000 1.000 0.000
#> SRR1058053     2   0.000      0.984 0.000 1.000 0.000
#> SRR1058054     2   0.000      0.984 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1058003     4  0.4888      1.000 0.000 0.000 0.412 0.588
#> SRR1058004     4  0.4888      1.000 0.000 0.000 0.412 0.588
#> SRR1058006     2  0.2101      0.707 0.000 0.928 0.060 0.012
#> SRR1058005     4  0.4888      1.000 0.000 0.000 0.412 0.588
#> SRR1058007     2  0.0188      0.768 0.000 0.996 0.004 0.000
#> SRR1058008     2  0.0188      0.768 0.000 0.996 0.004 0.000
#> SRR1058009     2  0.0188      0.768 0.000 0.996 0.004 0.000
#> SRR1058010     2  0.0188      0.768 0.000 0.996 0.004 0.000
#> SRR1058011     2  0.0188      0.768 0.000 0.996 0.004 0.000
#> SRR1058012     3  0.5105      0.000 0.004 0.432 0.564 0.000
#> SRR1058013     2  0.0188      0.768 0.000 0.996 0.004 0.000
#> SRR1058014     2  0.0188      0.768 0.000 0.996 0.004 0.000
#> SRR1058015     2  0.4323      0.471 0.204 0.776 0.020 0.000
#> SRR1058016     2  0.0376      0.769 0.000 0.992 0.004 0.004
#> SRR1058017     2  0.0524      0.768 0.000 0.988 0.004 0.008
#> SRR1058018     1  0.0707      0.979 0.980 0.000 0.020 0.000
#> SRR1058019     2  0.4888      0.497 0.000 0.588 0.000 0.412
#> SRR1058020     2  0.4564      0.560 0.000 0.672 0.000 0.328
#> SRR1058021     1  0.2174      0.911 0.928 0.052 0.020 0.000
#> SRR1058022     2  0.4888      0.497 0.000 0.588 0.000 0.412
#> SRR1058023     1  0.0707      0.979 0.980 0.000 0.020 0.000
#> SRR1058024     2  0.4888      0.497 0.000 0.588 0.000 0.412
#> SRR1058025     2  0.4564      0.560 0.000 0.672 0.000 0.328
#> SRR1058026     2  0.0336      0.769 0.000 0.992 0.000 0.008
#> SRR1058027     2  0.2011      0.729 0.000 0.920 0.000 0.080
#> SRR1058028     2  0.4877      0.500 0.000 0.592 0.000 0.408
#> SRR1058029     2  0.4888      0.497 0.000 0.588 0.000 0.412
#> SRR1058030     2  0.4888      0.497 0.000 0.588 0.000 0.412
#> SRR1058031     2  0.4888      0.497 0.000 0.588 0.000 0.412
#> SRR1058032     4  0.4888      1.000 0.000 0.000 0.412 0.588
#> SRR1058033     4  0.4888      1.000 0.000 0.000 0.412 0.588
#> SRR1058034     4  0.4888      1.000 0.000 0.000 0.412 0.588
#> SRR1058035     1  0.0000      0.991 1.000 0.000 0.000 0.000
#> SRR1058036     1  0.0000      0.991 1.000 0.000 0.000 0.000
#> SRR1058037     1  0.0000      0.991 1.000 0.000 0.000 0.000
#> SRR1058038     1  0.0000      0.991 1.000 0.000 0.000 0.000
#> SRR1058039     1  0.0000      0.991 1.000 0.000 0.000 0.000
#> SRR1058040     1  0.0000      0.991 1.000 0.000 0.000 0.000
#> SRR1058041     1  0.0000      0.991 1.000 0.000 0.000 0.000
#> SRR1058042     1  0.0000      0.991 1.000 0.000 0.000 0.000
#> SRR1058043     1  0.0000      0.991 1.000 0.000 0.000 0.000
#> SRR1058044     1  0.0000      0.991 1.000 0.000 0.000 0.000
#> SRR1058045     1  0.0000      0.991 1.000 0.000 0.000 0.000
#> SRR1058046     1  0.0000      0.991 1.000 0.000 0.000 0.000
#> SRR1058047     2  0.0000      0.770 0.000 1.000 0.000 0.000
#> SRR1058048     2  0.0000      0.770 0.000 1.000 0.000 0.000
#> SRR1058049     2  0.0188      0.770 0.000 0.996 0.000 0.004
#> SRR1058050     2  0.0188      0.770 0.000 0.996 0.000 0.004
#> SRR1058051     2  0.0000      0.770 0.000 1.000 0.000 0.000
#> SRR1058052     2  0.0000      0.770 0.000 1.000 0.000 0.000
#> SRR1058053     2  0.0188      0.770 0.000 0.996 0.000 0.004
#> SRR1058054     2  0.0188      0.770 0.000 0.996 0.000 0.004

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4    p5
#> SRR1058003     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000
#> SRR1058004     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000
#> SRR1058006     2  0.6651      0.653 0.000 0.516 0.200 0.012 0.272
#> SRR1058005     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000
#> SRR1058007     2  0.4291      0.798 0.000 0.536 0.000 0.000 0.464
#> SRR1058008     2  0.4291      0.798 0.000 0.536 0.000 0.000 0.464
#> SRR1058009     2  0.4291      0.798 0.000 0.536 0.000 0.000 0.464
#> SRR1058010     2  0.4300      0.794 0.000 0.524 0.000 0.000 0.476
#> SRR1058011     2  0.4291      0.798 0.000 0.536 0.000 0.000 0.464
#> SRR1058012     3  0.2648      0.000 0.000 0.000 0.848 0.000 0.152
#> SRR1058013     2  0.4291      0.798 0.000 0.536 0.000 0.000 0.464
#> SRR1058014     2  0.4291      0.798 0.000 0.536 0.000 0.000 0.464
#> SRR1058015     2  0.6773      0.588 0.012 0.496 0.232 0.000 0.260
#> SRR1058016     2  0.4291      0.798 0.000 0.536 0.000 0.000 0.464
#> SRR1058017     2  0.4287      0.798 0.000 0.540 0.000 0.000 0.460
#> SRR1058018     5  0.6349      0.958 0.244 0.000 0.232 0.000 0.524
#> SRR1058019     2  0.0000      0.531 0.000 1.000 0.000 0.000 0.000
#> SRR1058020     2  0.2329      0.630 0.000 0.876 0.000 0.000 0.124
#> SRR1058021     5  0.6793      0.920 0.244 0.016 0.232 0.000 0.508
#> SRR1058022     2  0.0162      0.531 0.000 0.996 0.000 0.000 0.004
#> SRR1058023     5  0.6349      0.958 0.244 0.000 0.232 0.000 0.524
#> SRR1058024     2  0.0290      0.530 0.000 0.992 0.000 0.000 0.008
#> SRR1058025     2  0.2280      0.620 0.000 0.880 0.000 0.000 0.120
#> SRR1058026     1  0.5450     -0.567 0.496 0.060 0.000 0.000 0.444
#> SRR1058027     2  0.4126      0.777 0.000 0.620 0.000 0.000 0.380
#> SRR1058028     2  0.0162      0.535 0.000 0.996 0.000 0.000 0.004
#> SRR1058029     2  0.0000      0.531 0.000 1.000 0.000 0.000 0.000
#> SRR1058030     2  0.0000      0.531 0.000 1.000 0.000 0.000 0.000
#> SRR1058031     2  0.0000      0.531 0.000 1.000 0.000 0.000 0.000
#> SRR1058032     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000
#> SRR1058033     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000
#> SRR1058034     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000
#> SRR1058035     1  0.4307      0.664 0.504 0.000 0.000 0.000 0.496
#> SRR1058036     1  0.4307      0.664 0.504 0.000 0.000 0.000 0.496
#> SRR1058037     1  0.4307      0.664 0.504 0.000 0.000 0.000 0.496
#> SRR1058038     1  0.4307      0.664 0.504 0.000 0.000 0.000 0.496
#> SRR1058039     1  0.4307      0.664 0.504 0.000 0.000 0.000 0.496
#> SRR1058040     1  0.4307      0.664 0.504 0.000 0.000 0.000 0.496
#> SRR1058041     1  0.4307      0.664 0.504 0.000 0.000 0.000 0.496
#> SRR1058042     1  0.4307      0.664 0.504 0.000 0.000 0.000 0.496
#> SRR1058043     1  0.4307      0.664 0.504 0.000 0.000 0.000 0.496
#> SRR1058044     1  0.4307      0.664 0.504 0.000 0.000 0.000 0.496
#> SRR1058045     1  0.4307      0.664 0.504 0.000 0.000 0.000 0.496
#> SRR1058046     1  0.4307      0.664 0.504 0.000 0.000 0.000 0.496
#> SRR1058047     2  0.4287      0.798 0.000 0.540 0.000 0.000 0.460
#> SRR1058048     2  0.4287      0.798 0.000 0.540 0.000 0.000 0.460
#> SRR1058049     2  0.4287      0.798 0.000 0.540 0.000 0.000 0.460
#> SRR1058050     2  0.4287      0.798 0.000 0.540 0.000 0.000 0.460
#> SRR1058051     2  0.4287      0.798 0.000 0.540 0.000 0.000 0.460
#> SRR1058052     2  0.4287      0.798 0.000 0.540 0.000 0.000 0.460
#> SRR1058053     2  0.4287      0.798 0.000 0.540 0.000 0.000 0.460
#> SRR1058054     2  0.4287      0.798 0.000 0.540 0.000 0.000 0.460

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR1058003     4  0.0000      0.997 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1058004     4  0.0260      0.993 0.000 0.000 0.000 0.992 0.000 0.008
#> SRR1058006     2  0.6845      0.414 0.000 0.480 0.268 0.000 0.136 0.116
#> SRR1058005     4  0.0260      0.993 0.000 0.000 0.000 0.992 0.000 0.008
#> SRR1058007     2  0.3993      0.578 0.000 0.520 0.476 0.000 0.000 0.004
#> SRR1058008     2  0.3995      0.576 0.000 0.516 0.480 0.000 0.000 0.004
#> SRR1058009     2  0.3993      0.578 0.000 0.520 0.476 0.000 0.000 0.004
#> SRR1058010     3  0.3998     -0.783 0.000 0.492 0.504 0.000 0.000 0.004
#> SRR1058011     2  0.3995      0.576 0.000 0.516 0.480 0.000 0.000 0.004
#> SRR1058012     3  0.3828     -0.651 0.000 0.000 0.560 0.000 0.440 0.000
#> SRR1058013     2  0.3993      0.578 0.000 0.520 0.476 0.000 0.000 0.004
#> SRR1058014     2  0.3993      0.578 0.000 0.520 0.476 0.000 0.000 0.004
#> SRR1058015     2  0.7433      0.174 0.008 0.432 0.204 0.000 0.140 0.216
#> SRR1058016     2  0.3995      0.576 0.000 0.516 0.480 0.000 0.000 0.004
#> SRR1058017     2  0.3989      0.580 0.000 0.528 0.468 0.000 0.000 0.004
#> SRR1058018     1  0.4965      0.596 0.644 0.000 0.000 0.000 0.140 0.216
#> SRR1058019     2  0.0146      0.389 0.000 0.996 0.000 0.000 0.000 0.004
#> SRR1058020     2  0.2362      0.474 0.000 0.860 0.136 0.000 0.000 0.004
#> SRR1058021     1  0.5383      0.571 0.628 0.016 0.000 0.000 0.140 0.216
#> SRR1058022     2  0.0508      0.387 0.000 0.984 0.012 0.000 0.000 0.004
#> SRR1058023     1  0.4965      0.596 0.644 0.000 0.000 0.000 0.140 0.216
#> SRR1058024     2  0.0508      0.387 0.000 0.984 0.012 0.000 0.000 0.004
#> SRR1058025     2  0.2278      0.466 0.000 0.868 0.128 0.000 0.000 0.004
#> SRR1058026     5  0.6220      0.000 0.000 0.048 0.120 0.000 0.496 0.336
#> SRR1058027     6  0.5296      0.000 0.000 0.128 0.308 0.000 0.000 0.564
#> SRR1058028     2  0.0291      0.393 0.000 0.992 0.004 0.000 0.000 0.004
#> SRR1058029     2  0.0000      0.391 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1058030     2  0.0000      0.391 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1058031     2  0.0000      0.391 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1058032     4  0.0000      0.997 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1058033     4  0.0000      0.997 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1058034     4  0.0000      0.997 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1058035     1  0.0000      0.918 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058036     1  0.0000      0.918 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058037     1  0.0000      0.918 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058038     1  0.0000      0.918 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058039     1  0.0000      0.918 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058040     1  0.0000      0.918 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058041     1  0.0000      0.918 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058042     1  0.0000      0.918 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058043     1  0.0000      0.918 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058044     1  0.0000      0.918 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058045     1  0.0000      0.918 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058046     1  0.0000      0.918 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058047     2  0.4183      0.568 0.000 0.508 0.480 0.000 0.000 0.012
#> SRR1058048     2  0.3995      0.574 0.000 0.516 0.480 0.000 0.000 0.004
#> SRR1058049     2  0.3995      0.574 0.000 0.516 0.480 0.000 0.000 0.004
#> SRR1058050     2  0.3995      0.574 0.000 0.516 0.480 0.000 0.000 0.004
#> SRR1058051     2  0.4183      0.568 0.000 0.508 0.480 0.000 0.000 0.012
#> SRR1058052     2  0.3995      0.574 0.000 0.516 0.480 0.000 0.000 0.004
#> SRR1058053     2  0.3995      0.574 0.000 0.516 0.480 0.000 0.000 0.004
#> SRR1058054     2  0.3995      0.574 0.000 0.516 0.480 0.000 0.000 0.004

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

consensus_heatmap(res, k = 2)

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

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

collect_plots(res)

plot of chunk MAD-mclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.3626 0.638   0.638
#> 3 3 0.627           0.864       0.913         0.6759 0.759   0.623
#> 4 4 0.885           0.832       0.923         0.0927 0.916   0.793
#> 5 5 0.689           0.700       0.800         0.1618 0.885   0.647
#> 6 6 0.751           0.725       0.819         0.0683 0.944   0.747

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
#> SRR1058003     2       0          1  0  1
#> SRR1058004     2       0          1  0  1
#> SRR1058006     2       0          1  0  1
#> SRR1058005     2       0          1  0  1
#> SRR1058007     2       0          1  0  1
#> SRR1058008     2       0          1  0  1
#> SRR1058009     2       0          1  0  1
#> SRR1058010     2       0          1  0  1
#> SRR1058011     2       0          1  0  1
#> SRR1058012     2       0          1  0  1
#> SRR1058013     2       0          1  0  1
#> SRR1058014     2       0          1  0  1
#> SRR1058015     2       0          1  0  1
#> SRR1058016     2       0          1  0  1
#> SRR1058017     2       0          1  0  1
#> SRR1058018     2       0          1  0  1
#> SRR1058019     2       0          1  0  1
#> SRR1058020     2       0          1  0  1
#> SRR1058021     2       0          1  0  1
#> SRR1058022     2       0          1  0  1
#> SRR1058023     2       0          1  0  1
#> SRR1058024     2       0          1  0  1
#> SRR1058025     2       0          1  0  1
#> SRR1058026     2       0          1  0  1
#> SRR1058027     2       0          1  0  1
#> SRR1058028     2       0          1  0  1
#> SRR1058029     2       0          1  0  1
#> SRR1058030     2       0          1  0  1
#> SRR1058031     2       0          1  0  1
#> SRR1058032     2       0          1  0  1
#> SRR1058033     2       0          1  0  1
#> SRR1058034     2       0          1  0  1
#> SRR1058035     1       0          1  1  0
#> SRR1058036     1       0          1  1  0
#> SRR1058037     1       0          1  1  0
#> SRR1058038     1       0          1  1  0
#> SRR1058039     1       0          1  1  0
#> SRR1058040     1       0          1  1  0
#> SRR1058041     1       0          1  1  0
#> SRR1058042     1       0          1  1  0
#> SRR1058043     1       0          1  1  0
#> SRR1058044     1       0          1  1  0
#> SRR1058045     1       0          1  1  0
#> SRR1058046     1       0          1  1  0
#> SRR1058047     2       0          1  0  1
#> SRR1058048     2       0          1  0  1
#> SRR1058049     2       0          1  0  1
#> SRR1058050     2       0          1  0  1
#> SRR1058051     2       0          1  0  1
#> SRR1058052     2       0          1  0  1
#> SRR1058053     2       0          1  0  1
#> SRR1058054     2       0          1  0  1

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1058003     2  0.5058      0.748 0.000 0.756 0.244
#> SRR1058004     2  0.4931      0.741 0.000 0.768 0.232
#> SRR1058006     2  0.4346      0.812 0.000 0.816 0.184
#> SRR1058005     2  0.4931      0.741 0.000 0.768 0.232
#> SRR1058007     2  0.3551      0.837 0.000 0.868 0.132
#> SRR1058008     2  0.3619      0.834 0.000 0.864 0.136
#> SRR1058009     2  0.0424      0.876 0.000 0.992 0.008
#> SRR1058010     2  0.0424      0.876 0.000 0.992 0.008
#> SRR1058011     2  0.0424      0.876 0.000 0.992 0.008
#> SRR1058012     2  0.4062      0.828 0.000 0.836 0.164
#> SRR1058013     2  0.0000      0.876 0.000 1.000 0.000
#> SRR1058014     2  0.0000      0.876 0.000 1.000 0.000
#> SRR1058015     2  0.4121      0.825 0.000 0.832 0.168
#> SRR1058016     2  0.0000      0.876 0.000 1.000 0.000
#> SRR1058017     2  0.0000      0.876 0.000 1.000 0.000
#> SRR1058018     2  0.4121      0.825 0.000 0.832 0.168
#> SRR1058019     2  0.4002      0.744 0.000 0.840 0.160
#> SRR1058020     2  0.0000      0.876 0.000 1.000 0.000
#> SRR1058021     2  0.4121      0.825 0.000 0.832 0.168
#> SRR1058022     2  0.1163      0.862 0.000 0.972 0.028
#> SRR1058023     2  0.4121      0.825 0.000 0.832 0.168
#> SRR1058024     2  0.0000      0.876 0.000 1.000 0.000
#> SRR1058025     2  0.0000      0.876 0.000 1.000 0.000
#> SRR1058026     2  0.0000      0.876 0.000 1.000 0.000
#> SRR1058027     2  0.0000      0.876 0.000 1.000 0.000
#> SRR1058028     2  0.0000      0.876 0.000 1.000 0.000
#> SRR1058029     2  0.4504      0.715 0.000 0.804 0.196
#> SRR1058030     2  0.5810      0.623 0.000 0.664 0.336
#> SRR1058031     2  0.4504      0.715 0.000 0.804 0.196
#> SRR1058032     3  0.6977      0.768 0.076 0.212 0.712
#> SRR1058033     3  0.6977      0.768 0.076 0.212 0.712
#> SRR1058034     3  0.6977      0.768 0.076 0.212 0.712
#> SRR1058035     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1058036     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1058037     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1058038     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1058039     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1058040     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1058041     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1058042     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1058043     1  0.0237      0.996 0.996 0.000 0.004
#> SRR1058044     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1058045     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1058046     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1058047     3  0.4504      0.821 0.000 0.196 0.804
#> SRR1058048     3  0.3412      0.850 0.000 0.124 0.876
#> SRR1058049     3  0.1163      0.849 0.000 0.028 0.972
#> SRR1058050     3  0.1163      0.849 0.000 0.028 0.972
#> SRR1058051     3  0.4504      0.821 0.000 0.196 0.804
#> SRR1058052     3  0.1163      0.849 0.000 0.028 0.972
#> SRR1058053     3  0.1163      0.849 0.000 0.028 0.972
#> SRR1058054     3  0.1163      0.849 0.000 0.028 0.972

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1058003     4  0.5165      0.312 0.000 0.484 0.004 0.512
#> SRR1058004     4  0.5602      0.348 0.000 0.472 0.020 0.508
#> SRR1058006     2  0.1978      0.894 0.000 0.928 0.004 0.068
#> SRR1058005     4  0.5602      0.348 0.000 0.472 0.020 0.508
#> SRR1058007     2  0.0000      0.922 0.000 1.000 0.000 0.000
#> SRR1058008     2  0.0336      0.921 0.000 0.992 0.008 0.000
#> SRR1058009     2  0.0000      0.922 0.000 1.000 0.000 0.000
#> SRR1058010     2  0.0188      0.921 0.000 0.996 0.000 0.004
#> SRR1058011     2  0.0376      0.921 0.000 0.992 0.004 0.004
#> SRR1058012     2  0.1743      0.906 0.000 0.940 0.004 0.056
#> SRR1058013     2  0.0000      0.922 0.000 1.000 0.000 0.000
#> SRR1058014     2  0.0000      0.922 0.000 1.000 0.000 0.000
#> SRR1058015     2  0.2053      0.892 0.000 0.924 0.004 0.072
#> SRR1058016     2  0.0188      0.921 0.000 0.996 0.000 0.004
#> SRR1058017     2  0.0895      0.917 0.000 0.976 0.020 0.004
#> SRR1058018     2  0.2125      0.889 0.000 0.920 0.004 0.076
#> SRR1058019     2  0.3583      0.740 0.000 0.816 0.180 0.004
#> SRR1058020     2  0.0188      0.921 0.000 0.996 0.000 0.004
#> SRR1058021     2  0.1978      0.894 0.000 0.928 0.004 0.068
#> SRR1058022     2  0.1302      0.902 0.000 0.956 0.044 0.000
#> SRR1058023     2  0.2125      0.889 0.000 0.920 0.004 0.076
#> SRR1058024     2  0.0000      0.922 0.000 1.000 0.000 0.000
#> SRR1058025     2  0.0000      0.922 0.000 1.000 0.000 0.000
#> SRR1058026     2  0.1022      0.917 0.000 0.968 0.000 0.032
#> SRR1058027     2  0.1022      0.917 0.000 0.968 0.000 0.032
#> SRR1058028     2  0.0921      0.918 0.000 0.972 0.000 0.028
#> SRR1058029     2  0.4426      0.698 0.000 0.772 0.204 0.024
#> SRR1058030     2  0.5062      0.550 0.000 0.692 0.284 0.024
#> SRR1058031     2  0.4365      0.720 0.000 0.784 0.188 0.028
#> SRR1058032     4  0.0817      0.433 0.024 0.000 0.000 0.976
#> SRR1058033     4  0.0817      0.433 0.024 0.000 0.000 0.976
#> SRR1058034     4  0.0817      0.433 0.024 0.000 0.000 0.976
#> SRR1058035     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> SRR1058036     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> SRR1058037     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> SRR1058038     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> SRR1058039     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> SRR1058040     1  0.0707      0.979 0.980 0.000 0.000 0.020
#> SRR1058041     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> SRR1058042     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> SRR1058043     1  0.2053      0.932 0.924 0.004 0.000 0.072
#> SRR1058044     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> SRR1058045     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> SRR1058046     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> SRR1058047     3  0.4950      0.527 0.000 0.004 0.620 0.376
#> SRR1058048     3  0.0188      0.882 0.000 0.004 0.996 0.000
#> SRR1058049     3  0.0188      0.882 0.000 0.004 0.996 0.000
#> SRR1058050     3  0.0188      0.882 0.000 0.004 0.996 0.000
#> SRR1058051     3  0.4950      0.527 0.000 0.004 0.620 0.376
#> SRR1058052     3  0.0188      0.882 0.000 0.004 0.996 0.000
#> SRR1058053     3  0.0188      0.882 0.000 0.004 0.996 0.000
#> SRR1058054     3  0.0188      0.882 0.000 0.004 0.996 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
#> SRR1058003     4  0.4676      0.576 0.000 0.072 0.000 0.720 0.208
#> SRR1058004     4  0.3754      0.758 0.000 0.084 0.000 0.816 0.100
#> SRR1058006     5  0.5932      0.592 0.000 0.308 0.000 0.132 0.560
#> SRR1058005     4  0.3754      0.758 0.000 0.084 0.000 0.816 0.100
#> SRR1058007     2  0.3164      0.591 0.000 0.852 0.000 0.044 0.104
#> SRR1058008     2  0.3359      0.584 0.000 0.840 0.000 0.052 0.108
#> SRR1058009     2  0.1952      0.628 0.000 0.912 0.000 0.004 0.084
#> SRR1058010     2  0.1588      0.647 0.000 0.948 0.016 0.008 0.028
#> SRR1058011     2  0.1913      0.652 0.000 0.932 0.016 0.008 0.044
#> SRR1058012     5  0.4495      0.585 0.000 0.244 0.000 0.044 0.712
#> SRR1058013     2  0.2237      0.630 0.000 0.904 0.004 0.008 0.084
#> SRR1058014     2  0.2513      0.605 0.000 0.876 0.000 0.008 0.116
#> SRR1058015     5  0.5027      0.646 0.000 0.304 0.000 0.056 0.640
#> SRR1058016     2  0.1701      0.647 0.000 0.944 0.016 0.012 0.028
#> SRR1058017     2  0.2522      0.647 0.000 0.904 0.028 0.012 0.056
#> SRR1058018     5  0.4863      0.652 0.000 0.296 0.000 0.048 0.656
#> SRR1058019     2  0.5132      0.552 0.000 0.712 0.184 0.012 0.092
#> SRR1058020     2  0.4517      0.338 0.000 0.616 0.004 0.008 0.372
#> SRR1058021     5  0.5271      0.641 0.000 0.296 0.000 0.076 0.628
#> SRR1058022     2  0.3927      0.594 0.000 0.792 0.164 0.004 0.040
#> SRR1058023     5  0.4863      0.652 0.000 0.296 0.000 0.048 0.656
#> SRR1058024     2  0.4595      0.283 0.000 0.588 0.004 0.008 0.400
#> SRR1058025     2  0.4613      0.263 0.000 0.580 0.004 0.008 0.408
#> SRR1058026     5  0.3990      0.356 0.000 0.308 0.004 0.000 0.688
#> SRR1058027     5  0.3990      0.356 0.000 0.308 0.004 0.000 0.688
#> SRR1058028     5  0.4088      0.356 0.000 0.304 0.008 0.000 0.688
#> SRR1058029     2  0.5777      0.493 0.000 0.652 0.184 0.012 0.152
#> SRR1058030     2  0.6319      0.360 0.000 0.560 0.280 0.012 0.148
#> SRR1058031     2  0.5777      0.493 0.000 0.652 0.184 0.012 0.152
#> SRR1058032     4  0.2536      0.789 0.128 0.000 0.000 0.868 0.004
#> SRR1058033     4  0.2536      0.789 0.128 0.000 0.000 0.868 0.004
#> SRR1058034     4  0.2536      0.789 0.128 0.000 0.000 0.868 0.004
#> SRR1058035     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1058036     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1058037     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1058038     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1058039     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1058040     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1058041     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1058042     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1058043     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1058044     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1058045     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1058046     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1058047     3  0.4935      0.441 0.000 0.040 0.616 0.344 0.000
#> SRR1058048     3  0.0162      0.873 0.000 0.004 0.996 0.000 0.000
#> SRR1058049     3  0.0162      0.873 0.000 0.004 0.996 0.000 0.000
#> SRR1058050     3  0.0162      0.873 0.000 0.004 0.996 0.000 0.000
#> SRR1058051     3  0.4950      0.433 0.000 0.040 0.612 0.348 0.000
#> SRR1058052     3  0.0162      0.873 0.000 0.004 0.996 0.000 0.000
#> SRR1058053     3  0.0162      0.873 0.000 0.004 0.996 0.000 0.000
#> SRR1058054     3  0.0162      0.873 0.000 0.004 0.996 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR1058003     4  0.3043     0.7853 0.000 0.008 0.000 0.792 0.200 0.000
#> SRR1058004     4  0.0363     0.8401 0.000 0.000 0.000 0.988 0.012 0.000
#> SRR1058006     5  0.3833     0.8680 0.000 0.016 0.000 0.052 0.788 0.144
#> SRR1058005     4  0.0363     0.8401 0.000 0.000 0.000 0.988 0.012 0.000
#> SRR1058007     2  0.4655     0.4854 0.000 0.704 0.000 0.032 0.216 0.048
#> SRR1058008     2  0.4700     0.4889 0.000 0.704 0.000 0.044 0.212 0.040
#> SRR1058009     2  0.3638     0.5342 0.000 0.784 0.000 0.008 0.172 0.036
#> SRR1058010     2  0.3466     0.5267 0.000 0.820 0.000 0.008 0.072 0.100
#> SRR1058011     2  0.4281     0.4854 0.000 0.732 0.000 0.000 0.136 0.132
#> SRR1058012     6  0.3969     0.0045 0.000 0.016 0.000 0.000 0.332 0.652
#> SRR1058013     2  0.3568     0.5367 0.000 0.788 0.000 0.008 0.172 0.032
#> SRR1058014     2  0.4121     0.5066 0.000 0.732 0.000 0.004 0.208 0.056
#> SRR1058015     5  0.2902     0.9138 0.000 0.000 0.000 0.004 0.800 0.196
#> SRR1058016     2  0.3297     0.5245 0.000 0.820 0.000 0.000 0.068 0.112
#> SRR1058017     2  0.5183     0.4685 0.000 0.692 0.028 0.008 0.104 0.168
#> SRR1058018     5  0.2527     0.9324 0.000 0.000 0.000 0.000 0.832 0.168
#> SRR1058019     2  0.6812     0.3232 0.000 0.500 0.196 0.000 0.100 0.204
#> SRR1058020     6  0.5378     0.4789 0.000 0.180 0.000 0.000 0.236 0.584
#> SRR1058021     5  0.3418     0.9024 0.000 0.008 0.000 0.016 0.784 0.192
#> SRR1058022     2  0.5723     0.3555 0.000 0.604 0.164 0.000 0.028 0.204
#> SRR1058023     5  0.2527     0.9324 0.000 0.000 0.000 0.000 0.832 0.168
#> SRR1058024     6  0.4990     0.5177 0.000 0.132 0.000 0.000 0.232 0.636
#> SRR1058025     6  0.4990     0.5185 0.000 0.132 0.000 0.000 0.232 0.636
#> SRR1058026     6  0.0260     0.6310 0.000 0.008 0.000 0.000 0.000 0.992
#> SRR1058027     6  0.0260     0.6310 0.000 0.008 0.000 0.000 0.000 0.992
#> SRR1058028     6  0.0260     0.6310 0.000 0.008 0.000 0.000 0.000 0.992
#> SRR1058029     2  0.7140     0.3046 0.000 0.456 0.196 0.000 0.140 0.208
#> SRR1058030     2  0.6887     0.3121 0.000 0.456 0.296 0.000 0.140 0.108
#> SRR1058031     2  0.7140     0.3046 0.000 0.456 0.196 0.000 0.140 0.208
#> SRR1058032     4  0.3563     0.8670 0.108 0.000 0.000 0.800 0.092 0.000
#> SRR1058033     4  0.3424     0.8742 0.096 0.000 0.000 0.812 0.092 0.000
#> SRR1058034     4  0.3472     0.8731 0.100 0.000 0.000 0.808 0.092 0.000
#> SRR1058035     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058036     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058037     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058038     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058039     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058040     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058041     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058042     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058043     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058044     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058045     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058046     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058047     3  0.3515     0.5831 0.000 0.000 0.676 0.324 0.000 0.000
#> SRR1058048     3  0.0547     0.8772 0.000 0.020 0.980 0.000 0.000 0.000
#> SRR1058049     3  0.0000     0.8929 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1058050     3  0.0000     0.8929 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1058051     3  0.3531     0.5763 0.000 0.000 0.672 0.328 0.000 0.000
#> SRR1058052     3  0.0000     0.8929 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1058053     3  0.0000     0.8929 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1058054     3  0.0000     0.8929 0.000 0.000 1.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.997       0.998         0.4986 0.502   0.502
#> 3 3 0.949           0.944       0.970         0.3171 0.818   0.649
#> 4 4 0.821           0.833       0.925         0.0634 0.939   0.832
#> 5 5 0.707           0.757       0.856         0.0777 0.919   0.752
#> 6 6 0.726           0.767       0.865         0.0372 0.956   0.830

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
#> SRR1058003     1  0.0000      1.000 1.000 0.000
#> SRR1058004     2  0.0000      0.997 0.000 1.000
#> SRR1058006     1  0.0000      1.000 1.000 0.000
#> SRR1058005     2  0.0000      0.997 0.000 1.000
#> SRR1058007     2  0.0000      0.997 0.000 1.000
#> SRR1058008     2  0.0000      0.997 0.000 1.000
#> SRR1058009     2  0.0000      0.997 0.000 1.000
#> SRR1058010     2  0.0000      0.997 0.000 1.000
#> SRR1058011     2  0.0000      0.997 0.000 1.000
#> SRR1058012     1  0.0000      1.000 1.000 0.000
#> SRR1058013     2  0.0000      0.997 0.000 1.000
#> SRR1058014     2  0.0000      0.997 0.000 1.000
#> SRR1058015     1  0.0000      1.000 1.000 0.000
#> SRR1058016     2  0.0000      0.997 0.000 1.000
#> SRR1058017     2  0.0000      0.997 0.000 1.000
#> SRR1058018     1  0.0000      1.000 1.000 0.000
#> SRR1058019     2  0.0000      0.997 0.000 1.000
#> SRR1058020     2  0.0000      0.997 0.000 1.000
#> SRR1058021     1  0.0000      1.000 1.000 0.000
#> SRR1058022     2  0.0000      0.997 0.000 1.000
#> SRR1058023     1  0.0000      1.000 1.000 0.000
#> SRR1058024     2  0.0376      0.994 0.004 0.996
#> SRR1058025     2  0.0938      0.987 0.012 0.988
#> SRR1058026     2  0.2423      0.961 0.040 0.960
#> SRR1058027     2  0.1843      0.973 0.028 0.972
#> SRR1058028     2  0.0000      0.997 0.000 1.000
#> SRR1058029     2  0.0000      0.997 0.000 1.000
#> SRR1058030     2  0.0000      0.997 0.000 1.000
#> SRR1058031     2  0.0000      0.997 0.000 1.000
#> SRR1058032     1  0.0000      1.000 1.000 0.000
#> SRR1058033     1  0.0000      1.000 1.000 0.000
#> SRR1058034     1  0.0000      1.000 1.000 0.000
#> SRR1058035     1  0.0000      1.000 1.000 0.000
#> SRR1058036     1  0.0000      1.000 1.000 0.000
#> SRR1058037     1  0.0000      1.000 1.000 0.000
#> SRR1058038     1  0.0000      1.000 1.000 0.000
#> SRR1058039     1  0.0000      1.000 1.000 0.000
#> SRR1058040     1  0.0000      1.000 1.000 0.000
#> SRR1058041     1  0.0000      1.000 1.000 0.000
#> SRR1058042     1  0.0000      1.000 1.000 0.000
#> SRR1058043     1  0.0000      1.000 1.000 0.000
#> SRR1058044     1  0.0000      1.000 1.000 0.000
#> SRR1058045     1  0.0000      1.000 1.000 0.000
#> SRR1058046     1  0.0000      1.000 1.000 0.000
#> SRR1058047     2  0.0000      0.997 0.000 1.000
#> SRR1058048     2  0.0000      0.997 0.000 1.000
#> SRR1058049     2  0.0000      0.997 0.000 1.000
#> SRR1058050     2  0.0000      0.997 0.000 1.000
#> SRR1058051     2  0.0000      0.997 0.000 1.000
#> SRR1058052     2  0.0000      0.997 0.000 1.000
#> SRR1058053     2  0.0000      0.997 0.000 1.000
#> SRR1058054     2  0.0000      0.997 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1058003     1  0.0000      0.988 1.000 0.000 0.000
#> SRR1058004     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1058006     1  0.0000      0.988 1.000 0.000 0.000
#> SRR1058005     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1058007     2  0.5810      0.578 0.000 0.664 0.336
#> SRR1058008     2  0.6079      0.473 0.000 0.612 0.388
#> SRR1058009     2  0.2537      0.902 0.000 0.920 0.080
#> SRR1058010     2  0.1529      0.926 0.000 0.960 0.040
#> SRR1058011     2  0.4346      0.803 0.000 0.816 0.184
#> SRR1058012     1  0.3752      0.832 0.856 0.144 0.000
#> SRR1058013     2  0.0592      0.935 0.000 0.988 0.012
#> SRR1058014     2  0.1411      0.928 0.000 0.964 0.036
#> SRR1058015     1  0.0747      0.977 0.984 0.016 0.000
#> SRR1058016     2  0.0000      0.935 0.000 1.000 0.000
#> SRR1058017     2  0.0747      0.934 0.000 0.984 0.016
#> SRR1058018     1  0.0424      0.983 0.992 0.008 0.000
#> SRR1058019     2  0.0424      0.935 0.000 0.992 0.008
#> SRR1058020     2  0.0000      0.935 0.000 1.000 0.000
#> SRR1058021     2  0.0747      0.927 0.016 0.984 0.000
#> SRR1058022     2  0.0000      0.935 0.000 1.000 0.000
#> SRR1058023     1  0.0747      0.977 0.984 0.016 0.000
#> SRR1058024     2  0.0000      0.935 0.000 1.000 0.000
#> SRR1058025     2  0.0000      0.935 0.000 1.000 0.000
#> SRR1058026     2  0.0000      0.935 0.000 1.000 0.000
#> SRR1058027     2  0.0000      0.935 0.000 1.000 0.000
#> SRR1058028     2  0.0000      0.935 0.000 1.000 0.000
#> SRR1058029     2  0.2261      0.909 0.000 0.932 0.068
#> SRR1058030     2  0.2959      0.890 0.000 0.900 0.100
#> SRR1058031     2  0.0892      0.933 0.000 0.980 0.020
#> SRR1058032     1  0.0000      0.988 1.000 0.000 0.000
#> SRR1058033     1  0.1163      0.966 0.972 0.000 0.028
#> SRR1058034     1  0.0892      0.973 0.980 0.000 0.020
#> SRR1058035     1  0.0000      0.988 1.000 0.000 0.000
#> SRR1058036     1  0.0000      0.988 1.000 0.000 0.000
#> SRR1058037     1  0.0000      0.988 1.000 0.000 0.000
#> SRR1058038     1  0.0000      0.988 1.000 0.000 0.000
#> SRR1058039     1  0.0000      0.988 1.000 0.000 0.000
#> SRR1058040     1  0.0000      0.988 1.000 0.000 0.000
#> SRR1058041     1  0.0000      0.988 1.000 0.000 0.000
#> SRR1058042     1  0.0000      0.988 1.000 0.000 0.000
#> SRR1058043     1  0.0000      0.988 1.000 0.000 0.000
#> SRR1058044     1  0.0000      0.988 1.000 0.000 0.000
#> SRR1058045     1  0.0000      0.988 1.000 0.000 0.000
#> SRR1058046     1  0.0000      0.988 1.000 0.000 0.000
#> SRR1058047     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1058048     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1058049     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1058050     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1058051     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1058052     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1058053     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1058054     3  0.0000      1.000 0.000 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1058003     1  0.4194     0.7539 0.800 0.172 0.000 0.028
#> SRR1058004     2  0.5511     0.3473 0.000 0.620 0.352 0.028
#> SRR1058006     1  0.5778     0.1292 0.500 0.472 0.000 0.028
#> SRR1058005     3  0.5780    -0.0154 0.000 0.476 0.496 0.028
#> SRR1058007     2  0.0707     0.8623 0.000 0.980 0.000 0.020
#> SRR1058008     2  0.0707     0.8623 0.000 0.980 0.000 0.020
#> SRR1058009     2  0.0336     0.8681 0.000 0.992 0.000 0.008
#> SRR1058010     2  0.0336     0.8684 0.000 0.992 0.000 0.008
#> SRR1058011     2  0.0707     0.8728 0.000 0.980 0.000 0.020
#> SRR1058012     1  0.3796     0.8044 0.848 0.096 0.000 0.056
#> SRR1058013     2  0.0188     0.8711 0.000 0.996 0.000 0.004
#> SRR1058014     2  0.0188     0.8694 0.000 0.996 0.000 0.004
#> SRR1058015     1  0.2831     0.8326 0.876 0.120 0.000 0.004
#> SRR1058016     2  0.0707     0.8728 0.000 0.980 0.000 0.020
#> SRR1058017     2  0.1211     0.8709 0.000 0.960 0.000 0.040
#> SRR1058018     1  0.0000     0.9315 1.000 0.000 0.000 0.000
#> SRR1058019     2  0.2281     0.8487 0.000 0.904 0.000 0.096
#> SRR1058020     2  0.2011     0.8574 0.000 0.920 0.000 0.080
#> SRR1058021     2  0.4123     0.7276 0.044 0.820 0.000 0.136
#> SRR1058022     2  0.1022     0.8722 0.000 0.968 0.000 0.032
#> SRR1058023     1  0.0469     0.9254 0.988 0.000 0.000 0.012
#> SRR1058024     2  0.3266     0.7961 0.000 0.832 0.000 0.168
#> SRR1058025     2  0.2149     0.8548 0.000 0.912 0.000 0.088
#> SRR1058026     4  0.0921     0.9704 0.000 0.028 0.000 0.972
#> SRR1058027     4  0.0921     0.9704 0.000 0.028 0.000 0.972
#> SRR1058028     4  0.1867     0.9407 0.000 0.072 0.000 0.928
#> SRR1058029     2  0.7201     0.3801 0.000 0.552 0.224 0.224
#> SRR1058030     2  0.5950     0.6356 0.000 0.696 0.156 0.148
#> SRR1058031     2  0.3529     0.7996 0.000 0.836 0.012 0.152
#> SRR1058032     1  0.1575     0.9096 0.956 0.012 0.004 0.028
#> SRR1058033     1  0.3232     0.8572 0.888 0.012 0.072 0.028
#> SRR1058034     1  0.2197     0.8989 0.936 0.012 0.024 0.028
#> SRR1058035     1  0.0000     0.9315 1.000 0.000 0.000 0.000
#> SRR1058036     1  0.0000     0.9315 1.000 0.000 0.000 0.000
#> SRR1058037     1  0.0000     0.9315 1.000 0.000 0.000 0.000
#> SRR1058038     1  0.0000     0.9315 1.000 0.000 0.000 0.000
#> SRR1058039     1  0.0000     0.9315 1.000 0.000 0.000 0.000
#> SRR1058040     1  0.0000     0.9315 1.000 0.000 0.000 0.000
#> SRR1058041     1  0.0000     0.9315 1.000 0.000 0.000 0.000
#> SRR1058042     1  0.0000     0.9315 1.000 0.000 0.000 0.000
#> SRR1058043     1  0.0000     0.9315 1.000 0.000 0.000 0.000
#> SRR1058044     1  0.0000     0.9315 1.000 0.000 0.000 0.000
#> SRR1058045     1  0.0000     0.9315 1.000 0.000 0.000 0.000
#> SRR1058046     1  0.0000     0.9315 1.000 0.000 0.000 0.000
#> SRR1058047     3  0.0000     0.9106 0.000 0.000 1.000 0.000
#> SRR1058048     3  0.0000     0.9106 0.000 0.000 1.000 0.000
#> SRR1058049     3  0.0000     0.9106 0.000 0.000 1.000 0.000
#> SRR1058050     3  0.0000     0.9106 0.000 0.000 1.000 0.000
#> SRR1058051     3  0.0000     0.9106 0.000 0.000 1.000 0.000
#> SRR1058052     3  0.0000     0.9106 0.000 0.000 1.000 0.000
#> SRR1058053     3  0.0000     0.9106 0.000 0.000 1.000 0.000
#> SRR1058054     3  0.0000     0.9106 0.000 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4    p5
#> SRR1058003     5  0.5588     0.4966 0.292 0.104 0.000 0.000 0.604
#> SRR1058004     5  0.5773     0.5967 0.000 0.356 0.100 0.000 0.544
#> SRR1058006     5  0.5882     0.6707 0.148 0.264 0.000 0.000 0.588
#> SRR1058005     5  0.6009     0.6098 0.000 0.320 0.136 0.000 0.544
#> SRR1058007     2  0.1410     0.8327 0.000 0.940 0.000 0.000 0.060
#> SRR1058008     2  0.3109     0.6227 0.000 0.800 0.000 0.000 0.200
#> SRR1058009     2  0.1502     0.8423 0.000 0.940 0.000 0.004 0.056
#> SRR1058010     2  0.1282     0.8462 0.000 0.952 0.000 0.004 0.044
#> SRR1058011     2  0.0771     0.8516 0.000 0.976 0.000 0.004 0.020
#> SRR1058012     1  0.6803     0.2149 0.488 0.060 0.000 0.084 0.368
#> SRR1058013     2  0.1197     0.8409 0.000 0.952 0.000 0.000 0.048
#> SRR1058014     2  0.1430     0.8431 0.000 0.944 0.000 0.004 0.052
#> SRR1058015     5  0.5606     0.4868 0.296 0.104 0.000 0.000 0.600
#> SRR1058016     2  0.0955     0.8507 0.000 0.968 0.000 0.004 0.028
#> SRR1058017     2  0.1704     0.8450 0.000 0.928 0.000 0.068 0.004
#> SRR1058018     1  0.4752     0.4333 0.648 0.000 0.000 0.036 0.316
#> SRR1058019     2  0.1671     0.8449 0.000 0.924 0.000 0.076 0.000
#> SRR1058020     2  0.2193     0.8401 0.000 0.900 0.000 0.092 0.008
#> SRR1058021     5  0.6546     0.5507 0.028 0.360 0.000 0.108 0.504
#> SRR1058022     2  0.1106     0.8538 0.000 0.964 0.000 0.024 0.012
#> SRR1058023     1  0.6069    -0.0626 0.456 0.008 0.000 0.092 0.444
#> SRR1058024     2  0.3728     0.7078 0.000 0.748 0.000 0.244 0.008
#> SRR1058025     2  0.2653     0.8364 0.000 0.880 0.000 0.096 0.024
#> SRR1058026     4  0.1430     0.8345 0.000 0.004 0.000 0.944 0.052
#> SRR1058027     4  0.1310     0.8534 0.000 0.024 0.000 0.956 0.020
#> SRR1058028     4  0.3612     0.7404 0.000 0.172 0.000 0.800 0.028
#> SRR1058029     2  0.6107     0.4336 0.000 0.600 0.144 0.244 0.012
#> SRR1058030     2  0.4981     0.6632 0.000 0.720 0.116 0.160 0.004
#> SRR1058031     2  0.2563     0.8198 0.000 0.872 0.008 0.120 0.000
#> SRR1058032     1  0.3508     0.6170 0.748 0.000 0.000 0.000 0.252
#> SRR1058033     1  0.4988     0.4977 0.656 0.000 0.060 0.000 0.284
#> SRR1058034     1  0.4540     0.4843 0.656 0.000 0.024 0.000 0.320
#> SRR1058035     1  0.0404     0.8367 0.988 0.000 0.000 0.000 0.012
#> SRR1058036     1  0.0290     0.8378 0.992 0.000 0.000 0.000 0.008
#> SRR1058037     1  0.0404     0.8367 0.988 0.000 0.000 0.000 0.012
#> SRR1058038     1  0.0162     0.8384 0.996 0.000 0.000 0.000 0.004
#> SRR1058039     1  0.0000     0.8385 1.000 0.000 0.000 0.000 0.000
#> SRR1058040     1  0.0162     0.8376 0.996 0.000 0.000 0.000 0.004
#> SRR1058041     1  0.0162     0.8376 0.996 0.000 0.000 0.000 0.004
#> SRR1058042     1  0.0000     0.8385 1.000 0.000 0.000 0.000 0.000
#> SRR1058043     1  0.0290     0.8358 0.992 0.000 0.000 0.000 0.008
#> SRR1058044     1  0.0000     0.8385 1.000 0.000 0.000 0.000 0.000
#> SRR1058045     1  0.0162     0.8384 0.996 0.000 0.000 0.000 0.004
#> SRR1058046     1  0.0162     0.8384 0.996 0.000 0.000 0.000 0.004
#> SRR1058047     3  0.0794     0.9699 0.000 0.000 0.972 0.000 0.028
#> SRR1058048     3  0.0000     0.9921 0.000 0.000 1.000 0.000 0.000
#> SRR1058049     3  0.0162     0.9916 0.000 0.000 0.996 0.000 0.004
#> SRR1058050     3  0.0162     0.9916 0.000 0.000 0.996 0.000 0.004
#> SRR1058051     3  0.0162     0.9921 0.000 0.000 0.996 0.000 0.004
#> SRR1058052     3  0.0162     0.9921 0.000 0.000 0.996 0.000 0.004
#> SRR1058053     3  0.0162     0.9921 0.000 0.000 0.996 0.000 0.004
#> SRR1058054     3  0.0162     0.9916 0.000 0.000 0.996 0.000 0.004

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR1058003     5  0.4929      0.569 0.112 0.060 0.000 0.104 0.724 0.000
#> SRR1058004     5  0.5551      0.566 0.000 0.184 0.060 0.104 0.652 0.000
#> SRR1058006     5  0.3377      0.650 0.056 0.136 0.000 0.000 0.808 0.000
#> SRR1058005     5  0.5744      0.562 0.000 0.164 0.088 0.104 0.644 0.000
#> SRR1058007     2  0.2218      0.835 0.000 0.884 0.000 0.012 0.104 0.000
#> SRR1058008     2  0.3541      0.635 0.000 0.728 0.000 0.012 0.260 0.000
#> SRR1058009     2  0.2407      0.847 0.000 0.892 0.000 0.048 0.056 0.004
#> SRR1058010     2  0.2605      0.827 0.000 0.864 0.000 0.108 0.028 0.000
#> SRR1058011     2  0.1333      0.850 0.000 0.944 0.000 0.048 0.008 0.000
#> SRR1058012     4  0.5536      0.000 0.244 0.024 0.000 0.644 0.044 0.044
#> SRR1058013     2  0.2002      0.848 0.000 0.908 0.000 0.012 0.076 0.004
#> SRR1058014     2  0.2507      0.840 0.000 0.884 0.000 0.040 0.072 0.004
#> SRR1058015     5  0.4413      0.613 0.108 0.068 0.000 0.048 0.772 0.004
#> SRR1058016     2  0.1563      0.856 0.000 0.932 0.000 0.012 0.056 0.000
#> SRR1058017     2  0.1269      0.849 0.000 0.956 0.000 0.020 0.012 0.012
#> SRR1058018     5  0.5992      0.315 0.284 0.008 0.000 0.136 0.552 0.020
#> SRR1058019     2  0.1168      0.849 0.000 0.956 0.000 0.000 0.016 0.028
#> SRR1058020     2  0.2213      0.847 0.000 0.908 0.000 0.012 0.032 0.048
#> SRR1058021     5  0.4835      0.586 0.016 0.176 0.000 0.080 0.716 0.012
#> SRR1058022     2  0.1364      0.857 0.000 0.944 0.000 0.004 0.048 0.004
#> SRR1058023     5  0.5743      0.428 0.216 0.008 0.000 0.136 0.616 0.024
#> SRR1058024     2  0.4278      0.692 0.000 0.724 0.000 0.024 0.032 0.220
#> SRR1058025     2  0.4109      0.790 0.000 0.784 0.000 0.036 0.116 0.064
#> SRR1058026     6  0.2515      0.784 0.000 0.016 0.000 0.072 0.024 0.888
#> SRR1058027     6  0.2016      0.812 0.000 0.040 0.000 0.024 0.016 0.920
#> SRR1058028     6  0.4025      0.734 0.000 0.120 0.000 0.060 0.032 0.788
#> SRR1058029     2  0.5575      0.544 0.000 0.632 0.156 0.016 0.008 0.188
#> SRR1058030     2  0.4797      0.669 0.000 0.716 0.160 0.012 0.008 0.104
#> SRR1058031     2  0.2849      0.817 0.000 0.872 0.020 0.016 0.008 0.084
#> SRR1058032     1  0.4402      0.545 0.712 0.000 0.000 0.104 0.184 0.000
#> SRR1058033     1  0.5435      0.438 0.640 0.000 0.036 0.104 0.220 0.000
#> SRR1058034     1  0.5311      0.391 0.616 0.000 0.016 0.104 0.264 0.000
#> SRR1058035     1  0.0146      0.884 0.996 0.000 0.000 0.000 0.004 0.000
#> SRR1058036     1  0.0146      0.884 0.996 0.000 0.000 0.000 0.004 0.000
#> SRR1058037     1  0.0146      0.884 0.996 0.000 0.000 0.000 0.004 0.000
#> SRR1058038     1  0.0146      0.885 0.996 0.000 0.000 0.000 0.004 0.000
#> SRR1058039     1  0.0260      0.884 0.992 0.000 0.000 0.000 0.008 0.000
#> SRR1058040     1  0.0405      0.882 0.988 0.000 0.000 0.004 0.008 0.000
#> SRR1058041     1  0.0260      0.884 0.992 0.000 0.000 0.000 0.008 0.000
#> SRR1058042     1  0.0363      0.882 0.988 0.000 0.000 0.000 0.012 0.000
#> SRR1058043     1  0.0692      0.871 0.976 0.000 0.000 0.004 0.020 0.000
#> SRR1058044     1  0.0000      0.885 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058045     1  0.0146      0.885 0.996 0.000 0.000 0.000 0.004 0.000
#> SRR1058046     1  0.0000      0.885 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058047     3  0.1418      0.932 0.000 0.000 0.944 0.024 0.032 0.000
#> SRR1058048     3  0.0000      0.991 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1058049     3  0.0000      0.991 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1058050     3  0.0000      0.991 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1058051     3  0.0000      0.991 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1058052     3  0.0000      0.991 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1058053     3  0.0000      0.991 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1058054     3  0.0000      0.991 0.000 0.000 1.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

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

collect_plots(res)

plot of chunk ATC-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.792           0.952       0.973         0.4744 0.509   0.509
#> 3 3 0.923           0.974       0.958         0.1654 0.932   0.867
#> 4 4 1.000           0.976       0.997         0.0554 0.977   0.949
#> 5 5 0.836           0.896       0.906         0.1749 0.867   0.683
#> 6 6 1.000           0.968       0.993         0.1050 0.957   0.850

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette    p1    p2
#> SRR1058003     1   0.788      0.768 0.764 0.236
#> SRR1058004     2   0.000      1.000 0.000 1.000
#> SRR1058006     1   0.788      0.768 0.764 0.236
#> SRR1058005     2   0.000      1.000 0.000 1.000
#> SRR1058007     2   0.000      1.000 0.000 1.000
#> SRR1058008     2   0.000      1.000 0.000 1.000
#> SRR1058009     2   0.000      1.000 0.000 1.000
#> SRR1058010     2   0.000      1.000 0.000 1.000
#> SRR1058011     2   0.000      1.000 0.000 1.000
#> SRR1058012     2   0.000      1.000 0.000 1.000
#> SRR1058013     2   0.000      1.000 0.000 1.000
#> SRR1058014     2   0.000      1.000 0.000 1.000
#> SRR1058015     1   0.788      0.768 0.764 0.236
#> SRR1058016     2   0.000      1.000 0.000 1.000
#> SRR1058017     2   0.000      1.000 0.000 1.000
#> SRR1058018     1   0.788      0.768 0.764 0.236
#> SRR1058019     2   0.000      1.000 0.000 1.000
#> SRR1058020     2   0.000      1.000 0.000 1.000
#> SRR1058021     1   0.788      0.768 0.764 0.236
#> SRR1058022     2   0.000      1.000 0.000 1.000
#> SRR1058023     1   0.788      0.768 0.764 0.236
#> SRR1058024     2   0.000      1.000 0.000 1.000
#> SRR1058025     2   0.000      1.000 0.000 1.000
#> SRR1058026     2   0.000      1.000 0.000 1.000
#> SRR1058027     2   0.000      1.000 0.000 1.000
#> SRR1058028     2   0.000      1.000 0.000 1.000
#> SRR1058029     2   0.000      1.000 0.000 1.000
#> SRR1058030     2   0.000      1.000 0.000 1.000
#> SRR1058031     2   0.000      1.000 0.000 1.000
#> SRR1058032     1   0.000      0.926 1.000 0.000
#> SRR1058033     1   0.000      0.926 1.000 0.000
#> SRR1058034     1   0.000      0.926 1.000 0.000
#> SRR1058035     1   0.000      0.926 1.000 0.000
#> SRR1058036     1   0.000      0.926 1.000 0.000
#> SRR1058037     1   0.000      0.926 1.000 0.000
#> SRR1058038     1   0.000      0.926 1.000 0.000
#> SRR1058039     1   0.000      0.926 1.000 0.000
#> SRR1058040     1   0.000      0.926 1.000 0.000
#> SRR1058041     1   0.000      0.926 1.000 0.000
#> SRR1058042     1   0.000      0.926 1.000 0.000
#> SRR1058043     1   0.000      0.926 1.000 0.000
#> SRR1058044     1   0.000      0.926 1.000 0.000
#> SRR1058045     1   0.000      0.926 1.000 0.000
#> SRR1058046     1   0.000      0.926 1.000 0.000
#> SRR1058047     2   0.000      1.000 0.000 1.000
#> SRR1058048     2   0.000      1.000 0.000 1.000
#> SRR1058049     2   0.000      1.000 0.000 1.000
#> SRR1058050     2   0.000      1.000 0.000 1.000
#> SRR1058051     2   0.000      1.000 0.000 1.000
#> SRR1058052     2   0.000      1.000 0.000 1.000
#> SRR1058053     2   0.000      1.000 0.000 1.000
#> SRR1058054     2   0.000      1.000 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette   p1    p2    p3
#> SRR1058003     3  0.5443      1.000 0.26 0.004 0.736
#> SRR1058004     2  0.1031      0.967 0.00 0.976 0.024
#> SRR1058006     3  0.5443      1.000 0.26 0.004 0.736
#> SRR1058005     2  0.1031      0.967 0.00 0.976 0.024
#> SRR1058007     2  0.0237      0.980 0.00 0.996 0.004
#> SRR1058008     2  0.0424      0.978 0.00 0.992 0.008
#> SRR1058009     2  0.0237      0.980 0.00 0.996 0.004
#> SRR1058010     2  0.0000      0.980 0.00 1.000 0.000
#> SRR1058011     2  0.0000      0.980 0.00 1.000 0.000
#> SRR1058012     2  0.6295      0.276 0.00 0.528 0.472
#> SRR1058013     2  0.0237      0.980 0.00 0.996 0.004
#> SRR1058014     2  0.0592      0.976 0.00 0.988 0.012
#> SRR1058015     3  0.5443      1.000 0.26 0.004 0.736
#> SRR1058016     2  0.0000      0.980 0.00 1.000 0.000
#> SRR1058017     2  0.0000      0.980 0.00 1.000 0.000
#> SRR1058018     3  0.5443      1.000 0.26 0.004 0.736
#> SRR1058019     2  0.0000      0.980 0.00 1.000 0.000
#> SRR1058020     2  0.0592      0.976 0.00 0.988 0.012
#> SRR1058021     3  0.5443      1.000 0.26 0.004 0.736
#> SRR1058022     2  0.0237      0.980 0.00 0.996 0.004
#> SRR1058023     3  0.5443      1.000 0.26 0.004 0.736
#> SRR1058024     2  0.0592      0.976 0.00 0.988 0.012
#> SRR1058025     2  0.0592      0.976 0.00 0.988 0.012
#> SRR1058026     2  0.0000      0.980 0.00 1.000 0.000
#> SRR1058027     2  0.0000      0.980 0.00 1.000 0.000
#> SRR1058028     2  0.0000      0.980 0.00 1.000 0.000
#> SRR1058029     2  0.0000      0.980 0.00 1.000 0.000
#> SRR1058030     2  0.0000      0.980 0.00 1.000 0.000
#> SRR1058031     2  0.0000      0.980 0.00 1.000 0.000
#> SRR1058032     1  0.0000      1.000 1.00 0.000 0.000
#> SRR1058033     1  0.0000      1.000 1.00 0.000 0.000
#> SRR1058034     1  0.0000      1.000 1.00 0.000 0.000
#> SRR1058035     1  0.0000      1.000 1.00 0.000 0.000
#> SRR1058036     1  0.0000      1.000 1.00 0.000 0.000
#> SRR1058037     1  0.0000      1.000 1.00 0.000 0.000
#> SRR1058038     1  0.0000      1.000 1.00 0.000 0.000
#> SRR1058039     1  0.0000      1.000 1.00 0.000 0.000
#> SRR1058040     1  0.0000      1.000 1.00 0.000 0.000
#> SRR1058041     1  0.0000      1.000 1.00 0.000 0.000
#> SRR1058042     1  0.0000      1.000 1.00 0.000 0.000
#> SRR1058043     1  0.0000      1.000 1.00 0.000 0.000
#> SRR1058044     1  0.0000      1.000 1.00 0.000 0.000
#> SRR1058045     1  0.0000      1.000 1.00 0.000 0.000
#> SRR1058046     1  0.0000      1.000 1.00 0.000 0.000
#> SRR1058047     2  0.0237      0.979 0.00 0.996 0.004
#> SRR1058048     2  0.0237      0.979 0.00 0.996 0.004
#> SRR1058049     2  0.0237      0.979 0.00 0.996 0.004
#> SRR1058050     2  0.0237      0.979 0.00 0.996 0.004
#> SRR1058051     2  0.0237      0.979 0.00 0.996 0.004
#> SRR1058052     2  0.0237      0.979 0.00 0.996 0.004
#> SRR1058053     2  0.0237      0.979 0.00 0.996 0.004
#> SRR1058054     2  0.0237      0.979 0.00 0.996 0.004

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette p1    p2    p3    p4
#> SRR1058003     4  0.0000      0.997  0 0.000 0.000 1.000
#> SRR1058004     2  0.0817      0.979  0 0.976 0.000 0.024
#> SRR1058006     4  0.0188      0.993  0 0.004 0.000 0.996
#> SRR1058005     2  0.0817      0.979  0 0.976 0.000 0.024
#> SRR1058007     2  0.0188      0.994  0 0.996 0.000 0.004
#> SRR1058008     2  0.0336      0.992  0 0.992 0.000 0.008
#> SRR1058009     2  0.0188      0.994  0 0.996 0.000 0.004
#> SRR1058010     2  0.0000      0.995  0 1.000 0.000 0.000
#> SRR1058011     2  0.0000      0.995  0 1.000 0.000 0.000
#> SRR1058012     3  0.0188      0.000  0 0.004 0.996 0.000
#> SRR1058013     2  0.0188      0.994  0 0.996 0.000 0.004
#> SRR1058014     2  0.0469      0.989  0 0.988 0.000 0.012
#> SRR1058015     4  0.0000      0.997  0 0.000 0.000 1.000
#> SRR1058016     2  0.0000      0.995  0 1.000 0.000 0.000
#> SRR1058017     2  0.0000      0.995  0 1.000 0.000 0.000
#> SRR1058018     4  0.0000      0.997  0 0.000 0.000 1.000
#> SRR1058019     2  0.0000      0.995  0 1.000 0.000 0.000
#> SRR1058020     2  0.0469      0.989  0 0.988 0.000 0.012
#> SRR1058021     4  0.0188      0.993  0 0.004 0.000 0.996
#> SRR1058022     2  0.0188      0.994  0 0.996 0.000 0.004
#> SRR1058023     4  0.0000      0.997  0 0.000 0.000 1.000
#> SRR1058024     2  0.0469      0.989  0 0.988 0.000 0.012
#> SRR1058025     2  0.0469      0.989  0 0.988 0.000 0.012
#> SRR1058026     2  0.0000      0.995  0 1.000 0.000 0.000
#> SRR1058027     2  0.0000      0.995  0 1.000 0.000 0.000
#> SRR1058028     2  0.0000      0.995  0 1.000 0.000 0.000
#> SRR1058029     2  0.0000      0.995  0 1.000 0.000 0.000
#> SRR1058030     2  0.0000      0.995  0 1.000 0.000 0.000
#> SRR1058031     2  0.0000      0.995  0 1.000 0.000 0.000
#> SRR1058032     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1058033     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1058034     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1058035     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1058036     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1058037     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1058038     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1058039     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1058040     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1058041     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1058042     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1058043     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1058044     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1058045     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1058046     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1058047     2  0.0188      0.994  0 0.996 0.004 0.000
#> SRR1058048     2  0.0188      0.994  0 0.996 0.004 0.000
#> SRR1058049     2  0.0188      0.994  0 0.996 0.004 0.000
#> SRR1058050     2  0.0188      0.994  0 0.996 0.004 0.000
#> SRR1058051     2  0.0188      0.994  0 0.996 0.004 0.000
#> SRR1058052     2  0.0188      0.994  0 0.996 0.004 0.000
#> SRR1058053     2  0.0188      0.994  0 0.996 0.004 0.000
#> SRR1058054     2  0.0188      0.994  0 0.996 0.004 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
#> SRR1058003     5  0.0000      0.997  0 0.000 0.000  0 1.000
#> SRR1058004     2  0.4841      0.867  0 0.560 0.416  0 0.024
#> SRR1058006     5  0.0162      0.994  0 0.004 0.000  0 0.996
#> SRR1058005     2  0.4841      0.867  0 0.560 0.416  0 0.024
#> SRR1058007     2  0.4383      0.880  0 0.572 0.424  0 0.004
#> SRR1058008     2  0.4489      0.879  0 0.572 0.420  0 0.008
#> SRR1058009     2  0.4383      0.880  0 0.572 0.424  0 0.004
#> SRR1058010     2  0.4249      0.872  0 0.568 0.432  0 0.000
#> SRR1058011     2  0.4242      0.876  0 0.572 0.428  0 0.000
#> SRR1058012     4  0.0000      0.000  0 0.000 0.000  1 0.000
#> SRR1058013     2  0.4383      0.880  0 0.572 0.424  0 0.004
#> SRR1058014     2  0.4582      0.878  0 0.572 0.416  0 0.012
#> SRR1058015     5  0.0000      0.997  0 0.000 0.000  0 1.000
#> SRR1058016     2  0.4235      0.879  0 0.576 0.424  0 0.000
#> SRR1058017     2  0.4304      0.786  0 0.516 0.484  0 0.000
#> SRR1058018     5  0.0000      0.997  0 0.000 0.000  0 1.000
#> SRR1058019     2  0.4235      0.879  0 0.576 0.424  0 0.000
#> SRR1058020     2  0.4582      0.878  0 0.572 0.416  0 0.012
#> SRR1058021     5  0.0162      0.994  0 0.004 0.000  0 0.996
#> SRR1058022     2  0.4383      0.880  0 0.572 0.424  0 0.004
#> SRR1058023     5  0.0000      0.997  0 0.000 0.000  0 1.000
#> SRR1058024     2  0.4582      0.878  0 0.572 0.416  0 0.012
#> SRR1058025     2  0.4582      0.878  0 0.572 0.416  0 0.012
#> SRR1058026     2  0.0000      0.346  0 1.000 0.000  0 0.000
#> SRR1058027     2  0.0000      0.346  0 1.000 0.000  0 0.000
#> SRR1058028     2  0.0000      0.346  0 1.000 0.000  0 0.000
#> SRR1058029     2  0.4235      0.879  0 0.576 0.424  0 0.000
#> SRR1058030     2  0.4235      0.879  0 0.576 0.424  0 0.000
#> SRR1058031     2  0.4235      0.879  0 0.576 0.424  0 0.000
#> SRR1058032     1  0.0000      1.000  1 0.000 0.000  0 0.000
#> SRR1058033     1  0.0000      1.000  1 0.000 0.000  0 0.000
#> SRR1058034     1  0.0000      1.000  1 0.000 0.000  0 0.000
#> SRR1058035     1  0.0000      1.000  1 0.000 0.000  0 0.000
#> SRR1058036     1  0.0000      1.000  1 0.000 0.000  0 0.000
#> SRR1058037     1  0.0000      1.000  1 0.000 0.000  0 0.000
#> SRR1058038     1  0.0000      1.000  1 0.000 0.000  0 0.000
#> SRR1058039     1  0.0000      1.000  1 0.000 0.000  0 0.000
#> SRR1058040     1  0.0000      1.000  1 0.000 0.000  0 0.000
#> SRR1058041     1  0.0000      1.000  1 0.000 0.000  0 0.000
#> SRR1058042     1  0.0000      1.000  1 0.000 0.000  0 0.000
#> SRR1058043     1  0.0000      1.000  1 0.000 0.000  0 0.000
#> SRR1058044     1  0.0000      1.000  1 0.000 0.000  0 0.000
#> SRR1058045     1  0.0000      1.000  1 0.000 0.000  0 0.000
#> SRR1058046     1  0.0000      1.000  1 0.000 0.000  0 0.000
#> SRR1058047     3  0.0000      1.000  0 0.000 1.000  0 0.000
#> SRR1058048     3  0.0000      1.000  0 0.000 1.000  0 0.000
#> SRR1058049     3  0.0000      1.000  0 0.000 1.000  0 0.000
#> SRR1058050     3  0.0000      1.000  0 0.000 1.000  0 0.000
#> SRR1058051     3  0.0000      1.000  0 0.000 1.000  0 0.000
#> SRR1058052     3  0.0000      1.000  0 0.000 1.000  0 0.000
#> SRR1058053     3  0.0000      1.000  0 0.000 1.000  0 0.000
#> SRR1058054     3  0.0000      1.000  0 0.000 1.000  0 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
#> SRR1058003     5  0.0000      0.994  0 0.000 0.000  0 1.000 0.000
#> SRR1058004     2  0.0458      0.977  0 0.984 0.000  0 0.016 0.000
#> SRR1058006     5  0.0405      0.987  0 0.008 0.004  0 0.988 0.000
#> SRR1058005     2  0.0458      0.977  0 0.984 0.000  0 0.016 0.000
#> SRR1058007     2  0.0146      0.987  0 0.996 0.004  0 0.000 0.000
#> SRR1058008     2  0.0000      0.986  0 1.000 0.000  0 0.000 0.000
#> SRR1058009     2  0.0291      0.987  0 0.992 0.004  0 0.000 0.004
#> SRR1058010     2  0.0622      0.982  0 0.980 0.012  0 0.000 0.008
#> SRR1058011     2  0.0520      0.984  0 0.984 0.008  0 0.000 0.008
#> SRR1058012     4  0.0000      0.000  0 0.000 0.000  1 0.000 0.000
#> SRR1058013     2  0.0146      0.987  0 0.996 0.004  0 0.000 0.000
#> SRR1058014     2  0.0146      0.985  0 0.996 0.004  0 0.000 0.000
#> SRR1058015     5  0.0000      0.994  0 0.000 0.000  0 1.000 0.000
#> SRR1058016     2  0.0405      0.986  0 0.988 0.004  0 0.000 0.008
#> SRR1058017     2  0.1757      0.910  0 0.916 0.076  0 0.000 0.008
#> SRR1058018     5  0.0000      0.994  0 0.000 0.000  0 1.000 0.000
#> SRR1058019     2  0.0405      0.986  0 0.988 0.004  0 0.000 0.008
#> SRR1058020     2  0.0146      0.985  0 0.996 0.004  0 0.000 0.000
#> SRR1058021     5  0.0405      0.987  0 0.008 0.004  0 0.988 0.000
#> SRR1058022     2  0.0146      0.987  0 0.996 0.004  0 0.000 0.000
#> SRR1058023     5  0.0000      0.994  0 0.000 0.000  0 1.000 0.000
#> SRR1058024     2  0.0146      0.985  0 0.996 0.004  0 0.000 0.000
#> SRR1058025     2  0.0146      0.985  0 0.996 0.004  0 0.000 0.000
#> SRR1058026     6  0.0000      0.929  0 0.000 0.000  0 0.000 1.000
#> SRR1058027     6  0.0363      0.941  0 0.012 0.000  0 0.000 0.988
#> SRR1058028     6  0.1075      0.898  0 0.048 0.000  0 0.000 0.952
#> SRR1058029     2  0.0405      0.986  0 0.988 0.004  0 0.000 0.008
#> SRR1058030     2  0.0405      0.986  0 0.988 0.004  0 0.000 0.008
#> SRR1058031     2  0.0405      0.986  0 0.988 0.004  0 0.000 0.008
#> SRR1058032     1  0.0000      1.000  1 0.000 0.000  0 0.000 0.000
#> SRR1058033     1  0.0000      1.000  1 0.000 0.000  0 0.000 0.000
#> SRR1058034     1  0.0000      1.000  1 0.000 0.000  0 0.000 0.000
#> SRR1058035     1  0.0000      1.000  1 0.000 0.000  0 0.000 0.000
#> SRR1058036     1  0.0000      1.000  1 0.000 0.000  0 0.000 0.000
#> SRR1058037     1  0.0000      1.000  1 0.000 0.000  0 0.000 0.000
#> SRR1058038     1  0.0000      1.000  1 0.000 0.000  0 0.000 0.000
#> SRR1058039     1  0.0000      1.000  1 0.000 0.000  0 0.000 0.000
#> SRR1058040     1  0.0000      1.000  1 0.000 0.000  0 0.000 0.000
#> SRR1058041     1  0.0000      1.000  1 0.000 0.000  0 0.000 0.000
#> SRR1058042     1  0.0000      1.000  1 0.000 0.000  0 0.000 0.000
#> SRR1058043     1  0.0000      1.000  1 0.000 0.000  0 0.000 0.000
#> SRR1058044     1  0.0000      1.000  1 0.000 0.000  0 0.000 0.000
#> SRR1058045     1  0.0000      1.000  1 0.000 0.000  0 0.000 0.000
#> SRR1058046     1  0.0000      1.000  1 0.000 0.000  0 0.000 0.000
#> SRR1058047     3  0.0146      1.000  0 0.004 0.996  0 0.000 0.000
#> SRR1058048     3  0.0146      1.000  0 0.004 0.996  0 0.000 0.000
#> SRR1058049     3  0.0146      1.000  0 0.004 0.996  0 0.000 0.000
#> SRR1058050     3  0.0146      1.000  0 0.004 0.996  0 0.000 0.000
#> SRR1058051     3  0.0146      1.000  0 0.004 0.996  0 0.000 0.000
#> SRR1058052     3  0.0146      1.000  0 0.004 0.996  0 0.000 0.000
#> SRR1058053     3  0.0146      1.000  0 0.004 0.996  0 0.000 0.000
#> SRR1058054     3  0.0146      1.000  0 0.004 0.996  0 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

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

collect_plots(res)

plot of chunk ATC-kmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.953       0.983         0.4357 0.551   0.551
#> 3 3 0.775           0.916       0.921         0.3545 0.774   0.618
#> 4 4 0.704           0.942       0.928         0.1528 0.896   0.744
#> 5 5 0.878           0.827       0.922         0.0782 0.983   0.945
#> 6 6 0.833           0.802       0.848         0.0551 0.928   0.749

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
#> SRR1058003     2   0.000      1.000 0.000 1.000
#> SRR1058004     2   0.000      1.000 0.000 1.000
#> SRR1058006     2   0.000      1.000 0.000 1.000
#> SRR1058005     2   0.000      1.000 0.000 1.000
#> SRR1058007     2   0.000      1.000 0.000 1.000
#> SRR1058008     2   0.000      1.000 0.000 1.000
#> SRR1058009     2   0.000      1.000 0.000 1.000
#> SRR1058010     2   0.000      1.000 0.000 1.000
#> SRR1058011     2   0.000      1.000 0.000 1.000
#> SRR1058012     2   0.000      1.000 0.000 1.000
#> SRR1058013     2   0.000      1.000 0.000 1.000
#> SRR1058014     2   0.000      1.000 0.000 1.000
#> SRR1058015     2   0.000      1.000 0.000 1.000
#> SRR1058016     2   0.000      1.000 0.000 1.000
#> SRR1058017     2   0.000      1.000 0.000 1.000
#> SRR1058018     1   0.985      0.291 0.572 0.428
#> SRR1058019     2   0.000      1.000 0.000 1.000
#> SRR1058020     2   0.000      1.000 0.000 1.000
#> SRR1058021     2   0.000      1.000 0.000 1.000
#> SRR1058022     2   0.000      1.000 0.000 1.000
#> SRR1058023     1   0.998      0.146 0.524 0.476
#> SRR1058024     2   0.000      1.000 0.000 1.000
#> SRR1058025     2   0.000      1.000 0.000 1.000
#> SRR1058026     2   0.000      1.000 0.000 1.000
#> SRR1058027     2   0.000      1.000 0.000 1.000
#> SRR1058028     2   0.000      1.000 0.000 1.000
#> SRR1058029     2   0.000      1.000 0.000 1.000
#> SRR1058030     2   0.000      1.000 0.000 1.000
#> SRR1058031     2   0.000      1.000 0.000 1.000
#> SRR1058032     1   0.000      0.943 1.000 0.000
#> SRR1058033     1   0.000      0.943 1.000 0.000
#> SRR1058034     1   0.000      0.943 1.000 0.000
#> SRR1058035     1   0.000      0.943 1.000 0.000
#> SRR1058036     1   0.000      0.943 1.000 0.000
#> SRR1058037     1   0.000      0.943 1.000 0.000
#> SRR1058038     1   0.000      0.943 1.000 0.000
#> SRR1058039     1   0.000      0.943 1.000 0.000
#> SRR1058040     1   0.000      0.943 1.000 0.000
#> SRR1058041     1   0.000      0.943 1.000 0.000
#> SRR1058042     1   0.000      0.943 1.000 0.000
#> SRR1058043     1   0.000      0.943 1.000 0.000
#> SRR1058044     1   0.000      0.943 1.000 0.000
#> SRR1058045     1   0.000      0.943 1.000 0.000
#> SRR1058046     1   0.000      0.943 1.000 0.000
#> SRR1058047     2   0.000      1.000 0.000 1.000
#> SRR1058048     2   0.000      1.000 0.000 1.000
#> SRR1058049     2   0.000      1.000 0.000 1.000
#> SRR1058050     2   0.000      1.000 0.000 1.000
#> SRR1058051     2   0.000      1.000 0.000 1.000
#> SRR1058052     2   0.000      1.000 0.000 1.000
#> SRR1058053     2   0.000      1.000 0.000 1.000
#> SRR1058054     2   0.000      1.000 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette   p1    p2    p3
#> SRR1058003     2  0.0000      0.727 0.00 1.000 0.000
#> SRR1058004     2  0.4796      0.895 0.00 0.780 0.220
#> SRR1058006     2  0.0000      0.727 0.00 1.000 0.000
#> SRR1058005     2  0.4796      0.895 0.00 0.780 0.220
#> SRR1058007     2  0.4796      0.895 0.00 0.780 0.220
#> SRR1058008     2  0.4796      0.895 0.00 0.780 0.220
#> SRR1058009     2  0.4796      0.895 0.00 0.780 0.220
#> SRR1058010     2  0.5529      0.867 0.00 0.704 0.296
#> SRR1058011     2  0.5529      0.867 0.00 0.704 0.296
#> SRR1058012     2  0.5178      0.885 0.00 0.744 0.256
#> SRR1058013     2  0.4796      0.895 0.00 0.780 0.220
#> SRR1058014     2  0.4796      0.895 0.00 0.780 0.220
#> SRR1058015     2  0.0000      0.727 0.00 1.000 0.000
#> SRR1058016     2  0.5465      0.872 0.00 0.712 0.288
#> SRR1058017     2  0.5529      0.867 0.00 0.704 0.296
#> SRR1058018     2  0.0892      0.707 0.02 0.980 0.000
#> SRR1058019     2  0.5465      0.872 0.00 0.712 0.288
#> SRR1058020     2  0.4796      0.895 0.00 0.780 0.220
#> SRR1058021     2  0.0000      0.727 0.00 1.000 0.000
#> SRR1058022     2  0.4796      0.895 0.00 0.780 0.220
#> SRR1058023     2  0.0892      0.707 0.02 0.980 0.000
#> SRR1058024     2  0.4796      0.895 0.00 0.780 0.220
#> SRR1058025     2  0.4796      0.895 0.00 0.780 0.220
#> SRR1058026     2  0.5560      0.869 0.00 0.700 0.300
#> SRR1058027     2  0.5016      0.891 0.00 0.760 0.240
#> SRR1058028     2  0.5591      0.866 0.00 0.696 0.304
#> SRR1058029     2  0.5560      0.864 0.00 0.700 0.300
#> SRR1058030     2  0.5529      0.867 0.00 0.704 0.296
#> SRR1058031     2  0.5529      0.867 0.00 0.704 0.296
#> SRR1058032     1  0.0000      1.000 1.00 0.000 0.000
#> SRR1058033     1  0.0000      1.000 1.00 0.000 0.000
#> SRR1058034     1  0.0000      1.000 1.00 0.000 0.000
#> SRR1058035     1  0.0000      1.000 1.00 0.000 0.000
#> SRR1058036     1  0.0000      1.000 1.00 0.000 0.000
#> SRR1058037     1  0.0000      1.000 1.00 0.000 0.000
#> SRR1058038     1  0.0000      1.000 1.00 0.000 0.000
#> SRR1058039     1  0.0000      1.000 1.00 0.000 0.000
#> SRR1058040     1  0.0000      1.000 1.00 0.000 0.000
#> SRR1058041     1  0.0000      1.000 1.00 0.000 0.000
#> SRR1058042     1  0.0000      1.000 1.00 0.000 0.000
#> SRR1058043     1  0.0000      1.000 1.00 0.000 0.000
#> SRR1058044     1  0.0000      1.000 1.00 0.000 0.000
#> SRR1058045     1  0.0000      1.000 1.00 0.000 0.000
#> SRR1058046     1  0.0000      1.000 1.00 0.000 0.000
#> SRR1058047     3  0.1031      1.000 0.00 0.024 0.976
#> SRR1058048     3  0.1031      1.000 0.00 0.024 0.976
#> SRR1058049     3  0.1031      1.000 0.00 0.024 0.976
#> SRR1058050     3  0.1031      1.000 0.00 0.024 0.976
#> SRR1058051     3  0.1031      1.000 0.00 0.024 0.976
#> SRR1058052     3  0.1031      1.000 0.00 0.024 0.976
#> SRR1058053     3  0.1031      1.000 0.00 0.024 0.976
#> SRR1058054     3  0.1031      1.000 0.00 0.024 0.976

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1058003     4  0.3400      0.986 0.000 0.180 0.000 0.820
#> SRR1058004     2  0.2760      0.824 0.000 0.872 0.000 0.128
#> SRR1058006     4  0.3569      0.986 0.000 0.196 0.000 0.804
#> SRR1058005     2  0.2760      0.824 0.000 0.872 0.000 0.128
#> SRR1058007     2  0.0921      0.916 0.000 0.972 0.000 0.028
#> SRR1058008     2  0.2647      0.833 0.000 0.880 0.000 0.120
#> SRR1058009     2  0.0000      0.928 0.000 1.000 0.000 0.000
#> SRR1058010     2  0.1118      0.930 0.000 0.964 0.036 0.000
#> SRR1058011     2  0.1118      0.930 0.000 0.964 0.036 0.000
#> SRR1058012     2  0.4244      0.759 0.000 0.800 0.032 0.168
#> SRR1058013     2  0.0000      0.928 0.000 1.000 0.000 0.000
#> SRR1058014     2  0.2704      0.829 0.000 0.876 0.000 0.124
#> SRR1058015     4  0.3569      0.986 0.000 0.196 0.000 0.804
#> SRR1058016     2  0.0921      0.930 0.000 0.972 0.028 0.000
#> SRR1058017     2  0.1118      0.930 0.000 0.964 0.036 0.000
#> SRR1058018     4  0.3400      0.986 0.000 0.180 0.000 0.820
#> SRR1058019     2  0.1118      0.930 0.000 0.964 0.036 0.000
#> SRR1058020     2  0.0000      0.928 0.000 1.000 0.000 0.000
#> SRR1058021     4  0.3569      0.986 0.000 0.196 0.000 0.804
#> SRR1058022     2  0.0000      0.928 0.000 1.000 0.000 0.000
#> SRR1058023     4  0.3400      0.986 0.000 0.180 0.000 0.820
#> SRR1058024     2  0.0469      0.924 0.000 0.988 0.000 0.012
#> SRR1058025     2  0.0000      0.928 0.000 1.000 0.000 0.000
#> SRR1058026     2  0.2660      0.894 0.000 0.908 0.036 0.056
#> SRR1058027     2  0.1557      0.905 0.000 0.944 0.000 0.056
#> SRR1058028     2  0.2660      0.894 0.000 0.908 0.036 0.056
#> SRR1058029     2  0.1118      0.930 0.000 0.964 0.036 0.000
#> SRR1058030     2  0.1118      0.930 0.000 0.964 0.036 0.000
#> SRR1058031     2  0.1118      0.930 0.000 0.964 0.036 0.000
#> SRR1058032     1  0.3149      0.906 0.880 0.000 0.088 0.032
#> SRR1058033     1  0.3149      0.906 0.880 0.000 0.088 0.032
#> SRR1058034     1  0.3745      0.883 0.852 0.000 0.088 0.060
#> SRR1058035     1  0.0000      0.977 1.000 0.000 0.000 0.000
#> SRR1058036     1  0.0000      0.977 1.000 0.000 0.000 0.000
#> SRR1058037     1  0.0000      0.977 1.000 0.000 0.000 0.000
#> SRR1058038     1  0.0000      0.977 1.000 0.000 0.000 0.000
#> SRR1058039     1  0.0000      0.977 1.000 0.000 0.000 0.000
#> SRR1058040     1  0.0000      0.977 1.000 0.000 0.000 0.000
#> SRR1058041     1  0.0000      0.977 1.000 0.000 0.000 0.000
#> SRR1058042     1  0.0000      0.977 1.000 0.000 0.000 0.000
#> SRR1058043     1  0.0000      0.977 1.000 0.000 0.000 0.000
#> SRR1058044     1  0.0000      0.977 1.000 0.000 0.000 0.000
#> SRR1058045     1  0.0000      0.977 1.000 0.000 0.000 0.000
#> SRR1058046     1  0.0000      0.977 1.000 0.000 0.000 0.000
#> SRR1058047     3  0.2647      0.998 0.000 0.120 0.880 0.000
#> SRR1058048     3  0.2647      0.998 0.000 0.120 0.880 0.000
#> SRR1058049     3  0.2647      0.998 0.000 0.120 0.880 0.000
#> SRR1058050     3  0.2647      0.998 0.000 0.120 0.880 0.000
#> SRR1058051     3  0.2831      0.998 0.000 0.120 0.876 0.004
#> SRR1058052     3  0.2831      0.998 0.000 0.120 0.876 0.004
#> SRR1058053     3  0.2831      0.998 0.000 0.120 0.876 0.004
#> SRR1058054     3  0.2831      0.998 0.000 0.120 0.876 0.004

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4    p5
#> SRR1058003     5  0.0798      0.981 0.000 0.008 0.000 0.016 0.976
#> SRR1058004     2  0.2362      0.704 0.000 0.900 0.000 0.024 0.076
#> SRR1058006     5  0.0510      0.993 0.000 0.016 0.000 0.000 0.984
#> SRR1058005     2  0.2362      0.704 0.000 0.900 0.000 0.024 0.076
#> SRR1058007     2  0.0451      0.812 0.000 0.988 0.000 0.004 0.008
#> SRR1058008     2  0.1638      0.751 0.000 0.932 0.000 0.004 0.064
#> SRR1058009     2  0.0000      0.819 0.000 1.000 0.000 0.000 0.000
#> SRR1058010     2  0.2179      0.788 0.000 0.888 0.000 0.112 0.000
#> SRR1058011     2  0.2020      0.796 0.000 0.900 0.000 0.100 0.000
#> SRR1058012     4  0.4944      0.000 0.000 0.416 0.012 0.560 0.012
#> SRR1058013     2  0.0000      0.819 0.000 1.000 0.000 0.000 0.000
#> SRR1058014     2  0.1768      0.740 0.000 0.924 0.000 0.004 0.072
#> SRR1058015     5  0.0510      0.993 0.000 0.016 0.000 0.000 0.984
#> SRR1058016     2  0.2020      0.796 0.000 0.900 0.000 0.100 0.000
#> SRR1058017     2  0.2179      0.788 0.000 0.888 0.000 0.112 0.000
#> SRR1058018     5  0.0404      0.993 0.000 0.012 0.000 0.000 0.988
#> SRR1058019     2  0.0794      0.819 0.000 0.972 0.000 0.028 0.000
#> SRR1058020     2  0.0162      0.820 0.000 0.996 0.000 0.004 0.000
#> SRR1058021     5  0.0510      0.993 0.000 0.016 0.000 0.000 0.984
#> SRR1058022     2  0.0000      0.819 0.000 1.000 0.000 0.000 0.000
#> SRR1058023     5  0.0404      0.993 0.000 0.012 0.000 0.000 0.988
#> SRR1058024     2  0.0162      0.817 0.000 0.996 0.000 0.000 0.004
#> SRR1058025     2  0.0162      0.820 0.000 0.996 0.000 0.004 0.000
#> SRR1058026     2  0.3661      0.396 0.000 0.724 0.000 0.276 0.000
#> SRR1058027     2  0.3636      0.401 0.000 0.728 0.000 0.272 0.000
#> SRR1058028     2  0.3612      0.427 0.000 0.732 0.000 0.268 0.000
#> SRR1058029     2  0.2179      0.788 0.000 0.888 0.000 0.112 0.000
#> SRR1058030     2  0.2179      0.788 0.000 0.888 0.000 0.112 0.000
#> SRR1058031     2  0.2179      0.788 0.000 0.888 0.000 0.112 0.000
#> SRR1058032     1  0.4367      0.653 0.620 0.000 0.000 0.372 0.008
#> SRR1058033     1  0.4367      0.653 0.620 0.000 0.000 0.372 0.008
#> SRR1058034     1  0.5068      0.597 0.572 0.000 0.000 0.388 0.040
#> SRR1058035     1  0.0000      0.924 1.000 0.000 0.000 0.000 0.000
#> SRR1058036     1  0.0000      0.924 1.000 0.000 0.000 0.000 0.000
#> SRR1058037     1  0.0000      0.924 1.000 0.000 0.000 0.000 0.000
#> SRR1058038     1  0.0000      0.924 1.000 0.000 0.000 0.000 0.000
#> SRR1058039     1  0.0000      0.924 1.000 0.000 0.000 0.000 0.000
#> SRR1058040     1  0.0162      0.923 0.996 0.000 0.004 0.000 0.000
#> SRR1058041     1  0.0162      0.923 0.996 0.000 0.004 0.000 0.000
#> SRR1058042     1  0.0162      0.923 0.996 0.000 0.004 0.000 0.000
#> SRR1058043     1  0.0510      0.918 0.984 0.000 0.016 0.000 0.000
#> SRR1058044     1  0.0000      0.924 1.000 0.000 0.000 0.000 0.000
#> SRR1058045     1  0.0000      0.924 1.000 0.000 0.000 0.000 0.000
#> SRR1058046     1  0.0000      0.924 1.000 0.000 0.000 0.000 0.000
#> SRR1058047     3  0.1750      0.984 0.000 0.028 0.936 0.036 0.000
#> SRR1058048     3  0.1668      0.985 0.000 0.028 0.940 0.032 0.000
#> SRR1058049     3  0.1668      0.985 0.000 0.028 0.940 0.032 0.000
#> SRR1058050     3  0.1668      0.985 0.000 0.028 0.940 0.032 0.000
#> SRR1058051     3  0.0955      0.984 0.000 0.028 0.968 0.004 0.000
#> SRR1058052     3  0.0794      0.985 0.000 0.028 0.972 0.000 0.000
#> SRR1058053     3  0.0794      0.985 0.000 0.028 0.972 0.000 0.000
#> SRR1058054     3  0.0794      0.985 0.000 0.028 0.972 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR1058003     5  0.0717      0.978 0.000 0.000 0.000 0.016 0.976 0.008
#> SRR1058004     2  0.3260      0.611 0.000 0.848 0.000 0.028 0.068 0.056
#> SRR1058006     5  0.0000      0.992 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1058005     2  0.3260      0.611 0.000 0.848 0.000 0.028 0.068 0.056
#> SRR1058007     2  0.2113      0.668 0.000 0.912 0.000 0.008 0.032 0.048
#> SRR1058008     2  0.2697      0.640 0.000 0.876 0.000 0.008 0.068 0.048
#> SRR1058009     2  0.0405      0.707 0.000 0.988 0.000 0.000 0.008 0.004
#> SRR1058010     2  0.3390      0.481 0.000 0.704 0.000 0.000 0.000 0.296
#> SRR1058011     2  0.3266      0.519 0.000 0.728 0.000 0.000 0.000 0.272
#> SRR1058012     6  0.5750      0.455 0.000 0.184 0.000 0.336 0.000 0.480
#> SRR1058013     2  0.0405      0.707 0.000 0.988 0.000 0.000 0.008 0.004
#> SRR1058014     2  0.2796      0.637 0.000 0.872 0.000 0.012 0.068 0.048
#> SRR1058015     5  0.0000      0.992 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1058016     2  0.3266      0.519 0.000 0.728 0.000 0.000 0.000 0.272
#> SRR1058017     2  0.3390      0.481 0.000 0.704 0.000 0.000 0.000 0.296
#> SRR1058018     5  0.0260      0.989 0.000 0.000 0.000 0.008 0.992 0.000
#> SRR1058019     2  0.2631      0.601 0.000 0.820 0.000 0.000 0.000 0.180
#> SRR1058020     2  0.0000      0.706 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1058021     5  0.0000      0.992 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1058022     2  0.0000      0.706 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1058023     5  0.0260      0.989 0.000 0.000 0.000 0.008 0.992 0.000
#> SRR1058024     2  0.0458      0.706 0.000 0.984 0.000 0.000 0.016 0.000
#> SRR1058025     2  0.0363      0.707 0.000 0.988 0.000 0.000 0.012 0.000
#> SRR1058026     6  0.4437      0.700 0.000 0.392 0.000 0.032 0.000 0.576
#> SRR1058027     6  0.4488      0.682 0.000 0.420 0.000 0.032 0.000 0.548
#> SRR1058028     6  0.3765      0.652 0.000 0.404 0.000 0.000 0.000 0.596
#> SRR1058029     2  0.3371      0.484 0.000 0.708 0.000 0.000 0.000 0.292
#> SRR1058030     2  0.3351      0.491 0.000 0.712 0.000 0.000 0.000 0.288
#> SRR1058031     2  0.3371      0.484 0.000 0.708 0.000 0.000 0.000 0.292
#> SRR1058032     4  0.3851      0.987 0.460 0.000 0.000 0.540 0.000 0.000
#> SRR1058033     4  0.3851      0.987 0.460 0.000 0.000 0.540 0.000 0.000
#> SRR1058034     4  0.3971      0.975 0.448 0.000 0.000 0.548 0.004 0.000
#> SRR1058035     1  0.0547      0.952 0.980 0.000 0.000 0.000 0.000 0.020
#> SRR1058036     1  0.0260      0.955 0.992 0.000 0.000 0.000 0.000 0.008
#> SRR1058037     1  0.0260      0.955 0.992 0.000 0.000 0.000 0.000 0.008
#> SRR1058038     1  0.0000      0.957 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058039     1  0.0146      0.956 0.996 0.000 0.000 0.000 0.000 0.004
#> SRR1058040     1  0.1225      0.936 0.952 0.000 0.012 0.000 0.000 0.036
#> SRR1058041     1  0.1398      0.920 0.940 0.000 0.008 0.000 0.000 0.052
#> SRR1058042     1  0.1082      0.928 0.956 0.000 0.004 0.000 0.000 0.040
#> SRR1058043     1  0.2212      0.816 0.880 0.000 0.008 0.000 0.000 0.112
#> SRR1058044     1  0.0458      0.952 0.984 0.000 0.000 0.000 0.000 0.016
#> SRR1058045     1  0.0000      0.957 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058046     1  0.0000      0.957 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058047     3  0.2709      0.949 0.000 0.016 0.868 0.100 0.000 0.016
#> SRR1058048     3  0.2308      0.956 0.000 0.016 0.896 0.076 0.000 0.012
#> SRR1058049     3  0.2308      0.956 0.000 0.016 0.896 0.076 0.000 0.012
#> SRR1058050     3  0.2308      0.956 0.000 0.016 0.896 0.076 0.000 0.012
#> SRR1058051     3  0.1232      0.949 0.000 0.016 0.956 0.024 0.000 0.004
#> SRR1058052     3  0.0458      0.956 0.000 0.016 0.984 0.000 0.000 0.000
#> SRR1058053     3  0.0458      0.956 0.000 0.016 0.984 0.000 0.000 0.000
#> SRR1058054     3  0.0458      0.956 0.000 0.016 0.984 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

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

collect_plots(res)

plot of chunk ATC-skmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.986       0.994         0.4889 0.509   0.509
#> 3 3 0.856           0.951       0.956         0.2680 0.798   0.628
#> 4 4 0.990           0.970       0.978         0.1359 0.914   0.775
#> 5 5 0.862           0.772       0.898         0.0849 0.968   0.895
#> 6 6 0.813           0.731       0.868         0.0455 0.942   0.789

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette    p1    p2
#> SRR1058003     1   0.000      0.985 1.000 0.000
#> SRR1058004     2   0.000      1.000 0.000 1.000
#> SRR1058006     1   0.844      0.630 0.728 0.272
#> SRR1058005     2   0.000      1.000 0.000 1.000
#> SRR1058007     2   0.000      1.000 0.000 1.000
#> SRR1058008     2   0.000      1.000 0.000 1.000
#> SRR1058009     2   0.000      1.000 0.000 1.000
#> SRR1058010     2   0.000      1.000 0.000 1.000
#> SRR1058011     2   0.000      1.000 0.000 1.000
#> SRR1058012     2   0.000      1.000 0.000 1.000
#> SRR1058013     2   0.000      1.000 0.000 1.000
#> SRR1058014     2   0.000      1.000 0.000 1.000
#> SRR1058015     1   0.224      0.952 0.964 0.036
#> SRR1058016     2   0.000      1.000 0.000 1.000
#> SRR1058017     2   0.000      1.000 0.000 1.000
#> SRR1058018     1   0.000      0.985 1.000 0.000
#> SRR1058019     2   0.000      1.000 0.000 1.000
#> SRR1058020     2   0.000      1.000 0.000 1.000
#> SRR1058021     1   0.000      0.985 1.000 0.000
#> SRR1058022     2   0.000      1.000 0.000 1.000
#> SRR1058023     1   0.000      0.985 1.000 0.000
#> SRR1058024     2   0.000      1.000 0.000 1.000
#> SRR1058025     2   0.000      1.000 0.000 1.000
#> SRR1058026     2   0.000      1.000 0.000 1.000
#> SRR1058027     2   0.000      1.000 0.000 1.000
#> SRR1058028     2   0.000      1.000 0.000 1.000
#> SRR1058029     2   0.000      1.000 0.000 1.000
#> SRR1058030     2   0.000      1.000 0.000 1.000
#> SRR1058031     2   0.000      1.000 0.000 1.000
#> SRR1058032     1   0.000      0.985 1.000 0.000
#> SRR1058033     1   0.000      0.985 1.000 0.000
#> SRR1058034     1   0.000      0.985 1.000 0.000
#> SRR1058035     1   0.000      0.985 1.000 0.000
#> SRR1058036     1   0.000      0.985 1.000 0.000
#> SRR1058037     1   0.000      0.985 1.000 0.000
#> SRR1058038     1   0.000      0.985 1.000 0.000
#> SRR1058039     1   0.000      0.985 1.000 0.000
#> SRR1058040     1   0.000      0.985 1.000 0.000
#> SRR1058041     1   0.000      0.985 1.000 0.000
#> SRR1058042     1   0.000      0.985 1.000 0.000
#> SRR1058043     1   0.000      0.985 1.000 0.000
#> SRR1058044     1   0.000      0.985 1.000 0.000
#> SRR1058045     1   0.000      0.985 1.000 0.000
#> SRR1058046     1   0.000      0.985 1.000 0.000
#> SRR1058047     2   0.000      1.000 0.000 1.000
#> SRR1058048     2   0.000      1.000 0.000 1.000
#> SRR1058049     2   0.000      1.000 0.000 1.000
#> SRR1058050     2   0.000      1.000 0.000 1.000
#> SRR1058051     2   0.000      1.000 0.000 1.000
#> SRR1058052     2   0.000      1.000 0.000 1.000
#> SRR1058053     2   0.000      1.000 0.000 1.000
#> SRR1058054     2   0.000      1.000 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1058003     1  0.4136      0.874 0.864 0.020 0.116
#> SRR1058004     2  0.0892      0.959 0.000 0.980 0.020
#> SRR1058006     2  0.3267      0.864 0.000 0.884 0.116
#> SRR1058005     2  0.0892      0.959 0.000 0.980 0.020
#> SRR1058007     2  0.0892      0.959 0.000 0.980 0.020
#> SRR1058008     2  0.0892      0.959 0.000 0.980 0.020
#> SRR1058009     2  0.0000      0.967 0.000 1.000 0.000
#> SRR1058010     2  0.0592      0.966 0.000 0.988 0.012
#> SRR1058011     2  0.0424      0.967 0.000 0.992 0.008
#> SRR1058012     2  0.3619      0.833 0.000 0.864 0.136
#> SRR1058013     2  0.0000      0.967 0.000 1.000 0.000
#> SRR1058014     2  0.0892      0.959 0.000 0.980 0.020
#> SRR1058015     2  0.3682      0.857 0.008 0.876 0.116
#> SRR1058016     2  0.0424      0.967 0.000 0.992 0.008
#> SRR1058017     2  0.0892      0.963 0.000 0.980 0.020
#> SRR1058018     1  0.2878      0.906 0.904 0.000 0.096
#> SRR1058019     2  0.0424      0.967 0.000 0.992 0.008
#> SRR1058020     2  0.0000      0.967 0.000 1.000 0.000
#> SRR1058021     1  0.7860      0.581 0.656 0.228 0.116
#> SRR1058022     2  0.0424      0.967 0.000 0.992 0.008
#> SRR1058023     1  0.2878      0.906 0.904 0.000 0.096
#> SRR1058024     2  0.0237      0.966 0.000 0.996 0.004
#> SRR1058025     2  0.0000      0.967 0.000 1.000 0.000
#> SRR1058026     2  0.0892      0.963 0.000 0.980 0.020
#> SRR1058027     2  0.0592      0.966 0.000 0.988 0.012
#> SRR1058028     2  0.0892      0.963 0.000 0.980 0.020
#> SRR1058029     2  0.1753      0.943 0.000 0.952 0.048
#> SRR1058030     2  0.1163      0.958 0.000 0.972 0.028
#> SRR1058031     2  0.1529      0.949 0.000 0.960 0.040
#> SRR1058032     1  0.0000      0.964 1.000 0.000 0.000
#> SRR1058033     1  0.0000      0.964 1.000 0.000 0.000
#> SRR1058034     1  0.0000      0.964 1.000 0.000 0.000
#> SRR1058035     1  0.0000      0.964 1.000 0.000 0.000
#> SRR1058036     1  0.0000      0.964 1.000 0.000 0.000
#> SRR1058037     1  0.0000      0.964 1.000 0.000 0.000
#> SRR1058038     1  0.0000      0.964 1.000 0.000 0.000
#> SRR1058039     1  0.0000      0.964 1.000 0.000 0.000
#> SRR1058040     1  0.0000      0.964 1.000 0.000 0.000
#> SRR1058041     1  0.0000      0.964 1.000 0.000 0.000
#> SRR1058042     1  0.0000      0.964 1.000 0.000 0.000
#> SRR1058043     1  0.0000      0.964 1.000 0.000 0.000
#> SRR1058044     1  0.0000      0.964 1.000 0.000 0.000
#> SRR1058045     1  0.0000      0.964 1.000 0.000 0.000
#> SRR1058046     1  0.0000      0.964 1.000 0.000 0.000
#> SRR1058047     3  0.3267      1.000 0.000 0.116 0.884
#> SRR1058048     3  0.3267      1.000 0.000 0.116 0.884
#> SRR1058049     3  0.3267      1.000 0.000 0.116 0.884
#> SRR1058050     3  0.3267      1.000 0.000 0.116 0.884
#> SRR1058051     3  0.3267      1.000 0.000 0.116 0.884
#> SRR1058052     3  0.3267      1.000 0.000 0.116 0.884
#> SRR1058053     3  0.3267      1.000 0.000 0.116 0.884
#> SRR1058054     3  0.3267      1.000 0.000 0.116 0.884

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1058003     4  0.0188      0.978 0.004 0.000 0.000 0.996
#> SRR1058004     2  0.3032      0.872 0.000 0.868 0.008 0.124
#> SRR1058006     4  0.0188      0.977 0.000 0.004 0.000 0.996
#> SRR1058005     2  0.3032      0.872 0.000 0.868 0.008 0.124
#> SRR1058007     2  0.0804      0.955 0.000 0.980 0.008 0.012
#> SRR1058008     2  0.2271      0.914 0.000 0.916 0.008 0.076
#> SRR1058009     2  0.0804      0.962 0.000 0.980 0.012 0.008
#> SRR1058010     2  0.1004      0.961 0.000 0.972 0.024 0.004
#> SRR1058011     2  0.0779      0.962 0.000 0.980 0.016 0.004
#> SRR1058012     2  0.4011      0.747 0.000 0.784 0.208 0.008
#> SRR1058013     2  0.0376      0.961 0.000 0.992 0.004 0.004
#> SRR1058014     2  0.2124      0.920 0.000 0.924 0.008 0.068
#> SRR1058015     4  0.0000      0.978 0.000 0.000 0.000 1.000
#> SRR1058016     2  0.0469      0.962 0.000 0.988 0.012 0.000
#> SRR1058017     2  0.0921      0.959 0.000 0.972 0.028 0.000
#> SRR1058018     4  0.1211      0.958 0.040 0.000 0.000 0.960
#> SRR1058019     2  0.0469      0.962 0.000 0.988 0.012 0.000
#> SRR1058020     2  0.0657      0.958 0.000 0.984 0.012 0.004
#> SRR1058021     4  0.0000      0.978 0.000 0.000 0.000 1.000
#> SRR1058022     2  0.0672      0.961 0.000 0.984 0.008 0.008
#> SRR1058023     4  0.1118      0.963 0.036 0.000 0.000 0.964
#> SRR1058024     2  0.0188      0.960 0.000 0.996 0.000 0.004
#> SRR1058025     2  0.0524      0.962 0.000 0.988 0.008 0.004
#> SRR1058026     2  0.0707      0.961 0.000 0.980 0.020 0.000
#> SRR1058027     2  0.0336      0.962 0.000 0.992 0.008 0.000
#> SRR1058028     2  0.0817      0.959 0.000 0.976 0.024 0.000
#> SRR1058029     2  0.0921      0.959 0.000 0.972 0.028 0.000
#> SRR1058030     2  0.0921      0.959 0.000 0.972 0.028 0.000
#> SRR1058031     2  0.0921      0.959 0.000 0.972 0.028 0.000
#> SRR1058032     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1058033     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1058034     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1058035     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1058036     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1058037     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1058038     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1058039     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1058040     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1058041     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1058042     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1058043     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1058044     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1058045     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1058046     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1058047     3  0.0336      1.000 0.000 0.008 0.992 0.000
#> SRR1058048     3  0.0336      1.000 0.000 0.008 0.992 0.000
#> SRR1058049     3  0.0336      1.000 0.000 0.008 0.992 0.000
#> SRR1058050     3  0.0336      1.000 0.000 0.008 0.992 0.000
#> SRR1058051     3  0.0336      1.000 0.000 0.008 0.992 0.000
#> SRR1058052     3  0.0336      1.000 0.000 0.008 0.992 0.000
#> SRR1058053     3  0.0336      1.000 0.000 0.008 0.992 0.000
#> SRR1058054     3  0.0336      1.000 0.000 0.008 0.992 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4    p5
#> SRR1058003     5  0.2280      0.904 0.000 0.000 0.000 0.120 0.880
#> SRR1058004     4  0.4564      0.984 0.000 0.372 0.000 0.612 0.016
#> SRR1058006     5  0.0963      0.962 0.000 0.000 0.000 0.036 0.964
#> SRR1058005     4  0.4494      0.984 0.000 0.380 0.000 0.608 0.012
#> SRR1058007     2  0.4242     -0.449 0.000 0.572 0.000 0.428 0.000
#> SRR1058008     2  0.4283     -0.559 0.000 0.544 0.000 0.456 0.000
#> SRR1058009     2  0.2280      0.616 0.000 0.880 0.000 0.120 0.000
#> SRR1058010     2  0.1082      0.693 0.000 0.964 0.008 0.028 0.000
#> SRR1058011     2  0.1638      0.665 0.000 0.932 0.004 0.064 0.000
#> SRR1058012     2  0.5703      0.413 0.000 0.588 0.092 0.316 0.004
#> SRR1058013     2  0.2732      0.568 0.000 0.840 0.000 0.160 0.000
#> SRR1058014     2  0.4437     -0.539 0.000 0.532 0.000 0.464 0.004
#> SRR1058015     5  0.0609      0.966 0.000 0.000 0.000 0.020 0.980
#> SRR1058016     2  0.1041      0.693 0.000 0.964 0.004 0.032 0.000
#> SRR1058017     2  0.0693      0.692 0.000 0.980 0.008 0.012 0.000
#> SRR1058018     5  0.0566      0.963 0.012 0.000 0.000 0.004 0.984
#> SRR1058019     2  0.1205      0.684 0.000 0.956 0.004 0.040 0.000
#> SRR1058020     2  0.2377      0.673 0.000 0.872 0.000 0.128 0.000
#> SRR1058021     5  0.0510      0.966 0.000 0.000 0.000 0.016 0.984
#> SRR1058022     2  0.2516      0.586 0.000 0.860 0.000 0.140 0.000
#> SRR1058023     5  0.0566      0.963 0.012 0.000 0.000 0.004 0.984
#> SRR1058024     2  0.3816      0.557 0.000 0.696 0.000 0.304 0.000
#> SRR1058025     2  0.3636      0.592 0.000 0.728 0.000 0.272 0.000
#> SRR1058026     2  0.3838      0.562 0.000 0.716 0.004 0.280 0.000
#> SRR1058027     2  0.3969      0.549 0.000 0.692 0.004 0.304 0.000
#> SRR1058028     2  0.3689      0.582 0.000 0.740 0.004 0.256 0.000
#> SRR1058029     2  0.0693      0.690 0.000 0.980 0.008 0.012 0.000
#> SRR1058030     2  0.0671      0.689 0.000 0.980 0.004 0.016 0.000
#> SRR1058031     2  0.0798      0.691 0.000 0.976 0.008 0.016 0.000
#> SRR1058032     1  0.1043      0.970 0.960 0.000 0.000 0.040 0.000
#> SRR1058033     1  0.1043      0.970 0.960 0.000 0.000 0.040 0.000
#> SRR1058034     1  0.1043      0.970 0.960 0.000 0.000 0.040 0.000
#> SRR1058035     1  0.0000      0.993 1.000 0.000 0.000 0.000 0.000
#> SRR1058036     1  0.0000      0.993 1.000 0.000 0.000 0.000 0.000
#> SRR1058037     1  0.0000      0.993 1.000 0.000 0.000 0.000 0.000
#> SRR1058038     1  0.0000      0.993 1.000 0.000 0.000 0.000 0.000
#> SRR1058039     1  0.0000      0.993 1.000 0.000 0.000 0.000 0.000
#> SRR1058040     1  0.0000      0.993 1.000 0.000 0.000 0.000 0.000
#> SRR1058041     1  0.0000      0.993 1.000 0.000 0.000 0.000 0.000
#> SRR1058042     1  0.0000      0.993 1.000 0.000 0.000 0.000 0.000
#> SRR1058043     1  0.0000      0.993 1.000 0.000 0.000 0.000 0.000
#> SRR1058044     1  0.0000      0.993 1.000 0.000 0.000 0.000 0.000
#> SRR1058045     1  0.0000      0.993 1.000 0.000 0.000 0.000 0.000
#> SRR1058046     1  0.0000      0.993 1.000 0.000 0.000 0.000 0.000
#> SRR1058047     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1058048     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1058049     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1058050     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1058051     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1058052     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1058053     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1058054     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR1058003     5  0.3269     0.8176 0.000 0.000 0.000 0.184 0.792 0.024
#> SRR1058004     4  0.2006     0.6178 0.000 0.104 0.000 0.892 0.000 0.004
#> SRR1058006     5  0.1257     0.9345 0.000 0.000 0.000 0.020 0.952 0.028
#> SRR1058005     4  0.1814     0.6111 0.000 0.100 0.000 0.900 0.000 0.000
#> SRR1058007     4  0.5462     0.4743 0.000 0.400 0.000 0.476 0.000 0.124
#> SRR1058008     4  0.4751     0.6449 0.000 0.300 0.000 0.624 0.000 0.076
#> SRR1058009     2  0.3921     0.5731 0.000 0.768 0.000 0.116 0.000 0.116
#> SRR1058010     2  0.2889     0.6052 0.000 0.848 0.000 0.044 0.000 0.108
#> SRR1058011     2  0.2571     0.6338 0.000 0.876 0.000 0.060 0.000 0.064
#> SRR1058012     6  0.4871     0.0000 0.000 0.352 0.040 0.016 0.000 0.592
#> SRR1058013     2  0.4884     0.4033 0.000 0.652 0.000 0.220 0.000 0.128
#> SRR1058014     4  0.5689     0.5877 0.000 0.316 0.000 0.520 0.004 0.160
#> SRR1058015     5  0.0508     0.9430 0.000 0.000 0.000 0.004 0.984 0.012
#> SRR1058016     2  0.2106     0.6529 0.000 0.904 0.000 0.032 0.000 0.064
#> SRR1058017     2  0.1492     0.6504 0.000 0.940 0.000 0.024 0.000 0.036
#> SRR1058018     5  0.1346     0.9350 0.016 0.000 0.000 0.008 0.952 0.024
#> SRR1058019     2  0.2608     0.6538 0.000 0.872 0.000 0.048 0.000 0.080
#> SRR1058020     2  0.4238     0.5594 0.000 0.728 0.000 0.092 0.000 0.180
#> SRR1058021     5  0.0260     0.9432 0.000 0.000 0.000 0.000 0.992 0.008
#> SRR1058022     2  0.3328     0.6218 0.000 0.816 0.000 0.120 0.000 0.064
#> SRR1058023     5  0.0951     0.9410 0.004 0.000 0.000 0.008 0.968 0.020
#> SRR1058024     2  0.5556     0.2038 0.000 0.512 0.000 0.152 0.000 0.336
#> SRR1058025     2  0.5076    -0.0449 0.000 0.476 0.000 0.064 0.004 0.456
#> SRR1058026     2  0.4109    -0.0754 0.000 0.576 0.000 0.012 0.000 0.412
#> SRR1058027     2  0.4093    -0.2784 0.000 0.516 0.000 0.008 0.000 0.476
#> SRR1058028     2  0.3653     0.2726 0.000 0.692 0.000 0.008 0.000 0.300
#> SRR1058029     2  0.1410     0.6350 0.000 0.944 0.004 0.008 0.000 0.044
#> SRR1058030     2  0.1196     0.6407 0.000 0.952 0.000 0.008 0.000 0.040
#> SRR1058031     2  0.1370     0.6361 0.000 0.948 0.004 0.012 0.000 0.036
#> SRR1058032     1  0.2972     0.8599 0.836 0.000 0.000 0.036 0.000 0.128
#> SRR1058033     1  0.2972     0.8599 0.836 0.000 0.000 0.036 0.000 0.128
#> SRR1058034     1  0.2972     0.8599 0.836 0.000 0.000 0.036 0.000 0.128
#> SRR1058035     1  0.0000     0.9678 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058036     1  0.0000     0.9678 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058037     1  0.0000     0.9678 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058038     1  0.0000     0.9678 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058039     1  0.0000     0.9678 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058040     1  0.0000     0.9678 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058041     1  0.0000     0.9678 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058042     1  0.0000     0.9678 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058043     1  0.0000     0.9678 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058044     1  0.0000     0.9678 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058045     1  0.0000     0.9678 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058046     1  0.0000     0.9678 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1058047     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1058048     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1058049     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1058050     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1058051     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1058052     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1058053     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1058054     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

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

collect_plots(res)

plot of chunk ATC-pam-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.999       1.000         0.4496 0.551   0.551
#> 3 3 0.899           0.910       0.961         0.3796 0.837   0.705
#> 4 4 1.000           0.992       0.995         0.1270 0.902   0.751
#> 5 5 1.000           0.995       0.997         0.0391 0.973   0.910
#> 6 6 1.000           0.972       0.995         0.0239 0.983   0.940

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
#> SRR1058003     2   0.000      0.999 0.000 1.000
#> SRR1058004     2   0.000      0.999 0.000 1.000
#> SRR1058006     2   0.000      0.999 0.000 1.000
#> SRR1058005     2   0.000      0.999 0.000 1.000
#> SRR1058007     2   0.000      0.999 0.000 1.000
#> SRR1058008     2   0.000      0.999 0.000 1.000
#> SRR1058009     2   0.000      0.999 0.000 1.000
#> SRR1058010     2   0.000      0.999 0.000 1.000
#> SRR1058011     2   0.000      0.999 0.000 1.000
#> SRR1058012     2   0.000      0.999 0.000 1.000
#> SRR1058013     2   0.000      0.999 0.000 1.000
#> SRR1058014     2   0.000      0.999 0.000 1.000
#> SRR1058015     2   0.000      0.999 0.000 1.000
#> SRR1058016     2   0.000      0.999 0.000 1.000
#> SRR1058017     2   0.000      0.999 0.000 1.000
#> SRR1058018     1   0.000      1.000 1.000 0.000
#> SRR1058019     2   0.000      0.999 0.000 1.000
#> SRR1058020     2   0.000      0.999 0.000 1.000
#> SRR1058021     2   0.163      0.975 0.024 0.976
#> SRR1058022     2   0.000      0.999 0.000 1.000
#> SRR1058023     1   0.000      1.000 1.000 0.000
#> SRR1058024     2   0.000      0.999 0.000 1.000
#> SRR1058025     2   0.000      0.999 0.000 1.000
#> SRR1058026     2   0.000      0.999 0.000 1.000
#> SRR1058027     2   0.000      0.999 0.000 1.000
#> SRR1058028     2   0.000      0.999 0.000 1.000
#> SRR1058029     2   0.000      0.999 0.000 1.000
#> SRR1058030     2   0.000      0.999 0.000 1.000
#> SRR1058031     2   0.000      0.999 0.000 1.000
#> SRR1058032     1   0.000      1.000 1.000 0.000
#> SRR1058033     1   0.000      1.000 1.000 0.000
#> SRR1058034     1   0.000      1.000 1.000 0.000
#> SRR1058035     1   0.000      1.000 1.000 0.000
#> SRR1058036     1   0.000      1.000 1.000 0.000
#> SRR1058037     1   0.000      1.000 1.000 0.000
#> SRR1058038     1   0.000      1.000 1.000 0.000
#> SRR1058039     1   0.000      1.000 1.000 0.000
#> SRR1058040     1   0.000      1.000 1.000 0.000
#> SRR1058041     1   0.000      1.000 1.000 0.000
#> SRR1058042     1   0.000      1.000 1.000 0.000
#> SRR1058043     1   0.000      1.000 1.000 0.000
#> SRR1058044     1   0.000      1.000 1.000 0.000
#> SRR1058045     1   0.000      1.000 1.000 0.000
#> SRR1058046     1   0.000      1.000 1.000 0.000
#> SRR1058047     2   0.000      0.999 0.000 1.000
#> SRR1058048     2   0.000      0.999 0.000 1.000
#> SRR1058049     2   0.000      0.999 0.000 1.000
#> SRR1058050     2   0.000      0.999 0.000 1.000
#> SRR1058051     2   0.000      0.999 0.000 1.000
#> SRR1058052     2   0.000      0.999 0.000 1.000
#> SRR1058053     2   0.000      0.999 0.000 1.000
#> SRR1058054     2   0.000      0.999 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1058003     2  0.0000      0.951 0.000 1.000 0.000
#> SRR1058004     2  0.0000      0.951 0.000 1.000 0.000
#> SRR1058006     2  0.0000      0.951 0.000 1.000 0.000
#> SRR1058005     2  0.0000      0.951 0.000 1.000 0.000
#> SRR1058007     2  0.0000      0.951 0.000 1.000 0.000
#> SRR1058008     2  0.0000      0.951 0.000 1.000 0.000
#> SRR1058009     2  0.0000      0.951 0.000 1.000 0.000
#> SRR1058010     2  0.0000      0.951 0.000 1.000 0.000
#> SRR1058011     2  0.0000      0.951 0.000 1.000 0.000
#> SRR1058012     2  0.2066      0.918 0.000 0.940 0.060
#> SRR1058013     2  0.0000      0.951 0.000 1.000 0.000
#> SRR1058014     2  0.0000      0.951 0.000 1.000 0.000
#> SRR1058015     2  0.0000      0.951 0.000 1.000 0.000
#> SRR1058016     2  0.0000      0.951 0.000 1.000 0.000
#> SRR1058017     2  0.4291      0.808 0.000 0.820 0.180
#> SRR1058018     1  0.5254      0.624 0.736 0.264 0.000
#> SRR1058019     2  0.1163      0.936 0.000 0.972 0.028
#> SRR1058020     2  0.0000      0.951 0.000 1.000 0.000
#> SRR1058021     2  0.0000      0.951 0.000 1.000 0.000
#> SRR1058022     2  0.0000      0.951 0.000 1.000 0.000
#> SRR1058023     1  0.6309      0.070 0.504 0.496 0.000
#> SRR1058024     2  0.0000      0.951 0.000 1.000 0.000
#> SRR1058025     2  0.0000      0.951 0.000 1.000 0.000
#> SRR1058026     2  0.3686      0.854 0.000 0.860 0.140
#> SRR1058027     2  0.0747      0.943 0.000 0.984 0.016
#> SRR1058028     2  0.3686      0.854 0.000 0.860 0.140
#> SRR1058029     2  0.6026      0.486 0.000 0.624 0.376
#> SRR1058030     2  0.2625      0.901 0.000 0.916 0.084
#> SRR1058031     2  0.5098      0.724 0.000 0.752 0.248
#> SRR1058032     1  0.0000      0.939 1.000 0.000 0.000
#> SRR1058033     1  0.0000      0.939 1.000 0.000 0.000
#> SRR1058034     1  0.0000      0.939 1.000 0.000 0.000
#> SRR1058035     1  0.0000      0.939 1.000 0.000 0.000
#> SRR1058036     1  0.0000      0.939 1.000 0.000 0.000
#> SRR1058037     1  0.0000      0.939 1.000 0.000 0.000
#> SRR1058038     1  0.0000      0.939 1.000 0.000 0.000
#> SRR1058039     1  0.0000      0.939 1.000 0.000 0.000
#> SRR1058040     1  0.0000      0.939 1.000 0.000 0.000
#> SRR1058041     1  0.0000      0.939 1.000 0.000 0.000
#> SRR1058042     1  0.0000      0.939 1.000 0.000 0.000
#> SRR1058043     1  0.0000      0.939 1.000 0.000 0.000
#> SRR1058044     1  0.0000      0.939 1.000 0.000 0.000
#> SRR1058045     1  0.0000      0.939 1.000 0.000 0.000
#> SRR1058046     1  0.0000      0.939 1.000 0.000 0.000
#> SRR1058047     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1058048     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1058049     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1058050     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1058051     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1058052     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1058053     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1058054     3  0.0000      1.000 0.000 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1058003     4  0.0469      0.991 0.000 0.012 0.000 0.988
#> SRR1058004     2  0.0000      0.992 0.000 1.000 0.000 0.000
#> SRR1058006     4  0.0592      0.992 0.000 0.016 0.000 0.984
#> SRR1058005     2  0.0000      0.992 0.000 1.000 0.000 0.000
#> SRR1058007     2  0.0000      0.992 0.000 1.000 0.000 0.000
#> SRR1058008     2  0.0000      0.992 0.000 1.000 0.000 0.000
#> SRR1058009     2  0.0000      0.992 0.000 1.000 0.000 0.000
#> SRR1058010     2  0.0000      0.992 0.000 1.000 0.000 0.000
#> SRR1058011     2  0.0000      0.992 0.000 1.000 0.000 0.000
#> SRR1058012     2  0.0376      0.990 0.000 0.992 0.004 0.004
#> SRR1058013     2  0.0000      0.992 0.000 1.000 0.000 0.000
#> SRR1058014     2  0.1867      0.924 0.000 0.928 0.000 0.072
#> SRR1058015     4  0.0592      0.992 0.000 0.016 0.000 0.984
#> SRR1058016     2  0.0000      0.992 0.000 1.000 0.000 0.000
#> SRR1058017     2  0.0469      0.986 0.000 0.988 0.012 0.000
#> SRR1058018     4  0.0188      0.983 0.004 0.000 0.000 0.996
#> SRR1058019     2  0.0000      0.992 0.000 1.000 0.000 0.000
#> SRR1058020     2  0.0000      0.992 0.000 1.000 0.000 0.000
#> SRR1058021     4  0.0592      0.992 0.000 0.016 0.000 0.984
#> SRR1058022     2  0.0000      0.992 0.000 1.000 0.000 0.000
#> SRR1058023     4  0.0376      0.987 0.004 0.004 0.000 0.992
#> SRR1058024     2  0.0469      0.984 0.000 0.988 0.000 0.012
#> SRR1058025     2  0.0000      0.992 0.000 1.000 0.000 0.000
#> SRR1058026     2  0.0469      0.986 0.000 0.988 0.012 0.000
#> SRR1058027     2  0.0188      0.991 0.000 0.996 0.004 0.000
#> SRR1058028     2  0.0188      0.991 0.000 0.996 0.004 0.000
#> SRR1058029     2  0.0707      0.980 0.000 0.980 0.020 0.000
#> SRR1058030     2  0.0188      0.991 0.000 0.996 0.004 0.000
#> SRR1058031     2  0.0592      0.983 0.000 0.984 0.016 0.000
#> SRR1058032     1  0.0592      0.988 0.984 0.000 0.000 0.016
#> SRR1058033     1  0.0592      0.988 0.984 0.000 0.000 0.016
#> SRR1058034     1  0.0592      0.988 0.984 0.000 0.000 0.016
#> SRR1058035     1  0.0000      0.997 1.000 0.000 0.000 0.000
#> SRR1058036     1  0.0000      0.997 1.000 0.000 0.000 0.000
#> SRR1058037     1  0.0000      0.997 1.000 0.000 0.000 0.000
#> SRR1058038     1  0.0000      0.997 1.000 0.000 0.000 0.000
#> SRR1058039     1  0.0000      0.997 1.000 0.000 0.000 0.000
#> SRR1058040     1  0.0000      0.997 1.000 0.000 0.000 0.000
#> SRR1058041     1  0.0000      0.997 1.000 0.000 0.000 0.000
#> SRR1058042     1  0.0000      0.997 1.000 0.000 0.000 0.000
#> SRR1058043     1  0.0000      0.997 1.000 0.000 0.000 0.000
#> SRR1058044     1  0.0000      0.997 1.000 0.000 0.000 0.000
#> SRR1058045     1  0.0000      0.997 1.000 0.000 0.000 0.000
#> SRR1058046     1  0.0000      0.997 1.000 0.000 0.000 0.000
#> SRR1058047     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1058048     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1058049     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1058050     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1058051     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1058052     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1058053     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR1058054     3  0.0000      1.000 0.000 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette p1    p2    p3    p4    p5
#> SRR1058003     5  0.0000      0.999  0 0.000 0.000 0.000 1.000
#> SRR1058004     2  0.0162      0.993  0 0.996 0.000 0.000 0.004
#> SRR1058006     5  0.0000      0.999  0 0.000 0.000 0.000 1.000
#> SRR1058005     2  0.0162      0.993  0 0.996 0.000 0.000 0.004
#> SRR1058007     2  0.0162      0.993  0 0.996 0.000 0.000 0.004
#> SRR1058008     2  0.0162      0.993  0 0.996 0.000 0.000 0.004
#> SRR1058009     2  0.0162      0.993  0 0.996 0.000 0.000 0.004
#> SRR1058010     2  0.0000      0.994  0 1.000 0.000 0.000 0.000
#> SRR1058011     2  0.0000      0.994  0 1.000 0.000 0.000 0.000
#> SRR1058012     2  0.0290      0.990  0 0.992 0.000 0.000 0.008
#> SRR1058013     2  0.0162      0.993  0 0.996 0.000 0.000 0.004
#> SRR1058014     2  0.1792      0.910  0 0.916 0.000 0.000 0.084
#> SRR1058015     5  0.0000      0.999  0 0.000 0.000 0.000 1.000
#> SRR1058016     2  0.0000      0.994  0 1.000 0.000 0.000 0.000
#> SRR1058017     2  0.0000      0.994  0 1.000 0.000 0.000 0.000
#> SRR1058018     5  0.0162      0.994  0 0.000 0.000 0.004 0.996
#> SRR1058019     2  0.0000      0.994  0 1.000 0.000 0.000 0.000
#> SRR1058020     2  0.0000      0.994  0 1.000 0.000 0.000 0.000
#> SRR1058021     5  0.0000      0.999  0 0.000 0.000 0.000 1.000
#> SRR1058022     2  0.0000      0.994  0 1.000 0.000 0.000 0.000
#> SRR1058023     5  0.0000      0.999  0 0.000 0.000 0.000 1.000
#> SRR1058024     2  0.0510      0.983  0 0.984 0.000 0.000 0.016
#> SRR1058025     2  0.0162      0.993  0 0.996 0.000 0.000 0.004
#> SRR1058026     2  0.0000      0.994  0 1.000 0.000 0.000 0.000
#> SRR1058027     2  0.0000      0.994  0 1.000 0.000 0.000 0.000
#> SRR1058028     2  0.0000      0.994  0 1.000 0.000 0.000 0.000
#> SRR1058029     2  0.0162      0.991  0 0.996 0.004 0.000 0.000
#> SRR1058030     2  0.0000      0.994  0 1.000 0.000 0.000 0.000
#> SRR1058031     2  0.0000      0.994  0 1.000 0.000 0.000 0.000
#> SRR1058032     4  0.0000      1.000  0 0.000 0.000 1.000 0.000
#> SRR1058033     4  0.0000      1.000  0 0.000 0.000 1.000 0.000
#> SRR1058034     4  0.0000      1.000  0 0.000 0.000 1.000 0.000
#> SRR1058035     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1058036     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1058037     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1058038     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1058039     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1058040     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1058041     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1058042     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1058043     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1058044     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1058045     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1058046     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> SRR1058047     3  0.0000      1.000  0 0.000 1.000 0.000 0.000
#> SRR1058048     3  0.0000      1.000  0 0.000 1.000 0.000 0.000
#> SRR1058049     3  0.0000      1.000  0 0.000 1.000 0.000 0.000
#> SRR1058050     3  0.0000      1.000  0 0.000 1.000 0.000 0.000
#> SRR1058051     3  0.0000      1.000  0 0.000 1.000 0.000 0.000
#> SRR1058052     3  0.0000      1.000  0 0.000 1.000 0.000 0.000
#> SRR1058053     3  0.0000      1.000  0 0.000 1.000 0.000 0.000
#> SRR1058054     3  0.0000      1.000  0 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette p1    p2 p3 p4    p5    p6
#> SRR1058003     5  0.0000      0.990  0 0.000  0  0 1.000 0.000
#> SRR1058004     2  0.0363      0.986  0 0.988  0  0 0.000 0.012
#> SRR1058006     5  0.0363      0.988  0 0.000  0  0 0.988 0.012
#> SRR1058005     2  0.0363      0.986  0 0.988  0  0 0.000 0.012
#> SRR1058007     2  0.0508      0.983  0 0.984  0  0 0.004 0.012
#> SRR1058008     2  0.0363      0.986  0 0.988  0  0 0.000 0.012
#> SRR1058009     2  0.0363      0.986  0 0.988  0  0 0.000 0.012
#> SRR1058010     2  0.0000      0.988  0 1.000  0  0 0.000 0.000
#> SRR1058011     2  0.0000      0.988  0 1.000  0  0 0.000 0.000
#> SRR1058012     6  0.0000      0.000  0 0.000  0  0 0.000 1.000
#> SRR1058013     2  0.0363      0.986  0 0.988  0  0 0.000 0.012
#> SRR1058014     2  0.2170      0.878  0 0.888  0  0 0.100 0.012
#> SRR1058015     5  0.0260      0.990  0 0.000  0  0 0.992 0.008
#> SRR1058016     2  0.0000      0.988  0 1.000  0  0 0.000 0.000
#> SRR1058017     2  0.0000      0.988  0 1.000  0  0 0.000 0.000
#> SRR1058018     5  0.0000      0.990  0 0.000  0  0 1.000 0.000
#> SRR1058019     2  0.0000      0.988  0 1.000  0  0 0.000 0.000
#> SRR1058020     2  0.0146      0.988  0 0.996  0  0 0.000 0.004
#> SRR1058021     5  0.0363      0.988  0 0.000  0  0 0.988 0.012
#> SRR1058022     2  0.0000      0.988  0 1.000  0  0 0.000 0.000
#> SRR1058023     5  0.0000      0.990  0 0.000  0  0 1.000 0.000
#> SRR1058024     2  0.0993      0.966  0 0.964  0  0 0.024 0.012
#> SRR1058025     2  0.0363      0.986  0 0.988  0  0 0.000 0.012
#> SRR1058026     2  0.0000      0.988  0 1.000  0  0 0.000 0.000
#> SRR1058027     2  0.0000      0.988  0 1.000  0  0 0.000 0.000
#> SRR1058028     2  0.0000      0.988  0 1.000  0  0 0.000 0.000
#> SRR1058029     2  0.0000      0.988  0 1.000  0  0 0.000 0.000
#> SRR1058030     2  0.0000      0.988  0 1.000  0  0 0.000 0.000
#> SRR1058031     2  0.0000      0.988  0 1.000  0  0 0.000 0.000
#> SRR1058032     4  0.0000      1.000  0 0.000  0  1 0.000 0.000
#> SRR1058033     4  0.0000      1.000  0 0.000  0  1 0.000 0.000
#> SRR1058034     4  0.0000      1.000  0 0.000  0  1 0.000 0.000
#> SRR1058035     1  0.0000      1.000  1 0.000  0  0 0.000 0.000
#> SRR1058036     1  0.0000      1.000  1 0.000  0  0 0.000 0.000
#> SRR1058037     1  0.0000      1.000  1 0.000  0  0 0.000 0.000
#> SRR1058038     1  0.0000      1.000  1 0.000  0  0 0.000 0.000
#> SRR1058039     1  0.0000      1.000  1 0.000  0  0 0.000 0.000
#> SRR1058040     1  0.0000      1.000  1 0.000  0  0 0.000 0.000
#> SRR1058041     1  0.0000      1.000  1 0.000  0  0 0.000 0.000
#> SRR1058042     1  0.0000      1.000  1 0.000  0  0 0.000 0.000
#> SRR1058043     1  0.0000      1.000  1 0.000  0  0 0.000 0.000
#> SRR1058044     1  0.0000      1.000  1 0.000  0  0 0.000 0.000
#> SRR1058045     1  0.0000      1.000  1 0.000  0  0 0.000 0.000
#> SRR1058046     1  0.0000      1.000  1 0.000  0  0 0.000 0.000
#> SRR1058047     3  0.0000      1.000  0 0.000  1  0 0.000 0.000
#> SRR1058048     3  0.0000      1.000  0 0.000  1  0 0.000 0.000
#> SRR1058049     3  0.0000      1.000  0 0.000  1  0 0.000 0.000
#> SRR1058050     3  0.0000      1.000  0 0.000  1  0 0.000 0.000
#> SRR1058051     3  0.0000      1.000  0 0.000  1  0 0.000 0.000
#> SRR1058052     3  0.0000      1.000  0 0.000  1  0 0.000 0.000
#> SRR1058053     3  0.0000      1.000  0 0.000  1  0 0.000 0.000
#> SRR1058054     3  0.0000      1.000  0 0.000  1  0 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

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

collect_plots(res)

plot of chunk ATC-mclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.997       0.998         0.3636 0.638   0.638
#> 3 3 0.953           0.986       0.993         0.6389 0.714   0.570
#> 4 4 0.860           0.882       0.937         0.0866 0.949   0.876
#> 5 5 1.000           0.969       0.980         0.1330 0.882   0.682
#> 6 6 0.876           0.869       0.922         0.1130 0.912   0.662

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

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
#> SRR1058003     2  0.0000      0.998 0.000 1.000
#> SRR1058004     2  0.0000      0.998 0.000 1.000
#> SRR1058006     2  0.0000      0.998 0.000 1.000
#> SRR1058005     2  0.0000      0.998 0.000 1.000
#> SRR1058007     2  0.0000      0.998 0.000 1.000
#> SRR1058008     2  0.0000      0.998 0.000 1.000
#> SRR1058009     2  0.0000      0.998 0.000 1.000
#> SRR1058010     2  0.0000      0.998 0.000 1.000
#> SRR1058011     2  0.0000      0.998 0.000 1.000
#> SRR1058012     2  0.0000      0.998 0.000 1.000
#> SRR1058013     2  0.0000      0.998 0.000 1.000
#> SRR1058014     2  0.0000      0.998 0.000 1.000
#> SRR1058015     2  0.0000      0.998 0.000 1.000
#> SRR1058016     2  0.0000      0.998 0.000 1.000
#> SRR1058017     2  0.0000      0.998 0.000 1.000
#> SRR1058018     2  0.0000      0.998 0.000 1.000
#> SRR1058019     2  0.0000      0.998 0.000 1.000
#> SRR1058020     2  0.0000      0.998 0.000 1.000
#> SRR1058021     2  0.0000      0.998 0.000 1.000
#> SRR1058022     2  0.0000      0.998 0.000 1.000
#> SRR1058023     2  0.0000      0.998 0.000 1.000
#> SRR1058024     2  0.0000      0.998 0.000 1.000
#> SRR1058025     2  0.0000      0.998 0.000 1.000
#> SRR1058026     2  0.0000      0.998 0.000 1.000
#> SRR1058027     2  0.0000      0.998 0.000 1.000
#> SRR1058028     2  0.0000      0.998 0.000 1.000
#> SRR1058029     2  0.0000      0.998 0.000 1.000
#> SRR1058030     2  0.0000      0.998 0.000 1.000
#> SRR1058031     2  0.0000      0.998 0.000 1.000
#> SRR1058032     2  0.0672      0.994 0.008 0.992
#> SRR1058033     2  0.0672      0.994 0.008 0.992
#> SRR1058034     2  0.0672      0.994 0.008 0.992
#> SRR1058035     1  0.0000      1.000 1.000 0.000
#> SRR1058036     1  0.0000      1.000 1.000 0.000
#> SRR1058037     1  0.0000      1.000 1.000 0.000
#> SRR1058038     1  0.0000      1.000 1.000 0.000
#> SRR1058039     1  0.0000      1.000 1.000 0.000
#> SRR1058040     1  0.0000      1.000 1.000 0.000
#> SRR1058041     1  0.0000      1.000 1.000 0.000
#> SRR1058042     1  0.0000      1.000 1.000 0.000
#> SRR1058043     1  0.0000      1.000 1.000 0.000
#> SRR1058044     1  0.0000      1.000 1.000 0.000
#> SRR1058045     1  0.0000      1.000 1.000 0.000
#> SRR1058046     1  0.0000      1.000 1.000 0.000
#> SRR1058047     2  0.0672      0.994 0.008 0.992
#> SRR1058048     2  0.0672      0.994 0.008 0.992
#> SRR1058049     2  0.0672      0.994 0.008 0.992
#> SRR1058050     2  0.0672      0.994 0.008 0.992
#> SRR1058051     2  0.0672      0.994 0.008 0.992
#> SRR1058052     2  0.0672      0.994 0.008 0.992
#> SRR1058053     2  0.0672      0.994 0.008 0.992
#> SRR1058054     2  0.0672      0.994 0.008 0.992

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette  p1    p2    p3
#> SRR1058003     2   0.000      0.997 0.0 1.000 0.000
#> SRR1058004     2   0.000      0.997 0.0 1.000 0.000
#> SRR1058006     2   0.000      0.997 0.0 1.000 0.000
#> SRR1058005     2   0.000      0.997 0.0 1.000 0.000
#> SRR1058007     2   0.000      0.997 0.0 1.000 0.000
#> SRR1058008     2   0.000      0.997 0.0 1.000 0.000
#> SRR1058009     2   0.000      0.997 0.0 1.000 0.000
#> SRR1058010     2   0.000      0.997 0.0 1.000 0.000
#> SRR1058011     2   0.000      0.997 0.0 1.000 0.000
#> SRR1058012     2   0.271      0.900 0.0 0.912 0.088
#> SRR1058013     2   0.000      0.997 0.0 1.000 0.000
#> SRR1058014     2   0.000      0.997 0.0 1.000 0.000
#> SRR1058015     2   0.000      0.997 0.0 1.000 0.000
#> SRR1058016     2   0.000      0.997 0.0 1.000 0.000
#> SRR1058017     2   0.000      0.997 0.0 1.000 0.000
#> SRR1058018     2   0.000      0.997 0.0 1.000 0.000
#> SRR1058019     2   0.000      0.997 0.0 1.000 0.000
#> SRR1058020     2   0.000      0.997 0.0 1.000 0.000
#> SRR1058021     2   0.000      0.997 0.0 1.000 0.000
#> SRR1058022     2   0.000      0.997 0.0 1.000 0.000
#> SRR1058023     2   0.000      0.997 0.0 1.000 0.000
#> SRR1058024     2   0.000      0.997 0.0 1.000 0.000
#> SRR1058025     2   0.000      0.997 0.0 1.000 0.000
#> SRR1058026     2   0.000      0.997 0.0 1.000 0.000
#> SRR1058027     2   0.000      0.997 0.0 1.000 0.000
#> SRR1058028     2   0.000      0.997 0.0 1.000 0.000
#> SRR1058029     2   0.000      0.997 0.0 1.000 0.000
#> SRR1058030     2   0.000      0.997 0.0 1.000 0.000
#> SRR1058031     2   0.000      0.997 0.0 1.000 0.000
#> SRR1058032     1   0.296      0.903 0.9 0.000 0.100
#> SRR1058033     1   0.296      0.903 0.9 0.000 0.100
#> SRR1058034     1   0.296      0.903 0.9 0.000 0.100
#> SRR1058035     1   0.000      0.978 1.0 0.000 0.000
#> SRR1058036     1   0.000      0.978 1.0 0.000 0.000
#> SRR1058037     1   0.000      0.978 1.0 0.000 0.000
#> SRR1058038     1   0.000      0.978 1.0 0.000 0.000
#> SRR1058039     1   0.000      0.978 1.0 0.000 0.000
#> SRR1058040     1   0.000      0.978 1.0 0.000 0.000
#> SRR1058041     1   0.000      0.978 1.0 0.000 0.000
#> SRR1058042     1   0.000      0.978 1.0 0.000 0.000
#> SRR1058043     1   0.000      0.978 1.0 0.000 0.000
#> SRR1058044     1   0.000      0.978 1.0 0.000 0.000
#> SRR1058045     1   0.000      0.978 1.0 0.000 0.000
#> SRR1058046     1   0.000      0.978 1.0 0.000 0.000
#> SRR1058047     3   0.000      1.000 0.0 0.000 1.000
#> SRR1058048     3   0.000      1.000 0.0 0.000 1.000
#> SRR1058049     3   0.000      1.000 0.0 0.000 1.000
#> SRR1058050     3   0.000      1.000 0.0 0.000 1.000
#> SRR1058051     3   0.000      1.000 0.0 0.000 1.000
#> SRR1058052     3   0.000      1.000 0.0 0.000 1.000
#> SRR1058053     3   0.000      1.000 0.0 0.000 1.000
#> SRR1058054     3   0.000      1.000 0.0 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2 p3    p4
#> SRR1058003     2  0.0336      0.937 0.000 0.992  0 0.008
#> SRR1058004     2  0.1022      0.927 0.000 0.968  0 0.032
#> SRR1058006     2  0.0188      0.938 0.000 0.996  0 0.004
#> SRR1058005     2  0.1022      0.927 0.000 0.968  0 0.032
#> SRR1058007     2  0.0188      0.938 0.000 0.996  0 0.004
#> SRR1058008     2  0.0188      0.938 0.000 0.996  0 0.004
#> SRR1058009     2  0.0000      0.938 0.000 1.000  0 0.000
#> SRR1058010     2  0.0592      0.935 0.000 0.984  0 0.016
#> SRR1058011     2  0.0469      0.936 0.000 0.988  0 0.012
#> SRR1058012     4  0.4998     -0.384 0.000 0.488  0 0.512
#> SRR1058013     2  0.0000      0.938 0.000 1.000  0 0.000
#> SRR1058014     2  0.0188      0.938 0.000 0.996  0 0.004
#> SRR1058015     2  0.0336      0.938 0.000 0.992  0 0.008
#> SRR1058016     2  0.0336      0.937 0.000 0.992  0 0.008
#> SRR1058017     2  0.1637      0.907 0.000 0.940  0 0.060
#> SRR1058018     2  0.0336      0.938 0.000 0.992  0 0.008
#> SRR1058019     2  0.0336      0.937 0.000 0.992  0 0.008
#> SRR1058020     2  0.0592      0.935 0.000 0.984  0 0.016
#> SRR1058021     2  0.0336      0.938 0.000 0.992  0 0.008
#> SRR1058022     2  0.0000      0.938 0.000 1.000  0 0.000
#> SRR1058023     2  0.0336      0.938 0.000 0.992  0 0.008
#> SRR1058024     2  0.0188      0.938 0.000 0.996  0 0.004
#> SRR1058025     2  0.0188      0.938 0.000 0.996  0 0.004
#> SRR1058026     2  0.4040      0.750 0.000 0.752  0 0.248
#> SRR1058027     2  0.4040      0.750 0.000 0.752  0 0.248
#> SRR1058028     2  0.3942      0.761 0.000 0.764  0 0.236
#> SRR1058029     2  0.3569      0.796 0.000 0.804  0 0.196
#> SRR1058030     2  0.3569      0.796 0.000 0.804  0 0.196
#> SRR1058031     2  0.3569      0.796 0.000 0.804  0 0.196
#> SRR1058032     4  0.4643      0.508 0.344 0.000  0 0.656
#> SRR1058033     4  0.4643      0.508 0.344 0.000  0 0.656
#> SRR1058034     4  0.4643      0.508 0.344 0.000  0 0.656
#> SRR1058035     1  0.0000      0.977 1.000 0.000  0 0.000
#> SRR1058036     1  0.0000      0.977 1.000 0.000  0 0.000
#> SRR1058037     1  0.0000      0.977 1.000 0.000  0 0.000
#> SRR1058038     1  0.0000      0.977 1.000 0.000  0 0.000
#> SRR1058039     1  0.0000      0.977 1.000 0.000  0 0.000
#> SRR1058040     1  0.2469      0.859 0.892 0.000  0 0.108
#> SRR1058041     1  0.0000      0.977 1.000 0.000  0 0.000
#> SRR1058042     1  0.0000      0.977 1.000 0.000  0 0.000
#> SRR1058043     1  0.2149      0.885 0.912 0.000  0 0.088
#> SRR1058044     1  0.0000      0.977 1.000 0.000  0 0.000
#> SRR1058045     1  0.0000      0.977 1.000 0.000  0 0.000
#> SRR1058046     1  0.0000      0.977 1.000 0.000  0 0.000
#> SRR1058047     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1058048     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1058049     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1058050     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1058051     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1058052     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1058053     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1058054     3  0.0000      1.000 0.000 0.000  1 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2 p3    p4    p5
#> SRR1058003     4  0.2629      0.818 0.000 0.136  0 0.860 0.004
#> SRR1058004     4  0.2471      0.820 0.000 0.136  0 0.864 0.000
#> SRR1058006     2  0.0290      0.987 0.000 0.992  0 0.000 0.008
#> SRR1058005     4  0.2966      0.809 0.000 0.136  0 0.848 0.016
#> SRR1058007     2  0.0290      0.987 0.000 0.992  0 0.000 0.008
#> SRR1058008     2  0.0609      0.986 0.000 0.980  0 0.000 0.020
#> SRR1058009     2  0.0162      0.987 0.000 0.996  0 0.000 0.004
#> SRR1058010     2  0.0404      0.986 0.000 0.988  0 0.000 0.012
#> SRR1058011     2  0.0404      0.986 0.000 0.988  0 0.000 0.012
#> SRR1058012     5  0.0000      0.969 0.000 0.000  0 0.000 1.000
#> SRR1058013     2  0.0290      0.987 0.000 0.992  0 0.000 0.008
#> SRR1058014     2  0.0404      0.987 0.000 0.988  0 0.000 0.012
#> SRR1058015     2  0.0404      0.987 0.000 0.988  0 0.000 0.012
#> SRR1058016     2  0.0510      0.986 0.000 0.984  0 0.000 0.016
#> SRR1058017     2  0.0290      0.987 0.000 0.992  0 0.000 0.008
#> SRR1058018     2  0.0510      0.986 0.000 0.984  0 0.000 0.016
#> SRR1058019     2  0.0290      0.987 0.000 0.992  0 0.000 0.008
#> SRR1058020     2  0.0794      0.982 0.000 0.972  0 0.000 0.028
#> SRR1058021     2  0.0404      0.987 0.000 0.988  0 0.000 0.012
#> SRR1058022     2  0.0162      0.986 0.000 0.996  0 0.000 0.004
#> SRR1058023     2  0.0510      0.986 0.000 0.984  0 0.000 0.016
#> SRR1058024     2  0.0703      0.985 0.000 0.976  0 0.000 0.024
#> SRR1058025     2  0.0794      0.983 0.000 0.972  0 0.000 0.028
#> SRR1058026     5  0.0000      0.969 0.000 0.000  0 0.000 1.000
#> SRR1058027     5  0.0000      0.969 0.000 0.000  0 0.000 1.000
#> SRR1058028     5  0.1270      0.905 0.000 0.052  0 0.000 0.948
#> SRR1058029     2  0.0794      0.971 0.000 0.972  0 0.000 0.028
#> SRR1058030     2  0.0794      0.971 0.000 0.972  0 0.000 0.028
#> SRR1058031     2  0.0794      0.971 0.000 0.972  0 0.000 0.028
#> SRR1058032     4  0.1671      0.822 0.076 0.000  0 0.924 0.000
#> SRR1058033     4  0.1671      0.822 0.076 0.000  0 0.924 0.000
#> SRR1058034     4  0.1671      0.822 0.076 0.000  0 0.924 0.000
#> SRR1058035     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> SRR1058036     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> SRR1058037     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> SRR1058038     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> SRR1058039     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> SRR1058040     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> SRR1058041     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> SRR1058042     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> SRR1058043     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> SRR1058044     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> SRR1058045     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> SRR1058046     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> SRR1058047     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1058048     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1058049     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1058050     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1058051     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1058052     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1058053     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1058054     3  0.0000      1.000 0.000 0.000  1 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2 p3    p4    p5    p6
#> SRR1058003     4  0.3274      0.857 0.000 0.080  0 0.824 0.096 0.000
#> SRR1058004     4  0.3167      0.860 0.000 0.072  0 0.832 0.096 0.000
#> SRR1058006     5  0.2697      0.739 0.000 0.188  0 0.000 0.812 0.000
#> SRR1058005     4  0.2462      0.868 0.000 0.028  0 0.876 0.096 0.000
#> SRR1058007     5  0.2416      0.777 0.000 0.156  0 0.000 0.844 0.000
#> SRR1058008     5  0.1863      0.817 0.000 0.104  0 0.000 0.896 0.000
#> SRR1058009     2  0.1814      0.802 0.000 0.900  0 0.000 0.100 0.000
#> SRR1058010     2  0.3911      0.533 0.000 0.624  0 0.000 0.368 0.008
#> SRR1058011     5  0.4032      0.118 0.000 0.420  0 0.000 0.572 0.008
#> SRR1058012     6  0.0000      0.989 0.000 0.000  0 0.000 0.000 1.000
#> SRR1058013     5  0.3309      0.613 0.000 0.280  0 0.000 0.720 0.000
#> SRR1058014     5  0.1765      0.825 0.000 0.096  0 0.000 0.904 0.000
#> SRR1058015     5  0.0260      0.832 0.000 0.008  0 0.000 0.992 0.000
#> SRR1058016     2  0.3819      0.545 0.000 0.624  0 0.000 0.372 0.004
#> SRR1058017     2  0.2340      0.794 0.000 0.852  0 0.000 0.148 0.000
#> SRR1058018     5  0.0000      0.830 0.000 0.000  0 0.000 1.000 0.000
#> SRR1058019     2  0.3198      0.728 0.000 0.740  0 0.000 0.260 0.000
#> SRR1058020     5  0.2053      0.809 0.000 0.108  0 0.000 0.888 0.004
#> SRR1058021     5  0.0000      0.830 0.000 0.000  0 0.000 1.000 0.000
#> SRR1058022     2  0.3198      0.714 0.000 0.740  0 0.000 0.260 0.000
#> SRR1058023     5  0.0000      0.830 0.000 0.000  0 0.000 1.000 0.000
#> SRR1058024     5  0.1714      0.815 0.000 0.092  0 0.000 0.908 0.000
#> SRR1058025     5  0.1970      0.812 0.000 0.092  0 0.000 0.900 0.008
#> SRR1058026     6  0.0000      0.989 0.000 0.000  0 0.000 0.000 1.000
#> SRR1058027     6  0.0000      0.989 0.000 0.000  0 0.000 0.000 1.000
#> SRR1058028     6  0.0713      0.966 0.000 0.000  0 0.000 0.028 0.972
#> SRR1058029     2  0.0713      0.789 0.000 0.972  0 0.000 0.028 0.000
#> SRR1058030     2  0.0713      0.789 0.000 0.972  0 0.000 0.028 0.000
#> SRR1058031     2  0.0790      0.791 0.000 0.968  0 0.000 0.032 0.000
#> SRR1058032     4  0.1267      0.856 0.060 0.000  0 0.940 0.000 0.000
#> SRR1058033     4  0.1765      0.830 0.096 0.000  0 0.904 0.000 0.000
#> SRR1058034     4  0.0547      0.864 0.020 0.000  0 0.980 0.000 0.000
#> SRR1058035     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> SRR1058036     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> SRR1058037     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> SRR1058038     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> SRR1058039     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> SRR1058040     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> SRR1058041     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> SRR1058042     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> SRR1058043     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> SRR1058044     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> SRR1058045     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> SRR1058046     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> SRR1058047     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1058048     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1058049     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1058050     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1058051     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1058052     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1058053     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1058054     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

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

collect_plots(res)

plot of chunk ATC-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.982       0.990         0.4995 0.502   0.502
#> 3 3 1.000           0.944       0.978         0.2154 0.695   0.494
#> 4 4 0.781           0.727       0.894         0.1382 0.898   0.755
#> 5 5 0.720           0.791       0.881         0.0607 0.887   0.674
#> 6 6 0.728           0.654       0.831         0.0522 0.943   0.799

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
#> SRR1058003     1  0.0000      1.000 1.000 0.000
#> SRR1058004     2  0.1414      0.971 0.020 0.980
#> SRR1058006     1  0.0376      0.996 0.996 0.004
#> SRR1058005     2  0.0000      0.983 0.000 1.000
#> SRR1058007     2  0.0376      0.981 0.004 0.996
#> SRR1058008     2  0.0672      0.979 0.008 0.992
#> SRR1058009     2  0.0000      0.983 0.000 1.000
#> SRR1058010     2  0.0000      0.983 0.000 1.000
#> SRR1058011     2  0.0000      0.983 0.000 1.000
#> SRR1058012     1  0.0000      1.000 1.000 0.000
#> SRR1058013     2  0.0000      0.983 0.000 1.000
#> SRR1058014     2  0.4298      0.914 0.088 0.912
#> SRR1058015     1  0.0000      1.000 1.000 0.000
#> SRR1058016     2  0.0000      0.983 0.000 1.000
#> SRR1058017     2  0.0000      0.983 0.000 1.000
#> SRR1058018     1  0.0000      1.000 1.000 0.000
#> SRR1058019     2  0.0000      0.983 0.000 1.000
#> SRR1058020     2  0.0000      0.983 0.000 1.000
#> SRR1058021     1  0.0000      1.000 1.000 0.000
#> SRR1058022     2  0.0000      0.983 0.000 1.000
#> SRR1058023     1  0.0000      1.000 1.000 0.000
#> SRR1058024     2  0.4939      0.894 0.108 0.892
#> SRR1058025     2  0.5294      0.881 0.120 0.880
#> SRR1058026     2  0.1633      0.968 0.024 0.976
#> SRR1058027     2  0.5408      0.877 0.124 0.876
#> SRR1058028     2  0.0000      0.983 0.000 1.000
#> SRR1058029     2  0.0000      0.983 0.000 1.000
#> SRR1058030     2  0.0000      0.983 0.000 1.000
#> SRR1058031     2  0.0000      0.983 0.000 1.000
#> SRR1058032     1  0.0000      1.000 1.000 0.000
#> SRR1058033     1  0.0000      1.000 1.000 0.000
#> SRR1058034     1  0.0000      1.000 1.000 0.000
#> SRR1058035     1  0.0000      1.000 1.000 0.000
#> SRR1058036     1  0.0000      1.000 1.000 0.000
#> SRR1058037     1  0.0000      1.000 1.000 0.000
#> SRR1058038     1  0.0000      1.000 1.000 0.000
#> SRR1058039     1  0.0000      1.000 1.000 0.000
#> SRR1058040     1  0.0000      1.000 1.000 0.000
#> SRR1058041     1  0.0000      1.000 1.000 0.000
#> SRR1058042     1  0.0000      1.000 1.000 0.000
#> SRR1058043     1  0.0000      1.000 1.000 0.000
#> SRR1058044     1  0.0000      1.000 1.000 0.000
#> SRR1058045     1  0.0000      1.000 1.000 0.000
#> SRR1058046     1  0.0000      1.000 1.000 0.000
#> SRR1058047     2  0.0000      0.983 0.000 1.000
#> SRR1058048     2  0.0000      0.983 0.000 1.000
#> SRR1058049     2  0.0000      0.983 0.000 1.000
#> SRR1058050     2  0.0000      0.983 0.000 1.000
#> SRR1058051     2  0.0000      0.983 0.000 1.000
#> SRR1058052     2  0.0000      0.983 0.000 1.000
#> SRR1058053     2  0.0000      0.983 0.000 1.000
#> SRR1058054     2  0.0000      0.983 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1058003     2  0.1860      0.925 0.052 0.948 0.000
#> SRR1058004     2  0.0000      0.971 0.000 1.000 0.000
#> SRR1058006     2  0.0000      0.971 0.000 1.000 0.000
#> SRR1058005     2  0.0424      0.968 0.000 0.992 0.008
#> SRR1058007     2  0.0000      0.971 0.000 1.000 0.000
#> SRR1058008     2  0.0000      0.971 0.000 1.000 0.000
#> SRR1058009     2  0.0000      0.971 0.000 1.000 0.000
#> SRR1058010     2  0.0892      0.962 0.000 0.980 0.020
#> SRR1058011     2  0.0892      0.962 0.000 0.980 0.020
#> SRR1058012     2  0.0000      0.971 0.000 1.000 0.000
#> SRR1058013     2  0.0000      0.971 0.000 1.000 0.000
#> SRR1058014     2  0.0000      0.971 0.000 1.000 0.000
#> SRR1058015     2  0.0000      0.971 0.000 1.000 0.000
#> SRR1058016     2  0.0237      0.969 0.000 0.996 0.004
#> SRR1058017     2  0.1289      0.954 0.000 0.968 0.032
#> SRR1058018     2  0.5905      0.436 0.352 0.648 0.000
#> SRR1058019     2  0.0892      0.962 0.000 0.980 0.020
#> SRR1058020     2  0.0000      0.971 0.000 1.000 0.000
#> SRR1058021     2  0.0000      0.971 0.000 1.000 0.000
#> SRR1058022     2  0.0000      0.971 0.000 1.000 0.000
#> SRR1058023     1  0.6140      0.300 0.596 0.404 0.000
#> SRR1058024     2  0.0000      0.971 0.000 1.000 0.000
#> SRR1058025     2  0.0000      0.971 0.000 1.000 0.000
#> SRR1058026     2  0.0000      0.971 0.000 1.000 0.000
#> SRR1058027     2  0.0000      0.971 0.000 1.000 0.000
#> SRR1058028     2  0.0000      0.971 0.000 1.000 0.000
#> SRR1058029     2  0.4062      0.811 0.000 0.836 0.164
#> SRR1058030     2  0.1411      0.951 0.000 0.964 0.036
#> SRR1058031     2  0.1411      0.951 0.000 0.964 0.036
#> SRR1058032     1  0.0000      0.964 1.000 0.000 0.000
#> SRR1058033     1  0.0000      0.964 1.000 0.000 0.000
#> SRR1058034     1  0.0000      0.964 1.000 0.000 0.000
#> SRR1058035     1  0.0000      0.964 1.000 0.000 0.000
#> SRR1058036     1  0.0000      0.964 1.000 0.000 0.000
#> SRR1058037     1  0.0000      0.964 1.000 0.000 0.000
#> SRR1058038     1  0.0000      0.964 1.000 0.000 0.000
#> SRR1058039     1  0.0000      0.964 1.000 0.000 0.000
#> SRR1058040     1  0.0000      0.964 1.000 0.000 0.000
#> SRR1058041     1  0.0000      0.964 1.000 0.000 0.000
#> SRR1058042     1  0.0000      0.964 1.000 0.000 0.000
#> SRR1058043     1  0.0000      0.964 1.000 0.000 0.000
#> SRR1058044     1  0.0000      0.964 1.000 0.000 0.000
#> SRR1058045     1  0.0000      0.964 1.000 0.000 0.000
#> SRR1058046     1  0.0000      0.964 1.000 0.000 0.000
#> SRR1058047     3  0.0000      0.998 0.000 0.000 1.000
#> SRR1058048     3  0.0592      0.986 0.012 0.000 0.988
#> SRR1058049     3  0.0000      0.998 0.000 0.000 1.000
#> SRR1058050     3  0.0000      0.998 0.000 0.000 1.000
#> SRR1058051     3  0.0000      0.998 0.000 0.000 1.000
#> SRR1058052     3  0.0000      0.998 0.000 0.000 1.000
#> SRR1058053     3  0.0000      0.998 0.000 0.000 1.000
#> SRR1058054     3  0.0000      0.998 0.000 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1058003     2  0.3761     0.5857 0.080 0.852 0.000 0.068
#> SRR1058004     2  0.0592     0.7249 0.000 0.984 0.000 0.016
#> SRR1058006     2  0.1356     0.7124 0.008 0.960 0.000 0.032
#> SRR1058005     2  0.1022     0.7176 0.000 0.968 0.000 0.032
#> SRR1058007     2  0.0336     0.7289 0.000 0.992 0.000 0.008
#> SRR1058008     2  0.0592     0.7275 0.000 0.984 0.000 0.016
#> SRR1058009     2  0.0000     0.7286 0.000 1.000 0.000 0.000
#> SRR1058010     2  0.1118     0.7241 0.000 0.964 0.000 0.036
#> SRR1058011     2  0.0336     0.7287 0.000 0.992 0.000 0.008
#> SRR1058012     4  0.5444     0.4677 0.048 0.264 0.000 0.688
#> SRR1058013     2  0.0707     0.7260 0.000 0.980 0.000 0.020
#> SRR1058014     2  0.0188     0.7290 0.000 0.996 0.000 0.004
#> SRR1058015     2  0.1489     0.7067 0.004 0.952 0.000 0.044
#> SRR1058016     2  0.1302     0.7148 0.000 0.956 0.000 0.044
#> SRR1058017     2  0.2408     0.6684 0.000 0.896 0.000 0.104
#> SRR1058018     2  0.5716     0.2802 0.272 0.668 0.000 0.060
#> SRR1058019     2  0.4428     0.4036 0.000 0.720 0.004 0.276
#> SRR1058020     2  0.3907     0.4917 0.000 0.768 0.000 0.232
#> SRR1058021     2  0.0707     0.7254 0.000 0.980 0.000 0.020
#> SRR1058022     2  0.1940     0.6937 0.000 0.924 0.000 0.076
#> SRR1058023     2  0.6212     0.1134 0.380 0.560 0.000 0.060
#> SRR1058024     2  0.4222     0.4226 0.000 0.728 0.000 0.272
#> SRR1058025     2  0.4830     0.0476 0.000 0.608 0.000 0.392
#> SRR1058026     4  0.4250     0.7482 0.000 0.276 0.000 0.724
#> SRR1058027     4  0.4356     0.7479 0.000 0.292 0.000 0.708
#> SRR1058028     4  0.4817     0.6059 0.000 0.388 0.000 0.612
#> SRR1058029     2  0.7706    -0.3528 0.000 0.448 0.252 0.300
#> SRR1058030     2  0.6653    -0.1513 0.000 0.548 0.096 0.356
#> SRR1058031     2  0.6163    -0.0636 0.000 0.576 0.060 0.364
#> SRR1058032     1  0.1302     0.9653 0.956 0.000 0.000 0.044
#> SRR1058033     1  0.1302     0.9653 0.956 0.000 0.000 0.044
#> SRR1058034     1  0.1302     0.9653 0.956 0.000 0.000 0.044
#> SRR1058035     1  0.0188     0.9857 0.996 0.000 0.000 0.004
#> SRR1058036     1  0.0336     0.9848 0.992 0.000 0.000 0.008
#> SRR1058037     1  0.0336     0.9848 0.992 0.000 0.000 0.008
#> SRR1058038     1  0.0188     0.9861 0.996 0.000 0.000 0.004
#> SRR1058039     1  0.0188     0.9861 0.996 0.000 0.000 0.004
#> SRR1058040     1  0.0469     0.9840 0.988 0.000 0.000 0.012
#> SRR1058041     1  0.0469     0.9840 0.988 0.000 0.000 0.012
#> SRR1058042     1  0.0469     0.9840 0.988 0.000 0.000 0.012
#> SRR1058043     1  0.0469     0.9840 0.988 0.000 0.000 0.012
#> SRR1058044     1  0.0188     0.9861 0.996 0.000 0.000 0.004
#> SRR1058045     1  0.0188     0.9857 0.996 0.000 0.000 0.004
#> SRR1058046     1  0.0000     0.9862 1.000 0.000 0.000 0.000
#> SRR1058047     3  0.0000     1.0000 0.000 0.000 1.000 0.000
#> SRR1058048     3  0.0000     1.0000 0.000 0.000 1.000 0.000
#> SRR1058049     3  0.0000     1.0000 0.000 0.000 1.000 0.000
#> SRR1058050     3  0.0000     1.0000 0.000 0.000 1.000 0.000
#> SRR1058051     3  0.0000     1.0000 0.000 0.000 1.000 0.000
#> SRR1058052     3  0.0000     1.0000 0.000 0.000 1.000 0.000
#> SRR1058053     3  0.0000     1.0000 0.000 0.000 1.000 0.000
#> SRR1058054     3  0.0000     1.0000 0.000 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4    p5
#> SRR1058003     5  0.3884      0.668 0.064 0.052 0.000 0.048 0.836
#> SRR1058004     5  0.1412      0.777 0.004 0.008 0.000 0.036 0.952
#> SRR1058006     5  0.0854      0.787 0.008 0.012 0.000 0.004 0.976
#> SRR1058005     5  0.1753      0.764 0.000 0.032 0.000 0.032 0.936
#> SRR1058007     5  0.1502      0.786 0.000 0.056 0.000 0.004 0.940
#> SRR1058008     5  0.0609      0.792 0.000 0.020 0.000 0.000 0.980
#> SRR1058009     5  0.1704      0.781 0.000 0.068 0.000 0.004 0.928
#> SRR1058010     5  0.3521      0.701 0.000 0.140 0.000 0.040 0.820
#> SRR1058011     5  0.2864      0.726 0.000 0.136 0.000 0.012 0.852
#> SRR1058012     4  0.3076      0.000 0.028 0.052 0.000 0.880 0.040
#> SRR1058013     5  0.2011      0.767 0.000 0.088 0.000 0.004 0.908
#> SRR1058014     5  0.0880      0.792 0.000 0.032 0.000 0.000 0.968
#> SRR1058015     5  0.1186      0.779 0.020 0.008 0.000 0.008 0.964
#> SRR1058016     5  0.3160      0.655 0.000 0.188 0.000 0.004 0.808
#> SRR1058017     5  0.4318      0.161 0.000 0.348 0.004 0.004 0.644
#> SRR1058018     5  0.4196      0.582 0.168 0.040 0.000 0.012 0.780
#> SRR1058019     2  0.4270      0.750 0.000 0.656 0.004 0.004 0.336
#> SRR1058020     2  0.4443      0.511 0.000 0.524 0.000 0.004 0.472
#> SRR1058021     5  0.1026      0.793 0.004 0.024 0.000 0.004 0.968
#> SRR1058022     5  0.3607      0.521 0.000 0.244 0.000 0.004 0.752
#> SRR1058023     5  0.5486      0.334 0.304 0.040 0.000 0.028 0.628
#> SRR1058024     2  0.4251      0.726 0.000 0.624 0.000 0.004 0.372
#> SRR1058025     2  0.4538      0.744 0.000 0.620 0.000 0.016 0.364
#> SRR1058026     2  0.3033      0.532 0.000 0.864 0.000 0.052 0.084
#> SRR1058027     2  0.3003      0.566 0.000 0.864 0.000 0.044 0.092
#> SRR1058028     2  0.3264      0.687 0.000 0.820 0.000 0.016 0.164
#> SRR1058029     2  0.6082      0.679 0.000 0.540 0.148 0.000 0.312
#> SRR1058030     2  0.4770      0.763 0.000 0.644 0.036 0.000 0.320
#> SRR1058031     2  0.4366      0.768 0.000 0.664 0.016 0.000 0.320
#> SRR1058032     1  0.2976      0.885 0.880 0.044 0.000 0.064 0.012
#> SRR1058033     1  0.2834      0.892 0.888 0.040 0.000 0.060 0.012
#> SRR1058034     1  0.3175      0.877 0.872 0.044 0.000 0.064 0.020
#> SRR1058035     1  0.0451      0.967 0.988 0.008 0.000 0.004 0.000
#> SRR1058036     1  0.0451      0.967 0.988 0.008 0.000 0.004 0.000
#> SRR1058037     1  0.0162      0.967 0.996 0.004 0.000 0.000 0.000
#> SRR1058038     1  0.0162      0.968 0.996 0.000 0.000 0.004 0.000
#> SRR1058039     1  0.0000      0.968 1.000 0.000 0.000 0.000 0.000
#> SRR1058040     1  0.0290      0.966 0.992 0.008 0.000 0.000 0.000
#> SRR1058041     1  0.0290      0.966 0.992 0.008 0.000 0.000 0.000
#> SRR1058042     1  0.0162      0.967 0.996 0.004 0.000 0.000 0.000
#> SRR1058043     1  0.0693      0.961 0.980 0.008 0.000 0.012 0.000
#> SRR1058044     1  0.0000      0.968 1.000 0.000 0.000 0.000 0.000
#> SRR1058045     1  0.0162      0.968 0.996 0.000 0.000 0.004 0.000
#> SRR1058046     1  0.0162      0.968 0.996 0.000 0.000 0.004 0.000
#> SRR1058047     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1058048     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1058049     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1058050     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1058051     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1058052     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1058053     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR1058054     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4 p5    p6
#> SRR1058003     2  0.4047      0.490 0.036 0.716 0.000 0.004 NA 0.000
#> SRR1058004     2  0.3894      0.539 0.004 0.740 0.000 0.000 NA 0.036
#> SRR1058006     2  0.0653      0.656 0.000 0.980 0.000 0.004 NA 0.004
#> SRR1058005     2  0.3671      0.553 0.000 0.756 0.000 0.000 NA 0.036
#> SRR1058007     2  0.3076      0.591 0.000 0.760 0.000 0.000 NA 0.240
#> SRR1058008     2  0.1007      0.663 0.000 0.956 0.000 0.000 NA 0.044
#> SRR1058009     2  0.2994      0.606 0.000 0.788 0.000 0.000 NA 0.208
#> SRR1058010     2  0.5438      0.320 0.000 0.536 0.000 0.068 NA 0.372
#> SRR1058011     2  0.4052      0.442 0.000 0.628 0.000 0.000 NA 0.356
#> SRR1058012     4  0.4093      0.000 0.000 0.004 0.000 0.552 NA 0.004
#> SRR1058013     2  0.2703      0.626 0.000 0.824 0.000 0.000 NA 0.172
#> SRR1058014     2  0.1327      0.661 0.000 0.936 0.000 0.000 NA 0.064
#> SRR1058015     2  0.0810      0.656 0.004 0.976 0.000 0.008 NA 0.004
#> SRR1058016     2  0.3915      0.349 0.000 0.584 0.000 0.000 NA 0.412
#> SRR1058017     6  0.3975      0.130 0.000 0.392 0.008 0.000 NA 0.600
#> SRR1058018     2  0.3405      0.584 0.088 0.828 0.000 0.004 NA 0.004
#> SRR1058019     6  0.2662      0.612 0.000 0.152 0.004 0.004 NA 0.840
#> SRR1058020     2  0.3989      0.142 0.000 0.528 0.000 0.004 NA 0.468
#> SRR1058021     2  0.0603      0.660 0.000 0.980 0.000 0.000 NA 0.016
#> SRR1058022     2  0.3727      0.399 0.000 0.612 0.000 0.000 NA 0.388
#> SRR1058023     2  0.4363      0.495 0.156 0.740 0.000 0.004 NA 0.004
#> SRR1058024     6  0.4482      0.236 0.000 0.416 0.000 0.032 NA 0.552
#> SRR1058025     2  0.5642     -0.177 0.000 0.472 0.000 0.132 NA 0.392
#> SRR1058026     6  0.3984      0.281 0.000 0.008 0.000 0.396 NA 0.596
#> SRR1058027     6  0.4403      0.297 0.000 0.028 0.000 0.408 NA 0.564
#> SRR1058028     6  0.3418      0.499 0.000 0.032 0.000 0.184 NA 0.784
#> SRR1058029     6  0.4252      0.557 0.000 0.176 0.096 0.000 NA 0.728
#> SRR1058030     6  0.3082      0.621 0.000 0.144 0.020 0.008 NA 0.828
#> SRR1058031     6  0.2912      0.602 0.000 0.172 0.012 0.000 NA 0.816
#> SRR1058032     1  0.3508      0.680 0.704 0.004 0.000 0.000 NA 0.000
#> SRR1058033     1  0.3528      0.675 0.700 0.004 0.000 0.000 NA 0.000
#> SRR1058034     1  0.3690      0.655 0.684 0.008 0.000 0.000 NA 0.000
#> SRR1058035     1  0.0547      0.911 0.980 0.000 0.000 0.000 NA 0.000
#> SRR1058036     1  0.0458      0.912 0.984 0.000 0.000 0.000 NA 0.000
#> SRR1058037     1  0.0363      0.913 0.988 0.000 0.000 0.000 NA 0.000
#> SRR1058038     1  0.0146      0.913 0.996 0.000 0.000 0.000 NA 0.000
#> SRR1058039     1  0.0458      0.911 0.984 0.000 0.000 0.000 NA 0.000
#> SRR1058040     1  0.0972      0.905 0.964 0.000 0.000 0.008 NA 0.000
#> SRR1058041     1  0.1010      0.903 0.960 0.000 0.000 0.004 NA 0.000
#> SRR1058042     1  0.1010      0.903 0.960 0.000 0.000 0.004 NA 0.000
#> SRR1058043     1  0.1285      0.894 0.944 0.000 0.000 0.004 NA 0.000
#> SRR1058044     1  0.0146      0.913 0.996 0.000 0.000 0.000 NA 0.000
#> SRR1058045     1  0.0260      0.913 0.992 0.000 0.000 0.000 NA 0.000
#> SRR1058046     1  0.0508      0.912 0.984 0.000 0.000 0.000 NA 0.004
#> SRR1058047     3  0.0260      0.991 0.000 0.000 0.992 0.000 NA 0.000
#> SRR1058048     3  0.0000      0.999 0.000 0.000 1.000 0.000 NA 0.000
#> SRR1058049     3  0.0000      0.999 0.000 0.000 1.000 0.000 NA 0.000
#> SRR1058050     3  0.0000      0.999 0.000 0.000 1.000 0.000 NA 0.000
#> SRR1058051     3  0.0000      0.999 0.000 0.000 1.000 0.000 NA 0.000
#> SRR1058052     3  0.0000      0.999 0.000 0.000 1.000 0.000 NA 0.000
#> SRR1058053     3  0.0000      0.999 0.000 0.000 1.000 0.000 NA 0.000
#> SRR1058054     3  0.0000      0.999 0.000 0.000 1.000 0.000 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-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