Skip to content

A heatmap of many samples

You have a value for many samples in windows along a genome: the depth of each sample, a copy number, a methylation level. What is known about each sample, its lineage or its country, is a different file, a sample sheet, which --traits draws beside these rows, or beside the tips of a tree.

karyon NC_000962.3 --heatmap depths.tsv --relative \
  --with-tree tree.nwk --label depth -o samples.svg

Forty samples in the order of a tree, each a row of cells along the chromosome, pale where the depth is usual: one clade has a blue cell where it lost a stretch, and three samples a pink one where they carry a stretch twice The same figure on the dark page

One row per sample and one cell per window, in the order of the tree's tips. --relative reads each sample against its own median, so 1× is its usual depth, drawn pale: a sample sequenced deeper is not a darker row, and what changed along the genome is what stands out, a loss in blue and a gain in pink. Here one clade lost a stretch, and three samples carry another twice.

NC_000962.3 is the place, the whole sequence; with no place, the table is laid across the whole genome as a bedGraph is, every sequence it names end to end in the order chromosomes are counted, so karyon --heatmap depths.tsv draws this one sequence too. A table of windows does not say how long the sequence is, so karyon draws as far as its last window. Where that window is cut short of the others, as bedtools makewindows and mosdepth --by cut the one at a sequence's end, that is the end; where every window is whole, karyon says it stopped there, and writing the span, as NC_000962.3:1-4,411,532, sets it yourself.

Your table

As bedtools unionbedg writes it: a sequence, a start and an end, counted from 0 as BED is, then one column per sample, named in the header.

bedtools unionbedg -header -names S01 S02 S03 -i S01.bg S02.bg S03.bg > depths.tsv

deepTools' multiBigwigSummary --outRawCounts writes the same shape, and is read too, as is the long form, a sequence, a start, an end, a sample and its value to a row.

Change it

To Write
The values as they are leave out --relative
Log ratios, read either side of nought --center 0 in place of --relative
What is known about each sample, beside the rows --traits samples.tsv
Thinner rows --row-height 6
One stretch of the genome NC_000962.3:1,300,000-1,600,000 as the place
Read several heatmaps off one colour scale, the gain ending at three times the usual depth --max 3 after --relative
Shade the stretch the clade lost, down the whole figure --shade NC_000962.3:1,400,001-1,500,000=lost

The example file: depths.tsv, with tree.nwk. Every option: karyon help heatmap, or the command line reference.