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

Unable to change effsize.ylim #52

Closed
silasprincipe opened this issue Aug 7, 2019 · 3 comments
Closed

Unable to change effsize.ylim #52

silasprincipe opened this issue Aug 7, 2019 · 3 comments

Comments

@silasprincipe
Copy link

Hi! I'm having trouble in changing the scale of y-axis of the effect size in a two-independent DABEST plot. I have two different plots to construct, and I want them to have the same scale sizes to facilitate understanding.

tgu_kit
tgu_poc

Here is the code with some data to exemplify:

cont1 <- c(17, 18.6, 21, 27, 13, 26, 19.5, 14.8, 12, 23, 10, 14.6, 23, 24)
treat1 <- c(30, 24, 18, 21, 12, 27.1, 25.5, 29, 45, 22, 29.3, 34, 22, 13)
cont2 <- c(6, 6, 22, 20, 15, 21, 13, 6, 6, 19, 6, 6, 31, 29)
treat2 <- c(6.1, 25, 22, 20, 15, 21, 13, 30, 60, 19, 6, 6, 31, 29)

First dataset

data.a <- tibble::tibble(Control = cont1, Treatment = treat1)
data.a.f <-
data.a %>%
tidyr::gather(key = Group, value = Measurement)
dabest.a <-
data.a.f %>%
dabest(Group, Measurement,
# The idx below passes "Control" as the control group,
# and "Group1" as the test group. The mean difference
# will be computed as mean(Group1) - mean(Control1).
idx = c("Control", "Treatment"),
paired = FALSE)
plot(dabest.a,
rawplot.ylabel = "Concentration",
effsize.ylabel = "Mean difference", palette = "Dark2",
rawplot.markersize = 4, rawplot.groupwidth = 0.2,
rawplot.ylim = c(10, 50),
effsize.ylim = c(0, 30))

Second dataset

data.b <- tibble::tibble(Control = cont2, Treatment = treat2)
data.b.f <-
data.b %>%
tidyr::gather(key = Group, value = Measurement)
dabest.b <-
data.b.f %>%
dabest(Group, Measurement,
# The idx below passes "Control" as the control group,
# and "Group1" as the test group. The mean difference
# will be computed as mean(Group1) - mean(Control1).
idx = c("Control", "Treatment"),
paired = FALSE)
plot(dabest.b,
rawplot.ylabel = "Concentration",
effsize.ylabel = "Mean difference", palette = "Dark2",
rawplot.markersize = 4, rawplot.groupwidth = 0.2,
rawplot.ylim = c(10, 50),
effsize.ylim = c(0,30))

Another question: how do I change the scale interval (for example, by 5, not 10). Thanks!

@josesho josesho added the help wanted Extra attention is needed label Aug 7, 2019
@josesho
Copy link
Member

josesho commented Aug 7, 2019

Hi,

I would suggest using a Cumming plot rather than two Gardner-Altman plots to achieve what you want.

all.data <- tibble::tibble(Control1 = cont1, Treatment1 = treat1,
                           Control2 = cont2, Treatment2 = treat2)

all.data.tidy <-
  all.data %>%
  tidyr::gather(key = Group, value = Measurement)

dabest.all.data <- 
  all.data.tidy %>%
  dabest(Group, Measurement,
         idx = list(c("Control1", "Treatment1"),
                    c("Control2", "Treatment2")),
         paired = FALSE)

plot(dabest.all.data)

cumming_demo

If, however, you want two Gardner-Altman plots, then what you have done above (setting rawplot.ylim) works. The nature of the Gardner-Altman plots is such that one can only set the ylims for the rawdata plot (on the left); the axes with the effect size and confidence interval is, by design, aligned to the axes on the left and currently cannot be set.

@josesho
Copy link
Member

josesho commented Aug 7, 2019

Another question: how do I change the scale interval (for example, by 5, not 10). Thanks!

To the best of my knowledge, this is effectively not possible now. (We use cowplot to stitch the raw swarmplot with the effect size plot. You might be able to isolate the axes, and then use ggplot's scale_y_continuous to set the tick breaks, but I'm not sure how yet.)

@josesho josesho removed the help wanted Extra attention is needed label Aug 7, 2019
@silasprincipe
Copy link
Author

Thanks @josesho !

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

No branches or pull requests

2 participants