Question: Setting colour palettes correctly for correlation plots
0
gravatar for exin
11 months ago by
exin50
Australia
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: https://ibb.co/Hx6bzdM

R correlation plot • 241 views
ADD COMMENTlink modified 11 months ago • written 11 months 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 11 months ago by Friederike5.7k

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
resv<-cor(ctsv,method="pearson")

library("RColorBrewer")
library("pheatmap")

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 11 months ago by exin50
1
gravatar for Jean-Karim Heriche
11 months ago by
EMBL Heidelberg, Germany
Jean-Karim Heriche22k wrote:

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

ADD COMMENTlink modified 11 months ago • written 11 months ago by Jean-Karim Heriche22k

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

ADD REPLYlink written 11 months ago by exin50
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: 767 users visited in the last hour