I have created a heatmap for the top 100 differentially expressed transcripts with EnsembIDs and three samples (RNA-seq -> kallisto -> sleuth) .
>heatmap.2(log(tmp_df+1), trace="none", density.info="none", scale="row")
Now I am interested to add gene names in the heatmap for e.g. EnsemblD_genename. For this purpose, I have proceeded as follows:
1) Created "ext_gene" column in tmp_df
>tmp_df["ext_gene"] <- NA
2) Matched target_id from tmp_df with target_id of top_100new (containing ext_gene)
>tmp_df$ext_gene <- top_100new$ext_gene[match(tmp_df$target_id, top_100new$target_id)]
3) Merged target_id and ext_gene columns in tmp_df (target_id__ext_gene column in place of target_id and ext_gene columns)
>unite <- unite(tmp_df, target_id__ext_gene, target_id, ext_gene, sep='_')
4) I was unable to convert "unite" to numeric matrix because one column "target_id__ext_gene" has NA in some rows for e.g. ENSEMBL00001_NA, so I tried to replace NA with NONE.
>unite$target_id__ext_gene <- gsub ('NA', 'NONE', unite$target_id__ext_gene)
5) But, still I am unable to convert "unite" into numeric matrix because column "target_id__ext_gene" has character class. I have tried to use
>unite$target_id__ext_gene <- as.numeric(as.character(unite$target_id__ext_gene))
but, it converts all rows of column "target_id__ext_gene" into NA.
Any help in this regard will be greatly appreciated.