This pull req generalizes the resolution of scalable parameters (e.g. color, size, or shape for scatter points) such that every such layout parameter can be defined as:
A static value (number or string independent of data)
An object implementing a scale function to be applied to a field on the element's data
An array of arbitrarily many of the above, to be iterated over until a non-null value is found or all options are exhausted.
There's also a new scale function in this branch called if that allows for a very basic conditional. Put it all together and we can support this definition for the color of scatter elements on the positions panel when the LD reference variant needs to be colored differently (e.g. we're coloring on the values of ld:state and ld:isrefvar with strict order):
The above layout, for each point on the scatter plot, is sent to LocusZoom.DataLayer.resolveScalableParameter() along with the data for that point. The first element in the array (the if scale function) will return its then value only if ld:isrefvar is 1, otherwise it will return null. This passes through to the next scale function, numerical_bin, which will map the value of ld:state to a breakpoint color or (if ld:state is not defined or numeric) will return null. That then passes to the last value, which is a string, and that gets returned no matter what. This ensures that LD ref variants are always purple, all other variants with a defined numerical LD value get an appropriate color, and any leftover variants show up gray.
The same behavior now applies to point_size and point_shape for scatter plot elements as well.
This pull req generalizes the resolution of scalable parameters (e.g. color, size, or shape for scatter points) such that every such layout parameter can be defined as:
There's also a new scale function in this branch called
if
that allows for a very basic conditional. Put it all together and we can support this definition for the color of scatter elements on the positions panel when the LD reference variant needs to be colored differently (e.g. we're coloring on the values ofld:state
andld:isrefvar
with strict order):The above layout, for each point on the scatter plot, is sent to
LocusZoom.DataLayer.resolveScalableParameter()
along with the data for that point. The first element in the array (theif
scale function) will return itsthen
value only ifld:isrefvar
is 1, otherwise it will return null. This passes through to the next scale function,numerical_bin
, which will map the value ofld:state
to a breakpoint color or (ifld:state
is not defined or numeric) will return null. That then passes to the last value, which is a string, and that gets returned no matter what. This ensures that LD ref variants are always purple, all other variants with a defined numerical LD value get an appropriate color, and any leftover variants show up gray.The same behavior now applies to
point_size
andpoint_shape
for scatter plot elements as well.