Skip to content

Commit

Permalink
Saved figures as ggplot2 objects to enable reloading and modification.
Browse files Browse the repository at this point in the history
  • Loading branch information
grahnavard committed Nov 14, 2024
1 parent e7644c3 commit 601bc6d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
^\.github$
^.*\.Rproj$
^\.Rproj\.user$
14 changes: 12 additions & 2 deletions R/viz.R
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,11 @@ maaslin3_summary_plot <-
invokeRestart("muffleWarning")
})
})
saveRDS(final_plot,
file = paste(figures_folder,
"/" ,
"summary_plot_gg.RDS",
sep = ""))
}
}

Expand Down Expand Up @@ -1380,7 +1385,6 @@ maaslin3_association_plots <-
)

saved_plots <- list()

features_by_metadata <-
unique(merged_results[, c('feature', 'metadata', 'model')])

Expand Down Expand Up @@ -1412,7 +1416,6 @@ maaslin3_association_plots <-
dplyr::inner_join(feature_abun, metadata_sub, by = c('sample'))

model_name <- features_by_metadata[row_num, 'model']

this_signif_association <-
merged_results[merged_results$feature == feature_name &
merged_results$metadata == metadata_name &
Expand Down Expand Up @@ -1444,6 +1447,7 @@ maaslin3_association_plots <-

saved_plots[[metadata_name]][[feature_name]][[model_name]] <-
temp_plot

}

association_plots_folder <-
Expand All @@ -1454,6 +1458,12 @@ maaslin3_association_plots <-

# Save all plots
for (metadata_variable in names(saved_plots)) {
saveRDS(saved_plots[[metadata_variable]],
file = paste(association_plots_folder,
"/" ,
metadata_variable,
"_gg_associations.RDS",
sep = ""))
for (feature in names(saved_plots[[metadata_variable]])) {
for (model_name in names(
saved_plots[[metadata_variable]][[feature]])) {
Expand Down

0 comments on commit 601bc6d

Please sign in to comment.