Skip to content

Commit

Permalink
Dev (#21)
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
  • Loading branch information
PharmCat authored Jul 16, 2024
1 parent e076182 commit 144cfd9
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/Documenter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
runs-on: ubuntu-22.04
timeout-minutes: 40
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Update
run: sudo apt-get update
- name: Install Pandoc
Expand Down
21 changes: 16 additions & 5 deletions .github/workflows/Tier1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,26 @@ jobs:
arch:
- x64
steps:
- uses: actions/checkout@v3
- uses: julia-actions/setup-julia@v1
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v2
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: julia-actions/cache@v1
- uses: actions/cache@v4
env:
cache-name: cache-artifacts
with:
path: ~/.julia/artifacts
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
restore-keys: |
${{ runner.os }}-test-${{ env.cache-name }}-
${{ runner.os }}-test-
${{ runner.os }}-
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v3
- uses: codecov/codecov-action@v4
if: ${{ matrix.os == 'ubuntu-latest' && matrix.version == '1' && matrix.arch == 'x64' }}
with:
files: lcov.info
file: lcov.info
token: ${{ secrets.CODECOV_TOKEN }}
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "MetidaNCA"
uuid = "097c2839-c7bc-4c4b-a5f2-b4167c1b4e7c"
authors = ["PharmCat <v.s.arnautov@yandex.ru>"]
version = "0.5.10"
version = "0.5.11"



Expand Down
3 changes: 3 additions & 0 deletions docs/src/details.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ 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.


See also: [`applylimitrule!`](@ref).


## Calculation steps for PK NCA

### Step 1
Expand Down
8 changes: 8 additions & 0 deletions src/MetidaNCA.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,21 @@ uniqueidlist,
indsdict!,
subset

using MetidaBase.Requires

export pkimport, upkimport, pdimport, nca!, nca, DoseTime, ElimRange, LimitRule, NoPageSort,
auc_sparse,
setdosetime!, setkelauto!, setkelrange!, applylimitrule!, setbl!, setth!,
pkplot,
getkeldata, getkelauto, getkelrange, getdosetime, getbl, getth, subset
metida_table

function __init__()
@require Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" begin
import Plots:savefig
end
end

const LOG2 = log(2)

include("types.jl")
Expand Down
40 changes: 32 additions & 8 deletions src/plots.jl
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,9 @@ end
pagesort::Union{Nothing, Symbol, AbstractVector{Symbol}, NoPageSort} = nothing,
filter::Union{Nothing, Dict{Symbol}} = nothing,
uylims::Bool = false,
ldict = nothing,
savepath::Union{Nothing, AbstractString} = nothing,
namepref::Union{Nothing, AbstractString} = nothing,
kwargs...) where T <: AbstractSubject
PK plot for subject set.
Expand All @@ -383,7 +386,9 @@ PK plot for subject set.
* `pagesort` - different pages by this id key;
* `filter` - use only subjects if filter ⊆ subject id;
* `uylims` - same ylims for all dataset;
* `ldict` - Dict with labels for replace.
* `ldict` - Dict with labels for replace;
* `savepath` - path for plot saving;
* `namepref` - name prefix for saving files.
Use `pagesort = MetidaNCA.NoPageSort()` to prevent page plotting.
"""
Expand All @@ -393,7 +398,9 @@ function pkplot(data::DataSet{T};
filter::Union{Nothing, Dict{Symbol}} = nothing,
uylims::Bool = false,
ldict = nothing,
savepng = nothing,
savepath::Union{Nothing, AbstractString} = nothing,
namepref::Union{Nothing, AbstractString} = nothing,

kwargs...) where T <: AbstractSubject

kwargs = Dict{Symbol, Any}(kwargs)
Expand Down Expand Up @@ -424,9 +431,8 @@ function pkplot(data::DataSet{T};
kwargs[:legend] = false
end
end

p = []
if isnothing(typesort) && isnothing(pagesort)
p = []
printtitle = false
if !(:title in k)
printtitle = true
Expand All @@ -440,20 +446,38 @@ function pkplot(data::DataSet{T};
end
push!(p, pkplot(subj; kwargs...))
end
return p
elseif !isnothing(pagesort) && !isa(pagesort, NoPageSort)
if isa(pagesort, Symbol) pagesort = [pagesort] end
p = []
pagelist = uniqueidlist(data, pagesort)
for id in pagelist
push!(p, pageplot(data, id, typelist; ldict, kwargs...))
end
return p
else
if !(:title in k) && !isnothing(filter)
kwargs[:title] = plotlabel(filter)
end
return pageplot(data, nothing, typelist; ldict, kwargs...)
push!(p,pageplot(data, nothing, typelist; ldict, kwargs...))
end

if !isnothing(savepath)
if @isdefined savefig
if isfile(savepath)
error("File found on this path...")
elseif !isdir(savepath)
mkpath(savepath)
end
if isnothing(namepref) namepref = "plot" end
for i = 1: length(p)
savefig(p[i], joinpath(savepath, namepref*"_$(i).png"))
end
else
@warn "savefig not defined, install Plots.jl for plot writing... plots NOT saved..."
end
end
if length(p) > 1
return p
else
return p[1]
end
end

Expand Down
12 changes: 10 additions & 2 deletions src/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ end
function Base.show(io::IO, obj::DataSet{ST}) where ST <: AbstractSubject
println(io, "DataSet: $(subject_type_str(ST))")
println(io, "Length: $(length(obj))")
for i = 1:length(obj)
lo = min(length(obj), 20)
for i = 1:lo
print(io, "Subject $(i): ")
if length(obj[i].id) > 0
for (k, v) in obj[i].id
Expand All @@ -82,6 +83,9 @@ function Base.show(io::IO, obj::DataSet{ST}) where ST <: AbstractSubject
println(io, "-")
end
end
if lo < length(obj)
printstyled(io, "$(length(obj) - lo) subjects omitted... \n"; color = :blue)
end
end

function Base.show(io::IO, obj::T) where T <: NCAResult
Expand All @@ -92,7 +96,8 @@ end
function Base.show(io::IO, obj::DataSet{Res}) where Res <: NCAResult
println(io, "DataSet: PK/PD NCA result")
println(io, "Length: $(length(obj))")
for i = 1:length(obj)
lo = min(length(obj), 20)
for i = 1:lo
print(io, "Subject $(i): ")
if length(obj[i].data.id) > 0
for (k, v) in obj[i].data.id
Expand All @@ -103,4 +108,7 @@ function Base.show(io::IO, obj::DataSet{Res}) where Res <: NCAResult
println(io, "-")
end
end
if lo < length(obj)
printstyled(io, "$(length(obj) - lo) subjects omitted... \n"; color = :blue)
end
end

0 comments on commit 144cfd9

Please sign in to comment.