adayim / consort

Create CONSORT diagrams for clinical studies.
Other
28 stars 4 forks source link

Add side box to split #10

Open JianWang2016 opened 1 year ago

JianWang2016 commented 1 year ago

Dear Alim,

Is there a way to only add side box to one of splitted boxes? In the code below, I don't need to add side box to Arm A.

g <- add_box(txt = c("Study 1 (n=8)", "Study 2 (n=12)")) g <- add_box(g, txt = "Included All (n=20)") g <- add_side_box(g, txt = "Excluded (n=7):\n\u2022 MRI not collected (n=3)") g <- add_box(g, txt = "Randomised") g <- add_split(g, txt = c("Arm A (n=143)", "Arm B (n=142)")) g <- add_side_box(g, txt = c(" ", "Exclude (n=3")) g <- add_box(g, txt = c("From Arm A", "From Arm B")) plot(g, grViz = TRUE)

I also wish to stop earlier in one of the arm, e.g. Arm A, and only continue on the Arm B. How could I achieve that?

g <- add_box(txt = c("Study 1 (n=8)", "Study 2 (n=12)")) g <- add_box(g, txt = "Included All (n=20)") g <- add_side_box(g, txt = "Excluded (n=7):\n\u2022 MRI not collected (n=3)") g <- add_box(g, txt = "Randomised") g <- add_split(g, txt = c("Arm A (n=143)", "Arm B (n=142)")) g <- add_side_box(g, txt = "Exclude (n=3)") g <- add_box(g, txt = "From Arm B") plot(g, grViz = TRUE)

adayim commented 1 year ago

Hi Jian,

You are right, the box shouldn't be drawn if the text is missing. I will fix that. Thank you for reporting this.

JianWang2016 commented 1 year ago

Alim, Thanks so much for your prompt feedback.

adayim commented 1 year ago

Hi Jian,

I have fixed this now and you can install the GitHub version. Plot below will work and hope this is what you want.

g <- add_box(txt = c("Study 1 (n=8)", "Study 2 (n=12)"))
g <- add_box(g, txt = "Included All (n=20)")
g <- add_side_box(g, txt = "Excluded (n=7):\n\u2022 MRI not collected (n=3)")
g <- add_box(g, txt = "Randomised")
g <- add_split(g, txt = c("Arm A (n=143)", "Arm B (n=142)"))
g <- add_side_box(g, txt = c("", "Exclude (n=3"))
g <- add_box(g, txt = c("", "From Arm B"))
g <- add_box(g, txt = c("This is it", "From Arm B"))

plot(g, grViz = TRUE)
JianWang2016 commented 1 year ago

This is fantastic!

Two comments: 1) It would be great if the edge from "Arm A" to "This is it" is shortened to reflect earlier ending. 2) Anyway to apply add_side_box from "Randomised" to each or selected spitted boxes as following,
g <- add_box(txt = c("Study 1 (n=8)", "Study 2 (n=12)")) g <- add_box(g, txt = "Included All (n=20)") g <- add_side_box(g, txt = "Excluded (n=7):\n\u2022 MRI not collected (n=3)") g <- add_box(g, txt = "Randomised") g <- add_side_box(g, txt = c("", "Exclude prior to split (n=2")) g <- add_split(g, txt = c("Arm A (n=143)", "Arm B (n=142)")) g <- add_side_box(g, txt = c("", "Exclude (n=3")) g <- add_box(g, txt = c("", "From Arm B")) g <- add_box(g, txt = c("This is it", "From Arm B"))

plot(g, grViz = TRUE)

adayim commented 1 year ago

The first comment is something I can consider. But I don't understand the second one. Why do you want to add a side box just before splitting and after randomization? Shouldn't that already randomized to an arm and exclude it from the corresponding arms instead of before the arms?

For the first quesiton, you can do the following:

g <- add_box(txt = c("Study 1 (n=8)", "Study 2 (n=12)"))
g <- add_box(g, txt = "Included All (n=20)")
g <- add_side_box(g, txt = "Excluded (n=7):\n\u2022 MRI not collected (n=3)")
g <- add_box(g, txt = "Randomised")
g <- add_split(g, txt = c("Arm A (n=143)", "Arm B (n=142)"))
g <- add_side_box(g, txt = c("", "Exclude (n=3"))
g <- add_box(g, txt = c("", "From Arm B"))
plot(g, grViz = TRUE)