Skip to content
This repository has been archived by the owner on Oct 6, 2020. It is now read-only.

Tools for (relatively) quickly analyzing screen data collected with Trikinetics DAM system

License

Notifications You must be signed in to change notification settings

williamrowell/drosophila_activity_analysis

Repository files navigation

drosophila_activity_analysis

Authors: William Rowell rowellw@janelia.hhmi.org

The code processes and analyzes the DAM (Drosophila Activity Monitor) data and delivers sleep/activity plots as well as data in Excel-readable format. The code contains a collection of functions for reading Trikinetics DENM (Drosophila Environmental Monitor) and DAM (Drosophila Activity Monitor) data formats, aggregating by genotype, identifying dead flies, identifying sleep bouts, plotting, and saving the data. System-wide parameters and experimental parameters are encoded in two separate config-style ini files.

FILE TYPES

There are four basic input file types: config_file, key_file, DEnM file, and DAM file:

  • config_file is an ini file that contains global configuration values, like the numbers of known environmental monitors (DEnMs) and the highest known monitor number. An example, config.ini, is included.
  • key_file is an ini file that contains experiment configuration values, like control genotypes, lights-on times, and fly positions. An example, example_experiment.ini, is included.
  • DEnM and DAM files are as specified by Trikinetics DAM System User Manual, Version 3.0. (I have included the DAM System manual in the repo for reference.) The files should be named following the MonitorN.txt naming scheme, which should be the default.

USAGE

An example script for driving these functions to analyze an experiment is included, process_experiment.py.

usage: python process_experiment.py [config_file] key_file

        To process trikinetics experimental data, pass a config file (containing
        relatively constant parameters) and a key file (containing both parameters
        relevant to the specific experiment as well as the genotypes and
        monitor/channel positions of flies).  If only one argument is passed, the
        default configuration is used.

        When called, these files are parsed and the raw experimental data is
        processed/aggregated into two dictionaries:
        activity_dict - tables containing the raw beam crossing events, per minute
        sleep_dict    - tables where minutes of sleep are marked with a '1'
                    (sleep is defined as 5+ consecutive minutes of 0 activity)

        After the construction of these dictionaries, plots are produced for the
        experimental metadata as well as sleep and activity for each line vs all
        controls.  Other plot types are included in the plot.y module, but not
        implemented in this script.

        The activity and sleep dictionaries are written as xls files for later use.

MODULES

  1. file_io: tools for reading config_file, key_file, DEnM files, and DAM files, as well as writing the processed data as xls files.
  2. analyze: groups activity by genotype, marks dead flies, and calculates sleep as 5+ minutes with zero activity; resulting activity_dict and sleep_dict are dicts containing per-genotype dataframes of per-fly data.
  3. plot: plots DEnM metadata per day and activity/sleep data per genotype per day.

TODO

  • Transform time to ZT
    • Should be as easy as subtracting lights_on
  • Save per-fly data as xls
  • Calculate total sleep per day aggregated
  • Calculate OA mean beam counts per waking minute
  • For individual flies, calculate
    1. number of sleep bouts
    2. total sleep per L, D, total
    3. sleep bout length
  • Dynamically determine y limits for activity plots
  • Panel plots instead of multi-page plots

REQUIREMENTS

  • python 2.7
  • pandas
  • numpy
  • matplotlib

NOTES

  • On a PC, install Git with Git Bash from here. Not only will you use it to download the scripts, but you can use "Git Bash" from the context menu to open a terminal in your data folder to process the experiment.
  • If you're not particularly technically saavy, I recommend grabbing Anaconda python from here.
  • It helps to make an alias in your .bashrc or .bash_profile, something like: alias process_dam='/path/to/drosophila_activity_analysis/process_experiment.py'
  • In OS X, it may be useful to enable "New Terminal Here" so that you can open a terminal easily from Finder. Instructions can be found here: http://stackoverflow.com/questions/420456/open-terminal-here-in-mac-os-finder\

About

Tools for (relatively) quickly analyzing screen data collected with Trikinetics DAM system

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages