This repository contains scripts, data, and outputs related to the paper. Below there is
- a description of the repository contents
- a description of how to generate the figures
-
ClusterSizeTreelikeness.py
Code for analyzing clusters and generating outputs related to size and treelikeness for real data. -
ClusterSizeTreelikenessNulls.py
Code for analyzing null reshufflings of cluster sizes and treelikeness. -
FixedReshuffling.py
Code for generating fixed reshufflings for null model analysis. -
KSCalculations.py
Code for computing Kolmogorov-Smirnov (KS) statistics between real and null datasets. -
Fig2C.py
Code for generating Fig 2C: Scatter plots comparing KS Size and KS Treelikeness. -
Fig2D.py
Code for generating Fig 2D: Ranked lists for species based on KS values and value of Kendall's Tau. -
TableS1.py
Code for generating TableS1: lists for species and their KS values (with p-values). -
Fig3C.py
Code for generating Fig3C and outputs relevant for FigS3. -
Fig3D.py
Code for generating Fig3D and outputs relevant for FigS3. -
DeltaAnd123Flips.py
Code for generating outputs relevant for FigS3. -
FigS3.py
Code for generating FigS3. -
Fig4B-4C.r
Code for generating Fig4B-4C. -
Fig4D.py
Code for generating Fig4D. -
FigS3.py
Code for generating FigS3. -
FigS6.ipynb / .py
Code for generating FigS6. -
RelabelAttacked.py
Code for generating outputs relevant for Fig4B-C, FigS6 and TableS2. -
ResilienceCalculations.py
Code for generating outputs relevant for Fig4B-D, FigS6 and TableS2. -
RNDAndEGMAttacks.py
Code for generating outputs relevant for Fig4B-C, FigS6 and TableS2. -
TableS2.py
Code for generating TableS2.
This folder contains files for Fig3C and Fig3D.
This folder will contain all the .pdf figures that can be generated from the .py scripts.
This folder contains all the keynote files (and exported .pdf files) that can be used to reconstruct more complex figures (i.e. figures that cannot be produced by only running python scripts).
This folder contains subfolders for MFPT data analysis:
-
Nulls_MFPT
Will contain Null_Fixed.zip with MFPT calculatons for null models.
-
Real_MFPT
Contains MFPT files for real nets.
This folder contains the outputs of the main analysis scripts:
-
ClusterSizeTreelikeness
Results of cluster size and treelikeness analyses for real datasets.
File format:{species}_{colour}_clustersize.txtor{species}_{colour}_treel.txt -
ClusterSizeTreelikenessNulls
Results of cluster size and treelikeness analyses for null datasets.
File format:{species}_{colour}_null{number}_clustersize.txtor{species}_{colour}_null{number}_treel.txt -
KSStatistics
Results of KS cluster size and treelikeness calculations.
Collection of fixed reshufflings for null models.
File format: {species}_null{number}.txt
Nets and nodeid-colour .txt files for each species.
Files format:
{species}_net_relabel.txtis the edges list .txt file. First node is called '0', second node is called '1', and so on.{species}_colour_relabel.txtis the nodeid-colour .txt file with no grey nodes (missing nodes are not included).{species}_colour_relabel_p.txtis the nodeid-colour .txt file with added grey nodes (missing nodes are now included and assigned colour '0'). Green is colour '1', blue is colour '2'.
- Run FixedReshuffling.py
- Check that the null models has been created in plants_nulls
- Run ClusterSizeTreelikeness.py
- Check that the ClusterSizeTreelikeness.zip folder has been created in outputs/ClusterSizeTreelikeness
- Run ClusterSizeTreelikenessNulls.py
- Check that the ClusterSizeTreelikenessNulls.zip folder has been created in outputs/ClusterSizeTreelikenessNulls
- Run KSCalculations.py
- Check that the KSStatistics folder has ben populated with KS_Size.csv and KS_Treel.csv
- Run Fig2C.py
- Check that the Fig2C.pdf has ben generated in generatedfigures
- Run Fig2D.py
- Check that the Fig2D.pdf has ben generated in generatedfigures
- Save the Kendall's Tau shown in the terminal
- Use .pdf and keynote in keynote folder to create Fig2D by mixing Fig2D.pdf, Kendall's Tau value and other components.
-
Follow steps 1-5 of Fig2C-Fig2D.
- Run TableS1.py
- Check that the TableS1.pdf has ben generated in generatedfigures
- Run Fig3C.py
- Check that Fig3C.pdf has ben generated in generatedfigures
- Run Fig3D.py
- Check that, for each species, the script has stored a taualfabeta matrix .txt file in ./outputs/TauAlfaBetaMatrices called
{species}_talfabeta_normalised.txt. - Check that Fig3D.pdf has ben generated in generatedfigures.
-
Follow steps for Fig3C and Fig3D.
- Run DeltaAnd123Flips.py
- Check that
Phylogenetic_originaldistancematrix.txtandMFPT_originaldistancematrix.txthas been generated in ./outputs/DeltaAndFlips/QuadrupleFlip/ - Store the value of Delta (printed on the terminal).
- Check that
{flip}_Phylogenetic_deltadistances.txtand{flip}_MFPT_deltadistances.txthas been generated in ./outputs/DeltaAndFlips/ for 1flip, 2flip and 3flip.
- Transfer QuadrupleFlip folder to an HPC
- Launch PHY_flip.sh
- Check that outputs for Phylogenetic have been generated in QuadrupleFlip/data folder
- Launch MFPT_flip.sh
- Check that outputs for MFPT have been generated in QuadrupleFlip/data folder
- Launch merge_flip_PHY.sh
- Check that
4flip_Phylogenetic_deltadistances.txthas been generated in QuadrupleFlip folder - Launch merge_flip_MFPT.sh
- Check that
4flip_MFPT_deltadistances.txthas been generated in QuadrupleFlip folder - Download QuadrupleFlip into ./outputs/DeltaAndFlips/
- Run FigS3.py
- Check that FigS3.pdf has been generated in generated figures.
- Run RGMAndEGMAttacks.py
- Check that the script has stored 100 RND (and 100 EGM) .txt files for each percentage in ./outputs/Attacks/RND/ (and ./outputs/Attacks/EGM/) called
{species_name}_net_rndatt_p{perc}_{count}.txt(and{species_name}_net_egmatt_p{perc}_{count}.txt).
- Run RelabelAttacked.py
- Check that the script has stored 100 RND (and 100 EGM) .txt files for each percentages in ./outputs/Attacks/{att_u}/{species_name}/Relabel/ called
{species_name}_net_{att}att_p{p}_{r}_r.txt - Check that the script has stored 100 RND (and 100 EGM) .txt files for each percentages in ./outputs/Attacks/{att_u}/{species_name}/Relabel/ called
{species_name}_colours_{att}att_p{p}_{r}_r.txt
- Run ResilienceCalculations.py
- Check that the following files has been created:
{species}_talfabeta.txtin ./outputs/TauAlfaBetaAttacked/Real/ (for each species);{species}_{attack.lower()}worm_p{perc}_talfabeta.txtin ./outputs/TauAlfaBetaAttacked/Attacked/ (for each species, attack, percentage);{species}_{attack.lower()}_resilience.txtin ./outputs/Resilience/ (for each species, attack);alluvial_data.csvin ./outputs/Resilience/;species_colors.txtin ./outputs/Resilience/.
- Run Fig4B-4C.r
- Check that Fig4B-4C.pdf has been generated in ./generatedfigures folder.
- Follow steps 1-5 for Fig4B-C
- Follow steps 1-5 for Fig2C-Fig2D
- Run Fig4D.py
- Check that the Fig4D.pdf has ben generated in generatedfigures
- Save the Kendall's Taus shown in the terminal
- Use .pdf and keynote in keynote folder to create Fig4D by mixing Fig4D.pdf, Kendall's Tau value and other components.
- Follow steps 1-5 for Fig4B-C
- Run FigS6.py
- Check that FigS6.pdf has been generated in generatedfigures folder.
- Follow steps 1-5 for Fig4B-C
- Follow steps 1-5 for Fig2C-Fig2D
- Run TableS2.py
- Check that TableS2_part1.pdf, TableS2_part2.pdf and TableS2_part3.pdf has been generated in generatedfigures folder
- Merge together TableS2_part1.pdf, TableS2_part2.pdf and TableS2_part3.pdf to get TableS2 figure