Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

343 show floating point #13

Merged
merged 5 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions frontend/src/components/IndividualModel/ContinuousSummary.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {observer} from "mobx-react";
import PropTypes from "prop-types";
import React, {Component} from "react";

import FloatingPointHover from "@/components/common/FloatingPointHover";
import {ff, fractionalFormatter} from "@/utils/formatters";

@observer
Expand All @@ -25,19 +26,27 @@ class ContinuousSummary extends Component {
<tbody>
<tr>
<td>BMD</td>
<td>{ff(results.bmd)}</td>
<td>
<FloatingPointHover value={results.bmd} />
</td>
</tr>
<tr>
<td>BMDL</td>
<td>{ff(results.bmdl)}</td>
<td>
<FloatingPointHover value={results.bmdl} />
</td>
</tr>
<tr>
<td>BMDU</td>
<td>{ff(results.bmdu)}</td>
<td>
<FloatingPointHover value={results.bmdu} />
</td>
</tr>
<tr>
<td>AIC</td>
<td>{ff(results.fit.aic)}</td>
<td>
<FloatingPointHover value={results.fit.aic} />
</td>
</tr>
<tr>
<td>-2* Log(Likelihood Ratio)</td>
Expand Down
17 changes: 13 additions & 4 deletions frontend/src/components/IndividualModel/DichotomousSummary.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {observer} from "mobx-react";
import PropTypes from "prop-types";
import React, {Component} from "react";

import FloatingPointHover from "@/components/common/FloatingPointHover";
import {ff, fourDecimalFormatter} from "@/utils/formatters";

@observer
Expand All @@ -24,19 +25,27 @@ class DichotomousSummary extends Component {
<tbody>
<tr>
<td>BMD</td>
<td>{ff(results.bmd)}</td>
<td>
<FloatingPointHover value={results.bmd} />
</td>
</tr>
<tr>
<td>BMDL</td>
<td>{ff(results.bmdl)}</td>
<td>
<FloatingPointHover value={results.bmdl} />
</td>
</tr>
<tr>
<td>BMDU</td>
<td>{ff(results.bmdu)}</td>
<td>
<FloatingPointHover value={results.bmdu} />
</td>
</tr>
<tr>
<td>AIC</td>
<td>{ff(results.fit.aic)}</td>
<td>
<FloatingPointHover value={results.fit.aic} />
</td>
</tr>
<tr>
<td>-2* Log(Likelihood Ratio)</td>
Expand Down
13 changes: 10 additions & 3 deletions frontend/src/components/IndividualModel/MaIndividualModels.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {observer} from "mobx-react";
import PropTypes from "prop-types";
import React, {Component} from "react";

import FloatingPointHover from "@/components/common/FloatingPointHover";
import {ff} from "@/utils/formatters";

@observer
Expand Down Expand Up @@ -38,9 +39,15 @@ class MaIndividualModels extends Component {
<td>{model.name}</td>
<td>{ff(model_average.results.priors[i])}</td>
<td>{ff(model_average.results.posteriors[i])}</td>
<td>{ff(model.results.bmdl)}</td>
<td>{ff(model.results.bmd)}</td>
<td>{ff(model.results.bmdu)}</td>
<td>
<FloatingPointHover value={model.results.bmdl} />
</td>
<td>
<FloatingPointHover value={model.results.bmd} />
</td>
<td>
<FloatingPointHover value={model.results.bmdu} />
</td>
</tr>
);
})}
Expand Down
25 changes: 19 additions & 6 deletions frontend/src/components/Output/BayesianResultTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {inject, observer} from "mobx-react";
import PropTypes from "prop-types";
import React, {Component} from "react";

import FloatingPointHover from "@/components/common/FloatingPointHover";
import {maIndex, modelClasses} from "@/constants/outputConstants";
import {ff, fractionalFormatter} from "@/utils/formatters";

Expand Down Expand Up @@ -59,9 +60,15 @@ class BayesianResultTable extends Component {
<td>
{ma ? fractionalFormatter(ma.results.posteriors[index]) : "-"}
</td>
<td>{ff(model.results.bmdl)}</td>
<td>{ff(model.results.bmd)}</td>
<td>{ff(model.results.bmdu)}</td>
<td>
<FloatingPointHover value={model.results.bmdl} />
</td>
<td>
<FloatingPointHover value={model.results.bmd} />
</td>
<td>
<FloatingPointHover value={model.results.bmdu} />
</td>
<td>{ff(model.results.fit.bic_equiv)}</td>
<td>{ff(model.results.gof.residual[0])}</td>
<td>{ff(model.results.gof.roi)}</td>
Expand All @@ -83,9 +90,15 @@ class BayesianResultTable extends Component {
</td>
<td>-</td>
<td>-</td>
<td>{ff(ma.results.bmdl)}</td>
<td>{ff(ma.results.bmd)}</td>
<td>{ff(ma.results.bmdu)}</td>
<td>
<FloatingPointHover value={ma.results.bmdl} />
</td>
<td>
<FloatingPointHover value={ma.results.bmd} />
</td>
<td>
<FloatingPointHover value={ma.results.bmdu} />
</td>
<td>-</td>
<td>-</td>
<td>-</td>
Expand Down
33 changes: 25 additions & 8 deletions frontend/src/components/Output/FrequentistResultTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {inject, observer} from "mobx-react";
import PropTypes from "prop-types";
import React, {Component} from "react";

import FloatingPointHover from "@/components/common/FloatingPointHover";
import {BIN_LABELS} from "@/constants/logicConstants";
import {getPValue, modelClasses, priorClass} from "@/constants/outputConstants";
import {fractionalFormatter} from "@/utils/formatters";
Expand Down Expand Up @@ -210,11 +211,19 @@ class FrequentistRow extends Component {
rowIcon={rowIcon}
modelClasses={modelClasses}
/>
<td>{ff(results.summary.bmdl)}</td>
<td>{ff(results.summary.bmd)}</td>
<td>{ff(results.summary.bmdu)}</td>
<td>
<FloatingPointHover value={results.summary.bmdl} />
</td>
<td>
<FloatingPointHover value={results.summary.bmd} />
</td>
<td>
<FloatingPointHover value={results.summary.bmdu} />
</td>
<td>{ff(results.combined_pvalue)}</td>
<td>{ff(results.summary.aic)}</td>
<td>
<FloatingPointHover value={results.summary.aic} />
</td>
<td>-</td>
<td>-</td>
<RecommendationTd
Expand All @@ -237,11 +246,19 @@ class FrequentistRow extends Component {
rowIcon={rowIcon}
modelClasses={modelClasses}
/>
<td>{ff(results.bmdl)}</td>
<td>{ff(results.bmd)}</td>
<td>{ff(results.bmdu)}</td>
<td>
<FloatingPointHover value={results.bmdl} />
</td>
<td>
<FloatingPointHover value={results.bmd} />
</td>
<td>
<FloatingPointHover value={results.bmdu} />
</td>
<td>{fractionalFormatter(getPValue(dataset.dtype, results))}</td>
<td>{ff(results.fit.aic)}</td>
<td>
<FloatingPointHover value={results.fit.aic} />
</td>
<td>{ff(results.gof.residual[0])}</td>
<td>{ff(results.gof.roi)}</td>
<RecommendationTd
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/components/Output/Multitumor/MsCombo.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ class MsComboSummary extends Component {
render() {
const {results} = this.props,
data = [
["BMD", ff(results.bmd)],
["BMDL", ff(results.bmdl)],
["BMDU", ff(results.bmdu)],
["Slope Factor", ff(results.slope_factor)],
["BMD", ff(results.bmd), results.bmd],
["BMDL", ff(results.bmdl), results.bmdl],
["BMDU", ff(results.bmdu), results.bmdu],
["Slope Factor", ff(results.slope_factor), results.slope_factor],
["Combined Log-Likelihood", ff(results.ll)],
["Combined Log-Likelihood Constant", ff(results.ll_constant)],
];
Expand Down
37 changes: 28 additions & 9 deletions frontend/src/components/Output/Multitumor/ResultTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {inject, observer} from "mobx-react";
import PropTypes from "prop-types";
import React, {Component} from "react";

import FloatingPointHover from "@/components/common/FloatingPointHover";
import {getNameFromDegrees} from "@/constants/modelConstants";
import {ff} from "@/utils/formatters";

Expand Down Expand Up @@ -60,10 +61,18 @@ class ResultTable extends Component {
</a>
</td>
<td>-</td>
<td>{ff(results.bmdl)}</td>
<td>{ff(results.bmd)}</td>
<td>{ff(results.bmdu)}</td>
<td>{ff(results.slope_factor)}</td>
<td>
<FloatingPointHover value={results.bmdl} />
</td>
<td>
<FloatingPointHover value={results.bmd} />
</td>
<td>
<FloatingPointHover value={results.bmdu} />
</td>
<td>
<FloatingPointHover value={results.slope_factor} />
</td>
<td>-</td>
<td>-</td>
<td>-</td>
Expand Down Expand Up @@ -95,12 +104,22 @@ class ResultTable extends Component {
</a>
</td>
<td>{dataset.metadata.name}</td>
<td>{ff(model.bmdl)}</td>
<td>{ff(model.bmd)}</td>
<td>{ff(model.bmdu)}</td>
<td>{ff(model.slope_factor)}</td>
<td>
<FloatingPointHover value={results.bmdl} />
</td>
<td>
<FloatingPointHover value={model.bmd} />
</td>
<td>
<FloatingPointHover value={model.bmdu} />
</td>
<td>
<FloatingPointHover value={model.slope_factor} />
</td>
<td>{ff(model.gof.p_value)}</td>
<td>{ff(model.fit.aic)}</td>
<td>
<FloatingPointHover value={model.fit.aic} />
</td>
<td>{ff(model.gof.residual[0])}</td>
<td>{ff(model.gof.roi)}</td>
</tr>
Expand Down
10 changes: 5 additions & 5 deletions frontend/src/components/Output/Multitumor/Summary.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ class Summary extends Component {
render() {
const {model} = this.props,
data = [
["BMD", ff(model.bmd)],
["BMDL", ff(model.bmdl)],
["BMDU", ff(model.bmdu)],
["Slope Factor", ff(model.slope_factor)],
["AIC", ff(model.fit.aic)],
["BMD", ff(model.bmd), model.bmd],
["BMDL", ff(model.bmdl), model.bmdl],
["BMDU", ff(model.bmdu), model.bmdu],
["Slope Factor", ff(model.slope_factor), model.slope_factor],
["AIC", ff(model.fit.aic), model.fit.aic],
[
<span key="0">
<i>P</i>-Value
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/components/Output/NestedDichotomous/Summary.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ class Summary extends Component {
render() {
const {results} = this.props,
data = [
["BMD", ff(results.summary.bmd)],
["BMDL", ff(results.summary.bmdl)],
["BMDU", ff(results.summary.bmdu)],
["AIC", ff(results.summary.aic)],
["BMD", ff(results.summary.bmd), results.summary.bmd],
["BMDL", ff(results.summary.bmdl), results.summary.bmdl],
["BMDU", ff(results.summary.bmdu), results.summary.bmdu],
["AIC", ff(results.summary.aic), results.summary.aic],
[
<span key={0}>
<i>P</i>-value
Expand Down
22 changes: 22 additions & 0 deletions frontend/src/components/common/FloatingPointHover.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import PropTypes from "prop-types";
import React, {Component} from "react";

import {ff} from "@/utils/formatters";

import Popover from "./Popover";

class FloatingPointHover extends Component {
render() {
const {value} = this.props;
return (
<Popover element={"span"} content={value} title="Floating-Point Value">
{ff(value)}
</Popover>
);
}
}
FloatingPointHover.propTypes = {
value: PropTypes.number.isRequired,
};

export default FloatingPointHover;
13 changes: 11 additions & 2 deletions frontend/src/components/common/TwoColumnTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,19 @@ import _ from "lodash";
import PropTypes from "prop-types";
import React, {Component} from "react";

import FloatingPointHover from "@/components/common/FloatingPointHover";

class TwoColumnTable extends Component {
render() {
const {id, data, label, colwidths} = this.props,
widths = colwidths.map(d => `${d}%`);
widths = colwidths.map(d => `${d}%`),
formatPopover = function(value, raw_value) {
return _.isFinite(raw_value) ? (
<FloatingPointHover value={raw_value} />
) : (
<span>{value}</span>
);
};
return (
<table id={id} className="table table-sm table-bordered">
<colgroup>
Expand All @@ -21,7 +30,7 @@ class TwoColumnTable extends Component {
{data.filter(_.isArrayLike).map((item, i) => (
<tr key={i}>
<td>{item[0]}</td>
<td>{item[1]}</td>
<td>{formatPopover(item[1], item[2])}</td>
</tr>
))}
</tbody>
Expand Down
1 change: 1 addition & 0 deletions tests/analysis/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ def test_nested_dichotomous(self, bmds_complete_nd, data_path, rewrite_data_file
write_excel(df, data_path / "nested_dichotomous.xlsx")
(data_path / "nested_dichotomous.docx").write_bytes(docx.getvalue())

@pytest.mark.xfail(reason="multitumor plotting error") # TODO - remove xfail once fixed
def test_multitumor(self, bmds_complete_mt, data_path, rewrite_data_files):
analysis = Analysis.objects.create(inputs=bmds_complete_mt)

Expand Down
Loading