So I have a dataset which looks like this:
Pos sample_1 sample_2 celltypeX_sample3 celltypeY_sample4 celltypeX_sample5
0 0 0 3 0 1
2 2 1 3 0 0
5 0 0 0 0 1
6 1 0 0 1 0
12 0 1 0 1 1
from this dataset I can calculate a correlation matrix and a heatmap in R with:
data = read.table(file = "fileNameX", row.names = 1, header = T, sep = "\t")
correlationData = cor(data)
heatmap(correlationData, cexRow = 0.25, cexCol = 0.25, symm = T)
after this I want to make a phylogenetic tree using the bionj function of the ape library
arbol <- bionj(correlationData)
plot(arbol1, cex = 0.25, edge.width = 0.5)
Here is where I get stuck, so i have read that it is possible to change te color of the labels by adding a row that indicates in which color group it should be in. So I added this column which creates the new dataset:
Pos sample_1 sample_2 celltypeX_sample3 celltypeY_sample4 celltypeX_sample5
0 0 0 3 0 1
2 2 1 3 0 0
...
7026 0 1 0 1 1
clr 0 0 1 2 1
Is there any way I could color the labels in this way? So everything without a celltype in the name (thus named sample_x) should have the same colour and all cell types should have the same color (thus named celltypeX_sampleY)
I hope my question is clear and it is even possible to do this...
a link to the dataset