Combined phylogenetic tree with admixture results

25 views
Skip to first unread message

_FZ_

unread,
Aug 10, 2023, 12:33:16 AM8/10/23
to ggtree
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
Reply all
Reply to author
Forward
0 new messages