Question: Setting colour palettes correctly for correlation plots
gravatar for exin
8 weeks ago by
exin50 wrote:

Newbie R question:

I currently use the standard blue-red palette for plotting a correlation plot:

> col<- colorRampPalette(c("blue", "white", "red"))(20)

but my data only covers a R value or ~0.2 to 1, hence white is set at ~0.4, which is misleading.

How do I select only "some blue and all red" of the spectrum, still with 20 divisions?

Undesired scale colours & associated plot:

R correlation plot • 117 views
ADD COMMENTlink modified 8 weeks ago • written 8 weeks ago by exin50

can you provide the entire code you use for the heatmap generation, not just the color part? (different heatmap functions may have different capabilities of tuning the colors)

ADD REPLYlink written 8 weeks ago by Friederike4.9k

Here we go:

cts<- read.table("cor_gene.txt",header=T,row.names=1,sep="\t")
cts<- cts[rowSums(cts)>0,]
cts$var<- apply(cts, 1, var)
ctsv<- cts[cts$var >= quantile(cts$var, c(.95)), ]
ctsv$var <- NULL


col<- colorRampPalette(c("blue", "white", "red"))(20)
pheatmap(resv, col=col, cluster_cols=T, cluster_rows=T, 
         show_rownames=T, scale = "none", border_color=F,
         fontsize_row=5.2, fontsize_col=5.2, fontsize=8, 
         cellheight=5, cellwidth=5, clustering_method = "complete")
ADD REPLYlink written 8 weeks ago by exin50
gravatar for Jean-Karim Heriche
8 weeks ago by
EMBL Heidelberg, Germany
Jean-Karim Heriche20k wrote:

Check the breaks option. Have a look at this pheatmap tutorial.

ADD COMMENTlink modified 8 weeks ago • written 8 weeks ago by Jean-Karim Heriche20k

Looks like what I need... Thank you! I'll look into that.

ADD REPLYlink written 8 weeks ago by exin50
Please log in to add an answer.


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