gosling-lang / gosling.js

Grammar of Scalable Linked Interactive Nucleotide Graphics
https://gosling.js.org
MIT License
164 stars 27 forks source link

Odd vertical between-view gaps appear in a certain nested view structure #654

Open sehilyi opened 2 years ago

sehilyi commented 2 years ago

Screenshot

Screen Shot 2022-03-15 at 4 18 01 PM

Spec

{
  "style": {
    "enableSmoothPath": true
  },
  "assembly": "hg38",
  "centerRadius": 0.6,
  "views": [
    {
      "arrangement": "horizontal",
      "xDomain": { "chromosome": "1" },
      "views": [
        {
          "spacing": 10,
          "assembly": "hg38",
          "tracks": [
            {
              "title": "BED1 - CAT1",
              "data": {
                "url": "https://s3.amazonaws.com/gosling-lang.org/data/cancer/rearrangement.PD35930a.csv",
                "type": "csv",
                "genomicFieldsToConvert": [
                  {
                    "chromosomeField": "chr1",
                    "genomicFields": ["start1", "end1"]
                  },
                  {
                    "chromosomeField": "chr2",
                    "genomicFields": ["start2", "end2"]
                  }
                ]
              },
              "dataTransform": [
                {
                  "type": "filter",
                  "field": "svclass",
                  "oneOf": ["translocation"],
                  "not": true
                }
              ],
              "mark": "rect",
              "x": { "field": "start1", "type": "genomic", "axis": "top" },
              "xe": { "field": "end2", "type": "genomic" },
              "color": {
                "field": "svclass",
                "type": "nominal",
                "legend": false,
                "domain": ["tandem-duplication", "delection", "inversion"],
                "range": ["#569C4D", "#4C75A2", "#DA5456", "#EA8A2A"]
              },
              "row": {
                "field": "svclass",
                "type": "nominal",
                "domain": ["tandem-duplication", "delection", "inversion"]
              },
              "stroke": {
                "field": "svclass",
                "type": "nominal",
                "domain": ["tandem-duplication", "delection", "inversion"],
                "range": ["#569C4D", "#4C75A2", "#DA5456", "#EA8A2A"]
              },
              "strokeWidth": { "value": 1 },
              "opacity": { "value": 0.6 },
              "width": 450,
              "height": 50
            }
          ]
        },
        {
          "tracks": [
            {
              "title": "BED2 - CAT1",
              "style": {
                "outlineWidth": 1
              },
              "width": 450,
              "height": 50,
              "data": {
                "url": "https://server.gosling-lang.org/api/v1/tileset_info/?d=gwas-beddb",
                "type": "beddb",
                "genomicFields": [
                  {
                    "index": 1,
                    "name": "start"
                  },
                  {
                    "index": 2,
                    "name": "end"
                  }
                ],
                "valueFields": [
                  {
                    "index": 3,
                    "name": "pubmedid",
                    "type": "nominal"
                  },
                  {
                    "index": 4,
                    "name": "date",
                    "type": "nominal"
                  },
                  {
                    "index": 5,
                    "name": "link",
                    "type": "nominal"
                  },
                  {
                    "index": 6,
                    "name": "pvalue",
                    "type": "quantitative"
                  },
                  {
                    "index": 8,
                    "name": "disease",
                    "type": "nominal"
                  },
                  {
                    "index": 9,
                    "name": "pvalue_log",
                    "type": "quantitative"
                  },
                  {
                    "index": 10,
                    "name": "pvalue_txt",
                    "type": "nominal"
                  }
                ]
              },
              "mark": "rect",
              "x": {
                "field": "start",
                "type": "genomic"
              },
              "color": {
                "field": "disease",
                "type": "nominal",
                "legend": false
              },
              "stroke": {
                "field": "disease",
                "type": "nominal"
              },
              "strokeWidth": {
                "value": 0.5
              },
              "opacity": {
                "value": 0.8
              }
            }
          ]
        }
      ]
    },
    {
      "arrangement": "horizontal",
      "xDomain": { "chromosome": "2" },
      "views": [
        {
          "spacing": 10,
          "assembly": "hg38",
          "tracks": [
            {
              "title": "BED1 - CAT1",
              "data": {
                "url": "https://s3.amazonaws.com/gosling-lang.org/data/cancer/rearrangement.PD35930a.csv",
                "type": "csv",
                "genomicFieldsToConvert": [
                  {
                    "chromosomeField": "chr1",
                    "genomicFields": ["start1", "end1"]
                  },
                  {
                    "chromosomeField": "chr2",
                    "genomicFields": ["start2", "end2"]
                  }
                ]
              },
              "dataTransform": [
                {
                  "type": "filter",
                  "field": "svclass",
                  "oneOf": ["translocation"],
                  "not": true
                }
              ],
              "mark": "rect",
              "x": { "field": "start1", "type": "genomic", "axis": "top" },
              "xe": { "field": "end2", "type": "genomic" },
              "color": {
                "field": "svclass",
                "type": "nominal",
                "legend": false,
                "domain": ["tandem-duplication", "delection", "inversion"],
                "range": ["#569C4D", "#4C75A2", "#DA5456", "#EA8A2A"]
              },
              "row": {
                "field": "svclass",
                "type": "nominal",
                "domain": ["tandem-duplication", "delection", "inversion"]
              },
              "stroke": {
                "field": "svclass",
                "type": "nominal",
                "domain": ["tandem-duplication", "delection", "inversion"],
                "range": ["#569C4D", "#4C75A2", "#DA5456", "#EA8A2A"]
              },
              "strokeWidth": { "value": 1 },
              "opacity": { "value": 0.6 },
              "width": 430,
              "height": 50
            }
          ]
        },
        {
          "xOffset": 20,
          "tracks": [
            {
              "title": "BED2 - CAT1",
              "style": {
                "outlineWidth": 1
              },
              "width": 430,
              "height": 50,
              "data": {
                "url": "https://server.gosling-lang.org/api/v1/tileset_info/?d=gwas-beddb",
                "type": "beddb",
                "genomicFields": [
                  {
                    "index": 1,
                    "name": "start"
                  },
                  {
                    "index": 2,
                    "name": "end"
                  }
                ],
                "valueFields": [
                  {
                    "index": 3,
                    "name": "pubmedid",
                    "type": "nominal"
                  },
                  {
                    "index": 4,
                    "name": "date",
                    "type": "nominal"
                  },
                  {
                    "index": 5,
                    "name": "link",
                    "type": "nominal"
                  },
                  {
                    "index": 6,
                    "name": "pvalue",
                    "type": "quantitative"
                  },
                  {
                    "index": 8,
                    "name": "disease",
                    "type": "nominal"
                  },
                  {
                    "index": 9,
                    "name": "pvalue_log",
                    "type": "quantitative"
                  },
                  {
                    "index": 10,
                    "name": "pvalue_txt",
                    "type": "nominal"
                  }
                ]
              },
              "mark": "rect",
              "x": {
                "field": "start",
                "type": "genomic"
              },
              "color": {
                "field": "disease",
                "type": "nominal",
                "legend": false
              },
              "stroke": {
                "field": "disease",
                "type": "nominal"
              },
              "strokeWidth": {
                "value": 0.5
              },
              "opacity": {
                "value": 0.8
              }
            }
          ]
        }
      ]
    },
    {
      "arrangement": "horizontal",
      "xDomain": { "chromosome": "3" },
      "views": [
        {
          "spacing": 10,
          "assembly": "hg38",
          "tracks": [
            {
              "title": "BED1 - CAT1",
              "data": {
                "url": "https://s3.amazonaws.com/gosling-lang.org/data/cancer/rearrangement.PD35930a.csv",
                "type": "csv",
                "genomicFieldsToConvert": [
                  {
                    "chromosomeField": "chr1",
                    "genomicFields": ["start1", "end1"]
                  },
                  {
                    "chromosomeField": "chr2",
                    "genomicFields": ["start2", "end2"]
                  }
                ]
              },
              "dataTransform": [
                {
                  "type": "filter",
                  "field": "svclass",
                  "oneOf": ["translocation"],
                  "not": true
                }
              ],
              "mark": "rect",
              "x": { "field": "start1", "type": "genomic", "axis": "top" },
              "xe": { "field": "end2", "type": "genomic" },
              "color": {
                "field": "svclass",
                "type": "nominal",
                "legend": false,
                "domain": ["tandem-duplication", "delection", "inversion"],
                "range": ["#569C4D", "#4C75A2", "#DA5456", "#EA8A2A"]
              },
              "row": {
                "field": "svclass",
                "type": "nominal",
                "domain": ["tandem-duplication", "delection", "inversion"]
              },
              "stroke": {
                "field": "svclass",
                "type": "nominal",
                "domain": ["tandem-duplication", "delection", "inversion"],
                "range": ["#569C4D", "#4C75A2", "#DA5456", "#EA8A2A"]
              },
              "strokeWidth": { "value": 1 },
              "opacity": { "value": 0.6 },
              "width": 400,
              "height": 50
            }
          ]
        },
        {
          "xOffset": 50,
          "tracks": [
            {
              "title": "BED2 - CAT1",
              "style": {
                "outlineWidth": 1
              },
              "width": 400,
              "height": 50,
              "data": {
                "url": "https://server.gosling-lang.org/api/v1/tileset_info/?d=gwas-beddb",
                "type": "beddb",
                "genomicFields": [
                  {
                    "index": 1,
                    "name": "start"
                  },
                  {
                    "index": 2,
                    "name": "end"
                  }
                ],
                "valueFields": [
                  {
                    "index": 3,
                    "name": "pubmedid",
                    "type": "nominal"
                  },
                  {
                    "index": 4,
                    "name": "date",
                    "type": "nominal"
                  },
                  {
                    "index": 5,
                    "name": "link",
                    "type": "nominal"
                  },
                  {
                    "index": 6,
                    "name": "pvalue",
                    "type": "quantitative"
                  },
                  {
                    "index": 8,
                    "name": "disease",
                    "type": "nominal"
                  },
                  {
                    "index": 9,
                    "name": "pvalue_log",
                    "type": "quantitative"
                  },
                  {
                    "index": 10,
                    "name": "pvalue_txt",
                    "type": "nominal"
                  }
                ]
              },
              "mark": "rect",
              "x": {
                "field": "start",
                "type": "genomic"
              },
              "color": {
                "field": "disease",
                "type": "nominal",
                "legend": false
              },
              "stroke": {
                "field": "disease",
                "type": "nominal"
              },
              "strokeWidth": {
                "value": 0.5
              },
              "opacity": {
                "value": 0.8
              }
            }
          ]
        }
      ]
    },
    {
      "arrangement": "horizontal",
      "xDomain": { "chromosome": "4" },
      "views": [
        {
          "spacing": 10,
          "assembly": "hg38",
          "tracks": [
            {
              "title": "BED1 - CAT1",
              "data": {
                "url": "https://s3.amazonaws.com/gosling-lang.org/data/cancer/rearrangement.PD35930a.csv",
                "type": "csv",
                "genomicFieldsToConvert": [
                  {
                    "chromosomeField": "chr1",
                    "genomicFields": ["start1", "end1"]
                  },
                  {
                    "chromosomeField": "chr2",
                    "genomicFields": ["start2", "end2"]
                  }
                ]
              },
              "dataTransform": [
                {
                  "type": "filter",
                  "field": "svclass",
                  "oneOf": ["translocation"],
                  "not": true
                }
              ],
              "mark": "rect",
              "x": { "field": "start1", "type": "genomic", "axis": "top" },
              "xe": { "field": "end2", "type": "genomic" },
              "color": {
                "field": "svclass",
                "type": "nominal",
                "legend": false,
                "domain": ["tandem-duplication", "delection", "inversion"],
                "range": ["#569C4D", "#4C75A2", "#DA5456", "#EA8A2A"]
              },
              "row": {
                "field": "svclass",
                "type": "nominal",
                "domain": ["tandem-duplication", "delection", "inversion"]
              },
              "stroke": {
                "field": "svclass",
                "type": "nominal",
                "domain": ["tandem-duplication", "delection", "inversion"],
                "range": ["#569C4D", "#4C75A2", "#DA5456", "#EA8A2A"]
              },
              "strokeWidth": { "value": 1 },
              "opacity": { "value": 0.6 },
              "width": 350,
              "height": 50
            }
          ]
        },
        {
          "xOffset": 100,
          "tracks": [
            {
              "title": "BED2 - CAT1",
              "style": {
                "outlineWidth": 1
              },
              "width": 350,
              "height": 50,
              "data": {
                "url": "https://server.gosling-lang.org/api/v1/tileset_info/?d=gwas-beddb",
                "type": "beddb",
                "genomicFields": [
                  {
                    "index": 1,
                    "name": "start"
                  },
                  {
                    "index": 2,
                    "name": "end"
                  }
                ],
                "valueFields": [
                  {
                    "index": 3,
                    "name": "pubmedid",
                    "type": "nominal"
                  },
                  {
                    "index": 4,
                    "name": "date",
                    "type": "nominal"
                  },
                  {
                    "index": 5,
                    "name": "link",
                    "type": "nominal"
                  },
                  {
                    "index": 6,
                    "name": "pvalue",
                    "type": "quantitative"
                  },
                  {
                    "index": 8,
                    "name": "disease",
                    "type": "nominal"
                  },
                  {
                    "index": 9,
                    "name": "pvalue_log",
                    "type": "quantitative"
                  },
                  {
                    "index": 10,
                    "name": "pvalue_txt",
                    "type": "nominal"
                  }
                ]
              },
              "mark": "rect",
              "x": {
                "field": "start",
                "type": "genomic"
              },
              "color": {
                "field": "disease",
                "type": "nominal",
                "legend": false
              },
              "stroke": {
                "field": "disease",
                "type": "nominal"
              },
              "strokeWidth": {
                "value": 0.5
              },
              "opacity": {
                "value": 0.8
              }
            }
          ]
        }
      ]
    },
    {
      "arrangement": "horizontal",
      "xDomain": { "chromosome": "5" },
      "views": [
        {
          "spacing": 10,
          "assembly": "hg38",
          "tracks": [
            {
              "title": "BED1 - CAT1",
              "data": {
                "url": "https://s3.amazonaws.com/gosling-lang.org/data/cancer/rearrangement.PD35930a.csv",
                "type": "csv",
                "genomicFieldsToConvert": [
                  {
                    "chromosomeField": "chr1",
                    "genomicFields": ["start1", "end1"]
                  },
                  {
                    "chromosomeField": "chr2",
                    "genomicFields": ["start2", "end2"]
                  }
                ]
              },
              "dataTransform": [
                {
                  "type": "filter",
                  "field": "svclass",
                  "oneOf": ["translocation"],
                  "not": true
                }
              ],
              "mark": "rect",
              "x": { "field": "start1", "type": "genomic", "axis": "top" },
              "xe": { "field": "end2", "type": "genomic" },
              "color": {
                "field": "svclass",
                "type": "nominal",
                "legend": false,
                "domain": ["tandem-duplication", "delection", "inversion"],
                "range": ["#569C4D", "#4C75A2", "#DA5456", "#EA8A2A"]
              },
              "row": {
                "field": "svclass",
                "type": "nominal",
                "domain": ["tandem-duplication", "delection", "inversion"]
              },
              "stroke": {
                "field": "svclass",
                "type": "nominal",
                "domain": ["tandem-duplication", "delection", "inversion"],
                "range": ["#569C4D", "#4C75A2", "#DA5456", "#EA8A2A"]
              },
              "strokeWidth": { "value": 1 },
              "opacity": { "value": 0.6 },
              "width": 350,
              "height": 50
            }
          ]
        },
        {
          "xOffset": 100,
          "tracks": [
            {
              "title": "BED2 - CAT1",
              "style": {
                "outlineWidth": 1
              },
              "width": 350,
              "height": 50,
              "data": {
                "url": "https://server.gosling-lang.org/api/v1/tileset_info/?d=gwas-beddb",
                "type": "beddb",
                "genomicFields": [
                  {
                    "index": 1,
                    "name": "start"
                  },
                  {
                    "index": 2,
                    "name": "end"
                  }
                ],
                "valueFields": [
                  {
                    "index": 3,
                    "name": "pubmedid",
                    "type": "nominal"
                  },
                  {
                    "index": 4,
                    "name": "date",
                    "type": "nominal"
                  },
                  {
                    "index": 5,
                    "name": "link",
                    "type": "nominal"
                  },
                  {
                    "index": 6,
                    "name": "pvalue",
                    "type": "quantitative"
                  },
                  {
                    "index": 8,
                    "name": "disease",
                    "type": "nominal"
                  },
                  {
                    "index": 9,
                    "name": "pvalue_log",
                    "type": "quantitative"
                  },
                  {
                    "index": 10,
                    "name": "pvalue_txt",
                    "type": "nominal"
                  }
                ]
              },
              "mark": "rect",
              "x": {
                "field": "start",
                "type": "genomic"
              },
              "color": {
                "field": "disease",
                "type": "nominal",
                "legend": false
              },
              "stroke": {
                "field": "disease",
                "type": "nominal"
              },
              "strokeWidth": {
                "value": 0.5
              },
              "opacity": {
                "value": 0.8
              }
            }
          ]
        }
      ]
    },
    {
      "arrangement": "horizontal",
      "xDomain": { "chromosome": "6" },
      "views": [
        {
          "spacing": 10,
          "assembly": "hg38",
          "tracks": [
            {
              "title": "BED1 - CAT1",
              "data": {
                "url": "https://s3.amazonaws.com/gosling-lang.org/data/cancer/rearrangement.PD35930a.csv",
                "type": "csv",
                "genomicFieldsToConvert": [
                  {
                    "chromosomeField": "chr1",
                    "genomicFields": ["start1", "end1"]
                  },
                  {
                    "chromosomeField": "chr2",
                    "genomicFields": ["start2", "end2"]
                  }
                ]
              },
              "dataTransform": [
                {
                  "type": "filter",
                  "field": "svclass",
                  "oneOf": ["translocation"],
                  "not": true
                }
              ],
              "mark": "rect",
              "x": { "field": "start1", "type": "genomic", "axis": "top" },
              "xe": { "field": "end2", "type": "genomic" },
              "color": {
                "field": "svclass",
                "type": "nominal",
                "legend": false,
                "domain": ["tandem-duplication", "delection", "inversion"],
                "range": ["#569C4D", "#4C75A2", "#DA5456", "#EA8A2A"]
              },
              "row": {
                "field": "svclass",
                "type": "nominal",
                "domain": ["tandem-duplication", "delection", "inversion"]
              },
              "stroke": {
                "field": "svclass",
                "type": "nominal",
                "domain": ["tandem-duplication", "delection", "inversion"],
                "range": ["#569C4D", "#4C75A2", "#DA5456", "#EA8A2A"]
              },
              "strokeWidth": { "value": 1 },
              "opacity": { "value": 0.6 },
              "width": 350,
              "height": 50
            }
          ]
        },
        {
          "xOffset": 100,
          "tracks": [
            {
              "title": "BED2 - CAT1",
              "style": {
                "outlineWidth": 1
              },
              "width": 350,
              "height": 50,
              "data": {
                "url": "https://server.gosling-lang.org/api/v1/tileset_info/?d=gwas-beddb",
                "type": "beddb",
                "genomicFields": [
                  {
                    "index": 1,
                    "name": "start"
                  },
                  {
                    "index": 2,
                    "name": "end"
                  }
                ],
                "valueFields": [
                  {
                    "index": 3,
                    "name": "pubmedid",
                    "type": "nominal"
                  },
                  {
                    "index": 4,
                    "name": "date",
                    "type": "nominal"
                  },
                  {
                    "index": 5,
                    "name": "link",
                    "type": "nominal"
                  },
                  {
                    "index": 6,
                    "name": "pvalue",
                    "type": "quantitative"
                  },
                  {
                    "index": 8,
                    "name": "disease",
                    "type": "nominal"
                  },
                  {
                    "index": 9,
                    "name": "pvalue_log",
                    "type": "quantitative"
                  },
                  {
                    "index": 10,
                    "name": "pvalue_txt",
                    "type": "nominal"
                  }
                ]
              },
              "mark": "rect",
              "x": {
                "field": "start",
                "type": "genomic"
              },
              "color": {
                "field": "disease",
                "type": "nominal",
                "legend": false
              },
              "stroke": {
                "field": "disease",
                "type": "nominal"
              },
              "strokeWidth": {
                "value": 0.5
              },
              "opacity": {
                "value": 0.8
              }
            }
          ]
        }
      ]
    },
    {
      "arrangement": "horizontal",
      "xDomain": { "chromosome": "6" },
      "views": [
        {
          "spacing": 10,
          "assembly": "hg38",
          "tracks": [
            {
              "title": "BED1 - CAT1",
              "data": {
                "url": "https://s3.amazonaws.com/gosling-lang.org/data/cancer/rearrangement.PD35930a.csv",
                "type": "csv",
                "genomicFieldsToConvert": [
                  {
                    "chromosomeField": "chr1",
                    "genomicFields": ["start1", "end1"]
                  },
                  {
                    "chromosomeField": "chr2",
                    "genomicFields": ["start2", "end2"]
                  }
                ]
              },
              "dataTransform": [
                {
                  "type": "filter",
                  "field": "svclass",
                  "oneOf": ["translocation"],
                  "not": true
                }
              ],
              "mark": "rect",
              "x": { "field": "start1", "type": "genomic", "axis": "top" },
              "xe": { "field": "end2", "type": "genomic" },
              "color": {
                "field": "svclass",
                "type": "nominal",
                "legend": false,
                "domain": ["tandem-duplication", "delection", "inversion"],
                "range": ["#569C4D", "#4C75A2", "#DA5456", "#EA8A2A"]
              },
              "row": {
                "field": "svclass",
                "type": "nominal",
                "domain": ["tandem-duplication", "delection", "inversion"]
              },
              "stroke": {
                "field": "svclass",
                "type": "nominal",
                "domain": ["tandem-duplication", "delection", "inversion"],
                "range": ["#569C4D", "#4C75A2", "#DA5456", "#EA8A2A"]
              },
              "strokeWidth": { "value": 1 },
              "opacity": { "value": 0.6 },
              "width": 350,
              "height": 50
            }
          ]
        },
        {
          "xOffset": 100,
          "tracks": [
            {
              "title": "BED2 - CAT1",
              "style": {
                "outlineWidth": 1
              },
              "width": 350,
              "height": 50,
              "data": {
                "url": "https://server.gosling-lang.org/api/v1/tileset_info/?d=gwas-beddb",
                "type": "beddb",
                "genomicFields": [
                  {
                    "index": 1,
                    "name": "start"
                  },
                  {
                    "index": 2,
                    "name": "end"
                  }
                ],
                "valueFields": [
                  {
                    "index": 3,
                    "name": "pubmedid",
                    "type": "nominal"
                  },
                  {
                    "index": 4,
                    "name": "date",
                    "type": "nominal"
                  },
                  {
                    "index": 5,
                    "name": "link",
                    "type": "nominal"
                  },
                  {
                    "index": 6,
                    "name": "pvalue",
                    "type": "quantitative"
                  },
                  {
                    "index": 8,
                    "name": "disease",
                    "type": "nominal"
                  },
                  {
                    "index": 9,
                    "name": "pvalue_log",
                    "type": "quantitative"
                  },
                  {
                    "index": 10,
                    "name": "pvalue_txt",
                    "type": "nominal"
                  }
                ]
              },
              "mark": "rect",
              "x": {
                "field": "start",
                "type": "genomic"
              },
              "color": {
                "field": "disease",
                "type": "nominal",
                "legend": false
              },
              "stroke": {
                "field": "disease",
                "type": "nominal"
              },
              "strokeWidth": {
                "value": 0.5
              },
              "opacity": {
                "value": 0.8
              }
            }
          ]
        }
      ]
    }

  ]
}
sehilyi commented 2 years ago

Using a different arrangement structure -- first arranging each column vertically and then horizontally juxtaposing the two columns -- works fine.