Skip to content

Commit

Permalink
refactor: rm ported code
Browse files Browse the repository at this point in the history
  • Loading branch information
tpoisot committed Jun 28, 2023
1 parent 8b3f840 commit 3997281
Showing 1 changed file with 0 additions and 38 deletions.
38 changes: 0 additions & 38 deletions _OLD/rand/linfilter.jl
Original file line number Diff line number Diff line change
@@ -1,41 +1,3 @@
"""
linearfilter(N::BinaryNetwork, α::Vector{Float64}=[0.25, 0.25, 0.25, 0.25])
Given a network `N` compute the linear filter scores according to Stock et al.
(2017). High scores for negative interactions indicate potential false negative
or missing interactions. Though this it returned as a probabilistic network,
score do not necessary convey a probabilistic interpretation.
The values of α give the *relative* weight of, in order, the measured
interaction value, the out-degree of the species, the in-degree of the species,
and of network connectance. The default parameterization is to have all four at
equal importance.
#### References
Stock, M., Pahikkala, T., Airola, A., Waegeman, W., Baets, B.D., 2018. Algebraic
Shortcuts for Leave-One-Out Cross-Validation in Supervised Network Inference.
bioRxiv 242321. https://doi.org/10.1101/242321
Stock, M., Poisot, T., Waegeman, W., Baets, B.D., 2017. Linear filtering reveals
false negatives in species interaction data. Scientific Reports 7, 45908.
https://doi.org/10.1038/srep45908
"""
function linearfilter(N::T; α::Vector{Float64}=fill(1.0, 4)) where {T <: BinaryNetwork}
@assert length(α) == 4
@assert all.≥ 0.0)
α = α ./ sum(α) # This ensures that α sums to 1.0

# Get the new weights
W = α[1]N.edges .+ α[2]mean(N.edges; dims=2) .+ α[3]mean(N.edges; dims=1) .+ α[4]mean(N.edges)

# Prepare a return object
return_type = T <: AbstractBipartiteNetwork ? BipartiteProbabilisticNetwork : UnipartiteProbabilisticNetwork
F = return_type(W, EcologicalNetworks._species_objects(N)...)

return F
end

"""
linearfilterzoo(N::BinaryNetwork, α::Vector{Float64}=[0.25, 0.25, 0.25, 0.25])
Expand Down

0 comments on commit 3997281

Please sign in to comment.