Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 | 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 2x 2x 2x 2x 2x 2x 2x 2x 2x 284x 284x 284x 284x 255x 255x 28x 28x 28x 284x 284x 2x 2x 2x 2x | /**
* The 1D metaplot, as a descriptor.
*
* The first task in the catalogue that touches no contact matrix at all: its
* inputs are tracks and a feature set, both of which already live in the
* annotations worker, which is why it declares `venue: 'annotations'` and costs
* no matrix reads whatever (§18.3).
*
* It is also the first with a **ranking and subsetting** control, and that
* control is the reason the task is worth having rather than a convenience. A
* single averaged line over four thousand features asserts that they behave
* alike; splitting them by a column and drawing one line per group is what makes
* that assertion falsifiable, and is what turns *here is the average signal at
* my peaks* into *the strongest quartile looks like this and the weakest looks
* like nothing*.
*/
import type { AnalysisContext, AnalysisTask, CostEstimate, ParamSpec, Params } from '../types'
import { READY, waitingFor } from '../types'
import { isIntervalSet } from '../../annotations/types'
const PARAMS: readonly ParamSpec[] = [
{
kind: 'track',
key: 'tracks',
label: 'tracks',
multiple: true,
},
{
kind: 'featureSet',
key: 'features',
label: 'features',
},
{
kind: 'choice',
key: 'mode',
label: 'mode',
default: 'reference',
options: [
{ value: 'reference', label: 'reference point', hint: 'A fixed flank around one point.' },
{ value: 'scaled', label: 'scaled region', hint: 'Every feature body resampled to one width.' },
],
},
{
kind: 'choice',
key: 'at',
label: 'anchor on',
default: 'start',
when: (params) => params.mode !== 'scaled',
options: [
{ value: 'start', label: 'start' },
{ value: 'centre', label: 'centre' },
{ value: 'end', label: 'end' },
],
},
// **Base pairs, and no bin count under either of them.** A metaplot reads
// tracks; a track has no bins of the map's (§18.2), and the flank a reader
// wants round a TSS is 2 kb whatever resolution some contact map beside it
// happens to be open at.
{
kind: 'number',
key: 'flank',
label: 'flank',
hint: 'Read this far either side of the anchor.',
default: 2000,
min: 0,
unit: 'bp',
},
{
kind: 'number',
key: 'step',
label: 'resolution',
hint: 'One column of the plot per this many base pairs.',
default: 50,
min: 1,
unit: 'bp',
},
{
kind: 'number',
key: 'body',
label: 'body columns',
default: 100,
min: 10,
integer: true,
when: (params) => params.mode === 'scaled',
},
{
kind: 'toggle',
key: 'stranded',
label: 'respect strand',
hint: 'A minus-strand feature is read right to left, or an asymmetric signal cancels itself.',
default: true,
},
{
kind: 'column',
key: 'rankBy',
label: 'rank by',
from: 'features',
optional: true,
noneLabel: 'Do not rank',
section: 'Ranking',
},
{
kind: 'choice',
key: 'subset',
label: 'then',
default: 'all',
when: (params) => typeof params.rankBy === 'string' && params.rankBy !== '',
options: [
{ value: 'all', label: 'one line', hint: 'Rank only; still one average.' },
{ value: 'top', label: 'top N' },
{ value: 'bottom', label: 'bottom N' },
{ value: 'groups', label: 'K groups', hint: 'One line per equal-sized group.' },
],
section: 'Ranking',
},
{
kind: 'number',
key: 'count',
label: 'N',
default: 500,
min: 1,
integer: true,
when: (params) => params.subset === 'top' || params.subset === 'bottom',
section: 'Ranking',
},
{
kind: 'number',
key: 'groups',
label: 'groups',
default: 4,
min: 2,
max: 10,
integer: true,
slider: true,
when: (params) => params.subset === 'groups',
section: 'Ranking',
},
{
// Before `average` rather than after it, because that is the order the two
// are applied in and the order they have to be read in: the rows are
// standardised, and *then* the summary is taken over the standardised
// values. Off by default — it changes the numbers of every figure it is on,
// so a stored recipe that never asked for it must come back unchanged.
kind: 'toggle',
key: 'zscore',
label: 'z-score tracks first',
hint:
'Centre and scale each track by its own mean and SD over this run’s windows, so tracks in ' +
'different units share one axis.',
default: false,
section: 'Summary',
},
{
kind: 'choice',
key: 'average',
label: 'average',
default: 'mean',
options: [
{ value: 'mean', label: 'mean' },
{ value: 'median', label: 'median' },
{ value: 'trimmed', label: 'trimmed' },
],
section: 'Summary',
},
{
kind: 'choice',
key: 'band',
label: 'band',
default: 'bootstrap',
options: [
{ value: 'bootstrap', label: 'bootstrap CI' },
{ value: 'sd', label: 'SD' },
{ value: 'none', label: 'none' },
],
section: 'Summary',
},
{
kind: 'number',
key: 'iterations',
label: 'bootstrap draws',
default: 200,
min: 20,
max: 2000,
integer: true,
when: (params) => params.band === 'bootstrap',
section: 'Summary',
},
{
kind: 'seed',
key: 'seed',
label: 'seed',
hint: 'The same seed gives the same band twice.',
default: 1,
when: (params) => params.band === 'bootstrap',
section: 'Summary',
},
{
kind: 'toggle',
key: 'heatmap',
label: 'per-feature heatmap',
hint: 'The mean of a bimodal set is a line that describes nothing.',
default: true,
section: 'Summary',
},
]
function estimate(_context: AnalysisContext, params: Params): CostEstimate {
const tracks = Array.isArray(params.tracks) ? params.tracks.length : params.tracks === null ? 0 : 1
if (tracks === 0) {
return {
class: 'free',
requests: 0,
bytes: 0,
note: 'Nothing to read.',
refusal: 'Choose at least one track to average.',
}
}
if (typeof params.features !== 'string' || params.features === '') {
return {
class: 'free',
requests: 0,
bytes: 0,
note: 'Nothing to read.',
refusal: 'Choose a feature set to average over.',
}
}
return {
class: 'bounded',
requests: null,
bytes: null,
note:
`No matrix reads at all: ${tracks} track${tracks === 1 ? '' : 's'} sampled in the ` +
'annotations worker, one batch per sequence.',
}
}
export const METAPLOT_TASK: AnalysisTask = {
id: 'metaplot',
title: 'Metaplot over a feature set',
blurb: 'Average track signal at a set of places, with a band and a heatmap.',
keywords: ['profile', 'aggregate', 'average', 'TSS', 'deeptools'],
group: '1d',
venue: 'annotations',
version: 1,
// Something to average, and somewhere to average it. **No map required** —
// this runs entirely on loaded tracks, so it is offered in a 1D browser
// session exactly as it is beside a map.
availability: (context) => {
const tracks = context.entries.some((entry) => entry.kind === 'track')
const sets = context.entries.some((entry) => isIntervalSet(entry.kind))
if (tracks && sets) return READY
if (!tracks && !sets) {
return waitingFor('Load a bigWig to average, and a BED or GTF of positions to average it at.')
}
return waitingFor(
tracks
? 'Load a BED or a GTF — the positions to average the track at.'
: 'Load a bigWig — the track to average.',
)
},
params: PARAMS,
outputs: ['curve', 'matrix'],
estimate,
}
|