diff --git a/.github/workflows/R-CMD-check.yml b/.github/workflows/R-CMD-check.yml index d826afe..cea6110 100644 --- a/.github/workflows/R-CMD-check.yml +++ b/.github/workflows/R-CMD-check.yml @@ -47,9 +47,9 @@ jobs: config: - {os: windows-latest, r: 'release'} - {os: macOS-latest, r: 'release'} - - {os: ubuntu-latest, r: '4.1', rspm: "https://packagemanager.rstudio.com/cran/__linux__/noble/latest"} # Until TreeDist can slough phangorn - - {os: ubuntu-latest, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/noble/latest"} - - {os: ubuntu-latest, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/noble/latest"} + - {os: ubuntu-22.04, r: '4.1', rspm: "https://packagemanager.rstudio.com/cran/__linux__/jammy/latest"} # Until TreeDist can slough phangorn + - {os: ubuntu-24.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/noble/latest"} + - {os: ubuntu-24.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/noble/latest"} env: R_REMOTES_NO_ERRORS_FROM_WARNINGS: true diff --git a/.github/workflows/memcheck.yml b/.github/workflows/memcheck.yml index 635339f..63e4d75 100644 --- a/.github/workflows/memcheck.yml +++ b/.github/workflows/memcheck.yml @@ -24,7 +24,7 @@ name: mem-check jobs: mem-check: - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 # Remember to update RSPM below to match name: valgrind ${{ matrix.config.test }} @@ -45,58 +45,7 @@ jobs: - uses: actions/checkout@v4 with: submodules: true - - - uses: r-lib/actions/setup-r@v2 - with: - r-version: release # CRAN uses devel, but takes ages to load deps. - - - name: Install apt packages - run: | - sudo apt-get install valgrind texlive-latex-base - - - uses: r-lib/actions/setup-pandoc@v2 - - - name: Query dependencies - run: | - install.packages('remotes') - saveRDS(remotes::dev_package_deps(dependencies = c("soft", - "Config/Needs/github-actions", "Config/Needs/memcheck")), - ".github/depends.Rds", version = 2) - writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version") - shell: Rscript {0} - - - name: Cache R packages - uses: actions/cache@v4 + + - uses: ms609/actions/memcheck@main with: - path: ${{ env.R_LIBS_USER }} - key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }} - restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1- - - - name: Install system dependencies - run: | - while read -r cmd - do - eval sudo $cmd - done < <(Rscript -e 'writeLines(remotes::system_requirements("ubuntu", "20.04"))') - - - name: Install dependencies - run: | - remotes::install_github('emmanuelparadis/ape') - if ("${{ matrix.config.test }}" == 'tests') { - remotes::install_github('r-lib/brio#20') # brio mem leak - } - remotes::install_deps(dependencies = c("soft", "Config/Needs/github-actions", "Config/Needs/memcheck")) - shell: Rscript {0} - - - name: Install this package - run: | - cd .. - R CMD build --no-manual --no-resave-data Rogue - R CMD INSTALL Rogue*.tar.gz - cd Rogue - - - name: valgrind - memcheck ${{ matrix.config.test }} - run: | - R -d "valgrind --tool=memcheck --leak-check=full \ - --errors-for-leak-kinds=definite --error-exitcode=1" \ - --vanilla < memcheck/${{ matrix.config.test }}.R + test: ${{ matrix.config.test}} diff --git a/.github/workflows/pkgdown.yml b/.github/workflows/pkgdown.yml index 9e3ac54..bdf8949 100644 --- a/.github/workflows/pkgdown.yml +++ b/.github/workflows/pkgdown.yml @@ -15,7 +15,7 @@ name: pkgdown jobs: pkgdown: - runs-on: macOS-latest + runs-on: ubuntu-latest env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} @@ -26,38 +26,5 @@ jobs: with: submodules: true - - uses: r-lib/actions/setup-r@v2 - - - uses: r-lib/actions/setup-pandoc@v2 - - - name: Query dependencies - run: | - install.packages('remotes') - saveRDS(remotes::dev_package_deps(dependencies = c('soft', 'Config/Needs/website')), ".github/depends.Rds", version = 2) - writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version") - shell: Rscript {0} - - - name: Cache R packages - uses: actions/cache@v4 - with: - path: ${{ env.R_LIBS_USER }} - key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }} - restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1- - - - name: Install Mac OS dependencies - run: | - brew install libgit2 - - - name: Install dependencies - run: | - remotes::install_deps(dependencies = c('soft', 'Config/Needs/website')) - shell: Rscript {0} - - - name: Install package - run: R CMD INSTALL . - - - name: Deploy package - run: | - git config --local user.email "actions@github.com" - git config --local user.name "GitHub Actions" - Rscript -e 'pkgdown::deploy_to_branch(new_process = FALSE)' + steps: + - uses: ms609/actions/pkgdown@main diff --git a/DESCRIPTION b/DESCRIPTION index 8606ab2..6f4027b 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -37,12 +37,15 @@ Imports: Rfast, stats, TreeDist (> 2.2.0), - TreeTools (>= 1.9.1.9003), + TreeTools (>= 1.10.0), utils, +Remotes: + ms609/TreeTools, Suggests: knitr, PlotTools, rmarkdown, + RCurl, spelling, testthat, Config/Needs/github-actions: diff --git a/NEWS.md b/NEWS.md index 1c452c8..23a8a6f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,7 @@ # Rogue v2.1.7 (2025-07-01) +- Simplify vignette with new `TreeTools::ReadMrBayesTrees()`. + - Improve tip instability calculation in identical tree sets ([#29](https://github.com/ms609/Rogue/issues/29)). - Improve variable protection. diff --git a/vignettes/Bayesian.Rmd b/vignettes/Bayesian.Rmd index f591fb9..0f7e081 100644 --- a/vignettes/Bayesian.Rmd +++ b/vignettes/Bayesian.Rmd @@ -37,10 +37,7 @@ library("Rogue") # Find rogue taxa ``` ```{r test-connection, echo = FALSE} -online <- tryCatch({ - read.csv("https://raw.githubusercontent.com/ms609/hyoliths/master/MrBayes/hyo.nex.pstat") - TRUE - }, +online <- tryCatch(RCurl::url.exists("https://raw.githubusercontent.com/"), warning = function(w) invokeRestart(""), error = function(e) FALSE ) @@ -51,63 +48,25 @@ analysis of early brachiopods [@Sun2018] using [MrBayes](https://nbisweden.github.io/MrBayes/) [@Hulsenbeck2001]. Our data files are stored on [GitHub](https://github.com/ms609/hyoliths/tree/master/MrBayes). -Let's load the results of run 1: +Let's sample 100 trees from the posterior (after discarding a 25% burn-in): ```{R load-trees} if (online) { - dataFolder <- "https://raw.githubusercontent.com/ms609/hyoliths/master/MrBayes/" - run1.t <- paste0(dataFolder, "hyo.nex.run1.t") - # Reading 10k trees takes a second or two... - run1Trees <- ape::read.nexus(run1.t) - if (packageVersion('ape') <= "5.6.1") { - # Workaround for a bug in ape, hopefully fixed in v5.6.2 - run1Trees <- structure(lapply(run1Trees, function(tr) { - tr$tip.label <- attr(run1Trees, 'TipLabel') - tr - }), class = 'multiPhylo') - } + # Downloading all trees takes a second or two... + trees <- ReadMrBayesTrees( + "https://raw.githubusercontent.com/ms609/hyoliths/master/MrBayes/hyo.nex", + n = 100, + burninFrac = 0.25 + ) } else { # If no internet connection, we can generate some example trees instead - run1Trees <- structure(unlist(lapply(0:21, function(backbone) { - AddTipEverywhere(ape::as.phylo(0, nTip = 12), 'ROGUE') - }), recursive = FALSE), class = 'multiPhylo') + trees <- structure(unlist(lapply(0:21, function(backbone) { + AddTipEverywhere(ape::as.phylo(0, nTip = 12), "ROGUE") + }), recursive = FALSE), class = "multiPhylo") } ``` -## Select trees to analyse - -Our tree file contains all trees generated. We typically want to discard -a proportion of trees as burn-in: - -```{R discard-burnin} -burninFrac <- 0.25 -nTrees <- length(run1Trees) -trees <- run1Trees[seq(from = burninFrac * nTrees, to = nTrees)] -``` - -This is a large number of trees to analyse. We could save time for an initial -analysis by thinning our sample somewhat. - -```{R thin-trees} -sampleSize <- 100 -trees <- run1Trees[seq(from = burninFrac * nTrees, to = nTrees, - length.out = sampleSize)] -``` - -For a full analysis, we ought to consider the output from the other runs of our -analysis, perhaps with - -```r -nRuns <- 4 -allTrees <- lapply(seq_len(nRuns), function(run) { - runTrees <- ape::read.nexus(paste0(dataFolder, 'hyo.nex.run', run, .'t')) - runTrees <- runTrees[seq(from = burninFrac * nTrees, to = nTrees, - length.out = sampleSize / nRuns)] -}) -trees <- structure(unlist(allTrees, recursive = FALSE), class = 'multiPhylo') -``` - ## Initial appraisal Let's start by looking at the majority rule consensus tree. @@ -122,7 +81,7 @@ plenary <- Consensus(trees, p = 0.5) par(mar = rep(0, 4), cex = 0.85) plot(plenary, tip.color = ColByStability(trees)) PlotTools::SpectrumLegend( - "bottomright", legend = c("Stable", "Unstable"), + "bottomright", legend = c("Stable", " ", "Unstable"), palette = hcl.colors(131, 'inferno')[1:101] ) ```