Increase height of box plots in ggplot
2
0
Entering edit mode
5.4 years ago

I have plotted genotype against splicing ratio, due to a large number of outliers the size of boxplots squeezed, is there any way to increase the size?

Sample data:

sample   Isoforms    Ratio   Genotype
108 AT1G04170_JC4   0.114555061397559   CC
139 AT1G04170_JC4   1.43188141139633E-07    CC
159 AT1G04170_JC4   0.974829214147311   CT
108 AT1G04170_P1    0.885444938602441   CC
139 AT1G04170_P1    0.980915433730349   CC
159 AT1G04170_P1    0.025170785852689   CT
108 AT1G04170_P2    0   CC
139 AT1G04170_P2    0   CC
159 AT1G04170_P2    0   CT
108 AT1G04170_c1    0   CC
139 AT1G04170_c1    0.01908442308151    CC
159 AT1G04170_c1    0   CT

R code:

Trans <- read.delim("EXAMPLES/AT1G04170_SR_2", header=TRUE, sep="\t")
Trans_1 <- ggplot(data=Trans,mapping=aes(x=Genotype,y=Ratio,fill=Isoforms)) +geom_boxplot()

Image

I want to increase the height of box plots

R ggplot2 boxplot • 5.1k views
ADD COMMENT
2
Entering edit mode
5.4 years ago

Given that you can't really change the scale or log transform this (or at least you probably wouldn't want to), I'd suggest trying violin plots instead.

ADD COMMENT
0
Entering edit mode

Many thanks for your suggestion, I have tried violin plots but it also didn't work for me

ADD REPLY
2
Entering edit mode
5.4 years ago

The data are the data. You can't make box plots "higher" without changing the standard definition of a box plot, but you could change the data that go into calculating their features (IQR, etc.), so that box plots show you a relevant subset of your data.

You could filter outliers to this subset using either, for example:

  1. Trimming: Removing outliers from the data altogether.

  2. Winsoring: Finding the threshold of your outliers and setting all values outside this range to the winsored minimum and maximum. This is different from trimming.

Either approach changes the set of data going into box plotting.

Another approach is that you investigate why you have so many outliers and fix your data, experiment, etc.

ADD COMMENT

Login before adding your answer.

Traffic: 1902 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6