Hello,
I am trying to plot a phylogenetic tree and results of an ADMIXTURE analysis (i.e., results about ancestry of each sample). For each tip in the phylogeny, I have a tibble with assignment probabilities to a given Population. The columns in the tibble correspond to sampleID, pop1, pop2, pop3, etc and each row to the sampleIDs and the probabilities of assignment to each population. I have tried to used ggtreeExtra but I failed. To create the stacked bar plot I am doing the following:
data_tidy = data %>%
gather("pop1", "pop2", "pop3", "pop4", "pop5",
key = "Population",
value = "Probability")
p2 = data_tidy %>%
ggplot(aes(x = SampleID,
y = Probability,
fill = Population))+
geom_bar(stat = "identity",
position = "stack") +
guides(x = "none") +
coord_flip()
p1 = ggtree(tree)
How can I combine these plots and make sure the tip labels match the order of the stacked bar plot?
Thanks