Want to look at the data from RMDB in R so you can make cool graphs and analyses? You’ve come to the right place! :)
I apologize in advance for any ugly scripting. I’ll try to make it look presentable before posting, but my style of coding is often trial and error until it works. I think it would be cool to get my scripts onto github to share them, but right now I don't understand github, so I'll start by just posting them here.
If you are using data that was already formatted (so, if you took the data from Meechl’s google drive), then you can load it into R quickly and move on to the fun scripts. You can use the built-in read.table function. For information on how to use it, type ?read.table into R. You'll probably want the data saved in csv format before loading. Example:
Stats = read.table("C:/Users/Meechl/Documents/Eterna/csv/R94.csv", sep=",", header=TRUE, na.strings=".") # read in data
However, if you are taking rdat data directly from RMDB, it’s a little more complicated. First, you’ll need to load the rdat file into a spreadsheet, unstack it, and remove several characters. Then, you’ll need to run a special function that will format the data so R will understand it. How exactly do you do this?
Loading the rdat data into a spreadsheet, unstacking, and removing characters:
- Download the data in rdat format
- Load the rdat data into excel (I use the text import wizard, this is probably doable in google spreadsheets, but I haven’t tried)
- Open a new spreadsheets
- Go to “data”, “from text”, then select the .rdat file and click “import”
- Make sure “delimited” is checked, then hit next
- Make sure “tab” is checked, then hit finish
- Unstack the data (we want to get all of the data for each sequence to be on the same line)
- Open a new sheet in the current excel file
- Copy and paste the first line from another file (should read: Annotation, ... X1, X2, ... E1, E2, ...)
- Copy and paste the annotation data for all sequences (all rows) from your initial sheet to the new sheet
- Copy and paste the reaction data for all sequence (all rows but the first) from your initial sheet to the new sheet
- Make sure to paste the data in the box right under “X1”.
- Scroll over to the end of the reaction data in the new sheet, and make sure that the number of reactivities you pasted was the same as the number of X’s in the header. If they aren’t the same, adjust the number of X’s in the header.
- Copy and paste the error data for all sequence (all rows but the first) from your initial sheet to the new sheet
- Make sure to paste the data in the box right under “E1”.
- If the number of X’s in your header was different from the number of reactivities, you will also have to adjust the number of E’s in the header to match the data.
- Remove all # “ ‘ , and replace with a space (in my experience, R gets confused by those characters)
- Hit ctrl-F, then switch to the replace tab
- In the “Find what:” box, type #
- In the “Replace with:” box, type one space
- Click “Replace all”
- Repeat for the other four characters
- Save the file as a .csv (comma delimited) file (remember where you saved it to!)
- Open R!
- Solutions to possible problems
- If you are using a mac and something doesn’t work the same, sorry? I’m a PC person. :)
- If you can’t find the rdat file that you downloaded, going to your downloads folder and sorting by most recent usually works. Or, you can right click on the download in the browser, say show in folder, and that’ll show you where it is. Then you can save it to someplace more convenient. Or
- If you didn’t find any # “ ‘ , in the file, it probably does have some, but missed them. Make sure that you didn’t select a group of boxes before hitting ctrl-F, because if you did, it will only search that selection of boxes.
- If you get warnings when saving as a .csv, don’t worry, just click ok.
Reading data into R:
Generating free energy values and structures for MS2 data:
Use the script here: http://nando.eternadev.org/web/script/3386853/
Or for vienna2: http://nando.eternadev.org/web/script/3388627/
- Download the data into excel
- Move the sequence column to be just to the right of the id#
- Filter by puzzle name
- Copy the first two columns (id# and sequence) into a new sheet, and save that sheet in csv format.
- Open that file in notepad, copy the whole thing
- Input it into the script.
- Add the cst to the script, then run.
- Copy and paste the output into notepad, and save as .txt.
- Use the text import wizard to import that file into excel, then copy and paste the free energies and structures into the original excel file.
- Repeat for all sublabs.
- Remove all # " ' , then save as .csv, and then you can load the data into R.
I'm slowly adding my other scripts for more analysis-type stuff here: