Skip to content

Commit

Permalink
fix: update jump-portrait dependency and fix image loading issues
Browse files Browse the repository at this point in the history
Add note on casting of load_data_csv casting after cpg changes.
  • Loading branch information
afermg committed Feb 10, 2025
1 parent 990b386 commit 00241bd
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 16 deletions.
1 change: 1 addition & 0 deletions explanations/quirks_details.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ source_7 where the compounds were assayed at 0.625 uM (the goal being to assay s
compounds at a low concentration in addition to the higher concentration used for most of data
production). The positive control compounds in compound, ORF and CRISPR plates were assayed at 5
uM. JUMP-Target-1-Compound and JUMP-Target-2-Compound plates were also assayed at 5 uM
- Due to some plates having letters and numbers and others only numbers, be careful when loading multiple `load_data_csv`s. We treat all columns and strings to avoid any potential casting issue.
8 changes: 4 additions & 4 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ seaborn = "^0.13.2"
biopython = "^1.84"
broad-babel = ">=0.1.26"
copairs = "^0.4.1"
jump-portrait = "^0.0.26"
jump-portrait = "^0.0.27"

[tool.poetry.group.dev.dependencies]
ipdb = "^0.13.13"
Expand Down
34 changes: 23 additions & 11 deletions scripts/4_display_perturbation_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import polars as pl
from jump_portrait.fetch import get_item_location_info, get_jump_image
from matplotlib import pyplot as plt

#
# %% [markdown]
# First, we need to get location information telling us where all images corresponding to a specific perturbation can be found. We will use the "get_item_location" function from jump_portrait for this.
# Here we retrieve image locations for the "RAB30" gene:
Expand All @@ -36,6 +38,8 @@

print(cmpd_info_byinchi.shape)
print(cmpd_info_byjcp.shape)


# %% [markdown]
# There are 34 sites corresponding to this compound.
# We've written a function to display all channels for a specific image. Note that this is just one possible way to display images - we've included the function here so that you can modify it to suit your own needs.
Expand All @@ -45,7 +49,7 @@ def display_site(
batch: str,
plate: str,
well: str,
site: str,
site: int,
label: str,
int_percentile: float,
) -> None:
Expand Down Expand Up @@ -78,11 +82,11 @@ def display_site(
counter = 0

channel_rgb = {
"AGP": "#FF7F00", # Orange
"DNA": "#0000FF", # Blue
"ER": "#00FF00", # Green
"Mito": "#FF0000", # Red
"RNA": "#FFFF00", # Yellow
"AGP": "#FF7F00", # Orange
"DNA": "#0000FF", # Blue
"ER": "#00FF00", # Green
"Mito": "#FF0000", # Red
"RNA": "#FFFF00", # Yellow
}

for ax, (channel, rgb) in zip(axes, channel_rgb.items()):
Expand Down Expand Up @@ -124,10 +128,18 @@ def display_site(

# show plot
plt.tight_layout()


# %% [markdown]
# We can get the required location parameters from the location info that we retrieved earlier. Here we get parameters for the first site in the JCP compound results:
# %%
source, batch, plate, well, site, *rest = cmpd_info_byjcp.row(0)
(
source,
batch,
plate,
well,
site,
) = cmpd_info_byjcp.select(pl.col(f"Metadata_{x}" for x in ("Source", "Batch", "Plate", "Well", "Site"))).row(0)
# %% [markdown]
# Next, we define the label and make the plot:
# %%
Expand All @@ -145,9 +157,9 @@ def display_site(
# %% [markdown]
# Here, we plot one of the RAB30 ORF images:
# %%
source, batch, plate, well, site, *rest = gene_info.filter(
source, batch, plate, well, site = gene_info.filter(
pl.col("Metadata_PlateType") == "ORF"
).row(0)
).select(pl.col(f"Metadata_{x}" for x in ("Source", "Batch", "Plate", "Well", "Site"))).row(0)
display_site(
source,
batch,
Expand All @@ -160,9 +172,9 @@ def display_site(
# %% [markdown]
# And for CRISPR:
# %%
source, batch, plate, well, site, *rest = gene_info.filter(
source, batch, plate, well, site = gene_info.filter(
pl.col("Metadata_PlateType") == "CRISPR"
).row(0)
).select(pl.col(f"Metadata_{x}" for x in ("Source", "Batch", "Plate", "Well", "Site"))).row(0)
display_site(
source,
batch,
Expand Down

0 comments on commit 00241bd

Please sign in to comment.