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

2. Adding model_viewer Shiny app #158

Merged
merged 28 commits into from
Oct 9, 2023
Merged

2. Adding model_viewer Shiny app #158

merged 28 commits into from
Oct 9, 2023

Conversation

gareth-j
Copy link
Contributor

@gareth-j gareth-j commented Oct 8, 2023

NOTE: #147 should go in before this PR.

  • Summary of changes (Bug fix, feature, docs update, ...)

This adds a new Shiny app to view model output. It takes the output of a model run and lets the user plot a range of differnet plots and a prediction field over a leaflet map.

  • Please check if the PR fulfills these requirements
  • Closes Model output visualisation Shiny app #111
  • Tests added and passed
  • All code checks passing - styler run over code
  • Vignettes updated/added
  • Added an entry in the latest CHANGELOG.md file if fixing a bug or adding a new feature
  • Any new libraries added to DESCRIPTION

@gareth-j gareth-j linked an issue Oct 8, 2023 that may be closed by this pull request
Copy link
Contributor

@XueqingYin XueqingYin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Thank you @gareth-j . I’ve test it on the covid data in Bristol, but the model_viewer app returns the following error:
    model_viewer_error

This is because of the wrong argument name used when calling the create_prediction_field function within the functionmodel_viewer_shiny(). It should be
create_prediction_field (…, data_dist = data_type ,…), rather than create_prediction_field (…, data_type = data_type ,…) in shiny_modelviewer.R
Alternatively, this can be fixed by changing the argument name “data_dist” in create_prediction_field() in model.parse.R into “data_type”, i.e, create_prediction_field<- function (…, data_type = "Poisson"){ }

  1. In the create_prediction_field() function in model.parse.R, it should be if (data_dist == "poisson") z <- base::exp(z)
    rather than if (data_type == "poisson") z <- base::exp(z)

  2. I also checked the prior shiny app, but it gave an error:
    priors_app_error

Solution: I think we should use the following codes in shiny_priors.R to check and set the default CRS if it’s not given.

if ( (is.null(mesh_crs) || is.na(mesh_crs)) && (is.na(spatial_crs) || is.null(spatial_crs)) ) {
  warning("Cannot read CRS from mesh or spatial_data, using default CRS = +proj=longlat +datum=WGS84")
  crs <- "+proj=longlat +datum=WGS84"
} else if (is.na(mesh_crs) || is.null(mesh_crs) ) {
  crs <- spatial_crs
} else {
  crs <- mesh_crs
}

Copy link
Contributor

@XueqingYin XueqingYin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @gareth-j, the errors are gone now.

Just a remainder that in the shiny_priors.R, the function launching the app is called interactive_priors() , but in the vignette priors_app.rmd, it's called fdmr::model_builder(...)

@gareth-j
Copy link
Contributor Author

gareth-j commented Oct 9, 2023

Thanks @gareth-j, the errors are gone now.

Just a remainder that in the shiny_priors.R, the function launching the app is called interactive_priors() , but in the vignette priors_app.rmd, it's called fdmr::model_builder(...)

I just noticed that and fixed it, thanks!

@gareth-j gareth-j merged commit 35e30b9 into devel Oct 9, 2023
@gareth-j gareth-j deleted the Iss111/ModelOutViz branch October 18, 2023 10:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Model output visualisation Shiny app
2 participants