GMOD / jbrowse-components

Source code for JBrowse 2, a modern React-based genome browser
https://jbrowse.org/jb2
Apache License 2.0
204 stars 61 forks source link

Allow using color encoded in an attribute #1734

Open cmdcolin opened 3 years ago

cmdcolin commented 3 years ago

The itemRgb/reserved field in bigbed is an example

It would be nice to have this functionality baked in for some cases, since it is difficult to make a color callback to properly express this.

Note that BAM also has this, and is not currently supported by our color by tag system (example YC:Z:255,0,0)

cmdcolin commented 2 years ago

Was mentioned on jb1 forum. Still probably a good thing to do in jb2

cmdcolin commented 7 months ago

this was brought up by a user at pag2024, how they had a hard time figuring out how to get the 'standard' BED itemRgb field to be used by a color callback

cmdcolin commented 7 months ago

ended up being in a field called field8 instead of itemRgb also, which i suppose if it was changed, would be a breaking change

sfederman commented 7 months ago

It would be great to support itemRgb natively in jbrowse for BED files, but here is a hack I used cobbled from other info I've gathered here in the meantime:

  {
    type: 'FeatureTrack',
    trackId: 'trackID_1',
    name: 'trackID_1',
    assemblyNames: ['GRCh38'],
    adapter: {
      type: 'BedTabixAdapter',
      bedGzLocation: {
        uri: 'data/trackID_1.bed.gz'
      },
      index: {
        location: {
          uri: 'data/trackID_1.bed.gz.tbi'
        }
      }
    },
    displays: [
      {
        type: "LinearBasicDisplay",
        displayId: "SetRGBColor_filt01",
        renderer: {
          type: "SvgFeatureRenderer",
          color1: "jexl:get(feature,'field8')"
        }
      }
    ]
  },
cmdcolin commented 7 months ago

yep thats the code to use, glad you got that example posted @sfederman

it could be that the field8 (just auto-named fields by column number...) gets renamed to itemRgb, and then we can make code so that any feature that has an itemRgb uses that value.

lidijaberke commented 2 months ago

Hi, Here is another vote in support of this feature being implemented.