Heatmap.2 draw a X if column name start by number
1
0
Entering edit mode
4.1 years ago

Hi all,

I'm having problems when heatmap.2 plot the column names if the first character is a number. Heatmap.2 add a X just before the number, and I don't know how to solve it.

The data matrix:

,1A,1B,1C,2A,2B,2C
Actinobacteria,22.30,3.44,4.48,8.23,14.90,12.82
Bacteroidetes,0.48,5.53,0.15,4.01,5.92,1.89
Balneolaeota,1.61,2.37,2.21,0.11,0.11,0.07
Candidatus Dadabacteria,0.10,0.12,29.39,0.00,0.00,0.00
Chloroflexi,0.09,0.20,0.50,4.65,11.29,8.00
Cyanobacteria,20.41,3.56,0.38,40.89,2.31,23.07
Firmicutes,47.58,64.02,48.88,15.40,14.32,7.20
Gemmatimonadetes,0.00,0.01,0.22,0.42,0.86,1.01
Proteobacteria,14.14,16.31,11.59,22.59,43.47,40.51
Planctomycetes,1.04,1.21,0.64,1.57,3.89,3.81
Rhodothermaeota,10.94,2.81,0.81,0.17,0.69,0.77
Candidatus Patescibacteria,0.33,0.24,0.07,1.58,1.33,0.37

The R script:

Phylum_data <- read.csv("phylum.txt")
phylum_rnames <- Phylum_data[,1]
phyl_dat <- data.matrix(Phylum_data[,2:ncol(Phylum_data)])
rownames(phyl_dat) <- phylum_rnames


heatmap.2(phyl_dat,
          dendrogram = "column", Colv = T, Rowv = NA,
          scale = "none", col= colorRampPalette(brewer.pal(9, "Blues"))(100),
          key = TRUE, density.info = "none", key.title = NA, key.xlab = "Abundance (%)",
          trace = "none",
          margins =c(8,17),
          cellnote = round(phyl_dat, 1),
          labRow=as.expression(lapply(rownames(nerja_datos_filo), function(a) bquote(italic(.(a))))), 
          notecol = "red",
          main = "Diversity at Phylum level",
          cexRow = 1.5,
          lhei = c(1,8), lwid = c(1,3)
)

When the heatmap is plotted, the colnames appear as "X1A" "X1B"... How could I proceed to remove the X??

R • 965 views
ADD COMMENT
1
Entering edit mode
4.1 years ago

I answer myself. The problem was in read.csv("phylum.txt"), I should have added check.names=FALSE.

Thanks!

ADD COMMENT

Login before adding your answer.

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