TITLE: Formatting Data for Use With ebFRET Hidden Markov Modeling Software
AUTHORS: Clark Fritsch

[DESCRIPTION]
This protocol follows from the "Selecting a Region of Interest for Hidden Markov Modeling using ebFRET" protocol and is the second step towards analyzing your data using Hidden Markov Modeling. This protocol describes the steps you need to take to convert traces containing your region of interest (selected in the previous protocol) and formatting them for use with ebFRET, a software package that is capable of performing Hidden Markov Modeling on single-molecule FRET datasets.

[STEPS]
1. This protocol is a continuation of the "Selecting a Region of Interest for Hidden Markov Modeling using ebFRET" practice protocol.
2. To begin this protocol, you should have your "SavedData.csv" file and traces in one directory, as shown below:

  

It is likely that when you are doing your real analysis that you don't include every trace that is included in your "GoodOnes.txt" file in your "SavedData.csv" file. For example, you might think that a trace is good at first and include it in your "GoodOnes.txt" file, but find upon closer inspection that the trace is not worthy of further analysis and therefore exclude it from your "SavedData.csv" file.

Because of this, you want to separate the traces that are included in your "SavedData.csv" file from the remainder of your traces.

3. To separate the traces included in your "SavedData.csv" file from the remainder of your traces, you can use the "SavedData_Copy_and_Transfer_v3.R" program that is attached below:

  

4. To use this program in R, simply copy the path to the directory that contains all of your traces and the "SavedData.csv" file and paste the path into the "path_var_old" variable in between the parentheses, as highlighted below:

  
Then press "Ctrl A" to highlight all of the code and press "Ctrl Enter" to run the code. 
5. After running the code, you will see that the following information has been outputted to the console (boxed in yellow):

 
This output simply shows that each trace (TRUE) has been transferred successfully to the output directory. If a trace is not transferred successfully, it was output FALSE. Additionally, your "SavedData.csv" file is transferred to the output directory.

6. After running the program successfully, you will see that the "SavedData" output directory has been created at the path directory that you inputted into the program:

  

This "SavedData" directory will contain only your "SavedData.csv" file and the traces that were contained within your "SavedData.csv" file, as shown below:

  

7. Next, you want to cut out the parts of each of your traces that are not included within the range set by Click 1 and Click 2 that is included in your "SavedData.csv" file.

  

You can do this using the "Click1_Click2_Cut.R" program that is included below:

   

8. The "Click1_Click2_Cut.R" program, as described above, simply takes the values for Click1 (leftmost boundary of your ROI) and Click2 (rightmost boundary of your ROI) and removes the frames from each trace that are not included between Click1 and Click2.

To use this program in R, simply copy the path to "SavedData" directory and paste the path into the "path_var" variable in between the parentheses, as highlighted below:

 
Then press "Ctrl A" to highlight all of the code and press "Ctrl Enter" to run the code.  

9. Once you have run the "Click1_Click2_Cut.R" program, a new directory called "T1_to_T2_Synchronized" that will contain your new traces, each of which has been cut to contain only the frames between your Click1 and Click2 values:

  
Each of these new "trimmed" traces can be distinguished from the original traces because the trimmed traces contain "-T1_to_T2_Synchronized" appended to the end of each filename:

  

10. Now that you have your trimmed traces prepared, you need to format the traces so that they can be run using the ebFRET Hidden Markov Modeling program.

To do this, you can use "RegionOfInterest_to_ebFRET.R" program that is attached below:

  

11. To use ebFRET, your traces of interest need to be stitched together with each trace being associated with a unique ID number. Additionally, the donor and acceptor fluorophore intensity for each timepoint in each trace needs to be included in the file.

To use the "RegionOfInterest_to_ebFRET.R" program to format your traces in this way, simply copy the path that contains your trimmed traces into the "path" variable in the program, as highlighted below:

  
Additionally, you need to name the formatted file that your trace information will be outputted to by entering the new filename into the "new_file_name" variable, as shown below:

   
Note that the new file name must have the ".dat" extension, as this is the only text file format that ebFRET will recognize.

Press "Ctrl A" to highlight all of the code and press "Ctrl Enter" to run the code.  

12. Once you have run the program, your ebFRET formatted file will appear in your "T1_to_T2_Synchronized" directory. It is now ready to input into ebFRET for Hidden Markov Analysis.