Skip to content

Commit 52cbd19

Browse files
committed
Document heatmap clustering method
1 parent 98791df commit 52cbd19

File tree

5 files changed

+44
-18
lines changed

5 files changed

+44
-18
lines changed

R/heatmap.R

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,15 @@
33
#'
44
#' Produces a heatmap as a grid grob.
55
#'
6-
#' Clustering is performed using the "seriation" package, and is approximately a Travelling Salesman Problem ordering. If there are many features (more than a couple of thousand) clustering may be slow.
6+
#' This heatmap differs from other heatmaps in R in the method of clustering used:
77
#'
8-
#' @param y A matrix of expression levels, such as a transformed counts matrix.
8+
#' 1. The distances used are cosine distances (i.e. the magnitude of log fold changes is not important, only the pattern).
9+
#'
10+
#' 2. \code{hclust()} is used to produce a clustering, as normal.
11+
#'
12+
#' 3. Branches in the hierarchical clustering are flipped to minimize sharp changes between neighbours, using the seriation package's OLO (Optimal Leaf Ordering) method.
13+
#'
14+
#' @param y A matrix of expression levels, such as a transformed counts matrix as produced by \code{varistran::vst}.
915
#' @param cluster_samples Should samples (columns) be clustered?
1016
#' @param cluster_features Should features (rows) be clustered?
1117
#' @param sample_labels Names for each sample. If not given and y has column names, these will be used instead.
@@ -20,6 +26,15 @@
2026
#' Additionally $info$row_order will contain row ordering and $info$col_order will contain column ordering.
2127
#' @author Paul Harrison.
2228
#'
29+
#' @examples
30+
#'
31+
#' # Generate some random data.
32+
#' counts <- matrix(rnbinom(1000, size=1/0.01, mu=100), ncol=10)
33+
#'
34+
#' y <- varistran::vst(counts, cpm=TRUE)
35+
#' print( varistran::plot_heatmap(y, n=20) )
36+
#'
37+
#'
2338
#' @export
2439
plot_heatmap <- function(
2540
y,

R/plot.R

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -133,17 +133,13 @@ plot_stability <- function(y, x=NULL, design=NULL, bins=20) {
133133
#'
134134
#' Produce a ggplot object containing a biplot of expression data.
135135
#'
136-
#' Biplot based on the Singular Value Decomposition of the matrix x. The
137-
#' dimensions corresponding to the two largest singular values are shown.
136+
#' Biplot based on the Singular Value Decomposition of the matrix x, after subtracting row means. The dimensions corresponding to the two largest singular values are shown.
138137
#'
139138
#' Genes are shown in blue and samples in red.
140139
#'
141-
#' The dot product of the gene and sample vectors approximates the difference
142-
#' from the average expression level of that gene in that sample.
140+
#' The dot product of the gene and sample vectors approximates the difference from the average expression level of that gene in that sample.
143141
#'
144-
#' Sample points (red) are scaled to have the same variance in the two
145-
#' dimensions. Therefore the gene points (blue) may have greater variance along
146-
#' dimension 1 if dimension 1 explains more of the variance than dimension 2.
142+
#' Sample points (red) are scaled to have the same variance in the two dimensions. Therefore the gene points (blue) may have greater variance along dimension 1 if dimension 1 explains more of the variance than dimension 2.
147143
#'
148144
#' @param x Matrix of expression levels, with features (eg genes) as rows and
149145
#' samples as columns. For example, you could use the output of varistran::vst

_pkgdown.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ reference:
1313
contents:
1414
- vst
1515
- shiny_report
16+
- plot_stability
17+
- plot_biplot
18+
- plot_heatmap
1619

1720
- title: Support functions
1821
contents:

man/plot_biplot.Rd

Lines changed: 3 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/plot_heatmap.Rd

Lines changed: 18 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)