Skip to content

Commit

Permalink
rename to TmleCLI
Browse files Browse the repository at this point in the history
  • Loading branch information
olivierlabayle committed Aug 21, 2024
1 parent 0161a34 commit 1496ac6
Show file tree
Hide file tree
Showing 28 changed files with 155 additions and 160 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ jobs:
- run: |
julia --project=docs -e '
using Documenter: DocMeta, doctest
using TMLECLI
DocMeta.setdocmeta!(TMLECLI, :DocTestSetup, :(using TMLECLI); recursive=true)
doctest(TMLECLI)'
using TmleCLI
DocMeta.setdocmeta!(TmleCLI, :DocTestSetup, :(using TmleCLI); recursive=true)
doctest(TmleCLI)'
- run: julia --project=docs docs/make.jl
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
8 changes: 2 additions & 6 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name = "TMLECLI"
name = "TmleCLI"
uuid = "2573d147-4098-46ba-9db2-8608d210ccac"
authors = ["Olivier Labayle"]
version = "0.9.0"
Expand All @@ -13,7 +13,6 @@ Configurations = "5218b696-f38b-4ac9-8b61-a12ec717816d"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
EvoTrees = "f6006082-12f8-11e9-0c9c-0d5d367ab1e5"
GLMNet = "8d5ece8b-de18-5317-b113-243142960cc6"
HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f"
JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
MKL = "33e6dc65-8f57-5167-99aa-e5a354878fb2"
Expand All @@ -24,8 +23,6 @@ MLJModelInterface = "e80e1ace-859a-464e-9ed9-23947d8ae3ea"
MLJModels = "d491faf4-2d78-11e9-2867-c94bc002c0b7"
MLJXGBoostInterface = "54119dfa-1dab-4055-a167-80440f4f7a91"
Mmap = "a63ad114-7e13-5084-954f-fe012c677804"
MultipleTesting = "f8716d33-7c4a-5097-896f-ce0ecbd3ef6b"
Optim = "429524aa-4258-5aef-a3af-852621145aeb"
PackageCompiler = "9b87118b-4619-50d2-8e1e-99f35a4d4d9d"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Serialization = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
Expand All @@ -52,9 +49,8 @@ MLJLinearModels = "0.10.0"
MLJModelInterface = "1.8.0"
MLJModels = "0.16, 0.17"
MLJXGBoostInterface = "0.3.4"
MultipleTesting = "0.6.0"
Optim = "1.7"
PackageCompiler = "2.1.16"
TMLE = "0.17"
Tables = "1.10.1"
YAML = "0.4.9"
julia = "1.10, 1"
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# TMLECLI
# TmleCLI

[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://targene.github.io/TMLE-CLI.jl/stable/)
![GitHub Workflow Status (with branch)](https://img.shields.io/github/actions/workflow/status/TARGENE/TMLE-CLI.jl/CI.yml?branch=main)
![Codecov](https://img.shields.io/codecov/c/github/TARGENE/TMLE-CLI.jl/main)
![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/TARGENE/TMLE-CLI.jl)
[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://targene.github.io/TmleCLI.jl/stable/)
![GitHub Workflow Status (with branch)](https://img.shields.io/github/actions/workflow/status/TARGENE/TmleCLI.jl/CI.yml?branch=main)
![Codecov](https://img.shields.io/codecov/c/github/TARGENE/TmleCLI.jl/main)
![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/TARGENE/TmleCLI.jl)

Command Line Interface for Targeted Minimum-Loss Estimation of causal effects on Tabular datasets.
2 changes: 1 addition & 1 deletion deps/build_sysimage.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using PackageCompiler
PackageCompiler.create_sysimage(
["TMLECLI"],
["TmleCLI"],
cpu_target="generic",
sysimage_path="TMLESysimage.so",
precompile_execution_file="deps/execute.jl",
Expand Down
4 changes: 2 additions & 2 deletions deps/execute.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using TMLECLI
using TmleCLI

@info "Running precompilation script."
# Run workload
TEST_DIR = joinpath(pkgdir(TMLECLI), "test")
TEST_DIR = joinpath(pkgdir(TmleCLI), "test")
push!(LOAD_PATH, TEST_DIR)
include(joinpath(TEST_DIR, "runtests.jl"))
4 changes: 2 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ RUN bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)"

# Import the project

COPY . /TMLECLI.jl
COPY . /TmleCLI.jl

WORKDIR /TMLECLI.jl
WORKDIR /TmleCLI.jl

# Precompile the project
RUN julia --project -e'using Pkg; Pkg.instantiate(); Pkg.resolve(); Pkg.precompile()'
Expand Down
14 changes: 7 additions & 7 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
using Documenter
using TMLECLI
using TmleCLI

DocMeta.setdocmeta!(TMLECLI, :DocTestSetup, :(using TMLECLI); recursive=true)
DocMeta.setdocmeta!(TmleCLI, :DocTestSetup, :(using TmleCLI); recursive=true)

makedocs(
authors="Olivier Labayle",
repo="https://github.com/TARGENE/TMLE-CLI.jl/blob/{commit}{path}#{line}",
sitename = "TMLE-CLI.jl",
repo="https://github.com/TARGENE/TmleCLI.jl/blob/{commit}{path}#{line}",
sitename = "TmleCLI.jl",
format = Documenter.HTML(;
prettyurls=get(ENV, "CI", "false") == "true",
canonical="https://TARGENE.github.io/TMLE-CLI.jl",
canonical="https://TARGENE.github.io/TmleCLI.jl",
assets=String["assets/logo.ico"],
),
modules = [TMLECLI],
modules = [TmleCLI],
pages=[
"Home" => "index.md",
"Command Line Interface" => ["cli.md", "tmle_estimation.md", "sieve_variance.md", "make_summary.md"],
Expand All @@ -25,7 +25,7 @@ makedocs(

@info "Deploying docs..."
deploydocs(;
repo="github.com/TARGENE/TMLE-CLI.jl",
repo="github.com/TARGENE/TmleCLI.jl",
devbranch="main",
push_preview=true
)
2 changes: 1 addition & 1 deletion docs/src/index.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# TMLE-CLI.jl
# TmleCLI.jl

The goal of this package, is to provide a standalone executable to run large scale Targeted Minimum Loss-based Estimation ([TMLE](https://link.springer.com/book/10.1007/978-1-4419-9782-1)) on tabular datasets. To learn more about TMLE, please visit [TMLE.jl](https://targene.github.io/TMLE.jl/stable/), the companion package.

Expand Down
8 changes: 4 additions & 4 deletions docs/src/models.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Models

```@meta
CurrentModule = TMLECLI
CurrentModule = TmleCLI
```

Because [TMLE.jl](https://targene.github.io/TMLE.jl/stable/) is based on top of [MLJ](https://alan-turing-institute.github.io/MLJ.jl/dev/), we can support any model respecting the MLJ interface. At the moment, we readily support all models from the following packages:
Expand All @@ -12,13 +12,13 @@ Because [TMLE.jl](https://targene.github.io/TMLE.jl/stable/) is based on top of
- [GLMNet](https://github.com/JuliaStats/GLMNet.jl): A Julia wrapper of the [glmnet](https://glmnet.stanford.edu/articles/glmnet.html) package. See the [GLMNet](@ref) section.
- [MLJModels](https://github.com/JuliaAI/MLJModels.jl): General utilities such as the `OneHotEncoder` or `InteractionTransformer`.

Further support for more packages can be added on request, please fill an [issue](https://github.com/TARGENE/TMLE-CLI.jl/issues).
Further support for more packages can be added on request, please fill an [issue](https://github.com/TARGENE/TmleCLI.jl/issues).

Also, because the estimator file used by the TMLE CLI is a pure Julia file, it is possible to use it in order to install additional package that can be used to define additional models.

Finally, we also provide some additional models described in [Additional models provided by TMLE-CLI.jl](@ref).
Finally, we also provide some additional models described in [Additional models provided by TmleCLI.jl](@ref).

## Additional models provided by TMLE-CLI.jl
## Additional models provided by TmleCLI.jl

### GLMNet

Expand Down
2 changes: 1 addition & 1 deletion docs/src/resampling.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Resampling Strategies

```@meta
CurrentModule = TMLECLI
CurrentModule = TmleCLI
```

We also provide additional resampling strategies compliant with the `MLJ.ResamplingStrategy` interface.
Expand Down
4 changes: 2 additions & 2 deletions docs/src/tmle_estimation.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ Linear models typically do not involve any interaction terms. Here, to add extra

### Estimators Via A Julia File

Building an estimator via a configuration string is quite flexible and should cover most use cases. However, in some cases you may want to have full control over the estimation procedure. This is possible by instead providing a Julia configuration file describing the estimators to be used. The file should define an `ESTIMATORS` NamedTuple describing the estimators to be used, and some examples can be found [here](https://github.com/TARGENE/TMLE-CLI.jl/tree/treatment_values/estimators-configs).
Building an estimator via a configuration string is quite flexible and should cover most use cases. However, in some cases you may want to have full control over the estimation procedure. This is possible by instead providing a Julia configuration file describing the estimators to be used. The file should define an `ESTIMATORS` NamedTuple describing the estimators to be used, and some examples can be found [here](https://github.com/TARGENE/TmleCLI.jl/tree/treatment_values/estimators-configs).

For further information, we recommend you have a look at both:

Expand Down Expand Up @@ -155,7 +155,7 @@ In what follows, `Y` is an outcome of interest, `W` a set of confounding variabl

For all the following experiments:

- The Julia script can be found at [experiments/runtime.jl](https://github.com/TARGENE/TMLE-CLI.jl/tree/main/experiments/runtime.jl).
- The Julia script can be found at [experiments/runtime.jl](https://github.com/TARGENE/TmleCLI.jl/tree/main/experiments/runtime.jl).
- The various estimators used below are further described in the[estimators-configs](https://github.com/TARGENE/TMLE.jl/tree/main/estimators-configs) folder.

### Multiple treatment contrasts
Expand Down
4 changes: 2 additions & 2 deletions experiments/runtime.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using ArgParse
using TMLECLI
using TmleCLI

const ESTIMATORS = [
"glm",
Expand Down Expand Up @@ -60,7 +60,7 @@ function main(parsed_args)
"chunksize" => 100,
"verbosity" => parsed_args["verbosity"],
)
nparams = length(TMLECLI.parameters_from_yaml(paramfile))
nparams = length(TmleCLI.parameters_from_yaml(paramfile))

# Time it: this will include precompilation time
t_start = time()
Expand Down
3 changes: 1 addition & 2 deletions src/TMLECLI.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module TMLECLI
module TmleCLI

if occursin("Intel", Sys.cpu_info()[1].model)
using MKL
Expand All @@ -20,7 +20,6 @@ using GLMNet
using MLJModels
using Mmap
using Serialization
using MultipleTesting
using Combinatorics
using Tables
using Random
Expand Down
2 changes: 1 addition & 1 deletion src/models/biallelic_snp_encoder.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function MLJModelInterface.transform(model::BiAllelicSNPEncoder, fitresult, X)
ref_allele = fitresult[colname]
newcoltype = Missing <: eltype(column) ? Union{Missing, Int} : Int
newcolumn = Vector{newcoltype}(undef, size(column, 1))
TMLECLI.count_nref!(newcolumn, column, ref_allele)
TmleCLI.count_nref!(newcolumn, column, ref_allele)
else
newcolumn = column
end
Expand Down
2 changes: 1 addition & 1 deletion src/runner.jl
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ function (runner::Runner)(partition)
continue
end
# Make sure data types are appropriate for the estimand
TMLECLI.coerce_types!(runner.dataset, Ψ)
TmleCLI.coerce_types!(runner.dataset, Ψ)
# Maybe update cache with new η_spec
estimators_results = []
for estimator in runner.estimators
Expand Down
22 changes: 11 additions & 11 deletions test/cache_managers.jl
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
module TestRunner

using TMLECLI
using TmleCLI
using Test
using TMLE

@testset "Test NoCacheManager" begin
cache_manager = TMLECLI.NoCacheManager()
cache_manager = TmleCLI.NoCacheManager()
cache_manager.cache["Toto"] = 1
cache_manager.cache["Tata"] = 2
TMLECLI.release!(cache_manager, nothing)
TmleCLI.release!(cache_manager, nothing)
@test cache_manager.cache == Dict()
# Check this does not throw
TMLECLI.release!(cache_manager, nothing)
TmleCLI.release!(cache_manager, nothing)
end

@testset "Test MaxSizeCacheManager" begin
cache_manager = TMLECLI.MaxSizeCacheManager(3)
cache_manager = TmleCLI.MaxSizeCacheManager(3)
Y_T₁T₂ = TMLE.ConditionalDistribution(:Y, (:T₁, :T₂, :W))
cache_manager.cache[Y_T₁T₂] = 1
T₁_W = TMLE.ConditionalDistribution(:T₁, (:W,))
Expand All @@ -29,7 +29,7 @@ end
cache_manager.cache[η] = 1
cache_manager.cache[:last_fluctuation] = 1
length(cache_manager.cache) == 5
TMLECLI.release!(cache_manager, nothing)
TmleCLI.release!(cache_manager, nothing)
# CMRelevantFactors and fluctuation dropped
@test cache_manager.cache == Dict(
TMLE.ConditionalDistribution(:Y, (:T₁, :T₂, :W)) => 1,
Expand Down Expand Up @@ -62,7 +62,7 @@ end
)
]
η_counts = TMLE.nuisance_function_counts(estimands)
cache_manager = TMLECLI.ReleaseUnusableCacheManager(η_counts)
cache_manager = TmleCLI.ReleaseUnusableCacheManager(η_counts)
# Estimation of the first estimand will fill the cache with the following
Y_T₁T₂ = TMLE.ConditionalDistribution(:Y, (:T₁, :T₂, :W))
cache_manager.cache[Y_T₁T₂] = 1
Expand All @@ -78,7 +78,7 @@ end
cache_manager.cache[:last_fluctuation] = 1
@test length(cache_manager.cache) == 5
# After estimation of the first estimand, the fluctuation and composite factor are released
TMLECLI.release!(cache_manager, estimands[1])
TmleCLI.release!(cache_manager, estimands[1])
@test cache_manager.cache == Dict(
TMLE.ConditionalDistribution(:Y, (:T₁, :T₂, :W)) => 1,
TMLE.ConditionalDistribution(:T₂, (:W,)) => 1,
Expand All @@ -89,7 +89,7 @@ end
cache_manager.cache[η] = 1
cache_manager.cache[:last_fluctuation] = 1
# Y_T₁T₂ and T₂_W are no longer needed
TMLECLI.release!(cache_manager, estimands[2])
TmleCLI.release!(cache_manager, estimands[2])
@test cache_manager.cache == Dict(TMLE.ConditionalDistribution(:T₁, (:W,)) => 1)

# Estimation of the third estimand will fill the cache with the following
Expand All @@ -102,10 +102,10 @@ end
cache_manager.cache[η] = 1
cache_manager.cache[:last_fluctuation] = 1
# Y_T₁ and T₁_W are no longer needed
TMLECLI.release!(cache_manager, estimands[3])
TmleCLI.release!(cache_manager, estimands[3])
@test cache_manager.cache == Dict()
# Check this does not throw
TMLECLI.release!(cache_manager, estimands[1])
TmleCLI.release!(cache_manager, estimands[1])
end

end
Expand Down
10 changes: 5 additions & 5 deletions test/models/adaptive_interaction_transformer.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module TestRestrictedInteractionTransformer

using Test
using TMLECLI
using TmleCLI
using Random
using MLJBase
using Tables
Expand Down Expand Up @@ -44,7 +44,7 @@ using Tables
]
@test expected_interactions == interactions
Xt = MLJBase.transform(mach, X)
feature_names = TMLECLI.feature_names(interactions)
feature_names = TmleCLI.feature_names(interactions)
@test Tables.columnnames(Xt) == tuple(Tables.columnnames(X)..., feature_names...)
@test Xt[Symbol("rs1234_&_sex_&_PC_2")] == X[:rs1234].*X[:sex].*X[:PC_2]

Expand Down Expand Up @@ -72,7 +72,7 @@ using Tables
]
@test expected_interactions == interactions
Xt = MLJBase.transform(mach, X)
feature_names = TMLECLI.feature_names(interactions)
feature_names = TmleCLI.feature_names(interactions)
@test Tables.columnnames(Xt) == tuple(Tables.columnnames(X)..., feature_names...)

# Test with both primary_variables and primary_variables_patterns
Expand Down Expand Up @@ -110,7 +110,7 @@ using Tables
]
@test expected_interactions == interactions
Xt = MLJBase.transform(mach, X)
feature_names = TMLECLI.feature_names(interactions)
feature_names = TmleCLI.feature_names(interactions)
@test Tables.columnnames(Xt) == tuple(Tables.columnnames(X)..., feature_names...)

# Invalid column
Expand All @@ -120,7 +120,7 @@ using Tables
primary_variables=[:A, :B],
)
mach = machine(model, X, scitype_check_level=0)
@test_throws TMLECLI.InvalidColumnError("A") fit!(mach, verbosity=0)
@test_throws TmleCLI.InvalidColumnError("A") fit!(mach, verbosity=0)
end

end
Expand Down
8 changes: 4 additions & 4 deletions test/models/biallelic_snp_encoder.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module TestBiAllelelicSNPEncoder

using Test
using TMLECLI
using TmleCLI
using CategoricalArrays
using MLJBase

Expand All @@ -28,21 +28,21 @@ using MLJBase
othercol = [1, 2, 3, 4]
)
mach = machine(BiAllelicSNPEncoder(patterns=[r"^rs"]), X)
@test_throws TMLECLI.NonBiAllelicGenotypeError(:rs1234, "CCC") fit!(mach, verbosity=0)
@test_throws TmleCLI.NonBiAllelicGenotypeError(:rs1234, "CCC") fit!(mach, verbosity=0)

X = (
rs1234 = categorical(["AC", "CC", "CCT", missing]),
othercol = [1, 2, 3, 4]
)
mach = machine(BiAllelicSNPEncoder(patterns=[r"^rs"]), X)
@test_throws TMLECLI.NonBiallelicSNPError(:rs1234) fit!(mach, verbosity=0)
@test_throws TmleCLI.NonBiallelicSNPError(:rs1234) fit!(mach, verbosity=0)

X = (
rs1234 = ["AC", "CC", "CCT", missing],
othercol = [1, 2, 3, 4]
)
mach = machine(BiAllelicSNPEncoder(patterns=[r"^rs"]), X)
@test_throws TMLECLI.NonCategoricalVectorError(:rs1234) fit!(mach, verbosity=0)
@test_throws TmleCLI.NonCategoricalVectorError(:rs1234) fit!(mach, verbosity=0)


end
Expand Down
Loading

0 comments on commit 1496ac6

Please sign in to comment.