Skip to content

Commit

Permalink
✨ summarise mangal networks
Browse files Browse the repository at this point in the history
  • Loading branch information
TanyaS08 committed Aug 2, 2024
1 parent a5006f6 commit c31d850
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 2 deletions.
48 changes: 46 additions & 2 deletions code/mangal/02_summarise_mangal_networks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,52 @@ using Mangal
using ProgressMeter
using SpeciesInteractionNetworks

include("../lib/internals.jl")
include("../../lib/internals.jl")

mangal_foodwebs = CSV.read("data/raw/mangal/mangal_foodwebs_metadata.csv", DataFrame)

N_mangal = network.(mangal_foodwebs.id)
N_mangal = network.(mangal_foodwebs.id)

# make a dataframe to store network data
mangal_topology = DataFrame(
id = Int64[],
richness = Int64[],
links = Int64[],
connectance = Float64[],
complexity = Float64[],
distance = Float64[],
basal = Float64[],
top = Float64[],
S1 = Float64[],
S2 = Float64[],
S4 = Float64[],
S5 = Float64[],
);

# get summary stats
for i in 1:nrow(mangal_foodwebs)

N = simplify(mangalnetwork(mangal_foodwebs.id[i]))
N = render(Binary, N) # make binary

d = _network_summary(N)

D = Dict{Symbol,Any}()
D[:id] = mangal_foodwebs.id[i]
D[:richness] = d[:richness]
D[:links] = d[:links]
D[:connectance] = d[:connectance]
D[:complexity] = d[:complexity]
D[:distance] = d[:distance]
D[:basal] = d[:basal]
D[:top] = d[:top]
D[:S1] = d[:S1]
D[:S2] = d[:S2]
D[:S4] = d[:S4]
D[:S5] = d[:S5]
push!(mangal_topology, D)

end

CSV.write("data/processed/mangal_summary.csv", mangal_topology)

41 changes: 41 additions & 0 deletions data/processed/mangal_summary.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
id,richness,links,connectance,complexity,distance,basal,top,S1,S2,S4,S5
3259,20,50,0.125,0.8952691016117368,1.0,3.0,6.0,55.0,0.0,112.0,69.0
947,19,58,0.16066481994459833,0.8973405201402957,1.0,2.0,3.0,68.0,23.0,99.0,106.0
1261,13,17,0.10059171597633136,0.9754799733756835,2.0,7.0,3.0,0.0,0.0,16.0,19.0
1237,45,211,0.10419753086419753,0.8508717987437875,3.0,20.0,4.0,257.0,50.0,474.0,803.0
1259,41,169,0.10053539559785842,0.8495639011192967,3.0,25.0,0.0,162.0,48.0,216.0,1070.0
1243,35,102,0.08326530612244898,0.9085390041201967,2.0,20.0,1.0,0.0,0.0,279.0,489.0
1231,22,58,0.11983471074380166,0.9236515708343849,3.0,11.0,0.0,0.0,0.0,42.0,51.0
1238,16,25,0.09765625,0.959386367912684,2.0,9.0,0.0,0.0,0.0,20.0,32.0
1258,22,36,0.0743801652892562,0.9571416823845703,2.0,13.0,9.0,0.0,0.0,100.0,90.0
1223,15,19,0.08444444444444445,0.9737794671730475,3.0,8.0,1.0,10.0,0.0,15.0,46.0
88,46,131,0.06190926275992439,0.9114758717264065,2.0,31.0,15.0,0.0,0.0,315.0,650.0
92,29,203,0.2413793103448276,0.8552680224502017,1.0,2.0,0.0,129.0,77.0,204.0,179.0
96,16,61,0.23828125,0.8192141835656614,3.0,5.0,2.0,20.0,114.0,28.0,103.0
98,14,23,0.11734693877551021,0.9326699618358462,2.0,3.0,2.0,24.0,10.0,3.0,23.0
99,9,15,0.18518518518518517,0.933383670300663,2.0,3.0,1.0,18.0,3.0,5.0,12.0
100,14,32,0.16326530612244897,0.9320796682832573,1.0,1.0,2.0,38.0,16.0,17.0,13.0
102,29,65,0.07728894173602854,0.9326980170089368,1.0,3.0,6.0,74.0,23.0,103.0,56.0
103,19,51,0.14127423822714683,0.9370589883175356,1.0,2.0,2.0,95.0,30.0,40.0,49.0
1280,14,79,0.4030612244897959,0.8039318284585195,2.0,3.0,2.0,37.0,50.0,16.0,28.0
2463,50,257,0.1028,0.838964507526264,2.0,26.0,0.0,154.0,17.0,848.0,965.0
2464,50,246,0.0984,0.835362191635649,2.0,28.0,1.0,0.0,30.0,872.0,1330.0
924,15,26,0.11555555555555555,0.95142121479341,1.0,3.0,2.0,27.0,0.0,29.0,26.0
1102,23,137,0.2589792060491493,0.8146920273767423,3.0,8.0,4.0,20.0,104.0,326.0,274.0
890,14,25,0.12755102040816327,0.9456683127352359,1.0,1.0,4.0,26.0,2.0,26.0,15.0
1115,26,66,0.09763313609467456,0.8954420591956201,1.0,10.0,5.0,112.0,16.0,89.0,125.0
1454,31,117,0.12174817898022892,0.8540189452645229,1.0,4.0,13.0,252.0,23.0,423.0,241.0
1456,47,150,0.06790402897238569,0.8841091482442536,4.0,9.0,11.0,216.0,7.0,493.0,425.0
1457,56,150,0.04783163265306122,0.9103225180989968,3.0,16.0,11.0,244.0,30.0,358.0,383.0
1455,17,33,0.11418685121107267,0.8921397015590888,2.0,4.0,7.0,43.0,9.0,44.0,30.0
1468,8,25,0.390625,0.8585457313262378,2.0,2.0,0.0,0.0,2.0,0.0,2.0
1469,6,7,0.19444444444444445,0.8685893832533697,3.0,3.0,2.0,2.0,0.0,3.0,6.0
1475,16,42,0.1640625,0.8742568157984866,3.0,5.0,1.0,18.0,12.0,79.0,92.0
1493,9,13,0.16049382716049382,0.961953230514878,3.0,1.0,2.0,7.0,2.0,10.0,7.0
1511,17,32,0.11072664359861592,0.9038429870617903,3.0,3.0,4.0,33.0,1.0,40.0,47.0
1518,20,79,0.1975,0.8478534575871511,2.0,7.0,2.0,74.0,132.0,58.0,154.0
1520,22,48,0.09917355371900827,0.9190599667145141,1.0,6.0,4.0,63.0,5.0,74.0,58.0
1591,7,8,0.16326530612244897,0.9870558585867127,3.0,1.0,2.0,4.0,0.0,6.0,2.0
1596,24,102,0.17708333333333334,0.8664029400721125,3.0,8.0,2.0,217.0,121.0,109.0,294.0
1678,24,72,0.125,0.852855816123145,2.0,16.0,8.0,0.0,0.0,143.0,309.0
1443,19,22,0.060941828254847646,0.8044492778471217,2.0,15.0,1.0,0.0,4.0,3.0,150.0

0 comments on commit c31d850

Please sign in to comment.