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

Updates #286

Merged
merged 8 commits into from Oct 15, 2023
Merged

Updates #286

merged 8 commits into from Oct 15, 2023

Conversation

Krgaric
Copy link
Collaborator

@Krgaric Krgaric commented Sep 24, 2023

No description provided.

Copy link
Owner

@leifeld leifeld left a comment

Choose a reason for hiding this comment

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

See comment. Also, it may make sense to fix the size issue in the same PR. The problem only occurs if every 8 hours or if you restart R.

#' labs ggtitle theme_bw theme arrow unit scale_shape_manual element_text
#' scale_x_datetime scale_colour_manual guides
#' scale_x_datetime scale_colour_manual guides rlang
Copy link
Owner

Choose a reason for hiding this comment

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

Is rlang an object or function exported by ggplot2? I thought it was an independent package. You need to add something like this to every function that uses .data: @importFrom rlang .data. I.e., also to the other autoplot methods that use this. Then recompile the documentation.

Copy link
Owner

@leifeld leifeld left a comment

Choose a reason for hiding this comment

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

Thanks, please fix as per my comments, then we'll see if it still produces errors (other than the ones I expect).

rDNA/rDNA/tests/testthat/test-phasetransitions.R Outdated Show resolved Hide resolved
rDNA/rDNA/tests/testthat/test-phasetransitions.R Outdated Show resolved Hide resolved
rDNA/rDNA/tests/testthat/test-phasetransitions.R Outdated Show resolved Hide resolved
rDNA/rDNA/tests/testthat/test-phasetransitions.R Outdated Show resolved Hide resolved
@leifeld
Copy link
Owner

leifeld commented Oct 3, 2023

Let's try to wrap this PR up soon. Did you want to add anything else regarding aes_string or backbone plotting? Can you make the requested changes? Thanks.

@Krgaric
Copy link
Collaborator Author

Krgaric commented Oct 3, 2023

All previous comments resolved. There is still an issue with autoplot function in dna_backbone. Here is the error log:

Error in ggplot2::geom_line(): ! Problem while computing aesthetics. ℹ Error occurred in the 1st layer. Caused by error: ! Can't subset .dataoutside of a data mask context. Runrlang::last_trace()` to see where the error occurred.

rlang::last_trace()
<error/rlang_error>
Error in ggplot2::geom_line():
! Problem while computing aesthetics.
ℹ Error occurred in the 1st layer.
Caused by error:
! Can't subset .data outside of a data mask context.


Backtrace:

  1. ├─base (local) <fn>(x)
  2. ├─ggplot2:::print.ggplot(x)
  3. │ ├─ggplot2::ggplot_build(x)
  4. │ └─ggplot2:::ggplot_build.ggplot(x)
  5. │ └─ggplot2:::by_layer(...)
  6. │ ├─rlang::try_fetch(...)
  7. │ │ ├─base::tryCatch(...)
  8. │ │ │ └─base (local) tryCatchList(expr, classes, parentenv, handlers)
  9. │ │ │ └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
  10. │ │ │ └─base (local) doTryCatch(return(expr), name, parentenv, handler)
  11. │ │ └─base::withCallingHandlers(...)
  12. │ └─ggplot2 (local) f(l = layers[[i]], d = data[[i]])
  13. │ └─l$compute_aesthetics(d, plot)
  14. │ └─ggplot2 (local) compute_aesthetics(..., self = self)
  15. │ └─ggplot2:::scales_add_defaults(...)
  16. │ └─base::lapply(aesthetics[new_aesthetics], eval_tidy, data = data)
  17. │ └─rlang (local) FUN(X[[i]], ...)
  18. ├─rlang::.data[["iteration"]]
  19. └─rlang:::[[.rlang_fake_data_pronoun(rlang::.data, "iteration")
  20. └─rlang:::stop_fake_data_subset(call)
  21. └─rlang::abort(...)
    

The error occurs somewhere between lines 2851 and 2956. I checked all the geom_lines where "iteration" appears but cannot find anything odd.

@leifeld
Copy link
Owner

leifeld commented Oct 3, 2023

Thanks. I hope you can figure it out. Let me tag @TimHenrichsen . Tim, can you help? Kristijan fixed the aes_string problem, but there is some issue with the backbone autoplot code.

@TimHenrichsen
Copy link
Collaborator

Hi Kristijan and thanks for all the work! I could reproduce your issue and noticed that I also couldn't compute other autoplot functions. I checked the .data help file which says the following:

The .data pronoun is automatically created for you by data-masking functions using the tidy eval framework. You don't need to import rlang::.data or use library(rlang) to work with this pronoun.

However, the .data object exported from rlang is useful to import in your package namespace to avoid a ⁠R CMD check⁠ note when referring to objects from the data mask. R does not have any way of knowing about the presence or absence of .data in a particular scope so you need to import it explicitly or equivalently declare it with utils::globalVariables(".data").

Note that rlang::.data is a "fake" pronoun. Do not refer to rlang::.data with the ⁠rlang::⁠ qualifier in data masking code. Use the unqualified .data symbol that is automatically put in scope by data-masking functions.

Could you test if the autoplot functions work, when you remove rlang:: before every .data command?

@Krgaric
Copy link
Collaborator Author

Krgaric commented Oct 3, 2023

Hi Kristijan and thanks for all the work! I could reproduce your issue and noticed that I also couldn't compute other autoplot functions. I checked the .data help file which says the following:

The .data pronoun is automatically created for you by data-masking functions using the tidy eval framework. You don't need to import rlang::.data or use library(rlang) to work with this pronoun.

However, the .data object exported from rlang is useful to import in your package namespace to avoid a ⁠R CMD check⁠ note when referring to objects from the data mask. R does not have any way of knowing about the presence or absence of .data in a particular scope so you need to import it explicitly or equivalently declare it with utils::globalVariables(".data").

Note that rlang::.data is a "fake" pronoun. Do not refer to rlang::.data with the ⁠rlang::⁠ qualifier in data masking code. Use the unqualified .data symbol that is automatically put in scope by data-masking functions.

Could you test if the autoplot functions work, when you remove rlang:: before every .data command?

Dear @TimHenrichsen, thank you, it works now. It plots as supposed, but there are some warning messages that should be checked out:
Warning messages:
1: Removed 499 rows containing missing values (geom_line()).
2: Removed 998 rows containing missing values (geom_line()).
3: Removed 499 rows containing missing values (geom_line()).

use the gridExtra package to arrange the diagnostics in a single plot

library("gridExtra")
grid.arrange(p[[1]], p[[2]], p[[3]], p[[4]])
Don't know how to automatically pick scale for object of type . Defaulting to continuous.
Don't know how to automatically pick scale for object of type . Defaulting to continuous.
Warning messages:
1: Removed 499 rows containing missing values (geom_line()).
2: Removed 998 rows containing missing values (geom_line()).
3: Removed 499 rows containing missing values (geom_line()).

This was ran on the sample example. Is something like that expected?

Thank you for the help so far!

@leifeld
Copy link
Owner

leifeld commented Oct 3, 2023

The checks below say that you need to put rlang in the DESCRIPTION file under Imports.

@Krgaric
Copy link
Collaborator Author

Krgaric commented Oct 3, 2023

The checks below say that you need to put rlang in the DESCRIPTION file under Imports.

Resolved.

@leifeld
Copy link
Owner

leifeld commented Oct 3, 2023

You forgot the comma in the line before. See new errors in the check log below.

Comma added.
@leifeld leifeld merged commit af8bdcb into leifeld:master Oct 15, 2023
8 of 9 checks passed
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.

None yet

3 participants