Answers.Body: <p>Your understanding of FASTA format is about right. The type of basic problem you're eluding to we term &quot;sequence alignment&quot;- edit distance might be okay for teaching but in practise we use other algorithms, e.g. you might be interested in the Needleman–Wunsch or Smith–Waterman algorithms. Richard Durbin et al. wrote a great book that covers these any much more <a href="https://rads.stackoverflow.com/amzn/click/com/0521629713" rel="nofollow noreferrer" rel="nofollow noreferrer">https://www.amazon.com/Biological-Sequence-Analysis-Probabilistic-Proteins/dp/0521629713</a></p>
  <p>Tracking mutations etc. requires more than just alignment though, see &quot;phylogenetics&quot; (i.e. building genetic trees) and &quot;variant calling&quot;. Also checkout what the nextstrain team is doing <a href="https://nextstrain.org/ncov/global" rel="nofollow noreferrer">https://nextstrain.org/ncov/global</a></p>
  <p>In general, looking for practical applications for your algorithms is great, but be very careful before drawing any real world conclusions about the coronavirus outbreak from such analyses</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-07-28T13:16:21.433Z
Answers.Text: Thanks! Yes, I certainly wouldn't draw any real conclusions from a basic analysis. I just want students to get a sense of algorithms in the wild, we could even discuss the differences between basic EditDistance and Needleman-Wunsch and Smith-Waterman, and potentially even bring in ethical issues, like asking how choice of algorithm (naive vs. better designed, for example) could have negative societal impacts if used incorrectly...
Answers.UserDisplayName: John
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-07-28T13:16:50.807Z
Answers.Text: And I did not know about those, so thanks for the references :)!
Answers.UserDisplayName: John
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-07-28T13:22:01.247Z
Answers.Text: I just looked at that book and its first procedure (UPGMA) for building phylogenetic trees looks to be about the same as the hierarchical clustering algorithm that I was thinking of having students implement in this project as well. So here's a quick follow up question: I would assume that the choice of tree construction algorithm can have drastic effects on the output tree. How is it that biologists validate which algorithm to use?
Answers.UserDisplayName: John
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-07-28T15:32:19.197Z
Answers.Text: @John Good question re trees. Simulated data might validate an algorithm but it's tricky. A bioinformatian might use a tool that has several models and compare them, e.g. see http://www.iqtree.org/
Answers.UserDisplayName: Chris_Rands
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-07-27T20:49:27.890Z
Answers.LastActivityDate: 2020-07-27T21:33:13.493Z
Answers.LastEditDate: 2020-07-27T21:33:13.493Z
Answers.UserDisplayName: Chris_Rands
Answers.Body: <p>The correct method is laborious and it is better to give the students a ready made tree at <a href="https://www.gisaid.org" rel="nofollow noreferrer">GISAID</a> to investigate the dispersion of COVID-19 into Europe.</p>
  <p>However, a quick approach to getting to the alignment and drawing a tree is easy and will readily complement your established teaching method. What this will give you is a very different phylogeny from <code>edit distances</code> and you would explain the matrix differences between the approaches. I suspect NCBI use Jukes Cantor distances.</p>
  <ol>
  <li>Go to blast.ncbi.nlm.nih.gov</li>
  <li>Select nucleotides</li>
  <li>Paste &quot;MN988669&quot; and hit return</li>
  <li>This will produce 100 hits</li>
  <li>On the menu page select the &quot;draw tree option&quot;</li>
  <li>This will produce a reasonable nucleotide tree for 100 COVID-19 sequences</li>
  <li>Select &quot;neighbor-joining&quot; rather than &quot;minimum evolution&quot; (this is hierarchical clustering geared to towards mutation rate heterogeneity between taxa)</li>
  <li>There are various point and click options including &quot;examine alignment&quot;</li>
  <li>You can then select &quot;minimum evolution&quot; and see the changes in the tree (and there are changes) - TEACHING OBJECTIVE 1 &amp; 2</li>
  <li>If you want to examine COVID-19 from the European perspective then select a European isolate, e.g. French isolates and input this into the blast. However, European isolates are basically Wuhan original.</li>
  </ol>
  <p>I have provided an example below, which I &quot;rerooted&quot; and represents the closest 100 to you sequence using collapsed clade format (your students can undo this, to examine the contents of a &quot;collapsed clade&quot;). The tree shows the dispersion of strains from the Wuhan seafood market.</p>
  <p>There's lots of flexibility and the students can do everything inside ½ hour easily and this would complement your approach. The advantage of my approach to teaching phylogeny and regardless of what  you do and how you do it Blast is central to rapidly obtaining alignment data for students and investigators alike. We use different blast options but blasting through is prerequisite to understand the diversity and clean some information on the population structure.</p>
  <p><a href="https://i.sstatic.net/RtUed.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/RtUed.jpg" alt="enter image description here" /></a></p>
  <hr />
  <blockquote>
  <p>Also, are there any recommended data sets where we could do something like track mutations in the virus (and see, e.g., that the NYC outbreak originated from Europe and not China)?</p>
  </blockquote>
  <p>Yes there are, today this would be Mesquite available <a href="https://www.mesquiteproject.org/" rel="nofollow noreferrer">here</a>. In my opinion this is a bit advanced. You can track amino acid mutations, which in my view is easier.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-08-01T11:41:21.840Z
Answers.LastActivityDate: 2020-08-01T12:49:00.007Z
Answers.LastEditDate: 2020-08-01T12:49:00.007Z
Answers.UserDisplayName: M__
Body: <p>I'm a computer scientist teaching algorithms development in the Fall. One of the algorithms we teach is called Edit Distance, and our folklore is that it is used to compare RNA sequences (is this actually true in practice?).</p>
  <p>I would like to have students implement the edit distance algorithm and run it on actual SARS-COV-2 sequences, so I'm trying to understand exactly what I get from the GenBank database. I downloaded this one: <a href="https://www.ncbi.nlm.nih.gov/nuccore/1798174254" rel="nofollow noreferrer">https://www.ncbi.nlm.nih.gov/nuccore/1798174254</a></p>
  <p>I am looking at the genomic.fna file. So this is apparently the FASTA file format, and the lines that begin with &gt;MN988669.1 ... are comments. I see comments like:</p>
  <pre><code>&gt;MN988669.1 Severe acute respiratory syndrome coronavirus 2 isolate 2019-nCoV WHU02, complete genome
  </code></pre>
  <p>Followed by an RNA string. Is this the start of a new sequence for a different coronavirus specimen? So I could have students extract each of these and run edit distance and then produce a dendrogram or something? How do I find more information on where the samples came from? Is this the right file to be using, or should I use the gbff file? And are the PDB files interesting to me at all (I actually do know what PDB files are)?</p>
  <p>Also, are there any recommended data sets where we could do something like track mutations in the virus (and see, e.g., that the NYC outbreak originated from Europe and not China)? Are there other useful algorithms / data that might be interesting for students to study in this vein? Specifically interesting to me would be graph-search algorithms, minimum spanning trees, and network flow. Also any NP-complete algorithms that we could run backtracking on. Obviously taking the theoretical study of algorithms to something as currently topical as the coronavirus has pedagogical value.</p>
  <p>Thanks</p>
  <p>EDIT:</p>
  <p>Based on comments below here is what is taking shape.</p>
  <ol>
  <li>Have students implement vanilla EditDistance (which there seems to be some disagreement about which algorithms are named what, so let's say insertions and deletions only, which I would call Longest Common Subsequence LCS). Then a variant that also does alignment (i.e. full Levenshtein distance computation, which I would call EditDistance, but Wikipedia calls the Needleman-Wunsch algorithm with a gap penalty of 1), then maybe Needleman-Wunsch with different gap penalties (if someone tells me what would make sense biologically).</li>
  <li>Have students implement basic heirarchical clustering / phylogenetic tree generation algorithms <em>a la</em> <a href="https://www.ncss.com/wp-content/themes/ncss/pdf/Procedures/NCSS/Hierarchical_Clustering-Dendrograms.pdf" rel="nofollow noreferrer">https://www.ncss.com/wp-content/themes/ncss/pdf/Procedures/NCSS/Hierarchical_Clustering-Dendrograms.pdf</a>.</li>
  <li>Have students run their sequence alignment variants and different clustering algorithms on SARS-COV-2 sequences and report on how the choices of parameters in 1 and 2 change the result and therefore potentially the analysis.</li>
  <li>Ask some open ended written response questions on what this might mean for society, whether this introduces ethical considerations for an algorithms designer or are they doing just the math, etc.</li>
  </ol>
  <p>My learning objectives (as they are now shaping up) are:</p>
  <ol>
  <li>Students will understand that just because their algorithm comes with a proof of correctness, it doesn't mean it's the correct algorithm for the job.</li>
  <li>Students will understand that different models / parameters to a model result in different outcomes, and thus even computational problems are not purely computational.</li>
  <li>Doing theoretical computer science / mathematics is not devoid of ethical considerations.</li>
  </ol>
  <p>I would very much appreciate thoughts on the above.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-07-27T18:00:49.760Z
Comments.Text: Hi John, if I get a bit of time over the weekend I will answer question. My apologies I can't do this right now.
Comments.UserDisplayName: M__
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-07-27T18:45:07.687Z
Comments.Text: @Michael Thanks! I look forward to it. I'm realizing how awesome it would be to have a good dataset where students could see, e.g. that the NYC cases originated from Europe, but I don't know enough to get this dataset put together myself, I don't think. Going to poke at it this week though.
Comments.UserDisplayName: John
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-07-28T09:07:55.807Z
Comments.Text: I'm assuming what you downloaded is actually a full RNA genome. It is one of many isolates. You could download the rest and do comparisons across them. You can look at also look directly at the RNA (transcription) or convert it into a different space such as amino acid sequence (translation). Here is an example of what that would look like: [reddit](http://www.reddit.com/r/dataisbeautiful/comments/f4ahdp/full_genome_of_sarscov2_new_coronavirus_oc/)
Comments.UserDisplayName: story
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-07-28T21:06:16.130Z
Comments.Text: Hi John, if you are interested in alignment in general, I would recommend not to take a viral sequence. AFAIK viruses have their own special alignment problems. I think using some eukaryotic gene sequences would do a better job for a class about algorithms.
Comments.UserDisplayName: Kamil S Jaron
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-07-29T13:51:13.800Z
Comments.Text: I think hemoglobin genes are the bio-informatics 101 go-to for such phylogeny/alignment/evolution introductions  :)
Comments.UserDisplayName: Pallie
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-07-30T22:50:53.817Z
Comments.Text: i think that in the end is only question of proteins (so what compare should be proteins) –
Comments.UserDisplayName: RosLuP
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-02-13T15:11:16.423Z
Comments.Text: @KamilSJaron SARS-CoV-2 is fine, it doesn't recombine too much and even then you can align it well.
Comments.UserDisplayName: Cornelius Roemer
Tags: <phylogenetics><phylogeny><fasta><covid-19>
Title: Understanding the fasta file format and using edit distance for alignment
ThreadText: # Understanding the fasta file format and using edit distance for alignment
  
  (Asked by: username_0 on 2020-07-27)
  
  I'm a computer scientist teaching algorithms development in the Fall. One of the algorithms we teach is called Edit Distance, and our folklore is that it is used to compare RNA sequences (is this actually true in practice?).
  
  I would like to have students implement the edit distance algorithm and run it on actual SARS-COV-2 sequences, so I'm trying to understand exactly what I get from the GenBank database. I downloaded this one: <https://www.ncbi.nlm.nih.gov/nuccore/1798174254>
  
  I am looking at the genomic.fna file. So this is apparently the FASTA file format, and the lines that begin with >MN988669.1 ... are comments. I see comments like:
  
  ```
  >MN988669.1 Severe acute respiratory syndrome coronavirus 2 isolate 2019-nCoV WHU02, complete genome
  
  ```
  
  Followed by an RNA string. Is this the start of a new sequence for a different coronavirus specimen? So I could have students extract each of these and run edit distance and then produce a dendrogram or something? How do I find more information on where the samples came from? Is this the right file to be using, or should I use the gbff file? And are the PDB files interesting to me at all (I actually do know what PDB files are)?
  
  Also, are there any recommended data sets where we could do something like track mutations in the virus (and see, e.g., that the NYC outbreak originated from Europe and not China)? Are there other useful algorithms / data that might be interesting for students to study in this vein? Specifically interesting to me would be graph-search algorithms, minimum spanning trees, and network flow. Also any NP-complete algorithms that we could run backtracking on. Obviously taking the theoretical study of algorithms to something as currently topical as the coronavirus has pedagogical value.
  
  Thanks
  
  EDIT:
  
  Based on comments below here is what is taking shape.
  
  1. Have students implement vanilla EditDistance (which there seems to be some disagreement about which algorithms are named what, so let's say insertions and deletions only, which I would call Longest Common Subsequence LCS). Then a variant that also does alignment (i.e. full Levenshtein distance computation, which I would call EditDistance, but Wikipedia calls the Needleman-Wunsch algorithm with a gap penalty of 1), then maybe Needleman-Wunsch with different gap penalties (if someone tells me what would make sense biologically).
  2. Have students implement basic heirarchical clustering / phylogenetic tree generation algorithms *a la* <https://www.ncss.com/wp-content/themes/ncss/pdf/Procedures/NCSS/Hierarchical_Clustering-Dendrograms.pdf>.
  3. Have students run their sequence alignment variants and different clustering algorithms on SARS-COV-2 sequences and report on how the choices of parameters in 1 and 2 change the result and therefore potentially the analysis.
  4. Ask some open ended written response questions on what this might mean for society, whether this introduces ethical considerations for an algorithms designer or are they doing just the math, etc.
  
  My learning objectives (as they are now shaping up) are:
  
  1. Students will understand that just because their algorithm comes with a proof of correctness, it doesn't mean it's the correct algorithm for the job.
  2. Students will understand that different models / parameters to a model result in different outcomes, and thus even computational problems are not purely computational.
  3. Doing theoretical computer science / mathematics is not devoid of ethical considerations.
  
  I would very much appreciate thoughts on the above.
  
  **Tags:** phylogenetics, phylogeny, fasta, covid-19
  
  > **Comments:**
  > **username_1**: Hi username_0, if I get a bit of time over the weekend I will answer question. My apologies I can't do this right now.  
  > **username_0**: @Michael Thanks! I look forward to it. I'm realizing how awesome it would be to have a good dataset where students could see, e.g. that the NYC cases originated from Europe, but I don't know enough to get this dataset put together myself, I don't think. Going to poke at it this week though.  
  > **username_2**: I'm assuming what you downloaded is actually a full RNA genome. It is one of many isolates. You could download the rest and do comparisons across them. You can look at also look directly at the RNA (transcription) or convert it into a different space such as amino acid sequence (translation). Here is an example of what that would look like: [reddit](http://www.reddit.com/r/dataisbeautiful/comments/f4ahdp/full_genome_of_sarscov2_new_coronavirus_oc/)  
  > **username_3**: Hi username_0, if you are interested in alignment in general, I would recommend not to take a viral sequence. AFAIK viruses have their own special alignment problems. I think using some eukaryotic gene sequences would do a better job for a class about algorithms.  
  > **username_4**: I think hemoglobin genes are the bio-informatics 101 go-to for such phylogeny/alignment/evolution introductions  :)  
  > **username_5**: i think that in the end is only question of proteins (so what compare should be proteins) –  
  > **username_6**: @username_3 SARS-CoV-2 is fine, it doesn't recombine too much and even then you can align it well.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_7 on 2020-07-27. Score: 3
  
  Your understanding of FASTA format is about right. The type of basic problem you're eluding to we term "sequence alignment"- edit distance might be okay for teaching but in practise we use other algorithms, e.g. you might be interested in the Needleman–Wunsch or Smith–Waterman algorithms. Richard Durbin et al. wrote a great book that covers these any much more [https://www.amazon.com/Biological-Sequence-Analysis-Probabilistic-Proteins/dp/0521629713](https://rads.stackoverflow.com/amzn/click/com/0521629713)
  
  Tracking mutations etc. requires more than just alignment though, see "phylogenetics" (i.e. building genetic trees) and "variant calling". Also checkout what the nextstrain team is doing <https://nextstrain.org/ncov/global>
  
  In general, looking for practical applications for your algorithms is great, but be very careful before drawing any real world conclusions about the coronavirus outbreak from such analyses
  
  > **Comments:**
  > **username_0**: Thanks! Yes, I certainly wouldn't draw any real conclusions from a basic analysis. I just want students to get a sense of algorithms in the wild, we could even discuss the differences between basic EditDistance and Needleman-Wunsch and Smith-Waterman, and potentially even bring in ethical issues, like asking how choice of algorithm (naive vs. better designed, for example) could have negative societal impacts if used incorrectly...  
  > **username_0**: And I did not know about those, so thanks for the references :)!  
  > **username_0**: I just looked at that book and its first procedure (UPGMA) for building phylogenetic trees looks to be about the same as the hierarchical clustering algorithm that I was thinking of having students implement in this project as well. So here's a quick follow up question: I would assume that the choice of tree construction algorithm can have drastic effects on the output tree. How is it that biologists validate which algorithm to use?  
  > **username_7**: @username_0 Good question re trees. Simulated data might validate an algorithm but it's tricky. A bioinformatian might use a tool that has several models and compare them, e.g. see http://www.iqtree.org/  
  
  ---
  
  ### Answer by username_1 on 2020-08-01. Score: 2
  
  The correct method is laborious and it is better to give the students a ready made tree at [GISAID](https://www.gisaid.org) to investigate the dispersion of COVID-19 into Europe.
  
  However, a quick approach to getting to the alignment and drawing a tree is easy and will readily complement your established teaching method. What this will give you is a very different phylogeny from `edit distances` and you would explain the matrix differences between the approaches. I suspect NCBI use Jukes Cantor distances.
  
  1. Go to blast.ncbi.nlm.nih.gov
  2. Select nucleotides
  3. Paste "MN988669" and hit return
  4. This will produce 100 hits
  5. On the menu page select the "draw tree option"
  6. This will produce a reasonable nucleotide tree for 100 COVID-19 sequences
  7. Select "neighbor-joining" rather than "minimum evolution" (this is hierarchical clustering geared to towards mutation rate heterogeneity between taxa)
  8. There are various point and click options including "examine alignment"
  9. You can then select "minimum evolution" and see the changes in the tree (and there are changes) - TEACHING OBJECTIVE 1 & 2
  10. If you want to examine COVID-19 from the European perspective then select a European isolate, e.g. French isolates and input this into the blast. However, European isolates are basically Wuhan original.
  
  I have provided an example below, which I "rerooted" and represents the closest 100 to you sequence using collapsed clade format (your students can undo this, to examine the contents of a "collapsed clade"). The tree shows the dispersion of strains from the Wuhan seafood market.
  
  There's lots of flexibility and the students can do everything inside ½ hour easily and this would complement your approach. The advantage of my approach to teaching phylogeny and regardless of what you do and how you do it Blast is central to rapidly obtaining alignment data for students and investigators alike. We use different blast options but blasting through is prerequisite to understand the diversity and clean some information on the population structure.
  
  [![enter image description here](https://i.sstatic.net/RtUed.jpg)](https://i.sstatic.net/RtUed.jpg)
  
  ---
  
  > Also, are there any recommended data sets where we could do something like track mutations in the virus (and see, e.g., that the NYC outbreak originated from Europe and not China)?
  
  Yes there are, today this would be Mesquite available [here](https://www.mesquiteproject.org/). In my opinion this is a bit advanced. You can track amino acid mutations, which in my view is easier.
  
  
  ---
  
  