Skip to content

Commit

Permalink
Use correct axis to infer mutations vs divergence
Browse files Browse the repository at this point in the history
Divergence is on the y-axis in clock layouts and the x-axis in rect layouts
  • Loading branch information
jameshadfield committed Mar 13, 2020
1 parent c74edc5 commit 3380872
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/components/tree/phyloTree/grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,14 +341,14 @@ export const addGrid = function addGrid() {
this.svg.selectAll(".axisText").remove();
if (layout === 'rect' || layout === "clock") {
let label = "Date";
if (this.distance === "div" || layout === 'clock') {
// This is a heuristic to determine whether this data
// measures "substitutions per site" or "substitutions"
if (this.yScale.domain()[0] > 5) {
label = "Mutations";
} else {
label = "Divergence";
}
// We use the same heursitic as in `getRateEstimate` to decide whether this data
// measures "substitutions per site" or "substitutions"
if (this.layout === 'clock') {
// In clock view the divergence / mutations axis is vertical
label = this.yScale.domain()[0] > 5 ? "Mutations" : "Divergence";
} else if (this.distance === "div") {
// In rectangular view the divergence / mutations axis is horizontal
label = this.xScale.domain()[1] > 5 ? "Mutations" : "Divergence";
}

/* Add a x-axis label */
Expand All @@ -361,7 +361,7 @@ export const addGrid = function addGrid() {
.style("fill", this.params.tickLabelFill)
.style("text-anchor", "middle")
.attr("x", this.xScale.range()[1] / 2)
.attr("y", this.yScale.range()[1] + this.params.margins.bottom - 6)
.attr("y", this.yScale.range()[1] + this.params.margins.bottom - 6);

/* Add a rotated y-axis label in clock view */
if (layout === 'clock') {
Expand All @@ -373,7 +373,7 @@ export const addGrid = function addGrid() {
.style("font-family", this.params.fontFamily)
.style("fill", this.params.tickLabelFill)
.style("text-anchor", "middle")
.attr('transform', 'translate(' + 10 + ',' + (this.yScale.range()[1] / 2) + ') rotate(-90)')
.attr('transform', 'translate(' + 10 + ',' + (this.yScale.range()[1] / 2) + ') rotate(-90)');
}
}

Expand Down

0 comments on commit 3380872

Please sign in to comment.