-
Notifications
You must be signed in to change notification settings - Fork 186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix issues with plot_tree function #1445
base: master
Are you sure you want to change the base?
Conversation
Fix error related to taxonomyTable type in 'treeonly' method Fix missing tip label in 'sampledodge' method
Thank you very much, this saved me a lot of time and nerves! Works like a charm. |
Hi @MoniaLo The PR should allow text labels to be justified. Using the example dataset library(ggplot2)
library(phyloseq)
library(cowplot)
data(GlobalPatterns)
clean <- prune_taxa(taxa_sums(GlobalPatterns) > 0, GlobalPatterns)
sub <- subset_taxa(clean, Order == "Desulfovibrionales")
a <- plot_tree(sub, color = "Family", shape = "SampleType", label.tips = "taxa_names", text.size = 3,
ladderize = "left", justify = "left", title = "Desulfovibrionales") + scale_shape_manual(values = 1:9)
b <- plot_tree(sub, color = "Family", shape = "SampleType", label.tips = "Genus", text.size = 3,
ladderize = "left", justify = "left", title = "Desulfovibrionales") + scale_shape_manual(values = 1:9)
plot_grid(a, b, ncol = 1) tax_table(sub)[is.na(tax_table(sub)[,"Genus"]),]
#> Taxonomy Table: [4 taxa by 7 taxonomic ranks]:
#> Kingdom Phylum Class Order
#> 147645 "Bacteria" "Proteobacteria" "Deltaproteobacteria" "Desulfovibrionales"
#> 137367 "Bacteria" "Proteobacteria" "Deltaproteobacteria" "Desulfovibrionales"
#> 361169 "Bacteria" "Proteobacteria" "Deltaproteobacteria" "Desulfovibrionales"
#> 201363 "Bacteria" "Proteobacteria" "Deltaproteobacteria" "Desulfovibrionales"
#> Family Genus Species
#> 147645 "Desulfovibrionaceae" NA NA
#> 137367 "Desulfovibrionaceae" NA NA
#> 361169 "Desulfovibrionaceae" NA NA
#> 201363 "Desulfovibrionaceae" NA NA Created on 2022-05-03 by the reprex package (v2.0.1) |
In my case, my samples don't miss in the annotations, so all the label tips (Species) should show up. So, as you can see from my pictures, everytime I add the justify command ("left" or "yes please"), some label.tip, and so, some Species miss on my tree (you can perfectly see that the last annotation, for example, Bdellovibrio bacteriovorus in greenish doesn't show up in the second plot). To be more clear, even if I set the label tip with taxa_name, some ASV will not show up because of justify, not because of the missing value. |
Hi @MoniaLo Would you like to provide a small dataset for me to test the |
PR to fix some issues with the current
plot_tree
function:method="treeonly"
, thetaxonomyTable
type in the data.table will cause the below issue when including tip labels. See plot_tree: combining "treeonly" with taxonomy table or instead have only one geom_point per leaf? #1042 and plot_tree from phyloseq missing branches names #796method="sampledodge"
, some tip labels would be missing due to abundance filtering with the unsorted data.table. See Missing labels in plot_tree #749 and plot_tree, label.tips = "taxa_names" doesn't display if a sample = 0 #475Usage examples