-
Notifications
You must be signed in to change notification settings - Fork 0
Refactor summary report generation: improve formatting and update example paths #33
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
Open
AbhirupaGhosh
wants to merge
1
commit into
main
Choose a base branch
from
minor-update-summary
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+20
−13
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,12 +9,14 @@ | |
| #' | ||
| #' @examples | ||
| #' generateSummary( | ||
| #' metadata_parquet = "results/metadata.parquet", | ||
| #' out_path = "results/" | ||
| #' metadata_parquet = "data/metadata.parquet", | ||
| #' out_path = "data/" | ||
| #' ) | ||
| #' | ||
| #' @export | ||
| generateSummary <- function(metadata_parquet, out_path) { | ||
| generateSummary <- function(metadata_parquet, | ||
| out_path | ||
| ) { | ||
| # Little helper to apply distinct + non-empty + sorted vector | ||
| clean_distinct <- function(df, col) { | ||
| df |> | ||
|
|
@@ -60,7 +62,9 @@ generateSummary <- function(metadata_parquet, out_path) { | |
| dplyr::pull() | ||
|
|
||
| # Core summaries | ||
| TotalEntryCount <- metadata |> dplyr::count() | ||
| TotalEntryCount <- metadata |> | ||
| dplyr::count() | ||
|
|
||
| CleanEntryCount <- metadata |> | ||
| dplyr::distinct(genome.genome_id) |> | ||
| dplyr::count() | ||
|
|
@@ -172,7 +176,7 @@ ResPropbyDrugClass <- drug_class_calls |> | |
| # Header | ||
| write_new( | ||
| md_path, | ||
| sprintf("# AMR summary report for *%s*", Species_name) | ||
| sprintf("# AMR summary report for *%s*", paste(Species_name, collapse = ", ")) | ||
| ) | ||
|
|
||
| # Basic stats | ||
|
|
@@ -218,18 +222,14 @@ ResPropbyDrugClass <- drug_class_calls |> | |
| append_lines(md_path, c("## Isolation sources", "", md_tbl(SourceCount), "", "")) | ||
| append_lines(md_path, c("## Hosts", "", md_tbl(HostCount), "", "")) | ||
|
|
||
|
|
||
| # Hosts as a simple list | ||
| # if (length(Host)) { | ||
| # append_lines(md_path, c("## Hosts", "", paste0("- ", Host), "", "")) | ||
| # } | ||
| invisible(md_path) | ||
| } | ||
|
|
||
|
|
||
| #' Write all summary plots to file(s) | ||
| #' | ||
| #' Expects `metadata_parquet` to be the output of `runDataProcessing()`'s | ||
| #' `cleanData()` step (or an export of the resulting `metadata` table), since | ||
| #' Expects `metadata_parquet` to be the output of | ||
| #' `cleanMetadata()` step (or an export of the resulting `metadata` table), since | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| #' `drug_abbr`, `drug_class`, and `num_resistant_classes` are only populated | ||
| #' after that step joins in the reference drug tables. | ||
| #' | ||
|
|
@@ -238,9 +238,16 @@ ResPropbyDrugClass <- drug_class_calls |> | |
| #' | ||
| #' @return Invisibly returns the path to the written PDF (all plots as | ||
| #' separate pages of one multi-page file). | ||
| #' | ||
| #' @examples | ||
| #' generatePlots( | ||
| #' metadata_parquet = "data/metadata.parquet", | ||
| #' out_path = "data/" | ||
| #' ) | ||
| #' @export | ||
| generatePlots <- function(metadata_parquet, | ||
| out_path) { | ||
| out_path | ||
| ) { | ||
| if (!dir.exists(out_path)) { | ||
| dir.create(out_path, showWarnings = FALSE, recursive = TRUE) | ||
| } | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe
@exampleswill look for input files in a different location --inst/extdata. right, @amcim @eboyer221? So that needs to be fixed -- until then, to avoid R CMD check errors, we may need to add\dontrun{}/\donttest{}.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, you're right @jananiravi. There's no example data actually included in the package (inst/extdata only has some reference files, not this kind of data), so this example won't run in an automated check.
Between \dontrun{} and \donttest{}: I'd go with \dontrun{} since it just skips the example entirely, which matches what we already do in the same situation elsewhere in the package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They're planning to add examples, Emily. Also, the examples will be visible on the help page but won't run when clicked on -- that's the distinction, right?