Entering edit mode
3.1 years ago
shelley.w.peterson ▴ 10
I am trying to generate a dot plot alongside my phylogenetic tree, with x axis = date and y axis is sample in the same order as a phylogenetic tree. dd5 is my info table and p2 is my tree.
dd5 <- drop_na(data.frame(id = dd2$Number, value = as.Date(dd2$Date.Collected, "%Y-%m-%d", origin = "2000-01-01"), prov = dd2$Province)) p4 <- facet_plot(p2, "Sample Date", data=dd5, geom = geom_point, mapping = aes(x = value, color = Province)
When I run this code, I get
> Error in as.Date.numeric(value): 'origin' must be supplied. is.date(dd5$value) = TRUE
and I get the same error whether or not I include
as.Date or an origin
mapping = aes(x = as.numeric(as.Date(value)), color = Province)
gives me the dot plot I want, but I need the x axis to show the actual dates.
If I add
scale_x_date, I get the error
> Invalid input: date_trans works with objects of class Date only
despite the fact that
Please help! TIA
Can you show us the output to:
dd2 is really large, but here's dd5 (the columns match as expected)
One more thing to add is that one of the rows has NA for date. I still get the same error if I put a dummy date in, so that shouldn't be the problem.
I'm trying to reproduce your problem. What is
It's a phylogenetic tree showing the relatedness between the samples. The order of the samples in the phylogenetic tree is how they should be plotted on the y axis on the dot plot.
Sorry, I'm not familiar with
ggtree, and this seems a little too complicated for me to reproduce here. I'd recommend chipping away at it until you get to the root of what is failing.