Closed lingyi-owl closed 1 year ago
Hey could you try an make a minimum reproducible example?
If you install the reprex package you can do something like this:
analysis
, then make a directory analysis/bug_reprex
, and put the input file(s) there.reprex
function around the minimum amount of code that triggers the bad behavior. E.g., something like this:
library(reprex)
reprex( { library(featuretable) pond_ft <- ... put code you used to make the feature table here ... core_microbiome(pond_ft, detection_limit = 20, min_sample_proportion = 0.2) },
wd = "bug_reprex",
venue = "gh",
session_info = TRUE )
* Then you can zip the `bug_reprex` outdirectory with the input files and send them to me. (Or if there is only one input file needed, just send that.)
* And also paste the reprex output into this GitHub issue so I can try and reproduce your problem.
If at all possible, it is helpful to reduce the size of the input file(s) (eg reduce the number of rows and columns). If the smaller file also triggers the error, send that instead of the full input file(s). If it works on the smaller file, then the full file is okay to send.
Let me know if you can do that, and we can go from there!
Actually, I have a feeling you may have rlang
version >= 1.0
. Before you do the other stuff, could you run this R code in your environment and paste the output?
library(rlang)
sessionInfo()
f <- function (predicate) {
rlang::is_expression(rlang::enexpr(predicate))
}
f(function(x) { x })
yes the rlang version is 1.0.1. I am not with that computer now but what version of rlang should I use?
I think as long as rlang
version is < 1.0, it should be okay. There was a change in how the rlang::is_expression
in version 1 of rlang that I think could be the cause of your error.
@mooreryan I am having the same issue and have attempted rolling back rlang to 0.4.12, 0.4.11, 0.4.5, and 0.4.1. All of the attempts result in the same error.
Error in keep_helpers$expr_has_query_function(rlang::enexpr(predicate)) : TODO NEEDED AN EXPRESSION
Edit: Additional context, the command was previously functional when running R v4.0.1 and v4.0.2.
Interesting...I have rlang 0.4.10 and I cannot reproduce. Would you mind making a reprex for me @AlexaBennett?
I loaded the pond_ft since you are familiar with how it should behave with FeatureTable. Let me know if/when you would like me to do the same with my featuretable object
library(featuretable)
load("~/Documents/IMBRE_MCAW_2021/ASV Analysis/data/pond_featuretable.Rdata")
pond_ft
#> <environment: 0x560c115d5b90>
#> attr(,"class")
#> [1] "FeatureTable" "R6"
core_microbiome(pond_ft, detection_limit = 20, min_sample_proportion = 0.2)
#> Error in keep_helpers$expr_has_query_function(rlang::enexpr(predicate)): TODO NEEDED AN EXPRESSION
Created on 2022-05-23 by the reprex package (v2.0.1)
Looks like you have rlang 1.0.2
in your current environment as shown there, which means you're probably running in to the same error as Lingyi was above.
If you are still getting that error with rlang
version < 1
then that would probably be a new bug that I can look at, but as shown in your reprex, it looks like the rlang > 1 bug.
I need to adjust the dependencies to mention that featuretable currently requires rlang < 1. Currently to work around it, you will need to downgrade rlang.
Wow, you are correct. Rstudio is saying v0.4.12 after running
install.packages("https://cran.r-project.org/src/contrib/Archive/rlang/rlang_0.4.12.tar.gz", repos=NULL, type="source")
yet the session is still 1.0.2! It seems that it wasn't detaching and unloading becasue several other loaded packages have it as a dependency.
Upon starting a new session, the core_microbiome function works.
EDIT: @mooreryan your chunk of code is working with v0.4.12. However, once I move the same code outside of reprex() it breaks.
@mooreryan TLDR: While further troubleshooting could flush out the details, I got core_microbiome() to work by manually attaching every package listed in the working reprex() chunk.
The packages section differed when calling session_info() in reprex compared to sessionInfo() on the console. Manually loading libraries shown in session_info() but not in sessionInfo() in conjunction with rlang v0.4.12 can be used as a temporary fix on my end. Would you mind explaining how I would go about navigating the repository for this R project? I am not familiar enough with the structure to being to chase down the fix necessary to use rlang >1.0. I primarily work with Python projects where the scripts and all relevant code hit you in the face once you enter bin :sweat_smile:
The problem line is this one: https://github.com/mooreryan/featuretable/blob/083f3f506a68762c288fca85a6718eae4d1b2568/R/feature_table.R#L1237
That file has the main R6 class...the other files in that directory are mostly S3 wrappers.
Regarding how to fix it: The info about the breaking change is here (here's the relevant part)
is_expression() now returns FALSE for manually constructed expressions that can't be created by the parser. It used to return TRUE for any calls, including those that contain injected objects.
Consider using is_call() or just remove the expression check. In many cases it is fine letting all objects go through when an expression is expected. For instance you can inject objects directly inside dplyr arguments:
x <- seq_len(nrow(data)) dplyr::mutate(data, col = !!x)
I actually have not thought through the implications for either one of these suggested fixes yet, however. But it could be as easy as removing the expression check like they say. You could try doing that and see what happens. featuretable
has a pretty extensive test suite, so you could try running the test suite after you change it and see if anything breaks.
Unfortunately, I don't have any detailed docs to help someone get started with hacking on the codebase, but you will at least need to install some additional deps if you want to run the tests.
This is fixed in the latest release.
Hi, i am using RStudio from a conda created environment. I installed rlang and featuretable using the introction in the gitpage. the featuretable library was installed and loaded succesfully. I could construct a featuretable object and make a plot using the built-in function. However, i had troubles using the core_microbiome function.
Here is the error:
Could you help me with this?
Best,