222
222
@test_throws ArgumentError TargeneCore. treatments_from_actors (1 , nothing , nothing )
223
223
@test_throws ArgumentError TargeneCore. treatments_from_actors (nothing , 1 , nothing )
224
224
225
- bqtl_file = joinpath (" data" , " bqtls .csv" )
225
+ bqtl_file = joinpath (" data" , " bqtls_1 .csv" )
226
226
trans_actors_prefix = joinpath (" data" , " trans_actors_1.csv" )
227
227
env_file = joinpath (" data" , " extra_treatments.txt" )
228
228
# bqtls and trans_actors
259
259
# - Order 1,2
260
260
parsed_args = Dict (
261
261
" from-actors" => Dict {String, Any} (
262
- " bqtls" => joinpath (" data" , " bqtls .csv" ),
262
+ " bqtls" => joinpath (" data" , " bqtls_1 .csv" ),
263
263
" trans-actors-prefix" => joinpath (" data" , " trans_actors_1.csv" ),
264
264
" extra-covariates" => joinpath (" data" , " extra_covariates.txt" ),
265
265
" extra-treatments" => joinpath (" data" , " extra_treatments.txt" ),
333
333
# - batched
334
334
parsed_args = Dict (
335
335
" from-actors" => Dict {String, Any} (
336
- " bqtls" => joinpath (" data" , " bqtls .csv" ),
336
+ " bqtls" => joinpath (" data" , " bqtls_1 .csv" ),
337
337
" trans-actors-prefix" => joinpath (" data" , " trans_actors_2" ),
338
338
" extra-covariates" => nothing ,
339
339
" extra-treatments" => nothing ,
@@ -361,10 +361,10 @@ end
361
361
@test size (traits) == (490 , 13 )
362
362
363
363
# Parameter files:
364
- ouparameters_1 = parameters_from_yaml (" final.param_1.yaml" )
365
- @test size (ouparameters_1 , 1 ) == 100
366
- ouparameters_2 = parameters_from_yaml (" final.param_2.yaml" )
367
- outparameters = vcat (ouparameters_1, ouparameters_2 )
364
+ outparameters_1 = parameters_from_yaml (" final.param_1.yaml" )
365
+ @test size (outparameters_1 , 1 ) == 100
366
+ outparameters_2 = parameters_from_yaml (" final.param_2.yaml" )
367
+ outparameters = vcat (outparameters_1, outparameters_2 )
368
368
369
369
found_targets = Dict (
370
370
:BINARY_1 => 0 ,
405
405
cleanup ()
406
406
end
407
407
408
+ @testset " Test tmle_inputs from-actors: scenario 3" begin
409
+ # Scenario:
410
+ # - Trans-actors
411
+ # - Extra Treatment
412
+ # - Extra Covariates
413
+ # - Order 1,2
414
+ # - More than 1 TF present
415
+ parsed_args = Dict (
416
+ " from-actors" => Dict {String, Any} (
417
+ " bqtls" => joinpath (" data" , " bqtls_2.csv" ),
418
+ " trans-actors-prefix" => joinpath (" data" , " trans_actors_3.csv" ),
419
+ " extra-covariates" => joinpath (" data" , " extra_covariates.txt" ),
420
+ " extra-treatments" => joinpath (" data" , " extra_treatments.txt" ),
421
+ " extra-confounders" => nothing ,
422
+ " orders" => " 1,2" ,
423
+ ),
424
+ " traits" => joinpath (" data" , " traits_1.csv" ),
425
+ " pcs" => joinpath (" data" , " pcs.csv" ),
426
+ " call-threshold" => 0.8 ,
427
+ " %COMMAND%" => " from-actors" ,
428
+ " bgen-prefix" => joinpath (" data" , " ukbb" , " imputed" ," ukbb" ),
429
+ " out-prefix" => " final" ,
430
+ " batch-size" => nothing ,
431
+ " positivity-constraint" => 0.
432
+ )
433
+ bqtls = Symbol .(unique (CSV. read (parsed_args[" from-actors" ][" bqtls" ], DataFrame). ID))
434
+ tmle_inputs (parsed_args)
435
+
436
+ # # Dataset file
437
+ trait_data = DataFrame (Arrow. Table (" final.data.arrow" ))
438
+ @test names (trait_data) == [
439
+ " SAMPLE_ID" , " BINARY_1" , " BINARY_2" , " CONTINUOUS_1" , " CONTINUOUS_2" ,
440
+ " COV_1" , " 21003" , " 22001" , " TREAT_1" , " PC1" , " PC2" , " RSID_2" , " RSID_102" ,
441
+ " RSID_17" , " RSID_198" , " RSID_99" ]
442
+ @test size (trait_data) == (490 , 16 )
443
+
444
+ # # Parameter file:
445
+ outparameters = [parameters_from_yaml (" final.TF1.param_1.yaml" ), parameters_from_yaml (" final.TF2.param_1.yaml" )]
446
+ found_targets = Dict (
447
+ :BINARY_1 => 0 ,
448
+ :CONTINUOUS_2 => 0 ,
449
+ :CONTINUOUS_1 => 0 ,
450
+ :BINARY_2 => 0
451
+ )
452
+ for tf in [1 ,2 ]
453
+ outparameters_tf = outparameters[tf]
454
+ for Ψ in outparameters_tf
455
+ if Ψ isa ATE
456
+ ntreatments = length (Ψ. treatment)
457
+ if ntreatments > 1
458
+ @test all (Ψ. treatment[index]. case == Ψ. treatment[index]. control for index ∈ 2 : ntreatments)
459
+ end
460
+ else
461
+ @test Ψ isa IATE
462
+ @test all (cc. case != cc. control for cc ∈ Ψ. treatment)
463
+ end
464
+ @test Ψ. covariates == [:COV_1 , Symbol (" 21003" ), Symbol (" 22001" )]
465
+ @test Ψ. confounders == [:PC1 , :PC2 ]
466
+ # The first treatment will be a bqtl
467
+ @test keys (Ψ. treatment)[1 ] ∈ bqtls
468
+ @test Ψ. treatment[1 ]. case isa AbstractString
469
+ @test length (Ψ. treatment) ∈ [1 , 2 ]
470
+ found_targets[Ψ. target] += 1
471
+ end
472
+ end
473
+ # The number of parameters with various targets should be the same
474
+ @test all (x == found_targets[:BINARY_1 ] for x in values (found_targets))
475
+ # This is difficult to really check the ordering
476
+ # Those correspond to the simple bQTL ATE
477
+ for tf in [1 ,2 ]
478
+ first_treatments = keys (outparameters[tf][1 ]. treatment)
479
+ @test all (keys (Ψ. treatment) == first_treatments for Ψ in outparameters[tf][1 : 12 ])
480
+ end
481
+
482
+ cleanup ()
483
+ end
484
+
408
485
end
409
486
410
487
true
0 commit comments