Skip to content

Commit

Permalink
Dev (#20)
Browse files Browse the repository at this point in the history
* plot update (ldict)

* plotting

* docs pkg

* docs, minor fix
  • Loading branch information
PharmCat authored Jul 8, 2024
1 parent 3f22de5 commit e076182
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 21 deletions.
3 changes: 2 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
name = "MetidaNCA"
uuid = "097c2839-c7bc-4c4b-a5f2-b4167c1b4e7c"
authors = ["PharmCat <[email protected]>"]
version = "0.5.9"
version = "0.5.10"



[deps]
Expand Down
4 changes: 2 additions & 2 deletions docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
Latexify = "23fbe1c1-3f47-55db-b15f-69d7ec21a316"

[compat]
Documenter = "≥0.25"
Documenter = "1"
MetidaNCA = "0.5"
CSV = "0.8, 0.9, 0.10"
DataFrames = "1"
PrettyTables = "1, 2"
Weave = "0.9, 0.10"
Plots = "1"
Latexify = "0.14, 0.15"
Latexify = "0.14, 0.15, 0.16"
10 changes: 10 additions & 0 deletions docs/src/details.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Details

## Using LimitRule

```julia
ll = LimitRule(;lloq = 0.1, btmax = 0.0, atmax = NaN, nan = NaN, rm = true)

```

It means that all values below `lloq` will be replaced by `btmax` before Tmax and replaced by `atmax` after Tmax; `NaN` values will be replaced by `nan`. If `rm` is `true`, all `NaN` values will be deleted.


## Calculation steps for PK NCA

### Step 1
Expand Down
3 changes: 3 additions & 0 deletions src/import.jl
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ keywords:
If time column have non-unique values - last pair time-concentration will be used.
See also: [`ElimRange`](@ref), [`DoseTime`](@ref), [`LimitRule`](@ref).
"""
function pkimport(data, time, conc, sort; kelauto = true, elimrange = ElimRange(), dosetime = nothing, limitrule::Union{Nothing, LimitRule} = nothing, warn = true, kwargs...)
if isa(sort, String) sort = [Symbol(sort)] end
Expand Down Expand Up @@ -181,6 +183,7 @@ end
kwargs...)
Import PK data from time vector `time` and concentration vector `conc`.
"""
function pkimport(time, conc; kelauto = true, elimrange = ElimRange(), dosetime = nothing, id = Dict{Symbol, Any}(), limitrule::Union{Nothing, LimitRule} = nothing, warn = true, kwargs...)
timevals_sp, concvals_sp = checkvalues(time, conc, warn = warn)
Expand Down
13 changes: 8 additions & 5 deletions src/nca.jl
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,8 @@ Import data and perform NCA analysis.
Syntax simillar to [`pkimport`](@ref)
Applicable `kwargs` see [`nca!`](@ref).
See also: [`ElimRange`](@ref), [`DoseTime`](@ref), [`LimitRule`](@ref).
"""
function nca(args...; type::Symbol = :bps, bl = 0, th = 0, kelauto = true, elimrange = ElimRange(), dosetime = DoseTime(), limitrule::Union{Nothing, LimitRule} = nothing, kwargs...)
if !(type in (:bps, :ur, :pd)) error("Unknown type") end
Expand All @@ -411,11 +413,12 @@ end
Non-compartmental (NCA) analysis of PK/PD data.
"""
function nca!(data::DataSet{Subj}; kwargs...) where Subj <: AbstractSubject
result = Vector{NCAResult{Subj}}(undef, length(data))
for i = 1:length(data)
result[i] = nca!(data[i]; kwargs...)
end
DataSet(result)
#result = Vector{NCAResult{Subj}}(undef, length(data))
#for i = 1:length(data)
# result[i] = nca!(data[i]; kwargs...)
#end
#DataSet(result)
map(x -> nca!(x; kwargs...), data)
end

"""
Expand Down
25 changes: 12 additions & 13 deletions src/plots.jl
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ function pkplot(data::DataSet{T};
filter::Union{Nothing, Dict{Symbol}} = nothing,
uylims::Bool = false,
ldict = nothing,
savepng = nothing,
kwargs...) where T <: AbstractSubject

kwargs = Dict{Symbol, Any}(kwargs)
Expand All @@ -414,6 +415,16 @@ function pkplot(data::DataSet{T};
end
if !isnothing(filter) data = subset(data, filter) end

if !isnothing(typesort)
if isa(typesort, Symbol) typesort = [typesort] end
typelist = uniqueidlist(data, typesort)
else
typelist = nothing
if !(:legend in k)
kwargs[:legend] = false
end
end

if isnothing(typesort) && isnothing(pagesort)
p = []
printtitle = false
Expand All @@ -430,19 +441,7 @@ function pkplot(data::DataSet{T};
push!(p, pkplot(subj; kwargs...))
end
return p
end

if !isnothing(typesort)
if isa(typesort, Symbol) typesort = [typesort] end
typelist = uniqueidlist(data, typesort)
else
typelist = nothing
if !(:legend in k)
kwargs[:legend] = false
end
end

if !isnothing(pagesort) && !isa(pagesort, NoPageSort)
elseif !isnothing(pagesort) && !isa(pagesort, NoPageSort)
if isa(pagesort, Symbol) pagesort = [pagesort] end
p = []
pagelist = uniqueidlist(data, pagesort)
Expand Down

2 comments on commit e076182

@PharmCat
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/110700

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.5.10 -m "<description of version>" e07618206358990d1f12e06b59aef44cac08795a
git push origin v0.5.10

Please sign in to comment.