i need a tab-delimited format
1
0
Entering edit mode
9.7 years ago
zizigolu ★ 4.3k

Hello,

I need a tab-delimited text format in which the first column is probesets, the header are array name and in between there are amounts, for example with 12 array, there are 13 columns that the first is prob sets but when I did like below, a messy file was produced that can't be used as tab-delimited and nothing is arranged alike I described

(affy)

> data <- ReadAffy()
> exp <- rma(data)

Background correcting
Normalizing
Calculating Expression
> control <- grep("AFFX",rownames(exp))
> exp <- exp[-control,]
> e <- exprs(exp)
> e <- apply(e,1,function(x) x-median(x))
> e.scaled <- t(scale(t(e),center=FALSE))
write.table(e.scaled,file="scaled.output.txt",sep="\t")

What happened please?

R • 3.5k views
ADD COMMENT
1
Entering edit mode

show here output of

head(e.scaled)
ADD REPLY
1
Entering edit mode

thank Deepak, a long R console that I copied a bit of

here instead of probes, arrays are in column one and no thing is like a tab-delimited format

GSM1217809_5f_02.16.07_A-1.CEL 0.05255516
GSM1217812_5f_02.16.07_F-1.CEL 0.17186324
GSM1217813_5f_02.16.07_F-2.CEL -0.13903232
RPTR-Cit-AF292559-4_s_at
GSM1217809_5f_02.16.07_A-1.CEL 0.08206178
GSM1217812_5f_02.16.07_F-1.CEL -0.40758425
GSM1217813_5f_02.16.07_F-2.CEL -0.04806016
RPTR-Cit-AF292560-1_s_at
GSM1217809_5f_02.16.07_A-1.CEL 0.002096532
GSM1217812_5f_02.16.07_F-1.CEL 0.421045649
GSM1217813_5f_02.16.07_F-2.CEL -0.017831992
RPTR-Cit-AF298789-1_at RPTR-Cit-AF323980-1_at
GSM1217809_5f_02.16.07_A-1.CEL -0.11951421 -0.27722569
GSM1217812_5f_02.16.07_F-1.CEL 0.04177827 -0.02018600
GSM1217813_5f_02.16.07_F-2.CEL -0.12014960 -0.22956421
RPTR-Cit-AF403737-1_at
GSM1217809_5f_02.16.07_A-1.CEL -0.08054451
GSM1217812_5f_02.16.07_F-1.CEL 0.15600860
GSM1217813_5f_02.16.07_F-2.CEL 0.19533998
RPTR-Cit-AJ002682-1_s_at
GSM1217809_5f_02.16.07_A-1.CEL 0.04503080
GSM1217812_5f_02.16.07_F-1.CEL -0.03033849
GSM1217813_5f_02.16.07_F-2.CEL -0.26139996
RPTR-Cit-AJ002682-2_s_at
GSM1217809_5f_02.16.07_A-1.CEL 0.2852115
GSM1217812_5f_02.16.07_F-1.CEL -0.1631590
GSM1217813_5f_02.16.07_F-2.CEL -0.0363517
RPTR-Cit-AJ132968-1_at RPTR-Cit-AY056050-1_at
GSM1217809_5f_02.16.07_A-1.CEL 0.133536388 -0.06412887
GSM1217812_5f_02.16.07_F-1.CEL 0.228111508 -0.14473409
GSM1217813_5f_02.16.07_F-2.CEL -0.194797919 -0.05747612
RPTR-Cit-AY125353_at RPTR-Cit-AY342347_at
GSM1217809_5f_02.16.07_A-1.CEL -0.1433425 -0.009057655
GSM1217812_5f_02.16.07_F-1.CEL -0.2668206 -0.014395990
GSM1217813_5f_02.16.07_F-2.CEL -0.3738729 0.056684675
RPTR-Cit-CVE247372-1_at RPTR-Cit-E00696-1_s_at
GSM1217809_5f_02.16.07_A-1.CEL 0.19075942 -0.003338260
GSM1217812_5f_02.16.07_F-1.CEL 0.24111934 0.061843554
GSM1217813_5f_02.16.07_F-2.CEL -0.08339595 -0.183964509
RPTR-Cit-ECOLOXB_at RPTR-Cit-J01347-1_s_at
GSM1217809_5f_02.16.07_A-1.CEL -0.10867961 -0.32320798
GSM1217812_5f_02.16.07_F-1.CEL 0.03054978 -0.09048522
GSM1217813_5f_02.16.07_F-2.CEL -0.21120692 -0.08085584
RPTR-Cit-J01347-2_at RPTR-Cit-J01347-3_at
GSM1217809_5f_02.16.07_A-1.CEL 0.20702548 -0.12302605
GSM1217812_5f_02.16.07_F-1.CEL -0.17961348 -0.37399036
GSM1217813_5f_02.16.07_F-2.CEL -0.14967317 0.00000000
RPTR-Cit-J01347-4_at RPTR-Cit-J01636-1_at
GSM1217809_5f_02.16.07_A-1.CEL 0.138833763 0.43868019
GSM1217812_5f_02.16.07_F-1.CEL 0.017175052 0.01354605
GSM1217813_5f_02.16.07_F-2.CEL 0.006266388 0.00000000
RPTR-Cit-J01636-3_at RPTR-Cit-J01636-4_at
GSM1217809_5f_02.16.07_A-1.CEL -0.133386582 -0.021722463
GSM1217812_5f_02.16.07_F-1.CEL 0.187753428 0.013258986
GSM1217813_5f_02.16.07_F-2.CEL -0.059438716 -0.067987479
RPTR-Cit-J03196-1_at RPTR-Cit-K01193-1_at
GSM1217809_5f_02.16.07_A-1.CEL 0.2400607 0.368636060
GSM1217812_5f_02.16.07_F-1.CEL 0.4388552 -0.069348142
GSM1217813_5f_02.16.07_F-2.CEL 0.1510561 0.037986489
RPTR-Cit-K01486-1_at RPTR-Cit-L36849-1_at
GSM1217809_5f_02.16.07_A-1.CEL 0.20840572 -0.34201316
GSM1217812_5f_02.16.07_F-1.CEL -0.07484432 0.31707235
GSM1217813_5f_02.16.07_F-2.CEL -0.15576517 0.06074941
RPTR-Cit-M10961-1_at RPTR-Cit-M10961-2_at
GSM1217809_5f_02.16.07_A-1.CEL -0.331028042 -0.12051846
GSM1217812_5f_02.16.07_F-1.CEL 0.001427136 0.00000000
GSM1217813_5f_02.16.07_F-2.CEL -0.322128415 0.08502204
RPTR-Cit-M10961-4_at RPTR-Cit-M15077-1_at
GSM1217809_5f_02.16.07_A-1.CEL -0.15341608 0.10184927
GSM1217812_5f_02.16.07_F-1.CEL -0.11565954 0.04693199
GSM1217813_5f_02.16.07_F-2.CEL -0.30116450 0.08021912
RPTR-Cit-M15077-1_s_at RPTR-Cit-M57289-1_s_at
GSM1217809_5f_02.16.07_A-1.CEL -0.08362693 0.14656191
GSM1217812_5f_02.16.07_F-1.CEL 0.08649142 -0.13507958
GSM1217813_5f_02.16.07_F-2.CEL 0.19089076 -0.09544879
RPTR-Cit-M62653-1_at RPTR-Cit-M62653-1_s_at
GSM1217809_5f_02.16.07_A-1.CEL -0.002132799 0.2219125
GSM1217812_5f_02.16.07_F-1.CEL -0.025525508 0.3162198
GSM1217813_5f_02.16.07_F-2.CEL -0.094741321 0.0000000
RPTR-Cit-NC_001669-1_at
GSM1217809_5f_02.16.07_A-1.CEL 0.35045538
GSM1217812_5f_02.16.07_F-1.CEL 0.10969333
GSM1217813_5f_02.16.07_F-2.CEL 0.13404253
RPTR-Cit-NC_001669-2_at
GSM1217809_5f_02.16.07_A-1.CEL 0.18123041
GSM1217812_5f_02.16.07_F-1.CEL -0.11793327
GSM1217813_5f_02.16.07_F-2.CEL -0.09229176
RPTR-Cit-NC_002086-1_at
GSM1217809_5f_02.16.07_A-1.CEL -0.06227755
GSM1217812_5f_02.16.07_F-1.CEL 0.01267942
GSM1217813_5f_02.16.07_F-2.CEL -0.47036044
RPTR-Cit-NM_131175-1_at RPTR-Cit-U43284-1_s_at
GSM1217809_5f_02.16.07_A-1.CEL 0.08635105 0.05726154
GSM1217812_5f_02.16.07_F-1.CEL -0.30847249 0.02293332
GSM1217813_5f_02.16.07_F-2.CEL -0.19770223 0.24267262
RPTR-Cit-U46493-1_s_at RPTR-Cit-U47295-1_at
GSM1217809_5f_02.16.07_A-1.CEL -0.14790170 -0.197104516
GSM1217812_5f_02.16.07_F-1.CEL 0.30764386 0.008246921
GSM1217813_5f_02.16.07_F-2.CEL -0.46238186 -0.056930944
RPTR-Cit-U55943-1_at RPTR-Cit-U57609-2_s_at
GSM1217809_5f_02.16.07_A-1.CEL -0.26479223 -0.70695225
GSM1217812_5f_02.16.07_F-1.CEL 0.13404993 -0.16724348
GSM1217813_5f_02.16.07_F-2.CEL -0.35250197 0.21860308
RPTR-Cit-U89963-1_at RPTR-Cit-U89963-1_s_at
GSM1217809_5f_02.16.07_A-1.CEL -0.1470777 -0.1960966
GSM1217812_5f_02.16.07_F-1.CEL 0.1693412 -0.1346432
GSM1217813_5f_02.16.07_F-2.CEL -0.2220062 -0.1183979
RPTR-Cit-U89963-1_x_at RPTR-Cit-V01555-1_at
GSM1217809_5f_02.16.07_A-1.CEL 0.16725847 0.08916747
GSM1217812_5f_02.16.07_F-1.CEL 0.07043568 0.20464053
GSM1217813_5f_02.16.07_F-2.CEL 0.06225230 -0.21173276
RPTR-Cit-X03453-1_at RPTR-Cit-X17220-1_at
GSM1217809_5f_02.16.07_A-1.CEL -0.27066087 0.4134924
GSM1217812_5f_02.16.07_F-1.CEL -0.22150327 0.0688757
GSM1217813_5f_02.16.07_F-2.CEL 0.01716142 0.0000000
RPTR-Cit-X58791-1_s_at RPTR-Cit-X58791-2_s_at
GSM1217809_5f_02.16.07_A-1.CEL 0.009855244 -0.02893986
GSM1217812_5f_02.16.07_F-1.CEL -0.098641094 -0.12332447
GSM1217813_5f_02.16.07_F-2.CEL -0.088178443 -0.28973725
RPTR-Cit-XXU09476-1_at
GSM1217809_5f_02.16.07_A-1.CEL 0.77284180
GSM1217812_5f_02.16.07_F-1.CEL 0.05441805
GSM1217813_5f_02.16.07_F-2.CEL -0.08185249
[ reached getOption("max.print") -- omitted 3 rows ]

ADD REPLY
1
Entering edit mode

Perform these 3 commands and show the output:

head(e.scaled)
dim(e.scaled)
str(e.scaled)
ADD REPLY
1
Entering edit mode

thank you,

[1]    12 30302
> str(e.scaled)
 num [1:12, 1:30302] -0.0315 -0.0786 -0.0576 0.1015 0.0796 ...
 - attr(*, "dimnames")=List of 2
  ..$ : chr [1:12] "GSM839728_GF_28mm_EC-1.CEL" "GSM839729_GF_28mm_EC-2.CEL" "GSM839730_GF_28mm_EC-3.CEL" "GSM839731_GF_28mm_PC-1.CEL" ...
  ..$ : chr [1:30302] "AF506028_F_at" "AF506028_R_at" "Cit.100.1.S1_x_at" "Cit.1000.1.S1_s_at" ...
 - attr(*, "scaled:scale")= Named num [1:12] 0.576 0.596 0.579 0.644 0.642 ...
  ..- attr(*, "names")= chr [1:12] "GSM839728_GF_28mm_EC-1.CEL" "GSM839729_GF_28mm_EC-2.CEL" "GSM839730_GF_28mm_EC-3.CEL" "GSM839731_GF_28mm_PC-1.CEL" ...
>

and the output of head(e.scaled) was which I copied and pasted in previous comment

ADD REPLY
3
Entering edit mode
9.7 years ago
Deepak Tanwar ★ 4.2k

Perform these commands:

write.table(e.scaled, file = "scaled_output.txt", sep = "\t", quote = F)

Now, try to read the table you have created in R

scaled_table <- read.table("scaled_output.txt", sep = "\t", header = T, stringAsFactors = F, check.names = F, comment.char = "")

View the table by:

View(scaled_table)

If you are able to see a proper table, that is a tab-deli. file. If you open and see a text file, it would be weird for you because of the no. of columns. I will not suggest to open a file in excel. If you use linux, you could open in terminal by:

cat scaled_output.txt | cut -f 1,2

This will display only first and second column.

ADD COMMENT
1
Entering edit mode

thank you Deepak for paying attention

I did so:

data <- ReadAffy()
> 
> exp <- rma(data)

Background correcting
Normalizing
Calculating Expression
>  control <- grep("AFFX",rownames(exp))
>  exp <- exp[-control,]
>  e <- exprs(exp)
>  e <- apply(e,1,function(x) x-median(x))
>  e.scaled <- t(scale(t(e),center=FALSE))
>  write.table(e.scaled, file = "scaled_output.txt", sep = "\t", quote = F)
> scaled_table <- read.table("scaled_output.txt", sep = "\t", header = T, stringAsFactors = F, check.names = F, comment.char = "")
Error in read.table("scaled_output.txt", sep = "\t", header = T, stringAsFactors = F,  :
  unused argument (stringAsFactors = F)
> View(scaled_table)
Error in as.data.frame(x) : object 'scaled_table' not found
>
ADD REPLY
2
Entering edit mode

my bad, its

stringsAsFactors = F
ADD REPLY
1
Entering edit mode

when I corrected the last code like this

scaled_table <- read.table("scaled_output.txt", sep = "\t", header = T, stringsAsFactors = F, check.names = F, comment.char = "")

R started to process for long time and still continuing....thank you Deepak

ADD REPLY
2
Entering edit mode

It might take some time, depending on the size of data. In actual, this was just your confusion regarding the the tab-del. data file. Whenever the data is very big, like this, you should save it as a R object.

saveRDS(scaled_output.txt, file="myDataFile.rds")

Load the data frame

x <- readRDS(file="myDataFile.rds")

This would be very quick

ADD REPLY
0
Entering edit mode
> data <- ReadAffy()
>  exp <- rma(data)

Background correcting
Normalizing
Calculating Expression
> control <- grep("AFFX",rownames(exp))
>  exp <- exp[-control,]
>  e <- exprs(exp)
>  e <- apply(e,1,function(x) x-median(x))
>  e.scaled <- t(scale(t(e),center=FALSE))
>  write.table(e.scaled, file = "scaled_output.txt", sep = "\t", quote = F)
>  > scaled_table <- read.table("scaled_output.txt", sep = "\t", header = T, stringsAsFactors = F, check.names = F, comment.char= "")
Error: unexpected '>' in " >"
> write.table(e.scaled, file = "scaled_output.txt", sep = "\t", quote = F)
> write.table(e.scaled, file = "scaled_output.txt", sep = "\t", quote = F)
> write.table(e.scaled, file = "scaled_output.txt", sep = "\t", quote = F)
> >  > scaled_table <- read.table("scaled_output.txt", sep = "\t", header = T, stringsAsFactors = F, check.names = F, comment.char
Error: unexpected '>' in ">"
> scaled_table <- read.table("scaled_output.txt", sep = "\t", header = T, stringsAsFactors = F, check.names = F, comment.char= "")
>  saveRDS(scaled_output.txt, file="myDataFile.rds")
Error in saveRDS(scaled_output.txt, file = "myDataFile.rds") :
  object 'scaled_output.txt' not found
> 
> x <- readRDS(file="myDataFile.rds")
Error in readRDS(file = "myDataFile.rds") : error reading from connection

sorry Deepak for disturbance

ADD REPLY
0
Entering edit mode

What are you trying to do here?

You loaded data into scaled_table (scaled_table <- read.table()) and try to save object scaled_output.txt.

You should read error messages, everything is written there (object 'scaled_output.txt' not found).

ADD REPLY
0
Entering edit mode

in this post I was trying to have a tab-delimited format that can be read by my workbench...I followed codes but by these codes problem is the same

ADD REPLY
1
Entering edit mode

Sarah, you have to save the object scaled table

saveRDS(scaled_table, file="myDataFile.rds")
ADD REPLY
0
Entering edit mode

thank you Deepak

ADD REPLY

Login before adding your answer.

Traffic: 1411 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