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

Problem with rob_summary and rob_traffic_light #131

Closed
zaddyzad opened this issue Jun 4, 2021 · 7 comments
Closed

Problem with rob_summary and rob_traffic_light #131

zaddyzad opened this issue Jun 4, 2021 · 7 comments
Assignees
Labels
bug Something isn't working reprex

Comments

@zaddyzad
Copy link

zaddyzad commented Jun 4, 2021

I have two problems with the main functions of ROBVIS, help would be sincerely appreciated!

First problem, rob_summary:

I am using PROBAST and there 9 domains: 4 for RoB, 3 for applicability, and 2 for overall assessments. When I use rob_summary to plot the data, the plot only shows the first 8 domains.

The second problem is with rob_traffic_light:

When I try to plot the data, I get the error "Error: Aesthetics must be either length 1 or the same as the data (1): colour."

The code is here, and a picture of the plot is attached.

full_data<-data
full_data$weights <- rep(1)
as.numeric(full_data$weights)

develop_data <- subset(full_data,`External Validation`=="Y")
develop_valid <- subset(full_data,`External Validation`=="N")

succinct_develop_data <- develop_data %>% select(Reference,d1,d1_a,d2,d2_a,d3,d3_a,d4,rob_all,rob_applicability,weights)
succinct_validation_data <- develop_valid %>% select(Reference,d1,d1_a,d2,d2_a,d3,d3_a,d4,rob_all,rob_applicability,weights)

succinct_develop_data <- `colnames<-`(succinct_develop_data,c("Study","Participant Selection","Participant Applicability","Predictor Inclusion","Predictor Applicability"
                             ,"Outcome Definition","Outcome Applicability","Multivariate Analysis","Overall Risk of Bias"
                             ,"Overall Applicability","Weights"))

succinct_validation_data <- `colnames<-`(succinct_validation_data,c("Study","Participant Selection","Participant Applicability","Predictor Inclusion","Predictor Applicability"
                                     ,"Outcome Definition","Outcome Applicability","Multivariate Analysis","Overall Risk of Bias"
                                     ,"Overall Applicability","Weights"))


succinct_validation_data <- as.data.frame(succinct_validation_data)
succinct_develop_data <- as.data.frame(succinct_develop_data)

rob_summary(succinct_develop_data,tool='ROB1')
rob_summary(succinct_validation_data,tool='ROB1')

rob_traffic_light(data=succinct_validation_data,tool='ROB1')
rob_traffic_light(data=succinct_develop_data,tool='ROB1')

robplot
robdata

@zaddyzad zaddyzad added the bug Something isn't working label Jun 4, 2021
@mcguinlu
Copy link
Owner

mcguinlu commented Jun 8, 2021

Can you please provide a minimal reproducible example using the reprex package?
The goal of a reprex is to make it as easy as possible for me to recreate your problem so that I can fix it.
If you've never made a minimal reprex before, there is lots of good advice here.

@mcguinlu mcguinlu added the reprex label Jun 8, 2021
@zaddyzad
Copy link
Author

zaddyzad commented Jun 8, 2021

Thank you for the suggestion! I added an example below. Don't mind the column names for the domains, but you can see doverall_applicability (doverall_a) doesn't make it into the summary plot and, and that rob_traffic_light plot gives an error.

library(tibble)
library(robvis)
#> Warning: package 'robvis' was built under R version 4.0.5
library(reprex)

data <- tibble::tribble(
  
~ stud , ~ d1, ~ d2, ~ d3, ~ d4, ~ d1a, ~ d2a, ~ d3a, ~ doverall, ~ doverall_a, ~ weight,

  "study1",   "high", "high", "low", "low", "low", "high", "high", "high", "high", 1,
  "study2",   "low", "high", "low", "low", "low", "high", "low", "high", "low", 1,
  "study2",   "high", "high", "low", "low", "low", "high", "low", "high", "low", 1,
  )

data <- as.data.frame(data)

rob_summary(data,tool='ROB1')

rob_traffic_light(data=data, tool='ROB1')
#> Error: Aesthetics must be either length 1 or the same as the data (1): colour

Created on 2021-06-08 by the reprex package (v0.3.0)

@zaddyzad
Copy link
Author

zaddyzad commented Jun 8, 2021

Can you please provide a minimal reproducible example using the reprex package?
The goal of a reprex is to make it as easy as possible for me to recreate your problem so that I can fix it.
If you've never made a minimal reprex before, there is lots of good advice here.

I'm new to GitHub, so my apologies if I was supposed to quote reply the reprex to your comment.

@mcguinlu
Copy link
Owner

mcguinlu commented Jun 8, 2021

Hi @zaddyzad - no, that's perfect, thanks!

Not entirely sure what is going on here, but will look into it and get back to you shortly.

@mcguinlu
Copy link
Owner

mcguinlu commented Jun 9, 2021

Hi @zaddyzad,

I think I have worked out what is going on - you have the old CRAN version of the package installed which does not provide good handling of the "ROB1/Generic" template. In order to create your figures, please install the newest development version of the package using:

install.packages("devtools")
devtools::install_github("mcguinlu/robvis")

Once you have done that, running

robvis::rob_summary(data,tool='Generic', overall = F)

using the data you provided will produced the barplot you are after (see below). In this case, the overall = F argument just prevents the last domain heading from being bolded.

zad_barplot

For the traffic light plot, things are a little bit more complicated. Installing the development version of the package will allow you to create the following plot using your example data:

zad_tfplot

However, because I thought there would only ever b1 one "overall" column per plot, this doesn't look exactly right, as one overall column title is put into the caption with the other domains, and the other is left in the column heading. This is something I need to work on further in the package. As a stop-gap, my best recommendation is to produce two traffic light plots, one for risk of bias and one for applicability, and merge them using patchwork:

library(patchwork)

p1 <-
  robvis::rob_traffic_light(data[c(1:5, 9)], tool = "Generic", x_title = "Risk of bias domains")
p2 <-
  robvis::rob_traffic_light(data[c(1, 6:8, 10)], tool = "Generic", x_title = "Applicability domains")

p <- p1 + p2 + plot_layout(guides = 'collect', tag_level = "new") + plot_annotation(tag_levels = c("A", "B")) &
  theme(legend.position = 'bottom',
        legend.justification = "right")

zad_tfnew

Yo can then reference to "Figure X, Panel A" in the text. This is actually how I believe the results for tools with both risk of bias and applicability sections should be displayed, as I think it makes it a lot easier to interpret.

Hopefully this helps!

@zaddyzad
Copy link
Author

zaddyzad commented Jun 9, 2021

@mcguinlu Thank you so much for all this, it all works splendidly!

PROBAST support would be a wonderful addition for subsequent versions of the tool.

Thank you for also introducing me to the patchwork package. This will be very helpful in the future.

@mcguinlu
Copy link
Owner

mcguinlu commented Jun 9, 2021

Ideal - glad it worked out. And PROBAST is definitely on my list of tools to add.

I'll close this issue now.

@mcguinlu mcguinlu closed this as completed Jun 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working reprex
Projects
None yet
Development

No branches or pull requests

2 participants