Skip to content

bleds22e/PP_shifts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DOI

PP Shifts

Temporal changes in species composition affect a ubiquitous species' use of habitat patches

This repo contains analyses for my project on how C. penicillatus's use of habitat patches has changed through time in response to the colonization of C. baileyi at The Protal Project.

The manuscript for this project is currently in press at Ecology.

Manuscript Analysis

To conduct the analyses in the manuscript, you'll need the two scripts in the "scripts" folder:

  • scripts/PP_shifts.R: contains all the analyses and figures in the paper
    • You should be able to source this code and have it should run smoothly, assuming all packages are installed
    • As written, revelant results files are imported in; to run the original RMark analysis, see Tip #3 below
  • scripts/functions.R: contains all functions used in the PP_shifts.R script
    • sourced in the PP_shifts.R script
    • includes both data-focused functions and plotting functions

Tips for Running These Analyses

1) Make sure all of the packages listed in the PP_shifts.R script have been installed.

portalr, a package for easily downloading data from the Portal Project, can now be downloaded from CRAN.

I used the patchwork package to make the multipanel figures. You'll need to download that package from GitHub:

# install.packages("devtools")
devtools::install_github("thomasp85/patchwork")

2) The script is broken into 3 main parts

In addition to calling in relevant libraries, source code, and data, the script has the following three sections:

  • Patch Preference of C. penicillatus in Response to C. baileyi Abundance [line 83]
  • C. penicillatus Population-level Metrics and RMark [line 211]
  • System-level Aspects of Patch Preference [line 367]

3) Choose whether you want to run the RMark analyses yourself or not

If you choose to run the entire script in its current state, it will NOT run all of the RMark analyses from scratch. Instead, it will import the necessary results files to complete the analyses.

The code to run the original RMark files can be found in the main analysis file, but these lines of code are commented out. If you would prefer to run the original code, you just need to remove the pound sign from those lines and comment out the lines of code that read in the results. To run the original RMark code, you will need to have MARK downloaded on your machine; running code will likely take a couple hours and potentially crash your computer.

See lines 226-235 and lines 247-256 in the scripts/PP_shifts.R file for more information

Other Files in the Repo

  • data/
    • all_model_results_20180712.csv output from all models from the latest RMark run
    • PP_capture_history_all_20180711.csv results from create_trmt_hist()(line 240)
    • test_data_prepared.csv test data for testthat functions
    • top_model_summary_20190416.csv output from top model from latest RMark run (line 294)
  • figures/
    • manuscript figures
  • testthat/
    • test_fuctions.r script with test functions to ensure functions are giving the expected outputs
  • preliminary_work/
    • all the bits and pieces used in the project but not in the manuscript

About

Repo for working on PP shifts at Portal

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages