MGE2 Molecular Ecology Analysis Code
====================================

Overview
--------
This repository contains the complete code used to analyze data from the Multigeneration Experiment 2 (MGE2) described in Röder et al. (2026). The scripts reproduce all statistical analyses, data processing steps, and figure generation reported in the publication.

All intermediate and processed data required to reproduce the analyses are either included here, available online (see Data Availability), or generated by the provided scripts.


Repository Structure
--------------------

Complete_Script/
    Contains the full analysis pipeline organized into sequential scripts for:
    - data preprocessing
    - quality control
    - statistical analyses
    - visualization

cvtk/
    Empty folder for organization.
    Place the following files here:
    - riparius_NR.ipynb (Jupyter notebook)
    - riparius_design.csv (experimental design)

R_scripts/
    Empty folder for organization.
    Place all 11 R scripts used for statistical analyses and figure generation here.

README.txt
    This file.

my_adapter_NR.fa
    Contains sequencing adapter sequences according to the sequencing company’s report.

to_sync.py
    Custom Python script included in this repository used to convert
    filtered variants into the synchronized (.sync) format required for
    downstream analyses with PoPoolation2.


Data Availability
-----------------

Raw sequencing data are archived at the National Center for Biotechnology Information (NCBI) under BioProject accession number: PRJNA1282899

These data should be downloaded into an empty folder: raw_data/

The dataset contains 40 sequencing files. MD5 checksums should be verified after download.

The reference genome for Chironomus riparius used in this study is available from NCBI under BioProject: PRJEB47883

The genome files should be downloaded into an empty folder: genome/


Reproducibility
---------------

All analyses were conducted on a Linux system using bash shell scripting and R Studio.

The following software versions were used:

Python v3.10.12  
FastQC v0.11.9  
MultiQC v1.33  
Trimmomatic v0.40  
Samtools v1.13  
BWA v0.7.19  
Samblaster v0.1.26  
GNU coreutils v8.32  
VarScan2 v2.4.2  
Popoolation v1.2.3  
Popoolation2 v1.201    
InterProScan v5.71-102.0  


Figures in the Publication
--------------------------

Figures in the main text were generated using the following scripts:

Figure 1
    plots_NR.R

Figure 2
    af_change_fish_NR.R

Figure 3
    plots_NR.R

Figure 4
    plots_NR.R

Figure 5
    Revigo_BP_Scatterplot_NR


Citation
--------

Röder N, Kolbenschlag S, Pietz S, Brennan RS, Bundschuh M, Pfenninger M, Schwenk K (2026)
Pollution-Driven Selection in a Non-biting Midge: Genome-Wide Responses to Bacillus thuringiensis israelensis and Copper. Molecular Ecology. DOI: 10.1111/mec.70263.


Contact
-------

For questions regarding the code or data, please contact:
Nina Röder, ORCID 0000-0002-9681-7538, nina-roeder@posteo.de
