You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When the levels of a categorical moderator are not capitalised to begin with, orchard_plot() breaks with changes to 'upper' or 'tree.order' options. Below I demonstrate with a reproducible example where I turn the factor to lowercase first. I also provide a workaround for the 'tree.order' break that might help you come up with a fix.
To Reproduce
# NON-CAPITALISED CATEGORIES --------------------------------------------------
data(lim)
#assume phylum is a lower-cased categorical variable from the start
lim$Phylum<-tolower(lim$Phylum)
# Add in the sampling variance
lim$vi <- (1/sqrt(lim$N - 3))^2
# Lets fit a meta-regression - I will do Article non-independence. The
# phylogenetic model found phylogenetic effects, however, instead we could fit
# Phylum as a fixed effect and explore them with an Orchard Plot
lim_MR <- metafor::rma.mv(yi = yi, V = vi, mods = ~ Phylum, random = list(~1 |
Article, ~1 | Datapoint), data = lim)
summary(lim_MR)
## UPPER = F (WORKS) ------------------------------------------------
# Plot the meta-regression model with default order
orchard_plot(lim_MR, mod = "Phylum", group = "Article", xlab = "Correlation coefficient",
alpha = 0.5, transfm = "tanh", angle = 45, N = "N", cb = FALSE,
upper = T)
## UPPER = F (BREAKS) ------------------------------------------------
orchard_plot(lim_MR, mod = "Phylum", group = "Article", xlab = "Correlation coefficient",
alpha = 0.5, transfm = "tanh", angle = 45, N = "N", cb = FALSE,
upper = F)
## CHANGE ORDER (BREAKS) ------------------------------------------------
new.order<-rev(sort(unique(lim_MR$data$Phylum)))
# Plot the meta-regression model with new order
orchard_plot(lim_MR, mod = "Phylum", group = "Article", xlab = "Correlation coefficient",
alpha = 0.5, transfm = "tanh", angle = 45, N = "N", cb = FALSE,
tree.order = new.order)
## WORKAROUND FOR CHANGING ORDER BUG ------------------------------------------------
#Apply firstup to new.order to get it to work (workaround)
new.order_firstup<-firstup(new.order)
# Plot the meta-regression model with new order
orchard_plot(lim_MR, mod = "Phylum", group = "Article", xlab = "Correlation coefficient",
alpha = 0.5, transfm = "tanh", angle = 45, N = "N", cb = FALSE,
tree.order = new.order_firstup)
Expected behavior
# CAPITALISED CATEGORIES --------------------------------------------------
data(lim)
# Add in the sampling variance
lim$vi <- (1/sqrt(lim$N - 3))^2
# Lets fit a meta-regression - I will do Article non-independence. The
# phylogenetic model found phylogenetic effects, however, instead we could fit
# Phylum as a fixed effect and explore them with an Orchard Plot
lim_MR <- metafor::rma.mv(yi = yi, V = vi, mods = ~ Phylum, random = list(~1 |
Article, ~1 | Datapoint), data = lim)
summary(lim_MR)
## UPPER = T (WORKS) ------------------------------------------------
# Plot the meta-regression model with default order
orchard_plot(lim_MR, mod = "Phylum", group = "Article", xlab = "Correlation coefficient",
alpha = 0.5, transfm = "tanh", angle = 45, N = "N", cb = FALSE,
upper = T)
## UPPER = F (WORKS) ------------------------------------------------
orchard_plot(lim_MR, mod = "Phylum", group = "Article", xlab = "Correlation coefficient",
alpha = 0.5, transfm = "tanh", angle = 45, N = "N", cb = FALSE,
upper = F)
## CHANGE ORDER (WORKS) ------------------------------------------------
new.order<-rev(sort(unique(lim_MR$data$Phylum)))
# Plot the meta-regression model with new order
orchard_plot(lim_MR, mod = "Phylum", group = "Article", xlab = "Correlation coefficient",
alpha = 0.5, transfm = "tanh", angle = 45, N = "N", cb = FALSE,
tree.order = new.order)
Desktop (please complete the following information):
OS: Windows 10
Browser: NA
Version: NA
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered:
@befriendabacterium Thanks for this mate! So sorry I didn't see this. I can't understand why I'm not getting notified when there's a new issue. I have all the notifications setup to be received (or so I thought). I'll see if I can find some time to fix this, but feel free to chuck in a pull request as this looks fairly simple
Hi Dan - no worries, not sure why that is. I rely on the email notifications to be honest so only thing I can suggest is make sure they're not going to your junk?!
I don't have a fix for this right now, just the workaround above sorry! Bit hectic at the mo to give this the brain power it needs, but I hope it's an easy fix.
Describe the bug
When the levels of a categorical moderator are not capitalised to begin with, orchard_plot() breaks with changes to 'upper' or 'tree.order' options. Below I demonstrate with a reproducible example where I turn the factor to lowercase first. I also provide a workaround for the 'tree.order' break that might help you come up with a fix.
To Reproduce
Expected behavior
Desktop (please complete the following information):
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: