代码之家  ›  专栏  ›  技术社区  ›  lf_araujo

荟萃分析流程图

  •  0
  • lf_araujo  · 技术社区  · 6 年前

    是否可以使用任何R工具重现下图中的荟萃分析类型的流程图? enter image description here

    我的尝试是使用 mermaid :

    diagram = "
    graph LR
      subgraph Screening
        b1-->b2
    end
      subgraph Eligibility
        c1-->c2
      end
      subgraph Included
        d1-->d2
      end
      subgraph Identification
        a1-->a2
      end
    
    
    
    "
    mermaid(diagram)
    

    这产生了:

    enter image description here

    但是我找不到一种方法来连接子图中的节点。

    还有其他更适合这种工作的工具吗?我正在考虑从我的Rmarkdown文档中使用的任何软件包。

    1 回复  |  直到 6 年前
        1
  •  6
  •   Pete    6 年前

    我发现DiagrammeR包最容易做到这一点。总体思路如下:

    library(glue)
    library(DiagrammeR)
    
    excluded <- glue('Full text articles excluded
                 n = 1000
                 Reasons for exclusion
                 Reason 1
                 Reason 2')
    grViz("
    digraph cohort_flow_chart
    {
    node [fontname = Helvetica, fontsize = 12, shape = box, width = 4]
    a[label = 'Records identified in original search']
    b[label = 'Records identified with update']
    c[label = 'Records after duplicates removed']
    d[label = 'Records screened']
    e[label = 'Records excluded']
    f[label = 'Full text articles assessed']
    g[label = 'Studies included']
    h[label = '@@1']
    
    
    
    { rank = same; a b}
    { rank = same; d, e}
    { rank = same; f, h}
    
    a -> c;
    b -> c;
    c -> d;
    d -> e [ minlen = 3 ];
    d -> f;
    f -> h [ minlen = 3 ];
    f -> g;
    }
    
    [1]: excluded
    ")
    

    enter image description here

    带有标签和空节点的图像

    grViz("
    digraph cohort_flow_chart
    {
    node [fontname = Helvetica, fontsize = 12, shape = box, width = 4]
    i[label = 'Identification', fillcolor = LightBlue, 
      style = filled,     width = 2]
    j[label = 'Screening',fillcolor = LightBlue, style = filled, width = 2]
    k[label = 'Eligibility', fillcolor = LightBlue, style = filled, 
      width = 2]
    l[label = 'Included', fillcolor = LightBlue, style = filled, width = 2]
    
    a[label = 'Records identified in original search']
    b[label = 'Records identified with update']
    c[label = 'Records after duplicates removed']
    d[label = 'Records screened']
    e[label = 'Records excluded']
    f[label = 'Full text articles assessed']
    g[label = 'Studies included']
    h[label = '@@1']
    blank_1[label = '', width = 0.01, height = 0.01]
    blank_2[label = '', width = 0.01, height = 0.01]
    blank_4[label = '', width = 4, color = White]
    
    { rank = same; a b i}
    { rank = same; blank_4 c j}
    { rank = same; f k}
    { rank = same; g l}
    { rank = same; blank_1 e}
    { rank = same; blank_2 h}
    
    a -> c;
    b -> c;
    b -> blank_4 [ dir = none, color = White];
    c -> d;
    d -> blank_1 [ dir = none ];
    blank_1 -> e [ minlen = 3 ];
    blank_1 -> f;
    f -> blank_2 [ dir = none ];
    blank_2 -> h [ minlen = 3 ];
    blank_2 -> g;
    
    }
    
    [1]: excluded
    ")
    

    enter image description here