James Reilly
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # BI278 Lab 7 Notes ### Exercise 1. andi (ANchor DIstances) - andi identifies long exact matches between two genomes which it uses as homologous segments. It then looks at the mismatched regions bracketed by these anchors and estimates a distance matrix. Ideally, it is used for very closely related genomes. - Running andi is quite simple but we need to first prepare an input file that contains all our genomes that we want to build a phylogeny with. 1. For this lab: `ls /courses/bi278/Course_Materials/lab_07/*.* > andi_inputs.txt` 2. To run andi: `andi --file-of-filenames=andi_inputs.txt -t 2 --join > andi_output.dist` ### Exercise 2. IQ-Tree for phylogenies - IQ-TREE estimates trees for either nucleotide or protein alignments using maximum likelihood. - tests a large range of phylogenetic models for you then outputs a tree best of which model appears to be most appropriate for your data. 3. To identify orthogroups with genes present from each genome, find the rows where orthologous groups share a common ancestor at node 0 and each genome has at least one gene member in the group. Utilizes this command: `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/Phylo genetic_Hierarchical_Orthogroups/N0.tsv > 18taxa_coregenes.txt` 4. To see how many genes are included in each orthogroup from the above command use: `sed 's/, /\t/g' 18taxa_coregenes.txt | awk '{print $1, NF-1}'` - This should give a list of a bunch of different orthogroups. Then you can collect the amino acid sequences for all the members of an orthogroup (from this list) of your choosing. ### Mistake here! I didn't choose a file found after the sed command, and therefore didn't limit the search enough. - In this lab, I chose to use the orthogroup titled OG0006491 to view the amino acid sequences in this lab, we utilize the command: `/courses/bi278/Course_Materials/lab_07/orthofinder_18taxa/Orthog roup_Sequences/OG0006491.fa` 5. To generate a multiple sequence alignment, you can use MAFFT: `mafft --maxiterate 3 /courses/bi278/Course_Materials/lab_07/orthofinder_18taxa/Ortho group_Sequences/OG0006491.fa > OG0006491_mafft.faa` 6. Now, you can use this Multiple Sequence Alignments as input for an iqtree: `iqtree -s OG0006491_mafft.faa` - this tests the protein substitution models it has, picks the best one for your data, and does tree searching then prints a detailed log to the screen as it does it. - At the end, it gave me a little message stating where to find specific items about the tree. My maximum-likelihood tree was found in a file called "OG0006491_mafft.faa.treefile" - This command also gives an overarching review of the information (along with a preview of the tree) in the file called "OG0006491_mafft.faa.iqtree" ### Exercise 3. Trees in R Now, we can compare trees in R. Phylogenetics packages in R are "ape: Analyses of Phylogenetics and Evolution" as well as "phytools". The developer of phytools created this website: http://blog.phytools.org/ Which is very helpful for answering questions regarding phytools. You can then copy trees from orthofinder that you may have found: (for this example) ``/courses/bi278/Course_Materials/lab_07/orthofinder_18taxa/Gene _Trees/OG0000084_tree.txt`` and `/courses/bi278/Course_Materials/lab_07/orthofinder_18taxa/Spec ies_Tree/SpeciesTree_rooted.txt` 7. Now, we can compare these trees. - First we log into to RStudio at bi278.colby.edu - Within RStudio, all commands typed for the following steps can be entered in the top left box, and executed by typing command+return - the cursor has to be on the line you are running it on though! 8. To load the phylogenetics packages we use: (written in R) ``` library(ape) library(phytools) ``` 9. we then take the distance matrix generated by andi and make a neighbor-joining tree from it. ``` andi.dist <- read.table("/home2/snoh/lab_07/andi_output.dist", header=F, row.names=1, skip=1) colnames(andi.dist) <- rownames(andi.dist) # infer tree from distance matrix andi.tree <- nj(as.dist(andi.dist)) ``` 10. To take a look at this tree: `plot(andi.tree)` 11. Now to make it easier to compare trees between methods, you can clean up the labels of the tips with a few different methods: - 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) 12. Now we can look at our tree again, and this time with node numbers. ``` plot(andi.tree) nodelabels() ``` 13. We can also root our tree with the outgroup node, then look at it again: ``` rooted.andi <- root.phylo(andi.tree, node=34, resolve.root=T) plot(rooted.andi, cex=1, label.offset=0.005) ``` 14. Now, we can look at the species tree outputted by orthofinder: ``` ortho.tree <- read.tree("/courses/bi278/Course_Materials/lab_07/orthofinder_1 8taxa/Species_Tree/SpeciesTree_rooted.txt") plot(ortho.tree) ``` fix tip labels: ``` 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) ``` To root 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) ``` 15. Now we can rotate the nodes of this tree so the tips more closely match the tips of the tree from andi: ``` rotate.ortho <- rotateConstr(rooted.ortho, rooted.andi$tip.label) plot(rotate.ortho) ``` 16. Now we can compare how similar these trees are: - 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) ``` - upon analysis of side by side comparisons, if there are notable differences between the trees, we can assume that we can either improve our taxon sampling (include more Paraburkholderia species other than the four we have here to better resolve their relationships in this example) or perhaps even just use andi for the very closely related taxa it's supposed to be best for. 17. Now we can compare our gene trees. - the tree generated with IQ-Tree: ``` iqtree <- read.tree("/home2/jereil26/lab_07/OG0006491_mafft.faa.treefile") ``` - to check and root this tree: ``` 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) ``` - rotate and compare ``` rotate.iq84 <- rotateConstr(rooted.iq84, rooted.or84$tip.label) all.equal(rooted.or84, rooted.iq84, use.edge.length=FALSE) cophyloplot(rooted.or84, rotate.iq84) ``` ## Mistake here: due to my random selection of the OG group (didn't fully follow instructions earlier) my tree was too small to be applied in R well, if a different (and applicable) orthologous group was chosen and the same steps occurred, I could have been in the correct place at this step :( 18. Last step is saving figures you created. You can do this directly, but you can also save species trees as text files in case you want to use it in the future: ``` write.tree(rooted.andi, file="PATH/andi_cleaned.tre") write.tree(rotate.ortho, file="PATH/ortho_cleaned.tre") ``` I saved these two trees in my home2 under lab_07. I saved the rscript for this lab as "lab7rscript.r"

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully