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

Bug fix for compound labels in plot_volcano function #24

Closed
delfarahalireza opened this issue Mar 14, 2024 · 2 comments
Closed

Bug fix for compound labels in plot_volcano function #24

delfarahalireza opened this issue Mar 14, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@delfarahalireza
Copy link
Contributor

delfarahalireza commented Mar 14, 2024

The if else logic that I previously wrote to add compoundName to volcano plots has a bug since it seems like you can have only have one command within the if statement to add to ggplot:

e.g. you can do:

df %>% ggplot(...) +
{if(...) {
geom_point(...)
}
}

but you cannot do:

df %>% ggplot(...) +
{if(...) {
geom_point(...) +
geom_text
}
}

instead this would need to be:

df %>% ggplot(...) +
{if(...) {
geom_point(...)
}
} +
{if(...) {
geom_text(...)
}
}
@delfarahalireza delfarahalireza added the bug Something isn't working label Mar 14, 2024
@delfarahalireza delfarahalireza self-assigned this Mar 14, 2024
@shackett
Copy link
Collaborator

The if else logic that I previously wrote to add compoundName to volcano plots has a bug since it seems like you can have only have one command within the if statement to add to ggplot:

e.g. you can do:

df %>% ggplot(...) +
{if(...) {
geom_point(...)
}
}

but you cannot do:

df %>% ggplot(...) +
{if(...) {
geom_point(...) +
geom_text
}
}

instead this would need to be:

df %>% ggplot(...) +
{if(...) {
geom_point(...)
}
} +
{if(...) {
geom_text(...)
}
}

Piping into an if statement isn't ideal. This isn't very readable. Its probably best to just assign the initial ggplot() call as a grob, and then build up the grob incrementally within if/else statements:

grob <- ggplot(x, aes(...))

if ({true condition}) {
    grob <- grob + geom_xxx()
} else {
    grob <- grob + geom_xxx() + geom_yyy()
}

@delfarahalireza
Copy link
Contributor Author

Thanks @shackett

Committed changes per your suggestion here: #25
Can you please review?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants