Transposing a data matrix using Perl

Transposing a data matrix using Perl

Postby Kaumudi » Thu Mar 01, 2018 1:22 pm

Sometimes you have a text file that won't fit into Excel one way, but when you transpose the data, it will fit (because Excel allows for many more rows than it does columns). I recently faced this issue with a text file I downloaded from TCGA. the text file itself had a problem when used straight up as downloaded from TCGA, even when care was taken to make sure it was MS-DOS coded text. As a result, the file was causing R Studio to hang such that I could not use the t() function in R. I also tried python, but it would not accept the file due to the file error.

After much struggle I approached Dr. Yoo who was kind enough to show a way around all of this using perl commands. Thanks Dr. Yoo!

Step1. Convert the text file to a .csv file using perl commands.
Step 2. SwapRowsand Columns and save as new .csv file

I am attaching a screenshot here for future use if anyone is in a similar situation.....
Attachments
SwapRowColumnSolution.JPG
SwapRowColumnSolution.JPG (98.1 KiB) Viewed 2292 times
Kaumudi
 
Posts: 76
Joined: Tue Feb 14, 2017 12:38 pm

Return to How to run scripts/programs

Who is online

Users browsing this forum: No registered users and 2 guests

cron