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

Update hypothesis.R to allow for backquoted parameters #1722

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

stemangiola
Copy link

@stemangiola stemangiola commented Jan 5, 2025

I happen to have this parameter ethnicity_groupsNativeAmerican&PacificIslander, for a series of fits (30K genes, with 5K samples each, in a biological study) that take ~ 2 weeks, to run.

The character & would normally cause an error.

Instead of rerunning everything, I have enabled hypothesis() to allow for backquotes, such as

hypothesis(
          c(
            "Europeans" = "(ethnicity_groupsAfrican
    + ethnicity_groupsEastAsian
    + ethnicity_groupsHispanicDLatinAmerican
    + ethnicity_groupsSouthAsian
    + `ethnicity_groupsNativeAmerican&PacificIslander`) / 5 = 0"

If this is side-effect-free, I think it would be a great addition to give more flexibility to users. Afterall the modelling worked with atypical names, it would make sense the whole pipeline would.

If you are interested I could design a unit test.

Note: This PR is based on a ChatGPT suggestion that I cleaned up.

escape backquoted parameters from find_vars regexp
@paul-buerkner
Copy link
Owner

I think this would be good feature. Thank you!

Adding some unit tests for this would be good. I suggest to add some in local tests (in tests/local/tests.models-5.R) would be great.

Can you also slightly edit the style to fit with the general code style of brms. That is, use <- instead of = for assignments. Use function(...) instead of function (...). Space before {.

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