Creating a loop to use read.eset in bioconductor
1
0
Entering edit mode
10.2 years ago
viniciushs88 ▴ 50

I would like to create a loop to load this files through read.esetof bioconductor. I have one file per chromosome (29) files. I tried that:

{for(k in 1:29){
  expr <- paste0("/home/proj/MT_Nellore/R/eBrowser/Adjusted/LRRadjustedextremes0.5kgchr",k,".txt")
  pdat <- paste0("/home/proj/MT_Nellore/R/eBrowser/Adjusted/Samplesbinary0.5.txt")
  ffdat <- paste0("/home/proj/MT_Nellore/R/LRR/Chr_adjusted/probeslabeladjustedchr",k,".txt")
  eset <- read.eset(exprs.file="expr", pdat.file="/home/proj/MT_Nellore/R/eBrowser/Adjusted/Samplesbinary0.5.txt", fdat.file="ffdat")}

However I get this error:

Error in file(file, "r") : cannot open the connection
In addition: Warning message:
In file(file, "r") : cannot open file 'ffdat': No such file or directory

Any sugestions? Cheers!

bioconductor R • 2.3k views
ADD COMMENT
0
Entering edit mode

No opening brace before the for, surely?

ADD REPLY
2
Entering edit mode
10.2 years ago

The last line should be:

eset <- read.eset(exprs.file=expr, pdat.file=pdat, fdat.file=ffdat)
ADD COMMENT
0
Entering edit mode

You are right! Now it works, but.... I put 4 more lines:

data <- fData(eset)
outfile <- paste0("chr",k,"FCadjusted.txt")
setwd("/home/proj/MT_Nellore/R/eBrowser/Adjusted/FC")
write.table(data, outfile, quote = FALSE, col.names = FALSE)}}

And now the problem is that just files 1 to 8 were writed...

Why files 9 until 29 cannot be written?

ADD REPLY
0
Entering edit mode

It's hard to say without seeing the entirety of the relevant code. You might add a print() line to try and figure out where things are breaking.

ADD REPLY
0
Entering edit mode

If I add print() line this error appears:
##Error in print.default() : argument "x" is missing, with no default

ADD REPLY
0
Entering edit mode

I wasn't being literal before. The general idea behind debugging is to determine exactly where in the code an error occurs. One of the simplest ways to do that is to add an occasional print("got here") or print("A") or something that you can use to identify the last time the code did what you expected.

ADD REPLY

Login before adding your answer.

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