Customize a PRISMA flow chart

Lionel Duarte

2020-04-29

library(prismadiagramR)
library(dplyr)

Purpose

This package aids in rapidly creating a PRISMA diagram for use in meta-analysis from a simple dataframe tracking the use of publications in the analysis.

The minimal arguments needed are: 1. Pub.ID: A unique publication ID. 2. Source: A source identifier to describe where the study is from. 3. Filter: A Filter identifier to describe how the study is filtered out or left NA if used.

Simple StudySet input

From a dataframe with only the three arguments stated above we can get an initial PRISMA diagram.


set.seed(25)
N <- 100
studyStatus <- data.frame(Pub.ID = seq(1:N),
                          Source = sample(letters[1:3], N, replace = TRUE),
                          Filter = sample(letters[1:5], N, replace = TRUE))
studyStatus$Filter[studyStatus$Filter=="e"] <- NA
getPrisma(studyStatus) %>% DiagrammeR::grViz(.)
prisma Source1 Source: a (N=38) Node8 Studies Remaining: (N=76) Source1->Node8 Source2 Source: b (N=32) Source2->Node8 Source3 Source: c (N=30) Source3->Node8 Filter4 Filter: a (N=24) Filter5 Filter: b (N=14) Filter6 Filter: c (N=27) Filter7 Filter: d (N=17) Node8->Filter4 Node9 Studies Remaining: (N=62) Node8->Node9 Node9->Filter5 Node10 Studies Remaining: (N=35) Node9->Node10 Node10->Filter6 Node11 Studies Remaining: (N=18) Node10->Node11 Node11->Filter7 End12 Studies in Analysis (N=18) Node11->End12

Switching Source

It is possible to re-order the sources and filters.

studyStatus$Source <- ordered(studyStatus$Source , levels = c("c", "b", "a"))
studyStatus$Filter <- ordered(studyStatus$Filter , levels = c("d", "c", "b", "a"))

getPrisma(studyStatus) %>% DiagrammeR::grViz(.)
prisma Source1 Source: c (N=30) Node8 Studies Remaining: (N=83) Source1->Node8 Source2 Source: b (N=32) Source2->Node8 Source3 Source: a (N=38) Source3->Node8 Filter4 Filter: d (N=17) Filter5 Filter: c (N=27) Filter6 Filter: b (N=14) Filter7 Filter: a (N=24) Node8->Filter4 Node9 Studies Remaining: (N=56) Node8->Node9 Node9->Filter5 Node10 Studies Remaining: (N=42) Node9->Node10 Node10->Filter6 Node11 Studies Remaining: (N=18) Node10->Node11 Node11->Filter7 End12 Studies in Analysis (N=18) Node11->End12

Additional Formatting

We can also obtain a custom prismaFormat dataframe to modify to change items in the PRISMA as desired. By default this dataframe has 3 arguments: 1. prismaLvl: This describes the level the node is created at. 2. nodeType: This describes the type of node it is. 3. prismaTxt: The text used in the node for the PRISMA diagram.

prismaFormat <- getPrismaFormat(studyStatus)
flextable::flextable(prismaFormat)

prismaLvl

nodeType

prismaTxt

1.000

Source

Source: c
(N=30)

1.000

Source

Source: b
(N=32)

1.000

Source

Source: a
(N=38)

2.000

Filter

Filter: d
(N=17)

3.000

Filter

Filter: c
(N=27)

4.000

Filter

Filter: b
(N=14)

5.000

Filter

Filter: a
(N=24)

2.000

Node

Studies Remaining:
(N=83)

3.000

Node

Studies Remaining:
(N=56)

4.000

Node

Studies Remaining:
(N=42)

5.000

Node

Studies Remaining:
(N=18)

6.000

End

Studies in Analysis
(N=18)

Changing Text

prismaFormat$prismaTxt[1] <- "Medline"
getPrisma(studyStatus = NULL, prismaFormat = prismaFormat) %>% DiagrammeR::grViz(.)
prisma Source1 Medline Node8 Studies Remaining: (N=83) Source1->Node8 Source2 Source: b (N=32) Source2->Node8 Source3 Source: a (N=38) Source3->Node8 Filter4 Filter: d (N=17) Filter5 Filter: c (N=27) Filter6 Filter: b (N=14) Filter7 Filter: a (N=24) Node8->Filter4 Node9 Studies Remaining: (N=56) Node8->Node9 Node9->Filter5 Node10 Studies Remaining: (N=42) Node9->Node10 Node10->Filter6 Node11 Studies Remaining: (N=18) Node10->Node11 Node11->Filter7 End12 Studies in Analysis (N=18) Node11->End12

Changing FonstSize

We can add the fontSize argument to the datatable to customize the fontsize in each node.

prismaFormat$fontSize <- 15
prismaFormat$fontSize[1] <- 10
getPrisma(studyStatus = NULL, prismaFormat = prismaFormat) %>% DiagrammeR::grViz(.)
prisma Source1 Medline Node8 Studies Remaining: (N=83) Source1->Node8 Source2 Source: b (N=32) Source2->Node8 Source3 Source: a (N=38) Source3->Node8 Filter4 Filter: d (N=17) Filter5 Filter: c (N=27) Filter6 Filter: b (N=14) Filter7 Filter: a (N=24) Node8->Filter4 Node9 Studies Remaining: (N=56) Node8->Node9 Node9->Filter5 Node10 Studies Remaining: (N=42) Node9->Node10 Node10->Filter6 Node11 Studies Remaining: (N=18) Node10->Node11 Node11->Filter7 End12 Studies in Analysis (N=18) Node11->End12

From Scratch

It is also possible to create the PRISMA directly from prismaFormat and create nodes that do not need a filter.

prismaFormat <-
  data.frame(
    prismaLvl = c(1,2,3,3,4),
    nodeType =  c("Source", "Node", "Node", "Filter", "End"),
    prismaTxt = letters[1:5]
  )

getPrisma(studyStatus = NULL, prismaFormat = prismaFormat) %>% DiagrammeR::grViz(.)
prisma Source1 a Node2 b Source1->Node2 Node3 c Node2->Node3 Filter4 d Node3->Filter4 End5 e Node3->End5