Skip to content

Commit

Permalink
Merge pull request #53 from PharmCat/dev
Browse files Browse the repository at this point in the history
v0.4.0 DataFrames initial remove (#52)
  • Loading branch information
PharmCat authored Dec 18, 2020
2 parents 51c3dcc + 86a772f commit 48171c7
Show file tree
Hide file tree
Showing 18 changed files with 166 additions and 215 deletions.
22 changes: 0 additions & 22 deletions .gitlab-ci.yml

This file was deleted.

9 changes: 1 addition & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@ os:

julia:
- 1.0
- 1.1
- 1.2
- 1.3
- 1.4
- 1.5
- 1

branches:
only:
Expand All @@ -32,9 +28,6 @@ jobs:
allow_failures:
- os:
- windows
- julia:
- 1.4
- 1.5
include:
- stage: "Documentation"
julia: 1.0
Expand Down
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
authors = ["Vladimir Arnautov ([email protected])"]
name = "ClinicalTrialUtilities"
uuid = "535c2557-d7d0-564d-8ff9-4ae146c18cfe"
version = "0.3.2"
version = "0.4.0"

[deps]
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Expand Down Expand Up @@ -31,4 +31,4 @@ SpecialFunctions = "0.8, 0.9, 0.10, 1"
Roots = "0.7, 0.8, 1"
RecipesBase = "0.7, 0.8, 1"
Reexport = "0.1, 0.2"
DataFrames = "0.19, 0.20"
DataFrames = "0.19, 0.20, 0.21, 0.22"
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

Clinical trial related calculation: descriptive statistics, power and sample size calculation, power simulations, confidence interval, pharmacokinetics/pharmacodynamics parameters calculation. This program comes with absolutely no warranty. No liability is accepted for any loss and risk to public health resulting from use of this software.

[![Build Status](https://travis-ci.com/PharmCat/ClinicalTrialUtilities.jl.svg?branch=master)](https://travis-ci.com/PharmCat/ClinicalTrialUtilities.jl)
[![Build status](https://ci.appveyor.com/api/projects/status/35f8b5vq259sbssg?svg=true)](https://ci.appveyor.com/project/PharmCat/clinicaltrialutilities-jl)
![Tier 1](https://github.com/PharmCat/ClinicalTrialUtilities.jl/workflows/Tier%201/badge.svg)

[![codecov](https://codecov.io/gh/PharmCat/ClinicalTrialUtilities.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/PharmCat/ClinicalTrialUtilities.jl)
[![Coverage Status](https://coveralls.io/repos/github/PharmCat/ClinicalTrialUtilities.jl/badge.svg?branch=master)](https://coveralls.io/github/PharmCat/ClinicalTrialUtilities.jl?branch=master)

[![Latest docs](https://img.shields.io/badge/docs-latest-blue.svg)](https://pharmcat.github.io/ClinicalTrialUtilities.jl/dev/)

## Description
Expand Down
35 changes: 0 additions & 35 deletions appveyor.yml

This file was deleted.

7 changes: 6 additions & 1 deletion cange.log
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
v0.4.0

- remove DataFrames interim
- minor fix

v0.3.2
- bugfix fisher test
- add show
Expand All @@ -10,7 +15,7 @@ v0.3.1
- simulation crush fix
- Equivalence Hypothesis alpha level fix!

v0.3.0
v0.3.0 (removed)
- #44 , #45 , #46
- update test
- Move alpha from CTask to Hypothesis
Expand Down
11 changes: 1 addition & 10 deletions src/ClinicalTrialUtilities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ using Distributions, Random, Roots, QuadGK, RecipesBase, Reexport
import SpecialFunctions
import Base: show, findfirst, getproperty, showerror, getindex, length, in, iterate, eltype, deleteat!, findall
import StatsBase.confint
import DataFrames: DataFrame, DataFrames, names!, unstack, deleterows!, rename!, AbstractDataFrame
import DataFrames: DataFrame, DataFrames, unstack

try
methods(SpecialFunctions.logabsgamma)
Expand All @@ -30,15 +30,6 @@ catch
global lgamma(x) = SpecialFunctions.lgamma(x)
end

#=
try
if collect(methods(DataFrames.delete!, (AbstractDataFrame, Any)))[1].file == Symbol("deprecated.jl")
DataFrames.delete!(df::AbstractDataFrame, inds) = deleterows!(df, inds)
end
catch
end
=#

const ZDIST = Normal()
const LOG2 = log(2)
const PI2 = π * 2.0
Expand Down
16 changes: 8 additions & 8 deletions src/ci.jl
Original file line number Diff line number Diff line change
Expand Up @@ -849,17 +849,17 @@ end
# metafor: Meta-Analysis Package for R - Wolfgang Viechtbauer

"""
diffcmhci(data::DataFrame; a = :a, b = :b, c = :c, d = :d,
diffcmhci(data; a = :a, b = :b, c = :c, d = :d,
alpha = 0.05, method = :default)::ConfInt
Cochran–Mantel–Haenszel confidence intervals for proportion difference.
**data**- dataframe with 4 columns, each line represent 2X2 table
**data**- data with 4 columns, each line represent 2X2 table
**a** **b** **c** **d** - dataframe table names (number of subjects in 2X2 table):
**a** **b** **c** **d** - data table names (number of subjects in 2X2 table):
"""
function diffcmhci(data::DataFrame; a = :a, b = :b, c = :c, d = :d, alpha = 0.05, method = :default)::ConfInt
function diffcmhci(data; a = :a, b = :b, c = :c, d = :d, alpha = 0.05, method = :default)::ConfInt
return diffcmhci(data[:, a], data[:, b], data[:, c], data[:, d]; alpha = alpha, method = method)
#=
n1 = data[:, a] + data[:, b]
Expand Down Expand Up @@ -909,12 +909,12 @@ Cochran–Mantel–Haenszel confidence intervals for proportion difference.
end

"""
orcmhci(data::DataFrame; a = :a, b = :b, c = :c, d = :d,
orcmhci(data; a = :a, b = :b, c = :c, d = :d,
alpha = 0.05, logscale = false)::ConfInt
Cochran–Mantel–Haenszel confidence intervals for odd ratio.
"""
function orcmhci(data::DataFrame; a = :a, b = :b, c = :c, d = :d, alpha = 0.05, logscale = false)::ConfInt
function orcmhci(data; a = :a, b = :b, c = :c, d = :d, alpha = 0.05, logscale = false)::ConfInt
return orcmhci(data[:, a], data[:, b], data[:, c], data[:, d]; alpha = alpha, logscale = logscale)
#=
N = data[:, a] + data[:, b] + data[:, c] + data[:, d]
Expand Down Expand Up @@ -949,12 +949,12 @@ Cochran–Mantel–Haenszel confidence intervals for proportion difference.
if logscale return ConfInt(estimate - z*se, estimate + z*se, estimate, alpha) else return ConfInt(exp(estimate - z*se), exp(estimate + z*se), exp(estimate), alpha) end
end
"""
rrcmhci(data::DataFrame; a = :a, b = :b, c = :c, d = :d,
rrcmhci(data; a = :a, b = :b, c = :c, d = :d,
alpha = 0.05, logscale = false)::ConfInt
Cochran–Mantel–Haenszel confidence intervals for risk ratio.
"""
function rrcmhci(data::DataFrame; a = :a, b = :b, c = :c, d = :d, alpha = 0.05, logscale = false)::ConfInt
function rrcmhci(data; a = :a, b = :b, c = :c, d = :d, alpha = 0.05, logscale = false)::ConfInt
return rrcmhci(data[:, a], data[:, b], data[:, c], data[:, d]; alpha = alpha, logscale = logscale)
#=
n1 = data[:, a] + data[:, b]
Expand Down
12 changes: 12 additions & 0 deletions src/dataset.jl
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,15 @@ function Base.deleteat!(a::DataSet{T}, inds::Dict) where T
deleteat!(a.data, findall(a, inds))
return a
end

################################################################################
#=
function Tables.istable(table::DataSet)
end
function Tables.rows(table::DataSet)
end
function Tables.columns(table::DataSet)
end
=#
39 changes: 39 additions & 0 deletions src/deprecated.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,44 @@
#deprecated

#DEPRECATED

"""
DataFrames.DataFrame(data::DataSet{PKPDProfile}; unst = false, us = false)
Make datafrafe from PK/PD DataSet.
unst | us - unstack data;
"""
function DataFrames.DataFrame(data::DataSet{T}; unst = false, us = false) where T
d = DataFrame(id = Int[], sortvar = Symbol[], sortval = Any[])
for i = 1:length(data)
if length(data[i].sort) > 0
for s in data[i].sort
push!(d, [i, s[1], s[2]])
end
end
end
d = unstack(d, :sortvar, :sortval)[!,2:end]
df = DataFrame()
dfn = names(d)
for i = 1:size(d,2)
df[!,dfn[i]] = Array{eltype(d[!, dfn[i]]), 1}(undef, 0)
end
df = hcat(df, DataFrame(param = Any[], value = Real[]))
for i = 1:size(d,1)
a = Array{Any,1}(undef, size(d,2))
copyto!(a, collect(d[i,:]))
for p in data[i].result
r = append!(copy(a), collect(p))
push!(df, r)
end
end
if unst || us
return unstack(df, names(df)[end-1], names(df)[end])
else
return df
end
end

#=
function ncarule!(data::DataFrame, conc::Symbol, time::Symbol, rule::LimitRule)
Expand Down
10 changes: 5 additions & 5 deletions src/descriptives.jl
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ function Base.show(io::IO, obj::DataSet{Descriptive})
end
end
"""
descriptive(data::DataFrame;
descriptive(data;
sort::Union{Symbol, Array{T,1}} = Array{Symbol,1}(undef,0),
vars = [],
stats::Union{Symbol, Array{T,1}, Tuple{Vararg{Symbol}}} = :default)::DataSet{Descriptive} where T <: Union{Symbol, String}
Expand All @@ -125,7 +125,7 @@ Descriptive statistics.
- ``vars`` variabels
- ``stats`` statistics
"""
function descriptive(data::DataFrame;
function descriptive(data;
sort::Union{Symbol, Array{T,1}} = Array{Symbol,1}(undef,0),
vars = [],
stats::Union{Symbol, Array{T,1}, Tuple{Vararg{Symbol}}} = :default)::DataSet{Descriptive} where T <: Union{Symbol, String}
Expand Down Expand Up @@ -202,15 +202,15 @@ end
"""
Push in d Descriptive obj in mx vardata
"""
@inline function pushvardescriptive!(d::Array{Descriptive, 1}, vars::Array{Symbol, 1}, mx::Union{DataFrame, Matrix{T}}, sortval::Union{Tuple{Vararg{Any}}, Nothing}, stats::Tuple{Vararg{Symbol}}) where T<: Real
@inline function pushvardescriptive!(d::Array{Descriptive, 1}, vars::Array{Symbol, 1}, mx, sortval::Union{Tuple{Vararg{Any}}, Nothing}, stats::Tuple{Vararg{Symbol}}) where T<: Real
for v = 1:length(vars) #For each variable in list
push!(d, Descriptive(vars[v], nothing, sortval, descriptive_(mx[:, v], stats)))
end
end
"""
Check if data row sortcol equal sortval
"""
@inline function checksort(data::DataFrame, row::Int, sortcol::Array{Symbol, 1}, sortval::Tuple{Vararg{Any}})::Bool
@inline function checksort(data, row::Int, sortcol::Array{Symbol, 1}, sortval::Tuple{Vararg{Any}})::Bool
for i = 1:length(sortcol)
if data[row, sortcol[i]] != sortval[i] return false end
end
Expand All @@ -219,7 +219,7 @@ end
"""
Return matrix of filtered data (datacol) by sortcol with sortval
"""
@inline function getsortedmatrix(data::DataFrame; datacol::Array{Symbol,1}, sortcol::Array{Symbol,1}, sortval::Tuple{Vararg{Any}})::Matrix{Real}
@inline function getsortedmatrix(data; datacol::Array{Symbol,1}, sortcol::Array{Symbol,1}, sortval::Tuple{Vararg{Any}})::Matrix{Real}
result = Array{Real, 1}(undef, 0)
for c = 1:size(data, 1) #For each line in data
if checksort(data, c, sortcol, sortval)
Expand Down
8 changes: 4 additions & 4 deletions src/export.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"""
htmlexport(data::DataFrame; io::IO = stdout, sort = NaN,
htmlexport(data; io::IO = stdout, sort = NaN,
rspan=:all, title="Title", dict::Union{Symbol, Dict} = :undef)
HTLM export for DataFrame.
HTLM export.
"""
function htmlexport(data::DataFrame; io::IO = stdout, sort = NaN, rspan=:all, title="Title", dict::Union{Symbol, Dict} = :undef)
function htmlexport(data; io::IO = stdout, sort = NaN, rspan=:all, title="Title", dict::Union{Symbol, Dict} = :undef)
rowlist = Array{String,1}(undef, 0)
cnames = names(data)
if isa(sort, Array)
Expand Down Expand Up @@ -189,7 +189,7 @@ HTLM export for DataFrame.
<TBODY>"""

sort!(data, tuple(sort))
sort!(data, sort)
tablematrix .= 1
for c = 1:coln
s = true
Expand Down
Loading

2 comments on commit 48171c7

@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 register

Release notes:

v0.4.0

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

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.4.0 -m "<description of version>" 48171c7eaedd28cd9dd75ff7336c5fda0bc176de
git push origin v0.4.0

Please sign in to comment.