Skip to content

Commit

Permalink
fix missing "no visible binding variable" errors
Browse files Browse the repository at this point in the history
  • Loading branch information
cpauvert committed Aug 28, 2023
1 parent afc2fd5 commit fb70573
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
12 changes: 6 additions & 6 deletions R/read_biotyper_report.R
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ read_biotyper_report <- function(path, best_hits = TRUE, long_format = TRUE) {
# Remove the spot for which no peaks were detected, and warn the user
breport <- tibble::as_tibble(breport) %>%
# Empty sample_name are considered logical and this is undesirable
dplyr::mutate(sample_name = as.character(sample_name)) %>%
dplyr::mutate("sample_name" = as.character(.data$sample_name)) %>%
dplyr::filter(.data$bruker_01_species != "no peaks found")
if (sum(no_peak_lgl) > 0) {
warning(
Expand Down Expand Up @@ -122,19 +122,19 @@ read_biotyper_report <- function(path, best_hits = TRUE, long_format = TRUE) {
names_to = c("hit_rank", "type"),
names_pattern = "bruker_(.*)_(.*)"
) %>%
tidyr::pivot_wider(names_from = type, values_from = value)
tidyr::pivot_wider(names_from = "type", values_from = "value")

report_num <- breport %>%
dplyr::select(
c("spot", "sample_name") |
tidyselect::all_of(c("spot", "sample_name")) |
tidyselect::contains("bruker") & tidyselect::where(is.numeric)
) %>%
tidyr::pivot_longer(
!c("spot", "sample_name"),
!tidyselect::all_of(c("spot", "sample_name")),
names_to = c("hit_rank", "type"),
names_pattern = "bruker_(.*)_(.*)"
) %>%
tidyr::pivot_wider(names_from = type, values_from = value)
tidyr::pivot_wider(names_from = "type", values_from = "value")


# Combine the two sub-tables and convert hit rank to integer for further filtering.
Expand All @@ -143,7 +143,7 @@ read_biotyper_report <- function(path, best_hits = TRUE, long_format = TRUE) {
report_num,
by = c("spot", "sample_name", "hit_rank")
) %>%
dplyr::mutate(hit_rank = strtoi(hit_rank, base = 10L)) %>%
dplyr::mutate("hit_rank" = strtoi(.data$hit_rank, base = 10L)) %>%
dplyr::relocate(
c(
"spot", "sample_name", "hit_rank",
Expand Down
12 changes: 6 additions & 6 deletions dev/import-data.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ read_biotyper_report <- function(path, best_hits = TRUE, long_format = TRUE) {
# Remove the spot for which no peaks were detected, and warn the user
breport <- tibble::as_tibble(breport) %>%
# Empty sample_name are considered logical and this is undesirable
dplyr::mutate(sample_name = as.character(sample_name)) %>%
dplyr::mutate("sample_name" = as.character(.data$sample_name)) %>%
dplyr::filter(.data$bruker_01_species != "no peaks found")
if (sum(no_peak_lgl) > 0) {
warning(
Expand Down Expand Up @@ -181,19 +181,19 @@ read_biotyper_report <- function(path, best_hits = TRUE, long_format = TRUE) {
names_to = c("hit_rank", "type"),
names_pattern = "bruker_(.*)_(.*)"
) %>%
tidyr::pivot_wider(names_from = type, values_from = value)
tidyr::pivot_wider(names_from = "type", values_from = "value")
report_num <- breport %>%
dplyr::select(
c("spot", "sample_name") |
tidyselect::all_of(c("spot", "sample_name")) |
tidyselect::contains("bruker") & tidyselect::where(is.numeric)
) %>%
tidyr::pivot_longer(
!c("spot", "sample_name"),
!tidyselect::all_of(c("spot", "sample_name")),
names_to = c("hit_rank", "type"),
names_pattern = "bruker_(.*)_(.*)"
) %>%
tidyr::pivot_wider(names_from = type, values_from = value)
tidyr::pivot_wider(names_from = "type", values_from = "value")
# Combine the two sub-tables and convert hit rank to integer for further filtering.
Expand All @@ -202,7 +202,7 @@ read_biotyper_report <- function(path, best_hits = TRUE, long_format = TRUE) {
report_num,
by = c("spot", "sample_name", "hit_rank")
) %>%
dplyr::mutate(hit_rank = strtoi(hit_rank, base = 10L)) %>%
dplyr::mutate("hit_rank" = strtoi(.data$hit_rank, base = 10L)) %>%
dplyr::relocate(
c(
"spot", "sample_name", "hit_rank",
Expand Down
8 changes: 4 additions & 4 deletions tests/testthat/test-read_biotyper_report.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ test_that("read_biotyper_report with best_hits is the same whatever format", {
)
})
test_that("read_biotyper_report is empty when no peaks are found", {
expect_equal(
nrow(read_biotyper_report(biotyper_empty)), 0
)
expect_warning(
read_biotyper_report(biotyper_empty), "Remove"
out <- read_biotyper_report(biotyper_empty), "Remove"
)
expect_equal(
nrow(out), 0
)
})

0 comments on commit fb70573

Please sign in to comment.