vgteam / sequenceTubeMap

displays multiple genomic sequences in the form of a tube map
MIT License
180 stars 25 forks source link

Use different default colors for different track types #333

Closed adamnovak closed 1 year ago

adamnovak commented 1 year ago

In the solution for https://github.com/vgteam/sequenceTubeMap/issues/217 we found that, if you make a new track and then set its type, it keeps whatever default colors there are for a default created track. It doesn't magically adopt the default colors appropriate for the type of track you have made it be.

We should allow the default colors to differ depending on track type, and if you change track types it should reset the colors to sensible defaults for that track type.

adamnovak commented 1 year ago

We also want the default colors for a track type to be consistent between e.g. the chunk extraction scripts and the client code. And we want them to be sensible; read colors should match the UCSC Genome Browser by default (where I think blue is forward and red is reverse), graph paths should highlight the reference path but make the others look distinct, and haplotype colors should be distinct from each other and distinct from path colors.

We might want to add some new named color schemes to make this all work, or revise/get rid of Ygreys which was doing the work of trying to highlight the reference path by itself.

adamnovak commented 1 year ago

We will need to:

  1. Create a defaultGraphColorPalette in the config: https://github.com/vgteam/sequenceTubeMap/blob/429fb486abc3a7fa500dfbfece00d067b33bcdc8/src/config.json#L68C1-L68C1
  2. When the track type changes at https://github.com/vgteam/sequenceTubeMap/blob/429fb486abc3a7fa500dfbfece00d067b33bcdc8/src/components/TrackListItem.js#L33, adopt the default color settings for the new track type
  3. When a track doesn't have a color scheme set at https://github.com/vgteam/sequenceTubeMap/blob/429fb486abc3a7fa500dfbfece00d067b33bcdc8/src/util/tubemap.js#L2480, adopt the right default color scheme for its type. Right now we do that for read tracks, but graph and haplotype tracks both get the haplotype track defaults.
  4. In the chunk preparation scripts at https://github.com/vgteam/sequenceTubeMap/blob/429fb486abc3a7fa500dfbfece00d067b33bcdc8/scripts/prepare_chunks.sh#L68 and https://github.com/vgteam/sequenceTubeMap/blob/429fb486abc3a7fa500dfbfece00d067b33bcdc8/scripts/prepare_local_chunk.sh#L69, use the script's path to find config.json, use jq to read out the default track color settings from config.json, and use those instead of hardcoded values in the script.
  5. Set sensible actual default colors in config.json. Reads should be blue on the forward strand and red on the reverse strand, which I think is what the UCSC genome browser does. Graph tracks should have a distinctive main palette (maybe a single color like #000000?) for the primary reference, and some mutually distinct colors for the alt palette for the non-reference paths (of which we don't expect more than 2 or 3 to usually exist). Hapolotypes should probably use the rainbow colors preset by default on the main palette, and they don't actually use their alt palette. You can create new preset sets of colors if appropriate.
adamnovak commented 1 year ago

Here's a relevant jq example:

[anovak@swords sequenceTubeMap]% cat src/config.json | jq '.defaultReadColorPalette'
{
  "mainPalette": "blues",
  "auxPalette": "reds",
  "colorReadsByMappingQuality": false
}
[anovak@swords sequenceTubeMap]% READ_PALETTE="$(cat src/config.json | jq '.defaultReadColorPalette')"
[anovak@swords sequenceTubeMap]% echo "$READ_PALETTE"
{
  "mainPalette": "blues",
  "auxPalette": "reds",
  "colorReadsByMappingQuality": false
}
adamnovak commented 1 year ago

Red should indeed mean reverse: https://genome.ucsc.edu/goldenPath/help/hgBamTrackHelp.html