Combine and Compare Population Activity Data¶
This tool uses 1.0 compute credits per hour.
Overview¶
This tool combines population activity metrics (trace activity and optionally event rates) from multiple recordings, potentially across two experimental groups. It performs statistical comparisons to identify differences between defined behavioral states and, if applicable, between the two groups.
The tool employs a comprehensive multi-level statistical approach:
- Cell-Level Analysis: Uses Linear Mixed Models (LMM) to analyze individual cell activity or event rates, accounting for repeated measures within subjects. This approach compares activity across different behavioral states and assesses interactions between state and group effects.
- Subject-Level Modulation Analysis: Performs ANOVA (Repeated Measures or Mixed, depending on experimental design) on the number of significantly modulated cells per subject per state. This compares overall neural modulation patterns across states and groups.
- Subject-Level Activity Analysis: Calculates average activity or event rate per subject for each state, then performs ANOVA to compare overall neural activity levels between experimental conditions.
Key features include:
- Support for single-group or two-group experimental designs
- Paired (within-subject treatment) or unpaired (independent groups) experimental designs with flexible subject matching options
- Separate analyses for average trace activity and event rate (event rate files are optional)
- Multiple comparison correction methods and effect size calculations
- Universal State Comparison Compatibility: Works with all state comparison types from the upstream Compare Neural Activity Across States tool, including baseline comparisons, state-vs-not-state, and pairwise comparisons
Parameters¶
Parameter | Required? | Default | Description |
---|---|---|---|
Group 1 Population Activity Files | True | N/A | Select population activity data from the first group to use for analysis |
Group 1 Population Event Rate Files | False | N/A | Select population event rate data from the first group to use for analysis |
Group 1 Name | False | group1 | Name of the first group |
Group 1 Color | False | tab:red | Color for the first group |
Group 2 Population Activity Files | False | N/A | Select population activity data from the second group to use for analysis |
Group 2 Population Event Rate Files | False | N/A | Select population event rate data from the second group to use for analysis |
Group 2 Name | False | N/A | Name of the second group |
Group 2 Color | False | N/A | Color for the second group |
State Names | True | N/A | Names of the state comparisons in the columns of the input files |
State Colors | False | N/A | Colors for the state comparisons |
Modulation Colors | False | N/A | Colors that represent up- and down-modulation respectively |
Significance Threshold | True | 0.05 | p-value threshold |
Multiple Comparison Correction | True | N/A | Method for correcting for multiple comparisons |
Effect Size Method | True | N/A | Method for calculating the effect size |
Data Pairing | False | unpaired | Indicates whether observations should be paired for statistical comparison. |
Subject Matching Method | False | order | Method for matching subjects between groups in paired analysis |
Method to Compare States | False | auto | Method for comparing states. 'Auto-detect' will automatically determine the method from the data. 'State vs Not State' and 'State vs Not Defined' both work with standard state comparison analysis. 'State vs Baseline' compares each state to a baseline state. 'Pairwise' compares states directly to each other. |
Input Files¶
The inputs to this tool are population activity metric files generated by the Compare Neural Activity Across States tool. Event rate files are optional but must be provided for both groups if used in a two-group comparison.
Source Parameter | File Type | File Format |
---|---|---|
Group 1 Population Activity Files | modulation_data | csv |
Group 1 Population Event Rate Files | modulation_data | csv |
Group 2 Population Activity Files | modulation_data | csv |
Group 2 Population Event Rate Files | modulation_data | csv |
The input files have the following requirements:
- Each group must contain at least two recording files (subjects) for meaningful statistical analysis
- All input files must contain data for the same set of states with identical state names
- State Comparison Compatibility: This tool is compatible with all state comparison methods from the upstream tool:
- Baseline Comparisons: Each state compared to a specified baseline state
- State vs Not-State: Each state compared to all time points not in that state
- State vs Not-Defined: Each state compared to time points not belonging to any defined state
- Pairwise Comparisons: Direct state-to-state comparisons (e.g., state1 vs state2) are supported and handled appropriately in the analysis pipeline
- If
Data Pairing
is set to "paired" for two-group comparisons:- Both groups must have the same number of recording files
- Files are matched between groups using the
Subject Matching Method
parameter
- Event files, if provided, must correspond to the activity files in number and naming
- Consistency Requirements: All input files must be generated with consistent parameters in the upstream tool:
- Same state comparison method across all files
- Same scaling method for trace activity and event rate data
- Same state definitions and column naming
- Same statistical parameters (recommended for comparable results)
Algorithm Description¶
The workflow combines data from multiple recordings, performs multi-level statistical analyses, and generates comprehensive outputs with visualizations.
Linear Mixed Models]; M --> F[Subject Level Modulation Analysis
ANOVA on Cell Counts]; M --> G[Subject Level Activity Analysis
ANOVA on Mean Values]; E --> H[Statistical Comparisons
& Effect Sizes]; F --> H; G --> H; H --> I[Generate Outputs
& Visualizations];
The tool executes the following key steps:
- Data Integration: Combines files within each group, adds subject identifiers, and ensures consistent significance thresholds across recordings
- Multi-Level Statistical Analysis:
- Cell-level: Linear Mixed Models account for hierarchical data structure (cells nested within subjects)
- Subject-level: ANOVA on modulation counts and subject-averaged activity measures
- Post-hoc Testing: Pairwise comparisons with multiple comparison correction and effect size calculations
Statistical Methods¶
Linear Mixed Model (LMM)¶
Used for cell-level analysis of activity and event rates. LMMs handle hierarchical data (cells nested within subjects) and repeated measures (multiple states per subject). The models include fixed effects for experimental factors while accounting for random subject-to-subject variability.
Analysis of Variance (ANOVA)¶
Used for subject-level comparisons of modulation counts and averaged measures:
- Repeated Measures ANOVA: For within-subject comparisons (single group) or paired group designs
- Mixed ANOVA: For between-subject comparisons (unpaired group designs)
Post-hoc Pairwise Testing¶
Following significant omnibus tests, pairwise comparisons identify specific group or state differences:
- Multiple comparison correction: User-selectable methods to control error rates
- Effect size calculation: Standardized measures of practical significance
Modulation Analysis Table¶
The following table summarizes the statistical approaches used for subject-level modulation analysis based on experimental design:
Case | Number of Groups | Data Pairing | Number of States | Comparison Type | Statistical Test | Example Situation |
---|---|---|---|---|---|---|
Single Group | 1 | N/A | multiple | pairwise | descriptive statistics only | Single group of mice analyzed across locomotion states (mobile, immobile, grooming) |
state vs baseline | one-way ANOVA | Single group comparing sleep states (REM, NREM) against wake baseline | ||||
state vs not state | Single group comparing reward-seeking vs non-reward-seeking periods | |||||
Multiple Paired Groups | 2 | paired | multiple | pairwise | paired t-tests | Same animals recorded before/after drug treatment across multiple behavioral states |
state vs baseline | repeated measures ANOVA | Within-subject drug vs vehicle comparison across states relative to baseline | ||||
state vs not state | Same animals in different contexts comparing state-specific vs general activity | |||||
Multiple Unpaired Groups | 2 | unpaired | multiple | pairwise | unpaired t-tests | Separate cohorts of control vs knockout mice across behavioral states |
state vs baseline | mixed ANOVA | Independent groups (e.g., male vs female) comparing states to baseline | ||||
state vs not state | Different treatment groups comparing task-specific vs general activity | |||||
Special Cases | 2 | paired | single | group comparison | paired t-tests | Same animals comparing one specific state (e.g., freezing) before/after treatment |
unpaired | unpaired t-tests | Independent groups comparing one behavioral state (e.g., control vs lesioned during exploration) |
Outputs¶
Combined Group Data¶
Group Data Files¶
Combined data from all recordings within each group, saved as CSV files named by group.
Example Combined Data:
Name | modulation scores in mobile | p-values in mobile | modulation in mobile | mean activity in mobile | modulation scores in immobile | p-values in immobile | modulation in immobile | mean activity in immobile | file | Comparison | subject_id | total_cell_count |
---|---|---|---|---|---|---|---|---|---|---|---|---|
Cell_1 | 0.1847 | 0.0234 | 1 | 0.0923 | -0.0623 | 0.3456 | 0 | 0.0756 | mouse_01.csv | trace_activity | subject_1 | 156 |
Cell_2 | -0.2156 | 0.0089 | -1 | 0.0834 | 0.1789 | 0.0456 | 1 | 0.0891 | mouse_01.csv | trace_activity | subject_1 | 156 |
Cell_3 | 0.0456 | 0.4567 | 0 | 0.0678 | -0.0234 | 0.7890 | 0 | 0.0623 | mouse_01.csv | trace_activity | subject_1 | 156 |
Cell_1 | 0.2134 | 0.0123 | 1 | 0.0945 | -0.0891 | 0.2345 | 0 | 0.0712 | mouse_02.csv | trace_activity | subject_2 | 142 |
Group Data Visualizations¶
-
Modulation Distribution: Proportion of cells showing increased, decreased, or unchanged activity for each state
Modulation distribution showing proportion of cells with increased, decreased, or unchanged activity across behavioral states -
Mean Activity/Event Rate: Distribution of average neural measures across experimental states
Combined group data showing mean activity and event rate distributions across experimental states
Statistical Comparison Results¶
ANOVA/LMM Results¶
Comprehensive statistical test results from all analysis levels, saved as a CSV file.
Example Output:
Source | p_value | F_statistic | df1 | df2 | stat_method | Measure | Comparison | analysis_level | coefficient | std_error | t_value | significance_threshold | multiple_correction | data_pairing |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
group | 0.738 | 0.147 | 1 | 2 | mixed_anova | activity | trace_activity | subject | - | - | - | 0.05 | bonf | unpaired |
state | 0.722 | 0.458 | 3 | 6 | mixed_anova | activity | trace_activity | subject | - | - | - | 0.05 | bonf | unpaired |
Interaction | 0.331 | 1.399 | 3 | 6 | mixed_anova | activity | trace_activity | subject | - | - | - | 0.05 | bonf | unpaired |
Intercept | - | - | 1 | 2 | lmm | activity | trace_activity | subject | 0.258 | - | - | 0.05 | bonf | unpaired |
state[T.quad 1] | 0.296 | - | 1 | 2 | lmm | activity | trace_activity | subject | -0.621 | 0.594 | -1.045 | 0.05 | bonf | unpaired |
group[T.Vehicle] | - | - | 1 | 2 | lmm | activity | trace_activity | subject | 0.160 | - | - | 0.05 | bonf | unpaired |
Pairwise Comparison Results¶
Detailed results from post-hoc pairwise tests following significant omnibus tests, saved as a CSV file.
Example Output:
A | B | Contrast | state | T | p-unc | p-corr | effect_size | stat_method | Measure | Comparison | analysis_level | state_pairing | group_pairing | significance_threshold | multiple_correction | data_pairing |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
center | quad 1 | state | - | 0.009 | 0.994 | 1.0 | 0.004 | paired_ttest | activity | trace_activity | subject | paired | unpaired | 0.05 | bonf | unpaired |
quad 2 | quad 4 | state | - | 3.400 | 0.042 | 0.255 | 1.700 | paired_ttest | activity | trace_activity | subject | paired | unpaired | 0.05 | bonf | unpaired |
Drug | Vehicle | group | across_states | -0.384 | 0.738 | - | -0.192 | unpaired_ttest | activity | trace_activity | subject | not_applicable | unpaired | 0.05 | bonf | unpaired |
Drug | Vehicle | state * group | center | 0.659 | 0.578 | 1.0 | 0.329 | unpaired_ttest | activity | trace_activity | subject | paired | unpaired | 0.05 | bonf | unpaired |
center | quad 1 | center vs quad 1 | - | -1.414 | 0.293 | - | 1.414 | unpaired_ttest | up_modulation | trace_activity | subject | not_applicable | unpaired | 0.05 | bonf | unpaired |
Statistical Comparison Visualizations¶
-
Cell-Level State Analysis: Violin plots showing activity/event rate distributions across states, with statistical significance indicators
Cell-level state comparison using Linear Mixed Models -
Subject-Level Group Analysis: Scatter plots with subject-averaged measures, showing group differences across states with connecting lines for paired analyses
Subject-level group comparison for activity measures Subject-level group comparison for event rate measures -
Modulation Pattern Analysis: Proportion of modulated cells per subject across states and groups
Modulation pattern comparison across groups and states