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(.)

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(.)

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(.)

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(.)

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(.)