0

I have very limited experience coding so please bear with me!

I have a newick tree and a .txt file with various cell numbers assigned to various clone numbers, shown here:

List

I've followed the steps from the PHE: Bioinformatics page and all I am getting is one color on all of the tips, not seeming to categorize the cells by Clone number.

Here is an image of the resulting plot:

Output

library("ggplot2")
library("ggtree")
nwk <- ("/Users/Nisu/Downloads/True.nwk")
tree <- read.tree(nwk)
p <- ggtree(tree,right = TRUE)
tip_metadata <- read.table("/Users/Nisu/Downloads/TallG5clone_50_9_True_cloneAnno.txt", sep="\t",col.names = c("Clone", "Cell"),header=TRUE,check.names=FALSE, stringsAsFactor=F)
p <- p %<+% tip_metadata + geom_tippoint(aes(color= "Clone"), size=3)
plot(p)
StupidWolf
  • 45,075
  • 17
  • 40
  • 72
np0119
  • 1

1 Answers1

0

That is most likely because you added quotation marks to "Clone". Variables in the data should not be quoted. It should be therefore geom_tippoint(aes(color= Clone).
Here is an example: Adding the aes colour = class without quotation marks:

library(ggplot2)

ggplot(mpg, aes(displ, hwy, colour = class)) + 
  geom_point()

enter image description here

Now with quotation marks:

ggplot(mpg, aes(displ, hwy, colour = "class")) + 
  geom_point()

enter image description here

ViviG
  • 1,613
  • 1
  • 9
  • 23
  • I thought that as well, but whenever I removed the quotation marks I received the following error: Error in FUN(X[[i]], ...) : object 'Clone' not found – np0119 Jun 07 '21 at 11:39
  • Sorry to bother, but @ViviG do you possibly know why I’m still getting the object not found error? – np0119 Jun 10 '21 at 07:15
  • It is really hard to tell because I can't reproduce your example. Is it possible for you to share your files? – ViviG Jun 10 '21 at 10:51
  • Yes here is a link to a dropbox with both files mentioned in my example: https://www.dropbox.com/sh/u94t2y67yiqzspl/AACuv6OumTHTqtDC5SVVF9f7a?dl=0 – np0119 Jun 11 '21 at 23:38