# BI278 Lab #7 notes ## exercise 1 First I ran `ls /courses/bi278/Course_Materials/lab_07/* > andi_inputs.txt` to create a file with what is in the cours directory. Then, I ran `andi` with `andi --file-of-filenames=andi_inputs.txt -t 2 --join > andi_output.dist` ## eercise 2 Next, I ran `awk -F "\t" '$3=="n0" && $4!="" && $5!="" && $6!="" && $7!="" && $8!="" && $9!="" && $10!="" && $11!="" && $12!="" && $13!="" && $14!="" && $15!="" && $16!="" && $17!="" && $18!="" && $19!="" && $20!="" && $21!=""' /courses/bi278/Course_Materials/lab_07/orthofinder_18taxa/Phylogenetic_Hierarchical_Orthogroups/N0.tsv > 18taxa_coregenes.txt` which identifys orthogroups. Then, I ran 'sed `'s/, /\t/g' 18taxa_coregenes.txt | awk '{print $1, NF-1}'` to see how many genes are included in each orthogroup from above. Then, I generated a multiple sequence alignment using MAFFT, `mafft --maxiterate 3 /courses/bi278/Course_Materials/lab_07/orthofinder_18taxa/Ortho group_Sequences/OG0000084.fa > OG0000084_mafft.faa` Using that, I ran `iqtree -s OG0000084_mafft.faa` to run iqtree ## exercise 3 We moved to R studio.bi278 * All of the commands below can be entered into the script section (upper left) on your RStudio view and executed from this same section by leaving your cursor anywhere in the line you want to run, then typing [command + return] or manually hitting the Run button. I first loaded our phylogenetics packages with `library(ape)` and `library(phytools)`. I ran `andi.dist <- read.table("/home2/khirat24/andi_output.dist", header = F, row.names = 1, skip = 1) colnames(andi.dist) <- rownames(andi.dist)` to take the distance matrix. Then, I ran `andi.tree <- nj(as.dist(andi.dist))` to create the tree. Now, I plotted the tree with `plot(andi.tree)`. Next, I clearned up the labels and tips * first check what the tip labels are `andi.tree$tip.label` * substitute patterns that have to do with method or source `temp <- gsub(andi.tree$tip.label, pattern="_nanoassembly", replacement="") temp2 <- gsub(temp, pattern="_ncbi", replacement="")` * we can also directly substitute individual elements `temp2[1] <- "bh69"` * we can also directly substitute ranges of elements `temp2[15:18] <- c("Pfungorum", "Psprentiae", "Pterrae", "Pxenovorans")` * last thing to clean up that was inconsistent across names `temp3 <- gsub(temp2, pattern="qs", replacement="")` * replace the original labels `andi.tree$tip.label <- temp3` * clean up unnecessary files `rm(temp, temp2, temp3)` Next, I plotted the tree again with the node labels, `plot(andi.tree) nodelabels()`. Then, I rooted the tree with outgroup, `rooted.andi <- root.phylo(andi.tree, node=34, resolve.root=T) plot(rooted.andi, cex=1, label.offset=0.005)`. Then, I plotted species tree made by Orthofinder by running `ortho.tree <- read.tree("SpeciesTree_rooted.txt")` `plot(ortho.tree)` I cleaned it up just like I did above. `ortho.tree$tip.label` `temp <- gsub(ortho.tree$tip.label, pattern="_prokka", replacement="")` `temp2 <- gsub(temp, pattern="qs", replacement="")` `ortho.tree$tip.label <- temp2` `rm(temp, temp2)` I rooted this tree too `plot(ortho.tree)` `nodelabels()` `rooted.ortho <- root.phylo(ortho.tree, node=25, resolve.root=T) plot(rooted.ortho, cex=1, label.offset=0.005)` I rotated the nodes by `rotate.ortho <- rotateConstr(rooted.ortho, rooted.andi$tip.label)` `plot(rotate.ortho)` Then, I compared the similar trees compare topology (branching pattern) `all.equal(andi.tree, ortho.tree, use.edge.length=FALSE)` plot both trees side by side `cophyloplot(rooted.andi, rotate.ortho)` I compared gene trees made by IQ-TREE and one from Orthofinder `iq.tree <- read.tree("OG0000084_mafft.faa.treefile") plot(iq.tree)` `nodelabels()` `rooted.iq84 <- root.phylo(iq.tree, node = 33, resolve.root = T)` `plot(rooted.iq84, cex = 0.75, label.offset = 0.005)` Orthofinder `gene.tree <- read.tree("OG0000084_tree.txt") plot(gene.tree) nodelabels() rooted.or84 <- root.phylo(gene.tree, node = 55, resolve.root = T) plot(rooted.or84, cex = 0.75, label.offset = 0.005) rotate.iq84 <- rotateConstr(rooted.iq84, rooted.or84$tip.label) all.equal(rooted.or84, rooted.iq84, use.edge.length = FALSE) cophyloplot(rooted.or84, rotate.iq84)` Lastly, I saved my tree figures by running `write.tree(rooted.andi, file = "andi_cleaned.tre")` `write.tree(rotate.ortho, file="ortho_cleaned.tre")`