Skip to content

Supporting data and code for: "Effects of phenotypic variation on consumer coexistence and prey community structure"

License

Notifications You must be signed in to change notification settings

slhogle/hambiConsumerCompetition

Repository files navigation

Effects of phenotypic variation on consumer coexistence and prey community structure

Preprint available from bioRxiv

Full text available from Ecology Letters

Supporting data and code is provided under the MIT License.

Setup

Clone the repository

git clone https://github.com/slhogle/hambiConsumerCompetition.git

System info

R version 4.1.1 (2021-08-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Pop!_OS 21.04
JAGS: deb jags (4.3.0-3build1)
STAN: 2.21.0

Dependencies

Project R dependencies are managed with pak and renv. This allows one to restore the correct package versions for this project to run with the system and R version listed above. You will need to also install JAGS. On Ubuntu you can do sudo apt-get install jags

To setup packages to the versions used in this analysis, simply run:

renv::restore()

from the main project directory.

Directory structure

  1. /sh contains scripts from running analysis on the puhti compute cluster
  2. /r contains R scripts
  3. /data_raw contains unprocessed data
  4. /data contains data that has been processed in some way for from /dataRaw for downstream use
  5. /figs contains figures generated from R scripts
  6. /tables contains summary tables generated from R scripts
  7. /rendered contains any markdown or HTML that gets rendered in the process of running the scripts.

16S amplicon processing

Download

Install the NCBI SRA Toolkit. You can download a prebuilt binary from here.

Access SRA data following the instructions here.

You will need to setup your configurations, but afterwards you could basically do:

prefetch SRR14323812
fasterq-dump SRR14323812

You will need to do this for all the SRA accessions associated with BioProject: PRJNA725120. For example:

cut -f1 data/sra_records.tsv | while read ID; do
  prefetch $ID
  fasterq-dump $ID
done

Quality control and mapping

Run these steps on an HPC cluster

  1. amplicon_quality_control.sh -- Trim and filter reads
  2. amplicon_mapping.sh -- map QC'ed reads to the database in data_raw/16S_amplicon/mapping.tar.gz

Analysis steps

Go through these steps in order to reproduce the analysis in the paper. You can also run Rscript R/runeverything.R which will perform all steps in the analysis automatically.

1. Format data

  1. rpkm2tab.R -- format bbmap output to tables
  2. format_raw_data.R -- format raw density data for downstream use

2. Process amplicon

  1. correct_bias.R -- applying method from this paper
  2. normalize_counts.R -- normalizing sequencing counts for later

3. Model consumer/prey densities

  1. gam_ciliate_density.R -- fit GAM used in Table S2 and Fig 2
  2. gam_OD600_density.R -- fit GAM used in Table S3 and Fig 2
  3. gam_nematode_density.R -- fit GAM used in Table S4 and Fig 2
  4. competitive_LV.R -- parameterize LV competitive model
  5. fig2.R -- Reproduces Fig. 2 from the main text

4. Prey community composition

  1. figS1a.R -- Reproduces Fig. S1A from supplementary
  2. community_dissimilarity_plot.R -- Reproduces Fig. S1B from supplementary
  3. community_dissimilarity_regression.R -- Reproduces Table S5
  4. shannon_diversity.R -- Run divnet estimate of Shannon diversity and save result
  5. shannon_change_point_regression.R -- Perform multiple change point regression of the shannon diversity estimate. Reproduces Fig. S2.
  6. shannon_sort_eq_regression_bayes.R -- Performs regression using MCMC from Stan on the Shannon estimates in the two experimental phases. Reproduces Fig. S3 and Tables S6 and S7 a. shannon_sort_eq_regression_freq.R -- Performs frequentist regression. No Stan required
  7. ordination.R -- Ordination and jump lengths. Generate Fig. 3C and Table S8
  8. fig3.R -- Generate final Fig 3

5. Bacteria traits

  1. traits.R -- Load and format trait data for use with JSDM models

6. Joint species distribution modeling

  1. JSDM_format_sort.R -- formats sorting phase models. Models need to be uploaded to cluster afterward
  2. JSDM_format_qeq.R -- formats equilibrium phase models. Models need to be uploaded to cluster afterward
  3. puhti_hmsc_mcmc.sh -- executes puhti_hmsc_mcmc.R and fits models using MCMC
  4. puhti_hmsc_crossvaliation.sh executes puhti_hmsc_crossvaliation.R and performs 5-fold cross validation to determine predictive performance of the full models
  5. JSDM_convergence.R -- Various stats to demonstrate chains have converged
  6. JSDM_inspect.R -- Produces Table S9 and S10 and main text Fig. 4

7. Consumer feeding efficiency

  1. fig5.R -- generates Figure 5 from main text
  2. consumer_feeding_stats.R -- reproduces Table S11 and S12

About

Supporting data and code for: "Effects of phenotypic variation on consumer coexistence and prey community structure"

Topics

Resources

License

Stars

Watchers

Forks

Packages