Skip to content

Commit

Permalink
try add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Olivier Labayle committed Jul 18, 2024
1 parent 58a31e1 commit fb95ee4
Show file tree
Hide file tree
Showing 12 changed files with 862 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ jobs:
- "ukb_allele_independent.jl"
- "custom_from_actors.jl"
- "make_dataset.jl"
- "null_simulation.jl"
- "realistic_simulation.jl"
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ nextflow run TARGENE/targene-pipeline -profile myprofile -resume
```julia
using LiveServer
servedocs()
```
```
779 changes: 779 additions & 0 deletions assets/Traits_Table_GeneATLAS.csv

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions conf/container.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
process {
withLabel: simulation_image {
container = "olivierlabayle/targene-simulations:main"
container = "olivierlabayle/targene-simulations:ps_simulation"
}
withLabel: targenecore_image {
container = "olivierlabayle/tl-core:simulation"
Expand All @@ -9,7 +9,7 @@ process {
container = "olivierlabayle/ukbmain:0.4"
}
withLabel: tmle_image {
container = "olivierlabayle/targeted-estimation:0.8"
container = "olivierlabayle/targeted-estimation:agnostic_composed"
}
withLabel: plink_image {
container = "olivierlabayle/plink2:0.1.0"
Expand Down
4 changes: 3 additions & 1 deletion main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ params.COHORT = "UKBB"
params.UKB_CONFIG = "${projectDir}/assets/ukbconfig.yaml"
params.UKB_WITHDRAWAL_LIST = "${projectDir}/assets/NO_WITHDRAWAL_LIST"
params.OUTDIR = "${launchDir}/results"
params.VARIANTS_REGEXP = "^(rs[0-9]*|Affx)"
params.SAMPLE_GA_HITS = true

// Confounding adjustment by PCA
params.NB_PCS = 6
Expand Down Expand Up @@ -78,7 +80,7 @@ include { TARGENE } from './workflows/targene.nf'
include { PERMUTATION_TEST; RANDOMIZATION_TEST } from './workflows/negative_control.nf'
include { PCA } from './workflows/pca.nf'
include { MAKE_DATASET } from './workflows/dataset.nf'
include { NULL_SIMULATION; REALISTIC_SIMULATION; SIMULATIONS } from './workflows/simulations.nf'
include { NULL_SIMULATION; REALISTIC_SIMULATION } from './workflows/simulations.nf'

log.info """\
${workflow.manifest.name} v${workflow.manifest.version}
Expand Down
2 changes: 2 additions & 0 deletions modules/simulations.nf
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ process RealisticSimulationInputs {
TEMPD=\$(mktemp -d)
JULIA_DEPOT_PATH=\$TEMPD:/opt julia --project=/opt/Simulations --startup-file=no --sysimage=/opt/Simulations/Simulations.so /opt/Simulations/targene-simulation.jl \
simulation-inputs-from-ga ${estimands_prefix} ${bgen_prefix} ${traits} ${pcs} \
--sample-gene-atlas-hits=${params.SAMPLE_GA_HITS} \
--ga-download-dir=gene_atlas \
--remove-ga-data=true \
--ga-trait-table=${ga_trait_table} \
Expand All @@ -121,6 +122,7 @@ process RealisticSimulationInputs {
--output-prefix=ga_sim_input \
--batchsize=${params.BATCH_SIZE} \
--verbosity=${params.VERBOSITY} \
--variants-regex=${params.VARIANTS_REGEXP} \
${call_threshold}
"""
}
Expand Down
16 changes: 16 additions & 0 deletions test/assets/estimators-configs/cv-glm.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
resampling = JointStratifiedCV(patterns=[r"^rs[0-9]+"], resampling=StratifiedCV(nfolds=3))

default_models = TMLE.default_models(
# For the estimation of E[Y|W, T]: continuous outcome
Q_continuous = LinearRegressor(),
# For the estimation of E[Y|W, T]: binary target
Q_binary = LogisticClassifier(lambda=0.),
# For the estimation of p(T| W)
G = LogisticClassifier(lambda=0.)
)

ESTIMATORS = (
CV_wTMLE_GLMNET = TMLEE(models=default_models, weighted=true, resampling=resampling),
CV_TMLE_GLMNET = TMLEE(models=default_models, weighted=false, resampling=resampling),
CV_OSE_GLMNET = OSE(models=default_models, resampling=resampling)
)
14 changes: 14 additions & 0 deletions test/assets/estimators-configs/glm.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
default_models = TMLE.default_models(
# For the estimation of E[Y|W, T]: continuous outcome
Q_continuous = LinearRegressor(),
# For the estimation of E[Y|W, T]: binary target
Q_binary = LogisticClassifier(lambda=0.),
# For the estimation of p(T| W)
G = LogisticClassifier(lambda=0.)
)

ESTIMATORS = (
wTMLE_GLMNET = TMLEE(models=default_models, weighted=true),
TMLE_GLMNET = TMLEE(models=default_models, weighted=false),
OSE_GLMNET = OSE(models=default_models)
)
17 changes: 17 additions & 0 deletions test/configs/simulation.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
includeConfig 'ukb.config'

params {
ESTIMANDS_FILE = "test/assets/parameters/parameters.yaml"
SAMPLE_GA_HITS = false // To complicated to test otherwise

// Grid
N_REPEATS = 3
RNGS = [0, 1, 3]
SAMPLE_SIZES = [1000]
ESTIMATORS = "test/assets/estimators-configs/*"

// Misc
POSITIVITY_CONSTRAINT = 0
BATCH_SIZE = 3
CALL_THRESHOLD = null // This is essential not to have too many missings
}
13 changes: 13 additions & 0 deletions test/null_simulation.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module TestNullSimulation

args = length(ARGS) > 0 ? ARGS : ["-profile", "local", "-resume"]

@testset "Test Null Simulation Workflow" begin
cmd = `nextflow run main.nf -entry NULL_SIMULATION -c test/configs/simulation.config $args`
@info string("The following command will be run:\n", cmd)

r = run(cmd)
@test r.exitcode == 0
end

end
13 changes: 13 additions & 0 deletions test/realistic_simulation.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module TestRealisticSimulation

args = length(ARGS) > 0 ? ARGS : ["-profile", "local", "-resume"]

@testset "Test Realistic Simulation Workflow" begin
cmd = `nextflow run main.nf -entry REALISTIC_SIMULATION -c test/configs/simulation.config $args`
@info string("The following command will be run:\n", cmd)

r = run(cmd)
@test r.exitcode == 0
end

end
5 changes: 0 additions & 5 deletions workflows/simulations.nf
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,4 @@ workflow REALISTIC_SIMULATION {

// Aggregation of Estimation Results
AggregateSimulationResults(simulation_results.collect(), "realistic_simulation_results.hdf5")
}

workflow SIMULATIONS {
NULL_SIMULATION()
REALISTIC_SIMULATION()
}

0 comments on commit fb95ee4

Please sign in to comment.