Skip to content

Commit

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

* plotting

* docs pkg

* docs, minor fix

* docs

* show ds

* show res ds

* save plots

* version bump

* update

* update

* update

* docs, plot output

* fix plots

* export, fix docs

* fix plots

* breaking changes in plots output

* fix docs

* pd tau

* plot dose time

* tests

* minor changes
  • Loading branch information
PharmCat authored Nov 13, 2024
1 parent e380d47 commit 7e2f843
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/MetidaNCA.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ PKSubject, UPKSubject, PDSubject, NCAResult
function __init__()
@require Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" begin
savefig = Plots.savefig
current = Plots.current
end
end

Expand Down
7 changes: 7 additions & 0 deletions src/nca.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1100,7 +1100,14 @@ function nca!(data::PDSubject{T,O}; calcm = :lint, intpm = nothing, verbose = 0,
################################################################################
result[:Obsnum] = obsnum = length(obs_cp)

result[:BL] = data.bl

result[:TH] = data.th


result[:Rmax], result[:Tmax], tmaxn = ctmax(time_cp, obs_cp, length(obs_cp))



# ALL NAN AND MISSING VALUES LINEAR INTERPOLATED
step_2_interpolate!(time_cp, obs_cp, einds, 1, :lint)
Expand Down
6 changes: 3 additions & 3 deletions src/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ function Base.show(io::IO, obj::PDSubject)
PrettyTables.pretty_table(io, metida_table(obj.time, obj.obs; names = (:Time, :Observation)); tf = PrettyTables.tf_compact)
end

function subject_type_str(subj::Type{<:PKSubject})
function subject_type_str(subj::Type{PKS}) where PKS <: PKSubject
"Pharmacokinetics subject"
end
function subject_type_str(subj::Type{<:UPKSubject})
function subject_type_str(subj::Type{UPKS}) where UPKS <: UPKSubject
"Pharmacokinetics subject (urine)"
end
function subject_type_str(subj::Type{<:PDSubject})
function subject_type_str(subj::Type{PDS}) where PDS <: PDSubject
"Pharmacodynamics subject"
end
function Base.show(io::IO, obj::DataSet{ST}) where ST <: AbstractSubject
Expand Down
3 changes: 3 additions & 0 deletions test/pdtest.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

@test_nowarn MetidaNCA.pkplot(pd)
@test_nowarn MetidaNCA.pkplot(pd[1], drawth = true, drawbl = true)
p = plot()
@test_nowarn MetidaNCA.pkplot!(pd[1], drawth = true, drawbl = true)


pd_res = MetidaNCA.nca!(pd[1])
pd_rds = MetidaNCA.nca!(pd)
Expand Down
17 changes: 17 additions & 0 deletions test/tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ include("refdicts.jl")
# If typesort defined and NoPageSort() return one plot
pl = @test_nowarn MetidaNCA.pkplot(ds; typesort = :Subject, pagesort = MetidaNCA.NoPageSort(), sort = Dict(:Formulation => "R"))
@test isa(pl, Plots.Plot) == true
#@test_throws "There is no pkplot! methods for DataSet, use pkplot or pkplot! for each subject separately." MetidaNCA.pkplot!(ds; typesort = :Subject, pagesort = MetidaNCA.NoPageSort(), sort = Dict(:Formulation => "R"))


pl = @test_nowarn MetidaNCA.pkplot(ds; typesort = :Formulation, pagesort = MetidaNCA.NoPageSort(), legend = true)
@test isa(pl, Plots.Plot) == true

Expand Down Expand Up @@ -107,12 +110,26 @@ include("refdicts.jl")
@test isa(pl, Plots.Plot) == true

# Return plot for PKSubject

@test_nowarn MetidaNCA.pkplot(ds[1].time, ds[1].obs)
@test_nowarn MetidaNCA.pkplot!(ds[1].time, ds[1].obs)
p = plot()
@test_nowarn MetidaNCA.pkplot!(p, ds[1].time, ds[1].obs)
p = plot()
@test_nowarn MetidaNCA.pkplot!(ds[1])
#p = plot()
#@test_nowarn MetidaNCA.pkplot!(ds[1])

@test_nowarn pl = MetidaNCA.pkplot(ds[1]; ylims = (0, 250), yscale = :log10, legend = false)
@test_nowarn pl = MetidaNCA.pkplot(ds[1]; elim = true, ls = false)
@test_nowarn MetidaNCA.plotstyle(40)
pl = MetidaNCA.pkplot(ds[3])
pl = MetidaNCA.pkplot!(ds[2]; yscale = :log10)

p = plot()
MetidaNCA.pkplot!(ds[1]; ylims = (0, 250), yscale = :log10, legend = false)
#MetidaNCA.pkplot!(p, ds[1]; ylims = (0, 250), yscale = :log10, legend = false)

kr = MetidaNCA.ElimRange(kelstart = 4, kelend = 12, kelexcl = Int[5,6])
MetidaNCA.setkelrange!(ds, kr, [1,2,3])
dsnca = MetidaNCA.nca!(ds)
Expand Down

2 comments on commit 7e2f843

@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/119557

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.14 -m "<description of version>" 7e2f843a0f4e0fb5dc0b9afbaabe2b1683daf4f1
git push origin v0.5.14

Please sign in to comment.