joey711 / phyloseq

phyloseq is a set of classes, wrappers, and tools (in R) to make it easier to import, store, and analyze phylogenetic sequencing data; and to reproducibly share that data and analysis with others. See the phyloseq front page:
http://joey711.github.io/phyloseq/
578 stars 187 forks source link

ggplot2 v0.9.2 issues, revise ggplot2 dependencies for new version #135

Closed joey711 closed 12 years ago

joey711 commented 12 years ago

This should actually have its own "dependency" label, as it is neither a bug (yet), because ggplot2 v0.9.2 is not yet released, and may turn out to not be a feature, because it is unclear if there will be any feature additions by supporting the new ggplot2 version. Although we can hope that there will be some advantages to using the latest ggplot2 version.

The ggplo2 developers kindly sent the following instructions well in advance:

Dear package maintainers -

You are receiving this email because you are listed as the maintainer of a CRAN package that depends on ggplot2 and we're about to release a new version, 0.9.2. (I am working with Hadley Wickham on ggplot2 and will be handling the release.) In accordance with our new release process, ggplot2 will be in a release candidate phase for a month before we submit it to CRAN, on August 27th.

We have checked the dependent packages (results here: https://gist.github.com/3188657) and haven't discovered any major problems, but there may be smaller issues you want to fix. In some cases, we might not have been able to fully check your package because some dependencies were not available on the test machine.

Thank you for your help!

Instructions for testing

First, install the new versions of ggplot2, gtable, and scales. Instead of overwriting your existing installation of the packages, the following commands will install them to a development library path, ~/R-dev/. (If you do want to overwrite your existing installation, skip the dev_mode() command below.)

install.packages("devtools") library(devtools) dev_mode() install_github("gtable", branch = "gtable-0.1.1-rc") install_github("scales", branch = "scales-0.2.2-rc") install_github("ggplot2", branch = "ggplot2-0.9.2-rc")

Once you have installed the release candidate versions of these packages, you can run R CMD check on your package. The easy way to do this is to use check() from devtools:

check('path/to/mypackage')

This will automatically set up R_LIBS so that it contains ~/R-dev/. If you choose instead to run 'R CMD check' from the command line, you will need to set R_LIBS to include ~/R-dev/.

Changes to ggplot2 0.9.2

Your existing code should continue to work, although you may receive warnings about some deprecated functions. Replacing them with new versions is easy. Here are the changes you are likely to encounter:

There are also a number of enhancements to the theming system. If you'd like to read more about it, see: https://github.com/wch/ggplot2/wiki/New-theme-system

For the full list of changes to this version of ggplot2, see: https://github.com/hadley/ggplot2/blob/master/NEWS

If you encounter any problems that aren't fixed with the information below, please contact me and Hadley, or file an issue on Github, and mention that you are testing your package with the release candidate: https://github.com/hadley/ggplot2/issues

Thanks for your help and patience, Winston Chang Hadley Wickham

joey711 commented 12 years ago

This has some new urgency, now that the latest version of ggplot2 was finally released. The release version of phyloseq now does not pass R CMD check on the Bioconductor servers. Recommendation from the BioC team is to just update for the latest version of ggplot2, and forget backward compatibility. Will have to make the same changes in the latest devel version. Pretty annoying.

Here is a link to the check output:

http://bioconductor.org/checkResults/2.10/bioc-LATEST/phyloseq/moscato2-checksrc.html

joey711 commented 12 years ago

The following script helps update all package source files with the new semantics for ggplot2 (the syntax highlighting for R is weird on GitHub, so no highlighting is shown here):

# Define the location of the package in which you want to update the old ggplot2 semantics
# e.g. for me this is `phyloseq` in the `~/github` directory
pkg_dir = "~/github/phyloseq"

# Source only (R and Rnw)
all_sources = list.files(pkg_dir, "[[:alnum:]]+\\.+R+($|nw)", recursive=TRUE)

# list of old_function/new_function pairs
rep_hash = list(
    c("opts(", "theme("),
    c("theme_text(", "element_text("),
    c("theme_rect(", "element_rect("),  
    c("theme_line(", "element_line("),
    c("theme_segment(", "element_line("),
    c("theme_blank(", "element_blank(") 
)

for( j in all_sources ){
    # Initialize source_text. No carry-over
    source_text = ""
    # paste together name
    source_file = paste(pkg_dir, j, sep="/")
    # Read the latest source file
    source_text = readLines(source_file, warn=FALSE)
    # Loop through each pair in rep_hash, and replace the first string with the second in the source file
    for( i in rep_hash ){
        source_text = gsub(i[1], i[2], source_text, fixed=TRUE) 
    }
    # Don't overwrite source text if failed to read or massive problem.
    if( identical(source_text, "") ){
        # Overwrite source text with the proper replacements.
        writeLines(source_text, source_file)    
    }
}
# Still need to manually replace any opts(title="Title text") commands, because the title argument could appear anywhere,
# not a simple find/replace.
joey711 commented 12 years ago

Almost done. The last bit about adding titles caused an error in R CMD check phyloseq stemming from one of the examples in which a title is added to a plot_ordination call. This means the title-adding step in any of the plot functions needs to be migrated, and probably best added using the new ggtitle command.

joey711 commented 12 years ago

Didn't mean to close in the first place. Issue is almost fully addressed, but this title problem needs to be fixed in all plot_ functions

joey711 commented 12 years ago

This is issue is now closed with the latest pull request merge

https://github.com/joey711/phyloseq/pull/142