Pairwise comparisons with BH correction and stars


Economist GGPlot Excel Paul Tol Black And White Solarized Stata Tableau Wall Street CanvasXpress
<html>

  <head>
    <!-- Include the CanvasXpress library in your HTML file -->
    <link rel="stylesheet" href="https://www.canvasxpress.org/dist/canvasXpress.css" type="text/css"/>
    <script src="https://www.canvasxpress.org/dist/canvasXpress.min.js"></script>
  </head>

  <body>

    <!-- Create a canvas element for the chart with the desired dimensions -->
    <div>
      <canvas id="canvasId" width="600" height="600"></canvas>
    </div>


    <!-- Create a script to initialize the chart -->
    <script>

      // Use a data frame (2D-array) for the graph
      var data = 

      // Create the configuration for the graph
      var config = {
         "graphType" : "Boxplot",
         "graphOrientation" : "vertical",
         "groupingFactors" : [
            "dose"
         ],
         "xAxis" : [
            "len"
         ],
         "xAxisTitle" : "len",
         "smpTitle" : "dose",
         "smpTitleFontStyle" : "bold",
         "axisTitleFontStyle" : "bold",
         "axisAlgorithm" : "rPretty",
         "smpTextRotate" : 0,
         "showLegend" : false,
         "colorBy" : "dose",
         "title" : "Tooth growth by dose (Welch t-test, BH-adjusted)",
         "showStatInference" : true,
         "statInference" : {
            "correction" : {
               "method" : "BH"
            },
            "annotate" : "stars",
            "comparisons" : [
               {
                  "groups" : [
                     "0.5",
                     "1"
                  ],
                  "p" : 1.26830072017385e-07
               },
               {
                  "groups" : [
                     "1",
                     "2"
                  ],
                  "p" : 1.9064295136718e-05
               },
               {
                  "groups" : [
                     "0.5",
                     "2"
                  ],
                  "p" : 4.39752495936323e-14
               }
            ]
         },
         "colorScheme" : "GGPlot"
      }

      // Event used to create graph (optional)
      var events = false

      // Call the CanvasXpress function to create the graph
      var cX = new CanvasXpress("canvasId", data, config, events);

    </script>

  </body>

</html>
<html>

  <head>
    <!-- Include the CanvasXpress library in your HTML file -->
    <link rel="stylesheet" href="https://www.canvasxpress.org/dist/canvasXpress.css" type="text/css"/>
    <script src="https://www.canvasxpress.org/dist/canvasXpress.min.js"></script>
  </head>

  <body>

    <!-- Create a canvas element for the chart with the desired dimensions -->
    <div>
      <canvas id="canvasId" width="600" height="600"></canvas>
    </div>


    <!-- Create a script to initialize the chart -->
    <script>

      // Create the data for the graph
      var data = {
         "y" : {
            "vars" : [
               "len"
            ],
            "smps" : [
               "Obs1",
               "Obs2",
               "Obs3",
               "Obs4",
               "Obs5",
               "Obs6",
               "Obs7",
               "Obs8",
               "Obs9",
               "Obs10",
               "Obs11",
               "Obs12",
               "Obs13",
               "Obs14",
               "Obs15",
               "Obs16",
               "Obs17",
               "Obs18",
               "Obs19",
               "Obs20",
               "Obs21",
               "Obs22",
               "Obs23",
               "Obs24",
               "Obs25",
               "Obs26",
               "Obs27",
               "Obs28",
               "Obs29",
               "Obs30",
               "Obs31",
               "Obs32",
               "Obs33",
               "Obs34",
               "Obs35",
               "Obs36",
               "Obs37",
               "Obs38",
               "Obs39",
               "Obs40",
               "Obs41",
               "Obs42",
               "Obs43",
               "Obs44",
               "Obs45",
               "Obs46",
               "Obs47",
               "Obs48",
               "Obs49",
               "Obs50",
               "Obs51",
               "Obs52",
               "Obs53",
               "Obs54",
               "Obs55",
               "Obs56",
               "Obs57",
               "Obs58",
               "Obs59",
               "Obs60"
            ],
            "data" : [
               [
                  4.2,
                  11.5,
                  7.3,
                  5.8,
                  6.4,
                  10,
                  11.2,
                  11.2,
                  5.2,
                  7,
                  15.2,
                  21.5,
                  17.6,
                  9.7,
                  14.5,
                  10,
                  8.2,
                  9.4,
                  16.5,
                  9.7,
                  16.5,
                  16.5,
                  15.2,
                  17.3,
                  22.5,
                  17.3,
                  13.6,
                  14.5,
                  18.8,
                  15.5,
                  19.7,
                  23.3,
                  23.6,
                  26.4,
                  20,
                  25.2,
                  25.8,
                  21.2,
                  14.5,
                  27.3,
                  23.6,
                  18.5,
                  33.9,
                  25.5,
                  26.4,
                  32.5,
                  26.7,
                  21.5,
                  23.3,
                  29.5,
                  25.5,
                  26.4,
                  22.4,
                  24.5,
                  24.8,
                  30.9,
                  26.4,
                  27.3,
                  29.4,
                  23
               ]
            ]
         },
         "x" : {
            "dose" : [
               "0.5",
               "0.5",
               "0.5",
               "0.5",
               "0.5",
               "0.5",
               "0.5",
               "0.5",
               "0.5",
               "0.5",
               "0.5",
               "0.5",
               "0.5",
               "0.5",
               "0.5",
               "0.5",
               "0.5",
               "0.5",
               "0.5",
               "0.5",
               "1",
               "1",
               "1",
               "1",
               "1",
               "1",
               "1",
               "1",
               "1",
               "1",
               "1",
               "1",
               "1",
               "1",
               "1",
               "1",
               "1",
               "1",
               "1",
               "1",
               "2",
               "2",
               "2",
               "2",
               "2",
               "2",
               "2",
               "2",
               "2",
               "2",
               "2",
               "2",
               "2",
               "2",
               "2",
               "2",
               "2",
               "2",
               "2",
               "2"
            ]
         }
      }

      // Create the configuration for the graph
      var config = {
         "graphType" : "Boxplot",
         "graphOrientation" : "vertical",
         "groupingFactors" : [
            "dose"
         ],
         "xAxis" : [
            "len"
         ],
         "xAxisTitle" : "len",
         "smpTitle" : "dose",
         "smpTitleFontStyle" : "bold",
         "axisTitleFontStyle" : "bold",
         "axisAlgorithm" : "rPretty",
         "smpTextRotate" : 0,
         "showLegend" : false,
         "colorBy" : "dose",
         "title" : "Tooth growth by dose (Welch t-test, BH-adjusted)",
         "showStatInference" : true,
         "statInference" : {
            "correction" : {
               "method" : "BH"
            },
            "annotate" : "stars",
            "comparisons" : [
               {
                  "groups" : [
                     "0.5",
                     "1"
                  ],
                  "p" : 1.26830072017385e-07
               },
               {
                  "groups" : [
                     "1",
                     "2"
                  ],
                  "p" : 1.9064295136718e-05
               },
               {
                  "groups" : [
                     "0.5",
                     "2"
                  ],
                  "p" : 4.39752495936323e-14
               }
            ]
         },
         "colorScheme" : "GGPlot"
      }

      // Event used to create graph (optional)
      var events = false

            // Call the CanvasXpress function to create the graph
      var cX = new CanvasXpress("canvasId", data, config, events);

    </script>

  </body>

</html>
library(canvasXpress)
y=read.table("https://www.canvasxpress.org/data/r/cX-statistics2-dat.txt", header=TRUE, sep="\t", quote="", row.names=1, fill=TRUE, check.names=FALSE, stringsAsFactors=FALSE)
x=read.table("https://www.canvasxpress.org/data/r/cX-statistics2-smp.txt", header=TRUE, sep="\t", quote="", row.names=1, fill=TRUE, check.names=FALSE, stringsAsFactors=FALSE)
canvasXpress(
data=y,
smpAnnot=x,
axisAlgorithm="rPretty",
axisTitleFontStyle="bold",
colorBy="dose",
colorScheme="GGPlot",
graphOrientation="vertical",
graphType="Boxplot",
groupingFactors=list("dose"),
showLegend=FALSE,
showStatInference=TRUE,
smpTextRotate=0,
smpTitle="dose",
smpTitleFontStyle="bold",
statInference=list(annotate="stars", comparisons=list(list(groups=list(0.5, 1), p=1.26830072017385e-07), list(groups=list(1, 2), p=1.9064295136718e-05), list(groups=list(0.5, 2), p=4.39752495936323e-14)), correction=list(method="BH")),
title="Tooth growth by dose (Welch t-test, BH-adjusted)",
xAxis=list("len"),
xAxisTitle="len"
)
from canvasxpress.canvas import CanvasXpress
from canvasxpress.plot import show_in_browser

if __name__ == "__main__":
  # Define the chart with its data and configuration
  chart: CanvasXpress = CanvasXpress(
    render_to = "statistics2",
    data = {
      "y": {
        "vars": ["len"],
        "smps": ["Obs1", "Obs2", "Obs3", "Obs4", "Obs5", "Obs6", "Obs7", "Obs8", "Obs9", "Obs10", "Obs11", "Obs12", "Obs13", "Obs14", "Obs15", "Obs16", "Obs17", "Obs18", "Obs19", "Obs20", "Obs21", "Obs22", "Obs23", "Obs24", "Obs25", "Obs26", "Obs27", "Obs28", "Obs29", "Obs30", "Obs31", "Obs32", "Obs33", "Obs34", "Obs35", "Obs36", "Obs37", "Obs38", "Obs39", "Obs40", "Obs41", "Obs42", "Obs43", "Obs44", "Obs45", "Obs46", "Obs47", "Obs48", "Obs49", "Obs50", "Obs51", "Obs52", "Obs53", "Obs54", "Obs55", "Obs56", "Obs57", "Obs58", "Obs59", "Obs60"],
        "data": [
          [4.2, 11.5, 7.3, 5.8, 6.4, 10, 11.2, 11.2, 5.2, 7, 15.2, 21.5, 17.6, 9.7, 14.5, 10, 8.2, 9.4, 16.5, 9.7, 16.5, 16.5, 15.2, 17.3, 22.5, 17.3, 13.6, 14.5, 18.8, 15.5, 19.7, 23.3, 23.6, 26.4, 20, 25.2, 25.8, 21.2, 14.5, 27.3, 23.6, 18.5, 33.9, 25.5, 26.4, 32.5, 26.7, 21.5, 23.3, 29.5, 25.5, 26.4, 22.4, 24.5, 24.8, 30.9, 26.4, 27.3, 29.4, 23]
        ]
      },
      "x": {
        "dose": ["0.5", "0.5", "0.5", "0.5", "0.5", "0.5", "0.5", "0.5", "0.5", "0.5", "0.5", "0.5", "0.5", "0.5", "0.5", "0.5", "0.5", "0.5", "0.5", "0.5", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2"]
      }
    },
    config = {
      "graphType": "Boxplot",
      "graphOrientation": "vertical",
      "groupingFactors": ["dose"],
      "xAxis": ["len"],
      "xAxisTitle": "len",
      "smpTitle": "dose",
      "smpTitleFontStyle": "bold",
      "axisTitleFontStyle": "bold",
      "axisAlgorithm": "rPretty",
      "smpTextRotate": 0,
      "showLegend": False,
      "colorBy": "dose",
      "title": "Tooth growth by dose (Welch t-test, BH-adjusted)",
      "showStatInference": True,
      "statInference": {
        "correction": {
          "method": "BH"
        },
        "annotate": "stars",
        "comparisons": [
          {
            "groups": ["0.5", "1"],
            "p": 1.26830072017385e-07
          },
          {
            "groups": ["1", "2"],
            "p": 1.9064295136718e-05
          },
          {
            "groups": ["0.5", "2"],
            "p": 4.39752495936323e-14
          }
        ]
      },
      "colorScheme": "GGPlot"
    },
    width = 600,
    height = 600
  )

  # Display the chart in its own Web page
  show_in_browser(chart)
Run this notebook: Open in Binder
from canvasxpress.canvas import CanvasXpress
from canvasxpress.plot import graph

graph(
  CanvasXpress(
    render_to = "statistics2",
    data = {
      "y": {
        "vars": ["len"],
        "smps": ["Obs1", "Obs2", "Obs3", "Obs4", "Obs5", "Obs6", "Obs7", "Obs8", "Obs9", "Obs10", "Obs11", "Obs12", "Obs13", "Obs14", "Obs15", "Obs16", "Obs17", "Obs18", "Obs19", "Obs20", "Obs21", "Obs22", "Obs23", "Obs24", "Obs25", "Obs26", "Obs27", "Obs28", "Obs29", "Obs30", "Obs31", "Obs32", "Obs33", "Obs34", "Obs35", "Obs36", "Obs37", "Obs38", "Obs39", "Obs40", "Obs41", "Obs42", "Obs43", "Obs44", "Obs45", "Obs46", "Obs47", "Obs48", "Obs49", "Obs50", "Obs51", "Obs52", "Obs53", "Obs54", "Obs55", "Obs56", "Obs57", "Obs58", "Obs59", "Obs60"],
        "data": [
          [4.2, 11.5, 7.3, 5.8, 6.4, 10, 11.2, 11.2, 5.2, 7, 15.2, 21.5, 17.6, 9.7, 14.5, 10, 8.2, 9.4, 16.5, 9.7, 16.5, 16.5, 15.2, 17.3, 22.5, 17.3, 13.6, 14.5, 18.8, 15.5, 19.7, 23.3, 23.6, 26.4, 20, 25.2, 25.8, 21.2, 14.5, 27.3, 23.6, 18.5, 33.9, 25.5, 26.4, 32.5, 26.7, 21.5, 23.3, 29.5, 25.5, 26.4, 22.4, 24.5, 24.8, 30.9, 26.4, 27.3, 29.4, 23]
        ]
      },
      "x": {
        "dose": ["0.5", "0.5", "0.5", "0.5", "0.5", "0.5", "0.5", "0.5", "0.5", "0.5", "0.5", "0.5", "0.5", "0.5", "0.5", "0.5", "0.5", "0.5", "0.5", "0.5", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2"]
      }
    },
    config = {
      "graphType": "Boxplot",
      "graphOrientation": "vertical",
      "groupingFactors": ["dose"],
      "xAxis": ["len"],
      "xAxisTitle": "len",
      "smpTitle": "dose",
      "smpTitleFontStyle": "bold",
      "axisTitleFontStyle": "bold",
      "axisAlgorithm": "rPretty",
      "smpTextRotate": 0,
      "showLegend": False,
      "colorBy": "dose",
      "title": "Tooth growth by dose (Welch t-test, BH-adjusted)",
      "showStatInference": True,
      "statInference": {
        "correction": {
          "method": "BH"
        },
        "annotate": "stars",
        "comparisons": [
          {
            "groups": ["0.5", "1"],
            "p": 1.26830072017385e-07
          },
          {
            "groups": ["1", "2"],
            "p": 1.9064295136718e-05
          },
          {
            "groups": ["0.5", "2"],
            "p": 4.39752495936323e-14
          }
        ]
      },
      "colorScheme": "GGPlot"
    },
    width = 600,
    height = 600
  )
)
using CanvasXpress

canvasxpress(Dict(
  "y" => Dict(
    "vars" => ["len"],
    "smps" => ["Obs1", "Obs2", "Obs3", "Obs4", "Obs5", "Obs6", "Obs7", "Obs8", "Obs9", "Obs10", "Obs11", "Obs12", "Obs13", "Obs14", "Obs15", "Obs16", "Obs17", "Obs18", "Obs19", "Obs20", "Obs21", "Obs22", "Obs23", "Obs24", "Obs25", "Obs26", "Obs27", "Obs28", "Obs29", "Obs30", "Obs31", "Obs32", "Obs33", "Obs34", "Obs35", "Obs36", "Obs37", "Obs38", "Obs39", "Obs40", "Obs41", "Obs42", "Obs43", "Obs44", "Obs45", "Obs46", "Obs47", "Obs48", "Obs49", "Obs50", "Obs51", "Obs52", "Obs53", "Obs54", "Obs55", "Obs56", "Obs57", "Obs58", "Obs59", "Obs60"],
    "data" => [
      [4.2, 11.5, 7.3, 5.8, 6.4, 10, 11.2, 11.2, 5.2, 7, 15.2, 21.5, 17.6, 9.7, 14.5, 10, 8.2, 9.4, 16.5, 9.7, 16.5, 16.5, 15.2, 17.3, 22.5, 17.3, 13.6, 14.5, 18.8, 15.5, 19.7, 23.3, 23.6, 26.4, 20, 25.2, 25.8, 21.2, 14.5, 27.3, 23.6, 18.5, 33.9, 25.5, 26.4, 32.5, 26.7, 21.5, 23.3, 29.5, 25.5, 26.4, 22.4, 24.5, 24.8, 30.9, 26.4, 27.3, 29.4, 23]
    ]
  ),
  "x" => Dict(
    "dose" => ["0.5", "0.5", "0.5", "0.5", "0.5", "0.5", "0.5", "0.5", "0.5", "0.5", "0.5", "0.5", "0.5", "0.5", "0.5", "0.5", "0.5", "0.5", "0.5", "0.5", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2"]
  )
);
  graphType = "Boxplot",
  graphOrientation = "vertical",
  groupingFactors = ["dose"],
  xAxis = ["len"],
  xAxisTitle = "len",
  smpTitle = "dose",
  smpTitleFontStyle = "bold",
  axisTitleFontStyle = "bold",
  axisAlgorithm = "rPretty",
  smpTextRotate = 0,
  showLegend = false,
  colorBy = "dose",
  title = "Tooth growth by dose (Welch t-test, BH-adjusted)",
  showStatInference = true,
  statInference = Dict(
    "correction" => Dict(
      "method" => "BH"
    ),
    "annotate" => "stars",
    "comparisons" => [
      Dict(
        "groups" => ["0.5", "1"],
        "p" => 1.26830072017385e-07
      ),
      Dict(
        "groups" => ["1", "2"],
        "p" => 1.9064295136718e-05
      ),
      Dict(
        "groups" => ["0.5", "2"],
        "p" => 4.39752495936323e-14
      )
    ]
  ),
  colorScheme = "GGPlot"
)
⇧