Last updated: 2021-05-23
Checks: 7 0
Knit directory: wildlife-bacteria/
This reproducible R Markdown analysis was created with workflowr (version 1.6.2). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.
Great! Since the R Markdown file has been committed to the Git repository, you know the exact version of the code that produced these results.
Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.
The command set.seed(20210129)
was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.
Great job! Recording the operating system, R version, and package versions is critical for reproducibility.
Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.
Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.
Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.
The results in this page were generated with repository version 3a8e4cd. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.
Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish
or wflow_git_commit
). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:
Ignored files:
Ignored: .DS_Store
Ignored: .Rhistory
Ignored: .Rproj.user/
Ignored: analysis/.DS_Store
Ignored: data/.DS_Store
Ignored: output/.DS_Store
Ignored: output/plots/.DS_Store
Ignored: output/plots/QC/.DS_Store
Ignored: output/plots/boxplots_select_taxa/.DS_Store
Ignored: output/plots/heatmaps/.DS_Store
Ignored: output/plots/maps/.DS_Store
Ignored: output/plots/tax_prev_abund/.DS_Store
Untracked files:
Untracked: NCBI_data/
Untracked: analysis/microbiome-viz-extra.Rmd
Untracked: analysis/tois.Rmd
Untracked: data/dada2/
Untracked: data/dada2_tois/
Untracked: data/taxa_trees/
Untracked: data/tmp/
Untracked: output/beta-div-statistics.txt
Untracked: output/supp_table_pos.xlsx
Untracked: tmp/
Unstaged changes:
Modified: analysis/_site.yml
Modified: analysis/index.Rmd
Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.
These are the previous versions of the repository in which changes were made to the R Markdown (analysis/phylogeny.Rmd
) and HTML (docs/phylogeny.html
) files. If you’ve configured a remote Git repository (see ?wflow_git_remote
), click on the hyperlinks in the table below to view the files as they were in that past version.
File | Version | Author | Date | Message |
---|---|---|---|---|
Rmd | 0d602a3 | siobhon-egan | 2021-05-23 | updates to pages |
html | 0d602a3 | siobhon-egan | 2021-05-23 | updates to pages |
html | 6ebcc5d | siobhon-egan | 2021-04-24 | updates |
library(ggtree)
library(treeio)
library(tidyverse)
library(ggtreeExtra)
library(ggstar)
library(readr)
library(ggrepel)
library(ape)
library(phangorn)
Tutorial here Tutorial here here here here blog post
Load data
toi_tree <- read.iqtree("data/dada2_tois/IQTREE/all_tois_aln.fasta.treefile") # load IQTREE output
metadata_tree <- read_csv("data/dada2_tois/IQTREE/all_tois_aln.csv")
Make tree
toi_tree = ggtree(toi_tree, branch.length='none', layout='circular')
toi_tree1 = toi_tree %<+% metadata_tree
toi_tree2 = toi_tree1 +
aes(color = Family)
ggsave("tree_toi.pdf", plot = toi_tree2, path = "output/plots", width = 20, height = 20, units = "cm")
# bootstrap
bsp = tree@phylo$node.label
# Add node info
toi_tree3 = toi_tree2 + geom_text(aes(label = label), hjust = 1, vjust = -0.4, size = 3) + geom_nodelab(aes(label = FALSE))
Add note support information
ggtree(toi_tree, layout = 'circular') + geom_label_repel(aes(label=UFboot, fill=UFboot)) +
theme(legend.position = c(.1, .8)) + scale_fill_viridis_c()
toi_tree2 %>% gheatmap(metadata_tree, offset=8, width=0.6, colnames=FALSE) %>% scale_x_ggtree() pp + theme(legend.position=“right”)
To identify node numbers
toi_tree2n = toi_tree2 + geom_text(aes(label=node), hjust=-.3)
Load data
bor_iqtree <- read.iqtree("data/taxa_trees/Borrelia/IQTREE_root/borrelia16sv34_trim_43.fasta.treefile") # load IQTREE output
# newtick tree
bor_ntree <- read.tree("data/taxa_trees/Borrelia/IQTREE_root/tree.newick") # load newick tree
# Metadata
library(readr)
metadata <- read_csv("data/taxa_trees/Borrelia/IQTREE_root/metadata.csv",
col_types = cols(X6 = col_skip(), X7 = col_skip(), X8 = col_skip(), X9 = col_skip(), X10 = col_skip()))
ggtree(bor_tree) + geom_label_repel(aes(label=UFboot, fill=UFboot)) +
theme(legend.position = c(.1, .8)) + scale_fill_viridis_c()
Edit labels
genus <- c(metadata$Genus)
species <- c(metadata$Species)
acc <- c(metadata$Accession)
d <- data.frame(label =bor_iqtree@phylo$tip.label, genus = genus,
species = species, acc = acc)
Make tree with new labels
bor_ntree2 = ggtree(bor_iqtree) %<+% d + geom_tiplab(aes(label=paste0('italic(', genus, ')~bolditalic(', species, ')~', acc)), parse=T) + geom_point2(aes(subset=(node==46)), shape=23, size=5, fill='black') + geom_hilight(mapping=aes(subset = node %in% c(46))) + scale_fill_manual(values=c("darkgreen"))
Save
ggsave("bor_ntree2.pdf", plot = bor_ntree2, path = "output/plots", width = 70, height = 40, units = "cm")
Load data
# load IQTREE output
bart_tree <- read.iqtree("data/taxa_trees/Bartonella/IQTREE_root/bartonella_clustalw_57seq_533bp.fasta.treefile")
# simple load with branch support and tip labels
ggtree(bart_tree) + geom_text(aes(label = label))
#Identify node numbers
ggtree(bart_tree) + geom_text(aes(label=node), hjust=-.3)
bart_tree\(root.edge <- 80 ggtree(b) + geom_tiplab() + geom_rootedge() ggtree(bart_tree) + geom_tiplab() + geom_rootedge() ggtree(bart_tree) + geom_tiplab() + geom_rootedge(rootedge = 80) bart_tree\)root.edge <- 80 ggtree(tree2) + geom_tiplab() + geom_rootedge()
read.nexus parsing standard NEXUS file (re-exported from ape)
plot_bartree = ggtree(bart_tree) + geom_label_repel(aes(label=UFboot, fill=SH_aLRT)) +
theme(legend.position = c(.1, .8)) + scale_fill_viridis_c()
plot_bartree = plot_bartree + geom_point2(aes(subset=(node==68)), shape=23, size=5, fill='red')
#zoom in on clade
viewClade(p, MRCA(p, "DQ538396", "GU168959"))
Old data
#To load data
load("data/taxa_of_interest.RData")
# Load tree
tree <- read.iqtree("data/dada2_tois/IQTREE/ASV_taxa_of_interest_aln.fasta.treefile") # load IQTREE output
# tree <- read.tree("data/dada2_tois/IQTREE/ASV_taxa_of_interest.newick") # load newick tree
# Add metadata
library(readr)
metadata_tree <- read_csv("data/dada2_tois/taxa_of_interest3.csv")
Plot tree
pg = ggtree(tree, branch.length='none', layout='circular')
pg2 = pg %<+% metadata_tree
pg3 = pg2 +
aes(color = Family)
pg3 = pg2 +
geom_tippoint(mapping=aes(color=Family)
pg4 = pg3 +
aes(color = "Family") +
geom_fruit(data=taxa_of_interest,
geom=geom_bar,
mapping = aes(y=OTU, size="Abundance"))
pg4 = pg3 +
geom_fruit(
data=taxa_of_interest,
geom=geom_boxplot,
mapping = aes(
y=OTU,
fill=species
))
pg4 = pg3 +
geom_fruit(
data=taxa_of_interest,
geom=geom_bar,
mapping = aes(
x=OTU,
y=Abundance))
pg = ggtree(tree, branch.length='none', layout='circular')
t1 = pg %<+% taxa_of_interest
t2 = t1 +
aes(color = Family)
t3 <- t1 +
geom_star(
mapping=aes(fill=Family, size=Abundance, starshape=SampleCategory),
starstroke=1
) +
scale_size_continuous(
range=c(1, 3),
guide=guide_legend(
keywidth=0.5,
keyheight=0.5,
override.aes=list(starshape=15),
order=2)
) +
scale_starshape_manual(
values=c(15, 13, 1),
guide=guide_legend(
keywidth=1,
keyheight=1,
order=1
)
)
t4 = t3 + geom_hilight(node=306, fill="pink", alpha=.6)
sessionInfo()