# MafColor

Auto-generated from the config schema in the source. See the [config guide](https://jbrowse.org/jb2/docs/config_guide) for concepts. Provided by the `maf` plugin. [View source](https://github.com/GMOD/jbrowse-components/blob/main/plugins/maf/src/LinearMafDisplay/mafColorConfigSchema.ts).

The MAF display's `encoding.color`: what fills each species row's aligned
cells, as alignments' `encoding.color` fills its reads. Unset, the theme's
match tone fills them, and the X-Y plot's bars take its one bar color.
`value` is a constant fill. `identity` paints the mean identity to the
reference along a ramp, from `scale.domainMin` 0 to `scale.domainMax` 1
along the `redgreyblue` scheme, as every display's identity does.
`refNameRank` paints each block by the rank of its source sequence within
the row, rank 0 being the sequence the row aligns most bases from, so a
rearranged block stands out. A string is the field. The mismatches and the
per-base layer draw over the fill: `alignments.mismatches` and
`alignments.bases`.

## Example usage

```js
{ type: 'LinearMafDisplay', encoding: { color: 'identity' } }
```

```js
{
  type: 'LinearMafDisplay',
  encoding: {
    color: { field: 'identity', scale: { domainMin: 0.7, scheme: 'viridis' } },
  },
}
```

```js
{ type: 'LinearMafDisplay', encoding: { color: { value: '#ccc' } } }
```

## Preset fields

A `field` named here paints through its own scale while `scale.type` is unset, and `range` and `names` index its levels in order while `domain` is unwritten.

| Field | Scale | Levels | Names | Other defaults |
| --- | --- | --- | --- | --- |
| `identity` | linear |  |  | `domainMin: 0`; `domainMax: 1`; `scheme: redgreyblue`; key "Per-base identity to reference" |
| `refNameRank` | ordinal | `0`, `1`, `2`, `3`, `4` | Main sequence, 2nd source, 3rd source, 4th source, Other source | `range`: `hsl(210, 55%, 55%)`, `hsl(28, 85%, 55%)`, `hsl(350, 70%, 57%)`, `hsl(275, 45%, 58%)`, `hsl(150, 45%, 42%)`; key "Source sequence" |

## Config slots

A setting written to it replaces it whole: a member left out returns to its default. Slot types (`fileLocation`, `frozen`, ...) are explained in the [config slot types reference](https://jbrowse.org/jb2/docs/config_guides/slot_types). Slots a base configuration contributes are listed here too, so this table is the whole surface.

| Slot | Description |
| --- | --- |
| **value**<br>[`maybeColor`](https://jbrowse.org/jb2/docs/config_guides/slot_types#the-maybe-types) | The fill of every aligned cell, and of the X-Y plot's bars, while no field paints. |
| **field**<br>[`maybeStringEnum`](https://jbrowse.org/jb2/docs/config_guides/slot_types#the-maybe-types) (identity, refNameRank) | field the aligned cells are filled by: identity or refNameRank; unset, the constant |
| **scale**<br>[MafColorScale sub-schema](#slot-scalescheme) | How the field's values map to colors, Vega-Lite's scale object. Each field has one scale type, so the object names none. |
| **scale.scheme**<br>[`maybeStringEnum`](https://jbrowse.org/jb2/docs/config_guides/slot_types#the-maybe-types) (viridis, magma, inferno, cividis, juicebox, fall, reds, blues, redblue, purpleorange, redgreyblue, redyellowblue) | the named ramp identity runs along; unset is redgreyblue, and range's colors, where it lists any, win over it |
| **scale.reverse**<br>[`maybeBoolean`](https://jbrowse.org/jb2/docs/config_guides/slot_types#the-maybe-types) | turns the identity ramp round, so its last color paints the low end; unset follows the field's preset, else runs as written |
| **scale.domainMin**<br>[`maybeNumber`](https://jbrowse.org/jb2/docs/config_guides/slot_types#the-maybe-types) | the identity the ramp's low end paints, 0 to 1; unset is 0, and 0.7 spreads the ramp over close relatives |
| **scale.domainMax**<br>[`maybeNumber`](https://jbrowse.org/jb2/docs/config_guides/slot_types#the-maybe-types) | the identity the ramp's high end paints; unset is 1 |
| **scale.domainMid**<br>[`maybeNumber`](https://jbrowse.org/jb2/docs/config_guides/slot_types#the-maybe-types) | the value the ramp's middle stop sits at, so a diverging ramp centres somewhere other than the middle of the domain, both sides on one scale: the farther end of the domain reaches its end color and equal distances from the middle take equal colors; unset, the stops are evenly spaced across it |
| **legend**<br>[MafColorLegend sub-schema](#slot-legendtitle) | The key this channel draws; an unset `title` is the field's own heading. |
| **scale.domain**<br>[`stringArray`](https://jbrowse.org/jb2/docs/config_guides/slot_types#stringarray) = <code>[]</code> | the ranks the key lists under refNameRank, in order, from 0, the main source sequence |
| **scale.range**<br>[`colorArray`](https://jbrowse.org/jb2/docs/config_guides/slot_types#colorarray) = <code>[]</code> | CSS colors: under refNameRank one per rank from the main source sequence, the last painting every rank past it; under identity the ramp's stops, winning over scheme |
| **scale.names**<br>[`stringArray`](https://jbrowse.org/jb2/docs/config_guides/slot_types#stringarray) = <code>[]</code> | key name for each domain value, one each in order, or under threshold for each interval from the lowest; a value past the end of the list shows its own |
| **legend.title**<br>[`maybeString`](https://jbrowse.org/jb2/docs/config_guides/slot_types#the-maybe-types) | key title; unset keeps the display's own heading, "" draws none |

