Skip to content
Kesem Abramov edited this page Feb 18, 2026 · 15 revisions

The code used to produce the results presented in the paper. All the code files are located in this repository under a folder with the same name.

How to run the code:

Open the R project file (softimpute.Rproj) in the main repository folder. This will automatically set the working directory so the scripts run properly. From there, you can run the relevant scripts to reproduce the results.

Scripts:

Abramov_et_al_spatial_prediction_analysis.R

Description

This script contains the main code producing the results in the paper. It contains:

  1. Island-scale prediction.
  2. Jaccard analysis
  3. Distance decay
  4. Correlations

Input

emln dataset no. 60: dataset of plant-pollinator interactions collected in the canary islands that was archived in the emln R package. used to build the layers of the network.

data/distance_between_sites_canary.csv: used to calculate correlations in the analysis. Taken from the paper that collected the data.

Output

results/predictions_island_scale.rds: The results of the link prediction. used for further analysis in the same scripts as well as in other scripts

Plots:
results/paper_figs/optimal_threshold.pdf: figure S8
results/paper_figs/predicted_original.pdf: figure S10
results/paper_figs/pr_roc.pdf: figure S9
results/paper_figs/hist_f1a_legend_bottom.pdf: figure 2b
results/paper_figs/netsize_f1_nnse.pdf: figure S13
netdensity_f1_nnse.pdf: figure S5
degree_unobserved_links.pdf: figure 3c
map_missing_links.pdf: figure 3a
map_missing_links_diags_offs.pdf: figure S11
pie_chart.pdf: figure 3b
island_heatmap_f1.pdf: figure 2c
degree_occurrence.pdf: figure S12
results/paper_figs/isl_jaccard_distance.pdf: figure 4 \


k_swap.R

Description

This script handles a sensitivity analysis to check the combined effect of different Ks and lambdas.

Input

results/predictions_island_scale.rds: The predictions found by Abramov_et_al_spatial_prediction_analysis.R script

Output

plot: boxplot to visualize f1s for each lambda and K tested. not saved in a new file.


site_scale_spatial_prediction_analysis.R

Description

This script contains the code for site scale analysis. It contains:

  1. Island-scale prediction.
  2. Jaccard analysis
  3. Distance decay
  4. ecological inference

Input

emln dataset no. 60: dataset of plant-pollinator interactions collected in the canary islands that was archived in the emln R package. used to build the layers of the network.

data/distance_between_sites_canary.csv: used to calculate correlations in the analysis. Taken from the paper that collected the data.

Output

results/predictions_site_scale.rds: The results of the link prediction, but this time, site scale.

Plots:
hist_f1_site.pdf: figure S3
site_netsize_f1_nnse.pdf: figure S6
site_netdensity_f1_nnse.pdf: figure S7
site_heatmap_f1.pdf: figure S2
jaccard_site_f1.pdf: figure S4
cor_plot_site_dif_f1.pdf: figure S5
nnse_f1_scales.pdf: figure S1 \


subset_analysis_comparison.R

Description

This script contains the code to compare prediction quality when using the entire species pools of A and P for prediction vs. prediction done based on subsetting only the species they share.

Input

emln dataset no. 60: dataset of plant-pollinator interactions collected in the canary islands that was archived in the emln R package. used to build the layers of the network.

Output

results/predictions_island_scale.rds: The results of the link prediction, on the island scale (only if it didn't exist already).

Plots:
subset_analysis.pdf: figure 2a,b


Clone this wiki locally