0

I want to run this code (below) to produce a gains/loss tree for some orthofinder data. I have been following a github guide https://github.com/guyleonard/orthomcl_tools

and have gotten through all of this except for the last part for plotting the data.

I'm sure there are a lot of ways you could do this in ggplot2 but it would be really helpful if someone knows how to fix this code so that the subset parameter is no longer there.

This is the error message I get:

Warning: Ignoring unknown parameters: subset Warning: Ignoring unknown parameters: subset Warning: Ignoring unknown parameters: subset Warning: Ignoring unknown parameters: subset Warning: Ignoring unknown parameters: subset Warning message: Duplicated aesthetics after name standardisation: size

I'm not sure yet if that aesthetics error is going to give me grief but I do know R no longer uses subset so that is definitely a problem.

library(ggplot2)
library(ggtree)

user_report <- read.csv("outfile.phy_newstyle_report.txt", sep = "\t", header=TRUE, as.is=1, row.names=NULL)

user_tree <- read.tree("tree_4code_internal_labels.tree")

user_p <- ggplot(user_tree, aes(x, y), ladderize=TRUE) + geom_tree() + 
           theme_tree() + 
           geom_tiplab(size=3, align=TRUE, color="purple", x=13) + 
           xlab("") + ylab("") + 
           geom_text(aes(label=Gain, x=branch), size=3, color="springgreen4", vjust=-0.6, subset=.(!isTip)) + 
           geom_text(aes(label=Gain), size=3, color="springgreen4", hjust=0, subset=.(isTip), x=13.5) + 
           geom_text(aes(label=Loss, x=branch), size=3, color="firebrick3", vjust=1.3, subset=.(!isTip)) + 
           geom_text(aes(label=Loss), size=3, color="firebrick3", hjust=0, subset=.(isTip), x=14) + 
           geom_text(aes(label=node), size=2, hjust=-1.5, subset=.(!isTip), color="grey") + 
           scale_x_continuous(expand = c(.1, .2))

user_p <- user_p %<+% user_report

print(user_p)
morgan121
  • 2,213
  • 1
  • 15
  • 33
Chloe
  • 1
  • 1
  • 1
    See https://stackoverflow.com/a/34588455/1222578 – Marius Apr 29 '19 at 06:46
  • 1
    This answer that uses `.` and `filter` is also quite clever, and might work better when you have facetting in your plot: https://stackoverflow.com/a/53264920/1222578 – Marius Apr 29 '19 at 06:52

0 Answers0