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:
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:
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)
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()
Now with quotation marks:
ggplot(mpg, aes(displ, hwy, colour = "class")) +
geom_point()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.