cola Report for recount2:SRP045999

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

The call of run_all_consensus_partition_methods() was:

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

Dimension of the input matrix:

mat = get_matrix(res_list)
dim(mat)
#> [1] 15301    63

Density distribution

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

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

plot of chunk density-heatmap

Suggest the best k

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

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

suggest_best_k(res_list)
The best k 1-PAC Mean silhouette Concordance Optional k
SD:hclust 3 1.000 1.000 1.000 **
SD:kmeans 3 1.000 0.978 0.949 **
SD:skmeans 3 1.000 0.985 0.980 ** 2
SD:pam 4 1.000 0.998 0.998 ** 2,3
SD:mclust 2 1.000 0.997 0.996 **
SD:NMF 3 1.000 1.000 1.000 ** 2
CV:skmeans 3 1.000 0.991 0.988 ** 2
CV:mclust 3 1.000 0.976 0.965 **
CV:NMF 3 1.000 0.994 0.990 **
MAD:hclust 4 1.000 0.996 0.997 ** 2,3
MAD:kmeans 2 1.000 0.988 0.981 **
ATC:hclust 6 1.000 0.996 0.997 ** 2,3,4,5
ATC:kmeans 2 1.000 1.000 1.000 **
ATC:skmeans 2 1.000 1.000 1.000 **
ATC:NMF 2 1.000 1.000 1.000 **
ATC:mclust 6 0.966 0.985 0.986 ** 2
MAD:NMF 4 0.959 0.959 0.967 ** 2
MAD:skmeans 6 0.948 0.950 0.920 * 2
MAD:mclust 6 0.942 0.971 0.955 * 4,5
MAD:pam 6 0.912 0.850 0.876 * 2,3,4
CV:hclust 6 0.911 0.936 0.970 * 3
CV:pam 6 0.910 0.955 0.955 * 2,3
ATC:pam 6 0.902 0.929 0.908 * 2,3,4,5
CV:kmeans 3 0.869 0.952 0.918

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

CDF of consensus matrices

Cumulative distribution function curves of consensus matrix for all methods.

collect_plots(res_list, fun = plot_ecdf)

plot of chunk collect-plots

Consensus heatmap

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

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

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

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

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

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

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

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

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

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

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

Membership heatmap

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

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

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

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

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

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

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

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

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

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

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

Signature heatmap

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

Note in following heatmaps, rows are scaled.

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

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

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

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

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

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

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

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

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

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

Statistics table

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

get_stats(res_list, k = 2)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      2 1.000           1.000       1.000          0.462 0.538   0.538
#> CV:NMF      2 0.775           0.980       0.984          0.449 0.538   0.538
#> MAD:NMF     2 1.000           1.000       1.000          0.462 0.538   0.538
#> ATC:NMF     2 1.000           1.000       1.000          0.462 0.538   0.538
#> SD:skmeans  2 1.000           1.000       1.000          0.462 0.538   0.538
#> CV:skmeans  2 1.000           1.000       1.000          0.462 0.538   0.538
#> MAD:skmeans 2 1.000           1.000       1.000          0.462 0.538   0.538
#> ATC:skmeans 2 1.000           1.000       1.000          0.462 0.538   0.538
#> SD:mclust   2 1.000           0.997       0.996          0.459 0.538   0.538
#> CV:mclust   2 0.775           0.951       0.960          0.362 0.649   0.649
#> MAD:mclust  2 0.481           0.940       0.935          0.400 0.538   0.538
#> ATC:mclust  2 1.000           1.000       1.000          0.462 0.538   0.538
#> SD:kmeans   2 0.481           0.577       0.805          0.335 0.775   0.775
#> CV:kmeans   2 0.481           0.911       0.908          0.373 0.538   0.538
#> MAD:kmeans  2 1.000           0.988       0.981          0.444 0.538   0.538
#> ATC:kmeans  2 1.000           1.000       1.000          0.462 0.538   0.538
#> SD:pam      2 1.000           1.000       1.000          0.352 0.649   0.649
#> CV:pam      2 1.000           0.986       0.992          0.359 0.649   0.649
#> MAD:pam     2 1.000           1.000       1.000          0.462 0.538   0.538
#> ATC:pam     2 1.000           1.000       1.000          0.462 0.538   0.538
#> SD:hclust   2 0.538           0.733       0.842          0.283 0.775   0.775
#> CV:hclust   2 0.538           0.857       0.860          0.302 0.649   0.649
#> MAD:hclust  2 1.000           1.000       1.000          0.462 0.538   0.538
#> ATC:hclust  2 1.000           1.000       1.000          0.462 0.538   0.538
get_stats(res_list, k = 3)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      3 1.000           1.000       1.000          0.124 0.943   0.893
#> CV:NMF      3 1.000           0.994       0.990          0.166 0.943   0.893
#> MAD:NMF     3 0.766           0.953       0.938          0.175 0.943   0.893
#> ATC:NMF     3 0.726           0.927       0.875          0.189 0.943   0.893
#> SD:skmeans  3 1.000           0.985       0.980          0.139 0.943   0.893
#> CV:skmeans  3 1.000           0.991       0.988          0.133 0.943   0.893
#> MAD:skmeans 3 0.764           0.940       0.871          0.281 0.822   0.669
#> ATC:skmeans 3 0.764           0.936       0.921          0.187 0.943   0.893
#> SD:mclust   3 0.693           0.843       0.919          0.230 0.943   0.893
#> CV:mclust   3 1.000           0.976       0.965          0.467 0.832   0.741
#> MAD:mclust  3 0.619           0.921       0.923          0.324 0.943   0.893
#> ATC:mclust  3 0.678           0.779       0.834          0.266 0.943   0.893
#> SD:kmeans   3 1.000           0.978       0.949          0.487 0.706   0.621
#> CV:kmeans   3 0.869           0.952       0.918          0.364 0.943   0.893
#> MAD:kmeans  3 0.642           0.677       0.756          0.350 0.822   0.669
#> ATC:kmeans  3 0.623           0.751       0.765          0.303 0.822   0.669
#> SD:pam      3 1.000           1.000       1.000          0.477 0.832   0.741
#> CV:pam      3 1.000           1.000       1.000          0.449 0.832   0.741
#> MAD:pam     3 1.000           1.000       1.000          0.124 0.943   0.893
#> ATC:pam     3 1.000           1.000       1.000          0.124 0.943   0.893
#> SD:hclust   3 1.000           1.000       1.000          0.837 0.706   0.621
#> CV:hclust   3 1.000           1.000       1.000          0.723 0.832   0.741
#> MAD:hclust  3 1.000           1.000       1.000          0.124 0.943   0.893
#> ATC:hclust  3 1.000           1.000       1.000          0.124 0.943   0.893
get_stats(res_list, k = 4)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      4 0.801           0.960       0.930         0.3296 0.788   0.559
#> CV:NMF      4 0.836           0.927       0.928         0.3362 0.788   0.559
#> MAD:NMF     4 0.959           0.959       0.967         0.3204 0.788   0.559
#> ATC:NMF     4 0.736           0.890       0.877         0.2267 0.788   0.559
#> SD:skmeans  4 0.751           0.832       0.911         0.3100 0.822   0.629
#> CV:skmeans  4 0.751           0.882       0.918         0.3110 0.822   0.629
#> MAD:skmeans 4 0.822           0.925       0.944         0.1943 0.943   0.841
#> ATC:skmeans 4 0.822           0.895       0.930         0.2772 0.822   0.629
#> SD:mclust   4 0.751           0.940       0.959         0.2222 0.822   0.629
#> CV:mclust   4 0.784           0.903       0.929         0.3216 0.822   0.629
#> MAD:mclust  4 1.000           0.991       0.992         0.3727 0.791   0.565
#> ATC:mclust  4 0.822           0.945       0.962         0.2027 0.822   0.629
#> SD:kmeans   4 0.614           0.834       0.796         0.2503 0.975   0.949
#> CV:kmeans   4 0.632           0.824       0.842         0.2330 1.000   1.000
#> MAD:kmeans  4 0.577           0.733       0.726         0.1486 0.822   0.589
#> ATC:kmeans  4 0.589           0.652       0.718         0.1194 1.000   1.000
#> SD:pam      4 1.000           0.998       0.998         0.2073 0.892   0.776
#> CV:pam      4 0.822           0.949       0.957         0.2085 0.892   0.776
#> MAD:pam     4 1.000           0.998       0.999         0.3432 0.822   0.629
#> ATC:pam     4 0.959           0.954       0.977         0.3127 0.822   0.629
#> SD:hclust   4 0.868           0.968       0.964         0.0775 0.975   0.949
#> CV:hclust   4 0.727           0.780       0.858         0.2182 0.892   0.776
#> MAD:hclust  4 1.000           0.996       0.997         0.3434 0.822   0.629
#> ATC:hclust  4 1.000           1.000       1.000         0.0472 0.975   0.949
get_stats(res_list, k = 5)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      5 0.763           0.861       0.864         0.0934 0.874   0.588
#> CV:NMF      5 0.734           0.928       0.892         0.0924 0.874   0.588
#> MAD:NMF     5 0.803           0.891       0.892         0.0901 0.892   0.626
#> ATC:NMF     5 0.788           0.755       0.819         0.1216 0.874   0.588
#> SD:skmeans  5 0.810           0.854       0.886         0.1036 0.840   0.529
#> CV:skmeans  5 0.791           0.838       0.878         0.1140 0.840   0.529
#> MAD:skmeans 5 0.877           0.955       0.947         0.1174 0.896   0.655
#> ATC:skmeans 5 0.843           0.861       0.879         0.1036 0.896   0.655
#> SD:mclust   5 0.779           0.741       0.839         0.1044 0.929   0.766
#> CV:mclust   5 0.806           0.839       0.865         0.1042 0.929   0.766
#> MAD:mclust  5 1.000           0.999       1.000         0.1029 0.926   0.729
#> ATC:mclust  5 0.871           0.971       0.919         0.1074 0.896   0.655
#> SD:kmeans   5 0.614           0.574       0.697         0.1373 0.779   0.540
#> CV:kmeans   5 0.590           0.571       0.720         0.1289 0.831   0.649
#> MAD:kmeans  5 0.615           0.574       0.635         0.0803 0.820   0.524
#> ATC:kmeans  5 0.620           0.658       0.681         0.1039 0.872   0.644
#> SD:pam      5 0.864           0.959       0.943         0.0701 0.975   0.934
#> CV:pam      5 0.797           0.919       0.929         0.0615 0.975   0.934
#> MAD:pam     5 0.816           0.837       0.845         0.0723 0.975   0.919
#> ATC:pam     5 0.959           0.951       0.977         0.0360 0.975   0.919
#> SD:hclust   5 0.684           0.862       0.915         0.2179 0.892   0.764
#> CV:hclust   5 0.745           0.795       0.786         0.1141 0.862   0.653
#> MAD:hclust  5 0.837           0.842       0.865         0.0881 1.000   1.000
#> ATC:hclust  5 1.000           0.992       0.995         0.3261 0.822   0.609
get_stats(res_list, k = 6)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      6 0.769           0.804       0.821         0.0432 1.000   1.000
#> CV:NMF      6 0.804           0.623       0.745         0.0515 0.889   0.619
#> MAD:NMF     6 0.802           0.703       0.821         0.0438 0.990   0.948
#> ATC:NMF     6 0.793           0.839       0.854         0.0528 0.945   0.765
#> SD:skmeans  6 0.843           0.788       0.817         0.0623 0.862   0.514
#> CV:skmeans  6 0.813           0.724       0.855         0.0566 0.892   0.576
#> MAD:skmeans 6 0.948           0.950       0.920         0.0406 0.982   0.907
#> ATC:skmeans 6 0.843           0.855       0.742         0.0542 0.923   0.655
#> SD:mclust   6 0.834           0.870       0.874         0.0775 0.905   0.620
#> CV:mclust   6 0.892           0.909       0.918         0.0671 0.932   0.709
#> MAD:mclust  6 0.942           0.971       0.955         0.0333 0.975   0.876
#> ATC:mclust  6 0.966           0.985       0.986         0.0561 0.975   0.876
#> SD:kmeans   6 0.637           0.707       0.677         0.0826 0.865   0.575
#> CV:kmeans   6 0.627           0.611       0.631         0.0871 0.828   0.519
#> MAD:kmeans  6 0.649           0.784       0.723         0.0545 0.951   0.801
#> ATC:kmeans  6 0.611           0.741       0.702         0.0448 0.929   0.718
#> SD:pam      6 0.817           0.946       0.926         0.1851 0.843   0.551
#> CV:pam      6 0.910           0.955       0.955         0.1319 0.911   0.744
#> MAD:pam     6 0.912           0.850       0.876         0.0927 0.840   0.493
#> ATC:pam     6 0.902           0.929       0.908         0.0953 0.929   0.746
#> SD:hclust   6 0.810           0.890       0.936         0.1278 0.911   0.744
#> CV:hclust   6 0.911           0.936       0.970         0.0738 0.975   0.914
#> MAD:hclust  6 0.856           0.930       0.901         0.0744 0.871   0.574
#> ATC:hclust  6 1.000           0.996       0.997         0.1444 0.896   0.624

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

collect_stats(res_list, k = 2)

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

collect_stats(res_list, k = 3)

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

collect_stats(res_list, k = 4)

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

collect_stats(res_list, k = 5)

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

collect_stats(res_list, k = 6)

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

Partition from all methods

Collect partitions from all methods:

collect_classes(res_list, k = 2)

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

collect_classes(res_list, k = 3)

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

collect_classes(res_list, k = 4)

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

collect_classes(res_list, k = 5)

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

collect_classes(res_list, k = 6)

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

Top rows overlap

Overlap of top rows from different top-row methods:

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Heatmaps of the top rows:

top_rows_heatmap(res_list, top_n = 1000)

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

top_rows_heatmap(res_list, top_n = 2000)

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

top_rows_heatmap(res_list, top_n = 3000)

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

top_rows_heatmap(res_list, top_n = 4000)

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

top_rows_heatmap(res_list, top_n = 5000)

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

Results for each method


SD:hclust**

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

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

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

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 15301 rows and 63 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#>   Subgroups are detected by 'hclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 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.538           0.733       0.842         0.2829 0.775   0.775
#> 3 3 1.000           1.000       1.000         0.8368 0.706   0.621
#> 4 4 0.868           0.968       0.964         0.0775 0.975   0.949
#> 5 5 0.684           0.862       0.915         0.2179 0.892   0.764
#> 6 6 0.810           0.890       0.936         0.1278 0.911   0.744

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
#> SRR1562718     2   0.000      0.786 0.000 1.000
#> SRR1562719     2   0.000      0.786 0.000 1.000
#> SRR1562720     2   0.000      0.786 0.000 1.000
#> SRR1562721     2   0.000      0.786 0.000 1.000
#> SRR1562723     2   0.000      0.786 0.000 1.000
#> SRR1562724     2   0.000      0.786 0.000 1.000
#> SRR1562725     2   0.000      0.786 0.000 1.000
#> SRR1562726     2   0.000      0.786 0.000 1.000
#> SRR1562727     2   0.000      0.786 0.000 1.000
#> SRR1562728     2   0.000      0.786 0.000 1.000
#> SRR1562729     2   0.000      0.786 0.000 1.000
#> SRR1562730     2   0.000      0.786 0.000 1.000
#> SRR1562731     2   0.000      0.786 0.000 1.000
#> SRR1562732     2   0.000      0.786 0.000 1.000
#> SRR1562733     2   0.000      0.786 0.000 1.000
#> SRR1562734     2   0.000      0.786 0.000 1.000
#> SRR1562735     2   0.000      0.786 0.000 1.000
#> SRR1562736     2   0.000      0.786 0.000 1.000
#> SRR1562737     2   0.000      0.786 0.000 1.000
#> SRR1562738     2   0.000      0.786 0.000 1.000
#> SRR1562739     2   0.000      0.786 0.000 1.000
#> SRR1562740     2   0.000      0.786 0.000 1.000
#> SRR1562741     2   0.000      0.786 0.000 1.000
#> SRR1562742     2   0.000      0.786 0.000 1.000
#> SRR1562743     2   0.000      0.786 0.000 1.000
#> SRR1562744     2   0.000      0.786 0.000 1.000
#> SRR1562745     2   0.000      0.786 0.000 1.000
#> SRR1562746     2   0.000      0.786 0.000 1.000
#> SRR1562747     2   0.000      0.786 0.000 1.000
#> SRR1562748     2   0.000      0.786 0.000 1.000
#> SRR1562749     2   0.000      0.786 0.000 1.000
#> SRR1562750     2   0.000      0.786 0.000 1.000
#> SRR1562751     2   0.000      0.786 0.000 1.000
#> SRR1562752     2   0.000      0.786 0.000 1.000
#> SRR1562753     2   0.000      0.786 0.000 1.000
#> SRR1562754     2   0.000      0.786 0.000 1.000
#> SRR1562755     2   0.000      0.786 0.000 1.000
#> SRR1562756     2   0.000      0.786 0.000 1.000
#> SRR1562757     2   0.000      0.786 0.000 1.000
#> SRR1562758     2   0.000      0.786 0.000 1.000
#> SRR1562759     2   0.000      0.786 0.000 1.000
#> SRR1562792     1   0.993      1.000 0.548 0.452
#> SRR1562793     1   0.993      1.000 0.548 0.452
#> SRR1562794     1   0.993      1.000 0.548 0.452
#> SRR1562795     1   0.993      1.000 0.548 0.452
#> SRR1562796     1   0.993      1.000 0.548 0.452
#> SRR1562797     1   0.993      1.000 0.548 0.452
#> SRR1562798     1   0.993      1.000 0.548 0.452
#> SRR1562799     1   0.993      1.000 0.548 0.452
#> SRR1562800     2   0.993      0.424 0.452 0.548
#> SRR1562801     2   0.993      0.424 0.452 0.548
#> SRR1562802     2   0.993      0.424 0.452 0.548
#> SRR1562803     2   0.993      0.424 0.452 0.548
#> SRR1562804     2   0.993      0.424 0.452 0.548
#> SRR1562805     2   0.993      0.424 0.452 0.548
#> SRR1562806     2   0.993      0.424 0.452 0.548
#> SRR1562807     2   0.993      0.424 0.452 0.548
#> SRR1562808     2   0.993      0.424 0.452 0.548
#> SRR1562809     2   0.993      0.424 0.452 0.548
#> SRR1562810     2   0.993      0.424 0.452 0.548
#> SRR1562811     2   0.993      0.424 0.452 0.548
#> SRR1562812     2   0.993      0.424 0.452 0.548
#> SRR1562813     2   0.993      0.424 0.452 0.548

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette p1 p2 p3
#> SRR1562718     2       0          1  0  1  0
#> SRR1562719     2       0          1  0  1  0
#> SRR1562720     2       0          1  0  1  0
#> SRR1562721     2       0          1  0  1  0
#> SRR1562723     2       0          1  0  1  0
#> SRR1562724     2       0          1  0  1  0
#> SRR1562725     2       0          1  0  1  0
#> SRR1562726     2       0          1  0  1  0
#> SRR1562727     2       0          1  0  1  0
#> SRR1562728     2       0          1  0  1  0
#> SRR1562729     2       0          1  0  1  0
#> SRR1562730     2       0          1  0  1  0
#> SRR1562731     2       0          1  0  1  0
#> SRR1562732     2       0          1  0  1  0
#> SRR1562733     2       0          1  0  1  0
#> SRR1562734     2       0          1  0  1  0
#> SRR1562735     2       0          1  0  1  0
#> SRR1562736     2       0          1  0  1  0
#> SRR1562737     2       0          1  0  1  0
#> SRR1562738     2       0          1  0  1  0
#> SRR1562739     2       0          1  0  1  0
#> SRR1562740     2       0          1  0  1  0
#> SRR1562741     2       0          1  0  1  0
#> SRR1562742     2       0          1  0  1  0
#> SRR1562743     2       0          1  0  1  0
#> SRR1562744     2       0          1  0  1  0
#> SRR1562745     2       0          1  0  1  0
#> SRR1562746     2       0          1  0  1  0
#> SRR1562747     2       0          1  0  1  0
#> SRR1562748     2       0          1  0  1  0
#> SRR1562749     2       0          1  0  1  0
#> SRR1562750     2       0          1  0  1  0
#> SRR1562751     2       0          1  0  1  0
#> SRR1562752     2       0          1  0  1  0
#> SRR1562753     2       0          1  0  1  0
#> SRR1562754     2       0          1  0  1  0
#> SRR1562755     2       0          1  0  1  0
#> SRR1562756     2       0          1  0  1  0
#> SRR1562757     2       0          1  0  1  0
#> SRR1562758     2       0          1  0  1  0
#> SRR1562759     2       0          1  0  1  0
#> SRR1562792     3       0          1  0  0  1
#> SRR1562793     3       0          1  0  0  1
#> SRR1562794     3       0          1  0  0  1
#> SRR1562795     3       0          1  0  0  1
#> SRR1562796     3       0          1  0  0  1
#> SRR1562797     3       0          1  0  0  1
#> SRR1562798     3       0          1  0  0  1
#> SRR1562799     3       0          1  0  0  1
#> SRR1562800     1       0          1  1  0  0
#> SRR1562801     1       0          1  1  0  0
#> SRR1562802     1       0          1  1  0  0
#> SRR1562803     1       0          1  1  0  0
#> SRR1562804     1       0          1  1  0  0
#> SRR1562805     1       0          1  1  0  0
#> SRR1562806     1       0          1  1  0  0
#> SRR1562807     1       0          1  1  0  0
#> SRR1562808     1       0          1  1  0  0
#> SRR1562809     1       0          1  1  0  0
#> SRR1562810     1       0          1  1  0  0
#> SRR1562811     1       0          1  1  0  0
#> SRR1562812     1       0          1  1  0  0
#> SRR1562813     1       0          1  1  0  0

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2 p3    p4
#> SRR1562718     2  0.0000      0.973 0.000 1.000  0 0.000
#> SRR1562719     2  0.0000      0.973 0.000 1.000  0 0.000
#> SRR1562720     2  0.0000      0.973 0.000 1.000  0 0.000
#> SRR1562721     2  0.0000      0.973 0.000 1.000  0 0.000
#> SRR1562723     2  0.0000      0.973 0.000 1.000  0 0.000
#> SRR1562724     2  0.0000      0.973 0.000 1.000  0 0.000
#> SRR1562725     2  0.0000      0.973 0.000 1.000  0 0.000
#> SRR1562726     2  0.0000      0.973 0.000 1.000  0 0.000
#> SRR1562727     2  0.0000      0.973 0.000 1.000  0 0.000
#> SRR1562728     2  0.0000      0.973 0.000 1.000  0 0.000
#> SRR1562729     2  0.0000      0.973 0.000 1.000  0 0.000
#> SRR1562730     2  0.0000      0.973 0.000 1.000  0 0.000
#> SRR1562731     2  0.0000      0.973 0.000 1.000  0 0.000
#> SRR1562732     2  0.0000      0.973 0.000 1.000  0 0.000
#> SRR1562733     2  0.0000      0.973 0.000 1.000  0 0.000
#> SRR1562734     2  0.0000      0.973 0.000 1.000  0 0.000
#> SRR1562735     2  0.0000      0.973 0.000 1.000  0 0.000
#> SRR1562736     2  0.0000      0.973 0.000 1.000  0 0.000
#> SRR1562737     2  0.0000      0.973 0.000 1.000  0 0.000
#> SRR1562738     2  0.0000      0.973 0.000 1.000  0 0.000
#> SRR1562739     2  0.0000      0.973 0.000 1.000  0 0.000
#> SRR1562740     2  0.0000      0.973 0.000 1.000  0 0.000
#> SRR1562741     2  0.0000      0.973 0.000 1.000  0 0.000
#> SRR1562742     2  0.0000      0.973 0.000 1.000  0 0.000
#> SRR1562743     2  0.0000      0.973 0.000 1.000  0 0.000
#> SRR1562744     2  0.0000      0.973 0.000 1.000  0 0.000
#> SRR1562745     2  0.0000      0.973 0.000 1.000  0 0.000
#> SRR1562746     2  0.0000      0.973 0.000 1.000  0 0.000
#> SRR1562747     2  0.0000      0.973 0.000 1.000  0 0.000
#> SRR1562748     2  0.3486      0.825 0.000 0.812  0 0.188
#> SRR1562749     2  0.3486      0.825 0.000 0.812  0 0.188
#> SRR1562750     2  0.3486      0.825 0.000 0.812  0 0.188
#> SRR1562751     2  0.3486      0.825 0.000 0.812  0 0.188
#> SRR1562752     2  0.3486      0.825 0.000 0.812  0 0.188
#> SRR1562753     2  0.3486      0.825 0.000 0.812  0 0.188
#> SRR1562754     2  0.0188      0.971 0.000 0.996  0 0.004
#> SRR1562755     2  0.0188      0.971 0.000 0.996  0 0.004
#> SRR1562756     2  0.0188      0.971 0.000 0.996  0 0.004
#> SRR1562757     2  0.0188      0.971 0.000 0.996  0 0.004
#> SRR1562758     2  0.0188      0.971 0.000 0.996  0 0.004
#> SRR1562759     2  0.0188      0.971 0.000 0.996  0 0.004
#> SRR1562792     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1562793     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1562794     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1562795     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1562796     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1562797     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1562798     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1562799     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1562800     4  0.3486      1.000 0.188 0.000  0 0.812
#> SRR1562801     4  0.3486      1.000 0.188 0.000  0 0.812
#> SRR1562802     4  0.3486      1.000 0.188 0.000  0 0.812
#> SRR1562803     4  0.3486      1.000 0.188 0.000  0 0.812
#> SRR1562804     4  0.3486      1.000 0.188 0.000  0 0.812
#> SRR1562805     4  0.3486      1.000 0.188 0.000  0 0.812
#> SRR1562806     1  0.0000      1.000 1.000 0.000  0 0.000
#> SRR1562807     1  0.0000      1.000 1.000 0.000  0 0.000
#> SRR1562808     1  0.0000      1.000 1.000 0.000  0 0.000
#> SRR1562809     1  0.0000      1.000 1.000 0.000  0 0.000
#> SRR1562810     1  0.0000      1.000 1.000 0.000  0 0.000
#> SRR1562811     1  0.0000      1.000 1.000 0.000  0 0.000
#> SRR1562812     1  0.0000      1.000 1.000 0.000  0 0.000
#> SRR1562813     1  0.0000      1.000 1.000 0.000  0 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette p1    p2 p3    p4 p5
#> SRR1562718     2   0.000      0.834  0 1.000  0 0.000  0
#> SRR1562719     2   0.000      0.834  0 1.000  0 0.000  0
#> SRR1562720     2   0.000      0.834  0 1.000  0 0.000  0
#> SRR1562721     2   0.000      0.834  0 1.000  0 0.000  0
#> SRR1562723     2   0.000      0.834  0 1.000  0 0.000  0
#> SRR1562724     2   0.000      0.834  0 1.000  0 0.000  0
#> SRR1562725     2   0.000      0.834  0 1.000  0 0.000  0
#> SRR1562726     2   0.000      0.834  0 1.000  0 0.000  0
#> SRR1562727     2   0.000      0.834  0 1.000  0 0.000  0
#> SRR1562728     2   0.000      0.834  0 1.000  0 0.000  0
#> SRR1562729     2   0.000      0.834  0 1.000  0 0.000  0
#> SRR1562730     2   0.242      0.746  0 0.868  0 0.132  0
#> SRR1562731     2   0.242      0.746  0 0.868  0 0.132  0
#> SRR1562732     2   0.242      0.746  0 0.868  0 0.132  0
#> SRR1562733     2   0.242      0.746  0 0.868  0 0.132  0
#> SRR1562734     2   0.242      0.746  0 0.868  0 0.132  0
#> SRR1562735     2   0.242      0.746  0 0.868  0 0.132  0
#> SRR1562736     2   0.223      0.826  0 0.884  0 0.116  0
#> SRR1562737     2   0.223      0.826  0 0.884  0 0.116  0
#> SRR1562738     2   0.223      0.826  0 0.884  0 0.116  0
#> SRR1562739     2   0.223      0.826  0 0.884  0 0.116  0
#> SRR1562740     2   0.223      0.826  0 0.884  0 0.116  0
#> SRR1562741     2   0.223      0.826  0 0.884  0 0.116  0
#> SRR1562742     2   0.223      0.826  0 0.884  0 0.116  0
#> SRR1562743     2   0.223      0.826  0 0.884  0 0.116  0
#> SRR1562744     2   0.223      0.826  0 0.884  0 0.116  0
#> SRR1562745     2   0.223      0.826  0 0.884  0 0.116  0
#> SRR1562746     2   0.223      0.826  0 0.884  0 0.116  0
#> SRR1562747     2   0.223      0.826  0 0.884  0 0.116  0
#> SRR1562748     4   0.242      1.000  0 0.132  0 0.868  0
#> SRR1562749     4   0.242      1.000  0 0.132  0 0.868  0
#> SRR1562750     4   0.242      1.000  0 0.132  0 0.868  0
#> SRR1562751     4   0.242      1.000  0 0.132  0 0.868  0
#> SRR1562752     4   0.242      1.000  0 0.132  0 0.868  0
#> SRR1562753     4   0.242      1.000  0 0.132  0 0.868  0
#> SRR1562754     2   0.413      0.459  0 0.620  0 0.380  0
#> SRR1562755     2   0.413      0.459  0 0.620  0 0.380  0
#> SRR1562756     2   0.413      0.459  0 0.620  0 0.380  0
#> SRR1562757     2   0.413      0.459  0 0.620  0 0.380  0
#> SRR1562758     2   0.413      0.459  0 0.620  0 0.380  0
#> SRR1562759     2   0.413      0.459  0 0.620  0 0.380  0
#> SRR1562792     3   0.000      1.000  0 0.000  1 0.000  0
#> SRR1562793     3   0.000      1.000  0 0.000  1 0.000  0
#> SRR1562794     3   0.000      1.000  0 0.000  1 0.000  0
#> SRR1562795     3   0.000      1.000  0 0.000  1 0.000  0
#> SRR1562796     3   0.000      1.000  0 0.000  1 0.000  0
#> SRR1562797     3   0.000      1.000  0 0.000  1 0.000  0
#> SRR1562798     3   0.000      1.000  0 0.000  1 0.000  0
#> SRR1562799     3   0.000      1.000  0 0.000  1 0.000  0
#> SRR1562800     5   0.000      1.000  0 0.000  0 0.000  1
#> SRR1562801     5   0.000      1.000  0 0.000  0 0.000  1
#> SRR1562802     5   0.000      1.000  0 0.000  0 0.000  1
#> SRR1562803     5   0.000      1.000  0 0.000  0 0.000  1
#> SRR1562804     5   0.000      1.000  0 0.000  0 0.000  1
#> SRR1562805     5   0.000      1.000  0 0.000  0 0.000  1
#> SRR1562806     1   0.000      1.000  1 0.000  0 0.000  0
#> SRR1562807     1   0.000      1.000  1 0.000  0 0.000  0
#> SRR1562808     1   0.000      1.000  1 0.000  0 0.000  0
#> SRR1562809     1   0.000      1.000  1 0.000  0 0.000  0
#> SRR1562810     1   0.000      1.000  1 0.000  0 0.000  0
#> SRR1562811     1   0.000      1.000  1 0.000  0 0.000  0
#> SRR1562812     1   0.000      1.000  1 0.000  0 0.000  0
#> SRR1562813     1   0.000      1.000  1 0.000  0 0.000  0

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette p1    p2 p3   p4    p5 p6
#> SRR1562718     5  0.2941      0.766  0 0.220  0 0.00 0.780  0
#> SRR1562719     5  0.2941      0.766  0 0.220  0 0.00 0.780  0
#> SRR1562720     5  0.2941      0.766  0 0.220  0 0.00 0.780  0
#> SRR1562721     5  0.2941      0.766  0 0.220  0 0.00 0.780  0
#> SRR1562723     5  0.2941      0.766  0 0.220  0 0.00 0.780  0
#> SRR1562724     5  0.2941      0.766  0 0.220  0 0.00 0.780  0
#> SRR1562725     5  0.2941      0.766  0 0.220  0 0.00 0.780  0
#> SRR1562726     5  0.2941      0.766  0 0.220  0 0.00 0.780  0
#> SRR1562727     5  0.2941      0.766  0 0.220  0 0.00 0.780  0
#> SRR1562728     5  0.2941      0.766  0 0.220  0 0.00 0.780  0
#> SRR1562729     5  0.2941      0.766  0 0.220  0 0.00 0.780  0
#> SRR1562730     2  0.0146      1.000  0 0.996  0 0.00 0.004  0
#> SRR1562731     2  0.0146      1.000  0 0.996  0 0.00 0.004  0
#> SRR1562732     2  0.0146      1.000  0 0.996  0 0.00 0.004  0
#> SRR1562733     2  0.0146      1.000  0 0.996  0 0.00 0.004  0
#> SRR1562734     2  0.0146      1.000  0 0.996  0 0.00 0.004  0
#> SRR1562735     2  0.0146      1.000  0 0.996  0 0.00 0.004  0
#> SRR1562736     5  0.0000      0.829  0 0.000  0 0.00 1.000  0
#> SRR1562737     5  0.0000      0.829  0 0.000  0 0.00 1.000  0
#> SRR1562738     5  0.0000      0.829  0 0.000  0 0.00 1.000  0
#> SRR1562739     5  0.0000      0.829  0 0.000  0 0.00 1.000  0
#> SRR1562740     5  0.0000      0.829  0 0.000  0 0.00 1.000  0
#> SRR1562741     5  0.0000      0.829  0 0.000  0 0.00 1.000  0
#> SRR1562742     5  0.0000      0.829  0 0.000  0 0.00 1.000  0
#> SRR1562743     5  0.0000      0.829  0 0.000  0 0.00 1.000  0
#> SRR1562744     5  0.0000      0.829  0 0.000  0 0.00 1.000  0
#> SRR1562745     5  0.0000      0.829  0 0.000  0 0.00 1.000  0
#> SRR1562746     5  0.0000      0.829  0 0.000  0 0.00 1.000  0
#> SRR1562747     5  0.0000      0.829  0 0.000  0 0.00 1.000  0
#> SRR1562748     4  0.0000      1.000  0 0.000  0 1.00 0.000  0
#> SRR1562749     4  0.0000      1.000  0 0.000  0 1.00 0.000  0
#> SRR1562750     4  0.0000      1.000  0 0.000  0 1.00 0.000  0
#> SRR1562751     4  0.0000      1.000  0 0.000  0 1.00 0.000  0
#> SRR1562752     4  0.0000      1.000  0 0.000  0 1.00 0.000  0
#> SRR1562753     4  0.0000      1.000  0 0.000  0 1.00 0.000  0
#> SRR1562754     5  0.3337      0.620  0 0.004  0 0.26 0.736  0
#> SRR1562755     5  0.3337      0.620  0 0.004  0 0.26 0.736  0
#> SRR1562756     5  0.3337      0.620  0 0.004  0 0.26 0.736  0
#> SRR1562757     5  0.3337      0.620  0 0.004  0 0.26 0.736  0
#> SRR1562758     5  0.3337      0.620  0 0.004  0 0.26 0.736  0
#> SRR1562759     5  0.3337      0.620  0 0.004  0 0.26 0.736  0
#> SRR1562792     3  0.0000      1.000  0 0.000  1 0.00 0.000  0
#> SRR1562793     3  0.0000      1.000  0 0.000  1 0.00 0.000  0
#> SRR1562794     3  0.0000      1.000  0 0.000  1 0.00 0.000  0
#> SRR1562795     3  0.0000      1.000  0 0.000  1 0.00 0.000  0
#> SRR1562796     3  0.0000      1.000  0 0.000  1 0.00 0.000  0
#> SRR1562797     3  0.0000      1.000  0 0.000  1 0.00 0.000  0
#> SRR1562798     3  0.0000      1.000  0 0.000  1 0.00 0.000  0
#> SRR1562799     3  0.0000      1.000  0 0.000  1 0.00 0.000  0
#> SRR1562800     6  0.0000      1.000  0 0.000  0 0.00 0.000  1
#> SRR1562801     6  0.0000      1.000  0 0.000  0 0.00 0.000  1
#> SRR1562802     6  0.0000      1.000  0 0.000  0 0.00 0.000  1
#> SRR1562803     6  0.0000      1.000  0 0.000  0 0.00 0.000  1
#> SRR1562804     6  0.0000      1.000  0 0.000  0 0.00 0.000  1
#> SRR1562805     6  0.0000      1.000  0 0.000  0 0.00 0.000  1
#> SRR1562806     1  0.0000      1.000  1 0.000  0 0.00 0.000  0
#> SRR1562807     1  0.0000      1.000  1 0.000  0 0.00 0.000  0
#> SRR1562808     1  0.0000      1.000  1 0.000  0 0.00 0.000  0
#> SRR1562809     1  0.0000      1.000  1 0.000  0 0.00 0.000  0
#> SRR1562810     1  0.0000      1.000  1 0.000  0 0.00 0.000  0
#> SRR1562811     1  0.0000      1.000  1 0.000  0 0.00 0.000  0
#> SRR1562812     1  0.0000      1.000  1 0.000  0 0.00 0.000  0
#> SRR1562813     1  0.0000      1.000  1 0.000  0 0.00 0.000  0

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-hclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-hclust-collect-classes

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


SD:kmeans**

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

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

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

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 15301 rows and 63 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#>   Subgroups are detected by 'kmeans' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 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.481           0.577       0.805         0.3347 0.775   0.775
#> 3 3 1.000           0.978       0.949         0.4870 0.706   0.621
#> 4 4 0.614           0.834       0.796         0.2503 0.975   0.949
#> 5 5 0.614           0.574       0.697         0.1373 0.779   0.540
#> 6 6 0.637           0.707       0.677         0.0826 0.865   0.575

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
#> SRR1562718     2   0.973     0.7014 0.404 0.596
#> SRR1562719     2   0.973     0.7014 0.404 0.596
#> SRR1562720     2   0.973     0.7014 0.404 0.596
#> SRR1562721     2   0.973     0.7014 0.404 0.596
#> SRR1562723     2   0.973     0.7014 0.404 0.596
#> SRR1562724     2   0.973     0.7014 0.404 0.596
#> SRR1562725     2   0.973     0.7014 0.404 0.596
#> SRR1562726     2   0.973     0.7014 0.404 0.596
#> SRR1562727     2   0.973     0.7014 0.404 0.596
#> SRR1562728     2   0.973     0.7014 0.404 0.596
#> SRR1562729     2   0.973     0.7014 0.404 0.596
#> SRR1562730     2   0.973     0.7014 0.404 0.596
#> SRR1562731     2   0.973     0.7014 0.404 0.596
#> SRR1562732     2   0.973     0.7014 0.404 0.596
#> SRR1562733     2   0.973     0.7014 0.404 0.596
#> SRR1562734     2   0.973     0.7014 0.404 0.596
#> SRR1562735     2   0.973     0.7014 0.404 0.596
#> SRR1562736     2   0.973     0.7014 0.404 0.596
#> SRR1562737     2   0.973     0.7014 0.404 0.596
#> SRR1562738     2   0.973     0.7014 0.404 0.596
#> SRR1562739     2   0.973     0.7014 0.404 0.596
#> SRR1562740     2   0.973     0.7014 0.404 0.596
#> SRR1562741     2   0.973     0.7014 0.404 0.596
#> SRR1562742     2   0.973     0.7014 0.404 0.596
#> SRR1562743     2   0.973     0.7014 0.404 0.596
#> SRR1562744     2   0.973     0.7014 0.404 0.596
#> SRR1562745     2   0.973     0.7014 0.404 0.596
#> SRR1562746     2   0.973     0.7014 0.404 0.596
#> SRR1562747     2   0.973     0.7014 0.404 0.596
#> SRR1562748     2   0.973     0.7014 0.404 0.596
#> SRR1562749     2   0.973     0.7014 0.404 0.596
#> SRR1562750     2   0.973     0.7014 0.404 0.596
#> SRR1562751     2   0.973     0.7014 0.404 0.596
#> SRR1562752     2   0.973     0.7014 0.404 0.596
#> SRR1562753     2   0.973     0.7014 0.404 0.596
#> SRR1562754     2   0.973     0.7014 0.404 0.596
#> SRR1562755     2   0.973     0.7014 0.404 0.596
#> SRR1562756     2   0.973     0.7014 0.404 0.596
#> SRR1562757     2   0.973     0.7014 0.404 0.596
#> SRR1562758     2   0.973     0.7014 0.404 0.596
#> SRR1562759     2   0.973     0.7014 0.404 0.596
#> SRR1562792     1   0.000     1.0000 1.000 0.000
#> SRR1562793     1   0.000     1.0000 1.000 0.000
#> SRR1562794     1   0.000     1.0000 1.000 0.000
#> SRR1562795     1   0.000     1.0000 1.000 0.000
#> SRR1562796     1   0.000     1.0000 1.000 0.000
#> SRR1562797     1   0.000     1.0000 1.000 0.000
#> SRR1562798     1   0.000     1.0000 1.000 0.000
#> SRR1562799     1   0.000     1.0000 1.000 0.000
#> SRR1562800     2   0.802    -0.0282 0.244 0.756
#> SRR1562801     2   0.802    -0.0282 0.244 0.756
#> SRR1562802     2   0.802    -0.0282 0.244 0.756
#> SRR1562803     2   0.802    -0.0282 0.244 0.756
#> SRR1562804     2   0.802    -0.0282 0.244 0.756
#> SRR1562805     2   0.802    -0.0282 0.244 0.756
#> SRR1562806     2   0.802    -0.0282 0.244 0.756
#> SRR1562807     2   0.802    -0.0282 0.244 0.756
#> SRR1562808     2   0.802    -0.0282 0.244 0.756
#> SRR1562809     2   0.802    -0.0282 0.244 0.756
#> SRR1562810     2   0.802    -0.0282 0.244 0.756
#> SRR1562811     2   0.802    -0.0282 0.244 0.756
#> SRR1562812     2   0.802    -0.0282 0.244 0.756
#> SRR1562813     2   0.802    -0.0282 0.244 0.756

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1562718     2  0.1031      0.982 0.000 0.976 0.024
#> SRR1562719     2  0.1031      0.982 0.000 0.976 0.024
#> SRR1562720     2  0.1031      0.982 0.000 0.976 0.024
#> SRR1562721     2  0.1031      0.982 0.000 0.976 0.024
#> SRR1562723     2  0.1031      0.982 0.000 0.976 0.024
#> SRR1562724     2  0.1163      0.981 0.000 0.972 0.028
#> SRR1562725     2  0.1163      0.981 0.000 0.972 0.028
#> SRR1562726     2  0.1163      0.981 0.000 0.972 0.028
#> SRR1562727     2  0.1163      0.981 0.000 0.972 0.028
#> SRR1562728     2  0.1163      0.981 0.000 0.972 0.028
#> SRR1562729     2  0.1163      0.981 0.000 0.972 0.028
#> SRR1562730     2  0.1411      0.979 0.000 0.964 0.036
#> SRR1562731     2  0.1411      0.979 0.000 0.964 0.036
#> SRR1562732     2  0.1411      0.979 0.000 0.964 0.036
#> SRR1562733     2  0.1411      0.979 0.000 0.964 0.036
#> SRR1562734     2  0.1411      0.979 0.000 0.964 0.036
#> SRR1562735     2  0.1411      0.979 0.000 0.964 0.036
#> SRR1562736     2  0.0237      0.985 0.000 0.996 0.004
#> SRR1562737     2  0.0237      0.985 0.000 0.996 0.004
#> SRR1562738     2  0.0237      0.985 0.000 0.996 0.004
#> SRR1562739     2  0.0237      0.985 0.000 0.996 0.004
#> SRR1562740     2  0.0237      0.985 0.000 0.996 0.004
#> SRR1562741     2  0.0237      0.985 0.000 0.996 0.004
#> SRR1562742     2  0.0237      0.984 0.000 0.996 0.004
#> SRR1562743     2  0.0237      0.984 0.000 0.996 0.004
#> SRR1562744     2  0.0237      0.984 0.000 0.996 0.004
#> SRR1562745     2  0.0237      0.984 0.000 0.996 0.004
#> SRR1562746     2  0.0237      0.984 0.000 0.996 0.004
#> SRR1562747     2  0.0237      0.984 0.000 0.996 0.004
#> SRR1562748     2  0.0592      0.984 0.000 0.988 0.012
#> SRR1562749     2  0.0592      0.984 0.000 0.988 0.012
#> SRR1562750     2  0.0592      0.984 0.000 0.988 0.012
#> SRR1562751     2  0.0592      0.984 0.000 0.988 0.012
#> SRR1562752     2  0.0592      0.984 0.000 0.988 0.012
#> SRR1562753     2  0.0592      0.984 0.000 0.988 0.012
#> SRR1562754     2  0.0424      0.984 0.000 0.992 0.008
#> SRR1562755     2  0.0424      0.984 0.000 0.992 0.008
#> SRR1562756     2  0.0424      0.984 0.000 0.992 0.008
#> SRR1562757     2  0.0424      0.984 0.000 0.992 0.008
#> SRR1562758     2  0.0424      0.984 0.000 0.992 0.008
#> SRR1562759     2  0.0424      0.984 0.000 0.992 0.008
#> SRR1562792     3  0.4232      0.979 0.044 0.084 0.872
#> SRR1562793     3  0.4232      0.979 0.044 0.084 0.872
#> SRR1562794     3  0.4232      0.979 0.044 0.084 0.872
#> SRR1562795     3  0.4232      0.979 0.044 0.084 0.872
#> SRR1562796     3  0.5500      0.979 0.100 0.084 0.816
#> SRR1562797     3  0.5500      0.979 0.100 0.084 0.816
#> SRR1562798     3  0.5500      0.979 0.100 0.084 0.816
#> SRR1562799     3  0.5500      0.979 0.100 0.084 0.816
#> SRR1562800     1  0.4281      0.960 0.872 0.056 0.072
#> SRR1562801     1  0.4281      0.960 0.872 0.056 0.072
#> SRR1562802     1  0.4281      0.960 0.872 0.056 0.072
#> SRR1562803     1  0.4281      0.960 0.872 0.056 0.072
#> SRR1562804     1  0.4281      0.960 0.872 0.056 0.072
#> SRR1562805     1  0.4281      0.960 0.872 0.056 0.072
#> SRR1562806     1  0.2384      0.967 0.936 0.056 0.008
#> SRR1562807     1  0.2384      0.967 0.936 0.056 0.008
#> SRR1562808     1  0.2384      0.967 0.936 0.056 0.008
#> SRR1562809     1  0.2384      0.967 0.936 0.056 0.008
#> SRR1562810     1  0.2200      0.968 0.940 0.056 0.004
#> SRR1562811     1  0.2200      0.968 0.940 0.056 0.004
#> SRR1562812     1  0.2200      0.968 0.940 0.056 0.004
#> SRR1562813     1  0.2200      0.968 0.940 0.056 0.004

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1562718     2  0.3528      0.798 0.000 0.808 0.000 0.192
#> SRR1562719     2  0.3528      0.798 0.000 0.808 0.000 0.192
#> SRR1562720     2  0.3528      0.798 0.000 0.808 0.000 0.192
#> SRR1562721     2  0.3528      0.798 0.000 0.808 0.000 0.192
#> SRR1562723     2  0.3528      0.798 0.000 0.808 0.000 0.192
#> SRR1562724     2  0.3852      0.798 0.008 0.800 0.000 0.192
#> SRR1562725     2  0.3852      0.798 0.008 0.800 0.000 0.192
#> SRR1562726     2  0.3852      0.798 0.008 0.800 0.000 0.192
#> SRR1562727     2  0.3852      0.798 0.008 0.800 0.000 0.192
#> SRR1562728     2  0.3852      0.798 0.008 0.800 0.000 0.192
#> SRR1562729     2  0.3852      0.798 0.008 0.800 0.000 0.192
#> SRR1562730     2  0.4560      0.739 0.004 0.700 0.000 0.296
#> SRR1562731     2  0.4560      0.739 0.004 0.700 0.000 0.296
#> SRR1562732     2  0.4560      0.739 0.004 0.700 0.000 0.296
#> SRR1562733     2  0.4560      0.739 0.004 0.700 0.000 0.296
#> SRR1562734     2  0.4560      0.739 0.004 0.700 0.000 0.296
#> SRR1562735     2  0.4560      0.739 0.004 0.700 0.000 0.296
#> SRR1562736     2  0.1637      0.820 0.060 0.940 0.000 0.000
#> SRR1562737     2  0.1637      0.820 0.060 0.940 0.000 0.000
#> SRR1562738     2  0.1637      0.820 0.060 0.940 0.000 0.000
#> SRR1562739     2  0.1637      0.820 0.060 0.940 0.000 0.000
#> SRR1562740     2  0.1637      0.820 0.060 0.940 0.000 0.000
#> SRR1562741     2  0.1637      0.820 0.060 0.940 0.000 0.000
#> SRR1562742     2  0.1677      0.820 0.040 0.948 0.000 0.012
#> SRR1562743     2  0.1677      0.820 0.040 0.948 0.000 0.012
#> SRR1562744     2  0.1677      0.820 0.040 0.948 0.000 0.012
#> SRR1562745     2  0.1677      0.820 0.040 0.948 0.000 0.012
#> SRR1562746     2  0.1677      0.820 0.040 0.948 0.000 0.012
#> SRR1562747     2  0.1677      0.820 0.040 0.948 0.000 0.012
#> SRR1562748     2  0.4222      0.715 0.272 0.728 0.000 0.000
#> SRR1562749     2  0.4222      0.715 0.272 0.728 0.000 0.000
#> SRR1562750     2  0.4222      0.715 0.272 0.728 0.000 0.000
#> SRR1562751     2  0.4222      0.715 0.272 0.728 0.000 0.000
#> SRR1562752     2  0.4222      0.715 0.272 0.728 0.000 0.000
#> SRR1562753     2  0.4222      0.715 0.272 0.728 0.000 0.000
#> SRR1562754     2  0.3123      0.788 0.156 0.844 0.000 0.000
#> SRR1562755     2  0.3123      0.788 0.156 0.844 0.000 0.000
#> SRR1562756     2  0.3123      0.788 0.156 0.844 0.000 0.000
#> SRR1562757     2  0.3123      0.788 0.156 0.844 0.000 0.000
#> SRR1562758     2  0.3123      0.788 0.156 0.844 0.000 0.000
#> SRR1562759     2  0.3123      0.788 0.156 0.844 0.000 0.000
#> SRR1562792     3  0.0817      0.961 0.000 0.024 0.976 0.000
#> SRR1562793     3  0.0817      0.961 0.000 0.024 0.976 0.000
#> SRR1562794     3  0.0817      0.961 0.000 0.024 0.976 0.000
#> SRR1562795     3  0.0817      0.961 0.000 0.024 0.976 0.000
#> SRR1562796     3  0.3143      0.961 0.100 0.024 0.876 0.000
#> SRR1562797     3  0.3143      0.961 0.100 0.024 0.876 0.000
#> SRR1562798     3  0.3143      0.961 0.100 0.024 0.876 0.000
#> SRR1562799     3  0.3143      0.961 0.100 0.024 0.876 0.000
#> SRR1562800     4  0.4535      0.987 0.292 0.000 0.004 0.704
#> SRR1562801     4  0.4535      0.987 0.292 0.000 0.004 0.704
#> SRR1562802     4  0.4535      0.987 0.292 0.000 0.004 0.704
#> SRR1562803     4  0.4535      0.987 0.292 0.000 0.004 0.704
#> SRR1562804     4  0.4908      0.975 0.292 0.000 0.016 0.692
#> SRR1562805     4  0.4908      0.975 0.292 0.000 0.016 0.692
#> SRR1562806     1  0.5070      0.865 0.580 0.000 0.004 0.416
#> SRR1562807     1  0.5070      0.865 0.580 0.000 0.004 0.416
#> SRR1562808     1  0.5070      0.865 0.580 0.000 0.004 0.416
#> SRR1562809     1  0.5070      0.865 0.580 0.000 0.004 0.416
#> SRR1562810     1  0.5483      0.856 0.536 0.000 0.016 0.448
#> SRR1562811     1  0.5483      0.856 0.536 0.000 0.016 0.448
#> SRR1562812     1  0.5483      0.856 0.536 0.000 0.016 0.448
#> SRR1562813     1  0.5483      0.856 0.536 0.000 0.016 0.448

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4    p5
#> SRR1562718     2  0.4367    -0.1850 0.000 0.580 0.000 0.004 0.416
#> SRR1562719     2  0.4367    -0.1850 0.000 0.580 0.000 0.004 0.416
#> SRR1562720     2  0.4367    -0.1850 0.000 0.580 0.000 0.004 0.416
#> SRR1562721     2  0.4367    -0.1850 0.000 0.580 0.000 0.004 0.416
#> SRR1562723     2  0.4367    -0.1850 0.000 0.580 0.000 0.004 0.416
#> SRR1562724     2  0.4909    -0.0542 0.000 0.588 0.000 0.032 0.380
#> SRR1562725     2  0.4909    -0.0542 0.000 0.588 0.000 0.032 0.380
#> SRR1562726     2  0.4909    -0.0542 0.000 0.588 0.000 0.032 0.380
#> SRR1562727     2  0.4909    -0.0542 0.000 0.588 0.000 0.032 0.380
#> SRR1562728     2  0.4909    -0.0542 0.000 0.588 0.000 0.032 0.380
#> SRR1562729     2  0.4909    -0.0542 0.000 0.588 0.000 0.032 0.380
#> SRR1562730     5  0.5458     0.9926 0.000 0.380 0.000 0.068 0.552
#> SRR1562731     5  0.5294     0.9941 0.000 0.380 0.000 0.056 0.564
#> SRR1562732     5  0.5405     0.9941 0.000 0.380 0.000 0.064 0.556
#> SRR1562733     5  0.5405     0.9929 0.000 0.380 0.000 0.064 0.556
#> SRR1562734     5  0.5294     0.9941 0.000 0.380 0.000 0.056 0.564
#> SRR1562735     5  0.5351     0.9940 0.000 0.380 0.000 0.060 0.560
#> SRR1562736     2  0.1872     0.4617 0.000 0.928 0.000 0.052 0.020
#> SRR1562737     2  0.1872     0.4617 0.000 0.928 0.000 0.052 0.020
#> SRR1562738     2  0.1872     0.4617 0.000 0.928 0.000 0.052 0.020
#> SRR1562739     2  0.1872     0.4617 0.000 0.928 0.000 0.052 0.020
#> SRR1562740     2  0.1872     0.4617 0.000 0.928 0.000 0.052 0.020
#> SRR1562741     2  0.1872     0.4617 0.000 0.928 0.000 0.052 0.020
#> SRR1562742     2  0.2782     0.4954 0.000 0.880 0.000 0.048 0.072
#> SRR1562743     2  0.2782     0.4954 0.000 0.880 0.000 0.048 0.072
#> SRR1562744     2  0.2782     0.4954 0.000 0.880 0.000 0.048 0.072
#> SRR1562745     2  0.2782     0.4954 0.000 0.880 0.000 0.048 0.072
#> SRR1562746     2  0.2782     0.4954 0.000 0.880 0.000 0.048 0.072
#> SRR1562747     2  0.2782     0.4954 0.000 0.880 0.000 0.048 0.072
#> SRR1562748     4  0.4446     0.9919 0.000 0.476 0.000 0.520 0.004
#> SRR1562749     4  0.4744     0.9898 0.000 0.476 0.000 0.508 0.016
#> SRR1562750     4  0.4655     0.9906 0.000 0.476 0.000 0.512 0.012
#> SRR1562751     4  0.4744     0.9898 0.000 0.476 0.000 0.508 0.016
#> SRR1562752     4  0.4655     0.9913 0.000 0.476 0.000 0.512 0.012
#> SRR1562753     4  0.4827     0.9901 0.000 0.476 0.000 0.504 0.020
#> SRR1562754     2  0.4226     0.1231 0.000 0.764 0.000 0.176 0.060
#> SRR1562755     2  0.4226     0.1231 0.000 0.764 0.000 0.176 0.060
#> SRR1562756     2  0.4226     0.1231 0.000 0.764 0.000 0.176 0.060
#> SRR1562757     2  0.4226     0.1231 0.000 0.764 0.000 0.176 0.060
#> SRR1562758     2  0.4226     0.1231 0.000 0.764 0.000 0.176 0.060
#> SRR1562759     2  0.4226     0.1231 0.000 0.764 0.000 0.176 0.060
#> SRR1562792     3  0.3803     0.9216 0.000 0.000 0.804 0.056 0.140
#> SRR1562793     3  0.3825     0.9216 0.000 0.000 0.804 0.060 0.136
#> SRR1562794     3  0.3825     0.9216 0.000 0.000 0.804 0.060 0.136
#> SRR1562795     3  0.3803     0.9216 0.000 0.000 0.804 0.056 0.140
#> SRR1562796     3  0.0162     0.9216 0.000 0.000 0.996 0.004 0.000
#> SRR1562797     3  0.0000     0.9218 0.000 0.000 1.000 0.000 0.000
#> SRR1562798     3  0.0000     0.9218 0.000 0.000 1.000 0.000 0.000
#> SRR1562799     3  0.0000     0.9218 0.000 0.000 1.000 0.000 0.000
#> SRR1562800     1  0.0000     0.8142 1.000 0.000 0.000 0.000 0.000
#> SRR1562801     1  0.0000     0.8142 1.000 0.000 0.000 0.000 0.000
#> SRR1562802     1  0.0000     0.8142 1.000 0.000 0.000 0.000 0.000
#> SRR1562803     1  0.0000     0.8142 1.000 0.000 0.000 0.000 0.000
#> SRR1562804     1  0.0290     0.8139 0.992 0.000 0.000 0.000 0.008
#> SRR1562805     1  0.0290     0.8139 0.992 0.000 0.000 0.000 0.008
#> SRR1562806     1  0.5530     0.8405 0.640 0.000 0.000 0.228 0.132
#> SRR1562807     1  0.5530     0.8405 0.640 0.000 0.000 0.228 0.132
#> SRR1562808     1  0.5530     0.8405 0.640 0.000 0.000 0.228 0.132
#> SRR1562809     1  0.5530     0.8405 0.640 0.000 0.000 0.228 0.132
#> SRR1562810     1  0.5035     0.8488 0.672 0.000 0.000 0.252 0.076
#> SRR1562811     1  0.5035     0.8488 0.672 0.000 0.000 0.252 0.076
#> SRR1562812     1  0.5035     0.8488 0.672 0.000 0.000 0.252 0.076
#> SRR1562813     1  0.5035     0.8488 0.672 0.000 0.000 0.252 0.076

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5 p6
#> SRR1562718     2  0.1765      0.696 0.000 0.924 0.000 0.000 0.052 NA
#> SRR1562719     2  0.1765      0.696 0.000 0.924 0.000 0.000 0.052 NA
#> SRR1562720     2  0.1765      0.696 0.000 0.924 0.000 0.000 0.052 NA
#> SRR1562721     2  0.1765      0.696 0.000 0.924 0.000 0.000 0.052 NA
#> SRR1562723     2  0.1765      0.696 0.000 0.924 0.000 0.000 0.052 NA
#> SRR1562724     2  0.2401      0.682 0.000 0.900 0.000 0.044 0.020 NA
#> SRR1562725     2  0.2401      0.682 0.000 0.900 0.000 0.044 0.020 NA
#> SRR1562726     2  0.2394      0.682 0.000 0.900 0.000 0.048 0.020 NA
#> SRR1562727     2  0.2401      0.682 0.000 0.900 0.000 0.044 0.020 NA
#> SRR1562728     2  0.2394      0.682 0.000 0.900 0.000 0.048 0.020 NA
#> SRR1562729     2  0.2401      0.682 0.000 0.900 0.000 0.044 0.020 NA
#> SRR1562730     2  0.5938      0.629 0.000 0.620 0.000 0.140 0.076 NA
#> SRR1562731     2  0.5900      0.629 0.000 0.620 0.000 0.172 0.068 NA
#> SRR1562732     2  0.5971      0.629 0.000 0.620 0.000 0.144 0.084 NA
#> SRR1562733     2  0.5958      0.629 0.000 0.620 0.000 0.148 0.080 NA
#> SRR1562734     2  0.5916      0.629 0.000 0.620 0.000 0.172 0.072 NA
#> SRR1562735     2  0.5900      0.629 0.000 0.620 0.000 0.172 0.068 NA
#> SRR1562736     5  0.6004      0.614 0.000 0.432 0.000 0.088 0.436 NA
#> SRR1562737     5  0.6004      0.614 0.000 0.432 0.000 0.088 0.436 NA
#> SRR1562738     5  0.6004      0.614 0.000 0.432 0.000 0.088 0.436 NA
#> SRR1562739     5  0.6004      0.614 0.000 0.432 0.000 0.088 0.436 NA
#> SRR1562740     5  0.6004      0.614 0.000 0.432 0.000 0.088 0.436 NA
#> SRR1562741     5  0.6004      0.614 0.000 0.432 0.000 0.088 0.436 NA
#> SRR1562742     5  0.4319      0.613 0.000 0.400 0.000 0.000 0.576 NA
#> SRR1562743     5  0.4319      0.613 0.000 0.400 0.000 0.000 0.576 NA
#> SRR1562744     5  0.4319      0.613 0.000 0.400 0.000 0.000 0.576 NA
#> SRR1562745     5  0.4319      0.613 0.000 0.400 0.000 0.000 0.576 NA
#> SRR1562746     5  0.4319      0.613 0.000 0.400 0.000 0.000 0.576 NA
#> SRR1562747     5  0.4319      0.613 0.000 0.400 0.000 0.000 0.576 NA
#> SRR1562748     4  0.5425      0.985 0.000 0.112 0.000 0.600 0.272 NA
#> SRR1562749     4  0.5029      0.984 0.000 0.112 0.000 0.612 0.276 NA
#> SRR1562750     4  0.5627      0.977 0.000 0.112 0.000 0.580 0.284 NA
#> SRR1562751     4  0.5145      0.985 0.000 0.112 0.000 0.612 0.272 NA
#> SRR1562752     4  0.5520      0.984 0.000 0.112 0.000 0.592 0.276 NA
#> SRR1562753     4  0.5046      0.985 0.000 0.112 0.000 0.608 0.280 NA
#> SRR1562754     5  0.6202      0.306 0.000 0.220 0.000 0.168 0.560 NA
#> SRR1562755     5  0.6202      0.306 0.000 0.220 0.000 0.168 0.560 NA
#> SRR1562756     5  0.6420      0.303 0.000 0.220 0.000 0.164 0.544 NA
#> SRR1562757     5  0.6420      0.303 0.000 0.220 0.000 0.164 0.544 NA
#> SRR1562758     5  0.6202      0.306 0.000 0.220 0.000 0.168 0.560 NA
#> SRR1562759     5  0.6202      0.306 0.000 0.220 0.000 0.168 0.560 NA
#> SRR1562792     3  0.0291      0.874 0.000 0.000 0.992 0.004 0.004 NA
#> SRR1562793     3  0.0000      0.875 0.000 0.000 1.000 0.000 0.000 NA
#> SRR1562794     3  0.0000      0.875 0.000 0.000 1.000 0.000 0.000 NA
#> SRR1562795     3  0.0000      0.875 0.000 0.000 1.000 0.000 0.000 NA
#> SRR1562796     3  0.4926      0.874 0.000 0.000 0.704 0.072 0.044 NA
#> SRR1562797     3  0.4926      0.874 0.000 0.000 0.704 0.072 0.044 NA
#> SRR1562798     3  0.4882      0.874 0.000 0.000 0.704 0.064 0.044 NA
#> SRR1562799     3  0.4882      0.874 0.000 0.000 0.704 0.064 0.044 NA
#> SRR1562800     1  0.3934      0.771 0.616 0.000 0.000 0.000 0.008 NA
#> SRR1562801     1  0.3934      0.771 0.616 0.000 0.000 0.000 0.008 NA
#> SRR1562802     1  0.3717      0.771 0.616 0.000 0.000 0.000 0.000 NA
#> SRR1562803     1  0.3717      0.771 0.616 0.000 0.000 0.000 0.000 NA
#> SRR1562804     1  0.4569      0.770 0.616 0.000 0.000 0.028 0.012 NA
#> SRR1562805     1  0.4569      0.770 0.616 0.000 0.000 0.028 0.012 NA
#> SRR1562806     1  0.0622      0.810 0.980 0.000 0.000 0.008 0.000 NA
#> SRR1562807     1  0.0603      0.810 0.980 0.000 0.000 0.004 0.000 NA
#> SRR1562808     1  0.0603      0.810 0.980 0.000 0.000 0.004 0.000 NA
#> SRR1562809     1  0.0622      0.810 0.980 0.000 0.000 0.008 0.000 NA
#> SRR1562810     1  0.2421      0.807 0.900 0.000 0.000 0.040 0.032 NA
#> SRR1562811     1  0.2421      0.807 0.900 0.000 0.000 0.040 0.032 NA
#> SRR1562812     1  0.2421      0.807 0.900 0.000 0.000 0.040 0.032 NA
#> SRR1562813     1  0.2421      0.807 0.900 0.000 0.000 0.040 0.032 NA

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-kmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-kmeans-collect-classes

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


SD:skmeans**

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

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

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

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

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

collect_plots(res)

plot of chunk SD-skmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4624 0.538   0.538
#> 3 3 1.000           0.985       0.980         0.1393 0.943   0.893
#> 4 4 0.751           0.832       0.911         0.3100 0.822   0.629
#> 5 5 0.810           0.854       0.886         0.1036 0.840   0.529
#> 6 6 0.843           0.788       0.817         0.0623 0.862   0.514

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
#> SRR1562718     2       0          1  0  1
#> SRR1562719     2       0          1  0  1
#> SRR1562720     2       0          1  0  1
#> SRR1562721     2       0          1  0  1
#> SRR1562723     2       0          1  0  1
#> SRR1562724     2       0          1  0  1
#> SRR1562725     2       0          1  0  1
#> SRR1562726     2       0          1  0  1
#> SRR1562727     2       0          1  0  1
#> SRR1562728     2       0          1  0  1
#> SRR1562729     2       0          1  0  1
#> SRR1562730     2       0          1  0  1
#> SRR1562731     2       0          1  0  1
#> SRR1562732     2       0          1  0  1
#> SRR1562733     2       0          1  0  1
#> SRR1562734     2       0          1  0  1
#> SRR1562735     2       0          1  0  1
#> SRR1562736     2       0          1  0  1
#> SRR1562737     2       0          1  0  1
#> SRR1562738     2       0          1  0  1
#> SRR1562739     2       0          1  0  1
#> SRR1562740     2       0          1  0  1
#> SRR1562741     2       0          1  0  1
#> SRR1562742     2       0          1  0  1
#> SRR1562743     2       0          1  0  1
#> SRR1562744     2       0          1  0  1
#> SRR1562745     2       0          1  0  1
#> SRR1562746     2       0          1  0  1
#> SRR1562747     2       0          1  0  1
#> SRR1562748     2       0          1  0  1
#> SRR1562749     2       0          1  0  1
#> SRR1562750     2       0          1  0  1
#> SRR1562751     2       0          1  0  1
#> SRR1562752     2       0          1  0  1
#> SRR1562753     2       0          1  0  1
#> SRR1562754     2       0          1  0  1
#> SRR1562755     2       0          1  0  1
#> SRR1562756     2       0          1  0  1
#> SRR1562757     2       0          1  0  1
#> SRR1562758     2       0          1  0  1
#> SRR1562759     2       0          1  0  1
#> SRR1562792     1       0          1  1  0
#> SRR1562793     1       0          1  1  0
#> SRR1562794     1       0          1  1  0
#> SRR1562795     1       0          1  1  0
#> SRR1562796     1       0          1  1  0
#> SRR1562797     1       0          1  1  0
#> SRR1562798     1       0          1  1  0
#> SRR1562799     1       0          1  1  0
#> SRR1562800     1       0          1  1  0
#> SRR1562801     1       0          1  1  0
#> SRR1562802     1       0          1  1  0
#> SRR1562803     1       0          1  1  0
#> SRR1562804     1       0          1  1  0
#> SRR1562805     1       0          1  1  0
#> SRR1562806     1       0          1  1  0
#> SRR1562807     1       0          1  1  0
#> SRR1562808     1       0          1  1  0
#> SRR1562809     1       0          1  1  0
#> SRR1562810     1       0          1  1  0
#> SRR1562811     1       0          1  1  0
#> SRR1562812     1       0          1  1  0
#> SRR1562813     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1562718     2  0.0747      0.982 0.000 0.984 0.016
#> SRR1562719     2  0.0747      0.982 0.000 0.984 0.016
#> SRR1562720     2  0.0747      0.982 0.000 0.984 0.016
#> SRR1562721     2  0.0747      0.982 0.000 0.984 0.016
#> SRR1562723     2  0.0747      0.982 0.000 0.984 0.016
#> SRR1562724     2  0.0747      0.982 0.000 0.984 0.016
#> SRR1562725     2  0.0747      0.982 0.000 0.984 0.016
#> SRR1562726     2  0.0747      0.982 0.000 0.984 0.016
#> SRR1562727     2  0.0747      0.982 0.000 0.984 0.016
#> SRR1562728     2  0.0747      0.982 0.000 0.984 0.016
#> SRR1562729     2  0.0747      0.982 0.000 0.984 0.016
#> SRR1562730     2  0.0747      0.982 0.000 0.984 0.016
#> SRR1562731     2  0.0747      0.982 0.000 0.984 0.016
#> SRR1562732     2  0.0747      0.982 0.000 0.984 0.016
#> SRR1562733     2  0.0747      0.982 0.000 0.984 0.016
#> SRR1562734     2  0.0747      0.982 0.000 0.984 0.016
#> SRR1562735     2  0.0747      0.982 0.000 0.984 0.016
#> SRR1562736     2  0.0000      0.982 0.000 1.000 0.000
#> SRR1562737     2  0.0000      0.982 0.000 1.000 0.000
#> SRR1562738     2  0.0000      0.982 0.000 1.000 0.000
#> SRR1562739     2  0.0000      0.982 0.000 1.000 0.000
#> SRR1562740     2  0.0000      0.982 0.000 1.000 0.000
#> SRR1562741     2  0.0000      0.982 0.000 1.000 0.000
#> SRR1562742     2  0.0000      0.982 0.000 1.000 0.000
#> SRR1562743     2  0.0000      0.982 0.000 1.000 0.000
#> SRR1562744     2  0.0000      0.982 0.000 1.000 0.000
#> SRR1562745     2  0.0000      0.982 0.000 1.000 0.000
#> SRR1562746     2  0.0000      0.982 0.000 1.000 0.000
#> SRR1562747     2  0.0000      0.982 0.000 1.000 0.000
#> SRR1562748     2  0.1753      0.964 0.000 0.952 0.048
#> SRR1562749     2  0.1753      0.964 0.000 0.952 0.048
#> SRR1562750     2  0.1753      0.964 0.000 0.952 0.048
#> SRR1562751     2  0.1753      0.964 0.000 0.952 0.048
#> SRR1562752     2  0.1753      0.964 0.000 0.952 0.048
#> SRR1562753     2  0.1753      0.964 0.000 0.952 0.048
#> SRR1562754     2  0.1411      0.970 0.000 0.964 0.036
#> SRR1562755     2  0.1411      0.970 0.000 0.964 0.036
#> SRR1562756     2  0.1411      0.970 0.000 0.964 0.036
#> SRR1562757     2  0.1411      0.970 0.000 0.964 0.036
#> SRR1562758     2  0.1411      0.970 0.000 0.964 0.036
#> SRR1562759     2  0.1411      0.970 0.000 0.964 0.036
#> SRR1562792     3  0.2165      1.000 0.064 0.000 0.936
#> SRR1562793     3  0.2165      1.000 0.064 0.000 0.936
#> SRR1562794     3  0.2165      1.000 0.064 0.000 0.936
#> SRR1562795     3  0.2165      1.000 0.064 0.000 0.936
#> SRR1562796     3  0.2165      1.000 0.064 0.000 0.936
#> SRR1562797     3  0.2165      1.000 0.064 0.000 0.936
#> SRR1562798     3  0.2165      1.000 0.064 0.000 0.936
#> SRR1562799     3  0.2165      1.000 0.064 0.000 0.936
#> SRR1562800     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1562801     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1562802     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1562803     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1562804     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1562805     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1562806     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1562807     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1562808     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1562809     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1562810     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1562811     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1562812     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1562813     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
#> SRR1562718     2  0.0000      0.803 0.000 1.000 0.000 0.000
#> SRR1562719     2  0.0000      0.803 0.000 1.000 0.000 0.000
#> SRR1562720     2  0.0000      0.803 0.000 1.000 0.000 0.000
#> SRR1562721     2  0.0000      0.803 0.000 1.000 0.000 0.000
#> SRR1562723     2  0.0000      0.803 0.000 1.000 0.000 0.000
#> SRR1562724     2  0.0000      0.803 0.000 1.000 0.000 0.000
#> SRR1562725     2  0.0000      0.803 0.000 1.000 0.000 0.000
#> SRR1562726     2  0.0000      0.803 0.000 1.000 0.000 0.000
#> SRR1562727     2  0.0000      0.803 0.000 1.000 0.000 0.000
#> SRR1562728     2  0.0000      0.803 0.000 1.000 0.000 0.000
#> SRR1562729     2  0.0000      0.803 0.000 1.000 0.000 0.000
#> SRR1562730     2  0.0817      0.792 0.000 0.976 0.000 0.024
#> SRR1562731     2  0.0817      0.792 0.000 0.976 0.000 0.024
#> SRR1562732     2  0.0817      0.792 0.000 0.976 0.000 0.024
#> SRR1562733     2  0.0817      0.792 0.000 0.976 0.000 0.024
#> SRR1562734     2  0.0817      0.792 0.000 0.976 0.000 0.024
#> SRR1562735     2  0.0817      0.792 0.000 0.976 0.000 0.024
#> SRR1562736     2  0.4720      0.606 0.000 0.672 0.004 0.324
#> SRR1562737     2  0.4720      0.606 0.000 0.672 0.004 0.324
#> SRR1562738     2  0.4720      0.606 0.000 0.672 0.004 0.324
#> SRR1562739     2  0.4720      0.606 0.000 0.672 0.004 0.324
#> SRR1562740     2  0.4720      0.606 0.000 0.672 0.004 0.324
#> SRR1562741     2  0.4720      0.606 0.000 0.672 0.004 0.324
#> SRR1562742     2  0.4584      0.638 0.000 0.696 0.004 0.300
#> SRR1562743     2  0.4584      0.638 0.000 0.696 0.004 0.300
#> SRR1562744     2  0.4584      0.638 0.000 0.696 0.004 0.300
#> SRR1562745     2  0.4584      0.638 0.000 0.696 0.004 0.300
#> SRR1562746     2  0.4584      0.638 0.000 0.696 0.004 0.300
#> SRR1562747     2  0.4584      0.638 0.000 0.696 0.004 0.300
#> SRR1562748     4  0.0592      0.805 0.000 0.016 0.000 0.984
#> SRR1562749     4  0.0592      0.805 0.000 0.016 0.000 0.984
#> SRR1562750     4  0.0592      0.805 0.000 0.016 0.000 0.984
#> SRR1562751     4  0.0592      0.805 0.000 0.016 0.000 0.984
#> SRR1562752     4  0.0592      0.805 0.000 0.016 0.000 0.984
#> SRR1562753     4  0.0592      0.805 0.000 0.016 0.000 0.984
#> SRR1562754     4  0.4134      0.757 0.000 0.260 0.000 0.740
#> SRR1562755     4  0.4134      0.757 0.000 0.260 0.000 0.740
#> SRR1562756     4  0.4134      0.757 0.000 0.260 0.000 0.740
#> SRR1562757     4  0.4134      0.757 0.000 0.260 0.000 0.740
#> SRR1562758     4  0.4134      0.757 0.000 0.260 0.000 0.740
#> SRR1562759     4  0.4134      0.757 0.000 0.260 0.000 0.740
#> SRR1562792     3  0.0188      1.000 0.004 0.000 0.996 0.000
#> SRR1562793     3  0.0188      1.000 0.004 0.000 0.996 0.000
#> SRR1562794     3  0.0188      1.000 0.004 0.000 0.996 0.000
#> SRR1562795     3  0.0188      1.000 0.004 0.000 0.996 0.000
#> SRR1562796     3  0.0188      1.000 0.004 0.000 0.996 0.000
#> SRR1562797     3  0.0188      1.000 0.004 0.000 0.996 0.000
#> SRR1562798     3  0.0188      1.000 0.004 0.000 0.996 0.000
#> SRR1562799     3  0.0188      1.000 0.004 0.000 0.996 0.000
#> SRR1562800     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1562801     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1562802     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1562803     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1562804     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1562805     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1562806     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1562807     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1562808     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1562809     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1562810     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1562811     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1562812     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1562813     1  0.0000      1.000 1.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2 p3    p4    p5
#> SRR1562718     2  0.0404      0.696 0.000 0.988  0 0.000 0.012
#> SRR1562719     2  0.0404      0.696 0.000 0.988  0 0.000 0.012
#> SRR1562720     2  0.0404      0.696 0.000 0.988  0 0.000 0.012
#> SRR1562721     2  0.0404      0.696 0.000 0.988  0 0.000 0.012
#> SRR1562723     2  0.0404      0.696 0.000 0.988  0 0.000 0.012
#> SRR1562724     2  0.0000      0.699 0.000 1.000  0 0.000 0.000
#> SRR1562725     2  0.0000      0.699 0.000 1.000  0 0.000 0.000
#> SRR1562726     2  0.0000      0.699 0.000 1.000  0 0.000 0.000
#> SRR1562727     2  0.0000      0.699 0.000 1.000  0 0.000 0.000
#> SRR1562728     2  0.0000      0.699 0.000 1.000  0 0.000 0.000
#> SRR1562729     2  0.0000      0.699 0.000 1.000  0 0.000 0.000
#> SRR1562730     2  0.4291      0.566 0.000 0.536  0 0.000 0.464
#> SRR1562731     2  0.4291      0.566 0.000 0.536  0 0.000 0.464
#> SRR1562732     2  0.4291      0.566 0.000 0.536  0 0.000 0.464
#> SRR1562733     2  0.4291      0.566 0.000 0.536  0 0.000 0.464
#> SRR1562734     2  0.4291      0.566 0.000 0.536  0 0.000 0.464
#> SRR1562735     2  0.4291      0.566 0.000 0.536  0 0.000 0.464
#> SRR1562736     5  0.5232      0.857 0.000 0.456  0 0.044 0.500
#> SRR1562737     5  0.5232      0.857 0.000 0.456  0 0.044 0.500
#> SRR1562738     5  0.5232      0.857 0.000 0.456  0 0.044 0.500
#> SRR1562739     5  0.5232      0.857 0.000 0.456  0 0.044 0.500
#> SRR1562740     5  0.5232      0.857 0.000 0.456  0 0.044 0.500
#> SRR1562741     5  0.5232      0.857 0.000 0.456  0 0.044 0.500
#> SRR1562742     5  0.5028      0.856 0.000 0.444  0 0.032 0.524
#> SRR1562743     5  0.5028      0.856 0.000 0.444  0 0.032 0.524
#> SRR1562744     5  0.5028      0.856 0.000 0.444  0 0.032 0.524
#> SRR1562745     5  0.5028      0.856 0.000 0.444  0 0.032 0.524
#> SRR1562746     5  0.5028      0.856 0.000 0.444  0 0.032 0.524
#> SRR1562747     5  0.5028      0.856 0.000 0.444  0 0.032 0.524
#> SRR1562748     4  0.0000      1.000 0.000 0.000  0 1.000 0.000
#> SRR1562749     4  0.0000      1.000 0.000 0.000  0 1.000 0.000
#> SRR1562750     4  0.0000      1.000 0.000 0.000  0 1.000 0.000
#> SRR1562751     4  0.0000      1.000 0.000 0.000  0 1.000 0.000
#> SRR1562752     4  0.0000      1.000 0.000 0.000  0 1.000 0.000
#> SRR1562753     4  0.0000      1.000 0.000 0.000  0 1.000 0.000
#> SRR1562754     5  0.6692      0.743 0.000 0.296  0 0.272 0.432
#> SRR1562755     5  0.6692      0.743 0.000 0.296  0 0.272 0.432
#> SRR1562756     5  0.6692      0.743 0.000 0.296  0 0.272 0.432
#> SRR1562757     5  0.6692      0.743 0.000 0.296  0 0.272 0.432
#> SRR1562758     5  0.6692      0.743 0.000 0.296  0 0.272 0.432
#> SRR1562759     5  0.6692      0.743 0.000 0.296  0 0.272 0.432
#> SRR1562792     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1562793     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1562794     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1562795     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1562796     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1562797     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1562798     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1562799     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1562800     1  0.0162      0.998 0.996 0.000  0 0.000 0.004
#> SRR1562801     1  0.0162      0.998 0.996 0.000  0 0.000 0.004
#> SRR1562802     1  0.0162      0.998 0.996 0.000  0 0.000 0.004
#> SRR1562803     1  0.0162      0.998 0.996 0.000  0 0.000 0.004
#> SRR1562804     1  0.0162      0.998 0.996 0.000  0 0.000 0.004
#> SRR1562805     1  0.0162      0.998 0.996 0.000  0 0.000 0.004
#> SRR1562806     1  0.0000      0.998 1.000 0.000  0 0.000 0.000
#> SRR1562807     1  0.0000      0.998 1.000 0.000  0 0.000 0.000
#> SRR1562808     1  0.0000      0.998 1.000 0.000  0 0.000 0.000
#> SRR1562809     1  0.0000      0.998 1.000 0.000  0 0.000 0.000
#> SRR1562810     1  0.0000      0.998 1.000 0.000  0 0.000 0.000
#> SRR1562811     1  0.0000      0.998 1.000 0.000  0 0.000 0.000
#> SRR1562812     1  0.0000      0.998 1.000 0.000  0 0.000 0.000
#> SRR1562813     1  0.0000      0.998 1.000 0.000  0 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette p1    p2 p3    p4    p5    p6
#> SRR1562718     5  0.3457      0.477  0 0.232  0 0.000 0.752 0.016
#> SRR1562719     5  0.3457      0.477  0 0.232  0 0.000 0.752 0.016
#> SRR1562720     5  0.3457      0.477  0 0.232  0 0.000 0.752 0.016
#> SRR1562721     5  0.3457      0.477  0 0.232  0 0.000 0.752 0.016
#> SRR1562723     5  0.3457      0.477  0 0.232  0 0.000 0.752 0.016
#> SRR1562724     5  0.2912      0.484  0 0.216  0 0.000 0.784 0.000
#> SRR1562725     5  0.2912      0.484  0 0.216  0 0.000 0.784 0.000
#> SRR1562726     5  0.2912      0.484  0 0.216  0 0.000 0.784 0.000
#> SRR1562727     5  0.2912      0.484  0 0.216  0 0.000 0.784 0.000
#> SRR1562728     5  0.2912      0.484  0 0.216  0 0.000 0.784 0.000
#> SRR1562729     5  0.2912      0.484  0 0.216  0 0.000 0.784 0.000
#> SRR1562730     2  0.0146      1.000  0 0.996  0 0.000 0.004 0.000
#> SRR1562731     2  0.0146      1.000  0 0.996  0 0.000 0.004 0.000
#> SRR1562732     2  0.0146      1.000  0 0.996  0 0.000 0.004 0.000
#> SRR1562733     2  0.0146      1.000  0 0.996  0 0.000 0.004 0.000
#> SRR1562734     2  0.0146      1.000  0 0.996  0 0.000 0.004 0.000
#> SRR1562735     2  0.0146      1.000  0 0.996  0 0.000 0.004 0.000
#> SRR1562736     5  0.4135      0.394  0 0.004  0 0.008 0.584 0.404
#> SRR1562737     5  0.4135      0.394  0 0.004  0 0.008 0.584 0.404
#> SRR1562738     5  0.4135      0.394  0 0.004  0 0.008 0.584 0.404
#> SRR1562739     5  0.4135      0.394  0 0.004  0 0.008 0.584 0.404
#> SRR1562740     5  0.4135      0.394  0 0.004  0 0.008 0.584 0.404
#> SRR1562741     5  0.4135      0.394  0 0.004  0 0.008 0.584 0.404
#> SRR1562742     5  0.3989      0.330  0 0.004  0 0.000 0.528 0.468
#> SRR1562743     5  0.3989      0.330  0 0.004  0 0.000 0.528 0.468
#> SRR1562744     5  0.3989      0.330  0 0.004  0 0.000 0.528 0.468
#> SRR1562745     5  0.3989      0.330  0 0.004  0 0.000 0.528 0.468
#> SRR1562746     5  0.3989      0.330  0 0.004  0 0.000 0.528 0.468
#> SRR1562747     5  0.3989      0.330  0 0.004  0 0.000 0.528 0.468
#> SRR1562748     4  0.0000      1.000  0 0.000  0 1.000 0.000 0.000
#> SRR1562749     4  0.0000      1.000  0 0.000  0 1.000 0.000 0.000
#> SRR1562750     4  0.0000      1.000  0 0.000  0 1.000 0.000 0.000
#> SRR1562751     4  0.0000      1.000  0 0.000  0 1.000 0.000 0.000
#> SRR1562752     4  0.0000      1.000  0 0.000  0 1.000 0.000 0.000
#> SRR1562753     4  0.0000      1.000  0 0.000  0 1.000 0.000 0.000
#> SRR1562754     6  0.1297      1.000  0 0.000  0 0.040 0.012 0.948
#> SRR1562755     6  0.1297      1.000  0 0.000  0 0.040 0.012 0.948
#> SRR1562756     6  0.1297      1.000  0 0.000  0 0.040 0.012 0.948
#> SRR1562757     6  0.1297      1.000  0 0.000  0 0.040 0.012 0.948
#> SRR1562758     6  0.1297      1.000  0 0.000  0 0.040 0.012 0.948
#> SRR1562759     6  0.1297      1.000  0 0.000  0 0.040 0.012 0.948
#> SRR1562792     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR1562793     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR1562794     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR1562795     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR1562796     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR1562797     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR1562798     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR1562799     3  0.0000      1.000  0 0.000  1 0.000 0.000 0.000
#> SRR1562800     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR1562801     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR1562802     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR1562803     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR1562804     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR1562805     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR1562806     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR1562807     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR1562808     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR1562809     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR1562810     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR1562811     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR1562812     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000
#> SRR1562813     1  0.0000      1.000  1 0.000  0 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-skmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-skmeans-collect-classes

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


SD:pam**

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

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

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

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

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

collect_plots(res)

plot of chunk SD-pam-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.3519 0.649   0.649
#> 3 3 1.000           1.000       1.000         0.4768 0.832   0.741
#> 4 4 1.000           0.998       0.998         0.2073 0.892   0.776
#> 5 5 0.864           0.959       0.943         0.0701 0.975   0.934
#> 6 6 0.817           0.946       0.926         0.1851 0.843   0.551

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette p1 p2
#> SRR1562718     2       0          1  0  1
#> SRR1562719     2       0          1  0  1
#> SRR1562720     2       0          1  0  1
#> SRR1562721     2       0          1  0  1
#> SRR1562723     2       0          1  0  1
#> SRR1562724     2       0          1  0  1
#> SRR1562725     2       0          1  0  1
#> SRR1562726     2       0          1  0  1
#> SRR1562727     2       0          1  0  1
#> SRR1562728     2       0          1  0  1
#> SRR1562729     2       0          1  0  1
#> SRR1562730     2       0          1  0  1
#> SRR1562731     2       0          1  0  1
#> SRR1562732     2       0          1  0  1
#> SRR1562733     2       0          1  0  1
#> SRR1562734     2       0          1  0  1
#> SRR1562735     2       0          1  0  1
#> SRR1562736     2       0          1  0  1
#> SRR1562737     2       0          1  0  1
#> SRR1562738     2       0          1  0  1
#> SRR1562739     2       0          1  0  1
#> SRR1562740     2       0          1  0  1
#> SRR1562741     2       0          1  0  1
#> SRR1562742     2       0          1  0  1
#> SRR1562743     2       0          1  0  1
#> SRR1562744     2       0          1  0  1
#> SRR1562745     2       0          1  0  1
#> SRR1562746     2       0          1  0  1
#> SRR1562747     2       0          1  0  1
#> SRR1562748     2       0          1  0  1
#> SRR1562749     2       0          1  0  1
#> SRR1562750     2       0          1  0  1
#> SRR1562751     2       0          1  0  1
#> SRR1562752     2       0          1  0  1
#> SRR1562753     2       0          1  0  1
#> SRR1562754     2       0          1  0  1
#> SRR1562755     2       0          1  0  1
#> SRR1562756     2       0          1  0  1
#> SRR1562757     2       0          1  0  1
#> SRR1562758     2       0          1  0  1
#> SRR1562759     2       0          1  0  1
#> SRR1562792     2       0          1  0  1
#> SRR1562793     2       0          1  0  1
#> SRR1562794     2       0          1  0  1
#> SRR1562795     2       0          1  0  1
#> SRR1562796     2       0          1  0  1
#> SRR1562797     2       0          1  0  1
#> SRR1562798     2       0          1  0  1
#> SRR1562799     2       0          1  0  1
#> SRR1562800     1       0          1  1  0
#> SRR1562801     1       0          1  1  0
#> SRR1562802     1       0          1  1  0
#> SRR1562803     1       0          1  1  0
#> SRR1562804     1       0          1  1  0
#> SRR1562805     1       0          1  1  0
#> SRR1562806     1       0          1  1  0
#> SRR1562807     1       0          1  1  0
#> SRR1562808     1       0          1  1  0
#> SRR1562809     1       0          1  1  0
#> SRR1562810     1       0          1  1  0
#> SRR1562811     1       0          1  1  0
#> SRR1562812     1       0          1  1  0
#> SRR1562813     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette p1 p2 p3
#> SRR1562718     2       0          1  0  1  0
#> SRR1562719     2       0          1  0  1  0
#> SRR1562720     2       0          1  0  1  0
#> SRR1562721     2       0          1  0  1  0
#> SRR1562723     2       0          1  0  1  0
#> SRR1562724     2       0          1  0  1  0
#> SRR1562725     2       0          1  0  1  0
#> SRR1562726     2       0          1  0  1  0
#> SRR1562727     2       0          1  0  1  0
#> SRR1562728     2       0          1  0  1  0
#> SRR1562729     2       0          1  0  1  0
#> SRR1562730     2       0          1  0  1  0
#> SRR1562731     2       0          1  0  1  0
#> SRR1562732     2       0          1  0  1  0
#> SRR1562733     2       0          1  0  1  0
#> SRR1562734     2       0          1  0  1  0
#> SRR1562735     2       0          1  0  1  0
#> SRR1562736     2       0          1  0  1  0
#> SRR1562737     2       0          1  0  1  0
#> SRR1562738     2       0          1  0  1  0
#> SRR1562739     2       0          1  0  1  0
#> SRR1562740     2       0          1  0  1  0
#> SRR1562741     2       0          1  0  1  0
#> SRR1562742     2       0          1  0  1  0
#> SRR1562743     2       0          1  0  1  0
#> SRR1562744     2       0          1  0  1  0
#> SRR1562745     2       0          1  0  1  0
#> SRR1562746     2       0          1  0  1  0
#> SRR1562747     2       0          1  0  1  0
#> SRR1562748     2       0          1  0  1  0
#> SRR1562749     2       0          1  0  1  0
#> SRR1562750     2       0          1  0  1  0
#> SRR1562751     2       0          1  0  1  0
#> SRR1562752     2       0          1  0  1  0
#> SRR1562753     2       0          1  0  1  0
#> SRR1562754     2       0          1  0  1  0
#> SRR1562755     2       0          1  0  1  0
#> SRR1562756     2       0          1  0  1  0
#> SRR1562757     2       0          1  0  1  0
#> SRR1562758     2       0          1  0  1  0
#> SRR1562759     2       0          1  0  1  0
#> SRR1562792     3       0          1  0  0  1
#> SRR1562793     3       0          1  0  0  1
#> SRR1562794     3       0          1  0  0  1
#> SRR1562795     3       0          1  0  0  1
#> SRR1562796     3       0          1  0  0  1
#> SRR1562797     3       0          1  0  0  1
#> SRR1562798     3       0          1  0  0  1
#> SRR1562799     3       0          1  0  0  1
#> SRR1562800     1       0          1  1  0  0
#> SRR1562801     1       0          1  1  0  0
#> SRR1562802     1       0          1  1  0  0
#> SRR1562803     1       0          1  1  0  0
#> SRR1562804     1       0          1  1  0  0
#> SRR1562805     1       0          1  1  0  0
#> SRR1562806     1       0          1  1  0  0
#> SRR1562807     1       0          1  1  0  0
#> SRR1562808     1       0          1  1  0  0
#> SRR1562809     1       0          1  1  0  0
#> SRR1562810     1       0          1  1  0  0
#> SRR1562811     1       0          1  1  0  0
#> SRR1562812     1       0          1  1  0  0
#> SRR1562813     1       0          1  1  0  0

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette p1    p2 p3    p4
#> SRR1562718     2  0.0000      0.997  0 1.000  0 0.000
#> SRR1562719     2  0.0000      0.997  0 1.000  0 0.000
#> SRR1562720     2  0.0000      0.997  0 1.000  0 0.000
#> SRR1562721     2  0.0000      0.997  0 1.000  0 0.000
#> SRR1562723     2  0.0000      0.997  0 1.000  0 0.000
#> SRR1562724     2  0.0000      0.997  0 1.000  0 0.000
#> SRR1562725     2  0.0000      0.997  0 1.000  0 0.000
#> SRR1562726     2  0.0000      0.997  0 1.000  0 0.000
#> SRR1562727     2  0.0000      0.997  0 1.000  0 0.000
#> SRR1562728     2  0.0000      0.997  0 1.000  0 0.000
#> SRR1562729     2  0.0000      0.997  0 1.000  0 0.000
#> SRR1562730     2  0.0188      0.995  0 0.996  0 0.004
#> SRR1562731     2  0.0188      0.995  0 0.996  0 0.004
#> SRR1562732     2  0.0188      0.995  0 0.996  0 0.004
#> SRR1562733     2  0.0188      0.995  0 0.996  0 0.004
#> SRR1562734     2  0.0188      0.995  0 0.996  0 0.004
#> SRR1562735     2  0.0188      0.995  0 0.996  0 0.004
#> SRR1562736     2  0.0188      0.997  0 0.996  0 0.004
#> SRR1562737     2  0.0188      0.997  0 0.996  0 0.004
#> SRR1562738     2  0.0188      0.997  0 0.996  0 0.004
#> SRR1562739     2  0.0188      0.997  0 0.996  0 0.004
#> SRR1562740     2  0.0188      0.997  0 0.996  0 0.004
#> SRR1562741     2  0.0188      0.997  0 0.996  0 0.004
#> SRR1562742     2  0.0188      0.997  0 0.996  0 0.004
#> SRR1562743     2  0.0188      0.997  0 0.996  0 0.004
#> SRR1562744     2  0.0188      0.997  0 0.996  0 0.004
#> SRR1562745     2  0.0188      0.997  0 0.996  0 0.004
#> SRR1562746     2  0.0188      0.997  0 0.996  0 0.004
#> SRR1562747     2  0.0188      0.997  0 0.996  0 0.004
#> SRR1562748     4  0.0188      1.000  0 0.004  0 0.996
#> SRR1562749     4  0.0188      1.000  0 0.004  0 0.996
#> SRR1562750     4  0.0188      1.000  0 0.004  0 0.996
#> SRR1562751     4  0.0188      1.000  0 0.004  0 0.996
#> SRR1562752     4  0.0188      1.000  0 0.004  0 0.996
#> SRR1562753     4  0.0188      1.000  0 0.004  0 0.996
#> SRR1562754     2  0.0188      0.997  0 0.996  0 0.004
#> SRR1562755     2  0.0188      0.997  0 0.996  0 0.004
#> SRR1562756     2  0.0188      0.997  0 0.996  0 0.004
#> SRR1562757     2  0.0188      0.997  0 0.996  0 0.004
#> SRR1562758     2  0.0188      0.997  0 0.996  0 0.004
#> SRR1562759     2  0.0188      0.997  0 0.996  0 0.004
#> SRR1562792     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1562793     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1562794     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1562795     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1562796     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1562797     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1562798     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1562799     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1562800     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1562801     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1562802     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1562803     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1562804     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1562805     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1562806     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1562807     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1562808     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1562809     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1562810     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1562811     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1562812     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1562813     1  0.0000      1.000  1 0.000  0 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2 p3 p4    p5
#> SRR1562718     2  0.1965      0.932 0.096 0.904  0  0 0.000
#> SRR1562719     2  0.1965      0.932 0.096 0.904  0  0 0.000
#> SRR1562720     2  0.1965      0.932 0.096 0.904  0  0 0.000
#> SRR1562721     2  0.1965      0.932 0.096 0.904  0  0 0.000
#> SRR1562723     2  0.1965      0.932 0.096 0.904  0  0 0.000
#> SRR1562724     2  0.1965      0.932 0.096 0.904  0  0 0.000
#> SRR1562725     2  0.1965      0.932 0.096 0.904  0  0 0.000
#> SRR1562726     2  0.1965      0.932 0.096 0.904  0  0 0.000
#> SRR1562727     2  0.1965      0.932 0.096 0.904  0  0 0.000
#> SRR1562728     2  0.1965      0.932 0.096 0.904  0  0 0.000
#> SRR1562729     2  0.1965      0.932 0.096 0.904  0  0 0.000
#> SRR1562730     2  0.3143      0.871 0.204 0.796  0  0 0.000
#> SRR1562731     2  0.3143      0.871 0.204 0.796  0  0 0.000
#> SRR1562732     2  0.3143      0.871 0.204 0.796  0  0 0.000
#> SRR1562733     2  0.3143      0.871 0.204 0.796  0  0 0.000
#> SRR1562734     2  0.3143      0.871 0.204 0.796  0  0 0.000
#> SRR1562735     2  0.3143      0.871 0.204 0.796  0  0 0.000
#> SRR1562736     2  0.0000      0.940 0.000 1.000  0  0 0.000
#> SRR1562737     2  0.0000      0.940 0.000 1.000  0  0 0.000
#> SRR1562738     2  0.0000      0.940 0.000 1.000  0  0 0.000
#> SRR1562739     2  0.0000      0.940 0.000 1.000  0  0 0.000
#> SRR1562740     2  0.0000      0.940 0.000 1.000  0  0 0.000
#> SRR1562741     2  0.0000      0.940 0.000 1.000  0  0 0.000
#> SRR1562742     2  0.0000      0.940 0.000 1.000  0  0 0.000
#> SRR1562743     2  0.0000      0.940 0.000 1.000  0  0 0.000
#> SRR1562744     2  0.0000      0.940 0.000 1.000  0  0 0.000
#> SRR1562745     2  0.0000      0.940 0.000 1.000  0  0 0.000
#> SRR1562746     2  0.0000      0.940 0.000 1.000  0  0 0.000
#> SRR1562747     2  0.0000      0.940 0.000 1.000  0  0 0.000
#> SRR1562748     4  0.0000      1.000 0.000 0.000  0  1 0.000
#> SRR1562749     4  0.0000      1.000 0.000 0.000  0  1 0.000
#> SRR1562750     4  0.0000      1.000 0.000 0.000  0  1 0.000
#> SRR1562751     4  0.0000      1.000 0.000 0.000  0  1 0.000
#> SRR1562752     4  0.0000      1.000 0.000 0.000  0  1 0.000
#> SRR1562753     4  0.0000      1.000 0.000 0.000  0  1 0.000
#> SRR1562754     2  0.0162      0.939 0.004 0.996  0  0 0.000
#> SRR1562755     2  0.0162      0.939 0.004 0.996  0  0 0.000
#> SRR1562756     2  0.0404      0.940 0.012 0.988  0  0 0.000
#> SRR1562757     2  0.0510      0.940 0.016 0.984  0  0 0.000
#> SRR1562758     2  0.0162      0.939 0.004 0.996  0  0 0.000
#> SRR1562759     2  0.0162      0.939 0.004 0.996  0  0 0.000
#> SRR1562792     3  0.0000      1.000 0.000 0.000  1  0 0.000
#> SRR1562793     3  0.0000      1.000 0.000 0.000  1  0 0.000
#> SRR1562794     3  0.0000      1.000 0.000 0.000  1  0 0.000
#> SRR1562795     3  0.0000      1.000 0.000 0.000  1  0 0.000
#> SRR1562796     3  0.0000      1.000 0.000 0.000  1  0 0.000
#> SRR1562797     3  0.0000      1.000 0.000 0.000  1  0 0.000
#> SRR1562798     3  0.0000      1.000 0.000 0.000  1  0 0.000
#> SRR1562799     3  0.0000      1.000 0.000 0.000  1  0 0.000
#> SRR1562800     5  0.0000      1.000 0.000 0.000  0  0 1.000
#> SRR1562801     5  0.0000      1.000 0.000 0.000  0  0 1.000
#> SRR1562802     5  0.0000      1.000 0.000 0.000  0  0 1.000
#> SRR1562803     5  0.0000      1.000 0.000 0.000  0  0 1.000
#> SRR1562804     5  0.0000      1.000 0.000 0.000  0  0 1.000
#> SRR1562805     5  0.0000      1.000 0.000 0.000  0  0 1.000
#> SRR1562806     1  0.3177      1.000 0.792 0.000  0  0 0.208
#> SRR1562807     1  0.3177      1.000 0.792 0.000  0  0 0.208
#> SRR1562808     1  0.3177      1.000 0.792 0.000  0  0 0.208
#> SRR1562809     1  0.3177      1.000 0.792 0.000  0  0 0.208
#> SRR1562810     1  0.3177      1.000 0.792 0.000  0  0 0.208
#> SRR1562811     1  0.3177      1.000 0.792 0.000  0  0 0.208
#> SRR1562812     1  0.3177      1.000 0.792 0.000  0  0 0.208
#> SRR1562813     1  0.3177      1.000 0.792 0.000  0  0 0.208

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2 p3 p4    p5    p6
#> SRR1562718     2  0.2135      0.901 0.000 0.872  0  0 0.128 0.000
#> SRR1562719     2  0.2135      0.901 0.000 0.872  0  0 0.128 0.000
#> SRR1562720     2  0.2135      0.901 0.000 0.872  0  0 0.128 0.000
#> SRR1562721     2  0.2135      0.901 0.000 0.872  0  0 0.128 0.000
#> SRR1562723     2  0.2135      0.901 0.000 0.872  0  0 0.128 0.000
#> SRR1562724     2  0.2135      0.901 0.000 0.872  0  0 0.128 0.000
#> SRR1562725     2  0.2135      0.901 0.000 0.872  0  0 0.128 0.000
#> SRR1562726     2  0.2135      0.901 0.000 0.872  0  0 0.128 0.000
#> SRR1562727     2  0.2135      0.901 0.000 0.872  0  0 0.128 0.000
#> SRR1562728     2  0.2135      0.901 0.000 0.872  0  0 0.128 0.000
#> SRR1562729     2  0.2135      0.901 0.000 0.872  0  0 0.128 0.000
#> SRR1562730     2  0.2092      0.809 0.000 0.876  0  0 0.000 0.124
#> SRR1562731     2  0.2092      0.809 0.000 0.876  0  0 0.000 0.124
#> SRR1562732     2  0.2092      0.809 0.000 0.876  0  0 0.000 0.124
#> SRR1562733     2  0.2092      0.809 0.000 0.876  0  0 0.000 0.124
#> SRR1562734     2  0.2092      0.809 0.000 0.876  0  0 0.000 0.124
#> SRR1562735     2  0.2092      0.809 0.000 0.876  0  0 0.000 0.124
#> SRR1562736     5  0.1663      0.949 0.000 0.088  0  0 0.912 0.000
#> SRR1562737     5  0.1863      0.942 0.000 0.104  0  0 0.896 0.000
#> SRR1562738     5  0.1910      0.939 0.000 0.108  0  0 0.892 0.000
#> SRR1562739     5  0.2048      0.931 0.000 0.120  0  0 0.880 0.000
#> SRR1562740     5  0.2135      0.921 0.000 0.128  0  0 0.872 0.000
#> SRR1562741     5  0.1910      0.940 0.000 0.108  0  0 0.892 0.000
#> SRR1562742     5  0.1556      0.951 0.000 0.080  0  0 0.920 0.000
#> SRR1562743     5  0.1556      0.951 0.000 0.080  0  0 0.920 0.000
#> SRR1562744     5  0.1556      0.951 0.000 0.080  0  0 0.920 0.000
#> SRR1562745     5  0.1556      0.951 0.000 0.080  0  0 0.920 0.000
#> SRR1562746     5  0.1556      0.951 0.000 0.080  0  0 0.920 0.000
#> SRR1562747     5  0.1556      0.951 0.000 0.080  0  0 0.920 0.000
#> SRR1562748     4  0.0000      1.000 0.000 0.000  0  1 0.000 0.000
#> SRR1562749     4  0.0000      1.000 0.000 0.000  0  1 0.000 0.000
#> SRR1562750     4  0.0000      1.000 0.000 0.000  0  1 0.000 0.000
#> SRR1562751     4  0.0000      1.000 0.000 0.000  0  1 0.000 0.000
#> SRR1562752     4  0.0000      1.000 0.000 0.000  0  1 0.000 0.000
#> SRR1562753     4  0.0000      1.000 0.000 0.000  0  1 0.000 0.000
#> SRR1562754     5  0.0146      0.916 0.000 0.000  0  0 0.996 0.004
#> SRR1562755     5  0.0146      0.916 0.000 0.000  0  0 0.996 0.004
#> SRR1562756     5  0.0508      0.917 0.000 0.012  0  0 0.984 0.004
#> SRR1562757     5  0.0508      0.917 0.000 0.012  0  0 0.984 0.004
#> SRR1562758     5  0.0603      0.916 0.000 0.016  0  0 0.980 0.004
#> SRR1562759     5  0.0146      0.916 0.000 0.000  0  0 0.996 0.004
#> SRR1562792     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1562793     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1562794     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1562795     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1562796     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1562797     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1562798     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1562799     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1562800     6  0.2135      1.000 0.128 0.000  0  0 0.000 0.872
#> SRR1562801     6  0.2135      1.000 0.128 0.000  0  0 0.000 0.872
#> SRR1562802     6  0.2135      1.000 0.128 0.000  0  0 0.000 0.872
#> SRR1562803     6  0.2135      1.000 0.128 0.000  0  0 0.000 0.872
#> SRR1562804     6  0.2135      1.000 0.128 0.000  0  0 0.000 0.872
#> SRR1562805     6  0.2135      1.000 0.128 0.000  0  0 0.000 0.872
#> SRR1562806     1  0.0000      1.000 1.000 0.000  0  0 0.000 0.000
#> SRR1562807     1  0.0000      1.000 1.000 0.000  0  0 0.000 0.000
#> SRR1562808     1  0.0000      1.000 1.000 0.000  0  0 0.000 0.000
#> SRR1562809     1  0.0000      1.000 1.000 0.000  0  0 0.000 0.000
#> SRR1562810     1  0.0000      1.000 1.000 0.000  0  0 0.000 0.000
#> SRR1562811     1  0.0000      1.000 1.000 0.000  0  0 0.000 0.000
#> SRR1562812     1  0.0000      1.000 1.000 0.000  0  0 0.000 0.000
#> SRR1562813     1  0.0000      1.000 1.000 0.000  0  0 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-pam-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-pam-collect-classes

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


SD:mclust**

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

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

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

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

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

collect_plots(res)

plot of chunk SD-mclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.997       0.996         0.4588 0.538   0.538
#> 3 3 0.693           0.843       0.919         0.2303 0.943   0.893
#> 4 4 0.751           0.940       0.959         0.2222 0.822   0.629
#> 5 5 0.779           0.741       0.839         0.1044 0.929   0.766
#> 6 6 0.834           0.870       0.874         0.0775 0.905   0.620

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
#> SRR1562718     2   0.000      1.000 0.000 1.000
#> SRR1562719     2   0.000      1.000 0.000 1.000
#> SRR1562720     2   0.000      1.000 0.000 1.000
#> SRR1562721     2   0.000      1.000 0.000 1.000
#> SRR1562723     2   0.000      1.000 0.000 1.000
#> SRR1562724     2   0.000      1.000 0.000 1.000
#> SRR1562725     2   0.000      1.000 0.000 1.000
#> SRR1562726     2   0.000      1.000 0.000 1.000
#> SRR1562727     2   0.000      1.000 0.000 1.000
#> SRR1562728     2   0.000      1.000 0.000 1.000
#> SRR1562729     2   0.000      1.000 0.000 1.000
#> SRR1562730     2   0.000      1.000 0.000 1.000
#> SRR1562731     2   0.000      1.000 0.000 1.000
#> SRR1562732     2   0.000      1.000 0.000 1.000
#> SRR1562733     2   0.000      1.000 0.000 1.000
#> SRR1562734     2   0.000      1.000 0.000 1.000
#> SRR1562735     2   0.000      1.000 0.000 1.000
#> SRR1562736     2   0.000      1.000 0.000 1.000
#> SRR1562737     2   0.000      1.000 0.000 1.000
#> SRR1562738     2   0.000      1.000 0.000 1.000
#> SRR1562739     2   0.000      1.000 0.000 1.000
#> SRR1562740     2   0.000      1.000 0.000 1.000
#> SRR1562741     2   0.000      1.000 0.000 1.000
#> SRR1562742     2   0.000      1.000 0.000 1.000
#> SRR1562743     2   0.000      1.000 0.000 1.000
#> SRR1562744     2   0.000      1.000 0.000 1.000
#> SRR1562745     2   0.000      1.000 0.000 1.000
#> SRR1562746     2   0.000      1.000 0.000 1.000
#> SRR1562747     2   0.000      1.000 0.000 1.000
#> SRR1562748     2   0.000      1.000 0.000 1.000
#> SRR1562749     2   0.000      1.000 0.000 1.000
#> SRR1562750     2   0.000      1.000 0.000 1.000
#> SRR1562751     2   0.000      1.000 0.000 1.000
#> SRR1562752     2   0.000      1.000 0.000 1.000
#> SRR1562753     2   0.000      1.000 0.000 1.000
#> SRR1562754     2   0.000      1.000 0.000 1.000
#> SRR1562755     2   0.000      1.000 0.000 1.000
#> SRR1562756     2   0.000      1.000 0.000 1.000
#> SRR1562757     2   0.000      1.000 0.000 1.000
#> SRR1562758     2   0.000      1.000 0.000 1.000
#> SRR1562759     2   0.000      1.000 0.000 1.000
#> SRR1562792     1   0.000      0.989 1.000 0.000
#> SRR1562793     1   0.000      0.989 1.000 0.000
#> SRR1562794     1   0.000      0.989 1.000 0.000
#> SRR1562795     1   0.000      0.989 1.000 0.000
#> SRR1562796     1   0.000      0.989 1.000 0.000
#> SRR1562797     1   0.000      0.989 1.000 0.000
#> SRR1562798     1   0.000      0.989 1.000 0.000
#> SRR1562799     1   0.000      0.989 1.000 0.000
#> SRR1562800     1   0.118      0.994 0.984 0.016
#> SRR1562801     1   0.118      0.994 0.984 0.016
#> SRR1562802     1   0.118      0.994 0.984 0.016
#> SRR1562803     1   0.118      0.994 0.984 0.016
#> SRR1562804     1   0.118      0.994 0.984 0.016
#> SRR1562805     1   0.118      0.994 0.984 0.016
#> SRR1562806     1   0.118      0.994 0.984 0.016
#> SRR1562807     1   0.118      0.994 0.984 0.016
#> SRR1562808     1   0.118      0.994 0.984 0.016
#> SRR1562809     1   0.118      0.994 0.984 0.016
#> SRR1562810     1   0.118      0.994 0.984 0.016
#> SRR1562811     1   0.118      0.994 0.984 0.016
#> SRR1562812     1   0.118      0.994 0.984 0.016
#> SRR1562813     1   0.118      0.994 0.984 0.016

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1562718     2  0.0000      0.865 0.000 1.000 0.000
#> SRR1562719     2  0.0000      0.865 0.000 1.000 0.000
#> SRR1562720     2  0.0000      0.865 0.000 1.000 0.000
#> SRR1562721     2  0.0000      0.865 0.000 1.000 0.000
#> SRR1562723     2  0.0000      0.865 0.000 1.000 0.000
#> SRR1562724     2  0.0237      0.865 0.000 0.996 0.004
#> SRR1562725     2  0.0237      0.865 0.000 0.996 0.004
#> SRR1562726     2  0.0237      0.865 0.000 0.996 0.004
#> SRR1562727     2  0.0237      0.865 0.000 0.996 0.004
#> SRR1562728     2  0.0237      0.865 0.000 0.996 0.004
#> SRR1562729     2  0.0237      0.865 0.000 0.996 0.004
#> SRR1562730     2  0.0000      0.865 0.000 1.000 0.000
#> SRR1562731     2  0.0000      0.865 0.000 1.000 0.000
#> SRR1562732     2  0.0000      0.865 0.000 1.000 0.000
#> SRR1562733     2  0.0000      0.865 0.000 1.000 0.000
#> SRR1562734     2  0.0000      0.865 0.000 1.000 0.000
#> SRR1562735     2  0.0000      0.865 0.000 1.000 0.000
#> SRR1562736     2  0.0237      0.865 0.000 0.996 0.004
#> SRR1562737     2  0.0237      0.865 0.000 0.996 0.004
#> SRR1562738     2  0.0237      0.865 0.000 0.996 0.004
#> SRR1562739     2  0.0237      0.865 0.000 0.996 0.004
#> SRR1562740     2  0.0237      0.865 0.000 0.996 0.004
#> SRR1562741     2  0.0237      0.865 0.000 0.996 0.004
#> SRR1562742     2  0.0000      0.865 0.000 1.000 0.000
#> SRR1562743     2  0.0000      0.865 0.000 1.000 0.000
#> SRR1562744     2  0.0000      0.865 0.000 1.000 0.000
#> SRR1562745     2  0.0000      0.865 0.000 1.000 0.000
#> SRR1562746     2  0.0000      0.865 0.000 1.000 0.000
#> SRR1562747     2  0.0000      0.865 0.000 1.000 0.000
#> SRR1562748     2  0.9314      0.386 0.328 0.492 0.180
#> SRR1562749     2  0.9314      0.386 0.328 0.492 0.180
#> SRR1562750     2  0.9314      0.386 0.328 0.492 0.180
#> SRR1562751     2  0.9314      0.386 0.328 0.492 0.180
#> SRR1562752     2  0.9314      0.386 0.328 0.492 0.180
#> SRR1562753     2  0.9314      0.386 0.328 0.492 0.180
#> SRR1562754     2  0.5902      0.614 0.316 0.680 0.004
#> SRR1562755     2  0.5902      0.614 0.316 0.680 0.004
#> SRR1562756     2  0.5902      0.614 0.316 0.680 0.004
#> SRR1562757     2  0.5902      0.614 0.316 0.680 0.004
#> SRR1562758     2  0.5902      0.614 0.316 0.680 0.004
#> SRR1562759     2  0.5902      0.614 0.316 0.680 0.004
#> SRR1562792     3  0.0424      1.000 0.008 0.000 0.992
#> SRR1562793     3  0.0424      1.000 0.008 0.000 0.992
#> SRR1562794     3  0.0424      1.000 0.008 0.000 0.992
#> SRR1562795     3  0.0424      1.000 0.008 0.000 0.992
#> SRR1562796     3  0.0424      1.000 0.008 0.000 0.992
#> SRR1562797     3  0.0424      1.000 0.008 0.000 0.992
#> SRR1562798     3  0.0424      1.000 0.008 0.000 0.992
#> SRR1562799     3  0.0424      1.000 0.008 0.000 0.992
#> SRR1562800     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1562801     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1562802     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1562803     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1562804     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1562805     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1562806     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1562807     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1562808     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1562809     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1562810     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1562811     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1562812     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1562813     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
#> SRR1562718     2  0.0188      0.942  0 0.996 0.000 0.004
#> SRR1562719     2  0.0188      0.942  0 0.996 0.000 0.004
#> SRR1562720     2  0.0188      0.942  0 0.996 0.000 0.004
#> SRR1562721     2  0.0188      0.942  0 0.996 0.000 0.004
#> SRR1562723     2  0.0188      0.942  0 0.996 0.000 0.004
#> SRR1562724     2  0.0188      0.942  0 0.996 0.000 0.004
#> SRR1562725     2  0.0188      0.942  0 0.996 0.000 0.004
#> SRR1562726     2  0.0188      0.942  0 0.996 0.000 0.004
#> SRR1562727     2  0.0188      0.942  0 0.996 0.000 0.004
#> SRR1562728     2  0.0188      0.942  0 0.996 0.000 0.004
#> SRR1562729     2  0.0188      0.942  0 0.996 0.000 0.004
#> SRR1562730     2  0.0188      0.942  0 0.996 0.000 0.004
#> SRR1562731     2  0.0188      0.942  0 0.996 0.000 0.004
#> SRR1562732     2  0.0188      0.942  0 0.996 0.000 0.004
#> SRR1562733     2  0.0188      0.942  0 0.996 0.000 0.004
#> SRR1562734     2  0.0188      0.942  0 0.996 0.000 0.004
#> SRR1562735     2  0.0188      0.942  0 0.996 0.000 0.004
#> SRR1562736     2  0.2704      0.902  0 0.876 0.000 0.124
#> SRR1562737     2  0.2704      0.902  0 0.876 0.000 0.124
#> SRR1562738     2  0.2704      0.902  0 0.876 0.000 0.124
#> SRR1562739     2  0.2589      0.908  0 0.884 0.000 0.116
#> SRR1562740     2  0.2704      0.902  0 0.876 0.000 0.124
#> SRR1562741     2  0.2704      0.902  0 0.876 0.000 0.124
#> SRR1562742     2  0.2345      0.917  0 0.900 0.000 0.100
#> SRR1562743     2  0.2345      0.917  0 0.900 0.000 0.100
#> SRR1562744     2  0.2345      0.917  0 0.900 0.000 0.100
#> SRR1562745     2  0.2345      0.917  0 0.900 0.000 0.100
#> SRR1562746     2  0.2345      0.917  0 0.900 0.000 0.100
#> SRR1562747     2  0.2345      0.917  0 0.900 0.000 0.100
#> SRR1562748     4  0.0336      0.856  0 0.000 0.008 0.992
#> SRR1562749     4  0.0336      0.856  0 0.000 0.008 0.992
#> SRR1562750     4  0.0336      0.856  0 0.000 0.008 0.992
#> SRR1562751     4  0.0336      0.856  0 0.000 0.008 0.992
#> SRR1562752     4  0.0336      0.856  0 0.000 0.008 0.992
#> SRR1562753     4  0.0336      0.856  0 0.000 0.008 0.992
#> SRR1562754     4  0.3356      0.861  0 0.176 0.000 0.824
#> SRR1562755     4  0.3356      0.861  0 0.176 0.000 0.824
#> SRR1562756     4  0.3356      0.861  0 0.176 0.000 0.824
#> SRR1562757     4  0.3356      0.861  0 0.176 0.000 0.824
#> SRR1562758     4  0.3356      0.861  0 0.176 0.000 0.824
#> SRR1562759     4  0.3356      0.861  0 0.176 0.000 0.824
#> SRR1562792     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR1562793     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR1562794     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR1562795     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR1562796     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR1562797     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR1562798     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR1562799     3  0.0000      1.000  0 0.000 1.000 0.000
#> SRR1562800     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1562801     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1562802     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1562803     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1562804     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1562805     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1562806     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1562807     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1562808     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1562809     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1562810     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1562811     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1562812     1  0.0000      1.000  1 0.000 0.000 0.000
#> SRR1562813     1  0.0000      1.000  1 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette   p1    p2 p3    p4    p5
#> SRR1562718     2   0.000      0.751 0.00 1.000  0 0.000 0.000
#> SRR1562719     2   0.000      0.751 0.00 1.000  0 0.000 0.000
#> SRR1562720     2   0.000      0.751 0.00 1.000  0 0.000 0.000
#> SRR1562721     2   0.000      0.751 0.00 1.000  0 0.000 0.000
#> SRR1562723     2   0.000      0.751 0.00 1.000  0 0.000 0.000
#> SRR1562724     2   0.148      0.729 0.00 0.936  0 0.000 0.064
#> SRR1562725     2   0.148      0.729 0.00 0.936  0 0.000 0.064
#> SRR1562726     2   0.148      0.729 0.00 0.936  0 0.000 0.064
#> SRR1562727     2   0.148      0.729 0.00 0.936  0 0.000 0.064
#> SRR1562728     2   0.148      0.729 0.00 0.936  0 0.000 0.064
#> SRR1562729     2   0.148      0.729 0.00 0.936  0 0.000 0.064
#> SRR1562730     2   0.148      0.729 0.00 0.936  0 0.000 0.064
#> SRR1562731     2   0.148      0.729 0.00 0.936  0 0.000 0.064
#> SRR1562732     2   0.148      0.729 0.00 0.936  0 0.000 0.064
#> SRR1562733     2   0.148      0.729 0.00 0.936  0 0.000 0.064
#> SRR1562734     2   0.148      0.729 0.00 0.936  0 0.000 0.064
#> SRR1562735     2   0.148      0.729 0.00 0.936  0 0.000 0.064
#> SRR1562736     5   0.478      1.000 0.00 0.388  0 0.024 0.588
#> SRR1562737     5   0.478      1.000 0.00 0.388  0 0.024 0.588
#> SRR1562738     5   0.478      1.000 0.00 0.388  0 0.024 0.588
#> SRR1562739     5   0.478      1.000 0.00 0.388  0 0.024 0.588
#> SRR1562740     5   0.478      1.000 0.00 0.388  0 0.024 0.588
#> SRR1562741     5   0.478      1.000 0.00 0.388  0 0.024 0.588
#> SRR1562742     2   0.413     -0.149 0.00 0.620  0 0.000 0.380
#> SRR1562743     2   0.413     -0.149 0.00 0.620  0 0.000 0.380
#> SRR1562744     2   0.413     -0.149 0.00 0.620  0 0.000 0.380
#> SRR1562745     2   0.413     -0.149 0.00 0.620  0 0.000 0.380
#> SRR1562746     2   0.413     -0.149 0.00 0.620  0 0.000 0.380
#> SRR1562747     2   0.413     -0.149 0.00 0.620  0 0.000 0.380
#> SRR1562748     4   0.000      0.792 0.00 0.000  0 1.000 0.000
#> SRR1562749     4   0.000      0.792 0.00 0.000  0 1.000 0.000
#> SRR1562750     4   0.000      0.792 0.00 0.000  0 1.000 0.000
#> SRR1562751     4   0.000      0.792 0.00 0.000  0 1.000 0.000
#> SRR1562752     4   0.000      0.792 0.00 0.000  0 1.000 0.000
#> SRR1562753     4   0.000      0.792 0.00 0.000  0 1.000 0.000
#> SRR1562754     4   0.445      0.752 0.00 0.016  0 0.644 0.340
#> SRR1562755     4   0.445      0.752 0.00 0.016  0 0.644 0.340
#> SRR1562756     4   0.445      0.752 0.00 0.016  0 0.644 0.340
#> SRR1562757     4   0.445      0.752 0.00 0.016  0 0.644 0.340
#> SRR1562758     4   0.445      0.752 0.00 0.016  0 0.644 0.340
#> SRR1562759     4   0.445      0.752 0.00 0.016  0 0.644 0.340
#> SRR1562792     3   0.000      1.000 0.00 0.000  1 0.000 0.000
#> SRR1562793     3   0.000      1.000 0.00 0.000  1 0.000 0.000
#> SRR1562794     3   0.000      1.000 0.00 0.000  1 0.000 0.000
#> SRR1562795     3   0.000      1.000 0.00 0.000  1 0.000 0.000
#> SRR1562796     3   0.000      1.000 0.00 0.000  1 0.000 0.000
#> SRR1562797     3   0.000      1.000 0.00 0.000  1 0.000 0.000
#> SRR1562798     3   0.000      1.000 0.00 0.000  1 0.000 0.000
#> SRR1562799     3   0.000      1.000 0.00 0.000  1 0.000 0.000
#> SRR1562800     1   0.000      0.813 1.00 0.000  0 0.000 0.000
#> SRR1562801     1   0.000      0.813 1.00 0.000  0 0.000 0.000
#> SRR1562802     1   0.000      0.813 1.00 0.000  0 0.000 0.000
#> SRR1562803     1   0.000      0.813 1.00 0.000  0 0.000 0.000
#> SRR1562804     1   0.000      0.813 1.00 0.000  0 0.000 0.000
#> SRR1562805     1   0.000      0.813 1.00 0.000  0 0.000 0.000
#> SRR1562806     1   0.398      0.864 0.66 0.000  0 0.000 0.340
#> SRR1562807     1   0.398      0.864 0.66 0.000  0 0.000 0.340
#> SRR1562808     1   0.398      0.864 0.66 0.000  0 0.000 0.340
#> SRR1562809     1   0.398      0.864 0.66 0.000  0 0.000 0.340
#> SRR1562810     1   0.398      0.864 0.66 0.000  0 0.000 0.340
#> SRR1562811     1   0.398      0.864 0.66 0.000  0 0.000 0.340
#> SRR1562812     1   0.398      0.864 0.66 0.000  0 0.000 0.340
#> SRR1562813     1   0.398      0.864 0.66 0.000  0 0.000 0.340

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2 p3    p4    p5    p6
#> SRR1562718     2  0.1471      0.893 0.004 0.932  0 0.000 0.064 0.000
#> SRR1562719     2  0.1471      0.893 0.004 0.932  0 0.000 0.064 0.000
#> SRR1562720     2  0.1471      0.893 0.004 0.932  0 0.000 0.064 0.000
#> SRR1562721     2  0.1471      0.893 0.004 0.932  0 0.000 0.064 0.000
#> SRR1562723     2  0.1471      0.893 0.004 0.932  0 0.000 0.064 0.000
#> SRR1562724     2  0.3076      0.834 0.000 0.760  0 0.000 0.240 0.000
#> SRR1562725     2  0.3076      0.834 0.000 0.760  0 0.000 0.240 0.000
#> SRR1562726     2  0.3076      0.834 0.000 0.760  0 0.000 0.240 0.000
#> SRR1562727     2  0.3076      0.834 0.000 0.760  0 0.000 0.240 0.000
#> SRR1562728     2  0.3076      0.834 0.000 0.760  0 0.000 0.240 0.000
#> SRR1562729     2  0.3076      0.834 0.000 0.760  0 0.000 0.240 0.000
#> SRR1562730     2  0.0547      0.878 0.020 0.980  0 0.000 0.000 0.000
#> SRR1562731     2  0.0547      0.878 0.020 0.980  0 0.000 0.000 0.000
#> SRR1562732     2  0.0547      0.878 0.020 0.980  0 0.000 0.000 0.000
#> SRR1562733     2  0.0547      0.878 0.020 0.980  0 0.000 0.000 0.000
#> SRR1562734     2  0.0547      0.878 0.020 0.980  0 0.000 0.000 0.000
#> SRR1562735     2  0.0547      0.878 0.020 0.980  0 0.000 0.000 0.000
#> SRR1562736     5  0.3094      0.750 0.140 0.000  0 0.036 0.824 0.000
#> SRR1562737     5  0.3094      0.750 0.140 0.000  0 0.036 0.824 0.000
#> SRR1562738     5  0.3094      0.750 0.140 0.000  0 0.036 0.824 0.000
#> SRR1562739     5  0.3094      0.750 0.140 0.000  0 0.036 0.824 0.000
#> SRR1562740     5  0.3094      0.750 0.140 0.000  0 0.036 0.824 0.000
#> SRR1562741     5  0.3094      0.750 0.140 0.000  0 0.036 0.824 0.000
#> SRR1562742     5  0.2219      0.778 0.000 0.136  0 0.000 0.864 0.000
#> SRR1562743     5  0.2219      0.778 0.000 0.136  0 0.000 0.864 0.000
#> SRR1562744     5  0.2219      0.778 0.000 0.136  0 0.000 0.864 0.000
#> SRR1562745     5  0.2219      0.778 0.000 0.136  0 0.000 0.864 0.000
#> SRR1562746     5  0.2219      0.778 0.000 0.136  0 0.000 0.864 0.000
#> SRR1562747     5  0.2219      0.778 0.000 0.136  0 0.000 0.864 0.000
#> SRR1562748     4  0.0000      0.774 0.000 0.000  0 1.000 0.000 0.000
#> SRR1562749     4  0.0000      0.774 0.000 0.000  0 1.000 0.000 0.000
#> SRR1562750     4  0.0000      0.774 0.000 0.000  0 1.000 0.000 0.000
#> SRR1562751     4  0.0000      0.774 0.000 0.000  0 1.000 0.000 0.000
#> SRR1562752     4  0.0000      0.774 0.000 0.000  0 1.000 0.000 0.000
#> SRR1562753     4  0.0000      0.774 0.000 0.000  0 1.000 0.000 0.000
#> SRR1562754     4  0.5079      0.739 0.148 0.000  0 0.628 0.224 0.000
#> SRR1562755     4  0.5079      0.739 0.148 0.000  0 0.628 0.224 0.000
#> SRR1562756     4  0.5079      0.739 0.148 0.000  0 0.628 0.224 0.000
#> SRR1562757     4  0.5079      0.739 0.148 0.000  0 0.628 0.224 0.000
#> SRR1562758     4  0.5079      0.739 0.148 0.000  0 0.628 0.224 0.000
#> SRR1562759     4  0.5079      0.739 0.148 0.000  0 0.628 0.224 0.000
#> SRR1562792     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1562793     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1562794     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1562795     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1562796     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1562797     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1562798     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1562799     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1562800     6  0.0000      1.000 0.000 0.000  0 0.000 0.000 1.000
#> SRR1562801     6  0.0000      1.000 0.000 0.000  0 0.000 0.000 1.000
#> SRR1562802     6  0.0000      1.000 0.000 0.000  0 0.000 0.000 1.000
#> SRR1562803     6  0.0000      1.000 0.000 0.000  0 0.000 0.000 1.000
#> SRR1562804     6  0.0000      1.000 0.000 0.000  0 0.000 0.000 1.000
#> SRR1562805     6  0.0000      1.000 0.000 0.000  0 0.000 0.000 1.000
#> SRR1562806     1  0.2562      0.980 0.828 0.000  0 0.000 0.000 0.172
#> SRR1562807     1  0.2562      0.980 0.828 0.000  0 0.000 0.000 0.172
#> SRR1562808     1  0.2562      0.980 0.828 0.000  0 0.000 0.000 0.172
#> SRR1562809     1  0.2562      0.980 0.828 0.000  0 0.000 0.000 0.172
#> SRR1562810     1  0.2793      0.980 0.800 0.000  0 0.000 0.000 0.200
#> SRR1562811     1  0.2793      0.980 0.800 0.000  0 0.000 0.000 0.200
#> SRR1562812     1  0.2793      0.980 0.800 0.000  0 0.000 0.000 0.200
#> SRR1562813     1  0.2793      0.980 0.800 0.000  0 0.000 0.000 0.200

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-mclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-mclust-collect-classes

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


SD:NMF**

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

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

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

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 15301 rows and 63 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#>   Subgroups are detected by 'NMF' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 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 1.000           1.000       1.000         0.4624 0.538   0.538
#> 3 3 1.000           1.000       1.000         0.1239 0.943   0.893
#> 4 4 0.801           0.960       0.930         0.3296 0.788   0.559
#> 5 5 0.763           0.861       0.864         0.0934 0.874   0.588
#> 6 6 0.769           0.804       0.821         0.0432 1.000   1.000

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

suggest_best_k(res)
#> [1] 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
#> SRR1562718     2       0          1  0  1
#> SRR1562719     2       0          1  0  1
#> SRR1562720     2       0          1  0  1
#> SRR1562721     2       0          1  0  1
#> SRR1562723     2       0          1  0  1
#> SRR1562724     2       0          1  0  1
#> SRR1562725     2       0          1  0  1
#> SRR1562726     2       0          1  0  1
#> SRR1562727     2       0          1  0  1
#> SRR1562728     2       0          1  0  1
#> SRR1562729     2       0          1  0  1
#> SRR1562730     2       0          1  0  1
#> SRR1562731     2       0          1  0  1
#> SRR1562732     2       0          1  0  1
#> SRR1562733     2       0          1  0  1
#> SRR1562734     2       0          1  0  1
#> SRR1562735     2       0          1  0  1
#> SRR1562736     2       0          1  0  1
#> SRR1562737     2       0          1  0  1
#> SRR1562738     2       0          1  0  1
#> SRR1562739     2       0          1  0  1
#> SRR1562740     2       0          1  0  1
#> SRR1562741     2       0          1  0  1
#> SRR1562742     2       0          1  0  1
#> SRR1562743     2       0          1  0  1
#> SRR1562744     2       0          1  0  1
#> SRR1562745     2       0          1  0  1
#> SRR1562746     2       0          1  0  1
#> SRR1562747     2       0          1  0  1
#> SRR1562748     2       0          1  0  1
#> SRR1562749     2       0          1  0  1
#> SRR1562750     2       0          1  0  1
#> SRR1562751     2       0          1  0  1
#> SRR1562752     2       0          1  0  1
#> SRR1562753     2       0          1  0  1
#> SRR1562754     2       0          1  0  1
#> SRR1562755     2       0          1  0  1
#> SRR1562756     2       0          1  0  1
#> SRR1562757     2       0          1  0  1
#> SRR1562758     2       0          1  0  1
#> SRR1562759     2       0          1  0  1
#> SRR1562792     1       0          1  1  0
#> SRR1562793     1       0          1  1  0
#> SRR1562794     1       0          1  1  0
#> SRR1562795     1       0          1  1  0
#> SRR1562796     1       0          1  1  0
#> SRR1562797     1       0          1  1  0
#> SRR1562798     1       0          1  1  0
#> SRR1562799     1       0          1  1  0
#> SRR1562800     1       0          1  1  0
#> SRR1562801     1       0          1  1  0
#> SRR1562802     1       0          1  1  0
#> SRR1562803     1       0          1  1  0
#> SRR1562804     1       0          1  1  0
#> SRR1562805     1       0          1  1  0
#> SRR1562806     1       0          1  1  0
#> SRR1562807     1       0          1  1  0
#> SRR1562808     1       0          1  1  0
#> SRR1562809     1       0          1  1  0
#> SRR1562810     1       0          1  1  0
#> SRR1562811     1       0          1  1  0
#> SRR1562812     1       0          1  1  0
#> SRR1562813     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette p1 p2 p3
#> SRR1562718     2       0          1  0  1  0
#> SRR1562719     2       0          1  0  1  0
#> SRR1562720     2       0          1  0  1  0
#> SRR1562721     2       0          1  0  1  0
#> SRR1562723     2       0          1  0  1  0
#> SRR1562724     2       0          1  0  1  0
#> SRR1562725     2       0          1  0  1  0
#> SRR1562726     2       0          1  0  1  0
#> SRR1562727     2       0          1  0  1  0
#> SRR1562728     2       0          1  0  1  0
#> SRR1562729     2       0          1  0  1  0
#> SRR1562730     2       0          1  0  1  0
#> SRR1562731     2       0          1  0  1  0
#> SRR1562732     2       0          1  0  1  0
#> SRR1562733     2       0          1  0  1  0
#> SRR1562734     2       0          1  0  1  0
#> SRR1562735     2       0          1  0  1  0
#> SRR1562736     2       0          1  0  1  0
#> SRR1562737     2       0          1  0  1  0
#> SRR1562738     2       0          1  0  1  0
#> SRR1562739     2       0          1  0  1  0
#> SRR1562740     2       0          1  0  1  0
#> SRR1562741     2       0          1  0  1  0
#> SRR1562742     2       0          1  0  1  0
#> SRR1562743     2       0          1  0  1  0
#> SRR1562744     2       0          1  0  1  0
#> SRR1562745     2       0          1  0  1  0
#> SRR1562746     2       0          1  0  1  0
#> SRR1562747     2       0          1  0  1  0
#> SRR1562748     2       0          1  0  1  0
#> SRR1562749     2       0          1  0  1  0
#> SRR1562750     2       0          1  0  1  0
#> SRR1562751     2       0          1  0  1  0
#> SRR1562752     2       0          1  0  1  0
#> SRR1562753     2       0          1  0  1  0
#> SRR1562754     2       0          1  0  1  0
#> SRR1562755     2       0          1  0  1  0
#> SRR1562756     2       0          1  0  1  0
#> SRR1562757     2       0          1  0  1  0
#> SRR1562758     2       0          1  0  1  0
#> SRR1562759     2       0          1  0  1  0
#> SRR1562792     3       0          1  0  0  1
#> SRR1562793     3       0          1  0  0  1
#> SRR1562794     3       0          1  0  0  1
#> SRR1562795     3       0          1  0  0  1
#> SRR1562796     3       0          1  0  0  1
#> SRR1562797     3       0          1  0  0  1
#> SRR1562798     3       0          1  0  0  1
#> SRR1562799     3       0          1  0  0  1
#> SRR1562800     1       0          1  1  0  0
#> SRR1562801     1       0          1  1  0  0
#> SRR1562802     1       0          1  1  0  0
#> SRR1562803     1       0          1  1  0  0
#> SRR1562804     1       0          1  1  0  0
#> SRR1562805     1       0          1  1  0  0
#> SRR1562806     1       0          1  1  0  0
#> SRR1562807     1       0          1  1  0  0
#> SRR1562808     1       0          1  1  0  0
#> SRR1562809     1       0          1  1  0  0
#> SRR1562810     1       0          1  1  0  0
#> SRR1562811     1       0          1  1  0  0
#> SRR1562812     1       0          1  1  0  0
#> SRR1562813     1       0          1  1  0  0

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2 p3    p4
#> SRR1562718     2  0.0000      0.993 0.000 1.000  0 0.000
#> SRR1562719     2  0.0000      0.993 0.000 1.000  0 0.000
#> SRR1562720     2  0.0000      0.993 0.000 1.000  0 0.000
#> SRR1562721     2  0.0000      0.993 0.000 1.000  0 0.000
#> SRR1562723     2  0.0000      0.993 0.000 1.000  0 0.000
#> SRR1562724     2  0.0000      0.993 0.000 1.000  0 0.000
#> SRR1562725     2  0.0000      0.993 0.000 1.000  0 0.000
#> SRR1562726     2  0.0000      0.993 0.000 1.000  0 0.000
#> SRR1562727     2  0.0000      0.993 0.000 1.000  0 0.000
#> SRR1562728     2  0.0000      0.993 0.000 1.000  0 0.000
#> SRR1562729     2  0.0000      0.993 0.000 1.000  0 0.000
#> SRR1562730     2  0.0000      0.993 0.000 1.000  0 0.000
#> SRR1562731     2  0.0000      0.993 0.000 1.000  0 0.000
#> SRR1562732     2  0.0000      0.993 0.000 1.000  0 0.000
#> SRR1562733     2  0.0000      0.993 0.000 1.000  0 0.000
#> SRR1562734     2  0.0000      0.993 0.000 1.000  0 0.000
#> SRR1562735     2  0.0000      0.993 0.000 1.000  0 0.000
#> SRR1562736     4  0.4477      0.867 0.000 0.312  0 0.688
#> SRR1562737     4  0.4543      0.856 0.000 0.324  0 0.676
#> SRR1562738     4  0.4477      0.866 0.000 0.312  0 0.688
#> SRR1562739     4  0.4543      0.856 0.000 0.324  0 0.676
#> SRR1562740     4  0.4500      0.864 0.000 0.316  0 0.684
#> SRR1562741     4  0.4543      0.856 0.000 0.324  0 0.676
#> SRR1562742     2  0.0707      0.979 0.000 0.980  0 0.020
#> SRR1562743     2  0.0707      0.979 0.000 0.980  0 0.020
#> SRR1562744     2  0.0707      0.979 0.000 0.980  0 0.020
#> SRR1562745     2  0.0707      0.979 0.000 0.980  0 0.020
#> SRR1562746     2  0.0707      0.979 0.000 0.980  0 0.020
#> SRR1562747     2  0.0707      0.979 0.000 0.980  0 0.020
#> SRR1562748     4  0.2868      0.879 0.000 0.136  0 0.864
#> SRR1562749     4  0.2868      0.879 0.000 0.136  0 0.864
#> SRR1562750     4  0.2868      0.879 0.000 0.136  0 0.864
#> SRR1562751     4  0.2868      0.879 0.000 0.136  0 0.864
#> SRR1562752     4  0.2868      0.879 0.000 0.136  0 0.864
#> SRR1562753     4  0.2868      0.879 0.000 0.136  0 0.864
#> SRR1562754     4  0.3873      0.913 0.000 0.228  0 0.772
#> SRR1562755     4  0.3873      0.913 0.000 0.228  0 0.772
#> SRR1562756     4  0.3873      0.913 0.000 0.228  0 0.772
#> SRR1562757     4  0.3873      0.913 0.000 0.228  0 0.772
#> SRR1562758     4  0.3873      0.913 0.000 0.228  0 0.772
#> SRR1562759     4  0.3873      0.913 0.000 0.228  0 0.772
#> SRR1562792     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1562793     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1562794     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1562795     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1562796     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1562797     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1562798     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1562799     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1562800     1  0.1118      0.982 0.964 0.000  0 0.036
#> SRR1562801     1  0.1118      0.982 0.964 0.000  0 0.036
#> SRR1562802     1  0.1118      0.982 0.964 0.000  0 0.036
#> SRR1562803     1  0.1118      0.982 0.964 0.000  0 0.036
#> SRR1562804     1  0.1118      0.982 0.964 0.000  0 0.036
#> SRR1562805     1  0.1118      0.982 0.964 0.000  0 0.036
#> SRR1562806     1  0.0000      0.987 1.000 0.000  0 0.000
#> SRR1562807     1  0.0000      0.987 1.000 0.000  0 0.000
#> SRR1562808     1  0.0000      0.987 1.000 0.000  0 0.000
#> SRR1562809     1  0.0000      0.987 1.000 0.000  0 0.000
#> SRR1562810     1  0.0000      0.987 1.000 0.000  0 0.000
#> SRR1562811     1  0.0000      0.987 1.000 0.000  0 0.000
#> SRR1562812     1  0.0000      0.987 1.000 0.000  0 0.000
#> SRR1562813     1  0.0000      0.987 1.000 0.000  0 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2 p3    p4    p5
#> SRR1562718     2  0.2471      0.849 0.000 0.864  0 0.000 0.136
#> SRR1562719     2  0.2377      0.859 0.000 0.872  0 0.000 0.128
#> SRR1562720     2  0.2377      0.859 0.000 0.872  0 0.000 0.128
#> SRR1562721     2  0.2179      0.873 0.000 0.888  0 0.000 0.112
#> SRR1562723     2  0.2471      0.849 0.000 0.864  0 0.000 0.136
#> SRR1562724     2  0.0865      0.931 0.000 0.972  0 0.004 0.024
#> SRR1562725     2  0.0865      0.931 0.000 0.972  0 0.004 0.024
#> SRR1562726     2  0.0703      0.932 0.000 0.976  0 0.000 0.024
#> SRR1562727     2  0.0703      0.932 0.000 0.976  0 0.000 0.024
#> SRR1562728     2  0.0703      0.932 0.000 0.976  0 0.000 0.024
#> SRR1562729     2  0.0703      0.932 0.000 0.976  0 0.000 0.024
#> SRR1562730     2  0.0609      0.921 0.000 0.980  0 0.020 0.000
#> SRR1562731     2  0.0609      0.921 0.000 0.980  0 0.020 0.000
#> SRR1562732     2  0.0609      0.921 0.000 0.980  0 0.020 0.000
#> SRR1562733     2  0.0609      0.921 0.000 0.980  0 0.020 0.000
#> SRR1562734     2  0.0609      0.921 0.000 0.980  0 0.020 0.000
#> SRR1562735     2  0.0609      0.921 0.000 0.980  0 0.020 0.000
#> SRR1562736     5  0.3016      0.749 0.000 0.132  0 0.020 0.848
#> SRR1562737     5  0.3319      0.757 0.000 0.160  0 0.020 0.820
#> SRR1562738     5  0.3284      0.756 0.000 0.148  0 0.024 0.828
#> SRR1562739     5  0.3326      0.757 0.000 0.152  0 0.024 0.824
#> SRR1562740     5  0.3284      0.758 0.000 0.148  0 0.024 0.828
#> SRR1562741     5  0.3284      0.758 0.000 0.148  0 0.024 0.828
#> SRR1562742     5  0.4321      0.593 0.000 0.396  0 0.004 0.600
#> SRR1562743     5  0.4321      0.593 0.000 0.396  0 0.004 0.600
#> SRR1562744     5  0.4321      0.593 0.000 0.396  0 0.004 0.600
#> SRR1562745     5  0.4310      0.600 0.000 0.392  0 0.004 0.604
#> SRR1562746     5  0.4321      0.593 0.000 0.396  0 0.004 0.600
#> SRR1562747     5  0.4310      0.600 0.000 0.392  0 0.004 0.604
#> SRR1562748     4  0.4264      1.000 0.000 0.004  0 0.620 0.376
#> SRR1562749     4  0.4264      1.000 0.000 0.004  0 0.620 0.376
#> SRR1562750     4  0.4264      1.000 0.000 0.004  0 0.620 0.376
#> SRR1562751     4  0.4264      1.000 0.000 0.004  0 0.620 0.376
#> SRR1562752     4  0.4264      1.000 0.000 0.004  0 0.620 0.376
#> SRR1562753     4  0.4264      1.000 0.000 0.004  0 0.620 0.376
#> SRR1562754     5  0.2006      0.703 0.000 0.072  0 0.012 0.916
#> SRR1562755     5  0.2006      0.703 0.000 0.072  0 0.012 0.916
#> SRR1562756     5  0.2006      0.703 0.000 0.072  0 0.012 0.916
#> SRR1562757     5  0.2069      0.707 0.000 0.076  0 0.012 0.912
#> SRR1562758     5  0.2006      0.703 0.000 0.072  0 0.012 0.916
#> SRR1562759     5  0.2006      0.703 0.000 0.072  0 0.012 0.916
#> SRR1562792     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1562793     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1562794     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1562795     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1562796     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1562797     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1562798     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1562799     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1562800     1  0.3366      0.875 0.768 0.000  0 0.232 0.000
#> SRR1562801     1  0.3366      0.875 0.768 0.000  0 0.232 0.000
#> SRR1562802     1  0.3366      0.875 0.768 0.000  0 0.232 0.000
#> SRR1562803     1  0.3366      0.875 0.768 0.000  0 0.232 0.000
#> SRR1562804     1  0.3366      0.875 0.768 0.000  0 0.232 0.000
#> SRR1562805     1  0.3366      0.875 0.768 0.000  0 0.232 0.000
#> SRR1562806     1  0.0000      0.908 1.000 0.000  0 0.000 0.000
#> SRR1562807     1  0.0000      0.908 1.000 0.000  0 0.000 0.000
#> SRR1562808     1  0.0000      0.908 1.000 0.000  0 0.000 0.000
#> SRR1562809     1  0.0000      0.908 1.000 0.000  0 0.000 0.000
#> SRR1562810     1  0.0000      0.908 1.000 0.000  0 0.000 0.000
#> SRR1562811     1  0.0000      0.908 1.000 0.000  0 0.000 0.000
#> SRR1562812     1  0.0000      0.908 1.000 0.000  0 0.000 0.000
#> SRR1562813     1  0.0000      0.908 1.000 0.000  0 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2 p3    p4    p5 p6
#> SRR1562718     2   0.387      0.648 0.000 0.636  0 0.008 0.356 NA
#> SRR1562719     2   0.385      0.655 0.000 0.644  0 0.008 0.348 NA
#> SRR1562720     2   0.385      0.655 0.000 0.644  0 0.008 0.348 NA
#> SRR1562721     2   0.380      0.666 0.000 0.656  0 0.008 0.336 NA
#> SRR1562723     2   0.385      0.655 0.000 0.644  0 0.008 0.348 NA
#> SRR1562724     2   0.378      0.757 0.000 0.760  0 0.020 0.204 NA
#> SRR1562725     2   0.375      0.758 0.000 0.764  0 0.020 0.200 NA
#> SRR1562726     2   0.389      0.753 0.000 0.744  0 0.020 0.220 NA
#> SRR1562727     2   0.387      0.754 0.000 0.748  0 0.020 0.216 NA
#> SRR1562728     2   0.389      0.752 0.000 0.744  0 0.020 0.220 NA
#> SRR1562729     2   0.384      0.756 0.000 0.752  0 0.020 0.212 NA
#> SRR1562730     2   0.231      0.694 0.000 0.880  0 0.000 0.016 NA
#> SRR1562731     2   0.231      0.694 0.000 0.880  0 0.000 0.016 NA
#> SRR1562732     2   0.231      0.694 0.000 0.880  0 0.000 0.016 NA
#> SRR1562733     2   0.231      0.694 0.000 0.880  0 0.000 0.016 NA
#> SRR1562734     2   0.231      0.694 0.000 0.880  0 0.000 0.016 NA
#> SRR1562735     2   0.231      0.694 0.000 0.880  0 0.000 0.016 NA
#> SRR1562736     5   0.350      0.775 0.000 0.124  0 0.056 0.812 NA
#> SRR1562737     5   0.357      0.768 0.000 0.136  0 0.052 0.804 NA
#> SRR1562738     5   0.370      0.768 0.000 0.128  0 0.060 0.800 NA
#> SRR1562739     5   0.373      0.763 0.000 0.136  0 0.056 0.796 NA
#> SRR1562740     5   0.361      0.769 0.000 0.128  0 0.060 0.804 NA
#> SRR1562741     5   0.373      0.763 0.000 0.136  0 0.056 0.796 NA
#> SRR1562742     5   0.190      0.803 0.000 0.072  0 0.000 0.912 NA
#> SRR1562743     5   0.184      0.804 0.000 0.068  0 0.000 0.916 NA
#> SRR1562744     5   0.190      0.803 0.000 0.072  0 0.000 0.912 NA
#> SRR1562745     5   0.190      0.803 0.000 0.072  0 0.000 0.912 NA
#> SRR1562746     5   0.190      0.804 0.000 0.072  0 0.000 0.912 NA
#> SRR1562747     5   0.184      0.804 0.000 0.068  0 0.000 0.916 NA
#> SRR1562748     4   0.101      1.000 0.000 0.000  0 0.956 0.044 NA
#> SRR1562749     4   0.101      1.000 0.000 0.000  0 0.956 0.044 NA
#> SRR1562750     4   0.101      1.000 0.000 0.000  0 0.956 0.044 NA
#> SRR1562751     4   0.101      1.000 0.000 0.000  0 0.956 0.044 NA
#> SRR1562752     4   0.101      1.000 0.000 0.000  0 0.956 0.044 NA
#> SRR1562753     4   0.101      1.000 0.000 0.000  0 0.956 0.044 NA
#> SRR1562754     5   0.408      0.744 0.000 0.008  0 0.100 0.768 NA
#> SRR1562755     5   0.408      0.744 0.000 0.008  0 0.100 0.768 NA
#> SRR1562756     5   0.408      0.744 0.000 0.008  0 0.100 0.768 NA
#> SRR1562757     5   0.408      0.744 0.000 0.008  0 0.100 0.768 NA
#> SRR1562758     5   0.408      0.744 0.000 0.008  0 0.100 0.768 NA
#> SRR1562759     5   0.403      0.746 0.000 0.008  0 0.096 0.772 NA
#> SRR1562792     3   0.000      1.000 0.000 0.000  1 0.000 0.000 NA
#> SRR1562793     3   0.000      1.000 0.000 0.000  1 0.000 0.000 NA
#> SRR1562794     3   0.000      1.000 0.000 0.000  1 0.000 0.000 NA
#> SRR1562795     3   0.000      1.000 0.000 0.000  1 0.000 0.000 NA
#> SRR1562796     3   0.000      1.000 0.000 0.000  1 0.000 0.000 NA
#> SRR1562797     3   0.000      1.000 0.000 0.000  1 0.000 0.000 NA
#> SRR1562798     3   0.000      1.000 0.000 0.000  1 0.000 0.000 NA
#> SRR1562799     3   0.000      1.000 0.000 0.000  1 0.000 0.000 NA
#> SRR1562800     1   0.383      0.728 0.556 0.000  0 0.000 0.000 NA
#> SRR1562801     1   0.383      0.728 0.556 0.000  0 0.000 0.000 NA
#> SRR1562802     1   0.383      0.730 0.560 0.000  0 0.000 0.000 NA
#> SRR1562803     1   0.383      0.730 0.560 0.000  0 0.000 0.000 NA
#> SRR1562804     1   0.386      0.715 0.532 0.000  0 0.000 0.000 NA
#> SRR1562805     1   0.386      0.715 0.532 0.000  0 0.000 0.000 NA
#> SRR1562806     1   0.000      0.808 1.000 0.000  0 0.000 0.000 NA
#> SRR1562807     1   0.000      0.808 1.000 0.000  0 0.000 0.000 NA
#> SRR1562808     1   0.000      0.808 1.000 0.000  0 0.000 0.000 NA
#> SRR1562809     1   0.000      0.808 1.000 0.000  0 0.000 0.000 NA
#> SRR1562810     1   0.000      0.808 1.000 0.000  0 0.000 0.000 NA
#> SRR1562811     1   0.000      0.808 1.000 0.000  0 0.000 0.000 NA
#> SRR1562812     1   0.000      0.808 1.000 0.000  0 0.000 0.000 NA
#> SRR1562813     1   0.000      0.808 1.000 0.000  0 0.000 0.000 NA

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-NMF-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-NMF-collect-classes

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


CV:hclust*

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

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

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

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

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

collect_plots(res)

plot of chunk CV-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.538           0.857       0.860         0.3016 0.649   0.649
#> 3 3 1.000           1.000       1.000         0.7231 0.832   0.741
#> 4 4 0.727           0.780       0.858         0.2182 0.892   0.776
#> 5 5 0.745           0.795       0.786         0.1141 0.862   0.653
#> 6 6 0.911           0.936       0.970         0.0738 0.975   0.914

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

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

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
#> SRR1562718     2   0.000      0.889 0.0 1.0
#> SRR1562719     2   0.000      0.889 0.0 1.0
#> SRR1562720     2   0.000      0.889 0.0 1.0
#> SRR1562721     2   0.000      0.889 0.0 1.0
#> SRR1562723     2   0.000      0.889 0.0 1.0
#> SRR1562724     2   0.000      0.889 0.0 1.0
#> SRR1562725     2   0.000      0.889 0.0 1.0
#> SRR1562726     2   0.000      0.889 0.0 1.0
#> SRR1562727     2   0.000      0.889 0.0 1.0
#> SRR1562728     2   0.000      0.889 0.0 1.0
#> SRR1562729     2   0.000      0.889 0.0 1.0
#> SRR1562730     2   0.000      0.889 0.0 1.0
#> SRR1562731     2   0.000      0.889 0.0 1.0
#> SRR1562732     2   0.000      0.889 0.0 1.0
#> SRR1562733     2   0.000      0.889 0.0 1.0
#> SRR1562734     2   0.000      0.889 0.0 1.0
#> SRR1562735     2   0.000      0.889 0.0 1.0
#> SRR1562736     2   0.000      0.889 0.0 1.0
#> SRR1562737     2   0.000      0.889 0.0 1.0
#> SRR1562738     2   0.000      0.889 0.0 1.0
#> SRR1562739     2   0.000      0.889 0.0 1.0
#> SRR1562740     2   0.000      0.889 0.0 1.0
#> SRR1562741     2   0.000      0.889 0.0 1.0
#> SRR1562742     2   0.000      0.889 0.0 1.0
#> SRR1562743     2   0.000      0.889 0.0 1.0
#> SRR1562744     2   0.000      0.889 0.0 1.0
#> SRR1562745     2   0.000      0.889 0.0 1.0
#> SRR1562746     2   0.000      0.889 0.0 1.0
#> SRR1562747     2   0.000      0.889 0.0 1.0
#> SRR1562748     2   0.000      0.889 0.0 1.0
#> SRR1562749     2   0.000      0.889 0.0 1.0
#> SRR1562750     2   0.000      0.889 0.0 1.0
#> SRR1562751     2   0.000      0.889 0.0 1.0
#> SRR1562752     2   0.000      0.889 0.0 1.0
#> SRR1562753     2   0.000      0.889 0.0 1.0
#> SRR1562754     2   0.000      0.889 0.0 1.0
#> SRR1562755     2   0.000      0.889 0.0 1.0
#> SRR1562756     2   0.000      0.889 0.0 1.0
#> SRR1562757     2   0.000      0.889 0.0 1.0
#> SRR1562758     2   0.000      0.889 0.0 1.0
#> SRR1562759     2   0.000      0.889 0.0 1.0
#> SRR1562792     2   0.971      0.442 0.4 0.6
#> SRR1562793     2   0.971      0.442 0.4 0.6
#> SRR1562794     2   0.971      0.442 0.4 0.6
#> SRR1562795     2   0.971      0.442 0.4 0.6
#> SRR1562796     2   0.971      0.442 0.4 0.6
#> SRR1562797     2   0.971      0.442 0.4 0.6
#> SRR1562798     2   0.971      0.442 0.4 0.6
#> SRR1562799     2   0.971      0.442 0.4 0.6
#> SRR1562800     1   0.971      1.000 0.6 0.4
#> SRR1562801     1   0.971      1.000 0.6 0.4
#> SRR1562802     1   0.971      1.000 0.6 0.4
#> SRR1562803     1   0.971      1.000 0.6 0.4
#> SRR1562804     1   0.971      1.000 0.6 0.4
#> SRR1562805     1   0.971      1.000 0.6 0.4
#> SRR1562806     1   0.971      1.000 0.6 0.4
#> SRR1562807     1   0.971      1.000 0.6 0.4
#> SRR1562808     1   0.971      1.000 0.6 0.4
#> SRR1562809     1   0.971      1.000 0.6 0.4
#> SRR1562810     1   0.971      1.000 0.6 0.4
#> SRR1562811     1   0.971      1.000 0.6 0.4
#> SRR1562812     1   0.971      1.000 0.6 0.4
#> SRR1562813     1   0.971      1.000 0.6 0.4

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette p1 p2 p3
#> SRR1562718     2       0          1  0  1  0
#> SRR1562719     2       0          1  0  1  0
#> SRR1562720     2       0          1  0  1  0
#> SRR1562721     2       0          1  0  1  0
#> SRR1562723     2       0          1  0  1  0
#> SRR1562724     2       0          1  0  1  0
#> SRR1562725     2       0          1  0  1  0
#> SRR1562726     2       0          1  0  1  0
#> SRR1562727     2       0          1  0  1  0
#> SRR1562728     2       0          1  0  1  0
#> SRR1562729     2       0          1  0  1  0
#> SRR1562730     2       0          1  0  1  0
#> SRR1562731     2       0          1  0  1  0
#> SRR1562732     2       0          1  0  1  0
#> SRR1562733     2       0          1  0  1  0
#> SRR1562734     2       0          1  0  1  0
#> SRR1562735     2       0          1  0  1  0
#> SRR1562736     2       0          1  0  1  0
#> SRR1562737     2       0          1  0  1  0
#> SRR1562738     2       0          1  0  1  0
#> SRR1562739     2       0          1  0  1  0
#> SRR1562740     2       0          1  0  1  0
#> SRR1562741     2       0          1  0  1  0
#> SRR1562742     2       0          1  0  1  0
#> SRR1562743     2       0          1  0  1  0
#> SRR1562744     2       0          1  0  1  0
#> SRR1562745     2       0          1  0  1  0
#> SRR1562746     2       0          1  0  1  0
#> SRR1562747     2       0          1  0  1  0
#> SRR1562748     2       0          1  0  1  0
#> SRR1562749     2       0          1  0  1  0
#> SRR1562750     2       0          1  0  1  0
#> SRR1562751     2       0          1  0  1  0
#> SRR1562752     2       0          1  0  1  0
#> SRR1562753     2       0          1  0  1  0
#> SRR1562754     2       0          1  0  1  0
#> SRR1562755     2       0          1  0  1  0
#> SRR1562756     2       0          1  0  1  0
#> SRR1562757     2       0          1  0  1  0
#> SRR1562758     2       0          1  0  1  0
#> SRR1562759     2       0          1  0  1  0
#> SRR1562792     3       0          1  0  0  1
#> SRR1562793     3       0          1  0  0  1
#> SRR1562794     3       0          1  0  0  1
#> SRR1562795     3       0          1  0  0  1
#> SRR1562796     3       0          1  0  0  1
#> SRR1562797     3       0          1  0  0  1
#> SRR1562798     3       0          1  0  0  1
#> SRR1562799     3       0          1  0  0  1
#> SRR1562800     1       0          1  1  0  0
#> SRR1562801     1       0          1  1  0  0
#> SRR1562802     1       0          1  1  0  0
#> SRR1562803     1       0          1  1  0  0
#> SRR1562804     1       0          1  1  0  0
#> SRR1562805     1       0          1  1  0  0
#> SRR1562806     1       0          1  1  0  0
#> SRR1562807     1       0          1  1  0  0
#> SRR1562808     1       0          1  1  0  0
#> SRR1562809     1       0          1  1  0  0
#> SRR1562810     1       0          1  1  0  0
#> SRR1562811     1       0          1  1  0  0
#> SRR1562812     1       0          1  1  0  0
#> SRR1562813     1       0          1  1  0  0

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette  p1    p2 p3    p4
#> SRR1562718     2   0.452      0.708 0.0 0.680  0 0.320
#> SRR1562719     2   0.452      0.708 0.0 0.680  0 0.320
#> SRR1562720     2   0.452      0.708 0.0 0.680  0 0.320
#> SRR1562721     2   0.452      0.708 0.0 0.680  0 0.320
#> SRR1562723     2   0.452      0.708 0.0 0.680  0 0.320
#> SRR1562724     2   0.452      0.708 0.0 0.680  0 0.320
#> SRR1562725     2   0.452      0.708 0.0 0.680  0 0.320
#> SRR1562726     2   0.452      0.708 0.0 0.680  0 0.320
#> SRR1562727     2   0.452      0.708 0.0 0.680  0 0.320
#> SRR1562728     2   0.452      0.708 0.0 0.680  0 0.320
#> SRR1562729     2   0.452      0.708 0.0 0.680  0 0.320
#> SRR1562730     4   0.416      1.000 0.0 0.264  0 0.736
#> SRR1562731     4   0.416      1.000 0.0 0.264  0 0.736
#> SRR1562732     4   0.416      1.000 0.0 0.264  0 0.736
#> SRR1562733     4   0.416      1.000 0.0 0.264  0 0.736
#> SRR1562734     4   0.416      1.000 0.0 0.264  0 0.736
#> SRR1562735     4   0.416      1.000 0.0 0.264  0 0.736
#> SRR1562736     2   0.452      0.708 0.0 0.680  0 0.320
#> SRR1562737     2   0.452      0.708 0.0 0.680  0 0.320
#> SRR1562738     2   0.452      0.708 0.0 0.680  0 0.320
#> SRR1562739     2   0.452      0.708 0.0 0.680  0 0.320
#> SRR1562740     2   0.452      0.708 0.0 0.680  0 0.320
#> SRR1562741     2   0.452      0.708 0.0 0.680  0 0.320
#> SRR1562742     2   0.452      0.708 0.0 0.680  0 0.320
#> SRR1562743     2   0.452      0.708 0.0 0.680  0 0.320
#> SRR1562744     2   0.452      0.708 0.0 0.680  0 0.320
#> SRR1562745     2   0.452      0.708 0.0 0.680  0 0.320
#> SRR1562746     2   0.452      0.708 0.0 0.680  0 0.320
#> SRR1562747     2   0.452      0.708 0.0 0.680  0 0.320
#> SRR1562748     2   0.172      0.484 0.0 0.936  0 0.064
#> SRR1562749     2   0.172      0.484 0.0 0.936  0 0.064
#> SRR1562750     2   0.172      0.484 0.0 0.936  0 0.064
#> SRR1562751     2   0.172      0.484 0.0 0.936  0 0.064
#> SRR1562752     2   0.172      0.484 0.0 0.936  0 0.064
#> SRR1562753     2   0.172      0.484 0.0 0.936  0 0.064
#> SRR1562754     2   0.000      0.538 0.0 1.000  0 0.000
#> SRR1562755     2   0.000      0.538 0.0 1.000  0 0.000
#> SRR1562756     2   0.000      0.538 0.0 1.000  0 0.000
#> SRR1562757     2   0.000      0.538 0.0 1.000  0 0.000
#> SRR1562758     2   0.000      0.538 0.0 1.000  0 0.000
#> SRR1562759     2   0.000      0.538 0.0 1.000  0 0.000
#> SRR1562792     3   0.000      1.000 0.0 0.000  1 0.000
#> SRR1562793     3   0.000      1.000 0.0 0.000  1 0.000
#> SRR1562794     3   0.000      1.000 0.0 0.000  1 0.000
#> SRR1562795     3   0.000      1.000 0.0 0.000  1 0.000
#> SRR1562796     3   0.000      1.000 0.0 0.000  1 0.000
#> SRR1562797     3   0.000      1.000 0.0 0.000  1 0.000
#> SRR1562798     3   0.000      1.000 0.0 0.000  1 0.000
#> SRR1562799     3   0.000      1.000 0.0 0.000  1 0.000
#> SRR1562800     1   0.361      0.895 0.8 0.000  0 0.200
#> SRR1562801     1   0.361      0.895 0.8 0.000  0 0.200
#> SRR1562802     1   0.361      0.895 0.8 0.000  0 0.200
#> SRR1562803     1   0.361      0.895 0.8 0.000  0 0.200
#> SRR1562804     1   0.361      0.895 0.8 0.000  0 0.200
#> SRR1562805     1   0.361      0.895 0.8 0.000  0 0.200
#> SRR1562806     1   0.000      0.922 1.0 0.000  0 0.000
#> SRR1562807     1   0.000      0.922 1.0 0.000  0 0.000
#> SRR1562808     1   0.000      0.922 1.0 0.000  0 0.000
#> SRR1562809     1   0.000      0.922 1.0 0.000  0 0.000
#> SRR1562810     1   0.000      0.922 1.0 0.000  0 0.000
#> SRR1562811     1   0.000      0.922 1.0 0.000  0 0.000
#> SRR1562812     1   0.000      0.922 1.0 0.000  0 0.000
#> SRR1562813     1   0.000      0.922 1.0 0.000  0 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4    p5
#> SRR1562718     2  0.3837      0.886 0.000 0.692 0.000 0.000 0.308
#> SRR1562719     2  0.3837      0.886 0.000 0.692 0.000 0.000 0.308
#> SRR1562720     2  0.3837      0.886 0.000 0.692 0.000 0.000 0.308
#> SRR1562721     2  0.3837      0.886 0.000 0.692 0.000 0.000 0.308
#> SRR1562723     2  0.3837      0.886 0.000 0.692 0.000 0.000 0.308
#> SRR1562724     2  0.3837      0.886 0.000 0.692 0.000 0.000 0.308
#> SRR1562725     2  0.3837      0.886 0.000 0.692 0.000 0.000 0.308
#> SRR1562726     2  0.3837      0.886 0.000 0.692 0.000 0.000 0.308
#> SRR1562727     2  0.3837      0.886 0.000 0.692 0.000 0.000 0.308
#> SRR1562728     2  0.3837      0.886 0.000 0.692 0.000 0.000 0.308
#> SRR1562729     2  0.3837      0.886 0.000 0.692 0.000 0.000 0.308
#> SRR1562730     5  0.1121      1.000 0.000 0.044 0.000 0.000 0.956
#> SRR1562731     5  0.1121      1.000 0.000 0.044 0.000 0.000 0.956
#> SRR1562732     5  0.1121      1.000 0.000 0.044 0.000 0.000 0.956
#> SRR1562733     5  0.1121      1.000 0.000 0.044 0.000 0.000 0.956
#> SRR1562734     5  0.1121      1.000 0.000 0.044 0.000 0.000 0.956
#> SRR1562735     5  0.1121      1.000 0.000 0.044 0.000 0.000 0.956
#> SRR1562736     2  0.3837      0.886 0.000 0.692 0.000 0.000 0.308
#> SRR1562737     2  0.3837      0.886 0.000 0.692 0.000 0.000 0.308
#> SRR1562738     2  0.3837      0.886 0.000 0.692 0.000 0.000 0.308
#> SRR1562739     2  0.3837      0.886 0.000 0.692 0.000 0.000 0.308
#> SRR1562740     2  0.3837      0.886 0.000 0.692 0.000 0.000 0.308
#> SRR1562741     2  0.3837      0.886 0.000 0.692 0.000 0.000 0.308
#> SRR1562742     2  0.3837      0.886 0.000 0.692 0.000 0.000 0.308
#> SRR1562743     2  0.3837      0.886 0.000 0.692 0.000 0.000 0.308
#> SRR1562744     2  0.3837      0.886 0.000 0.692 0.000 0.000 0.308
#> SRR1562745     2  0.3837      0.886 0.000 0.692 0.000 0.000 0.308
#> SRR1562746     2  0.3837      0.886 0.000 0.692 0.000 0.000 0.308
#> SRR1562747     2  0.3837      0.886 0.000 0.692 0.000 0.000 0.308
#> SRR1562748     3  0.5238      0.341 0.000 0.472 0.484 0.000 0.044
#> SRR1562749     3  0.5238      0.341 0.000 0.472 0.484 0.000 0.044
#> SRR1562750     3  0.5238      0.341 0.000 0.472 0.484 0.000 0.044
#> SRR1562751     3  0.5238      0.341 0.000 0.472 0.484 0.000 0.044
#> SRR1562752     3  0.5238      0.341 0.000 0.472 0.484 0.000 0.044
#> SRR1562753     3  0.5238      0.341 0.000 0.472 0.484 0.000 0.044
#> SRR1562754     2  0.0404      0.566 0.000 0.988 0.012 0.000 0.000
#> SRR1562755     2  0.0404      0.566 0.000 0.988 0.012 0.000 0.000
#> SRR1562756     2  0.0404      0.566 0.000 0.988 0.012 0.000 0.000
#> SRR1562757     2  0.0404      0.566 0.000 0.988 0.012 0.000 0.000
#> SRR1562758     2  0.0404      0.566 0.000 0.988 0.012 0.000 0.000
#> SRR1562759     2  0.0404      0.566 0.000 0.988 0.012 0.000 0.000
#> SRR1562792     3  0.4304      0.536 0.000 0.000 0.516 0.484 0.000
#> SRR1562793     3  0.4304      0.536 0.000 0.000 0.516 0.484 0.000
#> SRR1562794     3  0.4304      0.536 0.000 0.000 0.516 0.484 0.000
#> SRR1562795     3  0.4304      0.536 0.000 0.000 0.516 0.484 0.000
#> SRR1562796     3  0.4304      0.536 0.000 0.000 0.516 0.484 0.000
#> SRR1562797     3  0.4304      0.536 0.000 0.000 0.516 0.484 0.000
#> SRR1562798     3  0.4304      0.536 0.000 0.000 0.516 0.484 0.000
#> SRR1562799     3  0.4304      0.536 0.000 0.000 0.516 0.484 0.000
#> SRR1562800     4  0.4304      1.000 0.484 0.000 0.000 0.516 0.000
#> SRR1562801     4  0.4304      1.000 0.484 0.000 0.000 0.516 0.000
#> SRR1562802     4  0.4304      1.000 0.484 0.000 0.000 0.516 0.000
#> SRR1562803     4  0.4304      1.000 0.484 0.000 0.000 0.516 0.000
#> SRR1562804     4  0.4304      1.000 0.484 0.000 0.000 0.516 0.000
#> SRR1562805     4  0.4304      1.000 0.484 0.000 0.000 0.516 0.000
#> SRR1562806     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1562807     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1562808     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1562809     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1562810     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1562811     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1562812     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> SRR1562813     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette p1 p2 p3   p4   p5 p6
#> SRR1562718     5    0.00      0.926  0  0  0 0.00 1.00  0
#> SRR1562719     5    0.00      0.926  0  0  0 0.00 1.00  0
#> SRR1562720     5    0.00      0.926  0  0  0 0.00 1.00  0
#> SRR1562721     5    0.00      0.926  0  0  0 0.00 1.00  0
#> SRR1562723     5    0.00      0.926  0  0  0 0.00 1.00  0
#> SRR1562724     5    0.00      0.926  0  0  0 0.00 1.00  0
#> SRR1562725     5    0.00      0.926  0  0  0 0.00 1.00  0
#> SRR1562726     5    0.00      0.926  0  0  0 0.00 1.00  0
#> SRR1562727     5    0.00      0.926  0  0  0 0.00 1.00  0
#> SRR1562728     5    0.00      0.926  0  0  0 0.00 1.00  0
#> SRR1562729     5    0.00      0.926  0  0  0 0.00 1.00  0
#> SRR1562730     2    0.00      1.000  0  1  0 0.00 0.00  0
#> SRR1562731     2    0.00      1.000  0  1  0 0.00 0.00  0
#> SRR1562732     2    0.00      1.000  0  1  0 0.00 0.00  0
#> SRR1562733     2    0.00      1.000  0  1  0 0.00 0.00  0
#> SRR1562734     2    0.00      1.000  0  1  0 0.00 0.00  0
#> SRR1562735     2    0.00      1.000  0  1  0 0.00 0.00  0
#> SRR1562736     5    0.00      0.926  0  0  0 0.00 1.00  0
#> SRR1562737     5    0.00      0.926  0  0  0 0.00 1.00  0
#> SRR1562738     5    0.00      0.926  0  0  0 0.00 1.00  0
#> SRR1562739     5    0.00      0.926  0  0  0 0.00 1.00  0
#> SRR1562740     5    0.00      0.926  0  0  0 0.00 1.00  0
#> SRR1562741     5    0.00      0.926  0  0  0 0.00 1.00  0
#> SRR1562742     5    0.00      0.926  0  0  0 0.00 1.00  0
#> SRR1562743     5    0.00      0.926  0  0  0 0.00 1.00  0
#> SRR1562744     5    0.00      0.926  0  0  0 0.00 1.00  0
#> SRR1562745     5    0.00      0.926  0  0  0 0.00 1.00  0
#> SRR1562746     5    0.00      0.926  0  0  0 0.00 1.00  0
#> SRR1562747     5    0.00      0.926  0  0  0 0.00 1.00  0
#> SRR1562748     4    0.00      1.000  0  0  0 1.00 0.00  0
#> SRR1562749     4    0.00      1.000  0  0  0 1.00 0.00  0
#> SRR1562750     4    0.00      1.000  0  0  0 1.00 0.00  0
#> SRR1562751     4    0.00      1.000  0  0  0 1.00 0.00  0
#> SRR1562752     4    0.00      1.000  0  0  0 1.00 0.00  0
#> SRR1562753     4    0.00      1.000  0  0  0 1.00 0.00  0
#> SRR1562754     5    0.35      0.613  0  0  0 0.32 0.68  0
#> SRR1562755     5    0.35      0.613  0  0  0 0.32 0.68  0
#> SRR1562756     5    0.35      0.613  0  0  0 0.32 0.68  0
#> SRR1562757     5    0.35      0.613  0  0  0 0.32 0.68  0
#> SRR1562758     5    0.35      0.613  0  0  0 0.32 0.68  0
#> SRR1562759     5    0.35      0.613  0  0  0 0.32 0.68  0
#> SRR1562792     3    0.00      1.000  0  0  1 0.00 0.00  0
#> SRR1562793     3    0.00      1.000  0  0  1 0.00 0.00  0
#> SRR1562794     3    0.00      1.000  0  0  1 0.00 0.00  0
#> SRR1562795     3    0.00      1.000  0  0  1 0.00 0.00  0
#> SRR1562796     3    0.00      1.000  0  0  1 0.00 0.00  0
#> SRR1562797     3    0.00      1.000  0  0  1 0.00 0.00  0
#> SRR1562798     3    0.00      1.000  0  0  1 0.00 0.00  0
#> SRR1562799     3    0.00      1.000  0  0  1 0.00 0.00  0
#> SRR1562800     6    0.00      1.000  0  0  0 0.00 0.00  1
#> SRR1562801     6    0.00      1.000  0  0  0 0.00 0.00  1
#> SRR1562802     6    0.00      1.000  0  0  0 0.00 0.00  1
#> SRR1562803     6    0.00      1.000  0  0  0 0.00 0.00  1
#> SRR1562804     6    0.00      1.000  0  0  0 0.00 0.00  1
#> SRR1562805     6    0.00      1.000  0  0  0 0.00 0.00  1
#> SRR1562806     1    0.00      1.000  1  0  0 0.00 0.00  0
#> SRR1562807     1    0.00      1.000  1  0  0 0.00 0.00  0
#> SRR1562808     1    0.00      1.000  1  0  0 0.00 0.00  0
#> SRR1562809     1    0.00      1.000  1  0  0 0.00 0.00  0
#> SRR1562810     1    0.00      1.000  1  0  0 0.00 0.00  0
#> SRR1562811     1    0.00      1.000  1  0  0 0.00 0.00  0
#> SRR1562812     1    0.00      1.000  1  0  0 0.00 0.00  0
#> SRR1562813     1    0.00      1.000  1  0  0 0.00 0.00  0

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-hclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-hclust-collect-classes

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


CV:kmeans

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

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

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

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 15301 rows and 63 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#>   Subgroups are detected by 'kmeans' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 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.481           0.911       0.908         0.3731 0.538   0.538
#> 3 3 0.869           0.952       0.918         0.3643 0.943   0.893
#> 4 4 0.632           0.824       0.842         0.2330 1.000   1.000
#> 5 5 0.590           0.571       0.720         0.1289 0.831   0.649
#> 6 6 0.627           0.611       0.631         0.0871 0.828   0.519

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
#> SRR1562718     2   0.000      1.000 0.00 1.00
#> SRR1562719     2   0.000      1.000 0.00 1.00
#> SRR1562720     2   0.000      1.000 0.00 1.00
#> SRR1562721     2   0.000      1.000 0.00 1.00
#> SRR1562723     2   0.000      1.000 0.00 1.00
#> SRR1562724     2   0.000      1.000 0.00 1.00
#> SRR1562725     2   0.000      1.000 0.00 1.00
#> SRR1562726     2   0.000      1.000 0.00 1.00
#> SRR1562727     2   0.000      1.000 0.00 1.00
#> SRR1562728     2   0.000      1.000 0.00 1.00
#> SRR1562729     2   0.000      1.000 0.00 1.00
#> SRR1562730     2   0.000      1.000 0.00 1.00
#> SRR1562731     2   0.000      1.000 0.00 1.00
#> SRR1562732     2   0.000      1.000 0.00 1.00
#> SRR1562733     2   0.000      1.000 0.00 1.00
#> SRR1562734     2   0.000      1.000 0.00 1.00
#> SRR1562735     2   0.000      1.000 0.00 1.00
#> SRR1562736     2   0.000      1.000 0.00 1.00
#> SRR1562737     2   0.000      1.000 0.00 1.00
#> SRR1562738     2   0.000      1.000 0.00 1.00
#> SRR1562739     2   0.000      1.000 0.00 1.00
#> SRR1562740     2   0.000      1.000 0.00 1.00
#> SRR1562741     2   0.000      1.000 0.00 1.00
#> SRR1562742     2   0.000      1.000 0.00 1.00
#> SRR1562743     2   0.000      1.000 0.00 1.00
#> SRR1562744     2   0.000      1.000 0.00 1.00
#> SRR1562745     2   0.000      1.000 0.00 1.00
#> SRR1562746     2   0.000      1.000 0.00 1.00
#> SRR1562747     2   0.000      1.000 0.00 1.00
#> SRR1562748     2   0.000      1.000 0.00 1.00
#> SRR1562749     2   0.000      1.000 0.00 1.00
#> SRR1562750     2   0.000      1.000 0.00 1.00
#> SRR1562751     2   0.000      1.000 0.00 1.00
#> SRR1562752     2   0.000      1.000 0.00 1.00
#> SRR1562753     2   0.000      1.000 0.00 1.00
#> SRR1562754     2   0.000      1.000 0.00 1.00
#> SRR1562755     2   0.000      1.000 0.00 1.00
#> SRR1562756     2   0.000      1.000 0.00 1.00
#> SRR1562757     2   0.000      1.000 0.00 1.00
#> SRR1562758     2   0.000      1.000 0.00 1.00
#> SRR1562759     2   0.000      1.000 0.00 1.00
#> SRR1562792     1   0.925      0.611 0.66 0.34
#> SRR1562793     1   0.925      0.611 0.66 0.34
#> SRR1562794     1   0.925      0.611 0.66 0.34
#> SRR1562795     1   0.925      0.611 0.66 0.34
#> SRR1562796     1   0.925      0.611 0.66 0.34
#> SRR1562797     1   0.925      0.611 0.66 0.34
#> SRR1562798     1   0.925      0.611 0.66 0.34
#> SRR1562799     1   0.925      0.611 0.66 0.34
#> SRR1562800     1   0.760      0.820 0.78 0.22
#> SRR1562801     1   0.760      0.820 0.78 0.22
#> SRR1562802     1   0.760      0.820 0.78 0.22
#> SRR1562803     1   0.760      0.820 0.78 0.22
#> SRR1562804     1   0.760      0.820 0.78 0.22
#> SRR1562805     1   0.760      0.820 0.78 0.22
#> SRR1562806     1   0.760      0.820 0.78 0.22
#> SRR1562807     1   0.760      0.820 0.78 0.22
#> SRR1562808     1   0.760      0.820 0.78 0.22
#> SRR1562809     1   0.760      0.820 0.78 0.22
#> SRR1562810     1   0.760      0.820 0.78 0.22
#> SRR1562811     1   0.760      0.820 0.78 0.22
#> SRR1562812     1   0.760      0.820 0.78 0.22
#> SRR1562813     1   0.760      0.820 0.78 0.22

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1562718     2  0.2066      0.945 0.000 0.940 0.060
#> SRR1562719     2  0.2066      0.945 0.000 0.940 0.060
#> SRR1562720     2  0.2066      0.945 0.000 0.940 0.060
#> SRR1562721     2  0.2066      0.945 0.000 0.940 0.060
#> SRR1562723     2  0.2066      0.945 0.000 0.940 0.060
#> SRR1562724     2  0.1753      0.949 0.000 0.952 0.048
#> SRR1562725     2  0.1753      0.949 0.000 0.952 0.048
#> SRR1562726     2  0.1753      0.949 0.000 0.952 0.048
#> SRR1562727     2  0.1753      0.949 0.000 0.952 0.048
#> SRR1562728     2  0.1753      0.949 0.000 0.952 0.048
#> SRR1562729     2  0.1753      0.949 0.000 0.952 0.048
#> SRR1562730     2  0.3340      0.908 0.000 0.880 0.120
#> SRR1562731     2  0.3340      0.908 0.000 0.880 0.120
#> SRR1562732     2  0.3340      0.908 0.000 0.880 0.120
#> SRR1562733     2  0.3340      0.908 0.000 0.880 0.120
#> SRR1562734     2  0.3340      0.908 0.000 0.880 0.120
#> SRR1562735     2  0.3340      0.908 0.000 0.880 0.120
#> SRR1562736     2  0.0424      0.958 0.000 0.992 0.008
#> SRR1562737     2  0.0424      0.958 0.000 0.992 0.008
#> SRR1562738     2  0.0424      0.958 0.000 0.992 0.008
#> SRR1562739     2  0.0424      0.958 0.000 0.992 0.008
#> SRR1562740     2  0.0424      0.958 0.000 0.992 0.008
#> SRR1562741     2  0.0424      0.958 0.000 0.992 0.008
#> SRR1562742     2  0.0592      0.958 0.000 0.988 0.012
#> SRR1562743     2  0.0592      0.958 0.000 0.988 0.012
#> SRR1562744     2  0.0592      0.958 0.000 0.988 0.012
#> SRR1562745     2  0.0592      0.958 0.000 0.988 0.012
#> SRR1562746     2  0.0592      0.958 0.000 0.988 0.012
#> SRR1562747     2  0.0592      0.958 0.000 0.988 0.012
#> SRR1562748     2  0.1411      0.951 0.000 0.964 0.036
#> SRR1562749     2  0.1411      0.951 0.000 0.964 0.036
#> SRR1562750     2  0.1411      0.951 0.000 0.964 0.036
#> SRR1562751     2  0.1411      0.951 0.000 0.964 0.036
#> SRR1562752     2  0.1411      0.951 0.000 0.964 0.036
#> SRR1562753     2  0.1411      0.951 0.000 0.964 0.036
#> SRR1562754     2  0.1163      0.954 0.000 0.972 0.028
#> SRR1562755     2  0.1163      0.954 0.000 0.972 0.028
#> SRR1562756     2  0.1163      0.954 0.000 0.972 0.028
#> SRR1562757     2  0.1163      0.954 0.000 0.972 0.028
#> SRR1562758     2  0.1163      0.954 0.000 0.972 0.028
#> SRR1562759     2  0.1163      0.954 0.000 0.972 0.028
#> SRR1562792     3  0.6587      0.980 0.156 0.092 0.752
#> SRR1562793     3  0.6587      0.980 0.156 0.092 0.752
#> SRR1562794     3  0.6587      0.980 0.156 0.092 0.752
#> SRR1562795     3  0.6587      0.980 0.156 0.092 0.752
#> SRR1562796     3  0.7199      0.980 0.204 0.092 0.704
#> SRR1562797     3  0.7199      0.980 0.204 0.092 0.704
#> SRR1562798     3  0.7199      0.980 0.204 0.092 0.704
#> SRR1562799     3  0.7199      0.980 0.204 0.092 0.704
#> SRR1562800     1  0.4253      0.949 0.872 0.048 0.080
#> SRR1562801     1  0.4253      0.949 0.872 0.048 0.080
#> SRR1562802     1  0.4253      0.949 0.872 0.048 0.080
#> SRR1562803     1  0.4253      0.949 0.872 0.048 0.080
#> SRR1562804     1  0.4339      0.949 0.868 0.048 0.084
#> SRR1562805     1  0.4339      0.949 0.868 0.048 0.084
#> SRR1562806     1  0.2339      0.958 0.940 0.048 0.012
#> SRR1562807     1  0.2339      0.958 0.940 0.048 0.012
#> SRR1562808     1  0.2339      0.958 0.940 0.048 0.012
#> SRR1562809     1  0.2339      0.958 0.940 0.048 0.012
#> SRR1562810     1  0.1753      0.960 0.952 0.048 0.000
#> SRR1562811     1  0.1753      0.960 0.952 0.048 0.000
#> SRR1562812     1  0.1753      0.960 0.952 0.048 0.000
#> SRR1562813     1  0.1753      0.960 0.952 0.048 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3 p4
#> SRR1562718     2  0.1545      0.792 0.000 0.952 0.008 NA
#> SRR1562719     2  0.1545      0.792 0.000 0.952 0.008 NA
#> SRR1562720     2  0.1545      0.792 0.000 0.952 0.008 NA
#> SRR1562721     2  0.1545      0.792 0.000 0.952 0.008 NA
#> SRR1562723     2  0.1545      0.792 0.000 0.952 0.008 NA
#> SRR1562724     2  0.1388      0.797 0.000 0.960 0.012 NA
#> SRR1562725     2  0.1388      0.797 0.000 0.960 0.012 NA
#> SRR1562726     2  0.1388      0.797 0.000 0.960 0.012 NA
#> SRR1562727     2  0.1388      0.797 0.000 0.960 0.012 NA
#> SRR1562728     2  0.1388      0.797 0.000 0.960 0.012 NA
#> SRR1562729     2  0.1388      0.797 0.000 0.960 0.012 NA
#> SRR1562730     2  0.4453      0.626 0.000 0.744 0.012 NA
#> SRR1562731     2  0.4453      0.626 0.000 0.744 0.012 NA
#> SRR1562732     2  0.4453      0.626 0.000 0.744 0.012 NA
#> SRR1562733     2  0.4453      0.626 0.000 0.744 0.012 NA
#> SRR1562734     2  0.4453      0.626 0.000 0.744 0.012 NA
#> SRR1562735     2  0.4453      0.626 0.000 0.744 0.012 NA
#> SRR1562736     2  0.3626      0.827 0.000 0.812 0.004 NA
#> SRR1562737     2  0.3626      0.827 0.000 0.812 0.004 NA
#> SRR1562738     2  0.3626      0.827 0.000 0.812 0.004 NA
#> SRR1562739     2  0.3626      0.827 0.000 0.812 0.004 NA
#> SRR1562740     2  0.3626      0.827 0.000 0.812 0.004 NA
#> SRR1562741     2  0.3626      0.827 0.000 0.812 0.004 NA
#> SRR1562742     2  0.3893      0.825 0.000 0.796 0.008 NA
#> SRR1562743     2  0.3893      0.825 0.000 0.796 0.008 NA
#> SRR1562744     2  0.3893      0.825 0.000 0.796 0.008 NA
#> SRR1562745     2  0.3893      0.825 0.000 0.796 0.008 NA
#> SRR1562746     2  0.3893      0.825 0.000 0.796 0.008 NA
#> SRR1562747     2  0.3893      0.825 0.000 0.796 0.008 NA
#> SRR1562748     2  0.5039      0.718 0.000 0.592 0.004 NA
#> SRR1562749     2  0.5039      0.718 0.000 0.592 0.004 NA
#> SRR1562750     2  0.5039      0.718 0.000 0.592 0.004 NA
#> SRR1562751     2  0.5039      0.718 0.000 0.592 0.004 NA
#> SRR1562752     2  0.5039      0.718 0.000 0.592 0.004 NA
#> SRR1562753     2  0.5039      0.718 0.000 0.592 0.004 NA
#> SRR1562754     2  0.4277      0.803 0.000 0.720 0.000 NA
#> SRR1562755     2  0.4277      0.803 0.000 0.720 0.000 NA
#> SRR1562756     2  0.4277      0.803 0.000 0.720 0.000 NA
#> SRR1562757     2  0.4277      0.803 0.000 0.720 0.000 NA
#> SRR1562758     2  0.4277      0.803 0.000 0.720 0.000 NA
#> SRR1562759     2  0.4277      0.803 0.000 0.720 0.000 NA
#> SRR1562792     3  0.4100      0.961 0.040 0.016 0.844 NA
#> SRR1562793     3  0.4100      0.961 0.040 0.016 0.844 NA
#> SRR1562794     3  0.4100      0.961 0.040 0.016 0.844 NA
#> SRR1562795     3  0.4100      0.961 0.040 0.016 0.844 NA
#> SRR1562796     3  0.1798      0.961 0.040 0.016 0.944 NA
#> SRR1562797     3  0.1798      0.961 0.040 0.016 0.944 NA
#> SRR1562798     3  0.1798      0.961 0.040 0.016 0.944 NA
#> SRR1562799     3  0.1798      0.961 0.040 0.016 0.944 NA
#> SRR1562800     1  0.3266      0.899 0.832 0.000 0.000 NA
#> SRR1562801     1  0.3266      0.899 0.832 0.000 0.000 NA
#> SRR1562802     1  0.3355      0.899 0.836 0.000 0.004 NA
#> SRR1562803     1  0.3355      0.899 0.836 0.000 0.004 NA
#> SRR1562804     1  0.3448      0.898 0.828 0.000 0.004 NA
#> SRR1562805     1  0.3448      0.898 0.828 0.000 0.004 NA
#> SRR1562806     1  0.1489      0.909 0.952 0.000 0.004 NA
#> SRR1562807     1  0.1489      0.909 0.952 0.000 0.004 NA
#> SRR1562808     1  0.1489      0.909 0.952 0.000 0.004 NA
#> SRR1562809     1  0.1489      0.909 0.952 0.000 0.004 NA
#> SRR1562810     1  0.0376      0.918 0.992 0.000 0.004 NA
#> SRR1562811     1  0.0376      0.918 0.992 0.000 0.004 NA
#> SRR1562812     1  0.0376      0.918 0.992 0.000 0.004 NA
#> SRR1562813     1  0.0376      0.918 0.992 0.000 0.004 NA

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4 p5
#> SRR1562718     2  0.4551      0.381 0.000 0.556 0.004 0.436 NA
#> SRR1562719     2  0.4551      0.381 0.000 0.556 0.004 0.436 NA
#> SRR1562720     2  0.4551      0.381 0.000 0.556 0.004 0.436 NA
#> SRR1562721     2  0.4551      0.381 0.000 0.556 0.004 0.436 NA
#> SRR1562723     2  0.4551      0.381 0.000 0.556 0.004 0.436 NA
#> SRR1562724     4  0.5380     -0.204 0.000 0.464 0.004 0.488 NA
#> SRR1562725     4  0.5380     -0.204 0.000 0.464 0.004 0.488 NA
#> SRR1562726     4  0.5380     -0.204 0.000 0.464 0.004 0.488 NA
#> SRR1562727     4  0.5380     -0.204 0.000 0.464 0.004 0.488 NA
#> SRR1562728     4  0.5380     -0.204 0.000 0.464 0.004 0.488 NA
#> SRR1562729     4  0.5380     -0.204 0.000 0.464 0.004 0.488 NA
#> SRR1562730     2  0.5602      0.659 0.000 0.640 0.000 0.196 NA
#> SRR1562731     2  0.5700      0.659 0.000 0.628 0.000 0.196 NA
#> SRR1562732     2  0.5567      0.659 0.000 0.644 0.000 0.196 NA
#> SRR1562733     2  0.5635      0.659 0.000 0.636 0.000 0.196 NA
#> SRR1562734     2  0.5761      0.658 0.000 0.620 0.000 0.196 NA
#> SRR1562735     2  0.5791      0.658 0.000 0.616 0.000 0.196 NA
#> SRR1562736     4  0.4336      0.536 0.000 0.172 0.008 0.768 NA
#> SRR1562737     4  0.4336      0.536 0.000 0.172 0.008 0.768 NA
#> SRR1562738     4  0.4336      0.536 0.000 0.172 0.008 0.768 NA
#> SRR1562739     4  0.4336      0.536 0.000 0.172 0.008 0.768 NA
#> SRR1562740     4  0.4336      0.536 0.000 0.172 0.008 0.768 NA
#> SRR1562741     4  0.4336      0.536 0.000 0.172 0.008 0.768 NA
#> SRR1562742     4  0.5725      0.462 0.000 0.240 0.020 0.648 NA
#> SRR1562743     4  0.5725      0.462 0.000 0.240 0.020 0.648 NA
#> SRR1562744     4  0.5725      0.462 0.000 0.240 0.020 0.648 NA
#> SRR1562745     4  0.5725      0.462 0.000 0.240 0.020 0.648 NA
#> SRR1562746     4  0.5725      0.462 0.000 0.240 0.020 0.648 NA
#> SRR1562747     4  0.5725      0.462 0.000 0.240 0.020 0.648 NA
#> SRR1562748     4  0.3919      0.477 0.000 0.036 0.000 0.776 NA
#> SRR1562749     4  0.3876      0.477 0.000 0.032 0.000 0.776 NA
#> SRR1562750     4  0.3919      0.477 0.000 0.036 0.000 0.776 NA
#> SRR1562751     4  0.3876      0.477 0.000 0.032 0.000 0.776 NA
#> SRR1562752     4  0.3876      0.477 0.000 0.032 0.000 0.776 NA
#> SRR1562753     4  0.3876      0.477 0.000 0.032 0.000 0.776 NA
#> SRR1562754     4  0.1836      0.556 0.000 0.036 0.000 0.932 NA
#> SRR1562755     4  0.1836      0.556 0.000 0.036 0.000 0.932 NA
#> SRR1562756     4  0.1836      0.556 0.000 0.036 0.000 0.932 NA
#> SRR1562757     4  0.1836      0.556 0.000 0.036 0.000 0.932 NA
#> SRR1562758     4  0.1836      0.556 0.000 0.036 0.000 0.932 NA
#> SRR1562759     4  0.1836      0.556 0.000 0.036 0.000 0.932 NA
#> SRR1562792     3  0.3912      0.942 0.036 0.040 0.828 0.000 NA
#> SRR1562793     3  0.3932      0.942 0.036 0.044 0.828 0.000 NA
#> SRR1562794     3  0.3912      0.942 0.036 0.040 0.828 0.000 NA
#> SRR1562795     3  0.3932      0.942 0.036 0.044 0.828 0.000 NA
#> SRR1562796     3  0.1124      0.942 0.036 0.000 0.960 0.000 NA
#> SRR1562797     3  0.1124      0.942 0.036 0.004 0.960 0.000 NA
#> SRR1562798     3  0.1124      0.942 0.036 0.000 0.960 0.000 NA
#> SRR1562799     3  0.1124      0.942 0.036 0.000 0.960 0.000 NA
#> SRR1562800     1  0.3707      0.818 0.716 0.000 0.000 0.000 NA
#> SRR1562801     1  0.3707      0.818 0.716 0.000 0.000 0.000 NA
#> SRR1562802     1  0.3838      0.819 0.716 0.004 0.000 0.000 NA
#> SRR1562803     1  0.3838      0.819 0.716 0.004 0.000 0.000 NA
#> SRR1562804     1  0.4109      0.816 0.700 0.012 0.000 0.000 NA
#> SRR1562805     1  0.4109      0.816 0.700 0.012 0.000 0.000 NA
#> SRR1562806     1  0.2729      0.826 0.884 0.056 0.000 0.000 NA
#> SRR1562807     1  0.2729      0.826 0.884 0.056 0.000 0.000 NA
#> SRR1562808     1  0.2729      0.826 0.884 0.056 0.000 0.000 NA
#> SRR1562809     1  0.2729      0.826 0.884 0.056 0.000 0.000 NA
#> SRR1562810     1  0.0162      0.849 0.996 0.000 0.000 0.000 NA
#> SRR1562811     1  0.0162      0.849 0.996 0.000 0.000 0.000 NA
#> SRR1562812     1  0.0162      0.849 0.996 0.000 0.000 0.000 NA
#> SRR1562813     1  0.0162      0.849 0.996 0.000 0.000 0.000 NA

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5 p6
#> SRR1562718     5  0.3799      0.234 0.000 0.144 0.004 0.020 0.796 NA
#> SRR1562719     5  0.3799      0.234 0.000 0.144 0.004 0.020 0.796 NA
#> SRR1562720     5  0.3799      0.234 0.000 0.144 0.004 0.020 0.796 NA
#> SRR1562721     5  0.3799      0.234 0.000 0.144 0.004 0.020 0.796 NA
#> SRR1562723     5  0.3799      0.234 0.000 0.144 0.004 0.020 0.796 NA
#> SRR1562724     5  0.1003      0.326 0.000 0.028 0.000 0.004 0.964 NA
#> SRR1562725     5  0.1003      0.326 0.000 0.028 0.000 0.004 0.964 NA
#> SRR1562726     5  0.1003      0.326 0.000 0.028 0.000 0.004 0.964 NA
#> SRR1562727     5  0.1003      0.326 0.000 0.028 0.000 0.004 0.964 NA
#> SRR1562728     5  0.1003      0.326 0.000 0.028 0.000 0.004 0.964 NA
#> SRR1562729     5  0.1003      0.326 0.000 0.028 0.000 0.004 0.964 NA
#> SRR1562730     2  0.4727      0.975 0.000 0.568 0.000 0.036 0.388 NA
#> SRR1562731     2  0.4141      0.975 0.000 0.596 0.000 0.016 0.388 NA
#> SRR1562732     2  0.5176      0.968 0.000 0.544 0.000 0.028 0.388 NA
#> SRR1562733     2  0.4921      0.974 0.000 0.560 0.000 0.028 0.388 NA
#> SRR1562734     2  0.4455      0.974 0.000 0.584 0.000 0.008 0.388 NA
#> SRR1562735     2  0.4100      0.975 0.000 0.600 0.000 0.008 0.388 NA
#> SRR1562736     5  0.6491      0.267 0.000 0.080 0.004 0.344 0.480 NA
#> SRR1562737     5  0.6491      0.267 0.000 0.080 0.004 0.344 0.480 NA
#> SRR1562738     5  0.6491      0.267 0.000 0.080 0.004 0.344 0.480 NA
#> SRR1562739     5  0.6491      0.267 0.000 0.080 0.004 0.344 0.480 NA
#> SRR1562740     5  0.6491      0.267 0.000 0.080 0.004 0.344 0.480 NA
#> SRR1562741     5  0.6491      0.267 0.000 0.080 0.004 0.344 0.480 NA
#> SRR1562742     5  0.6997      0.319 0.000 0.160 0.000 0.364 0.380 NA
#> SRR1562743     5  0.6997      0.319 0.000 0.160 0.000 0.364 0.380 NA
#> SRR1562744     5  0.6997      0.319 0.000 0.160 0.000 0.364 0.380 NA
#> SRR1562745     5  0.6997      0.319 0.000 0.160 0.000 0.364 0.380 NA
#> SRR1562746     5  0.6997      0.319 0.000 0.160 0.000 0.364 0.380 NA
#> SRR1562747     5  0.6997      0.319 0.000 0.160 0.000 0.364 0.380 NA
#> SRR1562748     4  0.6292      0.672 0.000 0.064 0.000 0.552 0.148 NA
#> SRR1562749     4  0.6273      0.673 0.000 0.064 0.000 0.556 0.148 NA
#> SRR1562750     4  0.6262      0.673 0.000 0.060 0.000 0.552 0.148 NA
#> SRR1562751     4  0.6292      0.672 0.000 0.064 0.000 0.552 0.148 NA
#> SRR1562752     4  0.6292      0.672 0.000 0.064 0.000 0.552 0.148 NA
#> SRR1562753     4  0.6292      0.672 0.000 0.064 0.000 0.552 0.148 NA
#> SRR1562754     4  0.3394      0.604 0.000 0.012 0.000 0.752 0.236 NA
#> SRR1562755     4  0.3483      0.604 0.000 0.016 0.000 0.748 0.236 NA
#> SRR1562756     4  0.3394      0.604 0.000 0.012 0.000 0.752 0.236 NA
#> SRR1562757     4  0.3483      0.604 0.000 0.016 0.000 0.748 0.236 NA
#> SRR1562758     4  0.3483      0.604 0.000 0.016 0.000 0.748 0.236 NA
#> SRR1562759     4  0.3394      0.604 0.000 0.012 0.000 0.752 0.236 NA
#> SRR1562792     3  0.0551      0.905 0.008 0.000 0.984 0.004 0.000 NA
#> SRR1562793     3  0.0551      0.905 0.008 0.004 0.984 0.000 0.000 NA
#> SRR1562794     3  0.0520      0.905 0.008 0.000 0.984 0.008 0.000 NA
#> SRR1562795     3  0.0551      0.905 0.008 0.004 0.984 0.004 0.000 NA
#> SRR1562796     3  0.4069      0.906 0.008 0.064 0.776 0.008 0.000 NA
#> SRR1562797     3  0.4069      0.906 0.008 0.064 0.776 0.008 0.000 NA
#> SRR1562798     3  0.4069      0.906 0.008 0.064 0.776 0.008 0.000 NA
#> SRR1562799     3  0.4069      0.906 0.008 0.064 0.776 0.008 0.000 NA
#> SRR1562800     1  0.3592      0.780 0.656 0.000 0.000 0.000 0.000 NA
#> SRR1562801     1  0.3592      0.780 0.656 0.000 0.000 0.000 0.000 NA
#> SRR1562802     1  0.3607      0.780 0.652 0.000 0.000 0.000 0.000 NA
#> SRR1562803     1  0.3607      0.780 0.652 0.000 0.000 0.000 0.000 NA
#> SRR1562804     1  0.4513      0.778 0.636 0.016 0.000 0.024 0.000 NA
#> SRR1562805     1  0.4513      0.778 0.636 0.016 0.000 0.024 0.000 NA
#> SRR1562806     1  0.3324      0.788 0.840 0.080 0.000 0.020 0.000 NA
#> SRR1562807     1  0.3324      0.788 0.840 0.080 0.000 0.020 0.000 NA
#> SRR1562808     1  0.3324      0.788 0.840 0.080 0.000 0.020 0.000 NA
#> SRR1562809     1  0.3324      0.788 0.840 0.080 0.000 0.020 0.000 NA
#> SRR1562810     1  0.0405      0.813 0.988 0.000 0.000 0.004 0.000 NA
#> SRR1562811     1  0.0405      0.813 0.988 0.000 0.000 0.004 0.000 NA
#> SRR1562812     1  0.0405      0.813 0.988 0.000 0.000 0.004 0.000 NA
#> SRR1562813     1  0.0405      0.813 0.988 0.000 0.000 0.004 0.000 NA

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-kmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-kmeans-collect-classes

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


CV:skmeans**

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

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

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

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

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

collect_plots(res)

plot of chunk CV-skmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4624 0.538   0.538
#> 3 3 1.000           0.991       0.988         0.1327 0.943   0.893
#> 4 4 0.751           0.882       0.918         0.3110 0.822   0.629
#> 5 5 0.791           0.838       0.878         0.1140 0.840   0.529
#> 6 6 0.813           0.724       0.855         0.0566 0.892   0.576

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
#> SRR1562718     2       0          1  0  1
#> SRR1562719     2       0          1  0  1
#> SRR1562720     2       0          1  0  1
#> SRR1562721     2       0          1  0  1
#> SRR1562723     2       0          1  0  1
#> SRR1562724     2       0          1  0  1
#> SRR1562725     2       0          1  0  1
#> SRR1562726     2       0          1  0  1
#> SRR1562727     2       0          1  0  1
#> SRR1562728     2       0          1  0  1
#> SRR1562729     2       0          1  0  1
#> SRR1562730     2       0          1  0  1
#> SRR1562731     2       0          1  0  1
#> SRR1562732     2       0          1  0  1
#> SRR1562733     2       0          1  0  1
#> SRR1562734     2       0          1  0  1
#> SRR1562735     2       0          1  0  1
#> SRR1562736     2       0          1  0  1
#> SRR1562737     2       0          1  0  1
#> SRR1562738     2       0          1  0  1
#> SRR1562739     2       0          1  0  1
#> SRR1562740     2       0          1  0  1
#> SRR1562741     2       0          1  0  1
#> SRR1562742     2       0          1  0  1
#> SRR1562743     2       0          1  0  1
#> SRR1562744     2       0          1  0  1
#> SRR1562745     2       0          1  0  1
#> SRR1562746     2       0          1  0  1
#> SRR1562747     2       0          1  0  1
#> SRR1562748     2       0          1  0  1
#> SRR1562749     2       0          1  0  1
#> SRR1562750     2       0          1  0  1
#> SRR1562751     2       0          1  0  1
#> SRR1562752     2       0          1  0  1
#> SRR1562753     2       0          1  0  1
#> SRR1562754     2       0          1  0  1
#> SRR1562755     2       0          1  0  1
#> SRR1562756     2       0          1  0  1
#> SRR1562757     2       0          1  0  1
#> SRR1562758     2       0          1  0  1
#> SRR1562759     2       0          1  0  1
#> SRR1562792     1       0          1  1  0
#> SRR1562793     1       0          1  1  0
#> SRR1562794     1       0          1  1  0
#> SRR1562795     1       0          1  1  0
#> SRR1562796     1       0          1  1  0
#> SRR1562797     1       0          1  1  0
#> SRR1562798     1       0          1  1  0
#> SRR1562799     1       0          1  1  0
#> SRR1562800     1       0          1  1  0
#> SRR1562801     1       0          1  1  0
#> SRR1562802     1       0          1  1  0
#> SRR1562803     1       0          1  1  0
#> SRR1562804     1       0          1  1  0
#> SRR1562805     1       0          1  1  0
#> SRR1562806     1       0          1  1  0
#> SRR1562807     1       0          1  1  0
#> SRR1562808     1       0          1  1  0
#> SRR1562809     1       0          1  1  0
#> SRR1562810     1       0          1  1  0
#> SRR1562811     1       0          1  1  0
#> SRR1562812     1       0          1  1  0
#> SRR1562813     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette   p1    p2    p3
#> SRR1562718     2  0.0000      0.990 0.00 1.000 0.000
#> SRR1562719     2  0.0000      0.990 0.00 1.000 0.000
#> SRR1562720     2  0.0000      0.990 0.00 1.000 0.000
#> SRR1562721     2  0.0000      0.990 0.00 1.000 0.000
#> SRR1562723     2  0.0000      0.990 0.00 1.000 0.000
#> SRR1562724     2  0.0000      0.990 0.00 1.000 0.000
#> SRR1562725     2  0.0000      0.990 0.00 1.000 0.000
#> SRR1562726     2  0.0000      0.990 0.00 1.000 0.000
#> SRR1562727     2  0.0000      0.990 0.00 1.000 0.000
#> SRR1562728     2  0.0000      0.990 0.00 1.000 0.000
#> SRR1562729     2  0.0000      0.990 0.00 1.000 0.000
#> SRR1562730     2  0.0237      0.989 0.00 0.996 0.004
#> SRR1562731     2  0.0237      0.989 0.00 0.996 0.004
#> SRR1562732     2  0.0237      0.989 0.00 0.996 0.004
#> SRR1562733     2  0.0237      0.989 0.00 0.996 0.004
#> SRR1562734     2  0.0237      0.989 0.00 0.996 0.004
#> SRR1562735     2  0.0237      0.989 0.00 0.996 0.004
#> SRR1562736     2  0.0000      0.990 0.00 1.000 0.000
#> SRR1562737     2  0.0000      0.990 0.00 1.000 0.000
#> SRR1562738     2  0.0000      0.990 0.00 1.000 0.000
#> SRR1562739     2  0.0000      0.990 0.00 1.000 0.000
#> SRR1562740     2  0.0000      0.990 0.00 1.000 0.000
#> SRR1562741     2  0.0000      0.990 0.00 1.000 0.000
#> SRR1562742     2  0.0000      0.990 0.00 1.000 0.000
#> SRR1562743     2  0.0000      0.990 0.00 1.000 0.000
#> SRR1562744     2  0.0000      0.990 0.00 1.000 0.000
#> SRR1562745     2  0.0000      0.990 0.00 1.000 0.000
#> SRR1562746     2  0.0000      0.990 0.00 1.000 0.000
#> SRR1562747     2  0.0000      0.990 0.00 1.000 0.000
#> SRR1562748     2  0.1411      0.976 0.00 0.964 0.036
#> SRR1562749     2  0.1411      0.976 0.00 0.964 0.036
#> SRR1562750     2  0.1411      0.976 0.00 0.964 0.036
#> SRR1562751     2  0.1411      0.976 0.00 0.964 0.036
#> SRR1562752     2  0.1411      0.976 0.00 0.964 0.036
#> SRR1562753     2  0.1411      0.976 0.00 0.964 0.036
#> SRR1562754     2  0.1289      0.978 0.00 0.968 0.032
#> SRR1562755     2  0.1289      0.978 0.00 0.968 0.032
#> SRR1562756     2  0.1289      0.978 0.00 0.968 0.032
#> SRR1562757     2  0.1289      0.978 0.00 0.968 0.032
#> SRR1562758     2  0.1289      0.978 0.00 0.968 0.032
#> SRR1562759     2  0.1289      0.978 0.00 0.968 0.032
#> SRR1562792     3  0.1529      1.000 0.04 0.000 0.960
#> SRR1562793     3  0.1529      1.000 0.04 0.000 0.960
#> SRR1562794     3  0.1529      1.000 0.04 0.000 0.960
#> SRR1562795     3  0.1529      1.000 0.04 0.000 0.960
#> SRR1562796     3  0.1529      1.000 0.04 0.000 0.960
#> SRR1562797     3  0.1529      1.000 0.04 0.000 0.960
#> SRR1562798     3  0.1529      1.000 0.04 0.000 0.960
#> SRR1562799     3  0.1529      1.000 0.04 0.000 0.960
#> SRR1562800     1  0.0000      1.000 1.00 0.000 0.000
#> SRR1562801     1  0.0000      1.000 1.00 0.000 0.000
#> SRR1562802     1  0.0000      1.000 1.00 0.000 0.000
#> SRR1562803     1  0.0000      1.000 1.00 0.000 0.000
#> SRR1562804     1  0.0000      1.000 1.00 0.000 0.000
#> SRR1562805     1  0.0000      1.000 1.00 0.000 0.000
#> SRR1562806     1  0.0000      1.000 1.00 0.000 0.000
#> SRR1562807     1  0.0000      1.000 1.00 0.000 0.000
#> SRR1562808     1  0.0000      1.000 1.00 0.000 0.000
#> SRR1562809     1  0.0000      1.000 1.00 0.000 0.000
#> SRR1562810     1  0.0000      1.000 1.00 0.000 0.000
#> SRR1562811     1  0.0000      1.000 1.00 0.000 0.000
#> SRR1562812     1  0.0000      1.000 1.00 0.000 0.000
#> SRR1562813     1  0.0000      1.000 1.00 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
#> SRR1562718     2  0.0188      0.860 0.000 0.996 0.000 0.004
#> SRR1562719     2  0.0188      0.860 0.000 0.996 0.000 0.004
#> SRR1562720     2  0.0188      0.860 0.000 0.996 0.000 0.004
#> SRR1562721     2  0.0188      0.860 0.000 0.996 0.000 0.004
#> SRR1562723     2  0.0188      0.860 0.000 0.996 0.000 0.004
#> SRR1562724     2  0.0469      0.860 0.000 0.988 0.000 0.012
#> SRR1562725     2  0.0469      0.860 0.000 0.988 0.000 0.012
#> SRR1562726     2  0.0469      0.860 0.000 0.988 0.000 0.012
#> SRR1562727     2  0.0469      0.860 0.000 0.988 0.000 0.012
#> SRR1562728     2  0.0469      0.860 0.000 0.988 0.000 0.012
#> SRR1562729     2  0.0469      0.860 0.000 0.988 0.000 0.012
#> SRR1562730     2  0.1902      0.826 0.000 0.932 0.004 0.064
#> SRR1562731     2  0.1902      0.826 0.000 0.932 0.004 0.064
#> SRR1562732     2  0.1902      0.826 0.000 0.932 0.004 0.064
#> SRR1562733     2  0.1902      0.826 0.000 0.932 0.004 0.064
#> SRR1562734     2  0.1902      0.826 0.000 0.932 0.004 0.064
#> SRR1562735     2  0.1902      0.826 0.000 0.932 0.004 0.064
#> SRR1562736     2  0.3982      0.767 0.000 0.776 0.004 0.220
#> SRR1562737     2  0.3982      0.767 0.000 0.776 0.004 0.220
#> SRR1562738     2  0.3982      0.767 0.000 0.776 0.004 0.220
#> SRR1562739     2  0.3982      0.767 0.000 0.776 0.004 0.220
#> SRR1562740     2  0.3982      0.767 0.000 0.776 0.004 0.220
#> SRR1562741     2  0.3982      0.767 0.000 0.776 0.004 0.220
#> SRR1562742     2  0.3626      0.799 0.000 0.812 0.004 0.184
#> SRR1562743     2  0.3626      0.799 0.000 0.812 0.004 0.184
#> SRR1562744     2  0.3626      0.799 0.000 0.812 0.004 0.184
#> SRR1562745     2  0.3626      0.799 0.000 0.812 0.004 0.184
#> SRR1562746     2  0.3626      0.799 0.000 0.812 0.004 0.184
#> SRR1562747     2  0.3626      0.799 0.000 0.812 0.004 0.184
#> SRR1562748     4  0.1970      0.826 0.000 0.060 0.008 0.932
#> SRR1562749     4  0.1970      0.826 0.000 0.060 0.008 0.932
#> SRR1562750     4  0.1970      0.826 0.000 0.060 0.008 0.932
#> SRR1562751     4  0.1970      0.826 0.000 0.060 0.008 0.932
#> SRR1562752     4  0.1970      0.826 0.000 0.060 0.008 0.932
#> SRR1562753     4  0.1970      0.826 0.000 0.060 0.008 0.932
#> SRR1562754     4  0.4222      0.801 0.000 0.272 0.000 0.728
#> SRR1562755     4  0.4222      0.801 0.000 0.272 0.000 0.728
#> SRR1562756     4  0.4222      0.801 0.000 0.272 0.000 0.728
#> SRR1562757     4  0.4222      0.801 0.000 0.272 0.000 0.728
#> SRR1562758     4  0.4222      0.801 0.000 0.272 0.000 0.728
#> SRR1562759     4  0.4222      0.801 0.000 0.272 0.000 0.728
#> SRR1562792     3  0.0592      1.000 0.016 0.000 0.984 0.000
#> SRR1562793     3  0.0592      1.000 0.016 0.000 0.984 0.000
#> SRR1562794     3  0.0592      1.000 0.016 0.000 0.984 0.000
#> SRR1562795     3  0.0592      1.000 0.016 0.000 0.984 0.000
#> SRR1562796     3  0.0592      1.000 0.016 0.000 0.984 0.000
#> SRR1562797     3  0.0592      1.000 0.016 0.000 0.984 0.000
#> SRR1562798     3  0.0592      1.000 0.016 0.000 0.984 0.000
#> SRR1562799     3  0.0592      1.000 0.016 0.000 0.984 0.000
#> SRR1562800     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1562801     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1562802     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1562803     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1562804     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1562805     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1562806     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1562807     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1562808     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1562809     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1562810     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1562811     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1562812     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1562813     1  0.0000      1.000 1.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2 p3    p4    p5
#> SRR1562718     2  0.4101      0.735 0.000 0.628  0 0.000 0.372
#> SRR1562719     2  0.4101      0.735 0.000 0.628  0 0.000 0.372
#> SRR1562720     2  0.4101      0.735 0.000 0.628  0 0.000 0.372
#> SRR1562721     2  0.4101      0.735 0.000 0.628  0 0.000 0.372
#> SRR1562723     2  0.4101      0.735 0.000 0.628  0 0.000 0.372
#> SRR1562724     2  0.4639      0.736 0.000 0.612  0 0.020 0.368
#> SRR1562725     2  0.4639      0.736 0.000 0.612  0 0.020 0.368
#> SRR1562726     2  0.4639      0.736 0.000 0.612  0 0.020 0.368
#> SRR1562727     2  0.4639      0.736 0.000 0.612  0 0.020 0.368
#> SRR1562728     2  0.4639      0.736 0.000 0.612  0 0.020 0.368
#> SRR1562729     2  0.4639      0.736 0.000 0.612  0 0.020 0.368
#> SRR1562730     2  0.0566      0.653 0.000 0.984  0 0.012 0.004
#> SRR1562731     2  0.0566      0.653 0.000 0.984  0 0.012 0.004
#> SRR1562732     2  0.0566      0.653 0.000 0.984  0 0.012 0.004
#> SRR1562733     2  0.0566      0.653 0.000 0.984  0 0.012 0.004
#> SRR1562734     2  0.0566      0.653 0.000 0.984  0 0.012 0.004
#> SRR1562735     2  0.0566      0.653 0.000 0.984  0 0.012 0.004
#> SRR1562736     5  0.3281      0.773 0.000 0.092  0 0.060 0.848
#> SRR1562737     5  0.3281      0.773 0.000 0.092  0 0.060 0.848
#> SRR1562738     5  0.3281      0.773 0.000 0.092  0 0.060 0.848
#> SRR1562739     5  0.3281      0.773 0.000 0.092  0 0.060 0.848
#> SRR1562740     5  0.3281      0.773 0.000 0.092  0 0.060 0.848
#> SRR1562741     5  0.3281      0.773 0.000 0.092  0 0.060 0.848
#> SRR1562742     5  0.2074      0.761 0.000 0.104  0 0.000 0.896
#> SRR1562743     5  0.2074      0.761 0.000 0.104  0 0.000 0.896
#> SRR1562744     5  0.2074      0.761 0.000 0.104  0 0.000 0.896
#> SRR1562745     5  0.2074      0.761 0.000 0.104  0 0.000 0.896
#> SRR1562746     5  0.2074      0.761 0.000 0.104  0 0.000 0.896
#> SRR1562747     5  0.2074      0.761 0.000 0.104  0 0.000 0.896
#> SRR1562748     4  0.0510      1.000 0.000 0.000  0 0.984 0.016
#> SRR1562749     4  0.0510      1.000 0.000 0.000  0 0.984 0.016
#> SRR1562750     4  0.0510      1.000 0.000 0.000  0 0.984 0.016
#> SRR1562751     4  0.0510      1.000 0.000 0.000  0 0.984 0.016
#> SRR1562752     4  0.0510      1.000 0.000 0.000  0 0.984 0.016
#> SRR1562753     4  0.0510      1.000 0.000 0.000  0 0.984 0.016
#> SRR1562754     5  0.3980      0.602 0.000 0.008  0 0.284 0.708
#> SRR1562755     5  0.3980      0.602 0.000 0.008  0 0.284 0.708
#> SRR1562756     5  0.3980      0.602 0.000 0.008  0 0.284 0.708
#> SRR1562757     5  0.3980      0.602 0.000 0.008  0 0.284 0.708
#> SRR1562758     5  0.3980      0.602 0.000 0.008  0 0.284 0.708
#> SRR1562759     5  0.3980      0.602 0.000 0.008  0 0.284 0.708
#> SRR1562792     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1562793     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1562794     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1562795     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1562796     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1562797     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1562798     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1562799     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1562800     1  0.0162      0.998 0.996 0.000  0 0.004 0.000
#> SRR1562801     1  0.0162      0.998 0.996 0.000  0 0.004 0.000
#> SRR1562802     1  0.0162      0.998 0.996 0.000  0 0.004 0.000
#> SRR1562803     1  0.0162      0.998 0.996 0.000  0 0.004 0.000
#> SRR1562804     1  0.0162      0.998 0.996 0.000  0 0.004 0.000
#> SRR1562805     1  0.0162      0.998 0.996 0.000  0 0.004 0.000
#> SRR1562806     1  0.0000      0.998 1.000 0.000  0 0.000 0.000
#> SRR1562807     1  0.0000      0.998 1.000 0.000  0 0.000 0.000
#> SRR1562808     1  0.0000      0.998 1.000 0.000  0 0.000 0.000
#> SRR1562809     1  0.0000      0.998 1.000 0.000  0 0.000 0.000
#> SRR1562810     1  0.0000      0.998 1.000 0.000  0 0.000 0.000
#> SRR1562811     1  0.0000      0.998 1.000 0.000  0 0.000 0.000
#> SRR1562812     1  0.0000      0.998 1.000 0.000  0 0.000 0.000
#> SRR1562813     1  0.0000      0.998 1.000 0.000  0 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette p1    p2 p3    p4    p5    p6
#> SRR1562718     2  0.5022     0.0153  0 0.496  0 0.000 0.432 0.072
#> SRR1562719     2  0.5022     0.0153  0 0.496  0 0.000 0.432 0.072
#> SRR1562720     2  0.5022     0.0153  0 0.496  0 0.000 0.432 0.072
#> SRR1562721     2  0.5022     0.0153  0 0.496  0 0.000 0.432 0.072
#> SRR1562723     2  0.5022     0.0153  0 0.496  0 0.000 0.432 0.072
#> SRR1562724     5  0.4902     0.0855  0 0.460  0 0.000 0.480 0.060
#> SRR1562725     5  0.4902     0.0855  0 0.460  0 0.000 0.480 0.060
#> SRR1562726     5  0.4902     0.0855  0 0.460  0 0.000 0.480 0.060
#> SRR1562727     5  0.4902     0.0855  0 0.460  0 0.000 0.480 0.060
#> SRR1562728     5  0.4902     0.0855  0 0.460  0 0.000 0.480 0.060
#> SRR1562729     5  0.4902     0.0855  0 0.460  0 0.000 0.480 0.060
#> SRR1562730     2  0.2697     0.5692  0 0.812  0 0.000 0.000 0.188
#> SRR1562731     2  0.2697     0.5692  0 0.812  0 0.000 0.000 0.188
#> SRR1562732     2  0.2697     0.5692  0 0.812  0 0.000 0.000 0.188
#> SRR1562733     2  0.2697     0.5692  0 0.812  0 0.000 0.000 0.188
#> SRR1562734     2  0.2697     0.5692  0 0.812  0 0.000 0.000 0.188
#> SRR1562735     2  0.2697     0.5692  0 0.812  0 0.000 0.000 0.188
#> SRR1562736     5  0.0725     0.6613  0 0.000  0 0.012 0.976 0.012
#> SRR1562737     5  0.0725     0.6613  0 0.000  0 0.012 0.976 0.012
#> SRR1562738     5  0.0725     0.6613  0 0.000  0 0.012 0.976 0.012
#> SRR1562739     5  0.0725     0.6613  0 0.000  0 0.012 0.976 0.012
#> SRR1562740     5  0.0725     0.6613  0 0.000  0 0.012 0.976 0.012
#> SRR1562741     5  0.0725     0.6613  0 0.000  0 0.012 0.976 0.012
#> SRR1562742     5  0.2278     0.6113  0 0.004  0 0.000 0.868 0.128
#> SRR1562743     5  0.2278     0.6113  0 0.004  0 0.000 0.868 0.128
#> SRR1562744     5  0.2278     0.6113  0 0.004  0 0.000 0.868 0.128
#> SRR1562745     5  0.2278     0.6113  0 0.004  0 0.000 0.868 0.128
#> SRR1562746     5  0.2278     0.6113  0 0.004  0 0.000 0.868 0.128
#> SRR1562747     5  0.2278     0.6113  0 0.004  0 0.000 0.868 0.128
#> SRR1562748     4  0.0000     1.0000  0 0.000  0 1.000 0.000 0.000
#> SRR1562749     4  0.0000     1.0000  0 0.000  0 1.000 0.000 0.000
#> SRR1562750     4  0.0000     1.0000  0 0.000  0 1.000 0.000 0.000
#> SRR1562751     4  0.0000     1.0000  0 0.000  0 1.000 0.000 0.000
#> SRR1562752     4  0.0000     1.0000  0 0.000  0 1.000 0.000 0.000
#> SRR1562753     4  0.0000     1.0000  0 0.000  0 1.000 0.000 0.000
#> SRR1562754     6  0.4011     1.0000  0 0.000  0 0.060 0.204 0.736
#> SRR1562755     6  0.4011     1.0000  0 0.000  0 0.060 0.204 0.736
#> SRR1562756     6  0.4011     1.0000  0 0.000  0 0.060 0.204 0.736
#> SRR1562757     6  0.4011     1.0000  0 0.000  0 0.060 0.204 0.736
#> SRR1562758     6  0.4011     1.0000  0 0.000  0 0.060 0.204 0.736
#> SRR1562759     6  0.4011     1.0000  0 0.000  0 0.060 0.204 0.736
#> SRR1562792     3  0.0000     1.0000  0 0.000  1 0.000 0.000 0.000
#> SRR1562793     3  0.0000     1.0000  0 0.000  1 0.000 0.000 0.000
#> SRR1562794     3  0.0000     1.0000  0 0.000  1 0.000 0.000 0.000
#> SRR1562795     3  0.0000     1.0000  0 0.000  1 0.000 0.000 0.000
#> SRR1562796     3  0.0000     1.0000  0 0.000  1 0.000 0.000 0.000
#> SRR1562797     3  0.0000     1.0000  0 0.000  1 0.000 0.000 0.000
#> SRR1562798     3  0.0000     1.0000  0 0.000  1 0.000 0.000 0.000
#> SRR1562799     3  0.0000     1.0000  0 0.000  1 0.000 0.000 0.000
#> SRR1562800     1  0.0000     1.0000  1 0.000  0 0.000 0.000 0.000
#> SRR1562801     1  0.0000     1.0000  1 0.000  0 0.000 0.000 0.000
#> SRR1562802     1  0.0000     1.0000  1 0.000  0 0.000 0.000 0.000
#> SRR1562803     1  0.0000     1.0000  1 0.000  0 0.000 0.000 0.000
#> SRR1562804     1  0.0000     1.0000  1 0.000  0 0.000 0.000 0.000
#> SRR1562805     1  0.0000     1.0000  1 0.000  0 0.000 0.000 0.000
#> SRR1562806     1  0.0000     1.0000  1 0.000  0 0.000 0.000 0.000
#> SRR1562807     1  0.0000     1.0000  1 0.000  0 0.000 0.000 0.000
#> SRR1562808     1  0.0000     1.0000  1 0.000  0 0.000 0.000 0.000
#> SRR1562809     1  0.0000     1.0000  1 0.000  0 0.000 0.000 0.000
#> SRR1562810     1  0.0000     1.0000  1 0.000  0 0.000 0.000 0.000
#> SRR1562811     1  0.0000     1.0000  1 0.000  0 0.000 0.000 0.000
#> SRR1562812     1  0.0000     1.0000  1 0.000  0 0.000 0.000 0.000
#> SRR1562813     1  0.0000     1.0000  1 0.000  0 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-skmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-skmeans-collect-classes

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


CV:pam*

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

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

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

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

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

collect_plots(res)

plot of chunk CV-pam-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.986       0.992         0.3587 0.649   0.649
#> 3 3 1.000           1.000       1.000         0.4488 0.832   0.741
#> 4 4 0.822           0.949       0.957         0.2085 0.892   0.776
#> 5 5 0.797           0.919       0.929         0.0615 0.975   0.934
#> 6 6 0.910           0.955       0.955         0.1319 0.911   0.744

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette    p1    p2
#> SRR1562718     2   0.000      0.990 0.000 1.000
#> SRR1562719     2   0.000      0.990 0.000 1.000
#> SRR1562720     2   0.000      0.990 0.000 1.000
#> SRR1562721     2   0.000      0.990 0.000 1.000
#> SRR1562723     2   0.000      0.990 0.000 1.000
#> SRR1562724     2   0.000      0.990 0.000 1.000
#> SRR1562725     2   0.000      0.990 0.000 1.000
#> SRR1562726     2   0.000      0.990 0.000 1.000
#> SRR1562727     2   0.000      0.990 0.000 1.000
#> SRR1562728     2   0.000      0.990 0.000 1.000
#> SRR1562729     2   0.000      0.990 0.000 1.000
#> SRR1562730     2   0.000      0.990 0.000 1.000
#> SRR1562731     2   0.000      0.990 0.000 1.000
#> SRR1562732     2   0.000      0.990 0.000 1.000
#> SRR1562733     2   0.000      0.990 0.000 1.000
#> SRR1562734     2   0.000      0.990 0.000 1.000
#> SRR1562735     2   0.000      0.990 0.000 1.000
#> SRR1562736     2   0.000      0.990 0.000 1.000
#> SRR1562737     2   0.000      0.990 0.000 1.000
#> SRR1562738     2   0.000      0.990 0.000 1.000
#> SRR1562739     2   0.000      0.990 0.000 1.000
#> SRR1562740     2   0.000      0.990 0.000 1.000
#> SRR1562741     2   0.000      0.990 0.000 1.000
#> SRR1562742     2   0.000      0.990 0.000 1.000
#> SRR1562743     2   0.000      0.990 0.000 1.000
#> SRR1562744     2   0.000      0.990 0.000 1.000
#> SRR1562745     2   0.000      0.990 0.000 1.000
#> SRR1562746     2   0.000      0.990 0.000 1.000
#> SRR1562747     2   0.000      0.990 0.000 1.000
#> SRR1562748     2   0.000      0.990 0.000 1.000
#> SRR1562749     2   0.000      0.990 0.000 1.000
#> SRR1562750     2   0.000      0.990 0.000 1.000
#> SRR1562751     2   0.000      0.990 0.000 1.000
#> SRR1562752     2   0.000      0.990 0.000 1.000
#> SRR1562753     2   0.000      0.990 0.000 1.000
#> SRR1562754     2   0.000      0.990 0.000 1.000
#> SRR1562755     2   0.000      0.990 0.000 1.000
#> SRR1562756     2   0.000      0.990 0.000 1.000
#> SRR1562757     2   0.000      0.990 0.000 1.000
#> SRR1562758     2   0.000      0.990 0.000 1.000
#> SRR1562759     2   0.000      0.990 0.000 1.000
#> SRR1562792     2   0.204      0.967 0.032 0.968
#> SRR1562793     2   0.260      0.958 0.044 0.956
#> SRR1562794     2   0.260      0.958 0.044 0.956
#> SRR1562795     2   0.278      0.954 0.048 0.952
#> SRR1562796     2   0.388      0.929 0.076 0.924
#> SRR1562797     2   0.402      0.925 0.080 0.920
#> SRR1562798     2   0.388      0.929 0.076 0.924
#> SRR1562799     2   0.388      0.929 0.076 0.924
#> SRR1562800     1   0.000      1.000 1.000 0.000
#> SRR1562801     1   0.000      1.000 1.000 0.000
#> SRR1562802     1   0.000      1.000 1.000 0.000
#> SRR1562803     1   0.000      1.000 1.000 0.000
#> SRR1562804     1   0.000      1.000 1.000 0.000
#> SRR1562805     1   0.000      1.000 1.000 0.000
#> SRR1562806     1   0.000      1.000 1.000 0.000
#> SRR1562807     1   0.000      1.000 1.000 0.000
#> SRR1562808     1   0.000      1.000 1.000 0.000
#> SRR1562809     1   0.000      1.000 1.000 0.000
#> SRR1562810     1   0.000      1.000 1.000 0.000
#> SRR1562811     1   0.000      1.000 1.000 0.000
#> SRR1562812     1   0.000      1.000 1.000 0.000
#> SRR1562813     1   0.000      1.000 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
#> SRR1562718     2       0          1  0  1  0
#> SRR1562719     2       0          1  0  1  0
#> SRR1562720     2       0          1  0  1  0
#> SRR1562721     2       0          1  0  1  0
#> SRR1562723     2       0          1  0  1  0
#> SRR1562724     2       0          1  0  1  0
#> SRR1562725     2       0          1  0  1  0
#> SRR1562726     2       0          1  0  1  0
#> SRR1562727     2       0          1  0  1  0
#> SRR1562728     2       0          1  0  1  0
#> SRR1562729     2       0          1  0  1  0
#> SRR1562730     2       0          1  0  1  0
#> SRR1562731     2       0          1  0  1  0
#> SRR1562732     2       0          1  0  1  0
#> SRR1562733     2       0          1  0  1  0
#> SRR1562734     2       0          1  0  1  0
#> SRR1562735     2       0          1  0  1  0
#> SRR1562736     2       0          1  0  1  0
#> SRR1562737     2       0          1  0  1  0
#> SRR1562738     2       0          1  0  1  0
#> SRR1562739     2       0          1  0  1  0
#> SRR1562740     2       0          1  0  1  0
#> SRR1562741     2       0          1  0  1  0
#> SRR1562742     2       0          1  0  1  0
#> SRR1562743     2       0          1  0  1  0
#> SRR1562744     2       0          1  0  1  0
#> SRR1562745     2       0          1  0  1  0
#> SRR1562746     2       0          1  0  1  0
#> SRR1562747     2       0          1  0  1  0
#> SRR1562748     2       0          1  0  1  0
#> SRR1562749     2       0          1  0  1  0
#> SRR1562750     2       0          1  0  1  0
#> SRR1562751     2       0          1  0  1  0
#> SRR1562752     2       0          1  0  1  0
#> SRR1562753     2       0          1  0  1  0
#> SRR1562754     2       0          1  0  1  0
#> SRR1562755     2       0          1  0  1  0
#> SRR1562756     2       0          1  0  1  0
#> SRR1562757     2       0          1  0  1  0
#> SRR1562758     2       0          1  0  1  0
#> SRR1562759     2       0          1  0  1  0
#> SRR1562792     3       0          1  0  0  1
#> SRR1562793     3       0          1  0  0  1
#> SRR1562794     3       0          1  0  0  1
#> SRR1562795     3       0          1  0  0  1
#> SRR1562796     3       0          1  0  0  1
#> SRR1562797     3       0          1  0  0  1
#> SRR1562798     3       0          1  0  0  1
#> SRR1562799     3       0          1  0  0  1
#> SRR1562800     1       0          1  1  0  0
#> SRR1562801     1       0          1  1  0  0
#> SRR1562802     1       0          1  1  0  0
#> SRR1562803     1       0          1  1  0  0
#> SRR1562804     1       0          1  1  0  0
#> SRR1562805     1       0          1  1  0  0
#> SRR1562806     1       0          1  1  0  0
#> SRR1562807     1       0          1  1  0  0
#> SRR1562808     1       0          1  1  0  0
#> SRR1562809     1       0          1  1  0  0
#> SRR1562810     1       0          1  1  0  0
#> SRR1562811     1       0          1  1  0  0
#> SRR1562812     1       0          1  1  0  0
#> SRR1562813     1       0          1  1  0  0

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2 p3    p4
#> SRR1562718     2  0.0000      0.954 0.000 1.000  0 0.000
#> SRR1562719     2  0.0000      0.954 0.000 1.000  0 0.000
#> SRR1562720     2  0.0000      0.954 0.000 1.000  0 0.000
#> SRR1562721     2  0.0000      0.954 0.000 1.000  0 0.000
#> SRR1562723     2  0.0000      0.954 0.000 1.000  0 0.000
#> SRR1562724     2  0.0000      0.954 0.000 1.000  0 0.000
#> SRR1562725     2  0.0000      0.954 0.000 1.000  0 0.000
#> SRR1562726     2  0.0000      0.954 0.000 1.000  0 0.000
#> SRR1562727     2  0.0000      0.954 0.000 1.000  0 0.000
#> SRR1562728     2  0.0000      0.954 0.000 1.000  0 0.000
#> SRR1562729     2  0.0000      0.954 0.000 1.000  0 0.000
#> SRR1562730     2  0.3024      0.826 0.000 0.852  0 0.148
#> SRR1562731     2  0.3024      0.826 0.000 0.852  0 0.148
#> SRR1562732     2  0.3024      0.826 0.000 0.852  0 0.148
#> SRR1562733     2  0.3024      0.826 0.000 0.852  0 0.148
#> SRR1562734     2  0.3024      0.826 0.000 0.852  0 0.148
#> SRR1562735     2  0.3024      0.826 0.000 0.852  0 0.148
#> SRR1562736     2  0.0000      0.954 0.000 1.000  0 0.000
#> SRR1562737     2  0.0000      0.954 0.000 1.000  0 0.000
#> SRR1562738     2  0.0000      0.954 0.000 1.000  0 0.000
#> SRR1562739     2  0.0000      0.954 0.000 1.000  0 0.000
#> SRR1562740     2  0.0000      0.954 0.000 1.000  0 0.000
#> SRR1562741     2  0.0000      0.954 0.000 1.000  0 0.000
#> SRR1562742     2  0.0000      0.954 0.000 1.000  0 0.000
#> SRR1562743     2  0.0000      0.954 0.000 1.000  0 0.000
#> SRR1562744     2  0.0000      0.954 0.000 1.000  0 0.000
#> SRR1562745     2  0.0000      0.954 0.000 1.000  0 0.000
#> SRR1562746     2  0.0000      0.954 0.000 1.000  0 0.000
#> SRR1562747     2  0.0000      0.954 0.000 1.000  0 0.000
#> SRR1562748     4  0.3569      1.000 0.000 0.196  0 0.804
#> SRR1562749     4  0.3569      1.000 0.000 0.196  0 0.804
#> SRR1562750     4  0.3569      1.000 0.000 0.196  0 0.804
#> SRR1562751     4  0.3569      1.000 0.000 0.196  0 0.804
#> SRR1562752     4  0.3569      1.000 0.000 0.196  0 0.804
#> SRR1562753     4  0.3569      1.000 0.000 0.196  0 0.804
#> SRR1562754     2  0.0000      0.954 0.000 1.000  0 0.000
#> SRR1562755     2  0.0188      0.951 0.000 0.996  0 0.004
#> SRR1562756     2  0.1389      0.908 0.000 0.952  0 0.048
#> SRR1562757     2  0.4331      0.456 0.000 0.712  0 0.288
#> SRR1562758     2  0.0469      0.944 0.000 0.988  0 0.012
#> SRR1562759     2  0.0000      0.954 0.000 1.000  0 0.000
#> SRR1562792     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1562793     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1562794     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1562795     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1562796     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1562797     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1562798     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1562799     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1562800     1  0.1389      0.976 0.952 0.000  0 0.048
#> SRR1562801     1  0.1389      0.976 0.952 0.000  0 0.048
#> SRR1562802     1  0.1389      0.976 0.952 0.000  0 0.048
#> SRR1562803     1  0.1389      0.976 0.952 0.000  0 0.048
#> SRR1562804     1  0.1389      0.976 0.952 0.000  0 0.048
#> SRR1562805     1  0.1389      0.976 0.952 0.000  0 0.048
#> SRR1562806     1  0.0000      0.982 1.000 0.000  0 0.000
#> SRR1562807     1  0.0000      0.982 1.000 0.000  0 0.000
#> SRR1562808     1  0.0000      0.982 1.000 0.000  0 0.000
#> SRR1562809     1  0.0000      0.982 1.000 0.000  0 0.000
#> SRR1562810     1  0.0000      0.982 1.000 0.000  0 0.000
#> SRR1562811     1  0.0000      0.982 1.000 0.000  0 0.000
#> SRR1562812     1  0.0000      0.982 1.000 0.000  0 0.000
#> SRR1562813     1  0.0000      0.982 1.000 0.000  0 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2 p3    p4    p5
#> SRR1562718     2  0.0609      0.914 0.000 0.980  0 0.000 0.020
#> SRR1562719     2  0.0609      0.914 0.000 0.980  0 0.000 0.020
#> SRR1562720     2  0.0609      0.914 0.000 0.980  0 0.000 0.020
#> SRR1562721     2  0.0609      0.914 0.000 0.980  0 0.000 0.020
#> SRR1562723     2  0.0609      0.914 0.000 0.980  0 0.000 0.020
#> SRR1562724     2  0.0609      0.914 0.000 0.980  0 0.000 0.020
#> SRR1562725     2  0.0609      0.914 0.000 0.980  0 0.000 0.020
#> SRR1562726     2  0.0609      0.914 0.000 0.980  0 0.000 0.020
#> SRR1562727     2  0.0609      0.914 0.000 0.980  0 0.000 0.020
#> SRR1562728     2  0.0609      0.914 0.000 0.980  0 0.000 0.020
#> SRR1562729     2  0.0609      0.914 0.000 0.980  0 0.000 0.020
#> SRR1562730     2  0.5184      0.650 0.000 0.688  0 0.176 0.136
#> SRR1562731     2  0.5184      0.650 0.000 0.688  0 0.176 0.136
#> SRR1562732     2  0.5184      0.650 0.000 0.688  0 0.176 0.136
#> SRR1562733     2  0.5184      0.650 0.000 0.688  0 0.176 0.136
#> SRR1562734     2  0.5184      0.650 0.000 0.688  0 0.176 0.136
#> SRR1562735     2  0.5184      0.650 0.000 0.688  0 0.176 0.136
#> SRR1562736     2  0.0000      0.915 0.000 1.000  0 0.000 0.000
#> SRR1562737     2  0.0000      0.915 0.000 1.000  0 0.000 0.000
#> SRR1562738     2  0.0000      0.915 0.000 1.000  0 0.000 0.000
#> SRR1562739     2  0.0000      0.915 0.000 1.000  0 0.000 0.000
#> SRR1562740     2  0.0000      0.915 0.000 1.000  0 0.000 0.000
#> SRR1562741     2  0.0000      0.915 0.000 1.000  0 0.000 0.000
#> SRR1562742     2  0.0000      0.915 0.000 1.000  0 0.000 0.000
#> SRR1562743     2  0.0000      0.915 0.000 1.000  0 0.000 0.000
#> SRR1562744     2  0.0000      0.915 0.000 1.000  0 0.000 0.000
#> SRR1562745     2  0.0000      0.915 0.000 1.000  0 0.000 0.000
#> SRR1562746     2  0.0000      0.915 0.000 1.000  0 0.000 0.000
#> SRR1562747     2  0.0000      0.915 0.000 1.000  0 0.000 0.000
#> SRR1562748     4  0.2891      1.000 0.000 0.176  0 0.824 0.000
#> SRR1562749     4  0.2891      1.000 0.000 0.176  0 0.824 0.000
#> SRR1562750     4  0.2891      1.000 0.000 0.176  0 0.824 0.000
#> SRR1562751     4  0.2891      1.000 0.000 0.176  0 0.824 0.000
#> SRR1562752     4  0.2891      1.000 0.000 0.176  0 0.824 0.000
#> SRR1562753     4  0.2891      1.000 0.000 0.176  0 0.824 0.000
#> SRR1562754     2  0.0000      0.915 0.000 1.000  0 0.000 0.000
#> SRR1562755     2  0.0162      0.913 0.000 0.996  0 0.004 0.000
#> SRR1562756     2  0.1197      0.874 0.000 0.952  0 0.048 0.000
#> SRR1562757     2  0.3730      0.439 0.000 0.712  0 0.288 0.000
#> SRR1562758     2  0.0404      0.908 0.000 0.988  0 0.012 0.000
#> SRR1562759     2  0.0000      0.915 0.000 1.000  0 0.000 0.000
#> SRR1562792     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1562793     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1562794     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1562795     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1562796     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1562797     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1562798     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1562799     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1562800     5  0.2471      1.000 0.136 0.000  0 0.000 0.864
#> SRR1562801     5  0.2471      1.000 0.136 0.000  0 0.000 0.864
#> SRR1562802     5  0.2471      1.000 0.136 0.000  0 0.000 0.864
#> SRR1562803     5  0.2471      1.000 0.136 0.000  0 0.000 0.864
#> SRR1562804     5  0.2471      1.000 0.136 0.000  0 0.000 0.864
#> SRR1562805     5  0.2471      1.000 0.136 0.000  0 0.000 0.864
#> SRR1562806     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> SRR1562807     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> SRR1562808     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> SRR1562809     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> SRR1562810     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> SRR1562811     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> SRR1562812     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> SRR1562813     1  0.0000      1.000 1.000 0.000  0 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2 p3    p4    p5    p6
#> SRR1562718     5  0.2812      0.902 0.000 0.048  0 0.000 0.856 0.096
#> SRR1562719     5  0.2812      0.902 0.000 0.048  0 0.000 0.856 0.096
#> SRR1562720     5  0.2812      0.902 0.000 0.048  0 0.000 0.856 0.096
#> SRR1562721     5  0.2812      0.902 0.000 0.048  0 0.000 0.856 0.096
#> SRR1562723     5  0.2812      0.902 0.000 0.048  0 0.000 0.856 0.096
#> SRR1562724     5  0.2812      0.902 0.000 0.048  0 0.000 0.856 0.096
#> SRR1562725     5  0.2812      0.902 0.000 0.048  0 0.000 0.856 0.096
#> SRR1562726     5  0.2812      0.902 0.000 0.048  0 0.000 0.856 0.096
#> SRR1562727     5  0.2812      0.902 0.000 0.048  0 0.000 0.856 0.096
#> SRR1562728     5  0.2812      0.902 0.000 0.048  0 0.000 0.856 0.096
#> SRR1562729     5  0.2812      0.902 0.000 0.048  0 0.000 0.856 0.096
#> SRR1562730     2  0.0547      1.000 0.000 0.980  0 0.000 0.020 0.000
#> SRR1562731     2  0.0547      1.000 0.000 0.980  0 0.000 0.020 0.000
#> SRR1562732     2  0.0547      1.000 0.000 0.980  0 0.000 0.020 0.000
#> SRR1562733     2  0.0547      1.000 0.000 0.980  0 0.000 0.020 0.000
#> SRR1562734     2  0.0547      1.000 0.000 0.980  0 0.000 0.020 0.000
#> SRR1562735     2  0.0547      1.000 0.000 0.980  0 0.000 0.020 0.000
#> SRR1562736     5  0.1204      0.922 0.000 0.000  0 0.000 0.944 0.056
#> SRR1562737     5  0.0260      0.926 0.000 0.000  0 0.000 0.992 0.008
#> SRR1562738     5  0.0000      0.926 0.000 0.000  0 0.000 1.000 0.000
#> SRR1562739     5  0.0000      0.926 0.000 0.000  0 0.000 1.000 0.000
#> SRR1562740     5  0.0260      0.926 0.000 0.000  0 0.000 0.992 0.008
#> SRR1562741     5  0.0713      0.925 0.000 0.000  0 0.000 0.972 0.028
#> SRR1562742     5  0.0000      0.926 0.000 0.000  0 0.000 1.000 0.000
#> SRR1562743     5  0.0000      0.926 0.000 0.000  0 0.000 1.000 0.000
#> SRR1562744     5  0.0000      0.926 0.000 0.000  0 0.000 1.000 0.000
#> SRR1562745     5  0.0000      0.926 0.000 0.000  0 0.000 1.000 0.000
#> SRR1562746     5  0.0000      0.926 0.000 0.000  0 0.000 1.000 0.000
#> SRR1562747     5  0.0000      0.926 0.000 0.000  0 0.000 1.000 0.000
#> SRR1562748     4  0.0146      1.000 0.000 0.000  0 0.996 0.004 0.000
#> SRR1562749     4  0.0146      1.000 0.000 0.000  0 0.996 0.004 0.000
#> SRR1562750     4  0.0146      1.000 0.000 0.000  0 0.996 0.004 0.000
#> SRR1562751     4  0.0146      1.000 0.000 0.000  0 0.996 0.004 0.000
#> SRR1562752     4  0.0146      1.000 0.000 0.000  0 0.996 0.004 0.000
#> SRR1562753     4  0.0146      1.000 0.000 0.000  0 0.996 0.004 0.000
#> SRR1562754     5  0.0547      0.918 0.000 0.020  0 0.000 0.980 0.000
#> SRR1562755     5  0.0692      0.916 0.000 0.020  0 0.004 0.976 0.000
#> SRR1562756     5  0.1408      0.897 0.000 0.020  0 0.036 0.944 0.000
#> SRR1562757     5  0.3711      0.599 0.000 0.020  0 0.260 0.720 0.000
#> SRR1562758     5  0.0858      0.919 0.000 0.028  0 0.004 0.968 0.000
#> SRR1562759     5  0.0547      0.918 0.000 0.020  0 0.000 0.980 0.000
#> SRR1562792     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1562793     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1562794     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1562795     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1562796     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1562797     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1562798     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1562799     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1562800     6  0.1765      1.000 0.096 0.000  0 0.000 0.000 0.904
#> SRR1562801     6  0.1765      1.000 0.096 0.000  0 0.000 0.000 0.904
#> SRR1562802     6  0.1765      1.000 0.096 0.000  0 0.000 0.000 0.904
#> SRR1562803     6  0.1765      1.000 0.096 0.000  0 0.000 0.000 0.904
#> SRR1562804     6  0.1765      1.000 0.096 0.000  0 0.000 0.000 0.904
#> SRR1562805     6  0.1765      1.000 0.096 0.000  0 0.000 0.000 0.904
#> SRR1562806     1  0.0146      0.998 0.996 0.000  0 0.004 0.000 0.000
#> SRR1562807     1  0.0146      0.998 0.996 0.000  0 0.004 0.000 0.000
#> SRR1562808     1  0.0146      0.998 0.996 0.000  0 0.004 0.000 0.000
#> SRR1562809     1  0.0146      0.998 0.996 0.000  0 0.004 0.000 0.000
#> SRR1562810     1  0.0000      0.998 1.000 0.000  0 0.000 0.000 0.000
#> SRR1562811     1  0.0000      0.998 1.000 0.000  0 0.000 0.000 0.000
#> SRR1562812     1  0.0000      0.998 1.000 0.000  0 0.000 0.000 0.000
#> SRR1562813     1  0.0000      0.998 1.000 0.000  0 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-pam-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-pam-collect-classes

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


CV:mclust**

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

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

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

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 15301 rows and 63 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#>   Subgroups are detected by 'mclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 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-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.775           0.951       0.960         0.3619 0.649   0.649
#> 3 3 1.000           0.976       0.965         0.4668 0.832   0.741
#> 4 4 0.784           0.903       0.929         0.3216 0.822   0.629
#> 5 5 0.806           0.839       0.865         0.1042 0.929   0.766
#> 6 6 0.892           0.909       0.918         0.0671 0.932   0.709

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
#> SRR1562718     2   0.000      0.964 0.000 1.000
#> SRR1562719     2   0.000      0.964 0.000 1.000
#> SRR1562720     2   0.000      0.964 0.000 1.000
#> SRR1562721     2   0.000      0.964 0.000 1.000
#> SRR1562723     2   0.000      0.964 0.000 1.000
#> SRR1562724     2   0.000      0.964 0.000 1.000
#> SRR1562725     2   0.000      0.964 0.000 1.000
#> SRR1562726     2   0.000      0.964 0.000 1.000
#> SRR1562727     2   0.000      0.964 0.000 1.000
#> SRR1562728     2   0.000      0.964 0.000 1.000
#> SRR1562729     2   0.000      0.964 0.000 1.000
#> SRR1562730     2   0.000      0.964 0.000 1.000
#> SRR1562731     2   0.000      0.964 0.000 1.000
#> SRR1562732     2   0.000      0.964 0.000 1.000
#> SRR1562733     2   0.000      0.964 0.000 1.000
#> SRR1562734     2   0.000      0.964 0.000 1.000
#> SRR1562735     2   0.000      0.964 0.000 1.000
#> SRR1562736     2   0.000      0.964 0.000 1.000
#> SRR1562737     2   0.000      0.964 0.000 1.000
#> SRR1562738     2   0.000      0.964 0.000 1.000
#> SRR1562739     2   0.000      0.964 0.000 1.000
#> SRR1562740     2   0.000      0.964 0.000 1.000
#> SRR1562741     2   0.000      0.964 0.000 1.000
#> SRR1562742     2   0.000      0.964 0.000 1.000
#> SRR1562743     2   0.000      0.964 0.000 1.000
#> SRR1562744     2   0.000      0.964 0.000 1.000
#> SRR1562745     2   0.000      0.964 0.000 1.000
#> SRR1562746     2   0.000      0.964 0.000 1.000
#> SRR1562747     2   0.000      0.964 0.000 1.000
#> SRR1562748     2   0.118      0.956 0.016 0.984
#> SRR1562749     2   0.118      0.956 0.016 0.984
#> SRR1562750     2   0.118      0.956 0.016 0.984
#> SRR1562751     2   0.118      0.956 0.016 0.984
#> SRR1562752     2   0.118      0.956 0.016 0.984
#> SRR1562753     2   0.118      0.956 0.016 0.984
#> SRR1562754     2   0.000      0.964 0.000 1.000
#> SRR1562755     2   0.000      0.964 0.000 1.000
#> SRR1562756     2   0.000      0.964 0.000 1.000
#> SRR1562757     2   0.000      0.964 0.000 1.000
#> SRR1562758     2   0.000      0.964 0.000 1.000
#> SRR1562759     2   0.000      0.964 0.000 1.000
#> SRR1562792     2   0.730      0.803 0.204 0.796
#> SRR1562793     2   0.730      0.803 0.204 0.796
#> SRR1562794     2   0.730      0.803 0.204 0.796
#> SRR1562795     2   0.730      0.803 0.204 0.796
#> SRR1562796     2   0.730      0.803 0.204 0.796
#> SRR1562797     2   0.730      0.803 0.204 0.796
#> SRR1562798     2   0.730      0.803 0.204 0.796
#> SRR1562799     2   0.730      0.803 0.204 0.796
#> SRR1562800     1   0.311      1.000 0.944 0.056
#> SRR1562801     1   0.311      1.000 0.944 0.056
#> SRR1562802     1   0.311      1.000 0.944 0.056
#> SRR1562803     1   0.311      1.000 0.944 0.056
#> SRR1562804     1   0.311      1.000 0.944 0.056
#> SRR1562805     1   0.311      1.000 0.944 0.056
#> SRR1562806     1   0.311      1.000 0.944 0.056
#> SRR1562807     1   0.311      1.000 0.944 0.056
#> SRR1562808     1   0.311      1.000 0.944 0.056
#> SRR1562809     1   0.311      1.000 0.944 0.056
#> SRR1562810     1   0.311      1.000 0.944 0.056
#> SRR1562811     1   0.311      1.000 0.944 0.056
#> SRR1562812     1   0.311      1.000 0.944 0.056
#> SRR1562813     1   0.311      1.000 0.944 0.056

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1562718     2  0.0592      0.968 0.000 0.988 0.012
#> SRR1562719     2  0.0592      0.968 0.000 0.988 0.012
#> SRR1562720     2  0.0592      0.968 0.000 0.988 0.012
#> SRR1562721     2  0.0592      0.968 0.000 0.988 0.012
#> SRR1562723     2  0.0592      0.968 0.000 0.988 0.012
#> SRR1562724     2  0.1289      0.969 0.000 0.968 0.032
#> SRR1562725     2  0.1289      0.969 0.000 0.968 0.032
#> SRR1562726     2  0.1411      0.969 0.000 0.964 0.036
#> SRR1562727     2  0.1289      0.969 0.000 0.968 0.032
#> SRR1562728     2  0.1289      0.969 0.000 0.968 0.032
#> SRR1562729     2  0.1289      0.969 0.000 0.968 0.032
#> SRR1562730     2  0.0661      0.969 0.004 0.988 0.008
#> SRR1562731     2  0.0661      0.969 0.004 0.988 0.008
#> SRR1562732     2  0.0661      0.969 0.004 0.988 0.008
#> SRR1562733     2  0.0661      0.969 0.004 0.988 0.008
#> SRR1562734     2  0.0661      0.969 0.004 0.988 0.008
#> SRR1562735     2  0.0661      0.969 0.004 0.988 0.008
#> SRR1562736     2  0.1753      0.966 0.000 0.952 0.048
#> SRR1562737     2  0.1753      0.966 0.000 0.952 0.048
#> SRR1562738     2  0.1753      0.966 0.000 0.952 0.048
#> SRR1562739     2  0.1753      0.966 0.000 0.952 0.048
#> SRR1562740     2  0.1753      0.966 0.000 0.952 0.048
#> SRR1562741     2  0.1753      0.966 0.000 0.952 0.048
#> SRR1562742     2  0.0424      0.969 0.000 0.992 0.008
#> SRR1562743     2  0.0424      0.969 0.000 0.992 0.008
#> SRR1562744     2  0.0424      0.969 0.000 0.992 0.008
#> SRR1562745     2  0.0424      0.969 0.000 0.992 0.008
#> SRR1562746     2  0.0424      0.969 0.000 0.992 0.008
#> SRR1562747     2  0.0424      0.969 0.000 0.992 0.008
#> SRR1562748     2  0.2846      0.940 0.056 0.924 0.020
#> SRR1562749     2  0.2846      0.940 0.056 0.924 0.020
#> SRR1562750     2  0.2846      0.940 0.056 0.924 0.020
#> SRR1562751     2  0.2846      0.940 0.056 0.924 0.020
#> SRR1562752     2  0.2846      0.940 0.056 0.924 0.020
#> SRR1562753     2  0.2846      0.940 0.056 0.924 0.020
#> SRR1562754     2  0.2356      0.958 0.000 0.928 0.072
#> SRR1562755     2  0.2356      0.958 0.000 0.928 0.072
#> SRR1562756     2  0.2356      0.958 0.000 0.928 0.072
#> SRR1562757     2  0.2356      0.958 0.000 0.928 0.072
#> SRR1562758     2  0.2356      0.958 0.000 0.928 0.072
#> SRR1562759     2  0.2356      0.958 0.000 0.928 0.072
#> SRR1562792     3  0.2625      1.000 0.084 0.000 0.916
#> SRR1562793     3  0.2625      1.000 0.084 0.000 0.916
#> SRR1562794     3  0.2625      1.000 0.084 0.000 0.916
#> SRR1562795     3  0.2625      1.000 0.084 0.000 0.916
#> SRR1562796     3  0.2625      1.000 0.084 0.000 0.916
#> SRR1562797     3  0.2625      1.000 0.084 0.000 0.916
#> SRR1562798     3  0.2625      1.000 0.084 0.000 0.916
#> SRR1562799     3  0.2625      1.000 0.084 0.000 0.916
#> SRR1562800     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1562801     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1562802     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1562803     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1562804     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1562805     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1562806     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1562807     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1562808     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1562809     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1562810     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1562811     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1562812     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1562813     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
#> SRR1562718     2  0.0188      0.888 0.000 0.996  0 0.004
#> SRR1562719     2  0.0336      0.889 0.000 0.992  0 0.008
#> SRR1562720     2  0.0336      0.887 0.000 0.992  0 0.008
#> SRR1562721     2  0.0188      0.888 0.000 0.996  0 0.004
#> SRR1562723     2  0.0188      0.886 0.000 0.996  0 0.004
#> SRR1562724     2  0.0469      0.888 0.000 0.988  0 0.012
#> SRR1562725     2  0.0592      0.888 0.000 0.984  0 0.016
#> SRR1562726     2  0.0817      0.886 0.000 0.976  0 0.024
#> SRR1562727     2  0.0707      0.887 0.000 0.980  0 0.020
#> SRR1562728     2  0.0707      0.888 0.000 0.980  0 0.020
#> SRR1562729     2  0.0707      0.887 0.000 0.980  0 0.020
#> SRR1562730     2  0.0921      0.878 0.000 0.972  0 0.028
#> SRR1562731     2  0.0921      0.878 0.000 0.972  0 0.028
#> SRR1562732     2  0.0921      0.878 0.000 0.972  0 0.028
#> SRR1562733     2  0.0921      0.878 0.000 0.972  0 0.028
#> SRR1562734     2  0.1022      0.879 0.000 0.968  0 0.032
#> SRR1562735     2  0.0921      0.878 0.000 0.972  0 0.028
#> SRR1562736     2  0.3975      0.805 0.000 0.760  0 0.240
#> SRR1562737     2  0.3873      0.814 0.000 0.772  0 0.228
#> SRR1562738     2  0.3975      0.805 0.000 0.760  0 0.240
#> SRR1562739     2  0.3907      0.811 0.000 0.768  0 0.232
#> SRR1562740     2  0.3975      0.805 0.000 0.760  0 0.240
#> SRR1562741     2  0.3975      0.805 0.000 0.760  0 0.240
#> SRR1562742     2  0.3444      0.845 0.000 0.816  0 0.184
#> SRR1562743     2  0.3400      0.846 0.000 0.820  0 0.180
#> SRR1562744     2  0.3444      0.846 0.000 0.816  0 0.184
#> SRR1562745     2  0.3400      0.846 0.000 0.820  0 0.180
#> SRR1562746     2  0.3400      0.846 0.000 0.820  0 0.180
#> SRR1562747     2  0.3444      0.845 0.000 0.816  0 0.184
#> SRR1562748     4  0.1510      0.825 0.016 0.028  0 0.956
#> SRR1562749     4  0.1510      0.825 0.016 0.028  0 0.956
#> SRR1562750     4  0.1510      0.825 0.016 0.028  0 0.956
#> SRR1562751     4  0.1510      0.825 0.016 0.028  0 0.956
#> SRR1562752     4  0.1510      0.825 0.016 0.028  0 0.956
#> SRR1562753     4  0.1510      0.825 0.016 0.028  0 0.956
#> SRR1562754     4  0.3942      0.827 0.000 0.236  0 0.764
#> SRR1562755     4  0.3975      0.827 0.000 0.240  0 0.760
#> SRR1562756     4  0.3975      0.827 0.000 0.240  0 0.760
#> SRR1562757     4  0.3975      0.827 0.000 0.240  0 0.760
#> SRR1562758     4  0.3975      0.827 0.000 0.240  0 0.760
#> SRR1562759     4  0.3975      0.827 0.000 0.240  0 0.760
#> SRR1562792     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1562793     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1562794     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1562795     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1562796     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1562797     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1562798     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1562799     3  0.0000      1.000 0.000 0.000  1 0.000
#> SRR1562800     1  0.0000      1.000 1.000 0.000  0 0.000
#> SRR1562801     1  0.0000      1.000 1.000 0.000  0 0.000
#> SRR1562802     1  0.0000      1.000 1.000 0.000  0 0.000
#> SRR1562803     1  0.0000      1.000 1.000 0.000  0 0.000
#> SRR1562804     1  0.0000      1.000 1.000 0.000  0 0.000
#> SRR1562805     1  0.0000      1.000 1.000 0.000  0 0.000
#> SRR1562806     1  0.0000      1.000 1.000 0.000  0 0.000
#> SRR1562807     1  0.0000      1.000 1.000 0.000  0 0.000
#> SRR1562808     1  0.0000      1.000 1.000 0.000  0 0.000
#> SRR1562809     1  0.0000      1.000 1.000 0.000  0 0.000
#> SRR1562810     1  0.0000      1.000 1.000 0.000  0 0.000
#> SRR1562811     1  0.0000      1.000 1.000 0.000  0 0.000
#> SRR1562812     1  0.0000      1.000 1.000 0.000  0 0.000
#> SRR1562813     1  0.0000      1.000 1.000 0.000  0 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2 p3    p4    p5
#> SRR1562718     2  0.4256      0.622 0.000 0.564  0 0.000 0.436
#> SRR1562719     2  0.4256      0.622 0.000 0.564  0 0.000 0.436
#> SRR1562720     2  0.4256      0.622 0.000 0.564  0 0.000 0.436
#> SRR1562721     2  0.4256      0.622 0.000 0.564  0 0.000 0.436
#> SRR1562723     2  0.4256      0.622 0.000 0.564  0 0.000 0.436
#> SRR1562724     2  0.4192      0.643 0.000 0.596  0 0.000 0.404
#> SRR1562725     2  0.4192      0.643 0.000 0.596  0 0.000 0.404
#> SRR1562726     2  0.4192      0.643 0.000 0.596  0 0.000 0.404
#> SRR1562727     2  0.4192      0.643 0.000 0.596  0 0.000 0.404
#> SRR1562728     2  0.4192      0.643 0.000 0.596  0 0.000 0.404
#> SRR1562729     2  0.4192      0.643 0.000 0.596  0 0.000 0.404
#> SRR1562730     5  0.0404      1.000 0.000 0.012  0 0.000 0.988
#> SRR1562731     5  0.0404      1.000 0.000 0.012  0 0.000 0.988
#> SRR1562732     5  0.0404      1.000 0.000 0.012  0 0.000 0.988
#> SRR1562733     5  0.0404      1.000 0.000 0.012  0 0.000 0.988
#> SRR1562734     5  0.0404      1.000 0.000 0.012  0 0.000 0.988
#> SRR1562735     5  0.0404      1.000 0.000 0.012  0 0.000 0.988
#> SRR1562736     2  0.0794      0.652 0.000 0.972  0 0.028 0.000
#> SRR1562737     2  0.0798      0.664 0.000 0.976  0 0.016 0.008
#> SRR1562738     2  0.0794      0.652 0.000 0.972  0 0.028 0.000
#> SRR1562739     2  0.0865      0.658 0.000 0.972  0 0.024 0.004
#> SRR1562740     2  0.1082      0.658 0.000 0.964  0 0.028 0.008
#> SRR1562741     2  0.0794      0.652 0.000 0.972  0 0.028 0.000
#> SRR1562742     2  0.2471      0.717 0.000 0.864  0 0.000 0.136
#> SRR1562743     2  0.2471      0.717 0.000 0.864  0 0.000 0.136
#> SRR1562744     2  0.2471      0.717 0.000 0.864  0 0.000 0.136
#> SRR1562745     2  0.2471      0.717 0.000 0.864  0 0.000 0.136
#> SRR1562746     2  0.2471      0.717 0.000 0.864  0 0.000 0.136
#> SRR1562747     2  0.2471      0.717 0.000 0.864  0 0.000 0.136
#> SRR1562748     4  0.0000      0.808 0.000 0.000  0 1.000 0.000
#> SRR1562749     4  0.0000      0.808 0.000 0.000  0 1.000 0.000
#> SRR1562750     4  0.0000      0.808 0.000 0.000  0 1.000 0.000
#> SRR1562751     4  0.0000      0.808 0.000 0.000  0 1.000 0.000
#> SRR1562752     4  0.0000      0.808 0.000 0.000  0 1.000 0.000
#> SRR1562753     4  0.0000      0.808 0.000 0.000  0 1.000 0.000
#> SRR1562754     4  0.4147      0.810 0.000 0.316  0 0.676 0.008
#> SRR1562755     4  0.4147      0.810 0.000 0.316  0 0.676 0.008
#> SRR1562756     4  0.4147      0.810 0.000 0.316  0 0.676 0.008
#> SRR1562757     4  0.4147      0.810 0.000 0.316  0 0.676 0.008
#> SRR1562758     4  0.4147      0.810 0.000 0.316  0 0.676 0.008
#> SRR1562759     4  0.4147      0.810 0.000 0.316  0 0.676 0.008
#> SRR1562792     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1562793     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1562794     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1562795     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1562796     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1562797     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1562798     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1562799     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1562800     1  0.0404      0.994 0.988 0.000  0 0.000 0.012
#> SRR1562801     1  0.0404      0.994 0.988 0.000  0 0.000 0.012
#> SRR1562802     1  0.0404      0.994 0.988 0.000  0 0.000 0.012
#> SRR1562803     1  0.0404      0.994 0.988 0.000  0 0.000 0.012
#> SRR1562804     1  0.0404      0.994 0.988 0.000  0 0.000 0.012
#> SRR1562805     1  0.0404      0.994 0.988 0.000  0 0.000 0.012
#> SRR1562806     1  0.0000      0.995 1.000 0.000  0 0.000 0.000
#> SRR1562807     1  0.0000      0.995 1.000 0.000  0 0.000 0.000
#> SRR1562808     1  0.0000      0.995 1.000 0.000  0 0.000 0.000
#> SRR1562809     1  0.0000      0.995 1.000 0.000  0 0.000 0.000
#> SRR1562810     1  0.0000      0.995 1.000 0.000  0 0.000 0.000
#> SRR1562811     1  0.0000      0.995 1.000 0.000  0 0.000 0.000
#> SRR1562812     1  0.0000      0.995 1.000 0.000  0 0.000 0.000
#> SRR1562813     1  0.0000      0.995 1.000 0.000  0 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2 p3    p4    p5    p6
#> SRR1562718     2  0.0363      0.961 0.000 0.988  0 0.000 0.000 0.012
#> SRR1562719     2  0.0363      0.961 0.000 0.988  0 0.000 0.000 0.012
#> SRR1562720     2  0.0363      0.961 0.000 0.988  0 0.000 0.000 0.012
#> SRR1562721     2  0.0363      0.961 0.000 0.988  0 0.000 0.000 0.012
#> SRR1562723     2  0.0363      0.961 0.000 0.988  0 0.000 0.000 0.012
#> SRR1562724     2  0.1007      0.966 0.000 0.956  0 0.000 0.044 0.000
#> SRR1562725     2  0.1007      0.966 0.000 0.956  0 0.000 0.044 0.000
#> SRR1562726     2  0.0937      0.967 0.000 0.960  0 0.000 0.040 0.000
#> SRR1562727     2  0.1007      0.966 0.000 0.956  0 0.000 0.044 0.000
#> SRR1562728     2  0.0937      0.967 0.000 0.960  0 0.000 0.040 0.000
#> SRR1562729     2  0.1007      0.966 0.000 0.956  0 0.000 0.044 0.000
#> SRR1562730     6  0.1387      1.000 0.000 0.068  0 0.000 0.000 0.932
#> SRR1562731     6  0.1387      1.000 0.000 0.068  0 0.000 0.000 0.932
#> SRR1562732     6  0.1387      1.000 0.000 0.068  0 0.000 0.000 0.932
#> SRR1562733     6  0.1387      1.000 0.000 0.068  0 0.000 0.000 0.932
#> SRR1562734     6  0.1387      1.000 0.000 0.068  0 0.000 0.000 0.932
#> SRR1562735     6  0.1387      1.000 0.000 0.068  0 0.000 0.000 0.932
#> SRR1562736     5  0.0790      0.844 0.000 0.032  0 0.000 0.968 0.000
#> SRR1562737     5  0.0865      0.845 0.000 0.036  0 0.000 0.964 0.000
#> SRR1562738     5  0.0865      0.845 0.000 0.036  0 0.000 0.964 0.000
#> SRR1562739     5  0.0790      0.844 0.000 0.032  0 0.000 0.968 0.000
#> SRR1562740     5  0.0790      0.844 0.000 0.032  0 0.000 0.968 0.000
#> SRR1562741     5  0.0790      0.844 0.000 0.032  0 0.000 0.968 0.000
#> SRR1562742     5  0.3023      0.851 0.000 0.232  0 0.000 0.768 0.000
#> SRR1562743     5  0.3023      0.851 0.000 0.232  0 0.000 0.768 0.000
#> SRR1562744     5  0.3050      0.848 0.000 0.236  0 0.000 0.764 0.000
#> SRR1562745     5  0.3023      0.851 0.000 0.232  0 0.000 0.768 0.000
#> SRR1562746     5  0.3050      0.848 0.000 0.236  0 0.000 0.764 0.000
#> SRR1562747     5  0.3023      0.851 0.000 0.232  0 0.000 0.768 0.000
#> SRR1562748     4  0.0000      0.758 0.000 0.000  0 1.000 0.000 0.000
#> SRR1562749     4  0.0000      0.758 0.000 0.000  0 1.000 0.000 0.000
#> SRR1562750     4  0.0000      0.758 0.000 0.000  0 1.000 0.000 0.000
#> SRR1562751     4  0.0000      0.758 0.000 0.000  0 1.000 0.000 0.000
#> SRR1562752     4  0.0000      0.758 0.000 0.000  0 1.000 0.000 0.000
#> SRR1562753     4  0.0000      0.758 0.000 0.000  0 1.000 0.000 0.000
#> SRR1562754     4  0.3862      0.722 0.000 0.004  0 0.608 0.388 0.000
#> SRR1562755     4  0.3862      0.722 0.000 0.004  0 0.608 0.388 0.000
#> SRR1562756     4  0.3862      0.722 0.000 0.004  0 0.608 0.388 0.000
#> SRR1562757     4  0.3862      0.722 0.000 0.004  0 0.608 0.388 0.000
#> SRR1562758     4  0.3862      0.722 0.000 0.004  0 0.608 0.388 0.000
#> SRR1562759     4  0.3862      0.722 0.000 0.004  0 0.608 0.388 0.000
#> SRR1562792     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1562793     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1562794     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1562795     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1562796     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1562797     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1562798     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1562799     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1562800     1  0.0972      0.974 0.964 0.000  0 0.000 0.008 0.028
#> SRR1562801     1  0.0972      0.974 0.964 0.000  0 0.000 0.008 0.028
#> SRR1562802     1  0.0972      0.974 0.964 0.000  0 0.000 0.008 0.028
#> SRR1562803     1  0.0972      0.974 0.964 0.000  0 0.000 0.008 0.028
#> SRR1562804     1  0.0972      0.974 0.964 0.000  0 0.000 0.008 0.028
#> SRR1562805     1  0.0972      0.974 0.964 0.000  0 0.000 0.008 0.028
#> SRR1562806     1  0.0937      0.964 0.960 0.000  0 0.000 0.000 0.040
#> SRR1562807     1  0.0937      0.964 0.960 0.000  0 0.000 0.000 0.040
#> SRR1562808     1  0.0937      0.964 0.960 0.000  0 0.000 0.000 0.040
#> SRR1562809     1  0.0937      0.964 0.960 0.000  0 0.000 0.000 0.040
#> SRR1562810     1  0.0000      0.975 1.000 0.000  0 0.000 0.000 0.000
#> SRR1562811     1  0.0000      0.975 1.000 0.000  0 0.000 0.000 0.000
#> SRR1562812     1  0.0000      0.975 1.000 0.000  0 0.000 0.000 0.000
#> SRR1562813     1  0.0000      0.975 1.000 0.000  0 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-mclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-mclust-collect-classes

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


CV:NMF**

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

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

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

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 15301 rows and 63 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#>   Subgroups are detected by 'NMF' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 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.775           0.980       0.984         0.4485 0.538   0.538
#> 3 3 1.000           0.994       0.990         0.1659 0.943   0.893
#> 4 4 0.836           0.927       0.928         0.3362 0.788   0.559
#> 5 5 0.734           0.928       0.892         0.0924 0.874   0.588
#> 6 6 0.804           0.623       0.745         0.0515 0.889   0.619

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
#> SRR1562718     2  0.0000      1.000 0.000 1.000
#> SRR1562719     2  0.0000      1.000 0.000 1.000
#> SRR1562720     2  0.0000      1.000 0.000 1.000
#> SRR1562721     2  0.0000      1.000 0.000 1.000
#> SRR1562723     2  0.0000      1.000 0.000 1.000
#> SRR1562724     2  0.0000      1.000 0.000 1.000
#> SRR1562725     2  0.0000      1.000 0.000 1.000
#> SRR1562726     2  0.0000      1.000 0.000 1.000
#> SRR1562727     2  0.0000      1.000 0.000 1.000
#> SRR1562728     2  0.0000      1.000 0.000 1.000
#> SRR1562729     2  0.0000      1.000 0.000 1.000
#> SRR1562730     2  0.0000      1.000 0.000 1.000
#> SRR1562731     2  0.0000      1.000 0.000 1.000
#> SRR1562732     2  0.0000      1.000 0.000 1.000
#> SRR1562733     2  0.0000      1.000 0.000 1.000
#> SRR1562734     2  0.0000      1.000 0.000 1.000
#> SRR1562735     2  0.0000      1.000 0.000 1.000
#> SRR1562736     2  0.0000      1.000 0.000 1.000
#> SRR1562737     2  0.0000      1.000 0.000 1.000
#> SRR1562738     2  0.0000      1.000 0.000 1.000
#> SRR1562739     2  0.0000      1.000 0.000 1.000
#> SRR1562740     2  0.0000      1.000 0.000 1.000
#> SRR1562741     2  0.0000      1.000 0.000 1.000
#> SRR1562742     2  0.0000      1.000 0.000 1.000
#> SRR1562743     2  0.0000      1.000 0.000 1.000
#> SRR1562744     2  0.0000      1.000 0.000 1.000
#> SRR1562745     2  0.0000      1.000 0.000 1.000
#> SRR1562746     2  0.0000      1.000 0.000 1.000
#> SRR1562747     2  0.0000      1.000 0.000 1.000
#> SRR1562748     2  0.0000      1.000 0.000 1.000
#> SRR1562749     2  0.0000      1.000 0.000 1.000
#> SRR1562750     2  0.0000      1.000 0.000 1.000
#> SRR1562751     2  0.0000      1.000 0.000 1.000
#> SRR1562752     2  0.0000      1.000 0.000 1.000
#> SRR1562753     2  0.0000      1.000 0.000 1.000
#> SRR1562754     2  0.0000      1.000 0.000 1.000
#> SRR1562755     2  0.0000      1.000 0.000 1.000
#> SRR1562756     2  0.0000      1.000 0.000 1.000
#> SRR1562757     2  0.0000      1.000 0.000 1.000
#> SRR1562758     2  0.0000      1.000 0.000 1.000
#> SRR1562759     2  0.0000      1.000 0.000 1.000
#> SRR1562792     1  0.5059      0.917 0.888 0.112
#> SRR1562793     1  0.5059      0.917 0.888 0.112
#> SRR1562794     1  0.5059      0.917 0.888 0.112
#> SRR1562795     1  0.5059      0.917 0.888 0.112
#> SRR1562796     1  0.5059      0.917 0.888 0.112
#> SRR1562797     1  0.5059      0.917 0.888 0.112
#> SRR1562798     1  0.5059      0.917 0.888 0.112
#> SRR1562799     1  0.5059      0.917 0.888 0.112
#> SRR1562800     1  0.0672      0.957 0.992 0.008
#> SRR1562801     1  0.0672      0.957 0.992 0.008
#> SRR1562802     1  0.0672      0.957 0.992 0.008
#> SRR1562803     1  0.0672      0.957 0.992 0.008
#> SRR1562804     1  0.0672      0.957 0.992 0.008
#> SRR1562805     1  0.0672      0.957 0.992 0.008
#> SRR1562806     1  0.0672      0.957 0.992 0.008
#> SRR1562807     1  0.0672      0.957 0.992 0.008
#> SRR1562808     1  0.0672      0.957 0.992 0.008
#> SRR1562809     1  0.0672      0.957 0.992 0.008
#> SRR1562810     1  0.0672      0.957 0.992 0.008
#> SRR1562811     1  0.0672      0.957 0.992 0.008
#> SRR1562812     1  0.0672      0.957 0.992 0.008
#> SRR1562813     1  0.0672      0.957 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
#> SRR1562718     2  0.0000      0.992 0.000 1.000 0.000
#> SRR1562719     2  0.0000      0.992 0.000 1.000 0.000
#> SRR1562720     2  0.0000      0.992 0.000 1.000 0.000
#> SRR1562721     2  0.0000      0.992 0.000 1.000 0.000
#> SRR1562723     2  0.0000      0.992 0.000 1.000 0.000
#> SRR1562724     2  0.0000      0.992 0.000 1.000 0.000
#> SRR1562725     2  0.0000      0.992 0.000 1.000 0.000
#> SRR1562726     2  0.0000      0.992 0.000 1.000 0.000
#> SRR1562727     2  0.0000      0.992 0.000 1.000 0.000
#> SRR1562728     2  0.0000      0.992 0.000 1.000 0.000
#> SRR1562729     2  0.0000      0.992 0.000 1.000 0.000
#> SRR1562730     2  0.0000      0.992 0.000 1.000 0.000
#> SRR1562731     2  0.0000      0.992 0.000 1.000 0.000
#> SRR1562732     2  0.0000      0.992 0.000 1.000 0.000
#> SRR1562733     2  0.0000      0.992 0.000 1.000 0.000
#> SRR1562734     2  0.0000      0.992 0.000 1.000 0.000
#> SRR1562735     2  0.0000      0.992 0.000 1.000 0.000
#> SRR1562736     2  0.0747      0.989 0.000 0.984 0.016
#> SRR1562737     2  0.0592      0.990 0.000 0.988 0.012
#> SRR1562738     2  0.0747      0.989 0.000 0.984 0.016
#> SRR1562739     2  0.0592      0.990 0.000 0.988 0.012
#> SRR1562740     2  0.0747      0.989 0.000 0.984 0.016
#> SRR1562741     2  0.0747      0.989 0.000 0.984 0.016
#> SRR1562742     2  0.0000      0.992 0.000 1.000 0.000
#> SRR1562743     2  0.0000      0.992 0.000 1.000 0.000
#> SRR1562744     2  0.0000      0.992 0.000 1.000 0.000
#> SRR1562745     2  0.0000      0.992 0.000 1.000 0.000
#> SRR1562746     2  0.0000      0.992 0.000 1.000 0.000
#> SRR1562747     2  0.0000      0.992 0.000 1.000 0.000
#> SRR1562748     2  0.1163      0.984 0.000 0.972 0.028
#> SRR1562749     2  0.1163      0.984 0.000 0.972 0.028
#> SRR1562750     2  0.1163      0.984 0.000 0.972 0.028
#> SRR1562751     2  0.1163      0.984 0.000 0.972 0.028
#> SRR1562752     2  0.1163      0.984 0.000 0.972 0.028
#> SRR1562753     2  0.1163      0.984 0.000 0.972 0.028
#> SRR1562754     2  0.0892      0.988 0.000 0.980 0.020
#> SRR1562755     2  0.0892      0.988 0.000 0.980 0.020
#> SRR1562756     2  0.0892      0.988 0.000 0.980 0.020
#> SRR1562757     2  0.0892      0.988 0.000 0.980 0.020
#> SRR1562758     2  0.0892      0.988 0.000 0.980 0.020
#> SRR1562759     2  0.0892      0.988 0.000 0.980 0.020
#> SRR1562792     3  0.1163      1.000 0.028 0.000 0.972
#> SRR1562793     3  0.1163      1.000 0.028 0.000 0.972
#> SRR1562794     3  0.1163      1.000 0.028 0.000 0.972
#> SRR1562795     3  0.1163      1.000 0.028 0.000 0.972
#> SRR1562796     3  0.1163      1.000 0.028 0.000 0.972
#> SRR1562797     3  0.1163      1.000 0.028 0.000 0.972
#> SRR1562798     3  0.1163      1.000 0.028 0.000 0.972
#> SRR1562799     3  0.1163      1.000 0.028 0.000 0.972
#> SRR1562800     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1562801     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1562802     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1562803     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1562804     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1562805     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1562806     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1562807     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1562808     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1562809     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1562810     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1562811     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1562812     1  0.0000      1.000 1.000 0.000 0.000
#> SRR1562813     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
#> SRR1562718     2  0.0000      0.988 0.000 1.000 0.000 0.000
#> SRR1562719     2  0.0000      0.988 0.000 1.000 0.000 0.000
#> SRR1562720     2  0.0188      0.988 0.000 0.996 0.004 0.000
#> SRR1562721     2  0.0000      0.988 0.000 1.000 0.000 0.000
#> SRR1562723     2  0.0000      0.988 0.000 1.000 0.000 0.000
#> SRR1562724     2  0.0188      0.988 0.000 0.996 0.004 0.000
#> SRR1562725     2  0.0188      0.988 0.000 0.996 0.004 0.000
#> SRR1562726     2  0.0000      0.988 0.000 1.000 0.000 0.000
#> SRR1562727     2  0.0188      0.988 0.000 0.996 0.004 0.000
#> SRR1562728     2  0.0188      0.988 0.000 0.996 0.004 0.000
#> SRR1562729     2  0.0000      0.988 0.000 1.000 0.000 0.000
#> SRR1562730     2  0.0188      0.988 0.000 0.996 0.004 0.000
#> SRR1562731     2  0.0188      0.988 0.000 0.996 0.004 0.000
#> SRR1562732     2  0.0188      0.988 0.000 0.996 0.004 0.000
#> SRR1562733     2  0.0188      0.988 0.000 0.996 0.004 0.000
#> SRR1562734     2  0.0188      0.988 0.000 0.996 0.004 0.000
#> SRR1562735     2  0.0188      0.988 0.000 0.996 0.004 0.000
#> SRR1562736     4  0.4713      0.714 0.000 0.360 0.000 0.640
#> SRR1562737     4  0.4643      0.740 0.000 0.344 0.000 0.656
#> SRR1562738     4  0.4907      0.609 0.000 0.420 0.000 0.580
#> SRR1562739     4  0.4877      0.642 0.000 0.408 0.000 0.592
#> SRR1562740     4  0.4661      0.733 0.000 0.348 0.000 0.652
#> SRR1562741     4  0.4679      0.726 0.000 0.352 0.000 0.648
#> SRR1562742     2  0.0817      0.971 0.000 0.976 0.000 0.024
#> SRR1562743     2  0.0921      0.967 0.000 0.972 0.000 0.028
#> SRR1562744     2  0.0817      0.971 0.000 0.976 0.000 0.024
#> SRR1562745     2  0.0921      0.967 0.000 0.972 0.000 0.028
#> SRR1562746     2  0.0921      0.967 0.000 0.972 0.000 0.028
#> SRR1562747     2  0.0817      0.971 0.000 0.976 0.000 0.024
#> SRR1562748     4  0.2266      0.806 0.000 0.084 0.004 0.912
#> SRR1562749     4  0.2266      0.806 0.000 0.084 0.004 0.912
#> SRR1562750     4  0.2266      0.806 0.000 0.084 0.004 0.912
#> SRR1562751     4  0.2266      0.806 0.000 0.084 0.004 0.912
#> SRR1562752     4  0.2266      0.806 0.000 0.084 0.004 0.912
#> SRR1562753     4  0.2266      0.806 0.000 0.084 0.004 0.912
#> SRR1562754     4  0.3837      0.834 0.000 0.224 0.000 0.776
#> SRR1562755     4  0.3873      0.833 0.000 0.228 0.000 0.772
#> SRR1562756     4  0.3837      0.834 0.000 0.224 0.000 0.776
#> SRR1562757     4  0.3764      0.835 0.000 0.216 0.000 0.784
#> SRR1562758     4  0.3837      0.834 0.000 0.224 0.000 0.776
#> SRR1562759     4  0.3873      0.833 0.000 0.228 0.000 0.772
#> SRR1562792     3  0.0336      1.000 0.008 0.000 0.992 0.000
#> SRR1562793     3  0.0336      1.000 0.008 0.000 0.992 0.000
#> SRR1562794     3  0.0336      1.000 0.008 0.000 0.992 0.000
#> SRR1562795     3  0.0336      1.000 0.008 0.000 0.992 0.000
#> SRR1562796     3  0.0336      1.000 0.008 0.000 0.992 0.000
#> SRR1562797     3  0.0336      1.000 0.008 0.000 0.992 0.000
#> SRR1562798     3  0.0336      1.000 0.008 0.000 0.992 0.000
#> SRR1562799     3  0.0336      1.000 0.008 0.000 0.992 0.000
#> SRR1562800     1  0.1022      0.984 0.968 0.000 0.000 0.032
#> SRR1562801     1  0.1022      0.984 0.968 0.000 0.000 0.032
#> SRR1562802     1  0.1022      0.984 0.968 0.000 0.000 0.032
#> SRR1562803     1  0.1022      0.984 0.968 0.000 0.000 0.032
#> SRR1562804     1  0.1022      0.984 0.968 0.000 0.000 0.032
#> SRR1562805     1  0.1022      0.984 0.968 0.000 0.000 0.032
#> SRR1562806     1  0.0000      0.988 1.000 0.000 0.000 0.000
#> SRR1562807     1  0.0000      0.988 1.000 0.000 0.000 0.000
#> SRR1562808     1  0.0000      0.988 1.000 0.000 0.000 0.000
#> SRR1562809     1  0.0000      0.988 1.000 0.000 0.000 0.000
#> SRR1562810     1  0.0000      0.988 1.000 0.000 0.000 0.000
#> SRR1562811     1  0.0000      0.988 1.000 0.000 0.000 0.000
#> SRR1562812     1  0.0000      0.988 1.000 0.000 0.000 0.000
#> SRR1562813     1  0.0000      0.988 1.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4    p5
#> SRR1562718     2  0.2929      0.876 0.000 0.820 0.000 0.000 0.180
#> SRR1562719     2  0.2732      0.897 0.000 0.840 0.000 0.000 0.160
#> SRR1562720     2  0.2424      0.915 0.000 0.868 0.000 0.000 0.132
#> SRR1562721     2  0.2471      0.914 0.000 0.864 0.000 0.000 0.136
#> SRR1562723     2  0.2561      0.910 0.000 0.856 0.000 0.000 0.144
#> SRR1562724     2  0.2471      0.917 0.000 0.864 0.000 0.000 0.136
#> SRR1562725     2  0.2471      0.917 0.000 0.864 0.000 0.000 0.136
#> SRR1562726     2  0.2648      0.910 0.000 0.848 0.000 0.000 0.152
#> SRR1562727     2  0.2424      0.917 0.000 0.868 0.000 0.000 0.132
#> SRR1562728     2  0.2516      0.916 0.000 0.860 0.000 0.000 0.140
#> SRR1562729     2  0.3048      0.887 0.000 0.820 0.000 0.004 0.176
#> SRR1562730     2  0.0000      0.882 0.000 1.000 0.000 0.000 0.000
#> SRR1562731     2  0.0000      0.882 0.000 1.000 0.000 0.000 0.000
#> SRR1562732     2  0.0000      0.882 0.000 1.000 0.000 0.000 0.000
#> SRR1562733     2  0.0000      0.882 0.000 1.000 0.000 0.000 0.000
#> SRR1562734     2  0.0000      0.882 0.000 1.000 0.000 0.000 0.000
#> SRR1562735     2  0.0000      0.882 0.000 1.000 0.000 0.000 0.000
#> SRR1562736     5  0.2054      0.891 0.000 0.052 0.000 0.028 0.920
#> SRR1562737     5  0.1792      0.911 0.000 0.084 0.000 0.000 0.916
#> SRR1562738     5  0.2193      0.894 0.000 0.060 0.000 0.028 0.912
#> SRR1562739     5  0.1892      0.909 0.000 0.080 0.000 0.004 0.916
#> SRR1562740     5  0.1830      0.907 0.000 0.068 0.000 0.008 0.924
#> SRR1562741     5  0.2124      0.892 0.000 0.056 0.000 0.028 0.916
#> SRR1562742     5  0.3171      0.885 0.000 0.176 0.000 0.008 0.816
#> SRR1562743     5  0.3171      0.885 0.000 0.176 0.000 0.008 0.816
#> SRR1562744     5  0.3171      0.885 0.000 0.176 0.000 0.008 0.816
#> SRR1562745     5  0.3171      0.885 0.000 0.176 0.000 0.008 0.816
#> SRR1562746     5  0.3171      0.885 0.000 0.176 0.000 0.008 0.816
#> SRR1562747     5  0.3171      0.885 0.000 0.176 0.000 0.008 0.816
#> SRR1562748     4  0.2773      1.000 0.000 0.000 0.000 0.836 0.164
#> SRR1562749     4  0.2773      1.000 0.000 0.000 0.000 0.836 0.164
#> SRR1562750     4  0.2773      1.000 0.000 0.000 0.000 0.836 0.164
#> SRR1562751     4  0.2773      1.000 0.000 0.000 0.000 0.836 0.164
#> SRR1562752     4  0.2773      1.000 0.000 0.000 0.000 0.836 0.164
#> SRR1562753     4  0.2773      1.000 0.000 0.000 0.000 0.836 0.164
#> SRR1562754     5  0.2712      0.906 0.000 0.088 0.000 0.032 0.880
#> SRR1562755     5  0.2712      0.906 0.000 0.088 0.000 0.032 0.880
#> SRR1562756     5  0.2712      0.906 0.000 0.088 0.000 0.032 0.880
#> SRR1562757     5  0.2712      0.906 0.000 0.088 0.000 0.032 0.880
#> SRR1562758     5  0.2712      0.906 0.000 0.088 0.000 0.032 0.880
#> SRR1562759     5  0.2769      0.908 0.000 0.092 0.000 0.032 0.876
#> SRR1562792     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000
#> SRR1562793     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000
#> SRR1562794     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000
#> SRR1562795     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000
#> SRR1562796     3  0.0162      0.998 0.000 0.000 0.996 0.004 0.000
#> SRR1562797     3  0.0162      0.998 0.000 0.000 0.996 0.004 0.000
#> SRR1562798     3  0.0162      0.998 0.000 0.000 0.996 0.004 0.000
#> SRR1562799     3  0.0162      0.998 0.000 0.000 0.996 0.004 0.000
#> SRR1562800     1  0.3216      0.918 0.848 0.000 0.000 0.108 0.044
#> SRR1562801     1  0.3216      0.918 0.848 0.000 0.000 0.108 0.044
#> SRR1562802     1  0.3112      0.920 0.856 0.000 0.000 0.100 0.044
#> SRR1562803     1  0.3112      0.920 0.856 0.000 0.000 0.100 0.044
#> SRR1562804     1  0.3216      0.918 0.848 0.000 0.000 0.108 0.044
#> SRR1562805     1  0.3216      0.918 0.848 0.000 0.000 0.108 0.044
#> SRR1562806     1  0.0000      0.941 1.000 0.000 0.000 0.000 0.000
#> SRR1562807     1  0.0000      0.941 1.000 0.000 0.000 0.000 0.000
#> SRR1562808     1  0.0000      0.941 1.000 0.000 0.000 0.000 0.000
#> SRR1562809     1  0.0000      0.941 1.000 0.000 0.000 0.000 0.000
#> SRR1562810     1  0.0000      0.941 1.000 0.000 0.000 0.000 0.000
#> SRR1562811     1  0.0000      0.941 1.000 0.000 0.000 0.000 0.000
#> SRR1562812     1  0.0000      0.941 1.000 0.000 0.000 0.000 0.000
#> SRR1562813     1  0.0000      0.941 1.000 0.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR1562718     5  0.4331    -0.3479 0.000 0.464 0.000 0.000 0.516 0.020
#> SRR1562719     5  0.4310    -0.2954 0.000 0.440 0.000 0.000 0.540 0.020
#> SRR1562720     2  0.4331     0.3661 0.000 0.516 0.000 0.000 0.464 0.020
#> SRR1562721     2  0.4318     0.3877 0.000 0.532 0.000 0.000 0.448 0.020
#> SRR1562723     2  0.4337     0.3356 0.000 0.500 0.000 0.000 0.480 0.020
#> SRR1562724     5  0.4301    -0.1861 0.000 0.400 0.000 0.004 0.580 0.016
#> SRR1562725     5  0.4284    -0.1674 0.000 0.392 0.000 0.004 0.588 0.016
#> SRR1562726     5  0.4099    -0.1184 0.000 0.372 0.000 0.000 0.612 0.016
#> SRR1562727     5  0.4378    -0.1587 0.000 0.388 0.000 0.008 0.588 0.016
#> SRR1562728     5  0.4368    -0.1520 0.000 0.384 0.000 0.008 0.592 0.016
#> SRR1562729     5  0.4266    -0.0793 0.000 0.348 0.000 0.008 0.628 0.016
#> SRR1562730     2  0.0713     0.7794 0.000 0.972 0.000 0.000 0.028 0.000
#> SRR1562731     2  0.0713     0.7794 0.000 0.972 0.000 0.000 0.028 0.000
#> SRR1562732     2  0.0713     0.7794 0.000 0.972 0.000 0.000 0.028 0.000
#> SRR1562733     2  0.0713     0.7794 0.000 0.972 0.000 0.000 0.028 0.000
#> SRR1562734     2  0.0713     0.7794 0.000 0.972 0.000 0.000 0.028 0.000
#> SRR1562735     2  0.0713     0.7794 0.000 0.972 0.000 0.000 0.028 0.000
#> SRR1562736     5  0.1151     0.4830 0.000 0.000 0.000 0.032 0.956 0.012
#> SRR1562737     5  0.1074     0.4841 0.000 0.000 0.000 0.028 0.960 0.012
#> SRR1562738     5  0.1196     0.4784 0.000 0.000 0.000 0.040 0.952 0.008
#> SRR1562739     5  0.0777     0.4837 0.000 0.000 0.000 0.024 0.972 0.004
#> SRR1562740     5  0.0858     0.4830 0.000 0.000 0.000 0.028 0.968 0.004
#> SRR1562741     5  0.0937     0.4779 0.000 0.000 0.000 0.040 0.960 0.000
#> SRR1562742     5  0.4076     0.5462 0.000 0.012 0.000 0.000 0.592 0.396
#> SRR1562743     5  0.4101     0.5441 0.000 0.012 0.000 0.000 0.580 0.408
#> SRR1562744     5  0.4084     0.5456 0.000 0.012 0.000 0.000 0.588 0.400
#> SRR1562745     5  0.4066     0.5464 0.000 0.012 0.000 0.000 0.596 0.392
#> SRR1562746     5  0.4084     0.5456 0.000 0.012 0.000 0.000 0.588 0.400
#> SRR1562747     5  0.4076     0.5463 0.000 0.012 0.000 0.000 0.592 0.396
#> SRR1562748     4  0.0458     1.0000 0.000 0.000 0.000 0.984 0.016 0.000
#> SRR1562749     4  0.0458     1.0000 0.000 0.000 0.000 0.984 0.016 0.000
#> SRR1562750     4  0.0458     1.0000 0.000 0.000 0.000 0.984 0.016 0.000
#> SRR1562751     4  0.0458     1.0000 0.000 0.000 0.000 0.984 0.016 0.000
#> SRR1562752     4  0.0458     1.0000 0.000 0.000 0.000 0.984 0.016 0.000
#> SRR1562753     4  0.0458     1.0000 0.000 0.000 0.000 0.984 0.016 0.000
#> SRR1562754     5  0.4780     0.5097 0.000 0.004 0.000 0.040 0.484 0.472
#> SRR1562755     5  0.4780     0.5097 0.000 0.004 0.000 0.040 0.484 0.472
#> SRR1562756     5  0.4779     0.5103 0.000 0.004 0.000 0.040 0.488 0.468
#> SRR1562757     5  0.4780     0.5097 0.000 0.004 0.000 0.040 0.484 0.472
#> SRR1562758     5  0.4780     0.5097 0.000 0.004 0.000 0.040 0.484 0.472
#> SRR1562759     5  0.4722     0.5133 0.000 0.004 0.000 0.036 0.492 0.468
#> SRR1562792     3  0.0146     0.9983 0.000 0.004 0.996 0.000 0.000 0.000
#> SRR1562793     3  0.0146     0.9983 0.000 0.004 0.996 0.000 0.000 0.000
#> SRR1562794     3  0.0146     0.9983 0.000 0.004 0.996 0.000 0.000 0.000
#> SRR1562795     3  0.0146     0.9983 0.000 0.004 0.996 0.000 0.000 0.000
#> SRR1562796     3  0.0000     0.9983 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1562797     3  0.0000     0.9983 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1562798     3  0.0000     0.9983 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1562799     3  0.0000     0.9983 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1562800     1  0.3499     0.8132 0.680 0.000 0.000 0.000 0.000 0.320
#> SRR1562801     1  0.3499     0.8132 0.680 0.000 0.000 0.000 0.000 0.320
#> SRR1562802     1  0.3499     0.8132 0.680 0.000 0.000 0.000 0.000 0.320
#> SRR1562803     1  0.3499     0.8132 0.680 0.000 0.000 0.000 0.000 0.320
#> SRR1562804     1  0.3499     0.8132 0.680 0.000 0.000 0.000 0.000 0.320
#> SRR1562805     1  0.3499     0.8132 0.680 0.000 0.000 0.000 0.000 0.320
#> SRR1562806     1  0.0551     0.8593 0.984 0.004 0.000 0.004 0.000 0.008
#> SRR1562807     1  0.0551     0.8593 0.984 0.004 0.000 0.004 0.000 0.008
#> SRR1562808     1  0.0653     0.8581 0.980 0.004 0.000 0.004 0.000 0.012
#> SRR1562809     1  0.0551     0.8593 0.984 0.004 0.000 0.004 0.000 0.008
#> SRR1562810     1  0.0146     0.8604 0.996 0.000 0.000 0.000 0.000 0.004
#> SRR1562811     1  0.0146     0.8604 0.996 0.000 0.000 0.000 0.000 0.004
#> SRR1562812     1  0.0146     0.8604 0.996 0.000 0.000 0.000 0.000 0.004
#> SRR1562813     1  0.0146     0.8604 0.996 0.000 0.000 0.000 0.000 0.004

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-NMF-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-NMF-collect-classes

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


MAD:hclust**

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

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

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

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

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4624 0.538   0.538
#> 3 3 1.000           1.000       1.000         0.1239 0.943   0.893
#> 4 4 1.000           0.996       0.997         0.3434 0.822   0.629
#> 5 5 0.837           0.842       0.865         0.0881 1.000   1.000
#> 6 6 0.856           0.930       0.901         0.0744 0.871   0.574

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette p1 p2
#> SRR1562718     2       0          1  0  1
#> SRR1562719     2       0          1  0  1
#> SRR1562720     2       0          1  0  1
#> SRR1562721     2       0          1  0  1
#> SRR1562723     2       0          1  0  1
#> SRR1562724     2       0          1  0  1
#> SRR1562725     2       0          1  0  1
#> SRR1562726     2       0          1  0  1
#> SRR1562727     2       0          1  0  1
#> SRR1562728     2       0          1  0  1
#> SRR1562729     2       0          1  0  1
#> SRR1562730     2       0          1  0  1
#> SRR1562731     2       0          1  0  1
#> SRR1562732     2       0          1  0  1
#> SRR1562733     2       0          1  0  1
#> SRR1562734     2       0          1  0  1
#> SRR1562735     2       0          1  0  1
#> SRR1562736     2       0          1  0  1
#> SRR1562737     2       0          1  0  1
#> SRR1562738     2       0          1  0  1
#> SRR1562739     2       0          1  0  1
#> SRR1562740     2       0          1  0  1
#> SRR1562741     2       0          1  0  1
#> SRR1562742     2       0          1  0  1
#> SRR1562743     2       0          1  0  1
#> SRR1562744     2       0          1  0  1
#> SRR1562745     2       0          1  0  1
#> SRR1562746     2       0          1  0  1
#> SRR1562747     2       0          1  0  1
#> SRR1562748     2       0          1  0  1
#> SRR1562749     2       0          1  0  1
#> SRR1562750     2       0          1  0  1
#> SRR1562751     2       0          1  0  1
#> SRR1562752     2       0          1  0  1
#> SRR1562753     2       0          1  0  1
#> SRR1562754     2       0          1  0  1
#> SRR1562755     2       0          1  0  1
#> SRR1562756     2       0          1  0  1
#> SRR1562757     2       0          1  0  1
#> SRR1562758     2       0          1  0  1
#> SRR1562759     2       0          1  0  1
#> SRR1562792     1       0          1  1  0
#> SRR1562793     1       0          1  1  0
#> SRR1562794     1       0          1  1  0
#> SRR1562795     1       0          1  1  0
#> SRR1562796     1       0          1  1  0
#> SRR1562797     1       0          1  1  0
#> SRR1562798     1       0          1  1  0
#> SRR1562799     1       0          1  1  0
#> SRR1562800     1       0          1  1  0
#> SRR1562801     1       0          1  1  0
#> SRR1562802     1       0          1  1  0
#> SRR1562803     1       0          1  1  0
#> SRR1562804     1       0          1  1  0
#> SRR1562805     1       0          1  1  0
#> SRR1562806     1       0          1  1  0
#> SRR1562807     1       0          1  1  0
#> SRR1562808     1       0          1  1  0
#> SRR1562809     1       0          1  1  0
#> SRR1562810     1       0          1  1  0
#> SRR1562811     1       0          1  1  0
#> SRR1562812     1       0          1  1  0
#> SRR1562813     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette p1 p2 p3
#> SRR1562718     2       0          1  0  1  0
#> SRR1562719     2       0          1  0  1  0
#> SRR1562720     2       0          1  0  1  0
#> SRR1562721     2       0          1  0  1  0
#> SRR1562723     2       0          1  0  1  0
#> SRR1562724     2       0          1  0  1  0
#> SRR1562725     2       0          1  0  1  0
#> SRR1562726     2       0          1  0  1  0
#> SRR1562727     2       0          1  0  1  0
#> SRR1562728     2       0          1  0  1  0
#> SRR1562729     2       0          1  0  1  0
#> SRR1562730     2       0          1  0  1  0
#> SRR1562731     2       0          1  0  1  0
#> SRR1562732     2       0          1  0  1  0
#> SRR1562733     2       0          1  0  1  0
#> SRR1562734     2       0          1  0  1  0
#> SRR1562735     2       0          1  0  1  0
#> SRR1562736     2       0          1  0  1  0
#> SRR1562737     2       0          1  0  1  0
#> SRR1562738     2       0          1  0  1  0
#> SRR1562739     2       0          1  0  1  0
#> SRR1562740     2       0          1  0  1  0
#> SRR1562741     2       0          1  0  1  0
#> SRR1562742     2       0          1  0  1  0
#> SRR1562743     2       0          1  0  1  0
#> SRR1562744     2       0          1  0  1  0
#> SRR1562745     2       0          1  0  1  0
#> SRR1562746     2       0          1  0  1  0
#> SRR1562747     2       0          1  0  1  0
#> SRR1562748     2       0          1  0  1  0
#> SRR1562749     2       0          1  0  1  0
#> SRR1562750     2       0          1  0  1  0
#> SRR1562751     2       0          1  0  1  0
#> SRR1562752     2       0          1  0  1  0
#> SRR1562753     2       0          1  0  1  0
#> SRR1562754     2       0          1  0  1  0
#> SRR1562755     2       0          1  0  1  0
#> SRR1562756     2       0          1  0  1  0
#> SRR1562757     2       0          1  0  1  0
#> SRR1562758     2       0          1  0  1  0
#> SRR1562759     2       0          1  0  1  0
#> SRR1562792     3       0          1  0  0  1
#> SRR1562793     3       0          1  0  0  1
#> SRR1562794     3       0          1  0  0  1
#> SRR1562795     3       0          1  0  0  1
#> SRR1562796     3       0          1  0  0  1
#> SRR1562797     3       0          1  0  0  1
#> SRR1562798     3       0          1  0  0  1
#> SRR1562799     3       0          1  0  0  1
#> SRR1562800     1       0          1  1  0  0
#> SRR1562801     1       0          1  1  0  0
#> SRR1562802     1       0          1  1  0  0
#> SRR1562803     1       0          1  1  0  0
#> SRR1562804     1       0          1  1  0  0
#> SRR1562805     1       0          1  1  0  0
#> SRR1562806     1       0          1  1  0  0
#> SRR1562807     1       0          1  1  0  0
#> SRR1562808     1       0          1  1  0  0
#> SRR1562809     1       0          1  1  0  0
#> SRR1562810     1       0          1  1  0  0
#> SRR1562811     1       0          1  1  0  0
#> SRR1562812     1       0          1  1  0  0
#> SRR1562813     1       0          1  1  0  0

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette p1    p2 p3    p4
#> SRR1562718     2  0.0000      0.993  0 1.000  0 0.000
#> SRR1562719     2  0.0000      0.993  0 1.000  0 0.000
#> SRR1562720     2  0.0000      0.993  0 1.000  0 0.000
#> SRR1562721     2  0.0000      0.993  0 1.000  0 0.000
#> SRR1562723     2  0.0000      0.993  0 1.000  0 0.000
#> SRR1562724     2  0.0000      0.993  0 1.000  0 0.000
#> SRR1562725     2  0.0000      0.993  0 1.000  0 0.000
#> SRR1562726     2  0.0000      0.993  0 1.000  0 0.000
#> SRR1562727     2  0.0000      0.993  0 1.000  0 0.000
#> SRR1562728     2  0.0000      0.993  0 1.000  0 0.000
#> SRR1562729     2  0.0000      0.993  0 1.000  0 0.000
#> SRR1562730     2  0.0000      0.993  0 1.000  0 0.000
#> SRR1562731     2  0.0000      0.993  0 1.000  0 0.000
#> SRR1562732     2  0.0000      0.993  0 1.000  0 0.000
#> SRR1562733     2  0.0000      0.993  0 1.000  0 0.000
#> SRR1562734     2  0.0000      0.993  0 1.000  0 0.000
#> SRR1562735     2  0.0000      0.993  0 1.000  0 0.000
#> SRR1562736     2  0.0592      0.990  0 0.984  0 0.016
#> SRR1562737     2  0.0592      0.990  0 0.984  0 0.016
#> SRR1562738     2  0.0592      0.990  0 0.984  0 0.016
#> SRR1562739     2  0.0592      0.990  0 0.984  0 0.016
#> SRR1562740     2  0.0592      0.990  0 0.984  0 0.016
#> SRR1562741     2  0.0592      0.990  0 0.984  0 0.016
#> SRR1562742     2  0.0592      0.990  0 0.984  0 0.016
#> SRR1562743     2  0.0592      0.990  0 0.984  0 0.016
#> SRR1562744     2  0.0592      0.990  0 0.984  0 0.016
#> SRR1562745     2  0.0592      0.990  0 0.984  0 0.016
#> SRR1562746     2  0.0592      0.990  0 0.984  0 0.016
#> SRR1562747     2  0.0592      0.990  0 0.984  0 0.016
#> SRR1562748     4  0.0000      1.000  0 0.000  0 1.000
#> SRR1562749     4  0.0000      1.000  0 0.000  0 1.000
#> SRR1562750     4  0.0000      1.000  0 0.000  0 1.000
#> SRR1562751     4  0.0000      1.000  0 0.000  0 1.000
#> SRR1562752     4  0.0000      1.000  0 0.000  0 1.000
#> SRR1562753     4  0.0000      1.000  0 0.000  0 1.000
#> SRR1562754     4  0.0000      1.000  0 0.000  0 1.000
#> SRR1562755     4  0.0000      1.000  0 0.000  0 1.000
#> SRR1562756     4  0.0000      1.000  0 0.000  0 1.000
#> SRR1562757     4  0.0000      1.000  0 0.000  0 1.000
#> SRR1562758     4  0.0000      1.000  0 0.000  0 1.000
#> SRR1562759     4  0.0000      1.000  0 0.000  0 1.000
#> SRR1562792     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1562793     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1562794     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1562795     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1562796     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1562797     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1562798     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1562799     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1562800     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1562801     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1562802     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1562803     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1562804     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1562805     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1562806     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1562807     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1562808     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1562809     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1562810     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1562811     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1562812     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1562813     1  0.0000      1.000  1 0.000  0 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette  p1  p2 p3    p4    p5
#> SRR1562718     2   0.000      0.803 0.0 1.0  0 0.000 0.000
#> SRR1562719     2   0.000      0.803 0.0 1.0  0 0.000 0.000
#> SRR1562720     2   0.000      0.803 0.0 1.0  0 0.000 0.000
#> SRR1562721     2   0.000      0.803 0.0 1.0  0 0.000 0.000
#> SRR1562723     2   0.000      0.803 0.0 1.0  0 0.000 0.000
#> SRR1562724     2   0.000      0.803 0.0 1.0  0 0.000 0.000
#> SRR1562725     2   0.000      0.803 0.0 1.0  0 0.000 0.000
#> SRR1562726     2   0.000      0.803 0.0 1.0  0 0.000 0.000
#> SRR1562727     2   0.000      0.803 0.0 1.0  0 0.000 0.000
#> SRR1562728     2   0.000      0.803 0.0 1.0  0 0.000 0.000
#> SRR1562729     2   0.000      0.803 0.0 1.0  0 0.000 0.000
#> SRR1562730     2   0.380      0.626 0.0 0.7  0 0.000 0.300
#> SRR1562731     2   0.380      0.626 0.0 0.7  0 0.000 0.300
#> SRR1562732     2   0.380      0.626 0.0 0.7  0 0.000 0.300
#> SRR1562733     2   0.380      0.626 0.0 0.7  0 0.000 0.300
#> SRR1562734     2   0.380      0.626 0.0 0.7  0 0.000 0.300
#> SRR1562735     2   0.380      0.626 0.0 0.7  0 0.000 0.300
#> SRR1562736     2   0.380      0.770 0.0 0.7  0 0.000 0.300
#> SRR1562737     2   0.380      0.770 0.0 0.7  0 0.000 0.300
#> SRR1562738     2   0.380      0.770 0.0 0.7  0 0.000 0.300
#> SRR1562739     2   0.380      0.770 0.0 0.7  0 0.000 0.300
#> SRR1562740     2   0.380      0.770 0.0 0.7  0 0.000 0.300
#> SRR1562741     2   0.380      0.770 0.0 0.7  0 0.000 0.300
#> SRR1562742     2   0.380      0.770 0.0 0.7  0 0.000 0.300
#> SRR1562743     2   0.380      0.770 0.0 0.7  0 0.000 0.300
#> SRR1562744     2   0.380      0.770 0.0 0.7  0 0.000 0.300
#> SRR1562745     2   0.380      0.770 0.0 0.7  0 0.000 0.300
#> SRR1562746     2   0.380      0.770 0.0 0.7  0 0.000 0.300
#> SRR1562747     2   0.380      0.770 0.0 0.7  0 0.000 0.300
#> SRR1562748     4   0.000      0.990 0.0 0.0  0 1.000 0.000
#> SRR1562749     4   0.000      0.990 0.0 0.0  0 1.000 0.000
#> SRR1562750     4   0.000      0.990 0.0 0.0  0 1.000 0.000
#> SRR1562751     4   0.000      0.990 0.0 0.0  0 1.000 0.000
#> SRR1562752     4   0.000      0.990 0.0 0.0  0 1.000 0.000
#> SRR1562753     4   0.000      0.990 0.0 0.0  0 1.000 0.000
#> SRR1562754     4   0.051      0.990 0.0 0.0  0 0.984 0.016
#> SRR1562755     4   0.051      0.990 0.0 0.0  0 0.984 0.016
#> SRR1562756     4   0.051      0.990 0.0 0.0  0 0.984 0.016
#> SRR1562757     4   0.051      0.990 0.0 0.0  0 0.984 0.016
#> SRR1562758     4   0.051      0.990 0.0 0.0  0 0.984 0.016
#> SRR1562759     4   0.051      0.990 0.0 0.0  0 0.984 0.016
#> SRR1562792     3   0.000      1.000 0.0 0.0  1 0.000 0.000
#> SRR1562793     3   0.000      1.000 0.0 0.0  1 0.000 0.000
#> SRR1562794     3   0.000      1.000 0.0 0.0  1 0.000 0.000
#> SRR1562795     3   0.000      1.000 0.0 0.0  1 0.000 0.000
#> SRR1562796     3   0.000      1.000 0.0 0.0  1 0.000 0.000
#> SRR1562797     3   0.000      1.000 0.0 0.0  1 0.000 0.000
#> SRR1562798     3   0.000      1.000 0.0 0.0  1 0.000 0.000
#> SRR1562799     3   0.000      1.000 0.0 0.0  1 0.000 0.000
#> SRR1562800     1   0.000      0.776 1.0 0.0  0 0.000 0.000
#> SRR1562801     1   0.000      0.776 1.0 0.0  0 0.000 0.000
#> SRR1562802     1   0.000      0.776 1.0 0.0  0 0.000 0.000
#> SRR1562803     1   0.000      0.776 1.0 0.0  0 0.000 0.000
#> SRR1562804     1   0.000      0.776 1.0 0.0  0 0.000 0.000
#> SRR1562805     1   0.000      0.776 1.0 0.0  0 0.000 0.000
#> SRR1562806     1   0.418      0.838 0.6 0.0  0 0.000 0.400
#> SRR1562807     1   0.418      0.838 0.6 0.0  0 0.000 0.400
#> SRR1562808     1   0.418      0.838 0.6 0.0  0 0.000 0.400
#> SRR1562809     1   0.418      0.838 0.6 0.0  0 0.000 0.400
#> SRR1562810     1   0.418      0.838 0.6 0.0  0 0.000 0.400
#> SRR1562811     1   0.418      0.838 0.6 0.0  0 0.000 0.400
#> SRR1562812     1   0.418      0.838 0.6 0.0  0 0.000 0.400
#> SRR1562813     1   0.418      0.838 0.6 0.0  0 0.000 0.400

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2 p3    p4    p5    p6
#> SRR1562718     2  0.3330      0.838 0.000 0.716  0 0.000 0.284 0.000
#> SRR1562719     2  0.3330      0.838 0.000 0.716  0 0.000 0.284 0.000
#> SRR1562720     2  0.3330      0.838 0.000 0.716  0 0.000 0.284 0.000
#> SRR1562721     2  0.3330      0.838 0.000 0.716  0 0.000 0.284 0.000
#> SRR1562723     2  0.3330      0.838 0.000 0.716  0 0.000 0.284 0.000
#> SRR1562724     2  0.3330      0.838 0.000 0.716  0 0.000 0.284 0.000
#> SRR1562725     2  0.3330      0.838 0.000 0.716  0 0.000 0.284 0.000
#> SRR1562726     2  0.3330      0.838 0.000 0.716  0 0.000 0.284 0.000
#> SRR1562727     2  0.3330      0.838 0.000 0.716  0 0.000 0.284 0.000
#> SRR1562728     2  0.3330      0.838 0.000 0.716  0 0.000 0.284 0.000
#> SRR1562729     2  0.3330      0.838 0.000 0.716  0 0.000 0.284 0.000
#> SRR1562730     2  0.0865      0.729 0.000 0.964  0 0.000 0.000 0.036
#> SRR1562731     2  0.0865      0.729 0.000 0.964  0 0.000 0.000 0.036
#> SRR1562732     2  0.0865      0.729 0.000 0.964  0 0.000 0.000 0.036
#> SRR1562733     2  0.0865      0.729 0.000 0.964  0 0.000 0.000 0.036
#> SRR1562734     2  0.0865      0.729 0.000 0.964  0 0.000 0.000 0.036
#> SRR1562735     2  0.0865      0.729 0.000 0.964  0 0.000 0.000 0.036
#> SRR1562736     5  0.0000      1.000 0.000 0.000  0 0.000 1.000 0.000
#> SRR1562737     5  0.0000      1.000 0.000 0.000  0 0.000 1.000 0.000
#> SRR1562738     5  0.0000      1.000 0.000 0.000  0 0.000 1.000 0.000
#> SRR1562739     5  0.0000      1.000 0.000 0.000  0 0.000 1.000 0.000
#> SRR1562740     5  0.0000      1.000 0.000 0.000  0 0.000 1.000 0.000
#> SRR1562741     5  0.0000      1.000 0.000 0.000  0 0.000 1.000 0.000
#> SRR1562742     5  0.0000      1.000 0.000 0.000  0 0.000 1.000 0.000
#> SRR1562743     5  0.0000      1.000 0.000 0.000  0 0.000 1.000 0.000
#> SRR1562744     5  0.0000      1.000 0.000 0.000  0 0.000 1.000 0.000
#> SRR1562745     5  0.0000      1.000 0.000 0.000  0 0.000 1.000 0.000
#> SRR1562746     5  0.0000      1.000 0.000 0.000  0 0.000 1.000 0.000
#> SRR1562747     5  0.0000      1.000 0.000 0.000  0 0.000 1.000 0.000
#> SRR1562748     4  0.2527      0.918 0.000 0.000  0 0.832 0.000 0.168
#> SRR1562749     4  0.2527      0.918 0.000 0.000  0 0.832 0.000 0.168
#> SRR1562750     4  0.2527      0.918 0.000 0.000  0 0.832 0.000 0.168
#> SRR1562751     4  0.2527      0.918 0.000 0.000  0 0.832 0.000 0.168
#> SRR1562752     4  0.2527      0.918 0.000 0.000  0 0.832 0.000 0.168
#> SRR1562753     4  0.2527      0.918 0.000 0.000  0 0.832 0.000 0.168
#> SRR1562754     4  0.0260      0.918 0.000 0.000  0 0.992 0.008 0.000
#> SRR1562755     4  0.0260      0.918 0.000 0.000  0 0.992 0.008 0.000
#> SRR1562756     4  0.0260      0.918 0.000 0.000  0 0.992 0.008 0.000
#> SRR1562757     4  0.0260      0.918 0.000 0.000  0 0.992 0.008 0.000
#> SRR1562758     4  0.0260      0.918 0.000 0.000  0 0.992 0.008 0.000
#> SRR1562759     4  0.0260      0.918 0.000 0.000  0 0.992 0.008 0.000
#> SRR1562792     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1562793     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1562794     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1562795     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1562796     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1562797     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1562798     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1562799     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1562800     6  0.2823      1.000 0.204 0.000  0 0.000 0.000 0.796
#> SRR1562801     6  0.2823      1.000 0.204 0.000  0 0.000 0.000 0.796
#> SRR1562802     6  0.2823      1.000 0.204 0.000  0 0.000 0.000 0.796
#> SRR1562803     6  0.2823      1.000 0.204 0.000  0 0.000 0.000 0.796
#> SRR1562804     6  0.2823      1.000 0.204 0.000  0 0.000 0.000 0.796
#> SRR1562805     6  0.2823      1.000 0.204 0.000  0 0.000 0.000 0.796
#> SRR1562806     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> SRR1562807     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> SRR1562808     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> SRR1562809     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> SRR1562810     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> SRR1562811     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> SRR1562812     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> SRR1562813     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-hclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-hclust-collect-classes

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


MAD:kmeans**

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

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

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

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

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

collect_plots(res)

plot of chunk MAD-kmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.988       0.981         0.4436 0.538   0.538
#> 3 3 0.642           0.677       0.756         0.3504 0.822   0.669
#> 4 4 0.577           0.733       0.726         0.1486 0.822   0.589
#> 5 5 0.615           0.574       0.635         0.0803 0.820   0.524
#> 6 6 0.649           0.784       0.723         0.0545 0.951   0.801

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
#> SRR1562718     2   0.000      1.000 0.000 1.000
#> SRR1562719     2   0.000      1.000 0.000 1.000
#> SRR1562720     2   0.000      1.000 0.000 1.000
#> SRR1562721     2   0.000      1.000 0.000 1.000
#> SRR1562723     2   0.000      1.000 0.000 1.000
#> SRR1562724     2   0.000      1.000 0.000 1.000
#> SRR1562725     2   0.000      1.000 0.000 1.000
#> SRR1562726     2   0.000      1.000 0.000 1.000
#> SRR1562727     2   0.000      1.000 0.000 1.000
#> SRR1562728     2   0.000      1.000 0.000 1.000
#> SRR1562729     2   0.000      1.000 0.000 1.000
#> SRR1562730     2   0.000      1.000 0.000 1.000
#> SRR1562731     2   0.000      1.000 0.000 1.000
#> SRR1562732     2   0.000      1.000 0.000 1.000
#> SRR1562733     2   0.000      1.000 0.000 1.000
#> SRR1562734     2   0.000      1.000 0.000 1.000
#> SRR1562735     2   0.000      1.000 0.000 1.000
#> SRR1562736     2   0.000      1.000 0.000 1.000
#> SRR1562737     2   0.000      1.000 0.000 1.000
#> SRR1562738     2   0.000      1.000 0.000 1.000
#> SRR1562739     2   0.000      1.000 0.000 1.000
#> SRR1562740     2   0.000      1.000 0.000 1.000
#> SRR1562741     2   0.000      1.000 0.000 1.000
#> SRR1562742     2   0.000      1.000 0.000 1.000
#> SRR1562743     2   0.000      1.000 0.000 1.000
#> SRR1562744     2   0.000      1.000 0.000 1.000
#> SRR1562745     2   0.000      1.000 0.000 1.000
#> SRR1562746     2   0.000      1.000 0.000 1.000
#> SRR1562747     2   0.000      1.000 0.000 1.000
#> SRR1562748     2   0.000      1.000 0.000 1.000
#> SRR1562749     2   0.000      1.000 0.000 1.000
#> SRR1562750     2   0.000      1.000 0.000 1.000
#> SRR1562751     2   0.000      1.000 0.000 1.000
#> SRR1562752     2   0.000      1.000 0.000 1.000
#> SRR1562753     2   0.000      1.000 0.000 1.000
#> SRR1562754     2   0.000      1.000 0.000 1.000
#> SRR1562755     2   0.000      1.000 0.000 1.000
#> SRR1562756     2   0.000      1.000 0.000 1.000
#> SRR1562757     2   0.000      1.000 0.000 1.000
#> SRR1562758     2   0.000      1.000 0.000 1.000
#> SRR1562759     2   0.000      1.000 0.000 1.000
#> SRR1562792     1   0.184      0.954 0.972 0.028
#> SRR1562793     1   0.184      0.954 0.972 0.028
#> SRR1562794     1   0.184      0.954 0.972 0.028
#> SRR1562795     1   0.184      0.954 0.972 0.028
#> SRR1562796     1   0.184      0.954 0.972 0.028
#> SRR1562797     1   0.184      0.954 0.972 0.028
#> SRR1562798     1   0.184      0.954 0.972 0.028
#> SRR1562799     1   0.184      0.954 0.972 0.028
#> SRR1562800     1   0.358      0.973 0.932 0.068
#> SRR1562801     1   0.358      0.973 0.932 0.068
#> SRR1562802     1   0.358      0.973 0.932 0.068
#> SRR1562803     1   0.358      0.973 0.932 0.068
#> SRR1562804     1   0.358      0.973 0.932 0.068
#> SRR1562805     1   0.358      0.973 0.932 0.068
#> SRR1562806     1   0.358      0.973 0.932 0.068
#> SRR1562807     1   0.358      0.973 0.932 0.068
#> SRR1562808     1   0.358      0.973 0.932 0.068
#> SRR1562809     1   0.358      0.973 0.932 0.068
#> SRR1562810     1   0.358      0.973 0.932 0.068
#> SRR1562811     1   0.358      0.973 0.932 0.068
#> SRR1562812     1   0.358      0.973 0.932 0.068
#> SRR1562813     1   0.358      0.973 0.932 0.068

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1562718     2  0.0000      0.690 0.000 1.000 0.000
#> SRR1562719     2  0.0000      0.690 0.000 1.000 0.000
#> SRR1562720     2  0.0000      0.690 0.000 1.000 0.000
#> SRR1562721     2  0.0000      0.690 0.000 1.000 0.000
#> SRR1562723     2  0.0000      0.690 0.000 1.000 0.000
#> SRR1562724     2  0.0000      0.690 0.000 1.000 0.000
#> SRR1562725     2  0.0000      0.690 0.000 1.000 0.000
#> SRR1562726     2  0.0000      0.690 0.000 1.000 0.000
#> SRR1562727     2  0.0000      0.690 0.000 1.000 0.000
#> SRR1562728     2  0.0000      0.690 0.000 1.000 0.000
#> SRR1562729     2  0.0000      0.690 0.000 1.000 0.000
#> SRR1562730     2  0.2625      0.634 0.000 0.916 0.084
#> SRR1562731     2  0.2625      0.634 0.000 0.916 0.084
#> SRR1562732     2  0.2625      0.634 0.000 0.916 0.084
#> SRR1562733     2  0.2625      0.634 0.000 0.916 0.084
#> SRR1562734     2  0.2625      0.634 0.000 0.916 0.084
#> SRR1562735     2  0.2625      0.634 0.000 0.916 0.084
#> SRR1562736     2  0.5859     -0.143 0.000 0.656 0.344
#> SRR1562737     2  0.5859     -0.143 0.000 0.656 0.344
#> SRR1562738     2  0.5859     -0.143 0.000 0.656 0.344
#> SRR1562739     2  0.5859     -0.143 0.000 0.656 0.344
#> SRR1562740     2  0.5859     -0.143 0.000 0.656 0.344
#> SRR1562741     2  0.5859     -0.143 0.000 0.656 0.344
#> SRR1562742     2  0.5138      0.323 0.000 0.748 0.252
#> SRR1562743     2  0.5138      0.323 0.000 0.748 0.252
#> SRR1562744     2  0.5138      0.323 0.000 0.748 0.252
#> SRR1562745     2  0.5138      0.323 0.000 0.748 0.252
#> SRR1562746     2  0.5138      0.323 0.000 0.748 0.252
#> SRR1562747     2  0.5138      0.323 0.000 0.748 0.252
#> SRR1562748     3  0.6215      0.920 0.000 0.428 0.572
#> SRR1562749     3  0.6215      0.920 0.000 0.428 0.572
#> SRR1562750     3  0.6215      0.920 0.000 0.428 0.572
#> SRR1562751     3  0.6215      0.920 0.000 0.428 0.572
#> SRR1562752     3  0.6215      0.920 0.000 0.428 0.572
#> SRR1562753     3  0.6215      0.920 0.000 0.428 0.572
#> SRR1562754     3  0.6305      0.913 0.000 0.484 0.516
#> SRR1562755     3  0.6305      0.913 0.000 0.484 0.516
#> SRR1562756     3  0.6305      0.913 0.000 0.484 0.516
#> SRR1562757     3  0.6305      0.913 0.000 0.484 0.516
#> SRR1562758     3  0.6305      0.913 0.000 0.484 0.516
#> SRR1562759     3  0.6305      0.913 0.000 0.484 0.516
#> SRR1562792     1  0.0000      0.821 1.000 0.000 0.000
#> SRR1562793     1  0.0000      0.821 1.000 0.000 0.000
#> SRR1562794     1  0.0000      0.821 1.000 0.000 0.000
#> SRR1562795     1  0.0000      0.821 1.000 0.000 0.000
#> SRR1562796     1  0.0237      0.821 0.996 0.000 0.004
#> SRR1562797     1  0.0237      0.821 0.996 0.000 0.004
#> SRR1562798     1  0.0237      0.821 0.996 0.000 0.004
#> SRR1562799     1  0.0237      0.821 0.996 0.000 0.004
#> SRR1562800     1  0.6033      0.902 0.660 0.004 0.336
#> SRR1562801     1  0.6033      0.902 0.660 0.004 0.336
#> SRR1562802     1  0.6033      0.902 0.660 0.004 0.336
#> SRR1562803     1  0.6033      0.902 0.660 0.004 0.336
#> SRR1562804     1  0.6033      0.902 0.660 0.004 0.336
#> SRR1562805     1  0.6033      0.902 0.660 0.004 0.336
#> SRR1562806     1  0.6033      0.902 0.660 0.004 0.336
#> SRR1562807     1  0.6033      0.902 0.660 0.004 0.336
#> SRR1562808     1  0.6033      0.902 0.660 0.004 0.336
#> SRR1562809     1  0.6033      0.902 0.660 0.004 0.336
#> SRR1562810     1  0.6033      0.902 0.660 0.004 0.336
#> SRR1562811     1  0.6033      0.902 0.660 0.004 0.336
#> SRR1562812     1  0.6033      0.902 0.660 0.004 0.336
#> SRR1562813     1  0.6033      0.902 0.660 0.004 0.336

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2 p3    p4
#> SRR1562718     2  0.6967      0.856 0.000 0.456 NA 0.432
#> SRR1562719     2  0.6967      0.856 0.000 0.456 NA 0.432
#> SRR1562720     2  0.6967      0.856 0.000 0.456 NA 0.432
#> SRR1562721     2  0.6967      0.856 0.000 0.456 NA 0.432
#> SRR1562723     2  0.6967      0.856 0.000 0.456 NA 0.432
#> SRR1562724     2  0.7184      0.853 0.000 0.448 NA 0.416
#> SRR1562725     2  0.7184      0.853 0.000 0.448 NA 0.416
#> SRR1562726     2  0.7184      0.853 0.000 0.448 NA 0.416
#> SRR1562727     2  0.7184      0.853 0.000 0.448 NA 0.416
#> SRR1562728     2  0.7184      0.853 0.000 0.448 NA 0.416
#> SRR1562729     2  0.7184      0.853 0.000 0.448 NA 0.416
#> SRR1562730     2  0.4454      0.779 0.000 0.692 NA 0.308
#> SRR1562731     2  0.4454      0.779 0.000 0.692 NA 0.308
#> SRR1562732     2  0.4454      0.779 0.000 0.692 NA 0.308
#> SRR1562733     2  0.4454      0.779 0.000 0.692 NA 0.308
#> SRR1562734     2  0.4454      0.779 0.000 0.692 NA 0.308
#> SRR1562735     2  0.4454      0.779 0.000 0.692 NA 0.308
#> SRR1562736     4  0.0000      0.613 0.000 0.000 NA 1.000
#> SRR1562737     4  0.0000      0.613 0.000 0.000 NA 1.000
#> SRR1562738     4  0.0000      0.613 0.000 0.000 NA 1.000
#> SRR1562739     4  0.0000      0.613 0.000 0.000 NA 1.000
#> SRR1562740     4  0.0000      0.613 0.000 0.000 NA 1.000
#> SRR1562741     4  0.0000      0.613 0.000 0.000 NA 1.000
#> SRR1562742     4  0.3521      0.514 0.000 0.084 NA 0.864
#> SRR1562743     4  0.3521      0.514 0.000 0.084 NA 0.864
#> SRR1562744     4  0.3521      0.514 0.000 0.084 NA 0.864
#> SRR1562745     4  0.3521      0.514 0.000 0.084 NA 0.864
#> SRR1562746     4  0.3521      0.514 0.000 0.084 NA 0.864
#> SRR1562747     4  0.3521      0.514 0.000 0.084 NA 0.864
#> SRR1562748     4  0.7205      0.638 0.000 0.168 NA 0.528
#> SRR1562749     4  0.7222      0.638 0.000 0.172 NA 0.528
#> SRR1562750     4  0.7205      0.638 0.000 0.168 NA 0.528
#> SRR1562751     4  0.7222      0.638 0.000 0.172 NA 0.528
#> SRR1562752     4  0.7222      0.638 0.000 0.172 NA 0.528
#> SRR1562753     4  0.7205      0.638 0.000 0.168 NA 0.528
#> SRR1562754     4  0.6107      0.680 0.000 0.088 NA 0.648
#> SRR1562755     4  0.6107      0.680 0.000 0.088 NA 0.648
#> SRR1562756     4  0.6107      0.680 0.000 0.088 NA 0.648
#> SRR1562757     4  0.6107      0.680 0.000 0.088 NA 0.648
#> SRR1562758     4  0.6107      0.680 0.000 0.088 NA 0.648
#> SRR1562759     4  0.6107      0.680 0.000 0.088 NA 0.648
#> SRR1562792     1  0.5503      0.727 0.516 0.016 NA 0.000
#> SRR1562793     1  0.5503      0.727 0.516 0.016 NA 0.000
#> SRR1562794     1  0.5503      0.727 0.516 0.016 NA 0.000
#> SRR1562795     1  0.5503      0.727 0.516 0.016 NA 0.000
#> SRR1562796     1  0.4996      0.727 0.516 0.000 NA 0.000
#> SRR1562797     1  0.4996      0.727 0.516 0.000 NA 0.000
#> SRR1562798     1  0.4996      0.727 0.516 0.000 NA 0.000
#> SRR1562799     1  0.4996      0.727 0.516 0.000 NA 0.000
#> SRR1562800     1  0.2281      0.829 0.904 0.096 NA 0.000
#> SRR1562801     1  0.2281      0.829 0.904 0.096 NA 0.000
#> SRR1562802     1  0.2281      0.829 0.904 0.096 NA 0.000
#> SRR1562803     1  0.2281      0.829 0.904 0.096 NA 0.000
#> SRR1562804     1  0.2281      0.829 0.904 0.096 NA 0.000
#> SRR1562805     1  0.2281      0.829 0.904 0.096 NA 0.000
#> SRR1562806     1  0.0188      0.833 0.996 0.004 NA 0.000
#> SRR1562807     1  0.0188      0.833 0.996 0.004 NA 0.000
#> SRR1562808     1  0.0188      0.833 0.996 0.004 NA 0.000
#> SRR1562809     1  0.0188      0.833 0.996 0.004 NA 0.000
#> SRR1562810     1  0.0000      0.834 1.000 0.000 NA 0.000
#> SRR1562811     1  0.0000      0.834 1.000 0.000 NA 0.000
#> SRR1562812     1  0.0000      0.834 1.000 0.000 NA 0.000
#> SRR1562813     1  0.0000      0.834 1.000 0.000 NA 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
#> SRR1562718     2  0.2193      0.800 0.000 0.912 0.028 0.000 NA
#> SRR1562719     2  0.2193      0.800 0.000 0.912 0.028 0.000 NA
#> SRR1562720     2  0.2193      0.800 0.000 0.912 0.028 0.000 NA
#> SRR1562721     2  0.2193      0.800 0.000 0.912 0.028 0.000 NA
#> SRR1562723     2  0.2193      0.800 0.000 0.912 0.028 0.000 NA
#> SRR1562724     2  0.0798      0.793 0.000 0.976 0.008 0.000 NA
#> SRR1562725     2  0.0798      0.793 0.000 0.976 0.008 0.000 NA
#> SRR1562726     2  0.0798      0.793 0.000 0.976 0.008 0.000 NA
#> SRR1562727     2  0.0798      0.793 0.000 0.976 0.008 0.000 NA
#> SRR1562728     2  0.0798      0.793 0.000 0.976 0.008 0.000 NA
#> SRR1562729     2  0.0798      0.793 0.000 0.976 0.008 0.000 NA
#> SRR1562730     2  0.4738      0.689 0.000 0.564 0.012 0.004 NA
#> SRR1562731     2  0.4397      0.689 0.000 0.564 0.004 0.000 NA
#> SRR1562732     2  0.4738      0.689 0.000 0.564 0.012 0.004 NA
#> SRR1562733     2  0.4738      0.689 0.000 0.564 0.012 0.004 NA
#> SRR1562734     2  0.4682      0.689 0.000 0.564 0.016 0.000 NA
#> SRR1562735     2  0.4504      0.689 0.000 0.564 0.008 0.000 NA
#> SRR1562736     3  0.7032      0.086 0.000 0.340 0.364 0.288 NA
#> SRR1562737     3  0.7032      0.086 0.000 0.340 0.364 0.288 NA
#> SRR1562738     3  0.7032      0.086 0.000 0.340 0.364 0.288 NA
#> SRR1562739     3  0.7032      0.086 0.000 0.340 0.364 0.288 NA
#> SRR1562740     3  0.7032      0.086 0.000 0.340 0.364 0.288 NA
#> SRR1562741     3  0.7032      0.086 0.000 0.340 0.364 0.288 NA
#> SRR1562742     3  0.7934      0.203 0.000 0.348 0.364 0.192 NA
#> SRR1562743     3  0.7934      0.203 0.000 0.348 0.364 0.192 NA
#> SRR1562744     3  0.7934      0.203 0.000 0.348 0.364 0.192 NA
#> SRR1562745     3  0.7934      0.203 0.000 0.348 0.364 0.192 NA
#> SRR1562746     3  0.7934      0.203 0.000 0.348 0.364 0.192 NA
#> SRR1562747     3  0.7934      0.203 0.000 0.348 0.364 0.192 NA
#> SRR1562748     4  0.1732      0.817 0.000 0.080 0.000 0.920 NA
#> SRR1562749     4  0.1732      0.817 0.000 0.080 0.000 0.920 NA
#> SRR1562750     4  0.2130      0.815 0.000 0.080 0.000 0.908 NA
#> SRR1562751     4  0.1732      0.817 0.000 0.080 0.000 0.920 NA
#> SRR1562752     4  0.1732      0.817 0.000 0.080 0.000 0.920 NA
#> SRR1562753     4  0.1732      0.817 0.000 0.080 0.000 0.920 NA
#> SRR1562754     4  0.6793      0.805 0.000 0.128 0.140 0.612 NA
#> SRR1562755     4  0.6789      0.805 0.000 0.128 0.144 0.612 NA
#> SRR1562756     4  0.6793      0.805 0.000 0.128 0.140 0.612 NA
#> SRR1562757     4  0.6789      0.805 0.000 0.128 0.144 0.612 NA
#> SRR1562758     4  0.6789      0.805 0.000 0.128 0.144 0.612 NA
#> SRR1562759     4  0.6789      0.805 0.000 0.128 0.144 0.612 NA
#> SRR1562792     3  0.6451     -0.121 0.364 0.000 0.452 0.000 NA
#> SRR1562793     3  0.6451     -0.121 0.364 0.000 0.452 0.000 NA
#> SRR1562794     3  0.6571     -0.122 0.364 0.000 0.452 0.004 NA
#> SRR1562795     3  0.6451     -0.121 0.364 0.000 0.452 0.000 NA
#> SRR1562796     3  0.6237     -0.122 0.364 0.000 0.500 0.004 NA
#> SRR1562797     3  0.6125     -0.122 0.364 0.000 0.500 0.000 NA
#> SRR1562798     3  0.6125     -0.122 0.364 0.000 0.500 0.000 NA
#> SRR1562799     3  0.6237     -0.122 0.364 0.000 0.500 0.004 NA
#> SRR1562800     1  0.3134      0.904 0.848 0.000 0.000 0.032 NA
#> SRR1562801     1  0.3134      0.904 0.848 0.000 0.000 0.032 NA
#> SRR1562802     1  0.3134      0.904 0.848 0.000 0.000 0.032 NA
#> SRR1562803     1  0.3134      0.904 0.848 0.000 0.000 0.032 NA
#> SRR1562804     1  0.3242      0.903 0.844 0.000 0.000 0.040 NA
#> SRR1562805     1  0.3242      0.903 0.844 0.000 0.000 0.040 NA
#> SRR1562806     1  0.1041      0.920 0.964 0.000 0.000 0.004 NA
#> SRR1562807     1  0.1041      0.920 0.964 0.000 0.000 0.004 NA
#> SRR1562808     1  0.1041      0.920 0.964 0.000 0.000 0.004 NA
#> SRR1562809     1  0.1041      0.920 0.964 0.000 0.000 0.004 NA
#> SRR1562810     1  0.0609      0.923 0.980 0.000 0.000 0.020 NA
#> SRR1562811     1  0.0609      0.923 0.980 0.000 0.000 0.020 NA
#> SRR1562812     1  0.0609      0.923 0.980 0.000 0.000 0.020 NA
#> SRR1562813     1  0.0609      0.923 0.980 0.000 0.000 0.020 NA

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5 p6
#> SRR1562718     2  0.4584      0.740 0.000 0.688 0.052 0.016 0.244 NA
#> SRR1562719     2  0.4584      0.740 0.000 0.688 0.052 0.016 0.244 NA
#> SRR1562720     2  0.4584      0.740 0.000 0.688 0.052 0.016 0.244 NA
#> SRR1562721     2  0.4584      0.740 0.000 0.688 0.052 0.016 0.244 NA
#> SRR1562723     2  0.4584      0.740 0.000 0.688 0.052 0.016 0.244 NA
#> SRR1562724     2  0.4762      0.731 0.000 0.716 0.028 0.024 0.204 NA
#> SRR1562725     2  0.4762      0.731 0.000 0.716 0.028 0.024 0.204 NA
#> SRR1562726     2  0.4762      0.731 0.000 0.716 0.024 0.028 0.204 NA
#> SRR1562727     2  0.4762      0.731 0.000 0.716 0.028 0.024 0.204 NA
#> SRR1562728     2  0.4833      0.731 0.000 0.712 0.032 0.024 0.204 NA
#> SRR1562729     2  0.4836      0.731 0.000 0.712 0.028 0.028 0.204 NA
#> SRR1562730     2  0.6328      0.669 0.000 0.560 0.036 0.016 0.144 NA
#> SRR1562731     2  0.6445      0.669 0.000 0.552 0.044 0.016 0.144 NA
#> SRR1562732     2  0.6446      0.669 0.000 0.556 0.040 0.020 0.144 NA
#> SRR1562733     2  0.6446      0.669 0.000 0.556 0.040 0.020 0.144 NA
#> SRR1562734     2  0.6782      0.669 0.000 0.548 0.052 0.036 0.144 NA
#> SRR1562735     2  0.6445      0.669 0.000 0.552 0.044 0.016 0.144 NA
#> SRR1562736     5  0.3001      0.808 0.000 0.028 0.008 0.108 0.852 NA
#> SRR1562737     5  0.3001      0.808 0.000 0.028 0.008 0.108 0.852 NA
#> SRR1562738     5  0.3001      0.808 0.000 0.028 0.008 0.108 0.852 NA
#> SRR1562739     5  0.3001      0.808 0.000 0.028 0.008 0.108 0.852 NA
#> SRR1562740     5  0.3001      0.808 0.000 0.028 0.008 0.108 0.852 NA
#> SRR1562741     5  0.3001      0.808 0.000 0.028 0.008 0.108 0.852 NA
#> SRR1562742     5  0.3132      0.824 0.000 0.032 0.064 0.008 0.864 NA
#> SRR1562743     5  0.3073      0.824 0.000 0.032 0.060 0.008 0.868 NA
#> SRR1562744     5  0.3085      0.824 0.000 0.032 0.056 0.008 0.868 NA
#> SRR1562745     5  0.3132      0.824 0.000 0.032 0.064 0.008 0.864 NA
#> SRR1562746     5  0.3073      0.824 0.000 0.032 0.060 0.008 0.868 NA
#> SRR1562747     5  0.3073      0.824 0.000 0.032 0.060 0.008 0.868 NA
#> SRR1562748     4  0.6534      0.749 0.000 0.040 0.008 0.504 0.172 NA
#> SRR1562749     4  0.6238      0.749 0.000 0.032 0.000 0.504 0.172 NA
#> SRR1562750     4  0.6356      0.749 0.000 0.032 0.004 0.504 0.172 NA
#> SRR1562751     4  0.6534      0.749 0.000 0.040 0.008 0.504 0.172 NA
#> SRR1562752     4  0.6448      0.749 0.000 0.040 0.004 0.504 0.172 NA
#> SRR1562753     4  0.6238      0.749 0.000 0.032 0.000 0.504 0.172 NA
#> SRR1562754     4  0.3536      0.722 0.000 0.008 0.004 0.736 0.252 NA
#> SRR1562755     4  0.3398      0.722 0.000 0.008 0.000 0.740 0.252 NA
#> SRR1562756     4  0.3989      0.721 0.000 0.008 0.024 0.716 0.252 NA
#> SRR1562757     4  0.3911      0.721 0.000 0.008 0.020 0.720 0.252 NA
#> SRR1562758     4  0.3740      0.722 0.000 0.012 0.008 0.728 0.252 NA
#> SRR1562759     4  0.3398      0.722 0.000 0.008 0.000 0.740 0.252 NA
#> SRR1562792     3  0.5518      0.933 0.248 0.032 0.640 0.020 0.000 NA
#> SRR1562793     3  0.5518      0.933 0.248 0.032 0.640 0.020 0.000 NA
#> SRR1562794     3  0.5518      0.933 0.248 0.032 0.640 0.020 0.000 NA
#> SRR1562795     3  0.5518      0.933 0.248 0.032 0.640 0.020 0.000 NA
#> SRR1562796     3  0.3620      0.930 0.248 0.000 0.736 0.008 0.008 NA
#> SRR1562797     3  0.3651      0.930 0.248 0.000 0.736 0.004 0.008 NA
#> SRR1562798     3  0.3558      0.930 0.248 0.000 0.736 0.000 0.000 NA
#> SRR1562799     3  0.3608      0.930 0.248 0.000 0.736 0.000 0.004 NA
#> SRR1562800     1  0.0146      0.779 0.996 0.004 0.000 0.000 0.000 NA
#> SRR1562801     1  0.0146      0.779 0.996 0.004 0.000 0.000 0.000 NA
#> SRR1562802     1  0.0146      0.779 0.996 0.000 0.000 0.000 0.000 NA
#> SRR1562803     1  0.0146      0.779 0.996 0.000 0.000 0.000 0.000 NA
#> SRR1562804     1  0.0692      0.778 0.976 0.004 0.000 0.020 0.000 NA
#> SRR1562805     1  0.0692      0.778 0.976 0.004 0.000 0.020 0.000 NA
#> SRR1562806     1  0.4496      0.819 0.696 0.024 0.000 0.036 0.000 NA
#> SRR1562807     1  0.4484      0.819 0.696 0.020 0.000 0.040 0.000 NA
#> SRR1562808     1  0.4484      0.819 0.696 0.020 0.000 0.040 0.000 NA
#> SRR1562809     1  0.4484      0.819 0.696 0.020 0.000 0.040 0.000 NA
#> SRR1562810     1  0.3371      0.823 0.708 0.000 0.000 0.000 0.000 NA
#> SRR1562811     1  0.3371      0.823 0.708 0.000 0.000 0.000 0.000 NA
#> SRR1562812     1  0.3371      0.823 0.708 0.000 0.000 0.000 0.000 NA
#> SRR1562813     1  0.3371      0.823 0.708 0.000 0.000 0.000 0.000 NA

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-kmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-MAD-kmeans-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-kmeans-collect-classes

If matrix rows can be associated to genes, consider to use functional_enrichment(res, ...) to perform function enrichment for the signature genes. See this vignette for more detailed explanations.


MAD:skmeans*

The object with results only for a single top-value method and a single partition method can be extracted as:

res = res_list["MAD", "skmeans"]
# you can also extract it by
# res = res_list["MAD:skmeans"]

A summary of res and all the functions that can be applied to it:

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 15301 rows and 63 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'skmeans' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 6.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

collect_plots() function collects all the plots made from res for all k (number of partitions) into one single page to provide an easy and fast comparison between different k.

collect_plots(res)

plot of chunk MAD-skmeans-collect-plots

The plots are:

All the plots in panels can be made by individual functions and they are plotted later in this section.

select_partition_number() produces several plots showing different statistics for choosing “optimized” k. There are following statistics:

The detailed explanations of these statistics can be found in the cola vignette.

Generally speaking, lower PAC score, higher mean silhouette score or higher concordance corresponds to better partition. Rand index and Jaccard index measure how similar the current partition is compared to partition with k-1. If they are too similar, we won't accept k is better than k-1.

select_partition_number(res)

plot of chunk MAD-skmeans-select-partition-number

The numeric values for all these statistics can be obtained by get_stats().

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4624 0.538   0.538
#> 3 3 0.764           0.940       0.871         0.2809 0.822   0.669
#> 4 4 0.822           0.925       0.944         0.1943 0.943   0.841
#> 5 5 0.877           0.955       0.947         0.1174 0.896   0.655
#> 6 6 0.948           0.950       0.920         0.0406 0.982   0.907

suggest_best_k() suggests the best \(k\) based on these statistics. The rules are as follows:

suggest_best_k(res)
#> [1] 6
#> attr(,"optional")
#> [1] 2

There is also optional best \(k\) = 2 that is worth to check.

Following shows the table of the partitions (You need to click the show/hide code output link to see it). The membership matrix (columns with name p*) is inferred by clue::cl_consensus() function with the SE method. Basically the value in the membership matrix represents the probability to belong to a certain group. The finall class label for an item is determined with the group with highest probability it belongs to.

In get_classes() function, the entropy is calculated from the membership matrix and the silhouette score is calculated from the consensus matrix.

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette p1 p2
#> SRR1562718     2       0          1  0  1
#> SRR1562719     2       0          1  0  1
#> SRR1562720     2       0          1  0  1
#> SRR1562721     2       0          1  0  1
#> SRR1562723     2       0          1  0  1
#> SRR1562724     2       0          1  0  1
#> SRR1562725     2       0          1  0  1
#> SRR1562726     2       0          1  0  1
#> SRR1562727     2       0          1  0  1
#> SRR1562728     2       0          1  0  1
#> SRR1562729     2       0          1  0  1
#> SRR1562730     2       0          1  0  1
#> SRR1562731     2       0          1  0  1
#> SRR1562732     2       0          1  0  1
#> SRR1562733     2       0          1  0  1
#> SRR1562734     2       0          1  0  1
#> SRR1562735     2       0          1  0  1
#> SRR1562736     2       0          1  0  1
#> SRR1562737     2       0          1  0  1
#> SRR1562738     2       0          1  0  1
#> SRR1562739     2       0          1  0  1
#> SRR1562740     2       0          1  0  1
#> SRR1562741     2       0          1  0  1
#> SRR1562742     2       0          1  0  1
#> SRR1562743     2       0          1  0  1
#> SRR1562744     2       0          1  0  1
#> SRR1562745     2       0          1  0  1
#> SRR1562746     2       0          1  0  1
#> SRR1562747     2       0          1  0  1
#> SRR1562748     2       0          1  0  1
#> SRR1562749     2       0          1  0  1
#> SRR1562750     2       0          1  0  1
#> SRR1562751     2       0          1  0  1
#> SRR1562752     2       0          1  0  1
#> SRR1562753     2       0          1  0  1
#> SRR1562754     2       0          1  0  1
#> SRR1562755     2       0          1  0  1
#> SRR1562756     2       0          1  0  1
#> SRR1562757     2       0          1  0  1
#> SRR1562758     2       0          1  0  1
#> SRR1562759     2       0          1  0  1
#> SRR1562792     1       0          1  1  0
#> SRR1562793     1       0          1  1  0
#> SRR1562794     1       0          1  1  0
#> SRR1562795     1       0          1  1  0
#> SRR1562796     1       0          1  1  0
#> SRR1562797     1       0          1  1  0
#> SRR1562798     1       0          1  1  0
#> SRR1562799     1       0          1  1  0
#> SRR1562800     1       0          1  1  0
#> SRR1562801     1       0          1  1  0
#> SRR1562802     1       0          1  1  0
#> SRR1562803     1       0          1  1  0
#> SRR1562804     1       0          1  1  0
#> SRR1562805     1       0          1  1  0
#> SRR1562806     1       0          1  1  0
#> SRR1562807     1       0          1  1  0
#> SRR1562808     1       0          1  1  0
#> SRR1562809     1       0          1  1  0
#> SRR1562810     1       0          1  1  0
#> SRR1562811     1       0          1  1  0
#> SRR1562812     1       0          1  1  0
#> SRR1562813     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette  p1    p2    p3
#> SRR1562718     2   0.613      0.994 0.0 0.600 0.400
#> SRR1562719     2   0.613      0.994 0.0 0.600 0.400
#> SRR1562720     2   0.613      0.994 0.0 0.600 0.400
#> SRR1562721     2   0.613      0.994 0.0 0.600 0.400
#> SRR1562723     2   0.613      0.994 0.0 0.600 0.400
#> SRR1562724     2   0.613      0.994 0.0 0.600 0.400
#> SRR1562725     2   0.613      0.994 0.0 0.600 0.400
#> SRR1562726     2   0.613      0.994 0.0 0.600 0.400
#> SRR1562727     2   0.613      0.994 0.0 0.600 0.400
#> SRR1562728     2   0.613      0.994 0.0 0.600 0.400
#> SRR1562729     2   0.613      0.994 0.0 0.600 0.400
#> SRR1562730     2   0.613      0.994 0.0 0.600 0.400
#> SRR1562731     2   0.613      0.994 0.0 0.600 0.400
#> SRR1562732     2   0.613      0.994 0.0 0.600 0.400
#> SRR1562733     2   0.613      0.994 0.0 0.600 0.400
#> SRR1562734     2   0.613      0.994 0.0 0.600 0.400
#> SRR1562735     2   0.613      0.994 0.0 0.600 0.400
#> SRR1562736     2   0.615      0.992 0.0 0.592 0.408
#> SRR1562737     2   0.615      0.992 0.0 0.592 0.408
#> SRR1562738     2   0.615      0.992 0.0 0.592 0.408
#> SRR1562739     2   0.615      0.992 0.0 0.592 0.408
#> SRR1562740     2   0.615      0.992 0.0 0.592 0.408
#> SRR1562741     2   0.615      0.992 0.0 0.592 0.408
#> SRR1562742     2   0.615      0.992 0.0 0.592 0.408
#> SRR1562743     2   0.615      0.992 0.0 0.592 0.408
#> SRR1562744     2   0.615      0.992 0.0 0.592 0.408
#> SRR1562745     2   0.615      0.992 0.0 0.592 0.408
#> SRR1562746     2   0.615      0.992 0.0 0.592 0.408
#> SRR1562747     2   0.615      0.992 0.0 0.592 0.408
#> SRR1562748     3   0.000      1.000 0.0 0.000 1.000
#> SRR1562749     3   0.000      1.000 0.0 0.000 1.000
#> SRR1562750     3   0.000      1.000 0.0 0.000 1.000
#> SRR1562751     3   0.000      1.000 0.0 0.000 1.000
#> SRR1562752     3   0.000      1.000 0.0 0.000 1.000
#> SRR1562753     3   0.000      1.000 0.0 0.000 1.000
#> SRR1562754     3   0.000      1.000 0.0 0.000 1.000
#> SRR1562755     3   0.000      1.000 0.0 0.000 1.000
#> SRR1562756     3   0.000      1.000 0.0 0.000 1.000
#> SRR1562757     3   0.000      1.000 0.0 0.000 1.000
#> SRR1562758     3   0.000      1.000 0.0 0.000 1.000
#> SRR1562759     3   0.000      1.000 0.0 0.000 1.000
#> SRR1562792     1   0.613      0.771 0.6 0.400 0.000
#> SRR1562793     1   0.613      0.771 0.6 0.400 0.000
#> SRR1562794     1   0.613      0.771 0.6 0.400 0.000
#> SRR1562795     1   0.613      0.771 0.6 0.400 0.000
#> SRR1562796     1   0.613      0.771 0.6 0.400 0.000
#> SRR1562797     1   0.613      0.771 0.6 0.400 0.000
#> SRR1562798     1   0.613      0.771 0.6 0.400 0.000
#> SRR1562799     1   0.613      0.771 0.6 0.400 0.000
#> SRR1562800     1   0.000      0.877 1.0 0.000 0.000
#> SRR1562801     1   0.000      0.877 1.0 0.000 0.000
#> SRR1562802     1   0.000      0.877 1.0 0.000 0.000
#> SRR1562803     1   0.000      0.877 1.0 0.000 0.000
#> SRR1562804     1   0.000      0.877 1.0 0.000 0.000
#> SRR1562805     1   0.000      0.877 1.0 0.000 0.000
#> SRR1562806     1   0.000      0.877 1.0 0.000 0.000
#> SRR1562807     1   0.000      0.877 1.0 0.000 0.000
#> SRR1562808     1   0.000      0.877 1.0 0.000 0.000
#> SRR1562809     1   0.000      0.877 1.0 0.000 0.000
#> SRR1562810     1   0.000      0.877 1.0 0.000 0.000
#> SRR1562811     1   0.000      0.877 1.0 0.000 0.000
#> SRR1562812     1   0.000      0.877 1.0 0.000 0.000
#> SRR1562813     1   0.000      0.877 1.0 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
#> SRR1562718     2  0.0000      0.879 0.00 1.000 0.000 0.000
#> SRR1562719     2  0.0000      0.879 0.00 1.000 0.000 0.000
#> SRR1562720     2  0.0000      0.879 0.00 1.000 0.000 0.000
#> SRR1562721     2  0.0000      0.879 0.00 1.000 0.000 0.000
#> SRR1562723     2  0.0000      0.879 0.00 1.000 0.000 0.000
#> SRR1562724     2  0.0000      0.879 0.00 1.000 0.000 0.000
#> SRR1562725     2  0.0000      0.879 0.00 1.000 0.000 0.000
#> SRR1562726     2  0.0000      0.879 0.00 1.000 0.000 0.000
#> SRR1562727     2  0.0000      0.879 0.00 1.000 0.000 0.000
#> SRR1562728     2  0.0000      0.879 0.00 1.000 0.000 0.000
#> SRR1562729     2  0.0000      0.879 0.00 1.000 0.000 0.000
#> SRR1562730     2  0.0000      0.879 0.00 1.000 0.000 0.000
#> SRR1562731     2  0.0000      0.879 0.00 1.000 0.000 0.000
#> SRR1562732     2  0.0000      0.879 0.00 1.000 0.000 0.000
#> SRR1562733     2  0.0000      0.879 0.00 1.000 0.000 0.000
#> SRR1562734     2  0.0000      0.879 0.00 1.000 0.000 0.000
#> SRR1562735     2  0.0000      0.879 0.00 1.000 0.000 0.000
#> SRR1562736     2  0.5085      0.760 0.00 0.708 0.032 0.260
#> SRR1562737     2  0.5085      0.760 0.00 0.708 0.032 0.260
#> SRR1562738     2  0.5085      0.760 0.00 0.708 0.032 0.260
#> SRR1562739     2  0.5085      0.760 0.00 0.708 0.032 0.260
#> SRR1562740     2  0.5085      0.760 0.00 0.708 0.032 0.260
#> SRR1562741     2  0.5085      0.760 0.00 0.708 0.032 0.260
#> SRR1562742     2  0.4617      0.806 0.00 0.764 0.032 0.204
#> SRR1562743     2  0.4617      0.806 0.00 0.764 0.032 0.204
#> SRR1562744     2  0.4617      0.806 0.00 0.764 0.032 0.204
#> SRR1562745     2  0.4617      0.806 0.00 0.764 0.032 0.204
#> SRR1562746     2  0.4617      0.806 0.00 0.764 0.032 0.204
#> SRR1562747     2  0.4617      0.806 0.00 0.764 0.032 0.204
#> SRR1562748     4  0.0336      0.995 0.00 0.000 0.008 0.992
#> SRR1562749     4  0.0336      0.995 0.00 0.000 0.008 0.992
#> SRR1562750     4  0.0336      0.995 0.00 0.000 0.008 0.992
#> SRR1562751     4  0.0336      0.995 0.00 0.000 0.008 0.992
#> SRR1562752     4  0.0336      0.995 0.00 0.000 0.008 0.992
#> SRR1562753     4  0.0336      0.995 0.00 0.000 0.008 0.992
#> SRR1562754     4  0.0000      0.995 0.00 0.000 0.000 1.000
#> SRR1562755     4  0.0000      0.995 0.00 0.000 0.000 1.000
#> SRR1562756     4  0.0000      0.995 0.00 0.000 0.000 1.000
#> SRR1562757     4  0.0000      0.995 0.00 0.000 0.000 1.000
#> SRR1562758     4  0.0000      0.995 0.00 0.000 0.000 1.000
#> SRR1562759     4  0.0000      0.995 0.00 0.000 0.000 1.000
#> SRR1562792     3  0.1211      1.000 0.04 0.000 0.960 0.000
#> SRR1562793     3  0.1211      1.000 0.04 0.000 0.960 0.000
#> SRR1562794     3  0.1211      1.000 0.04 0.000 0.960 0.000
#> SRR1562795     3  0.1211      1.000 0.04 0.000 0.960 0.000
#> SRR1562796     3  0.1211      1.000 0.04 0.000 0.960 0.000
#> SRR1562797     3  0.1211      1.000 0.04 0.000 0.960 0.000
#> SRR1562798     3  0.1211      1.000 0.04 0.000 0.960 0.000
#> SRR1562799     3  0.1211      1.000 0.04 0.000 0.960 0.000
#> SRR1562800     1  0.0000      1.000 1.00 0.000 0.000 0.000
#> SRR1562801     1  0.0000      1.000 1.00 0.000 0.000 0.000
#> SRR1562802     1  0.0000      1.000 1.00 0.000 0.000 0.000
#> SRR1562803     1  0.0000      1.000 1.00 0.000 0.000 0.000
#> SRR1562804     1  0.0000      1.000 1.00 0.000 0.000 0.000
#> SRR1562805     1  0.0000      1.000 1.00 0.000 0.000 0.000
#> SRR1562806     1  0.0000      1.000 1.00 0.000 0.000 0.000
#> SRR1562807     1  0.0000      1.000 1.00 0.000 0.000 0.000
#> SRR1562808     1  0.0000      1.000 1.00 0.000 0.000 0.000
#> SRR1562809     1  0.0000      1.000 1.00 0.000 0.000 0.000
#> SRR1562810     1  0.0000      1.000 1.00 0.000 0.000 0.000
#> SRR1562811     1  0.0000      1.000 1.00 0.000 0.000 0.000
#> SRR1562812     1  0.0000      1.000 1.00 0.000 0.000 0.000
#> SRR1562813     1  0.0000      1.000 1.00 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2 p3    p4    p5
#> SRR1562718     2  0.2011      0.957 0.000 0.908  0 0.004 0.088
#> SRR1562719     2  0.2011      0.957 0.000 0.908  0 0.004 0.088
#> SRR1562720     2  0.2011      0.957 0.000 0.908  0 0.004 0.088
#> SRR1562721     2  0.2011      0.957 0.000 0.908  0 0.004 0.088
#> SRR1562723     2  0.2011      0.957 0.000 0.908  0 0.004 0.088
#> SRR1562724     2  0.1908      0.956 0.000 0.908  0 0.000 0.092
#> SRR1562725     2  0.1908      0.956 0.000 0.908  0 0.000 0.092
#> SRR1562726     2  0.1908      0.956 0.000 0.908  0 0.000 0.092
#> SRR1562727     2  0.1908      0.956 0.000 0.908  0 0.000 0.092
#> SRR1562728     2  0.1908      0.956 0.000 0.908  0 0.000 0.092
#> SRR1562729     2  0.1908      0.956 0.000 0.908  0 0.000 0.092
#> SRR1562730     2  0.0162      0.927 0.000 0.996  0 0.004 0.000
#> SRR1562731     2  0.0162      0.927 0.000 0.996  0 0.004 0.000
#> SRR1562732     2  0.0162      0.927 0.000 0.996  0 0.004 0.000
#> SRR1562733     2  0.0162      0.927 0.000 0.996  0 0.004 0.000
#> SRR1562734     2  0.0162      0.927 0.000 0.996  0 0.004 0.000
#> SRR1562735     2  0.0162      0.927 0.000 0.996  0 0.004 0.000
#> SRR1562736     5  0.1430      0.980 0.000 0.052  0 0.004 0.944
#> SRR1562737     5  0.1430      0.980 0.000 0.052  0 0.004 0.944
#> SRR1562738     5  0.1430      0.980 0.000 0.052  0 0.004 0.944
#> SRR1562739     5  0.1430      0.980 0.000 0.052  0 0.004 0.944
#> SRR1562740     5  0.1430      0.980 0.000 0.052  0 0.004 0.944
#> SRR1562741     5  0.1430      0.980 0.000 0.052  0 0.004 0.944
#> SRR1562742     5  0.1671      0.980 0.000 0.076  0 0.000 0.924
#> SRR1562743     5  0.1671      0.980 0.000 0.076  0 0.000 0.924
#> SRR1562744     5  0.1671      0.980 0.000 0.076  0 0.000 0.924
#> SRR1562745     5  0.1671      0.980 0.000 0.076  0 0.000 0.924
#> SRR1562746     5  0.1671      0.980 0.000 0.076  0 0.000 0.924
#> SRR1562747     5  0.1671      0.980 0.000 0.076  0 0.000 0.924
#> SRR1562748     4  0.0290      0.866 0.000 0.000  0 0.992 0.008
#> SRR1562749     4  0.0290      0.866 0.000 0.000  0 0.992 0.008
#> SRR1562750     4  0.0290      0.866 0.000 0.000  0 0.992 0.008
#> SRR1562751     4  0.0290      0.866 0.000 0.000  0 0.992 0.008
#> SRR1562752     4  0.0290      0.866 0.000 0.000  0 0.992 0.008
#> SRR1562753     4  0.0290      0.866 0.000 0.000  0 0.992 0.008
#> SRR1562754     4  0.3452      0.857 0.000 0.000  0 0.756 0.244
#> SRR1562755     4  0.3452      0.857 0.000 0.000  0 0.756 0.244
#> SRR1562756     4  0.3452      0.857 0.000 0.000  0 0.756 0.244
#> SRR1562757     4  0.3452      0.857 0.000 0.000  0 0.756 0.244
#> SRR1562758     4  0.3452      0.857 0.000 0.000  0 0.756 0.244
#> SRR1562759     4  0.3452      0.857 0.000 0.000  0 0.756 0.244
#> SRR1562792     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1562793     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1562794     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1562795     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1562796     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1562797     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1562798     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1562799     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1562800     1  0.0162      0.998 0.996 0.000  0 0.000 0.004
#> SRR1562801     1  0.0162      0.998 0.996 0.000  0 0.000 0.004
#> SRR1562802     1  0.0162      0.998 0.996 0.000  0 0.000 0.004
#> SRR1562803     1  0.0162      0.998 0.996 0.000  0 0.000 0.004
#> SRR1562804     1  0.0162      0.998 0.996 0.000  0 0.000 0.004
#> SRR1562805     1  0.0162      0.998 0.996 0.000  0 0.000 0.004
#> SRR1562806     1  0.0000      0.999 1.000 0.000  0 0.000 0.000
#> SRR1562807     1  0.0000      0.999 1.000 0.000  0 0.000 0.000
#> SRR1562808     1  0.0000      0.999 1.000 0.000  0 0.000 0.000
#> SRR1562809     1  0.0000      0.999 1.000 0.000  0 0.000 0.000
#> SRR1562810     1  0.0000      0.999 1.000 0.000  0 0.000 0.000
#> SRR1562811     1  0.0000      0.999 1.000 0.000  0 0.000 0.000
#> SRR1562812     1  0.0000      0.999 1.000 0.000  0 0.000 0.000
#> SRR1562813     1  0.0000      0.999 1.000 0.000  0 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2 p3    p4    p5    p6
#> SRR1562718     2  0.1204      0.883 0.000 0.944  0 0.000 0.056 0.000
#> SRR1562719     2  0.1204      0.883 0.000 0.944  0 0.000 0.056 0.000
#> SRR1562720     2  0.1204      0.883 0.000 0.944  0 0.000 0.056 0.000
#> SRR1562721     2  0.1204      0.883 0.000 0.944  0 0.000 0.056 0.000
#> SRR1562723     2  0.1204      0.883 0.000 0.944  0 0.000 0.056 0.000
#> SRR1562724     2  0.2129      0.878 0.000 0.904  0 0.000 0.056 0.040
#> SRR1562725     2  0.2129      0.878 0.000 0.904  0 0.000 0.056 0.040
#> SRR1562726     2  0.2129      0.878 0.000 0.904  0 0.000 0.056 0.040
#> SRR1562727     2  0.2129      0.878 0.000 0.904  0 0.000 0.056 0.040
#> SRR1562728     2  0.2129      0.878 0.000 0.904  0 0.000 0.056 0.040
#> SRR1562729     2  0.2129      0.878 0.000 0.904  0 0.000 0.056 0.040
#> SRR1562730     2  0.3602      0.792 0.000 0.760  0 0.032 0.000 0.208
#> SRR1562731     2  0.3602      0.792 0.000 0.760  0 0.032 0.000 0.208
#> SRR1562732     2  0.3602      0.792 0.000 0.760  0 0.032 0.000 0.208
#> SRR1562733     2  0.3602      0.792 0.000 0.760  0 0.032 0.000 0.208
#> SRR1562734     2  0.3602      0.792 0.000 0.760  0 0.032 0.000 0.208
#> SRR1562735     2  0.3602      0.792 0.000 0.760  0 0.032 0.000 0.208
#> SRR1562736     5  0.0777      0.956 0.000 0.000  0 0.024 0.972 0.004
#> SRR1562737     5  0.0777      0.956 0.000 0.000  0 0.024 0.972 0.004
#> SRR1562738     5  0.0777      0.956 0.000 0.000  0 0.024 0.972 0.004
#> SRR1562739     5  0.0777      0.956 0.000 0.000  0 0.024 0.972 0.004
#> SRR1562740     5  0.0777      0.956 0.000 0.000  0 0.024 0.972 0.004
#> SRR1562741     5  0.0777      0.956 0.000 0.000  0 0.024 0.972 0.004
#> SRR1562742     5  0.1327      0.956 0.000 0.000  0 0.000 0.936 0.064
#> SRR1562743     5  0.1327      0.956 0.000 0.000  0 0.000 0.936 0.064
#> SRR1562744     5  0.1327      0.956 0.000 0.000  0 0.000 0.936 0.064
#> SRR1562745     5  0.1327      0.956 0.000 0.000  0 0.000 0.936 0.064
#> SRR1562746     5  0.1327      0.956 0.000 0.000  0 0.000 0.936 0.064
#> SRR1562747     5  0.1327      0.956 0.000 0.000  0 0.000 0.936 0.064
#> SRR1562748     6  0.3515      1.000 0.000 0.000  0 0.324 0.000 0.676
#> SRR1562749     6  0.3515      1.000 0.000 0.000  0 0.324 0.000 0.676
#> SRR1562750     6  0.3515      1.000 0.000 0.000  0 0.324 0.000 0.676
#> SRR1562751     6  0.3515      1.000 0.000 0.000  0 0.324 0.000 0.676
#> SRR1562752     6  0.3515      1.000 0.000 0.000  0 0.324 0.000 0.676
#> SRR1562753     6  0.3515      1.000 0.000 0.000  0 0.324 0.000 0.676
#> SRR1562754     4  0.0790      1.000 0.000 0.000  0 0.968 0.032 0.000
#> SRR1562755     4  0.0790      1.000 0.000 0.000  0 0.968 0.032 0.000
#> SRR1562756     4  0.0790      1.000 0.000 0.000  0 0.968 0.032 0.000
#> SRR1562757     4  0.0790      1.000 0.000 0.000  0 0.968 0.032 0.000
#> SRR1562758     4  0.0790      1.000 0.000 0.000  0 0.968 0.032 0.000
#> SRR1562759     4  0.0790      1.000 0.000 0.000  0 0.968 0.032 0.000
#> SRR1562792     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1562793     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1562794     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1562795     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1562796     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1562797     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1562798     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1562799     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1562800     1  0.0363      0.994 0.988 0.000  0 0.000 0.000 0.012
#> SRR1562801     1  0.0363      0.994 0.988 0.000  0 0.000 0.000 0.012
#> SRR1562802     1  0.0363      0.994 0.988 0.000  0 0.000 0.000 0.012
#> SRR1562803     1  0.0363      0.994 0.988 0.000  0 0.000 0.000 0.012
#> SRR1562804     1  0.0363      0.994 0.988 0.000  0 0.000 0.000 0.012
#> SRR1562805     1  0.0363      0.994 0.988 0.000  0 0.000 0.000 0.012
#> SRR1562806     1  0.0000      0.995 1.000 0.000  0 0.000 0.000 0.000
#> SRR1562807     1  0.0000      0.995 1.000 0.000  0 0.000 0.000 0.000
#> SRR1562808     1  0.0000      0.995 1.000 0.000  0 0.000 0.000 0.000
#> SRR1562809     1  0.0000      0.995 1.000 0.000  0 0.000 0.000 0.000
#> SRR1562810     1  0.0000      0.995 1.000 0.000  0 0.000 0.000 0.000
#> SRR1562811     1  0.0000      0.995 1.000 0.000  0 0.000 0.000 0.000
#> SRR1562812     1  0.0000      0.995 1.000 0.000  0 0.000 0.000 0.000
#> SRR1562813     1  0.0000      0.995 1.000 0.000  0 0.000 0.000 0.000

Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.

consensus_heatmap(res, k = 2)

plot of chunk tab-MAD-skmeans-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-MAD-skmeans-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-MAD-skmeans-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-MAD-skmeans-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-MAD-skmeans-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-MAD-skmeans-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-MAD-skmeans-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-MAD-skmeans-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-MAD-skmeans-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-MAD-skmeans-membership-heatmap-5

As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

plot of chunk tab-MAD-skmeans-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-MAD-skmeans-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-MAD-skmeans-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-MAD-skmeans-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-MAD-skmeans-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-MAD-skmeans-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-MAD-skmeans-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-MAD-skmeans-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-MAD-skmeans-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-MAD-skmeans-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-skmeans-signature_compare

get_signature() returns a data frame invisibly. TO get the list of signatures, the function call should be assigned to a variable explicitly. In following code, if plot argument is set to FALSE, no heatmap is plotted while only the differential analysis is performed.

# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)

An example of the output of tb is:

#>   which_row         fdr    mean_1    mean_2 scaled_mean_1 scaled_mean_2 km
#> 1        38 0.042760348  8.373488  9.131774    -0.5533452     0.5164555  1
#> 2        40 0.018707592  7.106213  8.469186    -0.6173731     0.5762149  1
#> 3        55 0.019134737 10.221463 11.207825    -0.6159697     0.5749050  1
#> 4        59 0.006059896  5.921854  7.869574    -0.6899429     0.6439467  1
#> 5        60 0.018055526  8.928898 10.211722    -0.6204761     0.5791110  1
#> 6        98 0.009384629 15.714769 14.887706     0.6635654    -0.6193277  2
...

The columns in tb are:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. km: Row groups if k-means clustering is applied to rows.

UMAP plot which shows how samples are separated.

dimension_reduction(res, k = 2, method = "UMAP")

plot of chunk tab-MAD-skmeans-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-MAD-skmeans-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-MAD-skmeans-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-MAD-skmeans-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-MAD-skmeans-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-skmeans-collect-classes

If matrix rows can be associated to genes, consider to use functional_enrichment(res, ...) to perform function enrichment for the signature genes. See this vignette for more detailed explanations.


MAD:pam*

The object with results only for a single top-value method and a single partition method can be extracted as:

res = res_list["MAD", "pam"]
# you can also extract it by
# res = res_list["MAD:pam"]

A summary of res and all the functions that can be applied to it:

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 15301 rows and 63 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'pam' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 6.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

collect_plots() function collects all the plots made from res for all k (number of partitions) into one single page to provide an easy and fast comparison between different k.

collect_plots(res)

plot of chunk MAD-pam-collect-plots

The plots are:

All the plots in panels can be made by individual functions and they are plotted later in this section.

select_partition_number() produces several plots showing different statistics for choosing “optimized” k. There are following statistics:

The detailed explanations of these statistics can be found in the cola vignette.

Generally speaking, lower PAC score, higher mean silhouette score or higher concordance corresponds to better partition. Rand index and Jaccard index measure how similar the current partition is compared to partition with k-1. If they are too similar, we won't accept k is better than k-1.

select_partition_number(res)

plot of chunk MAD-pam-select-partition-number

The numeric values for all these statistics can be obtained by get_stats().

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4624 0.538   0.538
#> 3 3 1.000           1.000       1.000         0.1239 0.943   0.893
#> 4 4 1.000           0.998       0.999         0.3432 0.822   0.629
#> 5 5 0.816           0.837       0.845         0.0723 0.975   0.919
#> 6 6 0.912           0.850       0.876         0.0927 0.840   0.493

suggest_best_k() suggests the best \(k\) based on these statistics. The rules are as follows:

suggest_best_k(res)
#> [1] 6
#> attr(,"optional")
#> [1] 2 3 4

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
#> SRR1562718     2       0          1  0  1
#> SRR1562719     2       0          1  0  1
#> SRR1562720     2       0          1  0  1
#> SRR1562721     2       0          1  0  1
#> SRR1562723     2       0          1  0  1
#> SRR1562724     2       0          1  0  1
#> SRR1562725     2       0          1  0  1
#> SRR1562726     2       0          1  0  1
#> SRR1562727     2       0          1  0  1
#> SRR1562728     2       0          1  0  1
#> SRR1562729     2       0          1  0  1
#> SRR1562730     2       0          1  0  1
#> SRR1562731     2       0          1  0  1
#> SRR1562732     2       0          1  0  1
#> SRR1562733     2       0          1  0  1
#> SRR1562734     2       0          1  0  1
#> SRR1562735     2       0          1  0  1
#> SRR1562736     2       0          1  0  1
#> SRR1562737     2       0          1  0  1
#> SRR1562738     2       0          1  0  1
#> SRR1562739     2       0          1  0  1
#> SRR1562740     2       0          1  0  1
#> SRR1562741     2       0          1  0  1
#> SRR1562742     2       0          1  0  1
#> SRR1562743     2       0          1  0  1
#> SRR1562744     2       0          1  0  1
#> SRR1562745     2       0          1  0  1
#> SRR1562746     2       0          1  0  1
#> SRR1562747     2       0          1  0  1
#> SRR1562748     2       0          1  0  1
#> SRR1562749     2       0          1  0  1
#> SRR1562750     2       0          1  0  1
#> SRR1562751     2       0          1  0  1
#> SRR1562752     2       0          1  0  1
#> SRR1562753     2       0          1  0  1
#> SRR1562754     2       0          1  0  1
#> SRR1562755     2       0          1  0  1
#> SRR1562756     2       0          1  0  1
#> SRR1562757     2       0          1  0  1
#> SRR1562758     2       0          1  0  1
#> SRR1562759     2       0          1  0  1
#> SRR1562792     1       0          1  1  0
#> SRR1562793     1       0          1  1  0
#> SRR1562794     1       0          1  1  0
#> SRR1562795     1       0          1  1  0
#> SRR1562796     1       0          1  1  0
#> SRR1562797     1       0          1  1  0
#> SRR1562798     1       0          1  1  0
#> SRR1562799     1       0          1  1  0
#> SRR1562800     1       0          1  1  0
#> SRR1562801     1       0          1  1  0
#> SRR1562802     1       0          1  1  0
#> SRR1562803     1       0          1  1  0
#> SRR1562804     1       0          1  1  0
#> SRR1562805     1       0          1  1  0
#> SRR1562806     1       0          1  1  0
#> SRR1562807     1       0          1  1  0
#> SRR1562808     1       0          1  1  0
#> SRR1562809     1       0          1  1  0
#> SRR1562810     1       0          1  1  0
#> SRR1562811     1       0          1  1  0
#> SRR1562812     1       0          1  1  0
#> SRR1562813     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette p1 p2 p3
#> SRR1562718     2       0          1  0  1  0
#> SRR1562719     2       0          1  0  1  0
#> SRR1562720     2       0          1  0  1  0
#> SRR1562721     2       0          1  0  1  0
#> SRR1562723     2       0          1  0  1  0
#> SRR1562724     2       0          1  0  1  0
#> SRR1562725     2       0          1  0  1  0
#> SRR1562726     2       0          1  0  1  0
#> SRR1562727     2       0          1  0  1  0
#> SRR1562728     2       0          1  0  1  0
#> SRR1562729     2       0          1  0  1  0
#> SRR1562730     2       0          1  0  1  0
#> SRR1562731     2       0          1  0  1  0
#> SRR1562732     2       0          1  0  1  0
#> SRR1562733     2       0          1  0  1  0
#> SRR1562734     2       0          1  0  1  0
#> SRR1562735     2       0          1  0  1  0
#> SRR1562736     2       0          1  0  1  0
#> SRR1562737     2       0          1  0  1  0
#> SRR1562738     2       0          1  0  1  0
#> SRR1562739     2       0          1  0  1  0
#> SRR1562740     2       0          1  0  1  0
#> SRR1562741     2       0          1  0  1  0
#> SRR1562742     2       0          1  0  1  0
#> SRR1562743     2       0          1  0  1  0
#> SRR1562744     2       0          1  0  1  0
#> SRR1562745     2       0          1  0  1  0
#> SRR1562746     2       0          1  0  1  0
#> SRR1562747     2       0          1  0  1  0
#> SRR1562748     2       0          1  0  1  0
#> SRR1562749     2       0          1  0  1  0
#> SRR1562750     2       0          1  0  1  0
#> SRR1562751     2       0          1  0  1  0
#> SRR1562752     2       0          1  0  1  0
#> SRR1562753     2       0          1  0  1  0
#> SRR1562754     2       0          1  0  1  0
#> SRR1562755     2       0          1  0  1  0
#> SRR1562756     2       0          1  0  1  0
#> SRR1562757     2       0          1  0  1  0
#> SRR1562758     2       0          1  0  1  0
#> SRR1562759     2       0          1  0  1  0
#> SRR1562792     3       0          1  0  0  1
#> SRR1562793     3       0          1  0  0  1
#> SRR1562794     3       0          1  0  0  1
#> SRR1562795     3       0          1  0  0  1
#> SRR1562796     3       0          1  0  0  1
#> SRR1562797     3       0          1  0  0  1
#> SRR1562798     3       0          1  0  0  1
#> SRR1562799     3       0          1  0  0  1
#> SRR1562800     1       0          1  1  0  0
#> SRR1562801     1       0          1  1  0  0
#> SRR1562802     1       0          1  1  0  0
#> SRR1562803     1       0          1  1  0  0
#> SRR1562804     1       0          1  1  0  0
#> SRR1562805     1       0          1  1  0  0
#> SRR1562806     1       0          1  1  0  0
#> SRR1562807     1       0          1  1  0  0
#> SRR1562808     1       0          1  1  0  0
#> SRR1562809     1       0          1  1  0  0
#> SRR1562810     1       0          1  1  0  0
#> SRR1562811     1       0          1  1  0  0
#> SRR1562812     1       0          1  1  0  0
#> SRR1562813     1       0          1  1  0  0

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette p1    p2 p3    p4
#> SRR1562718     2  0.0000      0.997  0 1.000  0 0.000
#> SRR1562719     2  0.0000      0.997  0 1.000  0 0.000
#> SRR1562720     2  0.0000      0.997  0 1.000  0 0.000
#> SRR1562721     2  0.0000      0.997  0 1.000  0 0.000
#> SRR1562723     2  0.0000      0.997  0 1.000  0 0.000
#> SRR1562724     2  0.0000      0.997  0 1.000  0 0.000
#> SRR1562725     2  0.0000      0.997  0 1.000  0 0.000
#> SRR1562726     2  0.0000      0.997  0 1.000  0 0.000
#> SRR1562727     2  0.0000      0.997  0 1.000  0 0.000
#> SRR1562728     2  0.0000      0.997  0 1.000  0 0.000
#> SRR1562729     2  0.0000      0.997  0 1.000  0 0.000
#> SRR1562730     2  0.0000      0.997  0 1.000  0 0.000
#> SRR1562731     2  0.0000      0.997  0 1.000  0 0.000
#> SRR1562732     2  0.0000      0.997  0 1.000  0 0.000
#> SRR1562733     2  0.0000      0.997  0 1.000  0 0.000
#> SRR1562734     2  0.0000      0.997  0 1.000  0 0.000
#> SRR1562735     2  0.0000      0.997  0 1.000  0 0.000
#> SRR1562736     2  0.0469      0.991  0 0.988  0 0.012
#> SRR1562737     2  0.0469      0.991  0 0.988  0 0.012
#> SRR1562738     2  0.0469      0.991  0 0.988  0 0.012
#> SRR1562739     2  0.0469      0.991  0 0.988  0 0.012
#> SRR1562740     2  0.0469      0.991  0 0.988  0 0.012
#> SRR1562741     2  0.0188      0.996  0 0.996  0 0.004
#> SRR1562742     2  0.0188      0.996  0 0.996  0 0.004
#> SRR1562743     2  0.0188      0.996  0 0.996  0 0.004
#> SRR1562744     2  0.0188      0.996  0 0.996  0 0.004
#> SRR1562745     2  0.0188      0.996  0 0.996  0 0.004
#> SRR1562746     2  0.0188      0.996  0 0.996  0 0.004
#> SRR1562747     2  0.0188      0.996  0 0.996  0 0.004
#> SRR1562748     4  0.0000      1.000  0 0.000  0 1.000
#> SRR1562749     4  0.0000      1.000  0 0.000  0 1.000
#> SRR1562750     4  0.0000      1.000  0 0.000  0 1.000
#> SRR1562751     4  0.0000      1.000  0 0.000  0 1.000
#> SRR1562752     4  0.0000      1.000  0 0.000  0 1.000
#> SRR1562753     4  0.0000      1.000  0 0.000  0 1.000
#> SRR1562754     4  0.0000      1.000  0 0.000  0 1.000
#> SRR1562755     4  0.0000      1.000  0 0.000  0 1.000
#> SRR1562756     4  0.0000      1.000  0 0.000  0 1.000
#> SRR1562757     4  0.0000      1.000  0 0.000  0 1.000
#> SRR1562758     4  0.0000      1.000  0 0.000  0 1.000
#> SRR1562759     4  0.0000      1.000  0 0.000  0 1.000
#> SRR1562792     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1562793     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1562794     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1562795     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1562796     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1562797     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1562798     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1562799     3  0.0000      1.000  0 0.000  1 0.000
#> SRR1562800     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1562801     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1562802     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1562803     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1562804     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1562805     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1562806     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1562807     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1562808     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1562809     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1562810     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1562811     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1562812     1  0.0000      1.000  1 0.000  0 0.000
#> SRR1562813     1  0.0000      1.000  1 0.000  0 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2 p3    p4    p5
#> SRR1562718     2  0.0000      0.804 0.000 1.000  0 0.000 0.000
#> SRR1562719     2  0.0000      0.804 0.000 1.000  0 0.000 0.000
#> SRR1562720     2  0.0000      0.804 0.000 1.000  0 0.000 0.000
#> SRR1562721     2  0.0000      0.804 0.000 1.000  0 0.000 0.000
#> SRR1562723     2  0.0000      0.804 0.000 1.000  0 0.000 0.000
#> SRR1562724     2  0.0000      0.804 0.000 1.000  0 0.000 0.000
#> SRR1562725     2  0.0000      0.804 0.000 1.000  0 0.000 0.000
#> SRR1562726     2  0.0000      0.804 0.000 1.000  0 0.000 0.000
#> SRR1562727     2  0.0000      0.804 0.000 1.000  0 0.000 0.000
#> SRR1562728     2  0.0000      0.804 0.000 1.000  0 0.000 0.000
#> SRR1562729     2  0.0000      0.804 0.000 1.000  0 0.000 0.000
#> SRR1562730     2  0.0162      0.802 0.000 0.996  0 0.000 0.004
#> SRR1562731     2  0.0162      0.802 0.000 0.996  0 0.000 0.004
#> SRR1562732     2  0.0162      0.802 0.000 0.996  0 0.000 0.004
#> SRR1562733     2  0.0162      0.802 0.000 0.996  0 0.000 0.004
#> SRR1562734     2  0.0162      0.802 0.000 0.996  0 0.000 0.004
#> SRR1562735     2  0.0162      0.802 0.000 0.996  0 0.000 0.004
#> SRR1562736     2  0.4210      0.670 0.000 0.588  0 0.000 0.412
#> SRR1562737     2  0.4210      0.670 0.000 0.588  0 0.000 0.412
#> SRR1562738     2  0.4210      0.670 0.000 0.588  0 0.000 0.412
#> SRR1562739     2  0.4210      0.670 0.000 0.588  0 0.000 0.412
#> SRR1562740     2  0.4210      0.670 0.000 0.588  0 0.000 0.412
#> SRR1562741     2  0.4210      0.670 0.000 0.588  0 0.000 0.412
#> SRR1562742     2  0.4210      0.670 0.000 0.588  0 0.000 0.412
#> SRR1562743     2  0.4210      0.670 0.000 0.588  0 0.000 0.412
#> SRR1562744     2  0.4210      0.670 0.000 0.588  0 0.000 0.412
#> SRR1562745     2  0.4210      0.670 0.000 0.588  0 0.000 0.412
#> SRR1562746     2  0.4210      0.670 0.000 0.588  0 0.000 0.412
#> SRR1562747     2  0.4210      0.670 0.000 0.588  0 0.000 0.412
#> SRR1562748     4  0.0000      0.751 0.000 0.000  0 1.000 0.000
#> SRR1562749     4  0.0000      0.751 0.000 0.000  0 1.000 0.000
#> SRR1562750     4  0.0000      0.751 0.000 0.000  0 1.000 0.000
#> SRR1562751     4  0.0000      0.751 0.000 0.000  0 1.000 0.000
#> SRR1562752     4  0.0000      0.751 0.000 0.000  0 1.000 0.000
#> SRR1562753     4  0.0000      0.751 0.000 0.000  0 1.000 0.000
#> SRR1562754     4  0.4114      0.757 0.000 0.000  0 0.624 0.376
#> SRR1562755     4  0.4088      0.762 0.000 0.000  0 0.632 0.368
#> SRR1562756     4  0.4088      0.762 0.000 0.000  0 0.632 0.368
#> SRR1562757     4  0.4088      0.762 0.000 0.000  0 0.632 0.368
#> SRR1562758     4  0.4101      0.760 0.000 0.000  0 0.628 0.372
#> SRR1562759     4  0.4114      0.757 0.000 0.000  0 0.624 0.376
#> SRR1562792     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1562793     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1562794     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1562795     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1562796     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1562797     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1562798     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1562799     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1562800     5  0.4219      1.000 0.416 0.000  0 0.000 0.584
#> SRR1562801     5  0.4219      1.000 0.416 0.000  0 0.000 0.584
#> SRR1562802     5  0.4219      1.000 0.416 0.000  0 0.000 0.584
#> SRR1562803     5  0.4219      1.000 0.416 0.000  0 0.000 0.584
#> SRR1562804     5  0.4219      1.000 0.416 0.000  0 0.000 0.584
#> SRR1562805     5  0.4219      1.000 0.416 0.000  0 0.000 0.584
#> SRR1562806     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> SRR1562807     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> SRR1562808     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> SRR1562809     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> SRR1562810     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> SRR1562811     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> SRR1562812     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> SRR1562813     1  0.0000      1.000 1.000 0.000  0 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2 p3    p4    p5  p6
#> SRR1562718     2  0.0000      0.898 0.000 1.000  0 0.000 0.000 0.0
#> SRR1562719     2  0.0000      0.898 0.000 1.000  0 0.000 0.000 0.0
#> SRR1562720     2  0.0000      0.898 0.000 1.000  0 0.000 0.000 0.0
#> SRR1562721     2  0.0000      0.898 0.000 1.000  0 0.000 0.000 0.0
#> SRR1562723     2  0.0000      0.898 0.000 1.000  0 0.000 0.000 0.0
#> SRR1562724     2  0.0000      0.898 0.000 1.000  0 0.000 0.000 0.0
#> SRR1562725     2  0.0000      0.898 0.000 1.000  0 0.000 0.000 0.0
#> SRR1562726     2  0.0000      0.898 0.000 1.000  0 0.000 0.000 0.0
#> SRR1562727     2  0.0000      0.898 0.000 1.000  0 0.000 0.000 0.0
#> SRR1562728     2  0.0000      0.898 0.000 1.000  0 0.000 0.000 0.0
#> SRR1562729     2  0.0000      0.898 0.000 1.000  0 0.000 0.000 0.0
#> SRR1562730     2  0.3428      0.800 0.304 0.696  0 0.000 0.000 0.0
#> SRR1562731     2  0.3428      0.800 0.304 0.696  0 0.000 0.000 0.0
#> SRR1562732     2  0.3428      0.800 0.304 0.696  0 0.000 0.000 0.0
#> SRR1562733     2  0.3428      0.800 0.304 0.696  0 0.000 0.000 0.0
#> SRR1562734     2  0.3428      0.800 0.304 0.696  0 0.000 0.000 0.0
#> SRR1562735     2  0.3428      0.800 0.304 0.696  0 0.000 0.000 0.0
#> SRR1562736     5  0.0865      0.782 0.000 0.036  0 0.000 0.964 0.0
#> SRR1562737     5  0.0865      0.782 0.000 0.036  0 0.000 0.964 0.0
#> SRR1562738     5  0.0865      0.782 0.000 0.036  0 0.000 0.964 0.0
#> SRR1562739     5  0.0865      0.782 0.000 0.036  0 0.000 0.964 0.0
#> SRR1562740     5  0.0865      0.782 0.000 0.036  0 0.000 0.964 0.0
#> SRR1562741     5  0.0865      0.782 0.000 0.036  0 0.000 0.964 0.0
#> SRR1562742     5  0.0865      0.782 0.000 0.036  0 0.000 0.964 0.0
#> SRR1562743     5  0.0865      0.782 0.000 0.036  0 0.000 0.964 0.0
#> SRR1562744     5  0.0865      0.782 0.000 0.036  0 0.000 0.964 0.0
#> SRR1562745     5  0.0865      0.782 0.000 0.036  0 0.000 0.964 0.0
#> SRR1562746     5  0.0865      0.782 0.000 0.036  0 0.000 0.964 0.0
#> SRR1562747     5  0.0865      0.782 0.000 0.036  0 0.000 0.964 0.0
#> SRR1562748     4  0.0000      1.000 0.000 0.000  0 1.000 0.000 0.0
#> SRR1562749     4  0.0000      1.000 0.000 0.000  0 1.000 0.000 0.0
#> SRR1562750     4  0.0000      1.000 0.000 0.000  0 1.000 0.000 0.0
#> SRR1562751     4  0.0000      1.000 0.000 0.000  0 1.000 0.000 0.0
#> SRR1562752     4  0.0000      1.000 0.000 0.000  0 1.000 0.000 0.0
#> SRR1562753     4  0.0000      1.000 0.000 0.000  0 1.000 0.000 0.0
#> SRR1562754     5  0.5255      0.256 0.096 0.000  0 0.428 0.476 0.0
#> SRR1562755     5  0.5259      0.243 0.096 0.000  0 0.436 0.468 0.0
#> SRR1562756     5  0.5259      0.243 0.096 0.000  0 0.436 0.468 0.0
#> SRR1562757     5  0.5259      0.243 0.096 0.000  0 0.436 0.468 0.0
#> SRR1562758     5  0.5259      0.243 0.096 0.000  0 0.436 0.468 0.0
#> SRR1562759     5  0.5257      0.250 0.096 0.000  0 0.432 0.472 0.0
#> SRR1562792     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.0
#> SRR1562793     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.0
#> SRR1562794     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.0
#> SRR1562795     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.0
#> SRR1562796     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.0
#> SRR1562797     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.0
#> SRR1562798     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.0
#> SRR1562799     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.0
#> SRR1562800     6  0.0000      1.000 0.000 0.000  0 0.000 0.000 1.0
#> SRR1562801     6  0.0000      1.000 0.000 0.000  0 0.000 0.000 1.0
#> SRR1562802     6  0.0000      1.000 0.000 0.000  0 0.000 0.000 1.0
#> SRR1562803     6  0.0000      1.000 0.000 0.000  0 0.000 0.000 1.0
#> SRR1562804     6  0.0000      1.000 0.000 0.000  0 0.000 0.000 1.0
#> SRR1562805     6  0.0000      1.000 0.000 0.000  0 0.000 0.000 1.0
#> SRR1562806     1  0.3756      1.000 0.600 0.000  0 0.000 0.000 0.4
#> SRR1562807     1  0.3756      1.000 0.600 0.000  0 0.000 0.000 0.4
#> SRR1562808     1  0.3756      1.000 0.600 0.000  0 0.000 0.000 0.4
#> SRR1562809     1  0.3756      1.000 0.600 0.000  0 0.000 0.000 0.4
#> SRR1562810     1  0.3756      1.000 0.600 0.000  0 0.000 0.000 0.4
#> SRR1562811     1  0.3756      1.000 0.600 0.000  0 0.000 0.000 0.4
#> SRR1562812     1  0.3756      1.000 0.600 0.000  0 0.000 0.000 0.4
#> SRR1562813     1  0.3756      1.000 0.600 0.000  0 0.000 0.000 0.4

Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.

consensus_heatmap(res, k = 2)

plot of chunk tab-MAD-pam-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-MAD-pam-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-MAD-pam-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-MAD-pam-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-MAD-pam-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-MAD-pam-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-MAD-pam-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-MAD-pam-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-MAD-pam-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-MAD-pam-membership-heatmap-5

As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

plot of chunk tab-MAD-pam-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-MAD-pam-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-MAD-pam-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-MAD-pam-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-MAD-pam-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-MAD-pam-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-MAD-pam-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-MAD-pam-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-MAD-pam-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-MAD-pam-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-pam-signature_compare

get_signature() returns a data frame invisibly. TO get the list of signatures, the function call should be assigned to a variable explicitly. In following code, if plot argument is set to FALSE, no heatmap is plotted while only the differential analysis is performed.

# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)

An example of the output of tb is:

#>   which_row         fdr    mean_1    mean_2 scaled_mean_1 scaled_mean_2 km
#> 1        38 0.042760348  8.373488  9.131774    -0.5533452     0.5164555  1
#> 2        40 0.018707592  7.106213  8.469186    -0.6173731     0.5762149  1
#> 3        55 0.019134737 10.221463 11.207825    -0.6159697     0.5749050  1
#> 4        59 0.006059896  5.921854  7.869574    -0.6899429     0.6439467  1
#> 5        60 0.018055526  8.928898 10.211722    -0.6204761     0.5791110  1
#> 6        98 0.009384629 15.714769 14.887706     0.6635654    -0.6193277  2
...

The columns in tb are:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. km: Row groups if k-means clustering is applied to rows.

UMAP plot which shows how samples are separated.

dimension_reduction(res, k = 2, method = "UMAP")

plot of chunk tab-MAD-pam-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-MAD-pam-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-MAD-pam-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-MAD-pam-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-MAD-pam-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-pam-collect-classes

If matrix rows can be associated to genes, consider to use functional_enrichment(res, ...) to perform function enrichment for the signature genes. See this vignette for more detailed explanations.


MAD:mclust*

The object with results only for a single top-value method and a single partition method can be extracted as:

res = res_list["MAD", "mclust"]
# you can also extract it by
# res = res_list["MAD:mclust"]

A summary of res and all the functions that can be applied to it:

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 15301 rows and 63 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'mclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 6.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

collect_plots() function collects all the plots made from res for all k (number of partitions) into one single page to provide an easy and fast comparison between different k.

collect_plots(res)

plot of chunk MAD-mclust-collect-plots

The plots are:

All the plots in panels can be made by individual functions and they are plotted later in this section.

select_partition_number() produces several plots showing different statistics for choosing “optimized” k. There are following statistics:

The detailed explanations of these statistics can be found in the cola vignette.

Generally speaking, lower PAC score, higher mean silhouette score or higher concordance corresponds to better partition. Rand index and Jaccard index measure how similar the current partition is compared to partition with k-1. If they are too similar, we won't accept k is better than k-1.

select_partition_number(res)

plot of chunk MAD-mclust-select-partition-number

The numeric values for all these statistics can be obtained by get_stats().

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.481           0.940       0.935         0.4000 0.538   0.538
#> 3 3 0.619           0.921       0.923         0.3244 0.943   0.893
#> 4 4 1.000           0.991       0.992         0.3727 0.791   0.565
#> 5 5 1.000           0.999       1.000         0.1029 0.926   0.729
#> 6 6 0.942           0.971       0.955         0.0333 0.975   0.876

suggest_best_k() suggests the best \(k\) based on these statistics. The rules are as follows:

suggest_best_k(res)
#> [1] 6
#> attr(,"optional")
#> [1] 4 5

There is also optional best \(k\) = 4 5 that is worth to check.

Following shows the table of the partitions (You need to click the show/hide code output link to see it). The membership matrix (columns with name p*) is inferred by clue::cl_consensus() function with the SE method. Basically the value in the membership matrix represents the probability to belong to a certain group. The finall class label for an item is determined with the group with highest probability it belongs to.

In get_classes() function, the entropy is calculated from the membership matrix and the silhouette score is calculated from the consensus matrix.

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette    p1    p2
#> SRR1562718     2   0.000      1.000 0.000 1.000
#> SRR1562719     2   0.000      1.000 0.000 1.000
#> SRR1562720     2   0.000      1.000 0.000 1.000
#> SRR1562721     2   0.000      1.000 0.000 1.000
#> SRR1562723     2   0.000      1.000 0.000 1.000
#> SRR1562724     2   0.000      1.000 0.000 1.000
#> SRR1562725     2   0.000      1.000 0.000 1.000
#> SRR1562726     2   0.000      1.000 0.000 1.000
#> SRR1562727     2   0.000      1.000 0.000 1.000
#> SRR1562728     2   0.000      1.000 0.000 1.000
#> SRR1562729     2   0.000      1.000 0.000 1.000
#> SRR1562730     2   0.000      1.000 0.000 1.000
#> SRR1562731     2   0.000      1.000 0.000 1.000
#> SRR1562732     2   0.000      1.000 0.000 1.000
#> SRR1562733     2   0.000      1.000 0.000 1.000
#> SRR1562734     2   0.000      1.000 0.000 1.000
#> SRR1562735     2   0.000      1.000 0.000 1.000
#> SRR1562736     2   0.000      1.000 0.000 1.000
#> SRR1562737     2   0.000      1.000 0.000 1.000
#> SRR1562738     2   0.000      1.000 0.000 1.000
#> SRR1562739     2   0.000      1.000 0.000 1.000
#> SRR1562740     2   0.000      1.000 0.000 1.000
#> SRR1562741     2   0.000      1.000 0.000 1.000
#> SRR1562742     2   0.000      1.000 0.000 1.000
#> SRR1562743     2   0.000      1.000 0.000 1.000
#> SRR1562744     2   0.000      1.000 0.000 1.000
#> SRR1562745     2   0.000      1.000 0.000 1.000
#> SRR1562746     2   0.000      1.000 0.000 1.000
#> SRR1562747     2   0.000      1.000 0.000 1.000
#> SRR1562748     2   0.000      1.000 0.000 1.000
#> SRR1562749     2   0.000      1.000 0.000 1.000
#> SRR1562750     2   0.000      1.000 0.000 1.000
#> SRR1562751     2   0.000      1.000 0.000 1.000
#> SRR1562752     2   0.000      1.000 0.000 1.000
#> SRR1562753     2   0.000      1.000 0.000 1.000
#> SRR1562754     2   0.000      1.000 0.000 1.000
#> SRR1562755     2   0.000      1.000 0.000 1.000
#> SRR1562756     2   0.000      1.000 0.000 1.000
#> SRR1562757     2   0.000      1.000 0.000 1.000
#> SRR1562758     2   0.000      1.000 0.000 1.000
#> SRR1562759     2   0.000      1.000 0.000 1.000
#> SRR1562792     1   0.839      0.743 0.732 0.268
#> SRR1562793     1   0.839      0.743 0.732 0.268
#> SRR1562794     1   0.839      0.743 0.732 0.268
#> SRR1562795     1   0.839      0.743 0.732 0.268
#> SRR1562796     1   0.839      0.743 0.732 0.268
#> SRR1562797     1   0.839      0.743 0.732 0.268
#> SRR1562798     1   0.839      0.743 0.732 0.268
#> SRR1562799     1   0.839      0.743 0.732 0.268
#> SRR1562800     1   0.584      0.877 0.860 0.140
#> SRR1562801     1   0.584      0.877 0.860 0.140
#> SRR1562802     1   0.584      0.877 0.860 0.140
#> SRR1562803     1   0.584      0.877 0.860 0.140
#> SRR1562804     1   0.584      0.877 0.860 0.140
#> SRR1562805     1   0.584      0.877 0.860 0.140
#> SRR1562806     1   0.584      0.877 0.860 0.140
#> SRR1562807     1   0.584      0.877 0.860 0.140
#> SRR1562808     1   0.584      0.877 0.860 0.140
#> SRR1562809     1   0.584      0.877 0.860 0.140
#> SRR1562810     1   0.584      0.877 0.860 0.140
#> SRR1562811     1   0.584      0.877 0.860 0.140
#> SRR1562812     1   0.584      0.877 0.860 0.140
#> SRR1562813     1   0.584      0.877 0.860 0.140

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1562718     2  0.4399      0.863 0.188 0.812 0.000
#> SRR1562719     2  0.4399      0.863 0.188 0.812 0.000
#> SRR1562720     2  0.4399      0.863 0.188 0.812 0.000
#> SRR1562721     2  0.4399      0.863 0.188 0.812 0.000
#> SRR1562723     2  0.4399      0.863 0.188 0.812 0.000
#> SRR1562724     2  0.4399      0.863 0.188 0.812 0.000
#> SRR1562725     2  0.4399      0.863 0.188 0.812 0.000
#> SRR1562726     2  0.4399      0.863 0.188 0.812 0.000
#> SRR1562727     2  0.4399      0.863 0.188 0.812 0.000
#> SRR1562728     2  0.4399      0.863 0.188 0.812 0.000
#> SRR1562729     2  0.4399      0.863 0.188 0.812 0.000
#> SRR1562730     2  0.4399      0.863 0.188 0.812 0.000
#> SRR1562731     2  0.4399      0.863 0.188 0.812 0.000
#> SRR1562732     2  0.4399      0.863 0.188 0.812 0.000
#> SRR1562733     2  0.4399      0.863 0.188 0.812 0.000
#> SRR1562734     2  0.4399      0.863 0.188 0.812 0.000
#> SRR1562735     2  0.4399      0.863 0.188 0.812 0.000
#> SRR1562736     2  0.0747      0.889 0.000 0.984 0.016
#> SRR1562737     2  0.0747      0.889 0.000 0.984 0.016
#> SRR1562738     2  0.0747      0.889 0.000 0.984 0.016
#> SRR1562739     2  0.0747      0.889 0.000 0.984 0.016
#> SRR1562740     2  0.0747      0.889 0.000 0.984 0.016
#> SRR1562741     2  0.0747      0.889 0.000 0.984 0.016
#> SRR1562742     2  0.0747      0.889 0.000 0.984 0.016
#> SRR1562743     2  0.0747      0.889 0.000 0.984 0.016
#> SRR1562744     2  0.0747      0.889 0.000 0.984 0.016
#> SRR1562745     2  0.0747      0.889 0.000 0.984 0.016
#> SRR1562746     2  0.0747      0.889 0.000 0.984 0.016
#> SRR1562747     2  0.0747      0.889 0.000 0.984 0.016
#> SRR1562748     2  0.0592      0.888 0.012 0.988 0.000
#> SRR1562749     2  0.0592      0.888 0.012 0.988 0.000
#> SRR1562750     2  0.0592      0.888 0.012 0.988 0.000
#> SRR1562751     2  0.0592      0.888 0.012 0.988 0.000
#> SRR1562752     2  0.0592      0.888 0.012 0.988 0.000
#> SRR1562753     2  0.0592      0.888 0.012 0.988 0.000
#> SRR1562754     2  0.0592      0.888 0.012 0.988 0.000
#> SRR1562755     2  0.0592      0.888 0.012 0.988 0.000
#> SRR1562756     2  0.0592      0.888 0.012 0.988 0.000
#> SRR1562757     2  0.0592      0.888 0.012 0.988 0.000
#> SRR1562758     2  0.0592      0.888 0.012 0.988 0.000
#> SRR1562759     2  0.0592      0.888 0.012 0.988 0.000
#> SRR1562792     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1562793     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1562794     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1562795     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1562796     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1562797     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1562798     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1562799     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1562800     1  0.4399      1.000 0.812 0.188 0.000
#> SRR1562801     1  0.4399      1.000 0.812 0.188 0.000
#> SRR1562802     1  0.4399      1.000 0.812 0.188 0.000
#> SRR1562803     1  0.4399      1.000 0.812 0.188 0.000
#> SRR1562804     1  0.4399      1.000 0.812 0.188 0.000
#> SRR1562805     1  0.4399      1.000 0.812 0.188 0.000
#> SRR1562806     1  0.4399      1.000 0.812 0.188 0.000
#> SRR1562807     1  0.4399      1.000 0.812 0.188 0.000
#> SRR1562808     1  0.4399      1.000 0.812 0.188 0.000
#> SRR1562809     1  0.4399      1.000 0.812 0.188 0.000
#> SRR1562810     1  0.4399      1.000 0.812 0.188 0.000
#> SRR1562811     1  0.4399      1.000 0.812 0.188 0.000
#> SRR1562812     1  0.4399      1.000 0.812 0.188 0.000
#> SRR1562813     1  0.4399      1.000 0.812 0.188 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette p1   p2 p3   p4
#> SRR1562718     2   0.000      1.000  0 1.00  0 0.00
#> SRR1562719     2   0.000      1.000  0 1.00  0 0.00
#> SRR1562720     2   0.000      1.000  0 1.00  0 0.00
#> SRR1562721     2   0.000      1.000  0 1.00  0 0.00
#> SRR1562723     2   0.000      1.000  0 1.00  0 0.00
#> SRR1562724     2   0.000      1.000  0 1.00  0 0.00
#> SRR1562725     2   0.000      1.000  0 1.00  0 0.00
#> SRR1562726     2   0.000      1.000  0 1.00  0 0.00
#> SRR1562727     2   0.000      1.000  0 1.00  0 0.00
#> SRR1562728     2   0.000      1.000  0 1.00  0 0.00
#> SRR1562729     2   0.000      1.000  0 1.00  0 0.00
#> SRR1562730     2   0.000      1.000  0 1.00  0 0.00
#> SRR1562731     2   0.000      1.000  0 1.00  0 0.00
#> SRR1562732     2   0.000      1.000  0 1.00  0 0.00
#> SRR1562733     2   0.000      1.000  0 1.00  0 0.00
#> SRR1562734     2   0.000      1.000  0 1.00  0 0.00
#> SRR1562735     2   0.000      1.000  0 1.00  0 0.00
#> SRR1562736     4   0.121      0.976  0 0.04  0 0.96
#> SRR1562737     4   0.121      0.976  0 0.04  0 0.96
#> SRR1562738     4   0.121      0.976  0 0.04  0 0.96
#> SRR1562739     4   0.121      0.976  0 0.04  0 0.96
#> SRR1562740     4   0.121      0.976  0 0.04  0 0.96
#> SRR1562741     4   0.121      0.976  0 0.04  0 0.96
#> SRR1562742     4   0.121      0.976  0 0.04  0 0.96
#> SRR1562743     4   0.121      0.976  0 0.04  0 0.96
#> SRR1562744     4   0.121      0.976  0 0.04  0 0.96
#> SRR1562745     4   0.121      0.976  0 0.04  0 0.96
#> SRR1562746     4   0.121      0.976  0 0.04  0 0.96
#> SRR1562747     4   0.121      0.976  0 0.04  0 0.96
#> SRR1562748     4   0.000      0.976  0 0.00  0 1.00
#> SRR1562749     4   0.000      0.976  0 0.00  0 1.00
#> SRR1562750     4   0.000      0.976  0 0.00  0 1.00
#> SRR1562751     4   0.000      0.976  0 0.00  0 1.00
#> SRR1562752     4   0.000      0.976  0 0.00  0 1.00
#> SRR1562753     4   0.000      0.976  0 0.00  0 1.00
#> SRR1562754     4   0.000      0.976  0 0.00  0 1.00
#> SRR1562755     4   0.000      0.976  0 0.00  0 1.00
#> SRR1562756     4   0.000      0.976  0 0.00  0 1.00
#> SRR1562757     4   0.000      0.976  0 0.00  0 1.00
#> SRR1562758     4   0.000      0.976  0 0.00  0 1.00
#> SRR1562759     4   0.000      0.976  0 0.00  0 1.00
#> SRR1562792     3   0.000      1.000  0 0.00  1 0.00
#> SRR1562793     3   0.000      1.000  0 0.00  1 0.00
#> SRR1562794     3   0.000      1.000  0 0.00  1 0.00
#> SRR1562795     3   0.000      1.000  0 0.00  1 0.00
#> SRR1562796     3   0.000      1.000  0 0.00  1 0.00
#> SRR1562797     3   0.000      1.000  0 0.00  1 0.00
#> SRR1562798     3   0.000      1.000  0 0.00  1 0.00
#> SRR1562799     3   0.000      1.000  0 0.00  1 0.00
#> SRR1562800     1   0.000      1.000  1 0.00  0 0.00
#> SRR1562801     1   0.000      1.000  1 0.00  0 0.00
#> SRR1562802     1   0.000      1.000  1 0.00  0 0.00
#> SRR1562803     1   0.000      1.000  1 0.00  0 0.00
#> SRR1562804     1   0.000      1.000  1 0.00  0 0.00
#> SRR1562805     1   0.000      1.000  1 0.00  0 0.00
#> SRR1562806     1   0.000      1.000  1 0.00  0 0.00
#> SRR1562807     1   0.000      1.000  1 0.00  0 0.00
#> SRR1562808     1   0.000      1.000  1 0.00  0 0.00
#> SRR1562809     1   0.000      1.000  1 0.00  0 0.00
#> SRR1562810     1   0.000      1.000  1 0.00  0 0.00
#> SRR1562811     1   0.000      1.000  1 0.00  0 0.00
#> SRR1562812     1   0.000      1.000  1 0.00  0 0.00
#> SRR1562813     1   0.000      1.000  1 0.00  0 0.00

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette p1    p2 p3 p4    p5
#> SRR1562718     2  0.0162      0.997  0 0.996  0  0 0.004
#> SRR1562719     2  0.0162      0.997  0 0.996  0  0 0.004
#> SRR1562720     2  0.0162      0.997  0 0.996  0  0 0.004
#> SRR1562721     2  0.0162      0.997  0 0.996  0  0 0.004
#> SRR1562723     2  0.0162      0.997  0 0.996  0  0 0.004
#> SRR1562724     2  0.0000      0.999  0 1.000  0  0 0.000
#> SRR1562725     2  0.0000      0.999  0 1.000  0  0 0.000
#> SRR1562726     2  0.0000      0.999  0 1.000  0  0 0.000
#> SRR1562727     2  0.0000      0.999  0 1.000  0  0 0.000
#> SRR1562728     2  0.0000      0.999  0 1.000  0  0 0.000
#> SRR1562729     2  0.0000      0.999  0 1.000  0  0 0.000
#> SRR1562730     2  0.0000      0.999  0 1.000  0  0 0.000
#> SRR1562731     2  0.0000      0.999  0 1.000  0  0 0.000
#> SRR1562732     2  0.0000      0.999  0 1.000  0  0 0.000
#> SRR1562733     2  0.0000      0.999  0 1.000  0  0 0.000
#> SRR1562734     2  0.0000      0.999  0 1.000  0  0 0.000
#> SRR1562735     2  0.0000      0.999  0 1.000  0  0 0.000
#> SRR1562736     5  0.0000      1.000  0 0.000  0  0 1.000
#> SRR1562737     5  0.0000      1.000  0 0.000  0  0 1.000
#> SRR1562738     5  0.0000      1.000  0 0.000  0  0 1.000
#> SRR1562739     5  0.0000      1.000  0 0.000  0  0 1.000
#> SRR1562740     5  0.0000      1.000  0 0.000  0  0 1.000
#> SRR1562741     5  0.0000      1.000  0 0.000  0  0 1.000
#> SRR1562742     5  0.0000      1.000  0 0.000  0  0 1.000
#> SRR1562743     5  0.0000      1.000  0 0.000  0  0 1.000
#> SRR1562744     5  0.0000      1.000  0 0.000  0  0 1.000
#> SRR1562745     5  0.0000      1.000  0 0.000  0  0 1.000
#> SRR1562746     5  0.0000      1.000  0 0.000  0  0 1.000
#> SRR1562747     5  0.0000      1.000  0 0.000  0  0 1.000
#> SRR1562748     4  0.0000      1.000  0 0.000  0  1 0.000
#> SRR1562749     4  0.0000      1.000  0 0.000  0  1 0.000
#> SRR1562750     4  0.0000      1.000  0 0.000  0  1 0.000
#> SRR1562751     4  0.0000      1.000  0 0.000  0  1 0.000
#> SRR1562752     4  0.0000      1.000  0 0.000  0  1 0.000
#> SRR1562753     4  0.0000      1.000  0 0.000  0  1 0.000
#> SRR1562754     4  0.0000      1.000  0 0.000  0  1 0.000
#> SRR1562755     4  0.0000      1.000  0 0.000  0  1 0.000
#> SRR1562756     4  0.0000      1.000  0 0.000  0  1 0.000
#> SRR1562757     4  0.0000      1.000  0 0.000  0  1 0.000
#> SRR1562758     4  0.0000      1.000  0 0.000  0  1 0.000
#> SRR1562759     4  0.0000      1.000  0 0.000  0  1 0.000
#> SRR1562792     3  0.0000      1.000  0 0.000  1  0 0.000
#> SRR1562793     3  0.0000      1.000  0 0.000  1  0 0.000
#> SRR1562794     3  0.0000      1.000  0 0.000  1  0 0.000
#> SRR1562795     3  0.0000      1.000  0 0.000  1  0 0.000
#> SRR1562796     3  0.0000      1.000  0 0.000  1  0 0.000
#> SRR1562797     3  0.0000      1.000  0 0.000  1  0 0.000
#> SRR1562798     3  0.0000      1.000  0 0.000  1  0 0.000
#> SRR1562799     3  0.0000      1.000  0 0.000  1  0 0.000
#> SRR1562800     1  0.0000      1.000  1 0.000  0  0 0.000
#> SRR1562801     1  0.0000      1.000  1 0.000  0  0 0.000
#> SRR1562802     1  0.0000      1.000  1 0.000  0  0 0.000
#> SRR1562803     1  0.0000      1.000  1 0.000  0  0 0.000
#> SRR1562804     1  0.0000      1.000  1 0.000  0  0 0.000
#> SRR1562805     1  0.0000      1.000  1 0.000  0  0 0.000
#> SRR1562806     1  0.0000      1.000  1 0.000  0  0 0.000
#> SRR1562807     1  0.0000      1.000  1 0.000  0  0 0.000
#> SRR1562808     1  0.0000      1.000  1 0.000  0  0 0.000
#> SRR1562809     1  0.0000      1.000  1 0.000  0  0 0.000
#> SRR1562810     1  0.0000      1.000  1 0.000  0  0 0.000
#> SRR1562811     1  0.0000      1.000  1 0.000  0  0 0.000
#> SRR1562812     1  0.0000      1.000  1 0.000  0  0 0.000
#> SRR1562813     1  0.0000      1.000  1 0.000  0  0 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2 p3 p4 p5    p6
#> SRR1562718     2   0.305      0.920 0.000 0.764  0  0  0 0.236
#> SRR1562719     2   0.305      0.920 0.000 0.764  0  0  0 0.236
#> SRR1562720     2   0.305      0.920 0.000 0.764  0  0  0 0.236
#> SRR1562721     2   0.305      0.920 0.000 0.764  0  0  0 0.236
#> SRR1562723     2   0.305      0.920 0.000 0.764  0  0  0 0.236
#> SRR1562724     2   0.305      0.920 0.000 0.764  0  0  0 0.236
#> SRR1562725     2   0.305      0.920 0.000 0.764  0  0  0 0.236
#> SRR1562726     2   0.305      0.920 0.000 0.764  0  0  0 0.236
#> SRR1562727     2   0.305      0.920 0.000 0.764  0  0  0 0.236
#> SRR1562728     2   0.305      0.920 0.000 0.764  0  0  0 0.236
#> SRR1562729     2   0.305      0.920 0.000 0.764  0  0  0 0.236
#> SRR1562730     2   0.000      0.846 0.000 1.000  0  0  0 0.000
#> SRR1562731     2   0.000      0.846 0.000 1.000  0  0  0 0.000
#> SRR1562732     2   0.000      0.846 0.000 1.000  0  0  0 0.000
#> SRR1562733     2   0.000      0.846 0.000 1.000  0  0  0 0.000
#> SRR1562734     2   0.000      0.846 0.000 1.000  0  0  0 0.000
#> SRR1562735     2   0.000      0.846 0.000 1.000  0  0  0 0.000
#> SRR1562736     5   0.000      1.000 0.000 0.000  0  0  1 0.000
#> SRR1562737     5   0.000      1.000 0.000 0.000  0  0  1 0.000
#> SRR1562738     5   0.000      1.000 0.000 0.000  0  0  1 0.000
#> SRR1562739     5   0.000      1.000 0.000 0.000  0  0  1 0.000
#> SRR1562740     5   0.000      1.000 0.000 0.000  0  0  1 0.000
#> SRR1562741     5   0.000      1.000 0.000 0.000  0  0  1 0.000
#> SRR1562742     5   0.000      1.000 0.000 0.000  0  0  1 0.000
#> SRR1562743     5   0.000      1.000 0.000 0.000  0  0  1 0.000
#> SRR1562744     5   0.000      1.000 0.000 0.000  0  0  1 0.000
#> SRR1562745     5   0.000      1.000 0.000 0.000  0  0  1 0.000
#> SRR1562746     5   0.000      1.000 0.000 0.000  0  0  1 0.000
#> SRR1562747     5   0.000      1.000 0.000 0.000  0  0  1 0.000
#> SRR1562748     4   0.000      1.000 0.000 0.000  0  1  0 0.000
#> SRR1562749     4   0.000      1.000 0.000 0.000  0  1  0 0.000
#> SRR1562750     4   0.000      1.000 0.000 0.000  0  1  0 0.000
#> SRR1562751     4   0.000      1.000 0.000 0.000  0  1  0 0.000
#> SRR1562752     4   0.000      1.000 0.000 0.000  0  1  0 0.000
#> SRR1562753     4   0.000      1.000 0.000 0.000  0  1  0 0.000
#> SRR1562754     4   0.000      1.000 0.000 0.000  0  1  0 0.000
#> SRR1562755     4   0.000      1.000 0.000 0.000  0  1  0 0.000
#> SRR1562756     4   0.000      1.000 0.000 0.000  0  1  0 0.000
#> SRR1562757     4   0.000      1.000 0.000 0.000  0  1  0 0.000
#> SRR1562758     4   0.000      1.000 0.000 0.000  0  1  0 0.000
#> SRR1562759     4   0.000      1.000 0.000 0.000  0  1  0 0.000
#> SRR1562792     3   0.000      1.000 0.000 0.000  1  0  0 0.000
#> SRR1562793     3   0.000      1.000 0.000 0.000  1  0  0 0.000
#> SRR1562794     3   0.000      1.000 0.000 0.000  1  0  0 0.000
#> SRR1562795     3   0.000      1.000 0.000 0.000  1  0  0 0.000
#> SRR1562796     3   0.000      1.000 0.000 0.000  1  0  0 0.000
#> SRR1562797     3   0.000      1.000 0.000 0.000  1  0  0 0.000
#> SRR1562798     3   0.000      1.000 0.000 0.000  1  0  0 0.000
#> SRR1562799     3   0.000      1.000 0.000 0.000  1  0  0 0.000
#> SRR1562800     6   0.305      1.000 0.236 0.000  0  0  0 0.764
#> SRR1562801     6   0.305      1.000 0.236 0.000  0  0  0 0.764
#> SRR1562802     6   0.305      1.000 0.236 0.000  0  0  0 0.764
#> SRR1562803     6   0.305      1.000 0.236 0.000  0  0  0 0.764
#> SRR1562804     6   0.305      1.000 0.236 0.000  0  0  0 0.764
#> SRR1562805     6   0.305      1.000 0.236 0.000  0  0  0 0.764
#> SRR1562806     1   0.000      1.000 1.000 0.000  0  0  0 0.000
#> SRR1562807     1   0.000      1.000 1.000 0.000  0  0  0 0.000
#> SRR1562808     1   0.000      1.000 1.000 0.000  0  0  0 0.000
#> SRR1562809     1   0.000      1.000 1.000 0.000  0  0  0 0.000
#> SRR1562810     1   0.000      1.000 1.000 0.000  0  0  0 0.000
#> SRR1562811     1   0.000      1.000 1.000 0.000  0  0  0 0.000
#> SRR1562812     1   0.000      1.000 1.000 0.000  0  0  0 0.000
#> SRR1562813     1   0.000      1.000 1.000 0.000  0  0  0 0.000

Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.

consensus_heatmap(res, k = 2)

plot of chunk tab-MAD-mclust-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-MAD-mclust-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-MAD-mclust-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-MAD-mclust-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-MAD-mclust-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-MAD-mclust-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-MAD-mclust-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-MAD-mclust-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-MAD-mclust-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-MAD-mclust-membership-heatmap-5

As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

plot of chunk tab-MAD-mclust-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-MAD-mclust-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-MAD-mclust-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-MAD-mclust-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-MAD-mclust-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-MAD-mclust-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-MAD-mclust-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-MAD-mclust-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-MAD-mclust-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-MAD-mclust-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-mclust-signature_compare

get_signature() returns a data frame invisibly. TO get the list of signatures, the function call should be assigned to a variable explicitly. In following code, if plot argument is set to FALSE, no heatmap is plotted while only the differential analysis is performed.

# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)

An example of the output of tb is:

#>   which_row         fdr    mean_1    mean_2 scaled_mean_1 scaled_mean_2 km
#> 1        38 0.042760348  8.373488  9.131774    -0.5533452     0.5164555  1
#> 2        40 0.018707592  7.106213  8.469186    -0.6173731     0.5762149  1
#> 3        55 0.019134737 10.221463 11.207825    -0.6159697     0.5749050  1
#> 4        59 0.006059896  5.921854  7.869574    -0.6899429     0.6439467  1
#> 5        60 0.018055526  8.928898 10.211722    -0.6204761     0.5791110  1
#> 6        98 0.009384629 15.714769 14.887706     0.6635654    -0.6193277  2
...

The columns in tb are:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. km: Row groups if k-means clustering is applied to rows.

UMAP plot which shows how samples are separated.

dimension_reduction(res, k = 2, method = "UMAP")

plot of chunk tab-MAD-mclust-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-MAD-mclust-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-MAD-mclust-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-MAD-mclust-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-MAD-mclust-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-mclust-collect-classes

If matrix rows can be associated to genes, consider to use functional_enrichment(res, ...) to perform function enrichment for the signature genes. See this vignette for more detailed explanations.


MAD:NMF**

The object with results only for a single top-value method and a single partition method can be extracted as:

res = res_list["MAD", "NMF"]
# you can also extract it by
# res = res_list["MAD:NMF"]

A summary of res and all the functions that can be applied to it:

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 15301 rows and 63 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'NMF' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 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-NMF-collect-plots

The plots are:

All the plots in panels can be made by individual functions and they are plotted later in this section.

select_partition_number() produces several plots showing different statistics for choosing “optimized” k. There are following statistics:

The detailed explanations of these statistics can be found in the cola vignette.

Generally speaking, lower PAC score, higher mean silhouette score or higher concordance corresponds to better partition. Rand index and Jaccard index measure how similar the current partition is compared to partition with k-1. If they are too similar, we won't accept k is better than k-1.

select_partition_number(res)

plot of chunk MAD-NMF-select-partition-number

The numeric values for all these statistics can be obtained by get_stats().

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4624 0.538   0.538
#> 3 3 0.766           0.953       0.938         0.1747 0.943   0.893
#> 4 4 0.959           0.959       0.967         0.3204 0.788   0.559
#> 5 5 0.803           0.891       0.892         0.0901 0.892   0.626
#> 6 6 0.802           0.703       0.821         0.0438 0.990   0.948

suggest_best_k() suggests the best \(k\) based on these statistics. The rules are as follows:

suggest_best_k(res)
#> [1] 4
#> attr(,"optional")
#> [1] 2

There is also optional best \(k\) = 2 that is worth to check.

Following shows the table of the partitions (You need to click the show/hide code output link to see it). The membership matrix (columns with name p*) is inferred by clue::cl_consensus() function with the SE method. Basically the value in the membership matrix represents the probability to belong to a certain group. The finall class label for an item is determined with the group with highest probability it belongs to.

In get_classes() function, the entropy is calculated from the membership matrix and the silhouette score is calculated from the consensus matrix.

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette p1 p2
#> SRR1562718     2       0          1  0  1
#> SRR1562719     2       0          1  0  1
#> SRR1562720     2       0          1  0  1
#> SRR1562721     2       0          1  0  1
#> SRR1562723     2       0          1  0  1
#> SRR1562724     2       0          1  0  1
#> SRR1562725     2       0          1  0  1
#> SRR1562726     2       0          1  0  1
#> SRR1562727     2       0          1  0  1
#> SRR1562728     2       0          1  0  1
#> SRR1562729     2       0          1  0  1
#> SRR1562730     2       0          1  0  1
#> SRR1562731     2       0          1  0  1
#> SRR1562732     2       0          1  0  1
#> SRR1562733     2       0          1  0  1
#> SRR1562734     2       0          1  0  1
#> SRR1562735     2       0          1  0  1
#> SRR1562736     2       0          1  0  1
#> SRR1562737     2       0          1  0  1
#> SRR1562738     2       0          1  0  1
#> SRR1562739     2       0          1  0  1
#> SRR1562740     2       0          1  0  1
#> SRR1562741     2       0          1  0  1
#> SRR1562742     2       0          1  0  1
#> SRR1562743     2       0          1  0  1
#> SRR1562744     2       0          1  0  1
#> SRR1562745     2       0          1  0  1
#> SRR1562746     2       0          1  0  1
#> SRR1562747     2       0          1  0  1
#> SRR1562748     2       0          1  0  1
#> SRR1562749     2       0          1  0  1
#> SRR1562750     2       0          1  0  1
#> SRR1562751     2       0          1  0  1
#> SRR1562752     2       0          1  0  1
#> SRR1562753     2       0          1  0  1
#> SRR1562754     2       0          1  0  1
#> SRR1562755     2       0          1  0  1
#> SRR1562756     2       0          1  0  1
#> SRR1562757     2       0          1  0  1
#> SRR1562758     2       0          1  0  1
#> SRR1562759     2       0          1  0  1
#> SRR1562792     1       0          1  1  0
#> SRR1562793     1       0          1  1  0
#> SRR1562794     1       0          1  1  0
#> SRR1562795     1       0          1  1  0
#> SRR1562796     1       0          1  1  0
#> SRR1562797     1       0          1  1  0
#> SRR1562798     1       0          1  1  0
#> SRR1562799     1       0          1  1  0
#> SRR1562800     1       0          1  1  0
#> SRR1562801     1       0          1  1  0
#> SRR1562802     1       0          1  1  0
#> SRR1562803     1       0          1  1  0
#> SRR1562804     1       0          1  1  0
#> SRR1562805     1       0          1  1  0
#> SRR1562806     1       0          1  1  0
#> SRR1562807     1       0          1  1  0
#> SRR1562808     1       0          1  1  0
#> SRR1562809     1       0          1  1  0
#> SRR1562810     1       0          1  1  0
#> SRR1562811     1       0          1  1  0
#> SRR1562812     1       0          1  1  0
#> SRR1562813     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1562718     2   0.000      0.942 0.000 1.000 0.000
#> SRR1562719     2   0.000      0.942 0.000 1.000 0.000
#> SRR1562720     2   0.000      0.942 0.000 1.000 0.000
#> SRR1562721     2   0.000      0.942 0.000 1.000 0.000
#> SRR1562723     2   0.000      0.942 0.000 1.000 0.000
#> SRR1562724     2   0.000      0.942 0.000 1.000 0.000
#> SRR1562725     2   0.000      0.942 0.000 1.000 0.000
#> SRR1562726     2   0.000      0.942 0.000 1.000 0.000
#> SRR1562727     2   0.000      0.942 0.000 1.000 0.000
#> SRR1562728     2   0.000      0.942 0.000 1.000 0.000
#> SRR1562729     2   0.000      0.942 0.000 1.000 0.000
#> SRR1562730     2   0.000      0.942 0.000 1.000 0.000
#> SRR1562731     2   0.000      0.942 0.000 1.000 0.000
#> SRR1562732     2   0.000      0.942 0.000 1.000 0.000
#> SRR1562733     2   0.000      0.942 0.000 1.000 0.000
#> SRR1562734     2   0.000      0.942 0.000 1.000 0.000
#> SRR1562735     2   0.000      0.942 0.000 1.000 0.000
#> SRR1562736     2   0.263      0.928 0.000 0.916 0.084
#> SRR1562737     2   0.304      0.924 0.000 0.896 0.104
#> SRR1562738     2   0.319      0.921 0.000 0.888 0.112
#> SRR1562739     2   0.245      0.929 0.000 0.924 0.076
#> SRR1562740     2   0.304      0.923 0.000 0.896 0.104
#> SRR1562741     2   0.271      0.927 0.000 0.912 0.088
#> SRR1562742     2   0.000      0.942 0.000 1.000 0.000
#> SRR1562743     2   0.000      0.942 0.000 1.000 0.000
#> SRR1562744     2   0.000      0.942 0.000 1.000 0.000
#> SRR1562745     2   0.000      0.942 0.000 1.000 0.000
#> SRR1562746     2   0.000      0.942 0.000 1.000 0.000
#> SRR1562747     2   0.000      0.942 0.000 1.000 0.000
#> SRR1562748     2   0.412      0.900 0.000 0.832 0.168
#> SRR1562749     2   0.412      0.900 0.000 0.832 0.168
#> SRR1562750     2   0.412      0.900 0.000 0.832 0.168
#> SRR1562751     2   0.412      0.900 0.000 0.832 0.168
#> SRR1562752     2   0.412      0.900 0.000 0.832 0.168
#> SRR1562753     2   0.412      0.900 0.000 0.832 0.168
#> SRR1562754     2   0.412      0.900 0.000 0.832 0.168
#> SRR1562755     2   0.412      0.900 0.000 0.832 0.168
#> SRR1562756     2   0.412      0.900 0.000 0.832 0.168
#> SRR1562757     2   0.412      0.900 0.000 0.832 0.168
#> SRR1562758     2   0.412      0.900 0.000 0.832 0.168
#> SRR1562759     2   0.412      0.900 0.000 0.832 0.168
#> SRR1562792     3   0.412      1.000 0.168 0.000 0.832
#> SRR1562793     3   0.412      1.000 0.168 0.000 0.832
#> SRR1562794     3   0.412      1.000 0.168 0.000 0.832
#> SRR1562795     3   0.412      1.000 0.168 0.000 0.832
#> SRR1562796     3   0.412      1.000 0.168 0.000 0.832
#> SRR1562797     3   0.412      1.000 0.168 0.000 0.832
#> SRR1562798     3   0.412      1.000 0.168 0.000 0.832
#> SRR1562799     3   0.412      1.000 0.168 0.000 0.832
#> SRR1562800     1   0.000      1.000 1.000 0.000 0.000
#> SRR1562801     1   0.000      1.000 1.000 0.000 0.000
#> SRR1562802     1   0.000      1.000 1.000 0.000 0.000
#> SRR1562803     1   0.000      1.000 1.000 0.000 0.000
#> SRR1562804     1   0.000      1.000 1.000 0.000 0.000
#> SRR1562805     1   0.000      1.000 1.000 0.000 0.000
#> SRR1562806     1   0.000      1.000 1.000 0.000 0.000
#> SRR1562807     1   0.000      1.000 1.000 0.000 0.000
#> SRR1562808     1   0.000      1.000 1.000 0.000 0.000
#> SRR1562809     1   0.000      1.000 1.000 0.000 0.000
#> SRR1562810     1   0.000      1.000 1.000 0.000 0.000
#> SRR1562811     1   0.000      1.000 1.000 0.000 0.000
#> SRR1562812     1   0.000      1.000 1.000 0.000 0.000
#> SRR1562813     1   0.000      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
#> SRR1562718     2  0.0000      0.994 0.000 1.000 0.000 0.000
#> SRR1562719     2  0.0000      0.994 0.000 1.000 0.000 0.000
#> SRR1562720     2  0.0000      0.994 0.000 1.000 0.000 0.000
#> SRR1562721     2  0.0000      0.994 0.000 1.000 0.000 0.000
#> SRR1562723     2  0.0000      0.994 0.000 1.000 0.000 0.000
#> SRR1562724     2  0.0000      0.994 0.000 1.000 0.000 0.000
#> SRR1562725     2  0.0000      0.994 0.000 1.000 0.000 0.000
#> SRR1562726     2  0.0000      0.994 0.000 1.000 0.000 0.000
#> SRR1562727     2  0.0000      0.994 0.000 1.000 0.000 0.000
#> SRR1562728     2  0.0000      0.994 0.000 1.000 0.000 0.000
#> SRR1562729     2  0.0000      0.994 0.000 1.000 0.000 0.000
#> SRR1562730     2  0.0000      0.994 0.000 1.000 0.000 0.000
#> SRR1562731     2  0.0000      0.994 0.000 1.000 0.000 0.000
#> SRR1562732     2  0.0000      0.994 0.000 1.000 0.000 0.000
#> SRR1562733     2  0.0000      0.994 0.000 1.000 0.000 0.000
#> SRR1562734     2  0.0000      0.994 0.000 1.000 0.000 0.000
#> SRR1562735     2  0.0000      0.994 0.000 1.000 0.000 0.000
#> SRR1562736     4  0.4134      0.778 0.000 0.260 0.000 0.740
#> SRR1562737     4  0.3837      0.814 0.000 0.224 0.000 0.776
#> SRR1562738     4  0.3764      0.819 0.000 0.216 0.000 0.784
#> SRR1562739     4  0.4134      0.778 0.000 0.260 0.000 0.740
#> SRR1562740     4  0.3873      0.811 0.000 0.228 0.000 0.772
#> SRR1562741     4  0.4040      0.793 0.000 0.248 0.000 0.752
#> SRR1562742     2  0.0707      0.982 0.000 0.980 0.000 0.020
#> SRR1562743     2  0.0707      0.982 0.000 0.980 0.000 0.020
#> SRR1562744     2  0.0707      0.982 0.000 0.980 0.000 0.020
#> SRR1562745     2  0.0817      0.978 0.000 0.976 0.000 0.024
#> SRR1562746     2  0.0707      0.982 0.000 0.980 0.000 0.020
#> SRR1562747     2  0.0707      0.982 0.000 0.980 0.000 0.020
#> SRR1562748     4  0.1305      0.905 0.000 0.036 0.004 0.960
#> SRR1562749     4  0.1305      0.905 0.000 0.036 0.004 0.960
#> SRR1562750     4  0.1305      0.905 0.000 0.036 0.004 0.960
#> SRR1562751     4  0.1305      0.905 0.000 0.036 0.004 0.960
#> SRR1562752     4  0.1305      0.905 0.000 0.036 0.004 0.960
#> SRR1562753     4  0.1305      0.905 0.000 0.036 0.004 0.960
#> SRR1562754     4  0.1118      0.906 0.000 0.036 0.000 0.964
#> SRR1562755     4  0.1118      0.906 0.000 0.036 0.000 0.964
#> SRR1562756     4  0.1118      0.906 0.000 0.036 0.000 0.964
#> SRR1562757     4  0.1118      0.906 0.000 0.036 0.000 0.964
#> SRR1562758     4  0.1118      0.906 0.000 0.036 0.000 0.964
#> SRR1562759     4  0.1118      0.906 0.000 0.036 0.000 0.964
#> SRR1562792     3  0.0188      1.000 0.004 0.000 0.996 0.000
#> SRR1562793     3  0.0188      1.000 0.004 0.000 0.996 0.000
#> SRR1562794     3  0.0188      1.000 0.004 0.000 0.996 0.000
#> SRR1562795     3  0.0188      1.000 0.004 0.000 0.996 0.000
#> SRR1562796     3  0.0188      1.000 0.004 0.000 0.996 0.000
#> SRR1562797     3  0.0188      1.000 0.004 0.000 0.996 0.000
#> SRR1562798     3  0.0188      1.000 0.004 0.000 0.996 0.000
#> SRR1562799     3  0.0188      1.000 0.004 0.000 0.996 0.000
#> SRR1562800     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1562801     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1562802     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1562803     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1562804     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1562805     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1562806     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1562807     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1562808     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1562809     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1562810     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1562811     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1562812     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1562813     1  0.0000      1.000 1.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette   p1    p2 p3    p4    p5
#> SRR1562718     2   0.191      0.948 0.00 0.908  0 0.000 0.092
#> SRR1562719     2   0.207      0.936 0.00 0.896  0 0.000 0.104
#> SRR1562720     2   0.185      0.951 0.00 0.912  0 0.000 0.088
#> SRR1562721     2   0.173      0.956 0.00 0.920  0 0.000 0.080
#> SRR1562723     2   0.191      0.948 0.00 0.908  0 0.000 0.092
#> SRR1562724     2   0.161      0.959 0.00 0.928  0 0.000 0.072
#> SRR1562725     2   0.161      0.959 0.00 0.928  0 0.000 0.072
#> SRR1562726     2   0.161      0.959 0.00 0.928  0 0.000 0.072
#> SRR1562727     2   0.161      0.959 0.00 0.928  0 0.000 0.072
#> SRR1562728     2   0.161      0.959 0.00 0.928  0 0.000 0.072
#> SRR1562729     2   0.161      0.959 0.00 0.928  0 0.000 0.072
#> SRR1562730     2   0.000      0.936 0.00 1.000  0 0.000 0.000
#> SRR1562731     2   0.000      0.936 0.00 1.000  0 0.000 0.000
#> SRR1562732     2   0.000      0.936 0.00 1.000  0 0.000 0.000
#> SRR1562733     2   0.000      0.936 0.00 1.000  0 0.000 0.000
#> SRR1562734     2   0.000      0.936 0.00 1.000  0 0.000 0.000
#> SRR1562735     2   0.000      0.936 0.00 1.000  0 0.000 0.000
#> SRR1562736     5   0.365      0.818 0.00 0.052  0 0.132 0.816
#> SRR1562737     5   0.362      0.816 0.00 0.048  0 0.136 0.816
#> SRR1562738     5   0.360      0.811 0.00 0.044  0 0.140 0.816
#> SRR1562739     5   0.360      0.811 0.00 0.044  0 0.140 0.816
#> SRR1562740     5   0.362      0.816 0.00 0.048  0 0.136 0.816
#> SRR1562741     5   0.360      0.811 0.00 0.044  0 0.140 0.816
#> SRR1562742     5   0.314      0.843 0.00 0.204  0 0.000 0.796
#> SRR1562743     5   0.318      0.842 0.00 0.208  0 0.000 0.792
#> SRR1562744     5   0.318      0.842 0.00 0.208  0 0.000 0.792
#> SRR1562745     5   0.314      0.843 0.00 0.204  0 0.000 0.796
#> SRR1562746     5   0.318      0.842 0.00 0.208  0 0.000 0.792
#> SRR1562747     5   0.318      0.842 0.00 0.208  0 0.000 0.792
#> SRR1562748     4   0.051      0.786 0.00 0.000  0 0.984 0.016
#> SRR1562749     4   0.051      0.786 0.00 0.000  0 0.984 0.016
#> SRR1562750     4   0.051      0.786 0.00 0.000  0 0.984 0.016
#> SRR1562751     4   0.051      0.786 0.00 0.000  0 0.984 0.016
#> SRR1562752     4   0.051      0.786 0.00 0.000  0 0.984 0.016
#> SRR1562753     4   0.051      0.786 0.00 0.000  0 0.984 0.016
#> SRR1562754     4   0.405      0.674 0.00 0.000  0 0.644 0.356
#> SRR1562755     4   0.391      0.716 0.00 0.000  0 0.676 0.324
#> SRR1562756     4   0.391      0.716 0.00 0.000  0 0.676 0.324
#> SRR1562757     4   0.388      0.721 0.00 0.000  0 0.684 0.316
#> SRR1562758     4   0.402      0.688 0.00 0.000  0 0.652 0.348
#> SRR1562759     4   0.397      0.704 0.00 0.000  0 0.664 0.336
#> SRR1562792     3   0.000      1.000 0.00 0.000  1 0.000 0.000
#> SRR1562793     3   0.000      1.000 0.00 0.000  1 0.000 0.000
#> SRR1562794     3   0.000      1.000 0.00 0.000  1 0.000 0.000
#> SRR1562795     3   0.000      1.000 0.00 0.000  1 0.000 0.000
#> SRR1562796     3   0.000      1.000 0.00 0.000  1 0.000 0.000
#> SRR1562797     3   0.000      1.000 0.00 0.000  1 0.000 0.000
#> SRR1562798     3   0.000      1.000 0.00 0.000  1 0.000 0.000
#> SRR1562799     3   0.000      1.000 0.00 0.000  1 0.000 0.000
#> SRR1562800     1   0.252      0.928 0.86 0.000  0 0.000 0.140
#> SRR1562801     1   0.252      0.928 0.86 0.000  0 0.000 0.140
#> SRR1562802     1   0.252      0.928 0.86 0.000  0 0.000 0.140
#> SRR1562803     1   0.252      0.928 0.86 0.000  0 0.000 0.140
#> SRR1562804     1   0.252      0.928 0.86 0.000  0 0.000 0.140
#> SRR1562805     1   0.252      0.928 0.86 0.000  0 0.000 0.140
#> SRR1562806     1   0.000      0.947 1.00 0.000  0 0.000 0.000
#> SRR1562807     1   0.000      0.947 1.00 0.000  0 0.000 0.000
#> SRR1562808     1   0.000      0.947 1.00 0.000  0 0.000 0.000
#> SRR1562809     1   0.000      0.947 1.00 0.000  0 0.000 0.000
#> SRR1562810     1   0.000      0.947 1.00 0.000  0 0.000 0.000
#> SRR1562811     1   0.000      0.947 1.00 0.000  0 0.000 0.000
#> SRR1562812     1   0.000      0.947 1.00 0.000  0 0.000 0.000
#> SRR1562813     1   0.000      0.947 1.00 0.000  0 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2 p3    p4    p5    p6
#> SRR1562718     2  0.2778      0.846 0.000 0.824  0 0.000 0.168 0.008
#> SRR1562719     2  0.2877      0.844 0.000 0.820  0 0.000 0.168 0.012
#> SRR1562720     2  0.2558      0.849 0.000 0.840  0 0.000 0.156 0.004
#> SRR1562721     2  0.2558      0.849 0.000 0.840  0 0.000 0.156 0.004
#> SRR1562723     2  0.2595      0.848 0.000 0.836  0 0.000 0.160 0.004
#> SRR1562724     2  0.3081      0.833 0.000 0.776  0 0.000 0.220 0.004
#> SRR1562725     2  0.3136      0.829 0.000 0.768  0 0.000 0.228 0.004
#> SRR1562726     2  0.3189      0.825 0.000 0.760  0 0.000 0.236 0.004
#> SRR1562727     2  0.3136      0.831 0.000 0.768  0 0.000 0.228 0.004
#> SRR1562728     2  0.3050      0.826 0.000 0.764  0 0.000 0.236 0.000
#> SRR1562729     2  0.3163      0.827 0.000 0.764  0 0.000 0.232 0.004
#> SRR1562730     2  0.2135      0.781 0.000 0.872  0 0.000 0.000 0.128
#> SRR1562731     2  0.2135      0.781 0.000 0.872  0 0.000 0.000 0.128
#> SRR1562732     2  0.2135      0.781 0.000 0.872  0 0.000 0.000 0.128
#> SRR1562733     2  0.2135      0.781 0.000 0.872  0 0.000 0.000 0.128
#> SRR1562734     2  0.2135      0.781 0.000 0.872  0 0.000 0.000 0.128
#> SRR1562735     2  0.2135      0.781 0.000 0.872  0 0.000 0.000 0.128
#> SRR1562736     5  0.1092      0.821 0.000 0.020  0 0.020 0.960 0.000
#> SRR1562737     5  0.0914      0.828 0.000 0.016  0 0.016 0.968 0.000
#> SRR1562738     5  0.0914      0.828 0.000 0.016  0 0.016 0.968 0.000
#> SRR1562739     5  0.0914      0.828 0.000 0.016  0 0.016 0.968 0.000
#> SRR1562740     5  0.0820      0.828 0.000 0.012  0 0.016 0.972 0.000
#> SRR1562741     5  0.0914      0.827 0.000 0.016  0 0.016 0.968 0.000
#> SRR1562742     5  0.3730      0.822 0.000 0.060  0 0.000 0.772 0.168
#> SRR1562743     5  0.3763      0.821 0.000 0.060  0 0.000 0.768 0.172
#> SRR1562744     5  0.3763      0.821 0.000 0.060  0 0.000 0.768 0.172
#> SRR1562745     5  0.3763      0.821 0.000 0.060  0 0.000 0.768 0.172
#> SRR1562746     5  0.3829      0.813 0.000 0.060  0 0.000 0.760 0.180
#> SRR1562747     5  0.3796      0.817 0.000 0.060  0 0.000 0.764 0.176
#> SRR1562748     4  0.0363      0.556 0.000 0.000  0 0.988 0.012 0.000
#> SRR1562749     4  0.0260      0.559 0.000 0.000  0 0.992 0.008 0.000
#> SRR1562750     4  0.0146      0.559 0.000 0.000  0 0.996 0.004 0.000
#> SRR1562751     4  0.0260      0.559 0.000 0.000  0 0.992 0.008 0.000
#> SRR1562752     4  0.0146      0.559 0.000 0.000  0 0.996 0.004 0.000
#> SRR1562753     4  0.0146      0.559 0.000 0.000  0 0.996 0.004 0.000
#> SRR1562754     6  0.6337      0.966 0.000 0.008  0 0.332 0.312 0.348
#> SRR1562755     6  0.6330      0.965 0.000 0.008  0 0.344 0.300 0.348
#> SRR1562756     4  0.6323     -0.962 0.000 0.008  0 0.352 0.292 0.348
#> SRR1562757     4  0.6323     -0.955 0.000 0.008  0 0.356 0.292 0.344
#> SRR1562758     4  0.6330     -0.970 0.000 0.008  0 0.348 0.300 0.344
#> SRR1562759     4  0.6333     -0.978 0.000 0.008  0 0.344 0.304 0.344
#> SRR1562792     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1562793     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1562794     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1562795     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1562796     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1562797     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1562798     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1562799     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> SRR1562800     1  0.0000      0.754 1.000 0.000  0 0.000 0.000 0.000
#> SRR1562801     1  0.0000      0.754 1.000 0.000  0 0.000 0.000 0.000
#> SRR1562802     1  0.0000      0.754 1.000 0.000  0 0.000 0.000 0.000
#> SRR1562803     1  0.0000      0.754 1.000 0.000  0 0.000 0.000 0.000
#> SRR1562804     1  0.0146      0.752 0.996 0.000  0 0.000 0.004 0.000
#> SRR1562805     1  0.0146      0.752 0.996 0.000  0 0.000 0.004 0.000
#> SRR1562806     1  0.3804      0.823 0.576 0.000  0 0.000 0.000 0.424
#> SRR1562807     1  0.3804      0.823 0.576 0.000  0 0.000 0.000 0.424
#> SRR1562808     1  0.3804      0.823 0.576 0.000  0 0.000 0.000 0.424
#> SRR1562809     1  0.3804      0.823 0.576 0.000  0 0.000 0.000 0.424
#> SRR1562810     1  0.3804      0.823 0.576 0.000  0 0.000 0.000 0.424
#> SRR1562811     1  0.3804      0.823 0.576 0.000  0 0.000 0.000 0.424
#> SRR1562812     1  0.3804      0.823 0.576 0.000  0 0.000 0.000 0.424
#> SRR1562813     1  0.3804      0.823 0.576 0.000  0 0.000 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-MAD-NMF-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-MAD-NMF-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-MAD-NMF-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-MAD-NMF-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-MAD-NMF-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-MAD-NMF-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-MAD-NMF-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-MAD-NMF-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-MAD-NMF-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-MAD-NMF-membership-heatmap-5

As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

plot of chunk tab-MAD-NMF-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-MAD-NMF-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-MAD-NMF-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-MAD-NMF-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-MAD-NMF-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-MAD-NMF-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-MAD-NMF-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-MAD-NMF-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-MAD-NMF-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-MAD-NMF-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-NMF-signature_compare

get_signature() returns a data frame invisibly. TO get the list of signatures, the function call should be assigned to a variable explicitly. In following code, if plot argument is set to FALSE, no heatmap is plotted while only the differential analysis is performed.

# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)

An example of the output of tb is:

#>   which_row         fdr    mean_1    mean_2 scaled_mean_1 scaled_mean_2 km
#> 1        38 0.042760348  8.373488  9.131774    -0.5533452     0.5164555  1
#> 2        40 0.018707592  7.106213  8.469186    -0.6173731     0.5762149  1
#> 3        55 0.019134737 10.221463 11.207825    -0.6159697     0.5749050  1
#> 4        59 0.006059896  5.921854  7.869574    -0.6899429     0.6439467  1
#> 5        60 0.018055526  8.928898 10.211722    -0.6204761     0.5791110  1
#> 6        98 0.009384629 15.714769 14.887706     0.6635654    -0.6193277  2
...

The columns in tb are:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. km: Row groups if k-means clustering is applied to rows.

UMAP plot which shows how samples are separated.

dimension_reduction(res, k = 2, method = "UMAP")

plot of chunk tab-MAD-NMF-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-MAD-NMF-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-MAD-NMF-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-MAD-NMF-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-MAD-NMF-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-NMF-collect-classes

If matrix rows can be associated to genes, consider to use functional_enrichment(res, ...) to perform function enrichment for the signature genes. See this vignette for more detailed explanations.


ATC:hclust**

The object with results only for a single top-value method and a single partition method can be extracted as:

res = res_list["ATC", "hclust"]
# you can also extract it by
# res = res_list["ATC:hclust"]

A summary of res and all the functions that can be applied to it:

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 15301 rows and 63 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#>   Subgroups are detected by 'hclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 6.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

collect_plots() function collects all the plots made from res for all k (number of partitions) into one single page to provide an easy and fast comparison between different k.

collect_plots(res)

plot of chunk ATC-hclust-collect-plots

The plots are:

All the plots in panels can be made by individual functions and they are plotted later in this section.

select_partition_number() produces several plots showing different statistics for choosing “optimized” k. There are following statistics:

The detailed explanations of these statistics can be found in the cola vignette.

Generally speaking, lower PAC score, higher mean silhouette score or higher concordance corresponds to better partition. Rand index and Jaccard index measure how similar the current partition is compared to partition with k-1. If they are too similar, we won't accept k is better than k-1.

select_partition_number(res)

plot of chunk ATC-hclust-select-partition-number

The numeric values for all these statistics can be obtained by get_stats().

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2     1           1.000       1.000         0.4624 0.538   0.538
#> 3 3     1           1.000       1.000         0.1239 0.943   0.893
#> 4 4     1           1.000       1.000         0.0472 0.975   0.949
#> 5 5     1           0.992       0.995         0.3261 0.822   0.609
#> 6 6     1           0.996       0.997         0.1444 0.896   0.624

suggest_best_k() suggests the best \(k\) based on these statistics. The rules are as follows:

suggest_best_k(res)
#> [1] 6
#> attr(,"optional")
#> [1] 2 3 4 5

There is also optional best \(k\) = 2 3 4 5 that is worth to check.

Following shows the table of the partitions (You need to click the show/hide code output link to see it). The membership matrix (columns with name p*) is inferred by clue::cl_consensus() function with the SE method. Basically the value in the membership matrix represents the probability to belong to a certain group. The finall class label for an item is determined with the group with highest probability it belongs to.

In get_classes() function, the entropy is calculated from the membership matrix and the silhouette score is calculated from the consensus matrix.

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette p1 p2
#> SRR1562718     2       0          1  0  1
#> SRR1562719     2       0          1  0  1
#> SRR1562720     2       0          1  0  1
#> SRR1562721     2       0          1  0  1
#> SRR1562723     2       0          1  0  1
#> SRR1562724     2       0          1  0  1
#> SRR1562725     2       0          1  0  1
#> SRR1562726     2       0          1  0  1
#> SRR1562727     2       0          1  0  1
#> SRR1562728     2       0          1  0  1
#> SRR1562729     2       0          1  0  1
#> SRR1562730     2       0          1  0  1
#> SRR1562731     2       0          1  0  1
#> SRR1562732     2       0          1  0  1
#> SRR1562733     2       0          1  0  1
#> SRR1562734     2       0          1  0  1
#> SRR1562735     2       0          1  0  1
#> SRR1562736     2       0          1  0  1
#> SRR1562737     2       0          1  0  1
#> SRR1562738     2       0          1  0  1
#> SRR1562739     2       0          1  0  1
#> SRR1562740     2       0          1  0  1
#> SRR1562741     2       0          1  0  1
#> SRR1562742     2       0          1  0  1
#> SRR1562743     2       0          1  0  1
#> SRR1562744     2       0          1  0  1
#> SRR1562745     2       0          1  0  1
#> SRR1562746     2       0          1  0  1
#> SRR1562747     2       0          1  0  1
#> SRR1562748     2       0          1  0  1
#> SRR1562749     2       0          1  0  1
#> SRR1562750     2       0          1  0  1
#> SRR1562751     2       0          1  0  1
#> SRR1562752     2       0          1  0  1
#> SRR1562753     2       0          1  0  1
#> SRR1562754     2       0          1  0  1
#> SRR1562755     2       0          1  0  1
#> SRR1562756     2       0          1  0  1
#> SRR1562757     2       0          1  0  1
#> SRR1562758     2       0          1  0  1
#> SRR1562759     2       0          1  0  1
#> SRR1562792     1       0          1  1  0
#> SRR1562793     1       0          1  1  0
#> SRR1562794     1       0          1  1  0
#> SRR1562795     1       0          1  1  0
#> SRR1562796     1       0          1  1  0
#> SRR1562797     1       0          1  1  0
#> SRR1562798     1       0          1  1  0
#> SRR1562799     1       0          1  1  0
#> SRR1562800     1       0          1  1  0
#> SRR1562801     1       0          1  1  0
#> SRR1562802     1       0          1  1  0
#> SRR1562803     1       0          1  1  0
#> SRR1562804     1       0          1  1  0
#> SRR1562805     1       0          1  1  0
#> SRR1562806     1       0          1  1  0
#> SRR1562807     1       0          1  1  0
#> SRR1562808     1       0          1  1  0
#> SRR1562809     1       0          1  1  0
#> SRR1562810     1       0          1  1  0
#> SRR1562811     1       0          1  1  0
#> SRR1562812     1       0          1  1  0
#> SRR1562813     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette p1 p2 p3
#> SRR1562718     2       0          1  0  1  0
#> SRR1562719     2       0          1  0  1  0
#> SRR1562720     2       0          1  0  1  0
#> SRR1562721     2       0          1  0  1  0
#> SRR1562723     2       0          1  0  1  0
#> SRR1562724     2       0          1  0  1  0
#> SRR1562725     2       0          1  0  1  0
#> SRR1562726     2       0          1  0  1  0
#> SRR1562727     2       0          1  0  1  0
#> SRR1562728     2       0          1  0  1  0
#> SRR1562729     2       0          1  0  1  0
#> SRR1562730     2       0          1  0  1  0
#> SRR1562731     2       0          1  0  1  0
#> SRR1562732     2       0          1  0  1  0
#> SRR1562733     2       0          1  0  1  0
#> SRR1562734     2       0          1  0  1  0
#> SRR1562735     2       0          1  0  1  0
#> SRR1562736     2       0          1  0  1  0
#> SRR1562737     2       0          1  0  1  0
#> SRR1562738     2       0          1  0  1  0
#> SRR1562739     2       0          1  0  1  0
#> SRR1562740     2       0          1  0  1  0
#> SRR1562741     2       0          1  0  1  0
#> SRR1562742     2       0          1  0  1  0
#> SRR1562743     2       0          1  0  1  0
#> SRR1562744     2       0          1  0  1  0
#> SRR1562745     2       0          1  0  1  0
#> SRR1562746     2       0          1  0  1  0
#> SRR1562747     2       0          1  0  1  0
#> SRR1562748     2       0          1  0  1  0
#> SRR1562749     2       0          1  0  1  0
#> SRR1562750     2       0          1  0  1  0
#> SRR1562751     2       0          1  0  1  0
#> SRR1562752     2       0          1  0  1  0
#> SRR1562753     2       0          1  0  1  0
#> SRR1562754     2       0          1  0  1  0
#> SRR1562755     2       0          1  0  1  0
#> SRR1562756     2       0          1  0  1  0
#> SRR1562757     2       0          1  0  1  0
#> SRR1562758     2       0          1  0  1  0
#> SRR1562759     2       0          1  0  1  0
#> SRR1562792     3       0          1  0  0  1
#> SRR1562793     3       0          1  0  0  1
#> SRR1562794     3       0          1  0  0  1
#> SRR1562795     3       0          1  0  0  1
#> SRR1562796     3       0          1  0  0  1
#> SRR1562797     3       0          1  0  0  1
#> SRR1562798     3       0          1  0  0  1
#> SRR1562799     3       0          1  0  0  1
#> SRR1562800     1       0          1  1  0  0
#> SRR1562801     1       0          1  1  0  0
#> SRR1562802     1       0          1  1  0  0
#> SRR1562803     1       0          1  1  0  0
#> SRR1562804     1       0          1  1  0  0
#> SRR1562805     1       0          1  1  0  0
#> SRR1562806     1       0          1  1  0  0
#> SRR1562807     1       0          1  1  0  0
#> SRR1562808     1       0          1  1  0  0
#> SRR1562809     1       0          1  1  0  0
#> SRR1562810     1       0          1  1  0  0
#> SRR1562811     1       0          1  1  0  0
#> SRR1562812     1       0          1  1  0  0
#> SRR1562813     1       0          1  1  0  0

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette p1 p2 p3 p4
#> SRR1562718     2       0          1  0  1  0  0
#> SRR1562719     2       0          1  0  1  0  0
#> SRR1562720     2       0          1  0  1  0  0
#> SRR1562721     2       0          1  0  1  0  0
#> SRR1562723     2       0          1  0  1  0  0
#> SRR1562724     2       0          1  0  1  0  0
#> SRR1562725     2       0          1  0  1  0  0
#> SRR1562726     2       0          1  0  1  0  0
#> SRR1562727     2       0          1  0  1  0  0
#> SRR1562728     2       0          1  0  1  0  0
#> SRR1562729     2       0          1  0  1  0  0
#> SRR1562730     2       0          1  0  1  0  0
#> SRR1562731     2       0          1  0  1  0  0
#> SRR1562732     2       0          1  0  1  0  0
#> SRR1562733     2       0          1  0  1  0  0
#> SRR1562734     2       0          1  0  1  0  0
#> SRR1562735     2       0          1  0  1  0  0
#> SRR1562736     2       0          1  0  1  0  0
#> SRR1562737     2       0          1  0  1  0  0
#> SRR1562738     2       0          1  0  1  0  0
#> SRR1562739     2       0          1  0  1  0  0
#> SRR1562740     2       0          1  0  1  0  0
#> SRR1562741     2       0          1  0  1  0  0
#> SRR1562742     2       0          1  0  1  0  0
#> SRR1562743     2       0          1  0  1  0  0
#> SRR1562744     2       0          1  0  1  0  0
#> SRR1562745     2       0          1  0  1  0  0
#> SRR1562746     2       0          1  0  1  0  0
#> SRR1562747     2       0          1  0  1  0  0
#> SRR1562748     2       0          1  0  1  0  0
#> SRR1562749     2       0          1  0  1  0  0
#> SRR1562750     2       0          1  0  1  0  0
#> SRR1562751     2       0          1  0  1  0  0
#> SRR1562752     2       0          1  0  1  0  0
#> SRR1562753     2       0          1  0  1  0  0
#> SRR1562754     2       0          1  0  1  0  0
#> SRR1562755     2       0          1  0  1  0  0
#> SRR1562756     2       0          1  0  1  0  0
#> SRR1562757     2       0          1  0  1  0  0
#> SRR1562758     2       0          1  0  1  0  0
#> SRR1562759     2       0          1  0  1  0  0
#> SRR1562792     3       0          1  0  0  1  0
#> SRR1562793     3       0          1  0  0  1  0
#> SRR1562794     3       0          1  0  0  1  0
#> SRR1562795     3       0          1  0  0  1  0
#> SRR1562796     3       0          1  0  0  1  0
#> SRR1562797     3       0          1  0  0  1  0
#> SRR1562798     3       0          1  0  0  1  0
#> SRR1562799     3       0          1  0  0  1  0
#> SRR1562800     4       0          1  0  0  0  1
#> SRR1562801     4       0          1  0  0  0  1
#> SRR1562802     4       0          1  0  0  0  1
#> SRR1562803     4       0          1  0  0  0  1
#> SRR1562804     4       0          1  0  0  0  1
#> SRR1562805     4       0          1  0  0  0  1
#> SRR1562806     1       0          1  1  0  0  0
#> SRR1562807     1       0          1  1  0  0  0
#> SRR1562808     1       0          1  1  0  0  0
#> SRR1562809     1       0          1  1  0  0  0
#> SRR1562810     1       0          1  1  0  0  0
#> SRR1562811     1       0          1  1  0  0  0
#> SRR1562812     1       0          1  1  0  0  0
#> SRR1562813     1       0          1  1  0  0  0

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette p1    p2 p3    p4 p5
#> SRR1562718     2  0.0000      0.991  0 1.000  0 0.000  0
#> SRR1562719     2  0.0000      0.991  0 1.000  0 0.000  0
#> SRR1562720     2  0.0000      0.991  0 1.000  0 0.000  0
#> SRR1562721     2  0.0000      0.991  0 1.000  0 0.000  0
#> SRR1562723     2  0.0000      0.991  0 1.000  0 0.000  0
#> SRR1562724     2  0.0000      0.991  0 1.000  0 0.000  0
#> SRR1562725     2  0.0000      0.991  0 1.000  0 0.000  0
#> SRR1562726     2  0.0000      0.991  0 1.000  0 0.000  0
#> SRR1562727     2  0.0000      0.991  0 1.000  0 0.000  0
#> SRR1562728     2  0.0000      0.991  0 1.000  0 0.000  0
#> SRR1562729     2  0.0000      0.991  0 1.000  0 0.000  0
#> SRR1562730     2  0.0000      0.991  0 1.000  0 0.000  0
#> SRR1562731     2  0.0000      0.991  0 1.000  0 0.000  0
#> SRR1562732     2  0.0000      0.991  0 1.000  0 0.000  0
#> SRR1562733     2  0.0000      0.991  0 1.000  0 0.000  0
#> SRR1562734     2  0.0000      0.991  0 1.000  0 0.000  0
#> SRR1562735     2  0.0000      0.991  0 1.000  0 0.000  0
#> SRR1562736     2  0.0609      0.987  0 0.980  0 0.020  0
#> SRR1562737     2  0.0609      0.987  0 0.980  0 0.020  0
#> SRR1562738     2  0.0609      0.987  0 0.980  0 0.020  0
#> SRR1562739     2  0.0609      0.987  0 0.980  0 0.020  0
#> SRR1562740     2  0.0609      0.987  0 0.980  0 0.020  0
#> SRR1562741     2  0.0609      0.987  0 0.980  0 0.020  0
#> SRR1562742     2  0.0609      0.987  0 0.980  0 0.020  0
#> SRR1562743     2  0.0609      0.987  0 0.980  0 0.020  0
#> SRR1562744     2  0.0609      0.987  0 0.980  0 0.020  0
#> SRR1562745     2  0.0609      0.987  0 0.980  0 0.020  0
#> SRR1562746     2  0.0609      0.987  0 0.980  0 0.020  0
#> SRR1562747     2  0.0609      0.987  0 0.980  0 0.020  0
#> SRR1562748     4  0.0000      0.987  0 0.000  0 1.000  0
#> SRR1562749     4  0.0000      0.987  0 0.000  0 1.000  0
#> SRR1562750     4  0.0000      0.987  0 0.000  0 1.000  0
#> SRR1562751     4  0.0000      0.987  0 0.000  0 1.000  0
#> SRR1562752     4  0.0000      0.987  0 0.000  0 1.000  0
#> SRR1562753     4  0.0000      0.987  0 0.000  0 1.000  0
#> SRR1562754     4  0.0510      0.987  0 0.016  0 0.984  0
#> SRR1562755     4  0.0510      0.987  0 0.016  0 0.984  0
#> SRR1562756     4  0.0510      0.987  0 0.016  0 0.984  0
#> SRR1562757     4  0.0510      0.987  0 0.016  0 0.984  0
#> SRR1562758     4  0.0510      0.987  0 0.016  0 0.984  0
#> SRR1562759     4  0.0510      0.987  0 0.016  0 0.984  0
#> SRR1562792     3  0.0000      1.000  0 0.000  1 0.000  0
#> SRR1562793     3  0.0000      1.000  0 0.000  1 0.000  0
#> SRR1562794     3  0.0000      1.000  0 0.000  1 0.000  0
#> SRR1562795     3  0.0000      1.000  0 0.000  1 0.000  0
#> SRR1562796     3  0.0000      1.000  0 0.000  1 0.000  0
#> SRR1562797     3  0.0000      1.000  0 0.000  1 0.000  0
#> SRR1562798     3  0.0000      1.000  0 0.000  1 0.000  0
#> SRR1562799     3  0.0000      1.000  0 0.000  1 0.000  0
#> SRR1562800     5  0.0000      1.000  0 0.000  0 0.000  1
#> SRR1562801     5  0.0000      1.000  0 0.000  0 0.000  1
#> SRR1562802     5  0.0000      1.000  0 0.000  0 0.000  1
#> SRR1562803     5  0.0000      1.000  0 0.000  0 0.000  1
#> SRR1562804     5  0.0000      1.000  0 0.000  0 0.000  1
#> SRR1562805     5  0.0000      1.000  0 0.000  0 0.000  1
#> SRR1562806     1  0.0000      1.000  1 0.000  0 0.000  0
#> SRR1562807     1  0.0000      1.000  1 0.000  0 0.000  0
#> SRR1562808     1  0.0000      1.000  1 0.000  0 0.000  0
#> SRR1562809     1  0.0000      1.000  1 0.000  0 0.000  0
#> SRR1562810     1  0.0000      1.000  1 0.000  0 0.000  0
#> SRR1562811     1  0.0000      1.000  1 0.000  0 0.000  0
#> SRR1562812     1  0.0000      1.000  1 0.000  0 0.000  0
#> SRR1562813     1  0.0000      1.000  1 0.000  0 0.000  0

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette p1 p2 p3    p4    p5 p6
#> SRR1562718     2  0.0000      1.000  0  1  0 0.000 0.000  0
#> SRR1562719     2  0.0000      1.000  0  1  0 0.000 0.000  0
#> SRR1562720     2  0.0000      1.000  0  1  0 0.000 0.000  0
#> SRR1562721     2  0.0000      1.000  0  1  0 0.000 0.000  0
#> SRR1562723     2  0.0000      1.000  0  1  0 0.000 0.000  0
#> SRR1562724     2  0.0000      1.000  0  1  0 0.000 0.000  0
#> SRR1562725     2  0.0000      1.000  0  1  0 0.000 0.000  0
#> SRR1562726     2  0.0000      1.000  0  1  0 0.000 0.000  0
#> SRR1562727     2  0.0000      1.000  0  1  0 0.000 0.000  0
#> SRR1562728     2  0.0000      1.000  0  1  0 0.000 0.000  0
#> SRR1562729     2  0.0000      1.000  0  1  0 0.000 0.000  0
#> SRR1562730     2  0.0000      1.000  0  1  0 0.000 0.000  0
#> SRR1562731     2  0.0000      1.000  0  1  0 0.000 0.000  0
#> SRR1562732     2  0.0000      1.000  0  1  0 0.000 0.000  0
#> SRR1562733     2  0.0000      1.000  0  1  0 0.000 0.000  0
#> SRR1562734     2  0.0000      1.000  0  1  0 0.000 0.000  0
#> SRR1562735     2  0.0000      1.000  0  1  0 0.000 0.000  0
#> SRR1562736     5  0.0000      1.000  0  0  0 0.000 1.000  0
#> SRR1562737     5  0.0000      1.000  0  0  0 0.000 1.000  0
#> SRR1562738     5  0.0000      1.000  0  0  0 0.000 1.000  0
#> SRR1562739     5  0.0000      1.000  0  0  0 0.000 1.000  0
#> SRR1562740     5  0.0000      1.000  0  0  0 0.000 1.000  0
#> SRR1562741     5  0.0000      1.000  0  0  0 0.000 1.000  0
#> SRR1562742     5  0.0000      1.000  0  0  0 0.000 1.000  0
#> SRR1562743     5  0.0000      1.000  0  0  0 0.000 1.000  0
#> SRR1562744     5  0.0000      1.000  0  0  0 0.000 1.000  0
#> SRR1562745     5  0.0000      1.000  0  0  0 0.000 1.000  0
#> SRR1562746     5  0.0000      1.000  0  0  0 0.000 1.000  0
#> SRR1562747     5  0.0000      1.000  0  0  0 0.000 1.000  0
#> SRR1562748     4  0.0000      0.977  0  0  0 1.000 0.000  0
#> SRR1562749     4  0.0000      0.977  0  0  0 1.000 0.000  0
#> SRR1562750     4  0.0000      0.977  0  0  0 1.000 0.000  0
#> SRR1562751     4  0.0000      0.977  0  0  0 1.000 0.000  0
#> SRR1562752     4  0.0000      0.977  0  0  0 1.000 0.000  0
#> SRR1562753     4  0.0000      0.977  0  0  0 1.000 0.000  0
#> SRR1562754     4  0.0865      0.977  0  0  0 0.964 0.036  0
#> SRR1562755     4  0.0865      0.977  0  0  0 0.964 0.036  0
#> SRR1562756     4  0.0865      0.977  0  0  0 0.964 0.036  0
#> SRR1562757     4  0.0865      0.977  0  0  0 0.964 0.036  0
#> SRR1562758     4  0.0865      0.977  0  0  0 0.964 0.036  0
#> SRR1562759     4  0.0865      0.977  0  0  0 0.964 0.036  0
#> SRR1562792     3  0.0000      1.000  0  0  1 0.000 0.000  0
#> SRR1562793     3  0.0000      1.000  0  0  1 0.000 0.000  0
#> SRR1562794     3  0.0000      1.000  0  0  1 0.000 0.000  0
#> SRR1562795     3  0.0000      1.000  0  0  1 0.000 0.000  0
#> SRR1562796     3  0.0000      1.000  0  0  1 0.000 0.000  0
#> SRR1562797     3  0.0000      1.000  0  0  1 0.000 0.000  0
#> SRR1562798     3  0.0000      1.000  0  0  1 0.000 0.000  0
#> SRR1562799     3  0.0000      1.000  0  0  1 0.000 0.000  0
#> SRR1562800     6  0.0000      1.000  0  0  0 0.000 0.000  1
#> SRR1562801     6  0.0000      1.000  0  0  0 0.000 0.000  1
#> SRR1562802     6  0.0000      1.000  0  0  0 0.000 0.000  1
#> SRR1562803     6  0.0000      1.000  0  0  0 0.000 0.000  1
#> SRR1562804     6  0.0000      1.000  0  0  0 0.000 0.000  1
#> SRR1562805     6  0.0000      1.000  0  0  0 0.000 0.000  1
#> SRR1562806     1  0.0000      1.000  1  0  0 0.000 0.000  0
#> SRR1562807     1  0.0000      1.000  1  0  0 0.000 0.000  0
#> SRR1562808     1  0.0000      1.000  1  0  0 0.000 0.000  0
#> SRR1562809     1  0.0000      1.000  1  0  0 0.000 0.000  0
#> SRR1562810     1  0.0000      1.000  1  0  0 0.000 0.000  0
#> SRR1562811     1  0.0000      1.000  1  0  0 0.000 0.000  0
#> SRR1562812     1  0.0000      1.000  1  0  0 0.000 0.000  0
#> SRR1562813     1  0.0000      1.000  1  0  0 0.000 0.000  0

Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.

consensus_heatmap(res, k = 2)

plot of chunk tab-ATC-hclust-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-ATC-hclust-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-ATC-hclust-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-ATC-hclust-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-ATC-hclust-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-ATC-hclust-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-ATC-hclust-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-ATC-hclust-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-ATC-hclust-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-ATC-hclust-membership-heatmap-5

As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

plot of chunk tab-ATC-hclust-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-ATC-hclust-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-ATC-hclust-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-ATC-hclust-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-ATC-hclust-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-ATC-hclust-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-ATC-hclust-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-ATC-hclust-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-ATC-hclust-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-ATC-hclust-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-hclust-signature_compare

get_signature() returns a data frame invisibly. TO get the list of signatures, the function call should be assigned to a variable explicitly. In following code, if plot argument is set to FALSE, no heatmap is plotted while only the differential analysis is performed.

# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)

An example of the output of tb is:

#>   which_row         fdr    mean_1    mean_2 scaled_mean_1 scaled_mean_2 km
#> 1        38 0.042760348  8.373488  9.131774    -0.5533452     0.5164555  1
#> 2        40 0.018707592  7.106213  8.469186    -0.6173731     0.5762149  1
#> 3        55 0.019134737 10.221463 11.207825    -0.6159697     0.5749050  1
#> 4        59 0.006059896  5.921854  7.869574    -0.6899429     0.6439467  1
#> 5        60 0.018055526  8.928898 10.211722    -0.6204761     0.5791110  1
#> 6        98 0.009384629 15.714769 14.887706     0.6635654    -0.6193277  2
...

The columns in tb are:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. km: Row groups if k-means clustering is applied to rows.

UMAP plot which shows how samples are separated.

dimension_reduction(res, k = 2, method = "UMAP")

plot of chunk tab-ATC-hclust-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-ATC-hclust-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-ATC-hclust-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-ATC-hclust-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-ATC-hclust-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-hclust-collect-classes

If matrix rows can be associated to genes, consider to use functional_enrichment(res, ...) to perform function enrichment for the signature genes. See this vignette for more detailed explanations.


ATC:kmeans**

The object with results only for a single top-value method and a single partition method can be extracted as:

res = res_list["ATC", "kmeans"]
# you can also extract it by
# res = res_list["ATC:kmeans"]

A summary of res and all the functions that can be applied to it:

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 15301 rows and 63 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#>   Subgroups are detected by 'kmeans' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

collect_plots() function collects all the plots made from res for all k (number of partitions) into one single page to provide an easy and fast comparison between different k.

collect_plots(res)

plot of chunk ATC-kmeans-collect-plots

The plots are:

All the plots in panels can be made by individual functions and they are plotted later in this section.

select_partition_number() produces several plots showing different statistics for choosing “optimized” k. There are following statistics:

The detailed explanations of these statistics can be found in the cola vignette.

Generally speaking, lower PAC score, higher mean silhouette score or higher concordance corresponds to better partition. Rand index and Jaccard index measure how similar the current partition is compared to partition with k-1. If they are too similar, we won't accept k is better than k-1.

select_partition_number(res)

plot of chunk ATC-kmeans-select-partition-number

The numeric values for all these statistics can be obtained by get_stats().

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4624 0.538   0.538
#> 3 3 0.623           0.751       0.765         0.3033 0.822   0.669
#> 4 4 0.589           0.652       0.718         0.1194 1.000   1.000
#> 5 5 0.620           0.658       0.681         0.1039 0.872   0.644
#> 6 6 0.611           0.741       0.702         0.0448 0.929   0.718

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
#> SRR1562718     2       0          1  0  1
#> SRR1562719     2       0          1  0  1
#> SRR1562720     2       0          1  0  1
#> SRR1562721     2       0          1  0  1
#> SRR1562723     2       0          1  0  1
#> SRR1562724     2       0          1  0  1
#> SRR1562725     2       0          1  0  1
#> SRR1562726     2       0          1  0  1
#> SRR1562727     2       0          1  0  1
#> SRR1562728     2       0          1  0  1
#> SRR1562729     2       0          1  0  1
#> SRR1562730     2       0          1  0  1
#> SRR1562731     2       0          1  0  1
#> SRR1562732     2       0          1  0  1
#> SRR1562733     2       0          1  0  1
#> SRR1562734     2       0          1  0  1
#> SRR1562735     2       0          1  0  1
#> SRR1562736     2       0          1  0  1
#> SRR1562737     2       0          1  0  1
#> SRR1562738     2       0          1  0  1
#> SRR1562739     2       0          1  0  1
#> SRR1562740     2       0          1  0  1
#> SRR1562741     2       0          1  0  1
#> SRR1562742     2       0          1  0  1
#> SRR1562743     2       0          1  0  1
#> SRR1562744     2       0          1  0  1
#> SRR1562745     2       0          1  0  1
#> SRR1562746     2       0          1  0  1
#> SRR1562747     2       0          1  0  1
#> SRR1562748     2       0          1  0  1
#> SRR1562749     2       0          1  0  1
#> SRR1562750     2       0          1  0  1
#> SRR1562751     2       0          1  0  1
#> SRR1562752     2       0          1  0  1
#> SRR1562753     2       0          1  0  1
#> SRR1562754     2       0          1  0  1
#> SRR1562755     2       0          1  0  1
#> SRR1562756     2       0          1  0  1
#> SRR1562757     2       0          1  0  1
#> SRR1562758     2       0          1  0  1
#> SRR1562759     2       0          1  0  1
#> SRR1562792     1       0          1  1  0
#> SRR1562793     1       0          1  1  0
#> SRR1562794     1       0          1  1  0
#> SRR1562795     1       0          1  1  0
#> SRR1562796     1       0          1  1  0
#> SRR1562797     1       0          1  1  0
#> SRR1562798     1       0          1  1  0
#> SRR1562799     1       0          1  1  0
#> SRR1562800     1       0          1  1  0
#> SRR1562801     1       0          1  1  0
#> SRR1562802     1       0          1  1  0
#> SRR1562803     1       0          1  1  0
#> SRR1562804     1       0          1  1  0
#> SRR1562805     1       0          1  1  0
#> SRR1562806     1       0          1  1  0
#> SRR1562807     1       0          1  1  0
#> SRR1562808     1       0          1  1  0
#> SRR1562809     1       0          1  1  0
#> SRR1562810     1       0          1  1  0
#> SRR1562811     1       0          1  1  0
#> SRR1562812     1       0          1  1  0
#> SRR1562813     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1562718     2  0.0000      0.724 0.000 1.000 0.000
#> SRR1562719     2  0.0000      0.724 0.000 1.000 0.000
#> SRR1562720     2  0.0000      0.724 0.000 1.000 0.000
#> SRR1562721     2  0.0000      0.724 0.000 1.000 0.000
#> SRR1562723     2  0.0000      0.724 0.000 1.000 0.000
#> SRR1562724     2  0.0237      0.724 0.000 0.996 0.004
#> SRR1562725     2  0.0237      0.724 0.000 0.996 0.004
#> SRR1562726     2  0.0237      0.724 0.000 0.996 0.004
#> SRR1562727     2  0.0237      0.724 0.000 0.996 0.004
#> SRR1562728     2  0.0237      0.724 0.000 0.996 0.004
#> SRR1562729     2  0.0237      0.724 0.000 0.996 0.004
#> SRR1562730     2  0.2625      0.673 0.000 0.916 0.084
#> SRR1562731     2  0.2625      0.673 0.000 0.916 0.084
#> SRR1562732     2  0.2625      0.673 0.000 0.916 0.084
#> SRR1562733     2  0.2625      0.673 0.000 0.916 0.084
#> SRR1562734     2  0.2625      0.673 0.000 0.916 0.084
#> SRR1562735     2  0.2625      0.673 0.000 0.916 0.084
#> SRR1562736     2  0.5138      0.412 0.000 0.748 0.252
#> SRR1562737     2  0.5138      0.412 0.000 0.748 0.252
#> SRR1562738     2  0.5138      0.412 0.000 0.748 0.252
#> SRR1562739     2  0.5138      0.412 0.000 0.748 0.252
#> SRR1562740     2  0.5138      0.412 0.000 0.748 0.252
#> SRR1562741     2  0.5138      0.412 0.000 0.748 0.252
#> SRR1562742     2  0.5650      0.424 0.000 0.688 0.312
#> SRR1562743     2  0.5650      0.424 0.000 0.688 0.312
#> SRR1562744     2  0.5650      0.424 0.000 0.688 0.312
#> SRR1562745     2  0.5650      0.424 0.000 0.688 0.312
#> SRR1562746     2  0.5650      0.424 0.000 0.688 0.312
#> SRR1562747     2  0.5650      0.424 0.000 0.688 0.312
#> SRR1562748     3  0.6204      0.883 0.000 0.424 0.576
#> SRR1562749     3  0.6204      0.883 0.000 0.424 0.576
#> SRR1562750     3  0.6204      0.883 0.000 0.424 0.576
#> SRR1562751     3  0.6204      0.883 0.000 0.424 0.576
#> SRR1562752     3  0.6204      0.883 0.000 0.424 0.576
#> SRR1562753     3  0.6204      0.883 0.000 0.424 0.576
#> SRR1562754     3  0.6305      0.870 0.000 0.484 0.516
#> SRR1562755     3  0.6305      0.870 0.000 0.484 0.516
#> SRR1562756     3  0.6305      0.870 0.000 0.484 0.516
#> SRR1562757     3  0.6305      0.870 0.000 0.484 0.516
#> SRR1562758     3  0.6305      0.870 0.000 0.484 0.516
#> SRR1562759     3  0.6305      0.870 0.000 0.484 0.516
#> SRR1562792     1  0.0000      0.857 1.000 0.000 0.000
#> SRR1562793     1  0.0000      0.857 1.000 0.000 0.000
#> SRR1562794     1  0.0000      0.857 1.000 0.000 0.000
#> SRR1562795     1  0.0000      0.857 1.000 0.000 0.000
#> SRR1562796     1  0.0000      0.857 1.000 0.000 0.000
#> SRR1562797     1  0.0000      0.857 1.000 0.000 0.000
#> SRR1562798     1  0.0000      0.857 1.000 0.000 0.000
#> SRR1562799     1  0.0000      0.857 1.000 0.000 0.000
#> SRR1562800     1  0.5291      0.921 0.732 0.000 0.268
#> SRR1562801     1  0.5291      0.921 0.732 0.000 0.268
#> SRR1562802     1  0.5291      0.921 0.732 0.000 0.268
#> SRR1562803     1  0.5291      0.921 0.732 0.000 0.268
#> SRR1562804     1  0.5291      0.921 0.732 0.000 0.268
#> SRR1562805     1  0.5291      0.921 0.732 0.000 0.268
#> SRR1562806     1  0.5291      0.921 0.732 0.000 0.268
#> SRR1562807     1  0.5291      0.921 0.732 0.000 0.268
#> SRR1562808     1  0.5291      0.921 0.732 0.000 0.268
#> SRR1562809     1  0.5291      0.921 0.732 0.000 0.268
#> SRR1562810     1  0.5291      0.921 0.732 0.000 0.268
#> SRR1562811     1  0.5291      0.921 0.732 0.000 0.268
#> SRR1562812     1  0.5291      0.921 0.732 0.000 0.268
#> SRR1562813     1  0.5291      0.921 0.732 0.000 0.268

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2 p3    p4
#> SRR1562718     2  0.0336      0.622 0.000 0.992 NA 0.000
#> SRR1562719     2  0.0336      0.622 0.000 0.992 NA 0.000
#> SRR1562720     2  0.0336      0.622 0.000 0.992 NA 0.000
#> SRR1562721     2  0.0336      0.622 0.000 0.992 NA 0.000
#> SRR1562723     2  0.0336      0.622 0.000 0.992 NA 0.000
#> SRR1562724     2  0.1389      0.616 0.000 0.952 NA 0.000
#> SRR1562725     2  0.1389      0.616 0.000 0.952 NA 0.000
#> SRR1562726     2  0.1389      0.616 0.000 0.952 NA 0.000
#> SRR1562727     2  0.1389      0.616 0.000 0.952 NA 0.000
#> SRR1562728     2  0.1389      0.616 0.000 0.952 NA 0.000
#> SRR1562729     2  0.1389      0.616 0.000 0.952 NA 0.000
#> SRR1562730     2  0.5109      0.532 0.000 0.744 NA 0.060
#> SRR1562731     2  0.5109      0.532 0.000 0.744 NA 0.060
#> SRR1562732     2  0.5172      0.532 0.000 0.744 NA 0.068
#> SRR1562733     2  0.5172      0.532 0.000 0.744 NA 0.068
#> SRR1562734     2  0.5109      0.532 0.000 0.744 NA 0.060
#> SRR1562735     2  0.5109      0.532 0.000 0.744 NA 0.060
#> SRR1562736     2  0.6300      0.294 0.000 0.608 NA 0.308
#> SRR1562737     2  0.6300      0.294 0.000 0.608 NA 0.308
#> SRR1562738     2  0.6300      0.294 0.000 0.608 NA 0.308
#> SRR1562739     2  0.6300      0.294 0.000 0.608 NA 0.308
#> SRR1562740     2  0.6300      0.294 0.000 0.608 NA 0.308
#> SRR1562741     2  0.6300      0.294 0.000 0.608 NA 0.308
#> SRR1562742     2  0.7193      0.286 0.000 0.508 NA 0.340
#> SRR1562743     2  0.7193      0.286 0.000 0.508 NA 0.340
#> SRR1562744     2  0.7193      0.286 0.000 0.508 NA 0.340
#> SRR1562745     2  0.7193      0.286 0.000 0.508 NA 0.340
#> SRR1562746     2  0.7193      0.286 0.000 0.508 NA 0.340
#> SRR1562747     2  0.7193      0.286 0.000 0.508 NA 0.340
#> SRR1562748     4  0.5522      0.867 0.000 0.288 NA 0.668
#> SRR1562749     4  0.5359      0.867 0.000 0.288 NA 0.676
#> SRR1562750     4  0.5442      0.867 0.000 0.288 NA 0.672
#> SRR1562751     4  0.5522      0.867 0.000 0.288 NA 0.668
#> SRR1562752     4  0.5359      0.867 0.000 0.288 NA 0.676
#> SRR1562753     4  0.5359      0.867 0.000 0.288 NA 0.676
#> SRR1562754     4  0.6071      0.859 0.000 0.324 NA 0.612
#> SRR1562755     4  0.6071      0.859 0.000 0.324 NA 0.612
#> SRR1562756     4  0.6071      0.859 0.000 0.324 NA 0.612
#> SRR1562757     4  0.6071      0.859 0.000 0.324 NA 0.612
#> SRR1562758     4  0.6071      0.859 0.000 0.324 NA 0.612
#> SRR1562759     4  0.6071      0.859 0.000 0.324 NA 0.612
#> SRR1562792     1  0.6071      0.711 0.504 0.000 NA 0.044
#> SRR1562793     1  0.6071      0.711 0.504 0.000 NA 0.044
#> SRR1562794     1  0.6071      0.711 0.504 0.000 NA 0.044
#> SRR1562795     1  0.6071      0.711 0.504 0.000 NA 0.044
#> SRR1562796     1  0.5000      0.711 0.504 0.000 NA 0.000
#> SRR1562797     1  0.5000      0.711 0.504 0.000 NA 0.000
#> SRR1562798     1  0.5000      0.711 0.504 0.000 NA 0.000
#> SRR1562799     1  0.5000      0.711 0.504 0.000 NA 0.000
#> SRR1562800     1  0.2216      0.825 0.908 0.000 NA 0.092
#> SRR1562801     1  0.2216      0.825 0.908 0.000 NA 0.092
#> SRR1562802     1  0.2216      0.825 0.908 0.000 NA 0.092
#> SRR1562803     1  0.2216      0.825 0.908 0.000 NA 0.092
#> SRR1562804     1  0.2216      0.825 0.908 0.000 NA 0.092
#> SRR1562805     1  0.2216      0.825 0.908 0.000 NA 0.092
#> SRR1562806     1  0.0000      0.829 1.000 0.000 NA 0.000
#> SRR1562807     1  0.0000      0.829 1.000 0.000 NA 0.000
#> SRR1562808     1  0.0000      0.829 1.000 0.000 NA 0.000
#> SRR1562809     1  0.0000      0.829 1.000 0.000 NA 0.000
#> SRR1562810     1  0.0000      0.829 1.000 0.000 NA 0.000
#> SRR1562811     1  0.0000      0.829 1.000 0.000 NA 0.000
#> SRR1562812     1  0.0000      0.829 1.000 0.000 NA 0.000
#> SRR1562813     1  0.0000      0.829 1.000 0.000 NA 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
#> SRR1562718     2  0.2688      0.568 0.000 0.896 0.012 0.036 0.056
#> SRR1562719     2  0.2688      0.568 0.000 0.896 0.012 0.036 0.056
#> SRR1562720     2  0.2688      0.568 0.000 0.896 0.012 0.036 0.056
#> SRR1562721     2  0.2688      0.568 0.000 0.896 0.012 0.036 0.056
#> SRR1562723     2  0.2688      0.568 0.000 0.896 0.012 0.036 0.056
#> SRR1562724     2  0.3163      0.577 0.000 0.876 0.052 0.036 0.036
#> SRR1562725     2  0.3163      0.577 0.000 0.876 0.052 0.036 0.036
#> SRR1562726     2  0.3163      0.577 0.000 0.876 0.052 0.036 0.036
#> SRR1562727     2  0.3163      0.577 0.000 0.876 0.052 0.036 0.036
#> SRR1562728     2  0.3163      0.577 0.000 0.876 0.052 0.036 0.036
#> SRR1562729     2  0.3163      0.577 0.000 0.876 0.052 0.036 0.036
#> SRR1562730     2  0.5322      0.495 0.000 0.684 0.184 0.004 0.128
#> SRR1562731     2  0.5322      0.495 0.000 0.684 0.184 0.004 0.128
#> SRR1562732     2  0.5377      0.494 0.000 0.680 0.176 0.004 0.140
#> SRR1562733     2  0.5377      0.494 0.000 0.680 0.176 0.004 0.140
#> SRR1562734     2  0.5322      0.495 0.000 0.684 0.184 0.004 0.128
#> SRR1562735     2  0.5322      0.495 0.000 0.684 0.184 0.004 0.128
#> SRR1562736     2  0.7464     -0.512 0.000 0.388 0.044 0.356 0.212
#> SRR1562737     2  0.7464     -0.512 0.000 0.388 0.044 0.356 0.212
#> SRR1562738     2  0.7464     -0.512 0.000 0.388 0.044 0.356 0.212
#> SRR1562739     2  0.7464     -0.512 0.000 0.388 0.044 0.356 0.212
#> SRR1562740     2  0.7464     -0.512 0.000 0.388 0.044 0.356 0.212
#> SRR1562741     2  0.7464     -0.512 0.000 0.388 0.044 0.356 0.212
#> SRR1562742     5  0.6687      0.999 0.000 0.248 0.000 0.332 0.420
#> SRR1562743     5  0.6687      0.999 0.000 0.248 0.000 0.332 0.420
#> SRR1562744     5  0.6687      0.999 0.000 0.248 0.000 0.332 0.420
#> SRR1562745     5  0.6692      0.996 0.000 0.248 0.000 0.336 0.416
#> SRR1562746     5  0.6687      0.999 0.000 0.248 0.000 0.332 0.420
#> SRR1562747     5  0.6687      0.999 0.000 0.248 0.000 0.332 0.420
#> SRR1562748     4  0.5593      0.789 0.000 0.060 0.064 0.700 0.176
#> SRR1562749     4  0.5567      0.789 0.000 0.060 0.060 0.700 0.180
#> SRR1562750     4  0.5627      0.789 0.000 0.060 0.064 0.696 0.180
#> SRR1562751     4  0.5593      0.789 0.000 0.060 0.064 0.700 0.176
#> SRR1562752     4  0.5652      0.789 0.000 0.060 0.068 0.696 0.176
#> SRR1562753     4  0.5652      0.789 0.000 0.060 0.068 0.696 0.176
#> SRR1562754     4  0.2112      0.756 0.000 0.084 0.004 0.908 0.004
#> SRR1562755     4  0.2112      0.756 0.000 0.084 0.004 0.908 0.004
#> SRR1562756     4  0.2237      0.756 0.000 0.084 0.008 0.904 0.004
#> SRR1562757     4  0.2293      0.756 0.000 0.084 0.016 0.900 0.000
#> SRR1562758     4  0.1952      0.756 0.000 0.084 0.004 0.912 0.000
#> SRR1562759     4  0.1952      0.756 0.000 0.084 0.004 0.912 0.000
#> SRR1562792     3  0.4288      0.958 0.384 0.000 0.612 0.004 0.000
#> SRR1562793     3  0.4288      0.958 0.384 0.000 0.612 0.000 0.004
#> SRR1562794     3  0.4288      0.958 0.384 0.000 0.612 0.000 0.004
#> SRR1562795     3  0.4288      0.958 0.384 0.000 0.612 0.000 0.004
#> SRR1562796     3  0.5687      0.958 0.384 0.000 0.552 0.028 0.036
#> SRR1562797     3  0.5687      0.958 0.384 0.000 0.552 0.028 0.036
#> SRR1562798     3  0.5678      0.958 0.384 0.000 0.552 0.024 0.040
#> SRR1562799     3  0.5678      0.958 0.384 0.000 0.552 0.024 0.040
#> SRR1562800     1  0.2690      0.858 0.844 0.000 0.000 0.000 0.156
#> SRR1562801     1  0.2690      0.858 0.844 0.000 0.000 0.000 0.156
#> SRR1562802     1  0.2690      0.858 0.844 0.000 0.000 0.000 0.156
#> SRR1562803     1  0.2690      0.858 0.844 0.000 0.000 0.000 0.156
#> SRR1562804     1  0.2690      0.858 0.844 0.000 0.000 0.000 0.156
#> SRR1562805     1  0.2690      0.858 0.844 0.000 0.000 0.000 0.156
#> SRR1562806     1  0.0162      0.895 0.996 0.000 0.000 0.000 0.004
#> SRR1562807     1  0.0162      0.895 0.996 0.000 0.000 0.000 0.004
#> SRR1562808     1  0.0162      0.895 0.996 0.000 0.000 0.000 0.004
#> SRR1562809     1  0.0162      0.895 0.996 0.000 0.000 0.000 0.004
#> SRR1562810     1  0.0162      0.895 0.996 0.000 0.000 0.004 0.000
#> SRR1562811     1  0.0162      0.895 0.996 0.000 0.000 0.004 0.000
#> SRR1562812     1  0.0162      0.895 0.996 0.000 0.000 0.004 0.000
#> SRR1562813     1  0.0162      0.895 0.996 0.000 0.000 0.004 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5 p6
#> SRR1562718     2  0.3672      0.683 0.000 0.832 0.060 0.040 0.060 NA
#> SRR1562719     2  0.3672      0.683 0.000 0.832 0.060 0.040 0.060 NA
#> SRR1562720     2  0.3672      0.683 0.000 0.832 0.060 0.040 0.060 NA
#> SRR1562721     2  0.3672      0.683 0.000 0.832 0.060 0.040 0.060 NA
#> SRR1562723     2  0.3672      0.683 0.000 0.832 0.060 0.040 0.060 NA
#> SRR1562724     2  0.3201      0.688 0.000 0.864 0.048 0.040 0.012 NA
#> SRR1562725     2  0.3201      0.688 0.000 0.864 0.048 0.040 0.012 NA
#> SRR1562726     2  0.3165      0.688 0.000 0.864 0.052 0.040 0.008 NA
#> SRR1562727     2  0.3165      0.688 0.000 0.864 0.052 0.040 0.008 NA
#> SRR1562728     2  0.3201      0.688 0.000 0.864 0.048 0.040 0.012 NA
#> SRR1562729     2  0.3165      0.688 0.000 0.864 0.052 0.040 0.008 NA
#> SRR1562730     2  0.5444      0.601 0.000 0.580 0.024 0.004 0.068 NA
#> SRR1562731     2  0.5444      0.601 0.000 0.580 0.024 0.004 0.068 NA
#> SRR1562732     2  0.5464      0.601 0.000 0.576 0.020 0.004 0.076 NA
#> SRR1562733     2  0.5314      0.601 0.000 0.576 0.008 0.004 0.084 NA
#> SRR1562734     2  0.5003      0.602 0.000 0.580 0.004 0.004 0.060 NA
#> SRR1562735     2  0.4881      0.602 0.000 0.580 0.000 0.004 0.060 NA
#> SRR1562736     5  0.7833      0.708 0.000 0.300 0.044 0.260 0.324 NA
#> SRR1562737     5  0.7833      0.708 0.000 0.300 0.044 0.260 0.324 NA
#> SRR1562738     5  0.7833      0.708 0.000 0.300 0.044 0.260 0.324 NA
#> SRR1562739     5  0.7833      0.708 0.000 0.300 0.044 0.260 0.324 NA
#> SRR1562740     5  0.7833      0.708 0.000 0.300 0.044 0.260 0.324 NA
#> SRR1562741     5  0.7833      0.708 0.000 0.300 0.044 0.260 0.324 NA
#> SRR1562742     5  0.4680      0.737 0.000 0.184 0.000 0.132 0.684 NA
#> SRR1562743     5  0.4923      0.737 0.000 0.184 0.000 0.132 0.676 NA
#> SRR1562744     5  0.4923      0.737 0.000 0.184 0.000 0.132 0.676 NA
#> SRR1562745     5  0.4817      0.736 0.000 0.184 0.004 0.132 0.680 NA
#> SRR1562746     5  0.4923      0.737 0.000 0.184 0.000 0.132 0.676 NA
#> SRR1562747     5  0.4923      0.736 0.000 0.184 0.008 0.132 0.676 NA
#> SRR1562748     4  0.1820      0.764 0.000 0.044 0.012 0.928 0.000 NA
#> SRR1562749     4  0.1265      0.764 0.000 0.044 0.000 0.948 0.000 NA
#> SRR1562750     4  0.1921      0.764 0.000 0.044 0.024 0.924 0.004 NA
#> SRR1562751     4  0.1908      0.764 0.000 0.044 0.020 0.924 0.000 NA
#> SRR1562752     4  0.1367      0.764 0.000 0.044 0.000 0.944 0.000 NA
#> SRR1562753     4  0.1870      0.764 0.000 0.044 0.012 0.928 0.004 NA
#> SRR1562754     4  0.6390      0.738 0.000 0.064 0.036 0.616 0.164 NA
#> SRR1562755     4  0.6390      0.738 0.000 0.064 0.036 0.616 0.164 NA
#> SRR1562756     4  0.6416      0.738 0.000 0.064 0.040 0.616 0.164 NA
#> SRR1562757     4  0.6347      0.738 0.000 0.064 0.032 0.616 0.172 NA
#> SRR1562758     4  0.6374      0.738 0.000 0.064 0.036 0.616 0.172 NA
#> SRR1562759     4  0.6374      0.738 0.000 0.064 0.036 0.616 0.172 NA
#> SRR1562792     3  0.5683      0.927 0.280 0.000 0.600 0.012 0.080 NA
#> SRR1562793     3  0.5683      0.927 0.280 0.000 0.600 0.012 0.080 NA
#> SRR1562794     3  0.5657      0.927 0.280 0.000 0.600 0.012 0.084 NA
#> SRR1562795     3  0.5657      0.927 0.280 0.000 0.600 0.012 0.084 NA
#> SRR1562796     3  0.3555      0.927 0.280 0.000 0.712 0.000 0.008 NA
#> SRR1562797     3  0.3586      0.927 0.280 0.000 0.712 0.000 0.004 NA
#> SRR1562798     3  0.3586      0.927 0.280 0.000 0.712 0.000 0.004 NA
#> SRR1562799     3  0.3555      0.927 0.280 0.000 0.712 0.000 0.000 NA
#> SRR1562800     1  0.3769      0.705 0.640 0.000 0.000 0.000 0.004 NA
#> SRR1562801     1  0.3769      0.705 0.640 0.000 0.000 0.000 0.004 NA
#> SRR1562802     1  0.3647      0.705 0.640 0.000 0.000 0.000 0.000 NA
#> SRR1562803     1  0.3647      0.705 0.640 0.000 0.000 0.000 0.000 NA
#> SRR1562804     1  0.4246      0.703 0.636 0.000 0.000 0.012 0.012 NA
#> SRR1562805     1  0.4246      0.703 0.636 0.000 0.000 0.012 0.012 NA
#> SRR1562806     1  0.0146      0.779 0.996 0.000 0.000 0.000 0.000 NA
#> SRR1562807     1  0.0146      0.779 0.996 0.000 0.000 0.000 0.000 NA
#> SRR1562808     1  0.0146      0.779 0.996 0.000 0.000 0.000 0.000 NA
#> SRR1562809     1  0.0146      0.779 0.996 0.000 0.000 0.000 0.000 NA
#> SRR1562810     1  0.0993      0.779 0.964 0.000 0.000 0.012 0.024 NA
#> SRR1562811     1  0.0993      0.779 0.964 0.000 0.000 0.012 0.024 NA
#> SRR1562812     1  0.0993      0.779 0.964 0.000 0.000 0.012 0.024 NA
#> SRR1562813     1  0.0993      0.779 0.964 0.000 0.000 0.012 0.024 NA

Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.

consensus_heatmap(res, k = 2)

plot of chunk tab-ATC-kmeans-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-ATC-kmeans-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-ATC-kmeans-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-ATC-kmeans-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-ATC-kmeans-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-ATC-kmeans-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-ATC-kmeans-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-ATC-kmeans-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-ATC-kmeans-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-ATC-kmeans-membership-heatmap-5

As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

plot of chunk tab-ATC-kmeans-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-ATC-kmeans-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-ATC-kmeans-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-ATC-kmeans-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-ATC-kmeans-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-ATC-kmeans-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-ATC-kmeans-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-ATC-kmeans-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-ATC-kmeans-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-ATC-kmeans-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-kmeans-signature_compare

get_signature() returns a data frame invisibly. TO get the list of signatures, the function call should be assigned to a variable explicitly. In following code, if plot argument is set to FALSE, no heatmap is plotted while only the differential analysis is performed.

# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)

An example of the output of tb is:

#>   which_row         fdr    mean_1    mean_2 scaled_mean_1 scaled_mean_2 km
#> 1        38 0.042760348  8.373488  9.131774    -0.5533452     0.5164555  1
#> 2        40 0.018707592  7.106213  8.469186    -0.6173731     0.5762149  1
#> 3        55 0.019134737 10.221463 11.207825    -0.6159697     0.5749050  1
#> 4        59 0.006059896  5.921854  7.869574    -0.6899429     0.6439467  1
#> 5        60 0.018055526  8.928898 10.211722    -0.6204761     0.5791110  1
#> 6        98 0.009384629 15.714769 14.887706     0.6635654    -0.6193277  2
...

The columns in tb are:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. km: Row groups if k-means clustering is applied to rows.

UMAP plot which shows how samples are separated.

dimension_reduction(res, k = 2, method = "UMAP")

plot of chunk tab-ATC-kmeans-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-ATC-kmeans-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-ATC-kmeans-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-ATC-kmeans-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-ATC-kmeans-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-kmeans-collect-classes

If matrix rows can be associated to genes, consider to use functional_enrichment(res, ...) to perform function enrichment for the signature genes. See this vignette for more detailed explanations.


ATC:skmeans**

The object with results only for a single top-value method and a single partition method can be extracted as:

res = res_list["ATC", "skmeans"]
# you can also extract it by
# res = res_list["ATC:skmeans"]

A summary of res and all the functions that can be applied to it:

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 15301 rows and 63 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#>   Subgroups are detected by 'skmeans' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

collect_plots() function collects all the plots made from res for all k (number of partitions) into one single page to provide an easy and fast comparison between different k.

collect_plots(res)

plot of chunk ATC-skmeans-collect-plots

The plots are:

All the plots in panels can be made by individual functions and they are plotted later in this section.

select_partition_number() produces several plots showing different statistics for choosing “optimized” k. There are following statistics:

The detailed explanations of these statistics can be found in the cola vignette.

Generally speaking, lower PAC score, higher mean silhouette score or higher concordance corresponds to better partition. Rand index and Jaccard index measure how similar the current partition is compared to partition with k-1. If they are too similar, we won't accept k is better than k-1.

select_partition_number(res)

plot of chunk ATC-skmeans-select-partition-number

The numeric values for all these statistics can be obtained by get_stats().

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4624 0.538   0.538
#> 3 3 0.764           0.936       0.921         0.1867 0.943   0.893
#> 4 4 0.822           0.895       0.930         0.2772 0.822   0.629
#> 5 5 0.843           0.861       0.879         0.1036 0.896   0.655
#> 6 6 0.843           0.855       0.742         0.0542 0.923   0.655

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
#> SRR1562718     2       0          1  0  1
#> SRR1562719     2       0          1  0  1
#> SRR1562720     2       0          1  0  1
#> SRR1562721     2       0          1  0  1
#> SRR1562723     2       0          1  0  1
#> SRR1562724     2       0          1  0  1
#> SRR1562725     2       0          1  0  1
#> SRR1562726     2       0          1  0  1
#> SRR1562727     2       0          1  0  1
#> SRR1562728     2       0          1  0  1
#> SRR1562729     2       0          1  0  1
#> SRR1562730     2       0          1  0  1
#> SRR1562731     2       0          1  0  1
#> SRR1562732     2       0          1  0  1
#> SRR1562733     2       0          1  0  1
#> SRR1562734     2       0          1  0  1
#> SRR1562735     2       0          1  0  1
#> SRR1562736     2       0          1  0  1
#> SRR1562737     2       0          1  0  1
#> SRR1562738     2       0          1  0  1
#> SRR1562739     2       0          1  0  1
#> SRR1562740     2       0          1  0  1
#> SRR1562741     2       0          1  0  1
#> SRR1562742     2       0          1  0  1
#> SRR1562743     2       0          1  0  1
#> SRR1562744     2       0          1  0  1
#> SRR1562745     2       0          1  0  1
#> SRR1562746     2       0          1  0  1
#> SRR1562747     2       0          1  0  1
#> SRR1562748     2       0          1  0  1
#> SRR1562749     2       0          1  0  1
#> SRR1562750     2       0          1  0  1
#> SRR1562751     2       0          1  0  1
#> SRR1562752     2       0          1  0  1
#> SRR1562753     2       0          1  0  1
#> SRR1562754     2       0          1  0  1
#> SRR1562755     2       0          1  0  1
#> SRR1562756     2       0          1  0  1
#> SRR1562757     2       0          1  0  1
#> SRR1562758     2       0          1  0  1
#> SRR1562759     2       0          1  0  1
#> SRR1562792     1       0          1  1  0
#> SRR1562793     1       0          1  1  0
#> SRR1562794     1       0          1  1  0
#> SRR1562795     1       0          1  1  0
#> SRR1562796     1       0          1  1  0
#> SRR1562797     1       0          1  1  0
#> SRR1562798     1       0          1  1  0
#> SRR1562799     1       0          1  1  0
#> SRR1562800     1       0          1  1  0
#> SRR1562801     1       0          1  1  0
#> SRR1562802     1       0          1  1  0
#> SRR1562803     1       0          1  1  0
#> SRR1562804     1       0          1  1  0
#> SRR1562805     1       0          1  1  0
#> SRR1562806     1       0          1  1  0
#> SRR1562807     1       0          1  1  0
#> SRR1562808     1       0          1  1  0
#> SRR1562809     1       0          1  1  0
#> SRR1562810     1       0          1  1  0
#> SRR1562811     1       0          1  1  0
#> SRR1562812     1       0          1  1  0
#> SRR1562813     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1562718     2   0.103      0.929 0.024 0.976 0.000
#> SRR1562719     2   0.103      0.929 0.024 0.976 0.000
#> SRR1562720     2   0.103      0.929 0.024 0.976 0.000
#> SRR1562721     2   0.103      0.929 0.024 0.976 0.000
#> SRR1562723     2   0.103      0.929 0.024 0.976 0.000
#> SRR1562724     2   0.103      0.929 0.024 0.976 0.000
#> SRR1562725     2   0.103      0.929 0.024 0.976 0.000
#> SRR1562726     2   0.103      0.929 0.024 0.976 0.000
#> SRR1562727     2   0.103      0.929 0.024 0.976 0.000
#> SRR1562728     2   0.103      0.929 0.024 0.976 0.000
#> SRR1562729     2   0.103      0.929 0.024 0.976 0.000
#> SRR1562730     2   0.103      0.929 0.024 0.976 0.000
#> SRR1562731     2   0.103      0.929 0.024 0.976 0.000
#> SRR1562732     2   0.103      0.929 0.024 0.976 0.000
#> SRR1562733     2   0.103      0.929 0.024 0.976 0.000
#> SRR1562734     2   0.103      0.929 0.024 0.976 0.000
#> SRR1562735     2   0.103      0.929 0.024 0.976 0.000
#> SRR1562736     2   0.000      0.929 0.000 1.000 0.000
#> SRR1562737     2   0.000      0.929 0.000 1.000 0.000
#> SRR1562738     2   0.000      0.929 0.000 1.000 0.000
#> SRR1562739     2   0.000      0.929 0.000 1.000 0.000
#> SRR1562740     2   0.000      0.929 0.000 1.000 0.000
#> SRR1562741     2   0.000      0.929 0.000 1.000 0.000
#> SRR1562742     2   0.000      0.929 0.000 1.000 0.000
#> SRR1562743     2   0.000      0.929 0.000 1.000 0.000
#> SRR1562744     2   0.000      0.929 0.000 1.000 0.000
#> SRR1562745     2   0.000      0.929 0.000 1.000 0.000
#> SRR1562746     2   0.000      0.929 0.000 1.000 0.000
#> SRR1562747     2   0.000      0.929 0.000 1.000 0.000
#> SRR1562748     2   0.470      0.836 0.212 0.788 0.000
#> SRR1562749     2   0.470      0.836 0.212 0.788 0.000
#> SRR1562750     2   0.470      0.836 0.212 0.788 0.000
#> SRR1562751     2   0.470      0.836 0.212 0.788 0.000
#> SRR1562752     2   0.470      0.836 0.212 0.788 0.000
#> SRR1562753     2   0.470      0.836 0.212 0.788 0.000
#> SRR1562754     2   0.470      0.836 0.212 0.788 0.000
#> SRR1562755     2   0.470      0.836 0.212 0.788 0.000
#> SRR1562756     2   0.470      0.836 0.212 0.788 0.000
#> SRR1562757     2   0.470      0.836 0.212 0.788 0.000
#> SRR1562758     2   0.470      0.836 0.212 0.788 0.000
#> SRR1562759     2   0.470      0.836 0.212 0.788 0.000
#> SRR1562792     3   0.000      1.000 0.000 0.000 1.000
#> SRR1562793     3   0.000      1.000 0.000 0.000 1.000
#> SRR1562794     3   0.000      1.000 0.000 0.000 1.000
#> SRR1562795     3   0.000      1.000 0.000 0.000 1.000
#> SRR1562796     3   0.000      1.000 0.000 0.000 1.000
#> SRR1562797     3   0.000      1.000 0.000 0.000 1.000
#> SRR1562798     3   0.000      1.000 0.000 0.000 1.000
#> SRR1562799     3   0.000      1.000 0.000 0.000 1.000
#> SRR1562800     1   0.497      1.000 0.764 0.000 0.236
#> SRR1562801     1   0.497      1.000 0.764 0.000 0.236
#> SRR1562802     1   0.497      1.000 0.764 0.000 0.236
#> SRR1562803     1   0.497      1.000 0.764 0.000 0.236
#> SRR1562804     1   0.497      1.000 0.764 0.000 0.236
#> SRR1562805     1   0.497      1.000 0.764 0.000 0.236
#> SRR1562806     1   0.497      1.000 0.764 0.000 0.236
#> SRR1562807     1   0.497      1.000 0.764 0.000 0.236
#> SRR1562808     1   0.497      1.000 0.764 0.000 0.236
#> SRR1562809     1   0.497      1.000 0.764 0.000 0.236
#> SRR1562810     1   0.497      1.000 0.764 0.000 0.236
#> SRR1562811     1   0.497      1.000 0.764 0.000 0.236
#> SRR1562812     1   0.497      1.000 0.764 0.000 0.236
#> SRR1562813     1   0.497      1.000 0.764 0.000 0.236

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1562718     2  0.0469      0.846 0.000 0.988 0.000 0.012
#> SRR1562719     2  0.0469      0.846 0.000 0.988 0.000 0.012
#> SRR1562720     2  0.0469      0.846 0.000 0.988 0.000 0.012
#> SRR1562721     2  0.0469      0.846 0.000 0.988 0.000 0.012
#> SRR1562723     2  0.0469      0.846 0.000 0.988 0.000 0.012
#> SRR1562724     2  0.0469      0.846 0.000 0.988 0.000 0.012
#> SRR1562725     2  0.0469      0.846 0.000 0.988 0.000 0.012
#> SRR1562726     2  0.0469      0.846 0.000 0.988 0.000 0.012
#> SRR1562727     2  0.0469      0.846 0.000 0.988 0.000 0.012
#> SRR1562728     2  0.0469      0.846 0.000 0.988 0.000 0.012
#> SRR1562729     2  0.0469      0.846 0.000 0.988 0.000 0.012
#> SRR1562730     2  0.0188      0.839 0.000 0.996 0.004 0.000
#> SRR1562731     2  0.0188      0.839 0.000 0.996 0.004 0.000
#> SRR1562732     2  0.0188      0.839 0.000 0.996 0.004 0.000
#> SRR1562733     2  0.0188      0.839 0.000 0.996 0.004 0.000
#> SRR1562734     2  0.0188      0.839 0.000 0.996 0.004 0.000
#> SRR1562735     2  0.0188      0.839 0.000 0.996 0.004 0.000
#> SRR1562736     2  0.4673      0.734 0.000 0.700 0.008 0.292
#> SRR1562737     2  0.4673      0.734 0.000 0.700 0.008 0.292
#> SRR1562738     2  0.4673      0.734 0.000 0.700 0.008 0.292
#> SRR1562739     2  0.4673      0.734 0.000 0.700 0.008 0.292
#> SRR1562740     2  0.4673      0.734 0.000 0.700 0.008 0.292
#> SRR1562741     2  0.4673      0.734 0.000 0.700 0.008 0.292
#> SRR1562742     2  0.4697      0.732 0.000 0.696 0.008 0.296
#> SRR1562743     2  0.4697      0.732 0.000 0.696 0.008 0.296
#> SRR1562744     2  0.4697      0.732 0.000 0.696 0.008 0.296
#> SRR1562745     2  0.4697      0.732 0.000 0.696 0.008 0.296
#> SRR1562746     2  0.4697      0.732 0.000 0.696 0.008 0.296
#> SRR1562747     2  0.4697      0.732 0.000 0.696 0.008 0.296
#> SRR1562748     4  0.0657      0.938 0.000 0.004 0.012 0.984
#> SRR1562749     4  0.0657      0.938 0.000 0.004 0.012 0.984
#> SRR1562750     4  0.0657      0.938 0.000 0.004 0.012 0.984
#> SRR1562751     4  0.0657      0.938 0.000 0.004 0.012 0.984
#> SRR1562752     4  0.0657      0.938 0.000 0.004 0.012 0.984
#> SRR1562753     4  0.0657      0.938 0.000 0.004 0.012 0.984
#> SRR1562754     4  0.1867      0.939 0.000 0.072 0.000 0.928
#> SRR1562755     4  0.1867      0.939 0.000 0.072 0.000 0.928
#> SRR1562756     4  0.1867      0.939 0.000 0.072 0.000 0.928
#> SRR1562757     4  0.1867      0.939 0.000 0.072 0.000 0.928
#> SRR1562758     4  0.1867      0.939 0.000 0.072 0.000 0.928
#> SRR1562759     4  0.1867      0.939 0.000 0.072 0.000 0.928
#> SRR1562792     3  0.0817      1.000 0.024 0.000 0.976 0.000
#> SRR1562793     3  0.0817      1.000 0.024 0.000 0.976 0.000
#> SRR1562794     3  0.0817      1.000 0.024 0.000 0.976 0.000
#> SRR1562795     3  0.0817      1.000 0.024 0.000 0.976 0.000
#> SRR1562796     3  0.0817      1.000 0.024 0.000 0.976 0.000
#> SRR1562797     3  0.0817      1.000 0.024 0.000 0.976 0.000
#> SRR1562798     3  0.0817      1.000 0.024 0.000 0.976 0.000
#> SRR1562799     3  0.0817      1.000 0.024 0.000 0.976 0.000
#> SRR1562800     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1562801     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1562802     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1562803     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1562804     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1562805     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1562806     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1562807     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1562808     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1562809     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1562810     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1562811     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1562812     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> SRR1562813     1  0.0000      1.000 1.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2 p3    p4    p5
#> SRR1562718     2  0.3707      0.840 0.000 0.716  0 0.000 0.284
#> SRR1562719     2  0.3707      0.840 0.000 0.716  0 0.000 0.284
#> SRR1562720     2  0.3707      0.840 0.000 0.716  0 0.000 0.284
#> SRR1562721     2  0.3707      0.840 0.000 0.716  0 0.000 0.284
#> SRR1562723     2  0.3707      0.840 0.000 0.716  0 0.000 0.284
#> SRR1562724     2  0.3707      0.840 0.000 0.716  0 0.000 0.284
#> SRR1562725     2  0.3707      0.840 0.000 0.716  0 0.000 0.284
#> SRR1562726     2  0.3707      0.840 0.000 0.716  0 0.000 0.284
#> SRR1562727     2  0.3707      0.840 0.000 0.716  0 0.000 0.284
#> SRR1562728     2  0.3707      0.840 0.000 0.716  0 0.000 0.284
#> SRR1562729     2  0.3707      0.840 0.000 0.716  0 0.000 0.284
#> SRR1562730     2  0.0162      0.751 0.000 0.996  0 0.000 0.004
#> SRR1562731     2  0.0162      0.751 0.000 0.996  0 0.000 0.004
#> SRR1562732     2  0.0162      0.751 0.000 0.996  0 0.000 0.004
#> SRR1562733     2  0.0162      0.751 0.000 0.996  0 0.000 0.004
#> SRR1562734     2  0.0162      0.751 0.000 0.996  0 0.000 0.004
#> SRR1562735     2  0.0162      0.751 0.000 0.996  0 0.000 0.004
#> SRR1562736     5  0.5729      0.991 0.000 0.088  0 0.396 0.516
#> SRR1562737     5  0.5729      0.991 0.000 0.088  0 0.396 0.516
#> SRR1562738     5  0.5729      0.991 0.000 0.088  0 0.396 0.516
#> SRR1562739     5  0.5729      0.991 0.000 0.088  0 0.396 0.516
#> SRR1562740     5  0.5729      0.991 0.000 0.088  0 0.396 0.516
#> SRR1562741     5  0.5729      0.991 0.000 0.088  0 0.396 0.516
#> SRR1562742     5  0.5639      0.991 0.000 0.080  0 0.396 0.524
#> SRR1562743     5  0.5639      0.991 0.000 0.080  0 0.396 0.524
#> SRR1562744     5  0.5639      0.991 0.000 0.080  0 0.396 0.524
#> SRR1562745     5  0.5639      0.991 0.000 0.080  0 0.396 0.524
#> SRR1562746     5  0.5639      0.991 0.000 0.080  0 0.396 0.524
#> SRR1562747     5  0.5639      0.991 0.000 0.080  0 0.396 0.524
#> SRR1562748     4  0.4283      0.647 0.000 0.000  0 0.544 0.456
#> SRR1562749     4  0.4283      0.647 0.000 0.000  0 0.544 0.456
#> SRR1562750     4  0.4283      0.647 0.000 0.000  0 0.544 0.456
#> SRR1562751     4  0.4283      0.647 0.000 0.000  0 0.544 0.456
#> SRR1562752     4  0.4283      0.647 0.000 0.000  0 0.544 0.456
#> SRR1562753     4  0.4283      0.647 0.000 0.000  0 0.544 0.456
#> SRR1562754     4  0.2077      0.466 0.000 0.008  0 0.908 0.084
#> SRR1562755     4  0.2077      0.466 0.000 0.008  0 0.908 0.084
#> SRR1562756     4  0.2077      0.466 0.000 0.008  0 0.908 0.084
#> SRR1562757     4  0.2077      0.466 0.000 0.008  0 0.908 0.084
#> SRR1562758     4  0.2077      0.466 0.000 0.008  0 0.908 0.084
#> SRR1562759     4  0.2077      0.466 0.000 0.008  0 0.908 0.084
#> SRR1562792     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1562793     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1562794     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1562795     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1562796     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1562797     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1562798     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1562799     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> SRR1562800     1  0.0290      0.996 0.992 0.000  0 0.000 0.008
#> SRR1562801     1  0.0290      0.996 0.992 0.000  0 0.000 0.008
#> SRR1562802     1  0.0290      0.996 0.992 0.000  0 0.000 0.008
#> SRR1562803     1  0.0290      0.996 0.992 0.000  0 0.000 0.008
#> SRR1562804     1  0.0290      0.996 0.992 0.000  0 0.000 0.008
#> SRR1562805     1  0.0290      0.996 0.992 0.000  0 0.000 0.008
#> SRR1562806     1  0.0000      0.997 1.000 0.000  0 0.000 0.000
#> SRR1562807     1  0.0000      0.997 1.000 0.000  0 0.000 0.000
#> SRR1562808     1  0.0000      0.997 1.000 0.000  0 0.000 0.000
#> SRR1562809     1  0.0000      0.997 1.000 0.000  0 0.000 0.000
#> SRR1562810     1  0.0000      0.997 1.000 0.000  0 0.000 0.000
#> SRR1562811     1  0.0000      0.997 1.000 0.000  0 0.000 0.000
#> SRR1562812     1  0.0000      0.997 1.000 0.000  0 0.000 0.000
#> SRR1562813     1  0.0000      0.997 1.000 0.000  0 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5    p6
#> SRR1562718     2  0.0146      0.996 0.000 0.996 0.000 0.000 0.000 0.004
#> SRR1562719     2  0.0146      0.996 0.000 0.996 0.000 0.000 0.000 0.004
#> SRR1562720     2  0.0146      0.996 0.000 0.996 0.000 0.000 0.000 0.004
#> SRR1562721     2  0.0146      0.996 0.000 0.996 0.000 0.000 0.000 0.004
#> SRR1562723     2  0.0146      0.996 0.000 0.996 0.000 0.000 0.000 0.004
#> SRR1562724     2  0.0000      0.996 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1562725     2  0.0000      0.996 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1562726     2  0.0000      0.996 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1562727     2  0.0000      0.996 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1562728     2  0.0000      0.996 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1562729     2  0.0000      0.996 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1562730     6  0.3857      1.000 0.000 0.468 0.000 0.000 0.000 0.532
#> SRR1562731     6  0.3857      1.000 0.000 0.468 0.000 0.000 0.000 0.532
#> SRR1562732     6  0.3857      1.000 0.000 0.468 0.000 0.000 0.000 0.532
#> SRR1562733     6  0.3857      1.000 0.000 0.468 0.000 0.000 0.000 0.532
#> SRR1562734     6  0.3857      1.000 0.000 0.468 0.000 0.000 0.000 0.532
#> SRR1562735     6  0.3857      1.000 0.000 0.468 0.000 0.000 0.000 0.532
#> SRR1562736     5  0.4053      0.934 0.000 0.204 0.000 0.040 0.744 0.012
#> SRR1562737     5  0.4053      0.934 0.000 0.204 0.000 0.040 0.744 0.012
#> SRR1562738     5  0.4053      0.934 0.000 0.204 0.000 0.040 0.744 0.012
#> SRR1562739     5  0.4053      0.934 0.000 0.204 0.000 0.040 0.744 0.012
#> SRR1562740     5  0.4053      0.934 0.000 0.204 0.000 0.040 0.744 0.012
#> SRR1562741     5  0.4053      0.934 0.000 0.204 0.000 0.040 0.744 0.012
#> SRR1562742     5  0.2632      0.934 0.000 0.164 0.000 0.004 0.832 0.000
#> SRR1562743     5  0.2632      0.934 0.000 0.164 0.000 0.004 0.832 0.000
#> SRR1562744     5  0.2632      0.934 0.000 0.164 0.000 0.004 0.832 0.000
#> SRR1562745     5  0.2632      0.934 0.000 0.164 0.000 0.004 0.832 0.000
#> SRR1562746     5  0.2632      0.934 0.000 0.164 0.000 0.004 0.832 0.000
#> SRR1562747     5  0.2632      0.934 0.000 0.164 0.000 0.004 0.832 0.000
#> SRR1562748     3  0.5658      0.253 0.000 0.000 0.432 0.416 0.152 0.000
#> SRR1562749     3  0.5658      0.253 0.000 0.000 0.432 0.416 0.152 0.000
#> SRR1562750     3  0.5658      0.253 0.000 0.000 0.432 0.416 0.152 0.000
#> SRR1562751     3  0.5658      0.253 0.000 0.000 0.432 0.416 0.152 0.000
#> SRR1562752     3  0.5658      0.253 0.000 0.000 0.432 0.416 0.152 0.000
#> SRR1562753     3  0.5658      0.253 0.000 0.000 0.432 0.416 0.152 0.000
#> SRR1562754     4  0.3337      1.000 0.000 0.004 0.000 0.736 0.260 0.000
#> SRR1562755     4  0.3337      1.000 0.000 0.004 0.000 0.736 0.260 0.000
#> SRR1562756     4  0.3337      1.000 0.000 0.004 0.000 0.736 0.260 0.000
#> SRR1562757     4  0.3337      1.000 0.000 0.004 0.000 0.736 0.260 0.000
#> SRR1562758     4  0.3337      1.000 0.000 0.004 0.000 0.736 0.260 0.000
#> SRR1562759     4  0.3337      1.000 0.000 0.004 0.000 0.736 0.260 0.000
#> SRR1562792     3  0.3817      0.553 0.000 0.000 0.568 0.000 0.000 0.432
#> SRR1562793     3  0.3817      0.553 0.000 0.000 0.568 0.000 0.000 0.432
#> SRR1562794     3  0.3817      0.553 0.000 0.000 0.568 0.000 0.000 0.432
#> SRR1562795     3  0.3817      0.553 0.000 0.000 0.568 0.000 0.000 0.432
#> SRR1562796     3  0.3817      0.553 0.000 0.000 0.568 0.000 0.000 0.432
#> SRR1562797     3  0.3817      0.553 0.000 0.000 0.568 0.000 0.000 0.432
#> SRR1562798     3  0.3817      0.553 0.000 0.000 0.568 0.000 0.000 0.432
#> SRR1562799     3  0.3817      0.553 0.000 0.000 0.568 0.000 0.000 0.432
#> SRR1562800     1  0.0993      0.982 0.964 0.000 0.000 0.000 0.012 0.024
#> SRR1562801     1  0.0993      0.982 0.964 0.000 0.000 0.000 0.012 0.024
#> SRR1562802     1  0.0993      0.982 0.964 0.000 0.000 0.000 0.012 0.024
#> SRR1562803     1  0.0993      0.982 0.964 0.000 0.000 0.000 0.012 0.024
#> SRR1562804     1  0.0993      0.982 0.964 0.000 0.000 0.000 0.012 0.024
#> SRR1562805     1  0.0993      0.982 0.964 0.000 0.000 0.000 0.012 0.024
#> SRR1562806     1  0.0000      0.986 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1562807     1  0.0000      0.986 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1562808     1  0.0000      0.986 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1562809     1  0.0000      0.986 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1562810     1  0.0000      0.986 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1562811     1  0.0000      0.986 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1562812     1  0.0000      0.986 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1562813     1  0.0000      0.986 1.000 0.000 0.000 0.000 0.000 0.000

Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.

consensus_heatmap(res, k = 2)

plot of chunk tab-ATC-skmeans-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-ATC-skmeans-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-ATC-skmeans-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-ATC-skmeans-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-ATC-skmeans-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-ATC-skmeans-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-ATC-skmeans-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-ATC-skmeans-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-ATC-skmeans-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-ATC-skmeans-membership-heatmap-5

As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

plot of chunk tab-ATC-skmeans-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-ATC-skmeans-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-ATC-skmeans-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-ATC-skmeans-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-ATC-skmeans-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-ATC-skmeans-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-ATC-skmeans-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-ATC-skmeans-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-ATC-skmeans-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-ATC-skmeans-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-skmeans-signature_compare

get_signature() returns a data frame invisibly. TO get the list of signatures, the function call should be assigned to a variable explicitly. In following code, if plot argument is set to FALSE, no heatmap is plotted while only the differential analysis is performed.

# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)

An example of the output of tb is:

#>   which_row         fdr    mean_1    mean_2 scaled_mean_1 scaled_mean_2 km
#> 1        38 0.042760348  8.373488  9.131774    -0.5533452     0.5164555  1
#> 2        40 0.018707592  7.106213  8.469186    -0.6173731     0.5762149  1
#> 3        55 0.019134737 10.221463 11.207825    -0.6159697     0.5749050  1
#> 4        59 0.006059896  5.921854  7.869574    -0.6899429     0.6439467  1
#> 5        60 0.018055526  8.928898 10.211722    -0.6204761     0.5791110  1
#> 6        98 0.009384629 15.714769 14.887706     0.6635654    -0.6193277  2
...

The columns in tb are:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. km: Row groups if k-means clustering is applied to rows.

UMAP plot which shows how samples are separated.

dimension_reduction(res, k = 2, method = "UMAP")

plot of chunk tab-ATC-skmeans-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-ATC-skmeans-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-ATC-skmeans-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-ATC-skmeans-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-ATC-skmeans-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-skmeans-collect-classes

If matrix rows can be associated to genes, consider to use functional_enrichment(res, ...) to perform function enrichment for the signature genes. See this vignette for more detailed explanations.


ATC:pam*

The object with results only for a single top-value method and a single partition method can be extracted as:

res = res_list["ATC", "pam"]
# you can also extract it by
# res = res_list["ATC:pam"]

A summary of res and all the functions that can be applied to it:

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 15301 rows and 63 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#>   Subgroups are detected by 'pam' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 6.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

collect_plots() function collects all the plots made from res for all k (number of partitions) into one single page to provide an easy and fast comparison between different k.

collect_plots(res)

plot of chunk ATC-pam-collect-plots

The plots are:

All the plots in panels can be made by individual functions and they are plotted later in this section.

select_partition_number() produces several plots showing different statistics for choosing “optimized” k. There are following statistics:

The detailed explanations of these statistics can be found in the cola vignette.

Generally speaking, lower PAC score, higher mean silhouette score or higher concordance corresponds to better partition. Rand index and Jaccard index measure how similar the current partition is compared to partition with k-1. If they are too similar, we won't accept k is better than k-1.

select_partition_number(res)

plot of chunk ATC-pam-select-partition-number

The numeric values for all these statistics can be obtained by get_stats().

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4624 0.538   0.538
#> 3 3 1.000           1.000       1.000         0.1239 0.943   0.893
#> 4 4 0.959           0.954       0.977         0.3127 0.822   0.629
#> 5 5 0.959           0.951       0.977         0.0360 0.975   0.919
#> 6 6 0.902           0.929       0.908         0.0953 0.929   0.746

suggest_best_k() suggests the best \(k\) based on these statistics. The rules are as follows:

suggest_best_k(res)
#> [1] 6
#> attr(,"optional")
#> [1] 2 3 4 5

There is also optional best \(k\) = 2 3 4 5 that is worth to check.

Following shows the table of the partitions (You need to click the show/hide code output link to see it). The membership matrix (columns with name p*) is inferred by clue::cl_consensus() function with the SE method. Basically the value in the membership matrix represents the probability to belong to a certain group. The finall class label for an item is determined with the group with highest probability it belongs to.

In get_classes() function, the entropy is calculated from the membership matrix and the silhouette score is calculated from the consensus matrix.

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>            class entropy silhouette p1 p2
#> SRR1562718     2       0          1  0  1
#> SRR1562719     2       0          1  0  1
#> SRR1562720     2       0          1  0  1
#> SRR1562721     2       0          1  0  1
#> SRR1562723     2       0          1  0  1
#> SRR1562724     2       0          1  0  1
#> SRR1562725     2       0          1  0  1
#> SRR1562726     2       0          1  0  1
#> SRR1562727     2       0          1  0  1
#> SRR1562728     2       0          1  0  1
#> SRR1562729     2       0          1  0  1
#> SRR1562730     2       0          1  0  1
#> SRR1562731     2       0          1  0  1
#> SRR1562732     2       0          1  0  1
#> SRR1562733     2       0          1  0  1
#> SRR1562734     2       0          1  0  1
#> SRR1562735     2       0          1  0  1
#> SRR1562736     2       0          1  0  1
#> SRR1562737     2       0          1  0  1
#> SRR1562738     2       0          1  0  1
#> SRR1562739     2       0          1  0  1
#> SRR1562740     2       0          1  0  1
#> SRR1562741     2       0          1  0  1
#> SRR1562742     2       0          1  0  1
#> SRR1562743     2       0          1  0  1
#> SRR1562744     2       0          1  0  1
#> SRR1562745     2       0          1  0  1
#> SRR1562746     2       0          1  0  1
#> SRR1562747     2       0          1  0  1
#> SRR1562748     2       0          1  0  1
#> SRR1562749     2       0          1  0  1
#> SRR1562750     2       0          1  0  1
#> SRR1562751     2       0          1  0  1
#> SRR1562752     2       0          1  0  1
#> SRR1562753     2       0          1  0  1
#> SRR1562754     2       0          1  0  1
#> SRR1562755     2       0          1  0  1
#> SRR1562756     2       0          1  0  1
#> SRR1562757     2       0          1  0  1
#> SRR1562758     2       0          1  0  1
#> SRR1562759     2       0          1  0  1
#> SRR1562792     1       0          1  1  0
#> SRR1562793     1       0          1  1  0
#> SRR1562794     1       0          1  1  0
#> SRR1562795     1       0          1  1  0
#> SRR1562796     1       0          1  1  0
#> SRR1562797     1       0          1  1  0
#> SRR1562798     1       0          1  1  0
#> SRR1562799     1       0          1  1  0
#> SRR1562800     1       0          1  1  0
#> SRR1562801     1       0          1  1  0
#> SRR1562802     1       0          1  1  0
#> SRR1562803     1       0          1  1  0
#> SRR1562804     1       0          1  1  0
#> SRR1562805     1       0          1  1  0
#> SRR1562806     1       0          1  1  0
#> SRR1562807     1       0          1  1  0
#> SRR1562808     1       0          1  1  0
#> SRR1562809     1       0          1  1  0
#> SRR1562810     1       0          1  1  0
#> SRR1562811     1       0          1  1  0
#> SRR1562812     1       0          1  1  0
#> SRR1562813     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette p1 p2 p3
#> SRR1562718     2       0          1  0  1  0
#> SRR1562719     2       0          1  0  1  0
#> SRR1562720     2       0          1  0  1  0
#> SRR1562721     2       0          1  0  1  0
#> SRR1562723     2       0          1  0  1  0
#> SRR1562724     2       0          1  0  1  0
#> SRR1562725     2       0          1  0  1  0
#> SRR1562726     2       0          1  0  1  0
#> SRR1562727     2       0          1  0  1  0
#> SRR1562728     2       0          1  0  1  0
#> SRR1562729     2       0          1  0  1  0
#> SRR1562730     2       0          1  0  1  0
#> SRR1562731     2       0          1  0  1  0
#> SRR1562732     2       0          1  0  1  0
#> SRR1562733     2       0          1  0  1  0
#> SRR1562734     2       0          1  0  1  0
#> SRR1562735     2       0          1  0  1  0
#> SRR1562736     2       0          1  0  1  0
#> SRR1562737     2       0          1  0  1  0
#> SRR1562738     2       0          1  0  1  0
#> SRR1562739     2       0          1  0  1  0
#> SRR1562740     2       0          1  0  1  0
#> SRR1562741     2       0          1  0  1  0
#> SRR1562742     2       0          1  0  1  0
#> SRR1562743     2       0          1  0  1  0
#> SRR1562744     2       0          1  0  1  0
#> SRR1562745     2       0          1  0  1  0
#> SRR1562746     2       0          1  0  1  0
#> SRR1562747     2       0          1  0  1  0
#> SRR1562748     2       0          1  0  1  0
#> SRR1562749     2       0          1  0  1  0
#> SRR1562750     2       0          1  0  1  0
#> SRR1562751     2       0          1  0  1  0
#> SRR1562752     2       0          1  0  1  0
#> SRR1562753     2       0          1  0  1  0
#> SRR1562754     2       0          1  0  1  0
#> SRR1562755     2       0          1  0  1  0
#> SRR1562756     2       0          1  0  1  0
#> SRR1562757     2       0          1  0  1  0
#> SRR1562758     2       0          1  0  1  0
#> SRR1562759     2       0          1  0  1  0
#> SRR1562792     3       0          1  0  0  1
#> SRR1562793     3       0          1  0  0  1
#> SRR1562794     3       0          1  0  0  1
#> SRR1562795     3       0          1  0  0  1
#> SRR1562796     3       0          1  0  0  1
#> SRR1562797     3       0          1  0  0  1
#> SRR1562798     3       0          1  0  0  1
#> SRR1562799     3       0          1  0  0  1
#> SRR1562800     1       0          1  1  0  0
#> SRR1562801     1       0          1  1  0  0
#> SRR1562802     1       0          1  1  0  0
#> SRR1562803     1       0          1  1  0  0
#> SRR1562804     1       0          1  1  0  0
#> SRR1562805     1       0          1  1  0  0
#> SRR1562806     1       0          1  1  0  0
#> SRR1562807     1       0          1  1  0  0
#> SRR1562808     1       0          1  1  0  0
#> SRR1562809     1       0          1  1  0  0
#> SRR1562810     1       0          1  1  0  0
#> SRR1562811     1       0          1  1  0  0
#> SRR1562812     1       0          1  1  0  0
#> SRR1562813     1       0          1  1  0  0

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette p1    p2 p3    p4
#> SRR1562718     2   0.000      1.000  0 1.000  0 0.000
#> SRR1562719     2   0.000      1.000  0 1.000  0 0.000
#> SRR1562720     2   0.000      1.000  0 1.000  0 0.000
#> SRR1562721     2   0.000      1.000  0 1.000  0 0.000
#> SRR1562723     2   0.000      1.000  0 1.000  0 0.000
#> SRR1562724     2   0.000      1.000  0 1.000  0 0.000
#> SRR1562725     2   0.000      1.000  0 1.000  0 0.000
#> SRR1562726     2   0.000      1.000  0 1.000  0 0.000
#> SRR1562727     2   0.000      1.000  0 1.000  0 0.000
#> SRR1562728     2   0.000      1.000  0 1.000  0 0.000
#> SRR1562729     2   0.000      1.000  0 1.000  0 0.000
#> SRR1562730     2   0.000      1.000  0 1.000  0 0.000
#> SRR1562731     2   0.000      1.000  0 1.000  0 0.000
#> SRR1562732     2   0.000      1.000  0 1.000  0 0.000
#> SRR1562733     2   0.000      1.000  0 1.000  0 0.000
#> SRR1562734     2   0.000      1.000  0 1.000  0 0.000
#> SRR1562735     2   0.000      1.000  0 1.000  0 0.000
#> SRR1562736     2   0.000      1.000  0 1.000  0 0.000
#> SRR1562737     2   0.000      1.000  0 1.000  0 0.000
#> SRR1562738     2   0.000      1.000  0 1.000  0 0.000
#> SRR1562739     2   0.000      1.000  0 1.000  0 0.000
#> SRR1562740     2   0.000      1.000  0 1.000  0 0.000
#> SRR1562741     2   0.000      1.000  0 1.000  0 0.000
#> SRR1562742     2   0.000      1.000  0 1.000  0 0.000
#> SRR1562743     2   0.000      1.000  0 1.000  0 0.000
#> SRR1562744     2   0.000      1.000  0 1.000  0 0.000
#> SRR1562745     2   0.000      1.000  0 1.000  0 0.000
#> SRR1562746     2   0.000      1.000  0 1.000  0 0.000
#> SRR1562747     2   0.000      1.000  0 1.000  0 0.000
#> SRR1562748     4   0.000      0.809  0 0.000  0 1.000
#> SRR1562749     4   0.000      0.809  0 0.000  0 1.000
#> SRR1562750     4   0.000      0.809  0 0.000  0 1.000
#> SRR1562751     4   0.000      0.809  0 0.000  0 1.000
#> SRR1562752     4   0.000      0.809  0 0.000  0 1.000
#> SRR1562753     4   0.000      0.809  0 0.000  0 1.000
#> SRR1562754     4   0.234      0.801  0 0.100  0 0.900
#> SRR1562755     4   0.438      0.691  0 0.296  0 0.704
#> SRR1562756     4   0.234      0.801  0 0.100  0 0.900
#> SRR1562757     4   0.436      0.694  0 0.292  0 0.708
#> SRR1562758     4   0.485      0.513  0 0.400  0 0.600
#> SRR1562759     4   0.404      0.727  0 0.248  0 0.752
#> SRR1562792     3   0.000      1.000  0 0.000  1 0.000
#> SRR1562793     3   0.000      1.000  0 0.000  1 0.000
#> SRR1562794     3   0.000      1.000  0 0.000  1 0.000
#> SRR1562795     3   0.000      1.000  0 0.000  1 0.000
#> SRR1562796     3   0.000      1.000  0 0.000  1 0.000
#> SRR1562797     3   0.000      1.000  0 0.000  1 0.000
#> SRR1562798     3   0.000      1.000  0 0.000  1 0.000
#> SRR1562799     3   0.000      1.000  0 0.000  1 0.000
#> SRR1562800     1   0.000      1.000  1 0.000  0 0.000
#> SRR1562801     1   0.000      1.000  1 0.000  0 0.000
#> SRR1562802     1   0.000      1.000  1 0.000  0 0.000
#> SRR1562803     1   0.000      1.000  1 0.000  0 0.000
#> SRR1562804     1   0.000      1.000  1 0.000  0 0.000
#> SRR1562805     1   0.000      1.000  1 0.000  0 0.000
#> SRR1562806     1   0.000      1.000  1 0.000  0 0.000
#> SRR1562807     1   0.000      1.000  1 0.000  0 0.000
#> SRR1562808     1   0.000      1.000  1 0.000  0 0.000
#> SRR1562809     1   0.000      1.000  1 0.000  0 0.000
#> SRR1562810     1   0.000      1.000  1 0.000  0 0.000
#> SRR1562811     1   0.000      1.000  1 0.000  0 0.000
#> SRR1562812     1   0.000      1.000  1 0.000  0 0.000
#> SRR1562813     1   0.000      1.000  1 0.000  0 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette p1    p2 p3    p4 p5
#> SRR1562718     2   0.000      1.000  0 1.000  0 0.000  0
#> SRR1562719     2   0.000      1.000  0 1.000  0 0.000  0
#> SRR1562720     2   0.000      1.000  0 1.000  0 0.000  0
#> SRR1562721     2   0.000      1.000  0 1.000  0 0.000  0
#> SRR1562723     2   0.000      1.000  0 1.000  0 0.000  0
#> SRR1562724     2   0.000      1.000  0 1.000  0 0.000  0
#> SRR1562725     2   0.000      1.000  0 1.000  0 0.000  0
#> SRR1562726     2   0.000      1.000  0 1.000  0 0.000  0
#> SRR1562727     2   0.000      1.000  0 1.000  0 0.000  0
#> SRR1562728     2   0.000      1.000  0 1.000  0 0.000  0
#> SRR1562729     2   0.000      1.000  0 1.000  0 0.000  0
#> SRR1562730     2   0.000      1.000  0 1.000  0 0.000  0
#> SRR1562731     2   0.000      1.000  0 1.000  0 0.000  0
#> SRR1562732     2   0.000      1.000  0 1.000  0 0.000  0
#> SRR1562733     2   0.000      1.000  0 1.000  0 0.000  0
#> SRR1562734     2   0.000      1.000  0 1.000  0 0.000  0
#> SRR1562735     2   0.000      1.000  0 1.000  0 0.000  0
#> SRR1562736     2   0.000      1.000  0 1.000  0 0.000  0
#> SRR1562737     2   0.000      1.000  0 1.000  0 0.000  0
#> SRR1562738     2   0.000      1.000  0 1.000  0 0.000  0
#> SRR1562739     2   0.000      1.000  0 1.000  0 0.000  0
#> SRR1562740     2   0.000      1.000  0 1.000  0 0.000  0
#> SRR1562741     2   0.000      1.000  0 1.000  0 0.000  0
#> SRR1562742     2   0.000      1.000  0 1.000  0 0.000  0
#> SRR1562743     2   0.000      1.000  0 1.000  0 0.000  0
#> SRR1562744     2   0.000      1.000  0 1.000  0 0.000  0
#> SRR1562745     2   0.000      1.000  0 1.000  0 0.000  0
#> SRR1562746     2   0.000      1.000  0 1.000  0 0.000  0
#> SRR1562747     2   0.000      1.000  0 1.000  0 0.000  0
#> SRR1562748     4   0.000      0.797  0 0.000  0 1.000  0
#> SRR1562749     4   0.000      0.797  0 0.000  0 1.000  0
#> SRR1562750     4   0.000      0.797  0 0.000  0 1.000  0
#> SRR1562751     4   0.000      0.797  0 0.000  0 1.000  0
#> SRR1562752     4   0.000      0.797  0 0.000  0 1.000  0
#> SRR1562753     4   0.000      0.797  0 0.000  0 1.000  0
#> SRR1562754     4   0.202      0.788  0 0.100  0 0.900  0
#> SRR1562755     4   0.377      0.672  0 0.296  0 0.704  0
#> SRR1562756     4   0.202      0.789  0 0.100  0 0.900  0
#> SRR1562757     4   0.375      0.675  0 0.292  0 0.708  0
#> SRR1562758     4   0.418      0.513  0 0.400  0 0.600  0
#> SRR1562759     4   0.348      0.711  0 0.248  0 0.752  0
#> SRR1562792     3   0.000      1.000  0 0.000  1 0.000  0
#> SRR1562793     3   0.000      1.000  0 0.000  1 0.000  0
#> SRR1562794     3   0.000      1.000  0 0.000  1 0.000  0
#> SRR1562795     3   0.000      1.000  0 0.000  1 0.000  0
#> SRR1562796     3   0.000      1.000  0 0.000  1 0.000  0
#> SRR1562797     3   0.000      1.000  0 0.000  1 0.000  0
#> SRR1562798     3   0.000      1.000  0 0.000  1 0.000  0
#> SRR1562799     3   0.000      1.000  0 0.000  1 0.000  0
#> SRR1562800     5   0.000      1.000  0 0.000  0 0.000  1
#> SRR1562801     5   0.000      1.000  0 0.000  0 0.000  1
#> SRR1562802     5   0.000      1.000  0 0.000  0 0.000  1
#> SRR1562803     5   0.000      1.000  0 0.000  0 0.000  1
#> SRR1562804     5   0.000      1.000  0 0.000  0 0.000  1
#> SRR1562805     5   0.000      1.000  0 0.000  0 0.000  1
#> SRR1562806     1   0.000      1.000  1 0.000  0 0.000  0
#> SRR1562807     1   0.000      1.000  1 0.000  0 0.000  0
#> SRR1562808     1   0.000      1.000  1 0.000  0 0.000  0
#> SRR1562809     1   0.000      1.000  1 0.000  0 0.000  0
#> SRR1562810     1   0.000      1.000  1 0.000  0 0.000  0
#> SRR1562811     1   0.000      1.000  1 0.000  0 0.000  0
#> SRR1562812     1   0.000      1.000  1 0.000  0 0.000  0
#> SRR1562813     1   0.000      1.000  1 0.000  0 0.000  0

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette p1    p2 p3    p4    p5 p6
#> SRR1562718     2  0.0000      0.957  0 1.000  0 0.000 0.000  0
#> SRR1562719     2  0.0000      0.957  0 1.000  0 0.000 0.000  0
#> SRR1562720     2  0.0000      0.957  0 1.000  0 0.000 0.000  0
#> SRR1562721     2  0.0000      0.957  0 1.000  0 0.000 0.000  0
#> SRR1562723     2  0.0000      0.957  0 1.000  0 0.000 0.000  0
#> SRR1562724     2  0.0000      0.957  0 1.000  0 0.000 0.000  0
#> SRR1562725     2  0.0000      0.957  0 1.000  0 0.000 0.000  0
#> SRR1562726     2  0.0000      0.957  0 1.000  0 0.000 0.000  0
#> SRR1562727     2  0.0000      0.957  0 1.000  0 0.000 0.000  0
#> SRR1562728     2  0.0000      0.957  0 1.000  0 0.000 0.000  0
#> SRR1562729     2  0.0000      0.957  0 1.000  0 0.000 0.000  0
#> SRR1562730     2  0.0000      0.957  0 1.000  0 0.000 0.000  0
#> SRR1562731     2  0.0000      0.957  0 1.000  0 0.000 0.000  0
#> SRR1562732     2  0.0000      0.957  0 1.000  0 0.000 0.000  0
#> SRR1562733     2  0.0000      0.957  0 1.000  0 0.000 0.000  0
#> SRR1562734     2  0.0000      0.957  0 1.000  0 0.000 0.000  0
#> SRR1562735     2  0.0000      0.957  0 1.000  0 0.000 0.000  0
#> SRR1562736     2  0.1838      0.870  0 0.916  0 0.016 0.068  0
#> SRR1562737     2  0.2163      0.832  0 0.892  0 0.016 0.092  0
#> SRR1562738     2  0.1838      0.870  0 0.916  0 0.016 0.068  0
#> SRR1562739     2  0.1838      0.870  0 0.916  0 0.016 0.068  0
#> SRR1562740     2  0.1895      0.865  0 0.912  0 0.016 0.072  0
#> SRR1562741     2  0.2006      0.854  0 0.904  0 0.016 0.080  0
#> SRR1562742     5  0.4141      1.000  0 0.388  0 0.016 0.596  0
#> SRR1562743     5  0.4141      1.000  0 0.388  0 0.016 0.596  0
#> SRR1562744     5  0.4141      1.000  0 0.388  0 0.016 0.596  0
#> SRR1562745     5  0.4141      1.000  0 0.388  0 0.016 0.596  0
#> SRR1562746     5  0.4141      1.000  0 0.388  0 0.016 0.596  0
#> SRR1562747     5  0.4141      1.000  0 0.388  0 0.016 0.596  0
#> SRR1562748     4  0.3765      0.772  0 0.000  0 0.596 0.404  0
#> SRR1562749     4  0.3765      0.772  0 0.000  0 0.596 0.404  0
#> SRR1562750     4  0.3765      0.772  0 0.000  0 0.596 0.404  0
#> SRR1562751     4  0.3765      0.772  0 0.000  0 0.596 0.404  0
#> SRR1562752     4  0.3765      0.772  0 0.000  0 0.596 0.404  0
#> SRR1562753     4  0.3765      0.772  0 0.000  0 0.596 0.404  0
#> SRR1562754     4  0.0820      0.753  0 0.012  0 0.972 0.016  0
#> SRR1562755     4  0.1926      0.729  0 0.020  0 0.912 0.068  0
#> SRR1562756     4  0.0713      0.752  0 0.000  0 0.972 0.028  0
#> SRR1562757     4  0.1700      0.738  0 0.048  0 0.928 0.024  0
#> SRR1562758     4  0.2164      0.716  0 0.068  0 0.900 0.032  0
#> SRR1562759     4  0.1418      0.747  0 0.024  0 0.944 0.032  0
#> SRR1562792     3  0.0000      1.000  0 0.000  1 0.000 0.000  0
#> SRR1562793     3  0.0000      1.000  0 0.000  1 0.000 0.000  0
#> SRR1562794     3  0.0000      1.000  0 0.000  1 0.000 0.000  0
#> SRR1562795     3  0.0000      1.000  0 0.000  1 0.000 0.000  0
#> SRR1562796     3  0.0000      1.000  0 0.000  1 0.000 0.000  0
#> SRR1562797     3  0.0000      1.000  0 0.000  1 0.000 0.000  0
#> SRR1562798     3  0.0000      1.000  0 0.000  1 0.000 0.000  0
#> SRR1562799     3  0.0000      1.000  0 0.000  1 0.000 0.000  0
#> SRR1562800     6  0.0000      1.000  0 0.000  0 0.000 0.000  1
#> SRR1562801     6  0.0000      1.000  0 0.000  0 0.000 0.000  1
#> SRR1562802     6  0.0000      1.000  0 0.000  0 0.000 0.000  1
#> SRR1562803     6  0.0000      1.000  0 0.000  0 0.000 0.000  1
#> SRR1562804     6  0.0000      1.000  0 0.000  0 0.000 0.000  1
#> SRR1562805     6  0.0000      1.000  0 0.000  0 0.000 0.000  1
#> SRR1562806     1  0.0000      1.000  1 0.000  0 0.000 0.000  0
#> SRR1562807     1  0.0000      1.000  1 0.000  0 0.000 0.000  0
#> SRR1562808     1  0.0000      1.000  1 0.000  0 0.000 0.000  0
#> SRR1562809     1  0.0000      1.000  1 0.000  0 0.000 0.000  0
#> SRR1562810     1  0.0000      1.000  1 0.000  0 0.000 0.000  0
#> SRR1562811     1  0.0000      1.000  1 0.000  0 0.000 0.000  0
#> SRR1562812     1  0.0000      1.000  1 0.000  0 0.000 0.000  0
#> SRR1562813     1  0.0000      1.000  1 0.000  0 0.000 0.000  0

Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.

consensus_heatmap(res, k = 2)

plot of chunk tab-ATC-pam-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-ATC-pam-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-ATC-pam-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-ATC-pam-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-ATC-pam-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-ATC-pam-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-ATC-pam-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-ATC-pam-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-ATC-pam-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-ATC-pam-membership-heatmap-5

As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

plot of chunk tab-ATC-pam-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-ATC-pam-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-ATC-pam-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-ATC-pam-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-ATC-pam-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-ATC-pam-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-ATC-pam-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-ATC-pam-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-ATC-pam-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-ATC-pam-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-pam-signature_compare

get_signature() returns a data frame invisibly. TO get the list of signatures, the function call should be assigned to a variable explicitly. In following code, if plot argument is set to FALSE, no heatmap is plotted while only the differential analysis is performed.

# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)

An example of the output of tb is:

#>   which_row         fdr    mean_1    mean_2 scaled_mean_1 scaled_mean_2 km
#> 1        38 0.042760348  8.373488  9.131774    -0.5533452     0.5164555  1
#> 2        40 0.018707592  7.106213  8.469186    -0.6173731     0.5762149  1
#> 3        55 0.019134737 10.221463 11.207825    -0.6159697     0.5749050  1
#> 4        59 0.006059896  5.921854  7.869574    -0.6899429     0.6439467  1
#> 5        60 0.018055526  8.928898 10.211722    -0.6204761     0.5791110  1
#> 6        98 0.009384629 15.714769 14.887706     0.6635654    -0.6193277  2
...

The columns in tb are:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. km: Row groups if k-means clustering is applied to rows.

UMAP plot which shows how samples are separated.

dimension_reduction(res, k = 2, method = "UMAP")

plot of chunk tab-ATC-pam-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-ATC-pam-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-ATC-pam-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-ATC-pam-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-ATC-pam-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-pam-collect-classes

If matrix rows can be associated to genes, consider to use functional_enrichment(res, ...) to perform function enrichment for the signature genes. See this vignette for more detailed explanations.


ATC:mclust**

The object with results only for a single top-value method and a single partition method can be extracted as:

res = res_list["ATC", "mclust"]
# you can also extract it by
# res = res_list["ATC:mclust"]

A summary of res and all the functions that can be applied to it:

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 15301 rows and 63 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#>   Subgroups are detected by 'mclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 6.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

collect_plots() function collects all the plots made from res for all k (number of partitions) into one single page to provide an easy and fast comparison between different k.

collect_plots(res)

plot of chunk ATC-mclust-collect-plots

The plots are:

All the plots in panels can be made by individual functions and they are plotted later in this section.

select_partition_number() produces several plots showing different statistics for choosing “optimized” k. There are following statistics:

The detailed explanations of these statistics can be found in the cola vignette.

Generally speaking, lower PAC score, higher mean silhouette score or higher concordance corresponds to better partition. Rand index and Jaccard index measure how similar the current partition is compared to partition with k-1. If they are too similar, we won't accept k is better than k-1.

select_partition_number(res)

plot of chunk ATC-mclust-select-partition-number

The numeric values for all these statistics can be obtained by get_stats().

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4624 0.538   0.538
#> 3 3 0.678           0.779       0.834         0.2656 0.943   0.893
#> 4 4 0.822           0.945       0.962         0.2027 0.822   0.629
#> 5 5 0.871           0.971       0.919         0.1074 0.896   0.655
#> 6 6 0.966           0.985       0.986         0.0561 0.975   0.876

suggest_best_k() suggests the best \(k\) based on these statistics. The rules are as follows:

suggest_best_k(res)
#> [1] 6
#> 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
#> SRR1562718     2       0          1  0  1
#> SRR1562719     2       0          1  0  1
#> SRR1562720     2       0          1  0  1
#> SRR1562721     2       0          1  0  1
#> SRR1562723     2       0          1  0  1
#> SRR1562724     2       0          1  0  1
#> SRR1562725     2       0          1  0  1
#> SRR1562726     2       0          1  0  1
#> SRR1562727     2       0          1  0  1
#> SRR1562728     2       0          1  0  1
#> SRR1562729     2       0          1  0  1
#> SRR1562730     2       0          1  0  1
#> SRR1562731     2       0          1  0  1
#> SRR1562732     2       0          1  0  1
#> SRR1562733     2       0          1  0  1
#> SRR1562734     2       0          1  0  1
#> SRR1562735     2       0          1  0  1
#> SRR1562736     2       0          1  0  1
#> SRR1562737     2       0          1  0  1
#> SRR1562738     2       0          1  0  1
#> SRR1562739     2       0          1  0  1
#> SRR1562740     2       0          1  0  1
#> SRR1562741     2       0          1  0  1
#> SRR1562742     2       0          1  0  1
#> SRR1562743     2       0          1  0  1
#> SRR1562744     2       0          1  0  1
#> SRR1562745     2       0          1  0  1
#> SRR1562746     2       0          1  0  1
#> SRR1562747     2       0          1  0  1
#> SRR1562748     2       0          1  0  1
#> SRR1562749     2       0          1  0  1
#> SRR1562750     2       0          1  0  1
#> SRR1562751     2       0          1  0  1
#> SRR1562752     2       0          1  0  1
#> SRR1562753     2       0          1  0  1
#> SRR1562754     2       0          1  0  1
#> SRR1562755     2       0          1  0  1
#> SRR1562756     2       0          1  0  1
#> SRR1562757     2       0          1  0  1
#> SRR1562758     2       0          1  0  1
#> SRR1562759     2       0          1  0  1
#> SRR1562792     1       0          1  1  0
#> SRR1562793     1       0          1  1  0
#> SRR1562794     1       0          1  1  0
#> SRR1562795     1       0          1  1  0
#> SRR1562796     1       0          1  1  0
#> SRR1562797     1       0          1  1  0
#> SRR1562798     1       0          1  1  0
#> SRR1562799     1       0          1  1  0
#> SRR1562800     1       0          1  1  0
#> SRR1562801     1       0          1  1  0
#> SRR1562802     1       0          1  1  0
#> SRR1562803     1       0          1  1  0
#> SRR1562804     1       0          1  1  0
#> SRR1562805     1       0          1  1  0
#> SRR1562806     1       0          1  1  0
#> SRR1562807     1       0          1  1  0
#> SRR1562808     1       0          1  1  0
#> SRR1562809     1       0          1  1  0
#> SRR1562810     1       0          1  1  0
#> SRR1562811     1       0          1  1  0
#> SRR1562812     1       0          1  1  0
#> SRR1562813     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1562718     2   0.000      0.797 0.000 1.000 0.000
#> SRR1562719     2   0.000      0.797 0.000 1.000 0.000
#> SRR1562720     2   0.000      0.797 0.000 1.000 0.000
#> SRR1562721     2   0.000      0.797 0.000 1.000 0.000
#> SRR1562723     2   0.000      0.797 0.000 1.000 0.000
#> SRR1562724     2   0.000      0.797 0.000 1.000 0.000
#> SRR1562725     2   0.000      0.797 0.000 1.000 0.000
#> SRR1562726     2   0.000      0.797 0.000 1.000 0.000
#> SRR1562727     2   0.000      0.797 0.000 1.000 0.000
#> SRR1562728     2   0.000      0.797 0.000 1.000 0.000
#> SRR1562729     2   0.000      0.797 0.000 1.000 0.000
#> SRR1562730     2   0.000      0.797 0.000 1.000 0.000
#> SRR1562731     2   0.000      0.797 0.000 1.000 0.000
#> SRR1562732     2   0.000      0.797 0.000 1.000 0.000
#> SRR1562733     2   0.000      0.797 0.000 1.000 0.000
#> SRR1562734     2   0.000      0.797 0.000 1.000 0.000
#> SRR1562735     2   0.000      0.797 0.000 1.000 0.000
#> SRR1562736     2   0.186      0.797 0.000 0.948 0.052
#> SRR1562737     2   0.186      0.797 0.000 0.948 0.052
#> SRR1562738     2   0.186      0.797 0.000 0.948 0.052
#> SRR1562739     2   0.186      0.797 0.000 0.948 0.052
#> SRR1562740     2   0.186      0.797 0.000 0.948 0.052
#> SRR1562741     2   0.186      0.797 0.000 0.948 0.052
#> SRR1562742     2   0.186      0.797 0.000 0.948 0.052
#> SRR1562743     2   0.186      0.797 0.000 0.948 0.052
#> SRR1562744     2   0.186      0.797 0.000 0.948 0.052
#> SRR1562745     2   0.186      0.797 0.000 0.948 0.052
#> SRR1562746     2   0.186      0.797 0.000 0.948 0.052
#> SRR1562747     2   0.186      0.797 0.000 0.948 0.052
#> SRR1562748     2   0.993      0.319 0.328 0.388 0.284
#> SRR1562749     2   0.993      0.319 0.328 0.388 0.284
#> SRR1562750     2   0.993      0.319 0.328 0.388 0.284
#> SRR1562751     2   0.993      0.319 0.328 0.388 0.284
#> SRR1562752     2   0.993      0.319 0.328 0.388 0.284
#> SRR1562753     2   0.993      0.319 0.328 0.388 0.284
#> SRR1562754     2   0.987      0.340 0.328 0.404 0.268
#> SRR1562755     2   0.987      0.340 0.328 0.404 0.268
#> SRR1562756     2   0.987      0.340 0.328 0.404 0.268
#> SRR1562757     2   0.987      0.340 0.328 0.404 0.268
#> SRR1562758     2   0.987      0.340 0.328 0.404 0.268
#> SRR1562759     2   0.987      0.340 0.328 0.404 0.268
#> SRR1562792     3   0.525      1.000 0.264 0.000 0.736
#> SRR1562793     3   0.525      1.000 0.264 0.000 0.736
#> SRR1562794     3   0.525      1.000 0.264 0.000 0.736
#> SRR1562795     3   0.525      1.000 0.264 0.000 0.736
#> SRR1562796     3   0.525      1.000 0.264 0.000 0.736
#> SRR1562797     3   0.525      1.000 0.264 0.000 0.736
#> SRR1562798     3   0.525      1.000 0.264 0.000 0.736
#> SRR1562799     3   0.525      1.000 0.264 0.000 0.736
#> SRR1562800     1   0.000      1.000 1.000 0.000 0.000
#> SRR1562801     1   0.000      1.000 1.000 0.000 0.000
#> SRR1562802     1   0.000      1.000 1.000 0.000 0.000
#> SRR1562803     1   0.000      1.000 1.000 0.000 0.000
#> SRR1562804     1   0.000      1.000 1.000 0.000 0.000
#> SRR1562805     1   0.000      1.000 1.000 0.000 0.000
#> SRR1562806     1   0.000      1.000 1.000 0.000 0.000
#> SRR1562807     1   0.000      1.000 1.000 0.000 0.000
#> SRR1562808     1   0.000      1.000 1.000 0.000 0.000
#> SRR1562809     1   0.000      1.000 1.000 0.000 0.000
#> SRR1562810     1   0.000      1.000 1.000 0.000 0.000
#> SRR1562811     1   0.000      1.000 1.000 0.000 0.000
#> SRR1562812     1   0.000      1.000 1.000 0.000 0.000
#> SRR1562813     1   0.000      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
#> SRR1562718     2   0.000      0.904  0 1.0  0 0.0
#> SRR1562719     2   0.000      0.904  0 1.0  0 0.0
#> SRR1562720     2   0.000      0.904  0 1.0  0 0.0
#> SRR1562721     2   0.000      0.904  0 1.0  0 0.0
#> SRR1562723     2   0.000      0.904  0 1.0  0 0.0
#> SRR1562724     2   0.000      0.904  0 1.0  0 0.0
#> SRR1562725     2   0.000      0.904  0 1.0  0 0.0
#> SRR1562726     2   0.000      0.904  0 1.0  0 0.0
#> SRR1562727     2   0.000      0.904  0 1.0  0 0.0
#> SRR1562728     2   0.000      0.904  0 1.0  0 0.0
#> SRR1562729     2   0.000      0.904  0 1.0  0 0.0
#> SRR1562730     2   0.000      0.904  0 1.0  0 0.0
#> SRR1562731     2   0.000      0.904  0 1.0  0 0.0
#> SRR1562732     2   0.000      0.904  0 1.0  0 0.0
#> SRR1562733     2   0.000      0.904  0 1.0  0 0.0
#> SRR1562734     2   0.000      0.904  0 1.0  0 0.0
#> SRR1562735     2   0.000      0.904  0 1.0  0 0.0
#> SRR1562736     2   0.361      0.848  0 0.8  0 0.2
#> SRR1562737     2   0.361      0.848  0 0.8  0 0.2
#> SRR1562738     2   0.361      0.848  0 0.8  0 0.2
#> SRR1562739     2   0.361      0.848  0 0.8  0 0.2
#> SRR1562740     2   0.361      0.848  0 0.8  0 0.2
#> SRR1562741     2   0.361      0.848  0 0.8  0 0.2
#> SRR1562742     2   0.361      0.848  0 0.8  0 0.2
#> SRR1562743     2   0.361      0.848  0 0.8  0 0.2
#> SRR1562744     2   0.361      0.848  0 0.8  0 0.2
#> SRR1562745     2   0.361      0.848  0 0.8  0 0.2
#> SRR1562746     2   0.361      0.848  0 0.8  0 0.2
#> SRR1562747     2   0.361      0.848  0 0.8  0 0.2
#> SRR1562748     4   0.000      1.000  0 0.0  0 1.0
#> SRR1562749     4   0.000      1.000  0 0.0  0 1.0
#> SRR1562750     4   0.000      1.000  0 0.0  0 1.0
#> SRR1562751     4   0.000      1.000  0 0.0  0 1.0
#> SRR1562752     4   0.000      1.000  0 0.0  0 1.0
#> SRR1562753     4   0.000      1.000  0 0.0  0 1.0
#> SRR1562754     4   0.000      1.000  0 0.0  0 1.0
#> SRR1562755     4   0.000      1.000  0 0.0  0 1.0
#> SRR1562756     4   0.000      1.000  0 0.0  0 1.0
#> SRR1562757     4   0.000      1.000  0 0.0  0 1.0
#> SRR1562758     4   0.000      1.000  0 0.0  0 1.0
#> SRR1562759     4   0.000      1.000  0 0.0  0 1.0
#> SRR1562792     3   0.000      1.000  0 0.0  1 0.0
#> SRR1562793     3   0.000      1.000  0 0.0  1 0.0
#> SRR1562794     3   0.000      1.000  0 0.0  1 0.0
#> SRR1562795     3   0.000      1.000  0 0.0  1 0.0
#> SRR1562796     3   0.000      1.000  0 0.0  1 0.0
#> SRR1562797     3   0.000      1.000  0 0.0  1 0.0
#> SRR1562798     3   0.000      1.000  0 0.0  1 0.0
#> SRR1562799     3   0.000      1.000  0 0.0  1 0.0
#> SRR1562800     1   0.000      1.000  1 0.0  0 0.0
#> SRR1562801     1   0.000      1.000  1 0.0  0 0.0
#> SRR1562802     1   0.000      1.000  1 0.0  0 0.0
#> SRR1562803     1   0.000      1.000  1 0.0  0 0.0
#> SRR1562804     1   0.000      1.000  1 0.0  0 0.0
#> SRR1562805     1   0.000      1.000  1 0.0  0 0.0
#> SRR1562806     1   0.000      1.000  1 0.0  0 0.0
#> SRR1562807     1   0.000      1.000  1 0.0  0 0.0
#> SRR1562808     1   0.000      1.000  1 0.0  0 0.0
#> SRR1562809     1   0.000      1.000  1 0.0  0 0.0
#> SRR1562810     1   0.000      1.000  1 0.0  0 0.0
#> SRR1562811     1   0.000      1.000  1 0.0  0 0.0
#> SRR1562812     1   0.000      1.000  1 0.0  0 0.0
#> SRR1562813     1   0.000      1.000  1 0.0  0 0.0

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2 p3 p4    p5
#> SRR1562718     2   0.000      1.000 0.000 1.000  0  0 0.000
#> SRR1562719     2   0.000      1.000 0.000 1.000  0  0 0.000
#> SRR1562720     2   0.000      1.000 0.000 1.000  0  0 0.000
#> SRR1562721     2   0.000      1.000 0.000 1.000  0  0 0.000
#> SRR1562723     2   0.000      1.000 0.000 1.000  0  0 0.000
#> SRR1562724     2   0.000      1.000 0.000 1.000  0  0 0.000
#> SRR1562725     2   0.000      1.000 0.000 1.000  0  0 0.000
#> SRR1562726     2   0.000      1.000 0.000 1.000  0  0 0.000
#> SRR1562727     2   0.000      1.000 0.000 1.000  0  0 0.000
#> SRR1562728     2   0.000      1.000 0.000 1.000  0  0 0.000
#> SRR1562729     2   0.000      1.000 0.000 1.000  0  0 0.000
#> SRR1562730     2   0.000      1.000 0.000 1.000  0  0 0.000
#> SRR1562731     2   0.000      1.000 0.000 1.000  0  0 0.000
#> SRR1562732     2   0.000      1.000 0.000 1.000  0  0 0.000
#> SRR1562733     2   0.000      1.000 0.000 1.000  0  0 0.000
#> SRR1562734     2   0.000      1.000 0.000 1.000  0  0 0.000
#> SRR1562735     2   0.000      1.000 0.000 1.000  0  0 0.000
#> SRR1562736     5   0.371      1.000 0.000 0.284  0  0 0.716
#> SRR1562737     5   0.371      1.000 0.000 0.284  0  0 0.716
#> SRR1562738     5   0.371      1.000 0.000 0.284  0  0 0.716
#> SRR1562739     5   0.371      1.000 0.000 0.284  0  0 0.716
#> SRR1562740     5   0.371      1.000 0.000 0.284  0  0 0.716
#> SRR1562741     5   0.371      1.000 0.000 0.284  0  0 0.716
#> SRR1562742     5   0.371      1.000 0.000 0.284  0  0 0.716
#> SRR1562743     5   0.371      1.000 0.000 0.284  0  0 0.716
#> SRR1562744     5   0.371      1.000 0.000 0.284  0  0 0.716
#> SRR1562745     5   0.371      1.000 0.000 0.284  0  0 0.716
#> SRR1562746     5   0.371      1.000 0.000 0.284  0  0 0.716
#> SRR1562747     5   0.371      1.000 0.000 0.284  0  0 0.716
#> SRR1562748     4   0.000      1.000 0.000 0.000  0  1 0.000
#> SRR1562749     4   0.000      1.000 0.000 0.000  0  1 0.000
#> SRR1562750     4   0.000      1.000 0.000 0.000  0  1 0.000
#> SRR1562751     4   0.000      1.000 0.000 0.000  0  1 0.000
#> SRR1562752     4   0.000      1.000 0.000 0.000  0  1 0.000
#> SRR1562753     4   0.000      1.000 0.000 0.000  0  1 0.000
#> SRR1562754     4   0.000      1.000 0.000 0.000  0  1 0.000
#> SRR1562755     4   0.000      1.000 0.000 0.000  0  1 0.000
#> SRR1562756     4   0.000      1.000 0.000 0.000  0  1 0.000
#> SRR1562757     4   0.000      1.000 0.000 0.000  0  1 0.000
#> SRR1562758     4   0.000      1.000 0.000 0.000  0  1 0.000
#> SRR1562759     4   0.000      1.000 0.000 0.000  0  1 0.000
#> SRR1562792     3   0.000      1.000 0.000 0.000  1  0 0.000
#> SRR1562793     3   0.000      1.000 0.000 0.000  1  0 0.000
#> SRR1562794     3   0.000      1.000 0.000 0.000  1  0 0.000
#> SRR1562795     3   0.000      1.000 0.000 0.000  1  0 0.000
#> SRR1562796     3   0.000      1.000 0.000 0.000  1  0 0.000
#> SRR1562797     3   0.000      1.000 0.000 0.000  1  0 0.000
#> SRR1562798     3   0.000      1.000 0.000 0.000  1  0 0.000
#> SRR1562799     3   0.000      1.000 0.000 0.000  1  0 0.000
#> SRR1562800     1   0.000      0.846 1.000 0.000  0  0 0.000
#> SRR1562801     1   0.000      0.846 1.000 0.000  0  0 0.000
#> SRR1562802     1   0.000      0.846 1.000 0.000  0  0 0.000
#> SRR1562803     1   0.000      0.846 1.000 0.000  0  0 0.000
#> SRR1562804     1   0.000      0.846 1.000 0.000  0  0 0.000
#> SRR1562805     1   0.000      0.846 1.000 0.000  0  0 0.000
#> SRR1562806     1   0.371      0.888 0.716 0.000  0  0 0.284
#> SRR1562807     1   0.371      0.888 0.716 0.000  0  0 0.284
#> SRR1562808     1   0.371      0.888 0.716 0.000  0  0 0.284
#> SRR1562809     1   0.371      0.888 0.716 0.000  0  0 0.284
#> SRR1562810     1   0.371      0.888 0.716 0.000  0  0 0.284
#> SRR1562811     1   0.371      0.888 0.716 0.000  0  0 0.284
#> SRR1562812     1   0.371      0.888 0.716 0.000  0  0 0.284
#> SRR1562813     1   0.371      0.888 0.716 0.000  0  0 0.284

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2 p3 p4    p5    p6
#> SRR1562718     2  0.1075      0.979 0.000 0.952  0  0 0.048 0.000
#> SRR1562719     2  0.1075      0.979 0.000 0.952  0  0 0.048 0.000
#> SRR1562720     2  0.1075      0.979 0.000 0.952  0  0 0.048 0.000
#> SRR1562721     2  0.1075      0.979 0.000 0.952  0  0 0.048 0.000
#> SRR1562723     2  0.1075      0.979 0.000 0.952  0  0 0.048 0.000
#> SRR1562724     2  0.1075      0.979 0.000 0.952  0  0 0.048 0.000
#> SRR1562725     2  0.1075      0.979 0.000 0.952  0  0 0.048 0.000
#> SRR1562726     2  0.1075      0.979 0.000 0.952  0  0 0.048 0.000
#> SRR1562727     2  0.1075      0.979 0.000 0.952  0  0 0.048 0.000
#> SRR1562728     2  0.1075      0.979 0.000 0.952  0  0 0.048 0.000
#> SRR1562729     2  0.1075      0.979 0.000 0.952  0  0 0.048 0.000
#> SRR1562730     2  0.0146      0.960 0.000 0.996  0  0 0.000 0.004
#> SRR1562731     2  0.0146      0.960 0.000 0.996  0  0 0.000 0.004
#> SRR1562732     2  0.0146      0.960 0.000 0.996  0  0 0.000 0.004
#> SRR1562733     2  0.0146      0.960 0.000 0.996  0  0 0.000 0.004
#> SRR1562734     2  0.0146      0.960 0.000 0.996  0  0 0.000 0.004
#> SRR1562735     2  0.0146      0.960 0.000 0.996  0  0 0.000 0.004
#> SRR1562736     5  0.0000      0.961 0.000 0.000  0  0 1.000 0.000
#> SRR1562737     5  0.0000      0.961 0.000 0.000  0  0 1.000 0.000
#> SRR1562738     5  0.0000      0.961 0.000 0.000  0  0 1.000 0.000
#> SRR1562739     5  0.0000      0.961 0.000 0.000  0  0 1.000 0.000
#> SRR1562740     5  0.0000      0.961 0.000 0.000  0  0 1.000 0.000
#> SRR1562741     5  0.0000      0.961 0.000 0.000  0  0 1.000 0.000
#> SRR1562742     5  0.1204      0.961 0.000 0.056  0  0 0.944 0.000
#> SRR1562743     5  0.1204      0.961 0.000 0.056  0  0 0.944 0.000
#> SRR1562744     5  0.1204      0.961 0.000 0.056  0  0 0.944 0.000
#> SRR1562745     5  0.1204      0.961 0.000 0.056  0  0 0.944 0.000
#> SRR1562746     5  0.1204      0.961 0.000 0.056  0  0 0.944 0.000
#> SRR1562747     5  0.1204      0.961 0.000 0.056  0  0 0.944 0.000
#> SRR1562748     4  0.0000      1.000 0.000 0.000  0  1 0.000 0.000
#> SRR1562749     4  0.0000      1.000 0.000 0.000  0  1 0.000 0.000
#> SRR1562750     4  0.0000      1.000 0.000 0.000  0  1 0.000 0.000
#> SRR1562751     4  0.0000      1.000 0.000 0.000  0  1 0.000 0.000
#> SRR1562752     4  0.0000      1.000 0.000 0.000  0  1 0.000 0.000
#> SRR1562753     4  0.0000      1.000 0.000 0.000  0  1 0.000 0.000
#> SRR1562754     4  0.0000      1.000 0.000 0.000  0  1 0.000 0.000
#> SRR1562755     4  0.0000      1.000 0.000 0.000  0  1 0.000 0.000
#> SRR1562756     4  0.0000      1.000 0.000 0.000  0  1 0.000 0.000
#> SRR1562757     4  0.0000      1.000 0.000 0.000  0  1 0.000 0.000
#> SRR1562758     4  0.0000      1.000 0.000 0.000  0  1 0.000 0.000
#> SRR1562759     4  0.0000      1.000 0.000 0.000  0  1 0.000 0.000
#> SRR1562792     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1562793     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1562794     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1562795     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1562796     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1562797     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1562798     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1562799     3  0.0000      1.000 0.000 0.000  1  0 0.000 0.000
#> SRR1562800     6  0.0146      1.000 0.004 0.000  0  0 0.000 0.996
#> SRR1562801     6  0.0146      1.000 0.004 0.000  0  0 0.000 0.996
#> SRR1562802     6  0.0146      1.000 0.004 0.000  0  0 0.000 0.996
#> SRR1562803     6  0.0146      1.000 0.004 0.000  0  0 0.000 0.996
#> SRR1562804     6  0.0146      1.000 0.004 0.000  0  0 0.000 0.996
#> SRR1562805     6  0.0146      1.000 0.004 0.000  0  0 0.000 0.996
#> SRR1562806     1  0.0000      1.000 1.000 0.000  0  0 0.000 0.000
#> SRR1562807     1  0.0000      1.000 1.000 0.000  0  0 0.000 0.000
#> SRR1562808     1  0.0000      1.000 1.000 0.000  0  0 0.000 0.000
#> SRR1562809     1  0.0000      1.000 1.000 0.000  0  0 0.000 0.000
#> SRR1562810     1  0.0000      1.000 1.000 0.000  0  0 0.000 0.000
#> SRR1562811     1  0.0000      1.000 1.000 0.000  0  0 0.000 0.000
#> SRR1562812     1  0.0000      1.000 1.000 0.000  0  0 0.000 0.000
#> SRR1562813     1  0.0000      1.000 1.000 0.000  0  0 0.000 0.000

Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.

consensus_heatmap(res, k = 2)

plot of chunk tab-ATC-mclust-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-ATC-mclust-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-ATC-mclust-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-ATC-mclust-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-ATC-mclust-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-ATC-mclust-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-ATC-mclust-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-ATC-mclust-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-ATC-mclust-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-ATC-mclust-membership-heatmap-5

As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

plot of chunk tab-ATC-mclust-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-ATC-mclust-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-ATC-mclust-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-ATC-mclust-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-ATC-mclust-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-ATC-mclust-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-ATC-mclust-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-ATC-mclust-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-ATC-mclust-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-ATC-mclust-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-mclust-signature_compare

get_signature() returns a data frame invisibly. TO get the list of signatures, the function call should be assigned to a variable explicitly. In following code, if plot argument is set to FALSE, no heatmap is plotted while only the differential analysis is performed.

# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)

An example of the output of tb is:

#>   which_row         fdr    mean_1    mean_2 scaled_mean_1 scaled_mean_2 km
#> 1        38 0.042760348  8.373488  9.131774    -0.5533452     0.5164555  1
#> 2        40 0.018707592  7.106213  8.469186    -0.6173731     0.5762149  1
#> 3        55 0.019134737 10.221463 11.207825    -0.6159697     0.5749050  1
#> 4        59 0.006059896  5.921854  7.869574    -0.6899429     0.6439467  1
#> 5        60 0.018055526  8.928898 10.211722    -0.6204761     0.5791110  1
#> 6        98 0.009384629 15.714769 14.887706     0.6635654    -0.6193277  2
...

The columns in tb are:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. km: Row groups if k-means clustering is applied to rows.

UMAP plot which shows how samples are separated.

dimension_reduction(res, k = 2, method = "UMAP")

plot of chunk tab-ATC-mclust-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-ATC-mclust-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-ATC-mclust-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-ATC-mclust-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-ATC-mclust-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-mclust-collect-classes

If matrix rows can be associated to genes, consider to use functional_enrichment(res, ...) to perform function enrichment for the signature genes. See this vignette for more detailed explanations.


ATC:NMF**

The object with results only for a single top-value method and a single partition method can be extracted as:

res = res_list["ATC", "NMF"]
# you can also extract it by
# res = res_list["ATC:NMF"]

A summary of res and all the functions that can be applied to it:

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 15301 rows and 63 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#>   Subgroups are detected by 'NMF' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

collect_plots() function collects all the plots made from res for all k (number of partitions) into one single page to provide an easy and fast comparison between different k.

collect_plots(res)

plot of chunk ATC-NMF-collect-plots

The plots are:

All the plots in panels can be made by individual functions and they are plotted later in this section.

select_partition_number() produces several plots showing different statistics for choosing “optimized” k. There are following statistics:

The detailed explanations of these statistics can be found in the cola vignette.

Generally speaking, lower PAC score, higher mean silhouette score or higher concordance corresponds to better partition. Rand index and Jaccard index measure how similar the current partition is compared to partition with k-1. If they are too similar, we won't accept k is better than k-1.

select_partition_number(res)

plot of chunk ATC-NMF-select-partition-number

The numeric values for all these statistics can be obtained by get_stats().

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4624 0.538   0.538
#> 3 3 0.726           0.927       0.875         0.1893 0.943   0.893
#> 4 4 0.736           0.890       0.877         0.2267 0.788   0.559
#> 5 5 0.788           0.755       0.819         0.1216 0.874   0.588
#> 6 6 0.793           0.839       0.854         0.0528 0.945   0.765

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
#> SRR1562718     2       0          1  0  1
#> SRR1562719     2       0          1  0  1
#> SRR1562720     2       0          1  0  1
#> SRR1562721     2       0          1  0  1
#> SRR1562723     2       0          1  0  1
#> SRR1562724     2       0          1  0  1
#> SRR1562725     2       0          1  0  1
#> SRR1562726     2       0          1  0  1
#> SRR1562727     2       0          1  0  1
#> SRR1562728     2       0          1  0  1
#> SRR1562729     2       0          1  0  1
#> SRR1562730     2       0          1  0  1
#> SRR1562731     2       0          1  0  1
#> SRR1562732     2       0          1  0  1
#> SRR1562733     2       0          1  0  1
#> SRR1562734     2       0          1  0  1
#> SRR1562735     2       0          1  0  1
#> SRR1562736     2       0          1  0  1
#> SRR1562737     2       0          1  0  1
#> SRR1562738     2       0          1  0  1
#> SRR1562739     2       0          1  0  1
#> SRR1562740     2       0          1  0  1
#> SRR1562741     2       0          1  0  1
#> SRR1562742     2       0          1  0  1
#> SRR1562743     2       0          1  0  1
#> SRR1562744     2       0          1  0  1
#> SRR1562745     2       0          1  0  1
#> SRR1562746     2       0          1  0  1
#> SRR1562747     2       0          1  0  1
#> SRR1562748     2       0          1  0  1
#> SRR1562749     2       0          1  0  1
#> SRR1562750     2       0          1  0  1
#> SRR1562751     2       0          1  0  1
#> SRR1562752     2       0          1  0  1
#> SRR1562753     2       0          1  0  1
#> SRR1562754     2       0          1  0  1
#> SRR1562755     2       0          1  0  1
#> SRR1562756     2       0          1  0  1
#> SRR1562757     2       0          1  0  1
#> SRR1562758     2       0          1  0  1
#> SRR1562759     2       0          1  0  1
#> SRR1562792     1       0          1  1  0
#> SRR1562793     1       0          1  1  0
#> SRR1562794     1       0          1  1  0
#> SRR1562795     1       0          1  1  0
#> SRR1562796     1       0          1  1  0
#> SRR1562797     1       0          1  1  0
#> SRR1562798     1       0          1  1  0
#> SRR1562799     1       0          1  1  0
#> SRR1562800     1       0          1  1  0
#> SRR1562801     1       0          1  1  0
#> SRR1562802     1       0          1  1  0
#> SRR1562803     1       0          1  1  0
#> SRR1562804     1       0          1  1  0
#> SRR1562805     1       0          1  1  0
#> SRR1562806     1       0          1  1  0
#> SRR1562807     1       0          1  1  0
#> SRR1562808     1       0          1  1  0
#> SRR1562809     1       0          1  1  0
#> SRR1562810     1       0          1  1  0
#> SRR1562811     1       0          1  1  0
#> SRR1562812     1       0          1  1  0
#> SRR1562813     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>            class entropy silhouette    p1    p2    p3
#> SRR1562718     2  0.2261      0.896 0.068 0.932 0.000
#> SRR1562719     2  0.2261      0.896 0.068 0.932 0.000
#> SRR1562720     2  0.2261      0.896 0.068 0.932 0.000
#> SRR1562721     2  0.2261      0.896 0.068 0.932 0.000
#> SRR1562723     2  0.2261      0.896 0.068 0.932 0.000
#> SRR1562724     2  0.2261      0.896 0.068 0.932 0.000
#> SRR1562725     2  0.2261      0.896 0.068 0.932 0.000
#> SRR1562726     2  0.2261      0.896 0.068 0.932 0.000
#> SRR1562727     2  0.2261      0.896 0.068 0.932 0.000
#> SRR1562728     2  0.2261      0.896 0.068 0.932 0.000
#> SRR1562729     2  0.2261      0.896 0.068 0.932 0.000
#> SRR1562730     2  0.2261      0.896 0.068 0.932 0.000
#> SRR1562731     2  0.2261      0.896 0.068 0.932 0.000
#> SRR1562732     2  0.2261      0.896 0.068 0.932 0.000
#> SRR1562733     2  0.2261      0.896 0.068 0.932 0.000
#> SRR1562734     2  0.2261      0.896 0.068 0.932 0.000
#> SRR1562735     2  0.2261      0.896 0.068 0.932 0.000
#> SRR1562736     2  0.3482      0.888 0.128 0.872 0.000
#> SRR1562737     2  0.3551      0.887 0.132 0.868 0.000
#> SRR1562738     2  0.3482      0.888 0.128 0.872 0.000
#> SRR1562739     2  0.3192      0.892 0.112 0.888 0.000
#> SRR1562740     2  0.3619      0.886 0.136 0.864 0.000
#> SRR1562741     2  0.3192      0.892 0.112 0.888 0.000
#> SRR1562742     2  0.1753      0.900 0.048 0.952 0.000
#> SRR1562743     2  0.0000      0.901 0.000 1.000 0.000
#> SRR1562744     2  0.0237      0.901 0.004 0.996 0.000
#> SRR1562745     2  0.1031      0.901 0.024 0.976 0.000
#> SRR1562746     2  0.0592      0.901 0.012 0.988 0.000
#> SRR1562747     2  0.0592      0.900 0.012 0.988 0.000
#> SRR1562748     2  0.4452      0.868 0.192 0.808 0.000
#> SRR1562749     2  0.4452      0.868 0.192 0.808 0.000
#> SRR1562750     2  0.4452      0.868 0.192 0.808 0.000
#> SRR1562751     2  0.4452      0.868 0.192 0.808 0.000
#> SRR1562752     2  0.4452      0.868 0.192 0.808 0.000
#> SRR1562753     2  0.4452      0.868 0.192 0.808 0.000
#> SRR1562754     2  0.4452      0.868 0.192 0.808 0.000
#> SRR1562755     2  0.4452      0.868 0.192 0.808 0.000
#> SRR1562756     2  0.4452      0.868 0.192 0.808 0.000
#> SRR1562757     2  0.4452      0.868 0.192 0.808 0.000
#> SRR1562758     2  0.4452      0.868 0.192 0.808 0.000
#> SRR1562759     2  0.4452      0.868 0.192 0.808 0.000
#> SRR1562792     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1562793     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1562794     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1562795     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1562796     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1562797     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1562798     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1562799     3  0.0000      1.000 0.000 0.000 1.000
#> SRR1562800     1  0.6095      1.000 0.608 0.000 0.392
#> SRR1562801     1  0.6095      1.000 0.608 0.000 0.392
#> SRR1562802     1  0.6095      1.000 0.608 0.000 0.392
#> SRR1562803     1  0.6095      1.000 0.608 0.000 0.392
#> SRR1562804     1  0.6095      1.000 0.608 0.000 0.392
#> SRR1562805     1  0.6095      1.000 0.608 0.000 0.392
#> SRR1562806     1  0.6095      1.000 0.608 0.000 0.392
#> SRR1562807     1  0.6095      1.000 0.608 0.000 0.392
#> SRR1562808     1  0.6095      1.000 0.608 0.000 0.392
#> SRR1562809     1  0.6095      1.000 0.608 0.000 0.392
#> SRR1562810     1  0.6095      1.000 0.608 0.000 0.392
#> SRR1562811     1  0.6095      1.000 0.608 0.000 0.392
#> SRR1562812     1  0.6095      1.000 0.608 0.000 0.392
#> SRR1562813     1  0.6095      1.000 0.608 0.000 0.392

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>            class entropy silhouette    p1    p2    p3    p4
#> SRR1562718     2  0.0188      0.923 0.000 0.996 0.000 0.004
#> SRR1562719     2  0.0188      0.923 0.000 0.996 0.000 0.004
#> SRR1562720     2  0.0188      0.923 0.000 0.996 0.000 0.004
#> SRR1562721     2  0.0188      0.923 0.000 0.996 0.000 0.004
#> SRR1562723     2  0.0188      0.923 0.000 0.996 0.000 0.004
#> SRR1562724     2  0.0000      0.924 0.000 1.000 0.000 0.000
#> SRR1562725     2  0.0000      0.924 0.000 1.000 0.000 0.000
#> SRR1562726     2  0.0000      0.924 0.000 1.000 0.000 0.000
#> SRR1562727     2  0.0000      0.924 0.000 1.000 0.000 0.000
#> SRR1562728     2  0.0000      0.924 0.000 1.000 0.000 0.000
#> SRR1562729     2  0.0000      0.924 0.000 1.000 0.000 0.000
#> SRR1562730     2  0.0000      0.924 0.000 1.000 0.000 0.000
#> SRR1562731     2  0.0000      0.924 0.000 1.000 0.000 0.000
#> SRR1562732     2  0.0000      0.924 0.000 1.000 0.000 0.000
#> SRR1562733     2  0.0000      0.924 0.000 1.000 0.000 0.000
#> SRR1562734     2  0.0000      0.924 0.000 1.000 0.000 0.000
#> SRR1562735     2  0.0000      0.924 0.000 1.000 0.000 0.000
#> SRR1562736     4  0.5815      0.666 0.000 0.428 0.032 0.540
#> SRR1562737     4  0.5808      0.672 0.000 0.424 0.032 0.544
#> SRR1562738     4  0.5838      0.635 0.000 0.444 0.032 0.524
#> SRR1562739     4  0.5859      0.573 0.000 0.472 0.032 0.496
#> SRR1562740     4  0.5800      0.678 0.000 0.420 0.032 0.548
#> SRR1562741     4  0.5853      0.605 0.000 0.460 0.032 0.508
#> SRR1562742     2  0.4745      0.595 0.000 0.756 0.036 0.208
#> SRR1562743     2  0.3787      0.767 0.000 0.840 0.036 0.124
#> SRR1562744     2  0.4050      0.736 0.000 0.820 0.036 0.144
#> SRR1562745     2  0.4290      0.699 0.000 0.800 0.036 0.164
#> SRR1562746     2  0.4197      0.716 0.000 0.808 0.036 0.156
#> SRR1562747     2  0.3731      0.772 0.000 0.844 0.036 0.120
#> SRR1562748     4  0.4319      0.870 0.000 0.228 0.012 0.760
#> SRR1562749     4  0.4319      0.870 0.000 0.228 0.012 0.760
#> SRR1562750     4  0.4319      0.870 0.000 0.228 0.012 0.760
#> SRR1562751     4  0.4319      0.870 0.000 0.228 0.012 0.760
#> SRR1562752     4  0.4319      0.870 0.000 0.228 0.012 0.760
#> SRR1562753     4  0.4319      0.870 0.000 0.228 0.012 0.760
#> SRR1562754     4  0.3873      0.871 0.000 0.228 0.000 0.772
#> SRR1562755     4  0.3873      0.871 0.000 0.228 0.000 0.772
#> SRR1562756     4  0.3873      0.871 0.000 0.228 0.000 0.772
#> SRR1562757     4  0.3873      0.871 0.000 0.228 0.000 0.772
#> SRR1562758     4  0.3873      0.871 0.000 0.228 0.000 0.772
#> SRR1562759     4  0.3873      0.871 0.000 0.228 0.000 0.772
#> SRR1562792     3  0.2676      0.995 0.092 0.000 0.896 0.012
#> SRR1562793     3  0.2676      0.995 0.092 0.000 0.896 0.012
#> SRR1562794     3  0.2676      0.995 0.092 0.000 0.896 0.012
#> SRR1562795     3  0.2676      0.995 0.092 0.000 0.896 0.012
#> SRR1562796     3  0.2216      0.995 0.092 0.000 0.908 0.000
#> SRR1562797     3  0.2216      0.995 0.092 0.000 0.908 0.000
#> SRR1562798     3  0.2216      0.995 0.092 0.000 0.908 0.000
#> SRR1562799     3  0.2216      0.995 0.092 0.000 0.908 0.000
#> SRR1562800     1  0.0779      0.989 0.980 0.000 0.004 0.016
#> SRR1562801     1  0.0779      0.989 0.980 0.000 0.004 0.016
#> SRR1562802     1  0.0779      0.989 0.980 0.000 0.004 0.016
#> SRR1562803     1  0.0779      0.989 0.980 0.000 0.004 0.016
#> SRR1562804     1  0.0779      0.989 0.980 0.000 0.004 0.016
#> SRR1562805     1  0.0779      0.989 0.980 0.000 0.004 0.016
#> SRR1562806     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> SRR1562807     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> SRR1562808     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> SRR1562809     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> SRR1562810     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> SRR1562811     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> SRR1562812     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> SRR1562813     1  0.0000      0.992 1.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>            class entropy silhouette    p1    p2    p3    p4    p5
#> SRR1562718     2  0.0703      0.951 0.000 0.976 0.000 0.000 0.024
#> SRR1562719     2  0.0703      0.951 0.000 0.976 0.000 0.000 0.024
#> SRR1562720     2  0.0794      0.948 0.000 0.972 0.000 0.000 0.028
#> SRR1562721     2  0.0703      0.951 0.000 0.976 0.000 0.000 0.024
#> SRR1562723     2  0.0794      0.948 0.000 0.972 0.000 0.000 0.028
#> SRR1562724     2  0.0404      0.955 0.000 0.988 0.000 0.000 0.012
#> SRR1562725     2  0.0290      0.955 0.000 0.992 0.000 0.000 0.008
#> SRR1562726     2  0.0290      0.955 0.000 0.992 0.000 0.000 0.008
#> SRR1562727     2  0.0510      0.954 0.000 0.984 0.000 0.000 0.016
#> SRR1562728     2  0.0404      0.955 0.000 0.988 0.000 0.000 0.012
#> SRR1562729     2  0.0290      0.955 0.000 0.992 0.000 0.000 0.008
#> SRR1562730     2  0.1845      0.929 0.000 0.928 0.000 0.016 0.056
#> SRR1562731     2  0.1845      0.929 0.000 0.928 0.000 0.016 0.056
#> SRR1562732     2  0.1943      0.927 0.000 0.924 0.000 0.020 0.056
#> SRR1562733     2  0.1845      0.929 0.000 0.928 0.000 0.016 0.056
#> SRR1562734     2  0.1845      0.929 0.000 0.928 0.000 0.016 0.056
#> SRR1562735     2  0.1845      0.929 0.000 0.928 0.000 0.016 0.056
#> SRR1562736     5  0.3300      0.600 0.000 0.204 0.000 0.004 0.792
#> SRR1562737     5  0.3462      0.594 0.000 0.196 0.000 0.012 0.792
#> SRR1562738     5  0.3300      0.599 0.000 0.204 0.000 0.004 0.792
#> SRR1562739     5  0.3398      0.601 0.000 0.216 0.000 0.004 0.780
#> SRR1562740     5  0.3391      0.587 0.000 0.188 0.000 0.012 0.800
#> SRR1562741     5  0.3496      0.594 0.000 0.200 0.000 0.012 0.788
#> SRR1562742     5  0.3876      0.600 0.000 0.316 0.000 0.000 0.684
#> SRR1562743     5  0.4060      0.573 0.000 0.360 0.000 0.000 0.640
#> SRR1562744     5  0.4045      0.579 0.000 0.356 0.000 0.000 0.644
#> SRR1562745     5  0.3966      0.596 0.000 0.336 0.000 0.000 0.664
#> SRR1562746     5  0.4015      0.591 0.000 0.348 0.000 0.000 0.652
#> SRR1562747     5  0.4060      0.573 0.000 0.360 0.000 0.000 0.640
#> SRR1562748     4  0.4288      1.000 0.000 0.012 0.000 0.664 0.324
#> SRR1562749     4  0.4288      1.000 0.000 0.012 0.000 0.664 0.324
#> SRR1562750     4  0.4288      1.000 0.000 0.012 0.000 0.664 0.324
#> SRR1562751     4  0.4288      1.000 0.000 0.012 0.000 0.664 0.324
#> SRR1562752     4  0.4288      1.000 0.000 0.012 0.000 0.664 0.324
#> SRR1562753     4  0.4288      1.000 0.000 0.012 0.000 0.664 0.324
#> SRR1562754     5  0.4658     -0.554 0.000 0.012 0.000 0.484 0.504
#> SRR1562755     5  0.4637     -0.471 0.000 0.012 0.000 0.452 0.536
#> SRR1562756     5  0.4644     -0.489 0.000 0.012 0.000 0.460 0.528
#> SRR1562757     5  0.4644     -0.490 0.000 0.012 0.000 0.460 0.528
#> SRR1562758     5  0.4656     -0.542 0.000 0.012 0.000 0.480 0.508
#> SRR1562759     5  0.4648     -0.500 0.000 0.012 0.000 0.464 0.524
#> SRR1562792     3  0.1270      0.999 0.052 0.000 0.948 0.000 0.000
#> SRR1562793     3  0.1270      0.999 0.052 0.000 0.948 0.000 0.000
#> SRR1562794     3  0.1270      0.999 0.052 0.000 0.948 0.000 0.000
#> SRR1562795     3  0.1270      0.999 0.052 0.000 0.948 0.000 0.000
#> SRR1562796     3  0.1430      0.999 0.052 0.000 0.944 0.000 0.004
#> SRR1562797     3  0.1430      0.999 0.052 0.000 0.944 0.000 0.004
#> SRR1562798     3  0.1430      0.999 0.052 0.000 0.944 0.000 0.004
#> SRR1562799     3  0.1430      0.999 0.052 0.000 0.944 0.000 0.004
#> SRR1562800     1  0.2006      0.955 0.916 0.000 0.000 0.072 0.012
#> SRR1562801     1  0.2006      0.955 0.916 0.000 0.000 0.072 0.012
#> SRR1562802     1  0.2006      0.955 0.916 0.000 0.000 0.072 0.012
#> SRR1562803     1  0.2006      0.955 0.916 0.000 0.000 0.072 0.012
#> SRR1562804     1  0.2069      0.953 0.912 0.000 0.000 0.076 0.012
#> SRR1562805     1  0.2069      0.953 0.912 0.000 0.000 0.076 0.012
#> SRR1562806     1  0.0000      0.966 1.000 0.000 0.000 0.000 0.000
#> SRR1562807     1  0.0000      0.966 1.000 0.000 0.000 0.000 0.000
#> SRR1562808     1  0.0000      0.966 1.000 0.000 0.000 0.000 0.000
#> SRR1562809     1  0.0000      0.966 1.000 0.000 0.000 0.000 0.000
#> SRR1562810     1  0.0000      0.966 1.000 0.000 0.000 0.000 0.000
#> SRR1562811     1  0.0000      0.966 1.000 0.000 0.000 0.000 0.000
#> SRR1562812     1  0.0000      0.966 1.000 0.000 0.000 0.000 0.000
#> SRR1562813     1  0.0000      0.966 1.000 0.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>            class entropy silhouette    p1    p2    p3    p4    p5 p6
#> SRR1562718     2  0.1908      0.829 0.000 0.900 0.000 0.004 0.096 NA
#> SRR1562719     2  0.1714      0.834 0.000 0.908 0.000 0.000 0.092 NA
#> SRR1562720     2  0.1765      0.832 0.000 0.904 0.000 0.000 0.096 NA
#> SRR1562721     2  0.1610      0.836 0.000 0.916 0.000 0.000 0.084 NA
#> SRR1562723     2  0.2053      0.819 0.000 0.888 0.000 0.000 0.108 NA
#> SRR1562724     2  0.1858      0.832 0.000 0.904 0.000 0.004 0.092 NA
#> SRR1562725     2  0.1897      0.836 0.000 0.908 0.000 0.004 0.084 NA
#> SRR1562726     2  0.1753      0.836 0.000 0.912 0.000 0.004 0.084 NA
#> SRR1562727     2  0.1806      0.834 0.000 0.908 0.000 0.004 0.088 NA
#> SRR1562728     2  0.1949      0.835 0.000 0.904 0.000 0.004 0.088 NA
#> SRR1562729     2  0.1897      0.836 0.000 0.908 0.000 0.004 0.084 NA
#> SRR1562730     2  0.3705      0.730 0.000 0.740 0.000 0.020 0.004 NA
#> SRR1562731     2  0.3731      0.727 0.000 0.736 0.000 0.020 0.004 NA
#> SRR1562732     2  0.3705      0.730 0.000 0.740 0.000 0.020 0.004 NA
#> SRR1562733     2  0.3670      0.727 0.000 0.736 0.000 0.024 0.000 NA
#> SRR1562734     2  0.3758      0.730 0.000 0.740 0.000 0.024 0.004 NA
#> SRR1562735     2  0.3622      0.732 0.000 0.744 0.000 0.016 0.004 NA
#> SRR1562736     5  0.4541      0.811 0.000 0.208 0.000 0.072 0.708 NA
#> SRR1562737     5  0.4308      0.818 0.000 0.196 0.000 0.068 0.728 NA
#> SRR1562738     5  0.4744      0.798 0.000 0.224 0.000 0.080 0.684 NA
#> SRR1562739     5  0.4745      0.797 0.000 0.232 0.000 0.076 0.680 NA
#> SRR1562740     5  0.4688      0.805 0.000 0.208 0.000 0.084 0.696 NA
#> SRR1562741     5  0.4591      0.811 0.000 0.208 0.000 0.076 0.704 NA
#> SRR1562742     5  0.2209      0.823 0.000 0.072 0.000 0.004 0.900 NA
#> SRR1562743     5  0.2265      0.825 0.000 0.076 0.000 0.004 0.896 NA
#> SRR1562744     5  0.2265      0.825 0.000 0.076 0.000 0.004 0.896 NA
#> SRR1562745     5  0.2182      0.825 0.000 0.076 0.000 0.004 0.900 NA
#> SRR1562746     5  0.2126      0.824 0.000 0.072 0.000 0.004 0.904 NA
#> SRR1562747     5  0.2373      0.821 0.000 0.084 0.000 0.004 0.888 NA
#> SRR1562748     4  0.1141      0.781 0.000 0.000 0.000 0.948 0.052 NA
#> SRR1562749     4  0.1141      0.781 0.000 0.000 0.000 0.948 0.052 NA
#> SRR1562750     4  0.1141      0.781 0.000 0.000 0.000 0.948 0.052 NA
#> SRR1562751     4  0.1141      0.781 0.000 0.000 0.000 0.948 0.052 NA
#> SRR1562752     4  0.1141      0.781 0.000 0.000 0.000 0.948 0.052 NA
#> SRR1562753     4  0.1141      0.781 0.000 0.000 0.000 0.948 0.052 NA
#> SRR1562754     4  0.4854      0.723 0.000 0.016 0.000 0.612 0.328 NA
#> SRR1562755     4  0.5103      0.710 0.000 0.028 0.000 0.592 0.336 NA
#> SRR1562756     4  0.5103      0.712 0.000 0.028 0.000 0.592 0.336 NA
#> SRR1562757     4  0.5116      0.706 0.000 0.028 0.000 0.588 0.340 NA
#> SRR1562758     4  0.5049      0.723 0.000 0.028 0.000 0.608 0.320 NA
#> SRR1562759     4  0.5077      0.718 0.000 0.028 0.000 0.600 0.328 NA
#> SRR1562792     3  0.0458      0.995 0.016 0.000 0.984 0.000 0.000 NA
#> SRR1562793     3  0.0547      0.997 0.020 0.000 0.980 0.000 0.000 NA
#> SRR1562794     3  0.0458      0.995 0.016 0.000 0.984 0.000 0.000 NA
#> SRR1562795     3  0.0547      0.997 0.020 0.000 0.980 0.000 0.000 NA
#> SRR1562796     3  0.0806      0.996 0.020 0.000 0.972 0.000 0.000 NA
#> SRR1562797     3  0.0692      0.997 0.020 0.000 0.976 0.000 0.000 NA
#> SRR1562798     3  0.0692      0.997 0.020 0.000 0.976 0.000 0.000 NA
#> SRR1562799     3  0.0692      0.997 0.020 0.000 0.976 0.000 0.000 NA
#> SRR1562800     1  0.3345      0.874 0.776 0.000 0.020 0.000 0.000 NA
#> SRR1562801     1  0.3345      0.874 0.776 0.000 0.020 0.000 0.000 NA
#> SRR1562802     1  0.3073      0.879 0.788 0.000 0.008 0.000 0.000 NA
#> SRR1562803     1  0.3073      0.879 0.788 0.000 0.008 0.000 0.000 NA
#> SRR1562804     1  0.3248      0.872 0.768 0.000 0.004 0.000 0.004 NA
#> SRR1562805     1  0.3248      0.872 0.768 0.000 0.004 0.000 0.004 NA
#> SRR1562806     1  0.0146      0.912 0.996 0.000 0.000 0.000 0.000 NA
#> SRR1562807     1  0.0146      0.912 0.996 0.000 0.000 0.000 0.000 NA
#> SRR1562808     1  0.0000      0.914 1.000 0.000 0.000 0.000 0.000 NA
#> SRR1562809     1  0.0000      0.914 1.000 0.000 0.000 0.000 0.000 NA
#> SRR1562810     1  0.0000      0.914 1.000 0.000 0.000 0.000 0.000 NA
#> SRR1562811     1  0.0000      0.914 1.000 0.000 0.000 0.000 0.000 NA
#> SRR1562812     1  0.0000      0.914 1.000 0.000 0.000 0.000 0.000 NA
#> SRR1562813     1  0.0000      0.914 1.000 0.000 0.000 0.000 0.000 NA

Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.

consensus_heatmap(res, k = 2)

plot of chunk tab-ATC-NMF-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-ATC-NMF-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-ATC-NMF-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-ATC-NMF-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-ATC-NMF-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-ATC-NMF-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-ATC-NMF-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-ATC-NMF-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-ATC-NMF-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-ATC-NMF-membership-heatmap-5

As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

plot of chunk tab-ATC-NMF-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-ATC-NMF-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-ATC-NMF-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-ATC-NMF-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-ATC-NMF-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-ATC-NMF-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-ATC-NMF-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-ATC-NMF-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-ATC-NMF-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-ATC-NMF-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-NMF-signature_compare

get_signature() returns a data frame invisibly. TO get the list of signatures, the function call should be assigned to a variable explicitly. In following code, if plot argument is set to FALSE, no heatmap is plotted while only the differential analysis is performed.

# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)

An example of the output of tb is:

#>   which_row         fdr    mean_1    mean_2 scaled_mean_1 scaled_mean_2 km
#> 1        38 0.042760348  8.373488  9.131774    -0.5533452     0.5164555  1
#> 2        40 0.018707592  7.106213  8.469186    -0.6173731     0.5762149  1
#> 3        55 0.019134737 10.221463 11.207825    -0.6159697     0.5749050  1
#> 4        59 0.006059896  5.921854  7.869574    -0.6899429     0.6439467  1
#> 5        60 0.018055526  8.928898 10.211722    -0.6204761     0.5791110  1
#> 6        98 0.009384629 15.714769 14.887706     0.6635654    -0.6193277  2
...

The columns in tb are:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. km: Row groups if k-means clustering is applied to rows.

UMAP plot which shows how samples are separated.

dimension_reduction(res, k = 2, method = "UMAP")

plot of chunk tab-ATC-NMF-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-ATC-NMF-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-ATC-NMF-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-ATC-NMF-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-ATC-NMF-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-NMF-collect-classes

If matrix rows can be associated to genes, consider to use functional_enrichment(res, ...) to perform function enrichment for the signature genes. See this vignette for more detailed explanations.

Session info

sessionInfo()
#> R version 3.6.0 (2019-04-26)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: CentOS Linux 7 (Core)
#> 
#> Matrix products: default
#> BLAS:   /usr/lib64/libblas.so.3.4.2
#> LAPACK: /usr/lib64/liblapack.so.3.4.2
#> 
#> locale:
#>  [1] LC_CTYPE=en_GB.UTF-8       LC_NUMERIC=C               LC_TIME=en_GB.UTF-8       
#>  [4] LC_COLLATE=en_GB.UTF-8     LC_MONETARY=en_GB.UTF-8    LC_MESSAGES=en_GB.UTF-8   
#>  [7] LC_PAPER=en_GB.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
#> [10] LC_TELEPHONE=C             LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C       
#> 
#> attached base packages:
#> [1] grid      stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] genefilter_1.66.0    ComplexHeatmap_2.3.1 markdown_1.1         knitr_1.26          
#> [5] GetoptLong_0.1.7     cola_1.3.2          
#> 
#> loaded via a namespace (and not attached):
#>  [1] circlize_0.4.8       shape_1.4.4          xfun_0.11            slam_0.1-46         
#>  [5] lattice_0.20-38      splines_3.6.0        colorspace_1.4-1     vctrs_0.2.0         
#>  [9] stats4_3.6.0         blob_1.2.0           XML_3.98-1.20        survival_2.44-1.1   
#> [13] rlang_0.4.2          pillar_1.4.2         DBI_1.0.0            BiocGenerics_0.30.0 
#> [17] bit64_0.9-7          RColorBrewer_1.1-2   matrixStats_0.55.0   stringr_1.4.0       
#> [21] GlobalOptions_0.1.1  evaluate_0.14        memoise_1.1.0        Biobase_2.44.0      
#> [25] IRanges_2.18.3       parallel_3.6.0       AnnotationDbi_1.46.1 highr_0.8           
#> [29] Rcpp_1.0.3           xtable_1.8-4         backports_1.1.5      S4Vectors_0.22.1    
#> [33] annotate_1.62.0      skmeans_0.2-11       bit_1.1-14           microbenchmark_1.4-7
#> [37] brew_1.0-6           impute_1.58.0        rjson_0.2.20         png_0.1-7           
#> [41] digest_0.6.23        stringi_1.4.3        polyclip_1.10-0      clue_0.3-57         
#> [45] tools_3.6.0          bitops_1.0-6         magrittr_1.5         eulerr_6.0.0        
#> [49] RCurl_1.95-4.12      RSQLite_2.1.4        tibble_2.1.3         cluster_2.1.0       
#> [53] crayon_1.3.4         pkgconfig_2.0.3      zeallot_0.1.0        Matrix_1.2-17       
#> [57] xml2_1.2.2           httr_1.4.1           R6_2.4.1             mclust_5.4.5        
#> [61] compiler_3.6.0