Skip to content

Commit

Permalink
fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
penqe committed Dec 9, 2024
1 parent 0030eb5 commit b7bcdbf
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 41 deletions.
78 changes: 38 additions & 40 deletions stanzas/manhattan-plot/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,20 +370,20 @@ export default class ManhattanPlot extends Stanza {
if (horizonalDragBegin > horizonalDragEnd) {
horizonalRange = [
((horizonalDragEnd - marginLeft) / areaWidth) *
horizonalRangeLength +
horizonalRange[0],
horizonalRangeLength +
horizonalRange[0],
((horizonalDragBegin - marginLeft) / areaWidth) *
horizonalRangeLength +
horizonalRange[0],
horizonalRangeLength +
horizonalRange[0],
];
} else if (horizonalDragEnd > horizonalDragBegin) {
horizonalRange = [
((horizonalDragBegin - marginLeft) / areaWidth) *
horizonalRangeLength +
horizonalRange[0],
horizonalRangeLength +
horizonalRange[0],
((horizonalDragEnd - marginLeft) / areaWidth) *
horizonalRangeLength +
horizonalRange[0],
horizonalRangeLength +
horizonalRange[0],
];
}
svg.select("#selector").remove();
Expand All @@ -398,21 +398,21 @@ export default class ManhattanPlot extends Stanza {
const maxLog =
verticalRange[1] -
((verticalDragEnd - paddingTop) / drawAreaHeight) *
verticalRangeLength;
verticalRangeLength;
const minLog =
verticalRange[1] -
((verticalDragBegin - paddingTop) / drawAreaHeight) *
verticalRangeLength;
verticalRangeLength;
verticalRange = [minLog, maxLog];
} else if (verticalDragEnd - verticalDragBegin > 0) {
const maxLog =
verticalRange[1] -
((verticalDragBegin - paddingTop) / drawAreaHeight) *
verticalRangeLength;
verticalRangeLength;
const minLog =
verticalRange[1] -
((verticalDragEnd - paddingTop) / drawAreaHeight) *
verticalRangeLength;
verticalRangeLength;
verticalRange = [minLog, maxLog];
}
reRender(this._variants);
Expand Down Expand Up @@ -471,8 +471,8 @@ export default class ManhattanPlot extends Stanza {
delta = (parseFloat(slider.attr("x")) - marginLeft) * -1;
} else if (
parseFloat(slider.attr("x")) +
parseFloat(slider.attr("width")) +
delta >
parseFloat(slider.attr("width")) +
delta >
width
) {
delta =
Expand All @@ -487,8 +487,8 @@ export default class ManhattanPlot extends Stanza {
"left",
((horizonalRange[0] + move) /
getRangeLength(horizonalRange)) *
areaWidth +
"px"
areaWidth +
"px"
)
.style("display", "block");
setRange([horizonalRange[0] + move, horizonalRange[1] + move]);
Expand All @@ -505,8 +505,8 @@ export default class ManhattanPlot extends Stanza {
delta = (parseFloat(slider.attr("x")) - marginLeft) * -1;
} else if (
parseFloat(slider.attr("x")) +
parseFloat(slider.attr("width")) +
delta >
parseFloat(slider.attr("width")) +
delta >
width
) {
delta =
Expand Down Expand Up @@ -678,7 +678,7 @@ export default class ManhattanPlot extends Stanza {

maxLogP = Math.max(...pValueArray);
if (maxLogPInt === undefined) {
maxLogPInt = Math.floor(maxLogP);
maxLogPInt = Math.ceil(maxLogP);
}

if (verticalRange[0] === undefined) {
Expand Down Expand Up @@ -714,15 +714,15 @@ export default class ManhattanPlot extends Stanza {
.attr("cx", function (d) {
return (
((d.pos - horizonalRange[0]) / getRangeLength(horizonalRange)) *
areaWidth +
areaWidth +
marginLeft
);
})
.attr("cy", function (d) {
const logValue = Math.log10(parseFloat(d[pValueKey])) * -1;
return (
((verticalRange[1] - logValue) / getRangeLength(verticalRange)) *
drawAreaHeight +
drawAreaHeight +
paddingTop
);
})
Expand Down Expand Up @@ -766,7 +766,7 @@ export default class ManhattanPlot extends Stanza {
CHROMOSOME_POSIITONS.hg38[d] + CHROMOSOME_NT_LENGTH.hg38[d] / 2;
return (
((pos - horizonalRange[0]) / getRangeLength(horizonalRange)) *
areaWidth +
areaWidth +
marginLeft
);
})
Expand All @@ -787,14 +787,14 @@ export default class ManhattanPlot extends Stanza {
return (
((chromosomeStartPosition[d] - horizonalRange[0]) /
getRangeLength(horizonalRange)) *
areaWidth +
areaWidth +
marginLeft
);
} else {
return (
((chromosomeStartPosition[d] - horizonalRange[0]) /
getRangeLength(horizonalRange)) *
areaWidth +
areaWidth +
marginLeft
);
}
Expand Down Expand Up @@ -832,7 +832,7 @@ export default class ManhattanPlot extends Stanza {
const y =
areaHeight -
((i - verticalRange[0]) / getRangeLength(verticalRange)) *
drawAreaHeight;
drawAreaHeight;
//Calucurate display of scale
const tickNum = 20; //Tick number to display (set by manual)
const tickInterval = Math.floor(
Expand Down Expand Up @@ -896,12 +896,12 @@ export default class ManhattanPlot extends Stanza {
.attr(
"d",
"M " +
(marginLeft - 8) +
", " +
areaHeight +
" H " +
marginLeft +
" Z"
(marginLeft - 8) +
", " +
areaHeight +
" H " +
marginLeft +
" Z"
);

// slider
Expand Down Expand Up @@ -937,13 +937,11 @@ export default class ManhattanPlot extends Stanza {
`
M ${marginLeft} ${areaHeight}
L ${width} ${areaHeight}
L ${
(horizonalRange[1] / chromosomeSumLength.hg38) * areaWidth +
marginLeft
L ${(horizonalRange[1] / chromosomeSumLength.hg38) * areaWidth +
marginLeft
} ${height + 10}
L ${
(horizonalRange[0] / chromosomeSumLength.hg38) * areaWidth +
marginLeft
L ${(horizonalRange[0] / chromosomeSumLength.hg38) * areaWidth +
marginLeft
} ${height + 10}
z
`
Expand All @@ -968,9 +966,9 @@ export default class ManhattanPlot extends Stanza {
ctx.arc(
(d.pos / horizonalRangeLength) * areaWidth,
areaHeight -
((Math.log10(parseFloat(d[pValueKey])) * -1 - lowThresh) *
areaHeight) /
maxLogPInt,
((Math.log10(parseFloat(d[pValueKey])) * -1 - lowThresh) *
areaHeight) /
maxLogPInt,
2,
0,
Math.PI * 2
Expand Down
2 changes: 1 addition & 1 deletion stanzas/manhattan-plot/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"stanza:parameter": [
{
"stanza:key": "data-url",
"stanza:example": "./manhattan-plot/assets/manhattan-plot.json",
"stanza:example": "https://raw.githubusercontent.com/togostanza/togostanza-data/refs/heads/main/samples/json/manhattan-plot.json",
"stanza:description": "Data source URL (json)",
"stanza:required": true
},
Expand Down

0 comments on commit b7bcdbf

Please sign in to comment.