Skip to content

Commit

Permalink
WIP on load_experiment_data
Browse files Browse the repository at this point in the history
  • Loading branch information
alexzwanenburg committed Jan 6, 2025
1 parent 15aa242 commit e3f8a6f
Show file tree
Hide file tree
Showing 5 changed files with 294 additions and 61 deletions.
22 changes: 11 additions & 11 deletions R/DataPreProcessing.R
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
.get_feature_info_file_name <- function(file_paths, project_id) {
# Generate file name of pre-processing file
file_name <- paste0(project_id, "_feature_info.RDS")

# Add file path and normalise according to the OS
file_name <- normalizePath(file.path(
file_paths$process_data_dir, file_name
), mustWork = FALSE)

return(file_name)
}
# .get_feature_info_file_name <- function(file_paths, project_id) {
# # Generate file name of pre-processing file
# file_name <- paste0(project_id, "_feature_info.RDS")
#
# # Add file path and normalise according to the OS
# file_name <- normalizePath(file.path(
# file_paths$process_data_dir, file_name
# ), mustWork = FALSE)
#
# return(file_name)
# }



Expand Down
2 changes: 1 addition & 1 deletion R/DataServerBackend.R
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ get_feature_info_from_backend <- function(
} else if (!is.null(data_id) && !is.null(run_id)) {
# Retrieve run-specific feature information.
x <- get("master_feature_info_list", envir = data_env)[[
.get_feature_info_list_name(data_id = data_id, run_id = run_id)
paste0(data_id, ".", run_id)
]]

} else {
Expand Down
55 changes: 37 additions & 18 deletions R/ExperimentData.R
Original file line number Diff line number Diff line change
Expand Up @@ -74,30 +74,49 @@ load_experiment_data <- function(x, file_paths) {
# Start writing feature information.
if (!is.null(x@feature_info)) {

# Set file name
file_name <- .get_feature_info_file_name(
file_paths = file_paths,
project_id = x@project_id
)

# Check if the directory exists, and create it otherwise.
if (!dir.exists(dirname(file_name))) {
dir.create(dirname(file_name), recursive = TRUE)
}
for (feature_info_name in names(x@feature_info)) {
feature_info <- x@feature_info[[feature_info_name]]

# Set file name.
if (feature_info_name == "generic") {
file_name <- get_object_file_name(
object_type = "genericFeatureInfo",
project_id = feature_info@project_id,
dir_path = file_paths$process_data_dir
)

} else {
file_name <- get_object_file_name(
object_type = "featureInfo",
project_id = feature_info@project_id,
data_id = feature_info@data_id,
run_id = feature_info@run_id,
dir_path = file_paths$process_data_dir
)
}

# Check if the directory exists, and create it otherwise.
if (!dir.exists(file_paths$process_data_dir)) {
dir.create(file_paths$process_data_dir, recursive = TRUE)
}

# Write to file.
saveRDS(x@feature_info, file = file_name)
# Write to file.
saveRDS(feature_info, file = file_name)
}
}

# Write variable importance information.
if (!is.null(x@vimp_table_list)) {
for (vimp_method in names(x@vimp_table_list)) {
for (vimp_table in names(x@vimp_table_list)) {

# Set file name
file_name <- .get_variable_importance_data_filename(
project_id = x@project_id,
vimp_method = vimp_method,
file_paths = file_paths
file_name <- get_object_file_name(
object_type = "vimpTable",
data_id = vimp_table@data_id,
run_id = vimp_table@run_id,
vimp_method = vimp_table@vimp_method,
project_id = vimp_table@project_id,
dir_path = file_paths$vimp_dir
)

# Check if the directory exists, and create it otherwise.
Expand All @@ -106,7 +125,7 @@ load_experiment_data <- function(x, file_paths) {
}

# Write to file.
saveRDS(x@vimp_table_list[[vimp_method]], file = file_name)
saveRDS(vimp_table, file = file_name)
}
}

Expand Down
2 changes: 1 addition & 1 deletion R/FamiliarS4Classes.R
Original file line number Diff line number Diff line change
Expand Up @@ -989,7 +989,7 @@ setClass("vimpTable",
# Variable importance method that generated the current variable
# importance table.
vimp_method = "character",
# Run table for the current model
# Run table for the current table.
run_table = "ANY",
# Set how scores from encoded features should be aggregated.
score_aggregation = "character",
Expand Down
Loading

0 comments on commit e3f8a6f

Please sign in to comment.