cmdcolin / jbrowse-plugin-gwas

3 stars 1 forks source link

Color coding by trait #8

Closed svengato closed 1 year ago

svengato commented 1 year ago

I would like to color code the dots in the Manhattan plot by GWAS trait (my data files have a 'trait' column). For a LinearBasicDisplay, adding the following code to config.json works as expected:

      "displays": [
        {
          "displayId": "display-1",
          "type": "LinearBasicDisplay",
          "renderer": {
            "color1": "jexl:traitColor(feature)"
          }
        }
      ]

where traitColor() is a jexl function that assigns a color to each trait.

For LinearManhattanDisplay, it seems that it should be as simple as replacing 'color1' with 'color' (defined in jbrowse-plugin-gwas/src/LinearManhattanRenderer/index.ts), but neither of these tags work. I have not been able to change the color through config.json at all, only through 'Set color' in the browser (which assigns all dots the same color).

cmdcolin commented 1 year ago

thanks for reporting this. I think I found a fix here https://github.com/cmdcolin/jbrowse-plugin-gwas/pull/9

I can probably go ahead and try to make a quick release

cmdcolin commented 1 year ago

can also see the config, after this change, would look roughly like this

      "displays": [
        {
          "displayId": "gwas_display_custom_color",
          "type": "LinearManhattanDisplay",
          "renderers": {
            "LinearManhattanRenderer": {
              "color": "green"
            }
          }
        }
      ]

It is always a bit verbsoe to configure renderers unfortunately, and in this case, it is extending the "wiggle track" which uses this "renderers" config

cmdcolin commented 1 year ago

published as 1.0.5 :)

svengato commented 1 year ago

Thanks - now I see the green dots when using "green" as in your example, but get an error message "TypeError: feature is undefined" when using my jexl:traitColor(feature) as in the original post.

Could it be missing a line contextVariable: ["feature"] in jbrowse-plugin-gwas/src/LinearManhattanRenderer/index.ts?

export const configSchema = ConfigurationSchema(
  "LinearManhattanRenderer",
  {
    color: {
      type: "color",
      description: "the color of the marks",
      defaultValue: "darkblue",
      contextVariable: ["feature"]
    },
  },
  { explicitlyTyped: true },
);
cmdcolin commented 1 year ago

nice catch again :) added this fix as 1.0.6 from #10

svengato commented 1 year ago

The dots now have different colors according to their trait. Thanks!