Is there an equivalent function for write.fit() that produces values/output in R console?
1
0
Entering edit mode
@payam_delfani1980-17107
Last seen 6.3 years ago

write.fit() in limma is an excellent function that writes a MArrayLM Object to a File. Using this function, no value is produced in R console but a file is written to the current working directory. I'm wondering if there is an equivalent function for write.fit() that produces values/output in the same format in R console instead?

limma write.fit • 1.4k views
ADD COMMENT
0
Entering edit mode
@gordon-smyth
Last seen 2 hours ago
WEHI, Melbourne, Australia

The write.fit() function is designed to write all the results from a limma DE analysis to a flat delimited text file. The file includes results for all the coefficients or contrasts in the fit object. The function is provided for when you wish to record the results in a readable file -- it's not something that I do myself very often but you might want to.

For analysis during an R session, however, it is much better and more flexible to work with the output from topTable() and decideTests(). Between them, topTable() and decideTests() produce all the output that is recorded by write.fit(). I don't see any purpose in sending the write.fit() data.frame to the screen -- that doesn't seem useful to me. For one thing, the data.frame would be much too wide for the screen. The operation of appending all the columns in one big table only seems useful in a file context.

If you want to see the contents of a fit object at the screen, just use

show(fit)

or, if you really like data.frames, you could use

head(as.data.frame(fit))

 

ADD COMMENT
0
Entering edit mode

Thank you for your quick reply, Sir!

I've tested the two functions that you outlined above. Unfortunately, show() and as.data.frame() do not fully produce the same output as write.fit () does. The output differs because write.fit() can further process the testResults when the user provides arguments like adjust = "BH", method = "separate" into the function. 

As a result, I made a small change in to the write.fit() by commenting the last line of the function and instead added return(tab):

     return(tab) ##Added by Payam Delfani

  # write.table(tab,file=file,quote=quote,row.names=row.names,sep=sep,...) #Comment by Payam Delfani

This is a workaround that I had in mind and obviously not a nice solution. My suggestion is to add something similar to the function so that it generates the output to a file and/or to the R console if so specified by the user.

ADD REPLY
0
Entering edit mode

I also wanted to report that I found that write.fit() generates, among other outputs, a variable named "Coef" which is actually the Fold Change (FC). I also suggest to revise the name of variable to avoid any miss-interpretation of that variable. 

ADD REPLY
1
Entering edit mode

The coefficients are not always log-fold-changes. The function is correct as it is.

ADD REPLY

Login before adding your answer.

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