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

Create html and rds treeviews by default #18

Merged
merged 7 commits into from
Jan 20, 2023

Conversation

russHyde
Copy link
Collaborator

@russHyde russHyde commented Dec 6, 2022

Fix: #14

Adds a output_format parameter for both treeview() and save_trees() that allows the user to specify whether they would like to have the interactive ggtree objects saved in .rds files (as ggtree objects) or in .html files (as htmlwidgets).

By default the argument for output_format is c("rds", "html"), in which case it creates both .rds and .html versions of the interactive plots (as requested by Erik in meeting 2023-01-12).

The sina_output_format parameter that was previously included in the treeview() signature has been removed. Now the new output_format parameter determines the output format for the interactive versions of both sina plots and tree plots.

Tests have been added to ensure that the correct output files are created when save_trees() is called: a noninteractive plot is always made, and an interactive html and/or interactive rds plot is made based on user arguments to save_trees()

@russHyde russHyde changed the base branch from master to staging-wp5 December 7, 2022 10:33
@russHyde
Copy link
Collaborator Author

The initial version of this added a output_format to the treeview() parameters.
In the "sinaplot-rds" branch (now merged into "staging-wp5" but not yet "master"), a sina_output_format parameter was added.
It seems appropriate to rename the output_format as tree_output_format, or to use a single output_format parameter to control both tree output and sina output.

WDYT @jr-nicola

@jr-nicola
Copy link

I'd lean towards having a single output_format that controls both. For the app, if we want the .rds for one, we'd always want the .rds for the other. There might be times when Erik only wants the .html for the treeview but that seems less likely after the app is deployed.

@russHyde
Copy link
Collaborator Author

Thanks. I'll sort that out.

@russHyde russHyde force-pushed the optional-html-treeview branch from a687316 to 8ddf13b Compare January 17, 2023 17:29
@russHyde russHyde changed the title Draft: Optional html treeview Create html and rds treeviews by default Jan 17, 2023

filepaths
}

describe("save_trees", {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These tests have been constructed so that they look virtually identical. They could reasonably be rewritten as a single testthat block parameterised by the different arguments to save_trees using {patrick}. Adding the extra dependency seemed over the top to reduce 4 simple tests to 1, though.

Choose a reason for hiding this comment

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

Happy to have a little duplication to avoid extra dependencies

@russHyde russHyde requested a review from jr-nicola January 17, 2023 17:40
@russHyde
Copy link
Collaborator Author

@jr-nicola I've changed a dependency. The package now requires {htmlwidgets} >= 1.6.0.
I found, while running the tests associated with this PR, that with htmlwidgets < 1.6.0, I was getting an error when using system R and lots of pandoc warnings when using RStudio.

# System R
Error in `system(paste(shQuote(pandoc_path), "--version"), intern = TRUE)`: error in running command
Backtrace:
  1. tfpscanner:::save_trees(...)
       at test-plot_tree.R:101:4
  2. htmlwidgets::saveWidget(...)
       at tfpscanner/R/plot_tree.R:150:4
  3. htmlwidgets:::pandoc_available()
  4. htmlwidgets:::find_pandoc()
  5. base::lapply(...)
  6. htmlwidgets (local) FUN(X[[i]], ...)
  7. htmlwidgets:::get_pandoc_version(src)
 10. base::system(paste(shQuote(pandoc_path), "--version"), intern = TRUE)
# RStudio
[WARNING] Deprecated: --self-contained. use --embed-resources --standalone

These originated from the discovery and use of different versions of pandoc in {htmlwidgets} and {rmarkdown}. In brief, htmlwidgets was discovering the 'system' pandoc (2.9* on my machine) and creating the appropriate arguments for that version of pandoc but then sending those arguments to an 'RStudio'-embedded pandoc (2.19* on my machine; this is the one that rmarkdown uses when inside RStudio) for which they are invalid.

As of htmlwidgets 1.6.0, the method for discovering/using pandoc is aligned between htmlwidgets and rmarkdown.

Pinning against htmlwidgets >= 1.6.0 should prevent these clashes, and removed the errors and warnings on my machine.

Copy link

@jr-nicola jr-nicola left a comment

Choose a reason for hiding this comment

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

LGTM

@russHyde russHyde merged commit 0c0daf3 into staging-wp5 Jan 20, 2023
@russHyde russHyde deleted the optional-html-treeview branch January 20, 2023 12:04
This was referenced Jul 6, 2023
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.

2 participants