This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Transpose a large dataset

I have a gene expression dataset in Excel/CSV file with 200 columns and 22,000 rows. What will be the best way to switch columns and rows. (This cannot be done in Excel as it supports maximum ~ 16,000 columns)

I want my output as CSV file so that I can load it in Weka.

I don't know programming...So it would be good to know if there is any available tool for this

weka

2 answers

Never use excel for bioinformatics stuff!

Use R.

In R:

a <- read.table(file.csv,sep="\t")
b <- t(a)

Hi NicoBxl... I tried this with a small dataset , it seem to work fine...but I guess there are some issues working with such large dataset ..it gives some error

200 x 22,000 should work perfectly ;) What is the amount of RAM you have?

Tried..

Giving output like this...confused

[,22239]                      [,22240]                  [,22241]                 
    [,22242]                  [,22243]         [,22244]         [,22245]        
    [,22246]           [,22247]           [,22248]           [,22249]        
    [,22250]         [,22251]         [,22252]              [,22253]             
    [,22254]              [,22255]              [,22256]             
    [,22257]              [,22258]              [,22259]             
    [,22260]              [,22261]                [,22262]               
    [,22263]                [,22264]               [,22265]              
    [,22266]               [,22267]               [,22268]              
    [,22269]               [,22270]               [,22271]                  
    [,22272]                 [,22273]                   [,22274]                
    [,22275]                 [,22276]                 [,22277]             
    [,22278]              [,22279]         [,22280]         [,22281]        
    [,22282]          [,22283]          [,22284]         
 [ reached getOption("max.print") -- omitted 11 rows ]

Note one little quirk of read.table, it expects the header row to have one less entry than the rest of the file, so if you have a header for the first column, it's going to behave strangely. Also note that you might need to manually add a space to the header after you use write.table, or the header names might not match columns correctly.

Also how do I export the transposed data from R to my desktop as a CSV file?

write.csv(b,"out.csv")

Tried this code, but its exporting the original file but not the transposed one

Dear NicoBxl,

how to change in the structure and the data types of the data frame after the transposition?

Better rewrite a new thread for your question in order to be more specific.

Transpose is handy GNU core util style program..

Log in to answer this question.