DOI: 10.5061/dryad.47d7wm3jf
title: Sensory neurons couple arousal and foraging decisions in C. elegans

description: Foraging animals optimize feeding decisions by adjusting both common and
 rare behavioral patterns. Here, we characterize the relationship between
 an animal’s arousal state and a rare decision to leave a patch of
 bacterial food. Using long-term tracking and behavioral state
 classification, we find that food leaving decisions in C.
 elegans are coupled to arousal states across multiple timescales.
 Leaving emerges probabilistically over minutes from the high arousal
 roaming state, but is suppressed during the low arousal dwelling state.
 Immediately before leaving, animals have a brief acceleration in speed
 that appears as a characteristic signature of this behavioral motif.
 Neuromodulatory mutants and optogenetic manipulations that increase
 roaming have a coupled increase in leaving rates, and similarly acute
 manipulations that inhibit feeding induce both roaming and leaving. By
 contrast, inactivating a set of chemosensory neurons that depend on the
 cGMP-gated transduction channel TAX-4 uncouples roaming and leaving
 dynamics. In addition, tax-4-expressing sensory neurons promote
 lawn-leaving behaviors that are elicited by feeding inhibition. Our
 results indicate that sensory neurons responsive to both internal and
 external cues play an integrative role in arousal and foraging decisions.
description: The folllowing dataset comprises behavioral data from foraging
 locomotion patterns of <em>C. elegans</em> on small lawns of
 bacterial food. Animals were videotaped, their movements were tracked, and
 subsequently analyzed to find decision-making patterns.
description: Data is in .pkl format, which can be opened using Python (I used
 Python version 3.8.3). A single file is a .csv, which
 can be opened by many programs.
description: **Dryad ReadMe** **Title: Sensory neurons couple arousal and foraging
 decisions in C. elegans** **Abstract:** Foraging animals optimize feeding
 decisions by adjusting both common and rare behavioral patterns. Here, we
 characterize the relationship between an animals arousal state and a rare
 decision to leave a patch of bacterial food. Using long-term tracking and
 behavioral state classification, we find that food leaving decisions in
 *C. elegans* are coupled to arousal states across multiple timescales.
 Leaving emerges probabilistically over minutes from the high arousal
 roaming state, but is suppressed during the low arousal dwelling state.
 Immediately before leaving, animals have a brief acceleration in speed
 that appears as a characteristic signature of this behavioral motif.
 Neuromodulatory mutants and optogenetic manipulations that increase
 roaming have a coupled increase in leaving rates, and similarly acute
 manipulations that inhibit feeding induce both roaming and leaving. By
 contrast, inactivating a set of chemosensory neurons that depend on the
 cGMP-gated transduction channel TAX-4 uncouples roaming and leaving
 dynamics. In addition, tax-4-expressing sensory neurons promote
 lawn-leaving behaviors that are elicited by feeding inhibition. Our
 results indicate that sensory neurons responsive to both internal and
 external cues play an integrative role in arousal and foraging decisions.
 **Methods:** Animal behavior on small lawns was tracked and analyzed using
 code found here:
 [https://github.com/BargmannLab/Scheer_Bargmann2023](https://github.com/BargmannLab/Scheer_Bargmann2023) **Usage Notes:** See ipython notebooks for code to read in these results and make plots: * Figure 1 - Animals make foraging decisions at the boundaries of bacterial food lawns..ipynb * Figure 2 - Lawn leaving is associated with high arousal states on short and long scales..ipynb * Figure 3-6 - Genotype comparisons (without optogenetics).ipynb * Figure 3-6 - Optogenetics experiments.ipynb Download .pkl data and put in a folder. ***Data can be read in as follows, for each file included here:*** All code was done using Python 3.8.3. You will also need to install the SSM package for all Hidden Markov Model training and analysis. [https://github.com/lindermanlab/ssm](https://github.com/lindermanlab/ssm) Other package versions used can be found below. **GenotypeComparisons\_021523.pkl** This pickle contains all of the data for each genotype, excluding genotypes used in optogenetics experiments. ``` processDataPath = # *whatever that folders path is* with open(os.path.join(processDataPath,'GenotypeComparisons_021523.pkl'),'rb') as f: bins,binSize,genotypesData = pickle.load(f) ``` where bins specify the edges of contiguous 10-second bin intervals used in analysis. binSize is the number of frames that compose a bin. In this case, it is always 30 (10 seconds \* 3fps) genotypesData is a dictionary whose keys specify different genotypes and conditions. You can access all of the data for a particular genotype by entering the key as follows: ``` genotypesData['PD1074_od2_Data'] ``` And you can query what keys are available in this dictionary using ``` genotypesData['PD1074_od2_Data].keys() ``` For example, ``` genotypesData['PD1074_od2_Data']['Midbody_speed'].shape ``` returns ``` (1586, 7200) ``` which is the size of the matrix containing all 1586 wild type animals (rows) by 7200 datapoints collected at 3 frames per second = 40 minutes of data per animal. There are also many variables that contain a 10-second binned version of the data, which are of dimension (1586, 240). 240 times 10 seconds = 40 minutes of data per animal. For example, ``` genotypesData['PD1074_od2_Data']['bin_Midbody_fspeed'].shape ``` returns ``` (1586, 240) ``` For a detailed understanding of what each of the fields in each genotype mean, read through the code at [https://github.com/BargmannLab/Scheer_Bargmann2023/blob/main/LawnLeavingAnalysis/preProcessing.py](https://github.com/BargmannLab/Scheer_Bargmann2023/blob/main/LawnLeavingAnalysis/preProcessing.py). Here you will see the function preprocessData, which is used to compute all of these variables. **HMM\_OnLawnOnly\_ForwardFeaturesOnly\_noQuirk\_AR\_062321.pkl** This file contains all of the autoregressive Hidden Markov Models that were trained for analysis of animals behavior. It's contents can be accessed as follows: ``` with open(os.path.join(processDataPath,'HMM_OnLawnOnly_ForwardFeaturesOnly_noQuirk_AR_062321.pkl'),'rb') as f: obs_dim,N_iters,num_states,kappa,arHMMs_ALL, arHMMs_logLike_ALL,\ Obs_train_forHMM, Obs_test_forHMM, \ Choice_train_forHMM, Choice_test_forHMM = pickle.load(f) ``` The most important variable here is `arHMMs_ALL`, which contains the models themselves. The selected AR-HMM model used for subsequent analysis throughout the paper is `arHMM_model = arHMMs_ALL[4][2] #K=4, KAPPA = 25,000`, which consists of 4 states, decodes 5 dimensional data, and has a kappa "stickiness" parameter of 25,000. ``` vars(arHMM_model) &gt;&gt;{'K': 4, 'D': 5, 'M': 0, 'init_state_distn': , 'transitions': , 'observations': } ``` Dig deeper into the SSM package documentation for more details. **LIGHT.csv** A csv file containing the light stimulus used for optogenetics experiments. 0 indicates light OFF and 1 indicates light ON. The vector is 7200 in length, corresponding to 3 fps for 40 minutes of video data per animal. It can be loaded into a vector and a binned version of that vector as follows: ``` LIGHT_STIM = pd.read_csv(os.path.join(stimPath,'LIGHT.csv'),header=None).to_numpy()[0] #pd is pandas LIGHT_STIM = LIGHT_STIM.reshape(1,len(LIGHT_STIM)) bin_LIGHT_STIM = binData(LIGHT_STIM, binSize, np.nanmean).ravel() ``` **OptogeneticsComparisons\_021523.pkl** This file is much like *GenotypeComparisons\_021523.pkl,* except it contains data from animals involved in optogenetics experiments and their matched controls. Usage examples for this data type can be found at [https://github.com/BargmannLab/Scheer_Bargmann2023/blob/main/LawnLeavingAnalysis/Figure%203-6%20-%20Optogenetics%20experiments.ipynb](https://github.com/BargmannLab/Scheer_Bargmann2023/blob/main/LawnLeavingAnalysis/Figure%203-6%20-%20Optogenetics%20experiments.ipynb) It can be loaded as follows: ``` with open(os.path.join(processDataPath,'OptogeneticsComparisons_021523.pkl'),'rb') as f: bins,binSize,optogenetics = pickle.load(f) ``` **PD1074\_od2\_Fig1\_021523.pkl** This file only contains wild type data used in Figure 1 of the manuscript. It is otherwise identical to *GenotypeComparisons\_021523.pkl.* It can be loaded as follows: ``` with open(os.path.join(processDataPath,'PD1074_od2_Fig1_021523.pkl'),'rb') as f: bins,binSize,wildtype = pickle.load(f) ``` **PD1074\_od2\_LL\_Data\_Centroid\_RoamingDwellingHMM\_081721.pkl** This file contains the HMM model used to decode roaming and dwelling states (K=2 states) from 1-dimensional data (which side of Roaming/Dwelling separatrix in Absolute Speed vs. Angular Speed space -- see Figure 2 supplement 1 from manuscript). ``` with open(os.path.join(processDataPath,'PD1074_od2_LL_Data_Centroid_RoamingDwellingHMM_081721.pkl'),'rb') as f: RD_hmm_Cent_exog = pickle.load(f) ``` ``` vars(RD_hmm_Cent_exog) &gt;&gt;{'K': 2, 'D': 1, 'M': 0, 'init_state_distn': , 'transitions': , 'observations': } ``` **PD1074\_scalers\_062321.pkl** This file contains the scaler objects used to normalize data before decoding by the AR-HMM. Used in [https://github.com/BargmannLab/Scheer_Bargmann2023/blob/main/LawnLeavingAnalysis/preProcessing.py](https://github.com/BargmannLab/Scheer_Bargmann2023/blob/main/LawnLeavingAnalysis/preProcessing.py) Scalers used here are sklearn.preprocessing.StandardScaler ([https://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.StandardScaler.html](https://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.StandardScaler.html)). They can be loaded as follows: ``` #Load PD1074 scalers with open(os.path.join(processDataPath,'PD1074_scalers_062321.pkl'),'rb') as f: # Python 3: open(..., 'rb') Scalers = pickle.load(f) ``` There are scalers for each of the 5 input dimensions to the AR-HMM: Midbody Forward Speed, Fraction of Time moving Forward, Midbody Angular Speed, Head Angular Velocity relative to the Midbody, Head Radial Velocity relative to the Midbody. See Figure 2 - supplement 2 for more information. ``` Scalers &gt;&gt;{'midbodyF_scaler': StandardScaler(), 'fracForward_scaler': StandardScaler(), 'midbodyAngspeed_scaler': StandardScaler(), 'headAngVelrelMid_scaler': StandardScaler(), 'headRadVelrelMid_scaler': StandardScaler()} ``` *** **Python Package Versions Used** ``` anyio==2.0.2 appnope==0.1.2 argon2-cffi==20.1.0 async-generator==1.10 attrs==20.3.0 autograd==1.3 Babel==2.9.0 backcall==0.2.0 bleach==3.2.2 build==0.7.0 certifi==2020.12.5 cffi==1.14.4 chardet==4.0.0 click==8.0.1 click-plugins==1.1.1 cligj==0.7.2 colorama==0.4.4 contourpy==1.0.6 cycler==0.10.0 Cython==0.29.21 decorator==4.4.2 defusedxml==0.6.0 docopt==0.6.2 docutils==0.18.1 entrypoints==0.3 Fiona==1.8.20 fonttools==4.38.0 future==0.18.2 geopandas==0.9.0 h5py==3.1.0 idna==2.10 imageio==2.9.0 imbalanced-learn==0.7.0 importlib-metadata==4.10.1 intersect==1.2 ipykernel==5.4.3 ipython==7.19.0 ipython-genutils==0.2.0 ipywidgets==7.6.3 jedi==0.17.2 Jinja2==2.11.2 joblib==1.0.0 json5==0.9.5 jsonschema==3.2.0 jupyter==1.0.0 jupyter-client==6.1.11 jupyter-console==6.2.0 jupyter-core==4.7.0 jupyter-server==1.2.2 jupyterlab==3.0.5 jupyterlab-pygments==0.1.2 jupyterlab-server==2.1.2 jupyterlab-widgets==1.0.0 keyring==23.5.0 kiwisolver==1.3.1 llvmlite==0.35.0 MarkupSafe==1.1.1 matplotlib==3.3.3 mistune==0.8.4 munch==2.5.0 nbclassic==0.2.6 nbclient==0.5.1 nbconvert==6.0.7 nbformat==5.1.2 nbstripout==0.5.0 nest-asyncio==1.4.3 networkx==2.5.1 notebook==6.2.0 numba==0.52.0 numpy==1.19.5 packaging==21.3 pandas==1.2.1 pandocfilters==1.4.3 parso==0.7.1 patsy==0.5.2 pep517==0.12.0 pexpect==4.8.0 pickleshare==0.7.5 Pillow==8.1.0 pipreqs==0.4.11 pkginfo==1.8.2 prometheus-client==0.9.0 prompt-toolkit==3.0.11 ptyprocess==0.7.0 pycparser==2.20 Pygments==2.7.4 pyparsing==2.4.7 pyproj==3.1.0 pyrsistent==0.17.3 python-dateutil==2.8.1 pytz==2020.5 PyWavelets==1.1.1 pyzmq==21.0.1 qtconsole==5.0.2 QtPy==1.9.0 readme-renderer==32.0 requests==2.25.1 requests-toolbelt==0.9.1 rfc3986==2.0.0 Rtree==0.9.7 scikit-image==0.18.1 scikit-learn==0.24.1 scikit-posthocs==0.6.7 scipy==1.8.0 seaborn==0.11.1 Send2Trash==1.5.0 Shapely==1.7.1 six==1.15.0 sniffio==1.2.0 -e git+https://github.com/slinderman/ssm.git@c69b696b6677d8cf17000496258c79a6c3b82d15#egg=ssm statannotations==0.5.0 statsmodels==0.13.2 terminado==0.9.2 testpath==0.4.4 threadpoolctl==2.1.0 tifffile==2021.4.8 tomli==2.0.0 tornado==6.1 tqdm==4.56.0 traitlets==5.0.5 twine==3.7.1 urllib3==1.26.2 wcwidth==0.2.5 webencodings==0.5.1 widgetsnbextension==3.5.1 yarg==0.1.9 zipp==3.7.0 ``` **Funding** These data were collected in the Bargmann Lab at Rockefeller University in New York City from 2018-2022. Funding was provided by HHMI and Chan Zuckerberg Science Initiative. Scheer was supported by an NIH F31 Predoctoral fellowship.