cola Report for GDS5176

Date: 2019-12-25 22:00:25 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 29485 rows and 57 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, anno = anno)

Dimension of the input matrix:

mat = get_matrix(res_list)
dim(mat)
#> [1] 29485    57

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, top_annotation = HeatmapAnnotation(df = get_anno(res_list), 
    col = get_anno_col(res_list)), 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
ATC:kmeans 3 0.980 0.935 0.972 **
MAD:mclust 2 0.980 0.957 0.975 **
ATC:pam 5 0.960 0.943 0.977 ** 2,3,4
ATC:NMF 3 0.952 0.928 0.971 ** 2
MAD:skmeans 3 0.943 0.927 0.969 *
ATC:mclust 6 0.923 0.898 0.950 * 2,4,5
CV:NMF 3 0.918 0.903 0.960 *
ATC:skmeans 4 0.901 0.861 0.943 * 3
SD:NMF 3 0.874 0.911 0.961
MAD:NMF 3 0.862 0.911 0.961
SD:skmeans 4 0.857 0.897 0.938
CV:skmeans 4 0.853 0.905 0.942
CV:kmeans 3 0.840 0.876 0.943
SD:kmeans 3 0.820 0.873 0.942
CV:mclust 2 0.804 0.936 0.940
MAD:kmeans 3 0.790 0.876 0.940
ATC:hclust 3 0.693 0.877 0.936
SD:mclust 2 0.669 0.915 0.921
SD:pam 4 0.661 0.817 0.857
CV:hclust 3 0.654 0.711 0.881
MAD:pam 4 0.652 0.817 0.869
CV:pam 4 0.635 0.815 0.872
MAD:hclust 3 0.584 0.722 0.871
SD:hclust 3 0.549 0.733 0.883

**: 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.516           0.757       0.874          0.468 0.491   0.491
#> CV:NMF      2 0.514           0.771       0.885          0.472 0.491   0.491
#> MAD:NMF     2 0.419           0.793       0.877          0.488 0.499   0.499
#> ATC:NMF     2 0.999           0.961       0.983          0.476 0.526   0.526
#> SD:skmeans  2 0.556           0.842       0.907          0.506 0.492   0.492
#> CV:skmeans  2 0.535           0.829       0.905          0.507 0.491   0.491
#> MAD:skmeans 2 0.407           0.816       0.857          0.508 0.492   0.492
#> ATC:skmeans 2 0.707           0.840       0.926          0.504 0.495   0.495
#> SD:mclust   2 0.669           0.915       0.921          0.417 0.560   0.560
#> CV:mclust   2 0.804           0.936       0.940          0.423 0.560   0.560
#> MAD:mclust  2 0.980           0.957       0.975          0.263 0.754   0.754
#> ATC:mclust  2 1.000           0.982       0.992          0.386 0.623   0.623
#> SD:kmeans   2 0.217           0.635       0.823          0.439 0.589   0.589
#> CV:kmeans   2 0.210           0.637       0.787          0.448 0.589   0.589
#> MAD:kmeans  2 0.151           0.341       0.580          0.474 0.526   0.526
#> ATC:kmeans  2 0.294           0.722       0.842          0.426 0.574   0.574
#> SD:pam      2 0.363           0.726       0.821          0.433 0.560   0.560
#> CV:pam      2 0.364           0.692       0.799          0.422 0.560   0.560
#> MAD:pam     2 0.379           0.740       0.826          0.429 0.560   0.560
#> ATC:pam     2 1.000           0.981       0.985          0.345 0.662   0.662
#> SD:hclust   2 0.420           0.780       0.865          0.364 0.729   0.729
#> CV:hclust   2 0.425           0.669       0.853          0.378 0.683   0.683
#> MAD:hclust  2 0.323           0.640       0.833          0.399 0.623   0.623
#> ATC:hclust  2 0.846           0.960       0.979          0.343 0.662   0.662
get_stats(res_list, k = 3)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      3 0.874           0.911       0.961          0.421 0.682   0.443
#> CV:NMF      3 0.918           0.903       0.960          0.410 0.677   0.437
#> MAD:NMF     3 0.862           0.911       0.961          0.369 0.705   0.476
#> ATC:NMF     3 0.952           0.928       0.971          0.387 0.790   0.611
#> SD:skmeans  3 0.856           0.870       0.948          0.336 0.695   0.456
#> CV:skmeans  3 0.846           0.872       0.948          0.335 0.706   0.468
#> MAD:skmeans 3 0.943           0.927       0.969          0.331 0.706   0.469
#> ATC:skmeans 3 1.000           0.981       0.993          0.324 0.791   0.597
#> SD:mclust   3 0.656           0.863       0.928          0.344 0.612   0.441
#> CV:mclust   3 0.802           0.890       0.929          0.336 0.612   0.441
#> MAD:mclust  3 0.566           0.825       0.898          1.243 0.648   0.545
#> ATC:mclust  3 0.626           0.811       0.889          0.403 0.600   0.473
#> SD:kmeans   3 0.820           0.873       0.942          0.487 0.673   0.483
#> CV:kmeans   3 0.840           0.876       0.943          0.464 0.694   0.505
#> MAD:kmeans  3 0.790           0.876       0.940          0.402 0.737   0.534
#> ATC:kmeans  3 0.980           0.935       0.972          0.537 0.753   0.576
#> SD:pam      3 0.456           0.734       0.836          0.437 0.752   0.576
#> CV:pam      3 0.442           0.719       0.821          0.457 0.752   0.576
#> MAD:pam     3 0.590           0.776       0.854          0.453 0.752   0.576
#> ATC:pam     3 0.999           0.957       0.982          0.839 0.709   0.561
#> SD:hclust   3 0.549           0.733       0.883          0.566 0.715   0.609
#> CV:hclust   3 0.654           0.711       0.881          0.506 0.704   0.576
#> MAD:hclust  3 0.584           0.722       0.871          0.451 0.751   0.625
#> ATC:hclust  3 0.693           0.877       0.936          0.658 0.739   0.606
get_stats(res_list, k = 4)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      4 0.658           0.640       0.795          0.114 0.905   0.728
#> CV:NMF      4 0.680           0.663       0.807          0.115 0.888   0.679
#> MAD:NMF     4 0.678           0.737       0.848          0.110 0.897   0.705
#> ATC:NMF     4 0.693           0.716       0.843          0.118 0.857   0.616
#> SD:skmeans  4 0.857           0.897       0.938          0.125 0.840   0.556
#> CV:skmeans  4 0.853           0.905       0.942          0.124 0.836   0.547
#> MAD:skmeans 4 0.798           0.805       0.890          0.122 0.826   0.526
#> ATC:skmeans 4 0.901           0.861       0.943          0.124 0.893   0.688
#> SD:mclust   4 0.727           0.776       0.899          0.290 0.761   0.496
#> CV:mclust   4 0.727           0.809       0.912          0.293 0.761   0.496
#> MAD:mclust  4 0.750           0.814       0.870          0.252 0.698   0.391
#> ATC:mclust  4 0.927           0.912       0.967          0.306 0.713   0.460
#> SD:kmeans   4 0.624           0.627       0.816          0.134 0.841   0.587
#> CV:kmeans   4 0.633           0.423       0.673          0.132 0.887   0.683
#> MAD:kmeans  4 0.630           0.425       0.661          0.121 0.900   0.715
#> ATC:kmeans  4 0.796           0.882       0.934          0.123 0.771   0.451
#> SD:pam      4 0.661           0.817       0.857          0.161 0.894   0.710
#> CV:pam      4 0.635           0.815       0.872          0.176 0.904   0.737
#> MAD:pam     4 0.652           0.817       0.869          0.163 0.904   0.737
#> ATC:pam     4 0.957           0.947       0.977          0.174 0.872   0.661
#> SD:hclust   4 0.477           0.620       0.770          0.135 0.966   0.923
#> CV:hclust   4 0.477           0.496       0.741          0.174 0.852   0.672
#> MAD:hclust  4 0.480           0.575       0.734          0.145 0.977   0.951
#> ATC:hclust  4 0.690           0.834       0.884          0.287 0.840   0.602
get_stats(res_list, k = 5)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      5 0.699           0.702       0.818         0.0715 0.898   0.651
#> CV:NMF      5 0.635           0.630       0.769         0.0697 0.873   0.574
#> MAD:NMF     5 0.658           0.653       0.776         0.0704 0.911   0.684
#> ATC:NMF     5 0.645           0.570       0.754         0.0706 0.937   0.769
#> SD:skmeans  5 0.781           0.600       0.800         0.0513 0.867   0.543
#> CV:skmeans  5 0.780           0.630       0.816         0.0535 0.873   0.553
#> MAD:skmeans 5 0.771           0.698       0.850         0.0531 0.872   0.546
#> ATC:skmeans 5 0.832           0.748       0.886         0.0447 0.937   0.763
#> SD:mclust   5 0.744           0.760       0.843         0.0809 0.934   0.765
#> CV:mclust   5 0.820           0.799       0.892         0.0712 0.921   0.720
#> MAD:mclust  5 0.775           0.568       0.752         0.0678 0.887   0.600
#> ATC:mclust  5 0.948           0.915       0.952         0.0528 0.902   0.687
#> SD:kmeans   5 0.690           0.639       0.771         0.0679 0.845   0.499
#> CV:kmeans   5 0.690           0.655       0.782         0.0691 0.870   0.559
#> MAD:kmeans  5 0.683           0.589       0.737         0.0674 0.826   0.448
#> ATC:kmeans  5 0.754           0.771       0.870         0.0847 0.890   0.614
#> SD:pam      5 0.717           0.804       0.864         0.0600 0.883   0.623
#> CV:pam      5 0.708           0.799       0.869         0.0611 0.875   0.606
#> MAD:pam     5 0.726           0.775       0.841         0.0561 0.861   0.566
#> ATC:pam     5 0.960           0.943       0.977         0.0392 0.972   0.892
#> SD:hclust   5 0.611           0.709       0.821         0.1503 0.805   0.541
#> CV:hclust   5 0.642           0.669       0.808         0.1254 0.763   0.414
#> MAD:hclust  5 0.656           0.699       0.842         0.1413 0.774   0.514
#> ATC:hclust  5 0.736           0.832       0.899         0.0564 0.977   0.906
get_stats(res_list, k = 6)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      6 0.652           0.591       0.732         0.0439 0.888   0.550
#> CV:NMF      6 0.639           0.590       0.718         0.0447 0.886   0.537
#> MAD:NMF     6 0.647           0.559       0.704         0.0435 0.931   0.700
#> ATC:NMF     6 0.769           0.630       0.822         0.0486 0.883   0.543
#> SD:skmeans  6 0.792           0.662       0.820         0.0402 0.917   0.641
#> CV:skmeans  6 0.785           0.656       0.823         0.0393 0.911   0.612
#> MAD:skmeans 6 0.790           0.727       0.846         0.0400 0.937   0.712
#> ATC:skmeans 6 0.818           0.775       0.863         0.0354 0.951   0.790
#> SD:mclust   6 0.832           0.796       0.887         0.0536 0.900   0.591
#> CV:mclust   6 0.829           0.821       0.895         0.0625 0.904   0.598
#> MAD:mclust  6 0.759           0.467       0.663         0.0487 0.838   0.398
#> ATC:mclust  6 0.923           0.898       0.950         0.0489 0.975   0.900
#> SD:kmeans   6 0.711           0.638       0.776         0.0454 0.889   0.537
#> CV:kmeans   6 0.700           0.537       0.725         0.0416 0.916   0.635
#> MAD:kmeans  6 0.703           0.616       0.753         0.0427 0.905   0.584
#> ATC:kmeans  6 0.801           0.676       0.838         0.0435 0.944   0.729
#> SD:pam      6 0.738           0.707       0.829         0.0714 0.931   0.719
#> CV:pam      6 0.744           0.622       0.785         0.0675 0.952   0.805
#> MAD:pam     6 0.705           0.594       0.787         0.0698 0.927   0.695
#> ATC:pam     6 0.836           0.468       0.815         0.0506 0.932   0.730
#> SD:hclust   6 0.672           0.585       0.726         0.0725 0.978   0.912
#> CV:hclust   6 0.656           0.640       0.781         0.0568 0.929   0.711
#> MAD:hclust  6 0.733           0.612       0.779         0.0708 0.894   0.614
#> ATC:hclust  6 0.748           0.827       0.880         0.0233 0.987   0.943

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

Test to known annotations

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res_list, k = 2)
#>              n time(p) individual(p) k
#> SD:NMF      53   0.677      0.006636 2
#> CV:NMF      52   0.588      0.007252 2
#> MAD:NMF     54   0.648      0.013584 2
#> ATC:NMF     56   0.857      0.032726 2
#> SD:skmeans  56   0.796      0.003293 2
#> CV:skmeans  54   0.678      0.004877 2
#> MAD:skmeans 56   0.796      0.003293 2
#> ATC:skmeans 52   0.389      0.012691 2
#> SD:mclust   57   0.377      0.234717 2
#> CV:mclust   57   0.377      0.234717 2
#> MAD:mclust  56   0.329      0.011870 2
#> ATC:mclust  57   0.292      0.173506 2
#> SD:kmeans   50   0.742      0.114040 2
#> CV:kmeans   42   0.870      0.042355 2
#> MAD:kmeans  15      NA            NA 2
#> ATC:kmeans  53   0.558      0.001038 2
#> SD:pam      56   0.620      0.034995 2
#> CV:pam      54   0.526      0.034927 2
#> MAD:pam     56   0.620      0.034995 2
#> ATC:pam     57   0.387      0.000693 2
#> SD:hclust   54   0.989      0.038378 2
#> CV:hclust   50   0.913      0.062364 2
#> MAD:hclust  43   0.959      0.123137 2
#> ATC:hclust  57   0.387      0.000693 2
test_to_known_factors(res_list, k = 3)
#>              n time(p) individual(p) k
#> SD:NMF      54   0.341      3.30e-02 3
#> CV:NMF      54   0.341      3.30e-02 3
#> MAD:NMF     56   0.344      2.92e-02 3
#> ATC:NMF     56   0.388      1.50e-02 3
#> SD:skmeans  52   0.759      7.69e-03 3
#> CV:skmeans  53   0.822      6.25e-03 3
#> MAD:skmeans 55   0.879      1.26e-03 3
#> ATC:skmeans 56   0.724      1.67e-02 3
#> SD:mclust   55   0.612      5.01e-04 3
#> CV:mclust   56   0.570      7.23e-04 3
#> MAD:mclust  55   0.787      4.21e-04 3
#> ATC:mclust  57   0.456      1.97e-04 3
#> SD:kmeans   55   0.497      6.96e-03 3
#> CV:kmeans   55   0.460      1.16e-02 3
#> MAD:kmeans  55   0.507      1.11e-02 3
#> ATC:kmeans  55   0.456      7.79e-04 3
#> SD:pam      53   0.762      7.10e-05 3
#> CV:pam      52   0.790      8.83e-05 3
#> MAD:pam     54   0.706      8.47e-05 3
#> ATC:pam     56   0.512      1.82e-03 3
#> SD:hclust   49   0.953      1.90e-04 3
#> CV:hclust   46   0.866      1.79e-03 3
#> MAD:hclust  48   0.929      3.04e-04 3
#> ATC:hclust  54   0.818      4.03e-04 3
test_to_known_factors(res_list, k = 4)
#>              n time(p) individual(p) k
#> SD:NMF      46   0.598      2.06e-03 4
#> CV:NMF      49   0.547      4.18e-03 4
#> MAD:NMF     51   0.167      8.84e-03 4
#> ATC:NMF     49   0.367      1.89e-03 4
#> SD:skmeans  57   0.238      6.40e-03 4
#> CV:skmeans  57   0.238      6.40e-03 4
#> MAD:skmeans 55   0.334      3.37e-03 4
#> ATC:skmeans 54   0.634      2.57e-03 4
#> SD:mclust   50   0.251      4.11e-04 4
#> CV:mclust   53   0.395      1.70e-04 4
#> MAD:mclust  53   0.443      1.57e-03 4
#> ATC:mclust  55   0.748      2.99e-04 4
#> SD:kmeans   40   0.360      2.37e-04 4
#> CV:kmeans   22   0.518      4.61e-02 4
#> MAD:kmeans  23   0.779      1.17e-01 4
#> ATC:kmeans  57   0.831      1.19e-04 4
#> SD:pam      54   0.898      3.89e-05 4
#> CV:pam      55   0.890      2.59e-05 4
#> MAD:pam     55   0.935      1.13e-05 4
#> ATC:pam     56   0.862      5.32e-04 4
#> SD:hclust   45   0.724      4.50e-03 4
#> CV:hclust   38   0.909      6.47e-04 4
#> MAD:hclust  39   0.833      5.95e-04 4
#> ATC:hclust  54   0.764      5.15e-04 4
test_to_known_factors(res_list, k = 5)
#>              n time(p) individual(p) k
#> SD:NMF      51   0.290      3.27e-04 5
#> CV:NMF      47   0.637      3.51e-04 5
#> MAD:NMF     46   0.788      1.65e-04 5
#> ATC:NMF     39   0.317      2.34e-04 5
#> SD:skmeans  45   0.550      1.20e-04 5
#> CV:skmeans  43   0.448      1.75e-04 5
#> MAD:skmeans 53   0.712      3.50e-06 5
#> ATC:skmeans 48   0.938      1.39e-03 5
#> SD:mclust   49   0.262      5.32e-03 5
#> CV:mclust   53   0.301      1.18e-03 5
#> MAD:mclust  37   0.269      3.67e-02 5
#> ATC:mclust  55   0.623      1.43e-04 5
#> SD:kmeans   42   0.107      5.09e-04 5
#> CV:kmeans   44   0.272      8.90e-05 5
#> MAD:kmeans  38   0.730      2.09e-04 5
#> ATC:kmeans  53   0.307      1.49e-05 5
#> SD:pam      55   0.563      4.64e-07 5
#> CV:pam      54   0.681      1.23e-06 5
#> MAD:pam     55   0.674      4.46e-07 5
#> ATC:pam     56   0.861      4.20e-03 5
#> SD:hclust   48   0.698      1.24e-04 5
#> CV:hclust   44   0.845      1.23e-04 5
#> MAD:hclust  48   0.698      1.24e-04 5
#> ATC:hclust  57   0.645      1.12e-02 5
test_to_known_factors(res_list, k = 6)
#>              n time(p) individual(p) k
#> SD:NMF      42   0.183      4.56e-07 6
#> CV:NMF      42   0.335      7.74e-06 6
#> MAD:NMF     42   0.558      6.54e-05 6
#> ATC:NMF     42   0.585      1.60e-04 6
#> SD:skmeans  45   0.851      1.87e-06 6
#> CV:skmeans  47   0.896      1.53e-06 6
#> MAD:skmeans 51   0.905      5.65e-07 6
#> ATC:skmeans 52   0.880      3.17e-07 6
#> SD:mclust   52   0.198      2.50e-03 6
#> CV:mclust   53   0.237      3.68e-03 6
#> MAD:mclust  37   0.607      1.69e-02 6
#> ATC:mclust  55   0.565      5.85e-03 6
#> SD:kmeans   47   0.405      1.97e-06 6
#> CV:kmeans   33   0.641      1.12e-03 6
#> MAD:kmeans  38   0.626      2.18e-05 6
#> ATC:kmeans  41   0.497      3.02e-04 6
#> SD:pam      51   0.792      2.37e-07 6
#> CV:pam      47   0.647      8.00e-07 6
#> MAD:pam     43   0.956      7.05e-06 6
#> ATC:pam     38   0.632      1.62e-02 6
#> SD:hclust   32   0.672      3.13e-03 6
#> CV:hclust   44   0.569      2.46e-04 6
#> MAD:hclust  41   0.728      1.10e-04 6
#> ATC:hclust  57   0.465      9.01e-03 6

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

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

collect_plots(res)

plot of chunk SD-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.420           0.780       0.865         0.3639 0.729   0.729
#> 3 3 0.549           0.733       0.883         0.5658 0.715   0.609
#> 4 4 0.477           0.620       0.770         0.1348 0.966   0.923
#> 5 5 0.611           0.709       0.821         0.1503 0.805   0.541
#> 6 6 0.672           0.585       0.726         0.0725 0.978   0.912

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
#> GSM872244     1  0.8955      0.726 0.688 0.312
#> GSM872245     1  0.0376      0.832 0.996 0.004
#> GSM872246     1  0.7528      0.788 0.784 0.216
#> GSM872247     1  0.8955      0.726 0.688 0.312
#> GSM872248     2  0.0000      0.923 0.000 1.000
#> GSM872249     1  0.8955      0.726 0.688 0.312
#> GSM872250     1  0.0000      0.832 1.000 0.000
#> GSM872251     1  0.8813      0.736 0.700 0.300
#> GSM872252     1  0.0000      0.832 1.000 0.000
#> GSM872253     1  0.3274      0.826 0.940 0.060
#> GSM872254     2  0.8327      0.686 0.264 0.736
#> GSM872255     1  0.0000      0.832 1.000 0.000
#> GSM872256     1  0.0672      0.832 0.992 0.008
#> GSM872257     2  0.0000      0.923 0.000 1.000
#> GSM872258     1  0.6887      0.801 0.816 0.184
#> GSM872259     1  0.0000      0.832 1.000 0.000
#> GSM872260     1  0.0000      0.832 1.000 0.000
#> GSM872261     1  0.9170      0.597 0.668 0.332
#> GSM872262     1  0.0000      0.832 1.000 0.000
#> GSM872263     1  0.8955      0.726 0.688 0.312
#> GSM872264     1  0.8443      0.753 0.728 0.272
#> GSM872265     1  0.8443      0.753 0.728 0.272
#> GSM872266     1  0.9522      0.568 0.628 0.372
#> GSM872267     2  0.0000      0.923 0.000 1.000
#> GSM872268     1  0.8955      0.726 0.688 0.312
#> GSM872269     2  0.8386      0.682 0.268 0.732
#> GSM872270     1  0.8955      0.726 0.688 0.312
#> GSM872271     1  0.9970      0.453 0.532 0.468
#> GSM872272     1  0.9970      0.453 0.532 0.468
#> GSM872273     1  0.0000      0.832 1.000 0.000
#> GSM872274     2  0.0000      0.923 0.000 1.000
#> GSM872275     1  0.4939      0.823 0.892 0.108
#> GSM872276     1  0.0000      0.832 1.000 0.000
#> GSM872277     1  0.0000      0.832 1.000 0.000
#> GSM872278     1  0.4431      0.826 0.908 0.092
#> GSM872279     1  0.0000      0.832 1.000 0.000
#> GSM872280     1  0.0000      0.832 1.000 0.000
#> GSM872281     1  0.4298      0.826 0.912 0.088
#> GSM872282     1  0.8955      0.726 0.688 0.312
#> GSM872283     1  0.8443      0.753 0.728 0.272
#> GSM872284     1  0.7674      0.783 0.776 0.224
#> GSM872285     1  0.6973      0.800 0.812 0.188
#> GSM872286     1  0.0000      0.832 1.000 0.000
#> GSM872287     1  0.8955      0.726 0.688 0.312
#> GSM872288     1  0.0000      0.832 1.000 0.000
#> GSM872289     1  0.7056      0.798 0.808 0.192
#> GSM872290     1  0.0000      0.832 1.000 0.000
#> GSM872291     1  0.0000      0.832 1.000 0.000
#> GSM872292     2  0.0000      0.923 0.000 1.000
#> GSM872293     1  0.0000      0.832 1.000 0.000
#> GSM872294     1  0.9909      0.204 0.556 0.444
#> GSM872295     2  0.0000      0.923 0.000 1.000
#> GSM872296     2  0.0000      0.923 0.000 1.000
#> GSM872297     1  0.0000      0.832 1.000 0.000
#> GSM872298     1  0.4431      0.826 0.908 0.092
#> GSM872299     1  0.0000      0.832 1.000 0.000
#> GSM872300     1  0.0000      0.832 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
#> GSM872244     3  0.0000     0.8094 0.000 0.000 1.000
#> GSM872245     1  0.0237     0.8483 0.996 0.004 0.000
#> GSM872246     3  0.5926     0.4671 0.356 0.000 0.644
#> GSM872247     3  0.0000     0.8094 0.000 0.000 1.000
#> GSM872248     2  0.0000     0.9127 0.000 1.000 0.000
#> GSM872249     3  0.0000     0.8094 0.000 0.000 1.000
#> GSM872250     1  0.0000     0.8491 1.000 0.000 0.000
#> GSM872251     3  0.0592     0.8024 0.012 0.000 0.988
#> GSM872252     1  0.0000     0.8491 1.000 0.000 0.000
#> GSM872253     1  0.3502     0.8089 0.896 0.020 0.084
#> GSM872254     2  0.5254     0.6679 0.264 0.736 0.000
#> GSM872255     1  0.0000     0.8491 1.000 0.000 0.000
#> GSM872256     1  0.0424     0.8482 0.992 0.000 0.008
#> GSM872257     2  0.0000     0.9127 0.000 1.000 0.000
#> GSM872258     3  0.6095     0.3992 0.392 0.000 0.608
#> GSM872259     1  0.0000     0.8491 1.000 0.000 0.000
#> GSM872260     1  0.0000     0.8491 1.000 0.000 0.000
#> GSM872261     1  0.8566     0.5089 0.608 0.204 0.188
#> GSM872262     1  0.1163     0.8440 0.972 0.000 0.028
#> GSM872263     3  0.0000     0.8094 0.000 0.000 1.000
#> GSM872264     1  0.5905     0.5028 0.648 0.000 0.352
#> GSM872265     1  0.5905     0.5028 0.648 0.000 0.352
#> GSM872266     1  0.8950     0.4457 0.568 0.212 0.220
#> GSM872267     2  0.0000     0.9127 0.000 1.000 0.000
#> GSM872268     3  0.0000     0.8094 0.000 0.000 1.000
#> GSM872269     2  0.5291     0.6637 0.268 0.732 0.000
#> GSM872270     3  0.0000     0.8094 0.000 0.000 1.000
#> GSM872271     1  0.9531     0.2196 0.456 0.200 0.344
#> GSM872272     1  0.9531     0.2196 0.456 0.200 0.344
#> GSM872273     1  0.0000     0.8491 1.000 0.000 0.000
#> GSM872274     2  0.0000     0.9127 0.000 1.000 0.000
#> GSM872275     1  0.4551     0.7698 0.840 0.020 0.140
#> GSM872276     1  0.1163     0.8440 0.972 0.000 0.028
#> GSM872277     1  0.0000     0.8491 1.000 0.000 0.000
#> GSM872278     1  0.3851     0.7786 0.860 0.004 0.136
#> GSM872279     1  0.0000     0.8491 1.000 0.000 0.000
#> GSM872280     1  0.1163     0.8440 0.972 0.000 0.028
#> GSM872281     1  0.3267     0.7962 0.884 0.000 0.116
#> GSM872282     3  0.0000     0.8094 0.000 0.000 1.000
#> GSM872283     1  0.5905     0.5028 0.648 0.000 0.352
#> GSM872284     1  0.5560     0.5868 0.700 0.000 0.300
#> GSM872285     3  0.6299     0.0564 0.476 0.000 0.524
#> GSM872286     1  0.0000     0.8491 1.000 0.000 0.000
#> GSM872287     3  0.0000     0.8094 0.000 0.000 1.000
#> GSM872288     1  0.0000     0.8491 1.000 0.000 0.000
#> GSM872289     3  0.5988     0.4532 0.368 0.000 0.632
#> GSM872290     1  0.0000     0.8491 1.000 0.000 0.000
#> GSM872291     1  0.1031     0.8450 0.976 0.000 0.024
#> GSM872292     2  0.0000     0.9127 0.000 1.000 0.000
#> GSM872293     1  0.0000     0.8491 1.000 0.000 0.000
#> GSM872294     1  0.6897     0.1761 0.548 0.436 0.016
#> GSM872295     2  0.0000     0.9127 0.000 1.000 0.000
#> GSM872296     2  0.0000     0.9127 0.000 1.000 0.000
#> GSM872297     1  0.0000     0.8491 1.000 0.000 0.000
#> GSM872298     1  0.3851     0.7786 0.860 0.004 0.136
#> GSM872299     1  0.0000     0.8491 1.000 0.000 0.000
#> GSM872300     1  0.1163     0.8440 0.972 0.000 0.028

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM872244     3  0.0000      0.799 0.000 0.000 1.000 0.000
#> GSM872245     1  0.5119      0.589 0.556 0.004 0.000 0.440
#> GSM872246     3  0.4776      0.434 0.376 0.000 0.624 0.000
#> GSM872247     3  0.0000      0.799 0.000 0.000 1.000 0.000
#> GSM872248     2  0.0000      0.767 0.000 1.000 0.000 0.000
#> GSM872249     3  0.0000      0.799 0.000 0.000 1.000 0.000
#> GSM872250     1  0.4948      0.591 0.560 0.000 0.000 0.440
#> GSM872251     3  0.0469      0.791 0.012 0.000 0.988 0.000
#> GSM872252     1  0.4356      0.684 0.708 0.000 0.000 0.292
#> GSM872253     1  0.2877      0.713 0.904 0.008 0.060 0.028
#> GSM872254     2  0.4431      0.588 0.000 0.696 0.000 0.304
#> GSM872255     1  0.0921      0.733 0.972 0.000 0.000 0.028
#> GSM872256     1  0.3545      0.720 0.828 0.000 0.008 0.164
#> GSM872257     2  0.0000      0.767 0.000 1.000 0.000 0.000
#> GSM872258     3  0.4888      0.372 0.412 0.000 0.588 0.000
#> GSM872259     1  0.3528      0.711 0.808 0.000 0.000 0.192
#> GSM872260     1  0.0921      0.733 0.972 0.000 0.000 0.028
#> GSM872261     1  0.7824      0.308 0.480 0.016 0.168 0.336
#> GSM872262     1  0.0336      0.731 0.992 0.000 0.008 0.000
#> GSM872263     3  0.0000      0.799 0.000 0.000 1.000 0.000
#> GSM872264     1  0.4978      0.471 0.664 0.000 0.324 0.012
#> GSM872265     1  0.4978      0.471 0.664 0.000 0.324 0.012
#> GSM872266     1  0.8231      0.244 0.432 0.024 0.200 0.344
#> GSM872267     2  0.0000      0.767 0.000 1.000 0.000 0.000
#> GSM872268     3  0.0000      0.799 0.000 0.000 1.000 0.000
#> GSM872269     2  0.4608      0.584 0.004 0.692 0.000 0.304
#> GSM872270     3  0.0000      0.799 0.000 0.000 1.000 0.000
#> GSM872271     1  0.7887      0.214 0.472 0.012 0.316 0.200
#> GSM872272     1  0.7887      0.214 0.472 0.012 0.316 0.200
#> GSM872273     1  0.3528      0.711 0.808 0.000 0.000 0.192
#> GSM872274     4  0.4981      0.528 0.000 0.464 0.000 0.536
#> GSM872275     1  0.3653      0.683 0.856 0.008 0.112 0.024
#> GSM872276     1  0.0336      0.731 0.992 0.000 0.008 0.000
#> GSM872277     1  0.3528      0.711 0.808 0.000 0.000 0.192
#> GSM872278     1  0.3048      0.688 0.876 0.000 0.108 0.016
#> GSM872279     1  0.4356      0.684 0.708 0.000 0.000 0.292
#> GSM872280     1  0.0336      0.731 0.992 0.000 0.008 0.000
#> GSM872281     1  0.2281      0.707 0.904 0.000 0.096 0.000
#> GSM872282     3  0.0000      0.799 0.000 0.000 1.000 0.000
#> GSM872283     1  0.4978      0.471 0.664 0.000 0.324 0.012
#> GSM872284     1  0.4663      0.532 0.716 0.000 0.272 0.012
#> GSM872285     3  0.5000      0.103 0.496 0.000 0.504 0.000
#> GSM872286     1  0.4948      0.591 0.560 0.000 0.000 0.440
#> GSM872287     3  0.0000      0.799 0.000 0.000 1.000 0.000
#> GSM872288     1  0.4948      0.591 0.560 0.000 0.000 0.440
#> GSM872289     3  0.4776      0.440 0.376 0.000 0.624 0.000
#> GSM872290     1  0.4356      0.684 0.708 0.000 0.000 0.292
#> GSM872291     1  0.0524      0.732 0.988 0.000 0.008 0.004
#> GSM872292     4  0.4981      0.528 0.000 0.464 0.000 0.536
#> GSM872293     1  0.3528      0.711 0.808 0.000 0.000 0.192
#> GSM872294     4  0.7141      0.111 0.328 0.120 0.008 0.544
#> GSM872295     2  0.1211      0.744 0.000 0.960 0.000 0.040
#> GSM872296     4  0.4981      0.528 0.000 0.464 0.000 0.536
#> GSM872297     1  0.3528      0.711 0.808 0.000 0.000 0.192
#> GSM872298     1  0.3048      0.688 0.876 0.000 0.108 0.016
#> GSM872299     1  0.4356      0.684 0.708 0.000 0.000 0.292
#> GSM872300     1  0.0336      0.731 0.992 0.000 0.008 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
#> GSM872244     3  0.0000     0.8552 0.000 0.000 1.000 0.000 0.000
#> GSM872245     1  0.1399     0.7863 0.952 0.000 0.000 0.020 0.028
#> GSM872246     3  0.4138     0.3928 0.000 0.000 0.616 0.384 0.000
#> GSM872247     3  0.0000     0.8552 0.000 0.000 1.000 0.000 0.000
#> GSM872248     5  0.4026     0.8304 0.020 0.244 0.000 0.000 0.736
#> GSM872249     3  0.0000     0.8552 0.000 0.000 1.000 0.000 0.000
#> GSM872250     1  0.1310     0.7905 0.956 0.000 0.000 0.020 0.024
#> GSM872251     3  0.0404     0.8455 0.000 0.000 0.988 0.012 0.000
#> GSM872252     1  0.2605     0.8780 0.852 0.000 0.000 0.148 0.000
#> GSM872253     4  0.2672     0.7376 0.064 0.000 0.024 0.896 0.016
#> GSM872254     5  0.3855     0.6384 0.240 0.008 0.000 0.004 0.748
#> GSM872255     4  0.2886     0.6817 0.148 0.000 0.000 0.844 0.008
#> GSM872256     1  0.4067     0.7977 0.692 0.000 0.000 0.300 0.008
#> GSM872257     5  0.4026     0.8304 0.020 0.244 0.000 0.000 0.736
#> GSM872258     3  0.4227     0.3296 0.000 0.000 0.580 0.420 0.000
#> GSM872259     1  0.3942     0.8653 0.748 0.000 0.000 0.232 0.020
#> GSM872260     4  0.2886     0.6817 0.148 0.000 0.000 0.844 0.008
#> GSM872261     4  0.7767     0.3883 0.136 0.156 0.088 0.568 0.052
#> GSM872262     4  0.2020     0.7279 0.100 0.000 0.000 0.900 0.000
#> GSM872263     3  0.0000     0.8552 0.000 0.000 1.000 0.000 0.000
#> GSM872264     4  0.3424     0.6370 0.000 0.000 0.240 0.760 0.000
#> GSM872265     4  0.3424     0.6370 0.000 0.000 0.240 0.760 0.000
#> GSM872266     4  0.8278     0.3454 0.136 0.160 0.124 0.520 0.060
#> GSM872267     5  0.4026     0.8304 0.020 0.244 0.000 0.000 0.736
#> GSM872268     3  0.0000     0.8552 0.000 0.000 1.000 0.000 0.000
#> GSM872269     5  0.1914     0.6727 0.056 0.008 0.000 0.008 0.928
#> GSM872270     3  0.0000     0.8552 0.000 0.000 1.000 0.000 0.000
#> GSM872271     4  0.6840     0.4485 0.004 0.156 0.232 0.568 0.040
#> GSM872272     4  0.6840     0.4485 0.004 0.156 0.232 0.568 0.040
#> GSM872273     1  0.3942     0.8653 0.748 0.000 0.000 0.232 0.020
#> GSM872274     2  0.0000     0.7019 0.000 1.000 0.000 0.000 0.000
#> GSM872275     4  0.3003     0.7411 0.040 0.000 0.064 0.880 0.016
#> GSM872276     4  0.2020     0.7279 0.100 0.000 0.000 0.900 0.000
#> GSM872277     1  0.3942     0.8653 0.748 0.000 0.000 0.232 0.020
#> GSM872278     4  0.2359     0.7431 0.036 0.000 0.060 0.904 0.000
#> GSM872279     1  0.2605     0.8780 0.852 0.000 0.000 0.148 0.000
#> GSM872280     4  0.2020     0.7279 0.100 0.000 0.000 0.900 0.000
#> GSM872281     4  0.3535     0.7410 0.088 0.000 0.080 0.832 0.000
#> GSM872282     3  0.0000     0.8552 0.000 0.000 1.000 0.000 0.000
#> GSM872283     4  0.3424     0.6370 0.000 0.000 0.240 0.760 0.000
#> GSM872284     4  0.3003     0.6773 0.000 0.000 0.188 0.812 0.000
#> GSM872285     4  0.4307    -0.0274 0.000 0.000 0.496 0.504 0.000
#> GSM872286     1  0.1310     0.7905 0.956 0.000 0.000 0.020 0.024
#> GSM872287     3  0.0000     0.8552 0.000 0.000 1.000 0.000 0.000
#> GSM872288     1  0.1310     0.7905 0.956 0.000 0.000 0.020 0.024
#> GSM872289     3  0.4114     0.4282 0.000 0.000 0.624 0.376 0.000
#> GSM872290     1  0.2605     0.8780 0.852 0.000 0.000 0.148 0.000
#> GSM872291     4  0.2179     0.7218 0.112 0.000 0.000 0.888 0.000
#> GSM872292     2  0.0000     0.7019 0.000 1.000 0.000 0.000 0.000
#> GSM872293     1  0.3942     0.8653 0.748 0.000 0.000 0.232 0.020
#> GSM872294     2  0.7116     0.1392 0.016 0.388 0.000 0.352 0.244
#> GSM872295     5  0.3550     0.8154 0.000 0.236 0.000 0.004 0.760
#> GSM872296     2  0.0000     0.7019 0.000 1.000 0.000 0.000 0.000
#> GSM872297     1  0.3942     0.8653 0.748 0.000 0.000 0.232 0.020
#> GSM872298     4  0.2359     0.7431 0.036 0.000 0.060 0.904 0.000
#> GSM872299     1  0.2605     0.8780 0.852 0.000 0.000 0.148 0.000
#> GSM872300     4  0.2020     0.7279 0.100 0.000 0.000 0.900 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
#> GSM872244     3  0.0146     0.8115 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM872245     1  0.2852     0.7610 0.856 0.000 0.000 0.000 0.064 0.080
#> GSM872246     3  0.4683     0.4546 0.000 0.000 0.616 0.320 0.000 0.064
#> GSM872247     3  0.0000     0.8126 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872248     5  0.2454     0.7556 0.000 0.160 0.000 0.000 0.840 0.000
#> GSM872249     3  0.0000     0.8126 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872250     1  0.2794     0.7651 0.860 0.000 0.000 0.000 0.060 0.080
#> GSM872251     3  0.0363     0.8064 0.000 0.000 0.988 0.012 0.000 0.000
#> GSM872252     1  0.0547     0.8358 0.980 0.000 0.000 0.020 0.000 0.000
#> GSM872253     4  0.5044     0.3978 0.068 0.000 0.024 0.648 0.000 0.260
#> GSM872254     5  0.5219     0.5362 0.124 0.000 0.000 0.000 0.580 0.296
#> GSM872255     4  0.5761     0.3806 0.172 0.000 0.000 0.432 0.000 0.396
#> GSM872256     1  0.4745     0.6775 0.672 0.000 0.000 0.124 0.000 0.204
#> GSM872257     5  0.2454     0.7556 0.000 0.160 0.000 0.000 0.840 0.000
#> GSM872258     3  0.5090     0.4006 0.012 0.000 0.580 0.344 0.000 0.064
#> GSM872259     1  0.3493     0.8099 0.800 0.000 0.000 0.064 0.000 0.136
#> GSM872260     4  0.5761     0.3806 0.172 0.000 0.000 0.432 0.000 0.396
#> GSM872261     4  0.7683    -0.1921 0.068 0.148 0.060 0.464 0.008 0.252
#> GSM872262     4  0.4738     0.4793 0.064 0.000 0.000 0.600 0.000 0.336
#> GSM872263     3  0.0146     0.8115 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM872264     4  0.2597     0.3702 0.000 0.000 0.176 0.824 0.000 0.000
#> GSM872265     4  0.2597     0.3702 0.000 0.000 0.176 0.824 0.000 0.000
#> GSM872266     4  0.8073    -0.1985 0.064 0.152 0.084 0.432 0.016 0.252
#> GSM872267     5  0.2454     0.7556 0.000 0.160 0.000 0.000 0.840 0.000
#> GSM872268     3  0.0000     0.8126 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872269     5  0.4446     0.5421 0.040 0.000 0.000 0.000 0.612 0.348
#> GSM872270     3  0.0000     0.8126 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872271     4  0.7138    -0.0539 0.004 0.148 0.172 0.500 0.004 0.172
#> GSM872272     4  0.7138    -0.0539 0.004 0.148 0.172 0.500 0.004 0.172
#> GSM872273     1  0.3786     0.7911 0.768 0.000 0.000 0.064 0.000 0.168
#> GSM872274     2  0.0000     1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM872275     4  0.4125     0.3904 0.016 0.000 0.028 0.724 0.000 0.232
#> GSM872276     4  0.4738     0.4793 0.064 0.000 0.000 0.600 0.000 0.336
#> GSM872277     1  0.3493     0.8099 0.800 0.000 0.000 0.064 0.000 0.136
#> GSM872278     4  0.4364     0.4827 0.012 0.000 0.024 0.656 0.000 0.308
#> GSM872279     1  0.0547     0.8358 0.980 0.000 0.000 0.020 0.000 0.000
#> GSM872280     4  0.4855     0.4694 0.064 0.000 0.000 0.556 0.000 0.380
#> GSM872281     4  0.4887     0.4769 0.020 0.000 0.040 0.608 0.000 0.332
#> GSM872282     3  0.0146     0.8115 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM872283     4  0.2597     0.3702 0.000 0.000 0.176 0.824 0.000 0.000
#> GSM872284     4  0.2092     0.3931 0.000 0.000 0.124 0.876 0.000 0.000
#> GSM872285     3  0.5870     0.1858 0.008 0.000 0.496 0.328 0.000 0.168
#> GSM872286     1  0.2794     0.7651 0.860 0.000 0.000 0.000 0.060 0.080
#> GSM872287     3  0.0000     0.8126 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872288     1  0.2794     0.7651 0.860 0.000 0.000 0.000 0.060 0.080
#> GSM872289     3  0.4647     0.4755 0.012 0.000 0.624 0.328 0.000 0.036
#> GSM872290     1  0.0547     0.8358 0.980 0.000 0.000 0.020 0.000 0.000
#> GSM872291     4  0.4926     0.4729 0.080 0.000 0.000 0.584 0.000 0.336
#> GSM872292     2  0.0000     1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM872293     1  0.3786     0.7911 0.768 0.000 0.000 0.064 0.000 0.168
#> GSM872294     6  0.6076     0.0000 0.000 0.380 0.000 0.044 0.100 0.476
#> GSM872295     5  0.5078     0.7193 0.000 0.160 0.000 0.000 0.632 0.208
#> GSM872296     2  0.0000     1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM872297     1  0.3493     0.8099 0.800 0.000 0.000 0.064 0.000 0.136
#> GSM872298     4  0.4364     0.4827 0.012 0.000 0.024 0.656 0.000 0.308
#> GSM872299     1  0.0547     0.8358 0.980 0.000 0.000 0.020 0.000 0.000
#> GSM872300     4  0.4738     0.4793 0.064 0.000 0.000 0.600 0.000 0.336

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

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>            n time(p) individual(p) k
#> SD:hclust 54   0.989      0.038378 2
#> SD:hclust 49   0.953      0.000190 3
#> SD:hclust 45   0.724      0.004503 4
#> SD:hclust 48   0.698      0.000124 5
#> SD:hclust 32   0.672      0.003131 6

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 29485 rows and 57 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.217           0.635       0.823         0.4388 0.589   0.589
#> 3 3 0.820           0.873       0.942         0.4868 0.673   0.483
#> 4 4 0.624           0.627       0.816         0.1340 0.841   0.587
#> 5 5 0.690           0.639       0.771         0.0679 0.845   0.499
#> 6 6 0.711           0.638       0.776         0.0454 0.889   0.537

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
#> GSM872244     1  0.9795     0.1734 0.584 0.416
#> GSM872245     2  0.9988    -0.1034 0.480 0.520
#> GSM872246     1  0.4562     0.7179 0.904 0.096
#> GSM872247     1  0.4562     0.7179 0.904 0.096
#> GSM872248     2  0.0000     0.8254 0.000 1.000
#> GSM872249     1  0.4690     0.7152 0.900 0.100
#> GSM872250     2  0.9635     0.0798 0.388 0.612
#> GSM872251     1  0.4562     0.7179 0.904 0.096
#> GSM872252     1  0.9358     0.5261 0.648 0.352
#> GSM872253     1  0.6048     0.7244 0.852 0.148
#> GSM872254     2  0.0000     0.8254 0.000 1.000
#> GSM872255     1  0.5629     0.7348 0.868 0.132
#> GSM872256     1  0.9358     0.5261 0.648 0.352
#> GSM872257     2  0.1184     0.8283 0.016 0.984
#> GSM872258     1  0.4562     0.7179 0.904 0.096
#> GSM872259     1  0.9358     0.5261 0.648 0.352
#> GSM872260     1  0.5629     0.7348 0.868 0.132
#> GSM872261     2  0.9635     0.0798 0.388 0.612
#> GSM872262     1  0.5519     0.7359 0.872 0.128
#> GSM872263     1  0.4562     0.7179 0.904 0.096
#> GSM872264     1  0.7950     0.6120 0.760 0.240
#> GSM872265     1  0.9129     0.5991 0.672 0.328
#> GSM872266     2  0.0376     0.8268 0.004 0.996
#> GSM872267     2  0.0000     0.8254 0.000 1.000
#> GSM872268     1  0.4562     0.7179 0.904 0.096
#> GSM872269     2  0.7139     0.5939 0.196 0.804
#> GSM872270     1  0.7528     0.5894 0.784 0.216
#> GSM872271     2  0.4562     0.7859 0.096 0.904
#> GSM872272     2  0.4562     0.7859 0.096 0.904
#> GSM872273     1  0.7139     0.7004 0.804 0.196
#> GSM872274     2  0.2043     0.8242 0.032 0.968
#> GSM872275     1  0.5519     0.7226 0.872 0.128
#> GSM872276     1  0.5519     0.7359 0.872 0.128
#> GSM872277     1  0.7139     0.7004 0.804 0.196
#> GSM872278     1  0.5408     0.7241 0.876 0.124
#> GSM872279     1  0.9358     0.5261 0.648 0.352
#> GSM872280     1  0.0000     0.7223 1.000 0.000
#> GSM872281     1  0.2043     0.7326 0.968 0.032
#> GSM872282     1  0.9795     0.1734 0.584 0.416
#> GSM872283     1  0.7139     0.7034 0.804 0.196
#> GSM872284     1  0.5178     0.7373 0.884 0.116
#> GSM872285     1  0.2948     0.7251 0.948 0.052
#> GSM872286     1  0.9881     0.3200 0.564 0.436
#> GSM872287     1  0.4562     0.7179 0.904 0.096
#> GSM872288     1  0.9393     0.5243 0.644 0.356
#> GSM872289     1  0.4562     0.7179 0.904 0.096
#> GSM872290     1  0.9358     0.5261 0.648 0.352
#> GSM872291     1  0.5629     0.7348 0.868 0.132
#> GSM872292     2  0.2043     0.8242 0.032 0.968
#> GSM872293     1  0.9358     0.5261 0.648 0.352
#> GSM872294     2  0.1414     0.8282 0.020 0.980
#> GSM872295     2  0.1843     0.8254 0.028 0.972
#> GSM872296     2  0.2043     0.8242 0.032 0.968
#> GSM872297     1  0.9358     0.5261 0.648 0.352
#> GSM872298     1  0.5519     0.7359 0.872 0.128
#> GSM872299     1  0.9954     0.2429 0.540 0.460
#> GSM872300     1  0.5519     0.7359 0.872 0.128

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM872244     3  0.0000      0.938 0.000 0.000 1.000
#> GSM872245     1  0.0747      0.910 0.984 0.016 0.000
#> GSM872246     3  0.0237      0.940 0.004 0.000 0.996
#> GSM872247     3  0.0237      0.940 0.004 0.000 0.996
#> GSM872248     2  0.0592      0.960 0.012 0.988 0.000
#> GSM872249     3  0.0000      0.938 0.000 0.000 1.000
#> GSM872250     1  0.4452      0.723 0.808 0.192 0.000
#> GSM872251     3  0.0237      0.940 0.004 0.000 0.996
#> GSM872252     1  0.0237      0.915 0.996 0.004 0.000
#> GSM872253     3  0.3482      0.836 0.128 0.000 0.872
#> GSM872254     2  0.1753      0.937 0.048 0.952 0.000
#> GSM872255     1  0.0592      0.912 0.988 0.000 0.012
#> GSM872256     1  0.0000      0.915 1.000 0.000 0.000
#> GSM872257     2  0.0000      0.960 0.000 1.000 0.000
#> GSM872258     3  0.0237      0.940 0.004 0.000 0.996
#> GSM872259     1  0.0237      0.915 0.996 0.004 0.000
#> GSM872260     1  0.0000      0.915 1.000 0.000 0.000
#> GSM872261     1  0.6111      0.313 0.604 0.396 0.000
#> GSM872262     1  0.1753      0.893 0.952 0.000 0.048
#> GSM872263     3  0.0237      0.940 0.004 0.000 0.996
#> GSM872264     3  0.6079      0.300 0.388 0.000 0.612
#> GSM872265     1  0.5678      0.573 0.684 0.000 0.316
#> GSM872266     2  0.0592      0.960 0.012 0.988 0.000
#> GSM872267     2  0.0592      0.960 0.012 0.988 0.000
#> GSM872268     3  0.0237      0.940 0.004 0.000 0.996
#> GSM872269     2  0.4555      0.762 0.200 0.800 0.000
#> GSM872270     3  0.0000      0.938 0.000 0.000 1.000
#> GSM872271     2  0.2749      0.919 0.012 0.924 0.064
#> GSM872272     2  0.2749      0.919 0.012 0.924 0.064
#> GSM872273     1  0.0000      0.915 1.000 0.000 0.000
#> GSM872274     2  0.0475      0.961 0.004 0.992 0.004
#> GSM872275     3  0.1163      0.928 0.028 0.000 0.972
#> GSM872276     1  0.1753      0.893 0.952 0.000 0.048
#> GSM872277     1  0.0000      0.915 1.000 0.000 0.000
#> GSM872278     3  0.1163      0.928 0.028 0.000 0.972
#> GSM872279     1  0.0237      0.915 0.996 0.004 0.000
#> GSM872280     3  0.5058      0.680 0.244 0.000 0.756
#> GSM872281     1  0.5859      0.509 0.656 0.000 0.344
#> GSM872282     3  0.0892      0.924 0.000 0.020 0.980
#> GSM872283     1  0.3686      0.811 0.860 0.000 0.140
#> GSM872284     1  0.5650      0.574 0.688 0.000 0.312
#> GSM872285     3  0.0237      0.940 0.004 0.000 0.996
#> GSM872286     1  0.0424      0.914 0.992 0.008 0.000
#> GSM872287     3  0.0237      0.940 0.004 0.000 0.996
#> GSM872288     1  0.0424      0.914 0.992 0.008 0.000
#> GSM872289     3  0.0892      0.932 0.020 0.000 0.980
#> GSM872290     1  0.0237      0.915 0.996 0.004 0.000
#> GSM872291     1  0.0000      0.915 1.000 0.000 0.000
#> GSM872292     2  0.0475      0.961 0.004 0.992 0.004
#> GSM872293     1  0.0237      0.915 0.996 0.004 0.000
#> GSM872294     2  0.0475      0.961 0.004 0.992 0.004
#> GSM872295     2  0.0000      0.960 0.000 1.000 0.000
#> GSM872296     2  0.0475      0.961 0.004 0.992 0.004
#> GSM872297     1  0.0237      0.915 0.996 0.004 0.000
#> GSM872298     1  0.1753      0.893 0.952 0.000 0.048
#> GSM872299     1  0.0424      0.914 0.992 0.008 0.000
#> GSM872300     1  0.0892      0.909 0.980 0.000 0.020

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM872244     3  0.0657      0.895 0.012 0.000 0.984 0.004
#> GSM872245     1  0.0817      0.709 0.976 0.000 0.000 0.024
#> GSM872246     3  0.0000      0.898 0.000 0.000 1.000 0.000
#> GSM872247     3  0.0336      0.899 0.008 0.000 0.992 0.000
#> GSM872248     2  0.4804      0.331 0.384 0.616 0.000 0.000
#> GSM872249     3  0.0469      0.898 0.012 0.000 0.988 0.000
#> GSM872250     1  0.0779      0.708 0.980 0.004 0.000 0.016
#> GSM872251     3  0.0336      0.899 0.008 0.000 0.992 0.000
#> GSM872252     1  0.4679      0.211 0.648 0.000 0.000 0.352
#> GSM872253     3  0.5997      0.648 0.084 0.004 0.680 0.232
#> GSM872254     1  0.4697      0.333 0.644 0.356 0.000 0.000
#> GSM872255     4  0.2345      0.696 0.100 0.000 0.000 0.900
#> GSM872256     4  0.4877      0.496 0.408 0.000 0.000 0.592
#> GSM872257     2  0.1211      0.726 0.040 0.960 0.000 0.000
#> GSM872258     3  0.0000      0.898 0.000 0.000 1.000 0.000
#> GSM872259     4  0.4981      0.424 0.464 0.000 0.000 0.536
#> GSM872260     4  0.3024      0.682 0.148 0.000 0.000 0.852
#> GSM872261     1  0.5293      0.532 0.748 0.100 0.000 0.152
#> GSM872262     4  0.0921      0.703 0.028 0.000 0.000 0.972
#> GSM872263     3  0.0469      0.896 0.012 0.000 0.988 0.000
#> GSM872264     4  0.6544      0.358 0.044 0.040 0.276 0.640
#> GSM872265     4  0.5691      0.551 0.044 0.040 0.172 0.744
#> GSM872266     1  0.5290     -0.135 0.516 0.476 0.000 0.008
#> GSM872267     2  0.4746      0.365 0.368 0.632 0.000 0.000
#> GSM872268     3  0.0336      0.899 0.008 0.000 0.992 0.000
#> GSM872269     1  0.4679      0.342 0.648 0.352 0.000 0.000
#> GSM872270     3  0.0524      0.898 0.008 0.000 0.988 0.004
#> GSM872271     2  0.8857      0.280 0.208 0.452 0.072 0.268
#> GSM872272     2  0.8857      0.280 0.208 0.452 0.072 0.268
#> GSM872273     4  0.3907      0.641 0.232 0.000 0.000 0.768
#> GSM872274     2  0.0000      0.740 0.000 1.000 0.000 0.000
#> GSM872275     3  0.5051      0.682 0.028 0.004 0.724 0.244
#> GSM872276     4  0.0921      0.703 0.028 0.000 0.000 0.972
#> GSM872277     4  0.3907      0.641 0.232 0.000 0.000 0.768
#> GSM872278     3  0.5746      0.481 0.028 0.004 0.600 0.368
#> GSM872279     4  0.4996      0.380 0.484 0.000 0.000 0.516
#> GSM872280     4  0.4391      0.475 0.008 0.000 0.252 0.740
#> GSM872281     4  0.2928      0.647 0.012 0.000 0.108 0.880
#> GSM872282     3  0.0844      0.894 0.012 0.004 0.980 0.004
#> GSM872283     4  0.4876      0.602 0.068 0.032 0.088 0.812
#> GSM872284     4  0.3464      0.638 0.032 0.000 0.108 0.860
#> GSM872285     3  0.3942      0.713 0.000 0.000 0.764 0.236
#> GSM872286     1  0.1022      0.706 0.968 0.000 0.000 0.032
#> GSM872287     3  0.0336      0.899 0.008 0.000 0.992 0.000
#> GSM872288     1  0.0707      0.709 0.980 0.000 0.000 0.020
#> GSM872289     3  0.1302      0.868 0.044 0.000 0.956 0.000
#> GSM872290     4  0.4972      0.435 0.456 0.000 0.000 0.544
#> GSM872291     4  0.1022      0.703 0.032 0.000 0.000 0.968
#> GSM872292     2  0.0000      0.740 0.000 1.000 0.000 0.000
#> GSM872293     4  0.4977      0.433 0.460 0.000 0.000 0.540
#> GSM872294     2  0.0000      0.740 0.000 1.000 0.000 0.000
#> GSM872295     2  0.1118      0.728 0.036 0.964 0.000 0.000
#> GSM872296     2  0.0000      0.740 0.000 1.000 0.000 0.000
#> GSM872297     4  0.4961      0.447 0.448 0.000 0.000 0.552
#> GSM872298     4  0.1489      0.699 0.044 0.000 0.004 0.952
#> GSM872299     1  0.2281      0.659 0.904 0.000 0.000 0.096
#> GSM872300     4  0.0921      0.703 0.028 0.000 0.000 0.972

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM872244     3  0.1911    0.89911 0.004 0.000 0.932 0.036 0.028
#> GSM872245     5  0.4152    0.59201 0.296 0.000 0.000 0.012 0.692
#> GSM872246     3  0.1484    0.91208 0.000 0.000 0.944 0.048 0.008
#> GSM872247     3  0.0703    0.91390 0.000 0.000 0.976 0.024 0.000
#> GSM872248     5  0.4687    0.38829 0.000 0.336 0.000 0.028 0.636
#> GSM872249     3  0.0162    0.91113 0.000 0.000 0.996 0.004 0.000
#> GSM872250     5  0.2389    0.71340 0.116 0.000 0.000 0.004 0.880
#> GSM872251     3  0.1267    0.91152 0.004 0.000 0.960 0.024 0.012
#> GSM872252     1  0.6439    0.26740 0.448 0.000 0.000 0.180 0.372
#> GSM872253     4  0.6927    0.48762 0.036 0.000 0.240 0.532 0.192
#> GSM872254     5  0.3012    0.66757 0.000 0.124 0.000 0.024 0.852
#> GSM872255     1  0.4661    0.46598 0.656 0.000 0.000 0.312 0.032
#> GSM872256     1  0.1830    0.64985 0.924 0.000 0.000 0.008 0.068
#> GSM872257     2  0.2248    0.90542 0.000 0.900 0.000 0.012 0.088
#> GSM872258     3  0.2529    0.88407 0.004 0.000 0.900 0.056 0.040
#> GSM872259     1  0.2583    0.61216 0.864 0.000 0.000 0.004 0.132
#> GSM872260     1  0.4603    0.47970 0.668 0.000 0.000 0.300 0.032
#> GSM872261     5  0.5289    0.26395 0.064 0.000 0.000 0.340 0.596
#> GSM872262     1  0.4893    0.29234 0.568 0.000 0.000 0.404 0.028
#> GSM872263     3  0.1911    0.89911 0.004 0.000 0.932 0.036 0.028
#> GSM872264     4  0.4165    0.67483 0.072 0.032 0.056 0.828 0.012
#> GSM872265     4  0.4083    0.67263 0.084 0.032 0.036 0.832 0.016
#> GSM872266     5  0.4094    0.61100 0.000 0.128 0.000 0.084 0.788
#> GSM872267     5  0.4733    0.36330 0.000 0.348 0.000 0.028 0.624
#> GSM872268     3  0.0703    0.91390 0.000 0.000 0.976 0.024 0.000
#> GSM872269     5  0.3573    0.67118 0.012 0.124 0.000 0.032 0.832
#> GSM872270     3  0.0727    0.91383 0.004 0.000 0.980 0.012 0.004
#> GSM872271     4  0.5522    0.57650 0.012 0.148 0.020 0.716 0.104
#> GSM872272     4  0.5522    0.57650 0.012 0.148 0.020 0.716 0.104
#> GSM872273     1  0.1671    0.63197 0.924 0.000 0.000 0.076 0.000
#> GSM872274     2  0.0162    0.94698 0.000 0.996 0.000 0.000 0.004
#> GSM872275     4  0.5888    0.54169 0.028 0.000 0.276 0.620 0.076
#> GSM872276     1  0.4885    0.30205 0.572 0.000 0.000 0.400 0.028
#> GSM872277     1  0.2069    0.63252 0.912 0.000 0.000 0.076 0.012
#> GSM872278     4  0.4880    0.63095 0.028 0.000 0.196 0.732 0.044
#> GSM872279     1  0.3016    0.59107 0.848 0.000 0.000 0.020 0.132
#> GSM872280     4  0.6784    0.15933 0.356 0.000 0.120 0.488 0.036
#> GSM872281     4  0.3596    0.59490 0.212 0.000 0.012 0.776 0.000
#> GSM872282     3  0.1990    0.89722 0.004 0.000 0.928 0.040 0.028
#> GSM872283     4  0.3804    0.65813 0.104 0.032 0.008 0.836 0.020
#> GSM872284     4  0.3544    0.60334 0.200 0.000 0.008 0.788 0.004
#> GSM872285     3  0.6078   -0.00929 0.052 0.000 0.528 0.384 0.036
#> GSM872286     5  0.2813    0.70240 0.168 0.000 0.000 0.000 0.832
#> GSM872287     3  0.0703    0.91390 0.000 0.000 0.976 0.024 0.000
#> GSM872288     5  0.2674    0.71120 0.140 0.000 0.000 0.004 0.856
#> GSM872289     3  0.2928    0.85489 0.004 0.000 0.872 0.032 0.092
#> GSM872290     1  0.2462    0.62456 0.880 0.000 0.000 0.008 0.112
#> GSM872291     1  0.4836    0.39521 0.612 0.000 0.000 0.356 0.032
#> GSM872292     2  0.0162    0.94698 0.000 0.996 0.000 0.000 0.004
#> GSM872293     1  0.2179    0.62579 0.888 0.000 0.000 0.000 0.112
#> GSM872294     2  0.1251    0.91906 0.000 0.956 0.000 0.036 0.008
#> GSM872295     2  0.2351    0.90568 0.000 0.896 0.000 0.016 0.088
#> GSM872296     2  0.0000    0.94525 0.000 1.000 0.000 0.000 0.000
#> GSM872297     1  0.2513    0.62515 0.876 0.000 0.000 0.008 0.116
#> GSM872298     4  0.4808    0.29996 0.348 0.000 0.000 0.620 0.032
#> GSM872299     5  0.4872    0.36826 0.436 0.000 0.000 0.024 0.540
#> GSM872300     1  0.4893    0.29234 0.568 0.000 0.000 0.404 0.028

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM872244     3  0.3127     0.8521 0.000 0.000 0.852 0.084 0.020 0.044
#> GSM872245     5  0.4846     0.1956 0.436 0.000 0.000 0.016 0.520 0.028
#> GSM872246     3  0.1036     0.8943 0.000 0.000 0.964 0.024 0.004 0.008
#> GSM872247     3  0.0260     0.8964 0.000 0.000 0.992 0.008 0.000 0.000
#> GSM872248     5  0.5036     0.5403 0.000 0.188 0.000 0.076 0.692 0.044
#> GSM872249     3  0.0260     0.8948 0.000 0.000 0.992 0.000 0.000 0.008
#> GSM872250     5  0.2112     0.7442 0.088 0.000 0.000 0.016 0.896 0.000
#> GSM872251     3  0.2024     0.8725 0.000 0.000 0.920 0.036 0.016 0.028
#> GSM872252     6  0.7234     0.1659 0.272 0.000 0.000 0.120 0.200 0.408
#> GSM872253     6  0.6501     0.1912 0.000 0.000 0.088 0.308 0.108 0.496
#> GSM872254     5  0.3215     0.7296 0.036 0.016 0.000 0.052 0.864 0.032
#> GSM872255     6  0.3489     0.5437 0.288 0.000 0.000 0.004 0.000 0.708
#> GSM872256     1  0.1949     0.8385 0.904 0.000 0.000 0.004 0.004 0.088
#> GSM872257     2  0.3579     0.8456 0.000 0.828 0.000 0.072 0.064 0.036
#> GSM872258     3  0.4668     0.5393 0.000 0.000 0.660 0.052 0.012 0.276
#> GSM872259     1  0.0622     0.8570 0.980 0.000 0.000 0.008 0.012 0.000
#> GSM872260     6  0.4303     0.5118 0.292 0.000 0.000 0.020 0.016 0.672
#> GSM872261     5  0.6586     0.0464 0.036 0.000 0.000 0.208 0.404 0.352
#> GSM872262     6  0.4093     0.5270 0.204 0.000 0.000 0.056 0.004 0.736
#> GSM872263     3  0.3059     0.8542 0.000 0.000 0.856 0.084 0.020 0.040
#> GSM872264     4  0.4634     0.7371 0.032 0.004 0.024 0.684 0.000 0.256
#> GSM872265     4  0.4680     0.7398 0.036 0.004 0.016 0.684 0.004 0.256
#> GSM872266     5  0.3208     0.6914 0.000 0.044 0.000 0.084 0.848 0.024
#> GSM872267     5  0.5093     0.5281 0.000 0.196 0.000 0.076 0.684 0.044
#> GSM872268     3  0.0405     0.8958 0.000 0.000 0.988 0.008 0.000 0.004
#> GSM872269     5  0.3655     0.7245 0.044 0.012 0.000 0.048 0.836 0.060
#> GSM872270     3  0.0870     0.8962 0.000 0.000 0.972 0.012 0.004 0.012
#> GSM872271     4  0.4833     0.6226 0.004 0.080 0.016 0.756 0.040 0.104
#> GSM872272     4  0.4833     0.6226 0.004 0.080 0.016 0.756 0.040 0.104
#> GSM872273     1  0.2680     0.7608 0.856 0.000 0.000 0.016 0.004 0.124
#> GSM872274     2  0.0146     0.9284 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM872275     6  0.5877     0.0111 0.000 0.000 0.116 0.420 0.020 0.444
#> GSM872276     6  0.4121     0.5277 0.208 0.000 0.000 0.056 0.004 0.732
#> GSM872277     1  0.2915     0.7653 0.848 0.000 0.000 0.024 0.008 0.120
#> GSM872278     6  0.5332    -0.0204 0.000 0.000 0.072 0.424 0.012 0.492
#> GSM872279     1  0.2393     0.8274 0.892 0.000 0.000 0.004 0.040 0.064
#> GSM872280     6  0.3297     0.5361 0.100 0.000 0.060 0.008 0.000 0.832
#> GSM872281     6  0.4978    -0.4646 0.032 0.000 0.012 0.468 0.004 0.484
#> GSM872282     3  0.3228     0.8469 0.000 0.000 0.844 0.092 0.020 0.044
#> GSM872283     4  0.4478     0.7369 0.036 0.000 0.012 0.688 0.004 0.260
#> GSM872284     4  0.4961     0.3919 0.040 0.000 0.012 0.492 0.000 0.456
#> GSM872285     6  0.4507     0.2704 0.000 0.000 0.372 0.020 0.012 0.596
#> GSM872286     5  0.2377     0.7298 0.124 0.000 0.000 0.004 0.868 0.004
#> GSM872287     3  0.0260     0.8964 0.000 0.000 0.992 0.008 0.000 0.000
#> GSM872288     5  0.2358     0.7360 0.108 0.000 0.000 0.016 0.876 0.000
#> GSM872289     3  0.4714     0.6987 0.000 0.000 0.728 0.044 0.068 0.160
#> GSM872290     1  0.1781     0.8437 0.924 0.000 0.000 0.008 0.008 0.060
#> GSM872291     6  0.3445     0.5526 0.260 0.000 0.000 0.008 0.000 0.732
#> GSM872292     2  0.0146     0.9284 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM872293     1  0.0260     0.8589 0.992 0.000 0.000 0.000 0.008 0.000
#> GSM872294     2  0.2220     0.8922 0.000 0.908 0.000 0.052 0.020 0.020
#> GSM872295     2  0.3298     0.8771 0.000 0.844 0.000 0.060 0.072 0.024
#> GSM872296     2  0.0146     0.9284 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM872297     1  0.0622     0.8575 0.980 0.000 0.000 0.012 0.008 0.000
#> GSM872298     6  0.3301     0.5029 0.084 0.000 0.004 0.072 0.004 0.836
#> GSM872299     1  0.4985     0.4084 0.636 0.000 0.000 0.008 0.268 0.088
#> GSM872300     6  0.4093     0.5270 0.204 0.000 0.000 0.056 0.004 0.736

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

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>            n time(p) individual(p) k
#> SD:kmeans 50   0.742      1.14e-01 2
#> SD:kmeans 55   0.497      6.96e-03 3
#> SD:kmeans 40   0.360      2.37e-04 4
#> SD:kmeans 42   0.107      5.09e-04 5
#> SD:kmeans 47   0.405      1.97e-06 6

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 29485 rows and 57 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 0.556           0.842       0.907         0.5058 0.492   0.492
#> 3 3 0.856           0.870       0.948         0.3359 0.695   0.456
#> 4 4 0.857           0.897       0.938         0.1249 0.840   0.556
#> 5 5 0.781           0.600       0.800         0.0513 0.867   0.543
#> 6 6 0.792           0.662       0.820         0.0402 0.917   0.641

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
#> GSM872244     1  0.7883      0.757 0.764 0.236
#> GSM872245     2  0.1633      0.857 0.024 0.976
#> GSM872246     1  0.1414      0.922 0.980 0.020
#> GSM872247     1  0.2423      0.917 0.960 0.040
#> GSM872248     2  0.0000      0.861 0.000 1.000
#> GSM872249     1  0.7883      0.757 0.764 0.236
#> GSM872250     2  0.0938      0.861 0.012 0.988
#> GSM872251     1  0.2043      0.920 0.968 0.032
#> GSM872252     2  0.7883      0.796 0.236 0.764
#> GSM872253     1  0.1843      0.921 0.972 0.028
#> GSM872254     2  0.0000      0.861 0.000 1.000
#> GSM872255     1  0.0000      0.920 1.000 0.000
#> GSM872256     2  0.7883      0.796 0.236 0.764
#> GSM872257     2  0.0000      0.861 0.000 1.000
#> GSM872258     1  0.1414      0.922 0.980 0.020
#> GSM872259     2  0.7883      0.796 0.236 0.764
#> GSM872260     1  0.0000      0.920 1.000 0.000
#> GSM872261     2  0.0376      0.861 0.004 0.996
#> GSM872262     1  0.0000      0.920 1.000 0.000
#> GSM872263     1  0.2423      0.917 0.960 0.040
#> GSM872264     1  0.7745      0.760 0.772 0.228
#> GSM872265     2  0.8955      0.498 0.312 0.688
#> GSM872266     2  0.0000      0.861 0.000 1.000
#> GSM872267     2  0.0000      0.861 0.000 1.000
#> GSM872268     1  0.1633      0.922 0.976 0.024
#> GSM872269     2  0.0938      0.861 0.012 0.988
#> GSM872270     1  0.7883      0.757 0.764 0.236
#> GSM872271     2  0.0000      0.861 0.000 1.000
#> GSM872272     2  0.0000      0.861 0.000 1.000
#> GSM872273     2  0.9795      0.547 0.416 0.584
#> GSM872274     2  0.0000      0.861 0.000 1.000
#> GSM872275     1  0.7883      0.757 0.764 0.236
#> GSM872276     1  0.0000      0.920 1.000 0.000
#> GSM872277     2  0.9795      0.547 0.416 0.584
#> GSM872278     1  0.3274      0.905 0.940 0.060
#> GSM872279     2  0.7883      0.796 0.236 0.764
#> GSM872280     1  0.0000      0.920 1.000 0.000
#> GSM872281     1  0.0000      0.920 1.000 0.000
#> GSM872282     1  0.7883      0.757 0.764 0.236
#> GSM872283     2  0.4815      0.821 0.104 0.896
#> GSM872284     1  0.0000      0.920 1.000 0.000
#> GSM872285     1  0.0000      0.920 1.000 0.000
#> GSM872286     2  0.7883      0.796 0.236 0.764
#> GSM872287     1  0.2043      0.920 0.968 0.032
#> GSM872288     2  0.7883      0.796 0.236 0.764
#> GSM872289     1  0.1414      0.922 0.980 0.020
#> GSM872290     2  0.7883      0.796 0.236 0.764
#> GSM872291     1  0.0000      0.920 1.000 0.000
#> GSM872292     2  0.0000      0.861 0.000 1.000
#> GSM872293     2  0.7883      0.796 0.236 0.764
#> GSM872294     2  0.0000      0.861 0.000 1.000
#> GSM872295     2  0.0000      0.861 0.000 1.000
#> GSM872296     2  0.0000      0.861 0.000 1.000
#> GSM872297     2  0.7883      0.796 0.236 0.764
#> GSM872298     1  0.0000      0.920 1.000 0.000
#> GSM872299     2  0.7883      0.796 0.236 0.764
#> GSM872300     1  0.0000      0.920 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
#> GSM872244     3  0.0237      0.952 0.000 0.004 0.996
#> GSM872245     2  0.0000      0.942 0.000 1.000 0.000
#> GSM872246     3  0.0000      0.954 0.000 0.000 1.000
#> GSM872247     3  0.0000      0.954 0.000 0.000 1.000
#> GSM872248     2  0.0000      0.942 0.000 1.000 0.000
#> GSM872249     3  0.0000      0.954 0.000 0.000 1.000
#> GSM872250     2  0.0237      0.940 0.004 0.996 0.000
#> GSM872251     3  0.0000      0.954 0.000 0.000 1.000
#> GSM872252     1  0.0424      0.923 0.992 0.008 0.000
#> GSM872253     3  0.2261      0.894 0.068 0.000 0.932
#> GSM872254     2  0.0000      0.942 0.000 1.000 0.000
#> GSM872255     1  0.0000      0.928 1.000 0.000 0.000
#> GSM872256     1  0.0000      0.928 1.000 0.000 0.000
#> GSM872257     2  0.0000      0.942 0.000 1.000 0.000
#> GSM872258     3  0.0000      0.954 0.000 0.000 1.000
#> GSM872259     1  0.0000      0.928 1.000 0.000 0.000
#> GSM872260     1  0.0000      0.928 1.000 0.000 0.000
#> GSM872261     2  0.0237      0.940 0.004 0.996 0.000
#> GSM872262     1  0.0000      0.928 1.000 0.000 0.000
#> GSM872263     3  0.0000      0.954 0.000 0.000 1.000
#> GSM872264     3  0.5785      0.543 0.300 0.004 0.696
#> GSM872265     1  0.7424      0.322 0.572 0.388 0.040
#> GSM872266     2  0.0000      0.942 0.000 1.000 0.000
#> GSM872267     2  0.0000      0.942 0.000 1.000 0.000
#> GSM872268     3  0.0000      0.954 0.000 0.000 1.000
#> GSM872269     2  0.0237      0.940 0.004 0.996 0.000
#> GSM872270     3  0.0000      0.954 0.000 0.000 1.000
#> GSM872271     2  0.0000      0.942 0.000 1.000 0.000
#> GSM872272     2  0.0000      0.942 0.000 1.000 0.000
#> GSM872273     1  0.0000      0.928 1.000 0.000 0.000
#> GSM872274     2  0.0000      0.942 0.000 1.000 0.000
#> GSM872275     3  0.0000      0.954 0.000 0.000 1.000
#> GSM872276     1  0.0000      0.928 1.000 0.000 0.000
#> GSM872277     1  0.0000      0.928 1.000 0.000 0.000
#> GSM872278     3  0.0000      0.954 0.000 0.000 1.000
#> GSM872279     1  0.0000      0.928 1.000 0.000 0.000
#> GSM872280     3  0.5882      0.472 0.348 0.000 0.652
#> GSM872281     1  0.4452      0.742 0.808 0.000 0.192
#> GSM872282     3  0.0237      0.952 0.000 0.004 0.996
#> GSM872283     1  0.4575      0.773 0.828 0.160 0.012
#> GSM872284     1  0.4178      0.768 0.828 0.000 0.172
#> GSM872285     3  0.0000      0.954 0.000 0.000 1.000
#> GSM872286     2  0.6215      0.260 0.428 0.572 0.000
#> GSM872287     3  0.0000      0.954 0.000 0.000 1.000
#> GSM872288     1  0.5905      0.407 0.648 0.352 0.000
#> GSM872289     3  0.0000      0.954 0.000 0.000 1.000
#> GSM872290     1  0.0000      0.928 1.000 0.000 0.000
#> GSM872291     1  0.0000      0.928 1.000 0.000 0.000
#> GSM872292     2  0.0000      0.942 0.000 1.000 0.000
#> GSM872293     1  0.0000      0.928 1.000 0.000 0.000
#> GSM872294     2  0.0000      0.942 0.000 1.000 0.000
#> GSM872295     2  0.0000      0.942 0.000 1.000 0.000
#> GSM872296     2  0.0000      0.942 0.000 1.000 0.000
#> GSM872297     1  0.0000      0.928 1.000 0.000 0.000
#> GSM872298     1  0.0237      0.926 0.996 0.000 0.004
#> GSM872299     2  0.6280      0.166 0.460 0.540 0.000
#> GSM872300     1  0.0000      0.928 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM872244     3  0.0000      0.996 0.000 0.000 1.000 0.000
#> GSM872245     1  0.0336      0.888 0.992 0.008 0.000 0.000
#> GSM872246     3  0.0000      0.996 0.000 0.000 1.000 0.000
#> GSM872247     3  0.0000      0.996 0.000 0.000 1.000 0.000
#> GSM872248     2  0.1940      0.901 0.076 0.924 0.000 0.000
#> GSM872249     3  0.0000      0.996 0.000 0.000 1.000 0.000
#> GSM872250     1  0.0336      0.888 0.992 0.008 0.000 0.000
#> GSM872251     3  0.0000      0.996 0.000 0.000 1.000 0.000
#> GSM872252     1  0.0921      0.897 0.972 0.000 0.000 0.028
#> GSM872253     3  0.0817      0.976 0.024 0.000 0.976 0.000
#> GSM872254     2  0.4382      0.706 0.296 0.704 0.000 0.000
#> GSM872255     4  0.1118      0.893 0.036 0.000 0.000 0.964
#> GSM872256     1  0.3764      0.805 0.784 0.000 0.000 0.216
#> GSM872257     2  0.1118      0.911 0.036 0.964 0.000 0.000
#> GSM872258     3  0.0000      0.996 0.000 0.000 1.000 0.000
#> GSM872259     1  0.2216      0.896 0.908 0.000 0.000 0.092
#> GSM872260     1  0.4522      0.653 0.680 0.000 0.000 0.320
#> GSM872261     2  0.4331      0.716 0.288 0.712 0.000 0.000
#> GSM872262     4  0.0336      0.906 0.008 0.000 0.000 0.992
#> GSM872263     3  0.0000      0.996 0.000 0.000 1.000 0.000
#> GSM872264     4  0.4040      0.720 0.000 0.248 0.000 0.752
#> GSM872265     4  0.4072      0.715 0.000 0.252 0.000 0.748
#> GSM872266     2  0.1940      0.901 0.076 0.924 0.000 0.000
#> GSM872267     2  0.1557      0.908 0.056 0.944 0.000 0.000
#> GSM872268     3  0.0000      0.996 0.000 0.000 1.000 0.000
#> GSM872269     2  0.4522      0.672 0.320 0.680 0.000 0.000
#> GSM872270     3  0.0000      0.996 0.000 0.000 1.000 0.000
#> GSM872271     2  0.0336      0.905 0.000 0.992 0.000 0.008
#> GSM872272     2  0.0336      0.905 0.000 0.992 0.000 0.008
#> GSM872273     4  0.1022      0.896 0.032 0.000 0.000 0.968
#> GSM872274     2  0.0000      0.909 0.000 1.000 0.000 0.000
#> GSM872275     3  0.0469      0.988 0.000 0.012 0.988 0.000
#> GSM872276     4  0.0336      0.906 0.008 0.000 0.000 0.992
#> GSM872277     4  0.0921      0.898 0.028 0.000 0.000 0.972
#> GSM872278     3  0.0336      0.991 0.000 0.000 0.992 0.008
#> GSM872279     1  0.2281      0.896 0.904 0.000 0.000 0.096
#> GSM872280     4  0.3356      0.746 0.000 0.000 0.176 0.824
#> GSM872281     4  0.0000      0.905 0.000 0.000 0.000 1.000
#> GSM872282     3  0.0707      0.979 0.000 0.020 0.980 0.000
#> GSM872283     4  0.4040      0.720 0.000 0.248 0.000 0.752
#> GSM872284     4  0.0000      0.905 0.000 0.000 0.000 1.000
#> GSM872285     3  0.0000      0.996 0.000 0.000 1.000 0.000
#> GSM872286     1  0.0336      0.888 0.992 0.008 0.000 0.000
#> GSM872287     3  0.0000      0.996 0.000 0.000 1.000 0.000
#> GSM872288     1  0.0188      0.889 0.996 0.004 0.000 0.000
#> GSM872289     3  0.0000      0.996 0.000 0.000 1.000 0.000
#> GSM872290     1  0.2469      0.892 0.892 0.000 0.000 0.108
#> GSM872291     4  0.0707      0.902 0.020 0.000 0.000 0.980
#> GSM872292     2  0.0000      0.909 0.000 1.000 0.000 0.000
#> GSM872293     1  0.2921      0.877 0.860 0.000 0.000 0.140
#> GSM872294     2  0.0000      0.909 0.000 1.000 0.000 0.000
#> GSM872295     2  0.1118      0.911 0.036 0.964 0.000 0.000
#> GSM872296     2  0.0000      0.909 0.000 1.000 0.000 0.000
#> GSM872297     1  0.3074      0.869 0.848 0.000 0.000 0.152
#> GSM872298     4  0.0188      0.906 0.004 0.000 0.000 0.996
#> GSM872299     1  0.0336      0.888 0.992 0.008 0.000 0.000
#> GSM872300     4  0.0336      0.906 0.008 0.000 0.000 0.992

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM872244     3  0.0000     0.9564 0.000 0.000 1.000 0.000 0.000
#> GSM872245     5  0.1341     0.6352 0.056 0.000 0.000 0.000 0.944
#> GSM872246     3  0.0000     0.9564 0.000 0.000 1.000 0.000 0.000
#> GSM872247     3  0.0000     0.9564 0.000 0.000 1.000 0.000 0.000
#> GSM872248     5  0.4305     0.0805 0.000 0.488 0.000 0.000 0.512
#> GSM872249     3  0.0000     0.9564 0.000 0.000 1.000 0.000 0.000
#> GSM872250     5  0.0162     0.6693 0.000 0.004 0.000 0.000 0.996
#> GSM872251     3  0.0000     0.9564 0.000 0.000 1.000 0.000 0.000
#> GSM872252     1  0.4307     0.1857 0.500 0.000 0.000 0.000 0.500
#> GSM872253     3  0.3205     0.8642 0.052 0.020 0.876 0.004 0.048
#> GSM872254     5  0.3561     0.5078 0.000 0.260 0.000 0.000 0.740
#> GSM872255     1  0.1544     0.5520 0.932 0.000 0.000 0.068 0.000
#> GSM872256     1  0.3790     0.5870 0.724 0.000 0.000 0.004 0.272
#> GSM872257     2  0.1043     0.7724 0.000 0.960 0.000 0.000 0.040
#> GSM872258     3  0.0000     0.9564 0.000 0.000 1.000 0.000 0.000
#> GSM872259     1  0.3861     0.5774 0.712 0.000 0.000 0.004 0.284
#> GSM872260     1  0.1341     0.5582 0.944 0.000 0.000 0.056 0.000
#> GSM872261     2  0.4161     0.2047 0.000 0.608 0.000 0.000 0.392
#> GSM872262     1  0.4305    -0.2008 0.512 0.000 0.000 0.488 0.000
#> GSM872263     3  0.0000     0.9564 0.000 0.000 1.000 0.000 0.000
#> GSM872264     4  0.1892     0.7639 0.000 0.080 0.004 0.916 0.000
#> GSM872265     4  0.1792     0.7625 0.000 0.084 0.000 0.916 0.000
#> GSM872266     5  0.4306     0.0683 0.000 0.492 0.000 0.000 0.508
#> GSM872267     2  0.4440    -0.1295 0.000 0.528 0.000 0.004 0.468
#> GSM872268     3  0.0000     0.9564 0.000 0.000 1.000 0.000 0.000
#> GSM872269     5  0.3480     0.5208 0.000 0.248 0.000 0.000 0.752
#> GSM872270     3  0.0000     0.9564 0.000 0.000 1.000 0.000 0.000
#> GSM872271     2  0.3452     0.6333 0.000 0.756 0.000 0.244 0.000
#> GSM872272     2  0.3480     0.6281 0.000 0.752 0.000 0.248 0.000
#> GSM872273     1  0.2293     0.5619 0.900 0.000 0.000 0.084 0.016
#> GSM872274     2  0.0162     0.7933 0.000 0.996 0.000 0.004 0.000
#> GSM872275     3  0.3142     0.8366 0.004 0.108 0.856 0.032 0.000
#> GSM872276     1  0.4287    -0.1376 0.540 0.000 0.000 0.460 0.000
#> GSM872277     1  0.4630     0.5174 0.736 0.000 0.000 0.176 0.088
#> GSM872278     3  0.4956     0.4924 0.048 0.000 0.636 0.316 0.000
#> GSM872279     1  0.3730     0.5718 0.712 0.000 0.000 0.000 0.288
#> GSM872280     1  0.6695    -0.1466 0.428 0.000 0.308 0.264 0.000
#> GSM872281     4  0.3305     0.6403 0.224 0.000 0.000 0.776 0.000
#> GSM872282     3  0.0771     0.9409 0.000 0.020 0.976 0.004 0.000
#> GSM872283     4  0.1544     0.7680 0.000 0.068 0.000 0.932 0.000
#> GSM872284     4  0.1732     0.7403 0.080 0.000 0.000 0.920 0.000
#> GSM872285     3  0.0162     0.9544 0.000 0.000 0.996 0.004 0.000
#> GSM872286     5  0.0510     0.6695 0.016 0.000 0.000 0.000 0.984
#> GSM872287     3  0.0000     0.9564 0.000 0.000 1.000 0.000 0.000
#> GSM872288     5  0.0404     0.6699 0.012 0.000 0.000 0.000 0.988
#> GSM872289     3  0.0290     0.9520 0.000 0.000 0.992 0.000 0.008
#> GSM872290     1  0.3766     0.5861 0.728 0.000 0.000 0.004 0.268
#> GSM872291     1  0.1608     0.5478 0.928 0.000 0.000 0.072 0.000
#> GSM872292     2  0.0162     0.7933 0.000 0.996 0.000 0.004 0.000
#> GSM872293     1  0.3814     0.5842 0.720 0.000 0.000 0.004 0.276
#> GSM872294     2  0.0162     0.7933 0.000 0.996 0.000 0.004 0.000
#> GSM872295     2  0.0963     0.7745 0.000 0.964 0.000 0.000 0.036
#> GSM872296     2  0.0162     0.7933 0.000 0.996 0.000 0.004 0.000
#> GSM872297     1  0.3790     0.5870 0.724 0.000 0.000 0.004 0.272
#> GSM872298     4  0.4268     0.2808 0.444 0.000 0.000 0.556 0.000
#> GSM872299     5  0.4088     0.0485 0.368 0.000 0.000 0.000 0.632
#> GSM872300     1  0.4305    -0.2008 0.512 0.000 0.000 0.488 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
#> GSM872244     3  0.1036    0.91933 0.000 0.000 0.964 0.008 0.004 0.024
#> GSM872245     5  0.4537    0.12573 0.412 0.000 0.000 0.000 0.552 0.036
#> GSM872246     3  0.0603    0.92002 0.000 0.000 0.980 0.000 0.004 0.016
#> GSM872247     3  0.0146    0.92193 0.000 0.000 0.996 0.004 0.000 0.000
#> GSM872248     5  0.3659    0.47994 0.000 0.364 0.000 0.000 0.636 0.000
#> GSM872249     3  0.0405    0.92094 0.000 0.000 0.988 0.004 0.000 0.008
#> GSM872250     5  0.1141    0.70995 0.052 0.000 0.000 0.000 0.948 0.000
#> GSM872251     3  0.0622    0.91964 0.000 0.000 0.980 0.000 0.008 0.012
#> GSM872252     1  0.6431    0.34815 0.452 0.012 0.000 0.008 0.244 0.284
#> GSM872253     6  0.6779   -0.17673 0.040 0.020 0.408 0.012 0.096 0.424
#> GSM872254     5  0.3974    0.63716 0.000 0.116 0.000 0.004 0.772 0.108
#> GSM872255     6  0.3672    0.61322 0.304 0.000 0.000 0.008 0.000 0.688
#> GSM872256     1  0.0508    0.79773 0.984 0.000 0.000 0.000 0.004 0.012
#> GSM872257     2  0.0937    0.76641 0.000 0.960 0.000 0.000 0.040 0.000
#> GSM872258     3  0.0935    0.91603 0.000 0.000 0.964 0.000 0.004 0.032
#> GSM872259     1  0.0260    0.79928 0.992 0.000 0.000 0.000 0.008 0.000
#> GSM872260     6  0.3872    0.59832 0.264 0.000 0.000 0.004 0.020 0.712
#> GSM872261     2  0.6043    0.00333 0.016 0.484 0.000 0.008 0.368 0.124
#> GSM872262     6  0.5180    0.57851 0.164 0.000 0.000 0.220 0.000 0.616
#> GSM872263     3  0.0692    0.92070 0.000 0.000 0.976 0.000 0.004 0.020
#> GSM872264     4  0.0458    0.79170 0.000 0.016 0.000 0.984 0.000 0.000
#> GSM872265     4  0.0632    0.79021 0.000 0.024 0.000 0.976 0.000 0.000
#> GSM872266     5  0.3684    0.46890 0.000 0.372 0.000 0.000 0.628 0.000
#> GSM872267     5  0.3747    0.42699 0.000 0.396 0.000 0.000 0.604 0.000
#> GSM872268     3  0.0000    0.92182 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872269     5  0.3552    0.65854 0.008 0.068 0.000 0.004 0.820 0.100
#> GSM872270     3  0.0665    0.91970 0.000 0.000 0.980 0.008 0.004 0.008
#> GSM872271     2  0.4066    0.45865 0.000 0.596 0.000 0.392 0.000 0.012
#> GSM872272     2  0.4076    0.45191 0.000 0.592 0.000 0.396 0.000 0.012
#> GSM872273     1  0.2706    0.67878 0.852 0.000 0.000 0.024 0.000 0.124
#> GSM872274     2  0.0363    0.79231 0.000 0.988 0.000 0.012 0.000 0.000
#> GSM872275     3  0.4987    0.68633 0.000 0.144 0.728 0.056 0.012 0.060
#> GSM872276     6  0.4982    0.60990 0.172 0.000 0.000 0.180 0.000 0.648
#> GSM872277     1  0.2954    0.68570 0.852 0.000 0.000 0.048 0.004 0.096
#> GSM872278     3  0.6501    0.00850 0.000 0.004 0.424 0.224 0.020 0.328
#> GSM872279     1  0.2258    0.77047 0.896 0.000 0.000 0.000 0.044 0.060
#> GSM872280     6  0.4602    0.55571 0.056 0.000 0.128 0.068 0.000 0.748
#> GSM872281     4  0.3890    0.27607 0.004 0.000 0.000 0.596 0.000 0.400
#> GSM872282     3  0.0891    0.91929 0.000 0.000 0.968 0.008 0.000 0.024
#> GSM872283     4  0.0881    0.79147 0.008 0.012 0.000 0.972 0.000 0.008
#> GSM872284     4  0.2933    0.66474 0.004 0.000 0.000 0.796 0.000 0.200
#> GSM872285     3  0.1588    0.87293 0.000 0.000 0.924 0.004 0.000 0.072
#> GSM872286     5  0.1444    0.70775 0.072 0.000 0.000 0.000 0.928 0.000
#> GSM872287     3  0.0146    0.92193 0.000 0.000 0.996 0.004 0.000 0.000
#> GSM872288     5  0.1327    0.71001 0.064 0.000 0.000 0.000 0.936 0.000
#> GSM872289     3  0.1088    0.91267 0.000 0.000 0.960 0.000 0.024 0.016
#> GSM872290     1  0.2504    0.75986 0.880 0.000 0.000 0.004 0.028 0.088
#> GSM872291     6  0.4363    0.58406 0.272 0.000 0.000 0.024 0.020 0.684
#> GSM872292     2  0.0363    0.79231 0.000 0.988 0.000 0.012 0.000 0.000
#> GSM872293     1  0.0146    0.79929 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM872294     2  0.0458    0.79254 0.000 0.984 0.000 0.016 0.000 0.000
#> GSM872295     2  0.0603    0.77607 0.000 0.980 0.000 0.000 0.016 0.004
#> GSM872296     2  0.0458    0.79254 0.000 0.984 0.000 0.016 0.000 0.000
#> GSM872297     1  0.0146    0.79929 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM872298     6  0.4467    0.51026 0.056 0.000 0.000 0.216 0.016 0.712
#> GSM872299     1  0.5860    0.34271 0.532 0.008 0.000 0.004 0.296 0.160
#> GSM872300     6  0.5162    0.58639 0.168 0.000 0.000 0.212 0.000 0.620

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

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>             n time(p) individual(p) k
#> SD:skmeans 56   0.796      3.29e-03 2
#> SD:skmeans 52   0.759      7.69e-03 3
#> SD:skmeans 57   0.238      6.40e-03 4
#> SD:skmeans 45   0.550      1.20e-04 5
#> SD:skmeans 45   0.851      1.87e-06 6

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 29485 rows and 57 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 0.363           0.726       0.821         0.4327 0.560   0.560
#> 3 3 0.456           0.734       0.836         0.4371 0.752   0.576
#> 4 4 0.661           0.817       0.857         0.1609 0.894   0.710
#> 5 5 0.717           0.804       0.864         0.0600 0.883   0.623
#> 6 6 0.738           0.707       0.829         0.0714 0.931   0.719

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
#> GSM872244     2   0.966     0.7992 0.392 0.608
#> GSM872245     2   0.000     0.5777 0.000 1.000
#> GSM872246     1   0.000     0.8054 1.000 0.000
#> GSM872247     1   0.000     0.8054 1.000 0.000
#> GSM872248     2   0.966     0.7992 0.392 0.608
#> GSM872249     1   0.000     0.8054 1.000 0.000
#> GSM872250     2   0.625     0.6977 0.156 0.844
#> GSM872251     1   0.000     0.8054 1.000 0.000
#> GSM872252     1   0.855     0.6482 0.720 0.280
#> GSM872253     1   0.000     0.8054 1.000 0.000
#> GSM872254     2   0.552     0.6781 0.128 0.872
#> GSM872255     1   0.839     0.6556 0.732 0.268
#> GSM872256     1   0.861     0.6543 0.716 0.284
#> GSM872257     2   0.966     0.7992 0.392 0.608
#> GSM872258     1   0.000     0.8054 1.000 0.000
#> GSM872259     1   0.966     0.5866 0.608 0.392
#> GSM872260     1   0.506     0.7446 0.888 0.112
#> GSM872261     2   0.966     0.7992 0.392 0.608
#> GSM872262     1   0.000     0.8054 1.000 0.000
#> GSM872263     1   0.000     0.8054 1.000 0.000
#> GSM872264     1   0.000     0.8054 1.000 0.000
#> GSM872265     1   0.000     0.8054 1.000 0.000
#> GSM872266     2   0.966     0.7992 0.392 0.608
#> GSM872267     2   0.966     0.7992 0.392 0.608
#> GSM872268     1   0.000     0.8054 1.000 0.000
#> GSM872269     2   0.753     0.7283 0.216 0.784
#> GSM872270     1   0.000     0.8054 1.000 0.000
#> GSM872271     2   0.966     0.7992 0.392 0.608
#> GSM872272     2   0.966     0.7992 0.392 0.608
#> GSM872273     1   0.966     0.5866 0.608 0.392
#> GSM872274     2   0.966     0.7992 0.392 0.608
#> GSM872275     1   0.000     0.8054 1.000 0.000
#> GSM872276     1   0.966     0.5866 0.608 0.392
#> GSM872277     1   0.963     0.5898 0.612 0.388
#> GSM872278     1   0.000     0.8054 1.000 0.000
#> GSM872279     1   0.966     0.5866 0.608 0.392
#> GSM872280     1   0.000     0.8054 1.000 0.000
#> GSM872281     1   0.000     0.8054 1.000 0.000
#> GSM872282     1   0.163     0.7770 0.976 0.024
#> GSM872283     1   0.141     0.7964 0.980 0.020
#> GSM872284     1   0.000     0.8054 1.000 0.000
#> GSM872285     1   0.000     0.8054 1.000 0.000
#> GSM872286     2   0.000     0.5777 0.000 1.000
#> GSM872287     1   0.000     0.8054 1.000 0.000
#> GSM872288     2   0.689     0.6520 0.184 0.816
#> GSM872289     1   0.000     0.8054 1.000 0.000
#> GSM872290     1   0.966     0.5866 0.608 0.392
#> GSM872291     1   0.929     0.6156 0.656 0.344
#> GSM872292     2   0.966     0.7992 0.392 0.608
#> GSM872293     1   0.966     0.5866 0.608 0.392
#> GSM872294     1   0.000     0.8054 1.000 0.000
#> GSM872295     2   0.966     0.7992 0.392 0.608
#> GSM872296     1   0.327     0.7252 0.940 0.060
#> GSM872297     1   0.966     0.5866 0.608 0.392
#> GSM872298     1   0.000     0.8054 1.000 0.000
#> GSM872299     2   0.900     0.0401 0.316 0.684
#> GSM872300     1   0.955     0.5969 0.624 0.376

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM872244     3  0.0000      0.974 0.000 0.000 1.000
#> GSM872245     2  0.5706      0.691 0.320 0.680 0.000
#> GSM872246     3  0.0000      0.974 0.000 0.000 1.000
#> GSM872247     3  0.0000      0.974 0.000 0.000 1.000
#> GSM872248     2  0.0000      0.785 0.000 1.000 0.000
#> GSM872249     3  0.0000      0.974 0.000 0.000 1.000
#> GSM872250     2  0.6348      0.764 0.188 0.752 0.060
#> GSM872251     3  0.0237      0.970 0.004 0.000 0.996
#> GSM872252     1  0.3267      0.731 0.884 0.000 0.116
#> GSM872253     1  0.6079      0.643 0.612 0.000 0.388
#> GSM872254     2  0.4002      0.774 0.160 0.840 0.000
#> GSM872255     1  0.3619      0.729 0.864 0.000 0.136
#> GSM872256     1  0.3116      0.724 0.892 0.000 0.108
#> GSM872257     2  0.0000      0.785 0.000 1.000 0.000
#> GSM872258     3  0.0000      0.974 0.000 0.000 1.000
#> GSM872259     1  0.0000      0.708 1.000 0.000 0.000
#> GSM872260     1  0.5397      0.695 0.720 0.000 0.280
#> GSM872261     2  0.6079      0.446 0.000 0.612 0.388
#> GSM872262     1  0.6079      0.643 0.612 0.000 0.388
#> GSM872263     3  0.0000      0.974 0.000 0.000 1.000
#> GSM872264     1  0.6079      0.643 0.612 0.000 0.388
#> GSM872265     1  0.6079      0.643 0.612 0.000 0.388
#> GSM872266     2  0.5098      0.656 0.000 0.752 0.248
#> GSM872267     2  0.0000      0.785 0.000 1.000 0.000
#> GSM872268     3  0.0000      0.974 0.000 0.000 1.000
#> GSM872269     2  0.7113      0.750 0.168 0.720 0.112
#> GSM872270     3  0.0000      0.974 0.000 0.000 1.000
#> GSM872271     2  0.6079      0.446 0.000 0.612 0.388
#> GSM872272     2  0.6079      0.446 0.000 0.612 0.388
#> GSM872273     1  0.0000      0.708 1.000 0.000 0.000
#> GSM872274     2  0.0424      0.786 0.000 0.992 0.008
#> GSM872275     1  0.6079      0.643 0.612 0.000 0.388
#> GSM872276     1  0.0000      0.708 1.000 0.000 0.000
#> GSM872277     1  0.0237      0.710 0.996 0.000 0.004
#> GSM872278     1  0.6079      0.643 0.612 0.000 0.388
#> GSM872279     1  0.0000      0.708 1.000 0.000 0.000
#> GSM872280     1  0.6079      0.643 0.612 0.000 0.388
#> GSM872281     1  0.6079      0.643 0.612 0.000 0.388
#> GSM872282     3  0.0000      0.974 0.000 0.000 1.000
#> GSM872283     1  0.6008      0.650 0.628 0.000 0.372
#> GSM872284     1  0.6079      0.643 0.612 0.000 0.388
#> GSM872285     3  0.0592      0.962 0.012 0.000 0.988
#> GSM872286     2  0.5098      0.738 0.248 0.752 0.000
#> GSM872287     3  0.0000      0.974 0.000 0.000 1.000
#> GSM872288     2  0.7248      0.706 0.256 0.676 0.068
#> GSM872289     3  0.4555      0.617 0.200 0.000 0.800
#> GSM872290     1  0.0000      0.708 1.000 0.000 0.000
#> GSM872291     1  0.1753      0.724 0.952 0.000 0.048
#> GSM872292     2  0.0424      0.786 0.000 0.992 0.008
#> GSM872293     1  0.0000      0.708 1.000 0.000 0.000
#> GSM872294     1  0.8459      0.647 0.612 0.156 0.232
#> GSM872295     2  0.0424      0.786 0.000 0.992 0.008
#> GSM872296     1  0.9087      0.569 0.544 0.268 0.188
#> GSM872297     1  0.0000      0.708 1.000 0.000 0.000
#> GSM872298     1  0.6079      0.643 0.612 0.000 0.388
#> GSM872299     1  0.5591      0.154 0.696 0.304 0.000
#> GSM872300     1  0.0892      0.716 0.980 0.000 0.020

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM872244     3  0.1389     0.9152 0.000 0.000 0.952 0.048
#> GSM872245     1  0.2530     0.7932 0.888 0.112 0.000 0.000
#> GSM872246     3  0.0000     0.9284 0.000 0.000 1.000 0.000
#> GSM872247     3  0.0000     0.9284 0.000 0.000 1.000 0.000
#> GSM872248     2  0.0188     0.8546 0.000 0.996 0.000 0.004
#> GSM872249     3  0.0000     0.9284 0.000 0.000 1.000 0.000
#> GSM872250     2  0.1824     0.8435 0.060 0.936 0.000 0.004
#> GSM872251     3  0.2281     0.8837 0.000 0.000 0.904 0.096
#> GSM872252     4  0.3649     0.7739 0.204 0.000 0.000 0.796
#> GSM872253     4  0.3123     0.8552 0.000 0.000 0.156 0.844
#> GSM872254     2  0.1474     0.8463 0.052 0.948 0.000 0.000
#> GSM872255     4  0.3486     0.7786 0.188 0.000 0.000 0.812
#> GSM872256     4  0.4499     0.8291 0.124 0.000 0.072 0.804
#> GSM872257     2  0.2921     0.8450 0.000 0.860 0.000 0.140
#> GSM872258     3  0.0336     0.9279 0.000 0.000 0.992 0.008
#> GSM872259     1  0.0000     0.8897 1.000 0.000 0.000 0.000
#> GSM872260     4  0.4236     0.8445 0.088 0.000 0.088 0.824
#> GSM872261     2  0.4609     0.7699 0.000 0.788 0.156 0.056
#> GSM872262     4  0.3052     0.8592 0.004 0.000 0.136 0.860
#> GSM872263     3  0.0000     0.9284 0.000 0.000 1.000 0.000
#> GSM872264     4  0.3123     0.8552 0.000 0.000 0.156 0.844
#> GSM872265     4  0.3123     0.8552 0.000 0.000 0.156 0.844
#> GSM872266     2  0.1975     0.8481 0.000 0.936 0.016 0.048
#> GSM872267     2  0.2921     0.8450 0.000 0.860 0.000 0.140
#> GSM872268     3  0.0000     0.9284 0.000 0.000 1.000 0.000
#> GSM872269     2  0.1938     0.8470 0.052 0.936 0.000 0.012
#> GSM872270     3  0.1557     0.9116 0.000 0.000 0.944 0.056
#> GSM872271     2  0.4609     0.7699 0.000 0.788 0.156 0.056
#> GSM872272     2  0.4609     0.7699 0.000 0.788 0.156 0.056
#> GSM872273     1  0.0592     0.8842 0.984 0.000 0.000 0.016
#> GSM872274     2  0.3024     0.8451 0.000 0.852 0.000 0.148
#> GSM872275     4  0.3123     0.8552 0.000 0.000 0.156 0.844
#> GSM872276     4  0.3569     0.7722 0.196 0.000 0.000 0.804
#> GSM872277     1  0.0592     0.8842 0.984 0.000 0.000 0.016
#> GSM872278     4  0.3123     0.8552 0.000 0.000 0.156 0.844
#> GSM872279     4  0.4564     0.6133 0.328 0.000 0.000 0.672
#> GSM872280     4  0.3626     0.8423 0.004 0.000 0.184 0.812
#> GSM872281     4  0.3157     0.8584 0.004 0.000 0.144 0.852
#> GSM872282     3  0.1474     0.9140 0.000 0.000 0.948 0.052
#> GSM872283     4  0.3306     0.8555 0.004 0.000 0.156 0.840
#> GSM872284     4  0.2921     0.8584 0.000 0.000 0.140 0.860
#> GSM872285     3  0.1557     0.8974 0.000 0.000 0.944 0.056
#> GSM872286     2  0.1940     0.8341 0.076 0.924 0.000 0.000
#> GSM872287     3  0.0000     0.9284 0.000 0.000 1.000 0.000
#> GSM872288     2  0.4037     0.7589 0.056 0.832 0.000 0.112
#> GSM872289     3  0.6574     0.2714 0.000 0.084 0.532 0.384
#> GSM872290     1  0.0000     0.8897 1.000 0.000 0.000 0.000
#> GSM872291     4  0.3649     0.7739 0.204 0.000 0.000 0.796
#> GSM872292     2  0.3024     0.8451 0.000 0.852 0.000 0.148
#> GSM872293     1  0.0000     0.8897 1.000 0.000 0.000 0.000
#> GSM872294     4  0.1722     0.7619 0.000 0.048 0.008 0.944
#> GSM872295     2  0.3024     0.8451 0.000 0.852 0.000 0.148
#> GSM872296     4  0.4406     0.3789 0.000 0.300 0.000 0.700
#> GSM872297     1  0.0000     0.8897 1.000 0.000 0.000 0.000
#> GSM872298     4  0.3123     0.8552 0.000 0.000 0.156 0.844
#> GSM872299     1  0.7893     0.0593 0.376 0.300 0.000 0.324
#> GSM872300     4  0.3528     0.7759 0.192 0.000 0.000 0.808

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM872244     3  0.2732      0.813 0.000 0.000 0.840 0.160 0.000
#> GSM872245     1  0.2966      0.751 0.816 0.000 0.000 0.000 0.184
#> GSM872246     3  0.0000      0.859 0.000 0.000 1.000 0.000 0.000
#> GSM872247     3  0.0000      0.859 0.000 0.000 1.000 0.000 0.000
#> GSM872248     5  0.0290      0.823 0.000 0.008 0.000 0.000 0.992
#> GSM872249     3  0.0000      0.859 0.000 0.000 1.000 0.000 0.000
#> GSM872250     5  0.1124      0.839 0.004 0.000 0.000 0.036 0.960
#> GSM872251     3  0.3366      0.762 0.000 0.000 0.768 0.232 0.000
#> GSM872252     4  0.3160      0.787 0.188 0.000 0.000 0.808 0.004
#> GSM872253     4  0.1341      0.843 0.000 0.000 0.056 0.944 0.000
#> GSM872254     5  0.0000      0.826 0.000 0.000 0.000 0.000 1.000
#> GSM872255     4  0.4696      0.767 0.108 0.156 0.000 0.736 0.000
#> GSM872256     4  0.5112      0.799 0.152 0.080 0.024 0.740 0.004
#> GSM872257     2  0.2690      0.897 0.000 0.844 0.000 0.000 0.156
#> GSM872258     3  0.1341      0.851 0.000 0.000 0.944 0.056 0.000
#> GSM872259     1  0.0162      0.930 0.996 0.000 0.000 0.000 0.004
#> GSM872260     4  0.2130      0.835 0.080 0.000 0.012 0.908 0.000
#> GSM872261     4  0.1502      0.842 0.000 0.000 0.056 0.940 0.004
#> GSM872262     4  0.2971      0.815 0.008 0.156 0.000 0.836 0.000
#> GSM872263     3  0.0000      0.859 0.000 0.000 1.000 0.000 0.000
#> GSM872264     4  0.1608      0.832 0.000 0.000 0.072 0.928 0.000
#> GSM872265     4  0.1341      0.843 0.000 0.000 0.056 0.944 0.000
#> GSM872266     5  0.1121      0.835 0.000 0.000 0.000 0.044 0.956
#> GSM872267     5  0.3210      0.578 0.000 0.212 0.000 0.000 0.788
#> GSM872268     3  0.0000      0.859 0.000 0.000 1.000 0.000 0.000
#> GSM872269     5  0.1608      0.811 0.000 0.000 0.000 0.072 0.928
#> GSM872270     3  0.3586      0.728 0.000 0.000 0.736 0.264 0.000
#> GSM872271     4  0.1341      0.843 0.000 0.000 0.056 0.944 0.000
#> GSM872272     4  0.1341      0.843 0.000 0.000 0.056 0.944 0.000
#> GSM872273     1  0.2124      0.894 0.916 0.028 0.000 0.056 0.000
#> GSM872274     2  0.2690      0.897 0.000 0.844 0.000 0.000 0.156
#> GSM872275     4  0.1341      0.843 0.000 0.000 0.056 0.944 0.000
#> GSM872276     4  0.4696      0.767 0.108 0.156 0.000 0.736 0.000
#> GSM872277     1  0.2124      0.894 0.916 0.028 0.000 0.056 0.000
#> GSM872278     4  0.1341      0.843 0.000 0.000 0.056 0.944 0.000
#> GSM872279     4  0.4276      0.569 0.380 0.000 0.000 0.616 0.004
#> GSM872280     4  0.4873      0.762 0.008 0.156 0.100 0.736 0.000
#> GSM872281     4  0.2971      0.815 0.008 0.156 0.000 0.836 0.000
#> GSM872282     3  0.2690      0.815 0.000 0.000 0.844 0.156 0.000
#> GSM872283     4  0.1788      0.844 0.008 0.004 0.056 0.932 0.000
#> GSM872284     4  0.3087      0.820 0.004 0.152 0.008 0.836 0.000
#> GSM872285     3  0.2438      0.822 0.000 0.040 0.900 0.060 0.000
#> GSM872286     5  0.1043      0.823 0.040 0.000 0.000 0.000 0.960
#> GSM872287     3  0.0000      0.859 0.000 0.000 1.000 0.000 0.000
#> GSM872288     5  0.1364      0.838 0.012 0.000 0.000 0.036 0.952
#> GSM872289     3  0.5906      0.333 0.000 0.000 0.492 0.404 0.104
#> GSM872290     1  0.0162      0.930 0.996 0.000 0.000 0.000 0.004
#> GSM872291     4  0.5354      0.752 0.188 0.128 0.000 0.680 0.004
#> GSM872292     2  0.2690      0.897 0.000 0.844 0.000 0.000 0.156
#> GSM872293     1  0.0162      0.930 0.996 0.000 0.000 0.000 0.004
#> GSM872294     2  0.2773      0.798 0.000 0.836 0.000 0.164 0.000
#> GSM872295     2  0.2690      0.897 0.000 0.844 0.000 0.000 0.156
#> GSM872296     2  0.2690      0.806 0.000 0.844 0.000 0.156 0.000
#> GSM872297     1  0.0162      0.930 0.996 0.000 0.000 0.000 0.004
#> GSM872298     4  0.1341      0.843 0.000 0.000 0.056 0.944 0.000
#> GSM872299     5  0.6739      0.023 0.348 0.000 0.000 0.260 0.392
#> GSM872300     4  0.4696      0.767 0.108 0.156 0.000 0.736 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
#> GSM872244     3  0.2300     0.7198 0.000 0.000 0.856 0.000 0.000 0.144
#> GSM872245     1  0.3168     0.7055 0.792 0.000 0.000 0.000 0.192 0.016
#> GSM872246     3  0.3717     0.7967 0.000 0.000 0.616 0.000 0.000 0.384
#> GSM872247     3  0.3847     0.8025 0.000 0.000 0.544 0.000 0.000 0.456
#> GSM872248     5  0.0146     0.8675 0.000 0.004 0.000 0.000 0.996 0.000
#> GSM872249     3  0.3847     0.8025 0.000 0.000 0.544 0.000 0.000 0.456
#> GSM872250     5  0.0000     0.8683 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM872251     3  0.2100     0.6215 0.000 0.000 0.884 0.004 0.000 0.112
#> GSM872252     6  0.6775     0.6216 0.196 0.000 0.184 0.108 0.000 0.512
#> GSM872253     6  0.5205     0.4873 0.000 0.000 0.384 0.096 0.000 0.520
#> GSM872254     5  0.3868    -0.0405 0.000 0.000 0.000 0.000 0.508 0.492
#> GSM872255     4  0.0000     0.6952 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM872256     4  0.4327     0.6513 0.140 0.000 0.092 0.752 0.016 0.000
#> GSM872257     2  0.0000     0.9344 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM872258     3  0.3714     0.7996 0.000 0.000 0.656 0.004 0.000 0.340
#> GSM872259     1  0.0000     0.8224 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM872260     4  0.4624     0.6894 0.080 0.000 0.220 0.692 0.000 0.008
#> GSM872261     4  0.4610     0.6979 0.000 0.000 0.384 0.580 0.024 0.012
#> GSM872262     4  0.0000     0.6952 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM872263     3  0.3717     0.7967 0.000 0.000 0.616 0.000 0.000 0.384
#> GSM872264     4  0.4543     0.6985 0.000 0.000 0.384 0.576 0.000 0.040
#> GSM872265     4  0.4543     0.6985 0.000 0.000 0.384 0.576 0.000 0.040
#> GSM872266     5  0.0000     0.8683 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM872267     5  0.3394     0.5944 0.000 0.236 0.000 0.000 0.752 0.012
#> GSM872268     3  0.3847     0.8025 0.000 0.000 0.544 0.000 0.000 0.456
#> GSM872269     5  0.0713     0.8536 0.000 0.000 0.000 0.000 0.972 0.028
#> GSM872270     3  0.1556     0.5646 0.000 0.000 0.920 0.000 0.000 0.080
#> GSM872271     6  0.5190     0.4927 0.000 0.000 0.384 0.072 0.008 0.536
#> GSM872272     4  0.5168     0.6773 0.000 0.000 0.384 0.548 0.028 0.040
#> GSM872273     1  0.2697     0.7775 0.812 0.000 0.000 0.188 0.000 0.000
#> GSM872274     2  0.0000     0.9344 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM872275     4  0.3955     0.7112 0.000 0.000 0.384 0.608 0.000 0.008
#> GSM872276     4  0.0000     0.6952 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM872277     1  0.2697     0.7775 0.812 0.000 0.000 0.188 0.000 0.000
#> GSM872278     4  0.3955     0.7112 0.000 0.000 0.384 0.608 0.000 0.008
#> GSM872279     6  0.5358     0.5005 0.392 0.000 0.000 0.112 0.000 0.496
#> GSM872280     4  0.0000     0.6952 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM872281     4  0.0000     0.6952 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM872282     3  0.2219     0.7146 0.000 0.000 0.864 0.000 0.000 0.136
#> GSM872283     4  0.4607     0.7120 0.012 0.000 0.356 0.604 0.000 0.028
#> GSM872284     4  0.0632     0.7002 0.000 0.000 0.024 0.976 0.000 0.000
#> GSM872285     3  0.5309     0.7345 0.000 0.000 0.560 0.128 0.000 0.312
#> GSM872286     5  0.0146     0.8677 0.000 0.000 0.000 0.000 0.996 0.004
#> GSM872287     3  0.3847     0.8025 0.000 0.000 0.544 0.000 0.000 0.456
#> GSM872288     5  0.0260     0.8643 0.000 0.000 0.000 0.008 0.992 0.000
#> GSM872289     3  0.5410     0.4988 0.000 0.000 0.680 0.128 0.120 0.072
#> GSM872290     6  0.3869     0.3037 0.500 0.000 0.000 0.000 0.000 0.500
#> GSM872291     6  0.5716     0.5346 0.188 0.000 0.000 0.312 0.000 0.500
#> GSM872292     2  0.0000     0.9344 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM872293     1  0.0000     0.8224 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM872294     2  0.0146     0.9309 0.000 0.996 0.004 0.000 0.000 0.000
#> GSM872295     2  0.3907     0.5746 0.000 0.704 0.000 0.000 0.028 0.268
#> GSM872296     2  0.0000     0.9344 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM872297     1  0.0000     0.8224 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM872298     4  0.3955     0.7112 0.000 0.000 0.384 0.608 0.000 0.008
#> GSM872299     6  0.5735     0.3371 0.200 0.000 0.000 0.000 0.296 0.504
#> GSM872300     4  0.0000     0.6952 0.000 0.000 0.000 1.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-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

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>         n time(p) individual(p) k
#> SD:pam 56   0.620      3.50e-02 2
#> SD:pam 53   0.762      7.10e-05 3
#> SD:pam 54   0.898      3.89e-05 4
#> SD:pam 55   0.563      4.64e-07 5
#> SD:pam 51   0.792      2.37e-07 6

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 29485 rows and 57 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 0.669           0.915       0.921         0.4171 0.560   0.560
#> 3 3 0.656           0.863       0.928         0.3441 0.612   0.441
#> 4 4 0.727           0.776       0.899         0.2896 0.761   0.496
#> 5 5 0.744           0.760       0.843         0.0809 0.934   0.765
#> 6 6 0.832           0.796       0.887         0.0536 0.900   0.591

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
#> GSM872244     1  0.4431      0.903 0.908 0.092
#> GSM872245     1  0.8144      0.588 0.748 0.252
#> GSM872246     1  0.4431      0.903 0.908 0.092
#> GSM872247     1  0.4431      0.903 0.908 0.092
#> GSM872248     2  0.4431      0.925 0.092 0.908
#> GSM872249     1  0.4431      0.903 0.908 0.092
#> GSM872250     1  0.0376      0.944 0.996 0.004
#> GSM872251     1  0.4298      0.906 0.912 0.088
#> GSM872252     1  0.0000      0.946 1.000 0.000
#> GSM872253     1  0.0000      0.946 1.000 0.000
#> GSM872254     2  0.7950      0.882 0.240 0.760
#> GSM872255     1  0.0000      0.946 1.000 0.000
#> GSM872256     1  0.1414      0.937 0.980 0.020
#> GSM872257     2  0.4431      0.925 0.092 0.908
#> GSM872258     1  0.4161      0.908 0.916 0.084
#> GSM872259     1  0.0000      0.946 1.000 0.000
#> GSM872260     1  0.0000      0.946 1.000 0.000
#> GSM872261     2  0.6712      0.937 0.176 0.824
#> GSM872262     1  0.1843      0.931 0.972 0.028
#> GSM872263     1  0.4431      0.903 0.908 0.092
#> GSM872264     2  0.6623      0.939 0.172 0.828
#> GSM872265     2  0.6623      0.939 0.172 0.828
#> GSM872266     2  0.6623      0.939 0.172 0.828
#> GSM872267     2  0.4431      0.925 0.092 0.908
#> GSM872268     1  0.4431      0.903 0.908 0.092
#> GSM872269     2  0.8386      0.848 0.268 0.732
#> GSM872270     1  0.4431      0.903 0.908 0.092
#> GSM872271     2  0.6623      0.939 0.172 0.828
#> GSM872272     2  0.6623      0.939 0.172 0.828
#> GSM872273     1  0.1414      0.937 0.980 0.020
#> GSM872274     2  0.4431      0.925 0.092 0.908
#> GSM872275     1  0.1184      0.939 0.984 0.016
#> GSM872276     1  0.1414      0.937 0.980 0.020
#> GSM872277     1  0.1414      0.937 0.980 0.020
#> GSM872278     1  0.0938      0.941 0.988 0.012
#> GSM872279     1  0.0000      0.946 1.000 0.000
#> GSM872280     1  0.0000      0.946 1.000 0.000
#> GSM872281     1  0.7674      0.649 0.776 0.224
#> GSM872282     1  0.6247      0.848 0.844 0.156
#> GSM872283     2  0.6712      0.937 0.176 0.824
#> GSM872284     2  0.8386      0.834 0.268 0.732
#> GSM872285     1  0.0000      0.946 1.000 0.000
#> GSM872286     1  0.0000      0.946 1.000 0.000
#> GSM872287     1  0.4431      0.903 0.908 0.092
#> GSM872288     1  0.0000      0.946 1.000 0.000
#> GSM872289     1  0.1414      0.939 0.980 0.020
#> GSM872290     1  0.0000      0.946 1.000 0.000
#> GSM872291     1  0.0000      0.946 1.000 0.000
#> GSM872292     2  0.4431      0.925 0.092 0.908
#> GSM872293     1  0.0000      0.946 1.000 0.000
#> GSM872294     2  0.6531      0.939 0.168 0.832
#> GSM872295     2  0.4431      0.925 0.092 0.908
#> GSM872296     2  0.4431      0.925 0.092 0.908
#> GSM872297     1  0.0000      0.946 1.000 0.000
#> GSM872298     1  0.0938      0.941 0.988 0.012
#> GSM872299     1  0.0000      0.946 1.000 0.000
#> GSM872300     1  0.1414      0.937 0.980 0.020

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM872244     3  0.0000      0.955 0.000 0.000 1.000
#> GSM872245     1  0.3752      0.887 0.856 0.144 0.000
#> GSM872246     3  0.0000      0.955 0.000 0.000 1.000
#> GSM872247     3  0.0000      0.955 0.000 0.000 1.000
#> GSM872248     2  0.0000      0.806 0.000 1.000 0.000
#> GSM872249     3  0.0000      0.955 0.000 0.000 1.000
#> GSM872250     1  0.3752      0.887 0.856 0.144 0.000
#> GSM872251     3  0.0000      0.955 0.000 0.000 1.000
#> GSM872252     1  0.3752      0.887 0.856 0.144 0.000
#> GSM872253     1  0.4209      0.888 0.860 0.120 0.020
#> GSM872254     2  0.3482      0.753 0.128 0.872 0.000
#> GSM872255     1  0.1411      0.907 0.964 0.036 0.000
#> GSM872256     1  0.3116      0.897 0.892 0.108 0.000
#> GSM872257     2  0.0000      0.806 0.000 1.000 0.000
#> GSM872258     3  0.0000      0.955 0.000 0.000 1.000
#> GSM872259     1  0.3752      0.887 0.856 0.144 0.000
#> GSM872260     1  0.3482      0.893 0.872 0.128 0.000
#> GSM872261     1  0.3752      0.887 0.856 0.144 0.000
#> GSM872262     1  0.0000      0.907 1.000 0.000 0.000
#> GSM872263     3  0.0000      0.955 0.000 0.000 1.000
#> GSM872264     1  0.0424      0.903 0.992 0.008 0.000
#> GSM872265     1  0.0237      0.905 0.996 0.004 0.000
#> GSM872266     2  0.4842      0.673 0.224 0.776 0.000
#> GSM872267     2  0.0000      0.806 0.000 1.000 0.000
#> GSM872268     3  0.0000      0.955 0.000 0.000 1.000
#> GSM872269     2  0.6168      0.206 0.412 0.588 0.000
#> GSM872270     3  0.0000      0.955 0.000 0.000 1.000
#> GSM872271     1  0.2625      0.840 0.916 0.084 0.000
#> GSM872272     1  0.2796      0.830 0.908 0.092 0.000
#> GSM872273     1  0.0000      0.907 1.000 0.000 0.000
#> GSM872274     2  0.3752      0.759 0.144 0.856 0.000
#> GSM872275     1  0.0000      0.907 1.000 0.000 0.000
#> GSM872276     1  0.0000      0.907 1.000 0.000 0.000
#> GSM872277     1  0.0000      0.907 1.000 0.000 0.000
#> GSM872278     1  0.0000      0.907 1.000 0.000 0.000
#> GSM872279     1  0.3752      0.887 0.856 0.144 0.000
#> GSM872280     1  0.0000      0.907 1.000 0.000 0.000
#> GSM872281     1  0.0000      0.907 1.000 0.000 0.000
#> GSM872282     3  0.0000      0.955 0.000 0.000 1.000
#> GSM872283     1  0.0237      0.905 0.996 0.004 0.000
#> GSM872284     1  0.0000      0.907 1.000 0.000 0.000
#> GSM872285     1  0.2711      0.871 0.912 0.000 0.088
#> GSM872286     1  0.3752      0.887 0.856 0.144 0.000
#> GSM872287     3  0.0000      0.955 0.000 0.000 1.000
#> GSM872288     1  0.3752      0.887 0.856 0.144 0.000
#> GSM872289     3  0.6047      0.422 0.312 0.008 0.680
#> GSM872290     1  0.3752      0.887 0.856 0.144 0.000
#> GSM872291     1  0.1031      0.908 0.976 0.024 0.000
#> GSM872292     2  0.3752      0.759 0.144 0.856 0.000
#> GSM872293     1  0.3752      0.887 0.856 0.144 0.000
#> GSM872294     1  0.3686      0.767 0.860 0.140 0.000
#> GSM872295     2  0.0000      0.806 0.000 1.000 0.000
#> GSM872296     2  0.3752      0.759 0.144 0.856 0.000
#> GSM872297     1  0.3752      0.887 0.856 0.144 0.000
#> GSM872298     1  0.0000      0.907 1.000 0.000 0.000
#> GSM872299     1  0.3752      0.887 0.856 0.144 0.000
#> GSM872300     1  0.0000      0.907 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM872244     3  0.0188      0.947 0.000 0.004 0.996 0.000
#> GSM872245     1  0.0188      0.758 0.996 0.004 0.000 0.000
#> GSM872246     3  0.0000      0.950 0.000 0.000 1.000 0.000
#> GSM872247     3  0.0000      0.950 0.000 0.000 1.000 0.000
#> GSM872248     2  0.4948      0.402 0.440 0.560 0.000 0.000
#> GSM872249     3  0.0000      0.950 0.000 0.000 1.000 0.000
#> GSM872250     1  0.0188      0.758 0.996 0.004 0.000 0.000
#> GSM872251     3  0.0000      0.950 0.000 0.000 1.000 0.000
#> GSM872252     1  0.4122      0.761 0.760 0.004 0.000 0.236
#> GSM872253     3  0.5827      0.123 0.024 0.004 0.536 0.436
#> GSM872254     1  0.0188      0.758 0.996 0.004 0.000 0.000
#> GSM872255     4  0.0000      0.878 0.000 0.000 0.000 1.000
#> GSM872256     4  0.3539      0.672 0.176 0.004 0.000 0.820
#> GSM872257     2  0.1389      0.843 0.048 0.952 0.000 0.000
#> GSM872258     3  0.0000      0.950 0.000 0.000 1.000 0.000
#> GSM872259     1  0.4222      0.746 0.728 0.000 0.000 0.272
#> GSM872260     4  0.0817      0.863 0.024 0.000 0.000 0.976
#> GSM872261     1  0.3539      0.771 0.820 0.004 0.000 0.176
#> GSM872262     4  0.0469      0.878 0.000 0.012 0.000 0.988
#> GSM872263     3  0.0000      0.950 0.000 0.000 1.000 0.000
#> GSM872264     4  0.1510      0.871 0.000 0.028 0.016 0.956
#> GSM872265     4  0.1510      0.871 0.000 0.028 0.016 0.956
#> GSM872266     1  0.4661      0.134 0.652 0.348 0.000 0.000
#> GSM872267     2  0.1389      0.843 0.048 0.952 0.000 0.000
#> GSM872268     3  0.0000      0.950 0.000 0.000 1.000 0.000
#> GSM872269     1  0.0188      0.758 0.996 0.004 0.000 0.000
#> GSM872270     3  0.0000      0.950 0.000 0.000 1.000 0.000
#> GSM872271     4  0.4843      0.360 0.000 0.396 0.000 0.604
#> GSM872272     4  0.4746      0.427 0.000 0.368 0.000 0.632
#> GSM872273     4  0.0000      0.878 0.000 0.000 0.000 1.000
#> GSM872274     2  0.0000      0.846 0.000 1.000 0.000 0.000
#> GSM872275     4  0.4313      0.616 0.000 0.004 0.260 0.736
#> GSM872276     4  0.0817      0.876 0.000 0.024 0.000 0.976
#> GSM872277     4  0.0000      0.878 0.000 0.000 0.000 1.000
#> GSM872278     4  0.2125      0.836 0.000 0.004 0.076 0.920
#> GSM872279     1  0.4250      0.744 0.724 0.000 0.000 0.276
#> GSM872280     4  0.0000      0.878 0.000 0.000 0.000 1.000
#> GSM872281     4  0.0817      0.876 0.000 0.024 0.000 0.976
#> GSM872282     3  0.0188      0.947 0.000 0.004 0.996 0.000
#> GSM872283     4  0.0921      0.875 0.000 0.028 0.000 0.972
#> GSM872284     4  0.0817      0.876 0.000 0.024 0.000 0.976
#> GSM872285     4  0.4624      0.479 0.000 0.000 0.340 0.660
#> GSM872286     1  0.0188      0.758 0.996 0.004 0.000 0.000
#> GSM872287     3  0.0000      0.950 0.000 0.000 1.000 0.000
#> GSM872288     1  0.4018      0.764 0.772 0.004 0.000 0.224
#> GSM872289     3  0.0524      0.940 0.000 0.004 0.988 0.008
#> GSM872290     1  0.4564      0.673 0.672 0.000 0.000 0.328
#> GSM872291     4  0.0000      0.878 0.000 0.000 0.000 1.000
#> GSM872292     2  0.0000      0.846 0.000 1.000 0.000 0.000
#> GSM872293     1  0.4250      0.744 0.724 0.000 0.000 0.276
#> GSM872294     2  0.3801      0.626 0.000 0.780 0.000 0.220
#> GSM872295     2  0.3610      0.714 0.200 0.800 0.000 0.000
#> GSM872296     2  0.0000      0.846 0.000 1.000 0.000 0.000
#> GSM872297     4  0.4500      0.367 0.316 0.000 0.000 0.684
#> GSM872298     4  0.0000      0.878 0.000 0.000 0.000 1.000
#> GSM872299     1  0.0188      0.758 0.996 0.004 0.000 0.000
#> GSM872300     4  0.0000      0.878 0.000 0.000 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM872244     3  0.0000     0.9821 0.000 0.000 1.000 0.000 0.000
#> GSM872245     5  0.3561     0.7385 0.260 0.000 0.000 0.000 0.740
#> GSM872246     3  0.0000     0.9821 0.000 0.000 1.000 0.000 0.000
#> GSM872247     3  0.0000     0.9821 0.000 0.000 1.000 0.000 0.000
#> GSM872248     5  0.3274     0.3862 0.000 0.220 0.000 0.000 0.780
#> GSM872249     3  0.0000     0.9821 0.000 0.000 1.000 0.000 0.000
#> GSM872250     5  0.2424     0.7651 0.132 0.000 0.000 0.000 0.868
#> GSM872251     3  0.0000     0.9821 0.000 0.000 1.000 0.000 0.000
#> GSM872252     5  0.4434     0.4536 0.460 0.000 0.000 0.004 0.536
#> GSM872253     3  0.3674     0.7915 0.020 0.000 0.832 0.116 0.032
#> GSM872254     5  0.0510     0.7053 0.016 0.000 0.000 0.000 0.984
#> GSM872255     4  0.3636     0.6906 0.272 0.000 0.000 0.728 0.000
#> GSM872256     1  0.1124     0.9374 0.960 0.000 0.004 0.036 0.000
#> GSM872257     2  0.4060     0.5743 0.000 0.640 0.000 0.000 0.360
#> GSM872258     3  0.0162     0.9787 0.000 0.000 0.996 0.004 0.000
#> GSM872259     1  0.0510     0.9742 0.984 0.000 0.000 0.000 0.016
#> GSM872260     4  0.4287     0.3297 0.460 0.000 0.000 0.540 0.000
#> GSM872261     5  0.4867     0.6971 0.180 0.000 0.000 0.104 0.716
#> GSM872262     4  0.2230     0.8124 0.116 0.000 0.000 0.884 0.000
#> GSM872263     3  0.0000     0.9821 0.000 0.000 1.000 0.000 0.000
#> GSM872264     4  0.1278     0.7849 0.004 0.000 0.020 0.960 0.016
#> GSM872265     4  0.1278     0.7849 0.004 0.000 0.020 0.960 0.016
#> GSM872266     5  0.2251     0.7210 0.052 0.024 0.008 0.000 0.916
#> GSM872267     2  0.3109     0.6940 0.000 0.800 0.000 0.000 0.200
#> GSM872268     3  0.0000     0.9821 0.000 0.000 1.000 0.000 0.000
#> GSM872269     5  0.0510     0.7053 0.016 0.000 0.000 0.000 0.984
#> GSM872270     3  0.0000     0.9821 0.000 0.000 1.000 0.000 0.000
#> GSM872271     4  0.4737     0.5049 0.004 0.256 0.020 0.704 0.016
#> GSM872272     4  0.4762     0.4983 0.004 0.260 0.020 0.700 0.016
#> GSM872273     4  0.4287     0.2912 0.460 0.000 0.000 0.540 0.000
#> GSM872274     2  0.0000     0.7364 0.000 1.000 0.000 0.000 0.000
#> GSM872275     4  0.2020     0.7516 0.000 0.000 0.100 0.900 0.000
#> GSM872276     4  0.2230     0.8124 0.116 0.000 0.000 0.884 0.000
#> GSM872277     4  0.2230     0.8124 0.116 0.000 0.000 0.884 0.000
#> GSM872278     4  0.0963     0.7885 0.000 0.000 0.036 0.964 0.000
#> GSM872279     1  0.0510     0.9742 0.984 0.000 0.000 0.000 0.016
#> GSM872280     4  0.2230     0.8124 0.116 0.000 0.000 0.884 0.000
#> GSM872281     4  0.2144     0.8101 0.068 0.000 0.020 0.912 0.000
#> GSM872282     3  0.0000     0.9821 0.000 0.000 1.000 0.000 0.000
#> GSM872283     4  0.1117     0.7866 0.000 0.000 0.020 0.964 0.016
#> GSM872284     4  0.2012     0.8087 0.060 0.000 0.020 0.920 0.000
#> GSM872285     4  0.4161     0.4250 0.000 0.000 0.392 0.608 0.000
#> GSM872286     5  0.3424     0.7490 0.240 0.000 0.000 0.000 0.760
#> GSM872287     3  0.0000     0.9821 0.000 0.000 1.000 0.000 0.000
#> GSM872288     5  0.3961     0.7406 0.248 0.000 0.000 0.016 0.736
#> GSM872289     3  0.0510     0.9673 0.000 0.000 0.984 0.016 0.000
#> GSM872290     1  0.0162     0.9730 0.996 0.000 0.000 0.004 0.000
#> GSM872291     4  0.3612     0.6933 0.268 0.000 0.000 0.732 0.000
#> GSM872292     2  0.0000     0.7364 0.000 1.000 0.000 0.000 0.000
#> GSM872293     1  0.0510     0.9742 0.984 0.000 0.000 0.000 0.016
#> GSM872294     2  0.4446    -0.0339 0.004 0.520 0.000 0.476 0.000
#> GSM872295     2  0.4171     0.5411 0.000 0.604 0.000 0.000 0.396
#> GSM872296     2  0.0000     0.7364 0.000 1.000 0.000 0.000 0.000
#> GSM872297     1  0.0162     0.9730 0.996 0.000 0.000 0.004 0.000
#> GSM872298     4  0.2230     0.8124 0.116 0.000 0.000 0.884 0.000
#> GSM872299     5  0.4283     0.4692 0.456 0.000 0.000 0.000 0.544
#> GSM872300     4  0.2230     0.8124 0.116 0.000 0.000 0.884 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
#> GSM872244     3  0.0000      0.928 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872245     5  0.2260      0.836 0.140 0.000 0.000 0.000 0.860 0.000
#> GSM872246     3  0.0000      0.928 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872247     3  0.0000      0.928 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872248     2  0.3747      0.533 0.000 0.604 0.000 0.000 0.396 0.000
#> GSM872249     3  0.0000      0.928 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872250     5  0.1588      0.858 0.072 0.000 0.000 0.004 0.924 0.000
#> GSM872251     3  0.0790      0.914 0.000 0.000 0.968 0.032 0.000 0.000
#> GSM872252     5  0.4466      0.539 0.336 0.000 0.000 0.044 0.620 0.000
#> GSM872253     3  0.4804      0.709 0.000 0.000 0.728 0.096 0.132 0.044
#> GSM872254     5  0.1141      0.800 0.000 0.052 0.000 0.000 0.948 0.000
#> GSM872255     6  0.0806      0.950 0.008 0.000 0.000 0.020 0.000 0.972
#> GSM872256     1  0.3464      0.469 0.688 0.000 0.000 0.000 0.000 0.312
#> GSM872257     2  0.2340      0.836 0.000 0.852 0.000 0.000 0.148 0.000
#> GSM872258     3  0.1610      0.884 0.000 0.000 0.916 0.084 0.000 0.000
#> GSM872259     1  0.0000      0.832 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM872260     6  0.2999      0.789 0.112 0.000 0.000 0.048 0.000 0.840
#> GSM872261     5  0.2896      0.806 0.016 0.000 0.000 0.160 0.824 0.000
#> GSM872262     6  0.0000      0.966 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM872263     3  0.0000      0.928 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872264     4  0.3563      0.638 0.000 0.000 0.000 0.664 0.000 0.336
#> GSM872265     4  0.3515      0.650 0.000 0.000 0.000 0.676 0.000 0.324
#> GSM872266     5  0.0291      0.840 0.004 0.004 0.000 0.000 0.992 0.000
#> GSM872267     2  0.2980      0.831 0.000 0.808 0.000 0.012 0.180 0.000
#> GSM872268     3  0.0000      0.928 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872269     5  0.0000      0.838 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM872270     3  0.0000      0.928 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872271     4  0.2511      0.684 0.000 0.056 0.000 0.880 0.000 0.064
#> GSM872272     4  0.2511      0.684 0.000 0.056 0.000 0.880 0.000 0.064
#> GSM872273     6  0.1267      0.906 0.060 0.000 0.000 0.000 0.000 0.940
#> GSM872274     2  0.1387      0.815 0.000 0.932 0.000 0.068 0.000 0.000
#> GSM872275     4  0.4408      0.403 0.000 0.000 0.320 0.636 0.000 0.044
#> GSM872276     6  0.0000      0.966 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM872277     6  0.0000      0.966 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM872278     4  0.4871      0.631 0.000 0.000 0.196 0.660 0.000 0.144
#> GSM872279     1  0.0000      0.832 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM872280     6  0.0547      0.953 0.000 0.000 0.000 0.020 0.000 0.980
#> GSM872281     6  0.0000      0.966 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM872282     3  0.0000      0.928 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872283     4  0.3857      0.405 0.000 0.000 0.000 0.532 0.000 0.468
#> GSM872284     6  0.0000      0.966 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM872285     3  0.4902      0.450 0.000 0.000 0.608 0.088 0.000 0.304
#> GSM872286     5  0.2178      0.841 0.132 0.000 0.000 0.000 0.868 0.000
#> GSM872287     3  0.0000      0.928 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872288     5  0.3274      0.830 0.096 0.000 0.000 0.080 0.824 0.000
#> GSM872289     3  0.2214      0.866 0.000 0.000 0.888 0.096 0.016 0.000
#> GSM872290     1  0.0000      0.832 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM872291     6  0.0363      0.960 0.012 0.000 0.000 0.000 0.000 0.988
#> GSM872292     2  0.1387      0.815 0.000 0.932 0.000 0.068 0.000 0.000
#> GSM872293     1  0.0000      0.832 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM872294     4  0.2474      0.661 0.000 0.080 0.000 0.880 0.000 0.040
#> GSM872295     2  0.2664      0.825 0.000 0.816 0.000 0.000 0.184 0.000
#> GSM872296     2  0.1387      0.815 0.000 0.932 0.000 0.068 0.000 0.000
#> GSM872297     1  0.0000      0.832 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM872298     6  0.0000      0.966 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM872299     1  0.3862     -0.192 0.524 0.000 0.000 0.000 0.476 0.000
#> GSM872300     6  0.0000      0.966 0.000 0.000 0.000 0.000 0.000 1.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

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>            n time(p) individual(p) k
#> SD:mclust 57   0.377      0.234717 2
#> SD:mclust 55   0.612      0.000501 3
#> SD:mclust 50   0.251      0.000411 4
#> SD:mclust 49   0.262      0.005321 5
#> SD:mclust 52   0.198      0.002496 6

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 29485 rows and 57 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.516           0.757       0.874         0.4676 0.491   0.491
#> 3 3 0.874           0.911       0.961         0.4214 0.682   0.443
#> 4 4 0.658           0.640       0.795         0.1137 0.905   0.728
#> 5 5 0.699           0.702       0.818         0.0715 0.898   0.651
#> 6 6 0.652           0.591       0.732         0.0439 0.888   0.550

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
#> GSM872244     1  0.3274      0.867 0.940 0.060
#> GSM872245     2  0.7883      0.742 0.236 0.764
#> GSM872246     1  0.0000      0.914 1.000 0.000
#> GSM872247     1  0.0000      0.914 1.000 0.000
#> GSM872248     2  0.0000      0.763 0.000 1.000
#> GSM872249     1  0.2778      0.880 0.952 0.048
#> GSM872250     2  0.7815      0.739 0.232 0.768
#> GSM872251     1  0.0000      0.914 1.000 0.000
#> GSM872252     2  0.9491      0.676 0.368 0.632
#> GSM872253     1  0.2236      0.895 0.964 0.036
#> GSM872254     2  0.0000      0.763 0.000 1.000
#> GSM872255     1  0.0000      0.914 1.000 0.000
#> GSM872256     2  0.9358      0.696 0.352 0.648
#> GSM872257     2  0.0000      0.763 0.000 1.000
#> GSM872258     1  0.0000      0.914 1.000 0.000
#> GSM872259     2  0.9358      0.696 0.352 0.648
#> GSM872260     1  0.9129      0.262 0.672 0.328
#> GSM872261     2  0.7376      0.745 0.208 0.792
#> GSM872262     1  0.0000      0.914 1.000 0.000
#> GSM872263     1  0.1184      0.905 0.984 0.016
#> GSM872264     1  0.0000      0.914 1.000 0.000
#> GSM872265     1  0.9988     -0.351 0.520 0.480
#> GSM872266     2  0.0000      0.763 0.000 1.000
#> GSM872267     2  0.0000      0.763 0.000 1.000
#> GSM872268     1  0.0000      0.914 1.000 0.000
#> GSM872269     2  0.1184      0.763 0.016 0.984
#> GSM872270     1  0.2603      0.883 0.956 0.044
#> GSM872271     2  0.0000      0.763 0.000 1.000
#> GSM872272     2  0.0000      0.763 0.000 1.000
#> GSM872273     2  0.9754      0.606 0.408 0.592
#> GSM872274     2  0.0000      0.763 0.000 1.000
#> GSM872275     1  0.2778      0.880 0.952 0.048
#> GSM872276     1  0.0000      0.914 1.000 0.000
#> GSM872277     2  0.9996      0.409 0.488 0.512
#> GSM872278     1  0.0000      0.914 1.000 0.000
#> GSM872279     2  0.9358      0.696 0.352 0.648
#> GSM872280     1  0.0000      0.914 1.000 0.000
#> GSM872281     1  0.0000      0.914 1.000 0.000
#> GSM872282     1  0.8144      0.598 0.748 0.252
#> GSM872283     2  0.9635      0.643 0.388 0.612
#> GSM872284     1  0.0000      0.914 1.000 0.000
#> GSM872285     1  0.0000      0.914 1.000 0.000
#> GSM872286     2  0.9248      0.703 0.340 0.660
#> GSM872287     1  0.0000      0.914 1.000 0.000
#> GSM872288     2  0.9460      0.681 0.364 0.636
#> GSM872289     1  0.0000      0.914 1.000 0.000
#> GSM872290     2  0.9393      0.691 0.356 0.644
#> GSM872291     1  0.9393      0.156 0.644 0.356
#> GSM872292     2  0.0000      0.763 0.000 1.000
#> GSM872293     2  0.9358      0.696 0.352 0.648
#> GSM872294     2  0.0000      0.763 0.000 1.000
#> GSM872295     2  0.0000      0.763 0.000 1.000
#> GSM872296     2  0.0000      0.763 0.000 1.000
#> GSM872297     2  0.9393      0.691 0.356 0.644
#> GSM872298     1  0.0000      0.914 1.000 0.000
#> GSM872299     2  0.9286      0.701 0.344 0.656
#> GSM872300     1  0.0672      0.909 0.992 0.008

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM872244     3  0.0000      0.978 0.000 0.000 1.000
#> GSM872245     1  0.1031      0.927 0.976 0.024 0.000
#> GSM872246     3  0.0000      0.978 0.000 0.000 1.000
#> GSM872247     3  0.0000      0.978 0.000 0.000 1.000
#> GSM872248     2  0.0000      0.940 0.000 1.000 0.000
#> GSM872249     3  0.0000      0.978 0.000 0.000 1.000
#> GSM872250     2  0.5988      0.490 0.368 0.632 0.000
#> GSM872251     3  0.0000      0.978 0.000 0.000 1.000
#> GSM872252     1  0.0000      0.947 1.000 0.000 0.000
#> GSM872253     3  0.4002      0.802 0.160 0.000 0.840
#> GSM872254     2  0.1529      0.917 0.040 0.960 0.000
#> GSM872255     1  0.0000      0.947 1.000 0.000 0.000
#> GSM872256     1  0.0000      0.947 1.000 0.000 0.000
#> GSM872257     2  0.0000      0.940 0.000 1.000 0.000
#> GSM872258     3  0.0000      0.978 0.000 0.000 1.000
#> GSM872259     1  0.0000      0.947 1.000 0.000 0.000
#> GSM872260     1  0.0000      0.947 1.000 0.000 0.000
#> GSM872261     2  0.5363      0.661 0.276 0.724 0.000
#> GSM872262     1  0.2066      0.902 0.940 0.000 0.060
#> GSM872263     3  0.0000      0.978 0.000 0.000 1.000
#> GSM872264     3  0.0000      0.978 0.000 0.000 1.000
#> GSM872265     1  0.6735      0.283 0.564 0.012 0.424
#> GSM872266     2  0.0000      0.940 0.000 1.000 0.000
#> GSM872267     2  0.0000      0.940 0.000 1.000 0.000
#> GSM872268     3  0.0000      0.978 0.000 0.000 1.000
#> GSM872269     2  0.3551      0.841 0.132 0.868 0.000
#> GSM872270     3  0.0000      0.978 0.000 0.000 1.000
#> GSM872271     2  0.0000      0.940 0.000 1.000 0.000
#> GSM872272     2  0.0000      0.940 0.000 1.000 0.000
#> GSM872273     1  0.0000      0.947 1.000 0.000 0.000
#> GSM872274     2  0.0000      0.940 0.000 1.000 0.000
#> GSM872275     3  0.0000      0.978 0.000 0.000 1.000
#> GSM872276     1  0.0747      0.937 0.984 0.000 0.016
#> GSM872277     1  0.0000      0.947 1.000 0.000 0.000
#> GSM872278     3  0.0000      0.978 0.000 0.000 1.000
#> GSM872279     1  0.0000      0.947 1.000 0.000 0.000
#> GSM872280     3  0.0424      0.972 0.008 0.000 0.992
#> GSM872281     3  0.3267      0.861 0.116 0.000 0.884
#> GSM872282     3  0.0000      0.978 0.000 0.000 1.000
#> GSM872283     1  0.1031      0.932 0.976 0.000 0.024
#> GSM872284     1  0.5948      0.468 0.640 0.000 0.360
#> GSM872285     3  0.0000      0.978 0.000 0.000 1.000
#> GSM872286     1  0.0000      0.947 1.000 0.000 0.000
#> GSM872287     3  0.0000      0.978 0.000 0.000 1.000
#> GSM872288     1  0.0000      0.947 1.000 0.000 0.000
#> GSM872289     3  0.1964      0.928 0.056 0.000 0.944
#> GSM872290     1  0.0000      0.947 1.000 0.000 0.000
#> GSM872291     1  0.0000      0.947 1.000 0.000 0.000
#> GSM872292     2  0.0000      0.940 0.000 1.000 0.000
#> GSM872293     1  0.0000      0.947 1.000 0.000 0.000
#> GSM872294     2  0.0000      0.940 0.000 1.000 0.000
#> GSM872295     2  0.0000      0.940 0.000 1.000 0.000
#> GSM872296     2  0.0000      0.940 0.000 1.000 0.000
#> GSM872297     1  0.0000      0.947 1.000 0.000 0.000
#> GSM872298     1  0.3340      0.845 0.880 0.000 0.120
#> GSM872299     1  0.0000      0.947 1.000 0.000 0.000
#> GSM872300     1  0.0000      0.947 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM872244     3  0.0469     0.8147 0.000 0.000 0.988 0.012
#> GSM872245     1  0.2385     0.5777 0.920 0.052 0.000 0.028
#> GSM872246     3  0.1389     0.8289 0.000 0.000 0.952 0.048
#> GSM872247     3  0.3123     0.8239 0.000 0.000 0.844 0.156
#> GSM872248     2  0.4561     0.7243 0.176 0.788 0.008 0.028
#> GSM872249     3  0.0000     0.8194 0.000 0.000 1.000 0.000
#> GSM872250     1  0.7900    -0.0172 0.480 0.140 0.352 0.028
#> GSM872251     3  0.0817     0.8252 0.000 0.000 0.976 0.024
#> GSM872252     1  0.0000     0.6285 1.000 0.000 0.000 0.000
#> GSM872253     3  0.2342     0.7651 0.080 0.000 0.912 0.008
#> GSM872254     2  0.7401     0.6028 0.244 0.592 0.136 0.028
#> GSM872255     1  0.3907     0.6997 0.768 0.000 0.000 0.232
#> GSM872256     1  0.3569     0.7154 0.804 0.000 0.000 0.196
#> GSM872257     2  0.0000     0.7789 0.000 1.000 0.000 0.000
#> GSM872258     3  0.1452     0.8269 0.008 0.000 0.956 0.036
#> GSM872259     1  0.3486     0.7152 0.812 0.000 0.000 0.188
#> GSM872260     1  0.3688     0.7115 0.792 0.000 0.000 0.208
#> GSM872261     2  0.5427     0.4981 0.416 0.568 0.000 0.016
#> GSM872262     4  0.5126     0.0281 0.444 0.000 0.004 0.552
#> GSM872263     3  0.0188     0.8208 0.000 0.000 0.996 0.004
#> GSM872264     4  0.3401     0.3704 0.000 0.008 0.152 0.840
#> GSM872265     4  0.3556     0.5736 0.036 0.096 0.004 0.864
#> GSM872266     2  0.4742     0.7095 0.208 0.760 0.004 0.028
#> GSM872267     2  0.1151     0.7778 0.024 0.968 0.000 0.008
#> GSM872268     3  0.3123     0.8239 0.000 0.000 0.844 0.156
#> GSM872269     2  0.6896     0.6177 0.272 0.616 0.088 0.024
#> GSM872270     3  0.4382     0.7664 0.000 0.000 0.704 0.296
#> GSM872271     2  0.4761     0.4707 0.000 0.628 0.000 0.372
#> GSM872272     2  0.4730     0.4824 0.000 0.636 0.000 0.364
#> GSM872273     1  0.4164     0.6737 0.736 0.000 0.000 0.264
#> GSM872274     2  0.1389     0.7713 0.000 0.952 0.000 0.048
#> GSM872275     3  0.4175     0.8066 0.000 0.012 0.776 0.212
#> GSM872276     1  0.5097     0.3141 0.568 0.000 0.004 0.428
#> GSM872277     1  0.4222     0.6718 0.728 0.000 0.000 0.272
#> GSM872278     3  0.4925     0.6318 0.000 0.000 0.572 0.428
#> GSM872279     1  0.2281     0.6842 0.904 0.000 0.000 0.096
#> GSM872280     3  0.7258     0.4077 0.164 0.000 0.508 0.328
#> GSM872281     4  0.2965     0.6213 0.072 0.000 0.036 0.892
#> GSM872282     3  0.4643     0.7198 0.000 0.000 0.656 0.344
#> GSM872283     4  0.5299     0.1978 0.388 0.008 0.004 0.600
#> GSM872284     4  0.4446     0.5709 0.196 0.000 0.028 0.776
#> GSM872285     3  0.5519     0.7451 0.052 0.000 0.684 0.264
#> GSM872286     1  0.3978     0.5150 0.860 0.048 0.064 0.028
#> GSM872287     3  0.4164     0.7857 0.000 0.000 0.736 0.264
#> GSM872288     1  0.4164     0.4949 0.844 0.036 0.096 0.024
#> GSM872289     3  0.1256     0.8030 0.028 0.000 0.964 0.008
#> GSM872290     1  0.3528     0.7159 0.808 0.000 0.000 0.192
#> GSM872291     1  0.4040     0.6878 0.752 0.000 0.000 0.248
#> GSM872292     2  0.1389     0.7713 0.000 0.952 0.000 0.048
#> GSM872293     1  0.3400     0.7153 0.820 0.000 0.000 0.180
#> GSM872294     2  0.2704     0.7368 0.000 0.876 0.000 0.124
#> GSM872295     2  0.0524     0.7793 0.004 0.988 0.000 0.008
#> GSM872296     2  0.2081     0.7593 0.000 0.916 0.000 0.084
#> GSM872297     1  0.3975     0.6984 0.760 0.000 0.000 0.240
#> GSM872298     1  0.5273     0.2084 0.536 0.000 0.008 0.456
#> GSM872299     1  0.1677     0.5911 0.948 0.040 0.000 0.012
#> GSM872300     1  0.4677     0.5940 0.680 0.000 0.004 0.316

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM872244     3  0.3201     0.7819 0.000 0.000 0.852 0.096 0.052
#> GSM872245     5  0.2782     0.7837 0.048 0.000 0.000 0.072 0.880
#> GSM872246     3  0.0510     0.8314 0.000 0.000 0.984 0.016 0.000
#> GSM872247     3  0.2077     0.8286 0.000 0.000 0.908 0.084 0.008
#> GSM872248     5  0.3526     0.7891 0.000 0.096 0.000 0.072 0.832
#> GSM872249     3  0.2654     0.7970 0.000 0.000 0.884 0.084 0.032
#> GSM872250     5  0.5016     0.6081 0.016 0.000 0.160 0.092 0.732
#> GSM872251     3  0.1915     0.8159 0.000 0.000 0.928 0.032 0.040
#> GSM872252     1  0.2079     0.7981 0.916 0.000 0.000 0.020 0.064
#> GSM872253     3  0.6859     0.5432 0.212 0.004 0.596 0.092 0.096
#> GSM872254     2  0.7546     0.2443 0.008 0.468 0.092 0.104 0.328
#> GSM872255     1  0.0912     0.8213 0.972 0.000 0.016 0.012 0.000
#> GSM872256     1  0.2376     0.8145 0.904 0.000 0.000 0.044 0.052
#> GSM872257     2  0.0404     0.8495 0.000 0.988 0.000 0.000 0.012
#> GSM872258     3  0.1278     0.8297 0.020 0.000 0.960 0.016 0.004
#> GSM872259     1  0.2648     0.7588 0.848 0.000 0.000 0.000 0.152
#> GSM872260     1  0.0798     0.8243 0.976 0.000 0.008 0.016 0.000
#> GSM872261     2  0.5280     0.5873 0.240 0.676 0.000 0.012 0.072
#> GSM872262     4  0.5534     0.1196 0.424 0.000 0.068 0.508 0.000
#> GSM872263     3  0.2946     0.7910 0.000 0.000 0.868 0.088 0.044
#> GSM872264     4  0.4625     0.6279 0.000 0.008 0.036 0.712 0.244
#> GSM872265     4  0.4330     0.6527 0.016 0.008 0.024 0.776 0.176
#> GSM872266     5  0.2989     0.7931 0.000 0.060 0.000 0.072 0.868
#> GSM872267     5  0.3966     0.7696 0.000 0.132 0.000 0.072 0.796
#> GSM872268     3  0.2424     0.8179 0.000 0.000 0.868 0.132 0.000
#> GSM872269     2  0.4774     0.7349 0.064 0.780 0.008 0.032 0.116
#> GSM872270     3  0.2984     0.8266 0.000 0.000 0.860 0.108 0.032
#> GSM872271     4  0.5296     0.5225 0.000 0.280 0.000 0.636 0.084
#> GSM872272     4  0.5026     0.5844 0.000 0.064 0.000 0.656 0.280
#> GSM872273     1  0.4768     0.5072 0.656 0.000 0.000 0.304 0.040
#> GSM872274     2  0.0162     0.8513 0.000 0.996 0.000 0.000 0.004
#> GSM872275     3  0.3517     0.8240 0.016 0.004 0.844 0.112 0.024
#> GSM872276     1  0.4323     0.4791 0.656 0.000 0.012 0.332 0.000
#> GSM872277     4  0.6032     0.0551 0.424 0.000 0.000 0.460 0.116
#> GSM872278     3  0.4651     0.6845 0.016 0.008 0.680 0.292 0.004
#> GSM872279     1  0.1082     0.8252 0.964 0.000 0.000 0.008 0.028
#> GSM872280     3  0.5713     0.2318 0.416 0.000 0.500 0.084 0.000
#> GSM872281     4  0.3975     0.5771 0.064 0.000 0.144 0.792 0.000
#> GSM872282     3  0.3484     0.8228 0.000 0.004 0.824 0.144 0.028
#> GSM872283     4  0.4477     0.6094 0.016 0.008 0.000 0.688 0.288
#> GSM872284     4  0.5105     0.6404 0.040 0.000 0.104 0.748 0.108
#> GSM872285     3  0.3482     0.7964 0.012 0.000 0.812 0.168 0.008
#> GSM872286     5  0.2470     0.7581 0.104 0.000 0.000 0.012 0.884
#> GSM872287     3  0.2971     0.8064 0.000 0.000 0.836 0.156 0.008
#> GSM872288     5  0.2645     0.7655 0.096 0.000 0.012 0.008 0.884
#> GSM872289     3  0.4020     0.7433 0.000 0.000 0.796 0.108 0.096
#> GSM872290     1  0.0992     0.8291 0.968 0.000 0.000 0.008 0.024
#> GSM872291     1  0.1012     0.8290 0.968 0.000 0.000 0.020 0.012
#> GSM872292     2  0.0162     0.8509 0.000 0.996 0.000 0.004 0.000
#> GSM872293     1  0.0963     0.8269 0.964 0.000 0.000 0.000 0.036
#> GSM872294     2  0.0290     0.8500 0.000 0.992 0.000 0.008 0.000
#> GSM872295     2  0.0290     0.8505 0.000 0.992 0.000 0.000 0.008
#> GSM872296     2  0.1205     0.8299 0.000 0.956 0.000 0.040 0.004
#> GSM872297     1  0.3749     0.7558 0.816 0.000 0.000 0.080 0.104
#> GSM872298     1  0.5086     0.4390 0.636 0.000 0.060 0.304 0.000
#> GSM872299     1  0.2046     0.7956 0.916 0.000 0.000 0.016 0.068
#> GSM872300     1  0.4153     0.6399 0.740 0.000 0.016 0.236 0.008

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM872244     3  0.4377     0.7540 0.000 0.000 0.716 0.016 0.048 0.220
#> GSM872245     5  0.6332     0.3846 0.300 0.000 0.000 0.092 0.520 0.088
#> GSM872246     3  0.1503     0.8504 0.008 0.000 0.944 0.000 0.016 0.032
#> GSM872247     3  0.0870     0.8447 0.012 0.000 0.972 0.004 0.000 0.012
#> GSM872248     5  0.3105     0.7320 0.000 0.080 0.000 0.064 0.848 0.008
#> GSM872249     3  0.2279     0.8443 0.000 0.000 0.900 0.004 0.048 0.048
#> GSM872250     5  0.4005     0.6739 0.016 0.000 0.052 0.008 0.788 0.136
#> GSM872251     3  0.3032     0.8356 0.008 0.000 0.864 0.016 0.080 0.032
#> GSM872252     6  0.4238     0.2758 0.340 0.000 0.000 0.008 0.016 0.636
#> GSM872253     6  0.4758     0.4691 0.040 0.012 0.108 0.056 0.016 0.768
#> GSM872254     6  0.6663     0.1770 0.004 0.260 0.024 0.008 0.232 0.472
#> GSM872255     1  0.2463     0.5559 0.888 0.000 0.024 0.004 0.004 0.080
#> GSM872256     1  0.3407     0.5447 0.820 0.000 0.004 0.008 0.132 0.036
#> GSM872257     2  0.1812     0.8860 0.000 0.912 0.000 0.008 0.080 0.000
#> GSM872258     3  0.4025     0.6188 0.016 0.000 0.668 0.000 0.004 0.312
#> GSM872259     1  0.4171     0.5320 0.776 0.000 0.000 0.048 0.132 0.044
#> GSM872260     1  0.3989     0.0134 0.528 0.000 0.000 0.004 0.000 0.468
#> GSM872261     6  0.7048     0.5119 0.128 0.212 0.000 0.032 0.096 0.532
#> GSM872262     1  0.6113     0.0835 0.504 0.000 0.088 0.348 0.000 0.060
#> GSM872263     3  0.3487     0.8027 0.000 0.000 0.788 0.000 0.044 0.168
#> GSM872264     4  0.3724     0.6806 0.000 0.004 0.032 0.816 0.108 0.040
#> GSM872265     4  0.4843     0.6856 0.072 0.016 0.028 0.776 0.056 0.052
#> GSM872266     5  0.1657     0.7516 0.000 0.016 0.000 0.056 0.928 0.000
#> GSM872267     5  0.4702     0.6744 0.000 0.164 0.000 0.080 0.724 0.032
#> GSM872268     3  0.1794     0.8353 0.024 0.000 0.932 0.016 0.000 0.028
#> GSM872269     6  0.6219     0.3432 0.028 0.340 0.000 0.004 0.140 0.488
#> GSM872270     3  0.2036     0.8364 0.000 0.000 0.916 0.048 0.008 0.028
#> GSM872271     4  0.3840     0.6514 0.000 0.136 0.000 0.788 0.064 0.012
#> GSM872272     4  0.3897     0.6271 0.000 0.048 0.000 0.772 0.168 0.012
#> GSM872273     1  0.3668     0.5647 0.824 0.000 0.020 0.108 0.024 0.024
#> GSM872274     2  0.0146     0.9504 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM872275     3  0.5973     0.6646 0.040 0.036 0.696 0.120 0.052 0.056
#> GSM872276     1  0.5453     0.2258 0.544 0.000 0.008 0.340 0.000 0.108
#> GSM872277     1  0.5877     0.4190 0.640 0.000 0.012 0.192 0.084 0.072
#> GSM872278     4  0.5511     0.5570 0.020 0.012 0.188 0.652 0.000 0.128
#> GSM872279     1  0.3023     0.4596 0.784 0.000 0.000 0.004 0.000 0.212
#> GSM872280     1  0.7217     0.0346 0.356 0.000 0.284 0.088 0.000 0.272
#> GSM872281     4  0.5426     0.6102 0.112 0.000 0.180 0.668 0.008 0.032
#> GSM872282     3  0.3622     0.8144 0.000 0.000 0.792 0.024 0.020 0.164
#> GSM872283     4  0.4629     0.6429 0.056 0.004 0.004 0.764 0.104 0.068
#> GSM872284     4  0.5564     0.6475 0.132 0.000 0.116 0.684 0.052 0.016
#> GSM872285     3  0.2886     0.8072 0.060 0.000 0.876 0.028 0.004 0.032
#> GSM872286     5  0.3278     0.6884 0.152 0.000 0.000 0.000 0.808 0.040
#> GSM872287     3  0.2339     0.8297 0.028 0.000 0.908 0.024 0.004 0.036
#> GSM872288     5  0.4734     0.7109 0.056 0.000 0.024 0.056 0.764 0.100
#> GSM872289     3  0.3823     0.7907 0.000 0.000 0.764 0.004 0.048 0.184
#> GSM872290     1  0.4356     0.0773 0.548 0.000 0.000 0.016 0.004 0.432
#> GSM872291     6  0.5576     0.0791 0.376 0.000 0.000 0.144 0.000 0.480
#> GSM872292     2  0.0405     0.9505 0.000 0.988 0.000 0.004 0.000 0.008
#> GSM872293     1  0.2081     0.5689 0.916 0.000 0.000 0.012 0.036 0.036
#> GSM872294     2  0.0858     0.9417 0.000 0.968 0.000 0.028 0.004 0.000
#> GSM872295     2  0.0622     0.9468 0.000 0.980 0.000 0.000 0.012 0.008
#> GSM872296     2  0.1524     0.9141 0.000 0.932 0.000 0.060 0.000 0.008
#> GSM872297     1  0.4167     0.5376 0.784 0.000 0.000 0.080 0.096 0.040
#> GSM872298     4  0.6786     0.2162 0.252 0.000 0.076 0.476 0.000 0.196
#> GSM872299     1  0.4072     0.0312 0.544 0.000 0.000 0.008 0.000 0.448
#> GSM872300     1  0.3524     0.5582 0.832 0.000 0.040 0.076 0.000 0.052

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

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>         n time(p) individual(p) k
#> SD:NMF 53   0.677      6.64e-03 2
#> SD:NMF 54   0.341      3.30e-02 3
#> SD:NMF 46   0.598      2.06e-03 4
#> SD:NMF 51   0.290      3.27e-04 5
#> SD:NMF 42   0.183      4.56e-07 6

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 29485 rows and 57 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.425           0.669       0.853         0.3783 0.683   0.683
#> 3 3 0.654           0.711       0.881         0.5057 0.704   0.576
#> 4 4 0.477           0.496       0.741         0.1738 0.852   0.672
#> 5 5 0.642           0.669       0.808         0.1254 0.763   0.414
#> 6 6 0.656           0.640       0.781         0.0568 0.929   0.711

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
#> GSM872244     1  0.9580     0.5342 0.620 0.380
#> GSM872245     1  0.0000     0.8045 1.000 0.000
#> GSM872246     1  0.9248     0.5837 0.660 0.340
#> GSM872247     1  0.9580     0.5342 0.620 0.380
#> GSM872248     2  0.0000     0.7952 0.000 1.000
#> GSM872249     1  0.9580     0.5342 0.620 0.380
#> GSM872250     1  0.0000     0.8045 1.000 0.000
#> GSM872251     1  0.9580     0.5342 0.620 0.380
#> GSM872252     1  0.0000     0.8045 1.000 0.000
#> GSM872253     1  0.1184     0.7989 0.984 0.016
#> GSM872254     2  0.9358     0.4735 0.352 0.648
#> GSM872255     1  0.0000     0.8045 1.000 0.000
#> GSM872256     1  0.0000     0.8045 1.000 0.000
#> GSM872257     2  0.0000     0.7952 0.000 1.000
#> GSM872258     1  0.7528     0.6964 0.784 0.216
#> GSM872259     1  0.0000     0.8045 1.000 0.000
#> GSM872260     1  0.0000     0.8045 1.000 0.000
#> GSM872261     1  0.9491     0.3790 0.632 0.368
#> GSM872262     1  0.0000     0.8045 1.000 0.000
#> GSM872263     1  0.9580     0.5342 0.620 0.380
#> GSM872264     1  0.8861     0.6132 0.696 0.304
#> GSM872265     1  0.8861     0.6132 0.696 0.304
#> GSM872266     1  0.9661     0.3414 0.608 0.392
#> GSM872267     2  0.0000     0.7952 0.000 1.000
#> GSM872268     1  0.9580     0.5342 0.620 0.380
#> GSM872269     2  0.9323     0.4799 0.348 0.652
#> GSM872270     1  0.9580     0.5342 0.620 0.380
#> GSM872271     2  0.9970    -0.0888 0.468 0.532
#> GSM872272     2  0.9970    -0.0888 0.468 0.532
#> GSM872273     1  0.0000     0.8045 1.000 0.000
#> GSM872274     2  0.0000     0.7952 0.000 1.000
#> GSM872275     1  0.3114     0.7670 0.944 0.056
#> GSM872276     1  0.0000     0.8045 1.000 0.000
#> GSM872277     1  0.0000     0.8045 1.000 0.000
#> GSM872278     1  0.0376     0.8035 0.996 0.004
#> GSM872279     1  0.0000     0.8045 1.000 0.000
#> GSM872280     1  0.0000     0.8045 1.000 0.000
#> GSM872281     1  0.0000     0.8045 1.000 0.000
#> GSM872282     1  0.9580     0.5342 0.620 0.380
#> GSM872283     1  0.8861     0.6132 0.696 0.304
#> GSM872284     1  0.7139     0.7091 0.804 0.196
#> GSM872285     1  0.7602     0.6949 0.780 0.220
#> GSM872286     1  0.0000     0.8045 1.000 0.000
#> GSM872287     1  0.9580     0.5342 0.620 0.380
#> GSM872288     1  0.0000     0.8045 1.000 0.000
#> GSM872289     1  0.7602     0.6933 0.780 0.220
#> GSM872290     1  0.0000     0.8045 1.000 0.000
#> GSM872291     1  0.0000     0.8045 1.000 0.000
#> GSM872292     2  0.0000     0.7952 0.000 1.000
#> GSM872293     1  0.0000     0.8045 1.000 0.000
#> GSM872294     1  0.9710     0.1616 0.600 0.400
#> GSM872295     2  0.0000     0.7952 0.000 1.000
#> GSM872296     2  0.0000     0.7952 0.000 1.000
#> GSM872297     1  0.0000     0.8045 1.000 0.000
#> GSM872298     1  0.0376     0.8035 0.996 0.004
#> GSM872299     1  0.0000     0.8045 1.000 0.000
#> GSM872300     1  0.0000     0.8045 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
#> GSM872244     3  0.0000      0.732 0.000 0.000 1.000
#> GSM872245     1  0.0000      0.875 1.000 0.000 0.000
#> GSM872246     3  0.5678      0.527 0.316 0.000 0.684
#> GSM872247     3  0.0000      0.732 0.000 0.000 1.000
#> GSM872248     2  0.0000      0.880 0.000 1.000 0.000
#> GSM872249     3  0.0000      0.732 0.000 0.000 1.000
#> GSM872250     1  0.0000      0.875 1.000 0.000 0.000
#> GSM872251     3  0.0000      0.732 0.000 0.000 1.000
#> GSM872252     1  0.0000      0.875 1.000 0.000 0.000
#> GSM872253     1  0.2384      0.855 0.936 0.008 0.056
#> GSM872254     2  0.5905      0.523 0.352 0.648 0.000
#> GSM872255     1  0.0592      0.875 0.988 0.000 0.012
#> GSM872256     1  0.0592      0.875 0.988 0.000 0.012
#> GSM872257     2  0.0000      0.880 0.000 1.000 0.000
#> GSM872258     3  0.6244      0.303 0.440 0.000 0.560
#> GSM872259     1  0.0000      0.875 1.000 0.000 0.000
#> GSM872260     1  0.0592      0.875 0.988 0.000 0.012
#> GSM872261     1  0.8907      0.337 0.572 0.228 0.200
#> GSM872262     1  0.1529      0.868 0.960 0.000 0.040
#> GSM872263     3  0.0000      0.732 0.000 0.000 1.000
#> GSM872264     1  0.6079      0.314 0.612 0.000 0.388
#> GSM872265     1  0.6079      0.314 0.612 0.000 0.388
#> GSM872266     1  0.9119      0.279 0.548 0.228 0.224
#> GSM872267     2  0.0000      0.880 0.000 1.000 0.000
#> GSM872268     3  0.0000      0.732 0.000 0.000 1.000
#> GSM872269     2  0.5882      0.531 0.348 0.652 0.000
#> GSM872270     3  0.0000      0.732 0.000 0.000 1.000
#> GSM872271     3  0.9757      0.107 0.384 0.228 0.388
#> GSM872272     3  0.9757      0.107 0.384 0.228 0.388
#> GSM872273     1  0.0000      0.875 1.000 0.000 0.000
#> GSM872274     2  0.0000      0.880 0.000 1.000 0.000
#> GSM872275     1  0.3692      0.829 0.896 0.048 0.056
#> GSM872276     1  0.1529      0.868 0.960 0.000 0.040
#> GSM872277     1  0.0000      0.875 1.000 0.000 0.000
#> GSM872278     1  0.1643      0.866 0.956 0.000 0.044
#> GSM872279     1  0.0000      0.875 1.000 0.000 0.000
#> GSM872280     1  0.1529      0.868 0.960 0.000 0.040
#> GSM872281     1  0.1529      0.868 0.960 0.000 0.040
#> GSM872282     3  0.0000      0.732 0.000 0.000 1.000
#> GSM872283     1  0.6079      0.314 0.612 0.000 0.388
#> GSM872284     1  0.5397      0.553 0.720 0.000 0.280
#> GSM872285     3  0.6079      0.414 0.388 0.000 0.612
#> GSM872286     1  0.0000      0.875 1.000 0.000 0.000
#> GSM872287     3  0.0000      0.732 0.000 0.000 1.000
#> GSM872288     1  0.0000      0.875 1.000 0.000 0.000
#> GSM872289     3  0.6225      0.324 0.432 0.000 0.568
#> GSM872290     1  0.0000      0.875 1.000 0.000 0.000
#> GSM872291     1  0.1529      0.868 0.960 0.000 0.040
#> GSM872292     2  0.0000      0.880 0.000 1.000 0.000
#> GSM872293     1  0.0000      0.875 1.000 0.000 0.000
#> GSM872294     1  0.6513      0.217 0.592 0.400 0.008
#> GSM872295     2  0.0000      0.880 0.000 1.000 0.000
#> GSM872296     2  0.0000      0.880 0.000 1.000 0.000
#> GSM872297     1  0.0000      0.875 1.000 0.000 0.000
#> GSM872298     1  0.1643      0.866 0.956 0.000 0.044
#> GSM872299     1  0.0000      0.875 1.000 0.000 0.000
#> GSM872300     1  0.1529      0.868 0.960 0.000 0.040

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM872244     3   0.000     0.5840 0.000 0.000 1.000 0.000
#> GSM872245     1   0.441     0.4180 0.700 0.000 0.000 0.300
#> GSM872246     3   0.534     0.4246 0.300 0.000 0.668 0.032
#> GSM872247     3   0.000     0.5840 0.000 0.000 1.000 0.000
#> GSM872248     2   0.483     0.7498 0.000 0.608 0.000 0.392
#> GSM872249     3   0.000     0.5840 0.000 0.000 1.000 0.000
#> GSM872250     1   0.438     0.4236 0.704 0.000 0.000 0.296
#> GSM872251     3   0.000     0.5840 0.000 0.000 1.000 0.000
#> GSM872252     1   0.307     0.6004 0.848 0.000 0.000 0.152
#> GSM872253     1   0.526     0.6690 0.684 0.004 0.024 0.288
#> GSM872254     4   0.567    -0.2198 0.056 0.276 0.000 0.668
#> GSM872255     1   0.436     0.6905 0.744 0.000 0.008 0.248
#> GSM872256     1   0.292     0.6924 0.876 0.000 0.008 0.116
#> GSM872257     2   0.483     0.7498 0.000 0.608 0.000 0.392
#> GSM872258     3   0.610     0.2429 0.420 0.000 0.532 0.048
#> GSM872259     1   0.000     0.6742 1.000 0.000 0.000 0.000
#> GSM872260     1   0.436     0.6905 0.744 0.000 0.008 0.248
#> GSM872261     4   0.966     0.2526 0.200 0.224 0.188 0.388
#> GSM872262     1   0.459     0.6853 0.712 0.000 0.008 0.280
#> GSM872263     3   0.000     0.5840 0.000 0.000 1.000 0.000
#> GSM872264     3   0.784    -0.0122 0.364 0.000 0.372 0.264
#> GSM872265     3   0.784    -0.0122 0.364 0.000 0.372 0.264
#> GSM872266     4   0.964     0.2339 0.176 0.224 0.212 0.388
#> GSM872267     2   0.483     0.7498 0.000 0.608 0.000 0.392
#> GSM872268     3   0.000     0.5840 0.000 0.000 1.000 0.000
#> GSM872269     4   0.520    -0.2564 0.032 0.276 0.000 0.692
#> GSM872270     3   0.000     0.5840 0.000 0.000 1.000 0.000
#> GSM872271     3   0.957    -0.0770 0.136 0.224 0.372 0.268
#> GSM872272     3   0.957    -0.0770 0.136 0.224 0.372 0.268
#> GSM872273     1   0.000     0.6742 1.000 0.000 0.000 0.000
#> GSM872274     2   0.000     0.6628 0.000 1.000 0.000 0.000
#> GSM872275     1   0.624     0.6265 0.648 0.044 0.024 0.284
#> GSM872276     1   0.459     0.6853 0.712 0.000 0.008 0.280
#> GSM872277     1   0.000     0.6742 1.000 0.000 0.000 0.000
#> GSM872278     1   0.474     0.6840 0.704 0.000 0.012 0.284
#> GSM872279     1   0.307     0.6004 0.848 0.000 0.000 0.152
#> GSM872280     1   0.462     0.6855 0.708 0.000 0.008 0.284
#> GSM872281     1   0.459     0.6853 0.712 0.000 0.008 0.280
#> GSM872282     3   0.000     0.5840 0.000 0.000 1.000 0.000
#> GSM872283     3   0.784    -0.0122 0.364 0.000 0.372 0.264
#> GSM872284     1   0.764     0.2862 0.468 0.000 0.256 0.276
#> GSM872285     3   0.623     0.3660 0.348 0.000 0.584 0.068
#> GSM872286     1   0.438     0.4236 0.704 0.000 0.000 0.296
#> GSM872287     3   0.000     0.5840 0.000 0.000 1.000 0.000
#> GSM872288     1   0.438     0.4236 0.704 0.000 0.000 0.296
#> GSM872289     3   0.596     0.2538 0.420 0.000 0.540 0.040
#> GSM872290     1   0.307     0.6004 0.848 0.000 0.000 0.152
#> GSM872291     1   0.462     0.6855 0.708 0.000 0.008 0.284
#> GSM872292     2   0.000     0.6628 0.000 1.000 0.000 0.000
#> GSM872293     1   0.000     0.6742 1.000 0.000 0.000 0.000
#> GSM872294     4   0.674     0.3143 0.096 0.392 0.000 0.512
#> GSM872295     2   0.476     0.7418 0.000 0.628 0.000 0.372
#> GSM872296     2   0.000     0.6628 0.000 1.000 0.000 0.000
#> GSM872297     1   0.000     0.6742 1.000 0.000 0.000 0.000
#> GSM872298     1   0.474     0.6840 0.704 0.000 0.012 0.284
#> GSM872299     1   0.307     0.6004 0.848 0.000 0.000 0.152
#> GSM872300     1   0.459     0.6853 0.712 0.000 0.008 0.280

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM872244     3   0.000      0.818 0.000 0.000 1.000 0.000 0.000
#> GSM872245     1   0.265      0.762 0.880 0.000 0.000 0.024 0.096
#> GSM872246     3   0.395      0.490 0.000 0.000 0.668 0.332 0.000
#> GSM872247     3   0.000      0.818 0.000 0.000 1.000 0.000 0.000
#> GSM872248     5   0.458      0.760 0.020 0.352 0.000 0.000 0.628
#> GSM872249     3   0.000      0.818 0.000 0.000 1.000 0.000 0.000
#> GSM872250     1   0.256      0.766 0.884 0.000 0.000 0.020 0.096
#> GSM872251     3   0.000      0.818 0.000 0.000 1.000 0.000 0.000
#> GSM872252     1   0.173      0.843 0.920 0.000 0.000 0.080 0.000
#> GSM872253     4   0.161      0.741 0.040 0.000 0.012 0.944 0.004
#> GSM872254     5   0.384      0.486 0.256 0.004 0.000 0.004 0.736
#> GSM872255     4   0.297      0.648 0.184 0.000 0.000 0.816 0.000
#> GSM872256     1   0.442      0.611 0.632 0.000 0.000 0.356 0.012
#> GSM872257     5   0.458      0.760 0.020 0.352 0.000 0.000 0.628
#> GSM872258     3   0.429      0.282 0.000 0.000 0.532 0.468 0.000
#> GSM872259     1   0.390      0.823 0.768 0.000 0.000 0.204 0.028
#> GSM872260     4   0.297      0.648 0.184 0.000 0.000 0.816 0.000
#> GSM872261     4   0.889      0.241 0.108 0.204 0.152 0.444 0.092
#> GSM872262     4   0.112      0.742 0.044 0.000 0.000 0.956 0.000
#> GSM872263     3   0.000      0.818 0.000 0.000 1.000 0.000 0.000
#> GSM872264     4   0.408      0.488 0.004 0.000 0.328 0.668 0.000
#> GSM872265     4   0.408      0.488 0.004 0.000 0.328 0.668 0.000
#> GSM872266     4   0.900      0.227 0.104 0.204 0.176 0.424 0.092
#> GSM872267     5   0.458      0.760 0.020 0.352 0.000 0.000 0.628
#> GSM872268     3   0.000      0.818 0.000 0.000 1.000 0.000 0.000
#> GSM872269     5   0.120      0.532 0.032 0.004 0.000 0.004 0.960
#> GSM872270     3   0.000      0.818 0.000 0.000 1.000 0.000 0.000
#> GSM872271     4   0.715      0.301 0.004 0.204 0.328 0.444 0.020
#> GSM872272     4   0.715      0.301 0.004 0.204 0.328 0.444 0.020
#> GSM872273     1   0.390      0.823 0.768 0.000 0.000 0.204 0.028
#> GSM872274     2   0.000      0.688 0.000 1.000 0.000 0.000 0.000
#> GSM872275     4   0.274      0.723 0.040 0.024 0.012 0.904 0.020
#> GSM872276     4   0.112      0.742 0.044 0.000 0.000 0.956 0.000
#> GSM872277     1   0.390      0.823 0.768 0.000 0.000 0.204 0.028
#> GSM872278     4   0.136      0.743 0.048 0.000 0.004 0.948 0.000
#> GSM872279     1   0.173      0.843 0.920 0.000 0.000 0.080 0.000
#> GSM872280     4   0.120      0.742 0.048 0.000 0.000 0.952 0.000
#> GSM872281     4   0.112      0.742 0.044 0.000 0.000 0.956 0.000
#> GSM872282     3   0.000      0.818 0.000 0.000 1.000 0.000 0.000
#> GSM872283     4   0.408      0.488 0.004 0.000 0.328 0.668 0.000
#> GSM872284     4   0.337      0.598 0.004 0.000 0.212 0.784 0.000
#> GSM872285     3   0.436      0.383 0.004 0.000 0.584 0.412 0.000
#> GSM872286     1   0.256      0.766 0.884 0.000 0.000 0.020 0.096
#> GSM872287     3   0.000      0.818 0.000 0.000 1.000 0.000 0.000
#> GSM872288     1   0.256      0.766 0.884 0.000 0.000 0.020 0.096
#> GSM872289     3   0.429      0.303 0.000 0.000 0.540 0.460 0.000
#> GSM872290     1   0.173      0.843 0.920 0.000 0.000 0.080 0.000
#> GSM872291     4   0.161      0.730 0.072 0.000 0.000 0.928 0.000
#> GSM872292     2   0.000      0.688 0.000 1.000 0.000 0.000 0.000
#> GSM872293     1   0.390      0.823 0.768 0.000 0.000 0.204 0.028
#> GSM872294     2   0.743      0.244 0.032 0.372 0.000 0.264 0.332
#> GSM872295     5   0.418      0.746 0.000 0.352 0.000 0.004 0.644
#> GSM872296     2   0.000      0.688 0.000 1.000 0.000 0.000 0.000
#> GSM872297     1   0.390      0.823 0.768 0.000 0.000 0.204 0.028
#> GSM872298     4   0.136      0.743 0.048 0.000 0.004 0.948 0.000
#> GSM872299     1   0.173      0.843 0.920 0.000 0.000 0.080 0.000
#> GSM872300     4   0.112      0.742 0.044 0.000 0.000 0.956 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
#> GSM872244     3  0.0000      0.784 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872245     1  0.2933      0.723 0.796 0.200 0.000 0.004 0.000 0.000
#> GSM872246     3  0.3547      0.429 0.000 0.000 0.668 0.000 0.000 0.332
#> GSM872247     3  0.0000      0.784 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872248     5  0.0000      0.739 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM872249     3  0.0000      0.784 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872250     1  0.2933      0.727 0.796 0.200 0.000 0.000 0.000 0.004
#> GSM872251     3  0.0000      0.784 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872252     1  0.0146      0.818 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM872253     6  0.3163      0.674 0.008 0.000 0.012 0.172 0.000 0.808
#> GSM872254     5  0.7526      0.373 0.156 0.200 0.000 0.252 0.388 0.004
#> GSM872255     6  0.2730      0.664 0.192 0.000 0.000 0.000 0.000 0.808
#> GSM872256     1  0.4015      0.558 0.656 0.008 0.000 0.008 0.000 0.328
#> GSM872257     5  0.0000      0.739 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM872258     3  0.3857      0.298 0.000 0.000 0.532 0.000 0.000 0.468
#> GSM872259     1  0.3142      0.803 0.832 0.024 0.000 0.012 0.000 0.132
#> GSM872260     6  0.2730      0.664 0.192 0.000 0.000 0.000 0.000 0.808
#> GSM872261     4  0.7321      0.425 0.016 0.344 0.136 0.396 0.000 0.108
#> GSM872262     6  0.1010      0.819 0.004 0.000 0.000 0.036 0.000 0.960
#> GSM872263     3  0.0000      0.784 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872264     4  0.6116      0.404 0.000 0.000 0.312 0.368 0.000 0.320
#> GSM872265     4  0.6116      0.404 0.000 0.000 0.312 0.368 0.000 0.320
#> GSM872266     4  0.7294      0.438 0.016 0.340 0.160 0.396 0.000 0.088
#> GSM872267     5  0.0000      0.739 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM872268     3  0.0000      0.784 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872269     4  0.4531     -0.575 0.008 0.012 0.000 0.584 0.388 0.008
#> GSM872270     3  0.0000      0.784 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872271     4  0.7155      0.506 0.000 0.184 0.312 0.396 0.000 0.108
#> GSM872272     4  0.7155      0.506 0.000 0.184 0.312 0.396 0.000 0.108
#> GSM872273     1  0.3142      0.803 0.832 0.024 0.000 0.012 0.000 0.132
#> GSM872274     2  0.2996      1.000 0.000 0.772 0.000 0.000 0.228 0.000
#> GSM872275     6  0.3698      0.590 0.004 0.004 0.012 0.240 0.000 0.740
#> GSM872276     6  0.1010      0.819 0.004 0.000 0.000 0.036 0.000 0.960
#> GSM872277     1  0.3142      0.803 0.832 0.024 0.000 0.012 0.000 0.132
#> GSM872278     6  0.0922      0.815 0.004 0.000 0.004 0.024 0.000 0.968
#> GSM872279     1  0.0146      0.818 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM872280     6  0.0146      0.816 0.004 0.000 0.000 0.000 0.000 0.996
#> GSM872281     6  0.1010      0.819 0.004 0.000 0.000 0.036 0.000 0.960
#> GSM872282     3  0.0000      0.784 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872283     4  0.6116      0.404 0.000 0.000 0.312 0.368 0.000 0.320
#> GSM872284     6  0.5852     -0.260 0.000 0.000 0.196 0.364 0.000 0.440
#> GSM872285     3  0.3789      0.373 0.000 0.000 0.584 0.000 0.000 0.416
#> GSM872286     1  0.2933      0.727 0.796 0.200 0.000 0.000 0.000 0.004
#> GSM872287     3  0.0000      0.784 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872288     1  0.2933      0.727 0.796 0.200 0.000 0.000 0.000 0.004
#> GSM872289     3  0.3851      0.316 0.000 0.000 0.540 0.000 0.000 0.460
#> GSM872290     1  0.0146      0.818 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM872291     6  0.0865      0.806 0.036 0.000 0.000 0.000 0.000 0.964
#> GSM872292     2  0.2996      1.000 0.000 0.772 0.000 0.000 0.228 0.000
#> GSM872293     1  0.3142      0.803 0.832 0.024 0.000 0.012 0.000 0.132
#> GSM872294     4  0.6121     -0.306 0.004 0.356 0.000 0.404 0.000 0.236
#> GSM872295     5  0.3429      0.621 0.004 0.000 0.000 0.252 0.740 0.004
#> GSM872296     2  0.2996      1.000 0.000 0.772 0.000 0.000 0.228 0.000
#> GSM872297     1  0.3142      0.803 0.832 0.024 0.000 0.012 0.000 0.132
#> GSM872298     6  0.0922      0.815 0.004 0.000 0.004 0.024 0.000 0.968
#> GSM872299     1  0.0146      0.818 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM872300     6  0.1010      0.819 0.004 0.000 0.000 0.036 0.000 0.960

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

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>            n time(p) individual(p) k
#> CV:hclust 50   0.913      0.062364 2
#> CV:hclust 46   0.866      0.001793 3
#> CV:hclust 38   0.909      0.000647 4
#> CV:hclust 44   0.845      0.000123 5
#> CV:hclust 44   0.569      0.000246 6

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 29485 rows and 57 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.210           0.637       0.787         0.4478 0.589   0.589
#> 3 3 0.840           0.876       0.943         0.4644 0.694   0.505
#> 4 4 0.633           0.423       0.673         0.1317 0.887   0.683
#> 5 5 0.690           0.655       0.782         0.0691 0.870   0.559
#> 6 6 0.700           0.537       0.725         0.0416 0.916   0.635

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
#> GSM872244     1  0.9580      0.326 0.620 0.380
#> GSM872245     2  0.9635      0.253 0.388 0.612
#> GSM872246     1  0.5629      0.691 0.868 0.132
#> GSM872247     1  0.5737      0.689 0.864 0.136
#> GSM872248     2  0.0000      0.870 0.000 1.000
#> GSM872249     1  0.5842      0.686 0.860 0.140
#> GSM872250     2  0.9087      0.278 0.324 0.676
#> GSM872251     1  0.5629      0.691 0.868 0.132
#> GSM872252     1  0.9710      0.407 0.600 0.400
#> GSM872253     1  0.7528      0.693 0.784 0.216
#> GSM872254     2  0.0672      0.870 0.008 0.992
#> GSM872255     1  0.5178      0.712 0.884 0.116
#> GSM872256     1  0.9710      0.407 0.600 0.400
#> GSM872257     2  0.0672      0.870 0.008 0.992
#> GSM872258     1  0.5629      0.691 0.868 0.132
#> GSM872259     1  0.9710      0.407 0.600 0.400
#> GSM872260     1  0.5178      0.712 0.884 0.116
#> GSM872261     2  0.8386      0.456 0.268 0.732
#> GSM872262     1  0.5178      0.712 0.884 0.116
#> GSM872263     1  0.5737      0.689 0.864 0.136
#> GSM872264     1  0.7883      0.655 0.764 0.236
#> GSM872265     1  0.9209      0.612 0.664 0.336
#> GSM872266     2  0.0000      0.870 0.000 1.000
#> GSM872267     2  0.0000      0.870 0.000 1.000
#> GSM872268     1  0.5629      0.691 0.868 0.132
#> GSM872269     2  0.3733      0.815 0.072 0.928
#> GSM872270     1  0.7376      0.622 0.792 0.208
#> GSM872271     2  0.4022      0.822 0.080 0.920
#> GSM872272     2  0.4022      0.822 0.080 0.920
#> GSM872273     1  0.7453      0.656 0.788 0.212
#> GSM872274     2  0.1414      0.866 0.020 0.980
#> GSM872275     1  0.6712      0.694 0.824 0.176
#> GSM872276     1  0.5178      0.712 0.884 0.116
#> GSM872277     1  0.7453      0.656 0.788 0.212
#> GSM872278     1  0.6623      0.696 0.828 0.172
#> GSM872279     1  0.9710      0.407 0.600 0.400
#> GSM872280     1  0.0000      0.696 1.000 0.000
#> GSM872281     1  0.2603      0.708 0.956 0.044
#> GSM872282     1  0.9580      0.326 0.620 0.380
#> GSM872283     1  0.7674      0.658 0.776 0.224
#> GSM872284     1  0.5059      0.713 0.888 0.112
#> GSM872285     1  0.4161      0.700 0.916 0.084
#> GSM872286     1  0.9963      0.228 0.536 0.464
#> GSM872287     1  0.5737      0.689 0.864 0.136
#> GSM872288     1  0.9775      0.398 0.588 0.412
#> GSM872289     1  0.5629      0.691 0.868 0.132
#> GSM872290     1  0.9710      0.407 0.600 0.400
#> GSM872291     1  0.5178      0.712 0.884 0.116
#> GSM872292     2  0.1414      0.866 0.020 0.980
#> GSM872293     1  0.9710      0.407 0.600 0.400
#> GSM872294     2  0.0000      0.870 0.000 1.000
#> GSM872295     2  0.1414      0.866 0.020 0.980
#> GSM872296     2  0.1414      0.866 0.020 0.980
#> GSM872297     1  0.9710      0.407 0.600 0.400
#> GSM872298     1  0.5059      0.713 0.888 0.112
#> GSM872299     1  1.0000      0.113 0.504 0.496
#> GSM872300     1  0.5178      0.712 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
#> GSM872244     3  0.0000      0.953 0.000 0.000 1.000
#> GSM872245     1  0.1289      0.897 0.968 0.032 0.000
#> GSM872246     3  0.0000      0.953 0.000 0.000 1.000
#> GSM872247     3  0.0000      0.953 0.000 0.000 1.000
#> GSM872248     2  0.0829      0.939 0.012 0.984 0.004
#> GSM872249     3  0.0000      0.953 0.000 0.000 1.000
#> GSM872250     1  0.5982      0.426 0.668 0.328 0.004
#> GSM872251     3  0.0000      0.953 0.000 0.000 1.000
#> GSM872252     1  0.0000      0.918 1.000 0.000 0.000
#> GSM872253     3  0.2711      0.887 0.088 0.000 0.912
#> GSM872254     2  0.1765      0.927 0.040 0.956 0.004
#> GSM872255     1  0.0592      0.913 0.988 0.000 0.012
#> GSM872256     1  0.0000      0.918 1.000 0.000 0.000
#> GSM872257     2  0.0237      0.939 0.000 0.996 0.004
#> GSM872258     3  0.0000      0.953 0.000 0.000 1.000
#> GSM872259     1  0.0000      0.918 1.000 0.000 0.000
#> GSM872260     1  0.0000      0.918 1.000 0.000 0.000
#> GSM872261     2  0.6209      0.465 0.368 0.628 0.004
#> GSM872262     1  0.1989      0.894 0.948 0.004 0.048
#> GSM872263     3  0.0000      0.953 0.000 0.000 1.000
#> GSM872264     3  0.5158      0.677 0.232 0.004 0.764
#> GSM872265     1  0.5956      0.557 0.672 0.004 0.324
#> GSM872266     2  0.0829      0.939 0.012 0.984 0.004
#> GSM872267     2  0.0592      0.939 0.012 0.988 0.000
#> GSM872268     3  0.0000      0.953 0.000 0.000 1.000
#> GSM872269     2  0.4172      0.824 0.156 0.840 0.004
#> GSM872270     3  0.0000      0.953 0.000 0.000 1.000
#> GSM872271     2  0.2903      0.902 0.028 0.924 0.048
#> GSM872272     2  0.2903      0.902 0.028 0.924 0.048
#> GSM872273     1  0.0000      0.918 1.000 0.000 0.000
#> GSM872274     2  0.0237      0.939 0.000 0.996 0.004
#> GSM872275     3  0.1411      0.931 0.036 0.000 0.964
#> GSM872276     1  0.1989      0.894 0.948 0.004 0.048
#> GSM872277     1  0.0000      0.918 1.000 0.000 0.000
#> GSM872278     3  0.1647      0.929 0.036 0.004 0.960
#> GSM872279     1  0.0000      0.918 1.000 0.000 0.000
#> GSM872280     3  0.5553      0.627 0.272 0.004 0.724
#> GSM872281     1  0.6126      0.500 0.644 0.004 0.352
#> GSM872282     3  0.0000      0.953 0.000 0.000 1.000
#> GSM872283     1  0.4629      0.758 0.808 0.004 0.188
#> GSM872284     1  0.5982      0.551 0.668 0.004 0.328
#> GSM872285     3  0.0237      0.952 0.004 0.000 0.996
#> GSM872286     1  0.0000      0.918 1.000 0.000 0.000
#> GSM872287     3  0.0000      0.953 0.000 0.000 1.000
#> GSM872288     1  0.0000      0.918 1.000 0.000 0.000
#> GSM872289     3  0.0424      0.949 0.008 0.000 0.992
#> GSM872290     1  0.0000      0.918 1.000 0.000 0.000
#> GSM872291     1  0.0000      0.918 1.000 0.000 0.000
#> GSM872292     2  0.0237      0.939 0.000 0.996 0.004
#> GSM872293     1  0.0000      0.918 1.000 0.000 0.000
#> GSM872294     2  0.0000      0.939 0.000 1.000 0.000
#> GSM872295     2  0.0237      0.939 0.000 0.996 0.004
#> GSM872296     2  0.0000      0.939 0.000 1.000 0.000
#> GSM872297     1  0.0000      0.918 1.000 0.000 0.000
#> GSM872298     1  0.2096      0.891 0.944 0.004 0.052
#> GSM872299     1  0.0000      0.918 1.000 0.000 0.000
#> GSM872300     1  0.0829      0.913 0.984 0.004 0.012

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM872244     3  0.0592    0.86480 0.000 0.000 0.984 0.016
#> GSM872245     1  0.5685    0.14299 0.516 0.460 0.000 0.024
#> GSM872246     3  0.0188    0.86912 0.000 0.000 0.996 0.004
#> GSM872247     3  0.0469    0.86931 0.000 0.000 0.988 0.012
#> GSM872248     2  0.2799    0.64536 0.008 0.884 0.000 0.108
#> GSM872249     3  0.0592    0.86855 0.000 0.000 0.984 0.016
#> GSM872250     1  0.6147    0.11113 0.488 0.464 0.000 0.048
#> GSM872251     3  0.0336    0.86950 0.000 0.000 0.992 0.008
#> GSM872252     1  0.6316    0.32957 0.612 0.300 0.000 0.088
#> GSM872253     3  0.6773    0.37513 0.012 0.080 0.576 0.332
#> GSM872254     2  0.4175    0.41091 0.212 0.776 0.000 0.012
#> GSM872255     1  0.4888   -0.10421 0.588 0.000 0.000 0.412
#> GSM872256     1  0.2345    0.37403 0.900 0.000 0.000 0.100
#> GSM872257     2  0.4933    0.68919 0.000 0.568 0.000 0.432
#> GSM872258     3  0.0000    0.86876 0.000 0.000 1.000 0.000
#> GSM872259     1  0.0000    0.44183 1.000 0.000 0.000 0.000
#> GSM872260     1  0.4697   -0.00531 0.644 0.000 0.000 0.356
#> GSM872261     2  0.7216    0.03290 0.284 0.536 0.000 0.180
#> GSM872262     1  0.5277   -0.23560 0.532 0.000 0.008 0.460
#> GSM872263     3  0.0188    0.86873 0.000 0.000 0.996 0.004
#> GSM872264     4  0.7816    0.33542 0.176 0.012 0.352 0.460
#> GSM872265     4  0.7819    0.48076 0.340 0.012 0.180 0.468
#> GSM872266     2  0.2973    0.59121 0.020 0.884 0.000 0.096
#> GSM872267     2  0.3681    0.66089 0.008 0.816 0.000 0.176
#> GSM872268     3  0.0469    0.86931 0.000 0.000 0.988 0.012
#> GSM872269     2  0.4327    0.39988 0.216 0.768 0.000 0.016
#> GSM872270     3  0.0469    0.86895 0.000 0.000 0.988 0.012
#> GSM872271     4  0.7272   -0.27598 0.028 0.444 0.072 0.456
#> GSM872272     4  0.7272   -0.27598 0.028 0.444 0.072 0.456
#> GSM872273     1  0.4222    0.17965 0.728 0.000 0.000 0.272
#> GSM872274     2  0.4977    0.68508 0.000 0.540 0.000 0.460
#> GSM872275     3  0.4800    0.47721 0.004 0.000 0.656 0.340
#> GSM872276     1  0.5277   -0.23560 0.532 0.000 0.008 0.460
#> GSM872277     1  0.4222    0.17965 0.728 0.000 0.000 0.272
#> GSM872278     3  0.5097    0.26538 0.004 0.000 0.568 0.428
#> GSM872279     1  0.1004    0.43890 0.972 0.024 0.000 0.004
#> GSM872280     4  0.7384    0.37554 0.352 0.000 0.172 0.476
#> GSM872281     4  0.6882    0.44021 0.392 0.000 0.108 0.500
#> GSM872282     3  0.0707    0.86279 0.000 0.000 0.980 0.020
#> GSM872283     4  0.7412    0.46529 0.360 0.028 0.092 0.520
#> GSM872284     4  0.7252    0.45921 0.372 0.012 0.108 0.508
#> GSM872285     3  0.4382    0.54171 0.000 0.000 0.704 0.296
#> GSM872286     1  0.5497    0.15114 0.524 0.460 0.000 0.016
#> GSM872287     3  0.0469    0.86931 0.000 0.000 0.988 0.012
#> GSM872288     1  0.6145    0.12061 0.492 0.460 0.000 0.048
#> GSM872289     3  0.1118    0.84500 0.000 0.036 0.964 0.000
#> GSM872290     1  0.0000    0.44183 1.000 0.000 0.000 0.000
#> GSM872291     1  0.4972   -0.21160 0.544 0.000 0.000 0.456
#> GSM872292     2  0.4977    0.68508 0.000 0.540 0.000 0.460
#> GSM872293     1  0.0000    0.44183 1.000 0.000 0.000 0.000
#> GSM872294     2  0.4977    0.68508 0.000 0.540 0.000 0.460
#> GSM872295     2  0.4948    0.68909 0.000 0.560 0.000 0.440
#> GSM872296     2  0.4977    0.68508 0.000 0.540 0.000 0.460
#> GSM872297     1  0.0188    0.44030 0.996 0.000 0.000 0.004
#> GSM872298     4  0.5407    0.22101 0.484 0.000 0.012 0.504
#> GSM872299     1  0.5097    0.19246 0.568 0.428 0.000 0.004
#> GSM872300     1  0.5277   -0.23560 0.532 0.000 0.008 0.460

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM872244     3  0.1525      0.911 0.004 0.000 0.948 0.036 0.012
#> GSM872245     5  0.3819      0.644 0.228 0.000 0.000 0.016 0.756
#> GSM872246     3  0.0671      0.925 0.000 0.000 0.980 0.016 0.004
#> GSM872247     3  0.0324      0.927 0.000 0.000 0.992 0.004 0.004
#> GSM872248     5  0.4957      0.431 0.000 0.332 0.000 0.044 0.624
#> GSM872249     3  0.0162      0.926 0.000 0.000 0.996 0.000 0.004
#> GSM872250     5  0.1894      0.744 0.072 0.000 0.000 0.008 0.920
#> GSM872251     3  0.0451      0.925 0.000 0.000 0.988 0.008 0.004
#> GSM872252     1  0.6643      0.175 0.404 0.000 0.000 0.224 0.372
#> GSM872253     4  0.5796      0.599 0.020 0.004 0.164 0.676 0.136
#> GSM872254     5  0.2828      0.716 0.004 0.104 0.000 0.020 0.872
#> GSM872255     1  0.4298      0.461 0.640 0.000 0.000 0.352 0.008
#> GSM872256     1  0.2172      0.646 0.908 0.000 0.000 0.016 0.076
#> GSM872257     2  0.1670      0.938 0.000 0.936 0.000 0.012 0.052
#> GSM872258     3  0.2052      0.875 0.004 0.000 0.912 0.080 0.004
#> GSM872259     1  0.2660      0.616 0.864 0.000 0.000 0.008 0.128
#> GSM872260     1  0.4183      0.484 0.668 0.000 0.000 0.324 0.008
#> GSM872261     5  0.5428      0.439 0.064 0.008 0.000 0.308 0.620
#> GSM872262     1  0.4440      0.177 0.528 0.000 0.004 0.468 0.000
#> GSM872263     3  0.1267      0.916 0.004 0.000 0.960 0.024 0.012
#> GSM872264     4  0.4949      0.702 0.096 0.020 0.072 0.780 0.032
#> GSM872265     4  0.4930      0.699 0.108 0.020 0.056 0.780 0.036
#> GSM872266     5  0.4269      0.652 0.000 0.116 0.000 0.108 0.776
#> GSM872267     5  0.5167      0.267 0.000 0.404 0.000 0.044 0.552
#> GSM872268     3  0.0324      0.927 0.000 0.000 0.992 0.004 0.004
#> GSM872269     5  0.2575      0.718 0.004 0.100 0.000 0.012 0.884
#> GSM872270     3  0.0162      0.927 0.000 0.000 0.996 0.004 0.000
#> GSM872271     4  0.5953      0.581 0.012 0.192 0.020 0.668 0.108
#> GSM872272     4  0.5953      0.581 0.012 0.192 0.020 0.668 0.108
#> GSM872273     1  0.2068      0.615 0.904 0.000 0.000 0.092 0.004
#> GSM872274     2  0.0000      0.969 0.000 1.000 0.000 0.000 0.000
#> GSM872275     4  0.4384      0.644 0.012 0.004 0.208 0.752 0.024
#> GSM872276     1  0.4437      0.188 0.532 0.000 0.004 0.464 0.000
#> GSM872277     1  0.2536      0.598 0.868 0.000 0.000 0.128 0.004
#> GSM872278     4  0.3730      0.677 0.016 0.004 0.156 0.812 0.012
#> GSM872279     1  0.3573      0.566 0.812 0.000 0.000 0.036 0.152
#> GSM872280     4  0.5394      0.222 0.328 0.000 0.056 0.608 0.008
#> GSM872281     4  0.4584      0.623 0.208 0.000 0.032 0.740 0.020
#> GSM872282     3  0.1605      0.908 0.004 0.000 0.944 0.040 0.012
#> GSM872283     4  0.4577      0.690 0.116 0.020 0.024 0.796 0.044
#> GSM872284     4  0.4723      0.630 0.204 0.000 0.032 0.736 0.028
#> GSM872285     3  0.4997      0.133 0.020 0.000 0.568 0.404 0.008
#> GSM872286     5  0.2286      0.733 0.108 0.000 0.000 0.004 0.888
#> GSM872287     3  0.0324      0.927 0.000 0.000 0.992 0.004 0.004
#> GSM872288     5  0.2077      0.743 0.084 0.000 0.000 0.008 0.908
#> GSM872289     3  0.2929      0.852 0.004 0.000 0.876 0.044 0.076
#> GSM872290     1  0.2825      0.612 0.860 0.000 0.000 0.016 0.124
#> GSM872291     1  0.4455      0.363 0.588 0.000 0.000 0.404 0.008
#> GSM872292     2  0.0000      0.969 0.000 1.000 0.000 0.000 0.000
#> GSM872293     1  0.2377      0.616 0.872 0.000 0.000 0.000 0.128
#> GSM872294     2  0.0579      0.959 0.000 0.984 0.000 0.008 0.008
#> GSM872295     2  0.1430      0.943 0.000 0.944 0.000 0.004 0.052
#> GSM872296     2  0.0000      0.969 0.000 1.000 0.000 0.000 0.000
#> GSM872297     1  0.2563      0.621 0.872 0.000 0.000 0.008 0.120
#> GSM872298     4  0.3883      0.501 0.244 0.000 0.004 0.744 0.008
#> GSM872299     5  0.4833      0.356 0.412 0.000 0.000 0.024 0.564
#> GSM872300     1  0.4440      0.177 0.528 0.000 0.004 0.468 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
#> GSM872244     3  0.3198    0.78979 0.012 0.000 0.816 0.004 0.008 0.160
#> GSM872245     5  0.4127    0.57156 0.284 0.000 0.000 0.000 0.680 0.036
#> GSM872246     3  0.0748    0.84861 0.000 0.000 0.976 0.016 0.004 0.004
#> GSM872247     3  0.0146    0.85143 0.000 0.000 0.996 0.000 0.004 0.000
#> GSM872248     5  0.4877    0.49967 0.000 0.192 0.000 0.000 0.660 0.148
#> GSM872249     3  0.0405    0.85035 0.000 0.000 0.988 0.000 0.004 0.008
#> GSM872250     5  0.1349    0.72201 0.056 0.000 0.000 0.000 0.940 0.004
#> GSM872251     3  0.1779    0.82843 0.000 0.000 0.920 0.016 0.000 0.064
#> GSM872252     6  0.6866    0.00109 0.248 0.000 0.000 0.052 0.312 0.388
#> GSM872253     6  0.6240    0.42554 0.000 0.000 0.100 0.208 0.112 0.580
#> GSM872254     5  0.2076    0.71500 0.012 0.016 0.000 0.000 0.912 0.060
#> GSM872255     4  0.6117    0.08770 0.372 0.000 0.000 0.392 0.004 0.232
#> GSM872256     1  0.2137    0.80192 0.912 0.000 0.000 0.048 0.012 0.028
#> GSM872257     2  0.3252    0.84758 0.000 0.824 0.000 0.000 0.068 0.108
#> GSM872258     3  0.3776    0.65508 0.000 0.000 0.760 0.052 0.000 0.188
#> GSM872259     1  0.0909    0.80759 0.968 0.000 0.000 0.000 0.020 0.012
#> GSM872260     1  0.6463   -0.16815 0.364 0.000 0.000 0.336 0.016 0.284
#> GSM872261     5  0.5334    0.13650 0.028 0.000 0.000 0.052 0.536 0.384
#> GSM872262     4  0.5374    0.34847 0.276 0.000 0.000 0.584 0.004 0.136
#> GSM872263     3  0.3020    0.79398 0.012 0.000 0.824 0.000 0.008 0.156
#> GSM872264     4  0.4924    0.10714 0.020 0.008 0.040 0.688 0.008 0.236
#> GSM872265     4  0.4936    0.11405 0.024 0.008 0.036 0.688 0.008 0.236
#> GSM872266     5  0.3084    0.66629 0.000 0.032 0.000 0.004 0.832 0.132
#> GSM872267     5  0.5167    0.41537 0.000 0.240 0.000 0.000 0.612 0.148
#> GSM872268     3  0.0146    0.85143 0.000 0.000 0.996 0.000 0.004 0.000
#> GSM872269     5  0.2558    0.71305 0.012 0.016 0.000 0.004 0.884 0.084
#> GSM872270     3  0.0777    0.84934 0.000 0.000 0.972 0.004 0.000 0.024
#> GSM872271     4  0.6624   -0.14479 0.000 0.084 0.028 0.460 0.052 0.376
#> GSM872272     4  0.6624   -0.14479 0.000 0.084 0.028 0.460 0.052 0.376
#> GSM872273     1  0.2378    0.72524 0.848 0.000 0.000 0.152 0.000 0.000
#> GSM872274     2  0.0000    0.93712 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM872275     6  0.5692    0.38059 0.000 0.000 0.112 0.412 0.012 0.464
#> GSM872276     4  0.5390    0.34705 0.280 0.000 0.000 0.580 0.004 0.136
#> GSM872277     1  0.2730    0.72138 0.836 0.000 0.000 0.152 0.000 0.012
#> GSM872278     6  0.5243    0.33048 0.000 0.000 0.080 0.452 0.004 0.464
#> GSM872279     1  0.3052    0.75965 0.848 0.000 0.000 0.004 0.068 0.080
#> GSM872280     4  0.6134    0.20250 0.124 0.000 0.056 0.580 0.004 0.236
#> GSM872281     4  0.1225    0.27532 0.036 0.000 0.012 0.952 0.000 0.000
#> GSM872282     3  0.3308    0.78700 0.012 0.000 0.812 0.008 0.008 0.160
#> GSM872283     4  0.4787    0.12520 0.028 0.004 0.024 0.696 0.012 0.236
#> GSM872284     4  0.2307    0.25205 0.032 0.000 0.016 0.904 0.000 0.048
#> GSM872285     3  0.5771   -0.11574 0.000 0.000 0.444 0.380 0.000 0.176
#> GSM872286     5  0.2312    0.71530 0.112 0.000 0.000 0.000 0.876 0.012
#> GSM872287     3  0.0146    0.85143 0.000 0.000 0.996 0.000 0.004 0.000
#> GSM872288     5  0.1753    0.71798 0.084 0.000 0.000 0.000 0.912 0.004
#> GSM872289     3  0.4066    0.73618 0.000 0.000 0.788 0.036 0.064 0.112
#> GSM872290     1  0.2547    0.78357 0.880 0.000 0.000 0.004 0.036 0.080
#> GSM872291     4  0.6228    0.17996 0.332 0.000 0.000 0.412 0.008 0.248
#> GSM872292     2  0.0000    0.93712 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM872293     1  0.0547    0.80949 0.980 0.000 0.000 0.000 0.020 0.000
#> GSM872294     2  0.1364    0.91913 0.000 0.944 0.000 0.004 0.004 0.048
#> GSM872295     2  0.2705    0.89257 0.000 0.872 0.000 0.004 0.072 0.052
#> GSM872296     2  0.0260    0.93642 0.000 0.992 0.000 0.000 0.000 0.008
#> GSM872297     1  0.1078    0.80809 0.964 0.000 0.000 0.008 0.016 0.012
#> GSM872298     4  0.4314    0.16332 0.044 0.000 0.004 0.704 0.004 0.244
#> GSM872299     5  0.5479    0.23805 0.416 0.000 0.000 0.004 0.472 0.108
#> GSM872300     4  0.5374    0.34847 0.276 0.000 0.000 0.584 0.004 0.136

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

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>            n time(p) individual(p) k
#> CV:kmeans 42   0.870      0.042355 2
#> CV:kmeans 55   0.460      0.011551 3
#> CV:kmeans 22   0.518      0.046063 4
#> CV:kmeans 44   0.272      0.000089 5
#> CV:kmeans 33   0.641      0.001118 6

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

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

collect_plots(res)

plot of chunk CV-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.535           0.829       0.905         0.5065 0.491   0.491
#> 3 3 0.846           0.872       0.948         0.3349 0.706   0.468
#> 4 4 0.853           0.905       0.942         0.1240 0.836   0.547
#> 5 5 0.780           0.630       0.816         0.0535 0.873   0.553
#> 6 6 0.785           0.656       0.823         0.0393 0.911   0.612

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
#> GSM872244     1  0.7528      0.773 0.784 0.216
#> GSM872245     2  0.0938      0.864 0.012 0.988
#> GSM872246     1  0.0938      0.909 0.988 0.012
#> GSM872247     1  0.0938      0.909 0.988 0.012
#> GSM872248     2  0.0000      0.866 0.000 1.000
#> GSM872249     1  0.7453      0.777 0.788 0.212
#> GSM872250     2  0.0376      0.866 0.004 0.996
#> GSM872251     1  0.0938      0.909 0.988 0.012
#> GSM872252     2  0.7528      0.805 0.216 0.784
#> GSM872253     1  0.0938      0.909 0.988 0.012
#> GSM872254     2  0.0376      0.866 0.004 0.996
#> GSM872255     1  0.0000      0.908 1.000 0.000
#> GSM872256     2  0.7528      0.805 0.216 0.784
#> GSM872257     2  0.0000      0.866 0.000 1.000
#> GSM872258     1  0.0672      0.909 0.992 0.008
#> GSM872259     2  0.7528      0.805 0.216 0.784
#> GSM872260     1  0.0000      0.908 1.000 0.000
#> GSM872261     2  0.0376      0.866 0.004 0.996
#> GSM872262     1  0.0000      0.908 1.000 0.000
#> GSM872263     1  0.1184      0.908 0.984 0.016
#> GSM872264     1  0.7453      0.775 0.788 0.212
#> GSM872265     1  0.9998      0.192 0.508 0.492
#> GSM872266     2  0.0000      0.866 0.000 1.000
#> GSM872267     2  0.0000      0.866 0.000 1.000
#> GSM872268     1  0.0938      0.909 0.988 0.012
#> GSM872269     2  0.0376      0.866 0.004 0.996
#> GSM872270     1  0.7528      0.773 0.784 0.216
#> GSM872271     2  0.0000      0.866 0.000 1.000
#> GSM872272     2  0.0000      0.866 0.000 1.000
#> GSM872273     2  0.9909      0.454 0.444 0.556
#> GSM872274     2  0.0000      0.866 0.000 1.000
#> GSM872275     1  0.7528      0.773 0.784 0.216
#> GSM872276     1  0.0000      0.908 1.000 0.000
#> GSM872277     2  0.9909      0.454 0.444 0.556
#> GSM872278     1  0.7376      0.780 0.792 0.208
#> GSM872279     2  0.7528      0.805 0.216 0.784
#> GSM872280     1  0.0000      0.908 1.000 0.000
#> GSM872281     1  0.0376      0.909 0.996 0.004
#> GSM872282     1  0.7528      0.773 0.784 0.216
#> GSM872283     2  0.7815      0.628 0.232 0.768
#> GSM872284     1  0.0376      0.909 0.996 0.004
#> GSM872285     1  0.0000      0.908 1.000 0.000
#> GSM872286     2  0.7528      0.805 0.216 0.784
#> GSM872287     1  0.0938      0.909 0.988 0.012
#> GSM872288     2  0.7453      0.806 0.212 0.788
#> GSM872289     1  0.0672      0.909 0.992 0.008
#> GSM872290     2  0.7528      0.805 0.216 0.784
#> GSM872291     1  0.0000      0.908 1.000 0.000
#> GSM872292     2  0.0000      0.866 0.000 1.000
#> GSM872293     2  0.7528      0.805 0.216 0.784
#> GSM872294     2  0.0000      0.866 0.000 1.000
#> GSM872295     2  0.0000      0.866 0.000 1.000
#> GSM872296     2  0.0000      0.866 0.000 1.000
#> GSM872297     2  0.7528      0.805 0.216 0.784
#> GSM872298     1  0.0000      0.908 1.000 0.000
#> GSM872299     2  0.7528      0.805 0.216 0.784
#> GSM872300     1  0.0000      0.908 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
#> GSM872244     3   0.000     0.9594 0.000 0.000 1.000
#> GSM872245     2   0.000     0.9234 0.000 1.000 0.000
#> GSM872246     3   0.000     0.9594 0.000 0.000 1.000
#> GSM872247     3   0.000     0.9594 0.000 0.000 1.000
#> GSM872248     2   0.000     0.9234 0.000 1.000 0.000
#> GSM872249     3   0.000     0.9594 0.000 0.000 1.000
#> GSM872250     2   0.000     0.9234 0.000 1.000 0.000
#> GSM872251     3   0.000     0.9594 0.000 0.000 1.000
#> GSM872252     1   0.000     0.9441 1.000 0.000 0.000
#> GSM872253     3   0.164     0.9203 0.044 0.000 0.956
#> GSM872254     2   0.000     0.9234 0.000 1.000 0.000
#> GSM872255     1   0.000     0.9441 1.000 0.000 0.000
#> GSM872256     1   0.000     0.9441 1.000 0.000 0.000
#> GSM872257     2   0.000     0.9234 0.000 1.000 0.000
#> GSM872258     3   0.000     0.9594 0.000 0.000 1.000
#> GSM872259     1   0.000     0.9441 1.000 0.000 0.000
#> GSM872260     1   0.000     0.9441 1.000 0.000 0.000
#> GSM872261     2   0.000     0.9234 0.000 1.000 0.000
#> GSM872262     1   0.000     0.9441 1.000 0.000 0.000
#> GSM872263     3   0.000     0.9594 0.000 0.000 1.000
#> GSM872264     3   0.400     0.7811 0.160 0.000 0.840
#> GSM872265     1   0.836     0.5287 0.620 0.232 0.148
#> GSM872266     2   0.000     0.9234 0.000 1.000 0.000
#> GSM872267     2   0.000     0.9234 0.000 1.000 0.000
#> GSM872268     3   0.000     0.9594 0.000 0.000 1.000
#> GSM872269     2   0.000     0.9234 0.000 1.000 0.000
#> GSM872270     3   0.000     0.9594 0.000 0.000 1.000
#> GSM872271     2   0.000     0.9234 0.000 1.000 0.000
#> GSM872272     2   0.000     0.9234 0.000 1.000 0.000
#> GSM872273     1   0.000     0.9441 1.000 0.000 0.000
#> GSM872274     2   0.000     0.9234 0.000 1.000 0.000
#> GSM872275     3   0.000     0.9594 0.000 0.000 1.000
#> GSM872276     1   0.000     0.9441 1.000 0.000 0.000
#> GSM872277     1   0.000     0.9441 1.000 0.000 0.000
#> GSM872278     3   0.000     0.9594 0.000 0.000 1.000
#> GSM872279     1   0.000     0.9441 1.000 0.000 0.000
#> GSM872280     3   0.625     0.2000 0.444 0.000 0.556
#> GSM872281     1   0.502     0.6883 0.760 0.000 0.240
#> GSM872282     3   0.000     0.9594 0.000 0.000 1.000
#> GSM872283     1   0.500     0.7767 0.820 0.152 0.028
#> GSM872284     1   0.465     0.7352 0.792 0.000 0.208
#> GSM872285     3   0.000     0.9594 0.000 0.000 1.000
#> GSM872286     2   0.604     0.4364 0.380 0.620 0.000
#> GSM872287     3   0.000     0.9594 0.000 0.000 1.000
#> GSM872288     2   0.631     0.0797 0.500 0.500 0.000
#> GSM872289     3   0.000     0.9594 0.000 0.000 1.000
#> GSM872290     1   0.000     0.9441 1.000 0.000 0.000
#> GSM872291     1   0.000     0.9441 1.000 0.000 0.000
#> GSM872292     2   0.000     0.9234 0.000 1.000 0.000
#> GSM872293     1   0.000     0.9441 1.000 0.000 0.000
#> GSM872294     2   0.000     0.9234 0.000 1.000 0.000
#> GSM872295     2   0.000     0.9234 0.000 1.000 0.000
#> GSM872296     2   0.000     0.9234 0.000 1.000 0.000
#> GSM872297     1   0.000     0.9441 1.000 0.000 0.000
#> GSM872298     1   0.000     0.9441 1.000 0.000 0.000
#> GSM872299     2   0.625     0.2838 0.444 0.556 0.000
#> GSM872300     1   0.000     0.9441 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM872244     3  0.0000      0.993 0.000 0.000 1.000 0.000
#> GSM872245     1  0.0188      0.879 0.996 0.004 0.000 0.000
#> GSM872246     3  0.0000      0.993 0.000 0.000 1.000 0.000
#> GSM872247     3  0.0000      0.993 0.000 0.000 1.000 0.000
#> GSM872248     2  0.0921      0.933 0.028 0.972 0.000 0.000
#> GSM872249     3  0.0000      0.993 0.000 0.000 1.000 0.000
#> GSM872250     1  0.0592      0.870 0.984 0.016 0.000 0.000
#> GSM872251     3  0.0000      0.993 0.000 0.000 1.000 0.000
#> GSM872252     1  0.0188      0.882 0.996 0.000 0.000 0.004
#> GSM872253     3  0.1716      0.937 0.064 0.000 0.936 0.000
#> GSM872254     2  0.4072      0.758 0.252 0.748 0.000 0.000
#> GSM872255     4  0.2011      0.855 0.080 0.000 0.000 0.920
#> GSM872256     1  0.3649      0.845 0.796 0.000 0.000 0.204
#> GSM872257     2  0.0707      0.935 0.020 0.980 0.000 0.000
#> GSM872258     3  0.0000      0.993 0.000 0.000 1.000 0.000
#> GSM872259     1  0.2921      0.881 0.860 0.000 0.000 0.140
#> GSM872260     1  0.4134      0.777 0.740 0.000 0.000 0.260
#> GSM872261     2  0.4008      0.765 0.244 0.756 0.000 0.000
#> GSM872262     4  0.0000      0.906 0.000 0.000 0.000 1.000
#> GSM872263     3  0.0000      0.993 0.000 0.000 1.000 0.000
#> GSM872264     4  0.4426      0.754 0.000 0.204 0.024 0.772
#> GSM872265     4  0.3873      0.741 0.000 0.228 0.000 0.772
#> GSM872266     2  0.0817      0.934 0.024 0.976 0.000 0.000
#> GSM872267     2  0.0817      0.934 0.024 0.976 0.000 0.000
#> GSM872268     3  0.0000      0.993 0.000 0.000 1.000 0.000
#> GSM872269     2  0.4164      0.743 0.264 0.736 0.000 0.000
#> GSM872270     3  0.0000      0.993 0.000 0.000 1.000 0.000
#> GSM872271     2  0.0000      0.934 0.000 1.000 0.000 0.000
#> GSM872272     2  0.0000      0.934 0.000 1.000 0.000 0.000
#> GSM872273     4  0.1118      0.893 0.036 0.000 0.000 0.964
#> GSM872274     2  0.0000      0.934 0.000 1.000 0.000 0.000
#> GSM872275     3  0.0336      0.988 0.000 0.008 0.992 0.000
#> GSM872276     4  0.0000      0.906 0.000 0.000 0.000 1.000
#> GSM872277     4  0.0817      0.899 0.024 0.000 0.000 0.976
#> GSM872278     3  0.0817      0.974 0.000 0.000 0.976 0.024
#> GSM872279     1  0.2921      0.880 0.860 0.000 0.000 0.140
#> GSM872280     4  0.2814      0.798 0.000 0.000 0.132 0.868
#> GSM872281     4  0.0336      0.905 0.000 0.000 0.008 0.992
#> GSM872282     3  0.0000      0.993 0.000 0.000 1.000 0.000
#> GSM872283     4  0.3726      0.759 0.000 0.212 0.000 0.788
#> GSM872284     4  0.0336      0.905 0.000 0.000 0.008 0.992
#> GSM872285     3  0.0188      0.990 0.000 0.000 0.996 0.004
#> GSM872286     1  0.0000      0.881 1.000 0.000 0.000 0.000
#> GSM872287     3  0.0000      0.993 0.000 0.000 1.000 0.000
#> GSM872288     1  0.0000      0.881 1.000 0.000 0.000 0.000
#> GSM872289     3  0.0469      0.985 0.012 0.000 0.988 0.000
#> GSM872290     1  0.2921      0.881 0.860 0.000 0.000 0.140
#> GSM872291     4  0.1557      0.878 0.056 0.000 0.000 0.944
#> GSM872292     2  0.0000      0.934 0.000 1.000 0.000 0.000
#> GSM872293     1  0.3528      0.854 0.808 0.000 0.000 0.192
#> GSM872294     2  0.0000      0.934 0.000 1.000 0.000 0.000
#> GSM872295     2  0.0707      0.935 0.020 0.980 0.000 0.000
#> GSM872296     2  0.0000      0.934 0.000 1.000 0.000 0.000
#> GSM872297     1  0.3610      0.849 0.800 0.000 0.000 0.200
#> GSM872298     4  0.0000      0.906 0.000 0.000 0.000 1.000
#> GSM872299     1  0.0000      0.881 1.000 0.000 0.000 0.000
#> GSM872300     4  0.0000      0.906 0.000 0.000 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM872244     3  0.0000     0.9756 0.000 0.000 1.000 0.000 0.000
#> GSM872245     5  0.1877     0.7052 0.064 0.000 0.000 0.012 0.924
#> GSM872246     3  0.0000     0.9756 0.000 0.000 1.000 0.000 0.000
#> GSM872247     3  0.0000     0.9756 0.000 0.000 1.000 0.000 0.000
#> GSM872248     2  0.4307     0.2551 0.000 0.504 0.000 0.000 0.496
#> GSM872249     3  0.0000     0.9756 0.000 0.000 1.000 0.000 0.000
#> GSM872250     5  0.0000     0.7147 0.000 0.000 0.000 0.000 1.000
#> GSM872251     3  0.0000     0.9756 0.000 0.000 1.000 0.000 0.000
#> GSM872252     5  0.4448     0.0204 0.480 0.000 0.000 0.004 0.516
#> GSM872253     3  0.3473     0.8313 0.052 0.008 0.852 0.004 0.084
#> GSM872254     5  0.3579     0.4018 0.000 0.240 0.000 0.004 0.756
#> GSM872255     1  0.1544     0.6250 0.932 0.000 0.000 0.068 0.000
#> GSM872256     1  0.3579     0.5799 0.756 0.000 0.000 0.004 0.240
#> GSM872257     2  0.1197     0.7504 0.000 0.952 0.000 0.000 0.048
#> GSM872258     3  0.0000     0.9756 0.000 0.000 1.000 0.000 0.000
#> GSM872259     1  0.3906     0.5728 0.744 0.000 0.000 0.016 0.240
#> GSM872260     1  0.1571     0.6289 0.936 0.000 0.000 0.060 0.004
#> GSM872261     2  0.4403     0.2256 0.000 0.560 0.000 0.004 0.436
#> GSM872262     1  0.4307    -0.0109 0.504 0.000 0.000 0.496 0.000
#> GSM872263     3  0.0000     0.9756 0.000 0.000 1.000 0.000 0.000
#> GSM872264     4  0.2349     0.7194 0.012 0.084 0.004 0.900 0.000
#> GSM872265     4  0.2248     0.7173 0.012 0.088 0.000 0.900 0.000
#> GSM872266     2  0.4304     0.2834 0.000 0.516 0.000 0.000 0.484
#> GSM872267     2  0.4171     0.4369 0.000 0.604 0.000 0.000 0.396
#> GSM872268     3  0.0000     0.9756 0.000 0.000 1.000 0.000 0.000
#> GSM872269     5  0.3579     0.4018 0.000 0.240 0.000 0.004 0.756
#> GSM872270     3  0.0000     0.9756 0.000 0.000 1.000 0.000 0.000
#> GSM872271     2  0.2852     0.6504 0.000 0.828 0.000 0.172 0.000
#> GSM872272     2  0.2891     0.6474 0.000 0.824 0.000 0.176 0.000
#> GSM872273     1  0.2464     0.6272 0.888 0.000 0.000 0.096 0.016
#> GSM872274     2  0.0000     0.7608 0.000 1.000 0.000 0.000 0.000
#> GSM872275     3  0.2719     0.8145 0.000 0.144 0.852 0.004 0.000
#> GSM872276     1  0.4287     0.0784 0.540 0.000 0.000 0.460 0.000
#> GSM872277     1  0.4010     0.6114 0.784 0.000 0.000 0.160 0.056
#> GSM872278     4  0.5574     0.1172 0.044 0.012 0.440 0.504 0.000
#> GSM872279     1  0.3741     0.5549 0.732 0.000 0.000 0.004 0.264
#> GSM872280     1  0.6543    -0.1024 0.456 0.000 0.212 0.332 0.000
#> GSM872281     4  0.2929     0.6140 0.180 0.000 0.000 0.820 0.000
#> GSM872282     3  0.0000     0.9756 0.000 0.000 1.000 0.000 0.000
#> GSM872283     4  0.2130     0.7202 0.012 0.080 0.000 0.908 0.000
#> GSM872284     4  0.1544     0.6901 0.068 0.000 0.000 0.932 0.000
#> GSM872285     3  0.0404     0.9658 0.000 0.000 0.988 0.012 0.000
#> GSM872286     5  0.0609     0.7171 0.020 0.000 0.000 0.000 0.980
#> GSM872287     3  0.0000     0.9756 0.000 0.000 1.000 0.000 0.000
#> GSM872288     5  0.0162     0.7163 0.004 0.000 0.000 0.000 0.996
#> GSM872289     3  0.0162     0.9726 0.000 0.000 0.996 0.000 0.004
#> GSM872290     1  0.3395     0.5771 0.764 0.000 0.000 0.000 0.236
#> GSM872291     1  0.1544     0.6239 0.932 0.000 0.000 0.068 0.000
#> GSM872292     2  0.0000     0.7608 0.000 1.000 0.000 0.000 0.000
#> GSM872293     1  0.3635     0.5727 0.748 0.000 0.000 0.004 0.248
#> GSM872294     2  0.0000     0.7608 0.000 1.000 0.000 0.000 0.000
#> GSM872295     2  0.1197     0.7504 0.000 0.952 0.000 0.000 0.048
#> GSM872296     2  0.0000     0.7608 0.000 1.000 0.000 0.000 0.000
#> GSM872297     1  0.3878     0.5766 0.748 0.000 0.000 0.016 0.236
#> GSM872298     4  0.4060     0.3623 0.360 0.000 0.000 0.640 0.000
#> GSM872299     5  0.4009     0.4079 0.312 0.000 0.000 0.004 0.684
#> GSM872300     1  0.4306     0.0020 0.508 0.000 0.000 0.492 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
#> GSM872244     3  0.0717     0.9163 0.000 0.000 0.976 0.000 0.016 0.008
#> GSM872245     5  0.4614     0.0963 0.416 0.000 0.000 0.004 0.548 0.032
#> GSM872246     3  0.0725     0.9165 0.000 0.000 0.976 0.000 0.012 0.012
#> GSM872247     3  0.0260     0.9171 0.000 0.000 0.992 0.000 0.000 0.008
#> GSM872248     5  0.3881     0.4128 0.000 0.396 0.000 0.000 0.600 0.004
#> GSM872249     3  0.0146     0.9171 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM872250     5  0.1327     0.6955 0.064 0.000 0.000 0.000 0.936 0.000
#> GSM872251     3  0.0291     0.9172 0.000 0.000 0.992 0.000 0.004 0.004
#> GSM872252     1  0.6151     0.3705 0.484 0.000 0.000 0.016 0.296 0.204
#> GSM872253     3  0.6916     0.1570 0.024 0.016 0.432 0.040 0.096 0.392
#> GSM872254     5  0.3444     0.6598 0.000 0.124 0.000 0.008 0.816 0.052
#> GSM872255     6  0.3719     0.7017 0.248 0.000 0.000 0.024 0.000 0.728
#> GSM872256     1  0.0748     0.7953 0.976 0.000 0.000 0.004 0.004 0.016
#> GSM872257     2  0.0777     0.7892 0.000 0.972 0.000 0.000 0.024 0.004
#> GSM872258     3  0.1088     0.9118 0.000 0.000 0.960 0.000 0.016 0.024
#> GSM872259     1  0.0405     0.7969 0.988 0.000 0.000 0.004 0.000 0.008
#> GSM872260     6  0.3384     0.6675 0.228 0.000 0.000 0.004 0.008 0.760
#> GSM872261     2  0.5619    -0.0895 0.004 0.476 0.000 0.012 0.420 0.088
#> GSM872262     6  0.4590     0.6866 0.096 0.000 0.000 0.224 0.000 0.680
#> GSM872263     3  0.0717     0.9163 0.000 0.000 0.976 0.000 0.016 0.008
#> GSM872264     4  0.0692     0.6618 0.000 0.020 0.004 0.976 0.000 0.000
#> GSM872265     4  0.0692     0.6614 0.000 0.020 0.000 0.976 0.000 0.004
#> GSM872266     5  0.3915     0.3874 0.000 0.412 0.000 0.000 0.584 0.004
#> GSM872267     5  0.4114     0.2748 0.000 0.460 0.000 0.004 0.532 0.004
#> GSM872268     3  0.0260     0.9171 0.000 0.000 0.992 0.000 0.000 0.008
#> GSM872269     5  0.3113     0.6723 0.000 0.100 0.000 0.008 0.844 0.048
#> GSM872270     3  0.0291     0.9165 0.000 0.000 0.992 0.000 0.004 0.004
#> GSM872271     2  0.4058     0.5587 0.000 0.660 0.000 0.320 0.004 0.016
#> GSM872272     2  0.4195     0.5462 0.000 0.648 0.000 0.328 0.008 0.016
#> GSM872273     1  0.3417     0.6128 0.796 0.000 0.000 0.044 0.000 0.160
#> GSM872274     2  0.0000     0.8052 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM872275     3  0.5740     0.5476 0.000 0.192 0.660 0.056 0.028 0.064
#> GSM872276     6  0.4545     0.7185 0.124 0.000 0.000 0.176 0.000 0.700
#> GSM872277     1  0.3017     0.6883 0.844 0.000 0.000 0.072 0.000 0.084
#> GSM872278     4  0.6665     0.1274 0.000 0.000 0.312 0.348 0.028 0.312
#> GSM872279     1  0.2321     0.7704 0.900 0.000 0.000 0.008 0.040 0.052
#> GSM872280     6  0.3714     0.6742 0.044 0.000 0.064 0.072 0.000 0.820
#> GSM872281     4  0.3999    -0.1850 0.000 0.000 0.004 0.500 0.000 0.496
#> GSM872282     3  0.0717     0.9163 0.000 0.000 0.976 0.000 0.016 0.008
#> GSM872283     4  0.1003     0.6563 0.016 0.020 0.000 0.964 0.000 0.000
#> GSM872284     4  0.2933     0.5186 0.000 0.000 0.004 0.796 0.000 0.200
#> GSM872285     3  0.1524     0.8718 0.000 0.000 0.932 0.008 0.000 0.060
#> GSM872286     5  0.1556     0.6887 0.080 0.000 0.000 0.000 0.920 0.000
#> GSM872287     3  0.0260     0.9171 0.000 0.000 0.992 0.000 0.000 0.008
#> GSM872288     5  0.1444     0.6932 0.072 0.000 0.000 0.000 0.928 0.000
#> GSM872289     3  0.0909     0.9104 0.000 0.000 0.968 0.000 0.020 0.012
#> GSM872290     1  0.2741     0.7489 0.868 0.000 0.000 0.008 0.032 0.092
#> GSM872291     6  0.4341     0.5904 0.284 0.000 0.000 0.016 0.024 0.676
#> GSM872292     2  0.0000     0.8052 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM872293     1  0.0436     0.7969 0.988 0.000 0.000 0.004 0.004 0.004
#> GSM872294     2  0.0000     0.8052 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM872295     2  0.1053     0.7863 0.000 0.964 0.000 0.004 0.020 0.012
#> GSM872296     2  0.0146     0.8041 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM872297     1  0.0405     0.7969 0.988 0.000 0.000 0.004 0.000 0.008
#> GSM872298     6  0.3837     0.5828 0.020 0.000 0.000 0.212 0.016 0.752
#> GSM872299     1  0.5449     0.2917 0.536 0.000 0.000 0.016 0.364 0.084
#> GSM872300     6  0.4582     0.6948 0.100 0.000 0.000 0.216 0.000 0.684

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

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>             n time(p) individual(p) k
#> CV:skmeans 54   0.678      4.88e-03 2
#> CV:skmeans 53   0.822      6.25e-03 3
#> CV:skmeans 57   0.238      6.40e-03 4
#> CV:skmeans 43   0.448      1.75e-04 5
#> CV:skmeans 47   0.896      1.53e-06 6

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

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

collect_plots(res)

plot of chunk CV-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.364           0.692       0.799         0.4222 0.560   0.560
#> 3 3 0.442           0.719       0.821         0.4569 0.752   0.576
#> 4 4 0.635           0.815       0.872         0.1763 0.904   0.737
#> 5 5 0.708           0.799       0.869         0.0611 0.875   0.606
#> 6 6 0.744           0.622       0.785         0.0675 0.952   0.805

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
#> GSM872244     2   0.983      0.799 0.424 0.576
#> GSM872245     2   0.000      0.489 0.000 1.000
#> GSM872246     1   0.000      0.780 1.000 0.000
#> GSM872247     1   0.000      0.780 1.000 0.000
#> GSM872248     2   0.983      0.799 0.424 0.576
#> GSM872249     1   0.000      0.780 1.000 0.000
#> GSM872250     2   0.861      0.727 0.284 0.716
#> GSM872251     1   0.000      0.780 1.000 0.000
#> GSM872252     1   0.850      0.627 0.724 0.276
#> GSM872253     1   0.000      0.780 1.000 0.000
#> GSM872254     2   0.775      0.680 0.228 0.772
#> GSM872255     1   0.844      0.629 0.728 0.272
#> GSM872256     1   0.969      0.552 0.604 0.396
#> GSM872257     2   0.983      0.799 0.424 0.576
#> GSM872258     1   0.000      0.780 1.000 0.000
#> GSM872259     1   0.985      0.530 0.572 0.428
#> GSM872260     1   0.260      0.758 0.956 0.044
#> GSM872261     2   0.983      0.799 0.424 0.576
#> GSM872262     1   0.184      0.769 0.972 0.028
#> GSM872263     1   0.000      0.780 1.000 0.000
#> GSM872264     1   0.000      0.780 1.000 0.000
#> GSM872265     1   0.000      0.780 1.000 0.000
#> GSM872266     2   0.983      0.799 0.424 0.576
#> GSM872267     2   0.983      0.799 0.424 0.576
#> GSM872268     1   0.000      0.780 1.000 0.000
#> GSM872269     2   0.886      0.740 0.304 0.696
#> GSM872270     1   0.000      0.780 1.000 0.000
#> GSM872271     2   0.983      0.799 0.424 0.576
#> GSM872272     2   0.983      0.799 0.424 0.576
#> GSM872273     1   0.983      0.534 0.576 0.424
#> GSM872274     2   0.983      0.799 0.424 0.576
#> GSM872275     1   0.000      0.780 1.000 0.000
#> GSM872276     1   0.983      0.534 0.576 0.424
#> GSM872277     1   0.983      0.534 0.576 0.424
#> GSM872278     1   0.000      0.780 1.000 0.000
#> GSM872279     1   0.983      0.534 0.576 0.424
#> GSM872280     1   0.000      0.780 1.000 0.000
#> GSM872281     1   0.000      0.780 1.000 0.000
#> GSM872282     1   0.163      0.748 0.976 0.024
#> GSM872283     1   0.295      0.752 0.948 0.052
#> GSM872284     1   0.000      0.780 1.000 0.000
#> GSM872285     1   0.000      0.780 1.000 0.000
#> GSM872286     2   0.000      0.489 0.000 1.000
#> GSM872287     1   0.000      0.780 1.000 0.000
#> GSM872288     2   0.952      0.536 0.372 0.628
#> GSM872289     1   0.000      0.780 1.000 0.000
#> GSM872290     1   0.983      0.534 0.576 0.424
#> GSM872291     1   0.881      0.614 0.700 0.300
#> GSM872292     2   0.983      0.799 0.424 0.576
#> GSM872293     1   0.983      0.534 0.576 0.424
#> GSM872294     1   0.000      0.780 1.000 0.000
#> GSM872295     2   0.983      0.799 0.424 0.576
#> GSM872296     1   0.416      0.646 0.916 0.084
#> GSM872297     1   0.983      0.534 0.576 0.424
#> GSM872298     1   0.000      0.780 1.000 0.000
#> GSM872299     2   0.987     -0.343 0.432 0.568
#> GSM872300     1   0.886      0.611 0.696 0.304

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM872244     3  0.0000      0.965 0.000 0.000 1.000
#> GSM872245     2  0.5988      0.625 0.368 0.632 0.000
#> GSM872246     3  0.0000      0.965 0.000 0.000 1.000
#> GSM872247     3  0.0000      0.965 0.000 0.000 1.000
#> GSM872248     2  0.0000      0.764 0.000 1.000 0.000
#> GSM872249     3  0.0000      0.965 0.000 0.000 1.000
#> GSM872250     2  0.6594      0.750 0.116 0.756 0.128
#> GSM872251     3  0.0747      0.954 0.016 0.000 0.984
#> GSM872252     1  0.4062      0.716 0.836 0.000 0.164
#> GSM872253     1  0.6180      0.614 0.584 0.000 0.416
#> GSM872254     2  0.4742      0.770 0.104 0.848 0.048
#> GSM872255     1  0.4062      0.716 0.836 0.000 0.164
#> GSM872256     1  0.1399      0.695 0.968 0.004 0.028
#> GSM872257     2  0.0000      0.764 0.000 1.000 0.000
#> GSM872258     3  0.1163      0.942 0.028 0.000 0.972
#> GSM872259     1  0.0424      0.679 0.992 0.008 0.000
#> GSM872260     1  0.6008      0.646 0.628 0.000 0.372
#> GSM872261     2  0.6045      0.488 0.000 0.620 0.380
#> GSM872262     1  0.6062      0.639 0.616 0.000 0.384
#> GSM872263     3  0.0000      0.965 0.000 0.000 1.000
#> GSM872264     1  0.6180      0.614 0.584 0.000 0.416
#> GSM872265     1  0.6180      0.614 0.584 0.000 0.416
#> GSM872266     2  0.5058      0.672 0.000 0.756 0.244
#> GSM872267     2  0.0000      0.764 0.000 1.000 0.000
#> GSM872268     3  0.0000      0.965 0.000 0.000 1.000
#> GSM872269     2  0.6254      0.759 0.108 0.776 0.116
#> GSM872270     3  0.0000      0.965 0.000 0.000 1.000
#> GSM872271     2  0.6180      0.411 0.000 0.584 0.416
#> GSM872272     2  0.6180      0.411 0.000 0.584 0.416
#> GSM872273     1  0.0000      0.685 1.000 0.000 0.000
#> GSM872274     2  0.1964      0.768 0.000 0.944 0.056
#> GSM872275     1  0.6180      0.614 0.584 0.000 0.416
#> GSM872276     1  0.0000      0.685 1.000 0.000 0.000
#> GSM872277     1  0.0000      0.685 1.000 0.000 0.000
#> GSM872278     1  0.6180      0.614 0.584 0.000 0.416
#> GSM872279     1  0.0000      0.685 1.000 0.000 0.000
#> GSM872280     1  0.6168      0.618 0.588 0.000 0.412
#> GSM872281     1  0.6168      0.618 0.588 0.000 0.412
#> GSM872282     3  0.0000      0.965 0.000 0.000 1.000
#> GSM872283     1  0.5968      0.637 0.636 0.000 0.364
#> GSM872284     1  0.6168      0.618 0.588 0.000 0.412
#> GSM872285     3  0.2356      0.891 0.072 0.000 0.928
#> GSM872286     2  0.5058      0.704 0.244 0.756 0.000
#> GSM872287     3  0.0000      0.965 0.000 0.000 1.000
#> GSM872288     2  0.8349      0.590 0.264 0.608 0.128
#> GSM872289     3  0.4121      0.702 0.168 0.000 0.832
#> GSM872290     1  0.0000      0.685 1.000 0.000 0.000
#> GSM872291     1  0.3482      0.717 0.872 0.000 0.128
#> GSM872292     2  0.1964      0.768 0.000 0.944 0.056
#> GSM872293     1  0.0000      0.685 1.000 0.000 0.000
#> GSM872294     1  0.8748      0.620 0.584 0.172 0.244
#> GSM872295     2  0.1964      0.768 0.000 0.944 0.056
#> GSM872296     1  0.9355      0.497 0.492 0.320 0.188
#> GSM872297     1  0.0000      0.685 1.000 0.000 0.000
#> GSM872298     1  0.6180      0.614 0.584 0.000 0.416
#> GSM872299     1  0.5327      0.394 0.728 0.272 0.000
#> GSM872300     1  0.3267      0.717 0.884 0.000 0.116

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM872244     3  0.2647      0.870 0.000 0.000 0.880 0.120
#> GSM872245     1  0.1585      0.939 0.952 0.040 0.004 0.004
#> GSM872246     3  0.0188      0.888 0.000 0.000 0.996 0.004
#> GSM872247     3  0.0188      0.888 0.000 0.000 0.996 0.004
#> GSM872248     2  0.0376      0.818 0.000 0.992 0.004 0.004
#> GSM872249     3  0.0188      0.888 0.000 0.000 0.996 0.004
#> GSM872250     2  0.5082      0.793 0.108 0.776 0.004 0.112
#> GSM872251     3  0.3219      0.847 0.000 0.000 0.836 0.164
#> GSM872252     4  0.3585      0.809 0.164 0.004 0.004 0.828
#> GSM872253     4  0.1389      0.848 0.000 0.000 0.048 0.952
#> GSM872254     2  0.3765      0.800 0.116 0.848 0.004 0.032
#> GSM872255     4  0.2973      0.813 0.144 0.000 0.000 0.856
#> GSM872256     4  0.3810      0.798 0.188 0.000 0.008 0.804
#> GSM872257     2  0.0336      0.817 0.000 0.992 0.000 0.008
#> GSM872258     3  0.2216      0.873 0.000 0.000 0.908 0.092
#> GSM872259     1  0.0000      0.977 1.000 0.000 0.000 0.000
#> GSM872260     4  0.2214      0.854 0.044 0.000 0.028 0.928
#> GSM872261     2  0.5031      0.780 0.000 0.740 0.048 0.212
#> GSM872262     4  0.1388      0.853 0.028 0.000 0.012 0.960
#> GSM872263     3  0.0188      0.888 0.000 0.000 0.996 0.004
#> GSM872264     4  0.1557      0.845 0.000 0.000 0.056 0.944
#> GSM872265     4  0.1389      0.848 0.000 0.000 0.048 0.952
#> GSM872266     2  0.4285      0.807 0.000 0.804 0.040 0.156
#> GSM872267     2  0.0336      0.817 0.000 0.992 0.000 0.008
#> GSM872268     3  0.0188      0.888 0.000 0.000 0.996 0.004
#> GSM872269     2  0.4606      0.809 0.100 0.808 0.004 0.088
#> GSM872270     3  0.2868      0.859 0.000 0.000 0.864 0.136
#> GSM872271     2  0.5031      0.780 0.000 0.740 0.048 0.212
#> GSM872272     2  0.5031      0.780 0.000 0.740 0.048 0.212
#> GSM872273     1  0.1118      0.959 0.964 0.000 0.000 0.036
#> GSM872274     2  0.1118      0.822 0.000 0.964 0.000 0.036
#> GSM872275     4  0.1389      0.848 0.000 0.000 0.048 0.952
#> GSM872276     4  0.3311      0.793 0.172 0.000 0.000 0.828
#> GSM872277     1  0.1118      0.959 0.964 0.000 0.000 0.036
#> GSM872278     4  0.1389      0.848 0.000 0.000 0.048 0.952
#> GSM872279     4  0.4746      0.569 0.368 0.000 0.000 0.632
#> GSM872280     4  0.2345      0.828 0.000 0.000 0.100 0.900
#> GSM872281     4  0.1022      0.853 0.000 0.000 0.032 0.968
#> GSM872282     3  0.2469      0.873 0.000 0.000 0.892 0.108
#> GSM872283     4  0.1389      0.848 0.000 0.000 0.048 0.952
#> GSM872284     4  0.0469      0.853 0.000 0.000 0.012 0.988
#> GSM872285     3  0.3311      0.801 0.000 0.000 0.828 0.172
#> GSM872286     2  0.4198      0.710 0.224 0.768 0.004 0.004
#> GSM872287     3  0.0188      0.888 0.000 0.000 0.996 0.004
#> GSM872288     2  0.6758      0.548 0.104 0.580 0.004 0.312
#> GSM872289     3  0.4843      0.484 0.000 0.000 0.604 0.396
#> GSM872290     1  0.0000      0.977 1.000 0.000 0.000 0.000
#> GSM872291     4  0.3486      0.800 0.188 0.000 0.000 0.812
#> GSM872292     2  0.1118      0.822 0.000 0.964 0.000 0.036
#> GSM872293     1  0.0000      0.977 1.000 0.000 0.000 0.000
#> GSM872294     4  0.3583      0.767 0.000 0.180 0.004 0.816
#> GSM872295     2  0.1118      0.822 0.000 0.964 0.000 0.036
#> GSM872296     4  0.4730      0.523 0.000 0.364 0.000 0.636
#> GSM872297     1  0.0000      0.977 1.000 0.000 0.000 0.000
#> GSM872298     4  0.1389      0.848 0.000 0.000 0.048 0.952
#> GSM872299     4  0.7519      0.176 0.392 0.184 0.000 0.424
#> GSM872300     4  0.3074      0.809 0.152 0.000 0.000 0.848

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM872244     3  0.2970      0.822 0.000 0.000 0.828 0.168 0.004
#> GSM872245     1  0.3143      0.818 0.796 0.000 0.000 0.000 0.204
#> GSM872246     3  0.0000      0.853 0.000 0.000 1.000 0.000 0.000
#> GSM872247     3  0.0000      0.853 0.000 0.000 1.000 0.000 0.000
#> GSM872248     5  0.2471      0.717 0.000 0.136 0.000 0.000 0.864
#> GSM872249     3  0.0000      0.853 0.000 0.000 1.000 0.000 0.000
#> GSM872250     5  0.1121      0.797 0.000 0.000 0.000 0.044 0.956
#> GSM872251     3  0.3336      0.784 0.000 0.000 0.772 0.228 0.000
#> GSM872252     4  0.3780      0.786 0.072 0.000 0.000 0.812 0.116
#> GSM872253     4  0.0000      0.845 0.000 0.000 0.000 1.000 0.000
#> GSM872254     5  0.1197      0.788 0.000 0.048 0.000 0.000 0.952
#> GSM872255     4  0.5625      0.788 0.160 0.096 0.000 0.700 0.044
#> GSM872256     4  0.5582      0.774 0.112 0.060 0.000 0.716 0.112
#> GSM872257     2  0.1965      0.923 0.000 0.904 0.000 0.000 0.096
#> GSM872258     3  0.2230      0.830 0.000 0.000 0.884 0.116 0.000
#> GSM872259     1  0.1908      0.921 0.908 0.000 0.000 0.000 0.092
#> GSM872260     4  0.1485      0.844 0.020 0.000 0.000 0.948 0.032
#> GSM872261     4  0.1270      0.828 0.000 0.000 0.000 0.948 0.052
#> GSM872262     4  0.5125      0.811 0.112 0.096 0.000 0.748 0.044
#> GSM872263     3  0.0000      0.853 0.000 0.000 1.000 0.000 0.000
#> GSM872264     4  0.0609      0.835 0.000 0.000 0.020 0.980 0.000
#> GSM872265     4  0.0000      0.845 0.000 0.000 0.000 1.000 0.000
#> GSM872266     5  0.2471      0.723 0.000 0.000 0.000 0.136 0.864
#> GSM872267     5  0.4074      0.352 0.000 0.364 0.000 0.000 0.636
#> GSM872268     3  0.0000      0.853 0.000 0.000 1.000 0.000 0.000
#> GSM872269     5  0.1579      0.796 0.000 0.032 0.000 0.024 0.944
#> GSM872270     3  0.3534      0.750 0.000 0.000 0.744 0.256 0.000
#> GSM872271     4  0.0000      0.845 0.000 0.000 0.000 1.000 0.000
#> GSM872272     4  0.0000      0.845 0.000 0.000 0.000 1.000 0.000
#> GSM872273     1  0.0794      0.855 0.972 0.028 0.000 0.000 0.000
#> GSM872274     2  0.1965      0.923 0.000 0.904 0.000 0.000 0.096
#> GSM872275     4  0.0000      0.845 0.000 0.000 0.000 1.000 0.000
#> GSM872276     4  0.5625      0.788 0.160 0.096 0.000 0.700 0.044
#> GSM872277     1  0.0794      0.855 0.972 0.028 0.000 0.000 0.000
#> GSM872278     4  0.0000      0.845 0.000 0.000 0.000 1.000 0.000
#> GSM872279     4  0.6152      0.459 0.332 0.020 0.000 0.556 0.092
#> GSM872280     4  0.6244      0.786 0.092 0.096 0.064 0.704 0.044
#> GSM872281     4  0.5031      0.815 0.092 0.096 0.004 0.764 0.044
#> GSM872282     3  0.2690      0.820 0.000 0.000 0.844 0.156 0.000
#> GSM872283     4  0.1121      0.847 0.000 0.044 0.000 0.956 0.000
#> GSM872284     4  0.4569      0.821 0.092 0.096 0.000 0.784 0.028
#> GSM872285     3  0.4052      0.757 0.000 0.024 0.784 0.176 0.016
#> GSM872286     5  0.1121      0.779 0.044 0.000 0.000 0.000 0.956
#> GSM872287     3  0.0000      0.853 0.000 0.000 1.000 0.000 0.000
#> GSM872288     5  0.1282      0.797 0.004 0.000 0.000 0.044 0.952
#> GSM872289     3  0.5470      0.527 0.000 0.000 0.564 0.364 0.072
#> GSM872290     1  0.1908      0.921 0.908 0.000 0.000 0.000 0.092
#> GSM872291     4  0.5771      0.764 0.096 0.068 0.000 0.700 0.136
#> GSM872292     2  0.1965      0.923 0.000 0.904 0.000 0.000 0.096
#> GSM872293     1  0.1908      0.921 0.908 0.000 0.000 0.000 0.092
#> GSM872294     2  0.2329      0.841 0.000 0.876 0.000 0.124 0.000
#> GSM872295     2  0.1965      0.923 0.000 0.904 0.000 0.000 0.096
#> GSM872296     2  0.2179      0.853 0.000 0.888 0.000 0.112 0.000
#> GSM872297     1  0.1908      0.921 0.908 0.000 0.000 0.000 0.092
#> GSM872298     4  0.0000      0.845 0.000 0.000 0.000 1.000 0.000
#> GSM872299     5  0.6682      0.133 0.192 0.008 0.000 0.328 0.472
#> GSM872300     4  0.5625      0.788 0.160 0.096 0.000 0.700 0.044

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM872244     3  0.4898      0.737 0.000 0.000 0.656 0.200 0.000 0.144
#> GSM872245     1  0.3221      0.586 0.792 0.000 0.000 0.000 0.188 0.020
#> GSM872246     3  0.2300      0.783 0.000 0.000 0.856 0.000 0.000 0.144
#> GSM872247     3  0.0000      0.791 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872248     5  0.0000      0.859 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM872249     3  0.0000      0.791 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872250     5  0.0000      0.859 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM872251     3  0.3101      0.702 0.000 0.000 0.756 0.244 0.000 0.000
#> GSM872252     6  0.6139      0.425 0.188 0.000 0.000 0.388 0.012 0.412
#> GSM872253     4  0.3765     -0.249 0.000 0.000 0.000 0.596 0.000 0.404
#> GSM872254     5  0.3672      0.219 0.000 0.000 0.000 0.000 0.632 0.368
#> GSM872255     4  0.3804      0.587 0.000 0.000 0.000 0.576 0.000 0.424
#> GSM872256     4  0.5384      0.489 0.184 0.000 0.000 0.604 0.004 0.208
#> GSM872257     2  0.0000      0.983 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM872258     3  0.4154      0.765 0.000 0.000 0.744 0.112 0.000 0.144
#> GSM872259     1  0.0000      0.699 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM872260     4  0.2448      0.621 0.064 0.000 0.000 0.884 0.000 0.052
#> GSM872261     4  0.0000      0.647 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM872262     4  0.3804      0.587 0.000 0.000 0.000 0.576 0.000 0.424
#> GSM872263     3  0.2300      0.783 0.000 0.000 0.856 0.000 0.000 0.144
#> GSM872264     4  0.0547      0.640 0.000 0.000 0.000 0.980 0.000 0.020
#> GSM872265     4  0.0547      0.640 0.000 0.000 0.000 0.980 0.000 0.020
#> GSM872266     5  0.0000      0.859 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM872267     5  0.3756      0.271 0.000 0.400 0.000 0.000 0.600 0.000
#> GSM872268     3  0.0000      0.791 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872269     5  0.0000      0.859 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM872270     3  0.3464      0.605 0.000 0.000 0.688 0.312 0.000 0.000
#> GSM872271     4  0.3810     -0.266 0.000 0.000 0.000 0.572 0.000 0.428
#> GSM872272     4  0.0547      0.640 0.000 0.000 0.000 0.980 0.000 0.020
#> GSM872273     1  0.2597      0.646 0.824 0.000 0.000 0.000 0.000 0.176
#> GSM872274     2  0.0000      0.983 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM872275     4  0.0000      0.647 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM872276     4  0.3804      0.587 0.000 0.000 0.000 0.576 0.000 0.424
#> GSM872277     1  0.2597      0.646 0.824 0.000 0.000 0.000 0.000 0.176
#> GSM872278     4  0.0000      0.647 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM872279     1  0.5392     -0.315 0.448 0.000 0.000 0.112 0.000 0.440
#> GSM872280     4  0.3804      0.587 0.000 0.000 0.000 0.576 0.000 0.424
#> GSM872281     4  0.3804      0.587 0.000 0.000 0.000 0.576 0.000 0.424
#> GSM872282     3  0.4634      0.752 0.000 0.000 0.692 0.164 0.000 0.144
#> GSM872283     4  0.2006      0.643 0.004 0.000 0.000 0.892 0.000 0.104
#> GSM872284     4  0.3747      0.595 0.000 0.000 0.000 0.604 0.000 0.396
#> GSM872285     3  0.4793      0.534 0.000 0.000 0.628 0.288 0.000 0.084
#> GSM872286     5  0.0000      0.859 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM872287     3  0.0000      0.791 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872288     5  0.0000      0.859 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM872289     3  0.6847      0.596 0.000 0.000 0.504 0.216 0.136 0.144
#> GSM872290     1  0.3782      0.081 0.588 0.000 0.000 0.000 0.000 0.412
#> GSM872291     6  0.4892      0.418 0.176 0.000 0.000 0.164 0.000 0.660
#> GSM872292     2  0.0000      0.983 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM872293     1  0.0000      0.699 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM872294     2  0.0000      0.983 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM872295     2  0.1501      0.909 0.000 0.924 0.000 0.000 0.000 0.076
#> GSM872296     2  0.0000      0.983 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM872297     1  0.0000      0.699 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM872298     4  0.0000      0.647 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM872299     6  0.6010      0.133 0.200 0.000 0.000 0.004 0.384 0.412
#> GSM872300     4  0.3804      0.587 0.000 0.000 0.000 0.576 0.000 0.424

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

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>         n time(p) individual(p) k
#> CV:pam 54   0.526      3.49e-02 2
#> CV:pam 52   0.790      8.83e-05 3
#> CV:pam 55   0.890      2.59e-05 4
#> CV:pam 54   0.681      1.23e-06 5
#> CV:pam 47   0.647      8.00e-07 6

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 29485 rows and 57 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 0.804           0.936       0.940         0.4229 0.560   0.560
#> 3 3 0.802           0.890       0.929         0.3359 0.612   0.441
#> 4 4 0.727           0.809       0.912         0.2930 0.761   0.496
#> 5 5 0.820           0.799       0.892         0.0712 0.921   0.720
#> 6 6 0.829           0.821       0.895         0.0625 0.904   0.598

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
#> GSM872244     1   0.000      0.923 1.000 0.000
#> GSM872245     1   0.952      0.507 0.628 0.372
#> GSM872246     1   0.000      0.923 1.000 0.000
#> GSM872247     1   0.000      0.923 1.000 0.000
#> GSM872248     2   0.000      0.953 0.000 1.000
#> GSM872249     1   0.000      0.923 1.000 0.000
#> GSM872250     1   0.430      0.956 0.912 0.088
#> GSM872251     1   0.000      0.923 1.000 0.000
#> GSM872252     1   0.402      0.961 0.920 0.080
#> GSM872253     1   0.402      0.961 0.920 0.080
#> GSM872254     2   0.388      0.926 0.076 0.924
#> GSM872255     1   0.402      0.961 0.920 0.080
#> GSM872256     1   0.402      0.961 0.920 0.080
#> GSM872257     2   0.000      0.953 0.000 1.000
#> GSM872258     1   0.204      0.939 0.968 0.032
#> GSM872259     1   0.402      0.961 0.920 0.080
#> GSM872260     1   0.402      0.961 0.920 0.080
#> GSM872261     2   0.373      0.930 0.072 0.928
#> GSM872262     1   0.402      0.961 0.920 0.080
#> GSM872263     1   0.000      0.923 1.000 0.000
#> GSM872264     2   0.224      0.956 0.036 0.964
#> GSM872265     2   0.224      0.956 0.036 0.964
#> GSM872266     2   0.184      0.958 0.028 0.972
#> GSM872267     2   0.000      0.953 0.000 1.000
#> GSM872268     1   0.000      0.923 1.000 0.000
#> GSM872269     2   0.689      0.800 0.184 0.816
#> GSM872270     1   0.000      0.923 1.000 0.000
#> GSM872271     2   0.184      0.958 0.028 0.972
#> GSM872272     2   0.184      0.958 0.028 0.972
#> GSM872273     1   0.402      0.961 0.920 0.080
#> GSM872274     2   0.000      0.953 0.000 1.000
#> GSM872275     1   0.416      0.959 0.916 0.084
#> GSM872276     1   0.402      0.961 0.920 0.080
#> GSM872277     1   0.402      0.961 0.920 0.080
#> GSM872278     1   0.541      0.925 0.876 0.124
#> GSM872279     1   0.402      0.961 0.920 0.080
#> GSM872280     1   0.402      0.961 0.920 0.080
#> GSM872281     1   0.634      0.884 0.840 0.160
#> GSM872282     1   0.000      0.923 1.000 0.000
#> GSM872283     2   0.224      0.956 0.036 0.964
#> GSM872284     2   0.689      0.799 0.184 0.816
#> GSM872285     1   0.402      0.961 0.920 0.080
#> GSM872286     1   0.416      0.959 0.916 0.084
#> GSM872287     1   0.000      0.923 1.000 0.000
#> GSM872288     1   0.402      0.961 0.920 0.080
#> GSM872289     1   0.402      0.961 0.920 0.080
#> GSM872290     1   0.402      0.961 0.920 0.080
#> GSM872291     1   0.402      0.961 0.920 0.080
#> GSM872292     2   0.000      0.953 0.000 1.000
#> GSM872293     1   0.402      0.961 0.920 0.080
#> GSM872294     2   0.184      0.958 0.028 0.972
#> GSM872295     2   0.000      0.953 0.000 1.000
#> GSM872296     2   0.000      0.953 0.000 1.000
#> GSM872297     1   0.402      0.961 0.920 0.080
#> GSM872298     1   0.402      0.961 0.920 0.080
#> GSM872299     1   0.402      0.961 0.920 0.080
#> GSM872300     1   0.402      0.961 0.920 0.080

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM872244     3  0.0000      0.956 0.000 0.000 1.000
#> GSM872245     1  0.2625      0.922 0.916 0.084 0.000
#> GSM872246     3  0.0000      0.956 0.000 0.000 1.000
#> GSM872247     3  0.0000      0.956 0.000 0.000 1.000
#> GSM872248     2  0.0000      0.870 0.000 1.000 0.000
#> GSM872249     3  0.0000      0.956 0.000 0.000 1.000
#> GSM872250     1  0.2625      0.922 0.916 0.084 0.000
#> GSM872251     3  0.0000      0.956 0.000 0.000 1.000
#> GSM872252     1  0.2625      0.922 0.916 0.084 0.000
#> GSM872253     1  0.2625      0.922 0.916 0.084 0.000
#> GSM872254     2  0.3752      0.792 0.144 0.856 0.000
#> GSM872255     1  0.0747      0.924 0.984 0.016 0.000
#> GSM872256     1  0.2448      0.924 0.924 0.076 0.000
#> GSM872257     2  0.0000      0.870 0.000 1.000 0.000
#> GSM872258     3  0.0000      0.956 0.000 0.000 1.000
#> GSM872259     1  0.2625      0.922 0.916 0.084 0.000
#> GSM872260     1  0.2261      0.925 0.932 0.068 0.000
#> GSM872261     1  0.2625      0.922 0.916 0.084 0.000
#> GSM872262     1  0.0000      0.922 1.000 0.000 0.000
#> GSM872263     3  0.0000      0.956 0.000 0.000 1.000
#> GSM872264     1  0.1964      0.899 0.944 0.000 0.056
#> GSM872265     1  0.1964      0.899 0.944 0.000 0.056
#> GSM872266     2  0.3340      0.813 0.120 0.880 0.000
#> GSM872267     2  0.0000      0.870 0.000 1.000 0.000
#> GSM872268     3  0.0000      0.956 0.000 0.000 1.000
#> GSM872269     2  0.5650      0.553 0.312 0.688 0.000
#> GSM872270     3  0.0000      0.956 0.000 0.000 1.000
#> GSM872271     1  0.4519      0.814 0.852 0.116 0.032
#> GSM872272     1  0.4551      0.802 0.844 0.132 0.024
#> GSM872273     1  0.0000      0.922 1.000 0.000 0.000
#> GSM872274     2  0.2625      0.843 0.084 0.916 0.000
#> GSM872275     1  0.1964      0.899 0.944 0.000 0.056
#> GSM872276     1  0.0000      0.922 1.000 0.000 0.000
#> GSM872277     1  0.0000      0.922 1.000 0.000 0.000
#> GSM872278     1  0.1964      0.899 0.944 0.000 0.056
#> GSM872279     1  0.2625      0.922 0.916 0.084 0.000
#> GSM872280     1  0.0000      0.922 1.000 0.000 0.000
#> GSM872281     1  0.1964      0.899 0.944 0.000 0.056
#> GSM872282     3  0.0000      0.956 0.000 0.000 1.000
#> GSM872283     1  0.0237      0.921 0.996 0.000 0.004
#> GSM872284     1  0.1964      0.899 0.944 0.000 0.056
#> GSM872285     1  0.2959      0.881 0.900 0.000 0.100
#> GSM872286     1  0.2625      0.922 0.916 0.084 0.000
#> GSM872287     3  0.0000      0.956 0.000 0.000 1.000
#> GSM872288     1  0.2625      0.922 0.916 0.084 0.000
#> GSM872289     3  0.5785      0.451 0.332 0.000 0.668
#> GSM872290     1  0.2625      0.922 0.916 0.084 0.000
#> GSM872291     1  0.2165      0.925 0.936 0.064 0.000
#> GSM872292     2  0.2625      0.843 0.084 0.916 0.000
#> GSM872293     1  0.2625      0.922 0.916 0.084 0.000
#> GSM872294     1  0.5254      0.614 0.736 0.264 0.000
#> GSM872295     2  0.0000      0.870 0.000 1.000 0.000
#> GSM872296     2  0.2625      0.843 0.084 0.916 0.000
#> GSM872297     1  0.2625      0.922 0.916 0.084 0.000
#> GSM872298     1  0.0000      0.922 1.000 0.000 0.000
#> GSM872299     1  0.2625      0.922 0.916 0.084 0.000
#> GSM872300     1  0.0000      0.922 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM872244     3  0.0000      0.952 0.000 0.000 1.000 0.000
#> GSM872245     1  0.0000      0.871 1.000 0.000 0.000 0.000
#> GSM872246     3  0.0000      0.952 0.000 0.000 1.000 0.000
#> GSM872247     3  0.0000      0.952 0.000 0.000 1.000 0.000
#> GSM872248     2  0.3873      0.713 0.228 0.772 0.000 0.000
#> GSM872249     3  0.0000      0.952 0.000 0.000 1.000 0.000
#> GSM872250     1  0.0000      0.871 1.000 0.000 0.000 0.000
#> GSM872251     3  0.0000      0.952 0.000 0.000 1.000 0.000
#> GSM872252     1  0.2011      0.860 0.920 0.000 0.000 0.080
#> GSM872253     3  0.7302      0.166 0.168 0.000 0.500 0.332
#> GSM872254     1  0.0000      0.871 1.000 0.000 0.000 0.000
#> GSM872255     4  0.0000      0.860 0.000 0.000 0.000 1.000
#> GSM872256     4  0.3975      0.611 0.240 0.000 0.000 0.760
#> GSM872257     2  0.0000      0.898 0.000 1.000 0.000 0.000
#> GSM872258     3  0.0000      0.952 0.000 0.000 1.000 0.000
#> GSM872259     1  0.3311      0.817 0.828 0.000 0.000 0.172
#> GSM872260     4  0.3172      0.727 0.160 0.000 0.000 0.840
#> GSM872261     1  0.0707      0.871 0.980 0.000 0.000 0.020
#> GSM872262     4  0.0000      0.860 0.000 0.000 0.000 1.000
#> GSM872263     3  0.0000      0.952 0.000 0.000 1.000 0.000
#> GSM872264     4  0.2469      0.835 0.000 0.000 0.108 0.892
#> GSM872265     4  0.2469      0.835 0.000 0.000 0.108 0.892
#> GSM872266     1  0.4888      0.171 0.588 0.412 0.000 0.000
#> GSM872267     2  0.0000      0.898 0.000 1.000 0.000 0.000
#> GSM872268     3  0.0000      0.952 0.000 0.000 1.000 0.000
#> GSM872269     1  0.0000      0.871 1.000 0.000 0.000 0.000
#> GSM872270     3  0.0000      0.952 0.000 0.000 1.000 0.000
#> GSM872271     4  0.5923      0.340 0.000 0.376 0.044 0.580
#> GSM872272     4  0.5699      0.342 0.000 0.380 0.032 0.588
#> GSM872273     4  0.0188      0.859 0.004 0.000 0.000 0.996
#> GSM872274     2  0.0000      0.898 0.000 1.000 0.000 0.000
#> GSM872275     4  0.2704      0.824 0.000 0.000 0.124 0.876
#> GSM872276     4  0.0000      0.860 0.000 0.000 0.000 1.000
#> GSM872277     4  0.0000      0.860 0.000 0.000 0.000 1.000
#> GSM872278     4  0.2589      0.830 0.000 0.000 0.116 0.884
#> GSM872279     1  0.3311      0.817 0.828 0.000 0.000 0.172
#> GSM872280     4  0.1022      0.854 0.000 0.000 0.032 0.968
#> GSM872281     4  0.2011      0.848 0.000 0.000 0.080 0.920
#> GSM872282     3  0.0000      0.952 0.000 0.000 1.000 0.000
#> GSM872283     4  0.1389      0.856 0.000 0.000 0.048 0.952
#> GSM872284     4  0.2149      0.845 0.000 0.000 0.088 0.912
#> GSM872285     4  0.4477      0.602 0.000 0.000 0.312 0.688
#> GSM872286     1  0.0000      0.871 1.000 0.000 0.000 0.000
#> GSM872287     3  0.0000      0.952 0.000 0.000 1.000 0.000
#> GSM872288     1  0.2011      0.853 0.920 0.000 0.000 0.080
#> GSM872289     3  0.0707      0.931 0.000 0.000 0.980 0.020
#> GSM872290     1  0.4222      0.695 0.728 0.000 0.000 0.272
#> GSM872291     4  0.0000      0.860 0.000 0.000 0.000 1.000
#> GSM872292     2  0.0000      0.898 0.000 1.000 0.000 0.000
#> GSM872293     1  0.3311      0.817 0.828 0.000 0.000 0.172
#> GSM872294     2  0.3610      0.693 0.000 0.800 0.000 0.200
#> GSM872295     2  0.3266      0.767 0.168 0.832 0.000 0.000
#> GSM872296     2  0.0000      0.898 0.000 1.000 0.000 0.000
#> GSM872297     4  0.4331      0.522 0.288 0.000 0.000 0.712
#> GSM872298     4  0.0000      0.860 0.000 0.000 0.000 1.000
#> GSM872299     1  0.0000      0.871 1.000 0.000 0.000 0.000
#> GSM872300     4  0.0000      0.860 0.000 0.000 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM872244     3  0.0000      0.949 0.000 0.000 1.000 0.000 0.000
#> GSM872245     5  0.2690      0.825 0.156 0.000 0.000 0.000 0.844
#> GSM872246     3  0.0000      0.949 0.000 0.000 1.000 0.000 0.000
#> GSM872247     3  0.0000      0.949 0.000 0.000 1.000 0.000 0.000
#> GSM872248     5  0.3966      0.445 0.000 0.336 0.000 0.000 0.664
#> GSM872249     3  0.0000      0.949 0.000 0.000 1.000 0.000 0.000
#> GSM872250     5  0.2208      0.840 0.072 0.000 0.000 0.020 0.908
#> GSM872251     3  0.0000      0.949 0.000 0.000 1.000 0.000 0.000
#> GSM872252     5  0.4341      0.558 0.404 0.000 0.000 0.004 0.592
#> GSM872253     3  0.6388      0.241 0.000 0.000 0.496 0.312 0.192
#> GSM872254     5  0.1410      0.836 0.060 0.000 0.000 0.000 0.940
#> GSM872255     4  0.2813      0.714 0.168 0.000 0.000 0.832 0.000
#> GSM872256     1  0.1908      0.839 0.908 0.000 0.000 0.092 0.000
#> GSM872257     2  0.1608      0.839 0.000 0.928 0.000 0.000 0.072
#> GSM872258     3  0.0000      0.949 0.000 0.000 1.000 0.000 0.000
#> GSM872259     1  0.0000      0.905 1.000 0.000 0.000 0.000 0.000
#> GSM872260     4  0.4074      0.353 0.364 0.000 0.000 0.636 0.000
#> GSM872261     5  0.2505      0.839 0.092 0.000 0.000 0.020 0.888
#> GSM872262     4  0.0000      0.846 0.000 0.000 0.000 1.000 0.000
#> GSM872263     3  0.0000      0.949 0.000 0.000 1.000 0.000 0.000
#> GSM872264     4  0.3336      0.832 0.000 0.000 0.096 0.844 0.060
#> GSM872265     4  0.3401      0.830 0.000 0.000 0.096 0.840 0.064
#> GSM872266     5  0.2407      0.750 0.004 0.088 0.012 0.000 0.896
#> GSM872267     2  0.0703      0.861 0.000 0.976 0.000 0.000 0.024
#> GSM872268     3  0.0000      0.949 0.000 0.000 1.000 0.000 0.000
#> GSM872269     5  0.1410      0.836 0.060 0.000 0.000 0.000 0.940
#> GSM872270     3  0.0000      0.949 0.000 0.000 1.000 0.000 0.000
#> GSM872271     4  0.6589      0.535 0.000 0.252 0.096 0.588 0.064
#> GSM872272     4  0.6546      0.550 0.000 0.244 0.096 0.596 0.064
#> GSM872273     1  0.3966      0.538 0.664 0.000 0.000 0.336 0.000
#> GSM872274     2  0.0000      0.864 0.000 1.000 0.000 0.000 0.000
#> GSM872275     4  0.2074      0.845 0.000 0.000 0.104 0.896 0.000
#> GSM872276     4  0.0000      0.846 0.000 0.000 0.000 1.000 0.000
#> GSM872277     4  0.0000      0.846 0.000 0.000 0.000 1.000 0.000
#> GSM872278     4  0.1965      0.848 0.000 0.000 0.096 0.904 0.000
#> GSM872279     1  0.0000      0.905 1.000 0.000 0.000 0.000 0.000
#> GSM872280     4  0.0000      0.846 0.000 0.000 0.000 1.000 0.000
#> GSM872281     4  0.1965      0.848 0.000 0.000 0.096 0.904 0.000
#> GSM872282     3  0.0000      0.949 0.000 0.000 1.000 0.000 0.000
#> GSM872283     4  0.3401      0.830 0.000 0.000 0.096 0.840 0.064
#> GSM872284     4  0.1965      0.848 0.000 0.000 0.096 0.904 0.000
#> GSM872285     4  0.2605      0.820 0.000 0.000 0.148 0.852 0.000
#> GSM872286     5  0.2561      0.831 0.144 0.000 0.000 0.000 0.856
#> GSM872287     3  0.0000      0.949 0.000 0.000 1.000 0.000 0.000
#> GSM872288     5  0.3454      0.806 0.100 0.000 0.000 0.064 0.836
#> GSM872289     3  0.1478      0.884 0.000 0.000 0.936 0.064 0.000
#> GSM872290     1  0.0000      0.905 1.000 0.000 0.000 0.000 0.000
#> GSM872291     4  0.2690      0.726 0.156 0.000 0.000 0.844 0.000
#> GSM872292     2  0.0000      0.864 0.000 1.000 0.000 0.000 0.000
#> GSM872293     1  0.0000      0.905 1.000 0.000 0.000 0.000 0.000
#> GSM872294     2  0.4219      0.147 0.000 0.584 0.000 0.416 0.000
#> GSM872295     2  0.2605      0.782 0.000 0.852 0.000 0.000 0.148
#> GSM872296     2  0.0000      0.864 0.000 1.000 0.000 0.000 0.000
#> GSM872297     1  0.0000      0.905 1.000 0.000 0.000 0.000 0.000
#> GSM872298     4  0.0000      0.846 0.000 0.000 0.000 1.000 0.000
#> GSM872299     5  0.4060      0.642 0.360 0.000 0.000 0.000 0.640
#> GSM872300     4  0.0000      0.846 0.000 0.000 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM872244     3  0.0000     0.9035 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872245     5  0.2260     0.8000 0.140 0.000 0.000 0.000 0.860 0.000
#> GSM872246     3  0.0000     0.9035 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872247     3  0.0000     0.9035 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872248     2  0.3868     0.0522 0.000 0.508 0.000 0.000 0.492 0.000
#> GSM872249     3  0.0000     0.9035 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872250     5  0.0520     0.8506 0.008 0.000 0.000 0.008 0.984 0.000
#> GSM872251     3  0.0713     0.8918 0.000 0.000 0.972 0.028 0.000 0.000
#> GSM872252     5  0.4193     0.6421 0.272 0.000 0.000 0.044 0.684 0.000
#> GSM872253     3  0.5703     0.4407 0.000 0.000 0.540 0.188 0.268 0.004
#> GSM872254     5  0.1141     0.8215 0.000 0.052 0.000 0.000 0.948 0.000
#> GSM872255     6  0.1957     0.8606 0.000 0.000 0.000 0.112 0.000 0.888
#> GSM872256     1  0.2178     0.8169 0.868 0.000 0.000 0.000 0.000 0.132
#> GSM872257     2  0.0458     0.8378 0.000 0.984 0.000 0.000 0.016 0.000
#> GSM872258     3  0.2527     0.8116 0.000 0.000 0.832 0.168 0.000 0.000
#> GSM872259     1  0.0000     0.9641 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM872260     6  0.3495     0.7849 0.060 0.000 0.000 0.128 0.004 0.808
#> GSM872261     5  0.1204     0.8412 0.000 0.000 0.000 0.056 0.944 0.000
#> GSM872262     6  0.0000     0.9410 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM872263     3  0.0000     0.9035 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872264     4  0.3290     0.8258 0.000 0.000 0.004 0.744 0.000 0.252
#> GSM872265     4  0.3290     0.8258 0.000 0.000 0.004 0.744 0.000 0.252
#> GSM872266     5  0.0146     0.8470 0.000 0.004 0.000 0.000 0.996 0.000
#> GSM872267     2  0.1333     0.8531 0.000 0.944 0.000 0.048 0.008 0.000
#> GSM872268     3  0.0000     0.9035 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872269     5  0.0000     0.8475 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM872270     3  0.0000     0.9035 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872271     4  0.3240     0.8262 0.000 0.040 0.000 0.812 0.000 0.148
#> GSM872272     4  0.3240     0.8262 0.000 0.040 0.000 0.812 0.000 0.148
#> GSM872273     6  0.1204     0.8968 0.056 0.000 0.000 0.000 0.000 0.944
#> GSM872274     2  0.1204     0.8533 0.000 0.944 0.000 0.056 0.000 0.000
#> GSM872275     4  0.1765     0.6985 0.000 0.000 0.052 0.924 0.000 0.024
#> GSM872276     6  0.0000     0.9410 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM872277     6  0.0000     0.9410 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM872278     4  0.3046     0.8331 0.000 0.000 0.012 0.800 0.000 0.188
#> GSM872279     1  0.0000     0.9641 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM872280     6  0.1957     0.8611 0.000 0.000 0.000 0.112 0.000 0.888
#> GSM872281     6  0.0146     0.9389 0.000 0.000 0.004 0.000 0.000 0.996
#> GSM872282     3  0.0000     0.9035 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872283     4  0.3961     0.5391 0.000 0.000 0.004 0.556 0.000 0.440
#> GSM872284     6  0.0146     0.9389 0.000 0.000 0.004 0.000 0.000 0.996
#> GSM872285     3  0.5539     0.4762 0.000 0.000 0.552 0.188 0.000 0.260
#> GSM872286     5  0.0790     0.8497 0.032 0.000 0.000 0.000 0.968 0.000
#> GSM872287     3  0.0000     0.9035 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872288     5  0.2980     0.7481 0.012 0.000 0.000 0.180 0.808 0.000
#> GSM872289     3  0.3221     0.7852 0.000 0.000 0.792 0.188 0.020 0.000
#> GSM872290     1  0.0000     0.9641 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM872291     6  0.0146     0.9401 0.000 0.000 0.000 0.004 0.000 0.996
#> GSM872292     2  0.1204     0.8533 0.000 0.944 0.000 0.056 0.000 0.000
#> GSM872293     1  0.0000     0.9641 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM872294     4  0.3247     0.7067 0.000 0.156 0.000 0.808 0.000 0.036
#> GSM872295     2  0.2491     0.7432 0.000 0.836 0.000 0.000 0.164 0.000
#> GSM872296     2  0.1204     0.8533 0.000 0.944 0.000 0.056 0.000 0.000
#> GSM872297     1  0.0000     0.9641 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM872298     6  0.0000     0.9410 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM872299     5  0.3843     0.2936 0.452 0.000 0.000 0.000 0.548 0.000
#> GSM872300     6  0.0000     0.9410 0.000 0.000 0.000 0.000 0.000 1.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

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>            n time(p) individual(p) k
#> CV:mclust 57   0.377      0.234717 2
#> CV:mclust 56   0.570      0.000723 3
#> CV:mclust 53   0.395      0.000170 4
#> CV:mclust 53   0.301      0.001181 5
#> CV:mclust 53   0.237      0.003681 6

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 29485 rows and 57 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 0.514           0.771       0.885         0.4721 0.491   0.491
#> 3 3 0.918           0.903       0.960         0.4103 0.677   0.437
#> 4 4 0.680           0.663       0.807         0.1151 0.888   0.679
#> 5 5 0.635           0.630       0.769         0.0697 0.873   0.574
#> 6 6 0.639           0.590       0.718         0.0447 0.886   0.537

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
#> GSM872244     1  0.3584     0.8565 0.932 0.068
#> GSM872245     2  0.7745     0.7703 0.228 0.772
#> GSM872246     1  0.0000     0.9055 1.000 0.000
#> GSM872247     1  0.0000     0.9055 1.000 0.000
#> GSM872248     2  0.0000     0.7990 0.000 1.000
#> GSM872249     1  0.2948     0.8714 0.948 0.052
#> GSM872250     2  0.7056     0.7759 0.192 0.808
#> GSM872251     1  0.0000     0.9055 1.000 0.000
#> GSM872252     2  0.9000     0.7304 0.316 0.684
#> GSM872253     1  0.2236     0.8886 0.964 0.036
#> GSM872254     2  0.0000     0.7990 0.000 1.000
#> GSM872255     1  0.0000     0.9055 1.000 0.000
#> GSM872256     2  0.9000     0.7304 0.316 0.684
#> GSM872257     2  0.0000     0.7990 0.000 1.000
#> GSM872258     1  0.0000     0.9055 1.000 0.000
#> GSM872259     2  0.9000     0.7304 0.316 0.684
#> GSM872260     1  0.9286     0.2800 0.656 0.344
#> GSM872261     2  0.6801     0.7787 0.180 0.820
#> GSM872262     1  0.0000     0.9055 1.000 0.000
#> GSM872263     1  0.1843     0.8893 0.972 0.028
#> GSM872264     1  0.0000     0.9055 1.000 0.000
#> GSM872265     1  0.9775     0.0133 0.588 0.412
#> GSM872266     2  0.0000     0.7990 0.000 1.000
#> GSM872267     2  0.0000     0.7990 0.000 1.000
#> GSM872268     1  0.0000     0.9055 1.000 0.000
#> GSM872269     2  0.0000     0.7990 0.000 1.000
#> GSM872270     1  0.2948     0.8714 0.948 0.052
#> GSM872271     2  0.0000     0.7990 0.000 1.000
#> GSM872272     2  0.0000     0.7990 0.000 1.000
#> GSM872273     2  0.9909     0.4692 0.444 0.556
#> GSM872274     2  0.0000     0.7990 0.000 1.000
#> GSM872275     1  0.3431     0.8605 0.936 0.064
#> GSM872276     1  0.0000     0.9055 1.000 0.000
#> GSM872277     1  0.9963    -0.2090 0.536 0.464
#> GSM872278     1  0.0000     0.9055 1.000 0.000
#> GSM872279     2  0.9000     0.7304 0.316 0.684
#> GSM872280     1  0.0000     0.9055 1.000 0.000
#> GSM872281     1  0.0000     0.9055 1.000 0.000
#> GSM872282     1  0.6531     0.7344 0.832 0.168
#> GSM872283     2  0.9427     0.6597 0.360 0.640
#> GSM872284     1  0.0000     0.9055 1.000 0.000
#> GSM872285     1  0.0000     0.9055 1.000 0.000
#> GSM872286     2  0.8813     0.7410 0.300 0.700
#> GSM872287     1  0.0000     0.9055 1.000 0.000
#> GSM872288     2  0.9044     0.7249 0.320 0.680
#> GSM872289     1  0.0000     0.9055 1.000 0.000
#> GSM872290     2  0.9000     0.7304 0.316 0.684
#> GSM872291     1  0.8813     0.4114 0.700 0.300
#> GSM872292     2  0.0000     0.7990 0.000 1.000
#> GSM872293     2  0.9000     0.7304 0.316 0.684
#> GSM872294     2  0.0000     0.7990 0.000 1.000
#> GSM872295     2  0.0000     0.7990 0.000 1.000
#> GSM872296     2  0.0000     0.7990 0.000 1.000
#> GSM872297     2  0.9000     0.7304 0.316 0.684
#> GSM872298     1  0.0000     0.9055 1.000 0.000
#> GSM872299     2  0.8813     0.7410 0.300 0.700
#> GSM872300     1  0.0376     0.9029 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
#> GSM872244     3  0.0000      0.987 0.000 0.000 1.000
#> GSM872245     1  0.1289      0.907 0.968 0.032 0.000
#> GSM872246     3  0.0000      0.987 0.000 0.000 1.000
#> GSM872247     3  0.0000      0.987 0.000 0.000 1.000
#> GSM872248     2  0.0000      0.945 0.000 1.000 0.000
#> GSM872249     3  0.0000      0.987 0.000 0.000 1.000
#> GSM872250     2  0.6111      0.414 0.396 0.604 0.000
#> GSM872251     3  0.0000      0.987 0.000 0.000 1.000
#> GSM872252     1  0.0000      0.933 1.000 0.000 0.000
#> GSM872253     3  0.3715      0.837 0.128 0.004 0.868
#> GSM872254     2  0.0892      0.933 0.020 0.980 0.000
#> GSM872255     1  0.0000      0.933 1.000 0.000 0.000
#> GSM872256     1  0.0000      0.933 1.000 0.000 0.000
#> GSM872257     2  0.0000      0.945 0.000 1.000 0.000
#> GSM872258     3  0.0000      0.987 0.000 0.000 1.000
#> GSM872259     1  0.0000      0.933 1.000 0.000 0.000
#> GSM872260     1  0.0000      0.933 1.000 0.000 0.000
#> GSM872261     2  0.5291      0.664 0.268 0.732 0.000
#> GSM872262     1  0.2711      0.871 0.912 0.000 0.088
#> GSM872263     3  0.0000      0.987 0.000 0.000 1.000
#> GSM872264     3  0.0000      0.987 0.000 0.000 1.000
#> GSM872265     1  0.6950      0.130 0.508 0.016 0.476
#> GSM872266     2  0.0000      0.945 0.000 1.000 0.000
#> GSM872267     2  0.0000      0.945 0.000 1.000 0.000
#> GSM872268     3  0.0000      0.987 0.000 0.000 1.000
#> GSM872269     2  0.2356      0.893 0.072 0.928 0.000
#> GSM872270     3  0.0000      0.987 0.000 0.000 1.000
#> GSM872271     2  0.0000      0.945 0.000 1.000 0.000
#> GSM872272     2  0.0000      0.945 0.000 1.000 0.000
#> GSM872273     1  0.0000      0.933 1.000 0.000 0.000
#> GSM872274     2  0.0000      0.945 0.000 1.000 0.000
#> GSM872275     3  0.0237      0.984 0.000 0.004 0.996
#> GSM872276     1  0.2066      0.895 0.940 0.000 0.060
#> GSM872277     1  0.0000      0.933 1.000 0.000 0.000
#> GSM872278     3  0.0000      0.987 0.000 0.000 1.000
#> GSM872279     1  0.0000      0.933 1.000 0.000 0.000
#> GSM872280     3  0.0000      0.987 0.000 0.000 1.000
#> GSM872281     3  0.2066      0.928 0.060 0.000 0.940
#> GSM872282     3  0.0000      0.987 0.000 0.000 1.000
#> GSM872283     1  0.1643      0.906 0.956 0.000 0.044
#> GSM872284     1  0.6286      0.199 0.536 0.000 0.464
#> GSM872285     3  0.0000      0.987 0.000 0.000 1.000
#> GSM872286     1  0.0000      0.933 1.000 0.000 0.000
#> GSM872287     3  0.0000      0.987 0.000 0.000 1.000
#> GSM872288     1  0.0000      0.933 1.000 0.000 0.000
#> GSM872289     3  0.0592      0.976 0.012 0.000 0.988
#> GSM872290     1  0.0000      0.933 1.000 0.000 0.000
#> GSM872291     1  0.0000      0.933 1.000 0.000 0.000
#> GSM872292     2  0.0000      0.945 0.000 1.000 0.000
#> GSM872293     1  0.0000      0.933 1.000 0.000 0.000
#> GSM872294     2  0.0000      0.945 0.000 1.000 0.000
#> GSM872295     2  0.0000      0.945 0.000 1.000 0.000
#> GSM872296     2  0.0000      0.945 0.000 1.000 0.000
#> GSM872297     1  0.0000      0.933 1.000 0.000 0.000
#> GSM872298     1  0.3482      0.832 0.872 0.000 0.128
#> GSM872299     1  0.0000      0.933 1.000 0.000 0.000
#> GSM872300     1  0.0237      0.931 0.996 0.000 0.004

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM872244     3  0.0707      0.849 0.000 0.000 0.980 0.020
#> GSM872245     1  0.0927      0.638 0.976 0.008 0.000 0.016
#> GSM872246     3  0.1211      0.867 0.000 0.000 0.960 0.040
#> GSM872247     3  0.2408      0.866 0.000 0.000 0.896 0.104
#> GSM872248     2  0.4426      0.729 0.204 0.772 0.000 0.024
#> GSM872249     3  0.0188      0.859 0.000 0.000 0.996 0.004
#> GSM872250     1  0.7186      0.175 0.600 0.116 0.260 0.024
#> GSM872251     3  0.0707      0.864 0.000 0.000 0.980 0.020
#> GSM872252     1  0.0000      0.653 1.000 0.000 0.000 0.000
#> GSM872253     3  0.2345      0.790 0.100 0.000 0.900 0.000
#> GSM872254     2  0.6814      0.634 0.300 0.604 0.072 0.024
#> GSM872255     1  0.4277      0.668 0.720 0.000 0.000 0.280
#> GSM872256     1  0.3942      0.704 0.764 0.000 0.000 0.236
#> GSM872257     2  0.0707      0.787 0.000 0.980 0.000 0.020
#> GSM872258     3  0.0921      0.865 0.000 0.000 0.972 0.028
#> GSM872259     1  0.3486      0.715 0.812 0.000 0.000 0.188
#> GSM872260     1  0.3975      0.702 0.760 0.000 0.000 0.240
#> GSM872261     2  0.5500      0.445 0.464 0.520 0.000 0.016
#> GSM872262     4  0.4585      0.427 0.332 0.000 0.000 0.668
#> GSM872263     3  0.0000      0.857 0.000 0.000 1.000 0.000
#> GSM872264     4  0.3052      0.460 0.000 0.004 0.136 0.860
#> GSM872265     4  0.2662      0.595 0.016 0.084 0.000 0.900
#> GSM872266     2  0.4678      0.716 0.232 0.744 0.000 0.024
#> GSM872267     2  0.0592      0.788 0.016 0.984 0.000 0.000
#> GSM872268     3  0.2530      0.865 0.000 0.000 0.888 0.112
#> GSM872269     2  0.6396      0.641 0.312 0.620 0.044 0.024
#> GSM872270     3  0.4040      0.817 0.000 0.000 0.752 0.248
#> GSM872271     2  0.4866      0.380 0.000 0.596 0.000 0.404
#> GSM872272     2  0.4877      0.373 0.000 0.592 0.000 0.408
#> GSM872273     1  0.4543      0.606 0.676 0.000 0.000 0.324
#> GSM872274     2  0.0336      0.786 0.000 0.992 0.000 0.008
#> GSM872275     3  0.3991      0.847 0.000 0.020 0.808 0.172
#> GSM872276     4  0.4999     -0.110 0.492 0.000 0.000 0.508
#> GSM872277     1  0.4585      0.592 0.668 0.000 0.000 0.332
#> GSM872278     3  0.4843      0.660 0.000 0.000 0.604 0.396
#> GSM872279     1  0.2149      0.691 0.912 0.000 0.000 0.088
#> GSM872280     3  0.6508      0.519 0.088 0.000 0.568 0.344
#> GSM872281     4  0.1356      0.622 0.008 0.000 0.032 0.960
#> GSM872282     3  0.4103      0.811 0.000 0.000 0.744 0.256
#> GSM872283     4  0.4663      0.502 0.272 0.012 0.000 0.716
#> GSM872284     4  0.2699      0.629 0.068 0.000 0.028 0.904
#> GSM872285     3  0.4248      0.827 0.012 0.000 0.768 0.220
#> GSM872286     1  0.1739      0.618 0.952 0.008 0.016 0.024
#> GSM872287     3  0.3688      0.839 0.000 0.000 0.792 0.208
#> GSM872288     1  0.2125      0.598 0.932 0.004 0.052 0.012
#> GSM872289     3  0.0817      0.848 0.024 0.000 0.976 0.000
#> GSM872290     1  0.3764      0.712 0.784 0.000 0.000 0.216
#> GSM872291     1  0.4382      0.649 0.704 0.000 0.000 0.296
#> GSM872292     2  0.0336      0.786 0.000 0.992 0.000 0.008
#> GSM872293     1  0.3528      0.715 0.808 0.000 0.000 0.192
#> GSM872294     2  0.1211      0.776 0.000 0.960 0.000 0.040
#> GSM872295     2  0.0188      0.787 0.000 0.996 0.000 0.004
#> GSM872296     2  0.1022      0.779 0.000 0.968 0.000 0.032
#> GSM872297     1  0.4277      0.669 0.720 0.000 0.000 0.280
#> GSM872298     4  0.4941      0.130 0.436 0.000 0.000 0.564
#> GSM872299     1  0.0188      0.651 0.996 0.004 0.000 0.000
#> GSM872300     1  0.4713      0.530 0.640 0.000 0.000 0.360

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM872244     3  0.3821     0.7443 0.000 0.000 0.764 0.216 0.020
#> GSM872245     5  0.1430     0.7166 0.052 0.000 0.000 0.004 0.944
#> GSM872246     3  0.1591     0.8022 0.004 0.000 0.940 0.052 0.004
#> GSM872247     3  0.1043     0.7991 0.000 0.000 0.960 0.040 0.000
#> GSM872248     5  0.2719     0.7113 0.000 0.144 0.000 0.004 0.852
#> GSM872249     3  0.3003     0.7671 0.000 0.000 0.812 0.188 0.000
#> GSM872250     5  0.6107     0.5479 0.020 0.000 0.132 0.232 0.616
#> GSM872251     3  0.2488     0.7917 0.000 0.000 0.872 0.124 0.004
#> GSM872252     1  0.2535     0.6816 0.892 0.000 0.000 0.076 0.032
#> GSM872253     3  0.7967     0.3343 0.276 0.016 0.404 0.256 0.048
#> GSM872254     2  0.7994     0.1644 0.012 0.432 0.068 0.252 0.236
#> GSM872255     1  0.1617     0.7269 0.948 0.000 0.012 0.020 0.020
#> GSM872256     1  0.3970     0.6871 0.788 0.000 0.000 0.056 0.156
#> GSM872257     2  0.0963     0.8134 0.000 0.964 0.000 0.000 0.036
#> GSM872258     3  0.3658     0.7863 0.044 0.000 0.832 0.112 0.012
#> GSM872259     1  0.4248     0.6303 0.728 0.000 0.000 0.032 0.240
#> GSM872260     1  0.1082     0.7208 0.964 0.000 0.000 0.028 0.008
#> GSM872261     2  0.6395     0.5303 0.212 0.624 0.000 0.064 0.100
#> GSM872262     4  0.5684    -0.0315 0.432 0.000 0.080 0.488 0.000
#> GSM872263     3  0.3789     0.7472 0.000 0.000 0.768 0.212 0.020
#> GSM872264     4  0.6245     0.5893 0.008 0.008 0.120 0.580 0.284
#> GSM872265     4  0.6425     0.6274 0.060 0.012 0.056 0.612 0.260
#> GSM872266     5  0.2228     0.7289 0.000 0.092 0.004 0.004 0.900
#> GSM872267     5  0.3366     0.6443 0.000 0.232 0.000 0.000 0.768
#> GSM872268     3  0.2074     0.7813 0.000 0.000 0.896 0.104 0.000
#> GSM872269     2  0.5409     0.6811 0.100 0.740 0.004 0.092 0.064
#> GSM872270     3  0.2416     0.7824 0.000 0.000 0.888 0.100 0.012
#> GSM872271     4  0.5695     0.2258 0.000 0.444 0.004 0.484 0.068
#> GSM872272     4  0.6607     0.4479 0.000 0.212 0.004 0.484 0.300
#> GSM872273     1  0.5470     0.4882 0.612 0.000 0.000 0.296 0.092
#> GSM872274     2  0.0290     0.8244 0.000 0.992 0.000 0.000 0.008
#> GSM872275     3  0.2929     0.7844 0.012 0.004 0.856 0.128 0.000
#> GSM872276     1  0.4445     0.5021 0.676 0.000 0.024 0.300 0.000
#> GSM872277     1  0.7031     0.0924 0.424 0.000 0.020 0.356 0.200
#> GSM872278     3  0.5762     0.4984 0.068 0.012 0.624 0.288 0.008
#> GSM872279     1  0.1582     0.7264 0.944 0.000 0.000 0.028 0.028
#> GSM872280     1  0.5650    -0.0642 0.464 0.000 0.460 0.076 0.000
#> GSM872281     4  0.5289     0.5440 0.096 0.000 0.228 0.672 0.004
#> GSM872282     3  0.2873     0.7967 0.000 0.000 0.856 0.128 0.016
#> GSM872283     4  0.6315     0.5423 0.060 0.012 0.024 0.528 0.376
#> GSM872284     4  0.6873     0.6103 0.084 0.000 0.180 0.592 0.144
#> GSM872285     3  0.3001     0.7551 0.004 0.000 0.844 0.144 0.008
#> GSM872286     5  0.4170     0.7029 0.108 0.004 0.004 0.084 0.800
#> GSM872287     3  0.2660     0.7661 0.000 0.000 0.864 0.128 0.008
#> GSM872288     5  0.4636     0.6958 0.108 0.000 0.024 0.092 0.776
#> GSM872289     3  0.4315     0.6931 0.000 0.000 0.700 0.276 0.024
#> GSM872290     1  0.0703     0.7275 0.976 0.000 0.000 0.000 0.024
#> GSM872291     1  0.1195     0.7245 0.960 0.000 0.000 0.028 0.012
#> GSM872292     2  0.0000     0.8242 0.000 1.000 0.000 0.000 0.000
#> GSM872293     1  0.2249     0.7191 0.896 0.000 0.000 0.008 0.096
#> GSM872294     2  0.0703     0.8182 0.000 0.976 0.000 0.024 0.000
#> GSM872295     2  0.0290     0.8244 0.000 0.992 0.000 0.000 0.008
#> GSM872296     2  0.1124     0.8087 0.000 0.960 0.000 0.036 0.004
#> GSM872297     1  0.5059     0.6182 0.696 0.000 0.000 0.112 0.192
#> GSM872298     1  0.5301     0.4432 0.648 0.000 0.076 0.272 0.004
#> GSM872299     1  0.3110     0.6815 0.860 0.000 0.000 0.080 0.060
#> GSM872300     1  0.5149     0.5754 0.696 0.000 0.044 0.232 0.028

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM872244     3  0.4720     0.7505 0.000 0.000 0.700 0.016 0.084 0.200
#> GSM872245     5  0.5780     0.2045 0.388 0.000 0.000 0.116 0.480 0.016
#> GSM872246     3  0.1873     0.8353 0.000 0.000 0.924 0.008 0.020 0.048
#> GSM872247     3  0.1323     0.8279 0.020 0.000 0.956 0.008 0.008 0.008
#> GSM872248     5  0.3570     0.7133 0.012 0.076 0.000 0.076 0.828 0.008
#> GSM872249     3  0.2884     0.8243 0.000 0.000 0.864 0.008 0.064 0.064
#> GSM872250     5  0.4078     0.6661 0.036 0.000 0.032 0.012 0.792 0.128
#> GSM872251     3  0.2789     0.8314 0.008 0.000 0.880 0.012 0.064 0.036
#> GSM872252     6  0.4072     0.5077 0.260 0.000 0.000 0.032 0.004 0.704
#> GSM872253     6  0.4722     0.4371 0.020 0.008 0.136 0.080 0.008 0.748
#> GSM872254     6  0.6466    -0.0222 0.008 0.236 0.008 0.004 0.292 0.452
#> GSM872255     1  0.3401     0.5087 0.820 0.000 0.028 0.004 0.012 0.136
#> GSM872256     1  0.4191     0.5450 0.752 0.000 0.004 0.004 0.164 0.076
#> GSM872257     2  0.1700     0.8919 0.000 0.916 0.000 0.004 0.080 0.000
#> GSM872258     3  0.4197     0.6466 0.016 0.000 0.676 0.008 0.004 0.296
#> GSM872259     1  0.4712     0.5592 0.732 0.000 0.000 0.084 0.144 0.040
#> GSM872260     6  0.4212     0.3989 0.392 0.000 0.000 0.008 0.008 0.592
#> GSM872261     6  0.7046     0.4566 0.092 0.240 0.000 0.060 0.076 0.532
#> GSM872262     1  0.6466     0.1417 0.500 0.000 0.116 0.316 0.004 0.064
#> GSM872263     3  0.3982     0.7892 0.000 0.000 0.764 0.004 0.076 0.156
#> GSM872264     4  0.2884     0.6522 0.036 0.004 0.016 0.872 0.072 0.000
#> GSM872265     4  0.3910     0.6525 0.088 0.028 0.020 0.824 0.032 0.008
#> GSM872266     5  0.2878     0.7220 0.020 0.028 0.000 0.076 0.872 0.004
#> GSM872267     5  0.4954     0.5794 0.004 0.232 0.000 0.100 0.660 0.004
#> GSM872268     3  0.2095     0.8113 0.052 0.000 0.916 0.016 0.004 0.012
#> GSM872269     6  0.5603     0.0832 0.008 0.416 0.004 0.000 0.096 0.476
#> GSM872270     3  0.2038     0.8265 0.000 0.000 0.920 0.032 0.020 0.028
#> GSM872271     4  0.4239     0.6118 0.000 0.148 0.004 0.764 0.068 0.016
#> GSM872272     4  0.4356     0.5603 0.000 0.084 0.000 0.740 0.164 0.012
#> GSM872273     1  0.3625     0.6184 0.820 0.000 0.016 0.120 0.028 0.016
#> GSM872274     2  0.0146     0.9587 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM872275     3  0.6139     0.5813 0.064 0.000 0.652 0.152 0.064 0.068
#> GSM872276     1  0.6228     0.1863 0.516 0.000 0.040 0.292 0.000 0.152
#> GSM872277     1  0.5042     0.5175 0.672 0.000 0.008 0.212 0.100 0.008
#> GSM872278     4  0.5760     0.5394 0.028 0.008 0.172 0.640 0.004 0.148
#> GSM872279     1  0.3784     0.2267 0.680 0.000 0.000 0.000 0.012 0.308
#> GSM872280     6  0.7517     0.0198 0.300 0.000 0.280 0.112 0.004 0.304
#> GSM872281     4  0.6645     0.4240 0.184 0.000 0.224 0.528 0.012 0.052
#> GSM872282     3  0.3739     0.7977 0.000 0.000 0.796 0.024 0.036 0.144
#> GSM872283     4  0.3652     0.6295 0.092 0.008 0.004 0.824 0.064 0.008
#> GSM872284     4  0.6099     0.5202 0.180 0.000 0.120 0.628 0.028 0.044
#> GSM872285     3  0.2931     0.7920 0.056 0.000 0.876 0.024 0.008 0.036
#> GSM872286     5  0.3587     0.6616 0.188 0.000 0.000 0.000 0.772 0.040
#> GSM872287     3  0.2189     0.8139 0.028 0.000 0.916 0.024 0.004 0.028
#> GSM872288     5  0.5553     0.6512 0.104 0.000 0.012 0.056 0.680 0.148
#> GSM872289     3  0.4293     0.7778 0.000 0.000 0.740 0.008 0.084 0.168
#> GSM872290     6  0.4520     0.3087 0.448 0.000 0.000 0.032 0.000 0.520
#> GSM872291     6  0.5138     0.4658 0.268 0.000 0.000 0.128 0.000 0.604
#> GSM872292     2  0.0146     0.9584 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM872293     1  0.2842     0.5564 0.852 0.000 0.000 0.000 0.044 0.104
#> GSM872294     2  0.0696     0.9565 0.004 0.980 0.000 0.004 0.004 0.008
#> GSM872295     2  0.0405     0.9578 0.000 0.988 0.000 0.000 0.008 0.004
#> GSM872296     2  0.1471     0.9091 0.000 0.932 0.000 0.064 0.000 0.004
#> GSM872297     1  0.4013     0.5880 0.768 0.000 0.000 0.124 0.104 0.004
#> GSM872298     4  0.6751     0.2787 0.172 0.000 0.092 0.500 0.000 0.236
#> GSM872299     6  0.4045     0.3714 0.428 0.000 0.000 0.000 0.008 0.564
#> GSM872300     1  0.4616     0.5279 0.760 0.000 0.092 0.084 0.004 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-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

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>         n time(p) individual(p) k
#> CV:NMF 52   0.588      7.25e-03 2
#> CV:NMF 54   0.341      3.30e-02 3
#> CV:NMF 49   0.547      4.18e-03 4
#> CV:NMF 47   0.637      3.51e-04 5
#> CV:NMF 42   0.335      7.74e-06 6

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 29485 rows and 57 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 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-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.323           0.640       0.833         0.3993 0.623   0.623
#> 3 3 0.584           0.722       0.871         0.4510 0.751   0.625
#> 4 4 0.480           0.575       0.734         0.1451 0.977   0.951
#> 5 5 0.656           0.699       0.842         0.1413 0.774   0.514
#> 6 6 0.733           0.612       0.779         0.0708 0.894   0.614

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
#> GSM872244     1  0.9933      0.396 0.548 0.452
#> GSM872245     1  0.7139      0.667 0.804 0.196
#> GSM872246     1  0.8327      0.652 0.736 0.264
#> GSM872247     1  0.9933      0.396 0.548 0.452
#> GSM872248     2  0.0000      0.771 0.000 1.000
#> GSM872249     1  0.9933      0.396 0.548 0.452
#> GSM872250     1  0.0376      0.767 0.996 0.004
#> GSM872251     1  0.9933      0.396 0.548 0.452
#> GSM872252     1  0.0376      0.767 0.996 0.004
#> GSM872253     1  0.5294      0.735 0.880 0.120
#> GSM872254     2  0.1633      0.767 0.024 0.976
#> GSM872255     1  0.0000      0.769 1.000 0.000
#> GSM872256     1  0.0000      0.769 1.000 0.000
#> GSM872257     2  0.0000      0.771 0.000 1.000
#> GSM872258     1  0.8327      0.652 0.736 0.264
#> GSM872259     1  0.0000      0.769 1.000 0.000
#> GSM872260     1  0.0000      0.769 1.000 0.000
#> GSM872261     2  0.9866      0.231 0.432 0.568
#> GSM872262     1  0.0000      0.769 1.000 0.000
#> GSM872263     1  0.9933      0.396 0.548 0.452
#> GSM872264     1  0.8861      0.599 0.696 0.304
#> GSM872265     1  0.8861      0.599 0.696 0.304
#> GSM872266     2  0.9580      0.329 0.380 0.620
#> GSM872267     2  0.0000      0.771 0.000 1.000
#> GSM872268     1  0.9933      0.396 0.548 0.452
#> GSM872269     2  0.7602      0.579 0.220 0.780
#> GSM872270     1  0.9933      0.396 0.548 0.452
#> GSM872271     2  0.9866      0.229 0.432 0.568
#> GSM872272     2  0.9866      0.229 0.432 0.568
#> GSM872273     1  0.0000      0.769 1.000 0.000
#> GSM872274     2  0.0000      0.771 0.000 1.000
#> GSM872275     1  0.7815      0.659 0.768 0.232
#> GSM872276     1  0.0000      0.769 1.000 0.000
#> GSM872277     1  0.0000      0.769 1.000 0.000
#> GSM872278     1  0.6343      0.719 0.840 0.160
#> GSM872279     1  0.0376      0.767 0.996 0.004
#> GSM872280     1  0.0000      0.769 1.000 0.000
#> GSM872281     1  0.2603      0.761 0.956 0.044
#> GSM872282     1  0.9933      0.396 0.548 0.452
#> GSM872283     1  0.8861      0.599 0.696 0.304
#> GSM872284     1  0.8763      0.609 0.704 0.296
#> GSM872285     1  0.8081      0.668 0.752 0.248
#> GSM872286     1  0.0376      0.767 0.996 0.004
#> GSM872287     1  0.9933      0.396 0.548 0.452
#> GSM872288     1  0.0376      0.767 0.996 0.004
#> GSM872289     1  0.8386      0.648 0.732 0.268
#> GSM872290     1  0.0376      0.767 0.996 0.004
#> GSM872291     1  0.0000      0.769 1.000 0.000
#> GSM872292     2  0.0000      0.771 0.000 1.000
#> GSM872293     1  0.0000      0.769 1.000 0.000
#> GSM872294     2  0.8955      0.499 0.312 0.688
#> GSM872295     2  0.1633      0.767 0.024 0.976
#> GSM872296     2  0.0000      0.771 0.000 1.000
#> GSM872297     1  0.0000      0.769 1.000 0.000
#> GSM872298     1  0.6343      0.719 0.840 0.160
#> GSM872299     1  0.0376      0.767 0.996 0.004
#> GSM872300     1  0.0000      0.769 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
#> GSM872244     3  0.0000    1.00000 0.000 0.000 1.000
#> GSM872245     1  0.4733    0.65446 0.800 0.196 0.004
#> GSM872246     1  0.6299    0.30257 0.524 0.000 0.476
#> GSM872247     3  0.0000    1.00000 0.000 0.000 1.000
#> GSM872248     2  0.0000    0.78737 0.000 1.000 0.000
#> GSM872249     3  0.0000    1.00000 0.000 0.000 1.000
#> GSM872250     1  0.0475    0.81963 0.992 0.004 0.004
#> GSM872251     3  0.0000    1.00000 0.000 0.000 1.000
#> GSM872252     1  0.0475    0.81963 0.992 0.004 0.004
#> GSM872253     1  0.3619    0.76955 0.864 0.000 0.136
#> GSM872254     2  0.1129    0.78257 0.020 0.976 0.004
#> GSM872255     1  0.0237    0.82163 0.996 0.000 0.004
#> GSM872256     1  0.0000    0.82094 1.000 0.000 0.000
#> GSM872257     2  0.0000    0.78737 0.000 1.000 0.000
#> GSM872258     1  0.6299    0.30257 0.524 0.000 0.476
#> GSM872259     1  0.0000    0.82094 1.000 0.000 0.000
#> GSM872260     1  0.0237    0.82163 0.996 0.000 0.004
#> GSM872261     2  0.9024    0.05546 0.420 0.448 0.132
#> GSM872262     1  0.0892    0.82059 0.980 0.000 0.020
#> GSM872263     3  0.0000    1.00000 0.000 0.000 1.000
#> GSM872264     1  0.5810    0.61888 0.664 0.000 0.336
#> GSM872265     1  0.5810    0.61888 0.664 0.000 0.336
#> GSM872266     2  0.8936    0.21411 0.368 0.500 0.132
#> GSM872267     2  0.0000    0.78737 0.000 1.000 0.000
#> GSM872268     3  0.0000    1.00000 0.000 0.000 1.000
#> GSM872269     2  0.4978    0.62093 0.216 0.780 0.004
#> GSM872270     3  0.0000    1.00000 0.000 0.000 1.000
#> GSM872271     1  0.9778   -0.00557 0.408 0.356 0.236
#> GSM872272     1  0.9778   -0.00557 0.408 0.356 0.236
#> GSM872273     1  0.0000    0.82094 1.000 0.000 0.000
#> GSM872274     2  0.0000    0.78737 0.000 1.000 0.000
#> GSM872275     1  0.6662    0.69336 0.736 0.072 0.192
#> GSM872276     1  0.0892    0.82059 0.980 0.000 0.020
#> GSM872277     1  0.0000    0.82094 1.000 0.000 0.000
#> GSM872278     1  0.4399    0.74490 0.812 0.000 0.188
#> GSM872279     1  0.0475    0.81963 0.992 0.004 0.004
#> GSM872280     1  0.1031    0.82005 0.976 0.000 0.024
#> GSM872281     1  0.2165    0.80772 0.936 0.000 0.064
#> GSM872282     3  0.0000    1.00000 0.000 0.000 1.000
#> GSM872283     1  0.5810    0.61888 0.664 0.000 0.336
#> GSM872284     1  0.5760    0.62874 0.672 0.000 0.328
#> GSM872285     1  0.6244    0.41502 0.560 0.000 0.440
#> GSM872286     1  0.0475    0.81963 0.992 0.004 0.004
#> GSM872287     3  0.0000    1.00000 0.000 0.000 1.000
#> GSM872288     1  0.0475    0.81963 0.992 0.004 0.004
#> GSM872289     1  0.6302    0.29160 0.520 0.000 0.480
#> GSM872290     1  0.0475    0.81963 0.992 0.004 0.004
#> GSM872291     1  0.0237    0.82154 0.996 0.000 0.004
#> GSM872292     2  0.0000    0.78737 0.000 1.000 0.000
#> GSM872293     1  0.0000    0.82094 1.000 0.000 0.000
#> GSM872294     2  0.9072    0.35226 0.300 0.532 0.168
#> GSM872295     2  0.1129    0.78257 0.020 0.976 0.004
#> GSM872296     2  0.0000    0.78737 0.000 1.000 0.000
#> GSM872297     1  0.0000    0.82094 1.000 0.000 0.000
#> GSM872298     1  0.4399    0.74490 0.812 0.000 0.188
#> GSM872299     1  0.0475    0.81963 0.992 0.004 0.004
#> GSM872300     1  0.0892    0.82059 0.980 0.000 0.020

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM872244     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM872245     1  0.7283      0.465 0.524 0.292 0.000 0.184
#> GSM872246     1  0.4967      0.315 0.548 0.000 0.452 0.000
#> GSM872247     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM872248     2  0.4999      0.885 0.000 0.508 0.000 0.492
#> GSM872249     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM872250     1  0.4989      0.548 0.528 0.472 0.000 0.000
#> GSM872251     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM872252     1  0.4989      0.548 0.528 0.472 0.000 0.000
#> GSM872253     1  0.4046      0.543 0.828 0.048 0.124 0.000
#> GSM872254     2  0.5000      0.871 0.000 0.504 0.000 0.496
#> GSM872255     1  0.0817      0.611 0.976 0.024 0.000 0.000
#> GSM872256     1  0.4331      0.602 0.712 0.288 0.000 0.000
#> GSM872257     2  0.4999      0.885 0.000 0.508 0.000 0.492
#> GSM872258     1  0.4967      0.315 0.548 0.000 0.452 0.000
#> GSM872259     1  0.4522      0.599 0.680 0.320 0.000 0.000
#> GSM872260     1  0.0707      0.610 0.980 0.020 0.000 0.000
#> GSM872261     4  0.8174      0.364 0.388 0.048 0.124 0.440
#> GSM872262     1  0.0469      0.609 0.988 0.012 0.000 0.000
#> GSM872263     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM872264     1  0.5108      0.439 0.672 0.020 0.308 0.000
#> GSM872265     1  0.5108      0.439 0.672 0.020 0.308 0.000
#> GSM872266     4  0.7961      0.438 0.344 0.040 0.124 0.492
#> GSM872267     2  0.4999      0.885 0.000 0.508 0.000 0.492
#> GSM872268     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM872269     2  0.4769      0.620 0.008 0.684 0.000 0.308
#> GSM872270     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM872271     1  0.8406     -0.346 0.400 0.028 0.216 0.356
#> GSM872272     1  0.8406     -0.346 0.400 0.028 0.216 0.356
#> GSM872273     1  0.4522      0.599 0.680 0.320 0.000 0.000
#> GSM872274     4  0.0000      0.107 0.000 0.000 0.000 1.000
#> GSM872275     1  0.5855      0.431 0.736 0.028 0.164 0.072
#> GSM872276     1  0.0469      0.609 0.988 0.012 0.000 0.000
#> GSM872277     1  0.4522      0.599 0.680 0.320 0.000 0.000
#> GSM872278     1  0.3402      0.531 0.832 0.004 0.164 0.000
#> GSM872279     1  0.4989      0.548 0.528 0.472 0.000 0.000
#> GSM872280     1  0.0188      0.607 0.996 0.004 0.000 0.000
#> GSM872281     1  0.1767      0.606 0.944 0.012 0.044 0.000
#> GSM872282     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM872283     1  0.5108      0.439 0.672 0.020 0.308 0.000
#> GSM872284     1  0.5062      0.444 0.680 0.020 0.300 0.000
#> GSM872285     1  0.4898      0.338 0.584 0.000 0.416 0.000
#> GSM872286     1  0.4989      0.548 0.528 0.472 0.000 0.000
#> GSM872287     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM872288     1  0.4989      0.548 0.528 0.472 0.000 0.000
#> GSM872289     1  0.4972      0.309 0.544 0.000 0.456 0.000
#> GSM872290     1  0.4989      0.548 0.528 0.472 0.000 0.000
#> GSM872291     1  0.1022      0.611 0.968 0.032 0.000 0.000
#> GSM872292     4  0.0000      0.107 0.000 0.000 0.000 1.000
#> GSM872293     1  0.4522      0.599 0.680 0.320 0.000 0.000
#> GSM872294     4  0.7687      0.457 0.288 0.020 0.160 0.532
#> GSM872295     2  0.5000      0.871 0.000 0.504 0.000 0.496
#> GSM872296     4  0.0000      0.107 0.000 0.000 0.000 1.000
#> GSM872297     1  0.4522      0.599 0.680 0.320 0.000 0.000
#> GSM872298     1  0.3402      0.531 0.832 0.004 0.164 0.000
#> GSM872299     1  0.4989      0.548 0.528 0.472 0.000 0.000
#> GSM872300     1  0.0469      0.609 0.988 0.012 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM872244     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000
#> GSM872245     1  0.3333     0.7570 0.788 0.004 0.000 0.000 0.208
#> GSM872246     4  0.4278     0.2589 0.000 0.000 0.452 0.548 0.000
#> GSM872247     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000
#> GSM872248     5  0.0510     0.9126 0.000 0.016 0.000 0.000 0.984
#> GSM872249     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000
#> GSM872250     1  0.0510     0.8847 0.984 0.000 0.000 0.000 0.016
#> GSM872251     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000
#> GSM872252     1  0.0290     0.8875 0.992 0.000 0.000 0.000 0.008
#> GSM872253     4  0.0794     0.6256 0.028 0.000 0.000 0.972 0.000
#> GSM872254     5  0.1281     0.9018 0.012 0.032 0.000 0.000 0.956
#> GSM872255     4  0.3455     0.6287 0.208 0.008 0.000 0.784 0.000
#> GSM872256     1  0.3691     0.8326 0.804 0.040 0.000 0.156 0.000
#> GSM872257     5  0.0510     0.9126 0.000 0.016 0.000 0.000 0.984
#> GSM872258     4  0.4278     0.2589 0.000 0.000 0.452 0.548 0.000
#> GSM872259     1  0.3620     0.8688 0.824 0.068 0.000 0.108 0.000
#> GSM872260     4  0.3421     0.6312 0.204 0.008 0.000 0.788 0.000
#> GSM872261     4  0.6583    -0.0381 0.012 0.256 0.000 0.532 0.200
#> GSM872262     4  0.3231     0.6350 0.196 0.004 0.000 0.800 0.000
#> GSM872263     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000
#> GSM872264     4  0.3086     0.5754 0.000 0.004 0.180 0.816 0.000
#> GSM872265     4  0.3086     0.5754 0.000 0.004 0.180 0.816 0.000
#> GSM872266     4  0.6730    -0.1259 0.008 0.260 0.000 0.488 0.244
#> GSM872267     5  0.0510     0.9126 0.000 0.016 0.000 0.000 0.984
#> GSM872268     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000
#> GSM872269     5  0.4010     0.6947 0.208 0.032 0.000 0.000 0.760
#> GSM872270     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000
#> GSM872271     4  0.6821     0.0688 0.008 0.308 0.092 0.544 0.048
#> GSM872272     4  0.6821     0.0688 0.008 0.308 0.092 0.544 0.048
#> GSM872273     1  0.3620     0.8688 0.824 0.068 0.000 0.108 0.000
#> GSM872274     2  0.1608     0.7701 0.000 0.928 0.000 0.000 0.072
#> GSM872275     4  0.2916     0.5903 0.008 0.072 0.040 0.880 0.000
#> GSM872276     4  0.3266     0.6332 0.200 0.004 0.000 0.796 0.000
#> GSM872277     1  0.3620     0.8688 0.824 0.068 0.000 0.108 0.000
#> GSM872278     4  0.2569     0.6457 0.068 0.000 0.040 0.892 0.000
#> GSM872279     1  0.0290     0.8875 0.992 0.000 0.000 0.000 0.008
#> GSM872280     4  0.3160     0.6377 0.188 0.004 0.000 0.808 0.000
#> GSM872281     4  0.4290     0.6427 0.196 0.004 0.044 0.756 0.000
#> GSM872282     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000
#> GSM872283     4  0.3086     0.5754 0.000 0.004 0.180 0.816 0.000
#> GSM872284     4  0.3010     0.5800 0.000 0.004 0.172 0.824 0.000
#> GSM872285     4  0.5420     0.3538 0.060 0.000 0.416 0.524 0.000
#> GSM872286     1  0.0510     0.8847 0.984 0.000 0.000 0.000 0.016
#> GSM872287     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000
#> GSM872288     1  0.0510     0.8847 0.984 0.000 0.000 0.000 0.016
#> GSM872289     4  0.4283     0.2495 0.000 0.000 0.456 0.544 0.000
#> GSM872290     1  0.0290     0.8875 0.992 0.000 0.000 0.000 0.008
#> GSM872291     4  0.3430     0.6236 0.220 0.004 0.000 0.776 0.000
#> GSM872292     2  0.1608     0.7701 0.000 0.928 0.000 0.000 0.072
#> GSM872293     1  0.3620     0.8688 0.824 0.068 0.000 0.108 0.000
#> GSM872294     2  0.7463     0.2012 0.084 0.480 0.036 0.348 0.052
#> GSM872295     5  0.1281     0.9018 0.012 0.032 0.000 0.000 0.956
#> GSM872296     2  0.1608     0.7701 0.000 0.928 0.000 0.000 0.072
#> GSM872297     1  0.3620     0.8688 0.824 0.068 0.000 0.108 0.000
#> GSM872298     4  0.2569     0.6457 0.068 0.000 0.040 0.892 0.000
#> GSM872299     1  0.0290     0.8875 0.992 0.000 0.000 0.000 0.008
#> GSM872300     4  0.3231     0.6350 0.196 0.004 0.000 0.800 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
#> GSM872244     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872245     1  0.2933      0.565 0.796 0.000 0.000 0.000 0.200 0.004
#> GSM872246     6  0.4165      0.341 0.000 0.000 0.452 0.012 0.000 0.536
#> GSM872247     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872248     5  0.0806      0.911 0.000 0.008 0.000 0.020 0.972 0.000
#> GSM872249     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872250     1  0.0260      0.716 0.992 0.000 0.000 0.000 0.008 0.000
#> GSM872251     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872252     1  0.0000      0.719 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM872253     6  0.3454      0.545 0.024 0.000 0.000 0.208 0.000 0.768
#> GSM872254     5  0.1787      0.900 0.020 0.016 0.000 0.032 0.932 0.000
#> GSM872255     6  0.0976      0.712 0.016 0.008 0.000 0.008 0.000 0.968
#> GSM872256     1  0.6108      0.119 0.376 0.304 0.000 0.000 0.000 0.320
#> GSM872257     5  0.0806      0.911 0.000 0.008 0.000 0.020 0.972 0.000
#> GSM872258     6  0.4165      0.341 0.000 0.000 0.452 0.012 0.000 0.536
#> GSM872259     1  0.5724      0.281 0.456 0.376 0.000 0.000 0.000 0.168
#> GSM872260     6  0.1078      0.713 0.016 0.008 0.000 0.012 0.000 0.964
#> GSM872261     4  0.4229      0.526 0.008 0.000 0.000 0.732 0.200 0.060
#> GSM872262     6  0.0000      0.717 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM872263     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872264     4  0.5661      0.550 0.000 0.008 0.140 0.532 0.000 0.320
#> GSM872265     4  0.5661      0.550 0.000 0.008 0.140 0.532 0.000 0.320
#> GSM872266     4  0.3682      0.460 0.004 0.004 0.000 0.752 0.224 0.016
#> GSM872267     5  0.0806      0.911 0.000 0.008 0.000 0.020 0.972 0.000
#> GSM872268     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872269     5  0.4091      0.710 0.216 0.016 0.000 0.032 0.736 0.000
#> GSM872270     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872271     4  0.2938      0.575 0.004 0.004 0.056 0.868 0.004 0.064
#> GSM872272     4  0.2938      0.575 0.004 0.004 0.056 0.868 0.004 0.064
#> GSM872273     2  0.6025     -0.328 0.372 0.384 0.000 0.000 0.000 0.244
#> GSM872274     2  0.3774      0.366 0.000 0.592 0.000 0.408 0.000 0.000
#> GSM872275     6  0.3892      0.313 0.004 0.000 0.004 0.352 0.000 0.640
#> GSM872276     6  0.0146      0.716 0.000 0.004 0.000 0.000 0.000 0.996
#> GSM872277     1  0.5724      0.281 0.456 0.376 0.000 0.000 0.000 0.168
#> GSM872278     6  0.2913      0.594 0.004 0.000 0.004 0.180 0.000 0.812
#> GSM872279     1  0.0000      0.719 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM872280     6  0.0260      0.717 0.000 0.000 0.000 0.008 0.000 0.992
#> GSM872281     6  0.1124      0.703 0.000 0.000 0.008 0.036 0.000 0.956
#> GSM872282     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872283     4  0.5661      0.550 0.000 0.008 0.140 0.532 0.000 0.320
#> GSM872284     4  0.5632      0.532 0.000 0.008 0.132 0.528 0.000 0.332
#> GSM872285     6  0.4116      0.391 0.000 0.000 0.416 0.012 0.000 0.572
#> GSM872286     1  0.0260      0.716 0.992 0.000 0.000 0.000 0.008 0.000
#> GSM872287     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872288     1  0.0260      0.716 0.992 0.000 0.000 0.000 0.008 0.000
#> GSM872289     6  0.4169      0.331 0.000 0.000 0.456 0.012 0.000 0.532
#> GSM872290     1  0.0000      0.719 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM872291     6  0.0692      0.708 0.020 0.004 0.000 0.000 0.000 0.976
#> GSM872292     2  0.3774      0.366 0.000 0.592 0.000 0.408 0.000 0.000
#> GSM872293     2  0.6025     -0.328 0.372 0.384 0.000 0.000 0.000 0.244
#> GSM872294     4  0.5793      0.175 0.004 0.124 0.020 0.568 0.000 0.284
#> GSM872295     5  0.1787      0.900 0.020 0.016 0.000 0.032 0.932 0.000
#> GSM872296     2  0.3774      0.366 0.000 0.592 0.000 0.408 0.000 0.000
#> GSM872297     1  0.5724      0.281 0.456 0.376 0.000 0.000 0.000 0.168
#> GSM872298     6  0.2913      0.594 0.004 0.000 0.004 0.180 0.000 0.812
#> GSM872299     1  0.0000      0.719 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM872300     6  0.0000      0.717 0.000 0.000 0.000 0.000 0.000 1.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-hclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-hclust-collect-classes

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>             n time(p) individual(p) k
#> MAD:hclust 43   0.959      0.123137 2
#> MAD:hclust 48   0.929      0.000304 3
#> MAD:hclust 39   0.833      0.000595 4
#> MAD:hclust 48   0.698      0.000124 5
#> MAD:hclust 41   0.728      0.000110 6

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 29485 rows and 57 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 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-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.151           0.341       0.580         0.4740 0.526   0.526
#> 3 3 0.790           0.876       0.940         0.4016 0.737   0.534
#> 4 4 0.630           0.425       0.661         0.1206 0.900   0.715
#> 5 5 0.683           0.589       0.737         0.0674 0.826   0.448
#> 6 6 0.703           0.616       0.753         0.0427 0.905   0.584

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
#> GSM872244     2  0.3584     0.4311 0.068 0.932
#> GSM872245     1  0.6712     0.3693 0.824 0.176
#> GSM872246     2  0.7528     0.6678 0.216 0.784
#> GSM872247     2  0.6973     0.6739 0.188 0.812
#> GSM872248     1  0.9909     0.2329 0.556 0.444
#> GSM872249     2  0.5842     0.6519 0.140 0.860
#> GSM872250     1  0.9248     0.2671 0.660 0.340
#> GSM872251     2  0.7453     0.6699 0.212 0.788
#> GSM872252     1  0.5842     0.4372 0.860 0.140
#> GSM872253     2  0.8207     0.6118 0.256 0.744
#> GSM872254     1  0.9881     0.2373 0.564 0.436
#> GSM872255     1  0.9732     0.1349 0.596 0.404
#> GSM872256     1  0.5842     0.4372 0.860 0.140
#> GSM872257     1  0.9933     0.2238 0.548 0.452
#> GSM872258     2  0.7674     0.6613 0.224 0.776
#> GSM872259     1  0.5842     0.4372 0.860 0.140
#> GSM872260     1  0.9686     0.1474 0.604 0.396
#> GSM872261     1  0.9491     0.2635 0.632 0.368
#> GSM872262     1  0.9775     0.1202 0.588 0.412
#> GSM872263     2  0.6887     0.6735 0.184 0.816
#> GSM872264     2  0.7745     0.5355 0.228 0.772
#> GSM872265     1  0.9983     0.0796 0.524 0.476
#> GSM872266     1  0.9909     0.2329 0.556 0.444
#> GSM872267     1  0.9909     0.2329 0.556 0.444
#> GSM872268     2  0.7528     0.6678 0.216 0.784
#> GSM872269     1  0.9087     0.2763 0.676 0.324
#> GSM872270     2  0.4431     0.6104 0.092 0.908
#> GSM872271     1  1.0000     0.1605 0.500 0.500
#> GSM872272     2  1.0000    -0.2227 0.500 0.500
#> GSM872273     1  0.8443     0.3228 0.728 0.272
#> GSM872274     1  1.0000     0.1660 0.504 0.496
#> GSM872275     2  0.7453     0.6491 0.212 0.788
#> GSM872276     1  0.9775     0.1202 0.588 0.412
#> GSM872277     1  0.8443     0.3228 0.728 0.272
#> GSM872278     2  0.7883     0.6468 0.236 0.764
#> GSM872279     1  0.5842     0.4372 0.860 0.140
#> GSM872280     2  0.9909     0.1903 0.444 0.556
#> GSM872281     1  0.9983    -0.0487 0.524 0.476
#> GSM872282     2  0.3431     0.4357 0.064 0.936
#> GSM872283     1  0.9087     0.2767 0.676 0.324
#> GSM872284     1  0.9881     0.0711 0.564 0.436
#> GSM872285     2  0.7815     0.6515 0.232 0.768
#> GSM872286     1  0.0672     0.4220 0.992 0.008
#> GSM872287     2  0.7299     0.6720 0.204 0.796
#> GSM872288     1  0.8555     0.3135 0.720 0.280
#> GSM872289     2  0.7745     0.6571 0.228 0.772
#> GSM872290     1  0.5842     0.4372 0.860 0.140
#> GSM872291     1  0.9580     0.1746 0.620 0.380
#> GSM872292     2  1.0000    -0.2171 0.496 0.504
#> GSM872293     1  0.5842     0.4372 0.860 0.140
#> GSM872294     1  0.9460     0.2876 0.636 0.364
#> GSM872295     1  0.9977     0.1973 0.528 0.472
#> GSM872296     2  1.0000    -0.2171 0.496 0.504
#> GSM872297     1  0.5842     0.4372 0.860 0.140
#> GSM872298     1  0.9833     0.0918 0.576 0.424
#> GSM872299     1  0.0672     0.4220 0.992 0.008
#> GSM872300     1  0.9732     0.1349 0.596 0.404

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM872244     3  0.2796      0.884 0.000 0.092 0.908
#> GSM872245     1  0.5810      0.463 0.664 0.336 0.000
#> GSM872246     3  0.0000      0.964 0.000 0.000 1.000
#> GSM872247     3  0.0000      0.964 0.000 0.000 1.000
#> GSM872248     2  0.0000      0.953 0.000 1.000 0.000
#> GSM872249     3  0.0000      0.964 0.000 0.000 1.000
#> GSM872250     2  0.4504      0.792 0.196 0.804 0.000
#> GSM872251     3  0.0000      0.964 0.000 0.000 1.000
#> GSM872252     1  0.0000      0.896 1.000 0.000 0.000
#> GSM872253     3  0.2261      0.904 0.068 0.000 0.932
#> GSM872254     2  0.0000      0.953 0.000 1.000 0.000
#> GSM872255     1  0.0237      0.896 0.996 0.000 0.004
#> GSM872256     1  0.0000      0.896 1.000 0.000 0.000
#> GSM872257     2  0.0000      0.953 0.000 1.000 0.000
#> GSM872258     3  0.0000      0.964 0.000 0.000 1.000
#> GSM872259     1  0.0000      0.896 1.000 0.000 0.000
#> GSM872260     1  0.0000      0.896 1.000 0.000 0.000
#> GSM872261     2  0.4399      0.803 0.188 0.812 0.000
#> GSM872262     1  0.2711      0.863 0.912 0.000 0.088
#> GSM872263     3  0.0000      0.964 0.000 0.000 1.000
#> GSM872264     1  0.6305      0.189 0.516 0.000 0.484
#> GSM872265     1  0.5058      0.717 0.756 0.000 0.244
#> GSM872266     2  0.0000      0.953 0.000 1.000 0.000
#> GSM872267     2  0.0000      0.953 0.000 1.000 0.000
#> GSM872268     3  0.0000      0.964 0.000 0.000 1.000
#> GSM872269     2  0.4605      0.782 0.204 0.796 0.000
#> GSM872270     3  0.0000      0.964 0.000 0.000 1.000
#> GSM872271     2  0.0424      0.950 0.008 0.992 0.000
#> GSM872272     2  0.0424      0.950 0.008 0.992 0.000
#> GSM872273     1  0.0000      0.896 1.000 0.000 0.000
#> GSM872274     2  0.0000      0.953 0.000 1.000 0.000
#> GSM872275     3  0.0424      0.959 0.008 0.000 0.992
#> GSM872276     1  0.2711      0.863 0.912 0.000 0.088
#> GSM872277     1  0.0000      0.896 1.000 0.000 0.000
#> GSM872278     3  0.0424      0.959 0.008 0.000 0.992
#> GSM872279     1  0.0000      0.896 1.000 0.000 0.000
#> GSM872280     3  0.5058      0.656 0.244 0.000 0.756
#> GSM872281     1  0.5016      0.722 0.760 0.000 0.240
#> GSM872282     3  0.2796      0.884 0.000 0.092 0.908
#> GSM872283     1  0.3116      0.850 0.892 0.000 0.108
#> GSM872284     1  0.4974      0.726 0.764 0.000 0.236
#> GSM872285     3  0.0000      0.964 0.000 0.000 1.000
#> GSM872286     1  0.4178      0.743 0.828 0.172 0.000
#> GSM872287     3  0.0000      0.964 0.000 0.000 1.000
#> GSM872288     1  0.0424      0.892 0.992 0.008 0.000
#> GSM872289     3  0.0237      0.962 0.004 0.000 0.996
#> GSM872290     1  0.0000      0.896 1.000 0.000 0.000
#> GSM872291     1  0.0000      0.896 1.000 0.000 0.000
#> GSM872292     2  0.0000      0.953 0.000 1.000 0.000
#> GSM872293     1  0.0000      0.896 1.000 0.000 0.000
#> GSM872294     2  0.0424      0.950 0.008 0.992 0.000
#> GSM872295     2  0.0000      0.953 0.000 1.000 0.000
#> GSM872296     2  0.0000      0.953 0.000 1.000 0.000
#> GSM872297     1  0.0000      0.896 1.000 0.000 0.000
#> GSM872298     1  0.2796      0.861 0.908 0.000 0.092
#> GSM872299     1  0.4062      0.751 0.836 0.164 0.000
#> GSM872300     1  0.0747      0.893 0.984 0.000 0.016

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM872244     3  0.0592     0.9116 0.000 0.000 0.984 0.016
#> GSM872245     1  0.7030    -0.1218 0.472 0.408 0.000 0.120
#> GSM872246     3  0.0188     0.9147 0.000 0.000 0.996 0.004
#> GSM872247     3  0.0469     0.9150 0.000 0.000 0.988 0.012
#> GSM872248     2  0.0376     0.6238 0.004 0.992 0.000 0.004
#> GSM872249     3  0.0707     0.9131 0.000 0.000 0.980 0.020
#> GSM872250     2  0.7006     0.1225 0.428 0.456 0.000 0.116
#> GSM872251     3  0.0336     0.9152 0.000 0.000 0.992 0.008
#> GSM872252     1  0.6386     0.3232 0.648 0.140 0.000 0.212
#> GSM872253     3  0.4718     0.6814 0.004 0.008 0.716 0.272
#> GSM872254     2  0.5637     0.4836 0.168 0.720 0.000 0.112
#> GSM872255     1  0.4898     0.0683 0.584 0.000 0.000 0.416
#> GSM872256     1  0.2216     0.4147 0.908 0.000 0.000 0.092
#> GSM872257     2  0.4331     0.5829 0.000 0.712 0.000 0.288
#> GSM872258     3  0.0188     0.9138 0.000 0.000 0.996 0.004
#> GSM872259     1  0.0188     0.4533 0.996 0.000 0.000 0.004
#> GSM872260     1  0.4477     0.2313 0.688 0.000 0.000 0.312
#> GSM872261     2  0.7628     0.2581 0.260 0.472 0.000 0.268
#> GSM872262     1  0.5088     0.0410 0.572 0.000 0.004 0.424
#> GSM872263     3  0.0469     0.9125 0.000 0.000 0.988 0.012
#> GSM872264     4  0.7587     0.3452 0.292 0.000 0.232 0.476
#> GSM872265     4  0.6898     0.3454 0.360 0.000 0.116 0.524
#> GSM872266     2  0.0657     0.6226 0.004 0.984 0.000 0.012
#> GSM872267     2  0.0376     0.6238 0.004 0.992 0.000 0.004
#> GSM872268     3  0.0469     0.9150 0.000 0.000 0.988 0.012
#> GSM872269     2  0.6400     0.3910 0.252 0.632 0.000 0.116
#> GSM872270     3  0.0336     0.9152 0.000 0.000 0.992 0.008
#> GSM872271     4  0.5512    -0.4205 0.016 0.492 0.000 0.492
#> GSM872272     2  0.5512     0.2825 0.016 0.492 0.000 0.492
#> GSM872273     1  0.4331     0.2479 0.712 0.000 0.000 0.288
#> GSM872274     2  0.4697     0.5502 0.000 0.644 0.000 0.356
#> GSM872275     3  0.4049     0.7316 0.000 0.008 0.780 0.212
#> GSM872276     1  0.5088     0.0410 0.572 0.000 0.004 0.424
#> GSM872277     1  0.4331     0.2479 0.712 0.000 0.000 0.288
#> GSM872278     3  0.4406     0.6031 0.000 0.000 0.700 0.300
#> GSM872279     1  0.2385     0.4345 0.920 0.028 0.000 0.052
#> GSM872280     4  0.7702     0.2422 0.260 0.000 0.288 0.452
#> GSM872281     4  0.6599     0.2438 0.432 0.000 0.080 0.488
#> GSM872282     3  0.1389     0.8941 0.000 0.000 0.952 0.048
#> GSM872283     4  0.5535     0.2267 0.420 0.000 0.020 0.560
#> GSM872284     4  0.6599     0.2502 0.432 0.000 0.080 0.488
#> GSM872285     3  0.3266     0.7802 0.000 0.000 0.832 0.168
#> GSM872286     1  0.7030    -0.1218 0.472 0.408 0.000 0.120
#> GSM872287     3  0.0469     0.9150 0.000 0.000 0.988 0.012
#> GSM872288     1  0.6995    -0.0782 0.496 0.384 0.000 0.120
#> GSM872289     3  0.1211     0.8930 0.000 0.000 0.960 0.040
#> GSM872290     1  0.0336     0.4530 0.992 0.000 0.000 0.008
#> GSM872291     1  0.4916     0.0491 0.576 0.000 0.000 0.424
#> GSM872292     2  0.4697     0.5502 0.000 0.644 0.000 0.356
#> GSM872293     1  0.0188     0.4533 0.996 0.000 0.000 0.004
#> GSM872294     4  0.4948    -0.4229 0.000 0.440 0.000 0.560
#> GSM872295     2  0.4382     0.5807 0.000 0.704 0.000 0.296
#> GSM872296     2  0.4898     0.4962 0.000 0.584 0.000 0.416
#> GSM872297     1  0.0469     0.4521 0.988 0.000 0.000 0.012
#> GSM872298     1  0.5406    -0.1488 0.508 0.000 0.012 0.480
#> GSM872299     1  0.6839     0.0361 0.552 0.328 0.000 0.120
#> GSM872300     1  0.5088     0.0410 0.572 0.000 0.004 0.424

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM872244     3  0.1990      0.834 0.000 0.004 0.928 0.028 0.040
#> GSM872245     5  0.4522      0.452 0.440 0.000 0.000 0.008 0.552
#> GSM872246     3  0.0290      0.862 0.000 0.000 0.992 0.008 0.000
#> GSM872247     3  0.0451      0.862 0.000 0.004 0.988 0.008 0.000
#> GSM872248     5  0.4777      0.459 0.008 0.356 0.000 0.016 0.620
#> GSM872249     3  0.0324      0.859 0.000 0.004 0.992 0.000 0.004
#> GSM872250     5  0.3521      0.692 0.232 0.000 0.000 0.004 0.764
#> GSM872251     3  0.0671      0.861 0.000 0.004 0.980 0.016 0.000
#> GSM872252     1  0.5973      0.321 0.580 0.000 0.000 0.164 0.256
#> GSM872253     3  0.7767      0.190 0.016 0.032 0.408 0.280 0.264
#> GSM872254     5  0.5052      0.675 0.100 0.144 0.000 0.020 0.736
#> GSM872255     4  0.5390      0.386 0.420 0.000 0.008 0.532 0.040
#> GSM872256     1  0.2068      0.687 0.904 0.000 0.000 0.092 0.004
#> GSM872257     2  0.2864      0.602 0.000 0.852 0.000 0.012 0.136
#> GSM872258     3  0.2293      0.819 0.000 0.000 0.900 0.084 0.016
#> GSM872259     1  0.1106      0.743 0.964 0.000 0.000 0.024 0.012
#> GSM872260     4  0.5505      0.265 0.452 0.000 0.000 0.484 0.064
#> GSM872261     5  0.6505      0.526 0.172 0.056 0.000 0.152 0.620
#> GSM872262     4  0.4183      0.551 0.324 0.000 0.008 0.668 0.000
#> GSM872263     3  0.1830      0.837 0.000 0.000 0.932 0.028 0.040
#> GSM872264     4  0.6560      0.444 0.064 0.096 0.032 0.668 0.140
#> GSM872265     4  0.6541      0.451 0.068 0.096 0.028 0.668 0.140
#> GSM872266     5  0.4653      0.486 0.008 0.324 0.000 0.016 0.652
#> GSM872267     5  0.4777      0.459 0.008 0.356 0.000 0.016 0.620
#> GSM872268     3  0.0451      0.862 0.000 0.004 0.988 0.008 0.000
#> GSM872269     5  0.4686      0.700 0.188 0.052 0.000 0.016 0.744
#> GSM872270     3  0.0324      0.861 0.000 0.004 0.992 0.004 0.000
#> GSM872271     2  0.6634      0.415 0.004 0.452 0.000 0.348 0.196
#> GSM872272     2  0.6634      0.415 0.004 0.452 0.000 0.348 0.196
#> GSM872273     1  0.3684      0.400 0.720 0.000 0.000 0.280 0.000
#> GSM872274     2  0.0771      0.706 0.000 0.976 0.000 0.004 0.020
#> GSM872275     3  0.7183      0.260 0.008 0.040 0.484 0.332 0.136
#> GSM872276     4  0.4201      0.547 0.328 0.000 0.008 0.664 0.000
#> GSM872277     1  0.3990      0.363 0.688 0.000 0.000 0.308 0.004
#> GSM872278     4  0.6444      0.165 0.008 0.020 0.328 0.548 0.096
#> GSM872279     1  0.1197      0.726 0.952 0.000 0.000 0.000 0.048
#> GSM872280     4  0.5662      0.553 0.132 0.000 0.144 0.692 0.032
#> GSM872281     4  0.2951      0.615 0.084 0.004 0.016 0.880 0.016
#> GSM872282     3  0.3005      0.802 0.000 0.048 0.884 0.028 0.040
#> GSM872283     4  0.6076      0.461 0.076 0.096 0.004 0.684 0.140
#> GSM872284     4  0.3529      0.603 0.076 0.016 0.016 0.860 0.032
#> GSM872285     3  0.4329      0.520 0.000 0.000 0.672 0.312 0.016
#> GSM872286     5  0.4047      0.629 0.320 0.000 0.000 0.004 0.676
#> GSM872287     3  0.0451      0.862 0.000 0.004 0.988 0.008 0.000
#> GSM872288     5  0.3809      0.676 0.256 0.000 0.000 0.008 0.736
#> GSM872289     3  0.1997      0.840 0.000 0.000 0.924 0.036 0.040
#> GSM872290     1  0.1211      0.742 0.960 0.000 0.000 0.016 0.024
#> GSM872291     4  0.5206      0.396 0.428 0.000 0.000 0.528 0.044
#> GSM872292     2  0.0771      0.706 0.000 0.976 0.000 0.004 0.020
#> GSM872293     1  0.0693      0.744 0.980 0.000 0.000 0.012 0.008
#> GSM872294     2  0.5076      0.628 0.004 0.712 0.000 0.128 0.156
#> GSM872295     2  0.2625      0.638 0.000 0.876 0.000 0.016 0.108
#> GSM872296     2  0.1484      0.706 0.000 0.944 0.000 0.008 0.048
#> GSM872297     1  0.1251      0.739 0.956 0.000 0.000 0.036 0.008
#> GSM872298     4  0.3928      0.611 0.176 0.000 0.008 0.788 0.028
#> GSM872299     1  0.4666     -0.189 0.572 0.000 0.000 0.016 0.412
#> GSM872300     4  0.4183      0.551 0.324 0.000 0.008 0.668 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
#> GSM872244     3  0.3695     0.8294 0.008 0.004 0.832 0.068 0.024 0.064
#> GSM872245     5  0.4899     0.3325 0.356 0.000 0.000 0.036 0.588 0.020
#> GSM872246     3  0.1610     0.8803 0.020 0.004 0.944 0.004 0.004 0.024
#> GSM872247     3  0.0291     0.8915 0.004 0.000 0.992 0.000 0.000 0.004
#> GSM872248     5  0.4968     0.5410 0.000 0.208 0.000 0.060 0.688 0.044
#> GSM872249     3  0.0291     0.8905 0.004 0.000 0.992 0.000 0.000 0.004
#> GSM872250     5  0.1327     0.7320 0.064 0.000 0.000 0.000 0.936 0.000
#> GSM872251     3  0.1592     0.8736 0.016 0.000 0.944 0.012 0.004 0.024
#> GSM872252     6  0.7315     0.0543 0.204 0.000 0.000 0.136 0.256 0.404
#> GSM872253     6  0.7399     0.2558 0.020 0.004 0.140 0.232 0.124 0.480
#> GSM872254     5  0.3565     0.6975 0.004 0.028 0.000 0.080 0.832 0.056
#> GSM872255     6  0.3528     0.5038 0.296 0.000 0.000 0.004 0.000 0.700
#> GSM872256     1  0.1444     0.7837 0.928 0.000 0.000 0.000 0.000 0.072
#> GSM872257     2  0.3496     0.7863 0.000 0.836 0.000 0.056 0.056 0.052
#> GSM872258     3  0.4601     0.4963 0.016 0.004 0.664 0.016 0.008 0.292
#> GSM872259     1  0.1408     0.8159 0.944 0.000 0.000 0.020 0.036 0.000
#> GSM872260     6  0.4111     0.4805 0.296 0.000 0.000 0.024 0.004 0.676
#> GSM872261     5  0.6577     0.2810 0.044 0.000 0.000 0.204 0.460 0.292
#> GSM872262     6  0.4750     0.4522 0.244 0.000 0.000 0.100 0.000 0.656
#> GSM872263     3  0.3695     0.8294 0.008 0.004 0.832 0.068 0.024 0.064
#> GSM872264     4  0.4502     0.7318 0.040 0.016 0.004 0.720 0.004 0.216
#> GSM872265     4  0.4502     0.7318 0.040 0.016 0.004 0.720 0.004 0.216
#> GSM872266     5  0.4605     0.5885 0.000 0.160 0.000 0.060 0.736 0.044
#> GSM872267     5  0.4994     0.5358 0.000 0.212 0.000 0.060 0.684 0.044
#> GSM872268     3  0.0291     0.8915 0.004 0.000 0.992 0.000 0.000 0.004
#> GSM872269     5  0.4266     0.6926 0.040 0.012 0.000 0.076 0.792 0.080
#> GSM872270     3  0.0000     0.8914 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872271     4  0.4492     0.4906 0.000 0.216 0.000 0.712 0.020 0.052
#> GSM872272     4  0.4492     0.4906 0.000 0.216 0.000 0.712 0.020 0.052
#> GSM872273     1  0.2593     0.6972 0.844 0.000 0.000 0.008 0.000 0.148
#> GSM872274     2  0.0260     0.8638 0.000 0.992 0.000 0.008 0.000 0.000
#> GSM872275     6  0.6858     0.1720 0.020 0.000 0.288 0.288 0.016 0.388
#> GSM872276     6  0.4729     0.4537 0.248 0.000 0.000 0.096 0.000 0.656
#> GSM872277     1  0.3275     0.7019 0.816 0.000 0.000 0.036 0.004 0.144
#> GSM872278     6  0.6264     0.1198 0.020 0.000 0.152 0.340 0.008 0.480
#> GSM872279     1  0.2713     0.7841 0.880 0.000 0.000 0.016 0.052 0.052
#> GSM872280     6  0.4079     0.4879 0.096 0.000 0.084 0.032 0.000 0.788
#> GSM872281     4  0.4876     0.4533 0.048 0.000 0.004 0.504 0.000 0.444
#> GSM872282     3  0.4449     0.8024 0.008 0.040 0.796 0.068 0.024 0.064
#> GSM872283     4  0.4390     0.7308 0.040 0.016 0.000 0.720 0.004 0.220
#> GSM872284     4  0.4830     0.5838 0.044 0.000 0.004 0.580 0.004 0.368
#> GSM872285     6  0.4959    -0.0118 0.016 0.000 0.472 0.020 0.008 0.484
#> GSM872286     5  0.1918     0.7242 0.088 0.000 0.000 0.008 0.904 0.000
#> GSM872287     3  0.0291     0.8915 0.004 0.000 0.992 0.000 0.000 0.004
#> GSM872288     5  0.1501     0.7311 0.076 0.000 0.000 0.000 0.924 0.000
#> GSM872289     3  0.3936     0.7784 0.016 0.004 0.808 0.016 0.040 0.116
#> GSM872290     1  0.2341     0.7988 0.900 0.000 0.000 0.012 0.032 0.056
#> GSM872291     6  0.3636     0.4874 0.320 0.000 0.000 0.004 0.000 0.676
#> GSM872292     2  0.0260     0.8638 0.000 0.992 0.000 0.008 0.000 0.000
#> GSM872293     1  0.0790     0.8166 0.968 0.000 0.000 0.000 0.032 0.000
#> GSM872294     2  0.4909     0.5174 0.004 0.644 0.000 0.288 0.020 0.044
#> GSM872295     2  0.3426     0.8078 0.000 0.840 0.000 0.064 0.048 0.048
#> GSM872296     2  0.0632     0.8572 0.000 0.976 0.000 0.024 0.000 0.000
#> GSM872297     1  0.1408     0.8159 0.944 0.000 0.000 0.020 0.036 0.000
#> GSM872298     6  0.3678     0.4041 0.084 0.000 0.000 0.128 0.000 0.788
#> GSM872299     1  0.6302    -0.1530 0.432 0.000 0.000 0.064 0.408 0.096
#> GSM872300     6  0.4750     0.4522 0.244 0.000 0.000 0.100 0.000 0.656

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

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>             n time(p) individual(p) k
#> MAD:kmeans 15      NA            NA 2
#> MAD:kmeans 55   0.507      1.11e-02 3
#> MAD:kmeans 23   0.779      1.17e-01 4
#> MAD:kmeans 38   0.730      2.09e-04 5
#> MAD:kmeans 38   0.626      2.18e-05 6

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 29485 rows and 57 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 0.407           0.816       0.857         0.5083 0.492   0.492
#> 3 3 0.943           0.927       0.969         0.3308 0.706   0.469
#> 4 4 0.798           0.805       0.890         0.1215 0.826   0.526
#> 5 5 0.771           0.698       0.850         0.0531 0.872   0.546
#> 6 6 0.790           0.727       0.846         0.0400 0.937   0.712

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
#> GSM872244     1   0.855      0.831 0.720 0.280
#> GSM872245     2   0.706      0.834 0.192 0.808
#> GSM872246     1   0.706      0.855 0.808 0.192
#> GSM872247     1   0.833      0.841 0.736 0.264
#> GSM872248     2   0.000      0.812 0.000 1.000
#> GSM872249     1   0.855      0.831 0.720 0.280
#> GSM872250     2   0.506      0.837 0.112 0.888
#> GSM872251     1   0.827      0.843 0.740 0.260
#> GSM872252     2   0.855      0.822 0.280 0.720
#> GSM872253     1   0.494      0.848 0.892 0.108
#> GSM872254     2   0.343      0.827 0.064 0.936
#> GSM872255     1   0.000      0.816 1.000 0.000
#> GSM872256     2   0.855      0.822 0.280 0.720
#> GSM872257     2   0.000      0.812 0.000 1.000
#> GSM872258     1   0.625      0.856 0.844 0.156
#> GSM872259     2   0.855      0.822 0.280 0.720
#> GSM872260     1   0.000      0.816 1.000 0.000
#> GSM872261     2   0.506      0.837 0.112 0.888
#> GSM872262     1   0.000      0.816 1.000 0.000
#> GSM872263     1   0.833      0.841 0.736 0.264
#> GSM872264     1   0.814      0.838 0.748 0.252
#> GSM872265     2   0.963      0.248 0.388 0.612
#> GSM872266     2   0.000      0.812 0.000 1.000
#> GSM872267     2   0.000      0.812 0.000 1.000
#> GSM872268     1   0.706      0.855 0.808 0.192
#> GSM872269     2   0.689      0.831 0.184 0.816
#> GSM872270     1   0.855      0.831 0.720 0.280
#> GSM872271     2   0.000      0.812 0.000 1.000
#> GSM872272     2   0.000      0.812 0.000 1.000
#> GSM872273     2   0.891      0.804 0.308 0.692
#> GSM872274     2   0.000      0.812 0.000 1.000
#> GSM872275     1   0.855      0.831 0.720 0.280
#> GSM872276     1   0.000      0.816 1.000 0.000
#> GSM872277     2   0.891      0.804 0.308 0.692
#> GSM872278     1   0.839      0.839 0.732 0.268
#> GSM872279     2   0.855      0.822 0.280 0.720
#> GSM872280     1   0.000      0.816 1.000 0.000
#> GSM872281     1   0.343      0.839 0.936 0.064
#> GSM872282     1   0.855      0.831 0.720 0.280
#> GSM872283     2   0.595      0.829 0.144 0.856
#> GSM872284     1   0.343      0.839 0.936 0.064
#> GSM872285     1   0.343      0.842 0.936 0.064
#> GSM872286     2   0.850      0.823 0.276 0.724
#> GSM872287     1   0.833      0.841 0.736 0.264
#> GSM872288     2   0.833      0.826 0.264 0.736
#> GSM872289     1   0.494      0.848 0.892 0.108
#> GSM872290     2   0.855      0.822 0.280 0.720
#> GSM872291     1   0.000      0.816 1.000 0.000
#> GSM872292     2   0.000      0.812 0.000 1.000
#> GSM872293     2   0.855      0.822 0.280 0.720
#> GSM872294     2   0.327      0.824 0.060 0.940
#> GSM872295     2   0.000      0.812 0.000 1.000
#> GSM872296     2   0.000      0.812 0.000 1.000
#> GSM872297     2   0.855      0.822 0.280 0.720
#> GSM872298     1   0.000      0.816 1.000 0.000
#> GSM872299     2   0.855      0.822 0.280 0.720
#> GSM872300     1   0.000      0.816 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
#> GSM872244     3  0.0424      0.941 0.000 0.008 0.992
#> GSM872245     2  0.0237      0.972 0.004 0.996 0.000
#> GSM872246     3  0.0000      0.947 0.000 0.000 1.000
#> GSM872247     3  0.0000      0.947 0.000 0.000 1.000
#> GSM872248     2  0.0000      0.974 0.000 1.000 0.000
#> GSM872249     3  0.0000      0.947 0.000 0.000 1.000
#> GSM872250     2  0.0424      0.970 0.008 0.992 0.000
#> GSM872251     3  0.0000      0.947 0.000 0.000 1.000
#> GSM872252     1  0.2878      0.885 0.904 0.096 0.000
#> GSM872253     3  0.0424      0.941 0.008 0.000 0.992
#> GSM872254     2  0.0000      0.974 0.000 1.000 0.000
#> GSM872255     1  0.0000      0.977 1.000 0.000 0.000
#> GSM872256     1  0.0000      0.977 1.000 0.000 0.000
#> GSM872257     2  0.0000      0.974 0.000 1.000 0.000
#> GSM872258     3  0.0000      0.947 0.000 0.000 1.000
#> GSM872259     1  0.0000      0.977 1.000 0.000 0.000
#> GSM872260     1  0.0000      0.977 1.000 0.000 0.000
#> GSM872261     2  0.0000      0.974 0.000 1.000 0.000
#> GSM872262     1  0.0237      0.976 0.996 0.000 0.004
#> GSM872263     3  0.0000      0.947 0.000 0.000 1.000
#> GSM872264     3  0.7059      0.104 0.460 0.020 0.520
#> GSM872265     1  0.5883      0.783 0.796 0.112 0.092
#> GSM872266     2  0.0000      0.974 0.000 1.000 0.000
#> GSM872267     2  0.0000      0.974 0.000 1.000 0.000
#> GSM872268     3  0.0000      0.947 0.000 0.000 1.000
#> GSM872269     2  0.0424      0.970 0.008 0.992 0.000
#> GSM872270     3  0.0000      0.947 0.000 0.000 1.000
#> GSM872271     2  0.0000      0.974 0.000 1.000 0.000
#> GSM872272     2  0.0000      0.974 0.000 1.000 0.000
#> GSM872273     1  0.0000      0.977 1.000 0.000 0.000
#> GSM872274     2  0.0000      0.974 0.000 1.000 0.000
#> GSM872275     3  0.0000      0.947 0.000 0.000 1.000
#> GSM872276     1  0.0237      0.976 0.996 0.000 0.004
#> GSM872277     1  0.0000      0.977 1.000 0.000 0.000
#> GSM872278     3  0.0000      0.947 0.000 0.000 1.000
#> GSM872279     1  0.0000      0.977 1.000 0.000 0.000
#> GSM872280     3  0.6026      0.400 0.376 0.000 0.624
#> GSM872281     1  0.1529      0.949 0.960 0.000 0.040
#> GSM872282     3  0.0424      0.941 0.000 0.008 0.992
#> GSM872283     1  0.1031      0.962 0.976 0.024 0.000
#> GSM872284     1  0.1529      0.949 0.960 0.000 0.040
#> GSM872285     3  0.0000      0.947 0.000 0.000 1.000
#> GSM872286     2  0.3482      0.855 0.128 0.872 0.000
#> GSM872287     3  0.0000      0.947 0.000 0.000 1.000
#> GSM872288     2  0.1031      0.958 0.024 0.976 0.000
#> GSM872289     3  0.0000      0.947 0.000 0.000 1.000
#> GSM872290     1  0.0000      0.977 1.000 0.000 0.000
#> GSM872291     1  0.0000      0.977 1.000 0.000 0.000
#> GSM872292     2  0.0000      0.974 0.000 1.000 0.000
#> GSM872293     1  0.0000      0.977 1.000 0.000 0.000
#> GSM872294     2  0.0000      0.974 0.000 1.000 0.000
#> GSM872295     2  0.0000      0.974 0.000 1.000 0.000
#> GSM872296     2  0.0000      0.974 0.000 1.000 0.000
#> GSM872297     1  0.0000      0.977 1.000 0.000 0.000
#> GSM872298     1  0.0424      0.973 0.992 0.000 0.008
#> GSM872299     2  0.5431      0.622 0.284 0.716 0.000
#> GSM872300     1  0.0000      0.977 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM872244     3  0.0000     0.9968 0.000 0.000 1.000 0.000
#> GSM872245     1  0.0188     0.7384 0.996 0.004 0.000 0.000
#> GSM872246     3  0.0000     0.9968 0.000 0.000 1.000 0.000
#> GSM872247     3  0.0000     0.9968 0.000 0.000 1.000 0.000
#> GSM872248     2  0.3801     0.8279 0.220 0.780 0.000 0.000
#> GSM872249     3  0.0000     0.9968 0.000 0.000 1.000 0.000
#> GSM872250     1  0.0336     0.7346 0.992 0.008 0.000 0.000
#> GSM872251     3  0.0000     0.9968 0.000 0.000 1.000 0.000
#> GSM872252     1  0.2469     0.7749 0.892 0.000 0.000 0.108
#> GSM872253     3  0.0921     0.9720 0.028 0.000 0.972 0.000
#> GSM872254     2  0.4877     0.6095 0.408 0.592 0.000 0.000
#> GSM872255     4  0.0592     0.8239 0.016 0.000 0.000 0.984
#> GSM872256     1  0.4866     0.5767 0.596 0.000 0.000 0.404
#> GSM872257     2  0.3649     0.8330 0.204 0.796 0.000 0.000
#> GSM872258     3  0.0000     0.9968 0.000 0.000 1.000 0.000
#> GSM872259     1  0.4103     0.7524 0.744 0.000 0.000 0.256
#> GSM872260     1  0.4877     0.5688 0.592 0.000 0.000 0.408
#> GSM872261     2  0.4866     0.6136 0.404 0.596 0.000 0.000
#> GSM872262     4  0.0000     0.8324 0.000 0.000 0.000 1.000
#> GSM872263     3  0.0000     0.9968 0.000 0.000 1.000 0.000
#> GSM872264     4  0.4817     0.5181 0.000 0.388 0.000 0.612
#> GSM872265     4  0.4817     0.5181 0.000 0.388 0.000 0.612
#> GSM872266     2  0.3801     0.8279 0.220 0.780 0.000 0.000
#> GSM872267     2  0.3764     0.8297 0.216 0.784 0.000 0.000
#> GSM872268     3  0.0000     0.9968 0.000 0.000 1.000 0.000
#> GSM872269     1  0.4543     0.0731 0.676 0.324 0.000 0.000
#> GSM872270     3  0.0000     0.9968 0.000 0.000 1.000 0.000
#> GSM872271     2  0.0000     0.8326 0.000 1.000 0.000 0.000
#> GSM872272     2  0.0000     0.8326 0.000 1.000 0.000 0.000
#> GSM872273     4  0.0336     0.8293 0.008 0.000 0.000 0.992
#> GSM872274     2  0.0188     0.8341 0.004 0.996 0.000 0.000
#> GSM872275     3  0.0336     0.9908 0.000 0.008 0.992 0.000
#> GSM872276     4  0.0000     0.8324 0.000 0.000 0.000 1.000
#> GSM872277     4  0.0336     0.8291 0.008 0.000 0.000 0.992
#> GSM872278     3  0.0000     0.9968 0.000 0.000 1.000 0.000
#> GSM872279     1  0.3975     0.7581 0.760 0.000 0.000 0.240
#> GSM872280     4  0.4830     0.3373 0.000 0.000 0.392 0.608
#> GSM872281     4  0.0469     0.8301 0.000 0.012 0.000 0.988
#> GSM872282     3  0.0469     0.9872 0.000 0.012 0.988 0.000
#> GSM872283     4  0.4790     0.5300 0.000 0.380 0.000 0.620
#> GSM872284     4  0.2011     0.7965 0.000 0.080 0.000 0.920
#> GSM872285     3  0.0000     0.9968 0.000 0.000 1.000 0.000
#> GSM872286     1  0.0000     0.7411 1.000 0.000 0.000 0.000
#> GSM872287     3  0.0000     0.9968 0.000 0.000 1.000 0.000
#> GSM872288     1  0.0000     0.7411 1.000 0.000 0.000 0.000
#> GSM872289     3  0.0000     0.9968 0.000 0.000 1.000 0.000
#> GSM872290     1  0.4103     0.7524 0.744 0.000 0.000 0.256
#> GSM872291     4  0.0592     0.8238 0.016 0.000 0.000 0.984
#> GSM872292     2  0.0188     0.8341 0.004 0.996 0.000 0.000
#> GSM872293     1  0.4250     0.7395 0.724 0.000 0.000 0.276
#> GSM872294     2  0.0000     0.8326 0.000 1.000 0.000 0.000
#> GSM872295     2  0.3649     0.8330 0.204 0.796 0.000 0.000
#> GSM872296     2  0.0000     0.8326 0.000 1.000 0.000 0.000
#> GSM872297     1  0.4250     0.7395 0.724 0.000 0.000 0.276
#> GSM872298     4  0.0000     0.8324 0.000 0.000 0.000 1.000
#> GSM872299     1  0.0000     0.7411 1.000 0.000 0.000 0.000
#> GSM872300     4  0.0000     0.8324 0.000 0.000 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM872244     3  0.0290     0.9191 0.000 0.008 0.992 0.000 0.000
#> GSM872245     5  0.2179     0.6756 0.100 0.000 0.000 0.004 0.896
#> GSM872246     3  0.0000     0.9226 0.000 0.000 1.000 0.000 0.000
#> GSM872247     3  0.0000     0.9226 0.000 0.000 1.000 0.000 0.000
#> GSM872248     5  0.3913     0.5285 0.000 0.324 0.000 0.000 0.676
#> GSM872249     3  0.0000     0.9226 0.000 0.000 1.000 0.000 0.000
#> GSM872250     5  0.0510     0.7300 0.000 0.016 0.000 0.000 0.984
#> GSM872251     3  0.0000     0.9226 0.000 0.000 1.000 0.000 0.000
#> GSM872252     1  0.4029     0.6053 0.680 0.004 0.000 0.000 0.316
#> GSM872253     3  0.3731     0.8129 0.036 0.060 0.844 0.000 0.060
#> GSM872254     5  0.2813     0.6687 0.000 0.168 0.000 0.000 0.832
#> GSM872255     1  0.2605     0.6448 0.852 0.000 0.000 0.148 0.000
#> GSM872256     1  0.2674     0.8172 0.856 0.000 0.000 0.004 0.140
#> GSM872257     2  0.2891     0.6863 0.000 0.824 0.000 0.000 0.176
#> GSM872258     3  0.0000     0.9226 0.000 0.000 1.000 0.000 0.000
#> GSM872259     1  0.2806     0.8163 0.844 0.000 0.000 0.004 0.152
#> GSM872260     1  0.2719     0.6552 0.852 0.000 0.000 0.144 0.004
#> GSM872261     2  0.4307    -0.0531 0.000 0.500 0.000 0.000 0.500
#> GSM872262     4  0.4210     0.5081 0.412 0.000 0.000 0.588 0.000
#> GSM872263     3  0.0000     0.9226 0.000 0.000 1.000 0.000 0.000
#> GSM872264     4  0.2516     0.6055 0.000 0.140 0.000 0.860 0.000
#> GSM872265     4  0.2516     0.6055 0.000 0.140 0.000 0.860 0.000
#> GSM872266     5  0.3913     0.5285 0.000 0.324 0.000 0.000 0.676
#> GSM872267     5  0.3932     0.5216 0.000 0.328 0.000 0.000 0.672
#> GSM872268     3  0.0000     0.9226 0.000 0.000 1.000 0.000 0.000
#> GSM872269     5  0.2068     0.7140 0.004 0.092 0.000 0.000 0.904
#> GSM872270     3  0.0000     0.9226 0.000 0.000 1.000 0.000 0.000
#> GSM872271     2  0.2813     0.7459 0.000 0.832 0.000 0.168 0.000
#> GSM872272     2  0.2813     0.7459 0.000 0.832 0.000 0.168 0.000
#> GSM872273     1  0.2464     0.7168 0.888 0.000 0.000 0.096 0.016
#> GSM872274     2  0.0000     0.8244 0.000 1.000 0.000 0.000 0.000
#> GSM872275     3  0.3177     0.7160 0.000 0.208 0.792 0.000 0.000
#> GSM872276     4  0.4291     0.4082 0.464 0.000 0.000 0.536 0.000
#> GSM872277     1  0.4337     0.6141 0.748 0.000 0.000 0.196 0.056
#> GSM872278     3  0.2848     0.7886 0.004 0.000 0.840 0.156 0.000
#> GSM872279     1  0.2690     0.8169 0.844 0.000 0.000 0.000 0.156
#> GSM872280     3  0.6799    -0.2745 0.296 0.000 0.372 0.332 0.000
#> GSM872281     4  0.1908     0.6832 0.092 0.000 0.000 0.908 0.000
#> GSM872282     3  0.0963     0.9022 0.000 0.036 0.964 0.000 0.000
#> GSM872283     4  0.2753     0.6051 0.008 0.136 0.000 0.856 0.000
#> GSM872284     4  0.0794     0.6858 0.028 0.000 0.000 0.972 0.000
#> GSM872285     3  0.0290     0.9192 0.000 0.000 0.992 0.008 0.000
#> GSM872286     5  0.0703     0.7228 0.024 0.000 0.000 0.000 0.976
#> GSM872287     3  0.0000     0.9226 0.000 0.000 1.000 0.000 0.000
#> GSM872288     5  0.0290     0.7277 0.008 0.000 0.000 0.000 0.992
#> GSM872289     3  0.0162     0.9210 0.000 0.000 0.996 0.000 0.004
#> GSM872290     1  0.2516     0.8159 0.860 0.000 0.000 0.000 0.140
#> GSM872291     1  0.2561     0.6472 0.856 0.000 0.000 0.144 0.000
#> GSM872292     2  0.0000     0.8244 0.000 1.000 0.000 0.000 0.000
#> GSM872293     1  0.2648     0.8174 0.848 0.000 0.000 0.000 0.152
#> GSM872294     2  0.0451     0.8226 0.008 0.988 0.000 0.004 0.000
#> GSM872295     2  0.2377     0.7359 0.000 0.872 0.000 0.000 0.128
#> GSM872296     2  0.0290     0.8240 0.000 0.992 0.000 0.008 0.000
#> GSM872297     1  0.2763     0.8175 0.848 0.000 0.000 0.004 0.148
#> GSM872298     4  0.3966     0.5835 0.336 0.000 0.000 0.664 0.000
#> GSM872299     5  0.4434    -0.1598 0.460 0.004 0.000 0.000 0.536
#> GSM872300     4  0.4219     0.5021 0.416 0.000 0.000 0.584 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
#> GSM872244     3  0.1026     0.9000 0.000 0.008 0.968 0.008 0.004 0.012
#> GSM872245     5  0.4386     0.1888 0.412 0.008 0.000 0.004 0.568 0.008
#> GSM872246     3  0.0748     0.9026 0.000 0.000 0.976 0.004 0.004 0.016
#> GSM872247     3  0.0146     0.9038 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM872248     5  0.3398     0.6430 0.000 0.252 0.000 0.000 0.740 0.008
#> GSM872249     3  0.0146     0.9034 0.000 0.000 0.996 0.000 0.004 0.000
#> GSM872250     5  0.1230     0.7595 0.028 0.008 0.000 0.000 0.956 0.008
#> GSM872251     3  0.0260     0.9039 0.000 0.000 0.992 0.000 0.000 0.008
#> GSM872252     1  0.6555     0.4017 0.504 0.008 0.000 0.036 0.208 0.244
#> GSM872253     3  0.7438     0.2391 0.016 0.060 0.432 0.052 0.088 0.352
#> GSM872254     5  0.3767     0.6977 0.000 0.092 0.000 0.016 0.804 0.088
#> GSM872255     6  0.2793     0.8029 0.200 0.000 0.000 0.000 0.000 0.800
#> GSM872256     1  0.1080     0.8295 0.960 0.000 0.000 0.004 0.004 0.032
#> GSM872257     2  0.2070     0.7437 0.000 0.892 0.000 0.000 0.100 0.008
#> GSM872258     3  0.1194     0.8982 0.000 0.000 0.956 0.008 0.004 0.032
#> GSM872259     1  0.0291     0.8399 0.992 0.000 0.000 0.004 0.000 0.004
#> GSM872260     6  0.2902     0.7886 0.196 0.000 0.000 0.000 0.004 0.800
#> GSM872261     2  0.5913    -0.0382 0.004 0.444 0.000 0.020 0.428 0.104
#> GSM872262     6  0.4620     0.7671 0.132 0.000 0.000 0.176 0.000 0.692
#> GSM872263     3  0.0881     0.9016 0.000 0.000 0.972 0.008 0.008 0.012
#> GSM872264     4  0.1296     0.8310 0.000 0.044 0.004 0.948 0.000 0.004
#> GSM872265     4  0.1152     0.8304 0.004 0.044 0.000 0.952 0.000 0.000
#> GSM872266     5  0.3398     0.6430 0.000 0.252 0.000 0.000 0.740 0.008
#> GSM872267     5  0.3583     0.6292 0.000 0.260 0.000 0.004 0.728 0.008
#> GSM872268     3  0.0146     0.9038 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM872269     5  0.3655     0.7061 0.012 0.040 0.000 0.020 0.824 0.104
#> GSM872270     3  0.0146     0.9034 0.000 0.000 0.996 0.000 0.004 0.000
#> GSM872271     2  0.3690     0.5696 0.000 0.684 0.000 0.308 0.000 0.008
#> GSM872272     2  0.3690     0.5696 0.000 0.684 0.000 0.308 0.000 0.008
#> GSM872273     1  0.2706     0.7259 0.852 0.000 0.000 0.024 0.000 0.124
#> GSM872274     2  0.0405     0.8017 0.000 0.988 0.000 0.004 0.008 0.000
#> GSM872275     3  0.4664     0.5438 0.000 0.284 0.664 0.012 0.012 0.028
#> GSM872276     6  0.4014     0.8081 0.148 0.000 0.000 0.096 0.000 0.756
#> GSM872277     1  0.2318     0.7813 0.892 0.000 0.000 0.044 0.000 0.064
#> GSM872278     3  0.5587     0.5064 0.000 0.008 0.620 0.152 0.012 0.208
#> GSM872279     1  0.1138     0.8313 0.960 0.000 0.000 0.004 0.012 0.024
#> GSM872280     6  0.3259     0.7209 0.048 0.000 0.104 0.012 0.000 0.836
#> GSM872281     4  0.3899     0.2268 0.004 0.000 0.000 0.592 0.000 0.404
#> GSM872282     3  0.1514     0.8870 0.000 0.036 0.944 0.004 0.004 0.012
#> GSM872283     4  0.1297     0.8295 0.012 0.040 0.000 0.948 0.000 0.000
#> GSM872284     4  0.2092     0.7642 0.000 0.000 0.000 0.876 0.000 0.124
#> GSM872285     3  0.0935     0.8961 0.000 0.000 0.964 0.000 0.004 0.032
#> GSM872286     5  0.1701     0.7554 0.072 0.000 0.000 0.000 0.920 0.008
#> GSM872287     3  0.0146     0.9038 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM872288     5  0.1462     0.7580 0.056 0.000 0.000 0.000 0.936 0.008
#> GSM872289     3  0.0976     0.9008 0.000 0.000 0.968 0.008 0.008 0.016
#> GSM872290     1  0.1592     0.8246 0.944 0.004 0.000 0.016 0.012 0.024
#> GSM872291     6  0.4233     0.6645 0.304 0.004 0.000 0.016 0.008 0.668
#> GSM872292     2  0.0405     0.8017 0.000 0.988 0.000 0.004 0.008 0.000
#> GSM872293     1  0.0146     0.8396 0.996 0.000 0.000 0.004 0.000 0.000
#> GSM872294     2  0.1148     0.7985 0.000 0.960 0.000 0.020 0.004 0.016
#> GSM872295     2  0.2136     0.7631 0.000 0.908 0.000 0.016 0.064 0.012
#> GSM872296     2  0.0858     0.8001 0.000 0.968 0.000 0.028 0.004 0.000
#> GSM872297     1  0.0291     0.8399 0.992 0.000 0.000 0.004 0.000 0.004
#> GSM872298     6  0.4164     0.7225 0.064 0.000 0.000 0.184 0.008 0.744
#> GSM872299     1  0.5544     0.4306 0.612 0.004 0.000 0.020 0.252 0.112
#> GSM872300     6  0.4620     0.7671 0.132 0.000 0.000 0.176 0.000 0.692

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

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>              n time(p) individual(p) k
#> MAD:skmeans 56   0.796      3.29e-03 2
#> MAD:skmeans 55   0.879      1.26e-03 3
#> MAD:skmeans 55   0.334      3.37e-03 4
#> MAD:skmeans 53   0.712      3.50e-06 5
#> MAD:skmeans 51   0.905      5.65e-07 6

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

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

collect_plots(res)

plot of chunk MAD-pam-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.379           0.740       0.826         0.4288 0.560   0.560
#> 3 3 0.590           0.776       0.854         0.4528 0.752   0.576
#> 4 4 0.652           0.817       0.869         0.1631 0.904   0.737
#> 5 5 0.726           0.775       0.841         0.0561 0.861   0.566
#> 6 6 0.705           0.594       0.787         0.0698 0.927   0.695

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
#> GSM872244     2  0.9491      0.820 0.368 0.632
#> GSM872245     2  0.0000      0.583 0.000 1.000
#> GSM872246     1  0.0000      0.821 1.000 0.000
#> GSM872247     1  0.0000      0.821 1.000 0.000
#> GSM872248     2  0.9491      0.820 0.368 0.632
#> GSM872249     1  0.0000      0.821 1.000 0.000
#> GSM872250     2  0.6801      0.734 0.180 0.820
#> GSM872251     1  0.0000      0.821 1.000 0.000
#> GSM872252     1  0.7219      0.706 0.800 0.200
#> GSM872253     1  0.0000      0.821 1.000 0.000
#> GSM872254     2  0.7219      0.748 0.200 0.800
#> GSM872255     1  0.7056      0.711 0.808 0.192
#> GSM872256     1  0.9170      0.643 0.668 0.332
#> GSM872257     2  0.9491      0.820 0.368 0.632
#> GSM872258     1  0.0000      0.821 1.000 0.000
#> GSM872259     1  0.9491      0.619 0.632 0.368
#> GSM872260     1  0.0000      0.821 1.000 0.000
#> GSM872261     2  0.9491      0.820 0.368 0.632
#> GSM872262     1  0.0376      0.819 0.996 0.004
#> GSM872263     1  0.0000      0.821 1.000 0.000
#> GSM872264     1  0.0000      0.821 1.000 0.000
#> GSM872265     1  0.0000      0.821 1.000 0.000
#> GSM872266     2  0.9491      0.820 0.368 0.632
#> GSM872267     2  0.9491      0.820 0.368 0.632
#> GSM872268     1  0.0000      0.821 1.000 0.000
#> GSM872269     2  0.7219      0.748 0.200 0.800
#> GSM872270     1  0.0376      0.817 0.996 0.004
#> GSM872271     2  0.9491      0.820 0.368 0.632
#> GSM872272     2  0.9491      0.820 0.368 0.632
#> GSM872273     1  0.9491      0.619 0.632 0.368
#> GSM872274     2  0.9491      0.820 0.368 0.632
#> GSM872275     1  0.0000      0.821 1.000 0.000
#> GSM872276     1  0.9491      0.619 0.632 0.368
#> GSM872277     1  0.9491      0.619 0.632 0.368
#> GSM872278     1  0.0000      0.821 1.000 0.000
#> GSM872279     1  0.9491      0.619 0.632 0.368
#> GSM872280     1  0.0000      0.821 1.000 0.000
#> GSM872281     1  0.0000      0.821 1.000 0.000
#> GSM872282     1  0.3879      0.718 0.924 0.076
#> GSM872283     1  0.6531      0.725 0.832 0.168
#> GSM872284     1  0.0000      0.821 1.000 0.000
#> GSM872285     1  0.0000      0.821 1.000 0.000
#> GSM872286     2  0.0000      0.583 0.000 1.000
#> GSM872287     1  0.0000      0.821 1.000 0.000
#> GSM872288     2  0.7745      0.689 0.228 0.772
#> GSM872289     1  0.0000      0.821 1.000 0.000
#> GSM872290     1  0.9491      0.619 0.632 0.368
#> GSM872291     1  0.9393      0.627 0.644 0.356
#> GSM872292     2  0.9491      0.820 0.368 0.632
#> GSM872293     1  0.9491      0.619 0.632 0.368
#> GSM872294     1  0.0000      0.821 1.000 0.000
#> GSM872295     2  0.9491      0.820 0.368 0.632
#> GSM872296     1  0.1843      0.788 0.972 0.028
#> GSM872297     1  0.9491      0.619 0.632 0.368
#> GSM872298     1  0.0000      0.821 1.000 0.000
#> GSM872299     2  0.9944     -0.363 0.456 0.544
#> GSM872300     1  0.8608      0.667 0.716 0.284

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM872244     3  0.0000      0.987 0.000 0.000 1.000
#> GSM872245     2  0.5905      0.671 0.352 0.648 0.000
#> GSM872246     3  0.0000      0.987 0.000 0.000 1.000
#> GSM872247     3  0.0000      0.987 0.000 0.000 1.000
#> GSM872248     2  0.0000      0.821 0.000 1.000 0.000
#> GSM872249     3  0.0000      0.987 0.000 0.000 1.000
#> GSM872250     2  0.4953      0.791 0.176 0.808 0.016
#> GSM872251     3  0.0424      0.980 0.008 0.000 0.992
#> GSM872252     1  0.4002      0.740 0.840 0.000 0.160
#> GSM872253     1  0.5988      0.699 0.632 0.000 0.368
#> GSM872254     2  0.0000      0.821 0.000 1.000 0.000
#> GSM872255     1  0.4399      0.738 0.812 0.000 0.188
#> GSM872256     1  0.1031      0.736 0.976 0.000 0.024
#> GSM872257     2  0.0000      0.821 0.000 1.000 0.000
#> GSM872258     3  0.0000      0.987 0.000 0.000 1.000
#> GSM872259     1  0.0000      0.727 1.000 0.000 0.000
#> GSM872260     1  0.5988      0.699 0.632 0.000 0.368
#> GSM872261     2  0.5497      0.601 0.000 0.708 0.292
#> GSM872262     1  0.5968      0.701 0.636 0.000 0.364
#> GSM872263     3  0.0000      0.987 0.000 0.000 1.000
#> GSM872264     1  0.5988      0.699 0.632 0.000 0.368
#> GSM872265     1  0.5988      0.699 0.632 0.000 0.368
#> GSM872266     2  0.2066      0.819 0.000 0.940 0.060
#> GSM872267     2  0.0000      0.821 0.000 1.000 0.000
#> GSM872268     3  0.0000      0.987 0.000 0.000 1.000
#> GSM872269     2  0.5667      0.796 0.140 0.800 0.060
#> GSM872270     3  0.0000      0.987 0.000 0.000 1.000
#> GSM872271     2  0.5968      0.466 0.000 0.636 0.364
#> GSM872272     2  0.5988      0.457 0.000 0.632 0.368
#> GSM872273     1  0.0000      0.727 1.000 0.000 0.000
#> GSM872274     2  0.2165      0.818 0.000 0.936 0.064
#> GSM872275     1  0.5988      0.699 0.632 0.000 0.368
#> GSM872276     1  0.0000      0.727 1.000 0.000 0.000
#> GSM872277     1  0.0000      0.727 1.000 0.000 0.000
#> GSM872278     1  0.5988      0.699 0.632 0.000 0.368
#> GSM872279     1  0.0000      0.727 1.000 0.000 0.000
#> GSM872280     1  0.5988      0.699 0.632 0.000 0.368
#> GSM872281     1  0.5988      0.699 0.632 0.000 0.368
#> GSM872282     3  0.0000      0.987 0.000 0.000 1.000
#> GSM872283     1  0.4555      0.723 0.800 0.000 0.200
#> GSM872284     1  0.5988      0.699 0.632 0.000 0.368
#> GSM872285     3  0.0424      0.980 0.008 0.000 0.992
#> GSM872286     2  0.4555      0.780 0.200 0.800 0.000
#> GSM872287     3  0.0000      0.987 0.000 0.000 1.000
#> GSM872288     2  0.5138      0.739 0.252 0.748 0.000
#> GSM872289     3  0.2878      0.847 0.096 0.000 0.904
#> GSM872290     1  0.0000      0.727 1.000 0.000 0.000
#> GSM872291     1  0.0592      0.732 0.988 0.000 0.012
#> GSM872292     2  0.2165      0.818 0.000 0.936 0.064
#> GSM872293     1  0.0000      0.727 1.000 0.000 0.000
#> GSM872294     1  0.5988      0.699 0.632 0.000 0.368
#> GSM872295     2  0.2165      0.818 0.000 0.936 0.064
#> GSM872296     1  0.7032      0.671 0.604 0.028 0.368
#> GSM872297     1  0.0000      0.727 1.000 0.000 0.000
#> GSM872298     1  0.5988      0.699 0.632 0.000 0.368
#> GSM872299     1  0.5216      0.412 0.740 0.260 0.000
#> GSM872300     1  0.2448      0.743 0.924 0.000 0.076

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM872244     3  0.2197     0.9104 0.000 0.004 0.916 0.080
#> GSM872245     1  0.1118     0.8833 0.964 0.036 0.000 0.000
#> GSM872246     3  0.0000     0.9330 0.000 0.000 1.000 0.000
#> GSM872247     3  0.0000     0.9330 0.000 0.000 1.000 0.000
#> GSM872248     2  0.0000     0.8537 0.000 1.000 0.000 0.000
#> GSM872249     3  0.0000     0.9330 0.000 0.000 1.000 0.000
#> GSM872250     2  0.3547     0.8208 0.144 0.840 0.000 0.016
#> GSM872251     3  0.2281     0.9035 0.000 0.000 0.904 0.096
#> GSM872252     4  0.2831     0.7750 0.120 0.004 0.000 0.876
#> GSM872253     4  0.3266     0.8106 0.000 0.000 0.168 0.832
#> GSM872254     2  0.1888     0.8518 0.044 0.940 0.000 0.016
#> GSM872255     4  0.1545     0.7995 0.040 0.000 0.008 0.952
#> GSM872256     4  0.2530     0.7491 0.112 0.000 0.000 0.888
#> GSM872257     2  0.1004     0.8495 0.024 0.972 0.000 0.004
#> GSM872258     3  0.0817     0.9298 0.000 0.000 0.976 0.024
#> GSM872259     1  0.1792     0.9536 0.932 0.000 0.000 0.068
#> GSM872260     4  0.1792     0.8277 0.000 0.000 0.068 0.932
#> GSM872261     2  0.5265     0.7422 0.000 0.748 0.160 0.092
#> GSM872262     4  0.0707     0.8157 0.000 0.000 0.020 0.980
#> GSM872263     3  0.0000     0.9330 0.000 0.000 1.000 0.000
#> GSM872264     4  0.3266     0.8106 0.000 0.000 0.168 0.832
#> GSM872265     4  0.3266     0.8106 0.000 0.000 0.168 0.832
#> GSM872266     2  0.2807     0.8557 0.044 0.912 0.024 0.020
#> GSM872267     2  0.0000     0.8537 0.000 1.000 0.000 0.000
#> GSM872268     3  0.0000     0.9330 0.000 0.000 1.000 0.000
#> GSM872269     2  0.3708     0.8201 0.148 0.832 0.000 0.020
#> GSM872270     3  0.2216     0.9036 0.000 0.000 0.908 0.092
#> GSM872271     2  0.5309     0.7375 0.000 0.744 0.164 0.092
#> GSM872272     2  0.5352     0.7321 0.000 0.740 0.168 0.092
#> GSM872273     1  0.3024     0.9121 0.852 0.000 0.000 0.148
#> GSM872274     2  0.2596     0.8455 0.024 0.908 0.000 0.068
#> GSM872275     4  0.3266     0.8106 0.000 0.000 0.168 0.832
#> GSM872276     4  0.2530     0.7491 0.112 0.000 0.000 0.888
#> GSM872277     1  0.3024     0.9121 0.852 0.000 0.000 0.148
#> GSM872278     4  0.3266     0.8106 0.000 0.000 0.168 0.832
#> GSM872279     4  0.4992     0.1165 0.476 0.000 0.000 0.524
#> GSM872280     4  0.1389     0.8118 0.000 0.000 0.048 0.952
#> GSM872281     4  0.1302     0.8142 0.000 0.000 0.044 0.956
#> GSM872282     3  0.3080     0.8991 0.024 0.000 0.880 0.096
#> GSM872283     4  0.4893     0.8064 0.064 0.000 0.168 0.768
#> GSM872284     4  0.2081     0.8265 0.000 0.000 0.084 0.916
#> GSM872285     3  0.1867     0.8737 0.000 0.000 0.928 0.072
#> GSM872286     2  0.3695     0.8143 0.156 0.828 0.000 0.016
#> GSM872287     3  0.0000     0.9330 0.000 0.000 1.000 0.000
#> GSM872288     2  0.5140     0.7655 0.144 0.760 0.000 0.096
#> GSM872289     3  0.5115     0.7461 0.028 0.012 0.740 0.220
#> GSM872290     1  0.1792     0.9536 0.932 0.000 0.000 0.068
#> GSM872291     4  0.3444     0.7271 0.184 0.000 0.000 0.816
#> GSM872292     2  0.2596     0.8455 0.024 0.908 0.000 0.068
#> GSM872293     1  0.1792     0.9536 0.932 0.000 0.000 0.068
#> GSM872294     4  0.3266     0.8106 0.000 0.000 0.168 0.832
#> GSM872295     2  0.2596     0.8455 0.024 0.908 0.000 0.068
#> GSM872296     4  0.4955     0.7869 0.024 0.044 0.140 0.792
#> GSM872297     1  0.1792     0.9536 0.932 0.000 0.000 0.068
#> GSM872298     4  0.3266     0.8106 0.000 0.000 0.168 0.832
#> GSM872299     4  0.7863     0.0139 0.344 0.276 0.000 0.380
#> GSM872300     4  0.2345     0.7598 0.100 0.000 0.000 0.900

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM872244     3  0.3608     0.8176 0.000 0.112 0.824 0.064 0.000
#> GSM872245     1  0.2424     0.7307 0.868 0.000 0.000 0.000 0.132
#> GSM872246     3  0.0000     0.8683 0.000 0.000 1.000 0.000 0.000
#> GSM872247     3  0.0000     0.8683 0.000 0.000 1.000 0.000 0.000
#> GSM872248     5  0.2179     0.7731 0.000 0.112 0.000 0.000 0.888
#> GSM872249     3  0.0000     0.8683 0.000 0.000 1.000 0.000 0.000
#> GSM872250     5  0.1043     0.8536 0.040 0.000 0.000 0.000 0.960
#> GSM872251     3  0.3780     0.8113 0.000 0.116 0.812 0.072 0.000
#> GSM872252     4  0.5116     0.7643 0.188 0.120 0.000 0.692 0.000
#> GSM872253     4  0.4393     0.8135 0.000 0.168 0.076 0.756 0.000
#> GSM872254     5  0.0000     0.8432 0.000 0.000 0.000 0.000 1.000
#> GSM872255     4  0.1410     0.7829 0.060 0.000 0.000 0.940 0.000
#> GSM872256     4  0.1965     0.7720 0.096 0.000 0.000 0.904 0.000
#> GSM872257     2  0.2852     0.7816 0.000 0.828 0.000 0.000 0.172
#> GSM872258     3  0.2520     0.8508 0.000 0.048 0.896 0.056 0.000
#> GSM872259     1  0.0000     0.8324 1.000 0.000 0.000 0.000 0.000
#> GSM872260     4  0.3351     0.8190 0.028 0.132 0.004 0.836 0.000
#> GSM872261     4  0.5274     0.7849 0.000 0.096 0.076 0.744 0.084
#> GSM872262     4  0.1197     0.7901 0.048 0.000 0.000 0.952 0.000
#> GSM872263     3  0.0000     0.8683 0.000 0.000 1.000 0.000 0.000
#> GSM872264     4  0.4466     0.8104 0.000 0.176 0.076 0.748 0.000
#> GSM872265     4  0.4466     0.8104 0.000 0.176 0.076 0.748 0.000
#> GSM872266     5  0.0404     0.8425 0.000 0.012 0.000 0.000 0.988
#> GSM872267     5  0.2280     0.7668 0.000 0.120 0.000 0.000 0.880
#> GSM872268     3  0.0000     0.8683 0.000 0.000 1.000 0.000 0.000
#> GSM872269     5  0.1197     0.8510 0.048 0.000 0.000 0.000 0.952
#> GSM872270     3  0.4088     0.7772 0.000 0.168 0.776 0.056 0.000
#> GSM872271     4  0.4585     0.8107 0.000 0.172 0.076 0.748 0.004
#> GSM872272     4  0.4466     0.8104 0.000 0.176 0.076 0.748 0.000
#> GSM872273     1  0.2329     0.7792 0.876 0.000 0.000 0.124 0.000
#> GSM872274     2  0.2648     0.8089 0.000 0.848 0.000 0.000 0.152
#> GSM872275     4  0.4393     0.8135 0.000 0.168 0.076 0.756 0.000
#> GSM872276     4  0.1478     0.7797 0.064 0.000 0.000 0.936 0.000
#> GSM872277     1  0.2329     0.7792 0.876 0.000 0.000 0.124 0.000
#> GSM872278     4  0.4393     0.8135 0.000 0.168 0.076 0.756 0.000
#> GSM872279     1  0.4273    -0.0942 0.552 0.000 0.000 0.448 0.000
#> GSM872280     4  0.1862     0.7840 0.048 0.004 0.016 0.932 0.000
#> GSM872281     4  0.1197     0.7901 0.048 0.000 0.000 0.952 0.000
#> GSM872282     3  0.4495     0.7342 0.000 0.244 0.712 0.044 0.000
#> GSM872283     4  0.4753     0.7999 0.088 0.056 0.076 0.780 0.000
#> GSM872284     4  0.0000     0.8039 0.000 0.000 0.000 1.000 0.000
#> GSM872285     3  0.1251     0.8529 0.008 0.000 0.956 0.036 0.000
#> GSM872286     5  0.1197     0.8510 0.048 0.000 0.000 0.000 0.952
#> GSM872287     3  0.0000     0.8683 0.000 0.000 1.000 0.000 0.000
#> GSM872288     5  0.1043     0.8536 0.040 0.000 0.000 0.000 0.960
#> GSM872289     3  0.6524     0.6249 0.000 0.140 0.628 0.160 0.072
#> GSM872290     1  0.0000     0.8324 1.000 0.000 0.000 0.000 0.000
#> GSM872291     4  0.3003     0.7376 0.188 0.000 0.000 0.812 0.000
#> GSM872292     2  0.2648     0.8089 0.000 0.848 0.000 0.000 0.152
#> GSM872293     1  0.0000     0.8324 1.000 0.000 0.000 0.000 0.000
#> GSM872294     2  0.3791     0.5911 0.000 0.812 0.076 0.112 0.000
#> GSM872295     2  0.2648     0.8089 0.000 0.848 0.000 0.000 0.152
#> GSM872296     2  0.2592     0.6712 0.000 0.892 0.056 0.052 0.000
#> GSM872297     1  0.0000     0.8324 1.000 0.000 0.000 0.000 0.000
#> GSM872298     4  0.4393     0.8135 0.000 0.168 0.076 0.756 0.000
#> GSM872299     5  0.6614     0.1547 0.236 0.000 0.000 0.316 0.448
#> GSM872300     4  0.1478     0.7797 0.064 0.000 0.000 0.936 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
#> GSM872244     3  0.3672     0.6820 0.000 0.000 0.632 0.000 0.000 0.368
#> GSM872245     1  0.2664     0.6199 0.816 0.000 0.000 0.000 0.184 0.000
#> GSM872246     3  0.1501     0.7724 0.000 0.000 0.924 0.000 0.000 0.076
#> GSM872247     3  0.0000     0.7778 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872248     5  0.2416     0.7212 0.000 0.156 0.000 0.000 0.844 0.000
#> GSM872249     3  0.0000     0.7778 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872250     5  0.0000     0.7975 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM872251     3  0.3428     0.6776 0.000 0.000 0.696 0.000 0.000 0.304
#> GSM872252     6  0.4643     0.3620 0.184 0.000 0.000 0.128 0.000 0.688
#> GSM872253     6  0.1501     0.4835 0.000 0.000 0.000 0.076 0.000 0.924
#> GSM872254     5  0.3843     0.2987 0.000 0.000 0.000 0.000 0.548 0.452
#> GSM872255     4  0.0000     0.7343 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM872256     4  0.0865     0.7189 0.036 0.000 0.000 0.964 0.000 0.000
#> GSM872257     2  0.0000     0.8329 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM872258     3  0.3101     0.7525 0.000 0.000 0.756 0.000 0.000 0.244
#> GSM872259     1  0.0000     0.7277 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM872260     4  0.2793     0.6598 0.000 0.000 0.000 0.800 0.000 0.200
#> GSM872261     6  0.5852    -0.0361 0.000 0.000 0.000 0.328 0.208 0.464
#> GSM872262     4  0.0000     0.7343 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM872263     3  0.1501     0.7724 0.000 0.000 0.924 0.000 0.000 0.076
#> GSM872264     4  0.3860     0.3990 0.000 0.000 0.000 0.528 0.000 0.472
#> GSM872265     4  0.3860     0.3990 0.000 0.000 0.000 0.528 0.000 0.472
#> GSM872266     5  0.0000     0.7975 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM872267     5  0.3247     0.6964 0.000 0.156 0.000 0.000 0.808 0.036
#> GSM872268     3  0.0000     0.7778 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872269     5  0.3563     0.4877 0.000 0.000 0.000 0.000 0.664 0.336
#> GSM872270     3  0.3659     0.6092 0.000 0.000 0.636 0.000 0.000 0.364
#> GSM872271     6  0.1501     0.4835 0.000 0.000 0.000 0.076 0.000 0.924
#> GSM872272     6  0.5836    -0.0208 0.000 0.000 0.000 0.320 0.208 0.472
#> GSM872273     1  0.2697     0.6585 0.812 0.000 0.000 0.188 0.000 0.000
#> GSM872274     2  0.0000     0.8329 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM872275     4  0.3672     0.5488 0.000 0.000 0.000 0.632 0.000 0.368
#> GSM872276     4  0.0000     0.7343 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM872277     1  0.2664     0.6609 0.816 0.000 0.000 0.184 0.000 0.000
#> GSM872278     4  0.3672     0.5488 0.000 0.000 0.000 0.632 0.000 0.368
#> GSM872279     1  0.5428     0.1269 0.484 0.000 0.000 0.120 0.000 0.396
#> GSM872280     4  0.0146     0.7346 0.000 0.000 0.000 0.996 0.000 0.004
#> GSM872281     4  0.0000     0.7343 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM872282     3  0.4671     0.5864 0.000 0.044 0.532 0.000 0.000 0.424
#> GSM872283     4  0.4718     0.5812 0.124 0.000 0.000 0.676 0.000 0.200
#> GSM872284     4  0.0632     0.7329 0.000 0.000 0.000 0.976 0.000 0.024
#> GSM872285     3  0.1858     0.7498 0.000 0.000 0.904 0.092 0.000 0.004
#> GSM872286     5  0.0000     0.7975 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM872287     3  0.0000     0.7778 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872288     5  0.0146     0.7954 0.000 0.000 0.000 0.004 0.996 0.000
#> GSM872289     3  0.5718     0.6265 0.000 0.000 0.556 0.036 0.088 0.320
#> GSM872290     1  0.3843     0.2419 0.548 0.000 0.000 0.000 0.000 0.452
#> GSM872291     6  0.5795     0.1792 0.184 0.000 0.000 0.364 0.000 0.452
#> GSM872292     2  0.0000     0.8329 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM872293     1  0.0000     0.7277 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM872294     2  0.3373     0.6430 0.000 0.744 0.000 0.008 0.000 0.248
#> GSM872295     6  0.5903    -0.0594 0.000 0.364 0.000 0.000 0.208 0.428
#> GSM872296     2  0.2996     0.7078 0.000 0.772 0.000 0.000 0.000 0.228
#> GSM872297     1  0.0000     0.7277 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM872298     4  0.3672     0.5488 0.000 0.000 0.000 0.632 0.000 0.368
#> GSM872299     6  0.6015    -0.1282 0.216 0.000 0.000 0.004 0.328 0.452
#> GSM872300     4  0.0000     0.7343 0.000 0.000 0.000 1.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

plot of chunk tab-MAD-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

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>          n time(p) individual(p) k
#> MAD:pam 56   0.620      3.50e-02 2
#> MAD:pam 54   0.706      8.47e-05 3
#> MAD:pam 55   0.935      1.13e-05 4
#> MAD:pam 55   0.674      4.46e-07 5
#> MAD:pam 43   0.956      7.05e-06 6

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

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

collect_plots(res)

plot of chunk MAD-mclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.980           0.957       0.975         0.2633 0.754   0.754
#> 3 3 0.566           0.825       0.898         1.2430 0.648   0.545
#> 4 4 0.750           0.814       0.870         0.2523 0.698   0.391
#> 5 5 0.775           0.568       0.752         0.0678 0.887   0.600
#> 6 6 0.759           0.467       0.663         0.0487 0.838   0.398

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
#> GSM872244     1   0.946      0.460 0.636 0.364
#> GSM872245     1   0.163      0.974 0.976 0.024
#> GSM872246     2   0.000      0.977 0.000 1.000
#> GSM872247     2   0.000      0.977 0.000 1.000
#> GSM872248     1   0.000      0.973 1.000 0.000
#> GSM872249     2   0.000      0.977 0.000 1.000
#> GSM872250     1   0.000      0.973 1.000 0.000
#> GSM872251     2   0.469      0.891 0.100 0.900
#> GSM872252     1   0.163      0.974 0.976 0.024
#> GSM872253     1   0.163      0.974 0.976 0.024
#> GSM872254     1   0.000      0.973 1.000 0.000
#> GSM872255     1   0.163      0.974 0.976 0.024
#> GSM872256     1   0.163      0.974 0.976 0.024
#> GSM872257     1   0.000      0.973 1.000 0.000
#> GSM872258     1   0.469      0.904 0.900 0.100
#> GSM872259     1   0.163      0.974 0.976 0.024
#> GSM872260     1   0.163      0.974 0.976 0.024
#> GSM872261     1   0.000      0.973 1.000 0.000
#> GSM872262     1   0.000      0.973 1.000 0.000
#> GSM872263     2   0.000      0.977 0.000 1.000
#> GSM872264     1   0.000      0.973 1.000 0.000
#> GSM872265     1   0.000      0.973 1.000 0.000
#> GSM872266     1   0.000      0.973 1.000 0.000
#> GSM872267     1   0.000      0.973 1.000 0.000
#> GSM872268     2   0.000      0.977 0.000 1.000
#> GSM872269     1   0.000      0.973 1.000 0.000
#> GSM872270     2   0.295      0.942 0.052 0.948
#> GSM872271     1   0.000      0.973 1.000 0.000
#> GSM872272     1   0.000      0.973 1.000 0.000
#> GSM872273     1   0.163      0.974 0.976 0.024
#> GSM872274     1   0.000      0.973 1.000 0.000
#> GSM872275     1   0.163      0.974 0.976 0.024
#> GSM872276     1   0.000      0.973 1.000 0.000
#> GSM872277     1   0.163      0.974 0.976 0.024
#> GSM872278     1   0.163      0.974 0.976 0.024
#> GSM872279     1   0.163      0.974 0.976 0.024
#> GSM872280     1   0.163      0.974 0.976 0.024
#> GSM872281     1   0.000      0.973 1.000 0.000
#> GSM872282     1   0.795      0.708 0.760 0.240
#> GSM872283     1   0.000      0.973 1.000 0.000
#> GSM872284     1   0.000      0.973 1.000 0.000
#> GSM872285     1   0.163      0.974 0.976 0.024
#> GSM872286     1   0.141      0.974 0.980 0.020
#> GSM872287     2   0.000      0.977 0.000 1.000
#> GSM872288     1   0.163      0.974 0.976 0.024
#> GSM872289     1   0.184      0.972 0.972 0.028
#> GSM872290     1   0.163      0.974 0.976 0.024
#> GSM872291     1   0.163      0.974 0.976 0.024
#> GSM872292     1   0.000      0.973 1.000 0.000
#> GSM872293     1   0.163      0.974 0.976 0.024
#> GSM872294     1   0.000      0.973 1.000 0.000
#> GSM872295     1   0.000      0.973 1.000 0.000
#> GSM872296     1   0.000      0.973 1.000 0.000
#> GSM872297     1   0.163      0.974 0.976 0.024
#> GSM872298     1   0.163      0.974 0.976 0.024
#> GSM872299     1   0.163      0.974 0.976 0.024
#> GSM872300     1   0.141      0.974 0.980 0.020

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM872244     3  0.0000      0.975 0.000 0.000 1.000
#> GSM872245     1  0.3752      0.851 0.856 0.144 0.000
#> GSM872246     3  0.0000      0.975 0.000 0.000 1.000
#> GSM872247     3  0.0000      0.975 0.000 0.000 1.000
#> GSM872248     2  0.0000      0.878 0.000 1.000 0.000
#> GSM872249     3  0.0000      0.975 0.000 0.000 1.000
#> GSM872250     1  0.3752      0.851 0.856 0.144 0.000
#> GSM872251     3  0.0000      0.975 0.000 0.000 1.000
#> GSM872252     1  0.3752      0.851 0.856 0.144 0.000
#> GSM872253     1  0.5098      0.708 0.752 0.000 0.248
#> GSM872254     2  0.0000      0.878 0.000 1.000 0.000
#> GSM872255     1  0.4288      0.848 0.872 0.068 0.060
#> GSM872256     1  0.3482      0.853 0.872 0.128 0.000
#> GSM872257     2  0.0000      0.878 0.000 1.000 0.000
#> GSM872258     3  0.0000      0.975 0.000 0.000 1.000
#> GSM872259     1  0.3752      0.851 0.856 0.144 0.000
#> GSM872260     1  0.3851      0.852 0.860 0.136 0.004
#> GSM872261     1  0.3752      0.851 0.856 0.144 0.000
#> GSM872262     1  0.0000      0.843 1.000 0.000 0.000
#> GSM872263     3  0.0000      0.975 0.000 0.000 1.000
#> GSM872264     1  0.4346      0.721 0.816 0.000 0.184
#> GSM872265     1  0.2959      0.794 0.900 0.000 0.100
#> GSM872266     2  0.0000      0.878 0.000 1.000 0.000
#> GSM872267     2  0.0237      0.878 0.004 0.996 0.000
#> GSM872268     3  0.0000      0.975 0.000 0.000 1.000
#> GSM872269     2  0.5968      0.267 0.364 0.636 0.000
#> GSM872270     3  0.0000      0.975 0.000 0.000 1.000
#> GSM872271     1  0.5397      0.515 0.720 0.280 0.000
#> GSM872272     1  0.6095      0.217 0.608 0.392 0.000
#> GSM872273     1  0.0000      0.843 1.000 0.000 0.000
#> GSM872274     2  0.3752      0.805 0.144 0.856 0.000
#> GSM872275     1  0.5058      0.697 0.756 0.000 0.244
#> GSM872276     1  0.0000      0.843 1.000 0.000 0.000
#> GSM872277     1  0.0000      0.843 1.000 0.000 0.000
#> GSM872278     1  0.5058      0.689 0.756 0.000 0.244
#> GSM872279     1  0.3752      0.851 0.856 0.144 0.000
#> GSM872280     1  0.3686      0.815 0.860 0.000 0.140
#> GSM872281     1  0.3752      0.759 0.856 0.000 0.144
#> GSM872282     3  0.0000      0.975 0.000 0.000 1.000
#> GSM872283     1  0.0000      0.843 1.000 0.000 0.000
#> GSM872284     1  0.1163      0.835 0.972 0.000 0.028
#> GSM872285     1  0.6095      0.506 0.608 0.000 0.392
#> GSM872286     1  0.3752      0.851 0.856 0.144 0.000
#> GSM872287     3  0.0000      0.975 0.000 0.000 1.000
#> GSM872288     1  0.3752      0.851 0.856 0.144 0.000
#> GSM872289     3  0.4452      0.698 0.192 0.000 0.808
#> GSM872290     1  0.3752      0.851 0.856 0.144 0.000
#> GSM872291     1  0.2711      0.854 0.912 0.088 0.000
#> GSM872292     2  0.3752      0.805 0.144 0.856 0.000
#> GSM872293     1  0.3752      0.851 0.856 0.144 0.000
#> GSM872294     1  0.0000      0.843 1.000 0.000 0.000
#> GSM872295     2  0.0000      0.878 0.000 1.000 0.000
#> GSM872296     2  0.3752      0.805 0.144 0.856 0.000
#> GSM872297     1  0.3752      0.851 0.856 0.144 0.000
#> GSM872298     1  0.0000      0.843 1.000 0.000 0.000
#> GSM872299     1  0.3752      0.851 0.856 0.144 0.000
#> GSM872300     1  0.0000      0.843 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM872244     3  0.0000      0.943 0.000 0.000 1.000 0.000
#> GSM872245     1  0.1209      0.750 0.964 0.032 0.000 0.004
#> GSM872246     3  0.0000      0.943 0.000 0.000 1.000 0.000
#> GSM872247     3  0.0000      0.943 0.000 0.000 1.000 0.000
#> GSM872248     2  0.3801      0.813 0.220 0.780 0.000 0.000
#> GSM872249     3  0.0000      0.943 0.000 0.000 1.000 0.000
#> GSM872250     1  0.1022      0.750 0.968 0.032 0.000 0.000
#> GSM872251     3  0.0000      0.943 0.000 0.000 1.000 0.000
#> GSM872252     1  0.4199      0.730 0.804 0.032 0.000 0.164
#> GSM872253     3  0.3860      0.847 0.012 0.032 0.852 0.104
#> GSM872254     1  0.3311      0.569 0.828 0.172 0.000 0.000
#> GSM872255     4  0.0188      0.906 0.004 0.000 0.000 0.996
#> GSM872256     4  0.4277      0.537 0.280 0.000 0.000 0.720
#> GSM872257     2  0.1792      0.889 0.068 0.932 0.000 0.000
#> GSM872258     3  0.0336      0.940 0.000 0.000 0.992 0.008
#> GSM872259     1  0.4843      0.462 0.604 0.000 0.000 0.396
#> GSM872260     4  0.4250      0.544 0.276 0.000 0.000 0.724
#> GSM872261     1  0.1209      0.751 0.964 0.032 0.000 0.004
#> GSM872262     4  0.0000      0.907 0.000 0.000 0.000 1.000
#> GSM872263     3  0.0000      0.943 0.000 0.000 1.000 0.000
#> GSM872264     4  0.4782      0.714 0.000 0.068 0.152 0.780
#> GSM872265     4  0.1837      0.881 0.000 0.028 0.028 0.944
#> GSM872266     2  0.3907      0.802 0.232 0.768 0.000 0.000
#> GSM872267     2  0.1557      0.892 0.056 0.944 0.000 0.000
#> GSM872268     3  0.0000      0.943 0.000 0.000 1.000 0.000
#> GSM872269     1  0.1022      0.750 0.968 0.032 0.000 0.000
#> GSM872270     3  0.0000      0.943 0.000 0.000 1.000 0.000
#> GSM872271     2  0.1716      0.857 0.000 0.936 0.000 0.064
#> GSM872272     2  0.0817      0.886 0.000 0.976 0.000 0.024
#> GSM872273     4  0.0336      0.905 0.000 0.008 0.000 0.992
#> GSM872274     2  0.0000      0.896 0.000 1.000 0.000 0.000
#> GSM872275     3  0.2982      0.880 0.004 0.032 0.896 0.068
#> GSM872276     4  0.0000      0.907 0.000 0.000 0.000 1.000
#> GSM872277     4  0.0336      0.905 0.000 0.008 0.000 0.992
#> GSM872278     3  0.5346      0.639 0.004 0.032 0.692 0.272
#> GSM872279     1  0.4830      0.469 0.608 0.000 0.000 0.392
#> GSM872280     4  0.1004      0.893 0.004 0.000 0.024 0.972
#> GSM872281     4  0.0000      0.907 0.000 0.000 0.000 1.000
#> GSM872282     3  0.0000      0.943 0.000 0.000 1.000 0.000
#> GSM872283     4  0.0817      0.898 0.000 0.024 0.000 0.976
#> GSM872284     4  0.0000      0.907 0.000 0.000 0.000 1.000
#> GSM872285     3  0.4053      0.729 0.004 0.000 0.768 0.228
#> GSM872286     1  0.1022      0.750 0.968 0.032 0.000 0.000
#> GSM872287     3  0.0000      0.943 0.000 0.000 1.000 0.000
#> GSM872288     1  0.3749      0.741 0.840 0.032 0.000 0.128
#> GSM872289     3  0.0592      0.936 0.000 0.000 0.984 0.016
#> GSM872290     1  0.4843      0.462 0.604 0.000 0.000 0.396
#> GSM872291     4  0.0000      0.907 0.000 0.000 0.000 1.000
#> GSM872292     2  0.0000      0.896 0.000 1.000 0.000 0.000
#> GSM872293     1  0.4843      0.462 0.604 0.000 0.000 0.396
#> GSM872294     4  0.2868      0.803 0.000 0.136 0.000 0.864
#> GSM872295     2  0.3907      0.803 0.232 0.768 0.000 0.000
#> GSM872296     2  0.0000      0.896 0.000 1.000 0.000 0.000
#> GSM872297     4  0.4072      0.618 0.252 0.000 0.000 0.748
#> GSM872298     4  0.0188      0.906 0.004 0.000 0.000 0.996
#> GSM872299     1  0.1209      0.750 0.964 0.032 0.000 0.004
#> GSM872300     4  0.0000      0.907 0.000 0.000 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM872244     3  0.0162     0.9452 0.000 0.000 0.996 0.000 0.004
#> GSM872245     2  0.6715     0.0987 0.288 0.424 0.000 0.000 0.288
#> GSM872246     3  0.0162     0.9460 0.000 0.004 0.996 0.000 0.000
#> GSM872247     3  0.0000     0.9460 0.000 0.000 1.000 0.000 0.000
#> GSM872248     5  0.0510     0.4151 0.000 0.016 0.000 0.000 0.984
#> GSM872249     3  0.0162     0.9460 0.000 0.004 0.996 0.000 0.000
#> GSM872250     5  0.6274    -0.0610 0.148 0.424 0.000 0.000 0.428
#> GSM872251     3  0.0898     0.9426 0.008 0.020 0.972 0.000 0.000
#> GSM872252     2  0.6707     0.1069 0.308 0.424 0.000 0.000 0.268
#> GSM872253     3  0.1492     0.9350 0.008 0.040 0.948 0.000 0.004
#> GSM872254     5  0.5071     0.0920 0.036 0.424 0.000 0.000 0.540
#> GSM872255     4  0.3999     0.7212 0.344 0.000 0.000 0.656 0.000
#> GSM872256     1  0.1082     0.9202 0.964 0.000 0.000 0.028 0.008
#> GSM872257     5  0.3932     0.1753 0.000 0.328 0.000 0.000 0.672
#> GSM872258     3  0.1331     0.9366 0.008 0.040 0.952 0.000 0.000
#> GSM872259     1  0.0290     0.9301 0.992 0.000 0.000 0.000 0.008
#> GSM872260     1  0.3455     0.6129 0.784 0.000 0.000 0.208 0.008
#> GSM872261     2  0.6575    -0.0119 0.208 0.424 0.000 0.000 0.368
#> GSM872262     4  0.3966     0.7268 0.336 0.000 0.000 0.664 0.000
#> GSM872263     3  0.0162     0.9460 0.000 0.004 0.996 0.000 0.000
#> GSM872264     4  0.2249     0.6286 0.000 0.096 0.000 0.896 0.008
#> GSM872265     4  0.0992     0.6771 0.000 0.024 0.000 0.968 0.008
#> GSM872266     5  0.0510     0.4194 0.000 0.016 0.000 0.000 0.984
#> GSM872267     5  0.4310     0.1141 0.004 0.392 0.000 0.000 0.604
#> GSM872268     3  0.0000     0.9460 0.000 0.000 1.000 0.000 0.000
#> GSM872269     5  0.6219    -0.0466 0.140 0.424 0.000 0.000 0.436
#> GSM872270     3  0.0000     0.9460 0.000 0.000 1.000 0.000 0.000
#> GSM872271     2  0.6068     0.0183 0.000 0.452 0.000 0.428 0.120
#> GSM872272     2  0.5988     0.0134 0.000 0.516 0.000 0.364 0.120
#> GSM872273     4  0.3983     0.7228 0.340 0.000 0.000 0.660 0.000
#> GSM872274     2  0.4449    -0.1635 0.000 0.512 0.000 0.004 0.484
#> GSM872275     3  0.1960     0.9287 0.008 0.032 0.936 0.016 0.008
#> GSM872276     4  0.3966     0.7268 0.336 0.000 0.000 0.664 0.000
#> GSM872277     4  0.3966     0.7268 0.336 0.000 0.000 0.664 0.000
#> GSM872278     3  0.5384     0.1417 0.008 0.024 0.528 0.432 0.008
#> GSM872279     1  0.0290     0.9301 0.992 0.000 0.000 0.000 0.008
#> GSM872280     4  0.5499     0.6593 0.232 0.004 0.112 0.652 0.000
#> GSM872281     4  0.0510     0.6971 0.016 0.000 0.000 0.984 0.000
#> GSM872282     3  0.0609     0.9371 0.000 0.000 0.980 0.000 0.020
#> GSM872283     4  0.0693     0.6827 0.000 0.012 0.000 0.980 0.008
#> GSM872284     4  0.0404     0.6958 0.012 0.000 0.000 0.988 0.000
#> GSM872285     3  0.2201     0.9126 0.008 0.032 0.920 0.040 0.000
#> GSM872286     2  0.6681     0.0628 0.248 0.424 0.000 0.000 0.328
#> GSM872287     3  0.0000     0.9460 0.000 0.000 1.000 0.000 0.000
#> GSM872288     2  0.6703     0.0822 0.264 0.424 0.000 0.000 0.312
#> GSM872289     3  0.1412     0.9361 0.008 0.036 0.952 0.000 0.004
#> GSM872290     1  0.0290     0.9301 0.992 0.000 0.000 0.000 0.008
#> GSM872291     4  0.3983     0.7232 0.340 0.000 0.000 0.660 0.000
#> GSM872292     2  0.4304    -0.1653 0.000 0.516 0.000 0.000 0.484
#> GSM872293     1  0.0290     0.9301 0.992 0.000 0.000 0.000 0.008
#> GSM872294     4  0.2304     0.6252 0.000 0.100 0.000 0.892 0.008
#> GSM872295     5  0.0162     0.4214 0.000 0.004 0.000 0.000 0.996
#> GSM872296     2  0.4440    -0.1544 0.000 0.528 0.000 0.004 0.468
#> GSM872297     1  0.1408     0.9039 0.948 0.000 0.000 0.044 0.008
#> GSM872298     4  0.3796     0.7319 0.300 0.000 0.000 0.700 0.000
#> GSM872299     2  0.6665     0.1067 0.336 0.424 0.000 0.000 0.240
#> GSM872300     4  0.3966     0.7268 0.336 0.000 0.000 0.664 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
#> GSM872244     3  0.3672    0.68071 0.000 0.000 0.688 0.000 0.008 0.304
#> GSM872245     5  0.5258    0.27344 0.384 0.004 0.000 0.000 0.524 0.088
#> GSM872246     3  0.3672    0.65845 0.000 0.000 0.632 0.000 0.000 0.368
#> GSM872247     3  0.3578    0.68487 0.000 0.000 0.660 0.000 0.000 0.340
#> GSM872248     6  0.4570   -0.53316 0.000 0.436 0.000 0.000 0.036 0.528
#> GSM872249     3  0.3446    0.68464 0.000 0.000 0.692 0.000 0.000 0.308
#> GSM872250     5  0.4926    0.69660 0.068 0.000 0.000 0.000 0.540 0.392
#> GSM872251     6  0.5575    0.42376 0.000 0.000 0.140 0.000 0.400 0.460
#> GSM872252     5  0.6034    0.51521 0.308 0.000 0.000 0.000 0.420 0.272
#> GSM872253     6  0.5360    0.44896 0.000 0.000 0.108 0.000 0.436 0.456
#> GSM872254     5  0.4335    0.62611 0.020 0.000 0.000 0.000 0.508 0.472
#> GSM872255     3  0.8154   -0.51640 0.156 0.000 0.304 0.288 0.216 0.036
#> GSM872256     1  0.3168    0.63092 0.804 0.000 0.172 0.024 0.000 0.000
#> GSM872257     2  0.3984    0.57751 0.000 0.596 0.000 0.000 0.008 0.396
#> GSM872258     6  0.5475    0.44689 0.000 0.000 0.124 0.000 0.416 0.460
#> GSM872259     1  0.0000    0.85752 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM872260     3  0.8255   -0.47356 0.188 0.000 0.296 0.236 0.244 0.036
#> GSM872261     5  0.4917    0.70304 0.076 0.000 0.000 0.000 0.576 0.348
#> GSM872262     4  0.5859    0.61497 0.156 0.000 0.304 0.528 0.004 0.008
#> GSM872263     3  0.3578    0.68487 0.000 0.000 0.660 0.000 0.000 0.340
#> GSM872264     4  0.3122    0.35590 0.000 0.176 0.000 0.804 0.020 0.000
#> GSM872265     4  0.1003    0.50807 0.000 0.016 0.000 0.964 0.020 0.000
#> GSM872266     6  0.5799   -0.47446 0.016 0.380 0.000 0.004 0.104 0.496
#> GSM872267     2  0.3833    0.63220 0.000 0.648 0.000 0.000 0.008 0.344
#> GSM872268     3  0.3620    0.67581 0.000 0.000 0.648 0.000 0.000 0.352
#> GSM872269     5  0.4926    0.69660 0.068 0.000 0.000 0.000 0.540 0.392
#> GSM872270     3  0.3446    0.68349 0.000 0.000 0.692 0.000 0.000 0.308
#> GSM872271     4  0.4705   -0.13900 0.000 0.440 0.000 0.520 0.036 0.004
#> GSM872272     4  0.4719   -0.17699 0.000 0.460 0.000 0.500 0.036 0.004
#> GSM872273     4  0.6118    0.39544 0.336 0.000 0.304 0.360 0.000 0.000
#> GSM872274     2  0.0000    0.77943 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM872275     6  0.5417    0.45077 0.000 0.000 0.116 0.000 0.420 0.464
#> GSM872276     4  0.5859    0.61497 0.156 0.000 0.304 0.528 0.004 0.008
#> GSM872277     4  0.5625    0.60381 0.176 0.000 0.304 0.520 0.000 0.000
#> GSM872278     6  0.5739    0.43597 0.000 0.000 0.084 0.028 0.424 0.464
#> GSM872279     1  0.0000    0.85752 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM872280     5  0.7309   -0.26551 0.024 0.000 0.332 0.088 0.416 0.140
#> GSM872281     4  0.3946    0.64034 0.004 0.000 0.304 0.680 0.004 0.008
#> GSM872282     3  0.3565    0.68146 0.000 0.000 0.692 0.000 0.004 0.304
#> GSM872283     4  0.0000    0.52981 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM872284     4  0.3946    0.64034 0.004 0.000 0.304 0.680 0.004 0.008
#> GSM872285     6  0.5414    0.45124 0.000 0.000 0.116 0.000 0.416 0.468
#> GSM872286     5  0.5390    0.69433 0.128 0.000 0.000 0.000 0.532 0.340
#> GSM872287     3  0.3578    0.68487 0.000 0.000 0.660 0.000 0.000 0.340
#> GSM872288     5  0.4913    0.64956 0.112 0.000 0.000 0.000 0.636 0.252
#> GSM872289     6  0.5475    0.44689 0.000 0.000 0.124 0.000 0.416 0.460
#> GSM872290     1  0.0000    0.85752 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM872291     4  0.6520    0.59777 0.156 0.000 0.304 0.492 0.040 0.008
#> GSM872292     2  0.0146    0.77930 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM872293     1  0.0000    0.85752 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM872294     4  0.2728    0.42689 0.000 0.100 0.000 0.864 0.032 0.004
#> GSM872295     6  0.5122   -0.51075 0.016 0.420 0.000 0.000 0.048 0.516
#> GSM872296     2  0.1075    0.75276 0.000 0.952 0.000 0.048 0.000 0.000
#> GSM872297     1  0.0146    0.85466 0.996 0.000 0.004 0.000 0.000 0.000
#> GSM872298     4  0.5881    0.63014 0.076 0.000 0.304 0.572 0.016 0.032
#> GSM872299     1  0.4938   -0.00603 0.568 0.000 0.000 0.000 0.356 0.076
#> GSM872300     4  0.5859    0.61497 0.156 0.000 0.304 0.528 0.004 0.008

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

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>             n time(p) individual(p) k
#> MAD:mclust 56   0.329      0.011870 2
#> MAD:mclust 55   0.787      0.000421 3
#> MAD:mclust 53   0.443      0.001565 4
#> MAD:mclust 37   0.269      0.036734 5
#> MAD:mclust 37   0.607      0.016924 6

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 29485 rows and 57 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.419           0.793       0.877         0.4884 0.499   0.499
#> 3 3 0.862           0.911       0.961         0.3689 0.705   0.476
#> 4 4 0.678           0.737       0.848         0.1097 0.897   0.705
#> 5 5 0.658           0.653       0.776         0.0704 0.911   0.684
#> 6 6 0.647           0.559       0.704         0.0435 0.931   0.700

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
#> GSM872244     1  0.0000      0.787 1.000 0.000
#> GSM872245     2  0.0000      0.872 0.000 1.000
#> GSM872246     1  0.6247      0.844 0.844 0.156
#> GSM872247     1  0.4161      0.833 0.916 0.084
#> GSM872248     2  0.6531      0.841 0.168 0.832
#> GSM872249     1  0.0000      0.787 1.000 0.000
#> GSM872250     2  0.4431      0.865 0.092 0.908
#> GSM872251     1  0.6148      0.845 0.848 0.152
#> GSM872252     2  0.0000      0.872 0.000 1.000
#> GSM872253     1  0.6343      0.821 0.840 0.160
#> GSM872254     2  0.6531      0.841 0.168 0.832
#> GSM872255     1  0.9963      0.514 0.536 0.464
#> GSM872256     2  0.0000      0.872 0.000 1.000
#> GSM872257     2  0.6531      0.841 0.168 0.832
#> GSM872258     1  0.6531      0.840 0.832 0.168
#> GSM872259     2  0.0000      0.872 0.000 1.000
#> GSM872260     2  0.5842      0.707 0.140 0.860
#> GSM872261     2  0.4562      0.864 0.096 0.904
#> GSM872262     1  0.9922      0.547 0.552 0.448
#> GSM872263     1  0.3733      0.827 0.928 0.072
#> GSM872264     1  0.3584      0.823 0.932 0.068
#> GSM872265     2  0.8499      0.416 0.276 0.724
#> GSM872266     2  0.6531      0.841 0.168 0.832
#> GSM872267     2  0.6531      0.841 0.168 0.832
#> GSM872268     1  0.6247      0.844 0.844 0.156
#> GSM872269     2  0.4431      0.865 0.092 0.908
#> GSM872270     1  0.0000      0.787 1.000 0.000
#> GSM872271     2  0.6801      0.838 0.180 0.820
#> GSM872272     2  0.6801      0.838 0.180 0.820
#> GSM872273     2  0.0000      0.872 0.000 1.000
#> GSM872274     2  0.6531      0.841 0.168 0.832
#> GSM872275     1  0.0672      0.793 0.992 0.008
#> GSM872276     1  0.9850      0.584 0.572 0.428
#> GSM872277     2  0.2043      0.850 0.032 0.968
#> GSM872278     1  0.5294      0.841 0.880 0.120
#> GSM872279     2  0.0000      0.872 0.000 1.000
#> GSM872280     1  0.6531      0.840 0.832 0.168
#> GSM872281     1  0.6712      0.838 0.824 0.176
#> GSM872282     1  0.0000      0.787 1.000 0.000
#> GSM872283     2  0.0672      0.868 0.008 0.992
#> GSM872284     1  0.9833      0.590 0.576 0.424
#> GSM872285     1  0.6531      0.840 0.832 0.168
#> GSM872286     2  0.0000      0.872 0.000 1.000
#> GSM872287     1  0.6048      0.845 0.852 0.148
#> GSM872288     2  0.0000      0.872 0.000 1.000
#> GSM872289     1  0.6343      0.843 0.840 0.160
#> GSM872290     2  0.0000      0.872 0.000 1.000
#> GSM872291     2  0.1414      0.859 0.020 0.980
#> GSM872292     2  0.9896      0.450 0.440 0.560
#> GSM872293     2  0.0000      0.872 0.000 1.000
#> GSM872294     2  0.6343      0.845 0.160 0.840
#> GSM872295     2  0.8955      0.688 0.312 0.688
#> GSM872296     2  0.7674      0.815 0.224 0.776
#> GSM872297     2  0.0000      0.872 0.000 1.000
#> GSM872298     1  0.9881      0.570 0.564 0.436
#> GSM872299     2  0.0000      0.872 0.000 1.000
#> GSM872300     1  1.0000      0.434 0.504 0.496

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM872244     3  0.0237      0.965 0.000 0.004 0.996
#> GSM872245     1  0.6126      0.298 0.600 0.400 0.000
#> GSM872246     3  0.0000      0.967 0.000 0.000 1.000
#> GSM872247     3  0.0000      0.967 0.000 0.000 1.000
#> GSM872248     2  0.0000      0.970 0.000 1.000 0.000
#> GSM872249     3  0.0000      0.967 0.000 0.000 1.000
#> GSM872250     2  0.3116      0.888 0.108 0.892 0.000
#> GSM872251     3  0.0000      0.967 0.000 0.000 1.000
#> GSM872252     1  0.0000      0.937 1.000 0.000 0.000
#> GSM872253     3  0.4575      0.794 0.160 0.012 0.828
#> GSM872254     2  0.0000      0.970 0.000 1.000 0.000
#> GSM872255     1  0.0237      0.935 0.996 0.000 0.004
#> GSM872256     1  0.0000      0.937 1.000 0.000 0.000
#> GSM872257     2  0.0000      0.970 0.000 1.000 0.000
#> GSM872258     3  0.0000      0.967 0.000 0.000 1.000
#> GSM872259     1  0.0000      0.937 1.000 0.000 0.000
#> GSM872260     1  0.0000      0.937 1.000 0.000 0.000
#> GSM872261     2  0.2959      0.896 0.100 0.900 0.000
#> GSM872262     1  0.0237      0.935 0.996 0.000 0.004
#> GSM872263     3  0.0000      0.967 0.000 0.000 1.000
#> GSM872264     3  0.0000      0.967 0.000 0.000 1.000
#> GSM872265     1  0.5733      0.530 0.676 0.000 0.324
#> GSM872266     2  0.0000      0.970 0.000 1.000 0.000
#> GSM872267     2  0.0237      0.968 0.004 0.996 0.000
#> GSM872268     3  0.0000      0.967 0.000 0.000 1.000
#> GSM872269     2  0.4121      0.815 0.168 0.832 0.000
#> GSM872270     3  0.0000      0.967 0.000 0.000 1.000
#> GSM872271     2  0.0000      0.970 0.000 1.000 0.000
#> GSM872272     2  0.0000      0.970 0.000 1.000 0.000
#> GSM872273     1  0.0000      0.937 1.000 0.000 0.000
#> GSM872274     2  0.0000      0.970 0.000 1.000 0.000
#> GSM872275     3  0.0424      0.963 0.000 0.008 0.992
#> GSM872276     1  0.0237      0.935 0.996 0.000 0.004
#> GSM872277     1  0.0000      0.937 1.000 0.000 0.000
#> GSM872278     3  0.0000      0.967 0.000 0.000 1.000
#> GSM872279     1  0.0000      0.937 1.000 0.000 0.000
#> GSM872280     3  0.0747      0.956 0.016 0.000 0.984
#> GSM872281     3  0.5254      0.621 0.264 0.000 0.736
#> GSM872282     3  0.0237      0.965 0.000 0.004 0.996
#> GSM872283     1  0.0237      0.935 0.996 0.000 0.004
#> GSM872284     1  0.5431      0.609 0.716 0.000 0.284
#> GSM872285     3  0.0000      0.967 0.000 0.000 1.000
#> GSM872286     1  0.3879      0.786 0.848 0.152 0.000
#> GSM872287     3  0.0000      0.967 0.000 0.000 1.000
#> GSM872288     1  0.0000      0.937 1.000 0.000 0.000
#> GSM872289     3  0.2165      0.913 0.064 0.000 0.936
#> GSM872290     1  0.0000      0.937 1.000 0.000 0.000
#> GSM872291     1  0.0000      0.937 1.000 0.000 0.000
#> GSM872292     2  0.0000      0.970 0.000 1.000 0.000
#> GSM872293     1  0.0000      0.937 1.000 0.000 0.000
#> GSM872294     2  0.1031      0.956 0.024 0.976 0.000
#> GSM872295     2  0.0000      0.970 0.000 1.000 0.000
#> GSM872296     2  0.0000      0.970 0.000 1.000 0.000
#> GSM872297     1  0.0000      0.937 1.000 0.000 0.000
#> GSM872298     1  0.2796      0.864 0.908 0.000 0.092
#> GSM872299     1  0.0592      0.929 0.988 0.012 0.000
#> GSM872300     1  0.0237      0.935 0.996 0.000 0.004

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM872244     3  0.1398      0.831 0.000 0.040 0.956 0.004
#> GSM872245     1  0.4776      0.459 0.624 0.376 0.000 0.000
#> GSM872246     3  0.0188      0.846 0.000 0.000 0.996 0.004
#> GSM872247     3  0.3311      0.835 0.000 0.000 0.828 0.172
#> GSM872248     2  0.0188      0.795 0.000 0.996 0.000 0.004
#> GSM872249     3  0.0336      0.845 0.000 0.008 0.992 0.000
#> GSM872250     2  0.6736      0.484 0.092 0.588 0.312 0.008
#> GSM872251     3  0.0000      0.846 0.000 0.000 1.000 0.000
#> GSM872252     1  0.3102      0.799 0.872 0.116 0.004 0.008
#> GSM872253     3  0.3029      0.791 0.028 0.068 0.896 0.008
#> GSM872254     2  0.1489      0.777 0.004 0.952 0.044 0.000
#> GSM872255     1  0.0188      0.867 0.996 0.000 0.004 0.000
#> GSM872256     1  0.0592      0.870 0.984 0.000 0.000 0.016
#> GSM872257     2  0.2216      0.779 0.000 0.908 0.000 0.092
#> GSM872258     3  0.0804      0.840 0.012 0.000 0.980 0.008
#> GSM872259     1  0.0592      0.870 0.984 0.000 0.000 0.016
#> GSM872260     1  0.0336      0.865 0.992 0.000 0.000 0.008
#> GSM872261     2  0.2530      0.711 0.112 0.888 0.000 0.000
#> GSM872262     1  0.5344      0.467 0.668 0.000 0.032 0.300
#> GSM872263     3  0.0336      0.845 0.000 0.008 0.992 0.000
#> GSM872264     4  0.2161      0.625 0.048 0.004 0.016 0.932
#> GSM872265     4  0.2334      0.644 0.088 0.004 0.000 0.908
#> GSM872266     2  0.0592      0.795 0.000 0.984 0.000 0.016
#> GSM872267     2  0.2081      0.783 0.000 0.916 0.000 0.084
#> GSM872268     3  0.2281      0.847 0.000 0.000 0.904 0.096
#> GSM872269     2  0.6743      0.491 0.100 0.600 0.292 0.008
#> GSM872270     3  0.4250      0.791 0.000 0.000 0.724 0.276
#> GSM872271     4  0.4720      0.536 0.004 0.324 0.000 0.672
#> GSM872272     4  0.4720      0.536 0.004 0.324 0.000 0.672
#> GSM872273     1  0.1389      0.859 0.952 0.000 0.000 0.048
#> GSM872274     2  0.3266      0.716 0.000 0.832 0.000 0.168
#> GSM872275     3  0.5334      0.796 0.000 0.088 0.740 0.172
#> GSM872276     1  0.3245      0.797 0.872 0.000 0.028 0.100
#> GSM872277     1  0.1211      0.862 0.960 0.000 0.000 0.040
#> GSM872278     3  0.4522      0.756 0.000 0.000 0.680 0.320
#> GSM872279     1  0.1211      0.853 0.960 0.040 0.000 0.000
#> GSM872280     3  0.6316      0.671 0.184 0.000 0.660 0.156
#> GSM872281     4  0.4562      0.606 0.152 0.000 0.056 0.792
#> GSM872282     3  0.5173      0.758 0.000 0.020 0.660 0.320
#> GSM872283     4  0.5050      0.306 0.408 0.004 0.000 0.588
#> GSM872284     4  0.4868      0.561 0.256 0.000 0.024 0.720
#> GSM872285     3  0.4295      0.808 0.008 0.000 0.752 0.240
#> GSM872286     1  0.4642      0.749 0.808 0.116 0.068 0.008
#> GSM872287     3  0.4008      0.809 0.000 0.000 0.756 0.244
#> GSM872288     1  0.5646      0.674 0.740 0.116 0.136 0.008
#> GSM872289     3  0.1617      0.831 0.024 0.012 0.956 0.008
#> GSM872290     1  0.0592      0.870 0.984 0.000 0.000 0.016
#> GSM872291     1  0.0592      0.870 0.984 0.000 0.000 0.016
#> GSM872292     2  0.3074      0.733 0.000 0.848 0.000 0.152
#> GSM872293     1  0.0592      0.870 0.984 0.000 0.000 0.016
#> GSM872294     4  0.4917      0.520 0.008 0.336 0.000 0.656
#> GSM872295     2  0.1867      0.789 0.000 0.928 0.000 0.072
#> GSM872296     4  0.4817      0.414 0.000 0.388 0.000 0.612
#> GSM872297     1  0.0707      0.869 0.980 0.000 0.000 0.020
#> GSM872298     1  0.5328      0.547 0.704 0.000 0.048 0.248
#> GSM872299     1  0.2918      0.801 0.876 0.116 0.000 0.008
#> GSM872300     1  0.2174      0.846 0.928 0.000 0.020 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
#> GSM872244     3  0.4546     0.7225 0.000 0.008 0.688 0.284 0.020
#> GSM872245     5  0.1831     0.6329 0.076 0.004 0.000 0.000 0.920
#> GSM872246     3  0.2193     0.7891 0.000 0.000 0.900 0.092 0.008
#> GSM872247     3  0.0794     0.7893 0.000 0.000 0.972 0.028 0.000
#> GSM872248     5  0.3039     0.6643 0.000 0.152 0.000 0.012 0.836
#> GSM872249     3  0.3967     0.7378 0.000 0.000 0.724 0.264 0.012
#> GSM872250     5  0.6447     0.4549 0.016 0.012 0.100 0.312 0.560
#> GSM872251     3  0.3671     0.7503 0.000 0.000 0.756 0.236 0.008
#> GSM872252     1  0.2900     0.7768 0.876 0.012 0.000 0.092 0.020
#> GSM872253     4  0.8775    -0.2769 0.204 0.304 0.164 0.312 0.016
#> GSM872254     2  0.4865     0.6139 0.000 0.684 0.000 0.252 0.064
#> GSM872255     1  0.1617     0.8219 0.948 0.000 0.020 0.020 0.012
#> GSM872256     1  0.3085     0.8125 0.852 0.000 0.000 0.032 0.116
#> GSM872257     2  0.1965     0.7661 0.000 0.904 0.000 0.000 0.096
#> GSM872258     3  0.4571     0.7637 0.048 0.004 0.772 0.156 0.020
#> GSM872259     1  0.2516     0.8016 0.860 0.000 0.000 0.000 0.140
#> GSM872260     1  0.1825     0.8100 0.940 0.008 0.008 0.036 0.008
#> GSM872261     2  0.3778     0.7167 0.108 0.820 0.000 0.068 0.004
#> GSM872262     1  0.5723     0.3634 0.532 0.000 0.076 0.388 0.004
#> GSM872263     3  0.4358     0.7267 0.000 0.008 0.696 0.284 0.012
#> GSM872264     4  0.6285     0.4941 0.008 0.020 0.068 0.504 0.400
#> GSM872265     4  0.6251     0.5063 0.028 0.028 0.028 0.524 0.392
#> GSM872266     5  0.2329     0.6738 0.000 0.124 0.000 0.000 0.876
#> GSM872267     5  0.2536     0.6674 0.000 0.128 0.000 0.004 0.868
#> GSM872268     3  0.0880     0.7816 0.000 0.000 0.968 0.032 0.000
#> GSM872269     2  0.7273     0.4317 0.184 0.500 0.004 0.268 0.044
#> GSM872270     3  0.1522     0.7887 0.000 0.000 0.944 0.044 0.012
#> GSM872271     4  0.5237     0.0552 0.000 0.468 0.000 0.488 0.044
#> GSM872272     4  0.6077     0.4471 0.000 0.124 0.000 0.480 0.396
#> GSM872273     1  0.4482     0.7527 0.752 0.000 0.000 0.160 0.088
#> GSM872274     2  0.0566     0.7891 0.000 0.984 0.000 0.004 0.012
#> GSM872275     3  0.4307     0.7317 0.008 0.104 0.800 0.080 0.008
#> GSM872276     1  0.3441     0.7697 0.828 0.000 0.028 0.140 0.004
#> GSM872277     1  0.6271     0.5162 0.572 0.000 0.008 0.240 0.180
#> GSM872278     3  0.4994     0.6025 0.052 0.008 0.732 0.192 0.016
#> GSM872279     1  0.1836     0.8226 0.932 0.000 0.000 0.032 0.036
#> GSM872280     3  0.5271     0.2921 0.392 0.000 0.564 0.036 0.008
#> GSM872281     4  0.5203     0.3727 0.060 0.000 0.332 0.608 0.000
#> GSM872282     3  0.3126     0.7693 0.000 0.028 0.868 0.088 0.016
#> GSM872283     4  0.5925     0.4369 0.036 0.028 0.004 0.468 0.464
#> GSM872284     4  0.7077     0.4701 0.044 0.000 0.156 0.492 0.308
#> GSM872285     3  0.1991     0.7576 0.004 0.000 0.916 0.076 0.004
#> GSM872286     5  0.5211     0.6311 0.120 0.004 0.012 0.140 0.724
#> GSM872287     3  0.1341     0.7695 0.000 0.000 0.944 0.056 0.000
#> GSM872288     5  0.5149     0.6446 0.088 0.000 0.028 0.152 0.732
#> GSM872289     3  0.4567     0.6673 0.004 0.000 0.628 0.356 0.012
#> GSM872290     1  0.0771     0.8249 0.976 0.004 0.000 0.000 0.020
#> GSM872291     1  0.1490     0.8160 0.952 0.008 0.004 0.032 0.004
#> GSM872292     2  0.0404     0.7885 0.000 0.988 0.000 0.000 0.012
#> GSM872293     1  0.2017     0.8204 0.912 0.000 0.000 0.008 0.080
#> GSM872294     2  0.3566     0.6717 0.024 0.812 0.000 0.160 0.004
#> GSM872295     2  0.1018     0.7882 0.000 0.968 0.000 0.016 0.016
#> GSM872296     2  0.2843     0.6914 0.000 0.848 0.000 0.144 0.008
#> GSM872297     1  0.2997     0.7955 0.840 0.000 0.000 0.012 0.148
#> GSM872298     1  0.5225     0.5768 0.656 0.000 0.072 0.268 0.004
#> GSM872299     1  0.2845     0.7822 0.876 0.008 0.000 0.096 0.020
#> GSM872300     1  0.3878     0.7923 0.820 0.000 0.020 0.120 0.040

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM872244     3   0.495     0.7217 0.000 0.020 0.684 0.000 0.100 0.196
#> GSM872245     5   0.714     0.2098 0.332 0.012 0.000 0.232 0.372 0.052
#> GSM872246     3   0.198     0.7834 0.000 0.000 0.912 0.004 0.016 0.068
#> GSM872247     3   0.151     0.7690 0.016 0.000 0.948 0.004 0.016 0.016
#> GSM872248     5   0.419     0.6985 0.000 0.068 0.000 0.140 0.768 0.024
#> GSM872249     3   0.347     0.7724 0.000 0.000 0.808 0.000 0.092 0.100
#> GSM872250     5   0.451     0.6105 0.008 0.024 0.044 0.008 0.756 0.160
#> GSM872251     3   0.361     0.7735 0.000 0.000 0.804 0.004 0.100 0.092
#> GSM872252     6   0.401     0.2946 0.344 0.000 0.000 0.016 0.000 0.640
#> GSM872253     6   0.549     0.5345 0.036 0.176 0.056 0.036 0.004 0.692
#> GSM872254     6   0.562     0.1272 0.000 0.388 0.000 0.000 0.148 0.464
#> GSM872255     1   0.251     0.6161 0.884 0.000 0.040 0.004 0.000 0.072
#> GSM872256     1   0.388     0.5039 0.728 0.000 0.000 0.004 0.240 0.028
#> GSM872257     2   0.310     0.6929 0.000 0.784 0.000 0.000 0.208 0.008
#> GSM872258     3   0.417     0.5887 0.016 0.000 0.628 0.000 0.004 0.352
#> GSM872259     1   0.453     0.5947 0.768 0.004 0.000 0.088 0.068 0.072
#> GSM872260     1   0.384     0.0403 0.552 0.000 0.000 0.000 0.000 0.448
#> GSM872261     6   0.597     0.4006 0.080 0.380 0.000 0.012 0.028 0.500
#> GSM872262     1   0.623     0.3200 0.584 0.000 0.096 0.224 0.004 0.092
#> GSM872263     3   0.432     0.7501 0.000 0.012 0.740 0.000 0.076 0.172
#> GSM872264     4   0.271     0.5871 0.004 0.008 0.012 0.872 0.100 0.004
#> GSM872265     4   0.210     0.6019 0.024 0.004 0.000 0.916 0.048 0.008
#> GSM872266     5   0.383     0.7011 0.000 0.048 0.004 0.156 0.784 0.008
#> GSM872267     5   0.411     0.6630 0.000 0.040 0.000 0.212 0.736 0.012
#> GSM872268     3   0.209     0.7553 0.036 0.000 0.920 0.008 0.008 0.028
#> GSM872269     6   0.580     0.5504 0.100 0.124 0.000 0.000 0.132 0.644
#> GSM872270     3   0.189     0.7771 0.000 0.004 0.928 0.008 0.024 0.036
#> GSM872271     4   0.369     0.5187 0.000 0.204 0.000 0.764 0.020 0.012
#> GSM872272     4   0.381     0.5588 0.000 0.088 0.000 0.800 0.096 0.016
#> GSM872273     1   0.295     0.6338 0.864 0.000 0.008 0.092 0.016 0.020
#> GSM872274     2   0.183     0.8525 0.000 0.928 0.000 0.036 0.028 0.008
#> GSM872275     3   0.710     0.5252 0.068 0.168 0.596 0.040 0.068 0.060
#> GSM872276     1   0.567     0.3656 0.608 0.000 0.028 0.260 0.008 0.096
#> GSM872277     1   0.506     0.4660 0.640 0.004 0.000 0.280 0.052 0.024
#> GSM872278     4   0.743     0.4417 0.036 0.052 0.268 0.484 0.020 0.140
#> GSM872279     1   0.267     0.5826 0.836 0.000 0.000 0.000 0.008 0.156
#> GSM872280     3   0.723    -0.0146 0.300 0.000 0.392 0.064 0.012 0.232
#> GSM872281     4   0.717     0.4867 0.124 0.000 0.260 0.496 0.036 0.084
#> GSM872282     3   0.473     0.7386 0.000 0.072 0.744 0.008 0.040 0.136
#> GSM872283     4   0.286     0.5646 0.028 0.000 0.000 0.860 0.100 0.012
#> GSM872284     4   0.602     0.5769 0.096 0.000 0.104 0.672 0.068 0.060
#> GSM872285     3   0.279     0.7293 0.056 0.000 0.884 0.012 0.016 0.032
#> GSM872286     5   0.424     0.6474 0.156 0.008 0.012 0.004 0.768 0.052
#> GSM872287     3   0.190     0.7545 0.032 0.000 0.928 0.008 0.004 0.028
#> GSM872288     5   0.582     0.6398 0.088 0.000 0.032 0.068 0.676 0.136
#> GSM872289     3   0.462     0.7292 0.000 0.008 0.696 0.000 0.084 0.212
#> GSM872290     1   0.412     0.3125 0.628 0.000 0.000 0.020 0.000 0.352
#> GSM872291     6   0.541     0.0216 0.408 0.000 0.000 0.116 0.000 0.476
#> GSM872292     2   0.122     0.8490 0.000 0.948 0.004 0.048 0.000 0.000
#> GSM872293     1   0.212     0.6269 0.904 0.000 0.000 0.000 0.036 0.060
#> GSM872294     2   0.386     0.7973 0.020 0.796 0.000 0.144 0.012 0.028
#> GSM872295     2   0.158     0.8200 0.000 0.936 0.000 0.004 0.048 0.012
#> GSM872296     2   0.270     0.8099 0.000 0.836 0.000 0.156 0.004 0.004
#> GSM872297     1   0.433     0.5977 0.772 0.004 0.000 0.128 0.052 0.044
#> GSM872298     4   0.734     0.0029 0.360 0.000 0.092 0.372 0.016 0.160
#> GSM872299     1   0.392     0.1539 0.580 0.000 0.000 0.000 0.004 0.416
#> GSM872300     1   0.305     0.6180 0.864 0.000 0.048 0.040 0.000 0.048

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

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>          n time(p) individual(p) k
#> MAD:NMF 54   0.648      1.36e-02 2
#> MAD:NMF 56   0.344      2.92e-02 3
#> MAD:NMF 51   0.167      8.84e-03 4
#> MAD:NMF 46   0.788      1.65e-04 5
#> MAD:NMF 42   0.558      6.54e-05 6

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 29485 rows and 57 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.846           0.960       0.979         0.3433 0.662   0.662
#> 3 3 0.693           0.877       0.936         0.6577 0.739   0.606
#> 4 4 0.690           0.834       0.884         0.2870 0.840   0.602
#> 5 5 0.736           0.832       0.899         0.0564 0.977   0.906
#> 6 6 0.748           0.827       0.880         0.0233 0.987   0.943

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
#> GSM872244     2  0.0000      0.963 0.000 1.000
#> GSM872245     1  0.0000      0.981 1.000 0.000
#> GSM872246     2  0.0000      0.963 0.000 1.000
#> GSM872247     2  0.0000      0.963 0.000 1.000
#> GSM872248     1  0.0000      0.981 1.000 0.000
#> GSM872249     2  0.0000      0.963 0.000 1.000
#> GSM872250     1  0.1633      0.969 0.976 0.024
#> GSM872251     2  0.5408      0.877 0.124 0.876
#> GSM872252     1  0.0376      0.979 0.996 0.004
#> GSM872253     1  0.4815      0.895 0.896 0.104
#> GSM872254     1  0.0000      0.981 1.000 0.000
#> GSM872255     1  0.0000      0.981 1.000 0.000
#> GSM872256     1  0.0000      0.981 1.000 0.000
#> GSM872257     1  0.0000      0.981 1.000 0.000
#> GSM872258     2  0.5629      0.869 0.132 0.868
#> GSM872259     1  0.0000      0.981 1.000 0.000
#> GSM872260     1  0.0000      0.981 1.000 0.000
#> GSM872261     1  0.0376      0.979 0.996 0.004
#> GSM872262     1  0.0000      0.981 1.000 0.000
#> GSM872263     2  0.0000      0.963 0.000 1.000
#> GSM872264     1  0.1633      0.969 0.976 0.024
#> GSM872265     1  0.0000      0.981 1.000 0.000
#> GSM872266     1  0.0376      0.979 0.996 0.004
#> GSM872267     1  0.0000      0.981 1.000 0.000
#> GSM872268     2  0.0000      0.963 0.000 1.000
#> GSM872269     1  0.0000      0.981 1.000 0.000
#> GSM872270     2  0.0000      0.963 0.000 1.000
#> GSM872271     1  0.0376      0.979 0.996 0.004
#> GSM872272     1  0.0376      0.979 0.996 0.004
#> GSM872273     1  0.0000      0.981 1.000 0.000
#> GSM872274     1  0.0000      0.981 1.000 0.000
#> GSM872275     1  0.4815      0.895 0.896 0.104
#> GSM872276     1  0.0000      0.981 1.000 0.000
#> GSM872277     1  0.0000      0.981 1.000 0.000
#> GSM872278     1  0.4815      0.895 0.896 0.104
#> GSM872279     1  0.0000      0.981 1.000 0.000
#> GSM872280     1  0.4815      0.895 0.896 0.104
#> GSM872281     1  0.1633      0.969 0.976 0.024
#> GSM872282     2  0.0000      0.963 0.000 1.000
#> GSM872283     1  0.0000      0.981 1.000 0.000
#> GSM872284     1  0.1633      0.969 0.976 0.024
#> GSM872285     1  0.7674      0.730 0.776 0.224
#> GSM872286     1  0.1633      0.969 0.976 0.024
#> GSM872287     2  0.0000      0.963 0.000 1.000
#> GSM872288     1  0.1633      0.969 0.976 0.024
#> GSM872289     2  0.5629      0.869 0.132 0.868
#> GSM872290     1  0.0000      0.981 1.000 0.000
#> GSM872291     1  0.0000      0.981 1.000 0.000
#> GSM872292     1  0.0000      0.981 1.000 0.000
#> GSM872293     1  0.0000      0.981 1.000 0.000
#> GSM872294     1  0.0000      0.981 1.000 0.000
#> GSM872295     1  0.0000      0.981 1.000 0.000
#> GSM872296     1  0.0000      0.981 1.000 0.000
#> GSM872297     1  0.0000      0.981 1.000 0.000
#> GSM872298     1  0.1633      0.969 0.976 0.024
#> GSM872299     1  0.0000      0.981 1.000 0.000
#> GSM872300     1  0.0000      0.981 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
#> GSM872244     3   0.000      0.947 0.000 0.000 1.000
#> GSM872245     1   0.000      0.959 1.000 0.000 0.000
#> GSM872246     3   0.000      0.947 0.000 0.000 1.000
#> GSM872247     3   0.000      0.947 0.000 0.000 1.000
#> GSM872248     2   0.440      0.780 0.188 0.812 0.000
#> GSM872249     3   0.000      0.947 0.000 0.000 1.000
#> GSM872250     1   0.318      0.911 0.912 0.064 0.024
#> GSM872251     3   0.341      0.833 0.124 0.000 0.876
#> GSM872252     1   0.165      0.937 0.960 0.036 0.004
#> GSM872253     1   0.304      0.890 0.896 0.000 0.104
#> GSM872254     2   0.196      0.781 0.056 0.944 0.000
#> GSM872255     1   0.000      0.959 1.000 0.000 0.000
#> GSM872256     1   0.000      0.959 1.000 0.000 0.000
#> GSM872257     2   0.000      0.751 0.000 1.000 0.000
#> GSM872258     3   0.355      0.824 0.132 0.000 0.868
#> GSM872259     1   0.000      0.959 1.000 0.000 0.000
#> GSM872260     1   0.000      0.959 1.000 0.000 0.000
#> GSM872261     1   0.250      0.909 0.928 0.068 0.004
#> GSM872262     1   0.000      0.959 1.000 0.000 0.000
#> GSM872263     3   0.000      0.947 0.000 0.000 1.000
#> GSM872264     1   0.103      0.949 0.976 0.000 0.024
#> GSM872265     1   0.000      0.959 1.000 0.000 0.000
#> GSM872266     2   0.647      0.444 0.444 0.552 0.004
#> GSM872267     2   0.440      0.780 0.188 0.812 0.000
#> GSM872268     3   0.000      0.947 0.000 0.000 1.000
#> GSM872269     2   0.406      0.788 0.164 0.836 0.000
#> GSM872270     3   0.000      0.947 0.000 0.000 1.000
#> GSM872271     2   0.647      0.444 0.444 0.552 0.004
#> GSM872272     2   0.647      0.444 0.444 0.552 0.004
#> GSM872273     1   0.000      0.959 1.000 0.000 0.000
#> GSM872274     2   0.000      0.751 0.000 1.000 0.000
#> GSM872275     1   0.304      0.890 0.896 0.000 0.104
#> GSM872276     1   0.000      0.959 1.000 0.000 0.000
#> GSM872277     1   0.000      0.959 1.000 0.000 0.000
#> GSM872278     1   0.304      0.890 0.896 0.000 0.104
#> GSM872279     1   0.000      0.959 1.000 0.000 0.000
#> GSM872280     1   0.304      0.890 0.896 0.000 0.104
#> GSM872281     1   0.103      0.949 0.976 0.000 0.024
#> GSM872282     3   0.000      0.947 0.000 0.000 1.000
#> GSM872283     1   0.000      0.959 1.000 0.000 0.000
#> GSM872284     1   0.103      0.949 0.976 0.000 0.024
#> GSM872285     1   0.484      0.729 0.776 0.000 0.224
#> GSM872286     1   0.318      0.911 0.912 0.064 0.024
#> GSM872287     3   0.000      0.947 0.000 0.000 1.000
#> GSM872288     1   0.318      0.911 0.912 0.064 0.024
#> GSM872289     3   0.355      0.824 0.132 0.000 0.868
#> GSM872290     1   0.000      0.959 1.000 0.000 0.000
#> GSM872291     1   0.000      0.959 1.000 0.000 0.000
#> GSM872292     2   0.000      0.751 0.000 1.000 0.000
#> GSM872293     1   0.000      0.959 1.000 0.000 0.000
#> GSM872294     2   0.394      0.789 0.156 0.844 0.000
#> GSM872295     2   0.196      0.781 0.056 0.944 0.000
#> GSM872296     2   0.000      0.751 0.000 1.000 0.000
#> GSM872297     1   0.000      0.959 1.000 0.000 0.000
#> GSM872298     1   0.103      0.949 0.976 0.000 0.024
#> GSM872299     1   0.000      0.959 1.000 0.000 0.000
#> GSM872300     1   0.000      0.959 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM872244     3  0.0000      0.951 0.000 0.000 1.000 0.000
#> GSM872245     1  0.0188      0.856 0.996 0.000 0.000 0.004
#> GSM872246     3  0.0000      0.951 0.000 0.000 1.000 0.000
#> GSM872247     3  0.0000      0.951 0.000 0.000 1.000 0.000
#> GSM872248     2  0.5229      0.798 0.084 0.748 0.000 0.168
#> GSM872249     3  0.0000      0.951 0.000 0.000 1.000 0.000
#> GSM872250     4  0.0592      0.885 0.016 0.000 0.000 0.984
#> GSM872251     3  0.3024      0.842 0.000 0.000 0.852 0.148
#> GSM872252     1  0.3764      0.793 0.784 0.000 0.000 0.216
#> GSM872253     4  0.2915      0.890 0.028 0.000 0.080 0.892
#> GSM872254     2  0.2928      0.812 0.012 0.880 0.000 0.108
#> GSM872255     1  0.4277      0.748 0.720 0.000 0.000 0.280
#> GSM872256     1  0.0469      0.863 0.988 0.000 0.000 0.012
#> GSM872257     2  0.0336      0.782 0.000 0.992 0.000 0.008
#> GSM872258     3  0.3123      0.833 0.000 0.000 0.844 0.156
#> GSM872259     1  0.0469      0.863 0.988 0.000 0.000 0.012
#> GSM872260     1  0.4277      0.748 0.720 0.000 0.000 0.280
#> GSM872261     4  0.2197      0.829 0.080 0.004 0.000 0.916
#> GSM872262     1  0.4277      0.748 0.720 0.000 0.000 0.280
#> GSM872263     3  0.0000      0.951 0.000 0.000 1.000 0.000
#> GSM872264     4  0.1940      0.902 0.076 0.000 0.000 0.924
#> GSM872265     4  0.2345      0.888 0.100 0.000 0.000 0.900
#> GSM872266     2  0.6646      0.492 0.084 0.488 0.000 0.428
#> GSM872267     2  0.5229      0.798 0.084 0.748 0.000 0.168
#> GSM872268     3  0.0000      0.951 0.000 0.000 1.000 0.000
#> GSM872269     2  0.4938      0.807 0.080 0.772 0.000 0.148
#> GSM872270     3  0.0000      0.951 0.000 0.000 1.000 0.000
#> GSM872271     2  0.6646      0.492 0.084 0.488 0.000 0.428
#> GSM872272     2  0.6646      0.492 0.084 0.488 0.000 0.428
#> GSM872273     1  0.0469      0.863 0.988 0.000 0.000 0.012
#> GSM872274     2  0.0336      0.782 0.000 0.992 0.000 0.008
#> GSM872275     4  0.2915      0.890 0.028 0.000 0.080 0.892
#> GSM872276     1  0.4277      0.748 0.720 0.000 0.000 0.280
#> GSM872277     1  0.0921      0.863 0.972 0.000 0.000 0.028
#> GSM872278     4  0.2915      0.890 0.028 0.000 0.080 0.892
#> GSM872279     1  0.0188      0.856 0.996 0.000 0.000 0.004
#> GSM872280     4  0.2915      0.890 0.028 0.000 0.080 0.892
#> GSM872281     4  0.2081      0.898 0.084 0.000 0.000 0.916
#> GSM872282     3  0.0000      0.951 0.000 0.000 1.000 0.000
#> GSM872283     4  0.3486      0.811 0.188 0.000 0.000 0.812
#> GSM872284     4  0.1940      0.902 0.076 0.000 0.000 0.924
#> GSM872285     4  0.4485      0.765 0.028 0.000 0.200 0.772
#> GSM872286     4  0.0592      0.885 0.016 0.000 0.000 0.984
#> GSM872287     3  0.0000      0.951 0.000 0.000 1.000 0.000
#> GSM872288     4  0.0592      0.885 0.016 0.000 0.000 0.984
#> GSM872289     3  0.3123      0.833 0.000 0.000 0.844 0.156
#> GSM872290     1  0.1940      0.854 0.924 0.000 0.000 0.076
#> GSM872291     1  0.3837      0.792 0.776 0.000 0.000 0.224
#> GSM872292     2  0.0336      0.782 0.000 0.992 0.000 0.008
#> GSM872293     1  0.0469      0.863 0.988 0.000 0.000 0.012
#> GSM872294     2  0.4841      0.808 0.080 0.780 0.000 0.140
#> GSM872295     2  0.2928      0.812 0.012 0.880 0.000 0.108
#> GSM872296     2  0.0336      0.782 0.000 0.992 0.000 0.008
#> GSM872297     1  0.0469      0.863 0.988 0.000 0.000 0.012
#> GSM872298     4  0.2281      0.891 0.096 0.000 0.000 0.904
#> GSM872299     1  0.0188      0.856 0.996 0.000 0.000 0.004
#> GSM872300     1  0.4277      0.748 0.720 0.000 0.000 0.280

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM872244     3  0.0000      0.947 0.000 0.000 1.000 0.000 0.000
#> GSM872245     1  0.0510      0.825 0.984 0.000 0.000 0.000 0.016
#> GSM872246     3  0.0000      0.947 0.000 0.000 1.000 0.000 0.000
#> GSM872247     3  0.0000      0.947 0.000 0.000 1.000 0.000 0.000
#> GSM872248     5  0.1282      0.783 0.000 0.044 0.000 0.004 0.952
#> GSM872249     3  0.0000      0.947 0.000 0.000 1.000 0.000 0.000
#> GSM872250     4  0.2516      0.831 0.000 0.000 0.000 0.860 0.140
#> GSM872251     3  0.2798      0.838 0.000 0.008 0.852 0.140 0.000
#> GSM872252     1  0.4901      0.709 0.716 0.000 0.000 0.116 0.168
#> GSM872253     4  0.2017      0.866 0.000 0.008 0.080 0.912 0.000
#> GSM872254     5  0.2377      0.716 0.000 0.128 0.000 0.000 0.872
#> GSM872255     1  0.3949      0.714 0.668 0.000 0.000 0.332 0.000
#> GSM872256     1  0.0000      0.830 1.000 0.000 0.000 0.000 0.000
#> GSM872257     2  0.0290      1.000 0.000 0.992 0.000 0.000 0.008
#> GSM872258     3  0.2886      0.830 0.000 0.008 0.844 0.148 0.000
#> GSM872259     1  0.0000      0.830 1.000 0.000 0.000 0.000 0.000
#> GSM872260     1  0.3949      0.714 0.668 0.000 0.000 0.332 0.000
#> GSM872261     4  0.3395      0.702 0.000 0.000 0.000 0.764 0.236
#> GSM872262     1  0.3949      0.714 0.668 0.000 0.000 0.332 0.000
#> GSM872263     3  0.0000      0.947 0.000 0.000 1.000 0.000 0.000
#> GSM872264     4  0.0794      0.874 0.000 0.000 0.000 0.972 0.028
#> GSM872265     4  0.1493      0.864 0.024 0.000 0.000 0.948 0.028
#> GSM872266     5  0.4622      0.653 0.000 0.044 0.000 0.264 0.692
#> GSM872267     5  0.1282      0.783 0.000 0.044 0.000 0.004 0.952
#> GSM872268     3  0.0000      0.947 0.000 0.000 1.000 0.000 0.000
#> GSM872269     5  0.1082      0.778 0.000 0.028 0.000 0.008 0.964
#> GSM872270     3  0.0000      0.947 0.000 0.000 1.000 0.000 0.000
#> GSM872271     5  0.4622      0.653 0.000 0.044 0.000 0.264 0.692
#> GSM872272     5  0.4622      0.653 0.000 0.044 0.000 0.264 0.692
#> GSM872273     1  0.0000      0.830 1.000 0.000 0.000 0.000 0.000
#> GSM872274     2  0.0290      1.000 0.000 0.992 0.000 0.000 0.008
#> GSM872275     4  0.2017      0.866 0.000 0.008 0.080 0.912 0.000
#> GSM872276     1  0.3949      0.714 0.668 0.000 0.000 0.332 0.000
#> GSM872277     1  0.0510      0.831 0.984 0.000 0.000 0.016 0.000
#> GSM872278     4  0.2017      0.866 0.000 0.008 0.080 0.912 0.000
#> GSM872279     1  0.0510      0.825 0.984 0.000 0.000 0.000 0.016
#> GSM872280     4  0.2017      0.866 0.000 0.008 0.080 0.912 0.000
#> GSM872281     4  0.0162      0.870 0.004 0.000 0.000 0.996 0.000
#> GSM872282     3  0.0000      0.947 0.000 0.000 1.000 0.000 0.000
#> GSM872283     4  0.2824      0.797 0.116 0.000 0.000 0.864 0.020
#> GSM872284     4  0.0794      0.874 0.000 0.000 0.000 0.972 0.028
#> GSM872285     4  0.3388      0.740 0.000 0.008 0.200 0.792 0.000
#> GSM872286     4  0.2516      0.831 0.000 0.000 0.000 0.860 0.140
#> GSM872287     3  0.0000      0.947 0.000 0.000 1.000 0.000 0.000
#> GSM872288     4  0.2516      0.831 0.000 0.000 0.000 0.860 0.140
#> GSM872289     3  0.2886      0.830 0.000 0.008 0.844 0.148 0.000
#> GSM872290     1  0.1544      0.823 0.932 0.000 0.000 0.068 0.000
#> GSM872291     1  0.3561      0.764 0.740 0.000 0.000 0.260 0.000
#> GSM872292     2  0.0290      1.000 0.000 0.992 0.000 0.000 0.008
#> GSM872293     1  0.0000      0.830 1.000 0.000 0.000 0.000 0.000
#> GSM872294     5  0.0880      0.775 0.000 0.032 0.000 0.000 0.968
#> GSM872295     5  0.2377      0.716 0.000 0.128 0.000 0.000 0.872
#> GSM872296     2  0.0290      1.000 0.000 0.992 0.000 0.000 0.008
#> GSM872297     1  0.0000      0.830 1.000 0.000 0.000 0.000 0.000
#> GSM872298     4  0.0798      0.866 0.016 0.008 0.000 0.976 0.000
#> GSM872299     1  0.0510      0.825 0.984 0.000 0.000 0.000 0.016
#> GSM872300     1  0.3949      0.714 0.668 0.000 0.000 0.332 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
#> GSM872244     3  0.0000      0.936 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872245     1  0.0458      0.823 0.984 0.000 0.000 0.000 0.016 0.000
#> GSM872246     3  0.0000      0.936 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872247     3  0.0000      0.936 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872248     5  0.0632      0.634 0.000 0.000 0.000 0.000 0.976 0.024
#> GSM872249     3  0.0000      0.936 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872250     4  0.2593      0.792 0.000 0.000 0.000 0.844 0.148 0.008
#> GSM872251     3  0.3900      0.797 0.000 0.000 0.796 0.088 0.020 0.096
#> GSM872252     1  0.4895      0.698 0.712 0.000 0.000 0.116 0.140 0.032
#> GSM872253     4  0.3093      0.814 0.000 0.000 0.024 0.848 0.024 0.104
#> GSM872254     6  0.3045      0.902 0.000 0.100 0.000 0.000 0.060 0.840
#> GSM872255     1  0.4034      0.714 0.652 0.000 0.000 0.328 0.000 0.020
#> GSM872256     1  0.0000      0.829 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM872257     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM872258     3  0.3996      0.790 0.000 0.000 0.788 0.096 0.020 0.096
#> GSM872259     1  0.0000      0.829 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM872260     1  0.4034      0.714 0.652 0.000 0.000 0.328 0.000 0.020
#> GSM872261     4  0.3630      0.685 0.000 0.000 0.000 0.756 0.212 0.032
#> GSM872262     1  0.4034      0.714 0.652 0.000 0.000 0.328 0.000 0.020
#> GSM872263     3  0.0000      0.936 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872264     4  0.0935      0.828 0.000 0.000 0.000 0.964 0.032 0.004
#> GSM872265     4  0.1693      0.811 0.012 0.000 0.000 0.936 0.032 0.020
#> GSM872266     5  0.3175      0.788 0.000 0.000 0.000 0.256 0.744 0.000
#> GSM872267     5  0.0632      0.634 0.000 0.000 0.000 0.000 0.976 0.024
#> GSM872268     3  0.0000      0.936 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872269     6  0.2442      0.881 0.000 0.000 0.000 0.004 0.144 0.852
#> GSM872270     3  0.0000      0.936 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872271     5  0.3175      0.788 0.000 0.000 0.000 0.256 0.744 0.000
#> GSM872272     5  0.3175      0.788 0.000 0.000 0.000 0.256 0.744 0.000
#> GSM872273     1  0.0000      0.829 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM872274     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM872275     4  0.3093      0.814 0.000 0.000 0.024 0.848 0.024 0.104
#> GSM872276     1  0.4034      0.714 0.652 0.000 0.000 0.328 0.000 0.020
#> GSM872277     1  0.0458      0.829 0.984 0.000 0.000 0.016 0.000 0.000
#> GSM872278     4  0.3093      0.814 0.000 0.000 0.024 0.848 0.024 0.104
#> GSM872279     1  0.0458      0.823 0.984 0.000 0.000 0.000 0.016 0.000
#> GSM872280     4  0.3093      0.814 0.000 0.000 0.024 0.848 0.024 0.104
#> GSM872281     4  0.0260      0.821 0.000 0.000 0.000 0.992 0.000 0.008
#> GSM872282     3  0.0000      0.936 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872283     4  0.2925      0.761 0.104 0.000 0.000 0.856 0.024 0.016
#> GSM872284     4  0.1049      0.826 0.000 0.000 0.000 0.960 0.032 0.008
#> GSM872285     4  0.4661      0.668 0.000 0.000 0.144 0.728 0.024 0.104
#> GSM872286     4  0.2593      0.792 0.000 0.000 0.000 0.844 0.148 0.008
#> GSM872287     3  0.0000      0.936 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872288     4  0.2593      0.792 0.000 0.000 0.000 0.844 0.148 0.008
#> GSM872289     3  0.3996      0.790 0.000 0.000 0.788 0.096 0.020 0.096
#> GSM872290     1  0.1444      0.820 0.928 0.000 0.000 0.072 0.000 0.000
#> GSM872291     1  0.3688      0.755 0.724 0.000 0.000 0.256 0.000 0.020
#> GSM872292     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM872293     1  0.0000      0.829 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM872294     6  0.2092      0.897 0.000 0.000 0.000 0.000 0.124 0.876
#> GSM872295     6  0.3045      0.902 0.000 0.100 0.000 0.000 0.060 0.840
#> GSM872296     2  0.0146      0.997 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM872297     1  0.0000      0.829 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM872298     4  0.1353      0.827 0.012 0.000 0.000 0.952 0.012 0.024
#> GSM872299     1  0.0458      0.823 0.984 0.000 0.000 0.000 0.016 0.000
#> GSM872300     1  0.4034      0.714 0.652 0.000 0.000 0.328 0.000 0.020

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

consensus_heatmap(res, k = 2)

plot of chunk tab-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

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>             n time(p) individual(p) k
#> ATC:hclust 57   0.387      0.000693 2
#> ATC:hclust 54   0.818      0.000403 3
#> ATC:hclust 54   0.764      0.000515 4
#> ATC:hclust 57   0.645      0.011167 5
#> ATC:hclust 57   0.465      0.009007 6

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 29485 rows and 57 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.294           0.722       0.842         0.4261 0.574   0.574
#> 3 3 0.980           0.935       0.972         0.5369 0.753   0.576
#> 4 4 0.796           0.882       0.934         0.1227 0.771   0.451
#> 5 5 0.754           0.771       0.870         0.0847 0.890   0.614
#> 6 6 0.801           0.676       0.838         0.0435 0.944   0.729

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
#> GSM872244     1   0.529      0.878 0.880 0.120
#> GSM872245     2   0.529      0.748 0.120 0.880
#> GSM872246     1   0.529      0.878 0.880 0.120
#> GSM872247     1   0.529      0.878 0.880 0.120
#> GSM872248     2   0.987      0.533 0.432 0.568
#> GSM872249     1   0.529      0.878 0.880 0.120
#> GSM872250     2   0.895      0.509 0.312 0.688
#> GSM872251     1   0.529      0.878 0.880 0.120
#> GSM872252     2   0.000      0.809 0.000 1.000
#> GSM872253     1   0.991      0.343 0.556 0.444
#> GSM872254     2   0.987      0.533 0.432 0.568
#> GSM872255     2   0.000      0.809 0.000 1.000
#> GSM872256     2   0.000      0.809 0.000 1.000
#> GSM872257     2   0.987      0.533 0.432 0.568
#> GSM872258     1   0.529      0.878 0.880 0.120
#> GSM872259     2   0.000      0.809 0.000 1.000
#> GSM872260     2   0.000      0.809 0.000 1.000
#> GSM872261     2   0.443      0.765 0.092 0.908
#> GSM872262     2   0.000      0.809 0.000 1.000
#> GSM872263     1   0.529      0.878 0.880 0.120
#> GSM872264     2   0.821      0.598 0.256 0.744
#> GSM872265     2   0.000      0.809 0.000 1.000
#> GSM872266     2   0.978      0.560 0.412 0.588
#> GSM872267     2   0.753      0.728 0.216 0.784
#> GSM872268     1   0.529      0.878 0.880 0.120
#> GSM872269     2   0.985      0.533 0.428 0.572
#> GSM872270     1   0.529      0.878 0.880 0.120
#> GSM872271     2   0.961      0.595 0.384 0.616
#> GSM872272     2   0.961      0.595 0.384 0.616
#> GSM872273     2   0.000      0.809 0.000 1.000
#> GSM872274     2   0.987      0.533 0.432 0.568
#> GSM872275     1   0.992      0.330 0.552 0.448
#> GSM872276     2   0.000      0.809 0.000 1.000
#> GSM872277     2   0.000      0.809 0.000 1.000
#> GSM872278     1   0.988      0.365 0.564 0.436
#> GSM872279     2   0.000      0.809 0.000 1.000
#> GSM872280     1   1.000      0.204 0.500 0.500
#> GSM872281     2   0.204      0.783 0.032 0.968
#> GSM872282     1   0.529      0.878 0.880 0.120
#> GSM872283     2   0.000      0.809 0.000 1.000
#> GSM872284     2   0.000      0.809 0.000 1.000
#> GSM872285     1   0.529      0.878 0.880 0.120
#> GSM872286     2   0.000      0.809 0.000 1.000
#> GSM872287     1   0.529      0.878 0.880 0.120
#> GSM872288     2   0.697      0.681 0.188 0.812
#> GSM872289     1   0.529      0.878 0.880 0.120
#> GSM872290     2   0.000      0.809 0.000 1.000
#> GSM872291     2   0.000      0.809 0.000 1.000
#> GSM872292     2   0.987      0.533 0.432 0.568
#> GSM872293     2   0.000      0.809 0.000 1.000
#> GSM872294     2   0.529      0.748 0.120 0.880
#> GSM872295     2   0.987      0.533 0.432 0.568
#> GSM872296     2   0.987      0.533 0.432 0.568
#> GSM872297     2   0.000      0.809 0.000 1.000
#> GSM872298     2   0.000      0.809 0.000 1.000
#> GSM872299     2   0.518      0.751 0.116 0.884
#> GSM872300     2   0.000      0.809 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
#> GSM872244     3  0.0000      0.953 0.000 0.000 1.000
#> GSM872245     1  0.0424      0.979 0.992 0.008 0.000
#> GSM872246     3  0.0000      0.953 0.000 0.000 1.000
#> GSM872247     3  0.0000      0.953 0.000 0.000 1.000
#> GSM872248     2  0.0424      0.968 0.000 0.992 0.008
#> GSM872249     3  0.0000      0.953 0.000 0.000 1.000
#> GSM872250     2  0.3481      0.895 0.044 0.904 0.052
#> GSM872251     3  0.0000      0.953 0.000 0.000 1.000
#> GSM872252     1  0.0000      0.979 1.000 0.000 0.000
#> GSM872253     3  0.5058      0.643 0.000 0.244 0.756
#> GSM872254     2  0.0424      0.968 0.000 0.992 0.008
#> GSM872255     1  0.0000      0.979 1.000 0.000 0.000
#> GSM872256     1  0.0424      0.979 0.992 0.008 0.000
#> GSM872257     2  0.0424      0.968 0.000 0.992 0.008
#> GSM872258     3  0.0000      0.953 0.000 0.000 1.000
#> GSM872259     1  0.0424      0.979 0.992 0.008 0.000
#> GSM872260     1  0.0000      0.979 1.000 0.000 0.000
#> GSM872261     1  0.5988      0.397 0.632 0.368 0.000
#> GSM872262     1  0.0000      0.979 1.000 0.000 0.000
#> GSM872263     3  0.0000      0.953 0.000 0.000 1.000
#> GSM872264     1  0.1163      0.956 0.972 0.000 0.028
#> GSM872265     1  0.0000      0.979 1.000 0.000 0.000
#> GSM872266     2  0.0424      0.968 0.000 0.992 0.008
#> GSM872267     2  0.0000      0.963 0.000 1.000 0.000
#> GSM872268     3  0.0000      0.953 0.000 0.000 1.000
#> GSM872269     2  0.0424      0.968 0.000 0.992 0.008
#> GSM872270     3  0.0000      0.953 0.000 0.000 1.000
#> GSM872271     2  0.0475      0.966 0.004 0.992 0.004
#> GSM872272     2  0.0475      0.966 0.004 0.992 0.004
#> GSM872273     1  0.0424      0.979 0.992 0.008 0.000
#> GSM872274     2  0.0424      0.968 0.000 0.992 0.008
#> GSM872275     2  0.5733      0.520 0.000 0.676 0.324
#> GSM872276     1  0.0000      0.979 1.000 0.000 0.000
#> GSM872277     1  0.0424      0.979 0.992 0.008 0.000
#> GSM872278     3  0.0424      0.947 0.008 0.000 0.992
#> GSM872279     1  0.0424      0.979 0.992 0.008 0.000
#> GSM872280     3  0.5859      0.486 0.344 0.000 0.656
#> GSM872281     1  0.0000      0.979 1.000 0.000 0.000
#> GSM872282     3  0.0000      0.953 0.000 0.000 1.000
#> GSM872283     1  0.0424      0.979 0.992 0.008 0.000
#> GSM872284     1  0.0000      0.979 1.000 0.000 0.000
#> GSM872285     3  0.0424      0.947 0.008 0.000 0.992
#> GSM872286     1  0.0237      0.979 0.996 0.004 0.000
#> GSM872287     3  0.0000      0.953 0.000 0.000 1.000
#> GSM872288     1  0.0892      0.963 0.980 0.000 0.020
#> GSM872289     3  0.0000      0.953 0.000 0.000 1.000
#> GSM872290     1  0.0424      0.979 0.992 0.008 0.000
#> GSM872291     1  0.0000      0.979 1.000 0.000 0.000
#> GSM872292     2  0.0424      0.968 0.000 0.992 0.008
#> GSM872293     1  0.0424      0.979 0.992 0.008 0.000
#> GSM872294     2  0.0000      0.963 0.000 1.000 0.000
#> GSM872295     2  0.0424      0.968 0.000 0.992 0.008
#> GSM872296     2  0.0424      0.968 0.000 0.992 0.008
#> GSM872297     1  0.0424      0.979 0.992 0.008 0.000
#> GSM872298     1  0.0000      0.979 1.000 0.000 0.000
#> GSM872299     1  0.0424      0.979 0.992 0.008 0.000
#> GSM872300     1  0.0000      0.979 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM872244     3  0.0000      0.977 0.000 0.000 1.000 0.000
#> GSM872245     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> GSM872246     3  0.0000      0.977 0.000 0.000 1.000 0.000
#> GSM872247     3  0.0000      0.977 0.000 0.000 1.000 0.000
#> GSM872248     2  0.3486      0.816 0.000 0.812 0.000 0.188
#> GSM872249     3  0.0000      0.977 0.000 0.000 1.000 0.000
#> GSM872250     4  0.0000      0.878 0.000 0.000 0.000 1.000
#> GSM872251     3  0.0469      0.969 0.000 0.000 0.988 0.012
#> GSM872252     4  0.2011      0.874 0.080 0.000 0.000 0.920
#> GSM872253     4  0.0000      0.878 0.000 0.000 0.000 1.000
#> GSM872254     2  0.0000      0.865 0.000 1.000 0.000 0.000
#> GSM872255     4  0.3688      0.788 0.208 0.000 0.000 0.792
#> GSM872256     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> GSM872257     2  0.0000      0.865 0.000 1.000 0.000 0.000
#> GSM872258     3  0.2408      0.885 0.000 0.000 0.896 0.104
#> GSM872259     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> GSM872260     4  0.4008      0.753 0.244 0.000 0.000 0.756
#> GSM872261     4  0.0000      0.878 0.000 0.000 0.000 1.000
#> GSM872262     4  0.4585      0.640 0.332 0.000 0.000 0.668
#> GSM872263     3  0.0000      0.977 0.000 0.000 1.000 0.000
#> GSM872264     4  0.0000      0.878 0.000 0.000 0.000 1.000
#> GSM872265     4  0.0592      0.882 0.016 0.000 0.000 0.984
#> GSM872266     2  0.3610      0.807 0.000 0.800 0.000 0.200
#> GSM872267     2  0.3486      0.816 0.000 0.812 0.000 0.188
#> GSM872268     3  0.0000      0.977 0.000 0.000 1.000 0.000
#> GSM872269     4  0.2589      0.768 0.000 0.116 0.000 0.884
#> GSM872270     3  0.0000      0.977 0.000 0.000 1.000 0.000
#> GSM872271     2  0.4855      0.538 0.000 0.600 0.000 0.400
#> GSM872272     2  0.4855      0.538 0.000 0.600 0.000 0.400
#> GSM872273     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> GSM872274     2  0.0000      0.865 0.000 1.000 0.000 0.000
#> GSM872275     4  0.0000      0.878 0.000 0.000 0.000 1.000
#> GSM872276     4  0.4605      0.634 0.336 0.000 0.000 0.664
#> GSM872277     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> GSM872278     4  0.0000      0.878 0.000 0.000 0.000 1.000
#> GSM872279     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> GSM872280     4  0.1637      0.880 0.060 0.000 0.000 0.940
#> GSM872281     4  0.1637      0.880 0.060 0.000 0.000 0.940
#> GSM872282     3  0.0000      0.977 0.000 0.000 1.000 0.000
#> GSM872283     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> GSM872284     4  0.1118      0.883 0.036 0.000 0.000 0.964
#> GSM872285     4  0.1637      0.859 0.000 0.000 0.060 0.940
#> GSM872286     4  0.0707      0.880 0.020 0.000 0.000 0.980
#> GSM872287     3  0.0000      0.977 0.000 0.000 1.000 0.000
#> GSM872288     4  0.0000      0.878 0.000 0.000 0.000 1.000
#> GSM872289     3  0.2408      0.885 0.000 0.000 0.896 0.104
#> GSM872290     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> GSM872291     4  0.4605      0.634 0.336 0.000 0.000 0.664
#> GSM872292     2  0.0000      0.865 0.000 1.000 0.000 0.000
#> GSM872293     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> GSM872294     2  0.0000      0.865 0.000 1.000 0.000 0.000
#> GSM872295     2  0.0000      0.865 0.000 1.000 0.000 0.000
#> GSM872296     2  0.0000      0.865 0.000 1.000 0.000 0.000
#> GSM872297     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> GSM872298     4  0.1637      0.880 0.060 0.000 0.000 0.940
#> GSM872299     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> GSM872300     4  0.3649      0.791 0.204 0.000 0.000 0.796

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM872244     3  0.0703      0.898 0.000 0.000 0.976 0.000 0.024
#> GSM872245     1  0.0865      0.950 0.972 0.000 0.000 0.004 0.024
#> GSM872246     3  0.0880      0.897 0.000 0.000 0.968 0.000 0.032
#> GSM872247     3  0.0000      0.900 0.000 0.000 1.000 0.000 0.000
#> GSM872248     5  0.4269      0.494 0.000 0.300 0.000 0.016 0.684
#> GSM872249     3  0.0703      0.898 0.000 0.000 0.976 0.000 0.024
#> GSM872250     5  0.2605      0.681 0.000 0.000 0.000 0.148 0.852
#> GSM872251     3  0.3284      0.814 0.000 0.000 0.828 0.024 0.148
#> GSM872252     4  0.4326      0.554 0.028 0.000 0.000 0.708 0.264
#> GSM872253     5  0.3242      0.657 0.000 0.000 0.000 0.216 0.784
#> GSM872254     2  0.3783      0.661 0.000 0.740 0.000 0.008 0.252
#> GSM872255     4  0.1282      0.835 0.044 0.000 0.000 0.952 0.004
#> GSM872256     1  0.0000      0.963 1.000 0.000 0.000 0.000 0.000
#> GSM872257     2  0.0000      0.886 0.000 1.000 0.000 0.000 0.000
#> GSM872258     3  0.5617      0.587 0.000 0.000 0.620 0.124 0.256
#> GSM872259     1  0.0000      0.963 1.000 0.000 0.000 0.000 0.000
#> GSM872260     4  0.1800      0.831 0.048 0.000 0.000 0.932 0.020
#> GSM872261     5  0.3636      0.643 0.000 0.000 0.000 0.272 0.728
#> GSM872262     4  0.2648      0.785 0.152 0.000 0.000 0.848 0.000
#> GSM872263     3  0.0703      0.898 0.000 0.000 0.976 0.000 0.024
#> GSM872264     4  0.2377      0.785 0.000 0.000 0.000 0.872 0.128
#> GSM872265     4  0.2179      0.795 0.000 0.000 0.000 0.888 0.112
#> GSM872266     5  0.4318      0.507 0.000 0.292 0.000 0.020 0.688
#> GSM872267     5  0.4269      0.494 0.000 0.300 0.000 0.016 0.684
#> GSM872268     3  0.0880      0.897 0.000 0.000 0.968 0.000 0.032
#> GSM872269     5  0.3039      0.661 0.000 0.012 0.000 0.152 0.836
#> GSM872270     3  0.0000      0.900 0.000 0.000 1.000 0.000 0.000
#> GSM872271     5  0.4933      0.561 0.000 0.236 0.000 0.076 0.688
#> GSM872272     5  0.4933      0.561 0.000 0.236 0.000 0.076 0.688
#> GSM872273     1  0.0000      0.963 1.000 0.000 0.000 0.000 0.000
#> GSM872274     2  0.0000      0.886 0.000 1.000 0.000 0.000 0.000
#> GSM872275     5  0.3177      0.662 0.000 0.000 0.000 0.208 0.792
#> GSM872276     4  0.2648      0.785 0.152 0.000 0.000 0.848 0.000
#> GSM872277     1  0.0000      0.963 1.000 0.000 0.000 0.000 0.000
#> GSM872278     4  0.3534      0.626 0.000 0.000 0.000 0.744 0.256
#> GSM872279     1  0.0609      0.955 0.980 0.000 0.000 0.000 0.020
#> GSM872280     4  0.3318      0.699 0.008 0.000 0.000 0.800 0.192
#> GSM872281     4  0.0290      0.830 0.008 0.000 0.000 0.992 0.000
#> GSM872282     3  0.0703      0.898 0.000 0.000 0.976 0.000 0.024
#> GSM872283     1  0.3480      0.645 0.752 0.000 0.000 0.248 0.000
#> GSM872284     4  0.1792      0.809 0.000 0.000 0.000 0.916 0.084
#> GSM872285     4  0.3916      0.630 0.000 0.000 0.012 0.732 0.256
#> GSM872286     5  0.4138      0.448 0.000 0.000 0.000 0.384 0.616
#> GSM872287     3  0.0794      0.898 0.000 0.000 0.972 0.000 0.028
#> GSM872288     5  0.4302      0.136 0.000 0.000 0.000 0.480 0.520
#> GSM872289     3  0.5617      0.587 0.000 0.000 0.620 0.124 0.256
#> GSM872290     1  0.0000      0.963 1.000 0.000 0.000 0.000 0.000
#> GSM872291     4  0.2648      0.785 0.152 0.000 0.000 0.848 0.000
#> GSM872292     2  0.0000      0.886 0.000 1.000 0.000 0.000 0.000
#> GSM872293     1  0.0000      0.963 1.000 0.000 0.000 0.000 0.000
#> GSM872294     2  0.3957      0.631 0.000 0.712 0.000 0.008 0.280
#> GSM872295     2  0.0865      0.877 0.000 0.972 0.000 0.004 0.024
#> GSM872296     2  0.0000      0.886 0.000 1.000 0.000 0.000 0.000
#> GSM872297     1  0.0000      0.963 1.000 0.000 0.000 0.000 0.000
#> GSM872298     4  0.0290      0.830 0.008 0.000 0.000 0.992 0.000
#> GSM872299     1  0.0955      0.947 0.968 0.000 0.000 0.004 0.028
#> GSM872300     4  0.1121      0.835 0.044 0.000 0.000 0.956 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
#> GSM872244     3  0.1082     0.8932 0.000 0.000 0.956 0.000 0.040 0.004
#> GSM872245     1  0.0951     0.9114 0.968 0.000 0.000 0.020 0.008 0.004
#> GSM872246     3  0.1863     0.8636 0.000 0.000 0.896 0.104 0.000 0.000
#> GSM872247     3  0.0000     0.8939 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872248     5  0.1524     0.7265 0.000 0.060 0.000 0.008 0.932 0.000
#> GSM872249     3  0.1082     0.8932 0.000 0.000 0.956 0.000 0.040 0.004
#> GSM872250     5  0.3784     0.4678 0.000 0.000 0.000 0.308 0.680 0.012
#> GSM872251     3  0.3899     0.3531 0.000 0.000 0.592 0.404 0.000 0.004
#> GSM872252     6  0.4431     0.5332 0.000 0.000 0.000 0.228 0.080 0.692
#> GSM872253     4  0.3500     0.3161 0.000 0.000 0.000 0.768 0.204 0.028
#> GSM872254     2  0.5866     0.4896 0.000 0.512 0.000 0.232 0.252 0.004
#> GSM872255     6  0.0653     0.8442 0.004 0.000 0.000 0.012 0.004 0.980
#> GSM872256     1  0.0146     0.9226 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM872257     2  0.0146     0.8169 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM872258     4  0.4078     0.2846 0.000 0.000 0.340 0.640 0.000 0.020
#> GSM872259     1  0.0000     0.9231 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM872260     6  0.1251     0.8400 0.008 0.000 0.000 0.024 0.012 0.956
#> GSM872261     5  0.4480     0.4518 0.000 0.000 0.000 0.340 0.616 0.044
#> GSM872262     6  0.0777     0.8439 0.024 0.000 0.000 0.004 0.000 0.972
#> GSM872263     3  0.1082     0.8932 0.000 0.000 0.956 0.000 0.040 0.004
#> GSM872264     6  0.4475     0.6467 0.000 0.000 0.000 0.100 0.200 0.700
#> GSM872265     6  0.3650     0.7549 0.000 0.000 0.000 0.092 0.116 0.792
#> GSM872266     5  0.1524     0.7265 0.000 0.060 0.000 0.008 0.932 0.000
#> GSM872267     5  0.1524     0.7217 0.000 0.060 0.000 0.008 0.932 0.000
#> GSM872268     3  0.1814     0.8661 0.000 0.000 0.900 0.100 0.000 0.000
#> GSM872269     4  0.4310    -0.3056 0.000 0.004 0.000 0.512 0.472 0.012
#> GSM872270     3  0.0000     0.8939 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872271     5  0.2137     0.7281 0.000 0.048 0.000 0.028 0.912 0.012
#> GSM872272     5  0.2137     0.7281 0.000 0.048 0.000 0.028 0.912 0.012
#> GSM872273     1  0.0146     0.9226 0.996 0.000 0.000 0.004 0.000 0.000
#> GSM872274     2  0.0146     0.8169 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM872275     4  0.4131     0.1528 0.000 0.000 0.000 0.624 0.356 0.020
#> GSM872276     6  0.0858     0.8420 0.028 0.000 0.000 0.004 0.000 0.968
#> GSM872277     1  0.0146     0.9226 0.996 0.000 0.000 0.004 0.000 0.000
#> GSM872278     4  0.4057     0.2121 0.000 0.000 0.000 0.600 0.012 0.388
#> GSM872279     1  0.1053     0.9121 0.964 0.000 0.000 0.012 0.004 0.020
#> GSM872280     6  0.3854    -0.0337 0.000 0.000 0.000 0.464 0.000 0.536
#> GSM872281     6  0.1411     0.8361 0.000 0.000 0.000 0.060 0.004 0.936
#> GSM872282     3  0.1082     0.8932 0.000 0.000 0.956 0.000 0.040 0.004
#> GSM872283     1  0.5080     0.2073 0.552 0.000 0.000 0.056 0.012 0.380
#> GSM872284     6  0.2176     0.8251 0.000 0.000 0.000 0.080 0.024 0.896
#> GSM872285     4  0.3409     0.3837 0.000 0.000 0.000 0.700 0.000 0.300
#> GSM872286     5  0.5409     0.4215 0.000 0.000 0.000 0.188 0.580 0.232
#> GSM872287     3  0.1814     0.8661 0.000 0.000 0.900 0.100 0.000 0.000
#> GSM872288     5  0.5844     0.2156 0.000 0.000 0.000 0.324 0.468 0.208
#> GSM872289     4  0.4078     0.2846 0.000 0.000 0.340 0.640 0.000 0.020
#> GSM872290     1  0.0909     0.9132 0.968 0.000 0.000 0.012 0.000 0.020
#> GSM872291     6  0.1218     0.8397 0.028 0.000 0.000 0.012 0.004 0.956
#> GSM872292     2  0.0146     0.8169 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM872293     1  0.0000     0.9231 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM872294     2  0.6030     0.4475 0.000 0.468 0.000 0.256 0.272 0.004
#> GSM872295     2  0.2784     0.7709 0.000 0.848 0.000 0.124 0.028 0.000
#> GSM872296     2  0.0291     0.8161 0.000 0.992 0.000 0.004 0.004 0.000
#> GSM872297     1  0.0000     0.9231 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM872298     6  0.1398     0.8389 0.000 0.000 0.000 0.052 0.008 0.940
#> GSM872299     1  0.3062     0.8167 0.844 0.000 0.000 0.116 0.016 0.024
#> GSM872300     6  0.0405     0.8462 0.004 0.000 0.000 0.000 0.008 0.988

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

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>             n time(p) individual(p) k
#> ATC:kmeans 53   0.558      1.04e-03 2
#> ATC:kmeans 55   0.456      7.79e-04 3
#> ATC:kmeans 57   0.831      1.19e-04 4
#> ATC:kmeans 53   0.307      1.49e-05 5
#> ATC:kmeans 41   0.497      3.02e-04 6

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 29485 rows and 57 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 0.707           0.840       0.926         0.5044 0.495   0.495
#> 3 3 1.000           0.981       0.993         0.3236 0.791   0.597
#> 4 4 0.901           0.861       0.943         0.1236 0.893   0.688
#> 5 5 0.832           0.748       0.886         0.0447 0.937   0.763
#> 6 6 0.818           0.775       0.863         0.0354 0.951   0.790

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
#> GSM872244     2   0.000      0.857 0.000 1.000
#> GSM872245     1   0.000      0.983 1.000 0.000
#> GSM872246     2   0.000      0.857 0.000 1.000
#> GSM872247     2   0.000      0.857 0.000 1.000
#> GSM872248     2   0.909      0.612 0.324 0.676
#> GSM872249     2   0.000      0.857 0.000 1.000
#> GSM872250     2   0.000      0.857 0.000 1.000
#> GSM872251     2   0.000      0.857 0.000 1.000
#> GSM872252     1   0.000      0.983 1.000 0.000
#> GSM872253     2   0.000      0.857 0.000 1.000
#> GSM872254     2   0.909      0.612 0.324 0.676
#> GSM872255     1   0.000      0.983 1.000 0.000
#> GSM872256     1   0.000      0.983 1.000 0.000
#> GSM872257     2   0.909      0.612 0.324 0.676
#> GSM872258     2   0.000      0.857 0.000 1.000
#> GSM872259     1   0.000      0.983 1.000 0.000
#> GSM872260     1   0.000      0.983 1.000 0.000
#> GSM872261     1   0.000      0.983 1.000 0.000
#> GSM872262     1   0.000      0.983 1.000 0.000
#> GSM872263     2   0.000      0.857 0.000 1.000
#> GSM872264     2   0.827      0.624 0.260 0.740
#> GSM872265     1   0.000      0.983 1.000 0.000
#> GSM872266     2   0.909      0.612 0.324 0.676
#> GSM872267     1   0.163      0.954 0.976 0.024
#> GSM872268     2   0.000      0.857 0.000 1.000
#> GSM872269     2   0.204      0.842 0.032 0.968
#> GSM872270     2   0.000      0.857 0.000 1.000
#> GSM872271     2   0.988      0.412 0.436 0.564
#> GSM872272     2   0.980      0.456 0.416 0.584
#> GSM872273     1   0.000      0.983 1.000 0.000
#> GSM872274     2   0.909      0.612 0.324 0.676
#> GSM872275     2   0.000      0.857 0.000 1.000
#> GSM872276     1   0.000      0.983 1.000 0.000
#> GSM872277     1   0.000      0.983 1.000 0.000
#> GSM872278     2   0.000      0.857 0.000 1.000
#> GSM872279     1   0.000      0.983 1.000 0.000
#> GSM872280     2   0.996      0.135 0.464 0.536
#> GSM872281     1   0.909      0.440 0.676 0.324
#> GSM872282     2   0.000      0.857 0.000 1.000
#> GSM872283     1   0.000      0.983 1.000 0.000
#> GSM872284     1   0.000      0.983 1.000 0.000
#> GSM872285     2   0.000      0.857 0.000 1.000
#> GSM872286     1   0.000      0.983 1.000 0.000
#> GSM872287     2   0.000      0.857 0.000 1.000
#> GSM872288     2   0.929      0.480 0.344 0.656
#> GSM872289     2   0.000      0.857 0.000 1.000
#> GSM872290     1   0.000      0.983 1.000 0.000
#> GSM872291     1   0.000      0.983 1.000 0.000
#> GSM872292     2   0.000      0.857 0.000 1.000
#> GSM872293     1   0.000      0.983 1.000 0.000
#> GSM872294     1   0.000      0.983 1.000 0.000
#> GSM872295     2   0.000      0.857 0.000 1.000
#> GSM872296     2   0.909      0.612 0.324 0.676
#> GSM872297     1   0.000      0.983 1.000 0.000
#> GSM872298     1   0.000      0.983 1.000 0.000
#> GSM872299     1   0.000      0.983 1.000 0.000
#> GSM872300     1   0.000      0.983 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
#> GSM872244     3  0.0000      0.999 0.000 0.000 1.000
#> GSM872245     1  0.0000      1.000 1.000 0.000 0.000
#> GSM872246     3  0.0000      0.999 0.000 0.000 1.000
#> GSM872247     3  0.0000      0.999 0.000 0.000 1.000
#> GSM872248     2  0.0000      0.972 0.000 1.000 0.000
#> GSM872249     3  0.0000      0.999 0.000 0.000 1.000
#> GSM872250     2  0.6079      0.364 0.000 0.612 0.388
#> GSM872251     3  0.0000      0.999 0.000 0.000 1.000
#> GSM872252     1  0.0000      1.000 1.000 0.000 0.000
#> GSM872253     3  0.0000      0.999 0.000 0.000 1.000
#> GSM872254     2  0.0000      0.972 0.000 1.000 0.000
#> GSM872255     1  0.0000      1.000 1.000 0.000 0.000
#> GSM872256     1  0.0000      1.000 1.000 0.000 0.000
#> GSM872257     2  0.0000      0.972 0.000 1.000 0.000
#> GSM872258     3  0.0000      0.999 0.000 0.000 1.000
#> GSM872259     1  0.0000      1.000 1.000 0.000 0.000
#> GSM872260     1  0.0000      1.000 1.000 0.000 0.000
#> GSM872261     2  0.0000      0.972 0.000 1.000 0.000
#> GSM872262     1  0.0000      1.000 1.000 0.000 0.000
#> GSM872263     3  0.0000      0.999 0.000 0.000 1.000
#> GSM872264     3  0.0000      0.999 0.000 0.000 1.000
#> GSM872265     1  0.0000      1.000 1.000 0.000 0.000
#> GSM872266     2  0.0000      0.972 0.000 1.000 0.000
#> GSM872267     2  0.0000      0.972 0.000 1.000 0.000
#> GSM872268     3  0.0000      0.999 0.000 0.000 1.000
#> GSM872269     2  0.0000      0.972 0.000 1.000 0.000
#> GSM872270     3  0.0000      0.999 0.000 0.000 1.000
#> GSM872271     2  0.0000      0.972 0.000 1.000 0.000
#> GSM872272     2  0.0000      0.972 0.000 1.000 0.000
#> GSM872273     1  0.0000      1.000 1.000 0.000 0.000
#> GSM872274     2  0.0000      0.972 0.000 1.000 0.000
#> GSM872275     3  0.0592      0.987 0.000 0.012 0.988
#> GSM872276     1  0.0000      1.000 1.000 0.000 0.000
#> GSM872277     1  0.0000      1.000 1.000 0.000 0.000
#> GSM872278     3  0.0000      0.999 0.000 0.000 1.000
#> GSM872279     1  0.0000      1.000 1.000 0.000 0.000
#> GSM872280     3  0.0000      0.999 0.000 0.000 1.000
#> GSM872281     1  0.0000      1.000 1.000 0.000 0.000
#> GSM872282     3  0.0000      0.999 0.000 0.000 1.000
#> GSM872283     1  0.0000      1.000 1.000 0.000 0.000
#> GSM872284     1  0.0000      1.000 1.000 0.000 0.000
#> GSM872285     3  0.0000      0.999 0.000 0.000 1.000
#> GSM872286     1  0.0000      1.000 1.000 0.000 0.000
#> GSM872287     3  0.0000      0.999 0.000 0.000 1.000
#> GSM872288     3  0.0424      0.991 0.008 0.000 0.992
#> GSM872289     3  0.0000      0.999 0.000 0.000 1.000
#> GSM872290     1  0.0000      1.000 1.000 0.000 0.000
#> GSM872291     1  0.0000      1.000 1.000 0.000 0.000
#> GSM872292     2  0.0000      0.972 0.000 1.000 0.000
#> GSM872293     1  0.0000      1.000 1.000 0.000 0.000
#> GSM872294     2  0.0000      0.972 0.000 1.000 0.000
#> GSM872295     2  0.0000      0.972 0.000 1.000 0.000
#> GSM872296     2  0.0000      0.972 0.000 1.000 0.000
#> GSM872297     1  0.0000      1.000 1.000 0.000 0.000
#> GSM872298     1  0.0000      1.000 1.000 0.000 0.000
#> GSM872299     1  0.0000      1.000 1.000 0.000 0.000
#> GSM872300     1  0.0000      1.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM872244     3  0.0000     0.9864 0.000 0.000 1.000 0.000
#> GSM872245     1  0.0000     0.9167 1.000 0.000 0.000 0.000
#> GSM872246     3  0.0000     0.9864 0.000 0.000 1.000 0.000
#> GSM872247     3  0.0000     0.9864 0.000 0.000 1.000 0.000
#> GSM872248     2  0.0188     0.9660 0.000 0.996 0.000 0.004
#> GSM872249     3  0.0000     0.9864 0.000 0.000 1.000 0.000
#> GSM872250     2  0.5040     0.4212 0.000 0.628 0.364 0.008
#> GSM872251     3  0.0000     0.9864 0.000 0.000 1.000 0.000
#> GSM872252     1  0.0000     0.9167 1.000 0.000 0.000 0.000
#> GSM872253     3  0.0000     0.9864 0.000 0.000 1.000 0.000
#> GSM872254     2  0.0000     0.9668 0.000 1.000 0.000 0.000
#> GSM872255     1  0.4941     0.0784 0.564 0.000 0.000 0.436
#> GSM872256     1  0.0000     0.9167 1.000 0.000 0.000 0.000
#> GSM872257     2  0.0000     0.9668 0.000 1.000 0.000 0.000
#> GSM872258     3  0.0000     0.9864 0.000 0.000 1.000 0.000
#> GSM872259     1  0.0000     0.9167 1.000 0.000 0.000 0.000
#> GSM872260     1  0.1867     0.8548 0.928 0.000 0.000 0.072
#> GSM872261     2  0.0000     0.9668 0.000 1.000 0.000 0.000
#> GSM872262     4  0.4477     0.5556 0.312 0.000 0.000 0.688
#> GSM872263     3  0.0000     0.9864 0.000 0.000 1.000 0.000
#> GSM872264     4  0.1022     0.7608 0.000 0.000 0.032 0.968
#> GSM872265     4  0.1389     0.7609 0.048 0.000 0.000 0.952
#> GSM872266     2  0.0188     0.9660 0.000 0.996 0.000 0.004
#> GSM872267     2  0.0188     0.9660 0.000 0.996 0.000 0.004
#> GSM872268     3  0.0000     0.9864 0.000 0.000 1.000 0.000
#> GSM872269     2  0.0188     0.9648 0.000 0.996 0.000 0.004
#> GSM872270     3  0.0000     0.9864 0.000 0.000 1.000 0.000
#> GSM872271     2  0.0188     0.9660 0.000 0.996 0.000 0.004
#> GSM872272     2  0.0188     0.9660 0.000 0.996 0.000 0.004
#> GSM872273     1  0.0188     0.9141 0.996 0.000 0.000 0.004
#> GSM872274     2  0.0000     0.9668 0.000 1.000 0.000 0.000
#> GSM872275     3  0.0336     0.9780 0.000 0.008 0.992 0.000
#> GSM872276     4  0.4500     0.5491 0.316 0.000 0.000 0.684
#> GSM872277     1  0.2704     0.7789 0.876 0.000 0.000 0.124
#> GSM872278     3  0.0000     0.9864 0.000 0.000 1.000 0.000
#> GSM872279     1  0.0000     0.9167 1.000 0.000 0.000 0.000
#> GSM872280     3  0.3486     0.7491 0.000 0.000 0.812 0.188
#> GSM872281     4  0.0336     0.7709 0.008 0.000 0.000 0.992
#> GSM872282     3  0.0000     0.9864 0.000 0.000 1.000 0.000
#> GSM872283     4  0.4972     0.1653 0.456 0.000 0.000 0.544
#> GSM872284     4  0.0336     0.7709 0.008 0.000 0.000 0.992
#> GSM872285     3  0.0000     0.9864 0.000 0.000 1.000 0.000
#> GSM872286     1  0.0188     0.9135 0.996 0.000 0.000 0.004
#> GSM872287     3  0.0000     0.9864 0.000 0.000 1.000 0.000
#> GSM872288     4  0.3942     0.5818 0.000 0.000 0.236 0.764
#> GSM872289     3  0.0000     0.9864 0.000 0.000 1.000 0.000
#> GSM872290     1  0.0000     0.9167 1.000 0.000 0.000 0.000
#> GSM872291     1  0.4164     0.5640 0.736 0.000 0.000 0.264
#> GSM872292     2  0.0000     0.9668 0.000 1.000 0.000 0.000
#> GSM872293     1  0.0000     0.9167 1.000 0.000 0.000 0.000
#> GSM872294     2  0.0000     0.9668 0.000 1.000 0.000 0.000
#> GSM872295     2  0.0000     0.9668 0.000 1.000 0.000 0.000
#> GSM872296     2  0.0000     0.9668 0.000 1.000 0.000 0.000
#> GSM872297     1  0.0000     0.9167 1.000 0.000 0.000 0.000
#> GSM872298     4  0.0336     0.7709 0.008 0.000 0.000 0.992
#> GSM872299     1  0.0000     0.9167 1.000 0.000 0.000 0.000
#> GSM872300     4  0.4477     0.5556 0.312 0.000 0.000 0.688

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM872244     3  0.0000     0.9557 0.000 0.000 1.000 0.000 0.000
#> GSM872245     1  0.0162     0.8772 0.996 0.000 0.000 0.000 0.004
#> GSM872246     3  0.0000     0.9557 0.000 0.000 1.000 0.000 0.000
#> GSM872247     3  0.0000     0.9557 0.000 0.000 1.000 0.000 0.000
#> GSM872248     2  0.3508     0.7520 0.000 0.748 0.000 0.000 0.252
#> GSM872249     3  0.0000     0.9557 0.000 0.000 1.000 0.000 0.000
#> GSM872250     5  0.4335     0.4148 0.000 0.168 0.072 0.000 0.760
#> GSM872251     3  0.0000     0.9557 0.000 0.000 1.000 0.000 0.000
#> GSM872252     1  0.0912     0.8618 0.972 0.000 0.000 0.012 0.016
#> GSM872253     3  0.1331     0.9169 0.000 0.008 0.952 0.000 0.040
#> GSM872254     2  0.0609     0.8755 0.000 0.980 0.000 0.000 0.020
#> GSM872255     4  0.3857     0.5549 0.312 0.000 0.000 0.688 0.000
#> GSM872256     1  0.0000     0.8794 1.000 0.000 0.000 0.000 0.000
#> GSM872257     2  0.0000     0.8819 0.000 1.000 0.000 0.000 0.000
#> GSM872258     3  0.0000     0.9557 0.000 0.000 1.000 0.000 0.000
#> GSM872259     1  0.0000     0.8794 1.000 0.000 0.000 0.000 0.000
#> GSM872260     1  0.4262    -0.0411 0.560 0.000 0.000 0.440 0.000
#> GSM872261     2  0.1956     0.8517 0.008 0.916 0.000 0.000 0.076
#> GSM872262     4  0.3074     0.6663 0.196 0.000 0.000 0.804 0.000
#> GSM872263     3  0.0000     0.9557 0.000 0.000 1.000 0.000 0.000
#> GSM872264     4  0.5154     0.2840 0.000 0.000 0.048 0.580 0.372
#> GSM872265     4  0.5405     0.4082 0.104 0.000 0.000 0.640 0.256
#> GSM872266     2  0.3452     0.7601 0.000 0.756 0.000 0.000 0.244
#> GSM872267     2  0.3508     0.7520 0.000 0.748 0.000 0.000 0.252
#> GSM872268     3  0.0000     0.9557 0.000 0.000 1.000 0.000 0.000
#> GSM872269     2  0.3109     0.7062 0.000 0.800 0.000 0.000 0.200
#> GSM872270     3  0.0000     0.9557 0.000 0.000 1.000 0.000 0.000
#> GSM872271     2  0.2605     0.8317 0.000 0.852 0.000 0.000 0.148
#> GSM872272     2  0.2732     0.8252 0.000 0.840 0.000 0.000 0.160
#> GSM872273     1  0.0290     0.8746 0.992 0.000 0.000 0.008 0.000
#> GSM872274     2  0.0000     0.8819 0.000 1.000 0.000 0.000 0.000
#> GSM872275     3  0.2848     0.8171 0.000 0.104 0.868 0.000 0.028
#> GSM872276     4  0.3143     0.6650 0.204 0.000 0.000 0.796 0.000
#> GSM872277     1  0.1478     0.8157 0.936 0.000 0.000 0.064 0.000
#> GSM872278     3  0.0000     0.9557 0.000 0.000 1.000 0.000 0.000
#> GSM872279     1  0.0000     0.8794 1.000 0.000 0.000 0.000 0.000
#> GSM872280     3  0.4262     0.2346 0.000 0.000 0.560 0.440 0.000
#> GSM872281     4  0.1732     0.5984 0.000 0.000 0.000 0.920 0.080
#> GSM872282     3  0.0000     0.9557 0.000 0.000 1.000 0.000 0.000
#> GSM872283     1  0.6430     0.0459 0.480 0.000 0.000 0.328 0.192
#> GSM872284     4  0.3480     0.5004 0.000 0.000 0.000 0.752 0.248
#> GSM872285     3  0.0000     0.9557 0.000 0.000 1.000 0.000 0.000
#> GSM872286     5  0.4306     0.0168 0.492 0.000 0.000 0.000 0.508
#> GSM872287     3  0.0000     0.9557 0.000 0.000 1.000 0.000 0.000
#> GSM872288     5  0.1981     0.4346 0.000 0.000 0.028 0.048 0.924
#> GSM872289     3  0.0000     0.9557 0.000 0.000 1.000 0.000 0.000
#> GSM872290     1  0.0000     0.8794 1.000 0.000 0.000 0.000 0.000
#> GSM872291     4  0.4287     0.2419 0.460 0.000 0.000 0.540 0.000
#> GSM872292     2  0.0000     0.8819 0.000 1.000 0.000 0.000 0.000
#> GSM872293     1  0.0000     0.8794 1.000 0.000 0.000 0.000 0.000
#> GSM872294     2  0.0000     0.8819 0.000 1.000 0.000 0.000 0.000
#> GSM872295     2  0.0510     0.8771 0.000 0.984 0.000 0.000 0.016
#> GSM872296     2  0.0000     0.8819 0.000 1.000 0.000 0.000 0.000
#> GSM872297     1  0.0000     0.8794 1.000 0.000 0.000 0.000 0.000
#> GSM872298     4  0.0963     0.6352 0.036 0.000 0.000 0.964 0.000
#> GSM872299     1  0.0162     0.8772 0.996 0.000 0.000 0.000 0.004
#> GSM872300     4  0.3143     0.6650 0.204 0.000 0.000 0.796 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
#> GSM872244     3  0.0146      0.973 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM872245     1  0.0937      0.926 0.960 0.000 0.000 0.000 0.000 0.040
#> GSM872246     3  0.0000      0.974 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872247     3  0.0000      0.974 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872248     2  0.6129      0.514 0.000 0.536 0.000 0.116 0.296 0.052
#> GSM872249     3  0.0146      0.973 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM872250     5  0.0858      0.636 0.000 0.028 0.000 0.004 0.968 0.000
#> GSM872251     3  0.0000      0.974 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872252     1  0.3652      0.800 0.816 0.000 0.000 0.084 0.020 0.080
#> GSM872253     3  0.3766      0.809 0.000 0.008 0.820 0.084 0.064 0.024
#> GSM872254     2  0.1788      0.714 0.000 0.928 0.000 0.028 0.040 0.004
#> GSM872255     6  0.2300      0.793 0.144 0.000 0.000 0.000 0.000 0.856
#> GSM872256     1  0.0146      0.955 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM872257     2  0.0000      0.732 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM872258     3  0.0000      0.974 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872259     1  0.0146      0.955 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM872260     6  0.3271      0.712 0.232 0.000 0.000 0.008 0.000 0.760
#> GSM872261     2  0.6451      0.534 0.032 0.604 0.000 0.188 0.096 0.080
#> GSM872262     6  0.2257      0.798 0.116 0.000 0.000 0.008 0.000 0.876
#> GSM872263     3  0.0000      0.974 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872264     4  0.3996      0.650 0.000 0.000 0.036 0.780 0.036 0.148
#> GSM872265     4  0.4001      0.686 0.112 0.000 0.000 0.760 0.000 0.128
#> GSM872266     2  0.6116      0.518 0.000 0.540 0.000 0.116 0.292 0.052
#> GSM872267     2  0.6169      0.516 0.000 0.536 0.000 0.124 0.288 0.052
#> GSM872268     3  0.0000      0.974 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872269     2  0.5840      0.428 0.000 0.616 0.000 0.148 0.184 0.052
#> GSM872270     3  0.0146      0.973 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM872271     2  0.6072      0.565 0.000 0.584 0.000 0.184 0.180 0.052
#> GSM872272     2  0.6098      0.561 0.000 0.580 0.000 0.188 0.180 0.052
#> GSM872273     1  0.0260      0.953 0.992 0.000 0.000 0.000 0.000 0.008
#> GSM872274     2  0.0000      0.732 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM872275     3  0.3676      0.791 0.000 0.120 0.816 0.032 0.024 0.008
#> GSM872276     6  0.2346      0.800 0.124 0.000 0.000 0.008 0.000 0.868
#> GSM872277     1  0.0458      0.947 0.984 0.000 0.000 0.000 0.000 0.016
#> GSM872278     3  0.0291      0.971 0.000 0.000 0.992 0.004 0.000 0.004
#> GSM872279     1  0.0291      0.953 0.992 0.000 0.000 0.004 0.000 0.004
#> GSM872280     6  0.3795      0.342 0.000 0.000 0.364 0.004 0.000 0.632
#> GSM872281     6  0.3563      0.304 0.000 0.000 0.000 0.336 0.000 0.664
#> GSM872282     3  0.0146      0.973 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM872283     4  0.4552      0.390 0.388 0.000 0.000 0.572 0.000 0.040
#> GSM872284     4  0.3309      0.618 0.000 0.000 0.000 0.720 0.000 0.280
#> GSM872285     3  0.0146      0.972 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM872286     5  0.3515      0.463 0.324 0.000 0.000 0.000 0.676 0.000
#> GSM872287     3  0.0000      0.974 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872288     5  0.2730      0.607 0.000 0.000 0.012 0.152 0.836 0.000
#> GSM872289     3  0.0146      0.972 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM872290     1  0.0405      0.953 0.988 0.000 0.000 0.004 0.000 0.008
#> GSM872291     6  0.2933      0.754 0.200 0.000 0.000 0.004 0.000 0.796
#> GSM872292     2  0.0000      0.732 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM872293     1  0.0000      0.954 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM872294     2  0.2677      0.686 0.000 0.884 0.000 0.056 0.024 0.036
#> GSM872295     2  0.1642      0.716 0.000 0.936 0.000 0.028 0.032 0.004
#> GSM872296     2  0.0000      0.732 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM872297     1  0.0146      0.955 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM872298     6  0.2629      0.742 0.060 0.000 0.000 0.068 0.000 0.872
#> GSM872299     1  0.2760      0.854 0.872 0.000 0.000 0.068 0.008 0.052
#> GSM872300     6  0.2302      0.800 0.120 0.000 0.000 0.008 0.000 0.872

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

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>              n time(p) individual(p) k
#> ATC:skmeans 52   0.389      1.27e-02 2
#> ATC:skmeans 56   0.724      1.67e-02 3
#> ATC:skmeans 54   0.634      2.57e-03 4
#> ATC:skmeans 48   0.938      1.39e-03 5
#> ATC:skmeans 52   0.880      3.17e-07 6

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 29485 rows and 57 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.981       0.985         0.3448 0.662   0.662
#> 3 3 0.999           0.957       0.982         0.8394 0.709   0.561
#> 4 4 0.957           0.947       0.977         0.1743 0.872   0.661
#> 5 5 0.960           0.943       0.977         0.0392 0.972   0.892
#> 6 6 0.836           0.468       0.815         0.0506 0.932   0.730

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
#> GSM872244     2  0.0000      0.977 0.000 1.000
#> GSM872245     1  0.1633      0.982 0.976 0.024
#> GSM872246     2  0.1633      0.991 0.024 0.976
#> GSM872247     2  0.1633      0.991 0.024 0.976
#> GSM872248     1  0.1633      0.982 0.976 0.024
#> GSM872249     2  0.1633      0.991 0.024 0.976
#> GSM872250     1  0.1633      0.982 0.976 0.024
#> GSM872251     2  0.1633      0.991 0.024 0.976
#> GSM872252     1  0.0000      0.986 1.000 0.000
#> GSM872253     1  0.0000      0.986 1.000 0.000
#> GSM872254     1  0.1633      0.982 0.976 0.024
#> GSM872255     1  0.0000      0.986 1.000 0.000
#> GSM872256     1  0.0000      0.986 1.000 0.000
#> GSM872257     1  0.1633      0.982 0.976 0.024
#> GSM872258     2  0.2948      0.969 0.052 0.948
#> GSM872259     1  0.0000      0.986 1.000 0.000
#> GSM872260     1  0.0000      0.986 1.000 0.000
#> GSM872261     1  0.1633      0.982 0.976 0.024
#> GSM872262     1  0.0000      0.986 1.000 0.000
#> GSM872263     2  0.1633      0.991 0.024 0.976
#> GSM872264     1  0.0000      0.986 1.000 0.000
#> GSM872265     1  0.0000      0.986 1.000 0.000
#> GSM872266     1  0.1633      0.982 0.976 0.024
#> GSM872267     1  0.1633      0.982 0.976 0.024
#> GSM872268     2  0.1633      0.991 0.024 0.976
#> GSM872269     1  0.1633      0.982 0.976 0.024
#> GSM872270     2  0.0938      0.986 0.012 0.988
#> GSM872271     1  0.1633      0.982 0.976 0.024
#> GSM872272     1  0.1633      0.982 0.976 0.024
#> GSM872273     1  0.0000      0.986 1.000 0.000
#> GSM872274     1  0.1633      0.982 0.976 0.024
#> GSM872275     1  0.0672      0.985 0.992 0.008
#> GSM872276     1  0.0000      0.986 1.000 0.000
#> GSM872277     1  0.0000      0.986 1.000 0.000
#> GSM872278     1  0.0000      0.986 1.000 0.000
#> GSM872279     1  0.0000      0.986 1.000 0.000
#> GSM872280     1  0.0000      0.986 1.000 0.000
#> GSM872281     1  0.0000      0.986 1.000 0.000
#> GSM872282     2  0.0000      0.977 0.000 1.000
#> GSM872283     1  0.0000      0.986 1.000 0.000
#> GSM872284     1  0.0000      0.986 1.000 0.000
#> GSM872285     1  0.6712      0.778 0.824 0.176
#> GSM872286     1  0.1633      0.982 0.976 0.024
#> GSM872287     2  0.1633      0.991 0.024 0.976
#> GSM872288     1  0.0000      0.986 1.000 0.000
#> GSM872289     2  0.2043      0.986 0.032 0.968
#> GSM872290     1  0.0000      0.986 1.000 0.000
#> GSM872291     1  0.0000      0.986 1.000 0.000
#> GSM872292     1  0.1633      0.982 0.976 0.024
#> GSM872293     1  0.0000      0.986 1.000 0.000
#> GSM872294     1  0.1633      0.982 0.976 0.024
#> GSM872295     1  0.1633      0.982 0.976 0.024
#> GSM872296     1  0.1633      0.982 0.976 0.024
#> GSM872297     1  0.0000      0.986 1.000 0.000
#> GSM872298     1  0.0000      0.986 1.000 0.000
#> GSM872299     1  0.1414      0.982 0.980 0.020
#> GSM872300     1  0.0000      0.986 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
#> GSM872244     3  0.0000      0.988 0.000 0.000 1.000
#> GSM872245     2  0.0000      0.997 0.000 1.000 0.000
#> GSM872246     3  0.0000      0.988 0.000 0.000 1.000
#> GSM872247     3  0.0000      0.988 0.000 0.000 1.000
#> GSM872248     2  0.0000      0.997 0.000 1.000 0.000
#> GSM872249     3  0.0000      0.988 0.000 0.000 1.000
#> GSM872250     2  0.0000      0.997 0.000 1.000 0.000
#> GSM872251     3  0.0000      0.988 0.000 0.000 1.000
#> GSM872252     1  0.0000      0.966 1.000 0.000 0.000
#> GSM872253     1  0.0000      0.966 1.000 0.000 0.000
#> GSM872254     2  0.0000      0.997 0.000 1.000 0.000
#> GSM872255     1  0.0000      0.966 1.000 0.000 0.000
#> GSM872256     1  0.0000      0.966 1.000 0.000 0.000
#> GSM872257     2  0.0000      0.997 0.000 1.000 0.000
#> GSM872258     3  0.2878      0.884 0.096 0.000 0.904
#> GSM872259     1  0.0000      0.966 1.000 0.000 0.000
#> GSM872260     1  0.0000      0.966 1.000 0.000 0.000
#> GSM872261     2  0.1529      0.948 0.040 0.960 0.000
#> GSM872262     1  0.0000      0.966 1.000 0.000 0.000
#> GSM872263     3  0.0000      0.988 0.000 0.000 1.000
#> GSM872264     1  0.2625      0.892 0.916 0.084 0.000
#> GSM872265     1  0.0000      0.966 1.000 0.000 0.000
#> GSM872266     2  0.0000      0.997 0.000 1.000 0.000
#> GSM872267     2  0.0000      0.997 0.000 1.000 0.000
#> GSM872268     3  0.0000      0.988 0.000 0.000 1.000
#> GSM872269     2  0.0000      0.997 0.000 1.000 0.000
#> GSM872270     3  0.0000      0.988 0.000 0.000 1.000
#> GSM872271     2  0.0000      0.997 0.000 1.000 0.000
#> GSM872272     2  0.0000      0.997 0.000 1.000 0.000
#> GSM872273     1  0.0000      0.966 1.000 0.000 0.000
#> GSM872274     2  0.0000      0.997 0.000 1.000 0.000
#> GSM872275     1  0.6062      0.399 0.616 0.384 0.000
#> GSM872276     1  0.0000      0.966 1.000 0.000 0.000
#> GSM872277     1  0.0000      0.966 1.000 0.000 0.000
#> GSM872278     1  0.0000      0.966 1.000 0.000 0.000
#> GSM872279     1  0.0000      0.966 1.000 0.000 0.000
#> GSM872280     1  0.0000      0.966 1.000 0.000 0.000
#> GSM872281     1  0.0000      0.966 1.000 0.000 0.000
#> GSM872282     3  0.0000      0.988 0.000 0.000 1.000
#> GSM872283     1  0.0000      0.966 1.000 0.000 0.000
#> GSM872284     1  0.0000      0.966 1.000 0.000 0.000
#> GSM872285     1  0.0000      0.966 1.000 0.000 0.000
#> GSM872286     1  0.4235      0.792 0.824 0.176 0.000
#> GSM872287     3  0.0000      0.988 0.000 0.000 1.000
#> GSM872288     1  0.0000      0.966 1.000 0.000 0.000
#> GSM872289     3  0.0747      0.974 0.016 0.000 0.984
#> GSM872290     1  0.0000      0.966 1.000 0.000 0.000
#> GSM872291     1  0.0000      0.966 1.000 0.000 0.000
#> GSM872292     2  0.0000      0.997 0.000 1.000 0.000
#> GSM872293     1  0.0000      0.966 1.000 0.000 0.000
#> GSM872294     2  0.0000      0.997 0.000 1.000 0.000
#> GSM872295     2  0.0000      0.997 0.000 1.000 0.000
#> GSM872296     2  0.0000      0.997 0.000 1.000 0.000
#> GSM872297     1  0.0000      0.966 1.000 0.000 0.000
#> GSM872298     1  0.0000      0.966 1.000 0.000 0.000
#> GSM872299     1  0.5098      0.682 0.752 0.248 0.000
#> GSM872300     1  0.0000      0.966 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM872244     3   0.000      0.978 0.000 0.000 1.000 0.000
#> GSM872245     1   0.000      0.953 1.000 0.000 0.000 0.000
#> GSM872246     3   0.000      0.978 0.000 0.000 1.000 0.000
#> GSM872247     3   0.000      0.978 0.000 0.000 1.000 0.000
#> GSM872248     2   0.000      0.996 0.000 1.000 0.000 0.000
#> GSM872249     3   0.000      0.978 0.000 0.000 1.000 0.000
#> GSM872250     2   0.000      0.996 0.000 1.000 0.000 0.000
#> GSM872251     3   0.000      0.978 0.000 0.000 1.000 0.000
#> GSM872252     4   0.000      0.964 0.000 0.000 0.000 1.000
#> GSM872253     4   0.000      0.964 0.000 0.000 0.000 1.000
#> GSM872254     2   0.000      0.996 0.000 1.000 0.000 0.000
#> GSM872255     4   0.000      0.964 0.000 0.000 0.000 1.000
#> GSM872256     1   0.000      0.953 1.000 0.000 0.000 0.000
#> GSM872257     2   0.000      0.996 0.000 1.000 0.000 0.000
#> GSM872258     3   0.317      0.797 0.000 0.000 0.840 0.160
#> GSM872259     1   0.000      0.953 1.000 0.000 0.000 0.000
#> GSM872260     4   0.000      0.964 0.000 0.000 0.000 1.000
#> GSM872261     2   0.130      0.944 0.000 0.956 0.000 0.044
#> GSM872262     4   0.000      0.964 0.000 0.000 0.000 1.000
#> GSM872263     3   0.000      0.978 0.000 0.000 1.000 0.000
#> GSM872264     4   0.000      0.964 0.000 0.000 0.000 1.000
#> GSM872265     4   0.000      0.964 0.000 0.000 0.000 1.000
#> GSM872266     2   0.000      0.996 0.000 1.000 0.000 0.000
#> GSM872267     2   0.000      0.996 0.000 1.000 0.000 0.000
#> GSM872268     3   0.000      0.978 0.000 0.000 1.000 0.000
#> GSM872269     2   0.000      0.996 0.000 1.000 0.000 0.000
#> GSM872270     3   0.000      0.978 0.000 0.000 1.000 0.000
#> GSM872271     2   0.000      0.996 0.000 1.000 0.000 0.000
#> GSM872272     2   0.000      0.996 0.000 1.000 0.000 0.000
#> GSM872273     1   0.000      0.953 1.000 0.000 0.000 0.000
#> GSM872274     2   0.000      0.996 0.000 1.000 0.000 0.000
#> GSM872275     4   0.428      0.616 0.000 0.280 0.000 0.720
#> GSM872276     4   0.000      0.964 0.000 0.000 0.000 1.000
#> GSM872277     1   0.000      0.953 1.000 0.000 0.000 0.000
#> GSM872278     4   0.000      0.964 0.000 0.000 0.000 1.000
#> GSM872279     1   0.000      0.953 1.000 0.000 0.000 0.000
#> GSM872280     4   0.000      0.964 0.000 0.000 0.000 1.000
#> GSM872281     4   0.000      0.964 0.000 0.000 0.000 1.000
#> GSM872282     3   0.000      0.978 0.000 0.000 1.000 0.000
#> GSM872283     4   0.365      0.730 0.204 0.000 0.000 0.796
#> GSM872284     4   0.000      0.964 0.000 0.000 0.000 1.000
#> GSM872285     4   0.000      0.964 0.000 0.000 0.000 1.000
#> GSM872286     4   0.281      0.832 0.000 0.132 0.000 0.868
#> GSM872287     3   0.000      0.978 0.000 0.000 1.000 0.000
#> GSM872288     4   0.000      0.964 0.000 0.000 0.000 1.000
#> GSM872289     3   0.112      0.945 0.000 0.000 0.964 0.036
#> GSM872290     1   0.000      0.953 1.000 0.000 0.000 0.000
#> GSM872291     4   0.000      0.964 0.000 0.000 0.000 1.000
#> GSM872292     2   0.000      0.996 0.000 1.000 0.000 0.000
#> GSM872293     1   0.000      0.953 1.000 0.000 0.000 0.000
#> GSM872294     2   0.000      0.996 0.000 1.000 0.000 0.000
#> GSM872295     2   0.000      0.996 0.000 1.000 0.000 0.000
#> GSM872296     2   0.000      0.996 0.000 1.000 0.000 0.000
#> GSM872297     1   0.000      0.953 1.000 0.000 0.000 0.000
#> GSM872298     4   0.000      0.964 0.000 0.000 0.000 1.000
#> GSM872299     1   0.701      0.412 0.552 0.300 0.000 0.148
#> GSM872300     4   0.000      0.964 0.000 0.000 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1 p2    p3    p4    p5
#> GSM872244     3  0.0000      0.975 0.000  0 1.000 0.000 0.000
#> GSM872245     1  0.0000      0.944 1.000  0 0.000 0.000 0.000
#> GSM872246     3  0.0000      0.975 0.000  0 1.000 0.000 0.000
#> GSM872247     3  0.0000      0.975 0.000  0 1.000 0.000 0.000
#> GSM872248     5  0.0000      0.994 0.000  0 0.000 0.000 1.000
#> GSM872249     3  0.0000      0.975 0.000  0 1.000 0.000 0.000
#> GSM872250     5  0.0000      0.994 0.000  0 0.000 0.000 1.000
#> GSM872251     3  0.0000      0.975 0.000  0 1.000 0.000 0.000
#> GSM872252     4  0.0000      0.963 0.000  0 0.000 1.000 0.000
#> GSM872253     4  0.0000      0.963 0.000  0 0.000 1.000 0.000
#> GSM872254     5  0.0000      0.994 0.000  0 0.000 0.000 1.000
#> GSM872255     4  0.0000      0.963 0.000  0 0.000 1.000 0.000
#> GSM872256     1  0.0000      0.944 1.000  0 0.000 0.000 0.000
#> GSM872257     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> GSM872258     3  0.2732      0.763 0.000  0 0.840 0.160 0.000
#> GSM872259     1  0.0000      0.944 1.000  0 0.000 0.000 0.000
#> GSM872260     4  0.0000      0.963 0.000  0 0.000 1.000 0.000
#> GSM872261     5  0.1121      0.935 0.000  0 0.000 0.044 0.956
#> GSM872262     4  0.0000      0.963 0.000  0 0.000 1.000 0.000
#> GSM872263     3  0.0000      0.975 0.000  0 1.000 0.000 0.000
#> GSM872264     4  0.0000      0.963 0.000  0 0.000 1.000 0.000
#> GSM872265     4  0.0000      0.963 0.000  0 0.000 1.000 0.000
#> GSM872266     5  0.0000      0.994 0.000  0 0.000 0.000 1.000
#> GSM872267     5  0.0000      0.994 0.000  0 0.000 0.000 1.000
#> GSM872268     3  0.0000      0.975 0.000  0 1.000 0.000 0.000
#> GSM872269     5  0.0000      0.994 0.000  0 0.000 0.000 1.000
#> GSM872270     3  0.0000      0.975 0.000  0 1.000 0.000 0.000
#> GSM872271     5  0.0000      0.994 0.000  0 0.000 0.000 1.000
#> GSM872272     5  0.0000      0.994 0.000  0 0.000 0.000 1.000
#> GSM872273     1  0.0000      0.944 1.000  0 0.000 0.000 0.000
#> GSM872274     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> GSM872275     4  0.3684      0.615 0.000  0 0.000 0.720 0.280
#> GSM872276     4  0.0000      0.963 0.000  0 0.000 1.000 0.000
#> GSM872277     1  0.0000      0.944 1.000  0 0.000 0.000 0.000
#> GSM872278     4  0.0000      0.963 0.000  0 0.000 1.000 0.000
#> GSM872279     1  0.0000      0.944 1.000  0 0.000 0.000 0.000
#> GSM872280     4  0.0000      0.963 0.000  0 0.000 1.000 0.000
#> GSM872281     4  0.0000      0.963 0.000  0 0.000 1.000 0.000
#> GSM872282     3  0.0000      0.975 0.000  0 1.000 0.000 0.000
#> GSM872283     4  0.3143      0.729 0.204  0 0.000 0.796 0.000
#> GSM872284     4  0.0000      0.963 0.000  0 0.000 1.000 0.000
#> GSM872285     4  0.0000      0.963 0.000  0 0.000 1.000 0.000
#> GSM872286     4  0.2424      0.827 0.000  0 0.000 0.868 0.132
#> GSM872287     3  0.0000      0.975 0.000  0 1.000 0.000 0.000
#> GSM872288     4  0.0000      0.963 0.000  0 0.000 1.000 0.000
#> GSM872289     3  0.0963      0.937 0.000  0 0.964 0.036 0.000
#> GSM872290     1  0.0000      0.944 1.000  0 0.000 0.000 0.000
#> GSM872291     4  0.0000      0.963 0.000  0 0.000 1.000 0.000
#> GSM872292     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> GSM872293     1  0.0000      0.944 1.000  0 0.000 0.000 0.000
#> GSM872294     5  0.0000      0.994 0.000  0 0.000 0.000 1.000
#> GSM872295     5  0.0000      0.994 0.000  0 0.000 0.000 1.000
#> GSM872296     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> GSM872297     1  0.0000      0.944 1.000  0 0.000 0.000 0.000
#> GSM872298     4  0.0000      0.963 0.000  0 0.000 1.000 0.000
#> GSM872299     1  0.6039      0.383 0.552  0 0.000 0.148 0.300
#> GSM872300     4  0.0000      0.963 0.000  0 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1 p2    p3    p4    p5    p6
#> GSM872244     3   0.000      0.805 0.000  0 1.000 0.000 0.000 0.000
#> GSM872245     4   0.386      0.000 0.480  0 0.000 0.520 0.000 0.000
#> GSM872246     3   0.300      0.838 0.000  0 0.772 0.228 0.000 0.000
#> GSM872247     3   0.300      0.838 0.000  0 0.772 0.228 0.000 0.000
#> GSM872248     5   0.000      0.887 0.000  0 0.000 0.000 1.000 0.000
#> GSM872249     3   0.000      0.805 0.000  0 1.000 0.000 0.000 0.000
#> GSM872250     5   0.000      0.887 0.000  0 0.000 0.000 1.000 0.000
#> GSM872251     3   0.386      0.712 0.000  0 0.524 0.476 0.000 0.000
#> GSM872252     6   0.000      0.433 0.000  0 0.000 0.000 0.000 1.000
#> GSM872253     6   0.315      0.156 0.000  0 0.000 0.252 0.000 0.748
#> GSM872254     5   0.000      0.887 0.000  0 0.000 0.000 1.000 0.000
#> GSM872255     6   0.382      0.794 0.432  0 0.000 0.000 0.000 0.568
#> GSM872256     1   0.382     -0.799 0.568  0 0.000 0.432 0.000 0.000
#> GSM872257     2   0.000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> GSM872258     3   0.386      0.709 0.000  0 0.520 0.480 0.000 0.000
#> GSM872259     1   0.382     -0.799 0.568  0 0.000 0.432 0.000 0.000
#> GSM872260     6   0.382      0.794 0.432  0 0.000 0.000 0.000 0.568
#> GSM872261     5   0.101      0.843 0.000  0 0.000 0.000 0.956 0.044
#> GSM872262     6   0.382      0.794 0.432  0 0.000 0.000 0.000 0.568
#> GSM872263     3   0.000      0.805 0.000  0 1.000 0.000 0.000 0.000
#> GSM872264     6   0.382      0.794 0.432  0 0.000 0.000 0.000 0.568
#> GSM872265     6   0.382      0.794 0.432  0 0.000 0.000 0.000 0.568
#> GSM872266     5   0.000      0.887 0.000  0 0.000 0.000 1.000 0.000
#> GSM872267     5   0.000      0.887 0.000  0 0.000 0.000 1.000 0.000
#> GSM872268     3   0.300      0.838 0.000  0 0.772 0.228 0.000 0.000
#> GSM872269     5   0.444      0.455 0.000  0 0.000 0.028 0.540 0.432
#> GSM872270     3   0.171      0.826 0.000  0 0.908 0.092 0.000 0.000
#> GSM872271     5   0.000      0.887 0.000  0 0.000 0.000 1.000 0.000
#> GSM872272     5   0.000      0.887 0.000  0 0.000 0.000 1.000 0.000
#> GSM872273     1   0.382     -0.799 0.568  0 0.000 0.432 0.000 0.000
#> GSM872274     2   0.000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> GSM872275     1   0.765     -0.304 0.308  0 0.000 0.232 0.272 0.188
#> GSM872276     6   0.382      0.794 0.432  0 0.000 0.000 0.000 0.568
#> GSM872277     1   0.382     -0.799 0.568  0 0.000 0.432 0.000 0.000
#> GSM872278     6   0.382      0.794 0.432  0 0.000 0.000 0.000 0.568
#> GSM872279     1   0.562     -0.307 0.480  0 0.000 0.152 0.000 0.368
#> GSM872280     6   0.414      0.784 0.432  0 0.000 0.012 0.000 0.556
#> GSM872281     6   0.382      0.794 0.432  0 0.000 0.000 0.000 0.568
#> GSM872282     3   0.000      0.805 0.000  0 1.000 0.000 0.000 0.000
#> GSM872283     1   0.366     -0.577 0.636  0 0.000 0.000 0.000 0.364
#> GSM872284     6   0.382      0.794 0.432  0 0.000 0.000 0.000 0.568
#> GSM872285     1   0.599     -0.582 0.432  0 0.000 0.248 0.000 0.320
#> GSM872286     6   0.000      0.433 0.000  0 0.000 0.000 0.000 1.000
#> GSM872287     3   0.300      0.838 0.000  0 0.772 0.228 0.000 0.000
#> GSM872288     6   0.382      0.794 0.432  0 0.000 0.000 0.000 0.568
#> GSM872289     3   0.386      0.709 0.000  0 0.520 0.480 0.000 0.000
#> GSM872290     1   0.526     -0.412 0.568  0 0.000 0.124 0.000 0.308
#> GSM872291     6   0.000      0.433 0.000  0 0.000 0.000 0.000 1.000
#> GSM872292     2   0.000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> GSM872293     1   0.382     -0.799 0.568  0 0.000 0.432 0.000 0.000
#> GSM872294     5   0.518      0.394 0.000  0 0.000 0.088 0.480 0.432
#> GSM872295     5   0.000      0.887 0.000  0 0.000 0.000 1.000 0.000
#> GSM872296     2   0.000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> GSM872297     1   0.382     -0.799 0.568  0 0.000 0.432 0.000 0.000
#> GSM872298     6   0.382      0.794 0.432  0 0.000 0.000 0.000 0.568
#> GSM872299     6   0.689     -0.418 0.296  0 0.000 0.088 0.168 0.448
#> GSM872300     6   0.382      0.794 0.432  0 0.000 0.000 0.000 0.568

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

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>          n time(p) individual(p) k
#> ATC:pam 57   0.387      0.000693 2
#> ATC:pam 56   0.512      0.001825 3
#> ATC:pam 56   0.862      0.000532 4
#> ATC:pam 56   0.861      0.004198 5
#> ATC:pam 38   0.632      0.016196 6

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

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

collect_plots(res)

plot of chunk ATC-mclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.982       0.992         0.3856 0.623   0.623
#> 3 3 0.626           0.811       0.889         0.4033 0.600   0.473
#> 4 4 0.927           0.912       0.967         0.3062 0.713   0.460
#> 5 5 0.948           0.915       0.952         0.0528 0.902   0.687
#> 6 6 0.923           0.898       0.950         0.0489 0.975   0.900

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> GSM872244     1   0.000      0.989 1.000 0.000
#> GSM872245     1   0.000      0.989 1.000 0.000
#> GSM872246     1   0.000      0.989 1.000 0.000
#> GSM872247     1   0.000      0.989 1.000 0.000
#> GSM872248     2   0.000      1.000 0.000 1.000
#> GSM872249     1   0.000      0.989 1.000 0.000
#> GSM872250     1   0.000      0.989 1.000 0.000
#> GSM872251     1   0.000      0.989 1.000 0.000
#> GSM872252     1   0.000      0.989 1.000 0.000
#> GSM872253     1   0.000      0.989 1.000 0.000
#> GSM872254     2   0.000      1.000 0.000 1.000
#> GSM872255     1   0.000      0.989 1.000 0.000
#> GSM872256     1   0.000      0.989 1.000 0.000
#> GSM872257     2   0.000      1.000 0.000 1.000
#> GSM872258     1   0.000      0.989 1.000 0.000
#> GSM872259     1   0.000      0.989 1.000 0.000
#> GSM872260     1   0.000      0.989 1.000 0.000
#> GSM872261     1   0.900      0.539 0.684 0.316
#> GSM872262     1   0.000      0.989 1.000 0.000
#> GSM872263     1   0.000      0.989 1.000 0.000
#> GSM872264     2   0.000      1.000 0.000 1.000
#> GSM872265     1   0.506      0.871 0.888 0.112
#> GSM872266     2   0.000      1.000 0.000 1.000
#> GSM872267     2   0.000      1.000 0.000 1.000
#> GSM872268     1   0.000      0.989 1.000 0.000
#> GSM872269     2   0.000      1.000 0.000 1.000
#> GSM872270     1   0.000      0.989 1.000 0.000
#> GSM872271     2   0.000      1.000 0.000 1.000
#> GSM872272     2   0.000      1.000 0.000 1.000
#> GSM872273     1   0.000      0.989 1.000 0.000
#> GSM872274     2   0.000      1.000 0.000 1.000
#> GSM872275     1   0.000      0.989 1.000 0.000
#> GSM872276     1   0.000      0.989 1.000 0.000
#> GSM872277     1   0.000      0.989 1.000 0.000
#> GSM872278     1   0.000      0.989 1.000 0.000
#> GSM872279     1   0.000      0.989 1.000 0.000
#> GSM872280     1   0.000      0.989 1.000 0.000
#> GSM872281     1   0.000      0.989 1.000 0.000
#> GSM872282     1   0.000      0.989 1.000 0.000
#> GSM872283     1   0.000      0.989 1.000 0.000
#> GSM872284     1   0.141      0.971 0.980 0.020
#> GSM872285     1   0.000      0.989 1.000 0.000
#> GSM872286     1   0.000      0.989 1.000 0.000
#> GSM872287     1   0.000      0.989 1.000 0.000
#> GSM872288     1   0.000      0.989 1.000 0.000
#> GSM872289     1   0.000      0.989 1.000 0.000
#> GSM872290     1   0.000      0.989 1.000 0.000
#> GSM872291     1   0.000      0.989 1.000 0.000
#> GSM872292     2   0.000      1.000 0.000 1.000
#> GSM872293     1   0.000      0.989 1.000 0.000
#> GSM872294     2   0.000      1.000 0.000 1.000
#> GSM872295     2   0.000      1.000 0.000 1.000
#> GSM872296     2   0.000      1.000 0.000 1.000
#> GSM872297     1   0.000      0.989 1.000 0.000
#> GSM872298     1   0.000      0.989 1.000 0.000
#> GSM872299     1   0.000      0.989 1.000 0.000
#> GSM872300     1   0.000      0.989 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
#> GSM872244     3  0.0000      0.838 0.000 0.000 1.000
#> GSM872245     1  0.5678      0.712 0.684 0.316 0.000
#> GSM872246     3  0.5706      0.678 0.320 0.000 0.680
#> GSM872247     3  0.0000      0.838 0.000 0.000 1.000
#> GSM872248     2  0.0592      0.983 0.012 0.988 0.000
#> GSM872249     3  0.0000      0.838 0.000 0.000 1.000
#> GSM872250     1  0.5929      0.706 0.676 0.320 0.004
#> GSM872251     3  0.5706      0.678 0.320 0.000 0.680
#> GSM872252     1  0.5678      0.712 0.684 0.316 0.000
#> GSM872253     1  0.5678      0.712 0.684 0.316 0.000
#> GSM872254     2  0.0237      0.994 0.004 0.996 0.000
#> GSM872255     1  0.0000      0.838 1.000 0.000 0.000
#> GSM872256     1  0.0000      0.838 1.000 0.000 0.000
#> GSM872257     2  0.0000      0.995 0.000 1.000 0.000
#> GSM872258     3  0.5810      0.662 0.336 0.000 0.664
#> GSM872259     1  0.0000      0.838 1.000 0.000 0.000
#> GSM872260     1  0.0000      0.838 1.000 0.000 0.000
#> GSM872261     1  0.5733      0.705 0.676 0.324 0.000
#> GSM872262     1  0.0000      0.838 1.000 0.000 0.000
#> GSM872263     3  0.0000      0.838 0.000 0.000 1.000
#> GSM872264     1  0.5254      0.744 0.736 0.264 0.000
#> GSM872265     1  0.4750      0.769 0.784 0.216 0.000
#> GSM872266     1  0.5733      0.705 0.676 0.324 0.000
#> GSM872267     1  0.5785      0.695 0.668 0.332 0.000
#> GSM872268     3  0.0000      0.838 0.000 0.000 1.000
#> GSM872269     1  0.5733      0.705 0.676 0.324 0.000
#> GSM872270     3  0.0000      0.838 0.000 0.000 1.000
#> GSM872271     1  0.5733      0.705 0.676 0.324 0.000
#> GSM872272     1  0.5733      0.705 0.676 0.324 0.000
#> GSM872273     1  0.0000      0.838 1.000 0.000 0.000
#> GSM872274     2  0.0000      0.995 0.000 1.000 0.000
#> GSM872275     1  0.5929      0.706 0.676 0.320 0.004
#> GSM872276     1  0.1964      0.827 0.944 0.056 0.000
#> GSM872277     1  0.0000      0.838 1.000 0.000 0.000
#> GSM872278     1  0.0237      0.836 0.996 0.000 0.004
#> GSM872279     1  0.0000      0.838 1.000 0.000 0.000
#> GSM872280     1  0.0000      0.838 1.000 0.000 0.000
#> GSM872281     1  0.0000      0.838 1.000 0.000 0.000
#> GSM872282     3  0.0000      0.838 0.000 0.000 1.000
#> GSM872283     1  0.2165      0.825 0.936 0.064 0.000
#> GSM872284     1  0.0000      0.838 1.000 0.000 0.000
#> GSM872285     1  0.0237      0.836 0.996 0.000 0.004
#> GSM872286     1  0.4399      0.781 0.812 0.188 0.000
#> GSM872287     3  0.0000      0.838 0.000 0.000 1.000
#> GSM872288     1  0.0000      0.838 1.000 0.000 0.000
#> GSM872289     3  0.5810      0.662 0.336 0.000 0.664
#> GSM872290     1  0.0000      0.838 1.000 0.000 0.000
#> GSM872291     1  0.0000      0.838 1.000 0.000 0.000
#> GSM872292     2  0.0000      0.995 0.000 1.000 0.000
#> GSM872293     1  0.0000      0.838 1.000 0.000 0.000
#> GSM872294     1  0.5733      0.705 0.676 0.324 0.000
#> GSM872295     2  0.0237      0.994 0.004 0.996 0.000
#> GSM872296     2  0.0000      0.995 0.000 1.000 0.000
#> GSM872297     1  0.0000      0.838 1.000 0.000 0.000
#> GSM872298     1  0.0000      0.838 1.000 0.000 0.000
#> GSM872299     1  0.5678      0.712 0.684 0.316 0.000
#> GSM872300     1  0.0000      0.838 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM872244     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM872245     1  0.0000      0.910 1.000 0.000 0.000 0.000
#> GSM872246     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM872247     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM872248     2  0.0000      0.874 0.000 1.000 0.000 0.000
#> GSM872249     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM872250     4  0.0000      0.986 0.000 0.000 0.000 1.000
#> GSM872251     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM872252     4  0.0000      0.986 0.000 0.000 0.000 1.000
#> GSM872253     4  0.0000      0.986 0.000 0.000 0.000 1.000
#> GSM872254     2  0.0000      0.874 0.000 1.000 0.000 0.000
#> GSM872255     4  0.0000      0.986 0.000 0.000 0.000 1.000
#> GSM872256     1  0.0000      0.910 1.000 0.000 0.000 0.000
#> GSM872257     2  0.0000      0.874 0.000 1.000 0.000 0.000
#> GSM872258     4  0.0336      0.978 0.000 0.000 0.008 0.992
#> GSM872259     1  0.0000      0.910 1.000 0.000 0.000 0.000
#> GSM872260     4  0.3837      0.670 0.224 0.000 0.000 0.776
#> GSM872261     4  0.0000      0.986 0.000 0.000 0.000 1.000
#> GSM872262     1  0.4955      0.266 0.556 0.000 0.000 0.444
#> GSM872263     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM872264     4  0.0000      0.986 0.000 0.000 0.000 1.000
#> GSM872265     4  0.0000      0.986 0.000 0.000 0.000 1.000
#> GSM872266     4  0.0000      0.986 0.000 0.000 0.000 1.000
#> GSM872267     2  0.4431      0.593 0.000 0.696 0.000 0.304
#> GSM872268     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM872269     4  0.0000      0.986 0.000 0.000 0.000 1.000
#> GSM872270     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM872271     4  0.0000      0.986 0.000 0.000 0.000 1.000
#> GSM872272     4  0.0000      0.986 0.000 0.000 0.000 1.000
#> GSM872273     1  0.0000      0.910 1.000 0.000 0.000 0.000
#> GSM872274     2  0.0000      0.874 0.000 1.000 0.000 0.000
#> GSM872275     4  0.0000      0.986 0.000 0.000 0.000 1.000
#> GSM872276     1  0.3486      0.733 0.812 0.000 0.000 0.188
#> GSM872277     1  0.0000      0.910 1.000 0.000 0.000 0.000
#> GSM872278     4  0.0000      0.986 0.000 0.000 0.000 1.000
#> GSM872279     1  0.0000      0.910 1.000 0.000 0.000 0.000
#> GSM872280     4  0.0000      0.986 0.000 0.000 0.000 1.000
#> GSM872281     4  0.0000      0.986 0.000 0.000 0.000 1.000
#> GSM872282     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM872283     1  0.0000      0.910 1.000 0.000 0.000 0.000
#> GSM872284     4  0.0000      0.986 0.000 0.000 0.000 1.000
#> GSM872285     4  0.0000      0.986 0.000 0.000 0.000 1.000
#> GSM872286     4  0.0000      0.986 0.000 0.000 0.000 1.000
#> GSM872287     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM872288     4  0.0000      0.986 0.000 0.000 0.000 1.000
#> GSM872289     4  0.1118      0.947 0.000 0.000 0.036 0.964
#> GSM872290     1  0.0000      0.910 1.000 0.000 0.000 0.000
#> GSM872291     1  0.3975      0.673 0.760 0.000 0.000 0.240
#> GSM872292     2  0.0000      0.874 0.000 1.000 0.000 0.000
#> GSM872293     1  0.0000      0.910 1.000 0.000 0.000 0.000
#> GSM872294     2  0.5132      0.275 0.004 0.548 0.000 0.448
#> GSM872295     2  0.0000      0.874 0.000 1.000 0.000 0.000
#> GSM872296     2  0.0000      0.874 0.000 1.000 0.000 0.000
#> GSM872297     1  0.0000      0.910 1.000 0.000 0.000 0.000
#> GSM872298     4  0.0000      0.986 0.000 0.000 0.000 1.000
#> GSM872299     1  0.0000      0.910 1.000 0.000 0.000 0.000
#> GSM872300     4  0.0000      0.986 0.000 0.000 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM872244     3  0.0000     0.9983 0.000 0.000 1.000 0.000 0.000
#> GSM872245     1  0.1608     0.9078 0.928 0.000 0.000 0.072 0.000
#> GSM872246     3  0.0000     0.9983 0.000 0.000 1.000 0.000 0.000
#> GSM872247     3  0.0000     0.9983 0.000 0.000 1.000 0.000 0.000
#> GSM872248     5  0.2922     0.9151 0.000 0.072 0.000 0.056 0.872
#> GSM872249     3  0.0000     0.9983 0.000 0.000 1.000 0.000 0.000
#> GSM872250     4  0.0290     0.9464 0.000 0.000 0.000 0.992 0.008
#> GSM872251     3  0.0510     0.9843 0.000 0.000 0.984 0.000 0.016
#> GSM872252     4  0.0000     0.9483 0.000 0.000 0.000 1.000 0.000
#> GSM872253     4  0.0404     0.9451 0.000 0.000 0.000 0.988 0.012
#> GSM872254     2  0.2179     0.9274 0.004 0.896 0.000 0.000 0.100
#> GSM872255     4  0.0000     0.9483 0.000 0.000 0.000 1.000 0.000
#> GSM872256     1  0.1608     0.9078 0.928 0.000 0.000 0.072 0.000
#> GSM872257     2  0.0000     0.9648 0.000 1.000 0.000 0.000 0.000
#> GSM872258     4  0.1571     0.9018 0.000 0.000 0.004 0.936 0.060
#> GSM872259     1  0.0162     0.8944 0.996 0.000 0.000 0.004 0.000
#> GSM872260     4  0.1121     0.9132 0.044 0.000 0.000 0.956 0.000
#> GSM872261     4  0.0000     0.9483 0.000 0.000 0.000 1.000 0.000
#> GSM872262     4  0.2516     0.8037 0.140 0.000 0.000 0.860 0.000
#> GSM872263     3  0.0000     0.9983 0.000 0.000 1.000 0.000 0.000
#> GSM872264     4  0.0000     0.9483 0.000 0.000 0.000 1.000 0.000
#> GSM872265     4  0.0000     0.9483 0.000 0.000 0.000 1.000 0.000
#> GSM872266     5  0.2563     0.9423 0.000 0.008 0.000 0.120 0.872
#> GSM872267     5  0.2927     0.9292 0.000 0.060 0.000 0.068 0.872
#> GSM872268     3  0.0000     0.9983 0.000 0.000 1.000 0.000 0.000
#> GSM872269     4  0.1908     0.8836 0.000 0.000 0.000 0.908 0.092
#> GSM872270     3  0.0000     0.9983 0.000 0.000 1.000 0.000 0.000
#> GSM872271     5  0.2377     0.9400 0.000 0.000 0.000 0.128 0.872
#> GSM872272     5  0.2377     0.9400 0.000 0.000 0.000 0.128 0.872
#> GSM872273     1  0.0162     0.8944 0.996 0.000 0.000 0.004 0.000
#> GSM872274     2  0.0000     0.9648 0.000 1.000 0.000 0.000 0.000
#> GSM872275     4  0.0290     0.9464 0.000 0.000 0.000 0.992 0.008
#> GSM872276     1  0.4114     0.4459 0.624 0.000 0.000 0.376 0.000
#> GSM872277     1  0.1671     0.9054 0.924 0.000 0.000 0.076 0.000
#> GSM872278     4  0.0510     0.9432 0.000 0.000 0.000 0.984 0.016
#> GSM872279     1  0.1608     0.9078 0.928 0.000 0.000 0.072 0.000
#> GSM872280     4  0.0510     0.9432 0.000 0.000 0.000 0.984 0.016
#> GSM872281     4  0.0000     0.9483 0.000 0.000 0.000 1.000 0.000
#> GSM872282     3  0.0000     0.9983 0.000 0.000 1.000 0.000 0.000
#> GSM872283     1  0.1732     0.9021 0.920 0.000 0.000 0.080 0.000
#> GSM872284     4  0.0000     0.9483 0.000 0.000 0.000 1.000 0.000
#> GSM872285     4  0.0609     0.9407 0.000 0.000 0.000 0.980 0.020
#> GSM872286     4  0.0000     0.9483 0.000 0.000 0.000 1.000 0.000
#> GSM872287     3  0.0000     0.9983 0.000 0.000 1.000 0.000 0.000
#> GSM872288     4  0.0000     0.9483 0.000 0.000 0.000 1.000 0.000
#> GSM872289     4  0.2193     0.8824 0.000 0.000 0.028 0.912 0.060
#> GSM872290     1  0.0162     0.8944 0.996 0.000 0.000 0.004 0.000
#> GSM872291     4  0.4287     0.0239 0.460 0.000 0.000 0.540 0.000
#> GSM872292     2  0.0000     0.9648 0.000 1.000 0.000 0.000 0.000
#> GSM872293     1  0.0162     0.8944 0.996 0.000 0.000 0.004 0.000
#> GSM872294     5  0.1894     0.9254 0.000 0.008 0.000 0.072 0.920
#> GSM872295     2  0.2179     0.9274 0.004 0.896 0.000 0.000 0.100
#> GSM872296     2  0.0000     0.9648 0.000 1.000 0.000 0.000 0.000
#> GSM872297     1  0.0162     0.8944 0.996 0.000 0.000 0.004 0.000
#> GSM872298     4  0.0000     0.9483 0.000 0.000 0.000 1.000 0.000
#> GSM872299     1  0.1608     0.9078 0.928 0.000 0.000 0.072 0.000
#> GSM872300     4  0.0000     0.9483 0.000 0.000 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM872244     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872245     1  0.0146      0.893 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM872246     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872247     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872248     4  0.1327      0.915 0.000 0.064 0.000 0.936 0.000 0.000
#> GSM872249     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872250     6  0.0790      0.921 0.000 0.000 0.000 0.000 0.032 0.968
#> GSM872251     3  0.0632      0.972 0.000 0.000 0.976 0.000 0.024 0.000
#> GSM872252     6  0.0000      0.922 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM872253     6  0.0790      0.921 0.000 0.000 0.000 0.000 0.032 0.968
#> GSM872254     5  0.0993      0.976 0.000 0.012 0.000 0.024 0.964 0.000
#> GSM872255     6  0.0000      0.922 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM872256     1  0.0146      0.893 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM872257     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM872258     6  0.0790      0.921 0.000 0.000 0.000 0.000 0.032 0.968
#> GSM872259     1  0.0000      0.894 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM872260     6  0.0458      0.917 0.016 0.000 0.000 0.000 0.000 0.984
#> GSM872261     6  0.0547      0.920 0.000 0.000 0.000 0.020 0.000 0.980
#> GSM872262     6  0.1663      0.863 0.088 0.000 0.000 0.000 0.000 0.912
#> GSM872263     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872264     6  0.2902      0.766 0.000 0.000 0.000 0.196 0.004 0.800
#> GSM872265     6  0.2902      0.766 0.000 0.000 0.000 0.196 0.004 0.800
#> GSM872266     4  0.0000      0.979 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM872267     4  0.0000      0.979 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM872268     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872269     5  0.0891      0.969 0.000 0.000 0.000 0.024 0.968 0.008
#> GSM872270     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872271     4  0.0000      0.979 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM872272     4  0.0000      0.979 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM872273     1  0.0000      0.894 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM872274     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM872275     6  0.0790      0.921 0.000 0.000 0.000 0.000 0.032 0.968
#> GSM872276     1  0.3843      0.129 0.548 0.000 0.000 0.000 0.000 0.452
#> GSM872277     1  0.0713      0.877 0.972 0.000 0.000 0.000 0.000 0.028
#> GSM872278     6  0.0790      0.921 0.000 0.000 0.000 0.000 0.032 0.968
#> GSM872279     1  0.0146      0.893 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM872280     6  0.0790      0.921 0.000 0.000 0.000 0.000 0.032 0.968
#> GSM872281     6  0.1958      0.861 0.000 0.000 0.000 0.100 0.004 0.896
#> GSM872282     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872283     1  0.3582      0.679 0.768 0.000 0.000 0.196 0.000 0.036
#> GSM872284     6  0.2902      0.766 0.000 0.000 0.000 0.196 0.004 0.800
#> GSM872285     6  0.0790      0.921 0.000 0.000 0.000 0.000 0.032 0.968
#> GSM872286     6  0.0000      0.922 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM872287     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM872288     6  0.0000      0.922 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM872289     6  0.1245      0.913 0.000 0.000 0.016 0.000 0.032 0.952
#> GSM872290     1  0.0000      0.894 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM872291     6  0.3756      0.244 0.400 0.000 0.000 0.000 0.000 0.600
#> GSM872292     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM872293     1  0.0000      0.894 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM872294     5  0.1531      0.952 0.000 0.000 0.000 0.068 0.928 0.004
#> GSM872295     5  0.0993      0.976 0.000 0.012 0.000 0.024 0.964 0.000
#> GSM872296     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM872297     1  0.0000      0.894 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM872298     6  0.0000      0.922 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM872299     1  0.2902      0.713 0.800 0.000 0.000 0.000 0.196 0.004
#> GSM872300     6  0.0000      0.922 0.000 0.000 0.000 0.000 0.000 1.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

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>             n time(p) individual(p) k
#> ATC:mclust 57   0.292      0.173506 2
#> ATC:mclust 57   0.456      0.000197 3
#> ATC:mclust 55   0.748      0.000299 4
#> ATC:mclust 55   0.623      0.000143 5
#> ATC:mclust 55   0.565      0.005855 6

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

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

collect_plots(res)

plot of chunk ATC-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.999           0.961       0.983         0.4762 0.526   0.526
#> 3 3 0.952           0.928       0.971         0.3874 0.790   0.611
#> 4 4 0.693           0.716       0.843         0.1180 0.857   0.616
#> 5 5 0.645           0.570       0.754         0.0706 0.937   0.769
#> 6 6 0.769           0.630       0.822         0.0486 0.883   0.543

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
#> GSM872244     1  0.0000      0.984 1.000 0.000
#> GSM872245     2  0.0000      0.981 0.000 1.000
#> GSM872246     1  0.0000      0.984 1.000 0.000
#> GSM872247     1  0.0000      0.984 1.000 0.000
#> GSM872248     2  0.0938      0.972 0.012 0.988
#> GSM872249     1  0.0000      0.984 1.000 0.000
#> GSM872250     1  0.2423      0.951 0.960 0.040
#> GSM872251     1  0.0000      0.984 1.000 0.000
#> GSM872252     2  0.0000      0.981 0.000 1.000
#> GSM872253     1  0.0000      0.984 1.000 0.000
#> GSM872254     2  0.0376      0.978 0.004 0.996
#> GSM872255     2  0.0000      0.981 0.000 1.000
#> GSM872256     2  0.0000      0.981 0.000 1.000
#> GSM872257     2  0.0000      0.981 0.000 1.000
#> GSM872258     1  0.0000      0.984 1.000 0.000
#> GSM872259     2  0.0000      0.981 0.000 1.000
#> GSM872260     2  0.0000      0.981 0.000 1.000
#> GSM872261     2  0.0000      0.981 0.000 1.000
#> GSM872262     2  0.0000      0.981 0.000 1.000
#> GSM872263     1  0.0000      0.984 1.000 0.000
#> GSM872264     1  0.7528      0.722 0.784 0.216
#> GSM872265     2  0.0000      0.981 0.000 1.000
#> GSM872266     2  0.0000      0.981 0.000 1.000
#> GSM872267     2  0.0000      0.981 0.000 1.000
#> GSM872268     1  0.0000      0.984 1.000 0.000
#> GSM872269     2  0.3114      0.930 0.056 0.944
#> GSM872270     1  0.0000      0.984 1.000 0.000
#> GSM872271     2  0.0000      0.981 0.000 1.000
#> GSM872272     2  0.0672      0.975 0.008 0.992
#> GSM872273     2  0.0000      0.981 0.000 1.000
#> GSM872274     2  0.0000      0.981 0.000 1.000
#> GSM872275     1  0.0000      0.984 1.000 0.000
#> GSM872276     2  0.0000      0.981 0.000 1.000
#> GSM872277     2  0.0000      0.981 0.000 1.000
#> GSM872278     1  0.0000      0.984 1.000 0.000
#> GSM872279     2  0.0000      0.981 0.000 1.000
#> GSM872280     1  0.0000      0.984 1.000 0.000
#> GSM872281     2  0.6973      0.765 0.188 0.812
#> GSM872282     1  0.0000      0.984 1.000 0.000
#> GSM872283     2  0.0000      0.981 0.000 1.000
#> GSM872284     2  0.0000      0.981 0.000 1.000
#> GSM872285     1  0.0000      0.984 1.000 0.000
#> GSM872286     2  0.0000      0.981 0.000 1.000
#> GSM872287     1  0.0000      0.984 1.000 0.000
#> GSM872288     2  0.9522      0.408 0.372 0.628
#> GSM872289     1  0.0000      0.984 1.000 0.000
#> GSM872290     2  0.0000      0.981 0.000 1.000
#> GSM872291     2  0.0000      0.981 0.000 1.000
#> GSM872292     1  0.0000      0.984 1.000 0.000
#> GSM872293     2  0.0000      0.981 0.000 1.000
#> GSM872294     2  0.0000      0.981 0.000 1.000
#> GSM872295     1  0.2778      0.944 0.952 0.048
#> GSM872296     2  0.0000      0.981 0.000 1.000
#> GSM872297     2  0.0000      0.981 0.000 1.000
#> GSM872298     2  0.0000      0.981 0.000 1.000
#> GSM872299     2  0.0000      0.981 0.000 1.000
#> GSM872300     2  0.0000      0.981 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM872244     3  0.0000      0.947 0.000 0.000 1.000
#> GSM872245     1  0.0592      0.957 0.988 0.012 0.000
#> GSM872246     3  0.0000      0.947 0.000 0.000 1.000
#> GSM872247     3  0.0000      0.947 0.000 0.000 1.000
#> GSM872248     2  0.0000      1.000 0.000 1.000 0.000
#> GSM872249     3  0.0000      0.947 0.000 0.000 1.000
#> GSM872250     3  0.5733      0.542 0.000 0.324 0.676
#> GSM872251     3  0.0000      0.947 0.000 0.000 1.000
#> GSM872252     1  0.0000      0.967 1.000 0.000 0.000
#> GSM872253     3  0.0000      0.947 0.000 0.000 1.000
#> GSM872254     2  0.0000      1.000 0.000 1.000 0.000
#> GSM872255     1  0.0000      0.967 1.000 0.000 0.000
#> GSM872256     1  0.0000      0.967 1.000 0.000 0.000
#> GSM872257     2  0.0000      1.000 0.000 1.000 0.000
#> GSM872258     3  0.0000      0.947 0.000 0.000 1.000
#> GSM872259     1  0.0000      0.967 1.000 0.000 0.000
#> GSM872260     1  0.0000      0.967 1.000 0.000 0.000
#> GSM872261     1  0.6168      0.311 0.588 0.412 0.000
#> GSM872262     1  0.0000      0.967 1.000 0.000 0.000
#> GSM872263     3  0.0000      0.947 0.000 0.000 1.000
#> GSM872264     3  0.5016      0.663 0.240 0.000 0.760
#> GSM872265     1  0.0000      0.967 1.000 0.000 0.000
#> GSM872266     2  0.0000      1.000 0.000 1.000 0.000
#> GSM872267     2  0.0000      1.000 0.000 1.000 0.000
#> GSM872268     3  0.0000      0.947 0.000 0.000 1.000
#> GSM872269     2  0.0000      1.000 0.000 1.000 0.000
#> GSM872270     3  0.0000      0.947 0.000 0.000 1.000
#> GSM872271     2  0.0000      1.000 0.000 1.000 0.000
#> GSM872272     2  0.0000      1.000 0.000 1.000 0.000
#> GSM872273     1  0.0000      0.967 1.000 0.000 0.000
#> GSM872274     2  0.0000      1.000 0.000 1.000 0.000
#> GSM872275     3  0.5859      0.507 0.000 0.344 0.656
#> GSM872276     1  0.0000      0.967 1.000 0.000 0.000
#> GSM872277     1  0.0000      0.967 1.000 0.000 0.000
#> GSM872278     3  0.0000      0.947 0.000 0.000 1.000
#> GSM872279     1  0.0000      0.967 1.000 0.000 0.000
#> GSM872280     3  0.0000      0.947 0.000 0.000 1.000
#> GSM872281     1  0.1031      0.946 0.976 0.000 0.024
#> GSM872282     3  0.0000      0.947 0.000 0.000 1.000
#> GSM872283     1  0.0000      0.967 1.000 0.000 0.000
#> GSM872284     1  0.0000      0.967 1.000 0.000 0.000
#> GSM872285     3  0.0000      0.947 0.000 0.000 1.000
#> GSM872286     1  0.0000      0.967 1.000 0.000 0.000
#> GSM872287     3  0.0000      0.947 0.000 0.000 1.000
#> GSM872288     1  0.5733      0.504 0.676 0.000 0.324
#> GSM872289     3  0.0000      0.947 0.000 0.000 1.000
#> GSM872290     1  0.0000      0.967 1.000 0.000 0.000
#> GSM872291     1  0.0000      0.967 1.000 0.000 0.000
#> GSM872292     2  0.0000      1.000 0.000 1.000 0.000
#> GSM872293     1  0.0000      0.967 1.000 0.000 0.000
#> GSM872294     2  0.0000      1.000 0.000 1.000 0.000
#> GSM872295     2  0.0000      1.000 0.000 1.000 0.000
#> GSM872296     2  0.0000      1.000 0.000 1.000 0.000
#> GSM872297     1  0.0000      0.967 1.000 0.000 0.000
#> GSM872298     1  0.0000      0.967 1.000 0.000 0.000
#> GSM872299     1  0.0000      0.967 1.000 0.000 0.000
#> GSM872300     1  0.0000      0.967 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM872244     3  0.0000      0.882 0.000 0.000 1.000 0.000
#> GSM872245     1  0.3105      0.777 0.868 0.012 0.000 0.120
#> GSM872246     3  0.0469      0.883 0.000 0.000 0.988 0.012
#> GSM872247     3  0.1940      0.883 0.000 0.000 0.924 0.076
#> GSM872248     2  0.3764      0.604 0.000 0.784 0.000 0.216
#> GSM872249     3  0.0000      0.882 0.000 0.000 1.000 0.000
#> GSM872250     3  0.4911      0.530 0.008 0.280 0.704 0.008
#> GSM872251     3  0.1389      0.885 0.000 0.000 0.952 0.048
#> GSM872252     1  0.3801      0.708 0.780 0.000 0.000 0.220
#> GSM872253     3  0.5973      0.648 0.052 0.024 0.700 0.224
#> GSM872254     2  0.0188      0.798 0.000 0.996 0.000 0.004
#> GSM872255     1  0.3610      0.728 0.800 0.000 0.000 0.200
#> GSM872256     1  0.2081      0.819 0.916 0.000 0.000 0.084
#> GSM872257     2  0.0000      0.799 0.000 1.000 0.000 0.000
#> GSM872258     3  0.1302      0.867 0.000 0.000 0.956 0.044
#> GSM872259     1  0.1211      0.847 0.960 0.000 0.000 0.040
#> GSM872260     1  0.3764      0.712 0.784 0.000 0.000 0.216
#> GSM872261     2  0.5427      0.204 0.416 0.568 0.000 0.016
#> GSM872262     1  0.0592      0.856 0.984 0.000 0.000 0.016
#> GSM872263     3  0.0000      0.882 0.000 0.000 1.000 0.000
#> GSM872264     4  0.4948      0.639 0.124 0.000 0.100 0.776
#> GSM872265     4  0.4500      0.600 0.316 0.000 0.000 0.684
#> GSM872266     2  0.3726      0.611 0.000 0.788 0.000 0.212
#> GSM872267     4  0.4790      0.375 0.000 0.380 0.000 0.620
#> GSM872268     3  0.2011      0.882 0.000 0.000 0.920 0.080
#> GSM872269     2  0.6488      0.487 0.004 0.648 0.128 0.220
#> GSM872270     3  0.2647      0.868 0.000 0.000 0.880 0.120
#> GSM872271     4  0.4843      0.337 0.000 0.396 0.000 0.604
#> GSM872272     4  0.4889      0.404 0.004 0.360 0.000 0.636
#> GSM872273     1  0.4103      0.557 0.744 0.000 0.000 0.256
#> GSM872274     2  0.0000      0.799 0.000 1.000 0.000 0.000
#> GSM872275     2  0.4804      0.294 0.000 0.616 0.384 0.000
#> GSM872276     1  0.0469      0.856 0.988 0.000 0.000 0.012
#> GSM872277     1  0.4843      0.142 0.604 0.000 0.000 0.396
#> GSM872278     3  0.2760      0.864 0.000 0.000 0.872 0.128
#> GSM872279     1  0.0921      0.848 0.972 0.000 0.000 0.028
#> GSM872280     3  0.6931      0.502 0.184 0.000 0.588 0.228
#> GSM872281     4  0.6796      0.574 0.252 0.000 0.152 0.596
#> GSM872282     3  0.1867      0.883 0.000 0.000 0.928 0.072
#> GSM872283     4  0.4713      0.538 0.360 0.000 0.000 0.640
#> GSM872284     4  0.4560      0.619 0.296 0.000 0.004 0.700
#> GSM872285     3  0.2345      0.876 0.000 0.000 0.900 0.100
#> GSM872286     1  0.0469      0.856 0.988 0.000 0.000 0.012
#> GSM872287     3  0.2760      0.864 0.000 0.000 0.872 0.128
#> GSM872288     4  0.7760      0.487 0.276 0.000 0.288 0.436
#> GSM872289     3  0.1792      0.854 0.000 0.000 0.932 0.068
#> GSM872290     1  0.0000      0.855 1.000 0.000 0.000 0.000
#> GSM872291     1  0.1211      0.843 0.960 0.000 0.000 0.040
#> GSM872292     2  0.0000      0.799 0.000 1.000 0.000 0.000
#> GSM872293     1  0.1022      0.850 0.968 0.000 0.000 0.032
#> GSM872294     2  0.0188      0.798 0.000 0.996 0.000 0.004
#> GSM872295     2  0.0000      0.799 0.000 1.000 0.000 0.000
#> GSM872296     2  0.0469      0.794 0.000 0.988 0.000 0.012
#> GSM872297     1  0.2081      0.819 0.916 0.000 0.000 0.084
#> GSM872298     1  0.1305      0.849 0.960 0.000 0.004 0.036
#> GSM872299     1  0.4079      0.728 0.800 0.020 0.000 0.180
#> GSM872300     1  0.0336      0.856 0.992 0.000 0.000 0.008

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM872244     3  0.0566     0.7778 0.000 0.000 0.984 0.004 0.012
#> GSM872245     1  0.3687     0.5624 0.792 0.000 0.000 0.180 0.028
#> GSM872246     3  0.2628     0.7728 0.000 0.000 0.884 0.028 0.088
#> GSM872247     3  0.3106     0.7535 0.000 0.000 0.844 0.024 0.132
#> GSM872248     4  0.6126     0.4178 0.016 0.344 0.008 0.560 0.072
#> GSM872249     3  0.0290     0.7805 0.000 0.000 0.992 0.000 0.008
#> GSM872250     3  0.6723     0.2723 0.032 0.008 0.592 0.180 0.188
#> GSM872251     3  0.1117     0.7868 0.000 0.000 0.964 0.020 0.016
#> GSM872252     5  0.4307    -0.2959 0.496 0.000 0.000 0.000 0.504
#> GSM872253     5  0.5071     0.2190 0.028 0.004 0.420 0.000 0.548
#> GSM872254     2  0.2286     0.8096 0.000 0.888 0.000 0.004 0.108
#> GSM872255     1  0.4327     0.4039 0.632 0.000 0.000 0.008 0.360
#> GSM872256     1  0.0703     0.6999 0.976 0.000 0.000 0.024 0.000
#> GSM872257     2  0.0000     0.8832 0.000 1.000 0.000 0.000 0.000
#> GSM872258     3  0.1952     0.7526 0.000 0.000 0.912 0.004 0.084
#> GSM872259     1  0.0290     0.7009 0.992 0.000 0.000 0.008 0.000
#> GSM872260     1  0.4210     0.2966 0.588 0.000 0.000 0.000 0.412
#> GSM872261     2  0.5699     0.3411 0.264 0.608 0.000 0.000 0.128
#> GSM872262     1  0.6261     0.3759 0.524 0.000 0.000 0.180 0.296
#> GSM872263     3  0.0290     0.7805 0.000 0.000 0.992 0.000 0.008
#> GSM872264     4  0.1560     0.5760 0.020 0.000 0.028 0.948 0.004
#> GSM872265     4  0.4269     0.5454 0.188 0.000 0.000 0.756 0.056
#> GSM872266     4  0.5603     0.4125 0.008 0.356 0.000 0.572 0.064
#> GSM872267     4  0.5678     0.5338 0.040 0.260 0.000 0.648 0.052
#> GSM872268     3  0.4555     0.6893 0.000 0.000 0.732 0.068 0.200
#> GSM872269     5  0.7084     0.3043 0.076 0.272 0.120 0.000 0.532
#> GSM872270     3  0.1310     0.7869 0.000 0.000 0.956 0.024 0.020
#> GSM872271     4  0.4446     0.3538 0.000 0.400 0.000 0.592 0.008
#> GSM872272     4  0.4347     0.5754 0.004 0.212 0.000 0.744 0.040
#> GSM872273     1  0.2017     0.6862 0.912 0.000 0.000 0.080 0.008
#> GSM872274     2  0.0000     0.8832 0.000 1.000 0.000 0.000 0.000
#> GSM872275     2  0.2732     0.7058 0.000 0.840 0.160 0.000 0.000
#> GSM872276     1  0.5864     0.4505 0.572 0.000 0.000 0.128 0.300
#> GSM872277     1  0.2727     0.6563 0.868 0.000 0.000 0.116 0.016
#> GSM872278     3  0.6815     0.1400 0.000 0.000 0.360 0.312 0.328
#> GSM872279     1  0.1341     0.6928 0.944 0.000 0.000 0.000 0.056
#> GSM872280     5  0.5468     0.2338 0.072 0.000 0.272 0.012 0.644
#> GSM872281     4  0.7196     0.0466 0.176 0.000 0.036 0.416 0.372
#> GSM872282     3  0.0671     0.7811 0.000 0.000 0.980 0.004 0.016
#> GSM872283     4  0.3814     0.5206 0.276 0.000 0.000 0.720 0.004
#> GSM872284     4  0.4743     0.5198 0.156 0.000 0.000 0.732 0.112
#> GSM872285     3  0.5032     0.6525 0.000 0.000 0.688 0.092 0.220
#> GSM872286     1  0.6707     0.2797 0.596 0.000 0.060 0.148 0.196
#> GSM872287     3  0.4618     0.6843 0.000 0.000 0.724 0.068 0.208
#> GSM872288     4  0.6858     0.4028 0.328 0.000 0.068 0.516 0.088
#> GSM872289     3  0.2886     0.6414 0.000 0.000 0.844 0.008 0.148
#> GSM872290     1  0.1043     0.6966 0.960 0.000 0.000 0.000 0.040
#> GSM872291     1  0.3884     0.5247 0.708 0.000 0.000 0.004 0.288
#> GSM872292     2  0.0000     0.8832 0.000 1.000 0.000 0.000 0.000
#> GSM872293     1  0.0771     0.7003 0.976 0.000 0.000 0.004 0.020
#> GSM872294     2  0.0794     0.8661 0.000 0.972 0.000 0.000 0.028
#> GSM872295     2  0.0000     0.8832 0.000 1.000 0.000 0.000 0.000
#> GSM872296     2  0.0000     0.8832 0.000 1.000 0.000 0.000 0.000
#> GSM872297     1  0.0880     0.6988 0.968 0.000 0.000 0.032 0.000
#> GSM872298     1  0.6037     0.4606 0.612 0.000 0.012 0.232 0.144
#> GSM872299     1  0.3561     0.5086 0.740 0.000 0.000 0.000 0.260
#> GSM872300     1  0.4871     0.5630 0.704 0.000 0.000 0.084 0.212

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM872244     3  0.0520     0.8628 0.000 0.000 0.984 0.000 0.008 0.008
#> GSM872245     1  0.1053     0.7730 0.964 0.012 0.000 0.004 0.020 0.000
#> GSM872246     3  0.2416     0.8603 0.000 0.000 0.844 0.156 0.000 0.000
#> GSM872247     3  0.2234     0.8689 0.000 0.000 0.872 0.124 0.000 0.004
#> GSM872248     5  0.1584     0.7018 0.004 0.032 0.004 0.004 0.944 0.012
#> GSM872249     3  0.0291     0.8661 0.000 0.000 0.992 0.004 0.000 0.004
#> GSM872250     5  0.3857     0.5899 0.004 0.000 0.072 0.000 0.776 0.148
#> GSM872251     3  0.4117     0.8008 0.000 0.000 0.708 0.256 0.020 0.016
#> GSM872252     6  0.1714     0.6665 0.092 0.000 0.000 0.000 0.000 0.908
#> GSM872253     6  0.1925     0.6456 0.000 0.008 0.060 0.008 0.004 0.920
#> GSM872254     2  0.3292     0.7971 0.000 0.824 0.000 0.004 0.052 0.120
#> GSM872255     6  0.5020     0.1898 0.372 0.000 0.000 0.080 0.000 0.548
#> GSM872256     1  0.0146     0.7864 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM872257     2  0.0405     0.9545 0.000 0.988 0.000 0.004 0.000 0.008
#> GSM872258     3  0.1563     0.8752 0.000 0.000 0.932 0.056 0.000 0.012
#> GSM872259     1  0.0291     0.7869 0.992 0.000 0.000 0.000 0.004 0.004
#> GSM872260     6  0.2473     0.6449 0.136 0.000 0.000 0.008 0.000 0.856
#> GSM872261     6  0.4662     0.1253 0.012 0.420 0.000 0.004 0.016 0.548
#> GSM872262     4  0.5097     0.1389 0.420 0.000 0.000 0.508 0.004 0.068
#> GSM872263     3  0.0146     0.8653 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM872264     5  0.3852     0.3671 0.000 0.000 0.000 0.384 0.612 0.004
#> GSM872265     5  0.5260     0.0620 0.072 0.000 0.000 0.456 0.464 0.008
#> GSM872266     5  0.1699     0.7028 0.012 0.040 0.000 0.004 0.936 0.008
#> GSM872267     5  0.1959     0.7003 0.020 0.032 0.000 0.024 0.924 0.000
#> GSM872268     3  0.3508     0.7941 0.000 0.000 0.704 0.292 0.000 0.004
#> GSM872269     6  0.2452     0.6474 0.000 0.056 0.008 0.000 0.044 0.892
#> GSM872270     3  0.1480     0.8734 0.000 0.000 0.940 0.040 0.020 0.000
#> GSM872271     5  0.5510     0.4868 0.000 0.220 0.000 0.164 0.604 0.012
#> GSM872272     5  0.2580     0.6834 0.004 0.036 0.000 0.072 0.884 0.004
#> GSM872273     1  0.0653     0.7833 0.980 0.000 0.000 0.004 0.012 0.004
#> GSM872274     2  0.0146     0.9555 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM872275     2  0.1116     0.9358 0.000 0.960 0.028 0.004 0.000 0.008
#> GSM872276     1  0.5160    -0.1983 0.476 0.000 0.000 0.448 0.004 0.072
#> GSM872277     1  0.0653     0.7834 0.980 0.000 0.000 0.004 0.012 0.004
#> GSM872278     4  0.2206     0.4294 0.000 0.000 0.064 0.904 0.008 0.024
#> GSM872279     1  0.2053     0.7490 0.888 0.000 0.000 0.000 0.004 0.108
#> GSM872280     6  0.4787     0.2591 0.020 0.000 0.020 0.440 0.000 0.520
#> GSM872281     4  0.0653     0.4615 0.004 0.000 0.012 0.980 0.004 0.000
#> GSM872282     3  0.1148     0.8598 0.000 0.000 0.960 0.004 0.020 0.016
#> GSM872283     1  0.5844     0.0936 0.548 0.000 0.000 0.200 0.240 0.012
#> GSM872284     4  0.4362    -0.1207 0.020 0.000 0.000 0.584 0.392 0.004
#> GSM872285     3  0.3634     0.7367 0.000 0.000 0.644 0.356 0.000 0.000
#> GSM872286     5  0.5852     0.1526 0.364 0.000 0.000 0.000 0.440 0.196
#> GSM872287     3  0.3606     0.7988 0.000 0.000 0.708 0.284 0.004 0.004
#> GSM872288     5  0.2262     0.6869 0.036 0.000 0.020 0.000 0.908 0.036
#> GSM872289     3  0.1714     0.8383 0.000 0.000 0.908 0.000 0.000 0.092
#> GSM872290     1  0.1714     0.7576 0.908 0.000 0.000 0.000 0.000 0.092
#> GSM872291     1  0.4620     0.1819 0.532 0.000 0.000 0.040 0.000 0.428
#> GSM872292     2  0.0622     0.9520 0.000 0.980 0.000 0.000 0.008 0.012
#> GSM872293     1  0.0146     0.7865 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM872294     2  0.1155     0.9381 0.000 0.956 0.000 0.004 0.004 0.036
#> GSM872295     2  0.0291     0.9554 0.000 0.992 0.000 0.004 0.000 0.004
#> GSM872296     2  0.0291     0.9554 0.000 0.992 0.000 0.004 0.000 0.004
#> GSM872297     1  0.0260     0.7856 0.992 0.000 0.000 0.000 0.008 0.000
#> GSM872298     4  0.4181     0.0461 0.476 0.000 0.000 0.512 0.000 0.012
#> GSM872299     1  0.3584     0.5126 0.688 0.000 0.000 0.000 0.004 0.308
#> GSM872300     1  0.3045     0.7054 0.840 0.000 0.000 0.100 0.000 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-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

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>          n time(p) individual(p) k
#> ATC:NMF 56   0.857      0.032726 2
#> ATC:NMF 56   0.388      0.015038 3
#> ATC:NMF 49   0.367      0.001891 4
#> ATC:NMF 39   0.317      0.000234 5
#> ATC:NMF 42   0.585      0.000160 6

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