Showing posts with label data visualization. Show all posts
Showing posts with label data visualization. Show all posts

Monday, May 01, 2023

Violin plot versus Box-Whisker Plot

A box and whisker plot (Also called: box plot, box-whisker diagram) is defined as a graphical method of displaying variation in a set of data. In most cases, a histogram provides a sufficient display, but a box and whisker plot can provide additional detail while allowing multiple sets of data to be displayed in the same graph. The box-whisker plot displays the following in the data set. 

  1. Minimum value: The smallest value in the data set
  2. Second quartile: The value below which the lower 25% of the data are contained
  3. Median value: The middle number in a range of numbers
  4. Third quartile: The value above which the upper 25% of the data are contained
  5. Maximum value: The largest value in the data set

The box-whisker plot can also indicate the mean value (the dot). The difference between the mean value and the median value can indicate how skewed the data is. 


The box and whisker plot can also include the outliers where outliers are defined as values below Q1 - 1.5 * IQR or values above Q3 + 1.5 IQR (Q1 is 25th percentile and Q3 is 75th percentile, IQR - Interquartile is the distance between 25th percentile and 75th percentile). 


Boxplot can include the only box with lower, upper quartile and median, but not include the min and max values. In a paper by White et al "Combination Therapy with Oral Treprostinil for Pulmonary Arterial Hypertension A Double-Blind Placebo-controlled Clinical Trial", the boxplots without min and max were used to present the NT-proBNP data (a measure with skewed distribution). 

Recently, I see several papers using violin plots to display the data distribution. According to Wikipedia:

violin plot is a statistical graphic for comparing probability distribution. It is similar to a box plot, with the addition of a rotated kernel density plot on each side.

Violin plots are similar to box plots, except that they also show the probability density of the data at different values, usually smoothed by a kernel density estimator. Typically a violin plot will include all the data that is in a box plot: a marker for the median of the data; a box or marker indicating the interquartile range; and possibly all sample points, if the number of samples is not too high.

A violin plot is more informative than a plain box plot. While a box plot only shows summary statistics such as mean/median and interquartile ranges, the violin plot shows the full distribution of the data. The difference is particularly useful when the data distribution is multimodal (more than one peak). In this case a violin plot shows the presence of different peaks, their position and relative amplitude.

Like box plots, violin plots are used to represent comparison of a variable distribution (or sample distribution) across different "categories" (for example, temperature distribution compared between day and night, or distribution of car prices compared across different car makers).

A violin plot can have multiple layers. For instance, the outer shape represents all possible results. The next layer inside might represent the values that occur 95% of the time. The next layer (if it exists) inside might represent the values that occur 50% of the time.

Although more informative than box plots, they are less popular. Because of their unpopularity, they may be harder to understand for readers not familiar with them. In this case, a more accessible alternative is to plot a series of stacked histograms or kernel density distributions.


In a paper by Colli et al "Burden of Nonsynonymous Mutations amongTCGA Cancers and Candidate Immune CheckpointInhibitor Responses", the violin plot was used to display the distribution for r the number of NsM (log10) across different tumor types. 


SAS has a procedure Proc BOXPLOT to generate the box-whisker plots and SAS codes are also provided for generating the Violin plots. Other data analysis software including R have packages to generate the box-whisker plot and violin plot.  

Monday, May 02, 2022

Power of the statistical graphs - an example of different ways for a Bar Chart

For the same set of data from the clinical trial, it is important to choose the appropriate statistical analysis methods. It is also important to choose the appropriate plot to display and visualize the data. The example below demonstrate the power of the statistical graphs (even the simple bar charts). 

A clinical trial is designed as a randomized, double-blinded, parallel three-arm study to evaluate the effect of high-dose and low-dose of an investigational drug in comparison with the Placebo. The outcome measure is NYHA Functional Class with four grades (I, II, III, and IV). At each post-baseline visit, function class is improved if it is shifted at least one grade toward the lower end, and functional class deteriorates if it is shifted at least one grade toward the high end. Suppose that at the end of the study, the outcome of the last visit can be organized as the following: 

High-Dose
(n = 200)

Low-Dose
(n = 198)

Placebo
(n = 202)

Improved

49 (24.5%)

37 (18.7%)

26 (12.9%)

No Change

139 (69.5%)

142 (71.7%)

148 (73.3%)

Deteriorated

12 (6.0%)

19 (9.6%)

28 (13.9%)

Both the dose (high-dose, low-dose, and placebo) and outcome (improved, no change, deteriorated) are considered to be the ordinal data. The statistical test with CMH gives a p-value of 0.0010 indicating the association between the dose groups and the outcome measures. 

The interesting thing is the data visualization - there are different ways to plot the data in the table above. What is the best way to plot the results in the table above?

If we are only interested in the proportion of subjects who have 'improved' functional class:



If we are only interested in the proportion of subjects who have 'deteriorated' functional class:


If we are interested in both the proportion of subjects who have 'improved' functional class and the proportion of subjects who have 'deteriorated' functional class: 

The bar chart can be arranged by outcome (improved and deteriorated) and the dose group (high-dose, low-dose, and placebo)

or the bar chart can be arranged by the dose group (high-dose, low-dose, and placebo) and then the outcome (improved and deteriorated). 



A stacked bar chart can be used to include all three outcome categories (improved, no change, and deteriorated):



The best approach is to place the outcome of 'improved' and 'deteriorated' functional class on the same vertical bar, but one above the 0-line and one below the 0-line. This approach assigns the 'improved' category as a positive value and the 'deteriorated' category as a negative value. 

These bar charts can be created using existing software such as SAS/Graphs, Microsoft Excel, and Graphpad Prism. It seems to be easier to use SAS to manipulate the data or obtain the aggregate data and then use Excel or Prism to create the charts. Prism is better and easier to use for creating charts for publications. 

Friday, November 26, 2021

Venn Diagram to Display the Distribution of the Adverse Events

Visualizing the clinical trial data is becoming more common and various plots can be drawn to visualize the data. In previous posts, we discussed various types of plots that can be used in describing the clinical trial data. 

Recently, we are discussing the use of the 'Venn diagram' for displaying the distribution of the adverse events - the number and percentage of overlapping AEs. See an example of a four-way Venn diagram below:




Wikipedia introduced the Venn diagram as the following: 
A Venn diagram is a widely-used diagram style that shows the logical relation between sets, popularized by John Venn in the 1880s. The diagrams are used to teach elementary set theory, and to illustrate simple set relationships in probability, logic, statistics, linguistics and computer science. A Venn diagram uses simple closed curves drawn on a plane to represent sets. Very often, these curves are circles or ellipses.
According to the paper "V is for Venn Diagrams!": 
Venn diagrams where introduced in 1883 by John Venn (1834-1923), the Hull born philosopher and mathematician. They are a great way to visualize elements that are unique to only one group and simultaneously visualize elements that intersect with other groups. They are symmetrical by nature and the number of groups in a Venn diagram = 2n (including the group outside the diagram).

In clinical trials or the pharmacovigilance field, Venn Diagram can be used to virtualize the distribution of the adverse events, especially to display the distribution and relationships of the frequent adverse events. 

In NIH's "Guidance on Reviewing and Reporting Unanticipated ProblemsInvolving Risks to Subjects or Others and Adverse Events", the Venn diagram was mentioned for summarizing the general relationship between adverse events and unanticipated problems. 


In a paper by Gattepaille et al"Prospective Evaluation of Adverse Event Recognition Systems in Twitter: Results from the Web‑RADR Project", the Venn diagram was used to summarize the relationship of the recall performance results of the first two components, the relevance filter, and the NER module. 



In a paper by Xie et al "Differential Adverse Event Profiles Associated with BCG as a Preventive Tuberculosis Vaccine or Therapeutic Bladder Cancer Vaccine Identified by Comparative Ontology-Based VAERS and Literature Meta-Analysis", Venn diagram was used to compare four groups of the AEs associated with BCG TB vaccine or bladder cancer vaccine using VAERS and literature resources.