Question: How to create color range for RPKM/FPKM using R?
0
gravatar for Whoknows
4.4 years ago by
Whoknows660
Tehran,Iran
Whoknows660 wrote:

Hi every body

I want to create a color range for FPKM/RPKM data using R or another software if it possible, but i don't know how to do it.

For better understanding please take a look at the photo.Thanks a lot

Color range for FPKM / RPKM values

rna-seq gplots graphic ggplot2 R • 2.3k views
ADD COMMENTlink modified 4.4 years ago • written 4.4 years ago by Whoknows660
2

I might suggest using a density plot of values instead.  It will be much more informative, I suspect.

ADD REPLYlink written 4.4 years ago by Sean Davis25k
1

Have you read the documentation for scale_gradient()?

ADD REPLYlink written 4.4 years ago by Devon Ryan85k

yes i've read this kind of scale_gradient() diagram but as you see in the chart my values are discrete,

please note that i have more than 10000 FPKM/RPKM values which will be show in the diagram,

anyway thanks again,

ADD REPLYlink modified 4.4 years ago • written 4.4 years ago by Whoknows660
1

Err, your FPKM/RPKM values are continuous, that's why you can simply color by value and use a gradient scale, as in that image.

ADD REPLYlink written 4.4 years ago by Devon Ryan85k

BTW, you probably want to color on log2 level.

ADD REPLYlink written 4.4 years ago by Devon Ryan85k

yes of course log2, but how !!??

ADD REPLYlink written 4.4 years ago by Whoknows660

The simplest way would be to just graph log2(RPKM) to begin with. Alternatively, just add that as a column to the dataframe or just perhaps even use something like colour=log2(RPKM) as an argument.
 

ADD REPLYlink written 4.4 years ago by Devon Ryan85k

What do you want to use the color gradient for, a heatmap?

ADD REPLYlink written 4.4 years ago by Michael Dondrup44k
0
gravatar for Whoknows
4.4 years ago by
Whoknows660
Tehran,Iran
Whoknows660 wrote:

I offer this way if anybody  expert in R please develop it

 

x <- data.frame(FPKM = rnorm(1000))

x$Color <- cut(x$FPKM, 256)

library(gplot)

library(ggplot2)

x$Color2 <- redgreen(256)[as.numeric(x$Color)]

ggplot(x, aes(FPKM,1,fill=Color2))+geom_bar(stat="identity")+coord_flip()

// Or use below after log2

 ggplot(y, aes(FPKM,ymin=-1,ymax=1,color=Color))+

geom_linerange()+coord_flip()+theme(legend.position="none")+scale_x_log10()

 

 

 

ADD COMMENTlink modified 4.4 years ago • written 4.4 years ago by Whoknows660

Is library(gplot) supposed to be library(gplots)? I tried the graph, and it seems like kind of an odd way to represent the data. Also I get the following error when using the code

> ggplot(y, aes(FPKM,ymin=-1,ymax=1,color=Color))+
+ geom_linerange()+coord_flip()+theme(legend.position="none")+scale_x_log10()
Error: ggplot2 doesn't know how to deal with data of class numeric

Did you copy the code exactly? I agree with the previous poster that said a histogram would be much more informative. They are fairly simple to make, just use the hist() function. 

hist(x[,1])

Alternatively, you could plot the data as a line or xyplot where the cumulative percent (or actual number) of genes is on the y-axis and RPKM value (log2) is on the x-axis.  

ADD REPLYlink modified 4.4 years ago • written 4.4 years ago by Jason850
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: 603 users visited in the last hour