Skip to content

Repository files navigation

DOI

Repository for PyRATES Project

Created as part of the PyRATES workshop in June 2024 and as a professional development project for learning to code in Python.

This project is a partial reproducibility study of Koslow et al. (2011) “Impact of declining intermediate-water oxygen on deepwater fishes in the California Current”. Koslow et al. (2011) analyzed ichthyoplankton (larval fish) abundance data and hydrographic data obtained from the California Cooperative Oceanic Fisheries Investigations, CalCOFI, from the years 1951-2008. They found that the first principal component of the ichthyoplankton dataset was highly correlated to mean midwater oxygen levels, with many mesopelagic fishes showing declines in abundance in years when oxygen was low. I will aim to reproduce the first few parts of this study, covering the ichthyoplankton-oxygen analyses and reproducing Table 2 (partial), Figure 2, Figure 3, and Table 3 (partial).


Workflow outline:

Note

Original code was not available for this paper. In addition, datasets have been updated and changed since this paper was published, so my results will not be the same as in the paper.

Part 1. Get and process ichthyoplankton data

  • manual step: query ERDDAP for all CalCOFI ichthyoplankton data in the years 1951-2008, download the data as a csv
  • read in data
  • filter dataset for needed variables: line, station, scientific name, larval abundance
  • filter for the CalCOFI sampling stations used in the study
  • remove years with less than three seasons of data (JF = winter, MAM = spring, JJA = summer, SOND = winter)
  •  calculate seasonal mean abundance for each taxa
  • calculate annual mean abundance (based on seasonal means) for each taxa
  • remove taxa with data in less than half the years (29)
  • log10 transform annual means to normalize variance

output: ichthyoplankton abundance time series


Part 2. Get and process oxygen data

  • manual step: download CalCOFI bottle data as a csv
  • read in data
  • filter dataset for needed variables: year, line and station, depth, oxygen
  • filter for years 1951-2008
  • filter for the stations used in this study
  • filter for depths 200-400m
  • remove years with less than three seasons of data (JF = winter, MAM = spring, JJA = summer, SOND = winter)
  • calculate seasonal means of oxygen
  • calculate annual means (based on seasonal means) of oxygen

output: oxygen time series


Part 3. Analysis

Part 3.1. Principal Components Analysis (PCA)

input: ichthyoplankton abundance time series

  •  standardize the abundance data by each taxon's mean and standard deviation (Z-score)
  • perform PCA
  • extract PC1 scores and loadings

output: PC1 time series, PC1 loadings

Part 3.2. Detrending

input: PC1 time series

  • remove linear trend from PC1 time series

output: detrended PC1 time series

Part 3.3. First-Differencing

inputs: PC1 time series, oxygen time series, ichthyoplankton abundance time series

  •  for each dataset, remove the years of intermittent sampling (1967-1983)
  • take the first-difference of each time series

outputs: first-differenced PC1 time series, first-differenced oxygen time series, first-differenced ichthyoplankton abundance time series

Part 3.4. Correlations between first-differenced ichthyoplankton and first-differenced PC1

inputs: first-differenced PC1 time series, first-differenced ichthyoplankton abundance time series

  • calculate Pearson's r and p-value between each taxon's first-differenced time series and the first-differenced PC1 time series

outputs: dataframe of Pearson's correlations ichthyo-PC1

Part 3.5. Correlations between ichthyoplankton abundance and oxygen time series

inputs: ichthyoplankton abundance time series, oxygen time series

  • calculate Spearman's ρ and p-value between each taxon's abundance time series and the oxygen time series

outputs: dataframe of Spearman's correlations ichthyo-oxygen

Part 3.6. Correlations between PC1 and oxygen time series

inputs: PC1 time series, oxygen time series, detrended PC1 time series, first-differenced PC1 time series, first-differenced oxygen time series

  • calculate Pearson's r and p-value between the original PC1 time series and original oxygen time series
  • calculate Pearson's r and p-value between the detrended PC1 time series and original oxygen time series
  • calculate Pearson's r and p-value between the first-differenced PC1 time series and the first-differenced oxygen time series

outputs: dataframe of Pearson's correlations between PC1 and oxygen


Part 4. Make figures

Table 2 (partial)

inputs: PC1 loadings, dataframe of Pearson's correlations ichthyo-PC1, dataframe of Spearman's correlations ichthyo-oxygen

  • create a table with 4 columns: scientific name, loading on PC1, first-differenced correlation with PC1, and Spearman's correlation with oxygen

Figure 2

inputs: ichthyoplankton abundance time series

  • filter the abundance time series for 4 specific taxa (Cyclothone spp., Diogenichthys atlanticus, Bathylagoides wesethi, Vinciguerria lucetia)
  • plot the time series of each taxa abundance against year on shared axes

Figure 3

inputs: PC1 time series, oxygen time series

  • plot the two time series on a shared x-axis and separate y-axes

Table 3 (partial)

inputs: dataframe of Pearson's correlations between PC1 and oxygen

  • create a table to display the three correlation coefficients and their p-values

Releases

Contributors

Languages