Coder Social home page Coder Social logo

japan_ferns_spatial_phy's Introduction

Spatial phylogenetics of Japanese ferns

Code repostitory to run analyses and generate figures and manuscript for Nitta et al. "Spatial phylogenetics of Japanese ferns: Patterns, processes, and implications for conservation". https://doi.org/10.1101/2021.08.26.457744

All code is in R. The targets package is used to manage the workflow. To run all analyses and generate the manuscript, clone this repository and run targets::tar_make().

Data

Data files need to be downloaded from three locations.

  1. Dataset on FigShare for this project: https://doi.org/10.6084/m9.figshare.16655263. Cick on the "Download all" icon, download the zipped dataset, then unzip it and put the contents in the data/ folder in this repo.
  2. Dataset on Dryad for Ebihara and Nitta 2019: https://datadryad.org/stash/dataset/doi:10.5061/dryad.4362p32. Download the zipped dataset and put in the data/ folder directly (without unzipping).
  3. Dataset on FigShare for FTOL v0.0.1 (Nitta et al, BioRxiv): https://doi.org/10.6084/m9.figshare.13251290.v1. Cick on the "Download all" icon, download the zipped dataset, name it "ftol_data_release_v0.0.1.zip", and put in the data/ folder directly (without unzipping).

For more information about data files, see the READMEs for raw data and processed data.

Reproducible analysis with Docker

This project requires various packages to be installed, and may not work properly if package versions have changed. Therefore, a Docker image is provided to run the code reproducibly.

To use it, first install docker and clone this repository.

Navigate to the cloned repository (where /path/to/repo is the path on your machine):

cd /path/to/repo

Run targets::tar_make():

docker run --rm -v ${PWD}:/tmpdir -w /tmpdir joelnitta/japan_ferns_spatial_phy:latest Rscript -e 'targets::tar_make()'

You will see the targets being built by targets, and the final manuscript should be compiled at the end as manuscript.pdf and manuscript.docx in the results folder. Other figure and table files will also be compiled.

Interacting with the code

If you want to interact with the code in the Docker container, you can launch the container in the background using docker-compose:

docker-compose up -d

Navigate to http://localhost:8787/ in your browser of choice (firefox or google chrome recommended). There, you should be able to access an instance of the RStudio IDE, which can be used to inspect and manipulate objects in R. You can click on "Build All" in the "Build" tab to run the workflow.

When you're done, take down the container:

docker-compose down

Targets cache

The targets package manages the workflow and saves all intermediate analysis results to a folder named _targets; this is the targets cache. Normally, you would have to run all of the analyses starting from the original data files to generate all of the analysis results, as described above. This takes a long time. The longest step is the phylogenetic analysis, which takes about 1 week using 10 cores in parallel.

I have put the targets cache for this project on github under version control using the gittargets package.

So instead of running everything from scratch, you can checkout the exact results matching a specific code version as follows (this assumes we are in the japan_ferns_spatial_phy folder and requires git):

  1. Clone the targets cache to a folder called _targets.
git clone https://github.com/joelnitta/japan_ferns_spatial_phy_cache _targets
  1. Enter the _targets directory.
cd _targets
  1. Fetch branches from the remote repo (each branch corresponds to a selected commit in the code).
git fetch
  1. Change to the latest branch (the part of the name after code= matches the corresponding commit hash in japan_ferns_spatial_phy).
git switch code=868d97bc3e205adbf417c74123314f48db87e368
  1. Move back up to the japan_ferns_spatial_phy folder.
cd ..

You can also change between different snapshots of the targets cache and code using gittargets.

When you open the project in R as described above, you can use targets::tar_load() to load any target (intermediate workflow step) listed in _targets.R. For more information on how to use the targets package, see https://github.com/ropensci/targets.

Licenses

japan_ferns_spatial_phy's People

Contributors

joelnitta avatar

Stargazers

dikip avatar Erin Steiner avatar Masatoshi Katabuchi avatar

Watchers

 avatar

japan_ferns_spatial_phy's Issues

Remove hybrid from community dataframe

Currently includes at least one hybrid (Dryopteris_dickinsii_ร—_Dryopteris_polylepis). Seems to be included in raw occurrence point data (which was supposed to not include hybrids). So need to add a check hybrids by verifying with green list.

Update data on FigShare

after paper is accepted, so previous versions also show up

(If I try to updated on FigShare now while still private, will overwrite old data)

Polish some SI figures

9: values on K plot axis should be whole numbers

14: Change 'cluster' to 'bioregion', make sure text doesn't run off page

Fix some things in MS

  • Add citation for iNEXT package (SI Fig 1)
  • Double check number of full-plastome sequences in alignment
  • Double check number of fossil calibration points, clarify part about Cyatheaceae prior
  • Add citations for all R packages
  • Make island outline lighter/thinner to avoid obscuring data colors
  • Make CANAPE colors CVD friendly
  • Add check for statement "Conditional AIC was lower (indicating better model fit) in the reproductive model compared to the environmental model for SES of RPD and SES of PD"
  • Check on whether to use JpFernLUCID_forJoel.xlsx or JpFernLucid_forJoel20200827.xlsx

Add cAIC table

To compare between reproductive mode models and environmental models

Update data readme

... with DOIs when available

make sure to update overall description on FigShare landing page (not README.txt) too (currently links to preprint)

Fix Fig 4

Lat. area got dropped from y-axis!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.