Question: Can the code of a R package be changed? How?
0
gravatar for Antonio R. Franco
4.8 years ago by
Spain. Universidad de Córdoba
Antonio R. Franco4.4k wrote:

I am using limma, and in representing a volcano plot, it turn out that the gene systematic gene I want to highlight is truncated..

If I revise the code (shown below) I can see that the highlighted gene comes from a substring with a maximum of 8 digits.

This observation lead me to ask if it is possible to make minor changes in the code present in the R package, and how this can be accomplished.

In my case, I can change all the systematic gene names, or change that 8 by a different value 

> volcanoplot
function (fit, coef = 1, highlight = 0, names = fit$genes$ID, 
    xlab = "Log Fold Change", ylab = "Log Odds", pch = 16, cex = 0.35, 
    ...) 
{
    if (!is(fit, "MArrayLM")) 
        stop("fit must be an MArrayLM")
    if (is.null(fit$lods)) 
        stop("No B-statistics found, perhaps eBayes() not yet run")
    x <- as.matrix(fit$coef)[, coef]
    y <- as.matrix(fit$lods)[, coef]
    plot(x, y, xlab = xlab, ylab = ylab, pch = pch, cex = cex, 
        ...)
    if (highlight > 0) {
        if (is.null(names)) 
            names <- 1:length(x)
        names <- as.character(names)
        o <- order(y, decreasing = TRUE)
        i <- o[1:highlight]
        text(x[i], y[i], labels = substring(names[i], 1, 8), 
            cex = 0.8, col = "blue")
    }
    invisible()
}
<environment: namespace:limma>
code R • 24k views
ADD COMMENTlink modified 4.8 years ago • written 4.8 years ago by Antonio R. Franco4.4k
3
gravatar for Sukhdeep Singh
4.8 years ago by
Sukhdeep Singh10.0k
Netherlands
Sukhdeep Singh10.0k wrote:

You can always have the source and can directly change the files. Either repack and install the custom new package via command line
R CMD INSTALL package 

or use the powerful updated editing capabilities within R. Check for function trace

Check this post on SO here for more options.
http://stackoverflow.com/questions/3384598/how-to-edit-and-debug-r-library-sources

ADD COMMENTlink written 4.8 years ago by Sukhdeep Singh10.0k
2

You can also use the devtools package for easier debugging.

First, install the devtools and load it with library(devtools). Then, activate the development mode with dev_mode(). This will allow you to recompile and reinstall new packages without altering your main R installation. Then, use install_local("path to modified limma package") to install it again.

ADD REPLYlink written 4.8 years ago by Giovanni M Dall'Olio26k

This answer fulfill everything I need and even more. Thank you

ADD REPLYlink written 4.8 years ago by Antonio R. Franco4.4k
1

If that's the case, please mark the answer as accepted. That way the respondent gets credit and other readers can see this question has a satisfactory answer already.

ADD REPLYlink written 4.8 years ago by David Quigley11k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1782 users visited in the last hour