Skip to content

Commit

Permalink
Document Counts to Frequencies + Format
Browse files Browse the repository at this point in the history
  • Loading branch information
diegozea committed Jul 1, 2024
1 parent 9581fae commit 1779e58
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 11 deletions.
13 changes: 8 additions & 5 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

### Changes from v2.21.0 to dev

* *[Breaking change]* The `mapcolpairfreq!` and `mapseqpairfreq!` functions now uses the
boolean `usediagonal` keyword argument to indicate if the function should be applied to
the diagonal elements of the matrix (the default is `true`). Before, this was done passing
`Val{true}` or `Val{false}` as the last positional argument.
* *[Breaking change]* The `Information` module deprecates the `Counts` type in favor of
the new `Frequencies` type. The new type as the same signature and behavior as the old one.

* *[Breaking change]* The `count` function on sequences has been deprecated in favor of the
`frequencies` function, which has the same signature and behavior as the old one.
Expand Down Expand Up @@ -40,8 +38,13 @@
accept arrays of `Residue`s of any dimension. Therefore, there is no need to use the
`vec` function to convert the arrays to vectors.

* *[Breaking change]* The `mapcolpairfreq!` and `mapseqpairfreq!` functions now uses the
boolean `usediagonal` keyword argument to indicate if the function should be applied to
the diagonal elements of the matrix (the default is `true`). Before, this was done passing
`Val{true}` or `Val{false}` as the last positional argument.

* The `mapcolfreq!`, `mapseqfreq!`, `mapcolpairfreq!`, and `mapseqpairfreq!` methods using
keyword arguments, now pass the extra keyword arguments to mapped function.
keyword arguments, now pass the extra keyword arguments to the mapped function.

* The `Information` module now exports the `mapfreq` function that offers a more high-level
interface to the `mapcolfreq!`, `mapseqfreq!`, `mapcolpairfreq!`, and `mapseqpairfreq!`
Expand Down
6 changes: 5 additions & 1 deletion src/Information/ContingencyTables.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ mutable struct Counts{T,N,A} <: AbstractArray{T,N}
table::ContingencyTable{T,N,A}
end
function Counts{T,N,A}(table::ContingencyTable{T,N,A}) where {T,N,A}
Base.depwarn("The `Counts` type is deprecated. Please use `Frequencies` instead.", :Counts, force=true)
Base.depwarn(
"The `Counts` type is deprecated. Please use `Frequencies` instead.",
:Counts,
force = true,
)
Frequencies{T,N,A}(table)
end

Expand Down
22 changes: 17 additions & 5 deletions src/Information/InformationMeasures.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ function shannon_entropy(table::Frequencies{T,N,A}; base::Number = ℯ) where {T
end
end

function StatsBase.entropy(table::Union{Frequencies{T,N,A},Probabilities{T,N,A}}) where {T,N,A}
function StatsBase.entropy(
table::Union{Frequencies{T,N,A},Probabilities{T,N,A}},
) where {T,N,A}
Base.depwarn(
"entropy(table::Union{Frequencies,Probabilities}) is deprecated. Use shannon_entropy(table) instead.",
:entropy,
Expand Down Expand Up @@ -495,8 +497,18 @@ alignment using the [`mapfreq`](@ref) function—all the keyword arguments are p
`mapfreq`. $_DOC_NMI By default, it uses counts/frequencies to estimate the nMI, as it's
faster than using probabilities.
"""
function normalized_mutual_information(msa::AbstractArray{Residue}; rank::Int=2, probabilities::Bool=false,
kargs...)
function normalized_mutual_information(
msa::AbstractArray{Residue};
rank::Int = 2,
probabilities::Bool = false,
kargs...,
)
@assert rank > 1 "rank must be greater than 1 for normalized_mutual_information"
mapfreq(normalized_mutual_information, msa, rank=rank, probabilities=probabilities, kargs...)
end
mapfreq(
normalized_mutual_information,
msa,
rank = rank,
probabilities = probabilities,
kargs...,
)
end

0 comments on commit 1779e58

Please sign in to comment.