Reputation: 129
I am a complete newbie with R
and please forgive me if this already has been asked a gazillion times. I am trying to make a heatmap
using R
, following this example, which are tsvs
.
This is an example.
name sam1 sam2
a 0.2 0
b 0.1 0.05
c 0.3 0.06
Sorry, I can not post the graph that I get (because I am a newbie).
When the graph is made the scale is between 0 to 1 (the data is rescaled between 0 to 1 in heatmap
), however I do not have any values bigger than 0.3 in my files, hence I want to know if it is possible to have a scale between 0 to 0.3 in heatmap
. I am not sure if I am providing enough details here, please let me know if I need to put in some more details here.
basically I am using
a <- read.table(file = "name", sep ="\t", header =T)
a.m <- melt(a)
a.m <- ddply(a.m, .(variable), transform, rescale = rescale(value))
(p <- ggplot(a.m, aes(variable, transposons)) +
geom_tile(aes(fill = rescale), colour = "yellow") +
scale_fill_gradient(low = "yellow", high = "darkgreen"))
Any help is most appreciated, thanks in advance.
Upvotes: 3
Views: 2798
Reputation: 121568
By default we have ?rescale
rescale(x, to = c(0, 1), from = range(x, na.rm = TRUE))
That's why your values are between 0 and 1.Just specify min and max to ?rescale
a.m <- ddply(a.m, .(variable), transform,
rescale = rescale(value,to=c(0,0.3))))
Upvotes: 3