cola Report for recount2:SRP028301

Date: 2019-12-25 23:47:01 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 12673 rows and 62 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] 12673    62

Density distribution

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

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

plot of chunk density-heatmap

Suggest the best k

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

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

suggest_best_k(res_list)
The best k 1-PAC Mean silhouette Concordance Optional k
SD:hclust 4 1.000 0.991 0.998 ** 3
SD:mclust 2 1.000 0.970 0.988 **
SD:NMF 3 1.000 0.988 0.994 ** 2
CV:mclust 2 1.000 0.969 0.989 **
CV:NMF 3 1.000 0.969 0.990 ** 2
MAD:skmeans 3 1.000 0.985 0.988 ** 2
MAD:NMF 3 1.000 0.965 0.987 **
ATC:hclust 3 1.000 0.991 0.997 **
ATC:skmeans 4 1.000 0.972 0.986 ** 2,3
ATC:mclust 5 1.000 0.956 0.975 ** 4
ATC:NMF 3 1.000 0.950 0.981 ** 2
SD:skmeans 4 0.991 0.977 0.968 ** 2,3
MAD:pam 5 0.990 0.916 0.969 ** 2,3
MAD:hclust 5 0.952 0.982 0.981 ** 3
ATC:pam 5 0.938 0.910 0.965 * 2,3,4
SD:pam 4 0.927 0.877 0.955 * 2,3
SD:kmeans 3 0.878 0.958 0.952
CV:skmeans 2 0.868 0.919 0.966
CV:hclust 3 0.843 0.907 0.945
MAD:mclust 4 0.806 0.894 0.944
MAD:kmeans 2 0.787 0.944 0.957
ATC:kmeans 3 0.783 0.968 0.954
CV:pam 3 0.678 0.761 0.912
CV:kmeans 3 0.626 0.914 0.906

**: 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.974           0.930       0.967          0.395 0.611   0.611
#> CV:NMF      2 1.000           1.000       1.000          0.204 0.796   0.796
#> MAD:NMF     2 0.414           0.822       0.883          0.435 0.545   0.545
#> ATC:NMF     2 1.000           0.951       0.979          0.352 0.663   0.663
#> SD:skmeans  2 1.000           1.000       1.000          0.433 0.568   0.568
#> CV:skmeans  2 0.868           0.919       0.966          0.487 0.511   0.511
#> MAD:skmeans 2 1.000           0.940       0.974          0.476 0.511   0.511
#> ATC:skmeans 2 1.000           0.996       0.998          0.454 0.545   0.545
#> SD:mclust   2 1.000           0.970       0.988          0.422 0.568   0.568
#> CV:mclust   2 1.000           0.969       0.989          0.234 0.772   0.772
#> MAD:mclust  2 0.737           0.809       0.907          0.328 0.611   0.611
#> ATC:mclust  2 0.765           0.909       0.953          0.460 0.511   0.511
#> SD:kmeans   2 0.510           0.536       0.797          0.341 0.748   0.748
#> CV:kmeans   2 0.577           0.928       0.921          0.369 0.568   0.568
#> MAD:kmeans  2 0.787           0.944       0.957          0.389 0.568   0.568
#> ATC:kmeans  2 0.837           0.906       0.929          0.356 0.568   0.568
#> SD:pam      2 1.000           0.982       0.993          0.285 0.725   0.725
#> CV:pam      2 0.368           0.737       0.863          0.376 0.611   0.611
#> MAD:pam     2 1.000           0.989       0.995          0.495 0.505   0.505
#> ATC:pam     2 1.000           0.989       0.995          0.291 0.703   0.703
#> SD:hclust   2 0.800           0.973       0.986          0.292 0.725   0.725
#> CV:hclust   2 0.736           0.941       0.967          0.244 0.796   0.796
#> MAD:hclust  2 0.748           0.942       0.958          0.387 0.568   0.568
#> ATC:hclust  2 0.772           0.949       0.974          0.305 0.725   0.725
get_stats(res_list, k = 3)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      3 1.000           0.988       0.994          0.134 0.700   0.592
#> CV:NMF      3 1.000           0.969       0.990          1.450 0.696   0.619
#> MAD:NMF     3 1.000           0.965       0.987          0.161 0.675   0.528
#> ATC:NMF     3 1.000           0.950       0.981          0.315 0.762   0.674
#> SD:skmeans  3 1.000           0.993       0.989          0.395 0.825   0.693
#> CV:skmeans  3 0.629           0.790       0.862          0.282 0.740   0.546
#> MAD:skmeans 3 1.000           0.985       0.988          0.270 0.857   0.727
#> ATC:skmeans 3 1.000           0.970       0.980          0.313 0.832   0.696
#> SD:mclust   3 0.587           0.795       0.829          0.360 0.800   0.670
#> CV:mclust   3 0.736           0.933       0.944          1.459 0.619   0.517
#> MAD:mclust  3 0.763           0.881       0.920          0.702 0.742   0.605
#> ATC:mclust  3 0.666           0.807       0.883          0.317 0.677   0.476
#> SD:kmeans   3 0.878           0.958       0.952          0.449 0.773   0.696
#> CV:kmeans   3 0.626           0.914       0.906          0.373 0.927   0.876
#> MAD:kmeans  3 0.684           0.923       0.895          0.340 0.952   0.916
#> ATC:kmeans  3 0.783           0.968       0.954          0.401 0.952   0.916
#> SD:pam      3 1.000           1.000       1.000          0.554 0.833   0.770
#> CV:pam      3 0.678           0.761       0.912          0.401 0.827   0.721
#> MAD:pam     3 1.000           0.997       0.999          0.144 0.930   0.861
#> ATC:pam     3 1.000           0.987       0.995          0.540 0.849   0.786
#> SD:hclust   3 1.000           0.993       0.997          0.529 0.833   0.770
#> CV:hclust   3 0.843           0.907       0.945          0.911 0.727   0.657
#> MAD:hclust  3 1.000           0.999       0.999          0.241 0.952   0.916
#> ATC:hclust  3 1.000           0.991       0.997          0.566 0.795   0.718
get_stats(res_list, k = 4)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      4 0.662           0.793       0.870         0.4126 0.748   0.549
#> CV:NMF      4 0.600           0.758       0.876         0.2091 0.879   0.763
#> MAD:NMF     4 0.786           0.909       0.934         0.3632 0.727   0.491
#> ATC:NMF     4 0.838           0.903       0.952         0.3836 0.802   0.646
#> SD:skmeans  4 0.991           0.977       0.968         0.0983 0.952   0.879
#> CV:skmeans  4 0.656           0.770       0.856         0.1414 0.853   0.641
#> MAD:skmeans 4 0.842           0.961       0.933         0.1081 0.952   0.879
#> ATC:skmeans 4 1.000           0.972       0.986         0.0856 0.952   0.879
#> SD:mclust   4 0.846           0.902       0.945         0.1838 0.786   0.571
#> CV:mclust   4 0.665           0.790       0.859         0.1908 0.806   0.582
#> MAD:mclust  4 0.806           0.894       0.944         0.2203 0.769   0.532
#> ATC:mclust  4 1.000           0.951       0.976         0.1467 0.854   0.657
#> SD:kmeans   4 0.652           0.754       0.810         0.2156 0.993   0.986
#> CV:kmeans   4 0.646           0.863       0.885         0.3552 0.727   0.506
#> MAD:kmeans  4 0.629           0.775       0.786         0.2165 0.825   0.665
#> ATC:kmeans  4 0.640           0.756       0.829         0.2543 0.814   0.642
#> SD:pam      4 0.927           0.877       0.955         0.5118 0.768   0.590
#> CV:pam      4 0.672           0.757       0.919         0.0174 0.997   0.993
#> MAD:pam     4 0.746           0.833       0.888         0.2714 0.816   0.588
#> ATC:pam     4 0.915           0.906       0.945         0.4749 0.780   0.606
#> SD:hclust   4 1.000           0.991       0.998         0.0866 0.955   0.919
#> CV:hclust   4 0.778           0.875       0.917         0.1926 0.944   0.893
#> MAD:hclust  4 0.992           0.987       0.987         0.0301 0.993   0.986
#> ATC:hclust  4 0.878           0.968       0.984         0.0546 0.993   0.986
get_stats(res_list, k = 5)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      5 0.595           0.783       0.850        0.06007 0.917   0.751
#> CV:NMF      5 0.509           0.610       0.776        0.12117 0.902   0.769
#> MAD:NMF     5 0.755           0.804       0.896        0.04239 0.989   0.964
#> ATC:NMF     5 0.777           0.803       0.917        0.03419 0.983   0.952
#> SD:skmeans  5 0.769           0.789       0.883        0.16574 0.872   0.630
#> CV:skmeans  5 0.699           0.700       0.830        0.10298 0.869   0.588
#> MAD:skmeans 5 0.753           0.790       0.862        0.15629 0.867   0.615
#> ATC:skmeans 5 0.754           0.780       0.870        0.16669 0.878   0.648
#> SD:mclust   5 0.783           0.835       0.854        0.06098 0.954   0.864
#> CV:mclust   5 0.684           0.707       0.820        0.09164 0.838   0.577
#> MAD:mclust  5 0.742           0.820       0.883        0.09744 0.840   0.555
#> ATC:mclust  5 1.000           0.956       0.975        0.06608 0.927   0.770
#> SD:kmeans   5 0.588           0.748       0.791        0.14218 0.825   0.660
#> CV:kmeans   5 0.670           0.644       0.743        0.09355 0.920   0.730
#> MAD:kmeans  5 0.609           0.772       0.773        0.11410 0.853   0.589
#> ATC:kmeans  5 0.599           0.688       0.700        0.13861 0.827   0.520
#> SD:pam      5 0.906           0.844       0.942        0.00716 0.997   0.991
#> CV:pam      5 0.676           0.703       0.910        0.02197 0.952   0.897
#> MAD:pam     5 0.990           0.916       0.969        0.06971 0.943   0.797
#> ATC:pam     5 0.938           0.910       0.965        0.18575 0.855   0.585
#> SD:hclust   5 1.000           0.986       0.996        0.01713 0.992   0.984
#> CV:hclust   5 0.700           0.839       0.895        0.05537 0.998   0.996
#> MAD:hclust  5 0.952           0.982       0.981        0.05818 0.957   0.915
#> ATC:hclust  5 0.874           0.950       0.979        0.00613 0.997   0.994
get_stats(res_list, k = 6)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      6 0.608           0.792       0.871        0.04928 0.976   0.917
#> CV:NMF      6 0.516           0.517       0.732        0.09377 0.805   0.523
#> MAD:NMF     6 0.671           0.739       0.852        0.02859 0.992   0.970
#> ATC:NMF     6 0.750           0.764       0.888        0.03809 0.969   0.911
#> SD:skmeans  6 0.760           0.659       0.806        0.05535 0.972   0.874
#> CV:skmeans  6 0.725           0.644       0.803        0.05332 0.955   0.790
#> MAD:skmeans 6 0.757           0.563       0.759        0.05841 0.904   0.606
#> ATC:skmeans 6 0.734           0.559       0.754        0.05482 0.947   0.769
#> SD:mclust   6 0.760           0.587       0.745        0.11015 0.889   0.649
#> CV:mclust   6 0.847           0.837       0.907        0.06679 0.890   0.636
#> MAD:mclust  6 0.699           0.708       0.788        0.04061 0.828   0.512
#> ATC:mclust  6 0.899           0.920       0.942        0.03298 0.981   0.925
#> SD:kmeans   6 0.677           0.815       0.816        0.07650 0.867   0.606
#> CV:kmeans   6 0.735           0.639       0.757        0.05223 0.907   0.658
#> MAD:kmeans  6 0.713           0.786       0.832        0.08764 0.988   0.948
#> ATC:kmeans  6 0.730           0.781       0.816        0.07353 0.965   0.843
#> SD:pam      6 0.870           0.802       0.931        0.00971 0.970   0.915
#> CV:pam      6 0.636           0.724       0.905        0.01995 0.969   0.929
#> MAD:pam     6 0.975           0.890       0.962        0.00456 0.997   0.986
#> ATC:pam     6 0.903           0.849       0.939        0.01225 0.994   0.971
#> SD:hclust   6 1.000           0.978       0.993        0.01133 0.997   0.994
#> CV:hclust   6 0.641           0.760       0.873        0.06891 0.922   0.833
#> MAD:hclust  6 0.951           0.945       0.958        0.01948 1.000   1.000
#> ATC:hclust  6 0.870           0.918       0.979        0.00423 0.999   0.999

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

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

collect_plots(res)

plot of chunk SD-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.8           0.973       0.986         0.2917 0.725   0.725
#> 3 3   1.0           0.993       0.997         0.5294 0.833   0.770
#> 4 4   1.0           0.991       0.998         0.0866 0.955   0.919
#> 5 5   1.0           0.986       0.996         0.0171 0.992   0.984
#> 6 6   1.0           0.978       0.993         0.0113 0.997   0.994

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> SRR944282     1   0.000      0.982 1.000 0.000
#> SRR944283     1   0.000      0.982 1.000 0.000
#> SRR944284     1   0.000      0.982 1.000 0.000
#> SRR944285     1   0.000      0.982 1.000 0.000
#> SRR944288     1   0.000      0.982 1.000 0.000
#> SRR944287     1   0.000      0.982 1.000 0.000
#> SRR944289     1   0.000      0.982 1.000 0.000
#> SRR944290     1   0.000      0.982 1.000 0.000
#> SRR944291     1   0.000      0.982 1.000 0.000
#> SRR944292     1   0.000      0.982 1.000 0.000
#> SRR944293     1   0.000      0.982 1.000 0.000
#> SRR944294     1   0.000      0.982 1.000 0.000
#> SRR944295     2   0.000      1.000 0.000 1.000
#> SRR944296     2   0.000      1.000 0.000 1.000
#> SRR944297     2   0.000      1.000 0.000 1.000
#> SRR944298     2   0.000      1.000 0.000 1.000
#> SRR944299     1   0.000      0.982 1.000 0.000
#> SRR944300     1   0.000      0.982 1.000 0.000
#> SRR944301     1   0.000      0.982 1.000 0.000
#> SRR944302     1   0.388      0.922 0.924 0.076
#> SRR944303     2   0.000      1.000 0.000 1.000
#> SRR944304     1   0.000      0.982 1.000 0.000
#> SRR944305     1   0.000      0.982 1.000 0.000
#> SRR944306     1   0.000      0.982 1.000 0.000
#> SRR944307     1   0.000      0.982 1.000 0.000
#> SRR944308     1   0.000      0.982 1.000 0.000
#> SRR944309     1   0.000      0.982 1.000 0.000
#> SRR944310     1   0.000      0.982 1.000 0.000
#> SRR944311     2   0.000      1.000 0.000 1.000
#> SRR944312     1   0.000      0.982 1.000 0.000
#> SRR944313     1   0.000      0.982 1.000 0.000
#> SRR944315     1   0.000      0.982 1.000 0.000
#> SRR944314     1   0.000      0.982 1.000 0.000
#> SRR944316     1   0.000      0.982 1.000 0.000
#> SRR944317     2   0.000      1.000 0.000 1.000
#> SRR944318     2   0.000      1.000 0.000 1.000
#> SRR944319     2   0.000      1.000 0.000 1.000
#> SRR944320     2   0.000      1.000 0.000 1.000
#> SRR944321     1   0.000      0.982 1.000 0.000
#> SRR944322     1   0.000      0.982 1.000 0.000
#> SRR944323     1   0.000      0.982 1.000 0.000
#> SRR944324     1   0.000      0.982 1.000 0.000
#> SRR944325     1   0.000      0.982 1.000 0.000
#> SRR944326     1   0.000      0.982 1.000 0.000
#> SRR944327     1   0.000      0.982 1.000 0.000
#> SRR944328     1   0.000      0.982 1.000 0.000
#> SRR944329     1   0.000      0.982 1.000 0.000
#> SRR944330     1   0.000      0.982 1.000 0.000
#> SRR944331     1   0.000      0.982 1.000 0.000
#> SRR944332     1   0.000      0.982 1.000 0.000
#> SRR944334     1   0.000      0.982 1.000 0.000
#> SRR944333     1   0.000      0.982 1.000 0.000
#> SRR944335     1   0.000      0.982 1.000 0.000
#> SRR944336     1   0.000      0.982 1.000 0.000
#> SRR944337     1   0.000      0.982 1.000 0.000
#> SRR944338     1   0.518      0.887 0.884 0.116
#> SRR944339     1   0.518      0.887 0.884 0.116
#> SRR944340     1   0.518      0.887 0.884 0.116
#> SRR944341     1   0.518      0.887 0.884 0.116
#> SRR944342     1   0.518      0.887 0.884 0.116
#> SRR944343     1   0.518      0.887 0.884 0.116
#> SRR944344     1   0.518      0.887 0.884 0.116

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1 p2    p3
#> SRR944282     1   0.000      0.995 1.000  0 0.000
#> SRR944283     1   0.000      0.995 1.000  0 0.000
#> SRR944284     1   0.000      0.995 1.000  0 0.000
#> SRR944285     1   0.000      0.995 1.000  0 0.000
#> SRR944288     1   0.000      0.995 1.000  0 0.000
#> SRR944287     1   0.000      0.995 1.000  0 0.000
#> SRR944289     1   0.000      0.995 1.000  0 0.000
#> SRR944290     1   0.000      0.995 1.000  0 0.000
#> SRR944291     1   0.000      0.995 1.000  0 0.000
#> SRR944292     1   0.153      0.956 0.960  0 0.040
#> SRR944293     1   0.000      0.995 1.000  0 0.000
#> SRR944294     1   0.000      0.995 1.000  0 0.000
#> SRR944295     2   0.000      1.000 0.000  1 0.000
#> SRR944296     2   0.000      1.000 0.000  1 0.000
#> SRR944297     2   0.000      1.000 0.000  1 0.000
#> SRR944298     2   0.000      1.000 0.000  1 0.000
#> SRR944299     1   0.000      0.995 1.000  0 0.000
#> SRR944300     1   0.000      0.995 1.000  0 0.000
#> SRR944301     1   0.000      0.995 1.000  0 0.000
#> SRR944302     1   0.412      0.801 0.832  0 0.168
#> SRR944303     2   0.000      1.000 0.000  1 0.000
#> SRR944304     1   0.000      0.995 1.000  0 0.000
#> SRR944305     1   0.000      0.995 1.000  0 0.000
#> SRR944306     1   0.000      0.995 1.000  0 0.000
#> SRR944307     1   0.000      0.995 1.000  0 0.000
#> SRR944308     1   0.000      0.995 1.000  0 0.000
#> SRR944309     1   0.000      0.995 1.000  0 0.000
#> SRR944310     1   0.000      0.995 1.000  0 0.000
#> SRR944311     2   0.000      1.000 0.000  1 0.000
#> SRR944312     1   0.000      0.995 1.000  0 0.000
#> SRR944313     1   0.000      0.995 1.000  0 0.000
#> SRR944315     1   0.000      0.995 1.000  0 0.000
#> SRR944314     1   0.000      0.995 1.000  0 0.000
#> SRR944316     1   0.000      0.995 1.000  0 0.000
#> SRR944317     2   0.000      1.000 0.000  1 0.000
#> SRR944318     2   0.000      1.000 0.000  1 0.000
#> SRR944319     2   0.000      1.000 0.000  1 0.000
#> SRR944320     2   0.000      1.000 0.000  1 0.000
#> SRR944321     1   0.000      0.995 1.000  0 0.000
#> SRR944322     1   0.000      0.995 1.000  0 0.000
#> SRR944323     1   0.000      0.995 1.000  0 0.000
#> SRR944324     1   0.000      0.995 1.000  0 0.000
#> SRR944325     1   0.000      0.995 1.000  0 0.000
#> SRR944326     1   0.000      0.995 1.000  0 0.000
#> SRR944327     1   0.000      0.995 1.000  0 0.000
#> SRR944328     1   0.000      0.995 1.000  0 0.000
#> SRR944329     1   0.000      0.995 1.000  0 0.000
#> SRR944330     1   0.000      0.995 1.000  0 0.000
#> SRR944331     1   0.000      0.995 1.000  0 0.000
#> SRR944332     1   0.000      0.995 1.000  0 0.000
#> SRR944334     1   0.000      0.995 1.000  0 0.000
#> SRR944333     1   0.000      0.995 1.000  0 0.000
#> SRR944335     1   0.000      0.995 1.000  0 0.000
#> SRR944336     1   0.000      0.995 1.000  0 0.000
#> SRR944337     1   0.000      0.995 1.000  0 0.000
#> SRR944338     3   0.000      1.000 0.000  0 1.000
#> SRR944339     3   0.000      1.000 0.000  0 1.000
#> SRR944340     3   0.000      1.000 0.000  0 1.000
#> SRR944341     3   0.000      1.000 0.000  0 1.000
#> SRR944342     3   0.000      1.000 0.000  0 1.000
#> SRR944343     3   0.000      1.000 0.000  0 1.000
#> SRR944344     3   0.000      1.000 0.000  0 1.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1 p2 p3    p4
#> SRR944282     1   0.000      1.000 1.000  0  0 0.000
#> SRR944283     1   0.000      1.000 1.000  0  0 0.000
#> SRR944284     1   0.000      1.000 1.000  0  0 0.000
#> SRR944285     1   0.000      1.000 1.000  0  0 0.000
#> SRR944288     1   0.000      1.000 1.000  0  0 0.000
#> SRR944287     1   0.000      1.000 1.000  0  0 0.000
#> SRR944289     1   0.000      1.000 1.000  0  0 0.000
#> SRR944290     1   0.000      1.000 1.000  0  0 0.000
#> SRR944291     1   0.000      1.000 1.000  0  0 0.000
#> SRR944292     4   0.276      0.721 0.128  0  0 0.872
#> SRR944293     1   0.000      1.000 1.000  0  0 0.000
#> SRR944294     1   0.000      1.000 1.000  0  0 0.000
#> SRR944295     2   0.000      1.000 0.000  1  0 0.000
#> SRR944296     2   0.000      1.000 0.000  1  0 0.000
#> SRR944297     2   0.000      1.000 0.000  1  0 0.000
#> SRR944298     2   0.000      1.000 0.000  1  0 0.000
#> SRR944299     1   0.000      1.000 1.000  0  0 0.000
#> SRR944300     1   0.000      1.000 1.000  0  0 0.000
#> SRR944301     1   0.000      1.000 1.000  0  0 0.000
#> SRR944302     4   0.000      0.710 0.000  0  0 1.000
#> SRR944303     2   0.000      1.000 0.000  1  0 0.000
#> SRR944304     1   0.000      1.000 1.000  0  0 0.000
#> SRR944305     1   0.000      1.000 1.000  0  0 0.000
#> SRR944306     1   0.000      1.000 1.000  0  0 0.000
#> SRR944307     1   0.000      1.000 1.000  0  0 0.000
#> SRR944308     1   0.000      1.000 1.000  0  0 0.000
#> SRR944309     1   0.000      1.000 1.000  0  0 0.000
#> SRR944310     1   0.000      1.000 1.000  0  0 0.000
#> SRR944311     2   0.000      1.000 0.000  1  0 0.000
#> SRR944312     1   0.000      1.000 1.000  0  0 0.000
#> SRR944313     1   0.000      1.000 1.000  0  0 0.000
#> SRR944315     1   0.000      1.000 1.000  0  0 0.000
#> SRR944314     1   0.000      1.000 1.000  0  0 0.000
#> SRR944316     1   0.000      1.000 1.000  0  0 0.000
#> SRR944317     2   0.000      1.000 0.000  1  0 0.000
#> SRR944318     2   0.000      1.000 0.000  1  0 0.000
#> SRR944319     2   0.000      1.000 0.000  1  0 0.000
#> SRR944320     2   0.000      1.000 0.000  1  0 0.000
#> SRR944321     1   0.000      1.000 1.000  0  0 0.000
#> SRR944322     1   0.000      1.000 1.000  0  0 0.000
#> SRR944323     1   0.000      1.000 1.000  0  0 0.000
#> SRR944324     1   0.000      1.000 1.000  0  0 0.000
#> SRR944325     1   0.000      1.000 1.000  0  0 0.000
#> SRR944326     1   0.000      1.000 1.000  0  0 0.000
#> SRR944327     1   0.000      1.000 1.000  0  0 0.000
#> SRR944328     1   0.000      1.000 1.000  0  0 0.000
#> SRR944329     1   0.000      1.000 1.000  0  0 0.000
#> SRR944330     1   0.000      1.000 1.000  0  0 0.000
#> SRR944331     1   0.000      1.000 1.000  0  0 0.000
#> SRR944332     1   0.000      1.000 1.000  0  0 0.000
#> SRR944334     1   0.000      1.000 1.000  0  0 0.000
#> SRR944333     1   0.000      1.000 1.000  0  0 0.000
#> SRR944335     1   0.000      1.000 1.000  0  0 0.000
#> SRR944336     1   0.000      1.000 1.000  0  0 0.000
#> SRR944337     1   0.000      1.000 1.000  0  0 0.000
#> SRR944338     3   0.000      1.000 0.000  0  1 0.000
#> SRR944339     3   0.000      1.000 0.000  0  1 0.000
#> SRR944340     3   0.000      1.000 0.000  0  1 0.000
#> SRR944341     3   0.000      1.000 0.000  0  1 0.000
#> SRR944342     3   0.000      1.000 0.000  0  1 0.000
#> SRR944343     3   0.000      1.000 0.000  0  1 0.000
#> SRR944344     3   0.000      1.000 0.000  0  1 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3   p4    p5
#> SRR944282     1  0.0000      1.000 1.000 0.000 0.000 0.00 0.000
#> SRR944283     1  0.0000      1.000 1.000 0.000 0.000 0.00 0.000
#> SRR944284     1  0.0000      1.000 1.000 0.000 0.000 0.00 0.000
#> SRR944285     1  0.0000      1.000 1.000 0.000 0.000 0.00 0.000
#> SRR944288     1  0.0000      1.000 1.000 0.000 0.000 0.00 0.000
#> SRR944287     1  0.0000      1.000 1.000 0.000 0.000 0.00 0.000
#> SRR944289     1  0.0000      1.000 1.000 0.000 0.000 0.00 0.000
#> SRR944290     1  0.0000      1.000 1.000 0.000 0.000 0.00 0.000
#> SRR944291     1  0.0000      1.000 1.000 0.000 0.000 0.00 0.000
#> SRR944292     4  0.2825      0.602 0.124 0.000 0.000 0.86 0.016
#> SRR944293     1  0.0000      1.000 1.000 0.000 0.000 0.00 0.000
#> SRR944294     1  0.0000      1.000 1.000 0.000 0.000 0.00 0.000
#> SRR944295     2  0.0000      0.999 0.000 1.000 0.000 0.00 0.000
#> SRR944296     2  0.0000      0.999 0.000 1.000 0.000 0.00 0.000
#> SRR944297     2  0.0000      0.999 0.000 1.000 0.000 0.00 0.000
#> SRR944298     2  0.0000      0.999 0.000 1.000 0.000 0.00 0.000
#> SRR944299     1  0.0000      1.000 1.000 0.000 0.000 0.00 0.000
#> SRR944300     1  0.0000      1.000 1.000 0.000 0.000 0.00 0.000
#> SRR944301     1  0.0000      1.000 1.000 0.000 0.000 0.00 0.000
#> SRR944302     4  0.0000      0.568 0.000 0.000 0.000 1.00 0.000
#> SRR944303     2  0.0000      0.999 0.000 1.000 0.000 0.00 0.000
#> SRR944304     1  0.0000      1.000 1.000 0.000 0.000 0.00 0.000
#> SRR944305     1  0.0000      1.000 1.000 0.000 0.000 0.00 0.000
#> SRR944306     1  0.0000      1.000 1.000 0.000 0.000 0.00 0.000
#> SRR944307     1  0.0000      1.000 1.000 0.000 0.000 0.00 0.000
#> SRR944308     1  0.0000      1.000 1.000 0.000 0.000 0.00 0.000
#> SRR944309     1  0.0000      1.000 1.000 0.000 0.000 0.00 0.000
#> SRR944310     1  0.0000      1.000 1.000 0.000 0.000 0.00 0.000
#> SRR944311     2  0.0000      0.999 0.000 1.000 0.000 0.00 0.000
#> SRR944312     1  0.0000      1.000 1.000 0.000 0.000 0.00 0.000
#> SRR944313     1  0.0000      1.000 1.000 0.000 0.000 0.00 0.000
#> SRR944315     1  0.0000      1.000 1.000 0.000 0.000 0.00 0.000
#> SRR944314     1  0.0000      1.000 1.000 0.000 0.000 0.00 0.000
#> SRR944316     1  0.0000      1.000 1.000 0.000 0.000 0.00 0.000
#> SRR944317     2  0.0162      0.996 0.000 0.996 0.000 0.00 0.004
#> SRR944318     2  0.0162      0.996 0.000 0.996 0.000 0.00 0.004
#> SRR944319     5  0.1043      1.000 0.000 0.040 0.000 0.00 0.960
#> SRR944320     5  0.1043      1.000 0.000 0.040 0.000 0.00 0.960
#> SRR944321     1  0.0000      1.000 1.000 0.000 0.000 0.00 0.000
#> SRR944322     1  0.0000      1.000 1.000 0.000 0.000 0.00 0.000
#> SRR944323     1  0.0000      1.000 1.000 0.000 0.000 0.00 0.000
#> SRR944324     1  0.0000      1.000 1.000 0.000 0.000 0.00 0.000
#> SRR944325     1  0.0000      1.000 1.000 0.000 0.000 0.00 0.000
#> SRR944326     1  0.0000      1.000 1.000 0.000 0.000 0.00 0.000
#> SRR944327     1  0.0000      1.000 1.000 0.000 0.000 0.00 0.000
#> SRR944328     1  0.0000      1.000 1.000 0.000 0.000 0.00 0.000
#> SRR944329     1  0.0000      1.000 1.000 0.000 0.000 0.00 0.000
#> SRR944330     1  0.0000      1.000 1.000 0.000 0.000 0.00 0.000
#> SRR944331     1  0.0000      1.000 1.000 0.000 0.000 0.00 0.000
#> SRR944332     1  0.0000      1.000 1.000 0.000 0.000 0.00 0.000
#> SRR944334     1  0.0000      1.000 1.000 0.000 0.000 0.00 0.000
#> SRR944333     1  0.0000      1.000 1.000 0.000 0.000 0.00 0.000
#> SRR944335     1  0.0000      1.000 1.000 0.000 0.000 0.00 0.000
#> SRR944336     1  0.0000      1.000 1.000 0.000 0.000 0.00 0.000
#> SRR944337     1  0.0000      1.000 1.000 0.000 0.000 0.00 0.000
#> SRR944338     3  0.0000      0.996 0.000 0.000 1.000 0.00 0.000
#> SRR944339     3  0.0000      0.996 0.000 0.000 1.000 0.00 0.000
#> SRR944340     3  0.0000      0.996 0.000 0.000 1.000 0.00 0.000
#> SRR944341     3  0.0000      0.996 0.000 0.000 1.000 0.00 0.000
#> SRR944342     3  0.0000      0.996 0.000 0.000 1.000 0.00 0.000
#> SRR944343     3  0.0000      0.996 0.000 0.000 1.000 0.00 0.000
#> SRR944344     3  0.0703      0.979 0.000 0.000 0.976 0.00 0.024

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette p1    p2    p3    p4    p5    p6
#> SRR944282     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR944283     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR944284     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR944285     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR944288     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR944287     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR944289     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR944290     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR944291     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR944292     5  0.2912      0.820  0 0.000 0.000 0.216 0.784 0.000
#> SRR944293     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR944294     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR944295     2  0.0000      0.999  0 1.000 0.000 0.000 0.000 0.000
#> SRR944296     2  0.0000      0.999  0 1.000 0.000 0.000 0.000 0.000
#> SRR944297     2  0.0000      0.999  0 1.000 0.000 0.000 0.000 0.000
#> SRR944298     2  0.0000      0.999  0 1.000 0.000 0.000 0.000 0.000
#> SRR944299     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR944300     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR944301     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR944302     5  0.0000      0.820  0 0.000 0.000 0.000 1.000 0.000
#> SRR944303     2  0.0000      0.999  0 1.000 0.000 0.000 0.000 0.000
#> SRR944304     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR944305     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR944306     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR944307     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR944308     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR944309     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR944310     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR944311     2  0.0000      0.999  0 1.000 0.000 0.000 0.000 0.000
#> SRR944312     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR944313     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR944315     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR944314     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR944316     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR944317     2  0.0146      0.996  0 0.996 0.000 0.000 0.000 0.004
#> SRR944318     2  0.0146      0.996  0 0.996 0.000 0.000 0.000 0.004
#> SRR944319     6  0.0000      1.000  0 0.000 0.000 0.000 0.000 1.000
#> SRR944320     6  0.0000      1.000  0 0.000 0.000 0.000 0.000 1.000
#> SRR944321     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR944322     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR944323     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR944324     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR944325     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR944326     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR944327     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR944328     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR944329     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR944330     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR944331     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR944332     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR944334     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR944333     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR944335     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR944336     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR944337     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> SRR944338     3  0.0000      1.000  0 0.000 1.000 0.000 0.000 0.000
#> SRR944339     3  0.0000      1.000  0 0.000 1.000 0.000 0.000 0.000
#> SRR944340     3  0.0000      1.000  0 0.000 1.000 0.000 0.000 0.000
#> SRR944341     3  0.0000      1.000  0 0.000 1.000 0.000 0.000 0.000
#> SRR944342     3  0.0000      1.000  0 0.000 1.000 0.000 0.000 0.000
#> SRR944343     3  0.0000      1.000  0 0.000 1.000 0.000 0.000 0.000
#> SRR944344     4  0.2912      0.000  0 0.000 0.216 0.784 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 12673 rows and 62 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 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-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.510           0.536       0.797         0.3413 0.748   0.748
#> 3 3 0.878           0.958       0.952         0.4494 0.773   0.696
#> 4 4 0.652           0.754       0.810         0.2156 0.993   0.986
#> 5 5 0.588           0.748       0.791         0.1422 0.825   0.660
#> 6 6 0.677           0.815       0.816         0.0765 0.867   0.606

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
#> SRR944282     1   0.988      0.707 0.564 0.436
#> SRR944283     1   0.988      0.707 0.564 0.436
#> SRR944284     1   0.988      0.707 0.564 0.436
#> SRR944285     1   0.988      0.707 0.564 0.436
#> SRR944288     1   0.988      0.707 0.564 0.436
#> SRR944287     1   0.988      0.707 0.564 0.436
#> SRR944289     1   0.988      0.707 0.564 0.436
#> SRR944290     1   0.988      0.707 0.564 0.436
#> SRR944291     1   0.988      0.707 0.564 0.436
#> SRR944292     2   0.552      0.674 0.128 0.872
#> SRR944293     1   0.988      0.707 0.564 0.436
#> SRR944294     1   0.988      0.707 0.564 0.436
#> SRR944295     1   0.988     -0.448 0.564 0.436
#> SRR944296     1   0.988     -0.448 0.564 0.436
#> SRR944297     1   0.988     -0.448 0.564 0.436
#> SRR944298     1   0.988     -0.448 0.564 0.436
#> SRR944299     1   0.988      0.707 0.564 0.436
#> SRR944300     1   0.988      0.707 0.564 0.436
#> SRR944301     1   0.988      0.707 0.564 0.436
#> SRR944302     2   0.706      0.732 0.192 0.808
#> SRR944303     1   0.988     -0.448 0.564 0.436
#> SRR944304     1   0.988      0.707 0.564 0.436
#> SRR944305     1   0.988      0.707 0.564 0.436
#> SRR944306     1   0.988      0.707 0.564 0.436
#> SRR944307     1   0.988      0.707 0.564 0.436
#> SRR944308     1   0.988      0.707 0.564 0.436
#> SRR944309     1   0.988      0.707 0.564 0.436
#> SRR944310     1   0.988      0.707 0.564 0.436
#> SRR944311     1   0.988     -0.448 0.564 0.436
#> SRR944312     1   0.988      0.707 0.564 0.436
#> SRR944313     1   0.988      0.707 0.564 0.436
#> SRR944315     1   0.988      0.707 0.564 0.436
#> SRR944314     1   0.988      0.707 0.564 0.436
#> SRR944316     1   0.988      0.707 0.564 0.436
#> SRR944317     1   0.988     -0.448 0.564 0.436
#> SRR944318     1   0.988     -0.448 0.564 0.436
#> SRR944319     1   0.988     -0.448 0.564 0.436
#> SRR944320     1   0.988     -0.448 0.564 0.436
#> SRR944321     1   0.988      0.707 0.564 0.436
#> SRR944322     1   0.988      0.707 0.564 0.436
#> SRR944323     1   0.988      0.707 0.564 0.436
#> SRR944324     1   0.988      0.707 0.564 0.436
#> SRR944325     1   0.988      0.707 0.564 0.436
#> SRR944326     1   0.988      0.707 0.564 0.436
#> SRR944327     1   0.988      0.707 0.564 0.436
#> SRR944328     1   0.988      0.707 0.564 0.436
#> SRR944329     1   0.988      0.707 0.564 0.436
#> SRR944330     1   0.988      0.707 0.564 0.436
#> SRR944331     1   0.988      0.707 0.564 0.436
#> SRR944332     1   0.988      0.707 0.564 0.436
#> SRR944334     1   0.988      0.707 0.564 0.436
#> SRR944333     1   0.988      0.707 0.564 0.436
#> SRR944335     1   0.988      0.707 0.564 0.436
#> SRR944336     1   0.988      0.707 0.564 0.436
#> SRR944337     1   0.988      0.707 0.564 0.436
#> SRR944338     2   0.000      0.884 0.000 1.000
#> SRR944339     2   0.000      0.884 0.000 1.000
#> SRR944340     2   0.000      0.884 0.000 1.000
#> SRR944341     2   0.000      0.884 0.000 1.000
#> SRR944342     2   0.000      0.884 0.000 1.000
#> SRR944343     2   0.000      0.884 0.000 1.000
#> SRR944344     2   0.760      0.617 0.220 0.780

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> SRR944282     1  0.1860      0.961 0.948 0.000 0.052
#> SRR944283     1  0.1860      0.961 0.948 0.000 0.052
#> SRR944284     1  0.1753      0.962 0.952 0.000 0.048
#> SRR944285     1  0.1753      0.962 0.952 0.000 0.048
#> SRR944288     1  0.1753      0.962 0.952 0.000 0.048
#> SRR944287     1  0.1753      0.962 0.952 0.000 0.048
#> SRR944289     1  0.1753      0.950 0.952 0.000 0.048
#> SRR944290     1  0.0424      0.965 0.992 0.000 0.008
#> SRR944291     1  0.1753      0.962 0.952 0.000 0.048
#> SRR944292     3  0.7330      0.578 0.216 0.092 0.692
#> SRR944293     1  0.1753      0.962 0.952 0.000 0.048
#> SRR944294     1  0.1753      0.962 0.952 0.000 0.048
#> SRR944295     2  0.0000      1.000 0.000 1.000 0.000
#> SRR944296     2  0.0000      1.000 0.000 1.000 0.000
#> SRR944297     2  0.0000      1.000 0.000 1.000 0.000
#> SRR944298     2  0.0000      1.000 0.000 1.000 0.000
#> SRR944299     1  0.0892      0.962 0.980 0.000 0.020
#> SRR944300     1  0.0892      0.962 0.980 0.000 0.020
#> SRR944301     1  0.1753      0.962 0.952 0.000 0.048
#> SRR944302     3  0.3192      0.947 0.000 0.112 0.888
#> SRR944303     2  0.0000      1.000 0.000 1.000 0.000
#> SRR944304     1  0.0424      0.964 0.992 0.000 0.008
#> SRR944305     1  0.0424      0.963 0.992 0.000 0.008
#> SRR944306     1  0.0237      0.964 0.996 0.000 0.004
#> SRR944307     1  0.0892      0.962 0.980 0.000 0.020
#> SRR944308     1  0.1753      0.962 0.952 0.000 0.048
#> SRR944309     1  0.1964      0.962 0.944 0.000 0.056
#> SRR944310     1  0.1753      0.962 0.952 0.000 0.048
#> SRR944311     2  0.0000      1.000 0.000 1.000 0.000
#> SRR944312     1  0.0892      0.964 0.980 0.000 0.020
#> SRR944313     1  0.1860      0.962 0.948 0.000 0.052
#> SRR944315     1  0.1753      0.962 0.952 0.000 0.048
#> SRR944314     1  0.2066      0.961 0.940 0.000 0.060
#> SRR944316     1  0.1753      0.962 0.952 0.000 0.048
#> SRR944317     2  0.0000      1.000 0.000 1.000 0.000
#> SRR944318     2  0.0000      1.000 0.000 1.000 0.000
#> SRR944319     2  0.0000      1.000 0.000 1.000 0.000
#> SRR944320     2  0.0000      1.000 0.000 1.000 0.000
#> SRR944321     1  0.1031      0.961 0.976 0.000 0.024
#> SRR944322     1  0.1031      0.961 0.976 0.000 0.024
#> SRR944323     1  0.1031      0.961 0.976 0.000 0.024
#> SRR944324     1  0.1031      0.961 0.976 0.000 0.024
#> SRR944325     1  0.1031      0.961 0.976 0.000 0.024
#> SRR944326     1  0.1031      0.961 0.976 0.000 0.024
#> SRR944327     1  0.2066      0.961 0.940 0.000 0.060
#> SRR944328     1  0.1964      0.961 0.944 0.000 0.056
#> SRR944329     1  0.1860      0.948 0.948 0.000 0.052
#> SRR944330     1  0.1860      0.948 0.948 0.000 0.052
#> SRR944331     1  0.1860      0.948 0.948 0.000 0.052
#> SRR944332     1  0.1860      0.948 0.948 0.000 0.052
#> SRR944334     1  0.1860      0.948 0.948 0.000 0.052
#> SRR944333     1  0.1860      0.948 0.948 0.000 0.052
#> SRR944335     1  0.1964      0.947 0.944 0.000 0.056
#> SRR944336     1  0.1964      0.947 0.944 0.000 0.056
#> SRR944337     1  0.2066      0.946 0.940 0.000 0.060
#> SRR944338     3  0.3192      0.947 0.000 0.112 0.888
#> SRR944339     3  0.3192      0.947 0.000 0.112 0.888
#> SRR944340     3  0.3192      0.947 0.000 0.112 0.888
#> SRR944341     3  0.3192      0.947 0.000 0.112 0.888
#> SRR944342     3  0.3192      0.947 0.000 0.112 0.888
#> SRR944343     3  0.3192      0.947 0.000 0.112 0.888
#> SRR944344     3  0.3192      0.947 0.000 0.112 0.888

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> SRR944282     1  0.4643      0.650 0.656 0.000 0.000 0.344
#> SRR944283     1  0.4643      0.650 0.656 0.000 0.000 0.344
#> SRR944284     1  0.4605      0.654 0.664 0.000 0.000 0.336
#> SRR944285     1  0.4605      0.654 0.664 0.000 0.000 0.336
#> SRR944288     1  0.4605      0.654 0.664 0.000 0.000 0.336
#> SRR944287     1  0.4624      0.653 0.660 0.000 0.000 0.340
#> SRR944289     1  0.4323      0.628 0.788 0.000 0.028 0.184
#> SRR944290     1  0.1743      0.733 0.940 0.000 0.004 0.056
#> SRR944291     1  0.4605      0.654 0.664 0.000 0.000 0.336
#> SRR944292     4  0.6053      0.732 0.084 0.032 0.156 0.728
#> SRR944293     1  0.4605      0.654 0.664 0.000 0.000 0.336
#> SRR944294     1  0.4605      0.654 0.664 0.000 0.000 0.336
#> SRR944295     2  0.0000      0.983 0.000 1.000 0.000 0.000
#> SRR944296     2  0.0000      0.983 0.000 1.000 0.000 0.000
#> SRR944297     2  0.0000      0.983 0.000 1.000 0.000 0.000
#> SRR944298     2  0.0000      0.983 0.000 1.000 0.000 0.000
#> SRR944299     1  0.0376      0.727 0.992 0.000 0.004 0.004
#> SRR944300     1  0.0524      0.727 0.988 0.000 0.004 0.008
#> SRR944301     1  0.4741      0.657 0.668 0.000 0.004 0.328
#> SRR944302     4  0.5472      0.663 0.000 0.044 0.280 0.676
#> SRR944303     2  0.0000      0.983 0.000 1.000 0.000 0.000
#> SRR944304     1  0.1398      0.732 0.956 0.000 0.004 0.040
#> SRR944305     1  0.1109      0.730 0.968 0.000 0.004 0.028
#> SRR944306     1  0.1004      0.730 0.972 0.000 0.004 0.024
#> SRR944307     1  0.0657      0.726 0.984 0.000 0.004 0.012
#> SRR944308     1  0.4741      0.657 0.668 0.000 0.004 0.328
#> SRR944309     1  0.1489      0.730 0.952 0.000 0.004 0.044
#> SRR944310     1  0.4761      0.655 0.664 0.000 0.004 0.332
#> SRR944311     2  0.0000      0.983 0.000 1.000 0.000 0.000
#> SRR944312     1  0.1398      0.731 0.956 0.000 0.004 0.040
#> SRR944313     1  0.4677      0.658 0.680 0.000 0.004 0.316
#> SRR944315     1  0.4605      0.654 0.664 0.000 0.000 0.336
#> SRR944314     1  0.4585      0.649 0.668 0.000 0.000 0.332
#> SRR944316     1  0.4605      0.654 0.664 0.000 0.000 0.336
#> SRR944317     2  0.0817      0.976 0.000 0.976 0.000 0.024
#> SRR944318     2  0.0817      0.976 0.000 0.976 0.000 0.024
#> SRR944319     2  0.2081      0.936 0.000 0.916 0.000 0.084
#> SRR944320     2  0.1557      0.958 0.000 0.944 0.000 0.056
#> SRR944321     1  0.1174      0.722 0.968 0.000 0.012 0.020
#> SRR944322     1  0.1174      0.722 0.968 0.000 0.012 0.020
#> SRR944323     1  0.1174      0.722 0.968 0.000 0.012 0.020
#> SRR944324     1  0.1174      0.722 0.968 0.000 0.012 0.020
#> SRR944325     1  0.1174      0.722 0.968 0.000 0.012 0.020
#> SRR944326     1  0.1174      0.722 0.968 0.000 0.012 0.020
#> SRR944327     1  0.5057      0.642 0.648 0.000 0.012 0.340
#> SRR944328     1  0.5110      0.640 0.636 0.000 0.012 0.352
#> SRR944329     1  0.4741      0.593 0.744 0.000 0.028 0.228
#> SRR944330     1  0.4741      0.593 0.744 0.000 0.028 0.228
#> SRR944331     1  0.4741      0.593 0.744 0.000 0.028 0.228
#> SRR944332     1  0.4741      0.593 0.744 0.000 0.028 0.228
#> SRR944334     1  0.4741      0.593 0.744 0.000 0.028 0.228
#> SRR944333     1  0.4741      0.593 0.744 0.000 0.028 0.228
#> SRR944335     1  0.4562      0.599 0.764 0.000 0.028 0.208
#> SRR944336     1  0.4562      0.599 0.764 0.000 0.028 0.208
#> SRR944337     1  0.4524      0.599 0.768 0.000 0.028 0.204
#> SRR944338     3  0.1302      0.999 0.000 0.044 0.956 0.000
#> SRR944339     3  0.1302      0.999 0.000 0.044 0.956 0.000
#> SRR944340     3  0.1302      0.999 0.000 0.044 0.956 0.000
#> SRR944341     3  0.1302      0.999 0.000 0.044 0.956 0.000
#> SRR944342     3  0.1302      0.999 0.000 0.044 0.956 0.000
#> SRR944343     3  0.1302      0.999 0.000 0.044 0.956 0.000
#> SRR944344     3  0.1489      0.995 0.000 0.044 0.952 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
#> SRR944282     1  0.3282      0.674 0.804 0.000 0.000 0.008 0.188
#> SRR944283     1  0.3551      0.656 0.772 0.000 0.000 0.008 0.220
#> SRR944284     1  0.3551      0.656 0.772 0.000 0.000 0.008 0.220
#> SRR944285     1  0.3305      0.656 0.776 0.000 0.000 0.000 0.224
#> SRR944288     1  0.3582      0.653 0.768 0.000 0.000 0.008 0.224
#> SRR944287     1  0.2813      0.682 0.832 0.000 0.000 0.000 0.168
#> SRR944289     4  0.3395      0.944 0.236 0.000 0.000 0.764 0.000
#> SRR944290     1  0.2583      0.606 0.864 0.000 0.000 0.132 0.004
#> SRR944291     1  0.3582      0.653 0.768 0.000 0.000 0.008 0.224
#> SRR944292     5  0.1725      0.978 0.044 0.000 0.020 0.000 0.936
#> SRR944293     1  0.3582      0.653 0.768 0.000 0.000 0.008 0.224
#> SRR944294     1  0.3582      0.653 0.768 0.000 0.000 0.008 0.224
#> SRR944295     2  0.0162      0.964 0.000 0.996 0.000 0.004 0.000
#> SRR944296     2  0.0162      0.964 0.000 0.996 0.000 0.004 0.000
#> SRR944297     2  0.0162      0.964 0.000 0.996 0.000 0.004 0.000
#> SRR944298     2  0.0162      0.964 0.000 0.996 0.000 0.004 0.000
#> SRR944299     1  0.4456      0.348 0.660 0.000 0.000 0.320 0.020
#> SRR944300     1  0.4456      0.348 0.660 0.000 0.000 0.320 0.020
#> SRR944301     1  0.2077      0.688 0.908 0.000 0.000 0.008 0.084
#> SRR944302     5  0.2036      0.978 0.036 0.000 0.028 0.008 0.928
#> SRR944303     2  0.0000      0.964 0.000 1.000 0.000 0.000 0.000
#> SRR944304     1  0.2727      0.607 0.868 0.000 0.000 0.116 0.016
#> SRR944305     1  0.3586      0.549 0.792 0.000 0.000 0.188 0.020
#> SRR944306     1  0.3621      0.539 0.788 0.000 0.000 0.192 0.020
#> SRR944307     1  0.4456      0.348 0.660 0.000 0.000 0.320 0.020
#> SRR944308     1  0.2513      0.690 0.876 0.000 0.000 0.008 0.116
#> SRR944309     1  0.1251      0.659 0.956 0.000 0.000 0.036 0.008
#> SRR944310     1  0.3053      0.679 0.828 0.000 0.000 0.008 0.164
#> SRR944311     2  0.0000      0.964 0.000 1.000 0.000 0.000 0.000
#> SRR944312     1  0.3013      0.585 0.832 0.000 0.000 0.160 0.008
#> SRR944313     1  0.0162      0.671 0.996 0.000 0.000 0.000 0.004
#> SRR944315     1  0.3171      0.678 0.816 0.000 0.000 0.008 0.176
#> SRR944314     1  0.2511      0.687 0.892 0.000 0.000 0.028 0.080
#> SRR944316     1  0.3461      0.655 0.772 0.000 0.000 0.004 0.224
#> SRR944317     2  0.1310      0.952 0.000 0.956 0.000 0.024 0.020
#> SRR944318     2  0.1310      0.952 0.000 0.956 0.000 0.024 0.020
#> SRR944319     2  0.3476      0.871 0.000 0.836 0.000 0.076 0.088
#> SRR944320     2  0.2770      0.908 0.000 0.880 0.000 0.076 0.044
#> SRR944321     1  0.4682      0.306 0.620 0.000 0.000 0.356 0.024
#> SRR944322     1  0.4682      0.306 0.620 0.000 0.000 0.356 0.024
#> SRR944323     1  0.4682      0.306 0.620 0.000 0.000 0.356 0.024
#> SRR944324     1  0.4682      0.306 0.620 0.000 0.000 0.356 0.024
#> SRR944325     1  0.4682      0.306 0.620 0.000 0.000 0.356 0.024
#> SRR944326     1  0.4682      0.306 0.620 0.000 0.000 0.356 0.024
#> SRR944327     1  0.4190      0.646 0.768 0.000 0.000 0.060 0.172
#> SRR944328     1  0.4451      0.594 0.712 0.000 0.000 0.040 0.248
#> SRR944329     4  0.3177      0.980 0.208 0.000 0.000 0.792 0.000
#> SRR944330     4  0.3177      0.980 0.208 0.000 0.000 0.792 0.000
#> SRR944331     4  0.3177      0.980 0.208 0.000 0.000 0.792 0.000
#> SRR944332     4  0.3177      0.980 0.208 0.000 0.000 0.792 0.000
#> SRR944334     4  0.3177      0.980 0.208 0.000 0.000 0.792 0.000
#> SRR944333     4  0.3177      0.980 0.208 0.000 0.000 0.792 0.000
#> SRR944335     4  0.2966      0.964 0.184 0.000 0.000 0.816 0.000
#> SRR944336     4  0.2966      0.964 0.184 0.000 0.000 0.816 0.000
#> SRR944337     4  0.2966      0.964 0.184 0.000 0.000 0.816 0.000
#> SRR944338     3  0.0000      0.991 0.000 0.000 1.000 0.000 0.000
#> SRR944339     3  0.0000      0.991 0.000 0.000 1.000 0.000 0.000
#> SRR944340     3  0.0000      0.991 0.000 0.000 1.000 0.000 0.000
#> SRR944341     3  0.0000      0.991 0.000 0.000 1.000 0.000 0.000
#> SRR944342     3  0.0000      0.991 0.000 0.000 1.000 0.000 0.000
#> SRR944343     3  0.0000      0.991 0.000 0.000 1.000 0.000 0.000
#> SRR944344     3  0.1478      0.942 0.000 0.000 0.936 0.064 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
#> SRR944282     1  0.0458      0.854 0.984 0.000 0.000 0.000 0.000 0.016
#> SRR944283     1  0.0146      0.855 0.996 0.000 0.000 0.000 0.000 0.004
#> SRR944284     1  0.0000      0.856 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944285     1  0.0146      0.855 0.996 0.000 0.000 0.000 0.000 0.004
#> SRR944288     1  0.0000      0.856 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944287     1  0.0632      0.852 0.976 0.000 0.000 0.000 0.000 0.024
#> SRR944289     4  0.5125      0.931 0.132 0.000 0.000 0.632 0.004 0.232
#> SRR944290     1  0.3023      0.589 0.784 0.000 0.000 0.000 0.004 0.212
#> SRR944291     1  0.0000      0.856 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944292     5  0.1674      0.975 0.068 0.000 0.000 0.004 0.924 0.004
#> SRR944293     1  0.0000      0.856 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944294     1  0.0000      0.856 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944295     2  0.0000      0.898 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944296     2  0.0713      0.892 0.000 0.972 0.000 0.028 0.000 0.000
#> SRR944297     2  0.0146      0.898 0.000 0.996 0.000 0.004 0.000 0.000
#> SRR944298     2  0.0000      0.898 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944299     6  0.3690      0.809 0.308 0.000 0.000 0.000 0.008 0.684
#> SRR944300     6  0.3725      0.803 0.316 0.000 0.000 0.000 0.008 0.676
#> SRR944301     1  0.1610      0.818 0.916 0.000 0.000 0.000 0.000 0.084
#> SRR944302     5  0.1141      0.975 0.052 0.000 0.000 0.000 0.948 0.000
#> SRR944303     2  0.0000      0.898 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944304     1  0.4080     -0.371 0.536 0.000 0.000 0.000 0.008 0.456
#> SRR944305     6  0.4025      0.657 0.416 0.000 0.000 0.000 0.008 0.576
#> SRR944306     6  0.4051      0.635 0.432 0.000 0.000 0.000 0.008 0.560
#> SRR944307     6  0.3690      0.809 0.308 0.000 0.000 0.000 0.008 0.684
#> SRR944308     1  0.1610      0.816 0.916 0.000 0.000 0.000 0.000 0.084
#> SRR944309     1  0.3854     -0.341 0.536 0.000 0.000 0.000 0.000 0.464
#> SRR944310     1  0.1267      0.831 0.940 0.000 0.000 0.000 0.000 0.060
#> SRR944311     2  0.0000      0.898 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944312     6  0.3838      0.598 0.448 0.000 0.000 0.000 0.000 0.552
#> SRR944313     1  0.2092      0.775 0.876 0.000 0.000 0.000 0.000 0.124
#> SRR944315     1  0.0458      0.854 0.984 0.000 0.000 0.000 0.000 0.016
#> SRR944314     1  0.1753      0.807 0.912 0.000 0.000 0.000 0.004 0.084
#> SRR944316     1  0.0000      0.856 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944317     2  0.3095      0.858 0.000 0.856 0.000 0.052 0.020 0.072
#> SRR944318     2  0.3095      0.858 0.000 0.856 0.000 0.052 0.020 0.072
#> SRR944319     2  0.5847      0.687 0.000 0.632 0.000 0.116 0.084 0.168
#> SRR944320     2  0.5325      0.730 0.000 0.672 0.000 0.116 0.044 0.168
#> SRR944321     6  0.4795      0.820 0.268 0.000 0.000 0.052 0.020 0.660
#> SRR944322     6  0.4795      0.820 0.268 0.000 0.000 0.052 0.020 0.660
#> SRR944323     6  0.4795      0.820 0.268 0.000 0.000 0.052 0.020 0.660
#> SRR944324     6  0.4795      0.820 0.268 0.000 0.000 0.052 0.020 0.660
#> SRR944325     6  0.4795      0.820 0.268 0.000 0.000 0.052 0.020 0.660
#> SRR944326     6  0.4795      0.820 0.268 0.000 0.000 0.052 0.020 0.660
#> SRR944327     1  0.3665      0.672 0.800 0.000 0.000 0.052 0.012 0.136
#> SRR944328     1  0.3032      0.700 0.840 0.000 0.000 0.056 0.000 0.104
#> SRR944329     4  0.4680      0.959 0.120 0.000 0.000 0.680 0.000 0.200
#> SRR944330     4  0.4680      0.959 0.120 0.000 0.000 0.680 0.000 0.200
#> SRR944331     4  0.4680      0.959 0.120 0.000 0.000 0.680 0.000 0.200
#> SRR944332     4  0.4680      0.959 0.120 0.000 0.000 0.680 0.000 0.200
#> SRR944334     4  0.4680      0.959 0.120 0.000 0.000 0.680 0.000 0.200
#> SRR944333     4  0.4680      0.959 0.120 0.000 0.000 0.680 0.000 0.200
#> SRR944335     4  0.5125      0.922 0.096 0.000 0.000 0.632 0.012 0.260
#> SRR944336     4  0.5125      0.922 0.096 0.000 0.000 0.632 0.012 0.260
#> SRR944337     4  0.5125      0.922 0.096 0.000 0.000 0.632 0.012 0.260
#> SRR944338     3  0.0000      0.974 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR944339     3  0.0000      0.974 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR944340     3  0.0000      0.974 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR944341     3  0.0000      0.974 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR944342     3  0.0000      0.974 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR944343     3  0.0000      0.974 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR944344     3  0.3355      0.828 0.000 0.000 0.828 0.116 0.016 0.040

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-kmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-kmeans-collect-classes

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


SD:skmeans**

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

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

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

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

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

collect_plots(res)

plot of chunk SD-skmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4326 0.568   0.568
#> 3 3 1.000           0.993       0.989         0.3945 0.825   0.693
#> 4 4 0.991           0.977       0.968         0.0983 0.952   0.879
#> 5 5 0.769           0.789       0.883         0.1657 0.872   0.630
#> 6 6 0.760           0.659       0.806         0.0554 0.972   0.874

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette p1 p2
#> SRR944282     1       0          1  1  0
#> SRR944283     1       0          1  1  0
#> SRR944284     1       0          1  1  0
#> SRR944285     1       0          1  1  0
#> SRR944288     1       0          1  1  0
#> SRR944287     1       0          1  1  0
#> SRR944289     1       0          1  1  0
#> SRR944290     1       0          1  1  0
#> SRR944291     1       0          1  1  0
#> SRR944292     2       0          1  0  1
#> SRR944293     1       0          1  1  0
#> SRR944294     1       0          1  1  0
#> SRR944295     2       0          1  0  1
#> SRR944296     2       0          1  0  1
#> SRR944297     2       0          1  0  1
#> SRR944298     2       0          1  0  1
#> SRR944299     1       0          1  1  0
#> SRR944300     1       0          1  1  0
#> SRR944301     1       0          1  1  0
#> SRR944302     2       0          1  0  1
#> SRR944303     2       0          1  0  1
#> SRR944304     1       0          1  1  0
#> SRR944305     1       0          1  1  0
#> SRR944306     1       0          1  1  0
#> SRR944307     1       0          1  1  0
#> SRR944308     1       0          1  1  0
#> SRR944309     1       0          1  1  0
#> SRR944310     1       0          1  1  0
#> SRR944311     2       0          1  0  1
#> SRR944312     1       0          1  1  0
#> SRR944313     1       0          1  1  0
#> SRR944315     1       0          1  1  0
#> SRR944314     1       0          1  1  0
#> SRR944316     1       0          1  1  0
#> SRR944317     2       0          1  0  1
#> SRR944318     2       0          1  0  1
#> SRR944319     2       0          1  0  1
#> SRR944320     2       0          1  0  1
#> SRR944321     1       0          1  1  0
#> SRR944322     1       0          1  1  0
#> SRR944323     1       0          1  1  0
#> SRR944324     1       0          1  1  0
#> SRR944325     1       0          1  1  0
#> SRR944326     1       0          1  1  0
#> SRR944327     1       0          1  1  0
#> SRR944328     1       0          1  1  0
#> SRR944329     1       0          1  1  0
#> SRR944330     1       0          1  1  0
#> SRR944331     1       0          1  1  0
#> SRR944332     1       0          1  1  0
#> SRR944334     1       0          1  1  0
#> SRR944333     1       0          1  1  0
#> SRR944335     1       0          1  1  0
#> SRR944336     1       0          1  1  0
#> SRR944337     1       0          1  1  0
#> SRR944338     2       0          1  0  1
#> SRR944339     2       0          1  0  1
#> SRR944340     2       0          1  0  1
#> SRR944341     2       0          1  0  1
#> SRR944342     2       0          1  0  1
#> SRR944343     2       0          1  0  1
#> SRR944344     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
#> SRR944282     1  0.0000      1.000 1.000 0.000 0.000
#> SRR944283     1  0.0000      1.000 1.000 0.000 0.000
#> SRR944284     1  0.0000      1.000 1.000 0.000 0.000
#> SRR944285     1  0.0000      1.000 1.000 0.000 0.000
#> SRR944288     1  0.0000      1.000 1.000 0.000 0.000
#> SRR944287     1  0.0000      1.000 1.000 0.000 0.000
#> SRR944289     3  0.1411      0.993 0.036 0.000 0.964
#> SRR944290     1  0.0000      1.000 1.000 0.000 0.000
#> SRR944291     1  0.0000      1.000 1.000 0.000 0.000
#> SRR944292     2  0.0592      0.983 0.000 0.988 0.012
#> SRR944293     1  0.0000      1.000 1.000 0.000 0.000
#> SRR944294     1  0.0000      1.000 1.000 0.000 0.000
#> SRR944295     2  0.1031      0.985 0.000 0.976 0.024
#> SRR944296     2  0.1031      0.985 0.000 0.976 0.024
#> SRR944297     2  0.1031      0.985 0.000 0.976 0.024
#> SRR944298     2  0.1031      0.985 0.000 0.976 0.024
#> SRR944299     1  0.0000      1.000 1.000 0.000 0.000
#> SRR944300     1  0.0000      1.000 1.000 0.000 0.000
#> SRR944301     1  0.0000      1.000 1.000 0.000 0.000
#> SRR944302     2  0.0592      0.983 0.000 0.988 0.012
#> SRR944303     2  0.1031      0.985 0.000 0.976 0.024
#> SRR944304     1  0.0000      1.000 1.000 0.000 0.000
#> SRR944305     1  0.0000      1.000 1.000 0.000 0.000
#> SRR944306     1  0.0000      1.000 1.000 0.000 0.000
#> SRR944307     1  0.0000      1.000 1.000 0.000 0.000
#> SRR944308     1  0.0000      1.000 1.000 0.000 0.000
#> SRR944309     1  0.0000      1.000 1.000 0.000 0.000
#> SRR944310     1  0.0000      1.000 1.000 0.000 0.000
#> SRR944311     2  0.1031      0.985 0.000 0.976 0.024
#> SRR944312     1  0.0000      1.000 1.000 0.000 0.000
#> SRR944313     1  0.0000      1.000 1.000 0.000 0.000
#> SRR944315     1  0.0000      1.000 1.000 0.000 0.000
#> SRR944314     1  0.0000      1.000 1.000 0.000 0.000
#> SRR944316     1  0.0000      1.000 1.000 0.000 0.000
#> SRR944317     2  0.1031      0.985 0.000 0.976 0.024
#> SRR944318     2  0.1031      0.985 0.000 0.976 0.024
#> SRR944319     2  0.1031      0.985 0.000 0.976 0.024
#> SRR944320     2  0.1031      0.985 0.000 0.976 0.024
#> SRR944321     1  0.0000      1.000 1.000 0.000 0.000
#> SRR944322     1  0.0000      1.000 1.000 0.000 0.000
#> SRR944323     1  0.0000      1.000 1.000 0.000 0.000
#> SRR944324     1  0.0000      1.000 1.000 0.000 0.000
#> SRR944325     1  0.0000      1.000 1.000 0.000 0.000
#> SRR944326     1  0.0000      1.000 1.000 0.000 0.000
#> SRR944327     1  0.0000      1.000 1.000 0.000 0.000
#> SRR944328     1  0.0000      1.000 1.000 0.000 0.000
#> SRR944329     3  0.0592      0.970 0.012 0.000 0.988
#> SRR944330     3  0.0592      0.970 0.012 0.000 0.988
#> SRR944331     3  0.1411      0.993 0.036 0.000 0.964
#> SRR944332     3  0.1411      0.993 0.036 0.000 0.964
#> SRR944334     3  0.1411      0.993 0.036 0.000 0.964
#> SRR944333     3  0.1411      0.993 0.036 0.000 0.964
#> SRR944335     3  0.1411      0.993 0.036 0.000 0.964
#> SRR944336     3  0.1411      0.993 0.036 0.000 0.964
#> SRR944337     3  0.1411      0.993 0.036 0.000 0.964
#> SRR944338     2  0.0592      0.983 0.000 0.988 0.012
#> SRR944339     2  0.0592      0.983 0.000 0.988 0.012
#> SRR944340     2  0.0592      0.983 0.000 0.988 0.012
#> SRR944341     2  0.0592      0.983 0.000 0.988 0.012
#> SRR944342     2  0.0592      0.983 0.000 0.988 0.012
#> SRR944343     2  0.0592      0.983 0.000 0.988 0.012
#> SRR944344     2  0.0592      0.983 0.000 0.988 0.012

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> SRR944282     1  0.1004      0.964 0.972 0.000 0.024 0.004
#> SRR944283     1  0.0921      0.961 0.972 0.000 0.028 0.000
#> SRR944284     1  0.0817      0.963 0.976 0.000 0.024 0.000
#> SRR944285     1  0.0921      0.963 0.972 0.000 0.028 0.000
#> SRR944288     1  0.1022      0.960 0.968 0.000 0.032 0.000
#> SRR944287     1  0.0469      0.966 0.988 0.000 0.012 0.000
#> SRR944289     4  0.0000      0.993 0.000 0.000 0.000 1.000
#> SRR944290     1  0.2214      0.957 0.928 0.000 0.028 0.044
#> SRR944291     1  0.0707      0.964 0.980 0.000 0.020 0.000
#> SRR944292     3  0.1792      0.991 0.000 0.068 0.932 0.000
#> SRR944293     1  0.1022      0.960 0.968 0.000 0.032 0.000
#> SRR944294     1  0.0921      0.961 0.972 0.000 0.028 0.000
#> SRR944295     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR944296     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR944297     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR944298     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR944299     1  0.2466      0.950 0.916 0.000 0.028 0.056
#> SRR944300     1  0.2385      0.952 0.920 0.000 0.028 0.052
#> SRR944301     1  0.1042      0.967 0.972 0.000 0.020 0.008
#> SRR944302     3  0.1867      0.988 0.000 0.072 0.928 0.000
#> SRR944303     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR944304     1  0.2124      0.958 0.932 0.000 0.028 0.040
#> SRR944305     1  0.2300      0.954 0.924 0.000 0.028 0.048
#> SRR944306     1  0.2300      0.955 0.924 0.000 0.028 0.048
#> SRR944307     1  0.2466      0.950 0.916 0.000 0.028 0.056
#> SRR944308     1  0.1406      0.966 0.960 0.000 0.024 0.016
#> SRR944309     1  0.1388      0.966 0.960 0.000 0.028 0.012
#> SRR944310     1  0.1209      0.965 0.964 0.000 0.032 0.004
#> SRR944311     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR944312     1  0.1733      0.964 0.948 0.000 0.024 0.028
#> SRR944313     1  0.1151      0.966 0.968 0.000 0.024 0.008
#> SRR944315     1  0.0657      0.966 0.984 0.000 0.012 0.004
#> SRR944314     1  0.0336      0.966 0.992 0.000 0.008 0.000
#> SRR944316     1  0.0921      0.961 0.972 0.000 0.028 0.000
#> SRR944317     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR944318     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR944319     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR944320     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR944321     1  0.1452      0.964 0.956 0.000 0.008 0.036
#> SRR944322     1  0.1452      0.964 0.956 0.000 0.008 0.036
#> SRR944323     1  0.1452      0.964 0.956 0.000 0.008 0.036
#> SRR944324     1  0.1452      0.964 0.956 0.000 0.008 0.036
#> SRR944325     1  0.1452      0.964 0.956 0.000 0.008 0.036
#> SRR944326     1  0.1452      0.964 0.956 0.000 0.008 0.036
#> SRR944327     1  0.0707      0.964 0.980 0.000 0.020 0.000
#> SRR944328     1  0.0921      0.961 0.972 0.000 0.028 0.000
#> SRR944329     4  0.0469      0.983 0.000 0.012 0.000 0.988
#> SRR944330     4  0.0469      0.983 0.000 0.012 0.000 0.988
#> SRR944331     4  0.0000      0.993 0.000 0.000 0.000 1.000
#> SRR944332     4  0.0000      0.993 0.000 0.000 0.000 1.000
#> SRR944334     4  0.0000      0.993 0.000 0.000 0.000 1.000
#> SRR944333     4  0.0000      0.993 0.000 0.000 0.000 1.000
#> SRR944335     4  0.0336      0.990 0.000 0.000 0.008 0.992
#> SRR944336     4  0.0336      0.990 0.000 0.000 0.008 0.992
#> SRR944337     4  0.0336      0.990 0.000 0.000 0.008 0.992
#> SRR944338     3  0.1637      0.997 0.000 0.060 0.940 0.000
#> SRR944339     3  0.1637      0.997 0.000 0.060 0.940 0.000
#> SRR944340     3  0.1637      0.997 0.000 0.060 0.940 0.000
#> SRR944341     3  0.1637      0.997 0.000 0.060 0.940 0.000
#> SRR944342     3  0.1637      0.997 0.000 0.060 0.940 0.000
#> SRR944343     3  0.1637      0.997 0.000 0.060 0.940 0.000
#> SRR944344     3  0.1637      0.997 0.000 0.060 0.940 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
#> SRR944282     5  0.3837      0.633 0.308 0.000 0.000 0.000 0.692
#> SRR944283     5  0.3109      0.724 0.200 0.000 0.000 0.000 0.800
#> SRR944284     5  0.2813      0.728 0.168 0.000 0.000 0.000 0.832
#> SRR944285     5  0.3480      0.699 0.248 0.000 0.000 0.000 0.752
#> SRR944288     5  0.3210      0.707 0.212 0.000 0.000 0.000 0.788
#> SRR944287     1  0.3636      0.580 0.728 0.000 0.000 0.000 0.272
#> SRR944289     4  0.0671      0.981 0.016 0.000 0.000 0.980 0.004
#> SRR944290     1  0.2189      0.746 0.904 0.000 0.000 0.012 0.084
#> SRR944291     5  0.4074      0.544 0.364 0.000 0.000 0.000 0.636
#> SRR944292     3  0.2390      0.901 0.000 0.084 0.896 0.000 0.020
#> SRR944293     5  0.1792      0.679 0.084 0.000 0.000 0.000 0.916
#> SRR944294     5  0.2471      0.698 0.136 0.000 0.000 0.000 0.864
#> SRR944295     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR944296     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR944297     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR944298     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR944299     1  0.0693      0.739 0.980 0.000 0.000 0.012 0.008
#> SRR944300     1  0.0693      0.738 0.980 0.000 0.000 0.012 0.008
#> SRR944301     1  0.3336      0.657 0.772 0.000 0.000 0.000 0.228
#> SRR944302     3  0.2707      0.854 0.000 0.132 0.860 0.000 0.008
#> SRR944303     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR944304     1  0.1205      0.726 0.956 0.000 0.000 0.004 0.040
#> SRR944305     1  0.0771      0.735 0.976 0.000 0.000 0.004 0.020
#> SRR944306     1  0.0865      0.733 0.972 0.000 0.000 0.004 0.024
#> SRR944307     1  0.0912      0.740 0.972 0.000 0.000 0.012 0.016
#> SRR944308     1  0.1908      0.708 0.908 0.000 0.000 0.000 0.092
#> SRR944309     1  0.2020      0.738 0.900 0.000 0.000 0.000 0.100
#> SRR944310     1  0.3366      0.523 0.768 0.000 0.000 0.000 0.232
#> SRR944311     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR944312     1  0.1043      0.748 0.960 0.000 0.000 0.000 0.040
#> SRR944313     1  0.2648      0.702 0.848 0.000 0.000 0.000 0.152
#> SRR944315     1  0.4307     -0.143 0.504 0.000 0.000 0.000 0.496
#> SRR944314     1  0.4278      0.063 0.548 0.000 0.000 0.000 0.452
#> SRR944316     5  0.3999      0.584 0.344 0.000 0.000 0.000 0.656
#> SRR944317     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR944318     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR944319     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR944320     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR944321     1  0.3809      0.637 0.736 0.000 0.000 0.008 0.256
#> SRR944322     1  0.3809      0.637 0.736 0.000 0.000 0.008 0.256
#> SRR944323     1  0.3809      0.637 0.736 0.000 0.000 0.008 0.256
#> SRR944324     1  0.3809      0.637 0.736 0.000 0.000 0.008 0.256
#> SRR944325     1  0.3809      0.637 0.736 0.000 0.000 0.008 0.256
#> SRR944326     1  0.3809      0.637 0.736 0.000 0.000 0.008 0.256
#> SRR944327     5  0.4300      0.193 0.476 0.000 0.000 0.000 0.524
#> SRR944328     5  0.3534      0.694 0.256 0.000 0.000 0.000 0.744
#> SRR944329     4  0.0000      0.995 0.000 0.000 0.000 1.000 0.000
#> SRR944330     4  0.0000      0.995 0.000 0.000 0.000 1.000 0.000
#> SRR944331     4  0.0000      0.995 0.000 0.000 0.000 1.000 0.000
#> SRR944332     4  0.0000      0.995 0.000 0.000 0.000 1.000 0.000
#> SRR944334     4  0.0000      0.995 0.000 0.000 0.000 1.000 0.000
#> SRR944333     4  0.0000      0.995 0.000 0.000 0.000 1.000 0.000
#> SRR944335     4  0.0324      0.992 0.004 0.000 0.000 0.992 0.004
#> SRR944336     4  0.0324      0.992 0.004 0.000 0.000 0.992 0.004
#> SRR944337     4  0.0451      0.989 0.008 0.000 0.000 0.988 0.004
#> SRR944338     3  0.0000      0.971 0.000 0.000 1.000 0.000 0.000
#> SRR944339     3  0.0000      0.971 0.000 0.000 1.000 0.000 0.000
#> SRR944340     3  0.0000      0.971 0.000 0.000 1.000 0.000 0.000
#> SRR944341     3  0.0000      0.971 0.000 0.000 1.000 0.000 0.000
#> SRR944342     3  0.0000      0.971 0.000 0.000 1.000 0.000 0.000
#> SRR944343     3  0.0000      0.971 0.000 0.000 1.000 0.000 0.000
#> SRR944344     3  0.0000      0.971 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
#> SRR944282     6  0.3900     0.3820 0.232 0.000 0.000 0.000 0.040 0.728
#> SRR944283     6  0.3854     0.3006 0.136 0.000 0.000 0.000 0.092 0.772
#> SRR944284     6  0.4008     0.0713 0.064 0.000 0.000 0.000 0.196 0.740
#> SRR944285     5  0.5371     0.6076 0.120 0.000 0.000 0.000 0.520 0.360
#> SRR944288     6  0.4142     0.1500 0.056 0.000 0.000 0.000 0.232 0.712
#> SRR944287     1  0.5861     0.0770 0.444 0.000 0.000 0.000 0.356 0.200
#> SRR944289     4  0.2519     0.9148 0.044 0.000 0.000 0.892 0.048 0.016
#> SRR944290     1  0.3423     0.6288 0.812 0.000 0.000 0.000 0.088 0.100
#> SRR944291     6  0.5788     0.2489 0.224 0.000 0.000 0.000 0.276 0.500
#> SRR944292     3  0.3784     0.7941 0.000 0.124 0.792 0.000 0.076 0.008
#> SRR944293     6  0.4300    -0.2516 0.028 0.000 0.000 0.000 0.364 0.608
#> SRR944294     5  0.4764     0.5361 0.056 0.000 0.000 0.000 0.560 0.384
#> SRR944295     2  0.0000     1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944296     2  0.0000     1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944297     2  0.0000     1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944298     2  0.0000     1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944299     1  0.1265     0.6363 0.948 0.000 0.000 0.000 0.044 0.008
#> SRR944300     1  0.1152     0.6386 0.952 0.000 0.000 0.000 0.044 0.004
#> SRR944301     1  0.5172     0.4089 0.592 0.000 0.000 0.000 0.124 0.284
#> SRR944302     3  0.3279     0.7727 0.000 0.176 0.796 0.000 0.028 0.000
#> SRR944303     2  0.0000     1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944304     1  0.3134     0.5596 0.820 0.000 0.000 0.000 0.144 0.036
#> SRR944305     1  0.1858     0.6236 0.912 0.000 0.000 0.000 0.076 0.012
#> SRR944306     1  0.1913     0.6206 0.908 0.000 0.000 0.000 0.080 0.012
#> SRR944307     1  0.0972     0.6412 0.964 0.000 0.000 0.000 0.028 0.008
#> SRR944308     1  0.4781     0.4896 0.672 0.000 0.000 0.000 0.188 0.140
#> SRR944309     1  0.3821     0.6063 0.772 0.000 0.000 0.000 0.080 0.148
#> SRR944310     1  0.5926     0.0710 0.464 0.000 0.000 0.000 0.276 0.260
#> SRR944311     2  0.0000     1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944312     1  0.1970     0.6471 0.912 0.000 0.000 0.000 0.028 0.060
#> SRR944313     1  0.4984     0.4594 0.632 0.000 0.000 0.000 0.124 0.244
#> SRR944315     6  0.4972     0.2876 0.352 0.000 0.000 0.000 0.080 0.568
#> SRR944314     1  0.5992    -0.0602 0.412 0.000 0.000 0.000 0.236 0.352
#> SRR944316     5  0.5239     0.5336 0.152 0.000 0.000 0.000 0.600 0.248
#> SRR944317     2  0.0000     1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944318     2  0.0000     1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944319     2  0.0000     1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944320     2  0.0000     1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944321     1  0.4516     0.5367 0.668 0.000 0.000 0.000 0.072 0.260
#> SRR944322     1  0.4516     0.5367 0.668 0.000 0.000 0.000 0.072 0.260
#> SRR944323     1  0.4516     0.5367 0.668 0.000 0.000 0.000 0.072 0.260
#> SRR944324     1  0.4516     0.5367 0.668 0.000 0.000 0.000 0.072 0.260
#> SRR944325     1  0.4516     0.5367 0.668 0.000 0.000 0.000 0.072 0.260
#> SRR944326     1  0.4516     0.5367 0.668 0.000 0.000 0.000 0.072 0.260
#> SRR944327     6  0.5995     0.1901 0.304 0.000 0.000 0.000 0.260 0.436
#> SRR944328     6  0.5555    -0.1341 0.140 0.000 0.000 0.000 0.380 0.480
#> SRR944329     4  0.0000     0.9613 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR944330     4  0.0000     0.9613 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR944331     4  0.0000     0.9613 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR944332     4  0.0000     0.9613 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR944334     4  0.0000     0.9613 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR944333     4  0.0000     0.9613 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR944335     4  0.2051     0.9377 0.036 0.000 0.000 0.916 0.040 0.008
#> SRR944336     4  0.2051     0.9377 0.036 0.000 0.000 0.916 0.040 0.008
#> SRR944337     4  0.2051     0.9377 0.036 0.000 0.000 0.916 0.040 0.008
#> SRR944338     3  0.0000     0.9465 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR944339     3  0.0000     0.9465 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR944340     3  0.0000     0.9465 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR944341     3  0.0000     0.9465 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR944342     3  0.0000     0.9465 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR944343     3  0.0000     0.9465 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR944344     3  0.0000     0.9465 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 12673 rows and 62 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#>   Subgroups are detected by 'pam' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 4.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk SD-pam-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.982       0.993        0.28455 0.725   0.725
#> 3 3 1.000           1.000       1.000        0.55427 0.833   0.770
#> 4 4 0.927           0.877       0.955        0.51175 0.768   0.590
#> 5 5 0.906           0.844       0.942        0.00716 0.997   0.991
#> 6 6 0.870           0.802       0.931        0.00971 0.970   0.915

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> SRR944282     1   0.000      0.992 1.000 0.000
#> SRR944283     1   0.000      0.992 1.000 0.000
#> SRR944284     1   0.000      0.992 1.000 0.000
#> SRR944285     1   0.000      0.992 1.000 0.000
#> SRR944288     1   0.000      0.992 1.000 0.000
#> SRR944287     1   0.000      0.992 1.000 0.000
#> SRR944289     1   0.000      0.992 1.000 0.000
#> SRR944290     1   0.000      0.992 1.000 0.000
#> SRR944291     1   0.000      0.992 1.000 0.000
#> SRR944292     1   0.000      0.992 1.000 0.000
#> SRR944293     1   0.000      0.992 1.000 0.000
#> SRR944294     1   0.000      0.992 1.000 0.000
#> SRR944295     2   0.000      1.000 0.000 1.000
#> SRR944296     2   0.000      1.000 0.000 1.000
#> SRR944297     2   0.000      1.000 0.000 1.000
#> SRR944298     2   0.000      1.000 0.000 1.000
#> SRR944299     1   0.000      0.992 1.000 0.000
#> SRR944300     1   0.000      0.992 1.000 0.000
#> SRR944301     1   0.000      0.992 1.000 0.000
#> SRR944302     1   0.000      0.992 1.000 0.000
#> SRR944303     2   0.000      1.000 0.000 1.000
#> SRR944304     1   0.000      0.992 1.000 0.000
#> SRR944305     1   0.000      0.992 1.000 0.000
#> SRR944306     1   0.000      0.992 1.000 0.000
#> SRR944307     1   0.000      0.992 1.000 0.000
#> SRR944308     1   0.000      0.992 1.000 0.000
#> SRR944309     1   0.000      0.992 1.000 0.000
#> SRR944310     1   0.000      0.992 1.000 0.000
#> SRR944311     2   0.000      1.000 0.000 1.000
#> SRR944312     1   0.000      0.992 1.000 0.000
#> SRR944313     1   0.000      0.992 1.000 0.000
#> SRR944315     1   0.000      0.992 1.000 0.000
#> SRR944314     1   0.000      0.992 1.000 0.000
#> SRR944316     1   0.000      0.992 1.000 0.000
#> SRR944317     2   0.000      1.000 0.000 1.000
#> SRR944318     2   0.000      1.000 0.000 1.000
#> SRR944319     2   0.000      1.000 0.000 1.000
#> SRR944320     2   0.000      1.000 0.000 1.000
#> SRR944321     1   0.000      0.992 1.000 0.000
#> SRR944322     1   0.000      0.992 1.000 0.000
#> SRR944323     1   0.000      0.992 1.000 0.000
#> SRR944324     1   0.000      0.992 1.000 0.000
#> SRR944325     1   0.000      0.992 1.000 0.000
#> SRR944326     1   0.000      0.992 1.000 0.000
#> SRR944327     1   0.000      0.992 1.000 0.000
#> SRR944328     1   0.000      0.992 1.000 0.000
#> SRR944329     1   0.000      0.992 1.000 0.000
#> SRR944330     1   0.000      0.992 1.000 0.000
#> SRR944331     1   0.000      0.992 1.000 0.000
#> SRR944332     1   0.000      0.992 1.000 0.000
#> SRR944334     1   0.000      0.992 1.000 0.000
#> SRR944333     1   0.000      0.992 1.000 0.000
#> SRR944335     1   0.000      0.992 1.000 0.000
#> SRR944336     1   0.000      0.992 1.000 0.000
#> SRR944337     1   0.000      0.992 1.000 0.000
#> SRR944338     1   0.000      0.992 1.000 0.000
#> SRR944339     1   0.000      0.992 1.000 0.000
#> SRR944340     1   0.000      0.992 1.000 0.000
#> SRR944341     1   0.000      0.992 1.000 0.000
#> SRR944342     1   0.000      0.992 1.000 0.000
#> SRR944343     1   0.000      0.992 1.000 0.000
#> SRR944344     1   0.975      0.311 0.592 0.408

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1 p2    p3
#> SRR944282     1  0.0000      1.000 1.000  0 0.000
#> SRR944283     1  0.0000      1.000 1.000  0 0.000
#> SRR944284     1  0.0000      1.000 1.000  0 0.000
#> SRR944285     1  0.0000      1.000 1.000  0 0.000
#> SRR944288     1  0.0000      1.000 1.000  0 0.000
#> SRR944287     1  0.0000      1.000 1.000  0 0.000
#> SRR944289     1  0.0000      1.000 1.000  0 0.000
#> SRR944290     1  0.0000      1.000 1.000  0 0.000
#> SRR944291     1  0.0000      1.000 1.000  0 0.000
#> SRR944292     1  0.0000      1.000 1.000  0 0.000
#> SRR944293     1  0.0000      1.000 1.000  0 0.000
#> SRR944294     1  0.0000      1.000 1.000  0 0.000
#> SRR944295     2  0.0000      1.000 0.000  1 0.000
#> SRR944296     2  0.0000      1.000 0.000  1 0.000
#> SRR944297     2  0.0000      1.000 0.000  1 0.000
#> SRR944298     2  0.0000      1.000 0.000  1 0.000
#> SRR944299     1  0.0000      1.000 1.000  0 0.000
#> SRR944300     1  0.0000      1.000 1.000  0 0.000
#> SRR944301     1  0.0000      1.000 1.000  0 0.000
#> SRR944302     1  0.0424      0.992 0.992  0 0.008
#> SRR944303     2  0.0000      1.000 0.000  1 0.000
#> SRR944304     1  0.0000      1.000 1.000  0 0.000
#> SRR944305     1  0.0000      1.000 1.000  0 0.000
#> SRR944306     1  0.0000      1.000 1.000  0 0.000
#> SRR944307     1  0.0000      1.000 1.000  0 0.000
#> SRR944308     1  0.0000      1.000 1.000  0 0.000
#> SRR944309     1  0.0000      1.000 1.000  0 0.000
#> SRR944310     1  0.0000      1.000 1.000  0 0.000
#> SRR944311     2  0.0000      1.000 0.000  1 0.000
#> SRR944312     1  0.0000      1.000 1.000  0 0.000
#> SRR944313     1  0.0000      1.000 1.000  0 0.000
#> SRR944315     1  0.0000      1.000 1.000  0 0.000
#> SRR944314     1  0.0000      1.000 1.000  0 0.000
#> SRR944316     1  0.0000      1.000 1.000  0 0.000
#> SRR944317     2  0.0000      1.000 0.000  1 0.000
#> SRR944318     2  0.0000      1.000 0.000  1 0.000
#> SRR944319     2  0.0000      1.000 0.000  1 0.000
#> SRR944320     2  0.0000      1.000 0.000  1 0.000
#> SRR944321     1  0.0000      1.000 1.000  0 0.000
#> SRR944322     1  0.0000      1.000 1.000  0 0.000
#> SRR944323     1  0.0000      1.000 1.000  0 0.000
#> SRR944324     1  0.0000      1.000 1.000  0 0.000
#> SRR944325     1  0.0000      1.000 1.000  0 0.000
#> SRR944326     1  0.0000      1.000 1.000  0 0.000
#> SRR944327     1  0.0000      1.000 1.000  0 0.000
#> SRR944328     1  0.0000      1.000 1.000  0 0.000
#> SRR944329     1  0.0000      1.000 1.000  0 0.000
#> SRR944330     1  0.0000      1.000 1.000  0 0.000
#> SRR944331     1  0.0000      1.000 1.000  0 0.000
#> SRR944332     1  0.0000      1.000 1.000  0 0.000
#> SRR944334     1  0.0000      1.000 1.000  0 0.000
#> SRR944333     1  0.0000      1.000 1.000  0 0.000
#> SRR944335     1  0.0000      1.000 1.000  0 0.000
#> SRR944336     1  0.0000      1.000 1.000  0 0.000
#> SRR944337     1  0.0000      1.000 1.000  0 0.000
#> SRR944338     3  0.0000      1.000 0.000  0 1.000
#> SRR944339     3  0.0000      1.000 0.000  0 1.000
#> SRR944340     3  0.0000      1.000 0.000  0 1.000
#> SRR944341     3  0.0000      1.000 0.000  0 1.000
#> SRR944342     3  0.0000      1.000 0.000  0 1.000
#> SRR944343     3  0.0000      1.000 0.000  0 1.000
#> SRR944344     3  0.0000      1.000 0.000  0 1.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1  p2    p3    p4
#> SRR944282     1  0.0000      0.936 1.000 0.0 0.000 0.000
#> SRR944283     1  0.0000      0.936 1.000 0.0 0.000 0.000
#> SRR944284     1  0.0000      0.936 1.000 0.0 0.000 0.000
#> SRR944285     1  0.0000      0.936 1.000 0.0 0.000 0.000
#> SRR944288     1  0.0000      0.936 1.000 0.0 0.000 0.000
#> SRR944287     1  0.0000      0.936 1.000 0.0 0.000 0.000
#> SRR944289     4  0.0000      0.907 0.000 0.0 0.000 1.000
#> SRR944290     1  0.4830      0.373 0.608 0.0 0.000 0.392
#> SRR944291     1  0.0000      0.936 1.000 0.0 0.000 0.000
#> SRR944292     4  0.0188      0.904 0.004 0.0 0.000 0.996
#> SRR944293     4  0.5000     -0.106 0.496 0.0 0.000 0.504
#> SRR944294     1  0.0336      0.930 0.992 0.0 0.000 0.008
#> SRR944295     2  0.0000      1.000 0.000 1.0 0.000 0.000
#> SRR944296     2  0.0000      1.000 0.000 1.0 0.000 0.000
#> SRR944297     2  0.0000      1.000 0.000 1.0 0.000 0.000
#> SRR944298     2  0.0000      1.000 0.000 1.0 0.000 0.000
#> SRR944299     1  0.4790      0.400 0.620 0.0 0.000 0.380
#> SRR944300     1  0.0336      0.930 0.992 0.0 0.000 0.008
#> SRR944301     1  0.0000      0.936 1.000 0.0 0.000 0.000
#> SRR944302     4  0.0188      0.904 0.000 0.0 0.004 0.996
#> SRR944303     2  0.0000      1.000 0.000 1.0 0.000 0.000
#> SRR944304     1  0.4981      0.160 0.536 0.0 0.000 0.464
#> SRR944305     1  0.0000      0.936 1.000 0.0 0.000 0.000
#> SRR944306     1  0.4855      0.351 0.600 0.0 0.000 0.400
#> SRR944307     1  0.0000      0.936 1.000 0.0 0.000 0.000
#> SRR944308     1  0.0707      0.921 0.980 0.0 0.000 0.020
#> SRR944309     1  0.0000      0.936 1.000 0.0 0.000 0.000
#> SRR944310     1  0.3123      0.786 0.844 0.0 0.000 0.156
#> SRR944311     2  0.0000      1.000 0.000 1.0 0.000 0.000
#> SRR944312     1  0.0000      0.936 1.000 0.0 0.000 0.000
#> SRR944313     1  0.0000      0.936 1.000 0.0 0.000 0.000
#> SRR944315     1  0.0000      0.936 1.000 0.0 0.000 0.000
#> SRR944314     1  0.0000      0.936 1.000 0.0 0.000 0.000
#> SRR944316     1  0.0000      0.936 1.000 0.0 0.000 0.000
#> SRR944317     2  0.0000      1.000 0.000 1.0 0.000 0.000
#> SRR944318     2  0.0000      1.000 0.000 1.0 0.000 0.000
#> SRR944319     4  0.4855      0.342 0.000 0.4 0.000 0.600
#> SRR944320     2  0.0000      1.000 0.000 1.0 0.000 0.000
#> SRR944321     1  0.0000      0.936 1.000 0.0 0.000 0.000
#> SRR944322     1  0.0000      0.936 1.000 0.0 0.000 0.000
#> SRR944323     1  0.0000      0.936 1.000 0.0 0.000 0.000
#> SRR944324     1  0.0000      0.936 1.000 0.0 0.000 0.000
#> SRR944325     1  0.0000      0.936 1.000 0.0 0.000 0.000
#> SRR944326     1  0.0000      0.936 1.000 0.0 0.000 0.000
#> SRR944327     1  0.0000      0.936 1.000 0.0 0.000 0.000
#> SRR944328     1  0.0000      0.936 1.000 0.0 0.000 0.000
#> SRR944329     4  0.0000      0.907 0.000 0.0 0.000 1.000
#> SRR944330     4  0.0000      0.907 0.000 0.0 0.000 1.000
#> SRR944331     4  0.0000      0.907 0.000 0.0 0.000 1.000
#> SRR944332     4  0.0000      0.907 0.000 0.0 0.000 1.000
#> SRR944334     4  0.0000      0.907 0.000 0.0 0.000 1.000
#> SRR944333     4  0.0000      0.907 0.000 0.0 0.000 1.000
#> SRR944335     4  0.0000      0.907 0.000 0.0 0.000 1.000
#> SRR944336     4  0.0000      0.907 0.000 0.0 0.000 1.000
#> SRR944337     4  0.1118      0.870 0.036 0.0 0.000 0.964
#> SRR944338     3  0.0000      1.000 0.000 0.0 1.000 0.000
#> SRR944339     3  0.0000      1.000 0.000 0.0 1.000 0.000
#> SRR944340     3  0.0000      1.000 0.000 0.0 1.000 0.000
#> SRR944341     3  0.0000      1.000 0.000 0.0 1.000 0.000
#> SRR944342     3  0.0000      1.000 0.000 0.0 1.000 0.000
#> SRR944343     3  0.0000      1.000 0.000 0.0 1.000 0.000
#> SRR944344     3  0.0000      1.000 0.000 0.0 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> SRR944282     1  0.0000     0.9282 1.000 0.000 0.000 0.000 0.000
#> SRR944283     1  0.0000     0.9282 1.000 0.000 0.000 0.000 0.000
#> SRR944284     1  0.0290     0.9260 0.992 0.000 0.000 0.000 0.008
#> SRR944285     1  0.0162     0.9273 0.996 0.000 0.000 0.000 0.004
#> SRR944288     1  0.0290     0.9260 0.992 0.000 0.000 0.000 0.008
#> SRR944287     1  0.0000     0.9282 1.000 0.000 0.000 0.000 0.000
#> SRR944289     4  0.0290     0.8657 0.000 0.000 0.000 0.992 0.008
#> SRR944290     1  0.4403     0.3754 0.608 0.000 0.000 0.384 0.008
#> SRR944291     1  0.0290     0.9260 0.992 0.000 0.000 0.000 0.008
#> SRR944292     4  0.0451     0.8627 0.004 0.000 0.000 0.988 0.008
#> SRR944293     4  0.4562    -0.0926 0.492 0.000 0.000 0.500 0.008
#> SRR944294     1  0.0579     0.9217 0.984 0.000 0.000 0.008 0.008
#> SRR944295     2  0.0000     0.9950 0.000 1.000 0.000 0.000 0.000
#> SRR944296     2  0.0000     0.9950 0.000 1.000 0.000 0.000 0.000
#> SRR944297     2  0.0000     0.9950 0.000 1.000 0.000 0.000 0.000
#> SRR944298     2  0.0000     0.9950 0.000 1.000 0.000 0.000 0.000
#> SRR944299     1  0.4380     0.3927 0.616 0.000 0.000 0.376 0.008
#> SRR944300     1  0.0579     0.9217 0.984 0.000 0.000 0.008 0.008
#> SRR944301     1  0.0000     0.9282 1.000 0.000 0.000 0.000 0.000
#> SRR944302     4  0.3816     0.6063 0.000 0.000 0.000 0.696 0.304
#> SRR944303     2  0.0000     0.9950 0.000 1.000 0.000 0.000 0.000
#> SRR944304     1  0.4546     0.1483 0.532 0.000 0.000 0.460 0.008
#> SRR944305     1  0.0290     0.9260 0.992 0.000 0.000 0.000 0.008
#> SRR944306     1  0.4436     0.3434 0.596 0.000 0.000 0.396 0.008
#> SRR944307     1  0.0162     0.9273 0.996 0.000 0.000 0.000 0.004
#> SRR944308     1  0.0898     0.9124 0.972 0.000 0.000 0.020 0.008
#> SRR944309     1  0.0000     0.9282 1.000 0.000 0.000 0.000 0.000
#> SRR944310     1  0.2971     0.7771 0.836 0.000 0.000 0.156 0.008
#> SRR944311     2  0.0000     0.9950 0.000 1.000 0.000 0.000 0.000
#> SRR944312     1  0.0000     0.9282 1.000 0.000 0.000 0.000 0.000
#> SRR944313     1  0.0000     0.9282 1.000 0.000 0.000 0.000 0.000
#> SRR944315     1  0.0000     0.9282 1.000 0.000 0.000 0.000 0.000
#> SRR944314     1  0.0000     0.9282 1.000 0.000 0.000 0.000 0.000
#> SRR944316     1  0.0290     0.9260 0.992 0.000 0.000 0.000 0.008
#> SRR944317     2  0.0000     0.9950 0.000 1.000 0.000 0.000 0.000
#> SRR944318     2  0.0000     0.9950 0.000 1.000 0.000 0.000 0.000
#> SRR944319     4  0.4171     0.3701 0.000 0.396 0.000 0.604 0.000
#> SRR944320     2  0.1121     0.9588 0.000 0.956 0.000 0.000 0.044
#> SRR944321     1  0.0000     0.9282 1.000 0.000 0.000 0.000 0.000
#> SRR944322     1  0.0000     0.9282 1.000 0.000 0.000 0.000 0.000
#> SRR944323     1  0.0000     0.9282 1.000 0.000 0.000 0.000 0.000
#> SRR944324     1  0.0000     0.9282 1.000 0.000 0.000 0.000 0.000
#> SRR944325     1  0.0000     0.9282 1.000 0.000 0.000 0.000 0.000
#> SRR944326     1  0.0000     0.9282 1.000 0.000 0.000 0.000 0.000
#> SRR944327     1  0.0000     0.9282 1.000 0.000 0.000 0.000 0.000
#> SRR944328     1  0.0000     0.9282 1.000 0.000 0.000 0.000 0.000
#> SRR944329     4  0.0000     0.8674 0.000 0.000 0.000 1.000 0.000
#> SRR944330     4  0.0000     0.8674 0.000 0.000 0.000 1.000 0.000
#> SRR944331     4  0.0000     0.8674 0.000 0.000 0.000 1.000 0.000
#> SRR944332     4  0.0000     0.8674 0.000 0.000 0.000 1.000 0.000
#> SRR944334     4  0.0000     0.8674 0.000 0.000 0.000 1.000 0.000
#> SRR944333     4  0.0000     0.8674 0.000 0.000 0.000 1.000 0.000
#> SRR944335     4  0.0290     0.8657 0.000 0.000 0.000 0.992 0.008
#> SRR944336     4  0.0290     0.8657 0.000 0.000 0.000 0.992 0.008
#> SRR944337     4  0.1251     0.8298 0.036 0.000 0.000 0.956 0.008
#> SRR944338     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000
#> SRR944339     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000
#> SRR944340     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000
#> SRR944341     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000
#> SRR944342     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000
#> SRR944343     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000
#> SRR944344     5  0.4074     0.0000 0.000 0.000 0.364 0.000 0.636

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR944282     1  0.0000     0.9091 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944283     1  0.0000     0.9091 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944284     1  0.0547     0.9044 0.980 0.000 0.000 0.000 0.020 0.000
#> SRR944285     1  0.0458     0.9058 0.984 0.000 0.000 0.000 0.016 0.000
#> SRR944288     1  0.0458     0.9059 0.984 0.000 0.000 0.000 0.016 0.000
#> SRR944287     1  0.0000     0.9091 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944289     4  0.0547     0.8428 0.000 0.000 0.000 0.980 0.020 0.000
#> SRR944290     1  0.4178     0.3889 0.608 0.000 0.000 0.372 0.020 0.000
#> SRR944291     1  0.0547     0.9044 0.980 0.000 0.000 0.000 0.020 0.000
#> SRR944292     4  0.4475     0.2791 0.000 0.000 0.000 0.700 0.100 0.200
#> SRR944293     1  0.4338     0.0711 0.492 0.000 0.000 0.488 0.020 0.000
#> SRR944294     1  0.0806     0.9007 0.972 0.000 0.000 0.008 0.020 0.000
#> SRR944295     2  0.0000     0.9660 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944296     2  0.0000     0.9660 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944297     2  0.0000     0.9660 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944298     2  0.0000     0.9660 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944299     1  0.4155     0.4040 0.616 0.000 0.000 0.364 0.020 0.000
#> SRR944300     1  0.0692     0.9028 0.976 0.000 0.000 0.004 0.020 0.000
#> SRR944301     1  0.0000     0.9091 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944302     5  0.3695     0.0000 0.000 0.000 0.000 0.376 0.624 0.000
#> SRR944303     2  0.0000     0.9660 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944304     1  0.4318     0.1957 0.532 0.000 0.000 0.448 0.020 0.000
#> SRR944305     1  0.0547     0.9044 0.980 0.000 0.000 0.000 0.020 0.000
#> SRR944306     1  0.4209     0.3605 0.596 0.000 0.000 0.384 0.020 0.000
#> SRR944307     1  0.0458     0.9058 0.984 0.000 0.000 0.000 0.016 0.000
#> SRR944308     1  0.1092     0.8924 0.960 0.000 0.000 0.020 0.020 0.000
#> SRR944309     1  0.0000     0.9091 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944310     1  0.2869     0.7648 0.832 0.000 0.000 0.148 0.020 0.000
#> SRR944311     2  0.0000     0.9660 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944312     1  0.0000     0.9091 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944313     1  0.0000     0.9091 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944315     1  0.0000     0.9091 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944314     1  0.0000     0.9091 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944316     1  0.0547     0.9044 0.980 0.000 0.000 0.000 0.020 0.000
#> SRR944317     2  0.0260     0.9585 0.000 0.992 0.000 0.008 0.000 0.000
#> SRR944318     2  0.0000     0.9660 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944319     4  0.3747    -0.0379 0.000 0.396 0.000 0.604 0.000 0.000
#> SRR944320     2  0.3764     0.6813 0.000 0.724 0.000 0.008 0.256 0.012
#> SRR944321     1  0.0000     0.9091 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944322     1  0.0000     0.9091 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944323     1  0.0000     0.9091 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944324     1  0.0000     0.9091 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944325     1  0.0000     0.9091 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944326     1  0.0000     0.9091 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944327     1  0.0000     0.9091 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944328     1  0.0000     0.9091 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944329     4  0.0000     0.8540 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR944330     4  0.0000     0.8540 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR944331     4  0.0000     0.8540 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR944332     4  0.0000     0.8540 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR944334     4  0.0000     0.8540 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR944333     4  0.0000     0.8540 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR944335     4  0.0547     0.8428 0.000 0.000 0.000 0.980 0.020 0.000
#> SRR944336     4  0.0547     0.8428 0.000 0.000 0.000 0.980 0.020 0.000
#> SRR944337     4  0.1408     0.7676 0.036 0.000 0.000 0.944 0.020 0.000
#> SRR944338     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR944339     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR944340     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR944341     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR944342     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR944343     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR944344     6  0.2883     0.0000 0.000 0.000 0.212 0.000 0.000 0.788

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 12673 rows and 62 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           0.970       0.988          0.422 0.568   0.568
#> 3 3 0.587           0.795       0.829          0.360 0.800   0.670
#> 4 4 0.846           0.902       0.945          0.184 0.786   0.571
#> 5 5 0.783           0.835       0.854          0.061 0.954   0.864
#> 6 6 0.760           0.587       0.745          0.110 0.889   0.649

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
#> SRR944282     1   0.000      1.000 1.000 0.000
#> SRR944283     1   0.000      1.000 1.000 0.000
#> SRR944284     1   0.000      1.000 1.000 0.000
#> SRR944285     1   0.000      1.000 1.000 0.000
#> SRR944288     1   0.000      1.000 1.000 0.000
#> SRR944287     1   0.000      1.000 1.000 0.000
#> SRR944289     1   0.000      1.000 1.000 0.000
#> SRR944290     1   0.000      1.000 1.000 0.000
#> SRR944291     1   0.000      1.000 1.000 0.000
#> SRR944292     2   0.981      0.311 0.420 0.580
#> SRR944293     1   0.000      1.000 1.000 0.000
#> SRR944294     1   0.000      1.000 1.000 0.000
#> SRR944295     2   0.000      0.958 0.000 1.000
#> SRR944296     2   0.000      0.958 0.000 1.000
#> SRR944297     2   0.000      0.958 0.000 1.000
#> SRR944298     2   0.000      0.958 0.000 1.000
#> SRR944299     1   0.000      1.000 1.000 0.000
#> SRR944300     1   0.000      1.000 1.000 0.000
#> SRR944301     1   0.000      1.000 1.000 0.000
#> SRR944302     2   0.909      0.538 0.324 0.676
#> SRR944303     2   0.000      0.958 0.000 1.000
#> SRR944304     1   0.000      1.000 1.000 0.000
#> SRR944305     1   0.000      1.000 1.000 0.000
#> SRR944306     1   0.000      1.000 1.000 0.000
#> SRR944307     1   0.000      1.000 1.000 0.000
#> SRR944308     1   0.000      1.000 1.000 0.000
#> SRR944309     1   0.000      1.000 1.000 0.000
#> SRR944310     1   0.000      1.000 1.000 0.000
#> SRR944311     2   0.000      0.958 0.000 1.000
#> SRR944312     1   0.000      1.000 1.000 0.000
#> SRR944313     1   0.000      1.000 1.000 0.000
#> SRR944315     1   0.000      1.000 1.000 0.000
#> SRR944314     1   0.000      1.000 1.000 0.000
#> SRR944316     1   0.000      1.000 1.000 0.000
#> SRR944317     2   0.000      0.958 0.000 1.000
#> SRR944318     2   0.000      0.958 0.000 1.000
#> SRR944319     2   0.000      0.958 0.000 1.000
#> SRR944320     2   0.000      0.958 0.000 1.000
#> SRR944321     1   0.000      1.000 1.000 0.000
#> SRR944322     1   0.000      1.000 1.000 0.000
#> SRR944323     1   0.000      1.000 1.000 0.000
#> SRR944324     1   0.000      1.000 1.000 0.000
#> SRR944325     1   0.000      1.000 1.000 0.000
#> SRR944326     1   0.000      1.000 1.000 0.000
#> SRR944327     1   0.000      1.000 1.000 0.000
#> SRR944328     1   0.000      1.000 1.000 0.000
#> SRR944329     1   0.000      1.000 1.000 0.000
#> SRR944330     1   0.000      1.000 1.000 0.000
#> SRR944331     1   0.000      1.000 1.000 0.000
#> SRR944332     1   0.000      1.000 1.000 0.000
#> SRR944334     1   0.000      1.000 1.000 0.000
#> SRR944333     1   0.000      1.000 1.000 0.000
#> SRR944335     1   0.000      1.000 1.000 0.000
#> SRR944336     1   0.000      1.000 1.000 0.000
#> SRR944337     1   0.000      1.000 1.000 0.000
#> SRR944338     2   0.000      0.958 0.000 1.000
#> SRR944339     2   0.000      0.958 0.000 1.000
#> SRR944340     2   0.000      0.958 0.000 1.000
#> SRR944341     2   0.000      0.958 0.000 1.000
#> SRR944342     2   0.000      0.958 0.000 1.000
#> SRR944343     2   0.000      0.958 0.000 1.000
#> SRR944344     2   0.000      0.958 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
#> SRR944282     1  0.0747      0.904 0.984 0.000 0.016
#> SRR944283     1  0.0747      0.904 0.984 0.000 0.016
#> SRR944284     1  0.0747      0.904 0.984 0.000 0.016
#> SRR944285     1  0.1163      0.903 0.972 0.000 0.028
#> SRR944288     1  0.0747      0.904 0.984 0.000 0.016
#> SRR944287     1  0.3340      0.886 0.880 0.000 0.120
#> SRR944289     1  0.5723      0.710 0.744 0.016 0.240
#> SRR944290     1  0.1163      0.898 0.972 0.000 0.028
#> SRR944291     1  0.0747      0.904 0.984 0.000 0.016
#> SRR944292     2  0.8332      0.277 0.316 0.580 0.104
#> SRR944293     1  0.0747      0.904 0.984 0.000 0.016
#> SRR944294     1  0.0747      0.904 0.984 0.000 0.016
#> SRR944295     2  0.0000      0.626 0.000 1.000 0.000
#> SRR944296     2  0.0000      0.626 0.000 1.000 0.000
#> SRR944297     2  0.0000      0.626 0.000 1.000 0.000
#> SRR944298     2  0.0000      0.626 0.000 1.000 0.000
#> SRR944299     1  0.4750      0.831 0.784 0.000 0.216
#> SRR944300     1  0.4399      0.863 0.812 0.000 0.188
#> SRR944301     1  0.0592      0.904 0.988 0.000 0.012
#> SRR944302     2  0.8409      0.273 0.308 0.580 0.112
#> SRR944303     2  0.0000      0.626 0.000 1.000 0.000
#> SRR944304     1  0.3412      0.890 0.876 0.000 0.124
#> SRR944305     1  0.2356      0.903 0.928 0.000 0.072
#> SRR944306     1  0.1411      0.900 0.964 0.000 0.036
#> SRR944307     1  0.5363      0.796 0.724 0.000 0.276
#> SRR944308     1  0.3686      0.890 0.860 0.000 0.140
#> SRR944309     1  0.0000      0.903 1.000 0.000 0.000
#> SRR944310     1  0.3340      0.886 0.880 0.000 0.120
#> SRR944311     2  0.0000      0.626 0.000 1.000 0.000
#> SRR944312     1  0.1031      0.899 0.976 0.000 0.024
#> SRR944313     1  0.0592      0.904 0.988 0.000 0.012
#> SRR944315     1  0.0747      0.904 0.984 0.000 0.016
#> SRR944314     1  0.3482      0.890 0.872 0.000 0.128
#> SRR944316     1  0.3116      0.889 0.892 0.000 0.108
#> SRR944317     2  0.0000      0.626 0.000 1.000 0.000
#> SRR944318     2  0.0000      0.626 0.000 1.000 0.000
#> SRR944319     2  0.0000      0.626 0.000 1.000 0.000
#> SRR944320     2  0.0000      0.626 0.000 1.000 0.000
#> SRR944321     1  0.3192      0.889 0.888 0.000 0.112
#> SRR944322     1  0.3192      0.889 0.888 0.000 0.112
#> SRR944323     1  0.3192      0.889 0.888 0.000 0.112
#> SRR944324     1  0.2959      0.889 0.900 0.000 0.100
#> SRR944325     1  0.2959      0.889 0.900 0.000 0.100
#> SRR944326     1  0.2959      0.889 0.900 0.000 0.100
#> SRR944327     1  0.1267      0.899 0.972 0.004 0.024
#> SRR944328     1  0.5486      0.701 0.780 0.196 0.024
#> SRR944329     2  0.8845      0.574 0.184 0.576 0.240
#> SRR944330     2  0.8845      0.574 0.184 0.576 0.240
#> SRR944331     2  0.8886      0.572 0.188 0.572 0.240
#> SRR944332     2  0.8886      0.572 0.188 0.572 0.240
#> SRR944334     2  0.8926      0.568 0.192 0.568 0.240
#> SRR944333     2  0.8845      0.574 0.184 0.576 0.240
#> SRR944335     1  0.5723      0.710 0.744 0.016 0.240
#> SRR944336     1  0.5723      0.710 0.744 0.016 0.240
#> SRR944337     1  0.5681      0.715 0.748 0.016 0.236
#> SRR944338     3  0.5926      1.000 0.000 0.356 0.644
#> SRR944339     3  0.5926      1.000 0.000 0.356 0.644
#> SRR944340     3  0.5926      1.000 0.000 0.356 0.644
#> SRR944341     3  0.5926      1.000 0.000 0.356 0.644
#> SRR944342     3  0.5926      1.000 0.000 0.356 0.644
#> SRR944343     3  0.5926      1.000 0.000 0.356 0.644
#> SRR944344     3  0.5926      1.000 0.000 0.356 0.644

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2 p3    p4
#> SRR944282     1  0.0817      0.905 0.976 0.000  0 0.024
#> SRR944283     1  0.0707      0.905 0.980 0.000  0 0.020
#> SRR944284     1  0.0921      0.905 0.972 0.000  0 0.028
#> SRR944285     1  0.0817      0.905 0.976 0.000  0 0.024
#> SRR944288     1  0.0817      0.905 0.976 0.000  0 0.024
#> SRR944287     1  0.0000      0.901 1.000 0.000  0 0.000
#> SRR944289     4  0.0592      0.968 0.016 0.000  0 0.984
#> SRR944290     1  0.2647      0.862 0.880 0.000  0 0.120
#> SRR944291     1  0.0817      0.905 0.976 0.000  0 0.024
#> SRR944292     1  0.2973      0.803 0.856 0.144  0 0.000
#> SRR944293     1  0.0817      0.905 0.976 0.000  0 0.024
#> SRR944294     1  0.0817      0.905 0.976 0.000  0 0.024
#> SRR944295     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR944296     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR944297     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR944298     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR944299     4  0.2281      0.902 0.096 0.000  0 0.904
#> SRR944300     4  0.2408      0.892 0.104 0.000  0 0.896
#> SRR944301     1  0.0817      0.905 0.976 0.000  0 0.024
#> SRR944302     1  0.3024      0.799 0.852 0.148  0 0.000
#> SRR944303     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR944304     1  0.2760      0.842 0.872 0.000  0 0.128
#> SRR944305     1  0.3907      0.731 0.768 0.000  0 0.232
#> SRR944306     1  0.4008      0.721 0.756 0.000  0 0.244
#> SRR944307     4  0.1389      0.947 0.048 0.000  0 0.952
#> SRR944308     1  0.1389      0.891 0.952 0.000  0 0.048
#> SRR944309     1  0.0188      0.902 0.996 0.000  0 0.004
#> SRR944310     1  0.0000      0.901 1.000 0.000  0 0.000
#> SRR944311     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR944312     1  0.2216      0.877 0.908 0.000  0 0.092
#> SRR944313     1  0.0707      0.905 0.980 0.000  0 0.020
#> SRR944315     1  0.0817      0.905 0.976 0.000  0 0.024
#> SRR944314     1  0.0592      0.902 0.984 0.000  0 0.016
#> SRR944316     1  0.0000      0.901 1.000 0.000  0 0.000
#> SRR944317     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR944318     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR944319     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR944320     2  0.0000      1.000 0.000 1.000  0 0.000
#> SRR944321     1  0.4277      0.621 0.720 0.000  0 0.280
#> SRR944322     1  0.4977      0.157 0.540 0.000  0 0.460
#> SRR944323     1  0.4776      0.415 0.624 0.000  0 0.376
#> SRR944324     1  0.0188      0.902 0.996 0.000  0 0.004
#> SRR944325     1  0.0188      0.902 0.996 0.000  0 0.004
#> SRR944326     1  0.0336      0.902 0.992 0.000  0 0.008
#> SRR944327     1  0.3463      0.858 0.864 0.040  0 0.096
#> SRR944328     1  0.5092      0.773 0.764 0.140  0 0.096
#> SRR944329     4  0.0000      0.968 0.000 0.000  0 1.000
#> SRR944330     4  0.0000      0.968 0.000 0.000  0 1.000
#> SRR944331     4  0.0000      0.968 0.000 0.000  0 1.000
#> SRR944332     4  0.0000      0.968 0.000 0.000  0 1.000
#> SRR944334     4  0.0000      0.968 0.000 0.000  0 1.000
#> SRR944333     4  0.0000      0.968 0.000 0.000  0 1.000
#> SRR944335     4  0.0592      0.968 0.016 0.000  0 0.984
#> SRR944336     4  0.0592      0.968 0.016 0.000  0 0.984
#> SRR944337     4  0.0592      0.968 0.016 0.000  0 0.984
#> SRR944338     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR944339     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR944340     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR944341     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR944342     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR944343     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR944344     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
#> SRR944282     1  0.0162      0.868 0.996 0.000  0 0.000 0.004
#> SRR944283     1  0.0162      0.868 0.996 0.000  0 0.000 0.004
#> SRR944284     1  0.0566      0.868 0.984 0.000  0 0.012 0.004
#> SRR944285     1  0.0898      0.866 0.972 0.000  0 0.020 0.008
#> SRR944288     1  0.0162      0.868 0.996 0.000  0 0.000 0.004
#> SRR944287     1  0.1197      0.845 0.952 0.000  0 0.000 0.048
#> SRR944289     4  0.0771      0.726 0.020 0.000  0 0.976 0.004
#> SRR944290     1  0.3838      0.685 0.716 0.000  0 0.280 0.004
#> SRR944291     1  0.0162      0.868 0.996 0.000  0 0.000 0.004
#> SRR944292     5  0.4193      0.833 0.256 0.024  0 0.000 0.720
#> SRR944293     1  0.0162      0.868 0.996 0.000  0 0.000 0.004
#> SRR944294     1  0.0162      0.868 0.996 0.000  0 0.000 0.004
#> SRR944295     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR944296     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR944297     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR944298     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR944299     4  0.3231      0.509 0.196 0.000  0 0.800 0.004
#> SRR944300     4  0.3689      0.397 0.256 0.000  0 0.740 0.004
#> SRR944301     1  0.0404      0.870 0.988 0.000  0 0.012 0.000
#> SRR944302     5  0.4193      0.833 0.256 0.024  0 0.000 0.720
#> SRR944303     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR944304     1  0.3838      0.687 0.716 0.000  0 0.280 0.004
#> SRR944305     1  0.3689      0.717 0.740 0.000  0 0.256 0.004
#> SRR944306     1  0.3884      0.677 0.708 0.000  0 0.288 0.004
#> SRR944307     4  0.2124      0.654 0.096 0.000  0 0.900 0.004
#> SRR944308     1  0.1211      0.868 0.960 0.000  0 0.024 0.016
#> SRR944309     1  0.2390      0.855 0.896 0.000  0 0.084 0.020
#> SRR944310     1  0.1270      0.841 0.948 0.000  0 0.000 0.052
#> SRR944311     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR944312     1  0.3196      0.776 0.804 0.000  0 0.192 0.004
#> SRR944313     1  0.0162      0.869 0.996 0.000  0 0.004 0.000
#> SRR944315     1  0.0162      0.868 0.996 0.000  0 0.000 0.004
#> SRR944314     1  0.4575      0.716 0.712 0.000  0 0.236 0.052
#> SRR944316     1  0.0963      0.854 0.964 0.000  0 0.000 0.036
#> SRR944317     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR944318     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR944319     2  0.0162      0.996 0.000 0.996  0 0.000 0.004
#> SRR944320     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> SRR944321     1  0.2390      0.855 0.896 0.000  0 0.084 0.020
#> SRR944322     1  0.2390      0.855 0.896 0.000  0 0.084 0.020
#> SRR944323     1  0.2390      0.855 0.896 0.000  0 0.084 0.020
#> SRR944324     1  0.2390      0.855 0.896 0.000  0 0.084 0.020
#> SRR944325     1  0.2390      0.855 0.896 0.000  0 0.084 0.020
#> SRR944326     1  0.2390      0.855 0.896 0.000  0 0.084 0.020
#> SRR944327     1  0.5605      0.448 0.640 0.000  0 0.192 0.168
#> SRR944328     5  0.5426      0.632 0.132 0.004  0 0.192 0.672
#> SRR944329     4  0.3661      0.727 0.000 0.000  0 0.724 0.276
#> SRR944330     4  0.3661      0.727 0.000 0.000  0 0.724 0.276
#> SRR944331     4  0.3661      0.727 0.000 0.000  0 0.724 0.276
#> SRR944332     4  0.3661      0.727 0.000 0.000  0 0.724 0.276
#> SRR944334     4  0.3661      0.727 0.000 0.000  0 0.724 0.276
#> SRR944333     4  0.3661      0.727 0.000 0.000  0 0.724 0.276
#> SRR944335     4  0.0609      0.728 0.020 0.000  0 0.980 0.000
#> SRR944336     4  0.0609      0.728 0.020 0.000  0 0.980 0.000
#> SRR944337     4  0.0609      0.728 0.020 0.000  0 0.980 0.000
#> SRR944338     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR944339     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR944340     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR944341     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR944342     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR944343     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR944344     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
#> SRR944282     1  0.5177      0.600 0.540 0.388  0 0.000 0.056 0.016
#> SRR944283     1  0.5516      0.580 0.500 0.408  0 0.000 0.064 0.028
#> SRR944284     1  0.5544      0.589 0.500 0.408  0 0.000 0.056 0.036
#> SRR944285     1  0.6234      0.549 0.468 0.376  0 0.000 0.096 0.060
#> SRR944288     1  0.5283      0.591 0.512 0.416  0 0.000 0.040 0.032
#> SRR944287     2  0.6478     -0.494 0.348 0.424  0 0.000 0.032 0.196
#> SRR944289     6  0.3862      0.683 0.000 0.000  0 0.476 0.000 0.524
#> SRR944290     1  0.3847     -0.132 0.544 0.000  0 0.000 0.000 0.456
#> SRR944291     1  0.5127      0.605 0.544 0.392  0 0.000 0.032 0.032
#> SRR944292     5  0.0146      0.837 0.004 0.000  0 0.000 0.996 0.000
#> SRR944293     1  0.5557      0.586 0.500 0.404  0 0.000 0.068 0.028
#> SRR944294     1  0.5147      0.593 0.524 0.412  0 0.000 0.040 0.024
#> SRR944295     2  0.3810      0.625 0.000 0.572  0 0.000 0.000 0.428
#> SRR944296     2  0.3810      0.625 0.000 0.572  0 0.000 0.000 0.428
#> SRR944297     2  0.3810      0.625 0.000 0.572  0 0.000 0.000 0.428
#> SRR944298     2  0.3810      0.625 0.000 0.572  0 0.000 0.000 0.428
#> SRR944299     6  0.5556      0.654 0.264 0.000  0 0.188 0.000 0.548
#> SRR944300     6  0.5391      0.602 0.308 0.000  0 0.140 0.000 0.552
#> SRR944301     1  0.4361      0.627 0.700 0.236  0 0.000 0.004 0.060
#> SRR944302     5  0.0000      0.836 0.000 0.000  0 0.000 1.000 0.000
#> SRR944303     2  0.3810      0.625 0.000 0.572  0 0.000 0.000 0.428
#> SRR944304     1  0.3866     -0.220 0.516 0.000  0 0.000 0.000 0.484
#> SRR944305     1  0.3563      0.182 0.664 0.000  0 0.000 0.000 0.336
#> SRR944306     1  0.3868     -0.246 0.504 0.000  0 0.000 0.000 0.496
#> SRR944307     6  0.5531      0.688 0.184 0.000  0 0.264 0.000 0.552
#> SRR944308     1  0.6545      0.440 0.512 0.184  0 0.000 0.064 0.240
#> SRR944309     1  0.2149      0.621 0.888 0.104  0 0.000 0.004 0.004
#> SRR944310     2  0.6669     -0.491 0.332 0.416  0 0.000 0.044 0.208
#> SRR944311     2  0.3810      0.625 0.000 0.572  0 0.000 0.000 0.428
#> SRR944312     1  0.1957      0.537 0.888 0.000  0 0.000 0.000 0.112
#> SRR944313     1  0.4632      0.619 0.620 0.328  0 0.000 0.004 0.048
#> SRR944315     1  0.5200      0.609 0.556 0.372  0 0.000 0.044 0.028
#> SRR944314     2  0.6183     -0.497 0.336 0.424  0 0.000 0.008 0.232
#> SRR944316     2  0.6894     -0.496 0.316 0.424  0 0.000 0.076 0.184
#> SRR944317     2  0.3810      0.625 0.000 0.572  0 0.000 0.000 0.428
#> SRR944318     2  0.3810      0.625 0.000 0.572  0 0.000 0.000 0.428
#> SRR944319     2  0.3810      0.625 0.000 0.572  0 0.000 0.000 0.428
#> SRR944320     2  0.3810      0.625 0.000 0.572  0 0.000 0.000 0.428
#> SRR944321     1  0.0458      0.598 0.984 0.000  0 0.000 0.000 0.016
#> SRR944322     1  0.0458      0.598 0.984 0.000  0 0.000 0.000 0.016
#> SRR944323     1  0.0458      0.598 0.984 0.000  0 0.000 0.000 0.016
#> SRR944324     1  0.0458      0.598 0.984 0.000  0 0.000 0.000 0.016
#> SRR944325     1  0.0458      0.598 0.984 0.000  0 0.000 0.000 0.016
#> SRR944326     1  0.0458      0.598 0.984 0.000  0 0.000 0.000 0.016
#> SRR944327     5  0.5003      0.659 0.160 0.024  0 0.000 0.692 0.124
#> SRR944328     5  0.2446      0.787 0.012 0.000  0 0.000 0.864 0.124
#> SRR944329     4  0.0000      1.000 0.000 0.000  0 1.000 0.000 0.000
#> SRR944330     4  0.0000      1.000 0.000 0.000  0 1.000 0.000 0.000
#> SRR944331     4  0.0000      1.000 0.000 0.000  0 1.000 0.000 0.000
#> SRR944332     4  0.0000      1.000 0.000 0.000  0 1.000 0.000 0.000
#> SRR944334     4  0.0000      1.000 0.000 0.000  0 1.000 0.000 0.000
#> SRR944333     4  0.0000      1.000 0.000 0.000  0 1.000 0.000 0.000
#> SRR944335     6  0.3862      0.683 0.000 0.000  0 0.476 0.000 0.524
#> SRR944336     6  0.3862      0.683 0.000 0.000  0 0.476 0.000 0.524
#> SRR944337     6  0.3862      0.683 0.000 0.000  0 0.476 0.000 0.524
#> SRR944338     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR944339     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR944340     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR944341     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR944342     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR944343     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR944344     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-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 12673 rows and 62 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 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-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.974           0.930       0.967         0.3952 0.611   0.611
#> 3 3 1.000           0.988       0.994         0.1343 0.700   0.592
#> 4 4 0.662           0.793       0.870         0.4126 0.748   0.549
#> 5 5 0.595           0.783       0.850         0.0601 0.917   0.751
#> 6 6 0.608           0.792       0.871         0.0493 0.976   0.917

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
#> SRR944282     1  0.0376     0.9683 0.996 0.004
#> SRR944283     1  0.0376     0.9683 0.996 0.004
#> SRR944284     1  0.3274     0.9385 0.940 0.060
#> SRR944285     1  0.0000     0.9677 1.000 0.000
#> SRR944288     1  0.2948     0.9453 0.948 0.052
#> SRR944287     1  0.0000     0.9677 1.000 0.000
#> SRR944289     1  0.5059     0.8860 0.888 0.112
#> SRR944290     1  0.3431     0.9352 0.936 0.064
#> SRR944291     1  0.2043     0.9589 0.968 0.032
#> SRR944292     1  0.0000     0.9677 1.000 0.000
#> SRR944293     1  0.0672     0.9681 0.992 0.008
#> SRR944294     1  0.2043     0.9589 0.968 0.032
#> SRR944295     2  0.0000     0.9583 0.000 1.000
#> SRR944296     2  0.0000     0.9583 0.000 1.000
#> SRR944297     2  0.0000     0.9583 0.000 1.000
#> SRR944298     2  0.0000     0.9583 0.000 1.000
#> SRR944299     1  0.1414     0.9649 0.980 0.020
#> SRR944300     1  0.0938     0.9675 0.988 0.012
#> SRR944301     1  0.0938     0.9674 0.988 0.012
#> SRR944302     1  0.0000     0.9677 1.000 0.000
#> SRR944303     2  0.0000     0.9583 0.000 1.000
#> SRR944304     1  0.0000     0.9677 1.000 0.000
#> SRR944305     1  0.1414     0.9649 0.980 0.020
#> SRR944306     1  0.0376     0.9683 0.996 0.004
#> SRR944307     1  0.0672     0.9681 0.992 0.008
#> SRR944308     1  0.0376     0.9683 0.996 0.004
#> SRR944309     1  0.0672     0.9681 0.992 0.008
#> SRR944310     1  0.0376     0.9682 0.996 0.004
#> SRR944311     2  0.0000     0.9583 0.000 1.000
#> SRR944312     1  0.2948     0.9451 0.948 0.052
#> SRR944313     1  0.0000     0.9677 1.000 0.000
#> SRR944315     1  0.2423     0.9539 0.960 0.040
#> SRR944314     1  0.0000     0.9677 1.000 0.000
#> SRR944316     1  0.0938     0.9674 0.988 0.012
#> SRR944317     2  0.0000     0.9583 0.000 1.000
#> SRR944318     2  0.0000     0.9583 0.000 1.000
#> SRR944319     2  0.0000     0.9583 0.000 1.000
#> SRR944320     2  0.0000     0.9583 0.000 1.000
#> SRR944321     1  0.1414     0.9649 0.980 0.020
#> SRR944322     1  0.0376     0.9683 0.996 0.004
#> SRR944323     1  0.0672     0.9681 0.992 0.008
#> SRR944324     1  0.1633     0.9632 0.976 0.024
#> SRR944325     1  0.1633     0.9632 0.976 0.024
#> SRR944326     1  0.1633     0.9632 0.976 0.024
#> SRR944327     1  0.0376     0.9683 0.996 0.004
#> SRR944328     1  0.0000     0.9677 1.000 0.000
#> SRR944329     2  0.0000     0.9583 0.000 1.000
#> SRR944330     2  0.0000     0.9583 0.000 1.000
#> SRR944331     2  0.8661     0.5896 0.288 0.712
#> SRR944332     2  0.0000     0.9583 0.000 1.000
#> SRR944334     2  0.8713     0.5817 0.292 0.708
#> SRR944333     2  0.0000     0.9583 0.000 1.000
#> SRR944335     1  0.7528     0.7435 0.784 0.216
#> SRR944336     1  0.9996     0.0446 0.512 0.488
#> SRR944337     1  0.4298     0.9124 0.912 0.088
#> SRR944338     1  0.0000     0.9677 1.000 0.000
#> SRR944339     1  0.0000     0.9677 1.000 0.000
#> SRR944340     1  0.0000     0.9677 1.000 0.000
#> SRR944341     1  0.0000     0.9677 1.000 0.000
#> SRR944342     1  0.0000     0.9677 1.000 0.000
#> SRR944343     1  0.0000     0.9677 1.000 0.000
#> SRR944344     1  0.0000     0.9677 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
#> SRR944282     1   0.000      0.992 1.000 0.000 0.00
#> SRR944283     1   0.000      0.992 1.000 0.000 0.00
#> SRR944284     1   0.000      0.992 1.000 0.000 0.00
#> SRR944285     1   0.000      0.992 1.000 0.000 0.00
#> SRR944288     1   0.000      0.992 1.000 0.000 0.00
#> SRR944287     1   0.000      0.992 1.000 0.000 0.00
#> SRR944289     1   0.000      0.992 1.000 0.000 0.00
#> SRR944290     1   0.000      0.992 1.000 0.000 0.00
#> SRR944291     1   0.000      0.992 1.000 0.000 0.00
#> SRR944292     1   0.000      0.992 1.000 0.000 0.00
#> SRR944293     1   0.000      0.992 1.000 0.000 0.00
#> SRR944294     1   0.000      0.992 1.000 0.000 0.00
#> SRR944295     2   0.000      1.000 0.000 1.000 0.00
#> SRR944296     2   0.000      1.000 0.000 1.000 0.00
#> SRR944297     2   0.000      1.000 0.000 1.000 0.00
#> SRR944298     2   0.000      1.000 0.000 1.000 0.00
#> SRR944299     1   0.000      0.992 1.000 0.000 0.00
#> SRR944300     1   0.000      0.992 1.000 0.000 0.00
#> SRR944301     1   0.000      0.992 1.000 0.000 0.00
#> SRR944302     1   0.207      0.935 0.940 0.000 0.06
#> SRR944303     2   0.000      1.000 0.000 1.000 0.00
#> SRR944304     1   0.000      0.992 1.000 0.000 0.00
#> SRR944305     1   0.000      0.992 1.000 0.000 0.00
#> SRR944306     1   0.000      0.992 1.000 0.000 0.00
#> SRR944307     1   0.000      0.992 1.000 0.000 0.00
#> SRR944308     1   0.000      0.992 1.000 0.000 0.00
#> SRR944309     1   0.000      0.992 1.000 0.000 0.00
#> SRR944310     1   0.000      0.992 1.000 0.000 0.00
#> SRR944311     2   0.000      1.000 0.000 1.000 0.00
#> SRR944312     1   0.000      0.992 1.000 0.000 0.00
#> SRR944313     1   0.000      0.992 1.000 0.000 0.00
#> SRR944315     1   0.000      0.992 1.000 0.000 0.00
#> SRR944314     1   0.000      0.992 1.000 0.000 0.00
#> SRR944316     1   0.000      0.992 1.000 0.000 0.00
#> SRR944317     2   0.000      1.000 0.000 1.000 0.00
#> SRR944318     2   0.000      1.000 0.000 1.000 0.00
#> SRR944319     2   0.000      1.000 0.000 1.000 0.00
#> SRR944320     2   0.000      1.000 0.000 1.000 0.00
#> SRR944321     1   0.000      0.992 1.000 0.000 0.00
#> SRR944322     1   0.000      0.992 1.000 0.000 0.00
#> SRR944323     1   0.000      0.992 1.000 0.000 0.00
#> SRR944324     1   0.000      0.992 1.000 0.000 0.00
#> SRR944325     1   0.000      0.992 1.000 0.000 0.00
#> SRR944326     1   0.000      0.992 1.000 0.000 0.00
#> SRR944327     1   0.000      0.992 1.000 0.000 0.00
#> SRR944328     1   0.000      0.992 1.000 0.000 0.00
#> SRR944329     1   0.327      0.875 0.884 0.116 0.00
#> SRR944330     1   0.327      0.875 0.884 0.116 0.00
#> SRR944331     1   0.000      0.992 1.000 0.000 0.00
#> SRR944332     1   0.000      0.992 1.000 0.000 0.00
#> SRR944334     1   0.000      0.992 1.000 0.000 0.00
#> SRR944333     1   0.216      0.931 0.936 0.064 0.00
#> SRR944335     1   0.000      0.992 1.000 0.000 0.00
#> SRR944336     1   0.000      0.992 1.000 0.000 0.00
#> SRR944337     1   0.000      0.992 1.000 0.000 0.00
#> SRR944338     3   0.000      1.000 0.000 0.000 1.00
#> SRR944339     3   0.000      1.000 0.000 0.000 1.00
#> SRR944340     3   0.000      1.000 0.000 0.000 1.00
#> SRR944341     3   0.000      1.000 0.000 0.000 1.00
#> SRR944342     3   0.000      1.000 0.000 0.000 1.00
#> SRR944343     3   0.000      1.000 0.000 0.000 1.00
#> SRR944344     3   0.000      1.000 0.000 0.000 1.00

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> SRR944282     1  0.0188     0.8858 0.996 0.000 0.000 0.004
#> SRR944283     1  0.0188     0.8860 0.996 0.000 0.000 0.004
#> SRR944284     1  0.0188     0.8858 0.996 0.000 0.000 0.004
#> SRR944285     1  0.0188     0.8858 0.996 0.000 0.000 0.004
#> SRR944288     1  0.0000     0.8875 1.000 0.000 0.000 0.000
#> SRR944287     1  0.0817     0.8812 0.976 0.000 0.000 0.024
#> SRR944289     4  0.4713     0.8025 0.360 0.000 0.000 0.640
#> SRR944290     1  0.4996    -0.5430 0.516 0.000 0.000 0.484
#> SRR944291     1  0.0707     0.8819 0.980 0.000 0.000 0.020
#> SRR944292     1  0.0707     0.8708 0.980 0.000 0.000 0.020
#> SRR944293     1  0.0707     0.8839 0.980 0.000 0.000 0.020
#> SRR944294     1  0.0336     0.8887 0.992 0.000 0.000 0.008
#> SRR944295     2  0.0000     0.9382 0.000 1.000 0.000 0.000
#> SRR944296     2  0.0592     0.9339 0.000 0.984 0.000 0.016
#> SRR944297     2  0.0336     0.9378 0.000 0.992 0.000 0.008
#> SRR944298     2  0.0000     0.9382 0.000 1.000 0.000 0.000
#> SRR944299     4  0.4843     0.7703 0.396 0.000 0.000 0.604
#> SRR944300     4  0.4830     0.7755 0.392 0.000 0.000 0.608
#> SRR944301     1  0.1118     0.8703 0.964 0.000 0.000 0.036
#> SRR944302     4  0.5690     0.6512 0.168 0.000 0.116 0.716
#> SRR944303     2  0.0188     0.9378 0.000 0.996 0.000 0.004
#> SRR944304     4  0.4981     0.6520 0.464 0.000 0.000 0.536
#> SRR944305     4  0.4972     0.6687 0.456 0.000 0.000 0.544
#> SRR944306     4  0.4992     0.6207 0.476 0.000 0.000 0.524
#> SRR944307     4  0.4804     0.7836 0.384 0.000 0.000 0.616
#> SRR944308     1  0.4907    -0.3163 0.580 0.000 0.000 0.420
#> SRR944309     1  0.2647     0.7524 0.880 0.000 0.000 0.120
#> SRR944310     1  0.4679     0.0135 0.648 0.000 0.000 0.352
#> SRR944311     2  0.0000     0.9382 0.000 1.000 0.000 0.000
#> SRR944312     1  0.4193     0.3784 0.732 0.000 0.000 0.268
#> SRR944313     1  0.1716     0.8380 0.936 0.000 0.000 0.064
#> SRR944315     1  0.0000     0.8875 1.000 0.000 0.000 0.000
#> SRR944314     1  0.0336     0.8887 0.992 0.000 0.000 0.008
#> SRR944316     1  0.0336     0.8882 0.992 0.000 0.000 0.008
#> SRR944317     2  0.0336     0.9380 0.000 0.992 0.000 0.008
#> SRR944318     2  0.0469     0.9370 0.000 0.988 0.000 0.012
#> SRR944319     2  0.4713     0.6393 0.000 0.640 0.000 0.360
#> SRR944320     2  0.3726     0.8080 0.000 0.788 0.000 0.212
#> SRR944321     1  0.0592     0.8862 0.984 0.000 0.000 0.016
#> SRR944322     1  0.0592     0.8862 0.984 0.000 0.000 0.016
#> SRR944323     1  0.0592     0.8862 0.984 0.000 0.000 0.016
#> SRR944324     1  0.0336     0.8887 0.992 0.000 0.000 0.008
#> SRR944325     1  0.0188     0.8885 0.996 0.000 0.000 0.004
#> SRR944326     1  0.0000     0.8875 1.000 0.000 0.000 0.000
#> SRR944327     1  0.0188     0.8858 0.996 0.000 0.000 0.004
#> SRR944328     1  0.0336     0.8824 0.992 0.000 0.000 0.008
#> SRR944329     4  0.3485     0.6942 0.116 0.028 0.000 0.856
#> SRR944330     4  0.3497     0.7068 0.124 0.024 0.000 0.852
#> SRR944331     4  0.3837     0.7862 0.224 0.000 0.000 0.776
#> SRR944332     4  0.4053     0.7885 0.228 0.004 0.000 0.768
#> SRR944334     4  0.4222     0.8025 0.272 0.000 0.000 0.728
#> SRR944333     4  0.4121     0.7594 0.184 0.020 0.000 0.796
#> SRR944335     4  0.4643     0.8103 0.344 0.000 0.000 0.656
#> SRR944336     4  0.4624     0.8108 0.340 0.000 0.000 0.660
#> SRR944337     4  0.4643     0.8103 0.344 0.000 0.000 0.656
#> SRR944338     3  0.0000     0.9940 0.000 0.000 1.000 0.000
#> SRR944339     3  0.0000     0.9940 0.000 0.000 1.000 0.000
#> SRR944340     3  0.0000     0.9940 0.000 0.000 1.000 0.000
#> SRR944341     3  0.0000     0.9940 0.000 0.000 1.000 0.000
#> SRR944342     3  0.0000     0.9940 0.000 0.000 1.000 0.000
#> SRR944343     3  0.0000     0.9940 0.000 0.000 1.000 0.000
#> SRR944344     3  0.1474     0.9632 0.000 0.000 0.948 0.052

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> SRR944282     1  0.0579      0.847 0.984 0.000 0.000 0.008 0.008
#> SRR944283     1  0.0579      0.849 0.984 0.000 0.000 0.008 0.008
#> SRR944284     1  0.0162      0.855 0.996 0.000 0.000 0.000 0.004
#> SRR944285     1  0.0609      0.866 0.980 0.000 0.000 0.020 0.000
#> SRR944288     1  0.0671      0.865 0.980 0.000 0.000 0.016 0.004
#> SRR944287     1  0.2179      0.854 0.896 0.000 0.000 0.100 0.004
#> SRR944289     4  0.3612      0.832 0.228 0.000 0.000 0.764 0.008
#> SRR944290     4  0.4547      0.605 0.400 0.000 0.000 0.588 0.012
#> SRR944291     1  0.1851      0.862 0.912 0.000 0.000 0.088 0.000
#> SRR944292     1  0.3281      0.761 0.848 0.000 0.000 0.092 0.060
#> SRR944293     1  0.2439      0.838 0.876 0.000 0.000 0.120 0.004
#> SRR944294     1  0.2011      0.861 0.908 0.000 0.000 0.088 0.004
#> SRR944295     2  0.0290      0.977 0.000 0.992 0.000 0.000 0.008
#> SRR944296     2  0.1732      0.906 0.000 0.920 0.000 0.000 0.080
#> SRR944297     2  0.0162      0.978 0.000 0.996 0.000 0.000 0.004
#> SRR944298     2  0.0162      0.978 0.000 0.996 0.000 0.000 0.004
#> SRR944299     4  0.3970      0.829 0.236 0.000 0.000 0.744 0.020
#> SRR944300     4  0.3849      0.831 0.232 0.000 0.000 0.752 0.016
#> SRR944301     1  0.2970      0.790 0.828 0.000 0.000 0.168 0.004
#> SRR944302     5  0.7373      0.192 0.068 0.000 0.136 0.380 0.416
#> SRR944303     2  0.0693      0.973 0.000 0.980 0.000 0.008 0.012
#> SRR944304     4  0.4339      0.780 0.296 0.000 0.000 0.684 0.020
#> SRR944305     4  0.4213      0.769 0.308 0.000 0.000 0.680 0.012
#> SRR944306     4  0.4380      0.771 0.304 0.000 0.000 0.676 0.020
#> SRR944307     4  0.3882      0.832 0.224 0.000 0.000 0.756 0.020
#> SRR944308     4  0.4637      0.469 0.452 0.000 0.000 0.536 0.012
#> SRR944309     1  0.4066      0.421 0.672 0.000 0.000 0.324 0.004
#> SRR944310     4  0.4746      0.369 0.480 0.000 0.000 0.504 0.016
#> SRR944311     2  0.0324      0.978 0.000 0.992 0.000 0.004 0.004
#> SRR944312     1  0.4559     -0.313 0.512 0.000 0.000 0.480 0.008
#> SRR944313     1  0.3366      0.714 0.784 0.000 0.000 0.212 0.004
#> SRR944315     1  0.0880      0.869 0.968 0.000 0.000 0.032 0.000
#> SRR944314     1  0.0510      0.865 0.984 0.000 0.000 0.016 0.000
#> SRR944316     1  0.1270      0.870 0.948 0.000 0.000 0.052 0.000
#> SRR944317     2  0.0324      0.978 0.000 0.992 0.000 0.004 0.004
#> SRR944318     2  0.0451      0.977 0.000 0.988 0.000 0.008 0.004
#> SRR944319     5  0.6772      0.396 0.004 0.316 0.000 0.240 0.440
#> SRR944320     5  0.6257      0.224 0.004 0.400 0.000 0.128 0.468
#> SRR944321     1  0.2516      0.823 0.860 0.000 0.000 0.140 0.000
#> SRR944322     1  0.2471      0.828 0.864 0.000 0.000 0.136 0.000
#> SRR944323     1  0.2516      0.823 0.860 0.000 0.000 0.140 0.000
#> SRR944324     1  0.1792      0.862 0.916 0.000 0.000 0.084 0.000
#> SRR944325     1  0.1121      0.870 0.956 0.000 0.000 0.044 0.000
#> SRR944326     1  0.1043      0.870 0.960 0.000 0.000 0.040 0.000
#> SRR944327     1  0.0451      0.849 0.988 0.000 0.000 0.008 0.004
#> SRR944328     1  0.1195      0.826 0.960 0.000 0.000 0.028 0.012
#> SRR944329     4  0.2079      0.660 0.064 0.000 0.000 0.916 0.020
#> SRR944330     4  0.2079      0.660 0.064 0.000 0.000 0.916 0.020
#> SRR944331     4  0.2771      0.769 0.128 0.000 0.000 0.860 0.012
#> SRR944332     4  0.2771      0.769 0.128 0.000 0.000 0.860 0.012
#> SRR944334     4  0.2864      0.778 0.136 0.000 0.000 0.852 0.012
#> SRR944333     4  0.2522      0.741 0.108 0.000 0.000 0.880 0.012
#> SRR944335     4  0.3388      0.827 0.200 0.000 0.000 0.792 0.008
#> SRR944336     4  0.3318      0.823 0.192 0.000 0.000 0.800 0.008
#> SRR944337     4  0.3530      0.828 0.204 0.000 0.000 0.784 0.012
#> SRR944338     3  0.0162      0.965 0.000 0.000 0.996 0.000 0.004
#> SRR944339     3  0.0162      0.965 0.000 0.000 0.996 0.000 0.004
#> SRR944340     3  0.0671      0.959 0.000 0.000 0.980 0.004 0.016
#> SRR944341     3  0.0162      0.965 0.000 0.000 0.996 0.000 0.004
#> SRR944342     3  0.0290      0.964 0.000 0.000 0.992 0.000 0.008
#> SRR944343     3  0.0290      0.964 0.000 0.000 0.992 0.000 0.008
#> SRR944344     3  0.3039      0.811 0.000 0.000 0.808 0.000 0.192

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR944282     1  0.0862      0.846 0.972 0.000 0.000 0.008 0.016 0.004
#> SRR944283     1  0.0935      0.835 0.964 0.000 0.000 0.000 0.032 0.004
#> SRR944284     1  0.0820      0.853 0.972 0.000 0.000 0.016 0.012 0.000
#> SRR944285     1  0.1346      0.852 0.952 0.000 0.000 0.016 0.024 0.008
#> SRR944288     1  0.1370      0.862 0.948 0.000 0.000 0.036 0.012 0.004
#> SRR944287     1  0.2572      0.839 0.852 0.000 0.000 0.136 0.012 0.000
#> SRR944289     4  0.1957      0.833 0.112 0.000 0.000 0.888 0.000 0.000
#> SRR944290     4  0.3565      0.719 0.276 0.000 0.000 0.716 0.004 0.004
#> SRR944291     1  0.3158      0.822 0.812 0.000 0.000 0.164 0.020 0.004
#> SRR944292     1  0.5021      0.612 0.712 0.000 0.000 0.112 0.124 0.052
#> SRR944293     1  0.2932      0.815 0.820 0.000 0.000 0.164 0.016 0.000
#> SRR944294     1  0.3053      0.806 0.812 0.000 0.000 0.172 0.012 0.004
#> SRR944295     2  0.0508      0.941 0.000 0.984 0.000 0.000 0.004 0.012
#> SRR944296     2  0.2889      0.849 0.000 0.848 0.000 0.000 0.044 0.108
#> SRR944297     2  0.1498      0.928 0.000 0.940 0.000 0.000 0.028 0.032
#> SRR944298     2  0.1168      0.933 0.000 0.956 0.000 0.000 0.028 0.016
#> SRR944299     4  0.2655      0.826 0.140 0.000 0.000 0.848 0.008 0.004
#> SRR944300     4  0.2573      0.830 0.132 0.000 0.000 0.856 0.008 0.004
#> SRR944301     1  0.3287      0.744 0.768 0.000 0.000 0.220 0.012 0.000
#> SRR944302     5  0.5047      0.000 0.040 0.004 0.024 0.196 0.708 0.028
#> SRR944303     2  0.0862      0.939 0.000 0.972 0.000 0.004 0.008 0.016
#> SRR944304     4  0.3043      0.800 0.196 0.000 0.000 0.796 0.004 0.004
#> SRR944305     4  0.3340      0.797 0.196 0.000 0.000 0.784 0.016 0.004
#> SRR944306     4  0.3166      0.806 0.184 0.000 0.000 0.800 0.008 0.008
#> SRR944307     4  0.2053      0.832 0.108 0.000 0.000 0.888 0.000 0.004
#> SRR944308     4  0.4109      0.615 0.328 0.000 0.000 0.652 0.012 0.008
#> SRR944309     1  0.4136      0.201 0.560 0.000 0.000 0.428 0.012 0.000
#> SRR944310     4  0.4124      0.616 0.332 0.000 0.000 0.648 0.012 0.008
#> SRR944311     2  0.0603      0.940 0.000 0.980 0.000 0.000 0.004 0.016
#> SRR944312     4  0.4171      0.495 0.380 0.000 0.000 0.604 0.012 0.004
#> SRR944313     1  0.3953      0.524 0.656 0.000 0.000 0.328 0.016 0.000
#> SRR944315     1  0.0717      0.855 0.976 0.000 0.000 0.016 0.008 0.000
#> SRR944314     1  0.0993      0.858 0.964 0.000 0.000 0.024 0.012 0.000
#> SRR944316     1  0.1924      0.859 0.920 0.000 0.000 0.048 0.028 0.004
#> SRR944317     2  0.1370      0.933 0.000 0.948 0.000 0.004 0.012 0.036
#> SRR944318     2  0.1624      0.927 0.000 0.936 0.000 0.004 0.020 0.040
#> SRR944319     6  0.4311      0.816 0.000 0.120 0.000 0.108 0.016 0.756
#> SRR944320     6  0.3453      0.828 0.000 0.164 0.000 0.044 0.000 0.792
#> SRR944321     1  0.2402      0.839 0.856 0.000 0.000 0.140 0.004 0.000
#> SRR944322     1  0.2442      0.835 0.852 0.000 0.000 0.144 0.004 0.000
#> SRR944323     1  0.2772      0.803 0.816 0.000 0.000 0.180 0.004 0.000
#> SRR944324     1  0.1700      0.860 0.916 0.000 0.000 0.080 0.004 0.000
#> SRR944325     1  0.1367      0.862 0.944 0.000 0.000 0.044 0.012 0.000
#> SRR944326     1  0.1297      0.861 0.948 0.000 0.000 0.040 0.012 0.000
#> SRR944327     1  0.1148      0.843 0.960 0.000 0.000 0.016 0.020 0.004
#> SRR944328     1  0.1599      0.826 0.940 0.000 0.000 0.024 0.028 0.008
#> SRR944329     4  0.2016      0.737 0.024 0.000 0.000 0.920 0.016 0.040
#> SRR944330     4  0.1944      0.742 0.024 0.000 0.000 0.924 0.016 0.036
#> SRR944331     4  0.1793      0.793 0.048 0.000 0.000 0.928 0.012 0.012
#> SRR944332     4  0.1793      0.793 0.048 0.000 0.000 0.928 0.012 0.012
#> SRR944334     4  0.1542      0.802 0.052 0.000 0.000 0.936 0.008 0.004
#> SRR944333     4  0.1944      0.768 0.036 0.000 0.000 0.924 0.016 0.024
#> SRR944335     4  0.1610      0.826 0.084 0.000 0.000 0.916 0.000 0.000
#> SRR944336     4  0.1387      0.818 0.068 0.000 0.000 0.932 0.000 0.000
#> SRR944337     4  0.1663      0.828 0.088 0.000 0.000 0.912 0.000 0.000
#> SRR944338     3  0.0363      0.915 0.000 0.000 0.988 0.000 0.012 0.000
#> SRR944339     3  0.0146      0.916 0.000 0.000 0.996 0.000 0.004 0.000
#> SRR944340     3  0.0291      0.915 0.000 0.000 0.992 0.000 0.004 0.004
#> SRR944341     3  0.0717      0.909 0.000 0.000 0.976 0.000 0.016 0.008
#> SRR944342     3  0.0000      0.916 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR944343     3  0.0692      0.911 0.000 0.000 0.976 0.000 0.020 0.004
#> SRR944344     3  0.5110      0.371 0.000 0.000 0.556 0.008 0.368 0.068

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

consensus_heatmap(res, k = 2)

plot of chunk tab-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 12673 rows and 62 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 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-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.736           0.941       0.967         0.2436 0.796   0.796
#> 3 3 0.843           0.907       0.945         0.9109 0.727   0.657
#> 4 4 0.778           0.875       0.917         0.1926 0.944   0.893
#> 5 5 0.700           0.839       0.895         0.0554 0.998   0.996
#> 6 6 0.641           0.760       0.873         0.0689 0.922   0.833

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
#> SRR944282     1   0.000      0.961 1.000 0.000
#> SRR944283     1   0.000      0.961 1.000 0.000
#> SRR944284     1   0.000      0.961 1.000 0.000
#> SRR944285     1   0.000      0.961 1.000 0.000
#> SRR944288     1   0.000      0.961 1.000 0.000
#> SRR944287     1   0.000      0.961 1.000 0.000
#> SRR944289     1   0.000      0.961 1.000 0.000
#> SRR944290     1   0.000      0.961 1.000 0.000
#> SRR944291     1   0.000      0.961 1.000 0.000
#> SRR944292     1   0.443      0.898 0.908 0.092
#> SRR944293     1   0.000      0.961 1.000 0.000
#> SRR944294     1   0.000      0.961 1.000 0.000
#> SRR944295     1   0.689      0.819 0.816 0.184
#> SRR944296     1   0.689      0.819 0.816 0.184
#> SRR944297     1   0.689      0.819 0.816 0.184
#> SRR944298     1   0.689      0.819 0.816 0.184
#> SRR944299     1   0.000      0.961 1.000 0.000
#> SRR944300     1   0.000      0.961 1.000 0.000
#> SRR944301     1   0.000      0.961 1.000 0.000
#> SRR944302     1   0.430      0.901 0.912 0.088
#> SRR944303     1   0.689      0.819 0.816 0.184
#> SRR944304     1   0.000      0.961 1.000 0.000
#> SRR944305     1   0.000      0.961 1.000 0.000
#> SRR944306     1   0.000      0.961 1.000 0.000
#> SRR944307     1   0.000      0.961 1.000 0.000
#> SRR944308     1   0.000      0.961 1.000 0.000
#> SRR944309     1   0.000      0.961 1.000 0.000
#> SRR944310     1   0.000      0.961 1.000 0.000
#> SRR944311     1   0.689      0.819 0.816 0.184
#> SRR944312     1   0.000      0.961 1.000 0.000
#> SRR944313     1   0.000      0.961 1.000 0.000
#> SRR944315     1   0.000      0.961 1.000 0.000
#> SRR944314     1   0.000      0.961 1.000 0.000
#> SRR944316     1   0.000      0.961 1.000 0.000
#> SRR944317     1   0.689      0.819 0.816 0.184
#> SRR944318     1   0.689      0.819 0.816 0.184
#> SRR944319     1   0.689      0.819 0.816 0.184
#> SRR944320     1   0.689      0.819 0.816 0.184
#> SRR944321     1   0.000      0.961 1.000 0.000
#> SRR944322     1   0.000      0.961 1.000 0.000
#> SRR944323     1   0.000      0.961 1.000 0.000
#> SRR944324     1   0.000      0.961 1.000 0.000
#> SRR944325     1   0.000      0.961 1.000 0.000
#> SRR944326     1   0.000      0.961 1.000 0.000
#> SRR944327     1   0.000      0.961 1.000 0.000
#> SRR944328     1   0.000      0.961 1.000 0.000
#> SRR944329     1   0.000      0.961 1.000 0.000
#> SRR944330     1   0.000      0.961 1.000 0.000
#> SRR944331     1   0.000      0.961 1.000 0.000
#> SRR944332     1   0.000      0.961 1.000 0.000
#> SRR944334     1   0.000      0.961 1.000 0.000
#> SRR944333     1   0.000      0.961 1.000 0.000
#> SRR944335     1   0.000      0.961 1.000 0.000
#> SRR944336     1   0.000      0.961 1.000 0.000
#> SRR944337     1   0.000      0.961 1.000 0.000
#> SRR944338     2   0.000      1.000 0.000 1.000
#> SRR944339     2   0.000      1.000 0.000 1.000
#> SRR944340     2   0.000      1.000 0.000 1.000
#> SRR944341     2   0.000      1.000 0.000 1.000
#> SRR944342     2   0.000      1.000 0.000 1.000
#> SRR944343     2   0.000      1.000 0.000 1.000
#> SRR944344     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
#> SRR944282     1  0.0424      0.957 0.992 0.008  0
#> SRR944283     1  0.0592      0.957 0.988 0.012  0
#> SRR944284     1  0.1163      0.945 0.972 0.028  0
#> SRR944285     1  0.0747      0.954 0.984 0.016  0
#> SRR944288     1  0.0892      0.952 0.980 0.020  0
#> SRR944287     1  0.0592      0.957 0.988 0.012  0
#> SRR944289     1  0.1031      0.949 0.976 0.024  0
#> SRR944290     1  0.0592      0.955 0.988 0.012  0
#> SRR944291     1  0.3752      0.801 0.856 0.144  0
#> SRR944292     2  0.6192      0.436 0.420 0.580  0
#> SRR944293     1  0.1031      0.949 0.976 0.024  0
#> SRR944294     1  0.0747      0.956 0.984 0.016  0
#> SRR944295     2  0.2878      0.888 0.096 0.904  0
#> SRR944296     2  0.2878      0.888 0.096 0.904  0
#> SRR944297     2  0.2878      0.888 0.096 0.904  0
#> SRR944298     2  0.2878      0.888 0.096 0.904  0
#> SRR944299     1  0.2711      0.890 0.912 0.088  0
#> SRR944300     1  0.2711      0.890 0.912 0.088  0
#> SRR944301     1  0.0237      0.957 0.996 0.004  0
#> SRR944302     2  0.6307      0.230 0.488 0.512  0
#> SRR944303     2  0.2878      0.888 0.096 0.904  0
#> SRR944304     1  0.0592      0.955 0.988 0.012  0
#> SRR944305     1  0.2878      0.882 0.904 0.096  0
#> SRR944306     1  0.1753      0.927 0.952 0.048  0
#> SRR944307     1  0.2878      0.882 0.904 0.096  0
#> SRR944308     1  0.0892      0.952 0.980 0.020  0
#> SRR944309     1  0.1529      0.938 0.960 0.040  0
#> SRR944310     1  0.0747      0.956 0.984 0.016  0
#> SRR944311     2  0.2878      0.888 0.096 0.904  0
#> SRR944312     1  0.2165      0.913 0.936 0.064  0
#> SRR944313     1  0.1031      0.952 0.976 0.024  0
#> SRR944315     1  0.0592      0.955 0.988 0.012  0
#> SRR944314     1  0.0592      0.957 0.988 0.012  0
#> SRR944316     1  0.0747      0.954 0.984 0.016  0
#> SRR944317     2  0.2878      0.888 0.096 0.904  0
#> SRR944318     2  0.2878      0.888 0.096 0.904  0
#> SRR944319     2  0.2878      0.888 0.096 0.904  0
#> SRR944320     2  0.2878      0.888 0.096 0.904  0
#> SRR944321     1  0.0000      0.958 1.000 0.000  0
#> SRR944322     1  0.0000      0.958 1.000 0.000  0
#> SRR944323     1  0.0000      0.958 1.000 0.000  0
#> SRR944324     1  0.0000      0.958 1.000 0.000  0
#> SRR944325     1  0.0000      0.958 1.000 0.000  0
#> SRR944326     1  0.0000      0.958 1.000 0.000  0
#> SRR944327     1  0.5397      0.536 0.720 0.280  0
#> SRR944328     1  0.5529      0.498 0.704 0.296  0
#> SRR944329     1  0.0000      0.958 1.000 0.000  0
#> SRR944330     1  0.0000      0.958 1.000 0.000  0
#> SRR944331     1  0.0000      0.958 1.000 0.000  0
#> SRR944332     1  0.0000      0.958 1.000 0.000  0
#> SRR944334     1  0.0000      0.958 1.000 0.000  0
#> SRR944333     1  0.0000      0.958 1.000 0.000  0
#> SRR944335     1  0.0000      0.958 1.000 0.000  0
#> SRR944336     1  0.0000      0.958 1.000 0.000  0
#> SRR944337     1  0.0000      0.958 1.000 0.000  0
#> SRR944338     3  0.0000      1.000 0.000 0.000  1
#> SRR944339     3  0.0000      1.000 0.000 0.000  1
#> SRR944340     3  0.0000      1.000 0.000 0.000  1
#> SRR944341     3  0.0000      1.000 0.000 0.000  1
#> SRR944342     3  0.0000      1.000 0.000 0.000  1
#> SRR944343     3  0.0000      1.000 0.000 0.000  1
#> SRR944344     3  0.0000      1.000 0.000 0.000  1

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2 p3    p4
#> SRR944282     1  0.1004      0.914 0.972 0.004  0 0.024
#> SRR944283     1  0.1042      0.915 0.972 0.008  0 0.020
#> SRR944284     1  0.1792      0.892 0.932 0.000  0 0.068
#> SRR944285     1  0.2101      0.893 0.928 0.012  0 0.060
#> SRR944288     1  0.1661      0.900 0.944 0.004  0 0.052
#> SRR944287     1  0.1584      0.909 0.952 0.012  0 0.036
#> SRR944289     1  0.1489      0.901 0.952 0.004  0 0.044
#> SRR944290     1  0.0707      0.913 0.980 0.000  0 0.020
#> SRR944291     1  0.3726      0.669 0.788 0.000  0 0.212
#> SRR944292     4  0.7238      0.537 0.160 0.332  0 0.508
#> SRR944293     1  0.1890      0.896 0.936 0.008  0 0.056
#> SRR944294     1  0.1488      0.911 0.956 0.012  0 0.032
#> SRR944295     2  0.0188      0.919 0.004 0.996  0 0.000
#> SRR944296     2  0.3161      0.871 0.012 0.864  0 0.124
#> SRR944297     2  0.2676      0.897 0.012 0.896  0 0.092
#> SRR944298     2  0.1970      0.916 0.008 0.932  0 0.060
#> SRR944299     1  0.4134      0.681 0.740 0.000  0 0.260
#> SRR944300     1  0.3907      0.719 0.768 0.000  0 0.232
#> SRR944301     1  0.0779      0.917 0.980 0.004  0 0.016
#> SRR944302     4  0.7267      0.700 0.212 0.248  0 0.540
#> SRR944303     2  0.0188      0.919 0.004 0.996  0 0.000
#> SRR944304     1  0.1867      0.901 0.928 0.000  0 0.072
#> SRR944305     1  0.4304      0.644 0.716 0.000  0 0.284
#> SRR944306     1  0.3356      0.796 0.824 0.000  0 0.176
#> SRR944307     1  0.4331      0.638 0.712 0.000  0 0.288
#> SRR944308     1  0.2888      0.847 0.872 0.004  0 0.124
#> SRR944309     1  0.3356      0.798 0.824 0.000  0 0.176
#> SRR944310     1  0.2011      0.898 0.920 0.000  0 0.080
#> SRR944311     2  0.1004      0.921 0.004 0.972  0 0.024
#> SRR944312     1  0.3610      0.763 0.800 0.000  0 0.200
#> SRR944313     1  0.2647      0.864 0.880 0.000  0 0.120
#> SRR944315     1  0.0707      0.913 0.980 0.000  0 0.020
#> SRR944314     1  0.1488      0.910 0.956 0.012  0 0.032
#> SRR944316     1  0.2101      0.893 0.928 0.012  0 0.060
#> SRR944317     2  0.0188      0.919 0.004 0.996  0 0.000
#> SRR944318     2  0.1970      0.915 0.008 0.932  0 0.060
#> SRR944319     2  0.0000      0.915 0.000 1.000  0 0.000
#> SRR944320     2  0.4807      0.672 0.024 0.728  0 0.248
#> SRR944321     1  0.0000      0.917 1.000 0.000  0 0.000
#> SRR944322     1  0.0000      0.917 1.000 0.000  0 0.000
#> SRR944323     1  0.0000      0.917 1.000 0.000  0 0.000
#> SRR944324     1  0.0000      0.917 1.000 0.000  0 0.000
#> SRR944325     1  0.0000      0.917 1.000 0.000  0 0.000
#> SRR944326     1  0.0000      0.917 1.000 0.000  0 0.000
#> SRR944327     4  0.4331      0.755 0.288 0.000  0 0.712
#> SRR944328     4  0.4927      0.769 0.264 0.024  0 0.712
#> SRR944329     1  0.0000      0.917 1.000 0.000  0 0.000
#> SRR944330     1  0.0000      0.917 1.000 0.000  0 0.000
#> SRR944331     1  0.0000      0.917 1.000 0.000  0 0.000
#> SRR944332     1  0.0000      0.917 1.000 0.000  0 0.000
#> SRR944334     1  0.0000      0.917 1.000 0.000  0 0.000
#> SRR944333     1  0.0000      0.917 1.000 0.000  0 0.000
#> SRR944335     1  0.0000      0.917 1.000 0.000  0 0.000
#> SRR944336     1  0.0000      0.917 1.000 0.000  0 0.000
#> SRR944337     1  0.0000      0.917 1.000 0.000  0 0.000
#> SRR944338     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR944339     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR944340     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR944341     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR944342     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR944343     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR944344     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
#> SRR944282     1  0.1243      0.885 0.960 0.004 0.00 0.028 0.008
#> SRR944283     1  0.1299      0.886 0.960 0.008 0.00 0.012 0.020
#> SRR944284     1  0.2390      0.856 0.896 0.000 0.00 0.084 0.020
#> SRR944285     1  0.2604      0.859 0.896 0.012 0.00 0.072 0.020
#> SRR944288     1  0.2214      0.869 0.916 0.004 0.00 0.052 0.028
#> SRR944287     1  0.2217      0.873 0.920 0.012 0.00 0.024 0.044
#> SRR944289     1  0.1644      0.872 0.940 0.004 0.00 0.048 0.008
#> SRR944290     1  0.0609      0.885 0.980 0.000 0.00 0.020 0.000
#> SRR944291     1  0.4666      0.617 0.732 0.000 0.00 0.180 0.088
#> SRR944292     4  0.5466      0.666 0.136 0.192 0.00 0.668 0.004
#> SRR944293     1  0.2364      0.862 0.908 0.008 0.00 0.064 0.020
#> SRR944294     1  0.1978      0.879 0.932 0.012 0.00 0.032 0.024
#> SRR944295     2  0.0324      0.903 0.004 0.992 0.00 0.004 0.000
#> SRR944296     2  0.2707      0.855 0.008 0.860 0.00 0.132 0.000
#> SRR944297     2  0.2249      0.883 0.008 0.896 0.00 0.096 0.000
#> SRR944298     2  0.1638      0.901 0.004 0.932 0.00 0.064 0.000
#> SRR944299     1  0.4331      0.472 0.596 0.000 0.00 0.004 0.400
#> SRR944300     1  0.4074      0.538 0.636 0.000 0.00 0.000 0.364
#> SRR944301     1  0.1074      0.887 0.968 0.004 0.00 0.012 0.016
#> SRR944302     4  0.5073      0.631 0.196 0.088 0.00 0.708 0.008
#> SRR944303     2  0.0324      0.903 0.004 0.992 0.00 0.004 0.000
#> SRR944304     1  0.2438      0.868 0.900 0.000 0.00 0.060 0.040
#> SRR944305     1  0.5592      0.521 0.636 0.000 0.00 0.144 0.220
#> SRR944306     1  0.3863      0.694 0.740 0.000 0.00 0.012 0.248
#> SRR944307     1  0.4726      0.439 0.580 0.000 0.00 0.020 0.400
#> SRR944308     1  0.3197      0.804 0.832 0.004 0.00 0.012 0.152
#> SRR944309     1  0.3967      0.687 0.724 0.000 0.00 0.012 0.264
#> SRR944310     1  0.2580      0.864 0.892 0.000 0.00 0.044 0.064
#> SRR944311     2  0.0865      0.907 0.004 0.972 0.00 0.024 0.000
#> SRR944312     1  0.4029      0.620 0.680 0.000 0.00 0.004 0.316
#> SRR944313     1  0.3276      0.817 0.836 0.000 0.00 0.032 0.132
#> SRR944315     1  0.0609      0.885 0.980 0.000 0.00 0.020 0.000
#> SRR944314     1  0.2140      0.875 0.924 0.012 0.00 0.024 0.040
#> SRR944316     1  0.2604      0.859 0.896 0.012 0.00 0.072 0.020
#> SRR944317     2  0.0162      0.904 0.004 0.996 0.00 0.000 0.000
#> SRR944318     2  0.1697      0.901 0.008 0.932 0.00 0.060 0.000
#> SRR944319     2  0.0794      0.888 0.000 0.972 0.00 0.028 0.000
#> SRR944320     2  0.4384      0.520 0.016 0.660 0.00 0.324 0.000
#> SRR944321     1  0.0000      0.889 1.000 0.000 0.00 0.000 0.000
#> SRR944322     1  0.0000      0.889 1.000 0.000 0.00 0.000 0.000
#> SRR944323     1  0.0000      0.889 1.000 0.000 0.00 0.000 0.000
#> SRR944324     1  0.0000      0.889 1.000 0.000 0.00 0.000 0.000
#> SRR944325     1  0.0000      0.889 1.000 0.000 0.00 0.000 0.000
#> SRR944326     1  0.0000      0.889 1.000 0.000 0.00 0.000 0.000
#> SRR944327     5  0.6174      0.846 0.192 0.000 0.00 0.256 0.552
#> SRR944328     5  0.6470      0.847 0.156 0.020 0.00 0.260 0.564
#> SRR944329     1  0.0000      0.889 1.000 0.000 0.00 0.000 0.000
#> SRR944330     1  0.0000      0.889 1.000 0.000 0.00 0.000 0.000
#> SRR944331     1  0.0000      0.889 1.000 0.000 0.00 0.000 0.000
#> SRR944332     1  0.0000      0.889 1.000 0.000 0.00 0.000 0.000
#> SRR944334     1  0.0000      0.889 1.000 0.000 0.00 0.000 0.000
#> SRR944333     1  0.0000      0.889 1.000 0.000 0.00 0.000 0.000
#> SRR944335     1  0.0000      0.889 1.000 0.000 0.00 0.000 0.000
#> SRR944336     1  0.0000      0.889 1.000 0.000 0.00 0.000 0.000
#> SRR944337     1  0.0000      0.889 1.000 0.000 0.00 0.000 0.000
#> SRR944338     3  0.0000      0.997 0.000 0.000 1.00 0.000 0.000
#> SRR944339     3  0.0000      0.997 0.000 0.000 1.00 0.000 0.000
#> SRR944340     3  0.0000      0.997 0.000 0.000 1.00 0.000 0.000
#> SRR944341     3  0.0000      0.997 0.000 0.000 1.00 0.000 0.000
#> SRR944342     3  0.0000      0.997 0.000 0.000 1.00 0.000 0.000
#> SRR944343     3  0.0000      0.997 0.000 0.000 1.00 0.000 0.000
#> SRR944344     3  0.0609      0.983 0.000 0.000 0.98 0.020 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
#> SRR944282     1  0.1579      0.836 0.944 0.004 0.000 0.020 0.008 0.024
#> SRR944283     1  0.1772      0.830 0.936 0.008 0.000 0.028 0.008 0.020
#> SRR944284     1  0.3347      0.764 0.848 0.004 0.000 0.060 0.028 0.060
#> SRR944285     1  0.3665      0.744 0.828 0.008 0.000 0.072 0.024 0.068
#> SRR944288     1  0.2848      0.791 0.876 0.008 0.000 0.028 0.016 0.072
#> SRR944287     1  0.2773      0.790 0.876 0.008 0.000 0.044 0.004 0.068
#> SRR944289     1  0.1843      0.822 0.932 0.004 0.000 0.032 0.016 0.016
#> SRR944290     1  0.0820      0.841 0.972 0.000 0.000 0.000 0.016 0.012
#> SRR944291     1  0.5022      0.450 0.708 0.004 0.000 0.164 0.084 0.040
#> SRR944292     5  0.6105      0.700 0.108 0.216 0.000 0.052 0.608 0.016
#> SRR944293     1  0.3276      0.770 0.856 0.012 0.000 0.052 0.020 0.060
#> SRR944294     1  0.2494      0.811 0.900 0.012 0.000 0.048 0.012 0.028
#> SRR944295     2  0.0777      0.895 0.000 0.972 0.000 0.004 0.024 0.000
#> SRR944296     2  0.2118      0.850 0.000 0.888 0.000 0.008 0.104 0.000
#> SRR944297     2  0.1643      0.878 0.000 0.924 0.000 0.008 0.068 0.000
#> SRR944298     2  0.1010      0.895 0.000 0.960 0.000 0.004 0.036 0.000
#> SRR944299     6  0.4022      0.851 0.360 0.000 0.000 0.008 0.004 0.628
#> SRR944300     6  0.3890      0.851 0.400 0.000 0.000 0.000 0.004 0.596
#> SRR944301     1  0.1149      0.839 0.960 0.000 0.000 0.008 0.008 0.024
#> SRR944302     5  0.5079      0.677 0.132 0.108 0.000 0.032 0.716 0.012
#> SRR944303     2  0.0777      0.895 0.000 0.972 0.000 0.004 0.024 0.000
#> SRR944304     1  0.3324      0.756 0.840 0.000 0.000 0.024 0.048 0.088
#> SRR944305     1  0.6569     -0.632 0.444 0.000 0.000 0.040 0.204 0.312
#> SRR944306     1  0.4224     -0.151 0.640 0.000 0.000 0.008 0.016 0.336
#> SRR944307     6  0.4252      0.824 0.344 0.000 0.000 0.016 0.008 0.632
#> SRR944308     1  0.3254      0.630 0.804 0.000 0.000 0.016 0.008 0.172
#> SRR944309     1  0.4221     -0.334 0.588 0.000 0.000 0.008 0.008 0.396
#> SRR944310     1  0.3032      0.761 0.844 0.004 0.000 0.012 0.016 0.124
#> SRR944311     2  0.0000      0.900 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944312     6  0.4227      0.661 0.488 0.000 0.000 0.008 0.004 0.500
#> SRR944313     1  0.3418      0.635 0.784 0.000 0.000 0.008 0.016 0.192
#> SRR944315     1  0.0820      0.841 0.972 0.000 0.000 0.000 0.016 0.012
#> SRR944314     1  0.2648      0.797 0.884 0.008 0.000 0.040 0.004 0.064
#> SRR944316     1  0.3720      0.741 0.824 0.008 0.000 0.072 0.024 0.072
#> SRR944317     2  0.0692      0.896 0.000 0.976 0.000 0.004 0.020 0.000
#> SRR944318     2  0.1010      0.895 0.000 0.960 0.000 0.004 0.036 0.000
#> SRR944319     2  0.2344      0.840 0.000 0.896 0.000 0.008 0.068 0.028
#> SRR944320     2  0.4216      0.495 0.012 0.676 0.000 0.020 0.292 0.000
#> SRR944321     1  0.0146      0.844 0.996 0.000 0.000 0.000 0.000 0.004
#> SRR944322     1  0.0146      0.844 0.996 0.000 0.000 0.000 0.000 0.004
#> SRR944323     1  0.0146      0.844 0.996 0.000 0.000 0.000 0.000 0.004
#> SRR944324     1  0.0146      0.844 0.996 0.000 0.000 0.000 0.000 0.004
#> SRR944325     1  0.0146      0.844 0.996 0.000 0.000 0.000 0.000 0.004
#> SRR944326     1  0.0146      0.844 0.996 0.000 0.000 0.000 0.000 0.004
#> SRR944327     4  0.6484      0.624 0.160 0.008 0.000 0.552 0.060 0.220
#> SRR944328     4  0.2604      0.635 0.100 0.020 0.000 0.872 0.008 0.000
#> SRR944329     1  0.0146      0.844 0.996 0.000 0.000 0.000 0.000 0.004
#> SRR944330     1  0.0146      0.844 0.996 0.000 0.000 0.000 0.000 0.004
#> SRR944331     1  0.0146      0.844 0.996 0.000 0.000 0.000 0.000 0.004
#> SRR944332     1  0.0146      0.844 0.996 0.000 0.000 0.000 0.000 0.004
#> SRR944334     1  0.0146      0.844 0.996 0.000 0.000 0.000 0.000 0.004
#> SRR944333     1  0.0146      0.844 0.996 0.000 0.000 0.000 0.000 0.004
#> SRR944335     1  0.0146      0.844 0.996 0.000 0.000 0.000 0.000 0.004
#> SRR944336     1  0.0146      0.844 0.996 0.000 0.000 0.000 0.000 0.004
#> SRR944337     1  0.0146      0.844 0.996 0.000 0.000 0.000 0.000 0.004
#> SRR944338     3  0.0000      0.991 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR944339     3  0.0000      0.991 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR944340     3  0.0000      0.991 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR944341     3  0.0000      0.991 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR944342     3  0.0000      0.991 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR944343     3  0.0000      0.991 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR944344     3  0.1528      0.942 0.000 0.000 0.936 0.048 0.016 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-hclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-hclust-collect-classes

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


CV:kmeans

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

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

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

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

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.577           0.928       0.921         0.3688 0.568   0.568
#> 3 3 0.626           0.914       0.906         0.3728 0.927   0.876
#> 4 4 0.646           0.863       0.885         0.3552 0.727   0.506
#> 5 5 0.670           0.644       0.743         0.0936 0.920   0.730
#> 6 6 0.735           0.639       0.757         0.0522 0.907   0.658

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
#> SRR944282     1  0.2778      0.951 0.952 0.048
#> SRR944283     1  0.2778      0.951 0.952 0.048
#> SRR944284     1  0.2778      0.951 0.952 0.048
#> SRR944285     1  0.2778      0.951 0.952 0.048
#> SRR944288     1  0.2778      0.951 0.952 0.048
#> SRR944287     1  0.0000      0.981 1.000 0.000
#> SRR944289     1  0.2778      0.951 0.952 0.048
#> SRR944290     1  0.0000      0.981 1.000 0.000
#> SRR944291     1  0.2778      0.951 0.952 0.048
#> SRR944292     2  0.7950      0.858 0.240 0.760
#> SRR944293     1  0.2778      0.951 0.952 0.048
#> SRR944294     1  0.2778      0.951 0.952 0.048
#> SRR944295     2  0.7883      0.861 0.236 0.764
#> SRR944296     2  0.7883      0.861 0.236 0.764
#> SRR944297     2  0.7883      0.861 0.236 0.764
#> SRR944298     2  0.7883      0.861 0.236 0.764
#> SRR944299     1  0.0000      0.981 1.000 0.000
#> SRR944300     1  0.0000      0.981 1.000 0.000
#> SRR944301     1  0.0938      0.975 0.988 0.012
#> SRR944302     2  0.9608      0.665 0.384 0.616
#> SRR944303     2  0.7883      0.861 0.236 0.764
#> SRR944304     1  0.0938      0.975 0.988 0.012
#> SRR944305     1  0.0000      0.981 1.000 0.000
#> SRR944306     1  0.0000      0.981 1.000 0.000
#> SRR944307     1  0.0000      0.981 1.000 0.000
#> SRR944308     1  0.0000      0.981 1.000 0.000
#> SRR944309     1  0.0000      0.981 1.000 0.000
#> SRR944310     1  0.0376      0.979 0.996 0.004
#> SRR944311     2  0.7883      0.861 0.236 0.764
#> SRR944312     1  0.0000      0.981 1.000 0.000
#> SRR944313     1  0.0000      0.981 1.000 0.000
#> SRR944315     1  0.1184      0.973 0.984 0.016
#> SRR944314     1  0.0000      0.981 1.000 0.000
#> SRR944316     1  0.0000      0.981 1.000 0.000
#> SRR944317     2  0.7883      0.861 0.236 0.764
#> SRR944318     2  0.7883      0.861 0.236 0.764
#> SRR944319     2  0.8081      0.849 0.248 0.752
#> SRR944320     2  0.7883      0.861 0.236 0.764
#> SRR944321     1  0.0000      0.981 1.000 0.000
#> SRR944322     1  0.0000      0.981 1.000 0.000
#> SRR944323     1  0.0000      0.981 1.000 0.000
#> SRR944324     1  0.0000      0.981 1.000 0.000
#> SRR944325     1  0.0000      0.981 1.000 0.000
#> SRR944326     1  0.0000      0.981 1.000 0.000
#> SRR944327     1  0.2778      0.951 0.952 0.048
#> SRR944328     1  0.3879      0.917 0.924 0.076
#> SRR944329     1  0.0000      0.981 1.000 0.000
#> SRR944330     1  0.0000      0.981 1.000 0.000
#> SRR944331     1  0.0000      0.981 1.000 0.000
#> SRR944332     1  0.0000      0.981 1.000 0.000
#> SRR944334     1  0.0000      0.981 1.000 0.000
#> SRR944333     1  0.0000      0.981 1.000 0.000
#> SRR944335     1  0.0000      0.981 1.000 0.000
#> SRR944336     1  0.0000      0.981 1.000 0.000
#> SRR944337     1  0.0000      0.981 1.000 0.000
#> SRR944338     2  0.5737      0.801 0.136 0.864
#> SRR944339     2  0.5737      0.801 0.136 0.864
#> SRR944340     2  0.5737      0.801 0.136 0.864
#> SRR944341     2  0.5737      0.801 0.136 0.864
#> SRR944342     2  0.5737      0.801 0.136 0.864
#> SRR944343     2  0.5737      0.801 0.136 0.864
#> SRR944344     2  0.5737      0.801 0.136 0.864

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> SRR944282     1  0.6594      0.833 0.756 0.128 0.116
#> SRR944283     1  0.6254      0.848 0.776 0.108 0.116
#> SRR944284     1  0.6325      0.845 0.772 0.112 0.116
#> SRR944285     1  0.6031      0.856 0.788 0.096 0.116
#> SRR944288     1  0.6728      0.827 0.748 0.128 0.124
#> SRR944287     1  0.2959      0.904 0.900 0.000 0.100
#> SRR944289     1  0.6184      0.848 0.780 0.112 0.108
#> SRR944290     1  0.0237      0.905 0.996 0.000 0.004
#> SRR944291     1  0.6460      0.841 0.764 0.112 0.124
#> SRR944292     2  0.1751      0.957 0.012 0.960 0.028
#> SRR944293     1  0.6325      0.845 0.772 0.112 0.116
#> SRR944294     1  0.6254      0.848 0.776 0.108 0.116
#> SRR944295     2  0.0592      0.996 0.012 0.988 0.000
#> SRR944296     2  0.0592      0.996 0.012 0.988 0.000
#> SRR944297     2  0.0592      0.996 0.012 0.988 0.000
#> SRR944298     2  0.0592      0.996 0.012 0.988 0.000
#> SRR944299     1  0.1163      0.901 0.972 0.000 0.028
#> SRR944300     1  0.1163      0.901 0.972 0.000 0.028
#> SRR944301     1  0.3965      0.895 0.860 0.008 0.132
#> SRR944302     1  0.8058      0.696 0.640 0.236 0.124
#> SRR944303     2  0.0592      0.996 0.012 0.988 0.000
#> SRR944304     1  0.4277      0.893 0.852 0.016 0.132
#> SRR944305     1  0.2261      0.905 0.932 0.000 0.068
#> SRR944306     1  0.3482      0.898 0.872 0.000 0.128
#> SRR944307     1  0.1529      0.896 0.960 0.000 0.040
#> SRR944308     1  0.3116      0.902 0.892 0.000 0.108
#> SRR944309     1  0.2165      0.905 0.936 0.000 0.064
#> SRR944310     1  0.4033      0.895 0.856 0.008 0.136
#> SRR944311     2  0.0592      0.996 0.012 0.988 0.000
#> SRR944312     1  0.1529      0.896 0.960 0.000 0.040
#> SRR944313     1  0.3551      0.897 0.868 0.000 0.132
#> SRR944315     1  0.3995      0.894 0.868 0.016 0.116
#> SRR944314     1  0.3340      0.900 0.880 0.000 0.120
#> SRR944316     1  0.3038      0.902 0.896 0.000 0.104
#> SRR944317     2  0.0592      0.996 0.012 0.988 0.000
#> SRR944318     2  0.0592      0.996 0.012 0.988 0.000
#> SRR944319     2  0.0592      0.996 0.012 0.988 0.000
#> SRR944320     2  0.0592      0.996 0.012 0.988 0.000
#> SRR944321     1  0.0892      0.901 0.980 0.000 0.020
#> SRR944322     1  0.0892      0.901 0.980 0.000 0.020
#> SRR944323     1  0.0892      0.901 0.980 0.000 0.020
#> SRR944324     1  0.0892      0.901 0.980 0.000 0.020
#> SRR944325     1  0.0892      0.901 0.980 0.000 0.020
#> SRR944326     1  0.0892      0.901 0.980 0.000 0.020
#> SRR944327     1  0.6594      0.835 0.756 0.116 0.128
#> SRR944328     1  0.7155      0.800 0.720 0.152 0.128
#> SRR944329     1  0.0000      0.906 1.000 0.000 0.000
#> SRR944330     1  0.0000      0.906 1.000 0.000 0.000
#> SRR944331     1  0.0000      0.906 1.000 0.000 0.000
#> SRR944332     1  0.0000      0.906 1.000 0.000 0.000
#> SRR944334     1  0.0000      0.906 1.000 0.000 0.000
#> SRR944333     1  0.0000      0.906 1.000 0.000 0.000
#> SRR944335     1  0.0424      0.905 0.992 0.000 0.008
#> SRR944336     1  0.0424      0.905 0.992 0.000 0.008
#> SRR944337     1  0.0424      0.905 0.992 0.000 0.008
#> SRR944338     3  0.4121      0.999 0.000 0.168 0.832
#> SRR944339     3  0.4121      0.999 0.000 0.168 0.832
#> SRR944340     3  0.4121      0.999 0.000 0.168 0.832
#> SRR944341     3  0.4121      0.999 0.000 0.168 0.832
#> SRR944342     3  0.4121      0.999 0.000 0.168 0.832
#> SRR944343     3  0.4121      0.999 0.000 0.168 0.832
#> SRR944344     3  0.4291      0.991 0.000 0.180 0.820

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> SRR944282     1  0.1863      0.872 0.944 0.012 0.004 0.040
#> SRR944283     1  0.1863      0.872 0.944 0.012 0.004 0.040
#> SRR944284     1  0.1863      0.872 0.944 0.012 0.004 0.040
#> SRR944285     1  0.1767      0.872 0.944 0.012 0.000 0.044
#> SRR944288     1  0.1509      0.867 0.960 0.012 0.008 0.020
#> SRR944287     1  0.5452      0.134 0.556 0.000 0.016 0.428
#> SRR944289     1  0.3315      0.838 0.872 0.016 0.008 0.104
#> SRR944290     4  0.3982      0.863 0.220 0.000 0.004 0.776
#> SRR944291     1  0.1124      0.864 0.972 0.012 0.004 0.012
#> SRR944292     1  0.3937      0.673 0.800 0.188 0.012 0.000
#> SRR944293     1  0.1767      0.872 0.944 0.012 0.000 0.044
#> SRR944294     1  0.1767      0.872 0.944 0.012 0.000 0.044
#> SRR944295     2  0.0592      0.992 0.016 0.984 0.000 0.000
#> SRR944296     2  0.0817      0.994 0.024 0.976 0.000 0.000
#> SRR944297     2  0.0817      0.994 0.024 0.976 0.000 0.000
#> SRR944298     2  0.0817      0.994 0.024 0.976 0.000 0.000
#> SRR944299     4  0.2706      0.854 0.080 0.000 0.020 0.900
#> SRR944300     4  0.3991      0.780 0.172 0.000 0.020 0.808
#> SRR944301     1  0.3108      0.848 0.872 0.000 0.016 0.112
#> SRR944302     1  0.1488      0.847 0.956 0.032 0.012 0.000
#> SRR944303     2  0.0592      0.992 0.016 0.984 0.000 0.000
#> SRR944304     1  0.3224      0.843 0.864 0.000 0.016 0.120
#> SRR944305     4  0.4976      0.617 0.260 0.004 0.020 0.716
#> SRR944306     1  0.3597      0.831 0.836 0.000 0.016 0.148
#> SRR944307     4  0.1452      0.857 0.036 0.000 0.008 0.956
#> SRR944308     1  0.5472      0.244 0.544 0.000 0.016 0.440
#> SRR944309     4  0.3900      0.784 0.164 0.000 0.020 0.816
#> SRR944310     1  0.3108      0.848 0.872 0.000 0.016 0.112
#> SRR944311     2  0.0817      0.994 0.024 0.976 0.000 0.000
#> SRR944312     4  0.1722      0.857 0.048 0.000 0.008 0.944
#> SRR944313     1  0.3166      0.847 0.868 0.000 0.016 0.116
#> SRR944315     1  0.1637      0.862 0.940 0.000 0.000 0.060
#> SRR944314     1  0.3942      0.708 0.764 0.000 0.000 0.236
#> SRR944316     1  0.4222      0.587 0.728 0.000 0.000 0.272
#> SRR944317     2  0.0592      0.992 0.016 0.984 0.000 0.000
#> SRR944318     2  0.0817      0.994 0.024 0.976 0.000 0.000
#> SRR944319     2  0.0927      0.978 0.016 0.976 0.008 0.000
#> SRR944320     2  0.0817      0.994 0.024 0.976 0.000 0.000
#> SRR944321     4  0.2593      0.893 0.104 0.000 0.004 0.892
#> SRR944322     4  0.2593      0.893 0.104 0.000 0.004 0.892
#> SRR944323     4  0.2593      0.893 0.104 0.000 0.004 0.892
#> SRR944324     4  0.2593      0.893 0.104 0.000 0.004 0.892
#> SRR944325     4  0.2593      0.893 0.104 0.000 0.004 0.892
#> SRR944326     4  0.2593      0.893 0.104 0.000 0.004 0.892
#> SRR944327     1  0.1617      0.857 0.956 0.012 0.024 0.008
#> SRR944328     1  0.1520      0.849 0.956 0.020 0.024 0.000
#> SRR944329     4  0.4192      0.866 0.208 0.004 0.008 0.780
#> SRR944330     4  0.4192      0.866 0.208 0.004 0.008 0.780
#> SRR944331     4  0.4153      0.869 0.204 0.004 0.008 0.784
#> SRR944332     4  0.4153      0.869 0.204 0.004 0.008 0.784
#> SRR944334     4  0.4153      0.869 0.204 0.004 0.008 0.784
#> SRR944333     4  0.4153      0.869 0.204 0.004 0.008 0.784
#> SRR944335     4  0.3216      0.893 0.124 0.004 0.008 0.864
#> SRR944336     4  0.3216      0.893 0.124 0.004 0.008 0.864
#> SRR944337     4  0.3032      0.893 0.124 0.000 0.008 0.868
#> SRR944338     3  0.1557      0.994 0.000 0.056 0.944 0.000
#> SRR944339     3  0.1743      0.994 0.000 0.056 0.940 0.004
#> SRR944340     3  0.1824      0.994 0.000 0.060 0.936 0.004
#> SRR944341     3  0.1824      0.994 0.000 0.060 0.936 0.004
#> SRR944342     3  0.1637      0.994 0.000 0.060 0.940 0.000
#> SRR944343     3  0.1557      0.994 0.000 0.056 0.944 0.000
#> SRR944344     3  0.2599      0.979 0.004 0.064 0.912 0.020

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> SRR944282     1  0.1780      0.782 0.940 0.008 0.000 0.028 0.024
#> SRR944283     1  0.1686      0.782 0.944 0.008 0.000 0.020 0.028
#> SRR944284     1  0.1780      0.782 0.940 0.008 0.000 0.028 0.024
#> SRR944285     1  0.1603      0.782 0.948 0.004 0.004 0.012 0.032
#> SRR944288     1  0.0981      0.778 0.972 0.008 0.000 0.008 0.012
#> SRR944287     1  0.4906      0.271 0.496 0.000 0.000 0.024 0.480
#> SRR944289     1  0.5118      0.561 0.684 0.008 0.000 0.240 0.068
#> SRR944290     5  0.6296     -0.687 0.160 0.000 0.000 0.360 0.480
#> SRR944291     1  0.2150      0.759 0.916 0.008 0.004 0.068 0.004
#> SRR944292     1  0.4845      0.649 0.728 0.076 0.008 0.188 0.000
#> SRR944293     1  0.1729      0.782 0.944 0.008 0.004 0.012 0.032
#> SRR944294     1  0.1729      0.782 0.944 0.008 0.004 0.012 0.032
#> SRR944295     2  0.1638      0.965 0.004 0.932 0.000 0.064 0.000
#> SRR944296     2  0.0162      0.974 0.004 0.996 0.000 0.000 0.000
#> SRR944297     2  0.0162      0.974 0.004 0.996 0.000 0.000 0.000
#> SRR944298     2  0.0162      0.974 0.004 0.996 0.000 0.000 0.000
#> SRR944299     5  0.2519      0.239 0.060 0.000 0.004 0.036 0.900
#> SRR944300     5  0.3170      0.283 0.160 0.000 0.004 0.008 0.828
#> SRR944301     1  0.3895      0.639 0.680 0.000 0.000 0.000 0.320
#> SRR944302     1  0.3665      0.693 0.784 0.008 0.008 0.200 0.000
#> SRR944303     2  0.1502      0.968 0.004 0.940 0.000 0.056 0.000
#> SRR944304     1  0.4826      0.618 0.644 0.000 0.008 0.024 0.324
#> SRR944305     5  0.5351      0.122 0.260 0.000 0.008 0.076 0.656
#> SRR944306     1  0.4960      0.550 0.584 0.000 0.008 0.020 0.388
#> SRR944307     5  0.4046      0.129 0.000 0.000 0.008 0.296 0.696
#> SRR944308     5  0.4305     -0.377 0.488 0.000 0.000 0.000 0.512
#> SRR944309     5  0.3333      0.284 0.208 0.000 0.004 0.000 0.788
#> SRR944310     1  0.3895      0.639 0.680 0.000 0.000 0.000 0.320
#> SRR944311     2  0.1041      0.972 0.004 0.964 0.000 0.032 0.000
#> SRR944312     5  0.3699      0.189 0.008 0.000 0.008 0.204 0.780
#> SRR944313     1  0.3966      0.626 0.664 0.000 0.000 0.000 0.336
#> SRR944315     1  0.1469      0.781 0.948 0.000 0.000 0.016 0.036
#> SRR944314     1  0.4701      0.624 0.720 0.000 0.000 0.076 0.204
#> SRR944316     1  0.4126      0.661 0.784 0.000 0.004 0.056 0.156
#> SRR944317     2  0.1638      0.965 0.004 0.932 0.000 0.064 0.000
#> SRR944318     2  0.0162      0.974 0.004 0.996 0.000 0.000 0.000
#> SRR944319     2  0.2020      0.944 0.000 0.900 0.000 0.100 0.000
#> SRR944320     2  0.0162      0.974 0.004 0.996 0.000 0.000 0.000
#> SRR944321     5  0.4734      0.074 0.016 0.000 0.008 0.344 0.632
#> SRR944322     5  0.4734      0.074 0.016 0.000 0.008 0.344 0.632
#> SRR944323     5  0.4734      0.074 0.016 0.000 0.008 0.344 0.632
#> SRR944324     5  0.4734      0.074 0.016 0.000 0.008 0.344 0.632
#> SRR944325     5  0.4734      0.074 0.016 0.000 0.008 0.344 0.632
#> SRR944326     5  0.4734      0.074 0.016 0.000 0.008 0.344 0.632
#> SRR944327     1  0.3631      0.692 0.788 0.008 0.008 0.196 0.000
#> SRR944328     1  0.3561      0.695 0.796 0.008 0.008 0.188 0.000
#> SRR944329     4  0.6203      0.901 0.140 0.000 0.000 0.464 0.396
#> SRR944330     4  0.6203      0.901 0.140 0.000 0.000 0.464 0.396
#> SRR944331     4  0.6207      0.905 0.140 0.000 0.000 0.460 0.400
#> SRR944332     4  0.6207      0.905 0.140 0.000 0.000 0.460 0.400
#> SRR944334     4  0.6207      0.905 0.140 0.000 0.000 0.460 0.400
#> SRR944333     4  0.6207      0.905 0.140 0.000 0.000 0.460 0.400
#> SRR944335     4  0.5457      0.800 0.060 0.000 0.000 0.480 0.460
#> SRR944336     4  0.5457      0.800 0.060 0.000 0.000 0.480 0.460
#> SRR944337     4  0.5457      0.800 0.060 0.000 0.000 0.480 0.460
#> SRR944338     3  0.0703      0.989 0.000 0.024 0.976 0.000 0.000
#> SRR944339     3  0.0703      0.989 0.000 0.024 0.976 0.000 0.000
#> SRR944340     3  0.0703      0.989 0.000 0.024 0.976 0.000 0.000
#> SRR944341     3  0.0703      0.989 0.000 0.024 0.976 0.000 0.000
#> SRR944342     3  0.0703      0.989 0.000 0.024 0.976 0.000 0.000
#> SRR944343     3  0.0703      0.989 0.000 0.024 0.976 0.000 0.000
#> SRR944344     3  0.2707      0.930 0.000 0.024 0.876 0.100 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
#> SRR944282     1  0.0748      0.616 0.976 0.000 0.000 0.016 0.004 NA
#> SRR944283     1  0.0603      0.615 0.980 0.000 0.000 0.016 0.000 NA
#> SRR944284     1  0.1078      0.616 0.964 0.000 0.000 0.016 0.008 NA
#> SRR944285     1  0.1542      0.607 0.944 0.000 0.000 0.016 0.024 NA
#> SRR944288     1  0.1483      0.600 0.944 0.000 0.000 0.008 0.036 NA
#> SRR944287     1  0.5484     -0.462 0.500 0.000 0.000 0.100 0.392 NA
#> SRR944289     1  0.5490      0.177 0.548 0.000 0.000 0.116 0.008 NA
#> SRR944290     4  0.6313      0.571 0.164 0.000 0.000 0.584 0.112 NA
#> SRR944291     1  0.3170      0.569 0.844 0.000 0.004 0.008 0.040 NA
#> SRR944292     1  0.6337      0.400 0.568 0.064 0.008 0.000 0.124 NA
#> SRR944293     1  0.1346      0.609 0.952 0.000 0.000 0.016 0.024 NA
#> SRR944294     1  0.1346      0.609 0.952 0.000 0.000 0.016 0.024 NA
#> SRR944295     2  0.2721      0.926 0.004 0.868 0.000 0.000 0.088 NA
#> SRR944296     2  0.0291      0.940 0.004 0.992 0.000 0.000 0.000 NA
#> SRR944297     2  0.0291      0.940 0.004 0.992 0.000 0.000 0.000 NA
#> SRR944298     2  0.0146      0.941 0.004 0.996 0.000 0.000 0.000 NA
#> SRR944299     5  0.5727      0.640 0.140 0.000 0.000 0.252 0.584 NA
#> SRR944300     5  0.5459      0.701 0.192 0.000 0.000 0.212 0.592 NA
#> SRR944301     1  0.4152     -0.384 0.548 0.000 0.000 0.012 0.440 NA
#> SRR944302     1  0.5399      0.438 0.612 0.004 0.008 0.000 0.124 NA
#> SRR944303     2  0.2721      0.926 0.004 0.868 0.000 0.000 0.088 NA
#> SRR944304     5  0.4878      0.443 0.468 0.000 0.000 0.008 0.484 NA
#> SRR944305     5  0.6173      0.672 0.224 0.000 0.000 0.104 0.580 NA
#> SRR944306     5  0.4628      0.600 0.392 0.000 0.000 0.012 0.572 NA
#> SRR944307     4  0.1812      0.642 0.008 0.000 0.000 0.912 0.080 NA
#> SRR944308     5  0.5066      0.551 0.436 0.000 0.000 0.064 0.496 NA
#> SRR944309     5  0.5391      0.716 0.244 0.000 0.000 0.176 0.580 NA
#> SRR944310     1  0.4157     -0.394 0.544 0.000 0.000 0.012 0.444 NA
#> SRR944311     2  0.1738      0.937 0.004 0.928 0.000 0.000 0.052 NA
#> SRR944312     4  0.3245      0.464 0.008 0.000 0.000 0.764 0.228 NA
#> SRR944313     1  0.4256     -0.456 0.520 0.000 0.000 0.016 0.464 NA
#> SRR944315     1  0.1364      0.608 0.952 0.000 0.000 0.016 0.020 NA
#> SRR944314     1  0.3627      0.464 0.792 0.000 0.000 0.128 0.080 NA
#> SRR944316     1  0.3329      0.513 0.840 0.000 0.000 0.064 0.076 NA
#> SRR944317     2  0.2721      0.926 0.004 0.868 0.000 0.000 0.088 NA
#> SRR944318     2  0.0291      0.940 0.004 0.992 0.000 0.000 0.000 NA
#> SRR944319     2  0.4043      0.853 0.000 0.756 0.000 0.000 0.128 NA
#> SRR944320     2  0.0551      0.939 0.004 0.984 0.000 0.000 0.004 NA
#> SRR944321     4  0.0458      0.700 0.016 0.000 0.000 0.984 0.000 NA
#> SRR944322     4  0.0458      0.700 0.016 0.000 0.000 0.984 0.000 NA
#> SRR944323     4  0.0458      0.700 0.016 0.000 0.000 0.984 0.000 NA
#> SRR944324     4  0.0458      0.700 0.016 0.000 0.000 0.984 0.000 NA
#> SRR944325     4  0.0458      0.700 0.016 0.000 0.000 0.984 0.000 NA
#> SRR944326     4  0.0458      0.700 0.016 0.000 0.000 0.984 0.000 NA
#> SRR944327     1  0.5248      0.413 0.568 0.000 0.008 0.000 0.088 NA
#> SRR944328     1  0.5252      0.418 0.576 0.000 0.008 0.000 0.092 NA
#> SRR944329     4  0.5348      0.749 0.068 0.000 0.000 0.572 0.024 NA
#> SRR944330     4  0.5348      0.749 0.068 0.000 0.000 0.572 0.024 NA
#> SRR944331     4  0.5348      0.749 0.068 0.000 0.000 0.572 0.024 NA
#> SRR944332     4  0.5348      0.749 0.068 0.000 0.000 0.572 0.024 NA
#> SRR944334     4  0.5348      0.749 0.068 0.000 0.000 0.572 0.024 NA
#> SRR944333     4  0.5348      0.749 0.068 0.000 0.000 0.572 0.024 NA
#> SRR944335     4  0.4900      0.755 0.040 0.000 0.000 0.604 0.020 NA
#> SRR944336     4  0.4900      0.755 0.040 0.000 0.000 0.604 0.020 NA
#> SRR944337     4  0.4900      0.755 0.040 0.000 0.000 0.604 0.020 NA
#> SRR944338     3  0.0405      0.983 0.000 0.008 0.988 0.000 0.004 NA
#> SRR944339     3  0.0260      0.983 0.000 0.008 0.992 0.000 0.000 NA
#> SRR944340     3  0.0260      0.983 0.000 0.008 0.992 0.000 0.000 NA
#> SRR944341     3  0.0520      0.981 0.000 0.008 0.984 0.000 0.008 NA
#> SRR944342     3  0.0405      0.983 0.000 0.008 0.988 0.000 0.004 NA
#> SRR944343     3  0.0260      0.983 0.000 0.008 0.992 0.000 0.000 NA
#> SRR944344     3  0.2951      0.905 0.000 0.008 0.856 0.000 0.044 NA

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-kmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-kmeans-collect-classes

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


CV:skmeans

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

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

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

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

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

collect_plots(res)

plot of chunk CV-skmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.868           0.919       0.966         0.4867 0.511   0.511
#> 3 3 0.629           0.790       0.862         0.2819 0.740   0.546
#> 4 4 0.656           0.770       0.856         0.1414 0.853   0.641
#> 5 5 0.699           0.700       0.830         0.1030 0.869   0.588
#> 6 6 0.725           0.644       0.803         0.0533 0.955   0.790

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
#> SRR944282     2  0.8909      0.544 0.308 0.692
#> SRR944283     1  0.8327      0.657 0.736 0.264
#> SRR944284     2  0.9944      0.134 0.456 0.544
#> SRR944285     1  0.6343      0.811 0.840 0.160
#> SRR944288     2  0.1633      0.936 0.024 0.976
#> SRR944287     1  0.0000      0.967 1.000 0.000
#> SRR944289     1  0.6973      0.776 0.812 0.188
#> SRR944290     1  0.0000      0.967 1.000 0.000
#> SRR944291     2  0.7299      0.731 0.204 0.796
#> SRR944292     2  0.0000      0.956 0.000 1.000
#> SRR944293     1  0.8081      0.685 0.752 0.248
#> SRR944294     1  0.6973      0.776 0.812 0.188
#> SRR944295     2  0.0000      0.956 0.000 1.000
#> SRR944296     2  0.0000      0.956 0.000 1.000
#> SRR944297     2  0.0000      0.956 0.000 1.000
#> SRR944298     2  0.0000      0.956 0.000 1.000
#> SRR944299     1  0.0000      0.967 1.000 0.000
#> SRR944300     1  0.0000      0.967 1.000 0.000
#> SRR944301     1  0.0000      0.967 1.000 0.000
#> SRR944302     2  0.0000      0.956 0.000 1.000
#> SRR944303     2  0.0000      0.956 0.000 1.000
#> SRR944304     1  0.3584      0.909 0.932 0.068
#> SRR944305     1  0.0000      0.967 1.000 0.000
#> SRR944306     1  0.0000      0.967 1.000 0.000
#> SRR944307     1  0.0000      0.967 1.000 0.000
#> SRR944308     1  0.0000      0.967 1.000 0.000
#> SRR944309     1  0.0000      0.967 1.000 0.000
#> SRR944310     1  0.0000      0.967 1.000 0.000
#> SRR944311     2  0.0000      0.956 0.000 1.000
#> SRR944312     1  0.0000      0.967 1.000 0.000
#> SRR944313     1  0.0000      0.967 1.000 0.000
#> SRR944315     1  0.0376      0.964 0.996 0.004
#> SRR944314     1  0.0000      0.967 1.000 0.000
#> SRR944316     1  0.0000      0.967 1.000 0.000
#> SRR944317     2  0.0000      0.956 0.000 1.000
#> SRR944318     2  0.0000      0.956 0.000 1.000
#> SRR944319     2  0.0000      0.956 0.000 1.000
#> SRR944320     2  0.0000      0.956 0.000 1.000
#> SRR944321     1  0.0000      0.967 1.000 0.000
#> SRR944322     1  0.0000      0.967 1.000 0.000
#> SRR944323     1  0.0000      0.967 1.000 0.000
#> SRR944324     1  0.0000      0.967 1.000 0.000
#> SRR944325     1  0.0000      0.967 1.000 0.000
#> SRR944326     1  0.0000      0.967 1.000 0.000
#> SRR944327     2  0.0376      0.953 0.004 0.996
#> SRR944328     2  0.0000      0.956 0.000 1.000
#> SRR944329     1  0.0000      0.967 1.000 0.000
#> SRR944330     1  0.0000      0.967 1.000 0.000
#> SRR944331     1  0.0000      0.967 1.000 0.000
#> SRR944332     1  0.0000      0.967 1.000 0.000
#> SRR944334     1  0.0000      0.967 1.000 0.000
#> SRR944333     1  0.0000      0.967 1.000 0.000
#> SRR944335     1  0.0000      0.967 1.000 0.000
#> SRR944336     1  0.0000      0.967 1.000 0.000
#> SRR944337     1  0.0000      0.967 1.000 0.000
#> SRR944338     2  0.0000      0.956 0.000 1.000
#> SRR944339     2  0.0000      0.956 0.000 1.000
#> SRR944340     2  0.0000      0.956 0.000 1.000
#> SRR944341     2  0.0000      0.956 0.000 1.000
#> SRR944342     2  0.0000      0.956 0.000 1.000
#> SRR944343     2  0.0000      0.956 0.000 1.000
#> SRR944344     2  0.0000      0.956 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
#> SRR944282     1  0.7482    0.63235 0.688 0.108 0.204
#> SRR944283     1  0.4733    0.73788 0.800 0.004 0.196
#> SRR944284     1  0.8259    0.56073 0.632 0.152 0.216
#> SRR944285     1  0.4465    0.75439 0.820 0.004 0.176
#> SRR944288     1  0.9063    0.40527 0.552 0.248 0.200
#> SRR944287     1  0.0237    0.84246 0.996 0.000 0.004
#> SRR944289     3  0.0475    0.62105 0.004 0.004 0.992
#> SRR944290     1  0.4974    0.53297 0.764 0.000 0.236
#> SRR944291     3  0.9996   -0.25349 0.324 0.328 0.348
#> SRR944292     2  0.4555    0.89217 0.000 0.800 0.200
#> SRR944293     1  0.6108    0.69196 0.732 0.028 0.240
#> SRR944294     1  0.4555    0.73639 0.800 0.000 0.200
#> SRR944295     2  0.4931    0.89839 0.000 0.768 0.232
#> SRR944296     2  0.4931    0.89839 0.000 0.768 0.232
#> SRR944297     2  0.4931    0.89839 0.000 0.768 0.232
#> SRR944298     2  0.4931    0.89839 0.000 0.768 0.232
#> SRR944299     1  0.1529    0.82507 0.960 0.000 0.040
#> SRR944300     1  0.0892    0.83915 0.980 0.000 0.020
#> SRR944301     1  0.2448    0.82320 0.924 0.000 0.076
#> SRR944302     2  0.3686    0.88387 0.000 0.860 0.140
#> SRR944303     2  0.4931    0.89839 0.000 0.768 0.232
#> SRR944304     1  0.5343    0.76826 0.816 0.052 0.132
#> SRR944305     1  0.0424    0.84240 0.992 0.000 0.008
#> SRR944306     1  0.2496    0.81889 0.928 0.004 0.068
#> SRR944307     1  0.1031    0.83668 0.976 0.000 0.024
#> SRR944308     1  0.0424    0.84229 0.992 0.000 0.008
#> SRR944309     1  0.0237    0.84245 0.996 0.000 0.004
#> SRR944310     1  0.3030    0.81319 0.904 0.004 0.092
#> SRR944311     2  0.4931    0.89839 0.000 0.768 0.232
#> SRR944312     1  0.0592    0.84155 0.988 0.000 0.012
#> SRR944313     1  0.2280    0.83290 0.940 0.008 0.052
#> SRR944315     1  0.2356    0.82508 0.928 0.000 0.072
#> SRR944314     1  0.0000    0.84192 1.000 0.000 0.000
#> SRR944316     1  0.1453    0.84066 0.968 0.008 0.024
#> SRR944317     2  0.4974    0.89650 0.000 0.764 0.236
#> SRR944318     2  0.4931    0.89839 0.000 0.768 0.232
#> SRR944319     2  0.5058    0.89021 0.000 0.756 0.244
#> SRR944320     2  0.4931    0.89839 0.000 0.768 0.232
#> SRR944321     1  0.0747    0.84094 0.984 0.000 0.016
#> SRR944322     1  0.0747    0.84094 0.984 0.000 0.016
#> SRR944323     1  0.0747    0.84094 0.984 0.000 0.016
#> SRR944324     1  0.0747    0.84094 0.984 0.000 0.016
#> SRR944325     1  0.0747    0.84094 0.984 0.000 0.016
#> SRR944326     1  0.0747    0.84094 0.984 0.000 0.016
#> SRR944327     1  0.9584    0.00592 0.428 0.372 0.200
#> SRR944328     2  0.6495    0.84337 0.060 0.740 0.200
#> SRR944329     3  0.4555    0.87438 0.200 0.000 0.800
#> SRR944330     3  0.4555    0.87438 0.200 0.000 0.800
#> SRR944331     3  0.4555    0.87438 0.200 0.000 0.800
#> SRR944332     3  0.4555    0.87438 0.200 0.000 0.800
#> SRR944334     3  0.4555    0.87438 0.200 0.000 0.800
#> SRR944333     3  0.4555    0.87438 0.200 0.000 0.800
#> SRR944335     3  0.4931    0.85391 0.232 0.000 0.768
#> SRR944336     3  0.4931    0.85391 0.232 0.000 0.768
#> SRR944337     3  0.4931    0.85391 0.232 0.000 0.768
#> SRR944338     2  0.0000    0.83684 0.000 1.000 0.000
#> SRR944339     2  0.0000    0.83684 0.000 1.000 0.000
#> SRR944340     2  0.0000    0.83684 0.000 1.000 0.000
#> SRR944341     2  0.0000    0.83684 0.000 1.000 0.000
#> SRR944342     2  0.0000    0.83684 0.000 1.000 0.000
#> SRR944343     2  0.0000    0.83684 0.000 1.000 0.000
#> SRR944344     2  0.0000    0.83684 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
#> SRR944282     2  0.6605    -0.0698 0.440 0.480 0.080 0.000
#> SRR944283     1  0.5085     0.5924 0.676 0.304 0.020 0.000
#> SRR944284     2  0.6990     0.1857 0.364 0.548 0.056 0.032
#> SRR944285     1  0.4193     0.7710 0.796 0.184 0.016 0.004
#> SRR944288     2  0.6224     0.4458 0.264 0.648 0.084 0.004
#> SRR944287     1  0.0817     0.8746 0.976 0.000 0.000 0.024
#> SRR944289     4  0.3128     0.8219 0.004 0.128 0.004 0.864
#> SRR944290     1  0.3945     0.7675 0.780 0.004 0.000 0.216
#> SRR944291     2  0.7065     0.4801 0.196 0.652 0.104 0.048
#> SRR944292     2  0.4564     0.5449 0.000 0.672 0.328 0.000
#> SRR944293     1  0.7209     0.2839 0.508 0.396 0.036 0.060
#> SRR944294     1  0.4690     0.6623 0.712 0.276 0.000 0.012
#> SRR944295     2  0.3547     0.7297 0.000 0.840 0.144 0.016
#> SRR944296     2  0.3479     0.7270 0.000 0.840 0.148 0.012
#> SRR944297     2  0.3547     0.7297 0.000 0.840 0.144 0.016
#> SRR944298     2  0.3547     0.7297 0.000 0.840 0.144 0.016
#> SRR944299     1  0.3324     0.8445 0.852 0.012 0.000 0.136
#> SRR944300     1  0.2002     0.8768 0.936 0.020 0.000 0.044
#> SRR944301     1  0.2654     0.8505 0.888 0.108 0.000 0.004
#> SRR944302     3  0.5244     0.1404 0.012 0.388 0.600 0.000
#> SRR944303     2  0.3547     0.7297 0.000 0.840 0.144 0.016
#> SRR944304     1  0.6138     0.7078 0.716 0.176 0.076 0.032
#> SRR944305     1  0.2443     0.8720 0.916 0.060 0.000 0.024
#> SRR944306     1  0.4296     0.8392 0.832 0.084 0.008 0.076
#> SRR944307     1  0.2530     0.8665 0.896 0.004 0.000 0.100
#> SRR944308     1  0.2131     0.8758 0.932 0.032 0.000 0.036
#> SRR944309     1  0.1820     0.8758 0.944 0.020 0.000 0.036
#> SRR944310     1  0.4771     0.8126 0.788 0.148 0.004 0.060
#> SRR944311     2  0.3547     0.7297 0.000 0.840 0.144 0.016
#> SRR944312     1  0.1743     0.8750 0.940 0.004 0.000 0.056
#> SRR944313     1  0.4203     0.8337 0.828 0.128 0.012 0.032
#> SRR944315     1  0.3266     0.8539 0.868 0.108 0.000 0.024
#> SRR944314     1  0.1151     0.8721 0.968 0.024 0.000 0.008
#> SRR944316     1  0.3150     0.8644 0.888 0.036 0.004 0.072
#> SRR944317     2  0.3547     0.7297 0.000 0.840 0.144 0.016
#> SRR944318     2  0.3547     0.7297 0.000 0.840 0.144 0.016
#> SRR944319     2  0.4307     0.7016 0.000 0.808 0.144 0.048
#> SRR944320     2  0.3547     0.7297 0.000 0.840 0.144 0.016
#> SRR944321     1  0.1978     0.8748 0.928 0.004 0.000 0.068
#> SRR944322     1  0.1978     0.8748 0.928 0.004 0.000 0.068
#> SRR944323     1  0.1978     0.8748 0.928 0.004 0.000 0.068
#> SRR944324     1  0.1978     0.8748 0.928 0.004 0.000 0.068
#> SRR944325     1  0.1978     0.8748 0.928 0.004 0.000 0.068
#> SRR944326     1  0.1978     0.8748 0.928 0.004 0.000 0.068
#> SRR944327     2  0.6859     0.3908 0.256 0.588 0.156 0.000
#> SRR944328     2  0.5619     0.3748 0.040 0.640 0.320 0.000
#> SRR944329     4  0.0188     0.9705 0.000 0.004 0.000 0.996
#> SRR944330     4  0.0188     0.9705 0.000 0.004 0.000 0.996
#> SRR944331     4  0.0000     0.9730 0.000 0.000 0.000 1.000
#> SRR944332     4  0.0000     0.9730 0.000 0.000 0.000 1.000
#> SRR944334     4  0.0000     0.9730 0.000 0.000 0.000 1.000
#> SRR944333     4  0.0000     0.9730 0.000 0.000 0.000 1.000
#> SRR944335     4  0.0592     0.9645 0.016 0.000 0.000 0.984
#> SRR944336     4  0.0592     0.9645 0.016 0.000 0.000 0.984
#> SRR944337     4  0.0592     0.9645 0.016 0.000 0.000 0.984
#> SRR944338     3  0.0000     0.9281 0.000 0.000 1.000 0.000
#> SRR944339     3  0.0000     0.9281 0.000 0.000 1.000 0.000
#> SRR944340     3  0.0000     0.9281 0.000 0.000 1.000 0.000
#> SRR944341     3  0.0000     0.9281 0.000 0.000 1.000 0.000
#> SRR944342     3  0.0000     0.9281 0.000 0.000 1.000 0.000
#> SRR944343     3  0.0000     0.9281 0.000 0.000 1.000 0.000
#> SRR944344     3  0.0000     0.9281 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
#> SRR944282     5  0.7006     0.5621 0.208 0.184 0.056 0.000 0.552
#> SRR944283     5  0.5714     0.3868 0.380 0.048 0.020 0.000 0.552
#> SRR944284     5  0.5958     0.5860 0.140 0.128 0.032 0.012 0.688
#> SRR944285     1  0.5599     0.0925 0.564 0.032 0.028 0.000 0.376
#> SRR944288     5  0.6038     0.5559 0.080 0.204 0.060 0.000 0.656
#> SRR944287     1  0.2612     0.7419 0.868 0.000 0.008 0.000 0.124
#> SRR944289     4  0.3999     0.7717 0.000 0.116 0.008 0.808 0.068
#> SRR944290     1  0.4528     0.5535 0.728 0.000 0.000 0.212 0.060
#> SRR944291     5  0.7502     0.4288 0.080 0.264 0.052 0.060 0.544
#> SRR944292     2  0.5312     0.4886 0.000 0.652 0.248 0.000 0.100
#> SRR944293     5  0.6728     0.5483 0.196 0.112 0.048 0.020 0.624
#> SRR944294     5  0.6288     0.3817 0.348 0.076 0.016 0.012 0.548
#> SRR944295     2  0.0000     0.9595 0.000 1.000 0.000 0.000 0.000
#> SRR944296     2  0.0000     0.9595 0.000 1.000 0.000 0.000 0.000
#> SRR944297     2  0.0000     0.9595 0.000 1.000 0.000 0.000 0.000
#> SRR944298     2  0.0000     0.9595 0.000 1.000 0.000 0.000 0.000
#> SRR944299     1  0.4540     0.6931 0.768 0.000 0.012 0.076 0.144
#> SRR944300     1  0.4173     0.6689 0.760 0.000 0.008 0.028 0.204
#> SRR944301     5  0.4560    -0.0562 0.484 0.000 0.008 0.000 0.508
#> SRR944302     3  0.5507     0.0770 0.000 0.456 0.480 0.000 0.064
#> SRR944303     2  0.0000     0.9595 0.000 1.000 0.000 0.000 0.000
#> SRR944304     5  0.6299     0.2685 0.324 0.012 0.064 0.028 0.572
#> SRR944305     1  0.4083     0.6295 0.728 0.000 0.008 0.008 0.256
#> SRR944306     1  0.6600     0.0825 0.472 0.004 0.028 0.092 0.404
#> SRR944307     1  0.2757     0.7553 0.888 0.000 0.008 0.072 0.032
#> SRR944308     1  0.4095     0.6499 0.748 0.000 0.016 0.008 0.228
#> SRR944309     1  0.3402     0.7000 0.804 0.000 0.008 0.004 0.184
#> SRR944310     5  0.5795     0.1011 0.420 0.024 0.028 0.008 0.520
#> SRR944311     2  0.0000     0.9595 0.000 1.000 0.000 0.000 0.000
#> SRR944312     1  0.2006     0.7599 0.916 0.000 0.000 0.012 0.072
#> SRR944313     5  0.5207     0.0174 0.444 0.004 0.020 0.008 0.524
#> SRR944315     1  0.4201     0.3744 0.664 0.000 0.008 0.000 0.328
#> SRR944314     1  0.2439     0.7222 0.876 0.000 0.004 0.000 0.120
#> SRR944316     1  0.3844     0.6768 0.792 0.000 0.008 0.024 0.176
#> SRR944317     2  0.0000     0.9595 0.000 1.000 0.000 0.000 0.000
#> SRR944318     2  0.0000     0.9595 0.000 1.000 0.000 0.000 0.000
#> SRR944319     2  0.0566     0.9422 0.004 0.984 0.000 0.012 0.000
#> SRR944320     2  0.0000     0.9595 0.000 1.000 0.000 0.000 0.000
#> SRR944321     1  0.0794     0.7689 0.972 0.000 0.000 0.028 0.000
#> SRR944322     1  0.0794     0.7689 0.972 0.000 0.000 0.028 0.000
#> SRR944323     1  0.0794     0.7689 0.972 0.000 0.000 0.028 0.000
#> SRR944324     1  0.0794     0.7689 0.972 0.000 0.000 0.028 0.000
#> SRR944325     1  0.0794     0.7689 0.972 0.000 0.000 0.028 0.000
#> SRR944326     1  0.0794     0.7689 0.972 0.000 0.000 0.028 0.000
#> SRR944327     5  0.6085     0.5648 0.084 0.168 0.080 0.000 0.668
#> SRR944328     5  0.6969     0.1984 0.020 0.340 0.192 0.000 0.448
#> SRR944329     4  0.0000     0.9780 0.000 0.000 0.000 1.000 0.000
#> SRR944330     4  0.0000     0.9780 0.000 0.000 0.000 1.000 0.000
#> SRR944331     4  0.0000     0.9780 0.000 0.000 0.000 1.000 0.000
#> SRR944332     4  0.0000     0.9780 0.000 0.000 0.000 1.000 0.000
#> SRR944334     4  0.0000     0.9780 0.000 0.000 0.000 1.000 0.000
#> SRR944333     4  0.0000     0.9780 0.000 0.000 0.000 1.000 0.000
#> SRR944335     4  0.0000     0.9780 0.000 0.000 0.000 1.000 0.000
#> SRR944336     4  0.0000     0.9780 0.000 0.000 0.000 1.000 0.000
#> SRR944337     4  0.0000     0.9780 0.000 0.000 0.000 1.000 0.000
#> SRR944338     3  0.1121     0.9196 0.000 0.044 0.956 0.000 0.000
#> SRR944339     3  0.1121     0.9196 0.000 0.044 0.956 0.000 0.000
#> SRR944340     3  0.1121     0.9196 0.000 0.044 0.956 0.000 0.000
#> SRR944341     3  0.1121     0.9196 0.000 0.044 0.956 0.000 0.000
#> SRR944342     3  0.1121     0.9196 0.000 0.044 0.956 0.000 0.000
#> SRR944343     3  0.1121     0.9196 0.000 0.044 0.956 0.000 0.000
#> SRR944344     3  0.1121     0.9196 0.000 0.044 0.956 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
#> SRR944282     6  0.7289     0.3273 0.188 0.124 0.020 0.000 0.176 0.492
#> SRR944283     6  0.5578     0.3322 0.256 0.012 0.008 0.000 0.120 0.604
#> SRR944284     6  0.5432     0.4600 0.052 0.092 0.024 0.008 0.104 0.720
#> SRR944285     6  0.6257     0.1717 0.340 0.012 0.004 0.000 0.196 0.448
#> SRR944288     6  0.6850     0.2646 0.052 0.176 0.012 0.000 0.292 0.468
#> SRR944287     1  0.3770     0.6022 0.776 0.000 0.000 0.000 0.148 0.076
#> SRR944289     4  0.5256     0.6451 0.000 0.084 0.008 0.712 0.112 0.084
#> SRR944290     1  0.5346     0.4684 0.684 0.000 0.004 0.156 0.108 0.048
#> SRR944291     6  0.7662     0.2719 0.040 0.156 0.040 0.032 0.280 0.452
#> SRR944292     2  0.6125     0.2018 0.000 0.524 0.252 0.000 0.024 0.200
#> SRR944293     6  0.5686     0.4170 0.080 0.048 0.008 0.008 0.196 0.660
#> SRR944294     6  0.6422     0.3430 0.168 0.040 0.008 0.004 0.224 0.556
#> SRR944295     2  0.0260     0.9402 0.000 0.992 0.000 0.000 0.008 0.000
#> SRR944296     2  0.0000     0.9417 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944297     2  0.0000     0.9417 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944298     2  0.0000     0.9417 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944299     1  0.5742     0.3637 0.588 0.000 0.000 0.096 0.272 0.044
#> SRR944300     1  0.5140     0.0974 0.496 0.000 0.004 0.012 0.444 0.044
#> SRR944301     5  0.5619     0.5660 0.248 0.004 0.000 0.000 0.560 0.188
#> SRR944302     3  0.6204     0.0355 0.000 0.404 0.432 0.000 0.036 0.128
#> SRR944303     2  0.0260     0.9402 0.000 0.992 0.000 0.000 0.008 0.000
#> SRR944304     5  0.6408     0.4101 0.140 0.020 0.036 0.004 0.576 0.224
#> SRR944305     1  0.5295     0.0476 0.480 0.000 0.000 0.008 0.436 0.076
#> SRR944306     5  0.5586     0.5481 0.216 0.004 0.004 0.016 0.628 0.132
#> SRR944307     1  0.2829     0.6576 0.864 0.000 0.000 0.024 0.096 0.016
#> SRR944308     1  0.4653     0.3265 0.588 0.000 0.000 0.000 0.360 0.052
#> SRR944309     1  0.4252     0.3516 0.604 0.000 0.000 0.000 0.372 0.024
#> SRR944310     5  0.5560     0.5734 0.192 0.012 0.000 0.004 0.616 0.176
#> SRR944311     2  0.0146     0.9411 0.000 0.996 0.000 0.000 0.004 0.000
#> SRR944312     1  0.2825     0.6487 0.844 0.000 0.000 0.008 0.136 0.012
#> SRR944313     5  0.5270     0.5730 0.168 0.008 0.000 0.004 0.648 0.172
#> SRR944315     1  0.5985     0.0277 0.500 0.008 0.000 0.000 0.220 0.272
#> SRR944314     1  0.4371     0.5279 0.732 0.000 0.004 0.000 0.148 0.116
#> SRR944316     1  0.5694     0.3673 0.600 0.000 0.000 0.024 0.160 0.216
#> SRR944317     2  0.0405     0.9380 0.000 0.988 0.000 0.000 0.008 0.004
#> SRR944318     2  0.0000     0.9417 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944319     2  0.0653     0.9318 0.000 0.980 0.000 0.004 0.012 0.004
#> SRR944320     2  0.0000     0.9417 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944321     1  0.0000     0.6885 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944322     1  0.0000     0.6885 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944323     1  0.0000     0.6885 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944324     1  0.0000     0.6885 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944325     1  0.0000     0.6885 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944326     1  0.0000     0.6885 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944327     6  0.6861     0.3773 0.092 0.100 0.048 0.000 0.188 0.572
#> SRR944328     6  0.6735     0.3555 0.004 0.204 0.132 0.000 0.124 0.536
#> SRR944329     4  0.0146     0.9641 0.000 0.000 0.000 0.996 0.004 0.000
#> SRR944330     4  0.0146     0.9641 0.000 0.000 0.000 0.996 0.004 0.000
#> SRR944331     4  0.0146     0.9641 0.000 0.000 0.000 0.996 0.004 0.000
#> SRR944332     4  0.0000     0.9644 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR944334     4  0.0000     0.9644 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR944333     4  0.0000     0.9644 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR944335     4  0.0260     0.9620 0.008 0.000 0.000 0.992 0.000 0.000
#> SRR944336     4  0.0260     0.9620 0.008 0.000 0.000 0.992 0.000 0.000
#> SRR944337     4  0.0260     0.9620 0.008 0.000 0.000 0.992 0.000 0.000
#> SRR944338     3  0.0260     0.9060 0.000 0.008 0.992 0.000 0.000 0.000
#> SRR944339     3  0.0260     0.9060 0.000 0.008 0.992 0.000 0.000 0.000
#> SRR944340     3  0.0260     0.9060 0.000 0.008 0.992 0.000 0.000 0.000
#> SRR944341     3  0.0260     0.9060 0.000 0.008 0.992 0.000 0.000 0.000
#> SRR944342     3  0.0260     0.9060 0.000 0.008 0.992 0.000 0.000 0.000
#> SRR944343     3  0.0260     0.9060 0.000 0.008 0.992 0.000 0.000 0.000
#> SRR944344     3  0.0260     0.9060 0.000 0.008 0.992 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 12673 rows and 62 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 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-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.368           0.737       0.863         0.3764 0.611   0.611
#> 3 3 0.678           0.761       0.912         0.4009 0.827   0.721
#> 4 4 0.672           0.757       0.919         0.0174 0.997   0.993
#> 5 5 0.676           0.703       0.910         0.0220 0.952   0.897
#> 6 6 0.636           0.724       0.905         0.0199 0.969   0.929

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
#> SRR944282     1   0.978      0.660 0.588 0.412
#> SRR944283     1   0.966      0.705 0.608 0.392
#> SRR944284     2   0.204      0.831 0.032 0.968
#> SRR944285     1   0.955      0.740 0.624 0.376
#> SRR944288     2   0.000      0.858 0.000 1.000
#> SRR944287     1   0.730      0.927 0.796 0.204
#> SRR944289     2   0.000      0.858 0.000 1.000
#> SRR944290     2   0.760      0.563 0.220 0.780
#> SRR944291     2   0.000      0.858 0.000 1.000
#> SRR944292     2   0.000      0.858 0.000 1.000
#> SRR944293     2   0.000      0.858 0.000 1.000
#> SRR944294     2   0.000      0.858 0.000 1.000
#> SRR944295     2   0.000      0.858 0.000 1.000
#> SRR944296     2   0.000      0.858 0.000 1.000
#> SRR944297     2   0.000      0.858 0.000 1.000
#> SRR944298     2   0.000      0.858 0.000 1.000
#> SRR944299     2   0.615      0.685 0.152 0.848
#> SRR944300     2   0.722      0.604 0.200 0.800
#> SRR944301     2   0.886      0.343 0.304 0.696
#> SRR944302     2   0.000      0.858 0.000 1.000
#> SRR944303     2   0.000      0.858 0.000 1.000
#> SRR944304     2   0.000      0.858 0.000 1.000
#> SRR944305     2   0.999     -0.382 0.484 0.516
#> SRR944306     2   0.000      0.858 0.000 1.000
#> SRR944307     1   0.730      0.927 0.796 0.204
#> SRR944308     2   0.881      0.357 0.300 0.700
#> SRR944309     1   0.738      0.925 0.792 0.208
#> SRR944310     2   0.000      0.858 0.000 1.000
#> SRR944311     2   0.000      0.858 0.000 1.000
#> SRR944312     1   0.730      0.927 0.796 0.204
#> SRR944313     2   0.000      0.858 0.000 1.000
#> SRR944315     1   0.855      0.868 0.720 0.280
#> SRR944314     1   0.730      0.927 0.796 0.204
#> SRR944316     2   1.000     -0.398 0.488 0.512
#> SRR944317     2   0.000      0.858 0.000 1.000
#> SRR944318     2   0.000      0.858 0.000 1.000
#> SRR944319     2   0.000      0.858 0.000 1.000
#> SRR944320     2   0.000      0.858 0.000 1.000
#> SRR944321     1   0.730      0.927 0.796 0.204
#> SRR944322     1   0.730      0.927 0.796 0.204
#> SRR944323     1   0.730      0.927 0.796 0.204
#> SRR944324     1   0.730      0.927 0.796 0.204
#> SRR944325     1   0.730      0.927 0.796 0.204
#> SRR944326     1   0.730      0.927 0.796 0.204
#> SRR944327     2   0.998     -0.356 0.476 0.524
#> SRR944328     2   0.995     -0.299 0.460 0.540
#> SRR944329     2   0.000      0.858 0.000 1.000
#> SRR944330     2   0.000      0.858 0.000 1.000
#> SRR944331     2   0.000      0.858 0.000 1.000
#> SRR944332     2   0.000      0.858 0.000 1.000
#> SRR944334     2   0.000      0.858 0.000 1.000
#> SRR944333     2   0.000      0.858 0.000 1.000
#> SRR944335     2   0.000      0.858 0.000 1.000
#> SRR944336     2   0.000      0.858 0.000 1.000
#> SRR944337     1   0.891      0.838 0.692 0.308
#> SRR944338     2   0.730      0.687 0.204 0.796
#> SRR944339     2   0.730      0.687 0.204 0.796
#> SRR944340     2   0.730      0.687 0.204 0.796
#> SRR944341     2   0.730      0.687 0.204 0.796
#> SRR944342     2   0.730      0.687 0.204 0.796
#> SRR944343     2   0.730      0.687 0.204 0.796
#> SRR944344     2   0.653      0.719 0.168 0.832

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> SRR944282     1  0.6140     0.4304 0.596 0.404 0.000
#> SRR944283     1  0.6079     0.4685 0.612 0.388 0.000
#> SRR944284     2  0.1289     0.8844 0.032 0.968 0.000
#> SRR944285     1  0.5835     0.5664 0.660 0.340 0.000
#> SRR944288     2  0.0000     0.9112 0.000 1.000 0.000
#> SRR944287     1  0.1163     0.7626 0.972 0.028 0.000
#> SRR944289     2  0.0000     0.9112 0.000 1.000 0.000
#> SRR944290     2  0.4796     0.6566 0.220 0.780 0.000
#> SRR944291     2  0.0000     0.9112 0.000 1.000 0.000
#> SRR944292     2  0.0000     0.9112 0.000 1.000 0.000
#> SRR944293     2  0.0000     0.9112 0.000 1.000 0.000
#> SRR944294     2  0.0000     0.9112 0.000 1.000 0.000
#> SRR944295     2  0.0000     0.9112 0.000 1.000 0.000
#> SRR944296     2  0.0000     0.9112 0.000 1.000 0.000
#> SRR944297     2  0.0000     0.9112 0.000 1.000 0.000
#> SRR944298     2  0.0000     0.9112 0.000 1.000 0.000
#> SRR944299     2  0.3879     0.7553 0.152 0.848 0.000
#> SRR944300     2  0.4555     0.6892 0.200 0.800 0.000
#> SRR944301     2  0.5591     0.4865 0.304 0.696 0.000
#> SRR944302     2  0.0000     0.9112 0.000 1.000 0.000
#> SRR944303     2  0.0000     0.9112 0.000 1.000 0.000
#> SRR944304     2  0.0000     0.9112 0.000 1.000 0.000
#> SRR944305     2  0.6308    -0.1518 0.492 0.508 0.000
#> SRR944306     2  0.0000     0.9112 0.000 1.000 0.000
#> SRR944307     1  0.0000     0.7639 1.000 0.000 0.000
#> SRR944308     2  0.5560     0.4977 0.300 0.700 0.000
#> SRR944309     1  0.4399     0.7127 0.812 0.188 0.000
#> SRR944310     2  0.0000     0.9112 0.000 1.000 0.000
#> SRR944311     2  0.0000     0.9112 0.000 1.000 0.000
#> SRR944312     1  0.0424     0.7653 0.992 0.008 0.000
#> SRR944313     2  0.0000     0.9112 0.000 1.000 0.000
#> SRR944315     1  0.5327     0.6619 0.728 0.272 0.000
#> SRR944314     1  0.0424     0.7654 0.992 0.008 0.000
#> SRR944316     1  0.6309     0.1182 0.500 0.500 0.000
#> SRR944317     2  0.0000     0.9112 0.000 1.000 0.000
#> SRR944318     2  0.0000     0.9112 0.000 1.000 0.000
#> SRR944319     2  0.0000     0.9112 0.000 1.000 0.000
#> SRR944320     2  0.0000     0.9112 0.000 1.000 0.000
#> SRR944321     1  0.0000     0.7639 1.000 0.000 0.000
#> SRR944322     1  0.0000     0.7639 1.000 0.000 0.000
#> SRR944323     1  0.0000     0.7639 1.000 0.000 0.000
#> SRR944324     1  0.0000     0.7639 1.000 0.000 0.000
#> SRR944325     1  0.0000     0.7639 1.000 0.000 0.000
#> SRR944326     1  0.0000     0.7639 1.000 0.000 0.000
#> SRR944327     2  0.6302    -0.1113 0.480 0.520 0.000
#> SRR944328     2  0.6280    -0.0291 0.460 0.540 0.000
#> SRR944329     2  0.0000     0.9112 0.000 1.000 0.000
#> SRR944330     2  0.0000     0.9112 0.000 1.000 0.000
#> SRR944331     2  0.0000     0.9112 0.000 1.000 0.000
#> SRR944332     2  0.0000     0.9112 0.000 1.000 0.000
#> SRR944334     2  0.0000     0.9112 0.000 1.000 0.000
#> SRR944333     2  0.0000     0.9112 0.000 1.000 0.000
#> SRR944335     2  0.0000     0.9112 0.000 1.000 0.000
#> SRR944336     2  0.0000     0.9112 0.000 1.000 0.000
#> SRR944337     1  0.5254     0.6716 0.736 0.264 0.000
#> SRR944338     3  0.0000     0.9115 0.000 0.000 1.000
#> SRR944339     3  0.0000     0.9115 0.000 0.000 1.000
#> SRR944340     3  0.0000     0.9115 0.000 0.000 1.000
#> SRR944341     3  0.0000     0.9115 0.000 0.000 1.000
#> SRR944342     3  0.0000     0.9115 0.000 0.000 1.000
#> SRR944343     3  0.0000     0.9115 0.000 0.000 1.000
#> SRR944344     3  0.6111     0.3689 0.000 0.396 0.604

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1 p2 p3    p4
#> SRR944282     1  0.4866     0.4292 0.596  0  0 0.404
#> SRR944283     1  0.4817     0.4674 0.612  0  0 0.388
#> SRR944284     4  0.1022     0.8848 0.032  0  0 0.968
#> SRR944285     1  0.4624     0.5657 0.660  0  0 0.340
#> SRR944288     4  0.0000     0.9114 0.000  0  0 1.000
#> SRR944287     1  0.0921     0.7242 0.972  0  0 0.028
#> SRR944289     4  0.0000     0.9114 0.000  0  0 1.000
#> SRR944290     4  0.3801     0.6582 0.220  0  0 0.780
#> SRR944291     4  0.0000     0.9114 0.000  0  0 1.000
#> SRR944292     4  0.0000     0.9114 0.000  0  0 1.000
#> SRR944293     4  0.0000     0.9114 0.000  0  0 1.000
#> SRR944294     4  0.0000     0.9114 0.000  0  0 1.000
#> SRR944295     4  0.0000     0.9114 0.000  0  0 1.000
#> SRR944296     4  0.0000     0.9114 0.000  0  0 1.000
#> SRR944297     4  0.0000     0.9114 0.000  0  0 1.000
#> SRR944298     4  0.0000     0.9114 0.000  0  0 1.000
#> SRR944299     4  0.3074     0.7564 0.152  0  0 0.848
#> SRR944300     4  0.3610     0.6905 0.200  0  0 0.800
#> SRR944301     4  0.4431     0.4890 0.304  0  0 0.696
#> SRR944302     4  0.0000     0.9114 0.000  0  0 1.000
#> SRR944303     4  0.0000     0.9114 0.000  0  0 1.000
#> SRR944304     4  0.0000     0.9114 0.000  0  0 1.000
#> SRR944305     4  0.4999    -0.1488 0.492  0  0 0.508
#> SRR944306     4  0.0000     0.9114 0.000  0  0 1.000
#> SRR944307     1  0.0000     0.7248 1.000  0  0 0.000
#> SRR944308     4  0.4406     0.4994 0.300  0  0 0.700
#> SRR944309     1  0.3486     0.6743 0.812  0  0 0.188
#> SRR944310     4  0.0000     0.9114 0.000  0  0 1.000
#> SRR944311     4  0.0000     0.9114 0.000  0  0 1.000
#> SRR944312     1  0.0336     0.7266 0.992  0  0 0.008
#> SRR944313     4  0.0000     0.9114 0.000  0  0 1.000
#> SRR944315     1  0.4222     0.6366 0.728  0  0 0.272
#> SRR944314     1  0.0336     0.7268 0.992  0  0 0.008
#> SRR944316     1  0.5000     0.1156 0.500  0  0 0.500
#> SRR944317     4  0.0000     0.9114 0.000  0  0 1.000
#> SRR944318     4  0.0000     0.9114 0.000  0  0 1.000
#> SRR944319     4  0.0000     0.9114 0.000  0  0 1.000
#> SRR944320     4  0.0000     0.9114 0.000  0  0 1.000
#> SRR944321     1  0.0000     0.7248 1.000  0  0 0.000
#> SRR944322     1  0.0000     0.7248 1.000  0  0 0.000
#> SRR944323     1  0.0000     0.7248 1.000  0  0 0.000
#> SRR944324     1  0.0000     0.7248 1.000  0  0 0.000
#> SRR944325     1  0.0000     0.7248 1.000  0  0 0.000
#> SRR944326     1  0.0000     0.7248 1.000  0  0 0.000
#> SRR944327     4  0.4994    -0.1084 0.480  0  0 0.520
#> SRR944328     4  0.4977    -0.0257 0.460  0  0 0.540
#> SRR944329     4  0.0000     0.9114 0.000  0  0 1.000
#> SRR944330     4  0.0000     0.9114 0.000  0  0 1.000
#> SRR944331     4  0.0000     0.9114 0.000  0  0 1.000
#> SRR944332     4  0.0000     0.9114 0.000  0  0 1.000
#> SRR944334     4  0.0000     0.9114 0.000  0  0 1.000
#> SRR944333     4  0.0000     0.9114 0.000  0  0 1.000
#> SRR944335     4  0.0000     0.9114 0.000  0  0 1.000
#> SRR944336     4  0.0000     0.9114 0.000  0  0 1.000
#> SRR944337     1  0.4164     0.6414 0.736  0  0 0.264
#> SRR944338     3  0.0000     1.0000 0.000  0  1 0.000
#> SRR944339     3  0.0000     1.0000 0.000  0  1 0.000
#> SRR944340     3  0.0000     1.0000 0.000  0  1 0.000
#> SRR944341     3  0.0000     1.0000 0.000  0  1 0.000
#> SRR944342     3  0.0000     1.0000 0.000  0  1 0.000
#> SRR944343     3  0.0000     1.0000 0.000  0  1 0.000
#> SRR944344     2  0.0000     0.0000 0.000  1  0 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
#> SRR944282     1  0.4192    0.20654 0.596 0.000 0.000 0.404  0
#> SRR944283     1  0.4150    0.23819 0.612 0.000 0.000 0.388  0
#> SRR944284     4  0.0880    0.87840 0.032 0.000 0.000 0.968  0
#> SRR944285     1  0.3983    0.31291 0.660 0.000 0.000 0.340  0
#> SRR944288     4  0.0000    0.91799 0.000 0.000 0.000 1.000  0
#> SRR944287     1  0.0794    0.64107 0.972 0.000 0.000 0.028  0
#> SRR944289     4  0.0000    0.91799 0.000 0.000 0.000 1.000  0
#> SRR944290     4  0.3274    0.55034 0.220 0.000 0.000 0.780  0
#> SRR944291     4  0.0000    0.91799 0.000 0.000 0.000 1.000  0
#> SRR944292     4  0.0000    0.91799 0.000 0.000 0.000 1.000  0
#> SRR944293     4  0.0000    0.91799 0.000 0.000 0.000 1.000  0
#> SRR944294     4  0.0000    0.91799 0.000 0.000 0.000 1.000  0
#> SRR944295     4  0.0000    0.91799 0.000 0.000 0.000 1.000  0
#> SRR944296     4  0.0000    0.91799 0.000 0.000 0.000 1.000  0
#> SRR944297     4  0.0000    0.91799 0.000 0.000 0.000 1.000  0
#> SRR944298     4  0.0000    0.91799 0.000 0.000 0.000 1.000  0
#> SRR944299     4  0.2648    0.68901 0.152 0.000 0.000 0.848  0
#> SRR944300     4  0.3109    0.59436 0.200 0.000 0.000 0.800  0
#> SRR944301     4  0.3816    0.33120 0.304 0.000 0.000 0.696  0
#> SRR944302     4  0.0000    0.91799 0.000 0.000 0.000 1.000  0
#> SRR944303     4  0.0000    0.91799 0.000 0.000 0.000 1.000  0
#> SRR944304     4  0.0000    0.91799 0.000 0.000 0.000 1.000  0
#> SRR944305     1  0.5114   -0.04036 0.492 0.036 0.000 0.472  0
#> SRR944306     4  0.0000    0.91799 0.000 0.000 0.000 1.000  0
#> SRR944307     1  0.0000    0.65037 1.000 0.000 0.000 0.000  0
#> SRR944308     4  0.3796    0.33946 0.300 0.000 0.000 0.700  0
#> SRR944309     1  0.3003    0.51453 0.812 0.000 0.000 0.188  0
#> SRR944310     4  0.0000    0.91799 0.000 0.000 0.000 1.000  0
#> SRR944311     4  0.0000    0.91799 0.000 0.000 0.000 1.000  0
#> SRR944312     1  0.0290    0.64983 0.992 0.000 0.000 0.008  0
#> SRR944313     4  0.0000    0.91799 0.000 0.000 0.000 1.000  0
#> SRR944315     1  0.3636    0.42487 0.728 0.000 0.000 0.272  0
#> SRR944314     1  0.0290    0.65019 0.992 0.000 0.000 0.008  0
#> SRR944316     1  0.4307   -0.00532 0.500 0.000 0.000 0.500  0
#> SRR944317     4  0.0000    0.91799 0.000 0.000 0.000 1.000  0
#> SRR944318     4  0.0000    0.91799 0.000 0.000 0.000 1.000  0
#> SRR944319     4  0.0000    0.91799 0.000 0.000 0.000 1.000  0
#> SRR944320     4  0.0000    0.91799 0.000 0.000 0.000 1.000  0
#> SRR944321     1  0.0000    0.65037 1.000 0.000 0.000 0.000  0
#> SRR944322     1  0.0000    0.65037 1.000 0.000 0.000 0.000  0
#> SRR944323     1  0.0000    0.65037 1.000 0.000 0.000 0.000  0
#> SRR944324     1  0.0000    0.65037 1.000 0.000 0.000 0.000  0
#> SRR944325     1  0.0000    0.65037 1.000 0.000 0.000 0.000  0
#> SRR944326     1  0.0000    0.65037 1.000 0.000 0.000 0.000  0
#> SRR944327     4  0.4906   -0.25088 0.480 0.024 0.000 0.496  0
#> SRR944328     2  0.5681    0.00000 0.120 0.604 0.000 0.276  0
#> SRR944329     4  0.0000    0.91799 0.000 0.000 0.000 1.000  0
#> SRR944330     4  0.0000    0.91799 0.000 0.000 0.000 1.000  0
#> SRR944331     4  0.0000    0.91799 0.000 0.000 0.000 1.000  0
#> SRR944332     4  0.0000    0.91799 0.000 0.000 0.000 1.000  0
#> SRR944334     4  0.0000    0.91799 0.000 0.000 0.000 1.000  0
#> SRR944333     4  0.0000    0.91799 0.000 0.000 0.000 1.000  0
#> SRR944335     4  0.0000    0.91799 0.000 0.000 0.000 1.000  0
#> SRR944336     4  0.0000    0.91799 0.000 0.000 0.000 1.000  0
#> SRR944337     1  0.3586    0.43378 0.736 0.000 0.000 0.264  0
#> SRR944338     3  0.0290    0.90707 0.000 0.008 0.992 0.000  0
#> SRR944339     3  0.2773    0.86978 0.000 0.164 0.836 0.000  0
#> SRR944340     3  0.0510    0.90658 0.000 0.016 0.984 0.000  0
#> SRR944341     3  0.3508    0.78698 0.000 0.252 0.748 0.000  0
#> SRR944342     3  0.0290    0.90707 0.000 0.008 0.992 0.000  0
#> SRR944343     3  0.2280    0.89382 0.000 0.120 0.880 0.000  0
#> SRR944344     5  0.0000    0.00000 0.000 0.000 0.000 0.000  1

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5 p6
#> SRR944282     1  0.3765     0.3975 0.596 0.404 0.000 0.000 0.000  0
#> SRR944283     1  0.3727     0.4186 0.612 0.388 0.000 0.000 0.000  0
#> SRR944284     2  0.0790     0.9121 0.032 0.968 0.000 0.000 0.000  0
#> SRR944285     1  0.3578     0.4690 0.660 0.340 0.000 0.000 0.000  0
#> SRR944288     2  0.0000     0.9475 0.000 1.000 0.000 0.000 0.000  0
#> SRR944287     1  0.0713     0.6485 0.972 0.028 0.000 0.000 0.000  0
#> SRR944289     2  0.0000     0.9475 0.000 1.000 0.000 0.000 0.000  0
#> SRR944290     2  0.2941     0.6385 0.220 0.780 0.000 0.000 0.000  0
#> SRR944291     2  0.0000     0.9475 0.000 1.000 0.000 0.000 0.000  0
#> SRR944292     2  0.0000     0.9475 0.000 1.000 0.000 0.000 0.000  0
#> SRR944293     2  0.0000     0.9475 0.000 1.000 0.000 0.000 0.000  0
#> SRR944294     2  0.0000     0.9475 0.000 1.000 0.000 0.000 0.000  0
#> SRR944295     2  0.0000     0.9475 0.000 1.000 0.000 0.000 0.000  0
#> SRR944296     2  0.0000     0.9475 0.000 1.000 0.000 0.000 0.000  0
#> SRR944297     2  0.0000     0.9475 0.000 1.000 0.000 0.000 0.000  0
#> SRR944298     2  0.0000     0.9475 0.000 1.000 0.000 0.000 0.000  0
#> SRR944299     2  0.2378     0.7510 0.152 0.848 0.000 0.000 0.000  0
#> SRR944300     2  0.2793     0.6743 0.200 0.800 0.000 0.000 0.000  0
#> SRR944301     2  0.3428     0.4508 0.304 0.696 0.000 0.000 0.000  0
#> SRR944302     2  0.0000     0.9475 0.000 1.000 0.000 0.000 0.000  0
#> SRR944303     2  0.0000     0.9475 0.000 1.000 0.000 0.000 0.000  0
#> SRR944304     2  0.0000     0.9475 0.000 1.000 0.000 0.000 0.000  0
#> SRR944305     1  0.6015     0.2242 0.476 0.392 0.000 0.056 0.076  0
#> SRR944306     2  0.0000     0.9475 0.000 1.000 0.000 0.000 0.000  0
#> SRR944307     1  0.0000     0.6513 1.000 0.000 0.000 0.000 0.000  0
#> SRR944308     2  0.3409     0.4626 0.300 0.700 0.000 0.000 0.000  0
#> SRR944309     1  0.2697     0.5822 0.812 0.188 0.000 0.000 0.000  0
#> SRR944310     2  0.0000     0.9475 0.000 1.000 0.000 0.000 0.000  0
#> SRR944311     2  0.0000     0.9475 0.000 1.000 0.000 0.000 0.000  0
#> SRR944312     1  0.0260     0.6523 0.992 0.008 0.000 0.000 0.000  0
#> SRR944313     2  0.0000     0.9475 0.000 1.000 0.000 0.000 0.000  0
#> SRR944315     1  0.3266     0.5353 0.728 0.272 0.000 0.000 0.000  0
#> SRR944314     1  0.0260     0.6526 0.992 0.008 0.000 0.000 0.000  0
#> SRR944316     1  0.3869     0.2351 0.500 0.500 0.000 0.000 0.000  0
#> SRR944317     2  0.0000     0.9475 0.000 1.000 0.000 0.000 0.000  0
#> SRR944318     2  0.0000     0.9475 0.000 1.000 0.000 0.000 0.000  0
#> SRR944319     2  0.0000     0.9475 0.000 1.000 0.000 0.000 0.000  0
#> SRR944320     2  0.0000     0.9475 0.000 1.000 0.000 0.000 0.000  0
#> SRR944321     1  0.0000     0.6513 1.000 0.000 0.000 0.000 0.000  0
#> SRR944322     1  0.0000     0.6513 1.000 0.000 0.000 0.000 0.000  0
#> SRR944323     1  0.0000     0.6513 1.000 0.000 0.000 0.000 0.000  0
#> SRR944324     1  0.0000     0.6513 1.000 0.000 0.000 0.000 0.000  0
#> SRR944325     1  0.0000     0.6513 1.000 0.000 0.000 0.000 0.000  0
#> SRR944326     1  0.0000     0.6513 1.000 0.000 0.000 0.000 0.000  0
#> SRR944327     1  0.6481    -0.0215 0.352 0.328 0.000 0.016 0.304  0
#> SRR944328     4  0.3312     0.0000 0.028 0.180 0.000 0.792 0.000  0
#> SRR944329     2  0.0000     0.9475 0.000 1.000 0.000 0.000 0.000  0
#> SRR944330     2  0.0000     0.9475 0.000 1.000 0.000 0.000 0.000  0
#> SRR944331     2  0.0000     0.9475 0.000 1.000 0.000 0.000 0.000  0
#> SRR944332     2  0.0000     0.9475 0.000 1.000 0.000 0.000 0.000  0
#> SRR944334     2  0.0000     0.9475 0.000 1.000 0.000 0.000 0.000  0
#> SRR944333     2  0.0000     0.9475 0.000 1.000 0.000 0.000 0.000  0
#> SRR944335     2  0.0000     0.9475 0.000 1.000 0.000 0.000 0.000  0
#> SRR944336     2  0.0000     0.9475 0.000 1.000 0.000 0.000 0.000  0
#> SRR944337     1  0.3221     0.5407 0.736 0.264 0.000 0.000 0.000  0
#> SRR944338     3  0.0632     0.7988 0.000 0.000 0.976 0.000 0.024  0
#> SRR944339     3  0.4125     0.5394 0.000 0.000 0.748 0.128 0.124  0
#> SRR944340     3  0.0865     0.7861 0.000 0.000 0.964 0.000 0.036  0
#> SRR944341     5  0.3823     0.0000 0.000 0.000 0.436 0.000 0.564  0
#> SRR944342     3  0.0547     0.7992 0.000 0.000 0.980 0.000 0.020  0
#> SRR944343     3  0.2948     0.7180 0.000 0.000 0.848 0.092 0.060  0
#> SRR944344     6  0.0000     0.0000 0.000 0.000 0.000 0.000 0.000  1

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

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

collect_plots(res)

plot of chunk CV-mclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.969       0.989         0.2336 0.772   0.772
#> 3 3 0.736           0.933       0.944         1.4591 0.619   0.517
#> 4 4 0.665           0.790       0.859         0.1908 0.806   0.582
#> 5 5 0.684           0.707       0.820         0.0916 0.838   0.577
#> 6 6 0.847           0.837       0.907         0.0668 0.890   0.636

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
#> SRR944282     1  0.0000      0.991 1.000 0.000
#> SRR944283     1  0.0000      0.991 1.000 0.000
#> SRR944284     1  0.0000      0.991 1.000 0.000
#> SRR944285     1  0.0000      0.991 1.000 0.000
#> SRR944288     1  0.0000      0.991 1.000 0.000
#> SRR944287     1  0.0000      0.991 1.000 0.000
#> SRR944289     1  0.0000      0.991 1.000 0.000
#> SRR944290     1  0.0000      0.991 1.000 0.000
#> SRR944291     1  0.0000      0.991 1.000 0.000
#> SRR944292     1  0.9909      0.148 0.556 0.444
#> SRR944293     1  0.0000      0.991 1.000 0.000
#> SRR944294     1  0.0000      0.991 1.000 0.000
#> SRR944295     1  0.0000      0.991 1.000 0.000
#> SRR944296     1  0.0000      0.991 1.000 0.000
#> SRR944297     1  0.0000      0.991 1.000 0.000
#> SRR944298     1  0.0000      0.991 1.000 0.000
#> SRR944299     1  0.0000      0.991 1.000 0.000
#> SRR944300     1  0.0000      0.991 1.000 0.000
#> SRR944301     1  0.0000      0.991 1.000 0.000
#> SRR944302     2  0.8207      0.650 0.256 0.744
#> SRR944303     1  0.0000      0.991 1.000 0.000
#> SRR944304     1  0.0000      0.991 1.000 0.000
#> SRR944305     1  0.0000      0.991 1.000 0.000
#> SRR944306     1  0.0000      0.991 1.000 0.000
#> SRR944307     1  0.0000      0.991 1.000 0.000
#> SRR944308     1  0.0000      0.991 1.000 0.000
#> SRR944309     1  0.0000      0.991 1.000 0.000
#> SRR944310     1  0.0000      0.991 1.000 0.000
#> SRR944311     1  0.0000      0.991 1.000 0.000
#> SRR944312     1  0.0000      0.991 1.000 0.000
#> SRR944313     1  0.0000      0.991 1.000 0.000
#> SRR944315     1  0.0000      0.991 1.000 0.000
#> SRR944314     1  0.0000      0.991 1.000 0.000
#> SRR944316     1  0.0000      0.991 1.000 0.000
#> SRR944317     1  0.0000      0.991 1.000 0.000
#> SRR944318     1  0.0000      0.991 1.000 0.000
#> SRR944319     1  0.0000      0.991 1.000 0.000
#> SRR944320     1  0.0000      0.991 1.000 0.000
#> SRR944321     1  0.0000      0.991 1.000 0.000
#> SRR944322     1  0.0000      0.991 1.000 0.000
#> SRR944323     1  0.0000      0.991 1.000 0.000
#> SRR944324     1  0.0000      0.991 1.000 0.000
#> SRR944325     1  0.0000      0.991 1.000 0.000
#> SRR944326     1  0.0000      0.991 1.000 0.000
#> SRR944327     1  0.0376      0.987 0.996 0.004
#> SRR944328     1  0.0376      0.987 0.996 0.004
#> SRR944329     1  0.0000      0.991 1.000 0.000
#> SRR944330     1  0.0000      0.991 1.000 0.000
#> SRR944331     1  0.0000      0.991 1.000 0.000
#> SRR944332     1  0.0000      0.991 1.000 0.000
#> SRR944334     1  0.0000      0.991 1.000 0.000
#> SRR944333     1  0.0000      0.991 1.000 0.000
#> SRR944335     1  0.0000      0.991 1.000 0.000
#> SRR944336     1  0.0000      0.991 1.000 0.000
#> SRR944337     1  0.0000      0.991 1.000 0.000
#> SRR944338     2  0.0000      0.963 0.000 1.000
#> SRR944339     2  0.0000      0.963 0.000 1.000
#> SRR944340     2  0.0000      0.963 0.000 1.000
#> SRR944341     2  0.0000      0.963 0.000 1.000
#> SRR944342     2  0.0000      0.963 0.000 1.000
#> SRR944343     2  0.0000      0.963 0.000 1.000
#> SRR944344     2  0.0000      0.963 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
#> SRR944282     1  0.0237      0.930 0.996 0.004 0.000
#> SRR944283     1  0.0237      0.931 0.996 0.004 0.000
#> SRR944284     1  0.0424      0.929 0.992 0.008 0.000
#> SRR944285     1  0.0592      0.932 0.988 0.012 0.000
#> SRR944288     1  0.1411      0.927 0.964 0.036 0.000
#> SRR944287     1  0.1031      0.933 0.976 0.024 0.000
#> SRR944289     2  0.1753      0.953 0.048 0.952 0.000
#> SRR944290     1  0.4346      0.850 0.816 0.184 0.000
#> SRR944291     1  0.0747      0.929 0.984 0.016 0.000
#> SRR944292     1  0.5874      0.835 0.796 0.088 0.116
#> SRR944293     1  0.0892      0.934 0.980 0.020 0.000
#> SRR944294     1  0.1031      0.934 0.976 0.024 0.000
#> SRR944295     2  0.1031      0.971 0.024 0.976 0.000
#> SRR944296     2  0.3966      0.891 0.024 0.876 0.100
#> SRR944297     2  0.1031      0.971 0.024 0.976 0.000
#> SRR944298     2  0.1031      0.971 0.024 0.976 0.000
#> SRR944299     1  0.2959      0.920 0.900 0.100 0.000
#> SRR944300     1  0.2356      0.929 0.928 0.072 0.000
#> SRR944301     1  0.0000      0.929 1.000 0.000 0.000
#> SRR944302     1  0.6526      0.794 0.760 0.112 0.128
#> SRR944303     2  0.1031      0.971 0.024 0.976 0.000
#> SRR944304     1  0.0237      0.931 0.996 0.004 0.000
#> SRR944305     1  0.1031      0.935 0.976 0.024 0.000
#> SRR944306     1  0.0747      0.933 0.984 0.016 0.000
#> SRR944307     1  0.4452      0.844 0.808 0.192 0.000
#> SRR944308     1  0.0892      0.933 0.980 0.020 0.000
#> SRR944309     1  0.2165      0.930 0.936 0.064 0.000
#> SRR944310     1  0.0000      0.929 1.000 0.000 0.000
#> SRR944311     2  0.1031      0.971 0.024 0.976 0.000
#> SRR944312     1  0.4178      0.858 0.828 0.172 0.000
#> SRR944313     1  0.0237      0.930 0.996 0.004 0.000
#> SRR944315     1  0.0424      0.929 0.992 0.008 0.000
#> SRR944314     1  0.2356      0.929 0.928 0.072 0.000
#> SRR944316     1  0.0892      0.933 0.980 0.020 0.000
#> SRR944317     2  0.1031      0.971 0.024 0.976 0.000
#> SRR944318     2  0.1031      0.971 0.024 0.976 0.000
#> SRR944319     2  0.1031      0.971 0.024 0.976 0.000
#> SRR944320     2  0.3966      0.891 0.024 0.876 0.100
#> SRR944321     1  0.3038      0.917 0.896 0.104 0.000
#> SRR944322     1  0.3038      0.917 0.896 0.104 0.000
#> SRR944323     1  0.3038      0.917 0.896 0.104 0.000
#> SRR944324     1  0.3038      0.917 0.896 0.104 0.000
#> SRR944325     1  0.3038      0.917 0.896 0.104 0.000
#> SRR944326     1  0.3038      0.917 0.896 0.104 0.000
#> SRR944327     1  0.5588      0.846 0.808 0.124 0.068
#> SRR944328     1  0.5588      0.846 0.808 0.124 0.068
#> SRR944329     2  0.1163      0.970 0.028 0.972 0.000
#> SRR944330     2  0.1163      0.970 0.028 0.972 0.000
#> SRR944331     2  0.1163      0.970 0.028 0.972 0.000
#> SRR944332     2  0.1753      0.959 0.048 0.952 0.000
#> SRR944334     2  0.1411      0.967 0.036 0.964 0.000
#> SRR944333     2  0.1289      0.945 0.032 0.968 0.000
#> SRR944335     2  0.1289      0.969 0.032 0.968 0.000
#> SRR944336     2  0.1643      0.962 0.044 0.956 0.000
#> SRR944337     2  0.3941      0.805 0.156 0.844 0.000
#> SRR944338     3  0.0000      1.000 0.000 0.000 1.000
#> SRR944339     3  0.0000      1.000 0.000 0.000 1.000
#> SRR944340     3  0.0000      1.000 0.000 0.000 1.000
#> SRR944341     3  0.0000      1.000 0.000 0.000 1.000
#> SRR944342     3  0.0000      1.000 0.000 0.000 1.000
#> SRR944343     3  0.0000      1.000 0.000 0.000 1.000
#> SRR944344     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
#> SRR944282     1  0.1389      0.848 0.952 0.048 0.000 0.000
#> SRR944283     1  0.0336      0.857 0.992 0.008 0.000 0.000
#> SRR944284     1  0.0469      0.856 0.988 0.012 0.000 0.000
#> SRR944285     1  0.0000      0.855 1.000 0.000 0.000 0.000
#> SRR944288     1  0.1824      0.843 0.936 0.060 0.000 0.004
#> SRR944287     1  0.0921      0.847 0.972 0.000 0.000 0.028
#> SRR944289     4  0.3219      0.679 0.112 0.020 0.000 0.868
#> SRR944290     1  0.5526      0.160 0.564 0.020 0.000 0.416
#> SRR944291     1  0.0336      0.857 0.992 0.008 0.000 0.000
#> SRR944292     1  0.4922      0.685 0.700 0.284 0.004 0.012
#> SRR944293     1  0.0817      0.856 0.976 0.024 0.000 0.000
#> SRR944294     1  0.0592      0.857 0.984 0.016 0.000 0.000
#> SRR944295     2  0.4164      0.985 0.000 0.736 0.000 0.264
#> SRR944296     2  0.4453      0.977 0.012 0.744 0.000 0.244
#> SRR944297     2  0.4072      0.989 0.000 0.748 0.000 0.252
#> SRR944298     2  0.4072      0.989 0.000 0.748 0.000 0.252
#> SRR944299     1  0.5050      0.180 0.588 0.004 0.000 0.408
#> SRR944300     1  0.3933      0.681 0.792 0.008 0.000 0.200
#> SRR944301     1  0.1576      0.849 0.948 0.048 0.000 0.004
#> SRR944302     1  0.5712      0.529 0.572 0.404 0.012 0.012
#> SRR944303     2  0.4193      0.980 0.000 0.732 0.000 0.268
#> SRR944304     1  0.0188      0.857 0.996 0.004 0.000 0.000
#> SRR944305     1  0.2443      0.827 0.916 0.024 0.000 0.060
#> SRR944306     1  0.0592      0.857 0.984 0.016 0.000 0.000
#> SRR944307     4  0.5078      0.644 0.272 0.028 0.000 0.700
#> SRR944308     1  0.0657      0.855 0.984 0.012 0.000 0.004
#> SRR944309     1  0.3681      0.718 0.816 0.008 0.000 0.176
#> SRR944310     1  0.0657      0.857 0.984 0.012 0.000 0.004
#> SRR944311     2  0.4103      0.988 0.000 0.744 0.000 0.256
#> SRR944312     1  0.5713      0.394 0.620 0.040 0.000 0.340
#> SRR944313     1  0.0188      0.856 0.996 0.004 0.000 0.000
#> SRR944315     1  0.1004      0.856 0.972 0.024 0.000 0.004
#> SRR944314     1  0.3172      0.735 0.840 0.000 0.000 0.160
#> SRR944316     1  0.1211      0.854 0.960 0.040 0.000 0.000
#> SRR944317     2  0.4103      0.985 0.000 0.744 0.000 0.256
#> SRR944318     2  0.4072      0.989 0.000 0.748 0.000 0.252
#> SRR944319     2  0.4008      0.969 0.000 0.756 0.000 0.244
#> SRR944320     2  0.4072      0.989 0.000 0.748 0.000 0.252
#> SRR944321     4  0.4877      0.612 0.328 0.008 0.000 0.664
#> SRR944322     4  0.4877      0.612 0.328 0.008 0.000 0.664
#> SRR944323     4  0.4877      0.612 0.328 0.008 0.000 0.664
#> SRR944324     4  0.4955      0.587 0.344 0.008 0.000 0.648
#> SRR944325     4  0.5085      0.522 0.376 0.008 0.000 0.616
#> SRR944326     4  0.4936      0.595 0.340 0.008 0.000 0.652
#> SRR944327     1  0.4917      0.641 0.656 0.336 0.000 0.008
#> SRR944328     1  0.4769      0.670 0.684 0.308 0.000 0.008
#> SRR944329     4  0.0336      0.723 0.000 0.008 0.000 0.992
#> SRR944330     4  0.0336      0.723 0.000 0.008 0.000 0.992
#> SRR944331     4  0.0336      0.723 0.000 0.008 0.000 0.992
#> SRR944332     4  0.0336      0.723 0.000 0.008 0.000 0.992
#> SRR944334     4  0.0336      0.723 0.000 0.008 0.000 0.992
#> SRR944333     4  0.0336      0.723 0.000 0.008 0.000 0.992
#> SRR944335     4  0.0524      0.725 0.004 0.008 0.000 0.988
#> SRR944336     4  0.0336      0.723 0.000 0.008 0.000 0.992
#> SRR944337     4  0.1004      0.724 0.004 0.024 0.000 0.972
#> SRR944338     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR944339     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR944340     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR944341     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR944342     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR944343     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR944344     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
#> SRR944282     1  0.3607    0.32165 0.752 0.004  0 0.000 0.244
#> SRR944283     1  0.2377    0.59768 0.872 0.000  0 0.000 0.128
#> SRR944284     1  0.1965    0.62036 0.904 0.000  0 0.000 0.096
#> SRR944285     1  0.0880    0.67196 0.968 0.000  0 0.000 0.032
#> SRR944288     1  0.3521    0.34804 0.764 0.004  0 0.000 0.232
#> SRR944287     1  0.1478    0.67266 0.936 0.000  0 0.000 0.064
#> SRR944289     4  0.4886    0.65108 0.124 0.012  0 0.744 0.120
#> SRR944290     1  0.4735    0.53833 0.680 0.000  0 0.048 0.272
#> SRR944291     1  0.1270    0.65625 0.948 0.000  0 0.000 0.052
#> SRR944292     5  0.6275    0.80355 0.364 0.156  0 0.000 0.480
#> SRR944293     1  0.1478    0.64301 0.936 0.000  0 0.000 0.064
#> SRR944294     1  0.1341    0.65630 0.944 0.000  0 0.000 0.056
#> SRR944295     2  0.2439    0.85328 0.000 0.876  0 0.120 0.004
#> SRR944296     2  0.0162    0.87903 0.000 0.996  0 0.004 0.000
#> SRR944297     2  0.0000    0.87852 0.000 1.000  0 0.000 0.000
#> SRR944298     2  0.0000    0.87852 0.000 1.000  0 0.000 0.000
#> SRR944299     1  0.4887    0.53241 0.660 0.000  0 0.052 0.288
#> SRR944300     1  0.3053    0.64677 0.828 0.000  0 0.008 0.164
#> SRR944301     1  0.3305    0.41688 0.776 0.000  0 0.000 0.224
#> SRR944302     5  0.6416    0.72734 0.236 0.116  0 0.044 0.604
#> SRR944303     2  0.3586    0.74432 0.000 0.736  0 0.264 0.000
#> SRR944304     1  0.1544    0.66425 0.932 0.000  0 0.000 0.068
#> SRR944305     1  0.2424    0.65427 0.868 0.000  0 0.000 0.132
#> SRR944306     1  0.1043    0.66532 0.960 0.000  0 0.000 0.040
#> SRR944307     4  0.6770    0.00462 0.276 0.000  0 0.384 0.340
#> SRR944308     1  0.0880    0.67131 0.968 0.000  0 0.000 0.032
#> SRR944309     1  0.3093    0.65007 0.824 0.000  0 0.008 0.168
#> SRR944310     1  0.1792    0.62690 0.916 0.000  0 0.000 0.084
#> SRR944311     2  0.1121    0.87839 0.000 0.956  0 0.044 0.000
#> SRR944312     1  0.4996    0.27872 0.548 0.000  0 0.032 0.420
#> SRR944313     1  0.0963    0.66397 0.964 0.000  0 0.000 0.036
#> SRR944315     1  0.2020    0.62532 0.900 0.000  0 0.000 0.100
#> SRR944314     1  0.2864    0.65509 0.852 0.000  0 0.012 0.136
#> SRR944316     1  0.3305    0.58843 0.776 0.000  0 0.000 0.224
#> SRR944317     2  0.2674    0.84383 0.000 0.856  0 0.140 0.004
#> SRR944318     2  0.0000    0.87852 0.000 1.000  0 0.000 0.000
#> SRR944319     2  0.3752    0.70578 0.000 0.708  0 0.292 0.000
#> SRR944320     2  0.0404    0.87847 0.000 0.988  0 0.012 0.000
#> SRR944321     1  0.4449    0.43153 0.512 0.000  0 0.004 0.484
#> SRR944322     1  0.4450    0.42736 0.508 0.000  0 0.004 0.488
#> SRR944323     1  0.4450    0.42736 0.508 0.000  0 0.004 0.488
#> SRR944324     1  0.4305    0.43060 0.512 0.000  0 0.000 0.488
#> SRR944325     1  0.4302    0.43646 0.520 0.000  0 0.000 0.480
#> SRR944326     1  0.4449    0.43153 0.512 0.000  0 0.004 0.484
#> SRR944327     5  0.6589    0.82744 0.364 0.212  0 0.000 0.424
#> SRR944328     5  0.6587    0.82347 0.388 0.208  0 0.000 0.404
#> SRR944329     4  0.0000    0.88007 0.000 0.000  0 1.000 0.000
#> SRR944330     4  0.0000    0.88007 0.000 0.000  0 1.000 0.000
#> SRR944331     4  0.0703    0.88507 0.000 0.000  0 0.976 0.024
#> SRR944332     4  0.0162    0.88148 0.000 0.000  0 0.996 0.004
#> SRR944334     4  0.0794    0.88484 0.000 0.000  0 0.972 0.028
#> SRR944333     4  0.0162    0.88148 0.000 0.000  0 0.996 0.004
#> SRR944335     4  0.1043    0.88295 0.000 0.000  0 0.960 0.040
#> SRR944336     4  0.0963    0.88430 0.000 0.000  0 0.964 0.036
#> SRR944337     4  0.1830    0.86515 0.028 0.000  0 0.932 0.040
#> SRR944338     3  0.0000    1.00000 0.000 0.000  1 0.000 0.000
#> SRR944339     3  0.0000    1.00000 0.000 0.000  1 0.000 0.000
#> SRR944340     3  0.0000    1.00000 0.000 0.000  1 0.000 0.000
#> SRR944341     3  0.0000    1.00000 0.000 0.000  1 0.000 0.000
#> SRR944342     3  0.0000    1.00000 0.000 0.000  1 0.000 0.000
#> SRR944343     3  0.0000    1.00000 0.000 0.000  1 0.000 0.000
#> SRR944344     3  0.0000    1.00000 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
#> SRR944282     1  0.1845     0.8786 0.920 0.000  0 0.000 0.052 0.028
#> SRR944283     1  0.0790     0.8901 0.968 0.000  0 0.000 0.000 0.032
#> SRR944284     1  0.0508     0.8847 0.984 0.000  0 0.000 0.012 0.004
#> SRR944285     1  0.1225     0.8899 0.952 0.000  0 0.000 0.012 0.036
#> SRR944288     1  0.3053     0.7254 0.812 0.000  0 0.000 0.168 0.020
#> SRR944287     1  0.1720     0.8815 0.928 0.000  0 0.000 0.032 0.040
#> SRR944289     6  0.6130     0.1594 0.040 0.004  0 0.392 0.096 0.468
#> SRR944290     6  0.4732     0.5335 0.312 0.000  0 0.008 0.052 0.628
#> SRR944291     1  0.1049     0.8848 0.960 0.000  0 0.000 0.032 0.008
#> SRR944292     5  0.3534     0.7535 0.276 0.000  0 0.000 0.716 0.008
#> SRR944293     1  0.0914     0.8897 0.968 0.000  0 0.000 0.016 0.016
#> SRR944294     1  0.0858     0.8919 0.968 0.000  0 0.000 0.004 0.028
#> SRR944295     2  0.0520     0.9748 0.000 0.984  0 0.000 0.008 0.008
#> SRR944296     2  0.0000     0.9781 0.000 1.000  0 0.000 0.000 0.000
#> SRR944297     2  0.0000     0.9781 0.000 1.000  0 0.000 0.000 0.000
#> SRR944298     2  0.0000     0.9781 0.000 1.000  0 0.000 0.000 0.000
#> SRR944299     6  0.4134     0.5458 0.316 0.000  0 0.000 0.028 0.656
#> SRR944300     1  0.4724     0.3346 0.592 0.000  0 0.000 0.060 0.348
#> SRR944301     1  0.1682     0.8579 0.928 0.000  0 0.000 0.052 0.020
#> SRR944302     5  0.4887     0.6645 0.260 0.004  0 0.012 0.660 0.064
#> SRR944303     2  0.1523     0.9444 0.000 0.940  0 0.044 0.008 0.008
#> SRR944304     1  0.1418     0.8904 0.944 0.000  0 0.000 0.024 0.032
#> SRR944305     1  0.2527     0.8586 0.876 0.000  0 0.000 0.040 0.084
#> SRR944306     1  0.0891     0.8918 0.968 0.000  0 0.000 0.008 0.024
#> SRR944307     4  0.5313     0.0878 0.108 0.000  0 0.508 0.000 0.384
#> SRR944308     1  0.1594     0.8830 0.932 0.000  0 0.000 0.016 0.052
#> SRR944309     1  0.3923     0.7061 0.748 0.000  0 0.000 0.060 0.192
#> SRR944310     1  0.1320     0.8810 0.948 0.000  0 0.000 0.036 0.016
#> SRR944311     2  0.0405     0.9763 0.000 0.988  0 0.000 0.004 0.008
#> SRR944312     6  0.4732     0.4404 0.360 0.000  0 0.004 0.048 0.588
#> SRR944313     1  0.1649     0.8895 0.932 0.000  0 0.000 0.032 0.036
#> SRR944315     1  0.1168     0.8855 0.956 0.000  0 0.000 0.028 0.016
#> SRR944314     1  0.2384     0.8583 0.888 0.000  0 0.000 0.064 0.048
#> SRR944316     1  0.4406     0.6189 0.696 0.000  0 0.000 0.080 0.224
#> SRR944317     2  0.0881     0.9714 0.000 0.972  0 0.008 0.008 0.012
#> SRR944318     2  0.0000     0.9781 0.000 1.000  0 0.000 0.000 0.000
#> SRR944319     2  0.2159     0.9111 0.000 0.904  0 0.072 0.012 0.012
#> SRR944320     2  0.0000     0.9781 0.000 1.000  0 0.000 0.000 0.000
#> SRR944321     6  0.1204     0.7784 0.056 0.000  0 0.000 0.000 0.944
#> SRR944322     6  0.1204     0.7784 0.056 0.000  0 0.000 0.000 0.944
#> SRR944323     6  0.1204     0.7784 0.056 0.000  0 0.000 0.000 0.944
#> SRR944324     6  0.1204     0.7784 0.056 0.000  0 0.000 0.000 0.944
#> SRR944325     6  0.1444     0.7732 0.072 0.000  0 0.000 0.000 0.928
#> SRR944326     6  0.1349     0.7775 0.056 0.000  0 0.000 0.004 0.940
#> SRR944327     5  0.1814     0.7743 0.100 0.000  0 0.000 0.900 0.000
#> SRR944328     5  0.2416     0.8059 0.156 0.000  0 0.000 0.844 0.000
#> SRR944329     4  0.0000     0.9375 0.000 0.000  0 1.000 0.000 0.000
#> SRR944330     4  0.0000     0.9375 0.000 0.000  0 1.000 0.000 0.000
#> SRR944331     4  0.0000     0.9375 0.000 0.000  0 1.000 0.000 0.000
#> SRR944332     4  0.0000     0.9375 0.000 0.000  0 1.000 0.000 0.000
#> SRR944334     4  0.0000     0.9375 0.000 0.000  0 1.000 0.000 0.000
#> SRR944333     4  0.0000     0.9375 0.000 0.000  0 1.000 0.000 0.000
#> SRR944335     4  0.0000     0.9375 0.000 0.000  0 1.000 0.000 0.000
#> SRR944336     4  0.0000     0.9375 0.000 0.000  0 1.000 0.000 0.000
#> SRR944337     4  0.0146     0.9339 0.000 0.000  0 0.996 0.000 0.004
#> SRR944338     3  0.0000     1.0000 0.000 0.000  1 0.000 0.000 0.000
#> SRR944339     3  0.0000     1.0000 0.000 0.000  1 0.000 0.000 0.000
#> SRR944340     3  0.0000     1.0000 0.000 0.000  1 0.000 0.000 0.000
#> SRR944341     3  0.0000     1.0000 0.000 0.000  1 0.000 0.000 0.000
#> SRR944342     3  0.0000     1.0000 0.000 0.000  1 0.000 0.000 0.000
#> SRR944343     3  0.0000     1.0000 0.000 0.000  1 0.000 0.000 0.000
#> SRR944344     3  0.0000     1.0000 0.000 0.000  1 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-mclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-mclust-collect-classes

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


CV:NMF**

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

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

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

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

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.2044 0.796   0.796
#> 3 3 1.000           0.969       0.990         1.4501 0.696   0.619
#> 4 4 0.600           0.758       0.876         0.2091 0.879   0.763
#> 5 5 0.509           0.610       0.776         0.1212 0.902   0.769
#> 6 6 0.516           0.517       0.732         0.0938 0.805   0.523

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
#> SRR944282     1       0          1  1  0
#> SRR944283     1       0          1  1  0
#> SRR944284     1       0          1  1  0
#> SRR944285     1       0          1  1  0
#> SRR944288     1       0          1  1  0
#> SRR944287     1       0          1  1  0
#> SRR944289     1       0          1  1  0
#> SRR944290     1       0          1  1  0
#> SRR944291     1       0          1  1  0
#> SRR944292     1       0          1  1  0
#> SRR944293     1       0          1  1  0
#> SRR944294     1       0          1  1  0
#> SRR944295     1       0          1  1  0
#> SRR944296     1       0          1  1  0
#> SRR944297     1       0          1  1  0
#> SRR944298     1       0          1  1  0
#> SRR944299     1       0          1  1  0
#> SRR944300     1       0          1  1  0
#> SRR944301     1       0          1  1  0
#> SRR944302     1       0          1  1  0
#> SRR944303     1       0          1  1  0
#> SRR944304     1       0          1  1  0
#> SRR944305     1       0          1  1  0
#> SRR944306     1       0          1  1  0
#> SRR944307     1       0          1  1  0
#> SRR944308     1       0          1  1  0
#> SRR944309     1       0          1  1  0
#> SRR944310     1       0          1  1  0
#> SRR944311     1       0          1  1  0
#> SRR944312     1       0          1  1  0
#> SRR944313     1       0          1  1  0
#> SRR944315     1       0          1  1  0
#> SRR944314     1       0          1  1  0
#> SRR944316     1       0          1  1  0
#> SRR944317     1       0          1  1  0
#> SRR944318     1       0          1  1  0
#> SRR944319     1       0          1  1  0
#> SRR944320     1       0          1  1  0
#> SRR944321     1       0          1  1  0
#> SRR944322     1       0          1  1  0
#> SRR944323     1       0          1  1  0
#> SRR944324     1       0          1  1  0
#> SRR944325     1       0          1  1  0
#> SRR944326     1       0          1  1  0
#> SRR944327     1       0          1  1  0
#> SRR944328     1       0          1  1  0
#> SRR944329     1       0          1  1  0
#> SRR944330     1       0          1  1  0
#> SRR944331     1       0          1  1  0
#> SRR944332     1       0          1  1  0
#> SRR944334     1       0          1  1  0
#> SRR944333     1       0          1  1  0
#> SRR944335     1       0          1  1  0
#> SRR944336     1       0          1  1  0
#> SRR944337     1       0          1  1  0
#> SRR944338     2       0          1  0  1
#> SRR944339     2       0          1  0  1
#> SRR944340     2       0          1  0  1
#> SRR944341     2       0          1  0  1
#> SRR944342     2       0          1  0  1
#> SRR944343     2       0          1  0  1
#> SRR944344     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
#> SRR944282     1  0.0000      0.998 1.000 0.000  0
#> SRR944283     1  0.0000      0.998 1.000 0.000  0
#> SRR944284     1  0.0000      0.998 1.000 0.000  0
#> SRR944285     1  0.0000      0.998 1.000 0.000  0
#> SRR944288     1  0.0000      0.998 1.000 0.000  0
#> SRR944287     1  0.0000      0.998 1.000 0.000  0
#> SRR944289     1  0.2261      0.925 0.932 0.068  0
#> SRR944290     1  0.0000      0.998 1.000 0.000  0
#> SRR944291     1  0.0000      0.998 1.000 0.000  0
#> SRR944292     1  0.0000      0.998 1.000 0.000  0
#> SRR944293     1  0.0000      0.998 1.000 0.000  0
#> SRR944294     1  0.0000      0.998 1.000 0.000  0
#> SRR944295     2  0.0000      0.934 0.000 1.000  0
#> SRR944296     2  0.0000      0.934 0.000 1.000  0
#> SRR944297     2  0.0000      0.934 0.000 1.000  0
#> SRR944298     2  0.0000      0.934 0.000 1.000  0
#> SRR944299     1  0.0000      0.998 1.000 0.000  0
#> SRR944300     1  0.0000      0.998 1.000 0.000  0
#> SRR944301     1  0.0000      0.998 1.000 0.000  0
#> SRR944302     1  0.0000      0.998 1.000 0.000  0
#> SRR944303     2  0.0000      0.934 0.000 1.000  0
#> SRR944304     1  0.0000      0.998 1.000 0.000  0
#> SRR944305     1  0.0000      0.998 1.000 0.000  0
#> SRR944306     1  0.0000      0.998 1.000 0.000  0
#> SRR944307     1  0.0000      0.998 1.000 0.000  0
#> SRR944308     1  0.0000      0.998 1.000 0.000  0
#> SRR944309     1  0.0000      0.998 1.000 0.000  0
#> SRR944310     1  0.0000      0.998 1.000 0.000  0
#> SRR944311     2  0.0000      0.934 0.000 1.000  0
#> SRR944312     1  0.0000      0.998 1.000 0.000  0
#> SRR944313     1  0.0000      0.998 1.000 0.000  0
#> SRR944315     1  0.0000      0.998 1.000 0.000  0
#> SRR944314     1  0.0000      0.998 1.000 0.000  0
#> SRR944316     1  0.0000      0.998 1.000 0.000  0
#> SRR944317     2  0.0000      0.934 0.000 1.000  0
#> SRR944318     2  0.0000      0.934 0.000 1.000  0
#> SRR944319     2  0.0000      0.934 0.000 1.000  0
#> SRR944320     2  0.0000      0.934 0.000 1.000  0
#> SRR944321     1  0.0000      0.998 1.000 0.000  0
#> SRR944322     1  0.0000      0.998 1.000 0.000  0
#> SRR944323     1  0.0000      0.998 1.000 0.000  0
#> SRR944324     1  0.0000      0.998 1.000 0.000  0
#> SRR944325     1  0.0000      0.998 1.000 0.000  0
#> SRR944326     1  0.0000      0.998 1.000 0.000  0
#> SRR944327     1  0.0000      0.998 1.000 0.000  0
#> SRR944328     1  0.0000      0.998 1.000 0.000  0
#> SRR944329     2  0.0892      0.917 0.020 0.980  0
#> SRR944330     2  0.0747      0.921 0.016 0.984  0
#> SRR944331     1  0.0237      0.994 0.996 0.004  0
#> SRR944332     2  0.6274      0.174 0.456 0.544  0
#> SRR944334     1  0.0237      0.994 0.996 0.004  0
#> SRR944333     2  0.1411      0.896 0.036 0.964  0
#> SRR944335     1  0.0000      0.998 1.000 0.000  0
#> SRR944336     1  0.0000      0.998 1.000 0.000  0
#> SRR944337     1  0.0000      0.998 1.000 0.000  0
#> SRR944338     3  0.0000      1.000 0.000 0.000  1
#> SRR944339     3  0.0000      1.000 0.000 0.000  1
#> SRR944340     3  0.0000      1.000 0.000 0.000  1
#> SRR944341     3  0.0000      1.000 0.000 0.000  1
#> SRR944342     3  0.0000      1.000 0.000 0.000  1
#> SRR944343     3  0.0000      1.000 0.000 0.000  1
#> SRR944344     3  0.0000      1.000 0.000 0.000  1

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> SRR944282     4  0.4776     0.7620 0.376 0.000 0.000 0.624
#> SRR944283     4  0.4961     0.6563 0.448 0.000 0.000 0.552
#> SRR944284     1  0.3975     0.5746 0.760 0.000 0.000 0.240
#> SRR944285     1  0.4877    -0.0232 0.592 0.000 0.000 0.408
#> SRR944288     1  0.3726     0.6397 0.788 0.000 0.000 0.212
#> SRR944287     1  0.2760     0.7667 0.872 0.000 0.000 0.128
#> SRR944289     1  0.3108     0.6927 0.872 0.112 0.000 0.016
#> SRR944290     1  0.1022     0.8062 0.968 0.000 0.000 0.032
#> SRR944291     1  0.2011     0.7934 0.920 0.000 0.000 0.080
#> SRR944292     4  0.4925     0.6435 0.428 0.000 0.000 0.572
#> SRR944293     1  0.4164     0.5607 0.736 0.000 0.000 0.264
#> SRR944294     1  0.3688     0.6861 0.792 0.000 0.000 0.208
#> SRR944295     2  0.0817     0.8929 0.000 0.976 0.000 0.024
#> SRR944296     2  0.1474     0.8902 0.000 0.948 0.000 0.052
#> SRR944297     2  0.1474     0.8902 0.000 0.948 0.000 0.052
#> SRR944298     2  0.1474     0.8900 0.000 0.948 0.000 0.052
#> SRR944299     1  0.0921     0.8050 0.972 0.000 0.000 0.028
#> SRR944300     1  0.0469     0.8051 0.988 0.000 0.000 0.012
#> SRR944301     1  0.0592     0.8094 0.984 0.000 0.000 0.016
#> SRR944302     1  0.4776    -0.0403 0.624 0.000 0.000 0.376
#> SRR944303     2  0.0336     0.8913 0.000 0.992 0.000 0.008
#> SRR944304     1  0.1867     0.8021 0.928 0.000 0.000 0.072
#> SRR944305     1  0.1118     0.8082 0.964 0.000 0.000 0.036
#> SRR944306     1  0.1022     0.8060 0.968 0.000 0.000 0.032
#> SRR944307     1  0.0707     0.8074 0.980 0.000 0.000 0.020
#> SRR944308     1  0.0469     0.8081 0.988 0.000 0.000 0.012
#> SRR944309     1  0.0592     0.8099 0.984 0.000 0.000 0.016
#> SRR944310     1  0.1211     0.8084 0.960 0.000 0.000 0.040
#> SRR944311     2  0.0336     0.8912 0.000 0.992 0.000 0.008
#> SRR944312     1  0.0592     0.8099 0.984 0.000 0.000 0.016
#> SRR944313     1  0.0592     0.8045 0.984 0.000 0.000 0.016
#> SRR944315     1  0.3764     0.6503 0.784 0.000 0.000 0.216
#> SRR944314     1  0.4661     0.2869 0.652 0.000 0.000 0.348
#> SRR944316     1  0.2589     0.7833 0.884 0.000 0.000 0.116
#> SRR944317     2  0.0921     0.8920 0.000 0.972 0.000 0.028
#> SRR944318     2  0.1557     0.8891 0.000 0.944 0.000 0.056
#> SRR944319     2  0.3266     0.8548 0.000 0.832 0.000 0.168
#> SRR944320     2  0.3400     0.8513 0.000 0.820 0.000 0.180
#> SRR944321     1  0.3311     0.7277 0.828 0.000 0.000 0.172
#> SRR944322     1  0.2814     0.7613 0.868 0.000 0.000 0.132
#> SRR944323     1  0.2530     0.7710 0.888 0.000 0.000 0.112
#> SRR944324     1  0.2973     0.7491 0.856 0.000 0.000 0.144
#> SRR944325     1  0.3610     0.6854 0.800 0.000 0.000 0.200
#> SRR944326     1  0.3801     0.6518 0.780 0.000 0.000 0.220
#> SRR944327     4  0.4624     0.7377 0.340 0.000 0.000 0.660
#> SRR944328     4  0.4103     0.7227 0.256 0.000 0.000 0.744
#> SRR944329     2  0.4800     0.6889 0.196 0.760 0.000 0.044
#> SRR944330     2  0.3821     0.7977 0.120 0.840 0.000 0.040
#> SRR944331     1  0.2256     0.7693 0.924 0.020 0.000 0.056
#> SRR944332     1  0.4524     0.4569 0.768 0.204 0.000 0.028
#> SRR944334     1  0.2142     0.7735 0.928 0.016 0.000 0.056
#> SRR944333     2  0.5227     0.5710 0.256 0.704 0.000 0.040
#> SRR944335     1  0.0817     0.8049 0.976 0.000 0.000 0.024
#> SRR944336     1  0.1452     0.7961 0.956 0.008 0.000 0.036
#> SRR944337     1  0.0921     0.8039 0.972 0.000 0.000 0.028
#> SRR944338     3  0.0000     0.9986 0.000 0.000 1.000 0.000
#> SRR944339     3  0.0000     0.9986 0.000 0.000 1.000 0.000
#> SRR944340     3  0.0000     0.9986 0.000 0.000 1.000 0.000
#> SRR944341     3  0.0000     0.9986 0.000 0.000 1.000 0.000
#> SRR944342     3  0.0000     0.9986 0.000 0.000 1.000 0.000
#> SRR944343     3  0.0000     0.9986 0.000 0.000 1.000 0.000
#> SRR944344     3  0.0469     0.9917 0.000 0.000 0.988 0.012

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4 p5
#> SRR944282     4  0.4637     0.5934 0.160 0.000 0.000 0.740 NA
#> SRR944283     4  0.4495     0.5934 0.200 0.000 0.000 0.736 NA
#> SRR944284     4  0.5276     0.1880 0.436 0.000 0.000 0.516 NA
#> SRR944285     4  0.4989     0.4867 0.296 0.000 0.000 0.648 NA
#> SRR944288     1  0.5396     0.0236 0.500 0.000 0.000 0.444 NA
#> SRR944287     1  0.4817     0.5069 0.656 0.000 0.000 0.300 NA
#> SRR944289     1  0.3187     0.6581 0.864 0.088 0.000 0.012 NA
#> SRR944290     1  0.1997     0.7122 0.924 0.000 0.000 0.040 NA
#> SRR944291     1  0.4761     0.5745 0.732 0.000 0.000 0.124 NA
#> SRR944292     4  0.5339     0.5890 0.176 0.000 0.000 0.672 NA
#> SRR944293     4  0.5161     0.0661 0.444 0.000 0.000 0.516 NA
#> SRR944294     1  0.5024     0.1222 0.528 0.000 0.000 0.440 NA
#> SRR944295     2  0.1043     0.7721 0.000 0.960 0.000 0.000 NA
#> SRR944296     2  0.2629     0.7554 0.000 0.860 0.000 0.004 NA
#> SRR944297     2  0.2439     0.7638 0.000 0.876 0.000 0.004 NA
#> SRR944298     2  0.1952     0.7678 0.000 0.912 0.000 0.004 NA
#> SRR944299     1  0.1082     0.7100 0.964 0.000 0.000 0.008 NA
#> SRR944300     1  0.1300     0.7150 0.956 0.000 0.000 0.028 NA
#> SRR944301     1  0.3366     0.6804 0.828 0.000 0.000 0.140 NA
#> SRR944302     4  0.7288     0.3696 0.336 0.020 0.000 0.344 NA
#> SRR944303     2  0.0609     0.7691 0.000 0.980 0.000 0.000 NA
#> SRR944304     1  0.4498     0.6264 0.756 0.000 0.000 0.132 NA
#> SRR944305     1  0.3301     0.7027 0.848 0.000 0.000 0.072 NA
#> SRR944306     1  0.2291     0.7011 0.908 0.000 0.000 0.036 NA
#> SRR944307     1  0.1668     0.7180 0.940 0.000 0.000 0.032 NA
#> SRR944308     1  0.2079     0.7180 0.916 0.000 0.000 0.064 NA
#> SRR944309     1  0.2491     0.7142 0.896 0.000 0.000 0.068 NA
#> SRR944310     1  0.3655     0.6671 0.804 0.000 0.000 0.160 NA
#> SRR944311     2  0.0404     0.7694 0.000 0.988 0.000 0.000 NA
#> SRR944312     1  0.2592     0.7148 0.892 0.000 0.000 0.056 NA
#> SRR944313     1  0.2491     0.7154 0.896 0.000 0.000 0.068 NA
#> SRR944315     1  0.5206     0.1440 0.528 0.000 0.000 0.428 NA
#> SRR944314     4  0.4709     0.3545 0.364 0.000 0.000 0.612 NA
#> SRR944316     1  0.4920     0.4565 0.644 0.000 0.000 0.308 NA
#> SRR944317     2  0.1341     0.7712 0.000 0.944 0.000 0.000 NA
#> SRR944318     2  0.2732     0.7600 0.000 0.840 0.000 0.000 NA
#> SRR944319     2  0.4249     0.6379 0.000 0.568 0.000 0.000 NA
#> SRR944320     2  0.4542     0.6261 0.000 0.536 0.000 0.008 NA
#> SRR944321     1  0.4555     0.4678 0.636 0.000 0.000 0.344 NA
#> SRR944322     1  0.4193     0.5270 0.684 0.000 0.000 0.304 NA
#> SRR944323     1  0.4108     0.5293 0.684 0.000 0.000 0.308 NA
#> SRR944324     1  0.4402     0.4587 0.636 0.000 0.000 0.352 NA
#> SRR944325     1  0.4835     0.3664 0.592 0.000 0.000 0.380 NA
#> SRR944326     1  0.4885     0.2976 0.572 0.000 0.000 0.400 NA
#> SRR944327     4  0.6227     0.4690 0.184 0.000 0.000 0.536 NA
#> SRR944328     4  0.4980     0.4665 0.072 0.000 0.000 0.676 NA
#> SRR944329     2  0.5142     0.3549 0.392 0.564 0.000 0.000 NA
#> SRR944330     2  0.4890     0.4479 0.332 0.628 0.000 0.000 NA
#> SRR944331     1  0.2100     0.6970 0.924 0.012 0.000 0.016 NA
#> SRR944332     1  0.3893     0.5660 0.804 0.140 0.000 0.004 NA
#> SRR944334     1  0.1967     0.7038 0.932 0.012 0.000 0.020 NA
#> SRR944333     2  0.5100     0.2214 0.448 0.516 0.000 0.000 NA
#> SRR944335     1  0.1564     0.7082 0.948 0.004 0.000 0.024 NA
#> SRR944336     1  0.1701     0.7051 0.944 0.012 0.000 0.016 NA
#> SRR944337     1  0.1739     0.7100 0.940 0.004 0.000 0.032 NA
#> SRR944338     3  0.0579     0.9844 0.000 0.000 0.984 0.008 NA
#> SRR944339     3  0.0000     0.9891 0.000 0.000 1.000 0.000 NA
#> SRR944340     3  0.0000     0.9891 0.000 0.000 1.000 0.000 NA
#> SRR944341     3  0.0162     0.9884 0.000 0.000 0.996 0.000 NA
#> SRR944342     3  0.0162     0.9886 0.000 0.000 0.996 0.004 NA
#> SRR944343     3  0.0000     0.9891 0.000 0.000 1.000 0.000 NA
#> SRR944344     3  0.1845     0.9526 0.000 0.000 0.928 0.016 NA

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR944282     1  0.4601     0.2519 0.688 0.000 0.000 0.072 0.232 0.008
#> SRR944283     1  0.4053     0.4188 0.788 0.000 0.000 0.100 0.084 0.028
#> SRR944284     1  0.5521     0.5699 0.600 0.000 0.000 0.268 0.108 0.024
#> SRR944285     1  0.4998     0.5207 0.696 0.000 0.000 0.160 0.116 0.028
#> SRR944288     1  0.5544     0.5279 0.640 0.000 0.000 0.208 0.104 0.048
#> SRR944287     4  0.5521    -0.2201 0.448 0.000 0.000 0.460 0.068 0.024
#> SRR944289     4  0.3568     0.6056 0.012 0.072 0.000 0.836 0.060 0.020
#> SRR944290     4  0.2849     0.6135 0.036 0.000 0.000 0.876 0.044 0.044
#> SRR944291     4  0.6153     0.2824 0.172 0.000 0.000 0.564 0.216 0.048
#> SRR944292     1  0.6208     0.1079 0.588 0.000 0.000 0.104 0.196 0.112
#> SRR944293     1  0.5527     0.5504 0.648 0.000 0.000 0.180 0.128 0.044
#> SRR944294     1  0.5659     0.5730 0.596 0.000 0.000 0.272 0.088 0.044
#> SRR944295     2  0.1075     0.7521 0.000 0.952 0.000 0.000 0.000 0.048
#> SRR944296     2  0.3098     0.6665 0.000 0.812 0.000 0.000 0.024 0.164
#> SRR944297     2  0.3103     0.6338 0.000 0.784 0.000 0.000 0.008 0.208
#> SRR944298     2  0.2703     0.6913 0.000 0.824 0.000 0.000 0.004 0.172
#> SRR944299     4  0.2901     0.6259 0.040 0.000 0.000 0.872 0.056 0.032
#> SRR944300     4  0.2800     0.6240 0.052 0.000 0.000 0.876 0.052 0.020
#> SRR944301     4  0.6022     0.1625 0.340 0.000 0.000 0.520 0.072 0.068
#> SRR944302     1  0.7401    -0.1879 0.424 0.004 0.000 0.184 0.156 0.232
#> SRR944303     2  0.0922     0.7583 0.000 0.968 0.000 0.004 0.004 0.024
#> SRR944304     4  0.6384     0.3778 0.156 0.000 0.000 0.576 0.152 0.116
#> SRR944305     4  0.6029     0.4617 0.132 0.000 0.000 0.620 0.136 0.112
#> SRR944306     4  0.3879     0.6001 0.044 0.000 0.000 0.808 0.076 0.072
#> SRR944307     4  0.2351     0.6286 0.036 0.000 0.000 0.904 0.028 0.032
#> SRR944308     4  0.4217     0.5303 0.184 0.000 0.000 0.748 0.044 0.024
#> SRR944309     4  0.5055     0.4818 0.204 0.000 0.000 0.684 0.048 0.064
#> SRR944310     4  0.6156     0.0484 0.368 0.000 0.000 0.484 0.084 0.064
#> SRR944311     2  0.0858     0.7648 0.000 0.968 0.000 0.000 0.004 0.028
#> SRR944312     4  0.4082     0.5860 0.096 0.000 0.000 0.792 0.048 0.064
#> SRR944313     4  0.4716     0.5366 0.168 0.000 0.000 0.724 0.040 0.068
#> SRR944315     1  0.4887     0.6055 0.688 0.000 0.000 0.212 0.072 0.028
#> SRR944314     1  0.4537     0.5589 0.736 0.000 0.000 0.156 0.084 0.024
#> SRR944316     4  0.5924    -0.1117 0.364 0.000 0.000 0.504 0.092 0.040
#> SRR944317     2  0.1615     0.7284 0.000 0.928 0.000 0.004 0.004 0.064
#> SRR944318     2  0.3384     0.5126 0.000 0.760 0.000 0.004 0.008 0.228
#> SRR944319     6  0.4434     0.7593 0.004 0.460 0.000 0.012 0.004 0.520
#> SRR944320     6  0.3789     0.7596 0.000 0.416 0.000 0.000 0.000 0.584
#> SRR944321     1  0.4486     0.2977 0.512 0.000 0.000 0.464 0.016 0.008
#> SRR944322     4  0.4450    -0.1779 0.448 0.000 0.000 0.528 0.020 0.004
#> SRR944323     4  0.4381    -0.1836 0.456 0.000 0.000 0.524 0.016 0.004
#> SRR944324     1  0.4471     0.3252 0.532 0.000 0.000 0.444 0.016 0.008
#> SRR944325     1  0.4616     0.4957 0.592 0.000 0.000 0.368 0.032 0.008
#> SRR944326     1  0.5197     0.5275 0.568 0.000 0.000 0.348 0.072 0.012
#> SRR944327     5  0.5020     0.6527 0.288 0.000 0.000 0.056 0.632 0.024
#> SRR944328     5  0.4753     0.6626 0.288 0.000 0.000 0.016 0.648 0.048
#> SRR944329     4  0.4662     0.2434 0.000 0.424 0.000 0.540 0.008 0.028
#> SRR944330     4  0.4659     0.1624 0.000 0.460 0.000 0.504 0.004 0.032
#> SRR944331     4  0.1059     0.6268 0.000 0.004 0.000 0.964 0.016 0.016
#> SRR944332     4  0.3349     0.5609 0.000 0.164 0.000 0.804 0.008 0.024
#> SRR944334     4  0.1690     0.6271 0.004 0.016 0.000 0.940 0.020 0.020
#> SRR944333     4  0.4481     0.2897 0.000 0.416 0.000 0.556 0.004 0.024
#> SRR944335     4  0.1401     0.6264 0.004 0.000 0.000 0.948 0.020 0.028
#> SRR944336     4  0.1764     0.6270 0.004 0.024 0.000 0.936 0.012 0.024
#> SRR944337     4  0.1518     0.6259 0.008 0.000 0.000 0.944 0.024 0.024
#> SRR944338     3  0.0363     0.9726 0.000 0.000 0.988 0.000 0.000 0.012
#> SRR944339     3  0.0146     0.9761 0.004 0.000 0.996 0.000 0.000 0.000
#> SRR944340     3  0.0146     0.9761 0.004 0.000 0.996 0.000 0.000 0.000
#> SRR944341     3  0.0653     0.9709 0.004 0.000 0.980 0.000 0.004 0.012
#> SRR944342     3  0.0000     0.9764 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR944343     3  0.0000     0.9764 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR944344     3  0.2758     0.8869 0.012 0.000 0.872 0.000 0.036 0.080

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

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

collect_plots(res)

plot of chunk MAD-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.748           0.942       0.958         0.3869 0.568   0.568
#> 3 3 1.000           0.999       0.999         0.2410 0.952   0.916
#> 4 4 0.992           0.987       0.987         0.0301 0.993   0.986
#> 5 5 0.952           0.982       0.981         0.0582 0.957   0.915
#> 6 6 0.951           0.945       0.958         0.0195 1.000   1.000

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> SRR944282     1   0.000      1.000 1.000 0.000
#> SRR944283     1   0.000      1.000 1.000 0.000
#> SRR944284     1   0.000      1.000 1.000 0.000
#> SRR944285     1   0.000      1.000 1.000 0.000
#> SRR944288     1   0.000      1.000 1.000 0.000
#> SRR944287     1   0.000      1.000 1.000 0.000
#> SRR944289     1   0.000      1.000 1.000 0.000
#> SRR944290     1   0.000      1.000 1.000 0.000
#> SRR944291     1   0.000      1.000 1.000 0.000
#> SRR944292     2   0.871      0.771 0.292 0.708
#> SRR944293     1   0.000      1.000 1.000 0.000
#> SRR944294     1   0.000      1.000 1.000 0.000
#> SRR944295     2   0.000      0.844 0.000 1.000
#> SRR944296     2   0.000      0.844 0.000 1.000
#> SRR944297     2   0.000      0.844 0.000 1.000
#> SRR944298     2   0.000      0.844 0.000 1.000
#> SRR944299     1   0.000      1.000 1.000 0.000
#> SRR944300     1   0.000      1.000 1.000 0.000
#> SRR944301     1   0.000      1.000 1.000 0.000
#> SRR944302     2   0.871      0.771 0.292 0.708
#> SRR944303     2   0.000      0.844 0.000 1.000
#> SRR944304     1   0.000      1.000 1.000 0.000
#> SRR944305     1   0.000      1.000 1.000 0.000
#> SRR944306     1   0.000      1.000 1.000 0.000
#> SRR944307     1   0.000      1.000 1.000 0.000
#> SRR944308     1   0.000      1.000 1.000 0.000
#> SRR944309     1   0.000      1.000 1.000 0.000
#> SRR944310     1   0.000      1.000 1.000 0.000
#> SRR944311     2   0.000      0.844 0.000 1.000
#> SRR944312     1   0.000      1.000 1.000 0.000
#> SRR944313     1   0.000      1.000 1.000 0.000
#> SRR944315     1   0.000      1.000 1.000 0.000
#> SRR944314     1   0.000      1.000 1.000 0.000
#> SRR944316     1   0.000      1.000 1.000 0.000
#> SRR944317     2   0.000      0.844 0.000 1.000
#> SRR944318     2   0.000      0.844 0.000 1.000
#> SRR944319     2   0.000      0.844 0.000 1.000
#> SRR944320     2   0.000      0.844 0.000 1.000
#> SRR944321     1   0.000      1.000 1.000 0.000
#> SRR944322     1   0.000      1.000 1.000 0.000
#> SRR944323     1   0.000      1.000 1.000 0.000
#> SRR944324     1   0.000      1.000 1.000 0.000
#> SRR944325     1   0.000      1.000 1.000 0.000
#> SRR944326     1   0.000      1.000 1.000 0.000
#> SRR944327     1   0.000      1.000 1.000 0.000
#> SRR944328     1   0.000      1.000 1.000 0.000
#> SRR944329     1   0.000      1.000 1.000 0.000
#> SRR944330     1   0.000      1.000 1.000 0.000
#> SRR944331     1   0.000      1.000 1.000 0.000
#> SRR944332     1   0.000      1.000 1.000 0.000
#> SRR944334     1   0.000      1.000 1.000 0.000
#> SRR944333     1   0.000      1.000 1.000 0.000
#> SRR944335     1   0.000      1.000 1.000 0.000
#> SRR944336     1   0.000      1.000 1.000 0.000
#> SRR944337     1   0.000      1.000 1.000 0.000
#> SRR944338     2   0.871      0.771 0.292 0.708
#> SRR944339     2   0.871      0.771 0.292 0.708
#> SRR944340     2   0.871      0.771 0.292 0.708
#> SRR944341     2   0.871      0.771 0.292 0.708
#> SRR944342     2   0.871      0.771 0.292 0.708
#> SRR944343     2   0.871      0.771 0.292 0.708
#> SRR944344     2   0.871      0.771 0.292 0.708

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette p1    p2    p3
#> SRR944282     1   0.000      1.000  1 0.000 0.000
#> SRR944283     1   0.000      1.000  1 0.000 0.000
#> SRR944284     1   0.000      1.000  1 0.000 0.000
#> SRR944285     1   0.000      1.000  1 0.000 0.000
#> SRR944288     1   0.000      1.000  1 0.000 0.000
#> SRR944287     1   0.000      1.000  1 0.000 0.000
#> SRR944289     1   0.000      1.000  1 0.000 0.000
#> SRR944290     1   0.000      1.000  1 0.000 0.000
#> SRR944291     1   0.000      1.000  1 0.000 0.000
#> SRR944292     3   0.103      0.978  0 0.024 0.976
#> SRR944293     1   0.000      1.000  1 0.000 0.000
#> SRR944294     1   0.000      1.000  1 0.000 0.000
#> SRR944295     2   0.000      1.000  0 1.000 0.000
#> SRR944296     2   0.000      1.000  0 1.000 0.000
#> SRR944297     2   0.000      1.000  0 1.000 0.000
#> SRR944298     2   0.000      1.000  0 1.000 0.000
#> SRR944299     1   0.000      1.000  1 0.000 0.000
#> SRR944300     1   0.000      1.000  1 0.000 0.000
#> SRR944301     1   0.000      1.000  1 0.000 0.000
#> SRR944302     3   0.103      0.978  0 0.024 0.976
#> SRR944303     2   0.000      1.000  0 1.000 0.000
#> SRR944304     1   0.000      1.000  1 0.000 0.000
#> SRR944305     1   0.000      1.000  1 0.000 0.000
#> SRR944306     1   0.000      1.000  1 0.000 0.000
#> SRR944307     1   0.000      1.000  1 0.000 0.000
#> SRR944308     1   0.000      1.000  1 0.000 0.000
#> SRR944309     1   0.000      1.000  1 0.000 0.000
#> SRR944310     1   0.000      1.000  1 0.000 0.000
#> SRR944311     2   0.000      1.000  0 1.000 0.000
#> SRR944312     1   0.000      1.000  1 0.000 0.000
#> SRR944313     1   0.000      1.000  1 0.000 0.000
#> SRR944315     1   0.000      1.000  1 0.000 0.000
#> SRR944314     1   0.000      1.000  1 0.000 0.000
#> SRR944316     1   0.000      1.000  1 0.000 0.000
#> SRR944317     2   0.000      1.000  0 1.000 0.000
#> SRR944318     2   0.000      1.000  0 1.000 0.000
#> SRR944319     2   0.000      1.000  0 1.000 0.000
#> SRR944320     2   0.000      1.000  0 1.000 0.000
#> SRR944321     1   0.000      1.000  1 0.000 0.000
#> SRR944322     1   0.000      1.000  1 0.000 0.000
#> SRR944323     1   0.000      1.000  1 0.000 0.000
#> SRR944324     1   0.000      1.000  1 0.000 0.000
#> SRR944325     1   0.000      1.000  1 0.000 0.000
#> SRR944326     1   0.000      1.000  1 0.000 0.000
#> SRR944327     1   0.000      1.000  1 0.000 0.000
#> SRR944328     1   0.000      1.000  1 0.000 0.000
#> SRR944329     1   0.000      1.000  1 0.000 0.000
#> SRR944330     1   0.000      1.000  1 0.000 0.000
#> SRR944331     1   0.000      1.000  1 0.000 0.000
#> SRR944332     1   0.000      1.000  1 0.000 0.000
#> SRR944334     1   0.000      1.000  1 0.000 0.000
#> SRR944333     1   0.000      1.000  1 0.000 0.000
#> SRR944335     1   0.000      1.000  1 0.000 0.000
#> SRR944336     1   0.000      1.000  1 0.000 0.000
#> SRR944337     1   0.000      1.000  1 0.000 0.000
#> SRR944338     3   0.000      0.994  0 0.000 1.000
#> SRR944339     3   0.000      0.994  0 0.000 1.000
#> SRR944340     3   0.000      0.994  0 0.000 1.000
#> SRR944341     3   0.000      0.994  0 0.000 1.000
#> SRR944342     3   0.000      0.994  0 0.000 1.000
#> SRR944343     3   0.000      0.994  0 0.000 1.000
#> SRR944344     3   0.000      0.994  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
#> SRR944282     1  0.0188       0.99 0.996 0.000 0.000 0.004
#> SRR944283     1  0.0188       0.99 0.996 0.000 0.000 0.004
#> SRR944284     1  0.0188       0.99 0.996 0.000 0.000 0.004
#> SRR944285     1  0.0188       0.99 0.996 0.000 0.000 0.004
#> SRR944288     1  0.0188       0.99 0.996 0.000 0.000 0.004
#> SRR944287     1  0.0188       0.99 0.996 0.000 0.000 0.004
#> SRR944289     1  0.0000       0.99 1.000 0.000 0.000 0.000
#> SRR944290     1  0.0000       0.99 1.000 0.000 0.000 0.000
#> SRR944291     1  0.0188       0.99 0.996 0.000 0.000 0.004
#> SRR944292     4  0.3910       1.00 0.000 0.024 0.156 0.820
#> SRR944293     1  0.0188       0.99 0.996 0.000 0.000 0.004
#> SRR944294     1  0.0188       0.99 0.996 0.000 0.000 0.004
#> SRR944295     2  0.0000       1.00 0.000 1.000 0.000 0.000
#> SRR944296     2  0.0000       1.00 0.000 1.000 0.000 0.000
#> SRR944297     2  0.0000       1.00 0.000 1.000 0.000 0.000
#> SRR944298     2  0.0000       1.00 0.000 1.000 0.000 0.000
#> SRR944299     1  0.0000       0.99 1.000 0.000 0.000 0.000
#> SRR944300     1  0.0000       0.99 1.000 0.000 0.000 0.000
#> SRR944301     1  0.0000       0.99 1.000 0.000 0.000 0.000
#> SRR944302     4  0.3910       1.00 0.000 0.024 0.156 0.820
#> SRR944303     2  0.0000       1.00 0.000 1.000 0.000 0.000
#> SRR944304     1  0.0000       0.99 1.000 0.000 0.000 0.000
#> SRR944305     1  0.0000       0.99 1.000 0.000 0.000 0.000
#> SRR944306     1  0.0000       0.99 1.000 0.000 0.000 0.000
#> SRR944307     1  0.0000       0.99 1.000 0.000 0.000 0.000
#> SRR944308     1  0.0000       0.99 1.000 0.000 0.000 0.000
#> SRR944309     1  0.0000       0.99 1.000 0.000 0.000 0.000
#> SRR944310     1  0.0000       0.99 1.000 0.000 0.000 0.000
#> SRR944311     2  0.0000       1.00 0.000 1.000 0.000 0.000
#> SRR944312     1  0.0000       0.99 1.000 0.000 0.000 0.000
#> SRR944313     1  0.0000       0.99 1.000 0.000 0.000 0.000
#> SRR944315     1  0.0188       0.99 0.996 0.000 0.000 0.004
#> SRR944314     1  0.0188       0.99 0.996 0.000 0.000 0.004
#> SRR944316     1  0.0188       0.99 0.996 0.000 0.000 0.004
#> SRR944317     2  0.0000       1.00 0.000 1.000 0.000 0.000
#> SRR944318     2  0.0000       1.00 0.000 1.000 0.000 0.000
#> SRR944319     2  0.0000       1.00 0.000 1.000 0.000 0.000
#> SRR944320     2  0.0000       1.00 0.000 1.000 0.000 0.000
#> SRR944321     1  0.0188       0.99 0.996 0.000 0.000 0.004
#> SRR944322     1  0.0188       0.99 0.996 0.000 0.000 0.004
#> SRR944323     1  0.0188       0.99 0.996 0.000 0.000 0.004
#> SRR944324     1  0.0188       0.99 0.996 0.000 0.000 0.004
#> SRR944325     1  0.0188       0.99 0.996 0.000 0.000 0.004
#> SRR944326     1  0.0188       0.99 0.996 0.000 0.000 0.004
#> SRR944327     1  0.3400       0.80 0.820 0.000 0.000 0.180
#> SRR944328     1  0.3400       0.80 0.820 0.000 0.000 0.180
#> SRR944329     1  0.0000       0.99 1.000 0.000 0.000 0.000
#> SRR944330     1  0.0000       0.99 1.000 0.000 0.000 0.000
#> SRR944331     1  0.0000       0.99 1.000 0.000 0.000 0.000
#> SRR944332     1  0.0000       0.99 1.000 0.000 0.000 0.000
#> SRR944334     1  0.0000       0.99 1.000 0.000 0.000 0.000
#> SRR944333     1  0.0000       0.99 1.000 0.000 0.000 0.000
#> SRR944335     1  0.0000       0.99 1.000 0.000 0.000 0.000
#> SRR944336     1  0.0000       0.99 1.000 0.000 0.000 0.000
#> SRR944337     1  0.0000       0.99 1.000 0.000 0.000 0.000
#> SRR944338     3  0.0000       1.00 0.000 0.000 1.000 0.000
#> SRR944339     3  0.0000       1.00 0.000 0.000 1.000 0.000
#> SRR944340     3  0.0000       1.00 0.000 0.000 1.000 0.000
#> SRR944341     3  0.0000       1.00 0.000 0.000 1.000 0.000
#> SRR944342     3  0.0000       1.00 0.000 0.000 1.000 0.000
#> SRR944343     3  0.0000       1.00 0.000 0.000 1.000 0.000
#> SRR944344     3  0.0000       1.00 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
#> SRR944282     1  0.0404      0.991 0.988 0.000 0.000  0 0.012
#> SRR944283     1  0.0404      0.991 0.988 0.000 0.000  0 0.012
#> SRR944284     1  0.0404      0.991 0.988 0.000 0.000  0 0.012
#> SRR944285     1  0.0404      0.991 0.988 0.000 0.000  0 0.012
#> SRR944288     1  0.0404      0.991 0.988 0.000 0.000  0 0.012
#> SRR944287     1  0.0162      0.994 0.996 0.000 0.000  0 0.004
#> SRR944289     1  0.0162      0.994 0.996 0.000 0.000  0 0.004
#> SRR944290     1  0.0000      0.995 1.000 0.000 0.000  0 0.000
#> SRR944291     1  0.0404      0.991 0.988 0.000 0.000  0 0.012
#> SRR944292     4  0.0000      1.000 0.000 0.000 0.000  1 0.000
#> SRR944293     1  0.0404      0.991 0.988 0.000 0.000  0 0.012
#> SRR944294     1  0.0404      0.991 0.988 0.000 0.000  0 0.012
#> SRR944295     2  0.0000      0.956 0.000 1.000 0.000  0 0.000
#> SRR944296     2  0.0000      0.956 0.000 1.000 0.000  0 0.000
#> SRR944297     2  0.0000      0.956 0.000 1.000 0.000  0 0.000
#> SRR944298     2  0.0000      0.956 0.000 1.000 0.000  0 0.000
#> SRR944299     1  0.0000      0.995 1.000 0.000 0.000  0 0.000
#> SRR944300     1  0.0000      0.995 1.000 0.000 0.000  0 0.000
#> SRR944301     1  0.0000      0.995 1.000 0.000 0.000  0 0.000
#> SRR944302     4  0.0000      1.000 0.000 0.000 0.000  1 0.000
#> SRR944303     2  0.0000      0.956 0.000 1.000 0.000  0 0.000
#> SRR944304     1  0.0000      0.995 1.000 0.000 0.000  0 0.000
#> SRR944305     1  0.0000      0.995 1.000 0.000 0.000  0 0.000
#> SRR944306     1  0.0000      0.995 1.000 0.000 0.000  0 0.000
#> SRR944307     1  0.0000      0.995 1.000 0.000 0.000  0 0.000
#> SRR944308     1  0.0000      0.995 1.000 0.000 0.000  0 0.000
#> SRR944309     1  0.0000      0.995 1.000 0.000 0.000  0 0.000
#> SRR944310     1  0.0000      0.995 1.000 0.000 0.000  0 0.000
#> SRR944311     2  0.0000      0.956 0.000 1.000 0.000  0 0.000
#> SRR944312     1  0.0000      0.995 1.000 0.000 0.000  0 0.000
#> SRR944313     1  0.0000      0.995 1.000 0.000 0.000  0 0.000
#> SRR944315     1  0.0290      0.993 0.992 0.000 0.000  0 0.008
#> SRR944314     1  0.0290      0.992 0.992 0.000 0.000  0 0.008
#> SRR944316     1  0.0404      0.991 0.988 0.000 0.000  0 0.012
#> SRR944317     2  0.0000      0.956 0.000 1.000 0.000  0 0.000
#> SRR944318     2  0.0000      0.956 0.000 1.000 0.000  0 0.000
#> SRR944319     2  0.3210      0.801 0.000 0.788 0.000  0 0.212
#> SRR944320     2  0.3210      0.801 0.000 0.788 0.000  0 0.212
#> SRR944321     1  0.0162      0.994 0.996 0.000 0.000  0 0.004
#> SRR944322     1  0.0162      0.994 0.996 0.000 0.000  0 0.004
#> SRR944323     1  0.0162      0.994 0.996 0.000 0.000  0 0.004
#> SRR944324     1  0.0162      0.994 0.996 0.000 0.000  0 0.004
#> SRR944325     1  0.0162      0.994 0.996 0.000 0.000  0 0.004
#> SRR944326     1  0.0162      0.994 0.996 0.000 0.000  0 0.004
#> SRR944327     5  0.3586      1.000 0.264 0.000 0.000  0 0.736
#> SRR944328     5  0.3586      1.000 0.264 0.000 0.000  0 0.736
#> SRR944329     1  0.0162      0.994 0.996 0.000 0.000  0 0.004
#> SRR944330     1  0.0162      0.994 0.996 0.000 0.000  0 0.004
#> SRR944331     1  0.0162      0.994 0.996 0.000 0.000  0 0.004
#> SRR944332     1  0.0162      0.994 0.996 0.000 0.000  0 0.004
#> SRR944334     1  0.0162      0.994 0.996 0.000 0.000  0 0.004
#> SRR944333     1  0.0162      0.994 0.996 0.000 0.000  0 0.004
#> SRR944335     1  0.0000      0.995 1.000 0.000 0.000  0 0.000
#> SRR944336     1  0.0000      0.995 1.000 0.000 0.000  0 0.000
#> SRR944337     1  0.0000      0.995 1.000 0.000 0.000  0 0.000
#> SRR944338     3  0.0000      0.992 0.000 0.000 1.000  0 0.000
#> SRR944339     3  0.0000      0.992 0.000 0.000 1.000  0 0.000
#> SRR944340     3  0.0000      0.992 0.000 0.000 1.000  0 0.000
#> SRR944341     3  0.0000      0.992 0.000 0.000 1.000  0 0.000
#> SRR944342     3  0.0000      0.992 0.000 0.000 1.000  0 0.000
#> SRR944343     3  0.0000      0.992 0.000 0.000 1.000  0 0.000
#> SRR944344     3  0.1270      0.953 0.000 0.000 0.948  0 0.052

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4  p5 p6
#> SRR944282     1  0.0520      0.986 0.984 0.000 0.000 0.008 0.0 NA
#> SRR944283     1  0.0520      0.986 0.984 0.000 0.000 0.008 0.0 NA
#> SRR944284     1  0.0520      0.986 0.984 0.000 0.000 0.008 0.0 NA
#> SRR944285     1  0.0520      0.986 0.984 0.000 0.000 0.008 0.0 NA
#> SRR944288     1  0.0520      0.986 0.984 0.000 0.000 0.008 0.0 NA
#> SRR944287     1  0.0260      0.988 0.992 0.000 0.000 0.000 0.0 NA
#> SRR944289     1  0.0291      0.988 0.992 0.000 0.000 0.004 0.0 NA
#> SRR944290     1  0.0260      0.986 0.992 0.000 0.000 0.000 0.0 NA
#> SRR944291     1  0.0520      0.986 0.984 0.000 0.000 0.008 0.0 NA
#> SRR944292     5  0.2793      0.872 0.000 0.000 0.000 0.000 0.8 NA
#> SRR944293     1  0.0520      0.986 0.984 0.000 0.000 0.008 0.0 NA
#> SRR944294     1  0.0520      0.986 0.984 0.000 0.000 0.008 0.0 NA
#> SRR944295     2  0.0000      0.922 0.000 1.000 0.000 0.000 0.0 NA
#> SRR944296     2  0.0000      0.922 0.000 1.000 0.000 0.000 0.0 NA
#> SRR944297     2  0.0000      0.922 0.000 1.000 0.000 0.000 0.0 NA
#> SRR944298     2  0.0000      0.922 0.000 1.000 0.000 0.000 0.0 NA
#> SRR944299     1  0.0547      0.978 0.980 0.000 0.000 0.000 0.0 NA
#> SRR944300     1  0.0547      0.978 0.980 0.000 0.000 0.000 0.0 NA
#> SRR944301     1  0.0260      0.986 0.992 0.000 0.000 0.000 0.0 NA
#> SRR944302     5  0.0000      0.872 0.000 0.000 0.000 0.000 1.0 NA
#> SRR944303     2  0.0000      0.922 0.000 1.000 0.000 0.000 0.0 NA
#> SRR944304     1  0.0260      0.986 0.992 0.000 0.000 0.000 0.0 NA
#> SRR944305     1  0.0937      0.957 0.960 0.000 0.000 0.000 0.0 NA
#> SRR944306     1  0.0458      0.981 0.984 0.000 0.000 0.000 0.0 NA
#> SRR944307     1  0.0547      0.978 0.980 0.000 0.000 0.000 0.0 NA
#> SRR944308     1  0.0260      0.986 0.992 0.000 0.000 0.000 0.0 NA
#> SRR944309     1  0.0260      0.986 0.992 0.000 0.000 0.000 0.0 NA
#> SRR944310     1  0.0260      0.986 0.992 0.000 0.000 0.000 0.0 NA
#> SRR944311     2  0.0000      0.922 0.000 1.000 0.000 0.000 0.0 NA
#> SRR944312     1  0.0260      0.986 0.992 0.000 0.000 0.000 0.0 NA
#> SRR944313     1  0.0260      0.986 0.992 0.000 0.000 0.000 0.0 NA
#> SRR944315     1  0.0508      0.989 0.984 0.000 0.000 0.004 0.0 NA
#> SRR944314     1  0.0291      0.988 0.992 0.000 0.000 0.004 0.0 NA
#> SRR944316     1  0.0520      0.986 0.984 0.000 0.000 0.008 0.0 NA
#> SRR944317     2  0.0000      0.922 0.000 1.000 0.000 0.000 0.0 NA
#> SRR944318     2  0.0000      0.922 0.000 1.000 0.000 0.000 0.0 NA
#> SRR944319     2  0.5067      0.610 0.000 0.636 0.000 0.184 0.0 NA
#> SRR944320     2  0.4980      0.624 0.000 0.648 0.000 0.184 0.0 NA
#> SRR944321     1  0.0146      0.989 0.996 0.000 0.000 0.000 0.0 NA
#> SRR944322     1  0.0146      0.989 0.996 0.000 0.000 0.000 0.0 NA
#> SRR944323     1  0.0146      0.989 0.996 0.000 0.000 0.000 0.0 NA
#> SRR944324     1  0.0146      0.989 0.996 0.000 0.000 0.000 0.0 NA
#> SRR944325     1  0.0146      0.989 0.996 0.000 0.000 0.000 0.0 NA
#> SRR944326     1  0.0146      0.989 0.996 0.000 0.000 0.000 0.0 NA
#> SRR944327     4  0.4358      0.936 0.184 0.000 0.000 0.716 0.0 NA
#> SRR944328     4  0.2664      0.936 0.184 0.000 0.000 0.816 0.0 NA
#> SRR944329     1  0.0291      0.988 0.992 0.000 0.000 0.004 0.0 NA
#> SRR944330     1  0.0291      0.988 0.992 0.000 0.000 0.004 0.0 NA
#> SRR944331     1  0.0291      0.988 0.992 0.000 0.000 0.004 0.0 NA
#> SRR944332     1  0.0291      0.988 0.992 0.000 0.000 0.004 0.0 NA
#> SRR944334     1  0.0291      0.988 0.992 0.000 0.000 0.004 0.0 NA
#> SRR944333     1  0.0291      0.988 0.992 0.000 0.000 0.004 0.0 NA
#> SRR944335     1  0.0146      0.989 0.996 0.000 0.000 0.000 0.0 NA
#> SRR944336     1  0.0146      0.989 0.996 0.000 0.000 0.000 0.0 NA
#> SRR944337     1  0.0146      0.989 0.996 0.000 0.000 0.000 0.0 NA
#> SRR944338     3  0.0000      0.925 0.000 0.000 1.000 0.000 0.0 NA
#> SRR944339     3  0.0000      0.925 0.000 0.000 1.000 0.000 0.0 NA
#> SRR944340     3  0.0000      0.925 0.000 0.000 1.000 0.000 0.0 NA
#> SRR944341     3  0.0000      0.925 0.000 0.000 1.000 0.000 0.0 NA
#> SRR944342     3  0.0000      0.925 0.000 0.000 1.000 0.000 0.0 NA
#> SRR944343     3  0.0000      0.925 0.000 0.000 1.000 0.000 0.0 NA
#> SRR944344     3  0.3862      0.392 0.000 0.000 0.524 0.000 0.0 NA

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-hclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-hclust-collect-classes

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


MAD:kmeans

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

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

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

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 12673 rows and 62 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.787           0.944       0.957         0.3889 0.568   0.568
#> 3 3 0.684           0.923       0.895         0.3396 0.952   0.916
#> 4 4 0.629           0.775       0.786         0.2165 0.825   0.665
#> 5 5 0.609           0.772       0.773         0.1141 0.853   0.589
#> 6 6 0.713           0.786       0.832         0.0876 0.988   0.948

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
#> SRR944282     1   0.000      0.998 1.000 0.000
#> SRR944283     1   0.000      0.998 1.000 0.000
#> SRR944284     1   0.000      0.998 1.000 0.000
#> SRR944285     1   0.000      0.998 1.000 0.000
#> SRR944288     1   0.000      0.998 1.000 0.000
#> SRR944287     1   0.000      0.998 1.000 0.000
#> SRR944289     1   0.000      0.998 1.000 0.000
#> SRR944290     1   0.000      0.998 1.000 0.000
#> SRR944291     1   0.000      0.998 1.000 0.000
#> SRR944292     2   0.871      0.769 0.292 0.708
#> SRR944293     1   0.000      0.998 1.000 0.000
#> SRR944294     1   0.000      0.998 1.000 0.000
#> SRR944295     2   0.141      0.863 0.020 0.980
#> SRR944296     2   0.141      0.863 0.020 0.980
#> SRR944297     2   0.141      0.863 0.020 0.980
#> SRR944298     2   0.141      0.863 0.020 0.980
#> SRR944299     1   0.000      0.998 1.000 0.000
#> SRR944300     1   0.000      0.998 1.000 0.000
#> SRR944301     1   0.000      0.998 1.000 0.000
#> SRR944302     2   0.871      0.769 0.292 0.708
#> SRR944303     2   0.141      0.863 0.020 0.980
#> SRR944304     1   0.000      0.998 1.000 0.000
#> SRR944305     1   0.000      0.998 1.000 0.000
#> SRR944306     1   0.000      0.998 1.000 0.000
#> SRR944307     1   0.000      0.998 1.000 0.000
#> SRR944308     1   0.000      0.998 1.000 0.000
#> SRR944309     1   0.000      0.998 1.000 0.000
#> SRR944310     1   0.000      0.998 1.000 0.000
#> SRR944311     2   0.141      0.863 0.020 0.980
#> SRR944312     1   0.000      0.998 1.000 0.000
#> SRR944313     1   0.000      0.998 1.000 0.000
#> SRR944315     1   0.000      0.998 1.000 0.000
#> SRR944314     1   0.000      0.998 1.000 0.000
#> SRR944316     1   0.000      0.998 1.000 0.000
#> SRR944317     2   0.141      0.863 0.020 0.980
#> SRR944318     2   0.141      0.863 0.020 0.980
#> SRR944319     2   0.141      0.863 0.020 0.980
#> SRR944320     2   0.141      0.863 0.020 0.980
#> SRR944321     1   0.000      0.998 1.000 0.000
#> SRR944322     1   0.000      0.998 1.000 0.000
#> SRR944323     1   0.000      0.998 1.000 0.000
#> SRR944324     1   0.000      0.998 1.000 0.000
#> SRR944325     1   0.000      0.998 1.000 0.000
#> SRR944326     1   0.000      0.998 1.000 0.000
#> SRR944327     1   0.000      0.998 1.000 0.000
#> SRR944328     1   0.000      0.998 1.000 0.000
#> SRR944329     1   0.224      0.957 0.964 0.036
#> SRR944330     1   0.224      0.957 0.964 0.036
#> SRR944331     1   0.000      0.998 1.000 0.000
#> SRR944332     1   0.000      0.998 1.000 0.000
#> SRR944334     1   0.000      0.998 1.000 0.000
#> SRR944333     1   0.000      0.998 1.000 0.000
#> SRR944335     1   0.000      0.998 1.000 0.000
#> SRR944336     1   0.000      0.998 1.000 0.000
#> SRR944337     1   0.000      0.998 1.000 0.000
#> SRR944338     2   0.844      0.786 0.272 0.728
#> SRR944339     2   0.844      0.786 0.272 0.728
#> SRR944340     2   0.844      0.786 0.272 0.728
#> SRR944341     2   0.844      0.786 0.272 0.728
#> SRR944342     2   0.844      0.786 0.272 0.728
#> SRR944343     2   0.844      0.786 0.272 0.728
#> SRR944344     2   0.644      0.830 0.164 0.836

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> SRR944282     1  0.1860      0.918 0.948 0.000 0.052
#> SRR944283     1  0.1860      0.918 0.948 0.000 0.052
#> SRR944284     1  0.1753      0.918 0.952 0.000 0.048
#> SRR944285     1  0.1753      0.918 0.952 0.000 0.048
#> SRR944288     1  0.1753      0.918 0.952 0.000 0.048
#> SRR944287     1  0.1753      0.918 0.952 0.000 0.048
#> SRR944289     1  0.4062      0.862 0.836 0.000 0.164
#> SRR944290     1  0.0592      0.920 0.988 0.000 0.012
#> SRR944291     1  0.1753      0.918 0.952 0.000 0.048
#> SRR944292     3  0.6475      0.959 0.028 0.280 0.692
#> SRR944293     1  0.1753      0.918 0.952 0.000 0.048
#> SRR944294     1  0.1753      0.918 0.952 0.000 0.048
#> SRR944295     2  0.0000      1.000 0.000 1.000 0.000
#> SRR944296     2  0.0000      1.000 0.000 1.000 0.000
#> SRR944297     2  0.0000      1.000 0.000 1.000 0.000
#> SRR944298     2  0.0000      1.000 0.000 1.000 0.000
#> SRR944299     1  0.2448      0.911 0.924 0.000 0.076
#> SRR944300     1  0.2448      0.911 0.924 0.000 0.076
#> SRR944301     1  0.1860      0.918 0.948 0.000 0.052
#> SRR944302     3  0.6475      0.959 0.028 0.280 0.692
#> SRR944303     2  0.0000      1.000 0.000 1.000 0.000
#> SRR944304     1  0.2165      0.918 0.936 0.000 0.064
#> SRR944305     1  0.1860      0.916 0.948 0.000 0.052
#> SRR944306     1  0.1411      0.918 0.964 0.000 0.036
#> SRR944307     1  0.2448      0.911 0.924 0.000 0.076
#> SRR944308     1  0.1860      0.918 0.948 0.000 0.052
#> SRR944309     1  0.2261      0.917 0.932 0.000 0.068
#> SRR944310     1  0.1860      0.918 0.948 0.000 0.052
#> SRR944311     2  0.0000      1.000 0.000 1.000 0.000
#> SRR944312     1  0.1860      0.916 0.948 0.000 0.052
#> SRR944313     1  0.1860      0.918 0.948 0.000 0.052
#> SRR944315     1  0.1753      0.918 0.952 0.000 0.048
#> SRR944314     1  0.2261      0.916 0.932 0.000 0.068
#> SRR944316     1  0.1753      0.918 0.952 0.000 0.048
#> SRR944317     2  0.0000      1.000 0.000 1.000 0.000
#> SRR944318     2  0.0000      1.000 0.000 1.000 0.000
#> SRR944319     2  0.0000      1.000 0.000 1.000 0.000
#> SRR944320     2  0.0000      1.000 0.000 1.000 0.000
#> SRR944321     1  0.2165      0.913 0.936 0.000 0.064
#> SRR944322     1  0.2165      0.913 0.936 0.000 0.064
#> SRR944323     1  0.2165      0.913 0.936 0.000 0.064
#> SRR944324     1  0.2165      0.913 0.936 0.000 0.064
#> SRR944325     1  0.2165      0.913 0.936 0.000 0.064
#> SRR944326     1  0.2165      0.913 0.936 0.000 0.064
#> SRR944327     1  0.2959      0.899 0.900 0.000 0.100
#> SRR944328     1  0.2878      0.899 0.904 0.000 0.096
#> SRR944329     1  0.8026      0.656 0.656 0.180 0.164
#> SRR944330     1  0.8026      0.656 0.656 0.180 0.164
#> SRR944331     1  0.4062      0.862 0.836 0.000 0.164
#> SRR944332     1  0.4062      0.862 0.836 0.000 0.164
#> SRR944334     1  0.4062      0.862 0.836 0.000 0.164
#> SRR944333     1  0.4062      0.862 0.836 0.000 0.164
#> SRR944335     1  0.4235      0.859 0.824 0.000 0.176
#> SRR944336     1  0.4235      0.859 0.824 0.000 0.176
#> SRR944337     1  0.4235      0.859 0.824 0.000 0.176
#> SRR944338     3  0.6187      0.989 0.028 0.248 0.724
#> SRR944339     3  0.6187      0.989 0.028 0.248 0.724
#> SRR944340     3  0.6187      0.989 0.028 0.248 0.724
#> SRR944341     3  0.6187      0.989 0.028 0.248 0.724
#> SRR944342     3  0.6187      0.989 0.028 0.248 0.724
#> SRR944343     3  0.6187      0.989 0.028 0.248 0.724
#> SRR944344     3  0.6187      0.989 0.028 0.248 0.724

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> SRR944282     1  0.0707      0.754 0.980 0.000 0.000 0.020
#> SRR944283     1  0.0707      0.754 0.980 0.000 0.000 0.020
#> SRR944284     1  0.0000      0.759 1.000 0.000 0.000 0.000
#> SRR944285     1  0.0000      0.759 1.000 0.000 0.000 0.000
#> SRR944288     1  0.0188      0.759 0.996 0.000 0.004 0.000
#> SRR944287     1  0.0592      0.759 0.984 0.000 0.000 0.016
#> SRR944289     4  0.4661      0.959 0.348 0.000 0.000 0.652
#> SRR944290     1  0.3837      0.576 0.776 0.000 0.000 0.224
#> SRR944291     1  0.0336      0.755 0.992 0.000 0.000 0.008
#> SRR944292     3  0.8906      0.544 0.268 0.068 0.436 0.228
#> SRR944293     1  0.0000      0.759 1.000 0.000 0.000 0.000
#> SRR944294     1  0.0000      0.759 1.000 0.000 0.000 0.000
#> SRR944295     2  0.0000      0.997 0.000 1.000 0.000 0.000
#> SRR944296     2  0.0000      0.997 0.000 1.000 0.000 0.000
#> SRR944297     2  0.0000      0.997 0.000 1.000 0.000 0.000
#> SRR944298     2  0.0000      0.997 0.000 1.000 0.000 0.000
#> SRR944299     1  0.5003      0.507 0.676 0.000 0.016 0.308
#> SRR944300     1  0.5026      0.508 0.672 0.000 0.016 0.312
#> SRR944301     1  0.0657      0.759 0.984 0.000 0.004 0.012
#> SRR944302     3  0.8852      0.543 0.268 0.064 0.440 0.228
#> SRR944303     2  0.0000      0.997 0.000 1.000 0.000 0.000
#> SRR944304     1  0.1970      0.738 0.932 0.000 0.008 0.060
#> SRR944305     1  0.4980      0.522 0.680 0.000 0.016 0.304
#> SRR944306     1  0.4391      0.544 0.740 0.000 0.008 0.252
#> SRR944307     1  0.5364      0.493 0.652 0.000 0.028 0.320
#> SRR944308     1  0.0524      0.758 0.988 0.000 0.004 0.008
#> SRR944309     1  0.2610      0.735 0.900 0.000 0.012 0.088
#> SRR944310     1  0.0524      0.758 0.988 0.000 0.004 0.008
#> SRR944311     2  0.0000      0.997 0.000 1.000 0.000 0.000
#> SRR944312     1  0.5026      0.522 0.672 0.000 0.016 0.312
#> SRR944313     1  0.0469      0.759 0.988 0.000 0.000 0.012
#> SRR944315     1  0.0000      0.759 1.000 0.000 0.000 0.000
#> SRR944314     1  0.2216      0.725 0.908 0.000 0.000 0.092
#> SRR944316     1  0.0000      0.759 1.000 0.000 0.000 0.000
#> SRR944317     2  0.0336      0.996 0.000 0.992 0.000 0.008
#> SRR944318     2  0.0336      0.996 0.000 0.992 0.000 0.008
#> SRR944319     2  0.0336      0.996 0.000 0.992 0.000 0.008
#> SRR944320     2  0.0336      0.996 0.000 0.992 0.000 0.008
#> SRR944321     1  0.5436      0.472 0.620 0.000 0.024 0.356
#> SRR944322     1  0.5436      0.472 0.620 0.000 0.024 0.356
#> SRR944323     1  0.5436      0.472 0.620 0.000 0.024 0.356
#> SRR944324     1  0.5436      0.472 0.620 0.000 0.024 0.356
#> SRR944325     1  0.5436      0.472 0.620 0.000 0.024 0.356
#> SRR944326     1  0.5436      0.472 0.620 0.000 0.024 0.356
#> SRR944327     1  0.2635      0.710 0.904 0.000 0.020 0.076
#> SRR944328     1  0.3037      0.673 0.880 0.000 0.020 0.100
#> SRR944329     4  0.5453      0.930 0.320 0.032 0.000 0.648
#> SRR944330     4  0.5453      0.930 0.320 0.032 0.000 0.648
#> SRR944331     4  0.4661      0.959 0.348 0.000 0.000 0.652
#> SRR944332     4  0.4661      0.959 0.348 0.000 0.000 0.652
#> SRR944334     4  0.4661      0.959 0.348 0.000 0.000 0.652
#> SRR944333     4  0.4661      0.959 0.348 0.000 0.000 0.652
#> SRR944335     4  0.4477      0.936 0.312 0.000 0.000 0.688
#> SRR944336     4  0.4477      0.936 0.312 0.000 0.000 0.688
#> SRR944337     4  0.4477      0.936 0.312 0.000 0.000 0.688
#> SRR944338     3  0.1557      0.873 0.000 0.056 0.944 0.000
#> SRR944339     3  0.1557      0.873 0.000 0.056 0.944 0.000
#> SRR944340     3  0.1557      0.873 0.000 0.056 0.944 0.000
#> SRR944341     3  0.1557      0.873 0.000 0.056 0.944 0.000
#> SRR944342     3  0.1557      0.873 0.000 0.056 0.944 0.000
#> SRR944343     3  0.1557      0.873 0.000 0.056 0.944 0.000
#> SRR944344     3  0.3090      0.851 0.000 0.056 0.888 0.056

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> SRR944282     1  0.0771      0.819 0.976 0.000 0.000 0.004 0.020
#> SRR944283     1  0.0771      0.819 0.976 0.000 0.000 0.004 0.020
#> SRR944284     1  0.0162      0.832 0.996 0.000 0.000 0.004 0.000
#> SRR944285     1  0.0162      0.832 0.996 0.000 0.000 0.004 0.000
#> SRR944288     1  0.0162      0.832 0.996 0.000 0.000 0.004 0.000
#> SRR944287     1  0.1478      0.810 0.936 0.000 0.000 0.000 0.064
#> SRR944289     4  0.5934      0.968 0.176 0.000 0.000 0.592 0.232
#> SRR944290     1  0.3861      0.349 0.728 0.000 0.000 0.008 0.264
#> SRR944291     1  0.0324      0.829 0.992 0.000 0.000 0.004 0.004
#> SRR944292     5  0.8619     -0.212 0.292 0.016 0.112 0.268 0.312
#> SRR944293     1  0.0162      0.832 0.996 0.000 0.000 0.004 0.000
#> SRR944294     1  0.0162      0.832 0.996 0.000 0.000 0.004 0.000
#> SRR944295     2  0.0162      0.976 0.000 0.996 0.000 0.004 0.000
#> SRR944296     2  0.0566      0.974 0.000 0.984 0.000 0.012 0.004
#> SRR944297     2  0.0324      0.976 0.000 0.992 0.000 0.004 0.004
#> SRR944298     2  0.0324      0.976 0.000 0.992 0.000 0.004 0.004
#> SRR944299     5  0.4397      0.582 0.432 0.000 0.000 0.004 0.564
#> SRR944300     5  0.4397      0.582 0.432 0.000 0.000 0.004 0.564
#> SRR944301     1  0.1908      0.795 0.908 0.000 0.000 0.000 0.092
#> SRR944302     5  0.8619     -0.212 0.292 0.016 0.112 0.268 0.312
#> SRR944303     2  0.0162      0.976 0.000 0.996 0.000 0.004 0.000
#> SRR944304     1  0.2439      0.768 0.876 0.000 0.000 0.004 0.120
#> SRR944305     5  0.4437      0.519 0.464 0.000 0.000 0.004 0.532
#> SRR944306     1  0.4310     -0.114 0.604 0.000 0.000 0.004 0.392
#> SRR944307     5  0.4350      0.605 0.408 0.000 0.000 0.004 0.588
#> SRR944308     1  0.1908      0.795 0.908 0.000 0.000 0.000 0.092
#> SRR944309     1  0.3913      0.274 0.676 0.000 0.000 0.000 0.324
#> SRR944310     1  0.1965      0.793 0.904 0.000 0.000 0.000 0.096
#> SRR944311     2  0.0162      0.976 0.000 0.996 0.000 0.004 0.000
#> SRR944312     5  0.4300      0.515 0.476 0.000 0.000 0.000 0.524
#> SRR944313     1  0.1908      0.795 0.908 0.000 0.000 0.000 0.092
#> SRR944315     1  0.0162      0.832 0.996 0.000 0.000 0.004 0.000
#> SRR944314     1  0.3534      0.475 0.744 0.000 0.000 0.000 0.256
#> SRR944316     1  0.0162      0.832 0.996 0.000 0.000 0.004 0.000
#> SRR944317     2  0.1364      0.969 0.000 0.952 0.000 0.036 0.012
#> SRR944318     2  0.1281      0.969 0.000 0.956 0.000 0.032 0.012
#> SRR944319     2  0.1877      0.958 0.000 0.924 0.000 0.064 0.012
#> SRR944320     2  0.2110      0.954 0.000 0.912 0.000 0.072 0.016
#> SRR944321     5  0.5024      0.664 0.368 0.000 0.004 0.032 0.596
#> SRR944322     5  0.5024      0.664 0.368 0.000 0.004 0.032 0.596
#> SRR944323     5  0.5024      0.664 0.368 0.000 0.004 0.032 0.596
#> SRR944324     5  0.5024      0.664 0.368 0.000 0.004 0.032 0.596
#> SRR944325     5  0.5024      0.664 0.368 0.000 0.004 0.032 0.596
#> SRR944326     5  0.5024      0.664 0.368 0.000 0.004 0.032 0.596
#> SRR944327     1  0.3315      0.692 0.856 0.000 0.008 0.052 0.084
#> SRR944328     1  0.3049      0.713 0.876 0.000 0.012 0.048 0.064
#> SRR944329     4  0.6220      0.956 0.160 0.016 0.000 0.600 0.224
#> SRR944330     4  0.6220      0.956 0.160 0.016 0.000 0.600 0.224
#> SRR944331     4  0.6053      0.973 0.172 0.004 0.000 0.592 0.232
#> SRR944332     4  0.6053      0.973 0.172 0.004 0.000 0.592 0.232
#> SRR944334     4  0.6053      0.973 0.172 0.004 0.000 0.592 0.232
#> SRR944333     4  0.6053      0.973 0.172 0.004 0.000 0.592 0.232
#> SRR944335     4  0.5861      0.955 0.148 0.000 0.000 0.592 0.260
#> SRR944336     4  0.5861      0.955 0.148 0.000 0.000 0.592 0.260
#> SRR944337     4  0.5861      0.955 0.148 0.000 0.000 0.592 0.260
#> SRR944338     3  0.0510      0.976 0.000 0.016 0.984 0.000 0.000
#> SRR944339     3  0.0510      0.976 0.000 0.016 0.984 0.000 0.000
#> SRR944340     3  0.0510      0.976 0.000 0.016 0.984 0.000 0.000
#> SRR944341     3  0.0510      0.976 0.000 0.016 0.984 0.000 0.000
#> SRR944342     3  0.0510      0.976 0.000 0.016 0.984 0.000 0.000
#> SRR944343     3  0.0510      0.976 0.000 0.016 0.984 0.000 0.000
#> SRR944344     3  0.4338      0.847 0.000 0.016 0.792 0.112 0.080

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR944282     1  0.0717     0.7691 0.976 0.000 0.000 0.008 0.000 0.016
#> SRR944283     1  0.0862     0.7683 0.972 0.000 0.000 0.008 0.004 0.016
#> SRR944284     1  0.0405     0.7757 0.988 0.000 0.000 0.008 0.004 0.000
#> SRR944285     1  0.0520     0.7761 0.984 0.000 0.000 0.008 0.008 0.000
#> SRR944288     1  0.0260     0.7760 0.992 0.000 0.000 0.008 0.000 0.000
#> SRR944287     1  0.2511     0.7319 0.880 0.000 0.000 0.000 0.056 0.064
#> SRR944289     4  0.0865     0.9963 0.036 0.000 0.000 0.964 0.000 0.000
#> SRR944290     1  0.5962     0.4276 0.628 0.000 0.000 0.128 0.128 0.116
#> SRR944291     1  0.0405     0.7757 0.988 0.000 0.000 0.008 0.004 0.000
#> SRR944292     5  0.3311     1.0000 0.204 0.004 0.012 0.000 0.780 0.000
#> SRR944293     1  0.0520     0.7761 0.984 0.000 0.000 0.008 0.008 0.000
#> SRR944294     1  0.0520     0.7761 0.984 0.000 0.000 0.008 0.008 0.000
#> SRR944295     2  0.0000     0.9709 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944296     2  0.0653     0.9677 0.000 0.980 0.000 0.004 0.012 0.004
#> SRR944297     2  0.0260     0.9703 0.000 0.992 0.000 0.000 0.008 0.000
#> SRR944298     2  0.0260     0.9703 0.000 0.992 0.000 0.000 0.008 0.000
#> SRR944299     6  0.6931     0.5465 0.304 0.000 0.000 0.108 0.144 0.444
#> SRR944300     6  0.6857     0.5287 0.316 0.000 0.000 0.096 0.144 0.444
#> SRR944301     1  0.4085     0.6437 0.752 0.000 0.000 0.000 0.120 0.128
#> SRR944302     5  0.3311     1.0000 0.204 0.004 0.012 0.000 0.780 0.000
#> SRR944303     2  0.0000     0.9709 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944304     1  0.4701     0.5626 0.684 0.000 0.000 0.000 0.148 0.168
#> SRR944305     6  0.6778     0.4960 0.332 0.000 0.000 0.084 0.144 0.440
#> SRR944306     1  0.6515     0.1600 0.532 0.000 0.000 0.084 0.148 0.236
#> SRR944307     6  0.6808     0.5878 0.260 0.000 0.000 0.108 0.144 0.488
#> SRR944308     1  0.4125     0.6404 0.748 0.000 0.000 0.000 0.128 0.124
#> SRR944309     1  0.5543    -0.0737 0.488 0.000 0.000 0.000 0.140 0.372
#> SRR944310     1  0.4125     0.6404 0.748 0.000 0.000 0.000 0.128 0.124
#> SRR944311     2  0.0000     0.9709 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944312     6  0.6799     0.4850 0.348 0.000 0.000 0.084 0.144 0.424
#> SRR944313     1  0.4085     0.6437 0.752 0.000 0.000 0.000 0.120 0.128
#> SRR944315     1  0.0405     0.7754 0.988 0.000 0.000 0.008 0.000 0.004
#> SRR944314     1  0.2308     0.7150 0.880 0.000 0.000 0.008 0.004 0.108
#> SRR944316     1  0.0520     0.7761 0.984 0.000 0.000 0.008 0.008 0.000
#> SRR944317     2  0.1003     0.9638 0.000 0.964 0.000 0.004 0.004 0.028
#> SRR944318     2  0.1003     0.9638 0.000 0.964 0.000 0.004 0.004 0.028
#> SRR944319     2  0.2113     0.9263 0.000 0.896 0.000 0.008 0.004 0.092
#> SRR944320     2  0.2455     0.9261 0.000 0.888 0.000 0.016 0.016 0.080
#> SRR944321     6  0.5279     0.7135 0.200 0.000 0.000 0.196 0.000 0.604
#> SRR944322     6  0.5279     0.7135 0.200 0.000 0.000 0.196 0.000 0.604
#> SRR944323     6  0.5279     0.7135 0.200 0.000 0.000 0.196 0.000 0.604
#> SRR944324     6  0.5279     0.7135 0.200 0.000 0.000 0.196 0.000 0.604
#> SRR944325     6  0.5279     0.7135 0.200 0.000 0.000 0.196 0.000 0.604
#> SRR944326     6  0.5279     0.7135 0.200 0.000 0.000 0.196 0.000 0.604
#> SRR944327     1  0.3977     0.5622 0.776 0.000 0.004 0.008 0.060 0.152
#> SRR944328     1  0.3762     0.5973 0.800 0.000 0.004 0.008 0.064 0.124
#> SRR944329     4  0.1010     0.9932 0.036 0.000 0.000 0.960 0.000 0.004
#> SRR944330     4  0.1010     0.9932 0.036 0.000 0.000 0.960 0.000 0.004
#> SRR944331     4  0.0865     0.9963 0.036 0.000 0.000 0.964 0.000 0.000
#> SRR944332     4  0.0865     0.9963 0.036 0.000 0.000 0.964 0.000 0.000
#> SRR944334     4  0.0865     0.9963 0.036 0.000 0.000 0.964 0.000 0.000
#> SRR944333     4  0.0865     0.9963 0.036 0.000 0.000 0.964 0.000 0.000
#> SRR944335     4  0.0935     0.9936 0.032 0.000 0.000 0.964 0.000 0.004
#> SRR944336     4  0.0935     0.9936 0.032 0.000 0.000 0.964 0.000 0.004
#> SRR944337     4  0.0935     0.9936 0.032 0.000 0.000 0.964 0.000 0.004
#> SRR944338     3  0.0146     0.9462 0.000 0.004 0.996 0.000 0.000 0.000
#> SRR944339     3  0.0146     0.9462 0.000 0.004 0.996 0.000 0.000 0.000
#> SRR944340     3  0.0146     0.9462 0.000 0.004 0.996 0.000 0.000 0.000
#> SRR944341     3  0.0146     0.9462 0.000 0.004 0.996 0.000 0.000 0.000
#> SRR944342     3  0.0146     0.9462 0.000 0.004 0.996 0.000 0.000 0.000
#> SRR944343     3  0.0146     0.9462 0.000 0.004 0.996 0.000 0.000 0.000
#> SRR944344     3  0.4877     0.5690 0.000 0.004 0.668 0.016 0.252 0.060

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 12673 rows and 62 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.940       0.974         0.4763 0.511   0.511
#> 3 3 1.000           0.985       0.988         0.2705 0.857   0.727
#> 4 4 0.842           0.961       0.933         0.1081 0.952   0.879
#> 5 5 0.753           0.790       0.862         0.1563 0.867   0.615
#> 6 6 0.757           0.563       0.759         0.0584 0.904   0.606

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
#> SRR944282     1   0.000      1.000 1.000 0.000
#> SRR944283     1   0.000      1.000 1.000 0.000
#> SRR944284     1   0.000      1.000 1.000 0.000
#> SRR944285     1   0.000      1.000 1.000 0.000
#> SRR944288     1   0.000      1.000 1.000 0.000
#> SRR944287     1   0.000      1.000 1.000 0.000
#> SRR944289     1   0.000      1.000 1.000 0.000
#> SRR944290     1   0.000      1.000 1.000 0.000
#> SRR944291     1   0.000      1.000 1.000 0.000
#> SRR944292     2   0.000      0.932 0.000 1.000
#> SRR944293     1   0.000      1.000 1.000 0.000
#> SRR944294     1   0.000      1.000 1.000 0.000
#> SRR944295     2   0.000      0.932 0.000 1.000
#> SRR944296     2   0.000      0.932 0.000 1.000
#> SRR944297     2   0.000      0.932 0.000 1.000
#> SRR944298     2   0.000      0.932 0.000 1.000
#> SRR944299     1   0.000      1.000 1.000 0.000
#> SRR944300     1   0.000      1.000 1.000 0.000
#> SRR944301     1   0.000      1.000 1.000 0.000
#> SRR944302     2   0.000      0.932 0.000 1.000
#> SRR944303     2   0.000      0.932 0.000 1.000
#> SRR944304     1   0.000      1.000 1.000 0.000
#> SRR944305     1   0.000      1.000 1.000 0.000
#> SRR944306     1   0.000      1.000 1.000 0.000
#> SRR944307     1   0.000      1.000 1.000 0.000
#> SRR944308     1   0.000      1.000 1.000 0.000
#> SRR944309     1   0.000      1.000 1.000 0.000
#> SRR944310     1   0.000      1.000 1.000 0.000
#> SRR944311     2   0.000      0.932 0.000 1.000
#> SRR944312     1   0.000      1.000 1.000 0.000
#> SRR944313     1   0.000      1.000 1.000 0.000
#> SRR944315     1   0.000      1.000 1.000 0.000
#> SRR944314     1   0.000      1.000 1.000 0.000
#> SRR944316     1   0.000      1.000 1.000 0.000
#> SRR944317     2   0.000      0.932 0.000 1.000
#> SRR944318     2   0.000      0.932 0.000 1.000
#> SRR944319     2   0.000      0.932 0.000 1.000
#> SRR944320     2   0.000      0.932 0.000 1.000
#> SRR944321     1   0.000      1.000 1.000 0.000
#> SRR944322     1   0.000      1.000 1.000 0.000
#> SRR944323     1   0.000      1.000 1.000 0.000
#> SRR944324     1   0.000      1.000 1.000 0.000
#> SRR944325     1   0.000      1.000 1.000 0.000
#> SRR944326     1   0.000      1.000 1.000 0.000
#> SRR944327     1   0.000      1.000 1.000 0.000
#> SRR944328     1   0.000      1.000 1.000 0.000
#> SRR944329     2   0.000      0.932 0.000 1.000
#> SRR944330     2   0.000      0.932 0.000 1.000
#> SRR944331     2   0.969      0.426 0.396 0.604
#> SRR944332     2   0.969      0.426 0.396 0.604
#> SRR944334     2   0.969      0.426 0.396 0.604
#> SRR944333     2   0.969      0.426 0.396 0.604
#> SRR944335     1   0.000      1.000 1.000 0.000
#> SRR944336     1   0.000      1.000 1.000 0.000
#> SRR944337     1   0.000      1.000 1.000 0.000
#> SRR944338     2   0.000      0.932 0.000 1.000
#> SRR944339     2   0.000      0.932 0.000 1.000
#> SRR944340     2   0.000      0.932 0.000 1.000
#> SRR944341     2   0.000      0.932 0.000 1.000
#> SRR944342     2   0.000      0.932 0.000 1.000
#> SRR944343     2   0.000      0.932 0.000 1.000
#> SRR944344     2   0.000      0.932 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
#> SRR944282     1  0.0000      1.000 1.000 0.000 0.000
#> SRR944283     1  0.0000      1.000 1.000 0.000 0.000
#> SRR944284     1  0.0000      1.000 1.000 0.000 0.000
#> SRR944285     1  0.0000      1.000 1.000 0.000 0.000
#> SRR944288     1  0.0000      1.000 1.000 0.000 0.000
#> SRR944287     1  0.0000      1.000 1.000 0.000 0.000
#> SRR944289     3  0.0747      0.966 0.016 0.000 0.984
#> SRR944290     1  0.0000      1.000 1.000 0.000 0.000
#> SRR944291     1  0.0000      1.000 1.000 0.000 0.000
#> SRR944292     2  0.0000      0.970 0.000 1.000 0.000
#> SRR944293     1  0.0000      1.000 1.000 0.000 0.000
#> SRR944294     1  0.0000      1.000 1.000 0.000 0.000
#> SRR944295     2  0.1964      0.972 0.000 0.944 0.056
#> SRR944296     2  0.1964      0.972 0.000 0.944 0.056
#> SRR944297     2  0.1964      0.972 0.000 0.944 0.056
#> SRR944298     2  0.1964      0.972 0.000 0.944 0.056
#> SRR944299     1  0.0000      1.000 1.000 0.000 0.000
#> SRR944300     1  0.0000      1.000 1.000 0.000 0.000
#> SRR944301     1  0.0000      1.000 1.000 0.000 0.000
#> SRR944302     2  0.0000      0.970 0.000 1.000 0.000
#> SRR944303     2  0.1964      0.972 0.000 0.944 0.056
#> SRR944304     1  0.0000      1.000 1.000 0.000 0.000
#> SRR944305     1  0.0000      1.000 1.000 0.000 0.000
#> SRR944306     1  0.0000      1.000 1.000 0.000 0.000
#> SRR944307     1  0.0000      1.000 1.000 0.000 0.000
#> SRR944308     1  0.0000      1.000 1.000 0.000 0.000
#> SRR944309     1  0.0000      1.000 1.000 0.000 0.000
#> SRR944310     1  0.0000      1.000 1.000 0.000 0.000
#> SRR944311     2  0.1964      0.972 0.000 0.944 0.056
#> SRR944312     1  0.0000      1.000 1.000 0.000 0.000
#> SRR944313     1  0.0000      1.000 1.000 0.000 0.000
#> SRR944315     1  0.0000      1.000 1.000 0.000 0.000
#> SRR944314     1  0.0000      1.000 1.000 0.000 0.000
#> SRR944316     1  0.0000      1.000 1.000 0.000 0.000
#> SRR944317     2  0.1964      0.972 0.000 0.944 0.056
#> SRR944318     2  0.1964      0.972 0.000 0.944 0.056
#> SRR944319     2  0.1964      0.972 0.000 0.944 0.056
#> SRR944320     2  0.1964      0.972 0.000 0.944 0.056
#> SRR944321     1  0.0000      1.000 1.000 0.000 0.000
#> SRR944322     1  0.0000      1.000 1.000 0.000 0.000
#> SRR944323     1  0.0000      1.000 1.000 0.000 0.000
#> SRR944324     1  0.0000      1.000 1.000 0.000 0.000
#> SRR944325     1  0.0000      1.000 1.000 0.000 0.000
#> SRR944326     1  0.0000      1.000 1.000 0.000 0.000
#> SRR944327     1  0.0000      1.000 1.000 0.000 0.000
#> SRR944328     1  0.0000      1.000 1.000 0.000 0.000
#> SRR944329     3  0.0000      0.971 0.000 0.000 1.000
#> SRR944330     3  0.0000      0.971 0.000 0.000 1.000
#> SRR944331     3  0.0000      0.971 0.000 0.000 1.000
#> SRR944332     3  0.0000      0.971 0.000 0.000 1.000
#> SRR944334     3  0.0000      0.971 0.000 0.000 1.000
#> SRR944333     3  0.0000      0.971 0.000 0.000 1.000
#> SRR944335     3  0.1964      0.942 0.056 0.000 0.944
#> SRR944336     3  0.1964      0.942 0.056 0.000 0.944
#> SRR944337     3  0.1964      0.942 0.056 0.000 0.944
#> SRR944338     2  0.0000      0.970 0.000 1.000 0.000
#> SRR944339     2  0.0000      0.970 0.000 1.000 0.000
#> SRR944340     2  0.0000      0.970 0.000 1.000 0.000
#> SRR944341     2  0.0000      0.970 0.000 1.000 0.000
#> SRR944342     2  0.0000      0.970 0.000 1.000 0.000
#> SRR944343     2  0.0000      0.970 0.000 1.000 0.000
#> SRR944344     2  0.0000      0.970 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
#> SRR944282     1  0.2522      0.925 0.908 0.076 0.000 0.016
#> SRR944283     1  0.2522      0.925 0.908 0.076 0.000 0.016
#> SRR944284     1  0.2593      0.923 0.904 0.080 0.000 0.016
#> SRR944285     1  0.2329      0.928 0.916 0.072 0.000 0.012
#> SRR944288     1  0.2987      0.922 0.880 0.104 0.000 0.016
#> SRR944287     1  0.1722      0.945 0.944 0.048 0.000 0.008
#> SRR944289     4  0.0657      0.979 0.012 0.004 0.000 0.984
#> SRR944290     1  0.2142      0.938 0.928 0.056 0.000 0.016
#> SRR944291     1  0.2662      0.921 0.900 0.084 0.000 0.016
#> SRR944292     3  0.0469      0.986 0.000 0.012 0.988 0.000
#> SRR944293     1  0.2987      0.922 0.880 0.104 0.000 0.016
#> SRR944294     1  0.2924      0.921 0.884 0.100 0.000 0.016
#> SRR944295     2  0.3266      1.000 0.000 0.832 0.168 0.000
#> SRR944296     2  0.3266      1.000 0.000 0.832 0.168 0.000
#> SRR944297     2  0.3266      1.000 0.000 0.832 0.168 0.000
#> SRR944298     2  0.3266      1.000 0.000 0.832 0.168 0.000
#> SRR944299     1  0.2402      0.933 0.912 0.076 0.000 0.012
#> SRR944300     1  0.2402      0.933 0.912 0.076 0.000 0.012
#> SRR944301     1  0.2334      0.940 0.908 0.088 0.000 0.004
#> SRR944302     3  0.0188      0.994 0.000 0.004 0.996 0.000
#> SRR944303     2  0.3266      1.000 0.000 0.832 0.168 0.000
#> SRR944304     1  0.2542      0.932 0.904 0.084 0.000 0.012
#> SRR944305     1  0.2402      0.933 0.912 0.076 0.000 0.012
#> SRR944306     1  0.2473      0.932 0.908 0.080 0.000 0.012
#> SRR944307     1  0.2329      0.934 0.916 0.072 0.000 0.012
#> SRR944308     1  0.2197      0.936 0.916 0.080 0.000 0.004
#> SRR944309     1  0.1978      0.937 0.928 0.068 0.000 0.004
#> SRR944310     1  0.2149      0.936 0.912 0.088 0.000 0.000
#> SRR944311     2  0.3266      1.000 0.000 0.832 0.168 0.000
#> SRR944312     1  0.2179      0.936 0.924 0.064 0.000 0.012
#> SRR944313     1  0.2334      0.941 0.908 0.088 0.000 0.004
#> SRR944315     1  0.2450      0.927 0.912 0.072 0.000 0.016
#> SRR944314     1  0.1174      0.940 0.968 0.020 0.000 0.012
#> SRR944316     1  0.1938      0.942 0.936 0.052 0.000 0.012
#> SRR944317     2  0.3266      1.000 0.000 0.832 0.168 0.000
#> SRR944318     2  0.3266      1.000 0.000 0.832 0.168 0.000
#> SRR944319     2  0.3266      1.000 0.000 0.832 0.168 0.000
#> SRR944320     2  0.3266      1.000 0.000 0.832 0.168 0.000
#> SRR944321     1  0.0469      0.943 0.988 0.000 0.000 0.012
#> SRR944322     1  0.0469      0.943 0.988 0.000 0.000 0.012
#> SRR944323     1  0.0469      0.943 0.988 0.000 0.000 0.012
#> SRR944324     1  0.0469      0.943 0.988 0.000 0.000 0.012
#> SRR944325     1  0.0469      0.943 0.988 0.000 0.000 0.012
#> SRR944326     1  0.0469      0.943 0.988 0.000 0.000 0.012
#> SRR944327     1  0.1975      0.934 0.936 0.048 0.000 0.016
#> SRR944328     1  0.2522      0.927 0.908 0.076 0.000 0.016
#> SRR944329     4  0.0921      0.982 0.000 0.028 0.000 0.972
#> SRR944330     4  0.0921      0.982 0.000 0.028 0.000 0.972
#> SRR944331     4  0.0817      0.985 0.000 0.024 0.000 0.976
#> SRR944332     4  0.0817      0.985 0.000 0.024 0.000 0.976
#> SRR944334     4  0.0817      0.985 0.000 0.024 0.000 0.976
#> SRR944333     4  0.0817      0.985 0.000 0.024 0.000 0.976
#> SRR944335     4  0.0592      0.976 0.016 0.000 0.000 0.984
#> SRR944336     4  0.0592      0.976 0.016 0.000 0.000 0.984
#> SRR944337     4  0.0592      0.976 0.016 0.000 0.000 0.984
#> SRR944338     3  0.0000      0.998 0.000 0.000 1.000 0.000
#> SRR944339     3  0.0000      0.998 0.000 0.000 1.000 0.000
#> SRR944340     3  0.0000      0.998 0.000 0.000 1.000 0.000
#> SRR944341     3  0.0000      0.998 0.000 0.000 1.000 0.000
#> SRR944342     3  0.0000      0.998 0.000 0.000 1.000 0.000
#> SRR944343     3  0.0000      0.998 0.000 0.000 1.000 0.000
#> SRR944344     3  0.0000      0.998 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
#> SRR944282     5  0.3671      0.740 0.236 0.000 0.008 0.000 0.756
#> SRR944283     5  0.3607      0.746 0.244 0.000 0.004 0.000 0.752
#> SRR944284     5  0.2818      0.771 0.132 0.000 0.012 0.000 0.856
#> SRR944285     5  0.2966      0.731 0.184 0.000 0.000 0.000 0.816
#> SRR944288     5  0.3006      0.757 0.156 0.000 0.004 0.004 0.836
#> SRR944287     1  0.4118      0.536 0.660 0.000 0.000 0.004 0.336
#> SRR944289     4  0.0727      0.985 0.012 0.004 0.000 0.980 0.004
#> SRR944290     1  0.2787      0.692 0.856 0.000 0.004 0.004 0.136
#> SRR944291     5  0.3343      0.759 0.172 0.000 0.016 0.000 0.812
#> SRR944292     3  0.2127      0.905 0.000 0.108 0.892 0.000 0.000
#> SRR944293     5  0.2136      0.709 0.088 0.000 0.008 0.000 0.904
#> SRR944294     5  0.1892      0.731 0.080 0.000 0.004 0.000 0.916
#> SRR944295     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR944296     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR944297     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR944298     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR944299     1  0.0932      0.679 0.972 0.000 0.004 0.004 0.020
#> SRR944300     1  0.1357      0.679 0.948 0.000 0.004 0.000 0.048
#> SRR944301     1  0.4201      0.521 0.664 0.000 0.000 0.008 0.328
#> SRR944302     3  0.3003      0.811 0.000 0.188 0.812 0.000 0.000
#> SRR944303     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR944304     1  0.2957      0.607 0.860 0.000 0.008 0.012 0.120
#> SRR944305     1  0.1365      0.676 0.952 0.000 0.004 0.004 0.040
#> SRR944306     1  0.1901      0.660 0.928 0.000 0.012 0.004 0.056
#> SRR944307     1  0.0865      0.686 0.972 0.000 0.004 0.000 0.024
#> SRR944308     1  0.3053      0.663 0.828 0.000 0.000 0.008 0.164
#> SRR944309     1  0.2997      0.691 0.840 0.000 0.000 0.012 0.148
#> SRR944310     1  0.3989      0.529 0.728 0.000 0.004 0.008 0.260
#> SRR944311     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR944312     1  0.2377      0.694 0.872 0.000 0.000 0.000 0.128
#> SRR944313     1  0.4044      0.597 0.732 0.000 0.004 0.012 0.252
#> SRR944315     5  0.4193      0.667 0.304 0.000 0.012 0.000 0.684
#> SRR944314     1  0.4283      0.202 0.544 0.000 0.000 0.000 0.456
#> SRR944316     5  0.4288      0.384 0.384 0.000 0.004 0.000 0.612
#> SRR944317     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR944318     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR944319     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR944320     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR944321     1  0.4101      0.531 0.664 0.000 0.004 0.000 0.332
#> SRR944322     1  0.4101      0.531 0.664 0.000 0.004 0.000 0.332
#> SRR944323     1  0.4101      0.531 0.664 0.000 0.004 0.000 0.332
#> SRR944324     1  0.4101      0.531 0.664 0.000 0.004 0.000 0.332
#> SRR944325     1  0.4101      0.531 0.664 0.000 0.004 0.000 0.332
#> SRR944326     1  0.4101      0.531 0.664 0.000 0.004 0.000 0.332
#> SRR944327     5  0.4371      0.569 0.344 0.000 0.012 0.000 0.644
#> SRR944328     5  0.3759      0.755 0.220 0.000 0.016 0.000 0.764
#> SRR944329     4  0.0404      0.991 0.000 0.012 0.000 0.988 0.000
#> SRR944330     4  0.0404      0.991 0.000 0.012 0.000 0.988 0.000
#> SRR944331     4  0.0404      0.991 0.000 0.012 0.000 0.988 0.000
#> SRR944332     4  0.0404      0.991 0.000 0.012 0.000 0.988 0.000
#> SRR944334     4  0.0404      0.991 0.000 0.012 0.000 0.988 0.000
#> SRR944333     4  0.0404      0.991 0.000 0.012 0.000 0.988 0.000
#> SRR944335     4  0.0609      0.983 0.020 0.000 0.000 0.980 0.000
#> SRR944336     4  0.0609      0.983 0.020 0.000 0.000 0.980 0.000
#> SRR944337     4  0.0609      0.983 0.020 0.000 0.000 0.980 0.000
#> SRR944338     3  0.0703      0.968 0.000 0.024 0.976 0.000 0.000
#> SRR944339     3  0.0703      0.968 0.000 0.024 0.976 0.000 0.000
#> SRR944340     3  0.0703      0.968 0.000 0.024 0.976 0.000 0.000
#> SRR944341     3  0.0703      0.968 0.000 0.024 0.976 0.000 0.000
#> SRR944342     3  0.0703      0.968 0.000 0.024 0.976 0.000 0.000
#> SRR944343     3  0.0703      0.968 0.000 0.024 0.976 0.000 0.000
#> SRR944344     3  0.0703      0.968 0.000 0.024 0.976 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
#> SRR944282     1  0.5178   -0.44378 0.488 0.000 0.000 0.000 0.424 0.088
#> SRR944283     5  0.4689    0.48786 0.440 0.000 0.000 0.000 0.516 0.044
#> SRR944284     5  0.4271    0.67351 0.244 0.000 0.000 0.000 0.696 0.060
#> SRR944285     5  0.5240    0.59850 0.276 0.000 0.000 0.000 0.588 0.136
#> SRR944288     5  0.5702    0.54064 0.196 0.000 0.000 0.000 0.512 0.292
#> SRR944287     1  0.5184   -0.03874 0.584 0.000 0.000 0.000 0.120 0.296
#> SRR944289     4  0.1391    0.95044 0.000 0.000 0.000 0.944 0.016 0.040
#> SRR944290     1  0.4775   -0.08227 0.636 0.000 0.000 0.008 0.060 0.296
#> SRR944291     5  0.5176    0.62767 0.192 0.000 0.000 0.000 0.620 0.188
#> SRR944292     3  0.3642    0.79932 0.000 0.144 0.800 0.000 0.016 0.040
#> SRR944293     5  0.3947    0.64256 0.100 0.000 0.000 0.000 0.764 0.136
#> SRR944294     5  0.4729    0.62501 0.128 0.000 0.000 0.000 0.676 0.196
#> SRR944295     2  0.0000    1.00000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944296     2  0.0000    1.00000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944297     2  0.0000    1.00000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944298     2  0.0000    1.00000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944299     1  0.4080   -0.26068 0.536 0.000 0.000 0.000 0.008 0.456
#> SRR944300     1  0.3971   -0.25189 0.548 0.000 0.000 0.000 0.004 0.448
#> SRR944301     6  0.5887    0.37487 0.392 0.000 0.000 0.000 0.200 0.408
#> SRR944302     3  0.3425    0.79009 0.000 0.164 0.800 0.000 0.008 0.028
#> SRR944303     2  0.0000    1.00000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944304     6  0.4809    0.43471 0.328 0.000 0.000 0.000 0.072 0.600
#> SRR944305     1  0.4097   -0.33640 0.500 0.000 0.000 0.000 0.008 0.492
#> SRR944306     6  0.4471    0.23744 0.472 0.000 0.000 0.000 0.028 0.500
#> SRR944307     1  0.3684   -0.03197 0.664 0.000 0.000 0.000 0.004 0.332
#> SRR944308     6  0.5292    0.49199 0.372 0.000 0.000 0.000 0.108 0.520
#> SRR944309     1  0.4602   -0.30215 0.572 0.000 0.000 0.000 0.044 0.384
#> SRR944310     6  0.5167    0.50905 0.240 0.000 0.000 0.000 0.148 0.612
#> SRR944311     2  0.0000    1.00000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944312     1  0.3835   -0.00288 0.684 0.000 0.000 0.000 0.016 0.300
#> SRR944313     6  0.5836    0.45747 0.392 0.000 0.000 0.000 0.188 0.420
#> SRR944315     1  0.5392   -0.45070 0.444 0.000 0.000 0.000 0.444 0.112
#> SRR944314     1  0.4148    0.27230 0.744 0.000 0.000 0.000 0.148 0.108
#> SRR944316     1  0.5962   -0.25547 0.412 0.000 0.000 0.000 0.364 0.224
#> SRR944317     2  0.0000    1.00000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944318     2  0.0000    1.00000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944319     2  0.0000    1.00000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944320     2  0.0000    1.00000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944321     1  0.0000    0.42013 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944322     1  0.0000    0.42013 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944323     1  0.0000    0.42013 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944324     1  0.0000    0.42013 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944325     1  0.0000    0.42013 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944326     1  0.0000    0.42013 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944327     1  0.5645   -0.45778 0.456 0.000 0.000 0.000 0.392 0.152
#> SRR944328     5  0.5666    0.50723 0.388 0.000 0.004 0.000 0.472 0.136
#> SRR944329     4  0.0000    0.96817 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR944330     4  0.0000    0.96817 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR944331     4  0.0000    0.96817 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR944332     4  0.0000    0.96817 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR944334     4  0.0000    0.96817 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR944333     4  0.0000    0.96817 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR944335     4  0.2216    0.93347 0.052 0.000 0.000 0.908 0.024 0.016
#> SRR944336     4  0.2084    0.93887 0.044 0.000 0.000 0.916 0.024 0.016
#> SRR944337     4  0.2216    0.93347 0.052 0.000 0.000 0.908 0.024 0.016
#> SRR944338     3  0.0000    0.94824 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR944339     3  0.0000    0.94824 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR944340     3  0.0000    0.94824 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR944341     3  0.0000    0.94824 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR944342     3  0.0000    0.94824 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR944343     3  0.0000    0.94824 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR944344     3  0.0291    0.94487 0.000 0.000 0.992 0.000 0.004 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-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 12673 rows and 62 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'pam' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 5.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk MAD-pam-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.989       0.995        0.49504 0.505   0.505
#> 3 3 1.000           0.997       0.999        0.14398 0.930   0.861
#> 4 4 0.746           0.833       0.888        0.27143 0.816   0.588
#> 5 5 0.990           0.916       0.969        0.06971 0.943   0.797
#> 6 6 0.975           0.890       0.962        0.00456 0.997   0.986

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
#> SRR944282     1  0.0000      0.996 1.000 0.000
#> SRR944283     1  0.0000      0.996 1.000 0.000
#> SRR944284     1  0.0000      0.996 1.000 0.000
#> SRR944285     1  0.0000      0.996 1.000 0.000
#> SRR944288     1  0.0000      0.996 1.000 0.000
#> SRR944287     1  0.0000      0.996 1.000 0.000
#> SRR944289     2  0.0000      0.993 0.000 1.000
#> SRR944290     1  0.0000      0.996 1.000 0.000
#> SRR944291     1  0.0000      0.996 1.000 0.000
#> SRR944292     2  0.0000      0.993 0.000 1.000
#> SRR944293     1  0.1414      0.978 0.980 0.020
#> SRR944294     1  0.0000      0.996 1.000 0.000
#> SRR944295     2  0.0000      0.993 0.000 1.000
#> SRR944296     2  0.0000      0.993 0.000 1.000
#> SRR944297     2  0.0000      0.993 0.000 1.000
#> SRR944298     2  0.0000      0.993 0.000 1.000
#> SRR944299     1  0.0000      0.996 1.000 0.000
#> SRR944300     1  0.0000      0.996 1.000 0.000
#> SRR944301     1  0.0000      0.996 1.000 0.000
#> SRR944302     2  0.0000      0.993 0.000 1.000
#> SRR944303     2  0.0000      0.993 0.000 1.000
#> SRR944304     1  0.0938      0.986 0.988 0.012
#> SRR944305     1  0.0000      0.996 1.000 0.000
#> SRR944306     1  0.0000      0.996 1.000 0.000
#> SRR944307     1  0.0000      0.996 1.000 0.000
#> SRR944308     1  0.0000      0.996 1.000 0.000
#> SRR944309     1  0.0000      0.996 1.000 0.000
#> SRR944310     1  0.0000      0.996 1.000 0.000
#> SRR944311     2  0.0000      0.993 0.000 1.000
#> SRR944312     1  0.0000      0.996 1.000 0.000
#> SRR944313     1  0.0000      0.996 1.000 0.000
#> SRR944315     1  0.0000      0.996 1.000 0.000
#> SRR944314     1  0.0000      0.996 1.000 0.000
#> SRR944316     1  0.0000      0.996 1.000 0.000
#> SRR944317     2  0.0000      0.993 0.000 1.000
#> SRR944318     2  0.0000      0.993 0.000 1.000
#> SRR944319     2  0.0000      0.993 0.000 1.000
#> SRR944320     2  0.0000      0.993 0.000 1.000
#> SRR944321     1  0.0000      0.996 1.000 0.000
#> SRR944322     1  0.0000      0.996 1.000 0.000
#> SRR944323     1  0.0000      0.996 1.000 0.000
#> SRR944324     1  0.0000      0.996 1.000 0.000
#> SRR944325     1  0.0000      0.996 1.000 0.000
#> SRR944326     1  0.0000      0.996 1.000 0.000
#> SRR944327     1  0.0000      0.996 1.000 0.000
#> SRR944328     1  0.0000      0.996 1.000 0.000
#> SRR944329     2  0.0000      0.993 0.000 1.000
#> SRR944330     2  0.0000      0.993 0.000 1.000
#> SRR944331     2  0.0000      0.993 0.000 1.000
#> SRR944332     2  0.0000      0.993 0.000 1.000
#> SRR944334     2  0.0000      0.993 0.000 1.000
#> SRR944333     2  0.0000      0.993 0.000 1.000
#> SRR944335     1  0.0000      0.996 1.000 0.000
#> SRR944336     1  0.4562      0.894 0.904 0.096
#> SRR944337     1  0.0000      0.996 1.000 0.000
#> SRR944338     2  0.0000      0.993 0.000 1.000
#> SRR944339     2  0.6712      0.785 0.176 0.824
#> SRR944340     2  0.0000      0.993 0.000 1.000
#> SRR944341     2  0.0000      0.993 0.000 1.000
#> SRR944342     2  0.0000      0.993 0.000 1.000
#> SRR944343     2  0.0000      0.993 0.000 1.000
#> SRR944344     2  0.0000      0.993 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
#> SRR944282     1  0.0000      0.998 1.000 0.000  0
#> SRR944283     1  0.0000      0.998 1.000 0.000  0
#> SRR944284     1  0.0000      0.998 1.000 0.000  0
#> SRR944285     1  0.0000      0.998 1.000 0.000  0
#> SRR944288     1  0.0000      0.998 1.000 0.000  0
#> SRR944287     1  0.0000      0.998 1.000 0.000  0
#> SRR944289     2  0.0000      1.000 0.000 1.000  0
#> SRR944290     1  0.0000      0.998 1.000 0.000  0
#> SRR944291     1  0.0000      0.998 1.000 0.000  0
#> SRR944292     2  0.0000      1.000 0.000 1.000  0
#> SRR944293     1  0.0424      0.990 0.992 0.008  0
#> SRR944294     1  0.0000      0.998 1.000 0.000  0
#> SRR944295     2  0.0000      1.000 0.000 1.000  0
#> SRR944296     2  0.0000      1.000 0.000 1.000  0
#> SRR944297     2  0.0000      1.000 0.000 1.000  0
#> SRR944298     2  0.0000      1.000 0.000 1.000  0
#> SRR944299     1  0.0000      0.998 1.000 0.000  0
#> SRR944300     1  0.0000      0.998 1.000 0.000  0
#> SRR944301     1  0.0000      0.998 1.000 0.000  0
#> SRR944302     2  0.0000      1.000 0.000 1.000  0
#> SRR944303     2  0.0000      1.000 0.000 1.000  0
#> SRR944304     1  0.0237      0.994 0.996 0.004  0
#> SRR944305     1  0.0000      0.998 1.000 0.000  0
#> SRR944306     1  0.0000      0.998 1.000 0.000  0
#> SRR944307     1  0.0000      0.998 1.000 0.000  0
#> SRR944308     1  0.0000      0.998 1.000 0.000  0
#> SRR944309     1  0.0000      0.998 1.000 0.000  0
#> SRR944310     1  0.0000      0.998 1.000 0.000  0
#> SRR944311     2  0.0000      1.000 0.000 1.000  0
#> SRR944312     1  0.0000      0.998 1.000 0.000  0
#> SRR944313     1  0.0000      0.998 1.000 0.000  0
#> SRR944315     1  0.0000      0.998 1.000 0.000  0
#> SRR944314     1  0.0000      0.998 1.000 0.000  0
#> SRR944316     1  0.0000      0.998 1.000 0.000  0
#> SRR944317     2  0.0000      1.000 0.000 1.000  0
#> SRR944318     2  0.0000      1.000 0.000 1.000  0
#> SRR944319     2  0.0000      1.000 0.000 1.000  0
#> SRR944320     2  0.0000      1.000 0.000 1.000  0
#> SRR944321     1  0.0000      0.998 1.000 0.000  0
#> SRR944322     1  0.0000      0.998 1.000 0.000  0
#> SRR944323     1  0.0000      0.998 1.000 0.000  0
#> SRR944324     1  0.0000      0.998 1.000 0.000  0
#> SRR944325     1  0.0000      0.998 1.000 0.000  0
#> SRR944326     1  0.0000      0.998 1.000 0.000  0
#> SRR944327     1  0.0000      0.998 1.000 0.000  0
#> SRR944328     1  0.0000      0.998 1.000 0.000  0
#> SRR944329     2  0.0000      1.000 0.000 1.000  0
#> SRR944330     2  0.0000      1.000 0.000 1.000  0
#> SRR944331     2  0.0000      1.000 0.000 1.000  0
#> SRR944332     2  0.0000      1.000 0.000 1.000  0
#> SRR944334     2  0.0000      1.000 0.000 1.000  0
#> SRR944333     2  0.0000      1.000 0.000 1.000  0
#> SRR944335     1  0.0000      0.998 1.000 0.000  0
#> SRR944336     1  0.2066      0.930 0.940 0.060  0
#> SRR944337     1  0.0000      0.998 1.000 0.000  0
#> SRR944338     3  0.0000      1.000 0.000 0.000  1
#> SRR944339     3  0.0000      1.000 0.000 0.000  1
#> SRR944340     3  0.0000      1.000 0.000 0.000  1
#> SRR944341     3  0.0000      1.000 0.000 0.000  1
#> SRR944342     3  0.0000      1.000 0.000 0.000  1
#> SRR944343     3  0.0000      1.000 0.000 0.000  1
#> SRR944344     3  0.0000      1.000 0.000 0.000  1

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2 p3    p4
#> SRR944282     4  0.4193   0.993304 0.268 0.000  0 0.732
#> SRR944283     4  0.4454   0.944428 0.308 0.000  0 0.692
#> SRR944284     1  0.0000   0.762707 1.000 0.000  0 0.000
#> SRR944285     1  0.0469   0.751694 0.988 0.000  0 0.012
#> SRR944288     1  0.0000   0.762707 1.000 0.000  0 0.000
#> SRR944287     4  0.4193   0.993304 0.268 0.000  0 0.732
#> SRR944289     1  0.4193   0.742441 0.732 0.000  0 0.268
#> SRR944290     1  0.4193   0.742441 0.732 0.000  0 0.268
#> SRR944291     1  0.0000   0.762707 1.000 0.000  0 0.000
#> SRR944292     2  0.4193   0.840381 0.000 0.732  0 0.268
#> SRR944293     1  0.4072   0.748279 0.748 0.000  0 0.252
#> SRR944294     1  0.0000   0.762707 1.000 0.000  0 0.000
#> SRR944295     2  0.0000   0.837871 0.000 1.000  0 0.000
#> SRR944296     2  0.0000   0.837871 0.000 1.000  0 0.000
#> SRR944297     2  0.0000   0.837871 0.000 1.000  0 0.000
#> SRR944298     2  0.0000   0.837871 0.000 1.000  0 0.000
#> SRR944299     1  0.4193   0.742441 0.732 0.000  0 0.268
#> SRR944300     1  0.3024   0.766547 0.852 0.000  0 0.148
#> SRR944301     1  0.4103   0.310187 0.744 0.000  0 0.256
#> SRR944302     2  0.4193   0.840381 0.000 0.732  0 0.268
#> SRR944303     2  0.0000   0.837871 0.000 1.000  0 0.000
#> SRR944304     1  0.4193   0.742441 0.732 0.000  0 0.268
#> SRR944305     1  0.0000   0.762707 1.000 0.000  0 0.000
#> SRR944306     1  0.4193   0.742441 0.732 0.000  0 0.268
#> SRR944307     1  0.0000   0.762707 1.000 0.000  0 0.000
#> SRR944308     1  0.0000   0.762707 1.000 0.000  0 0.000
#> SRR944309     4  0.4193   0.993304 0.268 0.000  0 0.732
#> SRR944310     1  0.0000   0.762707 1.000 0.000  0 0.000
#> SRR944311     2  0.0000   0.837871 0.000 1.000  0 0.000
#> SRR944312     4  0.4356   0.966830 0.292 0.000  0 0.708
#> SRR944313     1  0.4103   0.311566 0.744 0.000  0 0.256
#> SRR944315     1  0.4585  -0.000513 0.668 0.000  0 0.332
#> SRR944314     4  0.4193   0.993304 0.268 0.000  0 0.732
#> SRR944316     1  0.0000   0.762707 1.000 0.000  0 0.000
#> SRR944317     2  0.0000   0.837871 0.000 1.000  0 0.000
#> SRR944318     2  0.0000   0.837871 0.000 1.000  0 0.000
#> SRR944319     2  0.4193   0.840381 0.000 0.732  0 0.268
#> SRR944320     2  0.0000   0.837871 0.000 1.000  0 0.000
#> SRR944321     4  0.4193   0.993304 0.268 0.000  0 0.732
#> SRR944322     4  0.4193   0.993304 0.268 0.000  0 0.732
#> SRR944323     4  0.4193   0.993304 0.268 0.000  0 0.732
#> SRR944324     4  0.4193   0.993304 0.268 0.000  0 0.732
#> SRR944325     4  0.4193   0.993304 0.268 0.000  0 0.732
#> SRR944326     4  0.4193   0.993304 0.268 0.000  0 0.732
#> SRR944327     4  0.4193   0.993304 0.268 0.000  0 0.732
#> SRR944328     4  0.4193   0.993304 0.268 0.000  0 0.732
#> SRR944329     2  0.4193   0.840381 0.000 0.732  0 0.268
#> SRR944330     2  0.4193   0.840381 0.000 0.732  0 0.268
#> SRR944331     2  0.4193   0.840381 0.000 0.732  0 0.268
#> SRR944332     2  0.4193   0.840381 0.000 0.732  0 0.268
#> SRR944334     2  0.4193   0.840381 0.000 0.732  0 0.268
#> SRR944333     2  0.4193   0.840381 0.000 0.732  0 0.268
#> SRR944335     1  0.4193   0.742441 0.732 0.000  0 0.268
#> SRR944336     1  0.4193   0.742441 0.732 0.000  0 0.268
#> SRR944337     1  0.4193   0.742441 0.732 0.000  0 0.268
#> SRR944338     3  0.0000   1.000000 0.000 0.000  1 0.000
#> SRR944339     3  0.0000   1.000000 0.000 0.000  1 0.000
#> SRR944340     3  0.0000   1.000000 0.000 0.000  1 0.000
#> SRR944341     3  0.0000   1.000000 0.000 0.000  1 0.000
#> SRR944342     3  0.0000   1.000000 0.000 0.000  1 0.000
#> SRR944343     3  0.0000   1.000000 0.000 0.000  1 0.000
#> SRR944344     3  0.0000   1.000000 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
#> SRR944282     5  0.0000      0.952 0.000 0.000  0 0.000 1.000
#> SRR944283     5  0.1043      0.912 0.040 0.000  0 0.000 0.960
#> SRR944284     1  0.0000      0.957 1.000 0.000  0 0.000 0.000
#> SRR944285     1  0.0404      0.946 0.988 0.000  0 0.000 0.012
#> SRR944288     1  0.0000      0.957 1.000 0.000  0 0.000 0.000
#> SRR944287     5  0.0000      0.952 0.000 0.000  0 0.000 1.000
#> SRR944289     1  0.0000      0.957 1.000 0.000  0 0.000 0.000
#> SRR944290     1  0.0000      0.957 1.000 0.000  0 0.000 0.000
#> SRR944291     1  0.0000      0.957 1.000 0.000  0 0.000 0.000
#> SRR944292     4  0.0000      0.946 0.000 0.000  0 1.000 0.000
#> SRR944293     1  0.0000      0.957 1.000 0.000  0 0.000 0.000
#> SRR944294     1  0.0000      0.957 1.000 0.000  0 0.000 0.000
#> SRR944295     2  0.0000      0.984 0.000 1.000  0 0.000 0.000
#> SRR944296     2  0.0000      0.984 0.000 1.000  0 0.000 0.000
#> SRR944297     2  0.0000      0.984 0.000 1.000  0 0.000 0.000
#> SRR944298     2  0.0000      0.984 0.000 1.000  0 0.000 0.000
#> SRR944299     1  0.0000      0.957 1.000 0.000  0 0.000 0.000
#> SRR944300     1  0.0000      0.957 1.000 0.000  0 0.000 0.000
#> SRR944301     1  0.4291      0.115 0.536 0.000  0 0.000 0.464
#> SRR944302     4  0.0000      0.946 0.000 0.000  0 1.000 0.000
#> SRR944303     2  0.1478      0.926 0.000 0.936  0 0.064 0.000
#> SRR944304     1  0.0000      0.957 1.000 0.000  0 0.000 0.000
#> SRR944305     1  0.0000      0.957 1.000 0.000  0 0.000 0.000
#> SRR944306     1  0.0000      0.957 1.000 0.000  0 0.000 0.000
#> SRR944307     1  0.0000      0.957 1.000 0.000  0 0.000 0.000
#> SRR944308     1  0.0000      0.957 1.000 0.000  0 0.000 0.000
#> SRR944309     5  0.0000      0.952 0.000 0.000  0 0.000 1.000
#> SRR944310     1  0.0000      0.957 1.000 0.000  0 0.000 0.000
#> SRR944311     2  0.0162      0.982 0.000 0.996  0 0.004 0.000
#> SRR944312     5  0.0703      0.931 0.024 0.000  0 0.000 0.976
#> SRR944313     1  0.3876      0.531 0.684 0.000  0 0.000 0.316
#> SRR944315     5  0.4273      0.154 0.448 0.000  0 0.000 0.552
#> SRR944314     5  0.0000      0.952 0.000 0.000  0 0.000 1.000
#> SRR944316     1  0.0000      0.957 1.000 0.000  0 0.000 0.000
#> SRR944317     4  0.0404      0.938 0.000 0.012  0 0.988 0.000
#> SRR944318     4  0.3366      0.711 0.000 0.232  0 0.768 0.000
#> SRR944319     4  0.0000      0.946 0.000 0.000  0 1.000 0.000
#> SRR944320     4  0.3949      0.552 0.000 0.332  0 0.668 0.000
#> SRR944321     5  0.0000      0.952 0.000 0.000  0 0.000 1.000
#> SRR944322     5  0.0000      0.952 0.000 0.000  0 0.000 1.000
#> SRR944323     5  0.0000      0.952 0.000 0.000  0 0.000 1.000
#> SRR944324     5  0.0000      0.952 0.000 0.000  0 0.000 1.000
#> SRR944325     5  0.0000      0.952 0.000 0.000  0 0.000 1.000
#> SRR944326     5  0.0000      0.952 0.000 0.000  0 0.000 1.000
#> SRR944327     5  0.0000      0.952 0.000 0.000  0 0.000 1.000
#> SRR944328     5  0.0000      0.952 0.000 0.000  0 0.000 1.000
#> SRR944329     4  0.0000      0.946 0.000 0.000  0 1.000 0.000
#> SRR944330     4  0.0000      0.946 0.000 0.000  0 1.000 0.000
#> SRR944331     4  0.0000      0.946 0.000 0.000  0 1.000 0.000
#> SRR944332     4  0.0000      0.946 0.000 0.000  0 1.000 0.000
#> SRR944334     4  0.0000      0.946 0.000 0.000  0 1.000 0.000
#> SRR944333     4  0.0000      0.946 0.000 0.000  0 1.000 0.000
#> SRR944335     1  0.0000      0.957 1.000 0.000  0 0.000 0.000
#> SRR944336     1  0.0000      0.957 1.000 0.000  0 0.000 0.000
#> SRR944337     1  0.0000      0.957 1.000 0.000  0 0.000 0.000
#> SRR944338     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR944339     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR944340     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR944341     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR944342     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR944343     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR944344     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
#> SRR944282     6  0.0000      0.946 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR944283     6  0.0937      0.899 0.040 0.000 0.000 0.000 0.000 0.960
#> SRR944284     1  0.0000      0.953 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944285     1  0.0363      0.941 0.988 0.000 0.000 0.000 0.000 0.012
#> SRR944288     1  0.0000      0.953 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944287     6  0.0000      0.946 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR944289     1  0.0000      0.953 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944290     1  0.0000      0.953 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944291     1  0.0000      0.953 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944292     4  0.2730      0.783 0.000 0.000 0.000 0.808 0.192 0.000
#> SRR944293     1  0.0000      0.953 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944294     1  0.0000      0.953 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944295     2  0.0000      0.979 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944296     2  0.0000      0.979 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944297     2  0.0000      0.979 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944298     2  0.0000      0.979 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944299     1  0.0000      0.953 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944300     1  0.0000      0.953 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944301     1  0.3854      0.115 0.536 0.000 0.000 0.000 0.000 0.464
#> SRR944302     4  0.0000      0.923 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR944303     2  0.1327      0.901 0.000 0.936 0.000 0.064 0.000 0.000
#> SRR944304     1  0.0000      0.953 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944305     1  0.0000      0.953 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944306     1  0.0000      0.953 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944307     1  0.0000      0.953 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944308     1  0.0000      0.953 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944309     6  0.0000      0.946 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR944310     1  0.0000      0.953 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944311     2  0.0146      0.976 0.000 0.996 0.000 0.004 0.000 0.000
#> SRR944312     6  0.0632      0.920 0.024 0.000 0.000 0.000 0.000 0.976
#> SRR944313     1  0.3482      0.506 0.684 0.000 0.000 0.000 0.000 0.316
#> SRR944315     6  0.3838      0.154 0.448 0.000 0.000 0.000 0.000 0.552
#> SRR944314     6  0.0000      0.946 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR944316     1  0.0000      0.953 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944317     4  0.0363      0.917 0.000 0.012 0.000 0.988 0.000 0.000
#> SRR944318     4  0.3023      0.713 0.000 0.232 0.000 0.768 0.000 0.000
#> SRR944319     4  0.0000      0.923 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR944320     4  0.3547      0.571 0.000 0.332 0.000 0.668 0.000 0.000
#> SRR944321     6  0.0000      0.946 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR944322     6  0.0000      0.946 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR944323     6  0.0000      0.946 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR944324     6  0.0000      0.946 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR944325     6  0.0000      0.946 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR944326     6  0.0000      0.946 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR944327     6  0.0000      0.946 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR944328     6  0.0000      0.946 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR944329     4  0.0000      0.923 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR944330     4  0.0000      0.923 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR944331     4  0.0000      0.923 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR944332     4  0.0000      0.923 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR944334     4  0.0000      0.923 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR944333     4  0.0000      0.923 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR944335     1  0.0000      0.953 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944336     1  0.0000      0.953 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944337     1  0.0000      0.953 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944338     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR944339     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR944340     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR944341     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR944342     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR944343     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR944344     5  0.2730      0.000 0.000 0.000 0.192 0.000 0.808 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-pam-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-pam-collect-classes

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


MAD:mclust

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

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

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

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

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

collect_plots(res)

plot of chunk MAD-mclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.737           0.809       0.907         0.3280 0.611   0.611
#> 3 3 0.763           0.881       0.920         0.7018 0.742   0.605
#> 4 4 0.806           0.894       0.944         0.2203 0.769   0.532
#> 5 5 0.742           0.820       0.883         0.0974 0.840   0.555
#> 6 6 0.699           0.708       0.788         0.0406 0.828   0.512

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

suggest_best_k(res)
#> [1] 4

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> SRR944282     1   0.000     0.9556 1.000 0.000
#> SRR944283     1   0.000     0.9556 1.000 0.000
#> SRR944284     1   0.000     0.9556 1.000 0.000
#> SRR944285     1   0.000     0.9556 1.000 0.000
#> SRR944288     1   0.000     0.9556 1.000 0.000
#> SRR944287     1   0.000     0.9556 1.000 0.000
#> SRR944289     1   0.000     0.9556 1.000 0.000
#> SRR944290     1   0.000     0.9556 1.000 0.000
#> SRR944291     1   0.000     0.9556 1.000 0.000
#> SRR944292     1   0.990     0.0504 0.560 0.440
#> SRR944293     1   0.000     0.9556 1.000 0.000
#> SRR944294     1   0.000     0.9556 1.000 0.000
#> SRR944295     2   0.999     0.5470 0.484 0.516
#> SRR944296     2   0.999     0.5470 0.484 0.516
#> SRR944297     2   0.999     0.5470 0.484 0.516
#> SRR944298     2   0.999     0.5470 0.484 0.516
#> SRR944299     1   0.000     0.9556 1.000 0.000
#> SRR944300     1   0.000     0.9556 1.000 0.000
#> SRR944301     1   0.000     0.9556 1.000 0.000
#> SRR944302     1   0.999    -0.0783 0.520 0.480
#> SRR944303     2   0.999     0.5470 0.484 0.516
#> SRR944304     1   0.000     0.9556 1.000 0.000
#> SRR944305     1   0.000     0.9556 1.000 0.000
#> SRR944306     1   0.000     0.9556 1.000 0.000
#> SRR944307     1   0.000     0.9556 1.000 0.000
#> SRR944308     1   0.000     0.9556 1.000 0.000
#> SRR944309     1   0.000     0.9556 1.000 0.000
#> SRR944310     1   0.000     0.9556 1.000 0.000
#> SRR944311     2   0.999     0.5470 0.484 0.516
#> SRR944312     1   0.000     0.9556 1.000 0.000
#> SRR944313     1   0.000     0.9556 1.000 0.000
#> SRR944315     1   0.000     0.9556 1.000 0.000
#> SRR944314     1   0.000     0.9556 1.000 0.000
#> SRR944316     1   0.000     0.9556 1.000 0.000
#> SRR944317     2   0.999     0.5470 0.484 0.516
#> SRR944318     2   0.999     0.5470 0.484 0.516
#> SRR944319     1   1.000    -0.5327 0.504 0.496
#> SRR944320     2   0.999     0.5470 0.484 0.516
#> SRR944321     1   0.000     0.9556 1.000 0.000
#> SRR944322     1   0.000     0.9556 1.000 0.000
#> SRR944323     1   0.000     0.9556 1.000 0.000
#> SRR944324     1   0.000     0.9556 1.000 0.000
#> SRR944325     1   0.000     0.9556 1.000 0.000
#> SRR944326     1   0.000     0.9556 1.000 0.000
#> SRR944327     1   0.000     0.9556 1.000 0.000
#> SRR944328     1   0.000     0.9556 1.000 0.000
#> SRR944329     1   0.000     0.9556 1.000 0.000
#> SRR944330     1   0.000     0.9556 1.000 0.000
#> SRR944331     1   0.000     0.9556 1.000 0.000
#> SRR944332     1   0.000     0.9556 1.000 0.000
#> SRR944334     1   0.000     0.9556 1.000 0.000
#> SRR944333     1   0.000     0.9556 1.000 0.000
#> SRR944335     1   0.000     0.9556 1.000 0.000
#> SRR944336     1   0.000     0.9556 1.000 0.000
#> SRR944337     1   0.000     0.9556 1.000 0.000
#> SRR944338     2   0.000     0.6712 0.000 1.000
#> SRR944339     2   0.000     0.6712 0.000 1.000
#> SRR944340     2   0.000     0.6712 0.000 1.000
#> SRR944341     2   0.000     0.6712 0.000 1.000
#> SRR944342     2   0.000     0.6712 0.000 1.000
#> SRR944343     2   0.000     0.6712 0.000 1.000
#> SRR944344     2   0.000     0.6712 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
#> SRR944282     1  0.0000      0.958 1.000 0.000 0.000
#> SRR944283     1  0.0000      0.958 1.000 0.000 0.000
#> SRR944284     1  0.0000      0.958 1.000 0.000 0.000
#> SRR944285     1  0.0237      0.958 0.996 0.000 0.004
#> SRR944288     1  0.0000      0.958 1.000 0.000 0.000
#> SRR944287     1  0.2261      0.944 0.932 0.000 0.068
#> SRR944289     1  0.2584      0.930 0.928 0.008 0.064
#> SRR944290     1  0.1289      0.950 0.968 0.000 0.032
#> SRR944291     1  0.0000      0.958 1.000 0.000 0.000
#> SRR944292     3  0.4551      0.749 0.140 0.020 0.840
#> SRR944293     1  0.0000      0.958 1.000 0.000 0.000
#> SRR944294     1  0.0000      0.958 1.000 0.000 0.000
#> SRR944295     2  0.0000      0.796 0.000 1.000 0.000
#> SRR944296     2  0.0000      0.796 0.000 1.000 0.000
#> SRR944297     2  0.0000      0.796 0.000 1.000 0.000
#> SRR944298     2  0.0000      0.796 0.000 1.000 0.000
#> SRR944299     1  0.2165      0.947 0.936 0.000 0.064
#> SRR944300     1  0.2448      0.952 0.924 0.000 0.076
#> SRR944301     1  0.0000      0.958 1.000 0.000 0.000
#> SRR944302     3  0.4551      0.749 0.140 0.020 0.840
#> SRR944303     2  0.0000      0.796 0.000 1.000 0.000
#> SRR944304     1  0.2625      0.950 0.916 0.000 0.084
#> SRR944305     1  0.2165      0.949 0.936 0.000 0.064
#> SRR944306     1  0.2537      0.952 0.920 0.000 0.080
#> SRR944307     1  0.2796      0.948 0.908 0.000 0.092
#> SRR944308     1  0.2261      0.944 0.932 0.000 0.068
#> SRR944309     1  0.2356      0.944 0.928 0.000 0.072
#> SRR944310     1  0.2261      0.944 0.932 0.000 0.068
#> SRR944311     2  0.0000      0.796 0.000 1.000 0.000
#> SRR944312     1  0.1289      0.959 0.968 0.000 0.032
#> SRR944313     1  0.0000      0.958 1.000 0.000 0.000
#> SRR944315     1  0.0000      0.958 1.000 0.000 0.000
#> SRR944314     1  0.2261      0.944 0.932 0.000 0.068
#> SRR944316     1  0.1529      0.954 0.960 0.000 0.040
#> SRR944317     2  0.0000      0.796 0.000 1.000 0.000
#> SRR944318     2  0.0000      0.796 0.000 1.000 0.000
#> SRR944319     2  0.0000      0.796 0.000 1.000 0.000
#> SRR944320     2  0.0000      0.796 0.000 1.000 0.000
#> SRR944321     1  0.2959      0.943 0.900 0.000 0.100
#> SRR944322     1  0.3116      0.941 0.892 0.000 0.108
#> SRR944323     1  0.3116      0.941 0.892 0.000 0.108
#> SRR944324     1  0.2878      0.943 0.904 0.000 0.096
#> SRR944325     1  0.2878      0.943 0.904 0.000 0.096
#> SRR944326     1  0.2796      0.944 0.908 0.000 0.092
#> SRR944327     1  0.0000      0.958 1.000 0.000 0.000
#> SRR944328     1  0.0000      0.958 1.000 0.000 0.000
#> SRR944329     2  0.6632      0.693 0.204 0.732 0.064
#> SRR944330     2  0.6632      0.693 0.204 0.732 0.064
#> SRR944331     2  0.7613      0.577 0.316 0.620 0.064
#> SRR944332     2  0.7332      0.623 0.276 0.660 0.064
#> SRR944334     2  0.8063      0.285 0.448 0.488 0.064
#> SRR944333     2  0.6632      0.693 0.204 0.732 0.064
#> SRR944335     1  0.2680      0.928 0.924 0.008 0.068
#> SRR944336     1  0.2680      0.928 0.924 0.008 0.068
#> SRR944337     1  0.2680      0.928 0.924 0.008 0.068
#> SRR944338     3  0.3551      0.929 0.000 0.132 0.868
#> SRR944339     3  0.3551      0.929 0.000 0.132 0.868
#> SRR944340     3  0.3551      0.929 0.000 0.132 0.868
#> SRR944341     3  0.3551      0.929 0.000 0.132 0.868
#> SRR944342     3  0.3551      0.929 0.000 0.132 0.868
#> SRR944343     3  0.3551      0.929 0.000 0.132 0.868
#> SRR944344     3  0.3551      0.929 0.000 0.132 0.868

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> SRR944282     1  0.0336      0.925 0.992 0.000 0.000 0.008
#> SRR944283     1  0.0469      0.925 0.988 0.000 0.000 0.012
#> SRR944284     1  0.0000      0.924 1.000 0.000 0.000 0.000
#> SRR944285     1  0.0469      0.925 0.988 0.000 0.000 0.012
#> SRR944288     1  0.0000      0.924 1.000 0.000 0.000 0.000
#> SRR944287     1  0.1389      0.911 0.952 0.000 0.000 0.048
#> SRR944289     4  0.0921      0.878 0.028 0.000 0.000 0.972
#> SRR944290     1  0.4304      0.623 0.716 0.000 0.000 0.284
#> SRR944291     1  0.0000      0.924 1.000 0.000 0.000 0.000
#> SRR944292     1  0.4261      0.815 0.820 0.068 0.112 0.000
#> SRR944293     1  0.0000      0.924 1.000 0.000 0.000 0.000
#> SRR944294     1  0.0188      0.924 0.996 0.000 0.000 0.004
#> SRR944295     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR944296     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR944297     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR944298     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR944299     4  0.2149      0.843 0.088 0.000 0.000 0.912
#> SRR944300     4  0.2760      0.811 0.128 0.000 0.000 0.872
#> SRR944301     1  0.0336      0.925 0.992 0.000 0.000 0.008
#> SRR944302     1  0.4419      0.809 0.812 0.084 0.104 0.000
#> SRR944303     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR944304     1  0.3486      0.796 0.812 0.000 0.000 0.188
#> SRR944305     4  0.4776      0.434 0.376 0.000 0.000 0.624
#> SRR944306     4  0.4985      0.141 0.468 0.000 0.000 0.532
#> SRR944307     4  0.2281      0.838 0.096 0.000 0.000 0.904
#> SRR944308     1  0.1474      0.909 0.948 0.000 0.000 0.052
#> SRR944309     1  0.1302      0.917 0.956 0.000 0.000 0.044
#> SRR944310     1  0.1389      0.911 0.952 0.000 0.000 0.048
#> SRR944311     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR944312     1  0.2589      0.890 0.884 0.000 0.000 0.116
#> SRR944313     1  0.0469      0.925 0.988 0.000 0.000 0.012
#> SRR944315     1  0.0000      0.924 1.000 0.000 0.000 0.000
#> SRR944314     1  0.1940      0.907 0.924 0.000 0.000 0.076
#> SRR944316     1  0.0921      0.919 0.972 0.000 0.000 0.028
#> SRR944317     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR944318     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR944319     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR944320     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR944321     1  0.2868      0.876 0.864 0.000 0.000 0.136
#> SRR944322     1  0.2868      0.876 0.864 0.000 0.000 0.136
#> SRR944323     1  0.2868      0.876 0.864 0.000 0.000 0.136
#> SRR944324     1  0.2868      0.876 0.864 0.000 0.000 0.136
#> SRR944325     1  0.2868      0.876 0.864 0.000 0.000 0.136
#> SRR944326     1  0.2868      0.876 0.864 0.000 0.000 0.136
#> SRR944327     1  0.0804      0.924 0.980 0.012 0.000 0.008
#> SRR944328     1  0.0804      0.924 0.980 0.012 0.000 0.008
#> SRR944329     4  0.0336      0.880 0.000 0.008 0.000 0.992
#> SRR944330     4  0.0336      0.880 0.000 0.008 0.000 0.992
#> SRR944331     4  0.0000      0.882 0.000 0.000 0.000 1.000
#> SRR944332     4  0.0188      0.881 0.000 0.004 0.000 0.996
#> SRR944334     4  0.0000      0.882 0.000 0.000 0.000 1.000
#> SRR944333     4  0.0188      0.881 0.000 0.004 0.000 0.996
#> SRR944335     4  0.0336      0.884 0.008 0.000 0.000 0.992
#> SRR944336     4  0.0336      0.884 0.008 0.000 0.000 0.992
#> SRR944337     4  0.0336      0.884 0.008 0.000 0.000 0.992
#> SRR944338     3  0.0000      0.991 0.000 0.000 1.000 0.000
#> SRR944339     3  0.0000      0.991 0.000 0.000 1.000 0.000
#> SRR944340     3  0.0000      0.991 0.000 0.000 1.000 0.000
#> SRR944341     3  0.0000      0.991 0.000 0.000 1.000 0.000
#> SRR944342     3  0.0000      0.991 0.000 0.000 1.000 0.000
#> SRR944343     3  0.0000      0.991 0.000 0.000 1.000 0.000
#> SRR944344     3  0.1389      0.947 0.000 0.048 0.952 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
#> SRR944282     1  0.1043      0.863 0.960 0.000 0.000 0.000 0.040
#> SRR944283     1  0.1544      0.861 0.932 0.000 0.000 0.000 0.068
#> SRR944284     1  0.0290      0.857 0.992 0.000 0.000 0.000 0.008
#> SRR944285     1  0.1544      0.857 0.932 0.000 0.000 0.000 0.068
#> SRR944288     1  0.0290      0.857 0.992 0.000 0.000 0.000 0.008
#> SRR944287     1  0.2280      0.844 0.880 0.000 0.000 0.000 0.120
#> SRR944289     5  0.3075      0.670 0.048 0.000 0.000 0.092 0.860
#> SRR944290     5  0.3752      0.667 0.292 0.000 0.000 0.000 0.708
#> SRR944291     1  0.0404      0.859 0.988 0.000 0.000 0.000 0.012
#> SRR944292     1  0.4959      0.706 0.772 0.124 0.016 0.036 0.052
#> SRR944293     1  0.0290      0.859 0.992 0.000 0.000 0.000 0.008
#> SRR944294     1  0.1043      0.863 0.960 0.000 0.000 0.000 0.040
#> SRR944295     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000
#> SRR944296     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000
#> SRR944297     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000
#> SRR944298     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000
#> SRR944299     5  0.3536      0.680 0.084 0.000 0.000 0.084 0.832
#> SRR944300     5  0.3644      0.690 0.096 0.000 0.000 0.080 0.824
#> SRR944301     1  0.1608      0.859 0.928 0.000 0.000 0.000 0.072
#> SRR944302     1  0.4959      0.706 0.772 0.124 0.016 0.036 0.052
#> SRR944303     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000
#> SRR944304     1  0.4481      0.267 0.576 0.000 0.000 0.008 0.416
#> SRR944305     5  0.3970      0.714 0.224 0.000 0.000 0.024 0.752
#> SRR944306     5  0.3779      0.717 0.200 0.000 0.000 0.024 0.776
#> SRR944307     5  0.3234      0.679 0.064 0.000 0.000 0.084 0.852
#> SRR944308     1  0.2516      0.832 0.860 0.000 0.000 0.000 0.140
#> SRR944309     1  0.4192      0.212 0.596 0.000 0.000 0.000 0.404
#> SRR944310     1  0.2074      0.847 0.896 0.000 0.000 0.000 0.104
#> SRR944311     2  0.0404      0.990 0.000 0.988 0.000 0.012 0.000
#> SRR944312     5  0.3895      0.651 0.320 0.000 0.000 0.000 0.680
#> SRR944313     1  0.1544      0.859 0.932 0.000 0.000 0.000 0.068
#> SRR944315     1  0.0290      0.857 0.992 0.000 0.000 0.000 0.008
#> SRR944314     1  0.3707      0.603 0.716 0.000 0.000 0.000 0.284
#> SRR944316     1  0.1908      0.852 0.908 0.000 0.000 0.000 0.092
#> SRR944317     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000
#> SRR944318     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000
#> SRR944319     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000
#> SRR944320     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000
#> SRR944321     5  0.3913      0.643 0.324 0.000 0.000 0.000 0.676
#> SRR944322     5  0.3913      0.643 0.324 0.000 0.000 0.000 0.676
#> SRR944323     5  0.3913      0.643 0.324 0.000 0.000 0.000 0.676
#> SRR944324     5  0.3913      0.643 0.324 0.000 0.000 0.000 0.676
#> SRR944325     5  0.3949      0.630 0.332 0.000 0.000 0.000 0.668
#> SRR944326     5  0.4030      0.591 0.352 0.000 0.000 0.000 0.648
#> SRR944327     1  0.3129      0.796 0.872 0.076 0.000 0.020 0.032
#> SRR944328     1  0.3106      0.791 0.872 0.080 0.000 0.020 0.028
#> SRR944329     4  0.0963      0.998 0.000 0.000 0.000 0.964 0.036
#> SRR944330     4  0.0963      0.998 0.000 0.000 0.000 0.964 0.036
#> SRR944331     4  0.0963      0.998 0.000 0.000 0.000 0.964 0.036
#> SRR944332     4  0.0963      0.998 0.000 0.000 0.000 0.964 0.036
#> SRR944334     4  0.1121      0.992 0.000 0.000 0.000 0.956 0.044
#> SRR944333     4  0.0963      0.998 0.000 0.000 0.000 0.964 0.036
#> SRR944335     5  0.3267      0.654 0.044 0.000 0.000 0.112 0.844
#> SRR944336     5  0.3267      0.654 0.044 0.000 0.000 0.112 0.844
#> SRR944337     5  0.3216      0.658 0.044 0.000 0.000 0.108 0.848
#> SRR944338     3  0.0000      0.979 0.000 0.000 1.000 0.000 0.000
#> SRR944339     3  0.0000      0.979 0.000 0.000 1.000 0.000 0.000
#> SRR944340     3  0.0000      0.979 0.000 0.000 1.000 0.000 0.000
#> SRR944341     3  0.0000      0.979 0.000 0.000 1.000 0.000 0.000
#> SRR944342     3  0.0000      0.979 0.000 0.000 1.000 0.000 0.000
#> SRR944343     3  0.0000      0.979 0.000 0.000 1.000 0.000 0.000
#> SRR944344     3  0.2608      0.869 0.000 0.088 0.888 0.004 0.020

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR944282     1  0.3672      0.531 0.776 0.000 0.000 0.000 0.056 0.168
#> SRR944283     1  0.3456      0.540 0.788 0.000 0.000 0.000 0.040 0.172
#> SRR944284     1  0.5365      0.292 0.580 0.000 0.000 0.000 0.256 0.164
#> SRR944285     1  0.3046      0.548 0.800 0.000 0.000 0.000 0.012 0.188
#> SRR944288     1  0.5327      0.308 0.588 0.000 0.000 0.000 0.248 0.164
#> SRR944287     1  0.2300      0.555 0.856 0.000 0.000 0.000 0.000 0.144
#> SRR944289     1  0.5919      0.399 0.588 0.000 0.000 0.040 0.152 0.220
#> SRR944290     1  0.3855      0.473 0.704 0.000 0.000 0.000 0.024 0.272
#> SRR944291     1  0.5202      0.352 0.612 0.000 0.000 0.000 0.224 0.164
#> SRR944292     5  0.2886      1.000 0.144 0.004 0.000 0.000 0.836 0.016
#> SRR944293     1  0.5267      0.331 0.600 0.000 0.000 0.000 0.236 0.164
#> SRR944294     1  0.5005      0.399 0.644 0.000 0.000 0.000 0.192 0.164
#> SRR944295     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944296     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944297     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944298     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944299     1  0.5757      0.410 0.608 0.000 0.000 0.036 0.148 0.208
#> SRR944300     1  0.5650      0.422 0.620 0.000 0.000 0.032 0.152 0.196
#> SRR944301     1  0.3221      0.545 0.792 0.000 0.000 0.000 0.020 0.188
#> SRR944302     5  0.2886      1.000 0.144 0.004 0.000 0.000 0.836 0.016
#> SRR944303     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944304     1  0.3394      0.525 0.776 0.000 0.000 0.000 0.024 0.200
#> SRR944305     1  0.4711      0.418 0.640 0.000 0.000 0.000 0.080 0.280
#> SRR944306     1  0.4215      0.475 0.700 0.000 0.000 0.000 0.056 0.244
#> SRR944307     1  0.5940      0.383 0.584 0.000 0.000 0.040 0.152 0.224
#> SRR944308     1  0.3739      0.544 0.768 0.000 0.000 0.000 0.056 0.176
#> SRR944309     1  0.4097      0.371 0.500 0.000 0.000 0.000 0.008 0.492
#> SRR944310     1  0.3694      0.517 0.784 0.000 0.000 0.000 0.076 0.140
#> SRR944311     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944312     1  0.4649      0.390 0.572 0.000 0.000 0.000 0.048 0.380
#> SRR944313     1  0.3189      0.544 0.796 0.000 0.000 0.000 0.020 0.184
#> SRR944315     1  0.4950      0.410 0.652 0.000 0.000 0.000 0.184 0.164
#> SRR944314     1  0.1918      0.546 0.904 0.000 0.000 0.000 0.008 0.088
#> SRR944316     1  0.3977      0.512 0.760 0.000 0.000 0.000 0.096 0.144
#> SRR944317     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944318     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944319     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944320     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944321     6  0.0000      0.999 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR944322     6  0.0146      0.995 0.000 0.000 0.000 0.000 0.004 0.996
#> SRR944323     6  0.0000      0.999 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR944324     6  0.0000      0.999 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR944325     6  0.0000      0.999 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR944326     6  0.0000      0.999 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR944327     1  0.3915      0.138 0.584 0.000 0.000 0.000 0.412 0.004
#> SRR944328     1  0.3930      0.118 0.576 0.000 0.000 0.000 0.420 0.004
#> SRR944329     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR944330     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR944331     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR944332     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR944334     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR944333     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR944335     1  0.6271      0.368 0.568 0.000 0.000 0.072 0.152 0.208
#> SRR944336     1  0.6271      0.368 0.568 0.000 0.000 0.072 0.152 0.208
#> SRR944337     1  0.6192      0.366 0.568 0.000 0.000 0.060 0.152 0.220
#> SRR944338     3  0.0000      0.987 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR944339     3  0.0000      0.987 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR944340     3  0.0000      0.987 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR944341     3  0.0000      0.987 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR944342     3  0.0000      0.987 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR944343     3  0.0000      0.987 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR944344     3  0.1700      0.914 0.000 0.004 0.916 0.000 0.080 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 12673 rows and 62 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 0.414           0.822       0.883         0.4346 0.545   0.545
#> 3 3 1.000           0.965       0.987         0.1607 0.675   0.528
#> 4 4 0.786           0.909       0.934         0.3632 0.727   0.491
#> 5 5 0.755           0.804       0.896         0.0424 0.989   0.964
#> 6 6 0.671           0.739       0.852         0.0286 0.992   0.970

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
#> SRR944282     1  0.2423      0.847 0.960 0.040
#> SRR944283     1  0.2423      0.847 0.960 0.040
#> SRR944284     1  0.8813      0.767 0.700 0.300
#> SRR944285     1  0.3274      0.853 0.940 0.060
#> SRR944288     1  0.7602      0.844 0.780 0.220
#> SRR944287     1  0.5294      0.866 0.880 0.120
#> SRR944289     2  0.6801      0.720 0.180 0.820
#> SRR944290     2  0.9983     -0.240 0.476 0.524
#> SRR944291     1  0.8267      0.812 0.740 0.260
#> SRR944292     1  0.0000      0.829 1.000 0.000
#> SRR944293     1  0.8267      0.812 0.740 0.260
#> SRR944294     1  0.7815      0.834 0.768 0.232
#> SRR944295     2  0.0000      0.918 0.000 1.000
#> SRR944296     2  0.0000      0.918 0.000 1.000
#> SRR944297     2  0.0000      0.918 0.000 1.000
#> SRR944298     2  0.0000      0.918 0.000 1.000
#> SRR944299     1  0.9087      0.729 0.676 0.324
#> SRR944300     1  0.8661      0.781 0.712 0.288
#> SRR944301     1  0.6247      0.868 0.844 0.156
#> SRR944302     1  0.2236      0.846 0.964 0.036
#> SRR944303     2  0.0000      0.918 0.000 1.000
#> SRR944304     1  0.6887      0.861 0.816 0.184
#> SRR944305     1  0.8713      0.775 0.708 0.292
#> SRR944306     1  0.8207      0.816 0.744 0.256
#> SRR944307     1  0.9754      0.560 0.592 0.408
#> SRR944308     1  0.7056      0.858 0.808 0.192
#> SRR944309     1  0.6438      0.866 0.836 0.164
#> SRR944310     1  0.7219      0.854 0.800 0.200
#> SRR944311     2  0.0000      0.918 0.000 1.000
#> SRR944312     1  0.9358      0.681 0.648 0.352
#> SRR944313     1  0.5737      0.868 0.864 0.136
#> SRR944315     1  0.8144      0.820 0.748 0.252
#> SRR944314     1  0.0672      0.833 0.992 0.008
#> SRR944316     1  0.7602      0.842 0.780 0.220
#> SRR944317     2  0.0000      0.918 0.000 1.000
#> SRR944318     2  0.0000      0.918 0.000 1.000
#> SRR944319     2  0.0000      0.918 0.000 1.000
#> SRR944320     2  0.0000      0.918 0.000 1.000
#> SRR944321     1  0.6531      0.865 0.832 0.168
#> SRR944322     1  0.4939      0.864 0.892 0.108
#> SRR944323     1  0.5946      0.867 0.856 0.144
#> SRR944324     1  0.6801      0.862 0.820 0.180
#> SRR944325     1  0.6438      0.866 0.836 0.164
#> SRR944326     1  0.6343      0.867 0.840 0.160
#> SRR944327     1  0.0672      0.833 0.992 0.008
#> SRR944328     1  0.0000      0.829 1.000 0.000
#> SRR944329     2  0.0000      0.918 0.000 1.000
#> SRR944330     2  0.0000      0.918 0.000 1.000
#> SRR944331     2  0.0672      0.914 0.008 0.992
#> SRR944332     2  0.0376      0.916 0.004 0.996
#> SRR944334     2  0.0672      0.914 0.008 0.992
#> SRR944333     2  0.0000      0.918 0.000 1.000
#> SRR944335     2  0.6712      0.727 0.176 0.824
#> SRR944336     2  0.4690      0.827 0.100 0.900
#> SRR944337     2  0.8955      0.420 0.312 0.688
#> SRR944338     1  0.0376      0.828 0.996 0.004
#> SRR944339     1  0.0376      0.828 0.996 0.004
#> SRR944340     1  0.0376      0.828 0.996 0.004
#> SRR944341     1  0.0376      0.828 0.996 0.004
#> SRR944342     1  0.0376      0.828 0.996 0.004
#> SRR944343     1  0.0376      0.828 0.996 0.004
#> SRR944344     1  0.0376      0.828 0.996 0.004

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> SRR944282     1  0.0000      0.979 1.000 0.000 0.000
#> SRR944283     1  0.0000      0.979 1.000 0.000 0.000
#> SRR944284     1  0.0000      0.979 1.000 0.000 0.000
#> SRR944285     1  0.0000      0.979 1.000 0.000 0.000
#> SRR944288     1  0.0000      0.979 1.000 0.000 0.000
#> SRR944287     1  0.0000      0.979 1.000 0.000 0.000
#> SRR944289     1  0.0000      0.979 1.000 0.000 0.000
#> SRR944290     1  0.0000      0.979 1.000 0.000 0.000
#> SRR944291     1  0.0000      0.979 1.000 0.000 0.000
#> SRR944292     1  0.0000      0.979 1.000 0.000 0.000
#> SRR944293     1  0.0000      0.979 1.000 0.000 0.000
#> SRR944294     1  0.0000      0.979 1.000 0.000 0.000
#> SRR944295     2  0.0000      0.999 0.000 1.000 0.000
#> SRR944296     2  0.0000      0.999 0.000 1.000 0.000
#> SRR944297     2  0.0000      0.999 0.000 1.000 0.000
#> SRR944298     2  0.0000      0.999 0.000 1.000 0.000
#> SRR944299     1  0.0000      0.979 1.000 0.000 0.000
#> SRR944300     1  0.0000      0.979 1.000 0.000 0.000
#> SRR944301     1  0.0000      0.979 1.000 0.000 0.000
#> SRR944302     1  0.1163      0.954 0.972 0.000 0.028
#> SRR944303     2  0.0000      0.999 0.000 1.000 0.000
#> SRR944304     1  0.0000      0.979 1.000 0.000 0.000
#> SRR944305     1  0.0000      0.979 1.000 0.000 0.000
#> SRR944306     1  0.0000      0.979 1.000 0.000 0.000
#> SRR944307     1  0.0000      0.979 1.000 0.000 0.000
#> SRR944308     1  0.0000      0.979 1.000 0.000 0.000
#> SRR944309     1  0.0000      0.979 1.000 0.000 0.000
#> SRR944310     1  0.0000      0.979 1.000 0.000 0.000
#> SRR944311     2  0.0000      0.999 0.000 1.000 0.000
#> SRR944312     1  0.0000      0.979 1.000 0.000 0.000
#> SRR944313     1  0.0000      0.979 1.000 0.000 0.000
#> SRR944315     1  0.0000      0.979 1.000 0.000 0.000
#> SRR944314     1  0.0000      0.979 1.000 0.000 0.000
#> SRR944316     1  0.0000      0.979 1.000 0.000 0.000
#> SRR944317     2  0.0000      0.999 0.000 1.000 0.000
#> SRR944318     2  0.0000      0.999 0.000 1.000 0.000
#> SRR944319     2  0.0000      0.999 0.000 1.000 0.000
#> SRR944320     2  0.0000      0.999 0.000 1.000 0.000
#> SRR944321     1  0.0000      0.979 1.000 0.000 0.000
#> SRR944322     1  0.0000      0.979 1.000 0.000 0.000
#> SRR944323     1  0.0000      0.979 1.000 0.000 0.000
#> SRR944324     1  0.0000      0.979 1.000 0.000 0.000
#> SRR944325     1  0.0000      0.979 1.000 0.000 0.000
#> SRR944326     1  0.0000      0.979 1.000 0.000 0.000
#> SRR944327     1  0.0000      0.979 1.000 0.000 0.000
#> SRR944328     1  0.0000      0.979 1.000 0.000 0.000
#> SRR944329     2  0.0000      0.999 0.000 1.000 0.000
#> SRR944330     2  0.0000      0.999 0.000 1.000 0.000
#> SRR944331     1  0.4235      0.785 0.824 0.176 0.000
#> SRR944332     1  0.6302      0.105 0.520 0.480 0.000
#> SRR944334     1  0.3686      0.830 0.860 0.140 0.000
#> SRR944333     2  0.0424      0.987 0.008 0.992 0.000
#> SRR944335     1  0.0000      0.979 1.000 0.000 0.000
#> SRR944336     1  0.0000      0.979 1.000 0.000 0.000
#> SRR944337     1  0.0000      0.979 1.000 0.000 0.000
#> SRR944338     3  0.0000      1.000 0.000 0.000 1.000
#> SRR944339     3  0.0000      1.000 0.000 0.000 1.000
#> SRR944340     3  0.0000      1.000 0.000 0.000 1.000
#> SRR944341     3  0.0000      1.000 0.000 0.000 1.000
#> SRR944342     3  0.0000      1.000 0.000 0.000 1.000
#> SRR944343     3  0.0000      1.000 0.000 0.000 1.000
#> SRR944344     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
#> SRR944282     1  0.0000     0.9528 1.000 0.000 0.000 0.000
#> SRR944283     1  0.0000     0.9528 1.000 0.000 0.000 0.000
#> SRR944284     1  0.0000     0.9528 1.000 0.000 0.000 0.000
#> SRR944285     1  0.0188     0.9542 0.996 0.000 0.000 0.004
#> SRR944288     1  0.0188     0.9542 0.996 0.000 0.000 0.004
#> SRR944287     1  0.0817     0.9408 0.976 0.000 0.000 0.024
#> SRR944289     4  0.2469     0.9193 0.108 0.000 0.000 0.892
#> SRR944290     4  0.2868     0.9134 0.136 0.000 0.000 0.864
#> SRR944291     1  0.0188     0.9542 0.996 0.000 0.000 0.004
#> SRR944292     1  0.0779     0.9407 0.980 0.000 0.004 0.016
#> SRR944293     1  0.0188     0.9542 0.996 0.000 0.000 0.004
#> SRR944294     1  0.0188     0.9542 0.996 0.000 0.000 0.004
#> SRR944295     2  0.0000     0.9902 0.000 1.000 0.000 0.000
#> SRR944296     2  0.0000     0.9902 0.000 1.000 0.000 0.000
#> SRR944297     2  0.0000     0.9902 0.000 1.000 0.000 0.000
#> SRR944298     2  0.0000     0.9902 0.000 1.000 0.000 0.000
#> SRR944299     4  0.2704     0.9193 0.124 0.000 0.000 0.876
#> SRR944300     4  0.2704     0.9193 0.124 0.000 0.000 0.876
#> SRR944301     1  0.2011     0.8808 0.920 0.000 0.000 0.080
#> SRR944302     4  0.5491     0.5390 0.052 0.000 0.260 0.688
#> SRR944303     2  0.0188     0.9894 0.000 0.996 0.000 0.004
#> SRR944304     4  0.3266     0.8919 0.168 0.000 0.000 0.832
#> SRR944305     4  0.2704     0.9193 0.124 0.000 0.000 0.876
#> SRR944306     4  0.2704     0.9193 0.124 0.000 0.000 0.876
#> SRR944307     4  0.2704     0.9193 0.124 0.000 0.000 0.876
#> SRR944308     4  0.4103     0.7894 0.256 0.000 0.000 0.744
#> SRR944309     1  0.4941     0.0271 0.564 0.000 0.000 0.436
#> SRR944310     4  0.4564     0.6660 0.328 0.000 0.000 0.672
#> SRR944311     2  0.0188     0.9894 0.000 0.996 0.000 0.004
#> SRR944312     4  0.3444     0.8778 0.184 0.000 0.000 0.816
#> SRR944313     1  0.4222     0.5556 0.728 0.000 0.000 0.272
#> SRR944315     1  0.0000     0.9528 1.000 0.000 0.000 0.000
#> SRR944314     1  0.0188     0.9542 0.996 0.000 0.000 0.004
#> SRR944316     1  0.1022     0.9327 0.968 0.000 0.000 0.032
#> SRR944317     2  0.0000     0.9902 0.000 1.000 0.000 0.000
#> SRR944318     2  0.0188     0.9891 0.000 0.996 0.000 0.004
#> SRR944319     2  0.1302     0.9627 0.000 0.956 0.000 0.044
#> SRR944320     2  0.1118     0.9681 0.000 0.964 0.000 0.036
#> SRR944321     1  0.0336     0.9527 0.992 0.000 0.000 0.008
#> SRR944322     1  0.0336     0.9527 0.992 0.000 0.000 0.008
#> SRR944323     1  0.0336     0.9527 0.992 0.000 0.000 0.008
#> SRR944324     1  0.0188     0.9542 0.996 0.000 0.000 0.004
#> SRR944325     1  0.0188     0.9542 0.996 0.000 0.000 0.004
#> SRR944326     1  0.0188     0.9542 0.996 0.000 0.000 0.004
#> SRR944327     1  0.0000     0.9528 1.000 0.000 0.000 0.000
#> SRR944328     1  0.0000     0.9528 1.000 0.000 0.000 0.000
#> SRR944329     4  0.2342     0.8334 0.008 0.080 0.000 0.912
#> SRR944330     4  0.2342     0.8334 0.008 0.080 0.000 0.912
#> SRR944331     4  0.2081     0.9083 0.084 0.000 0.000 0.916
#> SRR944332     4  0.2125     0.9028 0.076 0.004 0.000 0.920
#> SRR944334     4  0.2081     0.9083 0.084 0.000 0.000 0.916
#> SRR944333     4  0.2402     0.8381 0.012 0.076 0.000 0.912
#> SRR944335     4  0.2469     0.9193 0.108 0.000 0.000 0.892
#> SRR944336     4  0.2469     0.9193 0.108 0.000 0.000 0.892
#> SRR944337     4  0.2469     0.9193 0.108 0.000 0.000 0.892
#> SRR944338     3  0.0592     0.9858 0.000 0.000 0.984 0.016
#> SRR944339     3  0.0000     0.9876 0.000 0.000 1.000 0.000
#> SRR944340     3  0.0469     0.9844 0.000 0.000 0.988 0.012
#> SRR944341     3  0.0000     0.9876 0.000 0.000 1.000 0.000
#> SRR944342     3  0.0188     0.9870 0.000 0.000 0.996 0.004
#> SRR944343     3  0.0592     0.9858 0.000 0.000 0.984 0.016
#> SRR944344     3  0.1792     0.9595 0.000 0.000 0.932 0.068

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> SRR944282     1  0.0955      0.881 0.968 0.000 0.000 0.004 0.028
#> SRR944283     1  0.1041      0.879 0.964 0.000 0.000 0.004 0.032
#> SRR944284     1  0.0566      0.886 0.984 0.000 0.000 0.004 0.012
#> SRR944285     1  0.2514      0.883 0.896 0.000 0.000 0.044 0.060
#> SRR944288     1  0.0898      0.890 0.972 0.000 0.000 0.008 0.020
#> SRR944287     1  0.2573      0.851 0.880 0.000 0.000 0.104 0.016
#> SRR944289     4  0.1168      0.823 0.032 0.000 0.000 0.960 0.008
#> SRR944290     4  0.3462      0.696 0.196 0.000 0.000 0.792 0.012
#> SRR944291     1  0.1310      0.892 0.956 0.000 0.000 0.020 0.024
#> SRR944292     1  0.4046      0.763 0.780 0.000 0.008 0.032 0.180
#> SRR944293     1  0.2325      0.875 0.904 0.000 0.000 0.068 0.028
#> SRR944294     1  0.2136      0.867 0.904 0.000 0.000 0.088 0.008
#> SRR944295     2  0.0162      0.912 0.000 0.996 0.000 0.000 0.004
#> SRR944296     2  0.1908      0.886 0.000 0.908 0.000 0.000 0.092
#> SRR944297     2  0.1357      0.906 0.000 0.948 0.000 0.004 0.048
#> SRR944298     2  0.0404      0.912 0.000 0.988 0.000 0.000 0.012
#> SRR944299     4  0.1809      0.822 0.060 0.000 0.000 0.928 0.012
#> SRR944300     4  0.2006      0.818 0.072 0.000 0.000 0.916 0.012
#> SRR944301     1  0.2848      0.792 0.840 0.000 0.000 0.156 0.004
#> SRR944302     5  0.7179      0.000 0.056 0.004 0.144 0.272 0.524
#> SRR944303     2  0.0880      0.906 0.000 0.968 0.000 0.000 0.032
#> SRR944304     4  0.3615      0.734 0.156 0.000 0.000 0.808 0.036
#> SRR944305     4  0.2818      0.775 0.132 0.000 0.000 0.856 0.012
#> SRR944306     4  0.2540      0.805 0.088 0.000 0.000 0.888 0.024
#> SRR944307     4  0.1670      0.823 0.052 0.000 0.000 0.936 0.012
#> SRR944308     4  0.4329      0.513 0.312 0.000 0.000 0.672 0.016
#> SRR944309     1  0.4473      0.241 0.580 0.000 0.000 0.412 0.008
#> SRR944310     4  0.4890      0.450 0.332 0.000 0.000 0.628 0.040
#> SRR944311     2  0.0609      0.909 0.000 0.980 0.000 0.000 0.020
#> SRR944312     4  0.4086      0.565 0.284 0.000 0.000 0.704 0.012
#> SRR944313     1  0.4088      0.540 0.688 0.000 0.000 0.304 0.008
#> SRR944315     1  0.0566      0.891 0.984 0.000 0.000 0.012 0.004
#> SRR944314     1  0.0798      0.887 0.976 0.000 0.000 0.008 0.016
#> SRR944316     1  0.3301      0.855 0.848 0.000 0.000 0.080 0.072
#> SRR944317     2  0.0162      0.912 0.000 0.996 0.000 0.000 0.004
#> SRR944318     2  0.1571      0.902 0.000 0.936 0.000 0.004 0.060
#> SRR944319     2  0.4755      0.706 0.000 0.696 0.000 0.060 0.244
#> SRR944320     2  0.4679      0.698 0.000 0.652 0.000 0.032 0.316
#> SRR944321     1  0.1872      0.889 0.928 0.000 0.000 0.052 0.020
#> SRR944322     1  0.1809      0.887 0.928 0.000 0.000 0.060 0.012
#> SRR944323     1  0.1809      0.887 0.928 0.000 0.000 0.060 0.012
#> SRR944324     1  0.1670      0.889 0.936 0.000 0.000 0.052 0.012
#> SRR944325     1  0.1211      0.891 0.960 0.000 0.000 0.024 0.016
#> SRR944326     1  0.1041      0.883 0.964 0.000 0.000 0.004 0.032
#> SRR944327     1  0.1704      0.856 0.928 0.000 0.000 0.004 0.068
#> SRR944328     1  0.2424      0.807 0.868 0.000 0.000 0.000 0.132
#> SRR944329     4  0.1597      0.751 0.000 0.012 0.000 0.940 0.048
#> SRR944330     4  0.1522      0.757 0.000 0.012 0.000 0.944 0.044
#> SRR944331     4  0.0912      0.803 0.012 0.000 0.000 0.972 0.016
#> SRR944332     4  0.1012      0.801 0.012 0.000 0.000 0.968 0.020
#> SRR944334     4  0.0912      0.803 0.012 0.000 0.000 0.972 0.016
#> SRR944333     4  0.1356      0.779 0.004 0.012 0.000 0.956 0.028
#> SRR944335     4  0.1082      0.822 0.028 0.000 0.000 0.964 0.008
#> SRR944336     4  0.0992      0.820 0.024 0.000 0.000 0.968 0.008
#> SRR944337     4  0.1251      0.824 0.036 0.000 0.000 0.956 0.008
#> SRR944338     3  0.1197      0.919 0.000 0.000 0.952 0.000 0.048
#> SRR944339     3  0.0000      0.946 0.000 0.000 1.000 0.000 0.000
#> SRR944340     3  0.0000      0.946 0.000 0.000 1.000 0.000 0.000
#> SRR944341     3  0.0324      0.944 0.000 0.000 0.992 0.004 0.004
#> SRR944342     3  0.0162      0.946 0.000 0.000 0.996 0.000 0.004
#> SRR944343     3  0.0000      0.946 0.000 0.000 1.000 0.000 0.000
#> SRR944344     3  0.3480      0.696 0.000 0.000 0.752 0.000 0.248

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR944282     1  0.1341      0.816 0.948 0.000 0.000 0.000 0.024 0.028
#> SRR944283     1  0.1563      0.812 0.932 0.000 0.000 0.000 0.056 0.012
#> SRR944284     1  0.0984      0.826 0.968 0.000 0.000 0.008 0.012 0.012
#> SRR944285     1  0.3325      0.802 0.840 0.000 0.000 0.032 0.092 0.036
#> SRR944288     1  0.1829      0.816 0.920 0.000 0.000 0.000 0.056 0.024
#> SRR944287     1  0.3779      0.764 0.800 0.000 0.000 0.124 0.056 0.020
#> SRR944289     4  0.0717      0.797 0.016 0.000 0.000 0.976 0.000 0.008
#> SRR944290     4  0.4125      0.637 0.232 0.000 0.000 0.724 0.016 0.028
#> SRR944291     1  0.2752      0.827 0.880 0.000 0.000 0.024 0.044 0.052
#> SRR944292     1  0.5889      0.438 0.580 0.000 0.000 0.040 0.252 0.128
#> SRR944293     1  0.3133      0.803 0.856 0.000 0.000 0.072 0.040 0.032
#> SRR944294     1  0.3295      0.784 0.836 0.000 0.000 0.108 0.028 0.028
#> SRR944295     2  0.0622      0.886 0.000 0.980 0.000 0.000 0.008 0.012
#> SRR944296     2  0.2821      0.710 0.000 0.832 0.000 0.000 0.016 0.152
#> SRR944297     2  0.2060      0.844 0.000 0.900 0.000 0.000 0.016 0.084
#> SRR944298     2  0.1367      0.876 0.000 0.944 0.000 0.000 0.012 0.044
#> SRR944299     4  0.1633      0.796 0.044 0.000 0.000 0.932 0.000 0.024
#> SRR944300     4  0.2152      0.786 0.068 0.000 0.000 0.904 0.004 0.024
#> SRR944301     1  0.4259      0.688 0.744 0.000 0.000 0.188 0.040 0.028
#> SRR944302     5  0.5534      0.000 0.080 0.004 0.040 0.152 0.696 0.028
#> SRR944303     2  0.0909      0.876 0.000 0.968 0.000 0.000 0.012 0.020
#> SRR944304     4  0.3891      0.695 0.180 0.000 0.000 0.768 0.016 0.036
#> SRR944305     4  0.4017      0.686 0.184 0.000 0.000 0.760 0.024 0.032
#> SRR944306     4  0.2615      0.774 0.088 0.000 0.000 0.876 0.008 0.028
#> SRR944307     4  0.1367      0.798 0.044 0.000 0.000 0.944 0.000 0.012
#> SRR944308     4  0.5189      0.403 0.364 0.000 0.000 0.564 0.040 0.032
#> SRR944309     1  0.4980      0.445 0.616 0.000 0.000 0.316 0.036 0.032
#> SRR944310     4  0.5723      0.155 0.424 0.000 0.000 0.472 0.056 0.048
#> SRR944311     2  0.0520      0.884 0.000 0.984 0.000 0.000 0.008 0.008
#> SRR944312     4  0.5086      0.446 0.348 0.000 0.000 0.584 0.036 0.032
#> SRR944313     1  0.4828      0.542 0.652 0.000 0.000 0.280 0.032 0.036
#> SRR944315     1  0.1458      0.827 0.948 0.000 0.000 0.016 0.016 0.020
#> SRR944314     1  0.1116      0.827 0.960 0.000 0.000 0.008 0.028 0.004
#> SRR944316     1  0.4900      0.736 0.720 0.000 0.000 0.112 0.124 0.044
#> SRR944317     2  0.0363      0.888 0.000 0.988 0.000 0.000 0.000 0.012
#> SRR944318     2  0.2266      0.782 0.000 0.880 0.000 0.000 0.012 0.108
#> SRR944319     6  0.5178      0.776 0.000 0.444 0.000 0.040 0.024 0.492
#> SRR944320     6  0.4246      0.781 0.000 0.400 0.000 0.020 0.000 0.580
#> SRR944321     1  0.2800      0.824 0.876 0.000 0.000 0.052 0.052 0.020
#> SRR944322     1  0.2724      0.825 0.876 0.000 0.000 0.076 0.032 0.016
#> SRR944323     1  0.2501      0.826 0.888 0.000 0.000 0.072 0.028 0.012
#> SRR944324     1  0.2386      0.828 0.896 0.000 0.000 0.064 0.028 0.012
#> SRR944325     1  0.2188      0.826 0.912 0.000 0.000 0.032 0.036 0.020
#> SRR944326     1  0.2401      0.812 0.900 0.000 0.000 0.020 0.044 0.036
#> SRR944327     1  0.4018      0.690 0.768 0.000 0.000 0.004 0.116 0.112
#> SRR944328     1  0.4481      0.615 0.720 0.000 0.000 0.004 0.156 0.120
#> SRR944329     4  0.1462      0.740 0.000 0.008 0.000 0.936 0.000 0.056
#> SRR944330     4  0.1563      0.737 0.000 0.012 0.000 0.932 0.000 0.056
#> SRR944331     4  0.0363      0.783 0.000 0.000 0.000 0.988 0.000 0.012
#> SRR944332     4  0.0363      0.783 0.000 0.000 0.000 0.988 0.000 0.012
#> SRR944334     4  0.0363      0.783 0.000 0.000 0.000 0.988 0.000 0.012
#> SRR944333     4  0.0717      0.776 0.000 0.008 0.000 0.976 0.000 0.016
#> SRR944335     4  0.0692      0.798 0.020 0.000 0.000 0.976 0.000 0.004
#> SRR944336     4  0.0692      0.798 0.020 0.000 0.000 0.976 0.000 0.004
#> SRR944337     4  0.0777      0.799 0.024 0.000 0.000 0.972 0.000 0.004
#> SRR944338     3  0.1074      0.886 0.000 0.000 0.960 0.000 0.028 0.012
#> SRR944339     3  0.0146      0.896 0.000 0.000 0.996 0.000 0.000 0.004
#> SRR944340     3  0.0146      0.897 0.000 0.000 0.996 0.000 0.000 0.004
#> SRR944341     3  0.1088      0.882 0.000 0.000 0.960 0.000 0.016 0.024
#> SRR944342     3  0.0291      0.897 0.000 0.000 0.992 0.000 0.004 0.004
#> SRR944343     3  0.0622      0.896 0.000 0.000 0.980 0.000 0.008 0.012
#> SRR944344     3  0.5396      0.183 0.000 0.000 0.488 0.000 0.396 0.116

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 12673 rows and 62 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 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-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.772           0.949       0.974        0.30467 0.725   0.725
#> 3 3 1.000           0.991       0.997        0.56559 0.795   0.718
#> 4 4 0.878           0.968       0.984        0.05459 0.993   0.986
#> 5 5 0.874           0.950       0.979        0.00613 0.997   0.994
#> 6 6 0.870           0.918       0.979        0.00423 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] 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
#> SRR944282     1   0.000      0.967 1.000 0.000
#> SRR944283     1   0.000      0.967 1.000 0.000
#> SRR944284     1   0.000      0.967 1.000 0.000
#> SRR944285     1   0.000      0.967 1.000 0.000
#> SRR944288     1   0.000      0.967 1.000 0.000
#> SRR944287     1   0.000      0.967 1.000 0.000
#> SRR944289     1   0.000      0.967 1.000 0.000
#> SRR944290     1   0.000      0.967 1.000 0.000
#> SRR944291     1   0.000      0.967 1.000 0.000
#> SRR944292     1   0.358      0.914 0.932 0.068
#> SRR944293     1   0.000      0.967 1.000 0.000
#> SRR944294     1   0.000      0.967 1.000 0.000
#> SRR944295     2   0.000      1.000 0.000 1.000
#> SRR944296     2   0.000      1.000 0.000 1.000
#> SRR944297     2   0.000      1.000 0.000 1.000
#> SRR944298     2   0.000      1.000 0.000 1.000
#> SRR944299     1   0.000      0.967 1.000 0.000
#> SRR944300     1   0.000      0.967 1.000 0.000
#> SRR944301     1   0.000      0.967 1.000 0.000
#> SRR944302     1   0.714      0.793 0.804 0.196
#> SRR944303     2   0.000      1.000 0.000 1.000
#> SRR944304     1   0.000      0.967 1.000 0.000
#> SRR944305     1   0.000      0.967 1.000 0.000
#> SRR944306     1   0.000      0.967 1.000 0.000
#> SRR944307     1   0.000      0.967 1.000 0.000
#> SRR944308     1   0.000      0.967 1.000 0.000
#> SRR944309     1   0.000      0.967 1.000 0.000
#> SRR944310     1   0.000      0.967 1.000 0.000
#> SRR944311     2   0.000      1.000 0.000 1.000
#> SRR944312     1   0.000      0.967 1.000 0.000
#> SRR944313     1   0.000      0.967 1.000 0.000
#> SRR944315     1   0.000      0.967 1.000 0.000
#> SRR944314     1   0.000      0.967 1.000 0.000
#> SRR944316     1   0.000      0.967 1.000 0.000
#> SRR944317     2   0.000      1.000 0.000 1.000
#> SRR944318     2   0.000      1.000 0.000 1.000
#> SRR944319     2   0.000      1.000 0.000 1.000
#> SRR944320     2   0.000      1.000 0.000 1.000
#> SRR944321     1   0.000      0.967 1.000 0.000
#> SRR944322     1   0.000      0.967 1.000 0.000
#> SRR944323     1   0.000      0.967 1.000 0.000
#> SRR944324     1   0.000      0.967 1.000 0.000
#> SRR944325     1   0.000      0.967 1.000 0.000
#> SRR944326     1   0.000      0.967 1.000 0.000
#> SRR944327     1   0.000      0.967 1.000 0.000
#> SRR944328     1   0.000      0.967 1.000 0.000
#> SRR944329     1   0.000      0.967 1.000 0.000
#> SRR944330     1   0.000      0.967 1.000 0.000
#> SRR944331     1   0.000      0.967 1.000 0.000
#> SRR944332     1   0.000      0.967 1.000 0.000
#> SRR944334     1   0.000      0.967 1.000 0.000
#> SRR944333     1   0.000      0.967 1.000 0.000
#> SRR944335     1   0.000      0.967 1.000 0.000
#> SRR944336     1   0.000      0.967 1.000 0.000
#> SRR944337     1   0.000      0.967 1.000 0.000
#> SRR944338     1   0.714      0.793 0.804 0.196
#> SRR944339     1   0.714      0.793 0.804 0.196
#> SRR944340     1   0.714      0.793 0.804 0.196
#> SRR944341     1   0.714      0.793 0.804 0.196
#> SRR944342     1   0.714      0.793 0.804 0.196
#> SRR944343     1   0.714      0.793 0.804 0.196
#> SRR944344     1   0.714      0.793 0.804 0.196

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1 p2    p3
#> SRR944282     1  0.0000      1.000 1.000  0 0.000
#> SRR944283     1  0.0000      1.000 1.000  0 0.000
#> SRR944284     1  0.0000      1.000 1.000  0 0.000
#> SRR944285     1  0.0000      1.000 1.000  0 0.000
#> SRR944288     1  0.0000      1.000 1.000  0 0.000
#> SRR944287     1  0.0000      1.000 1.000  0 0.000
#> SRR944289     1  0.0000      1.000 1.000  0 0.000
#> SRR944290     1  0.0000      1.000 1.000  0 0.000
#> SRR944291     1  0.0000      1.000 1.000  0 0.000
#> SRR944292     3  0.3879      0.745 0.152  0 0.848
#> SRR944293     1  0.0000      1.000 1.000  0 0.000
#> SRR944294     1  0.0000      1.000 1.000  0 0.000
#> SRR944295     2  0.0000      1.000 0.000  1 0.000
#> SRR944296     2  0.0000      1.000 0.000  1 0.000
#> SRR944297     2  0.0000      1.000 0.000  1 0.000
#> SRR944298     2  0.0000      1.000 0.000  1 0.000
#> SRR944299     1  0.0000      1.000 1.000  0 0.000
#> SRR944300     1  0.0000      1.000 1.000  0 0.000
#> SRR944301     1  0.0000      1.000 1.000  0 0.000
#> SRR944302     3  0.0892      0.943 0.020  0 0.980
#> SRR944303     2  0.0000      1.000 0.000  1 0.000
#> SRR944304     1  0.0000      1.000 1.000  0 0.000
#> SRR944305     1  0.0000      1.000 1.000  0 0.000
#> SRR944306     1  0.0000      1.000 1.000  0 0.000
#> SRR944307     1  0.0000      1.000 1.000  0 0.000
#> SRR944308     1  0.0000      1.000 1.000  0 0.000
#> SRR944309     1  0.0000      1.000 1.000  0 0.000
#> SRR944310     1  0.0000      1.000 1.000  0 0.000
#> SRR944311     2  0.0000      1.000 0.000  1 0.000
#> SRR944312     1  0.0000      1.000 1.000  0 0.000
#> SRR944313     1  0.0000      1.000 1.000  0 0.000
#> SRR944315     1  0.0000      1.000 1.000  0 0.000
#> SRR944314     1  0.0000      1.000 1.000  0 0.000
#> SRR944316     1  0.0000      1.000 1.000  0 0.000
#> SRR944317     2  0.0000      1.000 0.000  1 0.000
#> SRR944318     2  0.0000      1.000 0.000  1 0.000
#> SRR944319     2  0.0000      1.000 0.000  1 0.000
#> SRR944320     2  0.0000      1.000 0.000  1 0.000
#> SRR944321     1  0.0000      1.000 1.000  0 0.000
#> SRR944322     1  0.0000      1.000 1.000  0 0.000
#> SRR944323     1  0.0000      1.000 1.000  0 0.000
#> SRR944324     1  0.0000      1.000 1.000  0 0.000
#> SRR944325     1  0.0000      1.000 1.000  0 0.000
#> SRR944326     1  0.0000      1.000 1.000  0 0.000
#> SRR944327     1  0.0000      1.000 1.000  0 0.000
#> SRR944328     1  0.0000      1.000 1.000  0 0.000
#> SRR944329     1  0.0000      1.000 1.000  0 0.000
#> SRR944330     1  0.0000      1.000 1.000  0 0.000
#> SRR944331     1  0.0000      1.000 1.000  0 0.000
#> SRR944332     1  0.0000      1.000 1.000  0 0.000
#> SRR944334     1  0.0000      1.000 1.000  0 0.000
#> SRR944333     1  0.0000      1.000 1.000  0 0.000
#> SRR944335     1  0.0000      1.000 1.000  0 0.000
#> SRR944336     1  0.0000      1.000 1.000  0 0.000
#> SRR944337     1  0.0000      1.000 1.000  0 0.000
#> SRR944338     3  0.0000      0.964 0.000  0 1.000
#> SRR944339     3  0.0000      0.964 0.000  0 1.000
#> SRR944340     3  0.0000      0.964 0.000  0 1.000
#> SRR944341     3  0.0000      0.964 0.000  0 1.000
#> SRR944342     3  0.0000      0.964 0.000  0 1.000
#> SRR944343     3  0.0000      0.964 0.000  0 1.000
#> SRR944344     3  0.0000      0.964 0.000  0 1.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1 p2    p3    p4
#> SRR944282     1  0.0000      0.980 1.000  0 0.000 0.000
#> SRR944283     1  0.0000      0.980 1.000  0 0.000 0.000
#> SRR944284     1  0.0000      0.980 1.000  0 0.000 0.000
#> SRR944285     1  0.0000      0.980 1.000  0 0.000 0.000
#> SRR944288     1  0.0000      0.980 1.000  0 0.000 0.000
#> SRR944287     1  0.0000      0.980 1.000  0 0.000 0.000
#> SRR944289     1  0.1302      0.949 0.956  0 0.000 0.044
#> SRR944290     1  0.0000      0.980 1.000  0 0.000 0.000
#> SRR944291     1  0.0000      0.980 1.000  0 0.000 0.000
#> SRR944292     4  0.0469      0.825 0.000  0 0.012 0.988
#> SRR944293     1  0.0000      0.980 1.000  0 0.000 0.000
#> SRR944294     1  0.0000      0.980 1.000  0 0.000 0.000
#> SRR944295     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR944296     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR944297     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR944298     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR944299     1  0.0000      0.980 1.000  0 0.000 0.000
#> SRR944300     1  0.0000      0.980 1.000  0 0.000 0.000
#> SRR944301     1  0.0000      0.980 1.000  0 0.000 0.000
#> SRR944302     4  0.2868      0.803 0.000  0 0.136 0.864
#> SRR944303     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR944304     1  0.0000      0.980 1.000  0 0.000 0.000
#> SRR944305     1  0.0000      0.980 1.000  0 0.000 0.000
#> SRR944306     1  0.0000      0.980 1.000  0 0.000 0.000
#> SRR944307     1  0.0000      0.980 1.000  0 0.000 0.000
#> SRR944308     1  0.0000      0.980 1.000  0 0.000 0.000
#> SRR944309     1  0.0000      0.980 1.000  0 0.000 0.000
#> SRR944310     1  0.0000      0.980 1.000  0 0.000 0.000
#> SRR944311     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR944312     1  0.0000      0.980 1.000  0 0.000 0.000
#> SRR944313     1  0.0000      0.980 1.000  0 0.000 0.000
#> SRR944315     1  0.0000      0.980 1.000  0 0.000 0.000
#> SRR944314     1  0.0000      0.980 1.000  0 0.000 0.000
#> SRR944316     1  0.0000      0.980 1.000  0 0.000 0.000
#> SRR944317     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR944318     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR944319     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR944320     2  0.0000      1.000 0.000  1 0.000 0.000
#> SRR944321     1  0.0000      0.980 1.000  0 0.000 0.000
#> SRR944322     1  0.0000      0.980 1.000  0 0.000 0.000
#> SRR944323     1  0.0000      0.980 1.000  0 0.000 0.000
#> SRR944324     1  0.0000      0.980 1.000  0 0.000 0.000
#> SRR944325     1  0.0000      0.980 1.000  0 0.000 0.000
#> SRR944326     1  0.0000      0.980 1.000  0 0.000 0.000
#> SRR944327     1  0.0000      0.980 1.000  0 0.000 0.000
#> SRR944328     1  0.0000      0.980 1.000  0 0.000 0.000
#> SRR944329     1  0.2814      0.873 0.868  0 0.000 0.132
#> SRR944330     1  0.2814      0.873 0.868  0 0.000 0.132
#> SRR944331     1  0.2814      0.873 0.868  0 0.000 0.132
#> SRR944332     1  0.2814      0.873 0.868  0 0.000 0.132
#> SRR944334     1  0.2814      0.873 0.868  0 0.000 0.132
#> SRR944333     1  0.2814      0.873 0.868  0 0.000 0.132
#> SRR944335     1  0.0336      0.975 0.992  0 0.000 0.008
#> SRR944336     1  0.0336      0.975 0.992  0 0.000 0.008
#> SRR944337     1  0.0336      0.975 0.992  0 0.000 0.008
#> SRR944338     3  0.0000      0.998 0.000  0 1.000 0.000
#> SRR944339     3  0.0000      0.998 0.000  0 1.000 0.000
#> SRR944340     3  0.0000      0.998 0.000  0 1.000 0.000
#> SRR944341     3  0.0000      0.998 0.000  0 1.000 0.000
#> SRR944342     3  0.0000      0.998 0.000  0 1.000 0.000
#> SRR944343     3  0.0000      0.998 0.000  0 1.000 0.000
#> SRR944344     3  0.0469      0.987 0.000  0 0.988 0.012

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> SRR944282     1  0.0000      0.979 1.000 0.000 0.000 0.000 0.000
#> SRR944283     1  0.0000      0.979 1.000 0.000 0.000 0.000 0.000
#> SRR944284     1  0.0000      0.979 1.000 0.000 0.000 0.000 0.000
#> SRR944285     1  0.0000      0.979 1.000 0.000 0.000 0.000 0.000
#> SRR944288     1  0.0000      0.979 1.000 0.000 0.000 0.000 0.000
#> SRR944287     1  0.0000      0.979 1.000 0.000 0.000 0.000 0.000
#> SRR944289     1  0.1121      0.948 0.956 0.000 0.000 0.044 0.000
#> SRR944290     1  0.0000      0.979 1.000 0.000 0.000 0.000 0.000
#> SRR944291     1  0.0000      0.979 1.000 0.000 0.000 0.000 0.000
#> SRR944292     4  0.0404      0.748 0.000 0.000 0.012 0.988 0.000
#> SRR944293     1  0.0000      0.979 1.000 0.000 0.000 0.000 0.000
#> SRR944294     1  0.0000      0.979 1.000 0.000 0.000 0.000 0.000
#> SRR944295     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000
#> SRR944296     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000
#> SRR944297     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000
#> SRR944298     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000
#> SRR944299     1  0.0000      0.979 1.000 0.000 0.000 0.000 0.000
#> SRR944300     1  0.0000      0.979 1.000 0.000 0.000 0.000 0.000
#> SRR944301     1  0.0000      0.979 1.000 0.000 0.000 0.000 0.000
#> SRR944302     4  0.3003      0.744 0.000 0.000 0.000 0.812 0.188
#> SRR944303     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000
#> SRR944304     1  0.0000      0.979 1.000 0.000 0.000 0.000 0.000
#> SRR944305     1  0.0000      0.979 1.000 0.000 0.000 0.000 0.000
#> SRR944306     1  0.0000      0.979 1.000 0.000 0.000 0.000 0.000
#> SRR944307     1  0.0000      0.979 1.000 0.000 0.000 0.000 0.000
#> SRR944308     1  0.0000      0.979 1.000 0.000 0.000 0.000 0.000
#> SRR944309     1  0.0000      0.979 1.000 0.000 0.000 0.000 0.000
#> SRR944310     1  0.0000      0.979 1.000 0.000 0.000 0.000 0.000
#> SRR944311     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000
#> SRR944312     1  0.0000      0.979 1.000 0.000 0.000 0.000 0.000
#> SRR944313     1  0.0000      0.979 1.000 0.000 0.000 0.000 0.000
#> SRR944315     1  0.0000      0.979 1.000 0.000 0.000 0.000 0.000
#> SRR944314     1  0.0000      0.979 1.000 0.000 0.000 0.000 0.000
#> SRR944316     1  0.0000      0.979 1.000 0.000 0.000 0.000 0.000
#> SRR944317     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000
#> SRR944318     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000
#> SRR944319     2  0.0290      0.992 0.000 0.992 0.000 0.000 0.008
#> SRR944320     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000
#> SRR944321     1  0.0000      0.979 1.000 0.000 0.000 0.000 0.000
#> SRR944322     1  0.0000      0.979 1.000 0.000 0.000 0.000 0.000
#> SRR944323     1  0.0000      0.979 1.000 0.000 0.000 0.000 0.000
#> SRR944324     1  0.0000      0.979 1.000 0.000 0.000 0.000 0.000
#> SRR944325     1  0.0000      0.979 1.000 0.000 0.000 0.000 0.000
#> SRR944326     1  0.0000      0.979 1.000 0.000 0.000 0.000 0.000
#> SRR944327     1  0.0000      0.979 1.000 0.000 0.000 0.000 0.000
#> SRR944328     1  0.0000      0.979 1.000 0.000 0.000 0.000 0.000
#> SRR944329     1  0.2424      0.873 0.868 0.000 0.000 0.132 0.000
#> SRR944330     1  0.2424      0.873 0.868 0.000 0.000 0.132 0.000
#> SRR944331     1  0.2424      0.873 0.868 0.000 0.000 0.132 0.000
#> SRR944332     1  0.2424      0.873 0.868 0.000 0.000 0.132 0.000
#> SRR944334     1  0.2424      0.873 0.868 0.000 0.000 0.132 0.000
#> SRR944333     1  0.2424      0.873 0.868 0.000 0.000 0.132 0.000
#> SRR944335     1  0.0290      0.975 0.992 0.000 0.000 0.008 0.000
#> SRR944336     1  0.0290      0.975 0.992 0.000 0.000 0.008 0.000
#> SRR944337     1  0.0290      0.975 0.992 0.000 0.000 0.008 0.000
#> SRR944338     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR944339     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR944340     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR944341     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR944342     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR944343     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR944344     5  0.3074      0.000 0.000 0.000 0.196 0.000 0.804

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR944282     1   0.000      0.979 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944283     1   0.000      0.979 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944284     1   0.000      0.979 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944285     1   0.000      0.979 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944288     1   0.000      0.979 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944287     1   0.000      0.979 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944289     1   0.101      0.948 0.956 0.000 0.000 0.000 0.044 0.000
#> SRR944290     1   0.000      0.979 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944291     1   0.000      0.979 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944292     5   0.191      0.000 0.000 0.000 0.000 0.000 0.892 0.108
#> SRR944293     1   0.000      0.979 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944294     1   0.000      0.979 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944295     2   0.000      0.963 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944296     2   0.000      0.963 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944297     2   0.000      0.963 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944298     2   0.000      0.963 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944299     1   0.000      0.979 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944300     1   0.000      0.979 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944301     1   0.000      0.979 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944302     6   0.000      0.000 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR944303     2   0.000      0.963 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944304     1   0.000      0.979 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944305     1   0.000      0.979 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944306     1   0.000      0.979 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944307     1   0.000      0.979 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944308     1   0.000      0.979 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944309     1   0.000      0.979 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944310     1   0.000      0.979 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944311     2   0.000      0.963 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944312     1   0.000      0.979 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944313     1   0.000      0.979 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944315     1   0.000      0.979 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944314     1   0.000      0.979 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944316     1   0.000      0.979 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944317     2   0.156      0.943 0.000 0.920 0.000 0.000 0.080 0.000
#> SRR944318     2   0.156      0.943 0.000 0.920 0.000 0.000 0.080 0.000
#> SRR944319     2   0.217      0.919 0.000 0.884 0.000 0.008 0.108 0.000
#> SRR944320     2   0.156      0.943 0.000 0.920 0.000 0.000 0.080 0.000
#> SRR944321     1   0.000      0.979 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944322     1   0.000      0.979 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944323     1   0.000      0.979 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944324     1   0.000      0.979 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944325     1   0.000      0.979 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944326     1   0.000      0.979 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944327     1   0.000      0.979 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944328     1   0.000      0.979 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944329     1   0.218      0.870 0.868 0.000 0.000 0.000 0.132 0.000
#> SRR944330     1   0.218      0.870 0.868 0.000 0.000 0.000 0.132 0.000
#> SRR944331     1   0.218      0.870 0.868 0.000 0.000 0.000 0.132 0.000
#> SRR944332     1   0.218      0.870 0.868 0.000 0.000 0.000 0.132 0.000
#> SRR944334     1   0.218      0.870 0.868 0.000 0.000 0.000 0.132 0.000
#> SRR944333     1   0.218      0.870 0.868 0.000 0.000 0.000 0.132 0.000
#> SRR944335     1   0.026      0.974 0.992 0.000 0.000 0.000 0.008 0.000
#> SRR944336     1   0.026      0.974 0.992 0.000 0.000 0.000 0.008 0.000
#> SRR944337     1   0.026      0.974 0.992 0.000 0.000 0.000 0.008 0.000
#> SRR944338     3   0.000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR944339     3   0.000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR944340     3   0.000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR944341     3   0.000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR944342     3   0.000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR944343     3   0.000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR944344     4   0.026      0.000 0.000 0.000 0.008 0.992 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 12673 rows and 62 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#>   Subgroups are detected by 'kmeans' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 3.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk ATC-kmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.837           0.906       0.929         0.3559 0.568   0.568
#> 3 3 0.783           0.968       0.954         0.4007 0.952   0.916
#> 4 4 0.640           0.756       0.829         0.2543 0.814   0.642
#> 5 5 0.599           0.688       0.700         0.1386 0.827   0.520
#> 6 6 0.730           0.781       0.816         0.0735 0.965   0.843

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
#> SRR944282     1   0.000      1.000 1.000 0.000
#> SRR944283     1   0.000      1.000 1.000 0.000
#> SRR944284     1   0.000      1.000 1.000 0.000
#> SRR944285     1   0.000      1.000 1.000 0.000
#> SRR944288     1   0.000      1.000 1.000 0.000
#> SRR944287     1   0.000      1.000 1.000 0.000
#> SRR944289     1   0.000      1.000 1.000 0.000
#> SRR944290     1   0.000      1.000 1.000 0.000
#> SRR944291     1   0.000      1.000 1.000 0.000
#> SRR944292     2   1.000      0.452 0.496 0.504
#> SRR944293     1   0.000      1.000 1.000 0.000
#> SRR944294     1   0.000      1.000 1.000 0.000
#> SRR944295     2   0.388      0.789 0.076 0.924
#> SRR944296     2   0.388      0.789 0.076 0.924
#> SRR944297     2   0.388      0.789 0.076 0.924
#> SRR944298     2   0.388      0.789 0.076 0.924
#> SRR944299     1   0.000      1.000 1.000 0.000
#> SRR944300     1   0.000      1.000 1.000 0.000
#> SRR944301     1   0.000      1.000 1.000 0.000
#> SRR944302     2   0.996      0.527 0.464 0.536
#> SRR944303     2   0.388      0.789 0.076 0.924
#> SRR944304     1   0.000      1.000 1.000 0.000
#> SRR944305     1   0.000      1.000 1.000 0.000
#> SRR944306     1   0.000      1.000 1.000 0.000
#> SRR944307     1   0.000      1.000 1.000 0.000
#> SRR944308     1   0.000      1.000 1.000 0.000
#> SRR944309     1   0.000      1.000 1.000 0.000
#> SRR944310     1   0.000      1.000 1.000 0.000
#> SRR944311     2   0.388      0.789 0.076 0.924
#> SRR944312     1   0.000      1.000 1.000 0.000
#> SRR944313     1   0.000      1.000 1.000 0.000
#> SRR944315     1   0.000      1.000 1.000 0.000
#> SRR944314     1   0.000      1.000 1.000 0.000
#> SRR944316     1   0.000      1.000 1.000 0.000
#> SRR944317     2   0.388      0.789 0.076 0.924
#> SRR944318     2   0.388      0.789 0.076 0.924
#> SRR944319     2   0.388      0.789 0.076 0.924
#> SRR944320     2   0.388      0.789 0.076 0.924
#> SRR944321     1   0.000      1.000 1.000 0.000
#> SRR944322     1   0.000      1.000 1.000 0.000
#> SRR944323     1   0.000      1.000 1.000 0.000
#> SRR944324     1   0.000      1.000 1.000 0.000
#> SRR944325     1   0.000      1.000 1.000 0.000
#> SRR944326     1   0.000      1.000 1.000 0.000
#> SRR944327     1   0.000      1.000 1.000 0.000
#> SRR944328     1   0.000      1.000 1.000 0.000
#> SRR944329     1   0.000      1.000 1.000 0.000
#> SRR944330     1   0.000      1.000 1.000 0.000
#> SRR944331     1   0.000      1.000 1.000 0.000
#> SRR944332     1   0.000      1.000 1.000 0.000
#> SRR944334     1   0.000      1.000 1.000 0.000
#> SRR944333     1   0.000      1.000 1.000 0.000
#> SRR944335     1   0.000      1.000 1.000 0.000
#> SRR944336     1   0.000      1.000 1.000 0.000
#> SRR944337     1   0.000      1.000 1.000 0.000
#> SRR944338     2   0.971      0.610 0.400 0.600
#> SRR944339     2   0.981      0.576 0.420 0.580
#> SRR944340     2   0.975      0.598 0.408 0.592
#> SRR944341     2   0.971      0.610 0.400 0.600
#> SRR944342     2   0.971      0.610 0.400 0.600
#> SRR944343     2   0.971      0.610 0.400 0.600
#> SRR944344     2   0.802      0.714 0.244 0.756

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> SRR944282     1  0.0000      0.967 1.000 0.000 0.000
#> SRR944283     1  0.0000      0.967 1.000 0.000 0.000
#> SRR944284     1  0.0000      0.967 1.000 0.000 0.000
#> SRR944285     1  0.0000      0.967 1.000 0.000 0.000
#> SRR944288     1  0.0000      0.967 1.000 0.000 0.000
#> SRR944287     1  0.0237      0.966 0.996 0.004 0.000
#> SRR944289     1  0.3539      0.919 0.888 0.100 0.012
#> SRR944290     1  0.0000      0.967 1.000 0.000 0.000
#> SRR944291     1  0.0000      0.967 1.000 0.000 0.000
#> SRR944292     3  0.0424      0.994 0.008 0.000 0.992
#> SRR944293     1  0.0000      0.967 1.000 0.000 0.000
#> SRR944294     1  0.0000      0.967 1.000 0.000 0.000
#> SRR944295     2  0.3412      1.000 0.000 0.876 0.124
#> SRR944296     2  0.3412      1.000 0.000 0.876 0.124
#> SRR944297     2  0.3412      1.000 0.000 0.876 0.124
#> SRR944298     2  0.3412      1.000 0.000 0.876 0.124
#> SRR944299     1  0.1529      0.964 0.960 0.040 0.000
#> SRR944300     1  0.1529      0.964 0.960 0.040 0.000
#> SRR944301     1  0.0000      0.967 1.000 0.000 0.000
#> SRR944302     3  0.0661      0.998 0.008 0.004 0.988
#> SRR944303     2  0.3412      1.000 0.000 0.876 0.124
#> SRR944304     1  0.0747      0.965 0.984 0.016 0.000
#> SRR944305     1  0.1529      0.964 0.960 0.040 0.000
#> SRR944306     1  0.1289      0.966 0.968 0.032 0.000
#> SRR944307     1  0.1529      0.964 0.960 0.040 0.000
#> SRR944308     1  0.0000      0.967 1.000 0.000 0.000
#> SRR944309     1  0.1031      0.964 0.976 0.024 0.000
#> SRR944310     1  0.0000      0.967 1.000 0.000 0.000
#> SRR944311     2  0.3412      1.000 0.000 0.876 0.124
#> SRR944312     1  0.1031      0.964 0.976 0.024 0.000
#> SRR944313     1  0.0892      0.965 0.980 0.020 0.000
#> SRR944315     1  0.0000      0.967 1.000 0.000 0.000
#> SRR944314     1  0.1031      0.964 0.976 0.024 0.000
#> SRR944316     1  0.0000      0.967 1.000 0.000 0.000
#> SRR944317     2  0.3412      1.000 0.000 0.876 0.124
#> SRR944318     2  0.3412      1.000 0.000 0.876 0.124
#> SRR944319     2  0.3412      1.000 0.000 0.876 0.124
#> SRR944320     2  0.3412      1.000 0.000 0.876 0.124
#> SRR944321     1  0.1529      0.964 0.960 0.040 0.000
#> SRR944322     1  0.1529      0.964 0.960 0.040 0.000
#> SRR944323     1  0.1529      0.964 0.960 0.040 0.000
#> SRR944324     1  0.1529      0.964 0.960 0.040 0.000
#> SRR944325     1  0.1529      0.964 0.960 0.040 0.000
#> SRR944326     1  0.1529      0.964 0.960 0.040 0.000
#> SRR944327     1  0.1031      0.964 0.976 0.024 0.000
#> SRR944328     1  0.1031      0.964 0.976 0.024 0.000
#> SRR944329     1  0.3539      0.919 0.888 0.100 0.012
#> SRR944330     1  0.3539      0.919 0.888 0.100 0.012
#> SRR944331     1  0.3539      0.919 0.888 0.100 0.012
#> SRR944332     1  0.3539      0.919 0.888 0.100 0.012
#> SRR944334     1  0.3539      0.919 0.888 0.100 0.012
#> SRR944333     1  0.3539      0.919 0.888 0.100 0.012
#> SRR944335     1  0.3213      0.926 0.900 0.092 0.008
#> SRR944336     1  0.3213      0.926 0.900 0.092 0.008
#> SRR944337     1  0.3213      0.926 0.900 0.092 0.008
#> SRR944338     3  0.0661      0.998 0.008 0.004 0.988
#> SRR944339     3  0.0661      0.998 0.008 0.004 0.988
#> SRR944340     3  0.0661      0.998 0.008 0.004 0.988
#> SRR944341     3  0.0661      0.998 0.008 0.004 0.988
#> SRR944342     3  0.0661      0.998 0.008 0.004 0.988
#> SRR944343     3  0.0661      0.998 0.008 0.004 0.988
#> SRR944344     3  0.0661      0.992 0.004 0.008 0.988

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> SRR944282     1  0.4999      0.767 0.660 0.000 0.012 0.328
#> SRR944283     1  0.5093      0.744 0.640 0.000 0.012 0.348
#> SRR944284     1  0.5093      0.744 0.640 0.000 0.012 0.348
#> SRR944285     1  0.5093      0.744 0.640 0.000 0.012 0.348
#> SRR944288     1  0.5174      0.725 0.620 0.000 0.012 0.368
#> SRR944287     1  0.5075      0.746 0.644 0.000 0.012 0.344
#> SRR944289     4  0.0524      0.786 0.008 0.000 0.004 0.988
#> SRR944290     4  0.5408     -0.684 0.488 0.000 0.012 0.500
#> SRR944291     1  0.5093      0.744 0.640 0.000 0.012 0.348
#> SRR944292     3  0.6840      0.672 0.308 0.032 0.600 0.060
#> SRR944293     1  0.5174      0.725 0.620 0.000 0.012 0.368
#> SRR944294     1  0.5174      0.725 0.620 0.000 0.012 0.368
#> SRR944295     2  0.0000      0.974 0.000 1.000 0.000 0.000
#> SRR944296     2  0.0000      0.974 0.000 1.000 0.000 0.000
#> SRR944297     2  0.0000      0.974 0.000 1.000 0.000 0.000
#> SRR944298     2  0.0000      0.974 0.000 1.000 0.000 0.000
#> SRR944299     1  0.5320      0.690 0.572 0.000 0.012 0.416
#> SRR944300     1  0.5320      0.690 0.572 0.000 0.012 0.416
#> SRR944301     1  0.5038      0.765 0.652 0.000 0.012 0.336
#> SRR944302     3  0.5885      0.722 0.304 0.036 0.648 0.012
#> SRR944303     2  0.0000      0.974 0.000 1.000 0.000 0.000
#> SRR944304     1  0.5244      0.687 0.556 0.000 0.008 0.436
#> SRR944305     1  0.5320      0.690 0.572 0.000 0.012 0.416
#> SRR944306     1  0.5337      0.688 0.564 0.000 0.012 0.424
#> SRR944307     1  0.5279      0.687 0.588 0.000 0.012 0.400
#> SRR944308     1  0.5174      0.725 0.620 0.000 0.012 0.368
#> SRR944309     1  0.4428      0.762 0.720 0.000 0.004 0.276
#> SRR944310     1  0.5174      0.725 0.620 0.000 0.012 0.368
#> SRR944311     2  0.0000      0.974 0.000 1.000 0.000 0.000
#> SRR944312     1  0.4356      0.767 0.708 0.000 0.000 0.292
#> SRR944313     1  0.4868      0.769 0.684 0.000 0.012 0.304
#> SRR944315     1  0.5189      0.750 0.616 0.000 0.012 0.372
#> SRR944314     1  0.4313      0.754 0.736 0.000 0.004 0.260
#> SRR944316     1  0.5174      0.725 0.620 0.000 0.012 0.368
#> SRR944317     2  0.1867      0.960 0.072 0.928 0.000 0.000
#> SRR944318     2  0.1867      0.960 0.072 0.928 0.000 0.000
#> SRR944319     2  0.2271      0.954 0.076 0.916 0.000 0.008
#> SRR944320     2  0.1867      0.960 0.072 0.928 0.000 0.000
#> SRR944321     1  0.5339      0.677 0.600 0.000 0.016 0.384
#> SRR944322     1  0.5339      0.677 0.600 0.000 0.016 0.384
#> SRR944323     1  0.5339      0.677 0.600 0.000 0.016 0.384
#> SRR944324     1  0.5339      0.677 0.600 0.000 0.016 0.384
#> SRR944325     1  0.5339      0.677 0.600 0.000 0.016 0.384
#> SRR944326     1  0.5339      0.677 0.600 0.000 0.016 0.384
#> SRR944327     1  0.4690      0.748 0.724 0.000 0.016 0.260
#> SRR944328     1  0.4516      0.749 0.736 0.000 0.012 0.252
#> SRR944329     4  0.0657      0.771 0.012 0.000 0.004 0.984
#> SRR944330     4  0.0657      0.771 0.012 0.000 0.004 0.984
#> SRR944331     4  0.0524      0.786 0.008 0.000 0.004 0.988
#> SRR944332     4  0.0524      0.786 0.008 0.000 0.004 0.988
#> SRR944334     4  0.0524      0.786 0.008 0.000 0.004 0.988
#> SRR944333     4  0.0524      0.786 0.008 0.000 0.004 0.988
#> SRR944335     4  0.3801      0.508 0.220 0.000 0.000 0.780
#> SRR944336     4  0.3649      0.523 0.204 0.000 0.000 0.796
#> SRR944337     4  0.4193      0.434 0.268 0.000 0.000 0.732
#> SRR944338     3  0.1118      0.922 0.000 0.036 0.964 0.000
#> SRR944339     3  0.1118      0.922 0.000 0.036 0.964 0.000
#> SRR944340     3  0.1118      0.922 0.000 0.036 0.964 0.000
#> SRR944341     3  0.1118      0.922 0.000 0.036 0.964 0.000
#> SRR944342     3  0.1118      0.922 0.000 0.036 0.964 0.000
#> SRR944343     3  0.1118      0.922 0.000 0.036 0.964 0.000
#> SRR944344     3  0.1118      0.922 0.000 0.036 0.964 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
#> SRR944282     1  0.2732      0.544 0.840 0.000 0.000 0.000 0.160
#> SRR944283     1  0.0609      0.705 0.980 0.000 0.000 0.000 0.020
#> SRR944284     1  0.0609      0.705 0.980 0.000 0.000 0.000 0.020
#> SRR944285     1  0.0510      0.706 0.984 0.000 0.000 0.000 0.016
#> SRR944288     1  0.0162      0.706 0.996 0.000 0.000 0.004 0.000
#> SRR944287     1  0.0510      0.698 0.984 0.000 0.000 0.000 0.016
#> SRR944289     4  0.3409      0.868 0.160 0.000 0.000 0.816 0.024
#> SRR944290     1  0.3602      0.478 0.796 0.000 0.000 0.024 0.180
#> SRR944291     1  0.0703      0.703 0.976 0.000 0.000 0.000 0.024
#> SRR944292     1  0.8408     -0.246 0.360 0.008 0.192 0.132 0.308
#> SRR944293     1  0.0162      0.706 0.996 0.000 0.000 0.004 0.000
#> SRR944294     1  0.0162      0.706 0.996 0.000 0.000 0.004 0.000
#> SRR944295     2  0.0000      0.956 0.000 1.000 0.000 0.000 0.000
#> SRR944296     2  0.0000      0.956 0.000 1.000 0.000 0.000 0.000
#> SRR944297     2  0.0000      0.956 0.000 1.000 0.000 0.000 0.000
#> SRR944298     2  0.0000      0.956 0.000 1.000 0.000 0.000 0.000
#> SRR944299     5  0.5699      0.727 0.436 0.000 0.008 0.060 0.496
#> SRR944300     5  0.5699      0.727 0.436 0.000 0.008 0.060 0.496
#> SRR944301     1  0.2561      0.573 0.856 0.000 0.000 0.000 0.144
#> SRR944302     5  0.8526     -0.446 0.288 0.008 0.268 0.124 0.312
#> SRR944303     2  0.0000      0.956 0.000 1.000 0.000 0.000 0.000
#> SRR944304     1  0.5710     -0.692 0.468 0.000 0.008 0.060 0.464
#> SRR944305     5  0.5699      0.727 0.436 0.000 0.008 0.060 0.496
#> SRR944306     5  0.5706      0.704 0.448 0.000 0.008 0.060 0.484
#> SRR944307     5  0.5666      0.747 0.408 0.000 0.008 0.060 0.524
#> SRR944308     1  0.0162      0.706 0.996 0.000 0.000 0.004 0.000
#> SRR944309     1  0.4297     -0.634 0.528 0.000 0.000 0.000 0.472
#> SRR944310     1  0.0162      0.706 0.996 0.000 0.000 0.004 0.000
#> SRR944311     2  0.0000      0.956 0.000 1.000 0.000 0.000 0.000
#> SRR944312     1  0.4114     -0.298 0.624 0.000 0.000 0.000 0.376
#> SRR944313     1  0.3534      0.274 0.744 0.000 0.000 0.000 0.256
#> SRR944315     1  0.2377      0.596 0.872 0.000 0.000 0.000 0.128
#> SRR944314     5  0.4306      0.660 0.492 0.000 0.000 0.000 0.508
#> SRR944316     1  0.0162      0.706 0.996 0.000 0.000 0.004 0.000
#> SRR944317     2  0.2574      0.933 0.000 0.876 0.000 0.012 0.112
#> SRR944318     2  0.2574      0.933 0.000 0.876 0.000 0.012 0.112
#> SRR944319     2  0.2624      0.931 0.000 0.872 0.000 0.012 0.116
#> SRR944320     2  0.2574      0.933 0.000 0.876 0.000 0.012 0.112
#> SRR944321     5  0.5288      0.778 0.404 0.000 0.000 0.052 0.544
#> SRR944322     5  0.5288      0.778 0.404 0.000 0.000 0.052 0.544
#> SRR944323     5  0.5288      0.778 0.404 0.000 0.000 0.052 0.544
#> SRR944324     5  0.5288      0.778 0.404 0.000 0.000 0.052 0.544
#> SRR944325     5  0.5288      0.778 0.404 0.000 0.000 0.052 0.544
#> SRR944326     5  0.5288      0.778 0.404 0.000 0.000 0.052 0.544
#> SRR944327     5  0.4425      0.700 0.452 0.000 0.000 0.004 0.544
#> SRR944328     5  0.4437      0.680 0.464 0.000 0.000 0.004 0.532
#> SRR944329     4  0.2732      0.873 0.160 0.000 0.000 0.840 0.000
#> SRR944330     4  0.2732      0.873 0.160 0.000 0.000 0.840 0.000
#> SRR944331     4  0.2848      0.876 0.156 0.000 0.000 0.840 0.004
#> SRR944332     4  0.2848      0.876 0.156 0.000 0.000 0.840 0.004
#> SRR944334     4  0.2848      0.876 0.156 0.000 0.000 0.840 0.004
#> SRR944333     4  0.2848      0.876 0.156 0.000 0.000 0.840 0.004
#> SRR944335     4  0.6278      0.641 0.228 0.000 0.004 0.560 0.208
#> SRR944336     4  0.6272      0.650 0.236 0.000 0.004 0.560 0.200
#> SRR944337     4  0.6209      0.581 0.168 0.000 0.004 0.560 0.268
#> SRR944338     3  0.0290      0.998 0.000 0.008 0.992 0.000 0.000
#> SRR944339     3  0.0290      0.998 0.000 0.008 0.992 0.000 0.000
#> SRR944340     3  0.0290      0.998 0.000 0.008 0.992 0.000 0.000
#> SRR944341     3  0.0290      0.998 0.000 0.008 0.992 0.000 0.000
#> SRR944342     3  0.0290      0.998 0.000 0.008 0.992 0.000 0.000
#> SRR944343     3  0.0290      0.998 0.000 0.008 0.992 0.000 0.000
#> SRR944344     3  0.0798      0.989 0.000 0.008 0.976 0.016 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
#> SRR944282     1  0.2119      0.806 0.904 0.000 0.000 0.000 0.036 0.060
#> SRR944283     1  0.0547      0.848 0.980 0.000 0.000 0.000 0.000 0.020
#> SRR944284     1  0.0547      0.848 0.980 0.000 0.000 0.000 0.000 0.020
#> SRR944285     1  0.0000      0.850 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR944288     1  0.0291      0.849 0.992 0.000 0.000 0.004 0.004 0.000
#> SRR944287     1  0.0146      0.850 0.996 0.000 0.000 0.000 0.004 0.000
#> SRR944289     4  0.3169      0.773 0.052 0.000 0.000 0.848 0.084 0.016
#> SRR944290     1  0.3439      0.708 0.808 0.000 0.000 0.000 0.120 0.072
#> SRR944291     1  0.1176      0.840 0.956 0.000 0.000 0.000 0.024 0.020
#> SRR944292     5  0.4398      0.908 0.220 0.000 0.060 0.004 0.712 0.004
#> SRR944293     1  0.0291      0.849 0.992 0.000 0.000 0.004 0.004 0.000
#> SRR944294     1  0.0291      0.849 0.992 0.000 0.000 0.004 0.004 0.000
#> SRR944295     2  0.0000      0.891 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944296     2  0.0000      0.891 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944297     2  0.0000      0.891 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944298     2  0.0000      0.891 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944299     6  0.6226      0.715 0.288 0.000 0.000 0.032 0.172 0.508
#> SRR944300     6  0.6226      0.715 0.288 0.000 0.000 0.032 0.172 0.508
#> SRR944301     1  0.3078      0.741 0.836 0.000 0.000 0.000 0.108 0.056
#> SRR944302     5  0.4319      0.902 0.168 0.000 0.108 0.000 0.724 0.000
#> SRR944303     2  0.0260      0.891 0.000 0.992 0.000 0.008 0.000 0.000
#> SRR944304     6  0.6302      0.682 0.316 0.000 0.000 0.032 0.172 0.480
#> SRR944305     6  0.6226      0.715 0.288 0.000 0.000 0.032 0.172 0.508
#> SRR944306     6  0.6226      0.715 0.288 0.000 0.000 0.032 0.172 0.508
#> SRR944307     6  0.6213      0.717 0.284 0.000 0.000 0.032 0.172 0.512
#> SRR944308     1  0.0291      0.849 0.992 0.000 0.000 0.004 0.004 0.000
#> SRR944309     1  0.5658     -0.588 0.432 0.000 0.000 0.000 0.152 0.416
#> SRR944310     1  0.0291      0.849 0.992 0.000 0.000 0.004 0.004 0.000
#> SRR944311     2  0.0260      0.891 0.000 0.992 0.000 0.008 0.000 0.000
#> SRR944312     1  0.4746      0.333 0.668 0.000 0.000 0.000 0.116 0.216
#> SRR944313     1  0.3352      0.713 0.816 0.000 0.000 0.000 0.112 0.072
#> SRR944315     1  0.1995      0.812 0.912 0.000 0.000 0.000 0.036 0.052
#> SRR944314     6  0.4381      0.590 0.440 0.000 0.000 0.000 0.024 0.536
#> SRR944316     1  0.0291      0.849 0.992 0.000 0.000 0.004 0.004 0.000
#> SRR944317     2  0.4264      0.832 0.000 0.752 0.000 0.012 0.088 0.148
#> SRR944318     2  0.4264      0.832 0.000 0.752 0.000 0.012 0.088 0.148
#> SRR944319     2  0.4428      0.821 0.000 0.736 0.000 0.012 0.096 0.156
#> SRR944320     2  0.4264      0.832 0.000 0.752 0.000 0.012 0.088 0.148
#> SRR944321     6  0.3734      0.780 0.264 0.000 0.000 0.020 0.000 0.716
#> SRR944322     6  0.3734      0.780 0.264 0.000 0.000 0.020 0.000 0.716
#> SRR944323     6  0.3734      0.780 0.264 0.000 0.000 0.020 0.000 0.716
#> SRR944324     6  0.3734      0.780 0.264 0.000 0.000 0.020 0.000 0.716
#> SRR944325     6  0.3734      0.780 0.264 0.000 0.000 0.020 0.000 0.716
#> SRR944326     6  0.3734      0.780 0.264 0.000 0.000 0.020 0.000 0.716
#> SRR944327     6  0.3383      0.740 0.268 0.000 0.000 0.004 0.000 0.728
#> SRR944328     6  0.3984      0.535 0.396 0.000 0.000 0.008 0.000 0.596
#> SRR944329     4  0.1333      0.811 0.048 0.000 0.000 0.944 0.000 0.008
#> SRR944330     4  0.1333      0.811 0.048 0.000 0.000 0.944 0.000 0.008
#> SRR944331     4  0.1075      0.815 0.048 0.000 0.000 0.952 0.000 0.000
#> SRR944332     4  0.1075      0.815 0.048 0.000 0.000 0.952 0.000 0.000
#> SRR944334     4  0.1075      0.815 0.048 0.000 0.000 0.952 0.000 0.000
#> SRR944333     4  0.1075      0.815 0.048 0.000 0.000 0.952 0.000 0.000
#> SRR944335     4  0.6177      0.591 0.096 0.000 0.000 0.588 0.112 0.204
#> SRR944336     4  0.6177      0.591 0.096 0.000 0.000 0.588 0.112 0.204
#> SRR944337     4  0.6140      0.577 0.088 0.000 0.000 0.588 0.112 0.212
#> SRR944338     3  0.0000      0.989 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR944339     3  0.0000      0.989 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR944340     3  0.0000      0.989 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR944341     3  0.0000      0.989 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR944342     3  0.0000      0.989 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR944343     3  0.0000      0.989 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR944344     3  0.1767      0.932 0.000 0.000 0.932 0.020 0.012 0.036

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 12673 rows and 62 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.996       0.998         0.4544 0.545   0.545
#> 3 3 1.000           0.970       0.980         0.3126 0.832   0.696
#> 4 4 1.000           0.972       0.986         0.0856 0.952   0.879
#> 5 5 0.754           0.780       0.870         0.1667 0.878   0.648
#> 6 6 0.734           0.559       0.754         0.0548 0.947   0.769

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> SRR944282     1   0.000      1.000 1.000 0.000
#> SRR944283     1   0.000      1.000 1.000 0.000
#> SRR944284     1   0.000      1.000 1.000 0.000
#> SRR944285     1   0.000      1.000 1.000 0.000
#> SRR944288     1   0.000      1.000 1.000 0.000
#> SRR944287     1   0.000      1.000 1.000 0.000
#> SRR944289     1   0.000      1.000 1.000 0.000
#> SRR944290     1   0.000      1.000 1.000 0.000
#> SRR944291     1   0.000      1.000 1.000 0.000
#> SRR944292     2   0.000      0.994 0.000 1.000
#> SRR944293     1   0.000      1.000 1.000 0.000
#> SRR944294     1   0.000      1.000 1.000 0.000
#> SRR944295     2   0.000      0.994 0.000 1.000
#> SRR944296     2   0.000      0.994 0.000 1.000
#> SRR944297     2   0.000      0.994 0.000 1.000
#> SRR944298     2   0.000      0.994 0.000 1.000
#> SRR944299     1   0.000      1.000 1.000 0.000
#> SRR944300     1   0.000      1.000 1.000 0.000
#> SRR944301     1   0.000      1.000 1.000 0.000
#> SRR944302     2   0.000      0.994 0.000 1.000
#> SRR944303     2   0.000      0.994 0.000 1.000
#> SRR944304     1   0.000      1.000 1.000 0.000
#> SRR944305     1   0.000      1.000 1.000 0.000
#> SRR944306     1   0.000      1.000 1.000 0.000
#> SRR944307     1   0.000      1.000 1.000 0.000
#> SRR944308     1   0.000      1.000 1.000 0.000
#> SRR944309     1   0.000      1.000 1.000 0.000
#> SRR944310     1   0.000      1.000 1.000 0.000
#> SRR944311     2   0.000      0.994 0.000 1.000
#> SRR944312     1   0.000      1.000 1.000 0.000
#> SRR944313     1   0.000      1.000 1.000 0.000
#> SRR944315     1   0.000      1.000 1.000 0.000
#> SRR944314     1   0.000      1.000 1.000 0.000
#> SRR944316     1   0.000      1.000 1.000 0.000
#> SRR944317     2   0.000      0.994 0.000 1.000
#> SRR944318     2   0.000      0.994 0.000 1.000
#> SRR944319     2   0.000      0.994 0.000 1.000
#> SRR944320     2   0.000      0.994 0.000 1.000
#> SRR944321     1   0.000      1.000 1.000 0.000
#> SRR944322     1   0.000      1.000 1.000 0.000
#> SRR944323     1   0.000      1.000 1.000 0.000
#> SRR944324     1   0.000      1.000 1.000 0.000
#> SRR944325     1   0.000      1.000 1.000 0.000
#> SRR944326     1   0.000      1.000 1.000 0.000
#> SRR944327     1   0.000      1.000 1.000 0.000
#> SRR944328     1   0.000      1.000 1.000 0.000
#> SRR944329     2   0.343      0.935 0.064 0.936
#> SRR944330     2   0.343      0.935 0.064 0.936
#> SRR944331     1   0.000      1.000 1.000 0.000
#> SRR944332     1   0.000      1.000 1.000 0.000
#> SRR944334     1   0.000      1.000 1.000 0.000
#> SRR944333     1   0.000      1.000 1.000 0.000
#> SRR944335     1   0.000      1.000 1.000 0.000
#> SRR944336     1   0.000      1.000 1.000 0.000
#> SRR944337     1   0.000      1.000 1.000 0.000
#> SRR944338     2   0.000      0.994 0.000 1.000
#> SRR944339     2   0.000      0.994 0.000 1.000
#> SRR944340     2   0.000      0.994 0.000 1.000
#> SRR944341     2   0.000      0.994 0.000 1.000
#> SRR944342     2   0.000      0.994 0.000 1.000
#> SRR944343     2   0.000      0.994 0.000 1.000
#> SRR944344     2   0.000      0.994 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
#> SRR944282     1  0.0000      1.000 1.000 0.00 0.000
#> SRR944283     1  0.0000      1.000 1.000 0.00 0.000
#> SRR944284     1  0.0000      1.000 1.000 0.00 0.000
#> SRR944285     1  0.0000      1.000 1.000 0.00 0.000
#> SRR944288     1  0.0000      1.000 1.000 0.00 0.000
#> SRR944287     1  0.0000      1.000 1.000 0.00 0.000
#> SRR944289     3  0.1529      0.888 0.040 0.00 0.960
#> SRR944290     1  0.0000      1.000 1.000 0.00 0.000
#> SRR944291     1  0.0000      1.000 1.000 0.00 0.000
#> SRR944292     2  0.0000      0.980 0.000 1.00 0.000
#> SRR944293     1  0.0000      1.000 1.000 0.00 0.000
#> SRR944294     1  0.0000      1.000 1.000 0.00 0.000
#> SRR944295     2  0.1529      0.982 0.000 0.96 0.040
#> SRR944296     2  0.1529      0.982 0.000 0.96 0.040
#> SRR944297     2  0.1529      0.982 0.000 0.96 0.040
#> SRR944298     2  0.1529      0.982 0.000 0.96 0.040
#> SRR944299     1  0.0000      1.000 1.000 0.00 0.000
#> SRR944300     1  0.0000      1.000 1.000 0.00 0.000
#> SRR944301     1  0.0000      1.000 1.000 0.00 0.000
#> SRR944302     2  0.0000      0.980 0.000 1.00 0.000
#> SRR944303     2  0.1529      0.982 0.000 0.96 0.040
#> SRR944304     1  0.0592      0.986 0.988 0.00 0.012
#> SRR944305     1  0.0000      1.000 1.000 0.00 0.000
#> SRR944306     1  0.0000      1.000 1.000 0.00 0.000
#> SRR944307     1  0.0000      1.000 1.000 0.00 0.000
#> SRR944308     1  0.0000      1.000 1.000 0.00 0.000
#> SRR944309     1  0.0000      1.000 1.000 0.00 0.000
#> SRR944310     1  0.0000      1.000 1.000 0.00 0.000
#> SRR944311     2  0.1529      0.982 0.000 0.96 0.040
#> SRR944312     1  0.0000      1.000 1.000 0.00 0.000
#> SRR944313     1  0.0000      1.000 1.000 0.00 0.000
#> SRR944315     1  0.0000      1.000 1.000 0.00 0.000
#> SRR944314     1  0.0000      1.000 1.000 0.00 0.000
#> SRR944316     1  0.0000      1.000 1.000 0.00 0.000
#> SRR944317     2  0.1529      0.982 0.000 0.96 0.040
#> SRR944318     2  0.1529      0.982 0.000 0.96 0.040
#> SRR944319     2  0.1529      0.982 0.000 0.96 0.040
#> SRR944320     2  0.1529      0.982 0.000 0.96 0.040
#> SRR944321     1  0.0000      1.000 1.000 0.00 0.000
#> SRR944322     1  0.0000      1.000 1.000 0.00 0.000
#> SRR944323     1  0.0000      1.000 1.000 0.00 0.000
#> SRR944324     1  0.0000      1.000 1.000 0.00 0.000
#> SRR944325     1  0.0000      1.000 1.000 0.00 0.000
#> SRR944326     1  0.0000      1.000 1.000 0.00 0.000
#> SRR944327     1  0.0000      1.000 1.000 0.00 0.000
#> SRR944328     1  0.0000      1.000 1.000 0.00 0.000
#> SRR944329     3  0.0000      0.882 0.000 0.00 1.000
#> SRR944330     3  0.0000      0.882 0.000 0.00 1.000
#> SRR944331     3  0.0747      0.896 0.016 0.00 0.984
#> SRR944332     3  0.0747      0.896 0.016 0.00 0.984
#> SRR944334     3  0.0747      0.896 0.016 0.00 0.984
#> SRR944333     3  0.0747      0.896 0.016 0.00 0.984
#> SRR944335     3  0.5016      0.771 0.240 0.00 0.760
#> SRR944336     3  0.5016      0.771 0.240 0.00 0.760
#> SRR944337     3  0.5016      0.771 0.240 0.00 0.760
#> SRR944338     2  0.0000      0.980 0.000 1.00 0.000
#> SRR944339     2  0.0000      0.980 0.000 1.00 0.000
#> SRR944340     2  0.0000      0.980 0.000 1.00 0.000
#> SRR944341     2  0.0000      0.980 0.000 1.00 0.000
#> SRR944342     2  0.0000      0.980 0.000 1.00 0.000
#> SRR944343     2  0.0000      0.980 0.000 1.00 0.000
#> SRR944344     2  0.0000      0.980 0.000 1.00 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> SRR944282     1  0.0188      0.994 0.996 0.000 0.004 0.000
#> SRR944283     1  0.0336      0.993 0.992 0.000 0.008 0.000
#> SRR944284     1  0.0336      0.993 0.992 0.000 0.008 0.000
#> SRR944285     1  0.0188      0.994 0.996 0.000 0.004 0.000
#> SRR944288     1  0.0336      0.993 0.992 0.000 0.008 0.000
#> SRR944287     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> SRR944289     4  0.0188      0.895 0.000 0.000 0.004 0.996
#> SRR944290     1  0.0376      0.992 0.992 0.000 0.004 0.004
#> SRR944291     1  0.0188      0.994 0.996 0.000 0.004 0.000
#> SRR944292     3  0.0921      0.983 0.000 0.028 0.972 0.000
#> SRR944293     1  0.0336      0.993 0.992 0.000 0.008 0.000
#> SRR944294     1  0.0336      0.993 0.992 0.000 0.008 0.000
#> SRR944295     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR944296     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR944297     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR944298     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR944299     1  0.0376      0.992 0.992 0.000 0.004 0.004
#> SRR944300     1  0.0376      0.992 0.992 0.000 0.004 0.004
#> SRR944301     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> SRR944302     3  0.0469      0.998 0.000 0.012 0.988 0.000
#> SRR944303     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR944304     1  0.1109      0.968 0.968 0.000 0.004 0.028
#> SRR944305     1  0.0376      0.992 0.992 0.000 0.004 0.004
#> SRR944306     1  0.0524      0.989 0.988 0.000 0.004 0.008
#> SRR944307     1  0.0376      0.992 0.992 0.000 0.004 0.004
#> SRR944308     1  0.0188      0.994 0.996 0.000 0.004 0.000
#> SRR944309     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> SRR944310     1  0.0188      0.994 0.996 0.000 0.004 0.000
#> SRR944311     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR944312     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> SRR944313     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> SRR944315     1  0.0188      0.994 0.996 0.000 0.004 0.000
#> SRR944314     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> SRR944316     1  0.0188      0.994 0.996 0.000 0.004 0.000
#> SRR944317     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR944318     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR944319     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR944320     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR944321     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> SRR944322     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> SRR944323     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> SRR944324     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> SRR944325     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> SRR944326     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> SRR944327     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> SRR944328     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> SRR944329     4  0.0000      0.896 0.000 0.000 0.000 1.000
#> SRR944330     4  0.0000      0.896 0.000 0.000 0.000 1.000
#> SRR944331     4  0.0000      0.896 0.000 0.000 0.000 1.000
#> SRR944332     4  0.0000      0.896 0.000 0.000 0.000 1.000
#> SRR944334     4  0.0000      0.896 0.000 0.000 0.000 1.000
#> SRR944333     4  0.0000      0.896 0.000 0.000 0.000 1.000
#> SRR944335     4  0.3791      0.758 0.200 0.000 0.004 0.796
#> SRR944336     4  0.3791      0.758 0.200 0.000 0.004 0.796
#> SRR944337     4  0.3791      0.758 0.200 0.000 0.004 0.796
#> SRR944338     3  0.0469      0.998 0.000 0.012 0.988 0.000
#> SRR944339     3  0.0469      0.998 0.000 0.012 0.988 0.000
#> SRR944340     3  0.0469      0.998 0.000 0.012 0.988 0.000
#> SRR944341     3  0.0469      0.998 0.000 0.012 0.988 0.000
#> SRR944342     3  0.0469      0.998 0.000 0.012 0.988 0.000
#> SRR944343     3  0.0469      0.998 0.000 0.012 0.988 0.000
#> SRR944344     3  0.0469      0.998 0.000 0.012 0.988 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
#> SRR944282     1  0.4138      0.558 0.616 0.000 0.000 0.000 0.384
#> SRR944283     5  0.4088      0.343 0.368 0.000 0.000 0.000 0.632
#> SRR944284     5  0.3480      0.625 0.248 0.000 0.000 0.000 0.752
#> SRR944285     5  0.3612      0.612 0.268 0.000 0.000 0.000 0.732
#> SRR944288     5  0.1478      0.693 0.064 0.000 0.000 0.000 0.936
#> SRR944287     5  0.4276      0.478 0.380 0.000 0.000 0.004 0.616
#> SRR944289     4  0.1732      0.846 0.080 0.000 0.000 0.920 0.000
#> SRR944290     1  0.0794      0.673 0.972 0.000 0.000 0.000 0.028
#> SRR944291     1  0.4297      0.267 0.528 0.000 0.000 0.000 0.472
#> SRR944292     3  0.0510      0.984 0.000 0.016 0.984 0.000 0.000
#> SRR944293     5  0.1908      0.713 0.092 0.000 0.000 0.000 0.908
#> SRR944294     5  0.1792      0.713 0.084 0.000 0.000 0.000 0.916
#> SRR944295     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR944296     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR944297     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR944298     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR944299     1  0.0000      0.667 1.000 0.000 0.000 0.000 0.000
#> SRR944300     1  0.0000      0.667 1.000 0.000 0.000 0.000 0.000
#> SRR944301     1  0.3990      0.599 0.688 0.000 0.000 0.004 0.308
#> SRR944302     3  0.0290      0.991 0.000 0.008 0.992 0.000 0.000
#> SRR944303     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR944304     1  0.0404      0.655 0.988 0.000 0.000 0.012 0.000
#> SRR944305     1  0.0162      0.670 0.996 0.000 0.000 0.000 0.004
#> SRR944306     1  0.0000      0.667 1.000 0.000 0.000 0.000 0.000
#> SRR944307     1  0.0000      0.667 1.000 0.000 0.000 0.000 0.000
#> SRR944308     5  0.4251      0.498 0.372 0.000 0.000 0.004 0.624
#> SRR944309     1  0.3086      0.738 0.816 0.000 0.000 0.004 0.180
#> SRR944310     5  0.3861      0.592 0.284 0.000 0.000 0.004 0.712
#> SRR944311     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR944312     1  0.3196      0.734 0.804 0.000 0.000 0.004 0.192
#> SRR944313     1  0.3689      0.668 0.740 0.000 0.000 0.004 0.256
#> SRR944315     1  0.4383      0.452 0.572 0.000 0.000 0.004 0.424
#> SRR944314     1  0.3913      0.673 0.676 0.000 0.000 0.000 0.324
#> SRR944316     5  0.3010      0.706 0.172 0.000 0.000 0.004 0.824
#> SRR944317     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR944318     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR944319     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR944320     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> SRR944321     1  0.3480      0.752 0.752 0.000 0.000 0.000 0.248
#> SRR944322     1  0.3480      0.752 0.752 0.000 0.000 0.000 0.248
#> SRR944323     1  0.3480      0.752 0.752 0.000 0.000 0.000 0.248
#> SRR944324     1  0.3480      0.752 0.752 0.000 0.000 0.000 0.248
#> SRR944325     1  0.3480      0.752 0.752 0.000 0.000 0.000 0.248
#> SRR944326     1  0.3480      0.752 0.752 0.000 0.000 0.000 0.248
#> SRR944327     1  0.3586      0.741 0.736 0.000 0.000 0.000 0.264
#> SRR944328     1  0.3838      0.726 0.716 0.000 0.000 0.004 0.280
#> SRR944329     4  0.0162      0.868 0.000 0.004 0.000 0.996 0.000
#> SRR944330     4  0.0162      0.868 0.000 0.004 0.000 0.996 0.000
#> SRR944331     4  0.0162      0.871 0.004 0.000 0.000 0.996 0.000
#> SRR944332     4  0.0162      0.871 0.004 0.000 0.000 0.996 0.000
#> SRR944334     4  0.0162      0.871 0.004 0.000 0.000 0.996 0.000
#> SRR944333     4  0.0162      0.871 0.004 0.000 0.000 0.996 0.000
#> SRR944335     4  0.3876      0.671 0.316 0.000 0.000 0.684 0.000
#> SRR944336     4  0.3876      0.671 0.316 0.000 0.000 0.684 0.000
#> SRR944337     4  0.3876      0.671 0.316 0.000 0.000 0.684 0.000
#> SRR944338     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000
#> SRR944339     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000
#> SRR944340     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000
#> SRR944341     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000
#> SRR944342     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000
#> SRR944343     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000
#> SRR944344     3  0.0000      0.997 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
#> SRR944282     6  0.5699    0.25037 0.344 0.000 0.000 0.000 0.172 0.484
#> SRR944283     5  0.5560    0.05163 0.136 0.000 0.000 0.000 0.444 0.420
#> SRR944284     5  0.5230    0.31480 0.108 0.000 0.000 0.000 0.548 0.344
#> SRR944285     5  0.5728    0.18593 0.180 0.000 0.000 0.000 0.484 0.336
#> SRR944288     5  0.4466    0.46012 0.044 0.000 0.000 0.000 0.620 0.336
#> SRR944287     6  0.5995    0.06432 0.280 0.000 0.000 0.000 0.280 0.440
#> SRR944289     4  0.4459    0.71922 0.132 0.000 0.000 0.748 0.024 0.096
#> SRR944290     1  0.2709    0.38391 0.848 0.000 0.000 0.000 0.020 0.132
#> SRR944291     6  0.6088    0.27894 0.312 0.000 0.000 0.000 0.296 0.392
#> SRR944292     3  0.1887    0.94455 0.000 0.012 0.924 0.000 0.016 0.048
#> SRR944293     5  0.3394    0.53521 0.052 0.000 0.000 0.000 0.804 0.144
#> SRR944294     5  0.3240    0.53786 0.040 0.000 0.000 0.000 0.812 0.148
#> SRR944295     2  0.0000    1.00000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944296     2  0.0000    1.00000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944297     2  0.0000    1.00000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944298     2  0.0000    1.00000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944299     1  0.0547    0.41412 0.980 0.000 0.000 0.000 0.000 0.020
#> SRR944300     1  0.0363    0.41993 0.988 0.000 0.000 0.000 0.000 0.012
#> SRR944301     1  0.5609   -0.08461 0.496 0.000 0.000 0.000 0.156 0.348
#> SRR944302     3  0.1857    0.94366 0.000 0.028 0.928 0.000 0.012 0.032
#> SRR944303     2  0.0000    1.00000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944304     1  0.1605    0.36890 0.936 0.000 0.000 0.016 0.004 0.044
#> SRR944305     1  0.0291    0.42000 0.992 0.000 0.000 0.000 0.004 0.004
#> SRR944306     1  0.0458    0.41127 0.984 0.000 0.000 0.000 0.000 0.016
#> SRR944307     1  0.0146    0.42262 0.996 0.000 0.000 0.000 0.000 0.004
#> SRR944308     6  0.6101   -0.16418 0.340 0.000 0.000 0.000 0.288 0.372
#> SRR944309     1  0.3934    0.30725 0.676 0.000 0.000 0.000 0.020 0.304
#> SRR944310     5  0.5803    0.24772 0.184 0.000 0.000 0.000 0.444 0.372
#> SRR944311     2  0.0000    1.00000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944312     1  0.4152    0.30176 0.664 0.000 0.000 0.000 0.032 0.304
#> SRR944313     1  0.5081    0.13892 0.588 0.000 0.000 0.000 0.104 0.308
#> SRR944315     6  0.5799    0.24852 0.368 0.000 0.000 0.000 0.184 0.448
#> SRR944314     1  0.5071    0.00612 0.480 0.000 0.000 0.000 0.076 0.444
#> SRR944316     5  0.5185    0.41963 0.108 0.000 0.000 0.000 0.564 0.328
#> SRR944317     2  0.0000    1.00000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944318     2  0.0000    1.00000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944319     2  0.0000    1.00000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944320     2  0.0000    1.00000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944321     1  0.3847    0.26672 0.544 0.000 0.000 0.000 0.000 0.456
#> SRR944322     1  0.3847    0.26672 0.544 0.000 0.000 0.000 0.000 0.456
#> SRR944323     1  0.3847    0.26672 0.544 0.000 0.000 0.000 0.000 0.456
#> SRR944324     1  0.3847    0.26672 0.544 0.000 0.000 0.000 0.000 0.456
#> SRR944325     1  0.3847    0.26672 0.544 0.000 0.000 0.000 0.000 0.456
#> SRR944326     1  0.3847    0.26672 0.544 0.000 0.000 0.000 0.000 0.456
#> SRR944327     1  0.4469    0.13572 0.504 0.000 0.000 0.000 0.028 0.468
#> SRR944328     6  0.4620   -0.06482 0.428 0.000 0.000 0.000 0.040 0.532
#> SRR944329     4  0.0000    0.80458 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR944330     4  0.0000    0.80458 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR944331     4  0.0000    0.80458 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR944332     4  0.0000    0.80458 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR944334     4  0.0000    0.80458 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR944333     4  0.0000    0.80458 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR944335     4  0.5819    0.57037 0.332 0.000 0.000 0.528 0.024 0.116
#> SRR944336     4  0.5819    0.57037 0.332 0.000 0.000 0.528 0.024 0.116
#> SRR944337     4  0.5863    0.56012 0.336 0.000 0.000 0.520 0.024 0.120
#> SRR944338     3  0.0000    0.98530 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR944339     3  0.0000    0.98530 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR944340     3  0.0000    0.98530 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR944341     3  0.0000    0.98530 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR944342     3  0.0000    0.98530 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR944343     3  0.0000    0.98530 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR944344     3  0.0000    0.98530 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 12673 rows and 62 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#>   Subgroups are detected by 'pam' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 5.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk ATC-pam-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.989       0.995         0.2911 0.703   0.703
#> 3 3 1.000           0.987       0.995         0.5402 0.849   0.786
#> 4 4 0.915           0.906       0.945         0.4749 0.780   0.606
#> 5 5 0.938           0.910       0.965         0.1857 0.855   0.585
#> 6 6 0.903           0.849       0.939         0.0123 0.994   0.971

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> SRR944282     1   0.000      1.000 1.000 0.000
#> SRR944283     1   0.000      1.000 1.000 0.000
#> SRR944284     1   0.000      1.000 1.000 0.000
#> SRR944285     1   0.000      1.000 1.000 0.000
#> SRR944288     1   0.000      1.000 1.000 0.000
#> SRR944287     1   0.000      1.000 1.000 0.000
#> SRR944289     1   0.000      1.000 1.000 0.000
#> SRR944290     1   0.000      1.000 1.000 0.000
#> SRR944291     1   0.000      1.000 1.000 0.000
#> SRR944292     1   0.000      1.000 1.000 0.000
#> SRR944293     1   0.000      1.000 1.000 0.000
#> SRR944294     1   0.000      1.000 1.000 0.000
#> SRR944295     2   0.000      0.971 0.000 1.000
#> SRR944296     2   0.000      0.971 0.000 1.000
#> SRR944297     2   0.000      0.971 0.000 1.000
#> SRR944298     2   0.000      0.971 0.000 1.000
#> SRR944299     1   0.000      1.000 1.000 0.000
#> SRR944300     1   0.000      1.000 1.000 0.000
#> SRR944301     1   0.000      1.000 1.000 0.000
#> SRR944302     1   0.000      1.000 1.000 0.000
#> SRR944303     2   0.000      0.971 0.000 1.000
#> SRR944304     1   0.000      1.000 1.000 0.000
#> SRR944305     1   0.000      1.000 1.000 0.000
#> SRR944306     1   0.000      1.000 1.000 0.000
#> SRR944307     1   0.000      1.000 1.000 0.000
#> SRR944308     1   0.000      1.000 1.000 0.000
#> SRR944309     1   0.000      1.000 1.000 0.000
#> SRR944310     1   0.000      1.000 1.000 0.000
#> SRR944311     2   0.000      0.971 0.000 1.000
#> SRR944312     1   0.000      1.000 1.000 0.000
#> SRR944313     1   0.000      1.000 1.000 0.000
#> SRR944315     1   0.000      1.000 1.000 0.000
#> SRR944314     1   0.000      1.000 1.000 0.000
#> SRR944316     1   0.000      1.000 1.000 0.000
#> SRR944317     2   0.000      0.971 0.000 1.000
#> SRR944318     2   0.000      0.971 0.000 1.000
#> SRR944319     2   0.000      0.971 0.000 1.000
#> SRR944320     2   0.000      0.971 0.000 1.000
#> SRR944321     1   0.000      1.000 1.000 0.000
#> SRR944322     1   0.000      1.000 1.000 0.000
#> SRR944323     1   0.000      1.000 1.000 0.000
#> SRR944324     1   0.000      1.000 1.000 0.000
#> SRR944325     1   0.000      1.000 1.000 0.000
#> SRR944326     1   0.000      1.000 1.000 0.000
#> SRR944327     1   0.000      1.000 1.000 0.000
#> SRR944328     1   0.000      1.000 1.000 0.000
#> SRR944329     1   0.000      1.000 1.000 0.000
#> SRR944330     1   0.000      1.000 1.000 0.000
#> SRR944331     1   0.000      1.000 1.000 0.000
#> SRR944332     1   0.000      1.000 1.000 0.000
#> SRR944334     1   0.000      1.000 1.000 0.000
#> SRR944333     1   0.000      1.000 1.000 0.000
#> SRR944335     1   0.000      1.000 1.000 0.000
#> SRR944336     1   0.000      1.000 1.000 0.000
#> SRR944337     1   0.000      1.000 1.000 0.000
#> SRR944338     1   0.000      1.000 1.000 0.000
#> SRR944339     1   0.000      1.000 1.000 0.000
#> SRR944340     1   0.000      1.000 1.000 0.000
#> SRR944341     1   0.000      1.000 1.000 0.000
#> SRR944342     1   0.000      1.000 1.000 0.000
#> SRR944343     1   0.000      1.000 1.000 0.000
#> SRR944344     2   0.871      0.588 0.292 0.708

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1 p2    p3
#> SRR944282     1   0.000      0.993 1.000  0 0.000
#> SRR944283     1   0.000      0.993 1.000  0 0.000
#> SRR944284     1   0.000      0.993 1.000  0 0.000
#> SRR944285     1   0.000      0.993 1.000  0 0.000
#> SRR944288     1   0.000      0.993 1.000  0 0.000
#> SRR944287     1   0.000      0.993 1.000  0 0.000
#> SRR944289     1   0.000      0.993 1.000  0 0.000
#> SRR944290     1   0.000      0.993 1.000  0 0.000
#> SRR944291     1   0.000      0.993 1.000  0 0.000
#> SRR944292     1   0.000      0.993 1.000  0 0.000
#> SRR944293     1   0.000      0.993 1.000  0 0.000
#> SRR944294     1   0.000      0.993 1.000  0 0.000
#> SRR944295     2   0.000      1.000 0.000  1 0.000
#> SRR944296     2   0.000      1.000 0.000  1 0.000
#> SRR944297     2   0.000      1.000 0.000  1 0.000
#> SRR944298     2   0.000      1.000 0.000  1 0.000
#> SRR944299     1   0.000      0.993 1.000  0 0.000
#> SRR944300     1   0.000      0.993 1.000  0 0.000
#> SRR944301     1   0.000      0.993 1.000  0 0.000
#> SRR944302     1   0.568      0.538 0.684  0 0.316
#> SRR944303     2   0.000      1.000 0.000  1 0.000
#> SRR944304     1   0.000      0.993 1.000  0 0.000
#> SRR944305     1   0.000      0.993 1.000  0 0.000
#> SRR944306     1   0.000      0.993 1.000  0 0.000
#> SRR944307     1   0.000      0.993 1.000  0 0.000
#> SRR944308     1   0.000      0.993 1.000  0 0.000
#> SRR944309     1   0.000      0.993 1.000  0 0.000
#> SRR944310     1   0.000      0.993 1.000  0 0.000
#> SRR944311     2   0.000      1.000 0.000  1 0.000
#> SRR944312     1   0.000      0.993 1.000  0 0.000
#> SRR944313     1   0.000      0.993 1.000  0 0.000
#> SRR944315     1   0.000      0.993 1.000  0 0.000
#> SRR944314     1   0.000      0.993 1.000  0 0.000
#> SRR944316     1   0.000      0.993 1.000  0 0.000
#> SRR944317     2   0.000      1.000 0.000  1 0.000
#> SRR944318     2   0.000      1.000 0.000  1 0.000
#> SRR944319     2   0.000      1.000 0.000  1 0.000
#> SRR944320     2   0.000      1.000 0.000  1 0.000
#> SRR944321     1   0.000      0.993 1.000  0 0.000
#> SRR944322     1   0.000      0.993 1.000  0 0.000
#> SRR944323     1   0.000      0.993 1.000  0 0.000
#> SRR944324     1   0.000      0.993 1.000  0 0.000
#> SRR944325     1   0.000      0.993 1.000  0 0.000
#> SRR944326     1   0.000      0.993 1.000  0 0.000
#> SRR944327     1   0.000      0.993 1.000  0 0.000
#> SRR944328     1   0.000      0.993 1.000  0 0.000
#> SRR944329     1   0.000      0.993 1.000  0 0.000
#> SRR944330     1   0.000      0.993 1.000  0 0.000
#> SRR944331     1   0.000      0.993 1.000  0 0.000
#> SRR944332     1   0.000      0.993 1.000  0 0.000
#> SRR944334     1   0.000      0.993 1.000  0 0.000
#> SRR944333     1   0.000      0.993 1.000  0 0.000
#> SRR944335     1   0.000      0.993 1.000  0 0.000
#> SRR944336     1   0.000      0.993 1.000  0 0.000
#> SRR944337     1   0.000      0.993 1.000  0 0.000
#> SRR944338     3   0.000      1.000 0.000  0 1.000
#> SRR944339     3   0.000      1.000 0.000  0 1.000
#> SRR944340     3   0.000      1.000 0.000  0 1.000
#> SRR944341     3   0.000      1.000 0.000  0 1.000
#> SRR944342     3   0.000      1.000 0.000  0 1.000
#> SRR944343     3   0.000      1.000 0.000  0 1.000
#> SRR944344     3   0.000      1.000 0.000  0 1.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2   p3    p4
#> SRR944282     1   0.201      0.938 0.920 0.000 0.00 0.080
#> SRR944283     1   0.201      0.938 0.920 0.000 0.00 0.080
#> SRR944284     1   0.201      0.938 0.920 0.000 0.00 0.080
#> SRR944285     1   0.201      0.938 0.920 0.000 0.00 0.080
#> SRR944288     1   0.276      0.906 0.872 0.000 0.00 0.128
#> SRR944287     1   0.201      0.938 0.920 0.000 0.00 0.080
#> SRR944289     4   0.000      0.902 0.000 0.000 0.00 1.000
#> SRR944290     1   0.428      0.692 0.720 0.000 0.00 0.280
#> SRR944291     1   0.201      0.938 0.920 0.000 0.00 0.080
#> SRR944292     4   0.000      0.902 0.000 0.000 0.00 1.000
#> SRR944293     1   0.228      0.930 0.904 0.000 0.00 0.096
#> SRR944294     1   0.413      0.740 0.740 0.000 0.00 0.260
#> SRR944295     2   0.000      0.980 0.000 1.000 0.00 0.000
#> SRR944296     2   0.000      0.980 0.000 1.000 0.00 0.000
#> SRR944297     2   0.000      0.980 0.000 1.000 0.00 0.000
#> SRR944298     2   0.000      0.980 0.000 1.000 0.00 0.000
#> SRR944299     1   0.201      0.938 0.920 0.000 0.00 0.080
#> SRR944300     1   0.201      0.938 0.920 0.000 0.00 0.080
#> SRR944301     1   0.201      0.938 0.920 0.000 0.00 0.080
#> SRR944302     4   0.428      0.591 0.000 0.000 0.28 0.720
#> SRR944303     2   0.000      0.980 0.000 1.000 0.00 0.000
#> SRR944304     4   0.485      0.263 0.400 0.000 0.00 0.600
#> SRR944305     1   0.201      0.938 0.920 0.000 0.00 0.080
#> SRR944306     1   0.448      0.627 0.688 0.000 0.00 0.312
#> SRR944307     1   0.139      0.932 0.952 0.000 0.00 0.048
#> SRR944308     1   0.247      0.922 0.892 0.000 0.00 0.108
#> SRR944309     1   0.000      0.919 1.000 0.000 0.00 0.000
#> SRR944310     1   0.215      0.934 0.912 0.000 0.00 0.088
#> SRR944311     2   0.000      0.980 0.000 1.000 0.00 0.000
#> SRR944312     1   0.000      0.919 1.000 0.000 0.00 0.000
#> SRR944313     1   0.201      0.938 0.920 0.000 0.00 0.080
#> SRR944315     1   0.201      0.938 0.920 0.000 0.00 0.080
#> SRR944314     1   0.000      0.919 1.000 0.000 0.00 0.000
#> SRR944316     1   0.201      0.938 0.920 0.000 0.00 0.080
#> SRR944317     2   0.000      0.980 0.000 1.000 0.00 0.000
#> SRR944318     2   0.000      0.980 0.000 1.000 0.00 0.000
#> SRR944319     2   0.307      0.807 0.000 0.848 0.00 0.152
#> SRR944320     2   0.000      0.980 0.000 1.000 0.00 0.000
#> SRR944321     1   0.000      0.919 1.000 0.000 0.00 0.000
#> SRR944322     1   0.000      0.919 1.000 0.000 0.00 0.000
#> SRR944323     1   0.000      0.919 1.000 0.000 0.00 0.000
#> SRR944324     1   0.000      0.919 1.000 0.000 0.00 0.000
#> SRR944325     1   0.000      0.919 1.000 0.000 0.00 0.000
#> SRR944326     1   0.000      0.919 1.000 0.000 0.00 0.000
#> SRR944327     1   0.000      0.919 1.000 0.000 0.00 0.000
#> SRR944328     1   0.000      0.919 1.000 0.000 0.00 0.000
#> SRR944329     4   0.000      0.902 0.000 0.000 0.00 1.000
#> SRR944330     4   0.000      0.902 0.000 0.000 0.00 1.000
#> SRR944331     4   0.000      0.902 0.000 0.000 0.00 1.000
#> SRR944332     4   0.000      0.902 0.000 0.000 0.00 1.000
#> SRR944334     4   0.000      0.902 0.000 0.000 0.00 1.000
#> SRR944333     4   0.000      0.902 0.000 0.000 0.00 1.000
#> SRR944335     4   0.000      0.902 0.000 0.000 0.00 1.000
#> SRR944336     4   0.000      0.902 0.000 0.000 0.00 1.000
#> SRR944337     4   0.361      0.688 0.200 0.000 0.00 0.800
#> SRR944338     3   0.000      1.000 0.000 0.000 1.00 0.000
#> SRR944339     3   0.000      1.000 0.000 0.000 1.00 0.000
#> SRR944340     3   0.000      1.000 0.000 0.000 1.00 0.000
#> SRR944341     3   0.000      1.000 0.000 0.000 1.00 0.000
#> SRR944342     3   0.000      1.000 0.000 0.000 1.00 0.000
#> SRR944343     3   0.000      1.000 0.000 0.000 1.00 0.000
#> SRR944344     3   0.000      1.000 0.000 0.000 1.00 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> SRR944282     1  0.0510      0.922 0.984 0.000 0.000 0.000 0.016
#> SRR944283     5  0.3366      0.678 0.232 0.000 0.000 0.000 0.768
#> SRR944284     5  0.0000      0.974 0.000 0.000 0.000 0.000 1.000
#> SRR944285     5  0.0000      0.974 0.000 0.000 0.000 0.000 1.000
#> SRR944288     5  0.0000      0.974 0.000 0.000 0.000 0.000 1.000
#> SRR944287     5  0.0000      0.974 0.000 0.000 0.000 0.000 1.000
#> SRR944289     4  0.0000      0.922 0.000 0.000 0.000 1.000 0.000
#> SRR944290     1  0.4887      0.496 0.660 0.000 0.000 0.288 0.052
#> SRR944291     5  0.0000      0.974 0.000 0.000 0.000 0.000 1.000
#> SRR944292     5  0.0000      0.974 0.000 0.000 0.000 0.000 1.000
#> SRR944293     5  0.0000      0.974 0.000 0.000 0.000 0.000 1.000
#> SRR944294     5  0.0000      0.974 0.000 0.000 0.000 0.000 1.000
#> SRR944295     2  0.0000      0.981 0.000 1.000 0.000 0.000 0.000
#> SRR944296     2  0.0000      0.981 0.000 1.000 0.000 0.000 0.000
#> SRR944297     2  0.0000      0.981 0.000 1.000 0.000 0.000 0.000
#> SRR944298     2  0.0000      0.981 0.000 1.000 0.000 0.000 0.000
#> SRR944299     1  0.0000      0.934 1.000 0.000 0.000 0.000 0.000
#> SRR944300     1  0.0000      0.934 1.000 0.000 0.000 0.000 0.000
#> SRR944301     1  0.4227      0.272 0.580 0.000 0.000 0.000 0.420
#> SRR944302     5  0.0510      0.959 0.000 0.000 0.016 0.000 0.984
#> SRR944303     2  0.0000      0.981 0.000 1.000 0.000 0.000 0.000
#> SRR944304     4  0.4182      0.353 0.400 0.000 0.000 0.600 0.000
#> SRR944305     1  0.0000      0.934 1.000 0.000 0.000 0.000 0.000
#> SRR944306     1  0.2732      0.762 0.840 0.000 0.000 0.160 0.000
#> SRR944307     1  0.0000      0.934 1.000 0.000 0.000 0.000 0.000
#> SRR944308     5  0.0000      0.974 0.000 0.000 0.000 0.000 1.000
#> SRR944309     1  0.0000      0.934 1.000 0.000 0.000 0.000 0.000
#> SRR944310     5  0.0000      0.974 0.000 0.000 0.000 0.000 1.000
#> SRR944311     2  0.0000      0.981 0.000 1.000 0.000 0.000 0.000
#> SRR944312     1  0.0000      0.934 1.000 0.000 0.000 0.000 0.000
#> SRR944313     1  0.0162      0.931 0.996 0.000 0.000 0.000 0.004
#> SRR944315     1  0.3480      0.653 0.752 0.000 0.000 0.000 0.248
#> SRR944314     1  0.0000      0.934 1.000 0.000 0.000 0.000 0.000
#> SRR944316     5  0.0000      0.974 0.000 0.000 0.000 0.000 1.000
#> SRR944317     2  0.0000      0.981 0.000 1.000 0.000 0.000 0.000
#> SRR944318     2  0.0000      0.981 0.000 1.000 0.000 0.000 0.000
#> SRR944319     2  0.2648      0.811 0.000 0.848 0.000 0.152 0.000
#> SRR944320     2  0.0000      0.981 0.000 1.000 0.000 0.000 0.000
#> SRR944321     1  0.0000      0.934 1.000 0.000 0.000 0.000 0.000
#> SRR944322     1  0.0000      0.934 1.000 0.000 0.000 0.000 0.000
#> SRR944323     1  0.0000      0.934 1.000 0.000 0.000 0.000 0.000
#> SRR944324     1  0.0000      0.934 1.000 0.000 0.000 0.000 0.000
#> SRR944325     1  0.0000      0.934 1.000 0.000 0.000 0.000 0.000
#> SRR944326     1  0.0000      0.934 1.000 0.000 0.000 0.000 0.000
#> SRR944327     1  0.0000      0.934 1.000 0.000 0.000 0.000 0.000
#> SRR944328     1  0.0000      0.934 1.000 0.000 0.000 0.000 0.000
#> SRR944329     4  0.0000      0.922 0.000 0.000 0.000 1.000 0.000
#> SRR944330     4  0.0000      0.922 0.000 0.000 0.000 1.000 0.000
#> SRR944331     4  0.0000      0.922 0.000 0.000 0.000 1.000 0.000
#> SRR944332     4  0.0000      0.922 0.000 0.000 0.000 1.000 0.000
#> SRR944334     4  0.0000      0.922 0.000 0.000 0.000 1.000 0.000
#> SRR944333     4  0.0000      0.922 0.000 0.000 0.000 1.000 0.000
#> SRR944335     4  0.0000      0.922 0.000 0.000 0.000 1.000 0.000
#> SRR944336     4  0.0000      0.922 0.000 0.000 0.000 1.000 0.000
#> SRR944337     4  0.3109      0.724 0.200 0.000 0.000 0.800 0.000
#> SRR944338     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR944339     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR944340     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR944341     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR944342     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR944343     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> SRR944344     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
#> SRR944282     1  0.2965      0.823 0.848 0.000 0.00 0.000 0.080 0.072
#> SRR944283     6  0.2941      0.523 0.220 0.000 0.00 0.000 0.000 0.780
#> SRR944284     6  0.0000      0.947 0.000 0.000 0.00 0.000 0.000 1.000
#> SRR944285     6  0.0000      0.947 0.000 0.000 0.00 0.000 0.000 1.000
#> SRR944288     6  0.0000      0.947 0.000 0.000 0.00 0.000 0.000 1.000
#> SRR944287     6  0.0000      0.947 0.000 0.000 0.00 0.000 0.000 1.000
#> SRR944289     4  0.0937      0.852 0.000 0.000 0.00 0.960 0.040 0.000
#> SRR944290     1  0.6162      0.443 0.564 0.000 0.00 0.256 0.080 0.100
#> SRR944291     6  0.1556      0.824 0.000 0.000 0.00 0.000 0.080 0.920
#> SRR944292     6  0.0000      0.947 0.000 0.000 0.00 0.000 0.000 1.000
#> SRR944293     6  0.0000      0.947 0.000 0.000 0.00 0.000 0.000 1.000
#> SRR944294     6  0.0000      0.947 0.000 0.000 0.00 0.000 0.000 1.000
#> SRR944295     2  0.0000      0.976 0.000 1.000 0.00 0.000 0.000 0.000
#> SRR944296     2  0.0000      0.976 0.000 1.000 0.00 0.000 0.000 0.000
#> SRR944297     2  0.0000      0.976 0.000 1.000 0.00 0.000 0.000 0.000
#> SRR944298     2  0.0000      0.976 0.000 1.000 0.00 0.000 0.000 0.000
#> SRR944299     1  0.1556      0.870 0.920 0.000 0.00 0.000 0.080 0.000
#> SRR944300     1  0.1556      0.870 0.920 0.000 0.00 0.000 0.080 0.000
#> SRR944301     1  0.5045      0.252 0.512 0.000 0.00 0.000 0.076 0.412
#> SRR944302     5  0.2969      0.000 0.000 0.000 0.00 0.000 0.776 0.224
#> SRR944303     2  0.0000      0.976 0.000 1.000 0.00 0.000 0.000 0.000
#> SRR944304     4  0.5071      0.233 0.400 0.000 0.00 0.520 0.080 0.000
#> SRR944305     1  0.1556      0.870 0.920 0.000 0.00 0.000 0.080 0.000
#> SRR944306     1  0.3667      0.748 0.788 0.000 0.00 0.132 0.080 0.000
#> SRR944307     1  0.1075      0.881 0.952 0.000 0.00 0.000 0.048 0.000
#> SRR944308     6  0.0000      0.947 0.000 0.000 0.00 0.000 0.000 1.000
#> SRR944309     1  0.0000      0.893 1.000 0.000 0.00 0.000 0.000 0.000
#> SRR944310     6  0.0000      0.947 0.000 0.000 0.00 0.000 0.000 1.000
#> SRR944311     2  0.0000      0.976 0.000 1.000 0.00 0.000 0.000 0.000
#> SRR944312     1  0.0000      0.893 1.000 0.000 0.00 0.000 0.000 0.000
#> SRR944313     1  0.2331      0.855 0.888 0.000 0.00 0.000 0.080 0.032
#> SRR944315     1  0.4526      0.595 0.676 0.000 0.00 0.000 0.080 0.244
#> SRR944314     1  0.0000      0.893 1.000 0.000 0.00 0.000 0.000 0.000
#> SRR944316     6  0.0000      0.947 0.000 0.000 0.00 0.000 0.000 1.000
#> SRR944317     2  0.0146      0.975 0.000 0.996 0.00 0.000 0.004 0.000
#> SRR944318     2  0.0146      0.975 0.000 0.996 0.00 0.000 0.004 0.000
#> SRR944319     2  0.2482      0.772 0.000 0.848 0.00 0.148 0.004 0.000
#> SRR944320     2  0.0146      0.975 0.000 0.996 0.00 0.000 0.004 0.000
#> SRR944321     1  0.0000      0.893 1.000 0.000 0.00 0.000 0.000 0.000
#> SRR944322     1  0.0000      0.893 1.000 0.000 0.00 0.000 0.000 0.000
#> SRR944323     1  0.0000      0.893 1.000 0.000 0.00 0.000 0.000 0.000
#> SRR944324     1  0.0000      0.893 1.000 0.000 0.00 0.000 0.000 0.000
#> SRR944325     1  0.0000      0.893 1.000 0.000 0.00 0.000 0.000 0.000
#> SRR944326     1  0.0000      0.893 1.000 0.000 0.00 0.000 0.000 0.000
#> SRR944327     1  0.0000      0.893 1.000 0.000 0.00 0.000 0.000 0.000
#> SRR944328     1  0.0000      0.893 1.000 0.000 0.00 0.000 0.000 0.000
#> SRR944329     4  0.0000      0.864 0.000 0.000 0.00 1.000 0.000 0.000
#> SRR944330     4  0.0000      0.864 0.000 0.000 0.00 1.000 0.000 0.000
#> SRR944331     4  0.0000      0.864 0.000 0.000 0.00 1.000 0.000 0.000
#> SRR944332     4  0.0000      0.864 0.000 0.000 0.00 1.000 0.000 0.000
#> SRR944334     4  0.0000      0.864 0.000 0.000 0.00 1.000 0.000 0.000
#> SRR944333     4  0.0000      0.864 0.000 0.000 0.00 1.000 0.000 0.000
#> SRR944335     4  0.1556      0.831 0.000 0.000 0.00 0.920 0.080 0.000
#> SRR944336     4  0.1556      0.831 0.000 0.000 0.00 0.920 0.080 0.000
#> SRR944337     4  0.4244      0.603 0.200 0.000 0.00 0.720 0.080 0.000
#> SRR944338     3  0.0000      0.979 0.000 0.000 1.00 0.000 0.000 0.000
#> SRR944339     3  0.0000      0.979 0.000 0.000 1.00 0.000 0.000 0.000
#> SRR944340     3  0.0000      0.979 0.000 0.000 1.00 0.000 0.000 0.000
#> SRR944341     3  0.0000      0.979 0.000 0.000 1.00 0.000 0.000 0.000
#> SRR944342     3  0.0000      0.979 0.000 0.000 1.00 0.000 0.000 0.000
#> SRR944343     3  0.0000      0.979 0.000 0.000 1.00 0.000 0.000 0.000
#> SRR944344     3  0.2260      0.860 0.000 0.000 0.86 0.000 0.140 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 12673 rows and 62 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#>   Subgroups are detected by 'mclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 5.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk ATC-mclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.765           0.909       0.953         0.4599 0.511   0.511
#> 3 3 0.666           0.807       0.883         0.3165 0.677   0.476
#> 4 4 1.000           0.951       0.976         0.1467 0.854   0.657
#> 5 5 1.000           0.956       0.975         0.0661 0.927   0.770
#> 6 6 0.899           0.920       0.942         0.0330 0.981   0.925

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

There is also optional best \(k\) = 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
#> SRR944282     1   0.000      1.000 1.000 0.000
#> SRR944283     1   0.000      1.000 1.000 0.000
#> SRR944284     1   0.000      1.000 1.000 0.000
#> SRR944285     1   0.000      1.000 1.000 0.000
#> SRR944288     1   0.000      1.000 1.000 0.000
#> SRR944287     1   0.000      1.000 1.000 0.000
#> SRR944289     1   0.000      1.000 1.000 0.000
#> SRR944290     1   0.000      1.000 1.000 0.000
#> SRR944291     1   0.000      1.000 1.000 0.000
#> SRR944292     2   0.814      0.703 0.252 0.748
#> SRR944293     1   0.000      1.000 1.000 0.000
#> SRR944294     1   0.000      1.000 1.000 0.000
#> SRR944295     2   0.000      0.873 0.000 1.000
#> SRR944296     2   0.000      0.873 0.000 1.000
#> SRR944297     2   0.000      0.873 0.000 1.000
#> SRR944298     2   0.000      0.873 0.000 1.000
#> SRR944299     1   0.000      1.000 1.000 0.000
#> SRR944300     1   0.000      1.000 1.000 0.000
#> SRR944301     1   0.000      1.000 1.000 0.000
#> SRR944302     2   0.814      0.703 0.252 0.748
#> SRR944303     2   0.000      0.873 0.000 1.000
#> SRR944304     1   0.000      1.000 1.000 0.000
#> SRR944305     1   0.000      1.000 1.000 0.000
#> SRR944306     1   0.000      1.000 1.000 0.000
#> SRR944307     1   0.000      1.000 1.000 0.000
#> SRR944308     1   0.000      1.000 1.000 0.000
#> SRR944309     1   0.000      1.000 1.000 0.000
#> SRR944310     1   0.000      1.000 1.000 0.000
#> SRR944311     2   0.000      0.873 0.000 1.000
#> SRR944312     1   0.000      1.000 1.000 0.000
#> SRR944313     1   0.000      1.000 1.000 0.000
#> SRR944315     1   0.000      1.000 1.000 0.000
#> SRR944314     1   0.000      1.000 1.000 0.000
#> SRR944316     1   0.000      1.000 1.000 0.000
#> SRR944317     2   0.000      0.873 0.000 1.000
#> SRR944318     2   0.000      0.873 0.000 1.000
#> SRR944319     2   0.000      0.873 0.000 1.000
#> SRR944320     2   0.000      0.873 0.000 1.000
#> SRR944321     1   0.000      1.000 1.000 0.000
#> SRR944322     1   0.000      1.000 1.000 0.000
#> SRR944323     1   0.000      1.000 1.000 0.000
#> SRR944324     1   0.000      1.000 1.000 0.000
#> SRR944325     1   0.000      1.000 1.000 0.000
#> SRR944326     1   0.000      1.000 1.000 0.000
#> SRR944327     1   0.000      1.000 1.000 0.000
#> SRR944328     1   0.000      1.000 1.000 0.000
#> SRR944329     2   0.971      0.514 0.400 0.600
#> SRR944330     2   0.971      0.514 0.400 0.600
#> SRR944331     2   0.971      0.514 0.400 0.600
#> SRR944332     2   0.971      0.514 0.400 0.600
#> SRR944334     2   0.971      0.514 0.400 0.600
#> SRR944333     2   0.971      0.514 0.400 0.600
#> SRR944335     1   0.000      1.000 1.000 0.000
#> SRR944336     1   0.000      1.000 1.000 0.000
#> SRR944337     1   0.000      1.000 1.000 0.000
#> SRR944338     2   0.000      0.873 0.000 1.000
#> SRR944339     2   0.000      0.873 0.000 1.000
#> SRR944340     2   0.000      0.873 0.000 1.000
#> SRR944341     2   0.000      0.873 0.000 1.000
#> SRR944342     2   0.000      0.873 0.000 1.000
#> SRR944343     2   0.000      0.873 0.000 1.000
#> SRR944344     2   0.000      0.873 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
#> SRR944282     1   0.000      1.000 1.000 0.000 0.000
#> SRR944283     1   0.000      1.000 1.000 0.000 0.000
#> SRR944284     1   0.000      1.000 1.000 0.000 0.000
#> SRR944285     1   0.000      1.000 1.000 0.000 0.000
#> SRR944288     1   0.000      1.000 1.000 0.000 0.000
#> SRR944287     1   0.000      1.000 1.000 0.000 0.000
#> SRR944289     2   0.554      0.638 0.252 0.740 0.008
#> SRR944290     2   0.565      0.603 0.312 0.688 0.000
#> SRR944291     1   0.000      1.000 1.000 0.000 0.000
#> SRR944292     2   0.867      0.519 0.124 0.552 0.324
#> SRR944293     1   0.000      1.000 1.000 0.000 0.000
#> SRR944294     1   0.000      1.000 1.000 0.000 0.000
#> SRR944295     2   0.556      0.532 0.000 0.700 0.300
#> SRR944296     2   0.556      0.532 0.000 0.700 0.300
#> SRR944297     2   0.556      0.532 0.000 0.700 0.300
#> SRR944298     2   0.556      0.532 0.000 0.700 0.300
#> SRR944299     2   0.565      0.603 0.312 0.688 0.000
#> SRR944300     2   0.565      0.603 0.312 0.688 0.000
#> SRR944301     1   0.000      1.000 1.000 0.000 0.000
#> SRR944302     2   0.867      0.519 0.124 0.552 0.324
#> SRR944303     2   0.556      0.532 0.000 0.700 0.300
#> SRR944304     2   0.556      0.616 0.300 0.700 0.000
#> SRR944305     2   0.565      0.603 0.312 0.688 0.000
#> SRR944306     2   0.565      0.603 0.312 0.688 0.000
#> SRR944307     2   0.565      0.603 0.312 0.688 0.000
#> SRR944308     1   0.000      1.000 1.000 0.000 0.000
#> SRR944309     1   0.000      1.000 1.000 0.000 0.000
#> SRR944310     1   0.000      1.000 1.000 0.000 0.000
#> SRR944311     2   0.556      0.532 0.000 0.700 0.300
#> SRR944312     1   0.000      1.000 1.000 0.000 0.000
#> SRR944313     1   0.000      1.000 1.000 0.000 0.000
#> SRR944315     1   0.000      1.000 1.000 0.000 0.000
#> SRR944314     1   0.000      1.000 1.000 0.000 0.000
#> SRR944316     1   0.000      1.000 1.000 0.000 0.000
#> SRR944317     2   0.556      0.532 0.000 0.700 0.300
#> SRR944318     2   0.556      0.532 0.000 0.700 0.300
#> SRR944319     2   0.556      0.532 0.000 0.700 0.300
#> SRR944320     2   0.556      0.532 0.000 0.700 0.300
#> SRR944321     1   0.000      1.000 1.000 0.000 0.000
#> SRR944322     1   0.000      1.000 1.000 0.000 0.000
#> SRR944323     1   0.000      1.000 1.000 0.000 0.000
#> SRR944324     1   0.000      1.000 1.000 0.000 0.000
#> SRR944325     1   0.000      1.000 1.000 0.000 0.000
#> SRR944326     1   0.000      1.000 1.000 0.000 0.000
#> SRR944327     1   0.000      1.000 1.000 0.000 0.000
#> SRR944328     1   0.000      1.000 1.000 0.000 0.000
#> SRR944329     2   0.101      0.645 0.008 0.980 0.012
#> SRR944330     2   0.101      0.645 0.008 0.980 0.012
#> SRR944331     2   0.148      0.650 0.020 0.968 0.012
#> SRR944332     2   0.148      0.650 0.020 0.968 0.012
#> SRR944334     2   0.148      0.650 0.020 0.968 0.012
#> SRR944333     2   0.148      0.650 0.020 0.968 0.012
#> SRR944335     2   0.554      0.638 0.252 0.740 0.008
#> SRR944336     2   0.554      0.638 0.252 0.740 0.008
#> SRR944337     2   0.554      0.638 0.252 0.740 0.008
#> SRR944338     3   0.000      1.000 0.000 0.000 1.000
#> SRR944339     3   0.000      1.000 0.000 0.000 1.000
#> SRR944340     3   0.000      1.000 0.000 0.000 1.000
#> SRR944341     3   0.000      1.000 0.000 0.000 1.000
#> SRR944342     3   0.000      1.000 0.000 0.000 1.000
#> SRR944343     3   0.000      1.000 0.000 0.000 1.000
#> SRR944344     3   0.000      1.000 0.000 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> SRR944282     1  0.0000      0.969 1.000 0.000 0.000 0.000
#> SRR944283     1  0.0000      0.969 1.000 0.000 0.000 0.000
#> SRR944284     1  0.0000      0.969 1.000 0.000 0.000 0.000
#> SRR944285     1  0.0000      0.969 1.000 0.000 0.000 0.000
#> SRR944288     1  0.0000      0.969 1.000 0.000 0.000 0.000
#> SRR944287     1  0.0000      0.969 1.000 0.000 0.000 0.000
#> SRR944289     4  0.0921      0.954 0.028 0.000 0.000 0.972
#> SRR944290     4  0.3172      0.830 0.160 0.000 0.000 0.840
#> SRR944291     1  0.0000      0.969 1.000 0.000 0.000 0.000
#> SRR944292     1  0.6259      0.372 0.592 0.356 0.028 0.024
#> SRR944293     1  0.0000      0.969 1.000 0.000 0.000 0.000
#> SRR944294     1  0.0000      0.969 1.000 0.000 0.000 0.000
#> SRR944295     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR944296     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR944297     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR944298     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR944299     4  0.1716      0.951 0.064 0.000 0.000 0.936
#> SRR944300     4  0.1716      0.951 0.064 0.000 0.000 0.936
#> SRR944301     1  0.0000      0.969 1.000 0.000 0.000 0.000
#> SRR944302     1  0.6259      0.372 0.592 0.356 0.028 0.024
#> SRR944303     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR944304     4  0.1716      0.951 0.064 0.000 0.000 0.936
#> SRR944305     4  0.1792      0.947 0.068 0.000 0.000 0.932
#> SRR944306     4  0.1716      0.951 0.064 0.000 0.000 0.936
#> SRR944307     4  0.1716      0.951 0.064 0.000 0.000 0.936
#> SRR944308     1  0.0000      0.969 1.000 0.000 0.000 0.000
#> SRR944309     1  0.0000      0.969 1.000 0.000 0.000 0.000
#> SRR944310     1  0.0000      0.969 1.000 0.000 0.000 0.000
#> SRR944311     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR944312     1  0.0000      0.969 1.000 0.000 0.000 0.000
#> SRR944313     1  0.0000      0.969 1.000 0.000 0.000 0.000
#> SRR944315     1  0.0000      0.969 1.000 0.000 0.000 0.000
#> SRR944314     1  0.0000      0.969 1.000 0.000 0.000 0.000
#> SRR944316     1  0.0000      0.969 1.000 0.000 0.000 0.000
#> SRR944317     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR944318     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR944319     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR944320     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> SRR944321     1  0.0000      0.969 1.000 0.000 0.000 0.000
#> SRR944322     1  0.0188      0.965 0.996 0.000 0.000 0.004
#> SRR944323     1  0.0000      0.969 1.000 0.000 0.000 0.000
#> SRR944324     1  0.0000      0.969 1.000 0.000 0.000 0.000
#> SRR944325     1  0.0000      0.969 1.000 0.000 0.000 0.000
#> SRR944326     1  0.0000      0.969 1.000 0.000 0.000 0.000
#> SRR944327     1  0.0000      0.969 1.000 0.000 0.000 0.000
#> SRR944328     1  0.0000      0.969 1.000 0.000 0.000 0.000
#> SRR944329     4  0.0000      0.943 0.000 0.000 0.000 1.000
#> SRR944330     4  0.0000      0.943 0.000 0.000 0.000 1.000
#> SRR944331     4  0.0000      0.943 0.000 0.000 0.000 1.000
#> SRR944332     4  0.0000      0.943 0.000 0.000 0.000 1.000
#> SRR944334     4  0.0000      0.943 0.000 0.000 0.000 1.000
#> SRR944333     4  0.0000      0.943 0.000 0.000 0.000 1.000
#> SRR944335     4  0.1211      0.956 0.040 0.000 0.000 0.960
#> SRR944336     4  0.1211      0.956 0.040 0.000 0.000 0.960
#> SRR944337     4  0.1211      0.956 0.040 0.000 0.000 0.960
#> SRR944338     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR944339     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR944340     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR944341     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR944342     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR944343     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR944344     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
#> SRR944282     1  0.0000      0.986 1.000 0.000 0.000 0.000 0.000
#> SRR944283     1  0.0000      0.986 1.000 0.000 0.000 0.000 0.000
#> SRR944284     1  0.0000      0.986 1.000 0.000 0.000 0.000 0.000
#> SRR944285     1  0.0000      0.986 1.000 0.000 0.000 0.000 0.000
#> SRR944288     1  0.0404      0.985 0.988 0.000 0.000 0.000 0.012
#> SRR944287     1  0.0404      0.985 0.988 0.000 0.000 0.000 0.012
#> SRR944289     5  0.0963      0.925 0.000 0.000 0.000 0.036 0.964
#> SRR944290     5  0.3607      0.636 0.244 0.000 0.000 0.004 0.752
#> SRR944291     1  0.0404      0.985 0.988 0.000 0.000 0.000 0.012
#> SRR944292     2  0.4667      0.710 0.180 0.760 0.024 0.020 0.016
#> SRR944293     1  0.0162      0.986 0.996 0.000 0.000 0.000 0.004
#> SRR944294     1  0.0404      0.985 0.988 0.000 0.000 0.000 0.012
#> SRR944295     2  0.0000      0.944 0.000 1.000 0.000 0.000 0.000
#> SRR944296     2  0.0000      0.944 0.000 1.000 0.000 0.000 0.000
#> SRR944297     2  0.0000      0.944 0.000 1.000 0.000 0.000 0.000
#> SRR944298     2  0.0000      0.944 0.000 1.000 0.000 0.000 0.000
#> SRR944299     5  0.0703      0.946 0.024 0.000 0.000 0.000 0.976
#> SRR944300     5  0.0703      0.946 0.024 0.000 0.000 0.000 0.976
#> SRR944301     1  0.0404      0.985 0.988 0.000 0.000 0.000 0.012
#> SRR944302     2  0.4667      0.710 0.180 0.760 0.024 0.020 0.016
#> SRR944303     2  0.0000      0.944 0.000 1.000 0.000 0.000 0.000
#> SRR944304     5  0.0703      0.946 0.024 0.000 0.000 0.000 0.976
#> SRR944305     5  0.1121      0.927 0.044 0.000 0.000 0.000 0.956
#> SRR944306     5  0.0703      0.946 0.024 0.000 0.000 0.000 0.976
#> SRR944307     5  0.0794      0.943 0.028 0.000 0.000 0.000 0.972
#> SRR944308     1  0.0404      0.985 0.988 0.000 0.000 0.000 0.012
#> SRR944309     1  0.0703      0.970 0.976 0.000 0.000 0.000 0.024
#> SRR944310     1  0.0404      0.985 0.988 0.000 0.000 0.000 0.012
#> SRR944311     2  0.0000      0.944 0.000 1.000 0.000 0.000 0.000
#> SRR944312     1  0.0000      0.986 1.000 0.000 0.000 0.000 0.000
#> SRR944313     1  0.0404      0.985 0.988 0.000 0.000 0.000 0.012
#> SRR944315     1  0.0000      0.986 1.000 0.000 0.000 0.000 0.000
#> SRR944314     1  0.2561      0.826 0.856 0.000 0.000 0.000 0.144
#> SRR944316     1  0.0404      0.985 0.988 0.000 0.000 0.000 0.012
#> SRR944317     2  0.0000      0.944 0.000 1.000 0.000 0.000 0.000
#> SRR944318     2  0.0000      0.944 0.000 1.000 0.000 0.000 0.000
#> SRR944319     2  0.0451      0.939 0.000 0.988 0.000 0.008 0.004
#> SRR944320     2  0.0609      0.935 0.000 0.980 0.000 0.020 0.000
#> SRR944321     1  0.0290      0.984 0.992 0.000 0.000 0.000 0.008
#> SRR944322     1  0.0290      0.984 0.992 0.000 0.000 0.000 0.008
#> SRR944323     1  0.0290      0.984 0.992 0.000 0.000 0.000 0.008
#> SRR944324     1  0.0290      0.984 0.992 0.000 0.000 0.000 0.008
#> SRR944325     1  0.0290      0.984 0.992 0.000 0.000 0.000 0.008
#> SRR944326     1  0.0290      0.984 0.992 0.000 0.000 0.000 0.008
#> SRR944327     1  0.0000      0.986 1.000 0.000 0.000 0.000 0.000
#> SRR944328     1  0.0162      0.985 0.996 0.000 0.000 0.000 0.004
#> SRR944329     4  0.0609      1.000 0.000 0.000 0.000 0.980 0.020
#> SRR944330     4  0.0609      1.000 0.000 0.000 0.000 0.980 0.020
#> SRR944331     4  0.0609      1.000 0.000 0.000 0.000 0.980 0.020
#> SRR944332     4  0.0609      1.000 0.000 0.000 0.000 0.980 0.020
#> SRR944334     4  0.0609      1.000 0.000 0.000 0.000 0.980 0.020
#> SRR944333     4  0.0609      1.000 0.000 0.000 0.000 0.980 0.020
#> SRR944335     5  0.1082      0.935 0.008 0.000 0.000 0.028 0.964
#> SRR944336     5  0.1082      0.935 0.008 0.000 0.000 0.028 0.964
#> SRR944337     5  0.1082      0.935 0.008 0.000 0.000 0.028 0.964
#> SRR944338     3  0.0000      0.999 0.000 0.000 1.000 0.000 0.000
#> SRR944339     3  0.0000      0.999 0.000 0.000 1.000 0.000 0.000
#> SRR944340     3  0.0000      0.999 0.000 0.000 1.000 0.000 0.000
#> SRR944341     3  0.0000      0.999 0.000 0.000 1.000 0.000 0.000
#> SRR944342     3  0.0000      0.999 0.000 0.000 1.000 0.000 0.000
#> SRR944343     3  0.0000      0.999 0.000 0.000 1.000 0.000 0.000
#> SRR944344     3  0.0162      0.995 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
#> SRR944282     1  0.0146      0.944 0.996 0.000 0.000 0.00 0.000 0.004
#> SRR944283     1  0.0363      0.945 0.988 0.000 0.000 0.00 0.000 0.012
#> SRR944284     1  0.0146      0.944 0.996 0.000 0.000 0.00 0.000 0.004
#> SRR944285     1  0.0146      0.944 0.996 0.000 0.000 0.00 0.000 0.004
#> SRR944288     1  0.0937      0.942 0.960 0.000 0.000 0.00 0.000 0.040
#> SRR944287     1  0.0937      0.942 0.960 0.000 0.000 0.00 0.000 0.040
#> SRR944289     6  0.1391      0.918 0.000 0.000 0.000 0.04 0.016 0.944
#> SRR944290     6  0.2933      0.663 0.200 0.000 0.000 0.00 0.004 0.796
#> SRR944291     1  0.1141      0.936 0.948 0.000 0.000 0.00 0.000 0.052
#> SRR944292     5  0.5408      0.594 0.240 0.132 0.008 0.00 0.616 0.004
#> SRR944293     1  0.0713      0.944 0.972 0.000 0.000 0.00 0.000 0.028
#> SRR944294     1  0.0713      0.944 0.972 0.000 0.000 0.00 0.000 0.028
#> SRR944295     2  0.0000      1.000 0.000 1.000 0.000 0.00 0.000 0.000
#> SRR944296     2  0.0000      1.000 0.000 1.000 0.000 0.00 0.000 0.000
#> SRR944297     2  0.0000      1.000 0.000 1.000 0.000 0.00 0.000 0.000
#> SRR944298     2  0.0000      1.000 0.000 1.000 0.000 0.00 0.000 0.000
#> SRR944299     6  0.0458      0.937 0.016 0.000 0.000 0.00 0.000 0.984
#> SRR944300     6  0.0458      0.937 0.016 0.000 0.000 0.00 0.000 0.984
#> SRR944301     1  0.0937      0.942 0.960 0.000 0.000 0.00 0.000 0.040
#> SRR944302     5  0.5387      0.597 0.236 0.132 0.008 0.00 0.620 0.004
#> SRR944303     2  0.0000      1.000 0.000 1.000 0.000 0.00 0.000 0.000
#> SRR944304     6  0.0363      0.937 0.012 0.000 0.000 0.00 0.000 0.988
#> SRR944305     6  0.0458      0.937 0.016 0.000 0.000 0.00 0.000 0.984
#> SRR944306     6  0.0363      0.937 0.012 0.000 0.000 0.00 0.000 0.988
#> SRR944307     6  0.0458      0.937 0.016 0.000 0.000 0.00 0.000 0.984
#> SRR944308     1  0.1007      0.940 0.956 0.000 0.000 0.00 0.000 0.044
#> SRR944309     1  0.0713      0.941 0.972 0.000 0.000 0.00 0.000 0.028
#> SRR944310     1  0.0937      0.942 0.960 0.000 0.000 0.00 0.000 0.040
#> SRR944311     2  0.0000      1.000 0.000 1.000 0.000 0.00 0.000 0.000
#> SRR944312     1  0.0000      0.943 1.000 0.000 0.000 0.00 0.000 0.000
#> SRR944313     1  0.0937      0.942 0.960 0.000 0.000 0.00 0.000 0.040
#> SRR944315     1  0.0146      0.944 0.996 0.000 0.000 0.00 0.000 0.004
#> SRR944314     1  0.2003      0.850 0.884 0.000 0.000 0.00 0.000 0.116
#> SRR944316     1  0.1007      0.940 0.956 0.000 0.000 0.00 0.000 0.044
#> SRR944317     5  0.3151      0.733 0.000 0.252 0.000 0.00 0.748 0.000
#> SRR944318     5  0.3151      0.733 0.000 0.252 0.000 0.00 0.748 0.000
#> SRR944319     5  0.2883      0.747 0.000 0.212 0.000 0.00 0.788 0.000
#> SRR944320     5  0.2697      0.743 0.000 0.188 0.000 0.00 0.812 0.000
#> SRR944321     1  0.2135      0.880 0.872 0.000 0.000 0.00 0.128 0.000
#> SRR944322     1  0.2135      0.880 0.872 0.000 0.000 0.00 0.128 0.000
#> SRR944323     1  0.2135      0.880 0.872 0.000 0.000 0.00 0.128 0.000
#> SRR944324     1  0.2135      0.880 0.872 0.000 0.000 0.00 0.128 0.000
#> SRR944325     1  0.2135      0.880 0.872 0.000 0.000 0.00 0.128 0.000
#> SRR944326     1  0.2135      0.880 0.872 0.000 0.000 0.00 0.128 0.000
#> SRR944327     1  0.0260      0.941 0.992 0.000 0.000 0.00 0.008 0.000
#> SRR944328     1  0.0405      0.942 0.988 0.000 0.000 0.00 0.008 0.004
#> SRR944329     4  0.0000      1.000 0.000 0.000 0.000 1.00 0.000 0.000
#> SRR944330     4  0.0000      1.000 0.000 0.000 0.000 1.00 0.000 0.000
#> SRR944331     4  0.0000      1.000 0.000 0.000 0.000 1.00 0.000 0.000
#> SRR944332     4  0.0000      1.000 0.000 0.000 0.000 1.00 0.000 0.000
#> SRR944334     4  0.0000      1.000 0.000 0.000 0.000 1.00 0.000 0.000
#> SRR944333     4  0.0000      1.000 0.000 0.000 0.000 1.00 0.000 0.000
#> SRR944335     6  0.1391      0.918 0.000 0.000 0.000 0.04 0.016 0.944
#> SRR944336     6  0.1391      0.918 0.000 0.000 0.000 0.04 0.016 0.944
#> SRR944337     6  0.1391      0.918 0.000 0.000 0.000 0.04 0.016 0.944
#> SRR944338     3  0.0000      0.993 0.000 0.000 1.000 0.00 0.000 0.000
#> SRR944339     3  0.0000      0.993 0.000 0.000 1.000 0.00 0.000 0.000
#> SRR944340     3  0.0000      0.993 0.000 0.000 1.000 0.00 0.000 0.000
#> SRR944341     3  0.0000      0.993 0.000 0.000 1.000 0.00 0.000 0.000
#> SRR944342     3  0.0000      0.993 0.000 0.000 1.000 0.00 0.000 0.000
#> SRR944343     3  0.0000      0.993 0.000 0.000 1.000 0.00 0.000 0.000
#> SRR944344     3  0.1088      0.956 0.000 0.024 0.960 0.00 0.016 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 12673 rows and 62 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.951       0.979         0.3521 0.663   0.663
#> 3 3 1.000           0.950       0.981         0.3146 0.762   0.674
#> 4 4 0.838           0.903       0.952         0.3836 0.802   0.646
#> 5 5 0.777           0.803       0.917         0.0342 0.983   0.952
#> 6 6 0.750           0.764       0.888         0.0381 0.969   0.911

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
#> SRR944282     1  0.0000      0.977 1.000 0.000
#> SRR944283     1  0.0000      0.977 1.000 0.000
#> SRR944284     1  0.0376      0.974 0.996 0.004
#> SRR944285     1  0.0000      0.977 1.000 0.000
#> SRR944288     1  0.0000      0.977 1.000 0.000
#> SRR944287     1  0.0000      0.977 1.000 0.000
#> SRR944289     1  0.4161      0.904 0.916 0.084
#> SRR944290     1  0.2043      0.952 0.968 0.032
#> SRR944291     1  0.0000      0.977 1.000 0.000
#> SRR944292     1  0.0000      0.977 1.000 0.000
#> SRR944293     1  0.0000      0.977 1.000 0.000
#> SRR944294     1  0.0000      0.977 1.000 0.000
#> SRR944295     2  0.0000      0.983 0.000 1.000
#> SRR944296     2  0.0000      0.983 0.000 1.000
#> SRR944297     2  0.0000      0.983 0.000 1.000
#> SRR944298     2  0.0000      0.983 0.000 1.000
#> SRR944299     1  0.0000      0.977 1.000 0.000
#> SRR944300     1  0.0000      0.977 1.000 0.000
#> SRR944301     1  0.0000      0.977 1.000 0.000
#> SRR944302     1  0.0000      0.977 1.000 0.000
#> SRR944303     2  0.0000      0.983 0.000 1.000
#> SRR944304     1  0.0000      0.977 1.000 0.000
#> SRR944305     1  0.0000      0.977 1.000 0.000
#> SRR944306     1  0.0000      0.977 1.000 0.000
#> SRR944307     1  0.0000      0.977 1.000 0.000
#> SRR944308     1  0.0000      0.977 1.000 0.000
#> SRR944309     1  0.0000      0.977 1.000 0.000
#> SRR944310     1  0.0000      0.977 1.000 0.000
#> SRR944311     2  0.0000      0.983 0.000 1.000
#> SRR944312     1  0.0672      0.971 0.992 0.008
#> SRR944313     1  0.0000      0.977 1.000 0.000
#> SRR944315     1  0.0000      0.977 1.000 0.000
#> SRR944314     1  0.0000      0.977 1.000 0.000
#> SRR944316     1  0.0000      0.977 1.000 0.000
#> SRR944317     2  0.0000      0.983 0.000 1.000
#> SRR944318     2  0.0000      0.983 0.000 1.000
#> SRR944319     2  0.0000      0.983 0.000 1.000
#> SRR944320     2  0.0000      0.983 0.000 1.000
#> SRR944321     1  0.0000      0.977 1.000 0.000
#> SRR944322     1  0.0000      0.977 1.000 0.000
#> SRR944323     1  0.0000      0.977 1.000 0.000
#> SRR944324     1  0.0000      0.977 1.000 0.000
#> SRR944325     1  0.0000      0.977 1.000 0.000
#> SRR944326     1  0.0000      0.977 1.000 0.000
#> SRR944327     1  0.0000      0.977 1.000 0.000
#> SRR944328     1  0.0000      0.977 1.000 0.000
#> SRR944329     2  0.0000      0.983 0.000 1.000
#> SRR944330     2  0.0000      0.983 0.000 1.000
#> SRR944331     1  0.7528      0.736 0.784 0.216
#> SRR944332     1  0.9933      0.197 0.548 0.452
#> SRR944334     1  0.6623      0.799 0.828 0.172
#> SRR944333     2  0.7139      0.742 0.196 0.804
#> SRR944335     1  0.3114      0.931 0.944 0.056
#> SRR944336     1  0.3431      0.924 0.936 0.064
#> SRR944337     1  0.1184      0.965 0.984 0.016
#> SRR944338     1  0.0000      0.977 1.000 0.000
#> SRR944339     1  0.0000      0.977 1.000 0.000
#> SRR944340     1  0.0000      0.977 1.000 0.000
#> SRR944341     1  0.0000      0.977 1.000 0.000
#> SRR944342     1  0.0000      0.977 1.000 0.000
#> SRR944343     1  0.0000      0.977 1.000 0.000
#> SRR944344     1  0.0000      0.977 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
#> SRR944282     1  0.0000      0.972 1.000 0.000 0.000
#> SRR944283     1  0.0000      0.972 1.000 0.000 0.000
#> SRR944284     1  0.0000      0.972 1.000 0.000 0.000
#> SRR944285     1  0.0000      0.972 1.000 0.000 0.000
#> SRR944288     1  0.0000      0.972 1.000 0.000 0.000
#> SRR944287     1  0.0000      0.972 1.000 0.000 0.000
#> SRR944289     1  0.0000      0.972 1.000 0.000 0.000
#> SRR944290     1  0.0000      0.972 1.000 0.000 0.000
#> SRR944291     1  0.0000      0.972 1.000 0.000 0.000
#> SRR944292     1  0.1753      0.928 0.952 0.000 0.048
#> SRR944293     1  0.0000      0.972 1.000 0.000 0.000
#> SRR944294     1  0.0000      0.972 1.000 0.000 0.000
#> SRR944295     2  0.0000      1.000 0.000 1.000 0.000
#> SRR944296     2  0.0000      1.000 0.000 1.000 0.000
#> SRR944297     2  0.0000      1.000 0.000 1.000 0.000
#> SRR944298     2  0.0000      1.000 0.000 1.000 0.000
#> SRR944299     1  0.0000      0.972 1.000 0.000 0.000
#> SRR944300     1  0.0000      0.972 1.000 0.000 0.000
#> SRR944301     1  0.0000      0.972 1.000 0.000 0.000
#> SRR944302     1  0.4399      0.758 0.812 0.000 0.188
#> SRR944303     2  0.0000      1.000 0.000 1.000 0.000
#> SRR944304     1  0.0000      0.972 1.000 0.000 0.000
#> SRR944305     1  0.0000      0.972 1.000 0.000 0.000
#> SRR944306     1  0.0000      0.972 1.000 0.000 0.000
#> SRR944307     1  0.0000      0.972 1.000 0.000 0.000
#> SRR944308     1  0.0000      0.972 1.000 0.000 0.000
#> SRR944309     1  0.0000      0.972 1.000 0.000 0.000
#> SRR944310     1  0.0000      0.972 1.000 0.000 0.000
#> SRR944311     2  0.0000      1.000 0.000 1.000 0.000
#> SRR944312     1  0.0000      0.972 1.000 0.000 0.000
#> SRR944313     1  0.0000      0.972 1.000 0.000 0.000
#> SRR944315     1  0.0000      0.972 1.000 0.000 0.000
#> SRR944314     1  0.0000      0.972 1.000 0.000 0.000
#> SRR944316     1  0.0000      0.972 1.000 0.000 0.000
#> SRR944317     2  0.0000      1.000 0.000 1.000 0.000
#> SRR944318     2  0.0000      1.000 0.000 1.000 0.000
#> SRR944319     2  0.0000      1.000 0.000 1.000 0.000
#> SRR944320     2  0.0000      1.000 0.000 1.000 0.000
#> SRR944321     1  0.0000      0.972 1.000 0.000 0.000
#> SRR944322     1  0.0000      0.972 1.000 0.000 0.000
#> SRR944323     1  0.0000      0.972 1.000 0.000 0.000
#> SRR944324     1  0.0000      0.972 1.000 0.000 0.000
#> SRR944325     1  0.0000      0.972 1.000 0.000 0.000
#> SRR944326     1  0.0000      0.972 1.000 0.000 0.000
#> SRR944327     1  0.0000      0.972 1.000 0.000 0.000
#> SRR944328     1  0.0000      0.972 1.000 0.000 0.000
#> SRR944329     1  0.6286      0.157 0.536 0.464 0.000
#> SRR944330     1  0.6267      0.195 0.548 0.452 0.000
#> SRR944331     1  0.0000      0.972 1.000 0.000 0.000
#> SRR944332     1  0.0000      0.972 1.000 0.000 0.000
#> SRR944334     1  0.0000      0.972 1.000 0.000 0.000
#> SRR944333     1  0.0892      0.954 0.980 0.020 0.000
#> SRR944335     1  0.0000      0.972 1.000 0.000 0.000
#> SRR944336     1  0.0000      0.972 1.000 0.000 0.000
#> SRR944337     1  0.0000      0.972 1.000 0.000 0.000
#> SRR944338     3  0.0000      1.000 0.000 0.000 1.000
#> SRR944339     3  0.0000      1.000 0.000 0.000 1.000
#> SRR944340     3  0.0000      1.000 0.000 0.000 1.000
#> SRR944341     3  0.0000      1.000 0.000 0.000 1.000
#> SRR944342     3  0.0000      1.000 0.000 0.000 1.000
#> SRR944343     3  0.0000      1.000 0.000 0.000 1.000
#> SRR944344     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
#> SRR944282     1  0.0000      0.946 1.000 0.000 0.000 0.000
#> SRR944283     1  0.0000      0.946 1.000 0.000 0.000 0.000
#> SRR944284     1  0.0000      0.946 1.000 0.000 0.000 0.000
#> SRR944285     1  0.0000      0.946 1.000 0.000 0.000 0.000
#> SRR944288     1  0.0336      0.944 0.992 0.000 0.000 0.008
#> SRR944287     1  0.0000      0.946 1.000 0.000 0.000 0.000
#> SRR944289     4  0.1389      0.886 0.048 0.000 0.000 0.952
#> SRR944290     1  0.2281      0.877 0.904 0.000 0.000 0.096
#> SRR944291     1  0.0469      0.943 0.988 0.000 0.000 0.012
#> SRR944292     1  0.4452      0.764 0.796 0.000 0.156 0.048
#> SRR944293     1  0.0469      0.943 0.988 0.000 0.000 0.012
#> SRR944294     1  0.0336      0.944 0.992 0.000 0.000 0.008
#> SRR944295     2  0.0000      0.967 0.000 1.000 0.000 0.000
#> SRR944296     2  0.0000      0.967 0.000 1.000 0.000 0.000
#> SRR944297     2  0.0000      0.967 0.000 1.000 0.000 0.000
#> SRR944298     2  0.0000      0.967 0.000 1.000 0.000 0.000
#> SRR944299     1  0.3726      0.729 0.788 0.000 0.000 0.212
#> SRR944300     1  0.2814      0.839 0.868 0.000 0.000 0.132
#> SRR944301     1  0.0592      0.940 0.984 0.000 0.000 0.016
#> SRR944302     1  0.4464      0.703 0.768 0.000 0.208 0.024
#> SRR944303     2  0.0000      0.967 0.000 1.000 0.000 0.000
#> SRR944304     4  0.4746      0.485 0.368 0.000 0.000 0.632
#> SRR944305     1  0.2149      0.884 0.912 0.000 0.000 0.088
#> SRR944306     1  0.4855      0.281 0.600 0.000 0.000 0.400
#> SRR944307     1  0.3219      0.799 0.836 0.000 0.000 0.164
#> SRR944308     1  0.0817      0.936 0.976 0.000 0.000 0.024
#> SRR944309     1  0.0336      0.944 0.992 0.000 0.000 0.008
#> SRR944310     1  0.0336      0.944 0.992 0.000 0.000 0.008
#> SRR944311     2  0.0000      0.967 0.000 1.000 0.000 0.000
#> SRR944312     1  0.0188      0.945 0.996 0.000 0.000 0.004
#> SRR944313     1  0.0188      0.945 0.996 0.000 0.000 0.004
#> SRR944315     1  0.0000      0.946 1.000 0.000 0.000 0.000
#> SRR944314     1  0.0000      0.946 1.000 0.000 0.000 0.000
#> SRR944316     1  0.0000      0.946 1.000 0.000 0.000 0.000
#> SRR944317     2  0.0336      0.964 0.000 0.992 0.000 0.008
#> SRR944318     2  0.0336      0.964 0.000 0.992 0.000 0.008
#> SRR944319     2  0.3975      0.708 0.000 0.760 0.000 0.240
#> SRR944320     2  0.1022      0.949 0.000 0.968 0.000 0.032
#> SRR944321     1  0.0188      0.945 0.996 0.000 0.000 0.004
#> SRR944322     1  0.0000      0.946 1.000 0.000 0.000 0.000
#> SRR944323     1  0.0000      0.946 1.000 0.000 0.000 0.000
#> SRR944324     1  0.0000      0.946 1.000 0.000 0.000 0.000
#> SRR944325     1  0.0000      0.946 1.000 0.000 0.000 0.000
#> SRR944326     1  0.0000      0.946 1.000 0.000 0.000 0.000
#> SRR944327     1  0.0000      0.946 1.000 0.000 0.000 0.000
#> SRR944328     1  0.0000      0.946 1.000 0.000 0.000 0.000
#> SRR944329     4  0.1109      0.885 0.028 0.004 0.000 0.968
#> SRR944330     4  0.1109      0.885 0.028 0.004 0.000 0.968
#> SRR944331     4  0.1022      0.889 0.032 0.000 0.000 0.968
#> SRR944332     4  0.1022      0.889 0.032 0.000 0.000 0.968
#> SRR944334     4  0.1022      0.889 0.032 0.000 0.000 0.968
#> SRR944333     4  0.1022      0.889 0.032 0.000 0.000 0.968
#> SRR944335     4  0.3172      0.822 0.160 0.000 0.000 0.840
#> SRR944336     4  0.2921      0.842 0.140 0.000 0.000 0.860
#> SRR944337     4  0.2973      0.839 0.144 0.000 0.000 0.856
#> SRR944338     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR944339     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR944340     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR944341     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR944342     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR944343     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> SRR944344     3  0.0188      0.997 0.000 0.000 0.996 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
#> SRR944282     1  0.0162      0.903 0.996 0.000 0.000 0.000 0.004
#> SRR944283     1  0.1478      0.847 0.936 0.000 0.000 0.000 0.064
#> SRR944284     1  0.0162      0.905 0.996 0.000 0.000 0.004 0.000
#> SRR944285     1  0.0290      0.903 0.992 0.000 0.000 0.000 0.008
#> SRR944288     1  0.0290      0.905 0.992 0.000 0.000 0.008 0.000
#> SRR944287     1  0.0510      0.896 0.984 0.000 0.000 0.000 0.016
#> SRR944289     4  0.2179      0.776 0.100 0.000 0.000 0.896 0.004
#> SRR944290     1  0.2873      0.766 0.856 0.000 0.000 0.128 0.016
#> SRR944291     1  0.0451      0.904 0.988 0.000 0.000 0.004 0.008
#> SRR944292     1  0.5657      0.396 0.696 0.000 0.132 0.036 0.136
#> SRR944293     1  0.0579      0.902 0.984 0.000 0.000 0.008 0.008
#> SRR944294     1  0.0290      0.905 0.992 0.000 0.000 0.008 0.000
#> SRR944295     2  0.0162      0.870 0.000 0.996 0.000 0.000 0.004
#> SRR944296     2  0.0162      0.871 0.000 0.996 0.000 0.000 0.004
#> SRR944297     2  0.0000      0.871 0.000 1.000 0.000 0.000 0.000
#> SRR944298     2  0.0000      0.871 0.000 1.000 0.000 0.000 0.000
#> SRR944299     1  0.4269      0.458 0.684 0.000 0.000 0.300 0.016
#> SRR944300     1  0.3563      0.647 0.780 0.000 0.000 0.208 0.012
#> SRR944301     1  0.0579      0.902 0.984 0.000 0.000 0.008 0.008
#> SRR944302     5  0.6141      0.000 0.272 0.000 0.092 0.032 0.604
#> SRR944303     2  0.0290      0.869 0.000 0.992 0.000 0.000 0.008
#> SRR944304     4  0.4787      0.312 0.364 0.000 0.000 0.608 0.028
#> SRR944305     1  0.2574      0.790 0.876 0.000 0.000 0.112 0.012
#> SRR944306     1  0.4848      0.150 0.556 0.000 0.000 0.420 0.024
#> SRR944307     1  0.3659      0.625 0.768 0.000 0.000 0.220 0.012
#> SRR944308     1  0.1082      0.887 0.964 0.000 0.000 0.028 0.008
#> SRR944309     1  0.0451      0.903 0.988 0.000 0.000 0.008 0.004
#> SRR944310     1  0.0162      0.905 0.996 0.000 0.000 0.004 0.000
#> SRR944311     2  0.0404      0.870 0.000 0.988 0.000 0.000 0.012
#> SRR944312     1  0.0290      0.905 0.992 0.000 0.000 0.008 0.000
#> SRR944313     1  0.0162      0.905 0.996 0.000 0.000 0.004 0.000
#> SRR944315     1  0.0162      0.905 0.996 0.000 0.000 0.004 0.000
#> SRR944314     1  0.0290      0.901 0.992 0.000 0.000 0.000 0.008
#> SRR944316     1  0.0880      0.886 0.968 0.000 0.000 0.000 0.032
#> SRR944317     2  0.1270      0.856 0.000 0.948 0.000 0.000 0.052
#> SRR944318     2  0.3152      0.801 0.000 0.840 0.000 0.024 0.136
#> SRR944319     2  0.6622      0.345 0.000 0.416 0.000 0.364 0.220
#> SRR944320     2  0.5970      0.588 0.000 0.588 0.000 0.184 0.228
#> SRR944321     1  0.0000      0.905 1.000 0.000 0.000 0.000 0.000
#> SRR944322     1  0.0000      0.905 1.000 0.000 0.000 0.000 0.000
#> SRR944323     1  0.0000      0.905 1.000 0.000 0.000 0.000 0.000
#> SRR944324     1  0.0162      0.903 0.996 0.000 0.000 0.000 0.004
#> SRR944325     1  0.0000      0.905 1.000 0.000 0.000 0.000 0.000
#> SRR944326     1  0.0000      0.905 1.000 0.000 0.000 0.000 0.000
#> SRR944327     1  0.0162      0.905 0.996 0.000 0.000 0.000 0.004
#> SRR944328     1  0.1043      0.873 0.960 0.000 0.000 0.000 0.040
#> SRR944329     4  0.1124      0.770 0.004 0.000 0.000 0.960 0.036
#> SRR944330     4  0.1041      0.773 0.004 0.000 0.000 0.964 0.032
#> SRR944331     4  0.0404      0.800 0.012 0.000 0.000 0.988 0.000
#> SRR944332     4  0.0510      0.803 0.016 0.000 0.000 0.984 0.000
#> SRR944334     4  0.0510      0.803 0.016 0.000 0.000 0.984 0.000
#> SRR944333     4  0.0510      0.803 0.016 0.000 0.000 0.984 0.000
#> SRR944335     4  0.3805      0.701 0.184 0.000 0.000 0.784 0.032
#> SRR944336     4  0.3687      0.709 0.180 0.000 0.000 0.792 0.028
#> SRR944337     4  0.3687      0.709 0.180 0.000 0.000 0.792 0.028
#> SRR944338     3  0.0162      0.980 0.000 0.000 0.996 0.000 0.004
#> SRR944339     3  0.0162      0.981 0.000 0.000 0.996 0.000 0.004
#> SRR944340     3  0.0290      0.980 0.000 0.000 0.992 0.000 0.008
#> SRR944341     3  0.0000      0.981 0.000 0.000 1.000 0.000 0.000
#> SRR944342     3  0.0162      0.981 0.000 0.000 0.996 0.000 0.004
#> SRR944343     3  0.0404      0.977 0.000 0.000 0.988 0.000 0.012
#> SRR944344     3  0.1908      0.912 0.000 0.000 0.908 0.000 0.092

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR944282     1  0.0363     0.8857 0.988 0.000 0.000 0.000 0.012 0.000
#> SRR944283     1  0.1531     0.8538 0.928 0.000 0.000 0.000 0.068 0.004
#> SRR944284     1  0.0363     0.8866 0.988 0.000 0.000 0.000 0.012 0.000
#> SRR944285     1  0.1148     0.8832 0.960 0.000 0.000 0.004 0.016 0.020
#> SRR944288     1  0.1049     0.8809 0.960 0.000 0.000 0.008 0.000 0.032
#> SRR944287     1  0.0951     0.8838 0.968 0.000 0.000 0.004 0.020 0.008
#> SRR944289     4  0.1983     0.7277 0.072 0.000 0.000 0.908 0.000 0.020
#> SRR944290     1  0.3897     0.6216 0.712 0.000 0.000 0.264 0.016 0.008
#> SRR944291     1  0.0993     0.8869 0.964 0.000 0.000 0.024 0.000 0.012
#> SRR944292     1  0.7471     0.0628 0.504 0.000 0.108 0.088 0.084 0.216
#> SRR944293     1  0.1429     0.8783 0.940 0.000 0.000 0.052 0.004 0.004
#> SRR944294     1  0.1226     0.8824 0.952 0.000 0.000 0.040 0.004 0.004
#> SRR944295     2  0.0000     0.8937 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR944296     2  0.0363     0.8936 0.000 0.988 0.000 0.000 0.000 0.012
#> SRR944297     2  0.0363     0.8936 0.000 0.988 0.000 0.000 0.000 0.012
#> SRR944298     2  0.0260     0.8935 0.000 0.992 0.000 0.000 0.000 0.008
#> SRR944299     1  0.4481     0.2635 0.572 0.000 0.000 0.400 0.008 0.020
#> SRR944300     1  0.4286     0.4203 0.624 0.000 0.000 0.352 0.012 0.012
#> SRR944301     1  0.1829     0.8717 0.920 0.000 0.000 0.064 0.012 0.004
#> SRR944302     5  0.3169     0.0000 0.096 0.000 0.024 0.020 0.852 0.008
#> SRR944303     2  0.0260     0.8923 0.000 0.992 0.000 0.000 0.008 0.000
#> SRR944304     4  0.4146     0.5531 0.288 0.000 0.000 0.676 0.000 0.036
#> SRR944305     1  0.3642     0.6662 0.744 0.000 0.000 0.236 0.008 0.012
#> SRR944306     4  0.4300     0.2292 0.432 0.000 0.000 0.548 0.000 0.020
#> SRR944307     1  0.4155     0.5061 0.660 0.000 0.000 0.316 0.012 0.012
#> SRR944308     1  0.2001     0.8646 0.912 0.000 0.000 0.068 0.008 0.012
#> SRR944309     1  0.1719     0.8747 0.928 0.000 0.000 0.056 0.008 0.008
#> SRR944310     1  0.1757     0.8763 0.928 0.000 0.000 0.052 0.012 0.008
#> SRR944311     2  0.0405     0.8909 0.000 0.988 0.000 0.000 0.008 0.004
#> SRR944312     1  0.1398     0.8784 0.940 0.000 0.000 0.052 0.008 0.000
#> SRR944313     1  0.0777     0.8871 0.972 0.000 0.000 0.024 0.004 0.000
#> SRR944315     1  0.0622     0.8880 0.980 0.000 0.000 0.008 0.012 0.000
#> SRR944314     1  0.0964     0.8849 0.968 0.000 0.000 0.004 0.016 0.012
#> SRR944316     1  0.1285     0.8712 0.944 0.000 0.000 0.000 0.052 0.004
#> SRR944317     2  0.2615     0.7552 0.000 0.852 0.000 0.008 0.004 0.136
#> SRR944318     2  0.4341     0.2270 0.000 0.616 0.000 0.024 0.004 0.356
#> SRR944319     6  0.5870     0.6813 0.000 0.168 0.000 0.296 0.012 0.524
#> SRR944320     6  0.5377     0.6715 0.000 0.272 0.000 0.156 0.000 0.572
#> SRR944321     1  0.0405     0.8885 0.988 0.000 0.000 0.008 0.000 0.004
#> SRR944322     1  0.0622     0.8878 0.980 0.000 0.000 0.008 0.012 0.000
#> SRR944323     1  0.0508     0.8874 0.984 0.000 0.000 0.004 0.012 0.000
#> SRR944324     1  0.0363     0.8864 0.988 0.000 0.000 0.000 0.012 0.000
#> SRR944325     1  0.0260     0.8870 0.992 0.000 0.000 0.000 0.008 0.000
#> SRR944326     1  0.0291     0.8857 0.992 0.000 0.000 0.000 0.004 0.004
#> SRR944327     1  0.0935     0.8776 0.964 0.000 0.000 0.000 0.004 0.032
#> SRR944328     1  0.1572     0.8588 0.936 0.000 0.000 0.000 0.036 0.028
#> SRR944329     4  0.1700     0.6409 0.004 0.000 0.000 0.916 0.000 0.080
#> SRR944330     4  0.1700     0.6409 0.004 0.000 0.000 0.916 0.000 0.080
#> SRR944331     4  0.1168     0.7085 0.016 0.000 0.000 0.956 0.000 0.028
#> SRR944332     4  0.1232     0.7110 0.016 0.000 0.000 0.956 0.004 0.024
#> SRR944334     4  0.1341     0.7206 0.028 0.000 0.000 0.948 0.000 0.024
#> SRR944333     4  0.1313     0.7079 0.016 0.000 0.000 0.952 0.004 0.028
#> SRR944335     4  0.3354     0.7005 0.168 0.000 0.000 0.796 0.000 0.036
#> SRR944336     4  0.3243     0.7110 0.156 0.000 0.000 0.812 0.004 0.028
#> SRR944337     4  0.3283     0.7079 0.160 0.000 0.000 0.804 0.000 0.036
#> SRR944338     3  0.0146     0.9527 0.000 0.000 0.996 0.000 0.000 0.004
#> SRR944339     3  0.0547     0.9513 0.000 0.000 0.980 0.000 0.000 0.020
#> SRR944340     3  0.0935     0.9427 0.000 0.000 0.964 0.000 0.004 0.032
#> SRR944341     3  0.0260     0.9540 0.000 0.000 0.992 0.000 0.000 0.008
#> SRR944342     3  0.0260     0.9540 0.000 0.000 0.992 0.000 0.000 0.008
#> SRR944343     3  0.0260     0.9514 0.000 0.000 0.992 0.000 0.000 0.008
#> SRR944344     3  0.3587     0.7670 0.000 0.000 0.792 0.000 0.068 0.140

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