How to create color range for RPKM/FPKM using R?
1
0
Entering edit mode
8.1 years ago
Whoknows ▴ 890

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 R Graphic ggplot2 gplots • 3.6k views
ADD COMMENT
2
Entering edit mode

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

ADD REPLY
1
Entering edit mode

Have you read the documentation for scale_gradient()?

ADD REPLY
0
Entering edit mode

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 REPLY
1
Entering edit mode

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 REPLY
0
Entering edit mode

BTW, you probably want to color on log2 level.

ADD REPLY
0
Entering edit mode

yes of course log2, but how !!??

ADD REPLY
0
Entering edit mode

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 REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode
8.1 years ago
Whoknows ▴ 890

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 COMMENT
0
Entering edit mode

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 REPLY

Login before adding your answer.

Traffic: 2612 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