From 98e53c3f4f18ae08f3fcf8629c10c9fa83c25f0d Mon Sep 17 00:00:00 2001 From: Eugene Date: Mon, 19 Oct 2026 21:02:06 -0700 Subject: [PATCH 1/4] feat(workflow-operator): volcano plot significance cut-offs Add optional Significance threshold and Effect-size threshold properties that draw dashed cut-off lines at -log10(threshold) and at plus and minus the effect-size threshold. Add a Color by significance toggle that, with both thresholds set, colors points Up, Down or Not significant instead of by effect size. Bound both thresholds in the JSON schema and ignore a non-positive, non-finite or above-one value instead of drawing it. --- .../volcanoPlot/VolcanoPlotOpDesc.scala | 94 +++++- .../volcanoPlot/VolcanoPlotOpDescSpec.scala | 267 +++++++++++++++++- 2 files changed, 356 insertions(+), 5 deletions(-) diff --git a/common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/visualization/volcanoPlot/VolcanoPlotOpDesc.scala b/common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/visualization/volcanoPlot/VolcanoPlotOpDesc.scala index 6fcc7085be1..d51c7224415 100644 --- a/common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/visualization/volcanoPlot/VolcanoPlotOpDesc.scala +++ b/common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/visualization/volcanoPlot/VolcanoPlotOpDesc.scala @@ -20,14 +20,16 @@ package org.apache.texera.amber.operator.visualization.volcanoPlot import com.fasterxml.jackson.annotation.{JsonProperty, JsonPropertyDescription} +import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.kjetland.jackson.jsonSchema.annotations.{JsonSchemaInject, JsonSchemaTitle} import org.apache.texera.amber.core.tuple.{AttributeType, Schema} import org.apache.texera.amber.pybuilder.PythonTemplateBuilder.PythonTemplateBuilderStringContext -import org.apache.texera.amber.pybuilder.PyStringTypes.EncodableString +import org.apache.texera.amber.pybuilder.PyStringTypes.{EncodableString, PythonLiteral} import org.apache.texera.amber.core.workflow.PortIdentity import org.apache.texera.amber.operator.PythonOperatorDescriptor import org.apache.texera.amber.operator.metadata.annotations.AutofillAttributeName import org.apache.texera.amber.operator.metadata.{OperatorGroupConstants, OperatorInfo} +import org.apache.texera.amber.pybuilder.PythonTemplateBuilder import javax.validation.constraints.NotNull @@ -65,6 +67,34 @@ class VolcanoPlotOpDesc extends PythonOperatorDescriptor { @NotNull(message = "P-Value Column cannot be empty") var pvalueColumn: EncodableString = "" + // Numeric: both are compared against the data and the first is log10'd. contentAs + // names the boxed class — Option erases its element type, and a blank must not read as 0. + @JsonProperty(required = false) + @JsonSchemaTitle("Significance threshold") + @JsonPropertyDescription( + "P-value cut-off such as 0.05; draws a dashed horizontal line at -log10 of it" + ) + @JsonSchemaInject(json = """{"exclusiveMinimum": 0, "maximum": 1}""") + @JsonDeserialize(contentAs = classOf[java.lang.Double]) + var significanceThreshold: Option[Double] = None + + @JsonProperty(required = false) + @JsonSchemaTitle("Effect-size threshold") + @JsonPropertyDescription( + "Effect-size cut-off such as 1; draws dashed vertical lines at plus and minus it" + ) + @JsonSchemaInject(json = """{"exclusiveMinimum": 0}""") + @JsonDeserialize(contentAs = classOf[java.lang.Double]) + var effectSizeThreshold: Option[Double] = None + + @JsonProperty(required = false, defaultValue = "false") + @JsonSchemaTitle("Color by significance") + @JsonPropertyDescription( + "Color points Up, Down or Not significant by both thresholds instead of by effect size; " + + "needs both thresholds, otherwise the effect-size coloring is kept" + ) + var colorBySignificance: Boolean = false + override def operatorInfo: OperatorInfo = OperatorInfo.forVisualization( userFriendlyName = "Volcano Plot", @@ -80,6 +110,62 @@ class VolcanoPlotOpDesc extends PythonOperatorDescriptor { Map(operatorInfo.outputPorts.head.id -> outputSchema) } + /** A cut-off is used only when it can be drawn: finite, above zero and, for the + * p-value, at most one. Anything else counts as unset. The schema bounds keep such + * values out of the property panel; this keeps a hand-edited workflow from failing. + */ + private def isUsable(cutoff: Double): Boolean = + !cutoff.isNaN && !cutoff.isInfinite && cutoff > 0 + + private def significanceCutoff: Option[Double] = + significanceThreshold.filter(sig => isUsable(sig) && sig <= 1) + + private def effectCutoff: Option[Double] = effectSizeThreshold.filter(isUsable) + + /** Both cut-offs are needed to call a point Up or Down. */ + private def colorByCategory: Boolean = + colorBySignificance && significanceCutoff.isDefined && effectCutoff.isDefined + + /** Strict comparisons: a point exactly on a cut-off is not significant. */ + private def significanceColumn: PythonTemplateBuilder = + if (colorByCategory) { + val sig = significanceCutoff.get + val eff = effectCutoff.get + pyb"""significant = table[$pvalueColumn] < $sig + | table["Significance"] = np.select( + | [significant & (table[$effectColumn] > $eff), significant & (table[$effectColumn] < -$eff)], + | ["Up", "Down"], + | default="Not significant", + | ) + |""" + } else pyb"" + + // ColorBrewer RdBu end points plus a neutral grey, so the figure reads like other + // volcano-plot tooling; the continuous RdBu scale stays when not coloring by category. + private def colorArgs: PythonTemplateBuilder = + if (colorByCategory) + pyb"""color="Significance", + | color_discrete_map={"Up": "#B2182B", "Down": "#2166AC", "Not significant": "#9E9E9E"}, + | category_orders={"Significance": ["Up", "Down", "Not significant"]},""" + else + pyb"""color=$effectColumn, + | color_continuous_scale="RdBu",""" + + /** One dashed line per cut-off that is set: horizontal at -log10 of the p-value + * cut-off, vertical at plus and minus the effect-size cut-off. + */ + private def thresholdLines: PythonLiteral = { + val lines = scala.collection.mutable.ArrayBuffer[PythonTemplateBuilder]() + significanceCutoff.foreach { sig => + lines += pyb"""fig.add_hline(y=-np.log10($sig), line_dash="dash", line_color="gray")""" + } + effectCutoff.foreach { eff => + lines += pyb"""fig.add_vline(x=$eff, line_dash="dash", line_color="gray")""" + lines += pyb"""fig.add_vline(x=-$eff, line_dash="dash", line_color="gray")""" + } + lines.mkString("\n ") + } + override def generatePythonCode(): String = { pyb""" |from pytexera import * @@ -109,16 +195,16 @@ class VolcanoPlotOpDesc extends PythonOperatorDescriptor { | return | | table["-log10(pvalue)"] = -np.log10(table[$pvalueColumn]) - | + | $significanceColumn | fig = px.scatter( | table, | x=$effectColumn, | y="-log10(pvalue)", | hover_name=table.columns[0], - | color=$effectColumn, - | color_continuous_scale="RdBu", + | $colorArgs | title="Volcano Plot" | ) + | $thresholdLines | | html = plotly.io.to_html(fig, include_plotlyjs='cdn', auto_play=False) | yield {"html-content": html} diff --git a/common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/visualization/volcanoPlot/VolcanoPlotOpDescSpec.scala b/common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/visualization/volcanoPlot/VolcanoPlotOpDescSpec.scala index e85ed589efa..defea730a75 100644 --- a/common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/visualization/volcanoPlot/VolcanoPlotOpDescSpec.scala +++ b/common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/visualization/volcanoPlot/VolcanoPlotOpDescSpec.scala @@ -20,7 +20,9 @@ package org.apache.texera.amber.operator.visualization.volcanoPlot import org.apache.texera.amber.core.tuple.AttributeType -import org.apache.texera.amber.operator.metadata.OperatorGroupConstants +import org.apache.texera.amber.operator.LogicalOp +import org.apache.texera.amber.operator.metadata.{OperatorGroupConstants, OperatorMetadataGenerator} +import org.apache.texera.amber.util.JSONUtils.objectMapper import org.scalatest.flatspec.AnyFlatSpec import org.scalatest.matchers.should.Matchers @@ -33,6 +35,20 @@ class VolcanoPlotOpDescSpec extends AnyFlatSpec with Matchers { op } + private val hline = """fig.add_hline(y=-np.log10(0.05), line_dash="dash", line_color="gray")""" + private val vlines = + """fig.add_vline(x=1.0, line_dash="dash", line_color="gray") + | fig.add_vline(x=-1.0, line_dash="dash", line_color="gray")""".stripMargin + private val discreteMap = + """color_discrete_map={"Up": "#B2182B", "Down": "#2166AC", "Not significant": "#9E9E9E"}""" + + private def assertContinuousColoring(code: String): Unit = { + code should include("""color_continuous_scale="RdBu"""") + code should not include "Significance" + code should not include discreteMap + code should not include "category_orders" + } + "VolcanoPlotOpDesc.operatorInfo" should "advertise the user-friendly name and Scientific group" in { val info = (new VolcanoPlotOpDesc).operatorInfo info.userFriendlyName shouldBe "Volcano Plot" @@ -68,6 +84,255 @@ class VolcanoPlotOpDescSpec extends AnyFlatSpec with Matchers { decodeOccurrences should be >= 2 } + it should "draw no cut-off line and keep the continuous effect-size coloring by default" in { + val code = configured.generatePythonCode() + code should not include "add_hline" + code should not include "add_vline" + assertContinuousColoring(code) + } + + it should "draw a dashed horizontal line at -log10 of the significance threshold" in { + val op = configured + op.significanceThreshold = Some(0.05) + val code = op.generatePythonCode() + code should include(hline) + code should not include "add_vline" + assertContinuousColoring(code) + } + + it should "draw dashed vertical lines at plus and minus the effect-size threshold" in { + val op = configured + op.effectSizeThreshold = Some(1.0) + val code = op.generatePythonCode() + code should include(vlines) + code should not include "add_hline" + assertContinuousColoring(code) + } + + it should "draw both cut-offs while keeping the continuous coloring when the toggle is off" in { + val op = configured + op.significanceThreshold = Some(0.05) + op.effectSizeThreshold = Some(1.0) + val code = op.generatePythonCode() + code should include(hline) + code should include(vlines) + assertContinuousColoring(code) + } + + it should "skip a significance threshold that has no -log10 (zero or negative)" in { + Seq(0.0, -0.01).foreach { bad => + val op = configured + op.significanceThreshold = Some(bad) + op.effectSizeThreshold = Some(1.0) + op.colorBySignificance = true + val code = op.generatePythonCode() + code should not include "add_hline" + code should not include "np.log10(0.0)" + code should not include "np.log10(-0.01)" + // The effect-size lines still draw, and without a usable p-value cut-off + // no point can be called Up or Down, so the coloring stays continuous. + code should include(vlines) + assertContinuousColoring(code) + } + } + + it should "skip an effect-size threshold that is zero or negative" in { + // A negative cut-off would flip the Up and Down comparisons and call small + // effects significant; zero is the same boundary and is ruled out too. + Seq(0.0, -1.0).foreach { bad => + val op = configured + op.significanceThreshold = Some(0.05) + op.effectSizeThreshold = Some(bad) + op.colorBySignificance = true + val code = op.generatePythonCode() + code should not include "add_vline" + code should include(hline) + assertContinuousColoring(code) + } + } + + it should "skip a significance threshold above one, whose line would sit below the axis" in { + val op = configured + op.significanceThreshold = Some(2.0) + op.effectSizeThreshold = Some(1.0) + op.colorBySignificance = true + val code = op.generatePythonCode() + code should not include "add_hline" + code should include(vlines) + assertContinuousColoring(code) + } + + it should "color Up, Down and Not significant when both thresholds are set and the toggle is on" in { + val op = configured + op.significanceThreshold = Some(0.05) + op.effectSizeThreshold = Some(1.0) + op.colorBySignificance = true + val code = op.generatePythonCode() + // Strict comparisons on the selected p-value column and the effect column: + // a point exactly on a cut-off is not significant. + code should include("significant = table[self.decode_python_template(") + code should include("] < 0.05") + code should include("] > 1.0)") + code should include("] < -1.0)") + code should include("""table["Significance"] = np.select(""") + code should include("""["Up", "Down"],""") + code should include("""default="Not significant",""") + code should include("""color="Significance",""") + code should include(discreteMap) + code should include("""category_orders={"Significance": ["Up", "Down", "Not significant"]}""") + code should not include "color_continuous_scale" + code should include(hline) + code should include(vlines) + } + + it should "accept a significance threshold of exactly one, the schema maximum, and draw it at y = 0" in { + val op = configured + op.significanceThreshold = Some(1.0) + op.effectSizeThreshold = Some(1.0) + op.colorBySignificance = true + val code = op.generatePythonCode() + code should include("""fig.add_hline(y=-np.log10(1.0), line_dash="dash", line_color="gray")""") + code should include(vlines) + code should include("""color="Significance",""") + code should include("] < 1.0") + } + + it should "emit every threshold as a literal Python float, exponent forms included" in { + val pyFloat = """^-?\d+(\.\d+)?([eE][-+]?\d+)?$""".r + // The literal after np.log10( or add_vline(x= ; the y column's np.log10(table[...]) does + // not match because its argument does not start with a digit. + val emittedLiterals = """np\.log10\(([0-9.Ee+-]+)\)|add_vline\(x=-?([0-9.Ee+-]+),""".r + Seq( + (1e-300, 1e21, "1.0E-300", "1.0E21"), + (java.lang.Double.MIN_VALUE, 1.0, "4.9E-324", "1.0") + ).foreach { + case (sig, eff, sigLit, effLit) => + val op = configured + op.significanceThreshold = Some(sig) + op.effectSizeThreshold = Some(eff) + op.colorBySignificance = true + val code = op.generatePythonCode() + val literals = emittedLiterals + .findAllMatchIn(code) + .map(m => Option(m.group(1)).getOrElse(m.group(2))) + .toSeq + literals should contain theSameElementsAs Seq(sigLit, effLit, effLit) + literals.foreach(lit => pyFloat.findFirstIn(lit) shouldBe Some(lit)) + // The category comparisons use the very same literals. + code should include(s"] < $sigLit") + code should include(s"] > $effLit)") + code should include(s"] < -$effLit)") + } + } + + it should "fall back to the continuous coloring when the toggle is on but a threshold is missing" in { + val onlySignificance = configured + onlySignificance.significanceThreshold = Some(0.05) + onlySignificance.colorBySignificance = true + val sigCode = onlySignificance.generatePythonCode() + sigCode should include(hline) + sigCode should not include "add_vline" + assertContinuousColoring(sigCode) + + val onlyEffect = configured + onlyEffect.effectSizeThreshold = Some(1.0) + onlyEffect.colorBySignificance = true + val effCode = onlyEffect.generatePythonCode() + effCode should include(vlines) + effCode should not include "add_hline" + assertContinuousColoring(effCode) + + val neither = configured + neither.colorBySignificance = true + assertContinuousColoring(neither.generatePythonCode()) + } + + it should "render a workflow saved before this change exactly as a default-constructed operator" in { + val saved = objectMapper + .readValue( + """{"operatorType":"VolcanoPlot","effectColumn":"log2fc","pvalueColumn":"pvalue"}""", + classOf[LogicalOp] + ) + .asInstanceOf[VolcanoPlotOpDesc] + val code = saved.generatePythonCode() + code shouldBe configured.generatePythonCode() + code should not include "add_hline" + code should not include "add_vline" + assertContinuousColoring(code) + } + + /** Reads the shapes a stored workflow can hold. Without `contentAs` a JSON string + * stays unconverted inside the Option and the first use throws. + */ + private def readOp(json: String): VolcanoPlotOpDesc = + objectMapper + .readValue(s"""{"operatorType":"VolcanoPlot"$json}""", classOf[LogicalOp]) + .asInstanceOf[VolcanoPlotOpDesc] + + "VolcanoPlotOpDesc thresholds" should "deserialize JSON numbers" in { + val op = readOp(""","significanceThreshold":0.05,"effectSizeThreshold":1""") + op.significanceThreshold shouldBe Some(0.05) + op.effectSizeThreshold shouldBe Some(1.0) + } + + it should "deserialize numeric strings" in { + val op = readOp(""","significanceThreshold":"0.05","effectSizeThreshold":"1.5"""") + op.significanceThreshold shouldBe Some(0.05) + op.effectSizeThreshold shouldBe Some(1.5) + } + + it should "read an absent, null or blank value as unset rather than as zero" in { + readOp("").significanceThreshold shouldBe None + readOp("").effectSizeThreshold shouldBe None + val nulls = readOp(""","significanceThreshold":null,"effectSizeThreshold":null""") + nulls.significanceThreshold shouldBe None + nulls.effectSizeThreshold shouldBe None + val blanks = readOp(""","significanceThreshold":"","effectSizeThreshold":""""") + blanks.significanceThreshold shouldBe None + blanks.effectSizeThreshold shouldBe None + } + + it should "hold Doubles, not the raw JSON values" in { + val op = readOp(""","significanceThreshold":"0.05","effectSizeThreshold":"1.5"""") + op.significanceThreshold.map(_ * 2) shouldBe Some(0.1) + op.effectSizeThreshold.map(_ * 2) shouldBe Some(3.0) + } + + it should "treat a non-finite value read from JSON as unset so no Infinity or NaN reaches the Python" in { + Seq(""""Infinity"""", """"-Infinity"""", """"NaN"""").foreach { raw => + val op = readOp( + s""","significanceThreshold":$raw,"effectSizeThreshold":$raw,"colorBySignificance":true""" + ) + // Jackson does read the text as a Double; the operator must be the one to drop it. + op.significanceThreshold.exists(d => d.isNaN || d.isInfinite) shouldBe true + op.effectSizeThreshold.exists(d => d.isNaN || d.isInfinite) shouldBe true + op.effectColumn = "log2fc" + op.pvalueColumn = "pvalue" + val code = op.generatePythonCode() + code should not include "add_hline" + code should not include "add_vline" + code should not include "Infinity" + code should not include "NaN" + assertContinuousColoring(code) + } + } + + "VolcanoPlotOpDesc schema" should "bound both thresholds so the property panel rejects what the operator ignores" in { + val props = OperatorMetadataGenerator + .generateOperatorJsonSchema(classOf[VolcanoPlotOpDesc]) + .path("properties") + props.path("significanceThreshold").path("exclusiveMinimum").asDouble() shouldBe 0.0 + props.path("significanceThreshold").path("maximum").asDouble() shouldBe 1.0 + props.path("effectSizeThreshold").path("exclusiveMinimum").asDouble() shouldBe 0.0 + props.path("effectSizeThreshold").has("maximum") shouldBe false + } + + "VolcanoPlotOpDesc.colorBySignificance" should "default to false and read a saved value" in { + readOp("").colorBySignificance shouldBe false + readOp(""","colorBySignificance":true""").colorBySignificance shouldBe true + readOp(""","colorBySignificance":false""").colorBySignificance shouldBe false + } + it should "currently render code even when required fields are empty (no assert guard)" in { // Documents the present behavior: VolcanoPlotOpDesc does not assert on // its required fields inside `generatePythonCode`. An empty From d5dadbbee7a79d106c523660ca86f522cd55e289 Mon Sep 17 00:00:00 2001 From: Eugene Date: Sat, 24 Oct 2026 16:32:24 -0700 Subject: [PATCH 2/4] feat(workflow-operator): draw the Volcano Plot cut-offs in the exported script too --- .../volcanoPlot/VolcanoPlotOpDesc.scala | 39 +++++++-- .../volcanoPlot/VolcanoPlotOpDescSpec.scala | 80 +++++++++++++++++++ 2 files changed, 113 insertions(+), 6 deletions(-) diff --git a/common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/visualization/volcanoPlot/VolcanoPlotOpDesc.scala b/common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/visualization/volcanoPlot/VolcanoPlotOpDesc.scala index 2a99b496fb5..262d97b7213 100644 --- a/common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/visualization/volcanoPlot/VolcanoPlotOpDesc.scala +++ b/common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/visualization/volcanoPlot/VolcanoPlotOpDesc.scala @@ -146,15 +146,41 @@ class VolcanoPlotOpDesc extends PythonOperatorDescriptor with PlotlyStandaloneCo // ColorBrewer RdBu end points plus a neutral grey, so the figure reads like other // volcano-plot tooling; the continuous RdBu scale stays when not coloring by category. + // Shared by both code paths so the exported figure cannot drift from the engine's. + private def categoryColorArgs: PythonLiteral = + """color="Significance", + | color_discrete_map={"Up": "#B2182B", "Down": "#2166AC", "Not significant": "#9E9E9E"}, + | category_orders={"Significance": ["Up", "Down", "Not significant"]},""".stripMargin + private def colorArgs: PythonTemplateBuilder = - if (colorByCategory) - pyb"""color="Significance", - | color_discrete_map={"Up": "#B2182B", "Down": "#2166AC", "Not significant": "#9E9E9E"}, - | category_orders={"Significance": ["Up", "Down", "Not significant"]},""" + if (colorByCategory) pyb"$categoryColorArgs" else pyb"""color=$effectColumn, | color_continuous_scale="RdBu",""" + // The exported script's twins of the two helpers above: the same Python with the + // column names as literals rather than decoded, and the very same threshold literals. + private def standaloneSignificanceColumn: String = + if (colorByCategory) { + val sig = significanceCutoff.get + val eff = effectCutoff.get + val pvalueLit = pyStringLiteral(pvalueColumn) + val effectLit = pyStringLiteral(effectColumn) + s"""significant = table[$pvalueLit] < $sig + | table["Significance"] = np.select( + | [significant & (table[$effectLit] > $eff), significant & (table[$effectLit] < -$eff)], + | ["Up", "Down"], + | default="Not significant", + | ) + |""".stripMargin + } else "" + + private def standaloneColorArgs: String = + if (colorByCategory) categoryColorArgs + else + s"""color=${pyStringLiteral(effectColumn)}, + | color_continuous_scale="RdBu",""".stripMargin + /** One dashed line per cut-off that is set: horizontal at -log10 of the p-value * cut-off, vertical at plus and minus the effect-size cut-off. */ @@ -238,15 +264,16 @@ class VolcanoPlotOpDesc extends PythonOperatorDescriptor with PlotlyStandaloneCo | output.write(render_error("No rows with valid p-values.")) | else: | table["-log10(pvalue)"] = -np.log10(table[$pvalueLit]) + | $standaloneSignificanceColumn | fig = px.scatter( | table, | x=$effectLit, | y="-log10(pvalue)", | hover_name=table.columns[0], - | color=$effectLit, - | color_continuous_scale="RdBu", + | $standaloneColorArgs | title="Volcano Plot" | ) + | $thresholdLines | fig.write_json(outputJson) | fig.write_html(outputHtml) | print("Volcano plot saved to " + outputHtml)""".stripMargin diff --git a/common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/visualization/volcanoPlot/VolcanoPlotOpDescSpec.scala b/common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/visualization/volcanoPlot/VolcanoPlotOpDescSpec.scala index defea730a75..69f6b3f68e7 100644 --- a/common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/visualization/volcanoPlot/VolcanoPlotOpDescSpec.scala +++ b/common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/visualization/volcanoPlot/VolcanoPlotOpDescSpec.scala @@ -261,6 +261,86 @@ class VolcanoPlotOpDescSpec extends AnyFlatSpec with Matchers { assertContinuousColoring(code) } + "VolcanoPlotOpDesc.generateStandaloneCode" should "draw no cut-off line and keep the continuous effect-size coloring by default" in { + val code = configured.generateStandaloneCode() + code should not include "add_hline" + code should not include "add_vline" + assertContinuousColoring(code) + code should include("""color="log2fc",""") + } + + it should "draw the dashed cut-off lines while keeping the continuous coloring when the toggle is off" in { + val op = configured + op.significanceThreshold = Some(0.05) + op.effectSizeThreshold = Some(1.0) + val code = op.generateStandaloneCode() + code should include(hline) + code should include(vlines) + assertContinuousColoring(code) + } + + it should "color Up, Down and Not significant with the column names as literals" in { + val op = configured + op.significanceThreshold = Some(0.05) + op.effectSizeThreshold = Some(1.0) + op.colorBySignificance = true + val code = op.generateStandaloneCode() + code should include("""significant = table["pvalue"] < 0.05""") + code should include( + """[significant & (table["log2fc"] > 1.0), significant & (table["log2fc"] < -1.0)]""" + ) + code should include("""color="Significance",""") + code should include(discreteMap) + code should include("""category_orders={"Significance": ["Up", "Down", "Not significant"]},""") + code should not include """color_continuous_scale="RdBu"""" + code should include(hline) + code should include(vlines) + code should not include "decode_python_template" + } + + it should "make the same cut-off and coloring decisions as the engine" in { + // The export is drawn from the same figure, so for every shape a stored + // threshold can take the two paths must agree on which lines to draw and on + // whether to color by category; a rule applied on one side only would make + // the exported figure differ from the one shown in the workflow. + val cutOffLine = """fig\.add_[hv]line\([^\n]*""".r + Seq( + (None, None, false), + (Some(0.05), Some(1.0), false), + (Some(0.05), Some(1.0), true), + (Some(0.05), None, true), + (Some(0.0), Some(1.0), true), + (Some(1.5), Some(-1.0), true), + (Some(Double.NaN), Some(Double.PositiveInfinity), true), + (Some(1e-300), Some(1e21), true) + ).foreach { + case (sig, eff, toggle) => + val op = configured + op.significanceThreshold = sig + op.effectSizeThreshold = eff + op.colorBySignificance = toggle + val engine = op.generatePythonCode() + val export = op.generateStandaloneCode() + cutOffLine.findAllIn(export).toSeq shouldBe cutOffLine.findAllIn(engine).toSeq + export.contains("Significance") shouldBe engine.contains("Significance") + export.contains(discreteMap) shouldBe engine.contains(discreteMap) + } + } + + it should "render a workflow saved before this change exactly as a default-constructed operator" in { + val saved = objectMapper + .readValue( + """{"operatorType":"VolcanoPlot","effectColumn":"log2fc","pvalueColumn":"pvalue"}""", + classOf[LogicalOp] + ) + .asInstanceOf[VolcanoPlotOpDesc] + val code = saved.generateStandaloneCode() + code shouldBe configured.generateStandaloneCode() + code should not include "add_hline" + code should not include "add_vline" + assertContinuousColoring(code) + } + /** Reads the shapes a stored workflow can hold. Without `contentAs` a JSON string * stays unconverted inside the Option and the first use throws. */ From 91ebd1ee19fc6adb4c11575e5ef53c0273f164aa Mon Sep 17 00:00:00 2001 From: Eugene Date: Sat, 14 Nov 2026 02:54:39 -0800 Subject: [PATCH 3/4] fix(workflow-operator): pass volcano plot significance categories straight to px Hand the Up / Down / Not significant categories to px as `color` instead of writing them into `table["Significance"]`, in both the engine template and the exported script, and add a regression test. Remove the redundant single-threshold, hold-Doubles, export toggle-off and export saved-workflow tests, stop the engine saved-workflow test at the equality check, and file the two required-field tests back under generatePythonCode. --- .../volcanoPlot/VolcanoPlotOpDesc.scala | 24 ++++-- .../volcanoPlot/VolcanoPlotOpDescSpec.scala | 85 ++++++------------- 2 files changed, 40 insertions(+), 69 deletions(-) diff --git a/common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/visualization/volcanoPlot/VolcanoPlotOpDesc.scala b/common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/visualization/volcanoPlot/VolcanoPlotOpDesc.scala index 1697bfb4311..0c0976730ea 100644 --- a/common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/visualization/volcanoPlot/VolcanoPlotOpDesc.scala +++ b/common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/visualization/volcanoPlot/VolcanoPlotOpDesc.scala @@ -120,13 +120,16 @@ class VolcanoPlotOpDesc extends PythonVisualizationOpDesc with PlotlyStandaloneC private def colorByCategory: Boolean = colorBySignificance && significanceCutoff.isDefined && effectCutoff.isDefined - /** Strict comparisons: a point exactly on a cut-off is not significant. */ - private def significanceColumn: PythonTemplateBuilder = + /** Strict comparisons: a point exactly on a cut-off is not significant. The categories + * stay a local array handed to px as `color`, so no category column is added to the + * table and an input column named Significance (the effect column, say) keeps its values. + */ + private def significanceCategories: PythonTemplateBuilder = if (colorByCategory) { val sig = significanceCutoff.get val eff = effectCutoff.get pyb"""significant = table[$pvalueColumn] < $sig - | table["Significance"] = np.select( + | significance = np.select( | [significant & (table[$effectColumn] > $eff), significant & (table[$effectColumn] < -$eff)], | ["Up", "Down"], | default="Not significant", @@ -137,10 +140,13 @@ class VolcanoPlotOpDesc extends PythonVisualizationOpDesc with PlotlyStandaloneC // ColorBrewer RdBu end points plus a neutral grey, so the figure reads like other // volcano-plot tooling; the continuous RdBu scale stays when not coloring by category. // Shared by both code paths so the exported figure cannot drift from the engine's. + // px names an array passed as `color` "color", so the legend title comes from labels + // and the category order is keyed by "color". private def categoryColorArgs: PythonLiteral = - """color="Significance", + """color=significance, + | labels={"color": "Significance"}, | color_discrete_map={"Up": "#B2182B", "Down": "#2166AC", "Not significant": "#9E9E9E"}, - | category_orders={"Significance": ["Up", "Down", "Not significant"]},""".stripMargin + | category_orders={"color": ["Up", "Down", "Not significant"]},""".stripMargin private def colorArgs: PythonTemplateBuilder = if (colorByCategory) pyb"$categoryColorArgs" @@ -150,14 +156,14 @@ class VolcanoPlotOpDesc extends PythonVisualizationOpDesc with PlotlyStandaloneC // The exported script's twins of the two helpers above: the same Python with the // column names as literals rather than decoded, and the very same threshold literals. - private def standaloneSignificanceColumn: String = + private def standaloneSignificanceCategories: String = if (colorByCategory) { val sig = significanceCutoff.get val eff = effectCutoff.get val pvalueLit = pyStringLiteral(pvalueColumn) val effectLit = pyStringLiteral(effectColumn) s"""significant = table[$pvalueLit] < $sig - | table["Significance"] = np.select( + | significance = np.select( | [significant & (table[$effectLit] > $eff), significant & (table[$effectLit] < -$eff)], | ["Up", "Down"], | default="Not significant", @@ -215,7 +221,7 @@ class VolcanoPlotOpDesc extends PythonVisualizationOpDesc with PlotlyStandaloneC | return | | table["-log10(pvalue)"] = -np.log10(table[$pvalueColumn]) - | $significanceColumn + | $significanceCategories | fig = px.scatter( | table, | x=$effectColumn, @@ -252,7 +258,7 @@ class VolcanoPlotOpDesc extends PythonVisualizationOpDesc with PlotlyStandaloneC | output.write(render_error("No rows with valid p-values.")) | else: | table["-log10(pvalue)"] = -np.log10(table[$pvalueLit]) - | $standaloneSignificanceColumn + | $standaloneSignificanceCategories | fig = px.scatter( | table, | x=$effectLit, diff --git a/common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/visualization/volcanoPlot/VolcanoPlotOpDescSpec.scala b/common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/visualization/volcanoPlot/VolcanoPlotOpDescSpec.scala index 69f6b3f68e7..38a527fedbc 100644 --- a/common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/visualization/volcanoPlot/VolcanoPlotOpDescSpec.scala +++ b/common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/visualization/volcanoPlot/VolcanoPlotOpDescSpec.scala @@ -44,6 +44,7 @@ class VolcanoPlotOpDescSpec extends AnyFlatSpec with Matchers { private def assertContinuousColoring(code: String): Unit = { code should include("""color_continuous_scale="RdBu"""") + code should not include "np.select" code should not include "Significance" code should not include discreteMap code should not include "category_orders" @@ -91,24 +92,6 @@ class VolcanoPlotOpDescSpec extends AnyFlatSpec with Matchers { assertContinuousColoring(code) } - it should "draw a dashed horizontal line at -log10 of the significance threshold" in { - val op = configured - op.significanceThreshold = Some(0.05) - val code = op.generatePythonCode() - code should include(hline) - code should not include "add_vline" - assertContinuousColoring(code) - } - - it should "draw dashed vertical lines at plus and minus the effect-size threshold" in { - val op = configured - op.effectSizeThreshold = Some(1.0) - val code = op.generatePythonCode() - code should include(vlines) - code should not include "add_hline" - assertContinuousColoring(code) - } - it should "draw both cut-offs while keeping the continuous coloring when the toggle is off" in { val op = configured op.significanceThreshold = Some(0.05) @@ -174,17 +157,32 @@ class VolcanoPlotOpDescSpec extends AnyFlatSpec with Matchers { code should include("] < 0.05") code should include("] > 1.0)") code should include("] < -1.0)") - code should include("""table["Significance"] = np.select(""") + code should include("significance = np.select(") code should include("""["Up", "Down"],""") code should include("""default="Not significant",""") - code should include("""color="Significance",""") + code should include("color=significance,") + code should include("""labels={"color": "Significance"},""") code should include(discreteMap) - code should include("""category_orders={"Significance": ["Up", "Down", "Not significant"]}""") + code should include("""category_orders={"color": ["Up", "Down", "Not significant"]}""") code should not include "color_continuous_scale" code should include(hline) code should include(vlines) } + it should "leave an input column named Significance alone, in the exported script too" in { + // Writing the categories into table["Significance"] would overwrite an input column + // of that name before px reads the table; as the effect column, the x axis would + // show the category labels. The categories go to px directly instead. + val op = configured + op.effectColumn = "Significance" + op.significanceThreshold = Some(0.05) + op.effectSizeThreshold = Some(1.0) + op.colorBySignificance = true + Seq(op.generatePythonCode(), op.generateStandaloneCode()).foreach { code => + code should not include """table["Significance"] =""" + } + } + it should "accept a significance threshold of exactly one, the schema maximum, and draw it at y = 0" in { val op = configured op.significanceThreshold = Some(1.0) @@ -193,7 +191,7 @@ class VolcanoPlotOpDescSpec extends AnyFlatSpec with Matchers { val code = op.generatePythonCode() code should include("""fig.add_hline(y=-np.log10(1.0), line_dash="dash", line_color="gray")""") code should include(vlines) - code should include("""color="Significance",""") + code should include("color=significance,") code should include("] < 1.0") } @@ -254,11 +252,7 @@ class VolcanoPlotOpDescSpec extends AnyFlatSpec with Matchers { classOf[LogicalOp] ) .asInstanceOf[VolcanoPlotOpDesc] - val code = saved.generatePythonCode() - code shouldBe configured.generatePythonCode() - code should not include "add_hline" - code should not include "add_vline" - assertContinuousColoring(code) + saved.generatePythonCode() shouldBe configured.generatePythonCode() } "VolcanoPlotOpDesc.generateStandaloneCode" should "draw no cut-off line and keep the continuous effect-size coloring by default" in { @@ -269,16 +263,6 @@ class VolcanoPlotOpDescSpec extends AnyFlatSpec with Matchers { code should include("""color="log2fc",""") } - it should "draw the dashed cut-off lines while keeping the continuous coloring when the toggle is off" in { - val op = configured - op.significanceThreshold = Some(0.05) - op.effectSizeThreshold = Some(1.0) - val code = op.generateStandaloneCode() - code should include(hline) - code should include(vlines) - assertContinuousColoring(code) - } - it should "color Up, Down and Not significant with the column names as literals" in { val op = configured op.significanceThreshold = Some(0.05) @@ -289,9 +273,10 @@ class VolcanoPlotOpDescSpec extends AnyFlatSpec with Matchers { code should include( """[significant & (table["log2fc"] > 1.0), significant & (table["log2fc"] < -1.0)]""" ) - code should include("""color="Significance",""") + code should include("color=significance,") + code should include("""labels={"color": "Significance"},""") code should include(discreteMap) - code should include("""category_orders={"Significance": ["Up", "Down", "Not significant"]},""") + code should include("""category_orders={"color": ["Up", "Down", "Not significant"]},""") code should not include """color_continuous_scale="RdBu"""" code should include(hline) code should include(vlines) @@ -327,20 +312,6 @@ class VolcanoPlotOpDescSpec extends AnyFlatSpec with Matchers { } } - it should "render a workflow saved before this change exactly as a default-constructed operator" in { - val saved = objectMapper - .readValue( - """{"operatorType":"VolcanoPlot","effectColumn":"log2fc","pvalueColumn":"pvalue"}""", - classOf[LogicalOp] - ) - .asInstanceOf[VolcanoPlotOpDesc] - val code = saved.generateStandaloneCode() - code shouldBe configured.generateStandaloneCode() - code should not include "add_hline" - code should not include "add_vline" - assertContinuousColoring(code) - } - /** Reads the shapes a stored workflow can hold. Without `contentAs` a JSON string * stays unconverted inside the Option and the first use throws. */ @@ -372,12 +343,6 @@ class VolcanoPlotOpDescSpec extends AnyFlatSpec with Matchers { blanks.effectSizeThreshold shouldBe None } - it should "hold Doubles, not the raw JSON values" in { - val op = readOp(""","significanceThreshold":"0.05","effectSizeThreshold":"1.5"""") - op.significanceThreshold.map(_ * 2) shouldBe Some(0.1) - op.effectSizeThreshold.map(_ * 2) shouldBe Some(3.0) - } - it should "treat a non-finite value read from JSON as unset so no Infinity or NaN reaches the Python" in { Seq(""""Infinity"""", """"-Infinity"""", """"NaN"""").foreach { raw => val op = readOp( @@ -413,7 +378,7 @@ class VolcanoPlotOpDescSpec extends AnyFlatSpec with Matchers { readOp(""","colorBySignificance":false""").colorBySignificance shouldBe false } - it should "currently render code even when required fields are empty (no assert guard)" in { + "VolcanoPlotOpDesc.generatePythonCode" should "currently render code even when required fields are empty (no assert guard)" in { // Documents the present behavior: VolcanoPlotOpDesc does not assert on // its required fields inside `generatePythonCode`. An empty // configuration therefore renders syntactically valid Python that From 237888b53b0cff94003560612e99df49e4a3a45e Mon Sep 17 00:00:00 2001 From: Eugene Date: Tue, 17 Nov 2026 19:36:35 -0800 Subject: [PATCH 4/4] fix(workflow-operator): keep volcano plot significance categories in a column no input uses --- .../volcanoPlot/VolcanoPlotOpDesc.scala | 34 +++++++++----- .../volcanoPlot/VolcanoPlotOpDescSpec.scala | 45 +++++++++++++------ 2 files changed, 54 insertions(+), 25 deletions(-) diff --git a/common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/visualization/volcanoPlot/VolcanoPlotOpDesc.scala b/common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/visualization/volcanoPlot/VolcanoPlotOpDesc.scala index 4d15bd623e4..19743072899 100644 --- a/common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/visualization/volcanoPlot/VolcanoPlotOpDesc.scala +++ b/common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/visualization/volcanoPlot/VolcanoPlotOpDesc.scala @@ -179,15 +179,20 @@ class VolcanoPlotOpDesc extends PythonVisualizationOpDesc with PlotlyStandaloneC colorBySignificance && significanceCutoff.isDefined && effectCutoff.isDefined /** Strict comparisons: a point exactly on a cut-off is not significant. The categories - * stay a local array handed to px as `color`, so no category column is added to the - * table and an input column named Significance (the effect column, say) keeps its values. + * go to a new column, Significance with underscores appended until no column has that + * name, so no input column is overwritten. px reads it by name: an array passed as + * `color` is named "color" by px and clashes with a column of that name that x, y or + * hover_name uses. */ private def significanceCategories: PythonTemplateBuilder = if (colorByCategory) { val sig = significanceCutoff.get val eff = effectCutoff.get pyb"""significant = table[$pvalueColumn] < $sig - | significance = np.select( + | significance_column = "Significance" + | while significance_column in table.columns: + | significance_column += "_" + | table[significance_column] = np.select( | [significant & (table[$effectColumn] > $eff), significant & (table[$effectColumn] < -$eff)], | ["Up", "Down"], | default="Not significant", @@ -198,13 +203,17 @@ class VolcanoPlotOpDesc extends PythonVisualizationOpDesc with PlotlyStandaloneC // ColorBrewer RdBu end points plus a neutral grey, so the figure reads like other // volcano-plot tooling; the continuous RdBu scale stays when not coloring by category. // Shared by both code paths so the exported figure cannot drift from the engine's. - // px names an array passed as `color` "color", so the legend title comes from labels - // and the category order is keyed by "color". - private def categoryColorArgs: PythonLiteral = - """color=significance, - | labels={"color": "Significance"}, - | color_discrete_map={"Up": "#B2182B", "Down": "#2166AC", "Not significant": "#9E9E9E"}, - | category_orders={"color": ["Up", "Down", "Not significant"]},""".stripMargin + // The legend and hover call the category column Significance, except when the effect + // column has that name: px would merge the two hover lines that share the label. + private def categoryColorArgs: PythonLiteral = { + val label = + if (effectColumn == "Significance") Seq.empty + else Seq("""labels={significance_column: "Significance"},""") + (Seq("color=significance_column,") ++ label ++ Seq( + """color_discrete_map={"Up": "#B2182B", "Down": "#2166AC", "Not significant": "#9E9E9E"},""", + """category_orders={significance_column: ["Up", "Down", "Not significant"]},""" + )).mkString("\n ") + } private def colorArgs: PythonTemplateBuilder = if (colorByCategory) pyb"$categoryColorArgs" @@ -221,7 +230,10 @@ class VolcanoPlotOpDesc extends PythonVisualizationOpDesc with PlotlyStandaloneC val pvalueLit = pyStringLiteral(pvalueColumn) val effectLit = pyStringLiteral(effectColumn) s"""significant = table[$pvalueLit] < $sig - | significance = np.select( + | significance_column = "Significance" + | while significance_column in table.columns: + | significance_column += "_" + | table[significance_column] = np.select( | [significant & (table[$effectLit] > $eff), significant & (table[$effectLit] < -$eff)], | ["Up", "Down"], | default="Not significant", diff --git a/common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/visualization/volcanoPlot/VolcanoPlotOpDescSpec.scala b/common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/visualization/volcanoPlot/VolcanoPlotOpDescSpec.scala index 1c3d89b82cc..a31641bd503 100644 --- a/common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/visualization/volcanoPlot/VolcanoPlotOpDescSpec.scala +++ b/common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/visualization/volcanoPlot/VolcanoPlotOpDescSpec.scala @@ -41,6 +41,15 @@ class VolcanoPlotOpDescSpec extends AnyFlatSpec with GeneratedCodeAssertionCheck | fig.add_vline(x=-1.0, line_dash="dash", line_color="gray")""".stripMargin private val discreteMap = """color_discrete_map={"Up": "#B2182B", "Down": "#2166AC", "Not significant": "#9E9E9E"}""" + // The categories go to a column no input column is named after, and px reads it by name. + private val categoryColumn = + """significance_column = "Significance" + | while significance_column in table.columns: + | significance_column += "_" + | table[significance_column] = np.select(""".stripMargin + private val categoryLabel = """labels={significance_column: "Significance"},""" + private val categoryOrders = + """category_orders={significance_column: ["Up", "Down", "Not significant"]},""" private def assertContinuousColoring(code: String): Unit = { code should include("""color_continuous_scale="RdBu"""") @@ -208,22 +217,24 @@ class VolcanoPlotOpDescSpec extends AnyFlatSpec with GeneratedCodeAssertionCheck code should include("] < 0.05") code should include("] > 1.0)") code should include("] < -1.0)") - code should include("significance = np.select(") + code should include(categoryColumn) code should include("""["Up", "Down"],""") code should include("""default="Not significant",""") - code should include("color=significance,") - code should include("""labels={"color": "Significance"},""") + // The column's name, not an array, which px would name "color". + code should include("color=significance_column,") + code should include(categoryLabel) code should include(discreteMap) - code should include("""category_orders={"color": ["Up", "Down", "Not significant"]}""") + code should include(categoryOrders) code should not include "color_continuous_scale" code should include(hline) code should include(vlines) } - it should "leave an input column named Significance alone, in the exported script too" in { + it should "keep an effect column named Significance apart from the categories, in the exported script too" in { // Writing the categories into table["Significance"] would overwrite an input column // of that name before px reads the table; as the effect column, the x axis would - // show the category labels. The categories go to px directly instead. + // show the category labels. Labelling the category column Significance as well would + // give two hover lines one label, and px would show only one of them. val op = configured op.effectColumn = "Significance" op.significanceThreshold = Some(0.05) @@ -231,7 +242,15 @@ class VolcanoPlotOpDescSpec extends AnyFlatSpec with GeneratedCodeAssertionCheck op.colorBySignificance = true Seq(op.generatePythonCode(), op.generateStandaloneCode()).foreach { code => code should not include """table["Significance"] =""" + code should include(categoryColumn) + code should include("color=significance_column,") + code should not include "labels=" + code should include(discreteMap) + code should include(categoryOrders) } + // Only that exact name drops the label. + op.effectColumn = "Significance_" + op.generateStandaloneCode() should include(categoryLabel) } it should "accept a significance threshold of exactly one, the schema maximum, and draw it at y = 0" in { @@ -242,7 +261,7 @@ class VolcanoPlotOpDescSpec extends AnyFlatSpec with GeneratedCodeAssertionCheck val code = op.generatePythonCode() code should include("""fig.add_hline(y=-np.log10(1.0), line_dash="dash", line_color="gray")""") code should include(vlines) - code should include("color=significance,") + code should include("color=significance_column,") code should include("] < 1.0") } @@ -435,10 +454,7 @@ class VolcanoPlotOpDescSpec extends AnyFlatSpec with GeneratedCodeAssertionCheck code should include( """[significant & (table["log2fc"] > 1.0), significant & (table["log2fc"] < -1.0)]""" ) - code should include("color=significance,") - code should include("""labels={"color": "Significance"},""") code should include(discreteMap) - code should include("""category_orders={"color": ["Up", "Down", "Not significant"]},""") code should not include """color_continuous_scale="RdBu"""" code should include(hline) code should include(vlines) @@ -448,9 +464,11 @@ class VolcanoPlotOpDescSpec extends AnyFlatSpec with GeneratedCodeAssertionCheck it should "make the same cut-off and coloring decisions as the engine" in { // The export is drawn from the same figure, so for every shape a stored // threshold can take the two paths must agree on which lines to draw and on - // whether to color by category; a rule applied on one side only would make - // the exported figure differ from the one shown in the workflow. + // whether and how to color by category; a rule applied on one side only would + // make the exported figure differ from the one shown in the workflow. val cutOffLine = """fig\.add_[hv]line\([^\n]*""".r + // These lines name no input column, so they read the same in both paths. + val categoryLine = """[^\n]*significance_column[^\n]*""".r Seq( (None, None, false), (Some(0.05), Some(1.0), false), @@ -469,8 +487,7 @@ class VolcanoPlotOpDescSpec extends AnyFlatSpec with GeneratedCodeAssertionCheck val engine = op.generatePythonCode() val export = op.generateStandaloneCode() cutOffLine.findAllIn(export).toSeq shouldBe cutOffLine.findAllIn(engine).toSeq - export.contains("Significance") shouldBe engine.contains("Significance") - export.contains(discreteMap) shouldBe engine.contains(discreteMap) + categoryLine.findAllIn(export).toSeq shouldBe categoryLine.findAllIn(engine).toSeq } }