Transpose a large dataset
2
0
Entering edit mode
9.2 years ago

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 • 12k views
ADD COMMENT
0
Entering edit mode
9.2 years ago

Never use excel for bioinformatics stuff!

Use R.

In R:

a <- read.table(file.csv,sep="\t")
b <- t(a)
ADD COMMENT
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

My laptop has 4GB RAM

ADD REPLY
0
Entering edit mode

should work

ADD REPLY
0
Entering edit mode

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 ]
ADD REPLY
0
Entering edit mode

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.

ADD REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

write.table(b,"out.txt",sep="\t",quote=F)

ADD REPLY
0
Entering edit mode
write.csv(b,"out.csv")
ADD REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

Dear NicoBxl,

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

ADD REPLY
1
Entering edit mode

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

ADD REPLY
0
Entering edit mode
9.2 years ago
5heikki 11k

Transpose is handy GNU core util style program..

ADD COMMENT

Login before adding your answer.

Traffic: 1620 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6