Statistical annotations on plots
Last updated
Last updated
The required package for this section is statannotations, which will also automatically install the pandas and seaborn packages, on which it is dependent. As of statannotations version 0.6, it unfortunately relies on outdated versions of pandas and seaborn. These can be installed with the following command in the command window (Windows) / terminal (Mac).
On Windows systems, the above command to install statannotations may give an error stating that the building of the wheels has failed. To fix this error the Visual studio C++ build tools have to be installed. You can use and check the options as shown in the screenshot below:
After the installation has completed run the following commands in the terminal:
The statsannotations library should now have installed correctly.
We will again use the demo lipidomics dataset:
Load the dataset into a Pandas DataFrame named df as described in the basic plotting section:
To get the annotations of a statistical test drawn automatically on a plot, the statsanotations package can be used in combination with seaborn. We'll have to define, which column of our dataframe contains the x-axis variable (the "Label" column), and the y-variable is the lipid species of choice. We'll define the order in which we want the different "Label" groups to appear and which pairs we want to compare. Finally we'll also pass to the configurator which statistical test we want to use, Mann-Whitney in this case: