Skip to content

Commit

Permalink
Add fitting results on full dataset
Browse files Browse the repository at this point in the history
Signed-off-by: Liang Zhang <[email protected]>
  • Loading branch information
psychelzh committed Apr 15, 2024
1 parent e7bda8d commit becc825
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 2 deletions.
54 changes: 54 additions & 0 deletions _scripts/analyze_factors.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,25 @@ tar_option_set(
)
setup_parallel_plan()

targets_cfa <- tarchetypes::tar_map(
list(type = rlang::syms(c("efa", "chc", "cognition"))),
tar_target(
config_dims,
config_dims_alternatives |>
select(manifest, latent = type)
),
tarchetypes::tar_map(
hypers_model,
tar_fit_cfa(
config_dims,
indices_cogstruct_games_censored,
theory = theory,
missing = "ml",
tar_post_fit = "gof"
)
)
)

list(
tarchetypes::tar_file_read(
indices_cogstruct_games_censored,
Expand Down Expand Up @@ -86,5 +105,40 @@ list(
list_rbind(),
fit_bootstrap
)
),
tarchetypes::tar_file_read(
config_dims_theory,
"config/game_dims_theory.csv",
read = read_csv(!!.x, col_types = cols(game_id = "I"))
),
tar_target(
config_dims_alternatives,
config_dims_theory |>
unite(manifest, game_name_abbr, index_name, sep = ".") |>
inner_join(rename(model_efa, efa = latent), by = "manifest")
),
tar_target(
file_config_dims,
config_dims_alternatives |>
writexl::write_xlsx("_output/config_dims.xlsx"),
format = "file"
),
targets_cfa,
tarchetypes::tar_combine(
gofs,
zutils::select_list(targets_cfa, starts_with("gof")),
command = list(!!!.x) |>
map(as_tibble) |>
bind_rows(.id = ".id") |>
zutils::separate_wider_dsv(
".id",
c(names(hypers_model), "type"),
patterns = c(".+?", ".+"),
prefix = "gof"
)
),
tar_target(
scores,
extract_latent_scores(fit_bf_efa, indices_cogstruct_games_censored)
)
)
5 changes: 3 additions & 2 deletions _scripts/predict_phenotypes.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ setup_parallel_plan()

config_neural <- prepare_config_neural(
xcpd == "gsr",
run == "full"
run == "full",
atlas == "4S256Parcels"
)
hypers_cpm <- hypers_cpm |>
dplyr::filter(
Expand Down Expand Up @@ -105,7 +106,7 @@ cpm_branches_perms <- tarchetypes::tar_map(
list(
tarchetypes::tar_file_read(
scores,
path_obj_from_proj("scores", "cognition_structure"),
path_obj_from_proj("scores", "analyze_factors"),
read = qs::qread(!!.x)
),
tar_prepare_neural_data(config_neural),
Expand Down

0 comments on commit becc825

Please sign in to comment.