gosling.js icon indicating copy to clipboard operation
gosling.js copied to clipboard

Track-level properties don't work in a nested view

Open zhangzhen opened this issue 2 years ago • 2 comments

The following code doesn't work. The error message says, "genomic type is not encoded to either a x- or y- axis". If a track in "tracks" is a view, data is specified in the view, x and y channels in any track of the view don't function as expected.

const goslingSpec = {
  "arrangement": "vertical",
  "title": "Large Rearrangment Auditing",
  "assembly": "hg19",
  "views": [
	{ .. },
	{
	  "alignment": "overlay",
	  "title": "SNP Copy Numbers & B-Allele Frequencies",
	  "xDomain": {"chromosome": "17"},
	  "tracks": [
		{
		  "data": {
	  	    "url": "https://xxx.xxx.xxx/RD2106699FFPx/report/gisplot/RD2106699FFP_CN_LOH_output_full.tsv",
	  	    "type": "csv",
	  	    "separator": "\t",
	  	    "chromosomeField": "chr",
	  	    "genomicFields": ["pos"],
	  	    "quantitativeFields": ["baf", "ascn"]
	  	  },
		  "dataTransform": [
			{ "type": "filter", "field": "tag", "oneOf": ["valid_snpGIS", "snpLR"] }
		  ],
		  "mark": "point",
		  "size": {"value": 1.5},
		  "tracks": [
			{
			  "x": { "field": "pos", "type": "genomic", "axis": "bottom" },
			  "y": {
				"field": "baf", 
				"type": "quantitative"
			  },
			  "color": { "value": "blue" }
			}
		  ]
		}
	  ],
	  "width": 1000,
	  "height": 500
	}
  ]
};

zhangzhen avatar Sep 08 '21 04:09 zhangzhen

We would need to document this better, but the children of "overlay" tracks cannot contain child tracks:

{ alignment: 'overlay', tracks: [{
   tracks: [...] // error 
}]}

So, to make the spec valid, you can change the spec as follows:

const goslingSpec = {
  "arrangement": "vertical",
  "title": "Large Rearrangment Auditing",
  "assembly": "hg19",
  "views": [
	{ .. },
	{
	  "alignment": "overlay",
	  "title": "SNP Copy Numbers & B-Allele Frequencies",
	  "xDomain": {"chromosome": "17"},
	  "tracks": [
		{
		  "data": {
	  	    "url": "https://xxx.xxx.xxx/RD2106699FFPx/report/gisplot/RD2106699FFP_CN_LOH_output_full.tsv",
	  	    "type": "csv",
	  	    "separator": "\t",
	  	    "chromosomeField": "chr",
	  	    "genomicFields": ["pos"],
	  	    "quantitativeFields": ["baf", "ascn"]
	  	  },
		  "dataTransform": [
			{ "type": "filter", "field": "tag", "oneOf": ["valid_snpGIS", "snpLR"] }
		  ],
		  "mark": "point",
		  "size": {"value": 1.5},
-		  "tracks": [
-			{
			  "x": { "field": "pos", "type": "genomic", "axis": "bottom" },
			  "y": {
				"field": "baf", 
				"type": "quantitative"
			  },
			  "color": { "value": "blue" }
-			}
-		  ]
		}
	  ],
	  "width": 1000,
	  "height": 500
	}
  ]
};

Is this what you intended with your spec?

sehilyi avatar Sep 08 '21 14:09 sehilyi

Is this what you intended with your spec?

I want to have a view that contains four tracks. The first two tracks use the same data: the same x values and different y values are to be represented. The last two tracks have the same requirement. All data needs to be drawn in the same figure. Inspired from your suggestions, I use a stack tracks instead which is allow to have a child tracks, and then use overlayOnPreviousTrack to overlay the tracks.

zhangzhen avatar Sep 09 '21 03:09 zhangzhen