# TE curation analysis, post RAM
This is a plan for examining the output of RepeatAfterMe, a TE consensus extension pipeline.
## Create four new folders
bad, good, long, odd, inverted_LTR
## Each putative TE will have five files associated with it.
.out - a subset of the larger RepeatMasker.out file telling you what TEs, if any, are present.
.png - a graphical representation of the alignment of 40+ hits and the consensus
extended.fa - an alignment of 40+ hits and the consensus
rep.fa - the consensus generated by RAM for this putative element
bp.fa - the same as _bp.fa but with the size of the consensus in the file name for easy viewing.
## Sort all of your files based on file size.
Peruse the files, looking for bp.fa files that are larger than 10,000 bp. These are likely segmental duplications and we don't want them. Send all of the files associated with that TE name to the 'long' folder.
## For all remaining sets of files, do the following
1. Open the .out file in a text editor. For some .out files, there will be hits from multiple elements. For example, For ...family-7, it will include ...family-71, family-715, etc. This is an artifact of my pipeline that I haven't fixed yet. Just focus on the ones that are from family-7. Most of them will not have this problem and will consist of ~10 lines or fewer. In the example below, for a file called aSto-rnd-1_family-7.out, we only care about the top 5 lines.
```27 8.2 0.0 0.0 aSto-rnd-1_family-7 1 39 (8241) + (T)n Simple_repeat 1 39 (0) 628
249 14.9 6.4 0.0 aSto-rnd-1_family-7 41 87 (8193) C L1_Felid LINE/L1 (51) 6378 6329 629
1126 29.3 1.4 0.0 aSto-rnd-1_family-7 249 606 (7674) C L1-4_PVa LINE/L1 (55) 6766 6404 630
234 27.4 1.4 0.0 aSto-rnd-1_family-7 607 679 (7601) + BTLTR1J LTR/ERVK 228 301 (297) 631 *
1846 31.9 1.4 4.1 aSto-rnd-1_family-7 643 1817 (6463) C Sat-1_TSy Satellite (310) 2926 1782 632
21662 16.1 1.4 0.8 aSto-rnd-1_family-7 1818 5689 (2591) C L1-4_PVa LINE/L1 (1626) 5195 1301 633
25 33.2 0.0 0.0 aSto-rnd-1_family-7 6173 6252 (2028) + (AT)n Simple_repeat 1 80 (0) 634
560 26.3 13.0 1.3 aSto-rnd-1_family-71 7 283 (19859) + L1ME3G LINE/L1 5351 5659 (518) 635 *
2003 17.8 11.8 4.1 aSto-rnd-1_family-71 275 843 (19299) + L1MDa LINE/L1 1578 2188 (4445) 636
588 34.3 9.8 1.7 aSto-rnd-1_family-71 854 1525 (18617) + L2a LINE/L2 2612 3323 (52) 637
194 28.9 0.0 0.0 aSto-rnd-1_family-71 1528 1579 (18563) C MIR SINE/MIR (0) 262 211 638
348 22.1 0.0 0.0 aSto-rnd-1_family-71 1609 1676 (18466) + PlatSat2A Satellite 262 329 (704) 639
410 21.6 2.0 1.0 aSto-rnd-1_family-71 1979 2076 (18066) + L1_Carn7 LINE/L1 6410 6508 (0) 640
560 26.3 13.0 1.3 aSto-rnd-1_family-71 2860 3136 (17006) + L1ME3G LINE/L1 5351 5659 (518) 641 *
2003 17.8 11.8 4.1 aSto-rnd-1_family-71 3128 3696 (16446) + L1MDa LINE/L1 1578 2188 (4445) 642
588 34.3 9.8 1.7 aSto-rnd-1_family-71 3707 4378 (15764) + L2a LINE/L2
...and so on
```
Examine the hits to that element, if any exist. Some files will be empty, indicating that RepeatMasker found not hits. Generally, if the majority of them come from a single TE type, that's a good sign that this is a well-curated TE. At the very least, it will give you an idea of what you should look for. In the example above, three of the top five lines indicate LINE elements. This putative TE could be a LINE. If the categorizations are all over the place, multiple TE types, it could be segmental duplication that we missed in the size filtering.
2. Open the .png file. Zoom in on the two ends. Well-curated TEs will have clear random sequence in both flanks. Note the figure below. 
At both flanks, you have no pattern to the nucleotides. They're random. That means we have found the both ends of the TE in question. Good. Sometimes you will find examples where there are subsets of sequences that have patterns. This is often due to repetitive regions within the TE itself. You can check this by examining if the overall alignment is missing large swaths. See the example below.

These are an artifact of the RAM curation process and can usually be ignored. As long as the regions that show end-to-end alignment are showing random flanks, we're good.
Another possible scenario, the inverted LTR. Because of the way LTRs are structured, they can sometimes be reconstructed incorrectly, with the flanking Long Terminal Repeats in the middle rather than at the ends. See the following png.

Note the region toward the central right side. If you see this pattern and the .out file suggests an LTR retrotranposon, toss it into the inverted_LTR folder for later deconvolution.
3. If the two above steps are inconclusive, open the extended.fa file. Depending on the type of element, you can identify particular hallmarks.
Typically...
* LINEs have 5-10 bp that are GC rich at one end and have a poly-A tail at the other end. Full length LINEs in bats are 6-9 kb. But, there are things called HALs (half LINEs) in bats. They're very similar to LINEs but short, a couple thousand bp. Also, because of the way LINEs insert, they will often have more copies of the poly-A end (3') than the front end (5').
* LTR retrotransposons start with TG (or TGT) and end with CA (or ACA). Full length LTR retrotransposons in these bats are often around 4-8 kb. But many of the LTRs you'll see are just the terminal repeat segments. They can be anywhere from 150 bp to 1.5 kb.
* Helitrons almost always have a CTAG at one end or the other and are typically associated with microsatellites. Range from a few hundred bp to 2kb+. Unlikely to be encountered outside of vesper bats. Let me know if you do start seeing them in your species.
* SINEs are short, 150-500 bp.
* DNA transposons are often short (150-500 bp) but autonomous versions can range up to 3 kb.
* It's entirely possible that you may not know what kind of TE it is. If it passes the flank test, try to mark it as 'good'. If you really aren't sure --> odd.
4. Make a call. Does this belong in the bad, good, or odd folder?
If it doesn't pass the flanks test, --> bad
If it passes the flanks test and looks like a valid element based on the other two tests --> good.
If you're unsure --> odd.
Move all of the files associated with that putative TE to the appropriate folder. All files associated with a putative TE should end up in one of these folders.
Assignments -
Francisco - Rhinolophids --> rAff (Rhinolophis affinis), rCfl (R. luctus), rSed (R. sedulus), rTri (R. trifoliatus)
Riley - Selected yangochiropterans --> gSor (Glossophaga sorcina), nLep (Noctilio leporinus), nTum (Natalus_tumidirostris), pHas (Phyllostomus hastatus)
David - everything else
# TE naming
## Run each group of TEs through DeepTE
Details to be added.
###### tags: `TEs`, `David`