Skip to content

Commit

Permalink
Update manuscript figures per review (#72)
Browse files Browse the repository at this point in the history
* update manuscript figure per review

* add figure 4 to main README
  • Loading branch information
jenna-tomkinson authored Sep 5, 2024
1 parent e581f47 commit 775cc9a
Show file tree
Hide file tree
Showing 24 changed files with 1,273 additions and 579 deletions.
Binary file modified 3.figures/figures/main_figure_4_feature_importance.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified 3.figures/figures/supplementary/supp_figure_1_splitbyplate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
51 changes: 31 additions & 20 deletions 3.figures/main_figure_4/2.generate_image_montage.ipynb

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions 3.figures/main_figure_4/3.main_figure_4.ipynb

Large diffs are not rendered by default.

Binary file modified 3.figures/main_figure_4/correlation_feature_montage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified 3.figures/main_figure_4/intensity_feature_montage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified 3.figures/main_figure_4/radial_feature_montage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 12 additions & 10 deletions 3.figures/main_figure_4/scripts/2.generate_image_montage.r
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ list_of_images <- list(
width <- 2.5
height <- 2.5

text_size <- 8
text_size <- 10

options(repr.plot.width = width, repr.plot.height = height)

Expand Down Expand Up @@ -194,17 +194,17 @@ options(repr.plot.width = width, repr.plot.height = height)
# ggplot of just text
radial_feat_text <- (
ggplot()
+ geom_text(aes(x = 0.5, y = 0.5, label = "Cytoplasm_RadialDistribution_FracAtD_RFP_4of4"), size = text_size)
+ geom_text(aes(x = 0.5, y = 0.5, label = "CellProfiler feature:\nCytoplasm_RadialDistribution_FracAtD_RFP_4of4"), size = text_size)
+ theme_void()
)
int_feat_text <- (
ggplot()
+ geom_text(aes(x = 0.5, y = 0.5, label = "Cytoplasm_Intensity_MeanIntensityEdge_GFP"), size = text_size)
+ geom_text(aes(x = 0.5, y = 0.5, label = "CellProfiler feature:\nCytoplasm_Intensity_MeanIntensityEdge_GFP"), size = text_size)
+ theme_void()
)
corr_feat_text <- (
ggplot()
+ geom_text(aes(x = 0.5, y = 0.5, label = "Cells_Correlation_Correlation_DAPI_GFP"), size = text_size)
+ geom_text(aes(x = 0.5, y = 0.5, label = "CellProfiler feature:\nCells_Correlation_Correlation_DAPI_GFP"), size = text_size)
+ theme_void()
)

Expand Down Expand Up @@ -233,8 +233,8 @@ options(repr.plot.width = width, repr.plot.height = height)
radial_patch_text

# Create montage
width <- 12.5
height <- 8
width <- 17.5
height <- 11

options(repr.plot.width = width, repr.plot.height = height)

Expand All @@ -259,8 +259,8 @@ ggsave(
)

# Create montage
width <- 12.5
height <- 8
width <- 17.5
height <- 11

options(repr.plot.width = width, repr.plot.height = height)

Expand All @@ -285,8 +285,8 @@ ggsave(
)

# Create montage
width <- 12.5
height <- 8
width <- 17.5
height <- 11

options(repr.plot.width = width, repr.plot.height = height)

Expand All @@ -309,3 +309,5 @@ ggsave(
),
corr_feat_plot, width = width, height = height, dpi = 600
)


4 changes: 2 additions & 2 deletions 3.figures/main_figure_4/scripts/3.main_figure_4.r
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,8 @@ radial_montage <- ggplot() +
radial_montage

bottom_montage <- (
free(corr_montage) |
radial_montage
free(radial_montage) |
corr_montage
) + plot_layout(widths = c(1,1.25))

bottom_montage
Expand Down
177 changes: 97 additions & 80 deletions 3.figures/supp_figure_1/SuppFigure1_splitbyplate.ipynb

Large diffs are not rendered by default.

20 changes: 19 additions & 1 deletion 3.figures/supp_figure_1/scripts/SuppFigure1_splitbyplate.r
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ suppressPackageStartupMessages(library(dplyr))
suppressPackageStartupMessages(library(ggplot2))
suppressPackageStartupMessages(library(grid))
suppressPackageStartupMessages(library(patchwork))
suppressPackageStartupMessages(library(platetools))

figure_dir <- "../figures/supplementary"
output_supp_figure_1 <- file.path(figure_dir, "supp_figure_1_splitbyplate.png")
Expand All @@ -17,6 +16,12 @@ UMAP_results_file <- file.path(UMAP_results_dir, "UMAP_concat_model_plates_sc_fe

UMAP_results_df <- readr::read_tsv(UMAP_results_file)

UMAP_results_df <- UMAP_results_df %>%
mutate(Metadata_Plate = recode(Metadata_Plate,
"Plate_3" = "Plate A",
"Plate_3_prime" = "Plate B",
"Plate_5" = "Plate C"))

dim(UMAP_results_df)
head(UMAP_results_df)

Expand Down Expand Up @@ -106,6 +111,19 @@ corr_results_dir <- file.path(
corr_results_file <- file.path(corr_results_dir, "well_agg_plate_genotype_correlations.parquet")
corr_results_df <- arrow::read_parquet(corr_results_file)

# Rename plates in both group columns
corr_results_df <- corr_results_df %>%
mutate(
Metadata_Plate__group0 = recode(Metadata_Plate__group0,
"Plate_3" = "Plate A",
"Plate_3_prime" = "Plate B",
"Plate_5" = "Plate C"),
Metadata_Plate__group1 = recode(Metadata_Plate__group1,
"Plate_3" = "Plate A",
"Plate_3_prime" = "Plate B",
"Plate_5" = "Plate C")
)

# Filter rows where Metadata_Plate__group0 matches Metadata_Plate__group1
filtered_df <- corr_results_df %>%
filter(Metadata_Plate__group0 == Metadata_Plate__group1)
Expand Down
4 changes: 2 additions & 2 deletions 3.figures/supp_figure_2/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Creating supplemental figure 2 - Image quality control distributions
# Creating supplemental figure 2 - Plate maps

To generate the second supplemental figure of the manuscript, there is one step to follow:

1. [SuppFigure2_qualitycontrol.ipynb](./SuppFigure2_qualitycontrol.ipynb): Generate distribution plots for blur and saturation metrics across plate, and patch the plots together to make one figure.
1. [SuppFigure2_platemaps.ipynb](./SuppFigure2_platemaps.ipynb): Generate platemap layout figures per plate.

All steps can be ran with the bash script using the command below:

Expand Down
520 changes: 520 additions & 0 deletions 3.figures/supp_figure_2/SuppFigure2_platemaps.ipynb

Large diffs are not rendered by default.

450 changes: 0 additions & 450 deletions 3.figures/supp_figure_2/SuppFigure2_qualitycontrol.ipynb

This file was deleted.

82 changes: 82 additions & 0 deletions 3.figures/supp_figure_2/scripts/SuppFigure2_platemaps.r
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
suppressPackageStartupMessages(library(dplyr))
suppressPackageStartupMessages(library(ggplot2))
suppressPackageStartupMessages(library(platetools))
suppressPackageStartupMessages(library(patchwork))

figure_dir <- "../figures/supplementary"
output_supp_figure_2 <- file.path(figure_dir, "supp_figure_2_platemaps.png")

# Path to platemaps
platemap_dir <- file.path(
"../../../nf1_cellpainting_data/0.download_data/metadata"
)

# Load data
plate_A_B_file <- file.path(platemap_dir, "platemap_NF1_plate3.csv")

plate_A_B_df <- readr::read_csv(plate_A_B_file)

# Remove rows where genotype is "HET"
plate_A_B_df <- plate_A_B_df %>%
filter(!grepl("HET", genotype))

dim(plate_A_B_df)
head(plate_A_B_df)

platemap_A_B <-
platetools::raw_map(
data = as.numeric(plate_A_B_df$seed_density),
well = plate_A_B_df$well_position,
plate = 96,
size = 8
) +
theme(plot.title = element_text(size = 10, face = "bold")) +
ggplot2::geom_point(aes(shape = plate_A_B_df$genotype)) +
ggplot2::scale_shape_discrete(name = "Genotype") +
ggplot2::scale_fill_gradient2(
name = "Seed Density",
low = "white",
high = "red",
)

platemap_A_B

# Load data
plate_C_file <- file.path(platemap_dir, "platemap_NF1_plate5.csv")

plate_C_df <- readr::read_csv(plate_C_file)

# Remove rows where genotype is "HET"
plate_C_df <- plate_C_df %>%
filter(!grepl("HET", genotype))

dim(plate_C_df)
head(plate_C_df)

platemap_C <-
platetools::raw_map(
data = plate_C_df$genotype,
well = plate_C_df$well_position,
plate = 96,
size = 8
) +
theme(plot.title = element_text(size = 10, face = "bold")) +
ggplot2::scale_fill_discrete(name = "Genotype")

platemap_C

align_plot <- (
platemap_A_B /
platemap_C
) + plot_layout(heights= c(2,2))

align_plot

supp_fig_2_gg <- (
align_plot
) + plot_annotation(tag_levels = "A") & theme(plot.tag = element_text(size = 20))

# Save or display the plot
ggsave(output_supp_figure_2, plot = supp_fig_2_gg, dpi = 500, height = 7.75, width = 7)

supp_fig_2_gg
2 changes: 1 addition & 1 deletion 3.figures/supp_figure_2/supp_figure_2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ conda activate nf1_figures
jupyter nbconvert --to script --output-dir=scripts/ *.ipynb

# run notebooks to generate supplemental figure 2
Rscript scripts/SuppFigure2_qaulitycontrol.r
Rscript scripts/SuppFigure2_platemaps.r
11 changes: 11 additions & 0 deletions 3.figures/supp_figure_3/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Creating supplemental figure 3 - Image quality control distributions

To generate the third supplemental figure of the manuscript, there is one step to follow:

1. [SuppFigure3_qualitycontrol.ipynb](./SuppFigure3_qualitycontrol.ipynb): Generate distribution plots for blur and saturation metrics across plate, and patch the plots together to make one figure.

All steps can be ran with the bash script using the command below:

```bash
source supp_figure_3.sh
```
Loading

0 comments on commit 775cc9a

Please sign in to comment.