Question: How to make a clear box plot or whatever beautiful for showing the ratio of two genes to each other
0
gravatar for Za
9 months ago by
Za120
Za120 wrote:

Hi,

I have the ratio of the expression of gene A to B (log) in 72 cells from single cell RNA-seq as below

> Ratio
             [,1]
s1.4    1.5451283
s1.5    3.7811063
s1.12   1.7763262
s1.13   0.8683650
s1.19   1.1773567
s1.30   6.4666937
s1.33   1.4422777
s1.35   1.6460203
s1.36   1.5832157
s1.45   2.0319145
s1.46   0.9189128
s1.49   2.0439501
s1.52   1.4832935
s1.53   2.4118799
s1.54   1.2506484
s1.60   1.3955746
s1.62   1.4739499

and value of each gene separately

             [,1]
s1.141 0.00000000
s8.3   0.00000000
s8.5   0.22023869
s8.6   0.20162064
s8.7   0.14204612
s8.8   0.07985437
s8.10  0.10130779
s8.11  0.19110346
s8.12  0.29389777
s8.24  0.50348913
s8.29  0.03306174
s8.30  0.07589081
s8.32  0.02313745
s8.33  0.07523744
s8.34  0.08875268
s8.37  0.12353521


             [,1]
s1.141 0.00000000
s8.3   0.02378827
s8.5   0.15207664
s8.6   0.00000000
s8.7   0.03006931
s8.8   0.00000000
s8.10  0.05193626
s8.11  0.10010986
s8.12  1.31725878
s8.24  0.21005366
s8.29  0.18372565
s8.30  0.07589081
s8.32  0.19116962
s8.33  0.09319443
s8.34  0.08875268
s8.37  0.00000000
s8.38  0.06294988
s8.41  0.09039819
s8.44  0.32153638
s8.46  0.12057702
s8.47  0.00000000
s8.48  0.17554241
s8.53  0.00000000
s8.54  0.12686845
s8.60  0.09154598
s8.61  0.00000000

I tried to visualised that but nothing is clear

boxplot(Ratio)

![enter image description here][1]

How I can make a clear plot of this data please?

ggplots2 R • 607 views
ADD COMMENTlink modified 9 months ago • written 9 months ago by Za120

How to add images to a Biostars post

ADD REPLYlink written 9 months ago by WouterDeCoster38k
6
gravatar for cpad0112
9 months ago by
cpad011211k
India
cpad011211k wrote:
boxplot(Ratio[,1])
beeswarm::beeswarm(Ratio[,1], add = T)

in ggplot(with ratios column with name V2):

p1=ggplot(test, aes(x='',y=V2))+
    geom_violin(fill="steelblue", alpha=0.1, trim = T)+
    geom_boxplot(width=0.1, fill="yellow",outlier.shape = NA)+
    geom_quasirandom()+
    theme_bw()

p2=ggplot(test, aes(x=V2,y=""))+
    geom_density_ridges(fill="steelblue", alpha=0.1,quantile_lines = TRUE)+
    geom_quasirandom(color="blue", groupOnX=T)+
    theme_bw()

library(gridExtra)
grid.arrange(p1, p2,ncol=2)

Rplot

ADD COMMENTlink modified 9 months ago • written 9 months ago by cpad011211k

Very nice, cpad.

ADD REPLYlink written 9 months ago by Kevin Blighe41k
1

Thanks and post was updated after seeing your post @ Kevin Blighe

ADD REPLYlink modified 9 months ago • written 9 months ago by cpad011211k
6
gravatar for Kevin Blighe
9 months ago by
Kevin Blighe41k
Guy's Hospital, London
Kevin Blighe41k wrote:

For yet further ideas from Devon, cpad, and I: Boxplot in ggplot2

Kevin

boxscatter

ADD COMMENTlink written 9 months ago by Kevin Blighe41k
3
gravatar for EagleEye
9 months ago by
EagleEye6.2k
Sweden
EagleEye6.2k wrote:

Try

boxplot(log2(Ratio), notch=TRUE, col="gold")

If in case you have zeros in your data,

boxplot(log2(Ratio+1), notch=TRUE, col="gold")

If you think showing outliers are not important,

boxplot(log2(Ratio), outline=F, notch=TRUE, col="gold")

Or

boxplot(log2(Ratio+1), outline=F, notch=TRUE, col="gold")
ADD COMMENTlink modified 9 months ago • written 9 months ago by EagleEye6.2k

Sorry but my data already are natural logarithm normalised

ADD REPLYlink modified 9 months ago • written 9 months ago by Za120

Hi, sorry I need help on this picture please

> head(gx)
            id time Expression
1 DDB_G0267382 h0_T  10.215756
2 DDB_G0267418 h0_T  12.772017
3 DDB_G0267438 h0_T   9.700146
4 DDB_G0267440 h0_T   5.189603
5 DDB_G0267454 h0_T  13.281143
6 DDB_G0267462 h0_T   6.391131
> tail(gx)
               id  time Expression
9175 DDB_G0295699 h16_R   7.666829
9176 DDB_G0295707 h16_R   5.413715
9177 DDB_G0295735 h16_R   4.813064
9178 DDB_G0295781 h16_R   7.903280
9179 DDB_G0305150 h16_R  10.247035
9180 DDB_G0349530 h16_R   8.388925
> 

> p <- ggplot(gx, aes(time,Expression),outline=F, notch=TRUE, col="gold")
> p + geom_boxplot()

gives me this picture

![enter image description here][1]

How I can order x axis? I mean h0_R h0_T h2_R h2_T ...

seems to me that outline=F, notch=TRUE, col="gold" did not change anything in graph

ADD REPLYlink modified 9 months ago • written 9 months ago by Za120
1

It won't because I did not mention anything about the order of boxplot and those parameters are not meant for 'ggplot'. FYI: I also did not recommend 'ggplot'.

With ggplot you need to first define the orders,

Example,

mydata$mycol <- factor(mydata$mycol, levels = c(3,4,5,1,2,3))

OR

mydata$mycol <- factor(mydata$mycol, levels = c("d","e","f","a","b","c"))

Then plot (if you would like to have different color for each group),

ggplot(mydata, aes(y= values, x= mycol, fill=mycol))+ geom_boxplot(notch=TRUE)

Uniform color for all groups,

ggplot(mydata, aes(y= values, x= mycol))+ geom_boxplot(notch=TRUE, fill="red")
ADD REPLYlink modified 9 months ago • written 9 months ago by EagleEye6.2k

Sorry how to remove outliers and show the mean?

ADD REPLYlink written 9 months ago by Za120
1

Here is the explanation for removing outliers from ggplot and here is how you can mark mean values in boxes. For more information about ggplot boxplots, check here. Have a look at this tutorial for more information on ggplot boxplots.

ADD REPLYlink written 9 months ago by EagleEye6.2k

Thank you, p+coord_cartesian(ylim = quantile(gx$Expression, c(0.1, 0.9))) removed the outliers

ADD REPLYlink written 9 months ago by Za120
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1154 users visited in the last hour