Skip to content
This repository was archived by the owner on Oct 15, 2025. It is now read-only.

Commit e957c31

Browse files
tanyasgTanya Grancharova
andauthored
Data/zero scores (#158)
* add 0 structure scores to bonus * update merging manual scores * add fish manual zero structure score csvs Co-authored-by: Tanya Grancharova <[email protected]>
1 parent 5336493 commit e957c31

File tree

6 files changed

+15382
-1004
lines changed

6 files changed

+15382
-1004
lines changed

data/structure_scores/holdout_fish_manual_scores.csv

Lines changed: 6720 additions & 1001 deletions
Large diffs are not rendered by default.

data/structure_scores/scores_bonus_fish_metadata.csv

Lines changed: 6720 additions & 0 deletions
Large diffs are not rendered by default.

data/structure_scores/scores_newACTN2_fish_metadata.csv

Lines changed: 1604 additions & 0 deletions
Large diffs are not rendered by default.

data/structure_scores/scores_originalACTN2_fish_metadata.csv

Lines changed: 299 additions & 0 deletions
Large diffs are not rendered by default.

fish_morphology_code/bin/add_fovid_to_structure_holdout_fish.py

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,18 @@
55

66

77
def run(
8-
structure_scores="../../data/structure_scores/KG_MH_scoring_all.csv",
8+
structure_scores="/allen/aics/gene-editing/FISH/2019/chaos/image_processing_scripts/fish_morphology_code/data/structure_scores/KG_MH_scoring_all.csv",
99
classifier_manifest="/allen/aics/assay-dev/computational/data/cardio_pipeline_datastep/local_staging_new_fish_max/singlecells/manifest.csv",
10-
out_csv="../../data/structure_scores/holdout_fish_manual_scores.csv",
10+
zero_scores="/allen/aics/gene-editing/FISH/2019/chaos/image_processing_scripts/fish_morphology_code/data/structure_scores/scores_bonus_fish_metadata.csv",
11+
out_csv="/allen/aics/gene-editing/FISH/2019/chaos/image_processing_scripts/fish_morphology_code/data/structure_scores/holdout_fish_manual_scores.csv",
1112
):
1213
r"""
1314
Write structure score csv that include image fovID from labkey
1415
Args:
1516
structure_scores (str): location (absolute path) to manual structure scores; score is actn2 organization score
1617
classifier_manifest (str): location (absolute path) to image manifest; image manifest must include both labkey fovID
1718
and cell ids used in structure classifier pipeline
19+
zero_scores (str): location (absolute path) to manual 0 structure scores; only 0 scores are indicated; all other are NaN
1820
structure_scores_updated (str): location (absolute path) where to save structure csv with fov id
1921
"""
2022

@@ -66,7 +68,28 @@ def run(
6668
]
6769
)
6870

69-
fish_classifier_manifest.to_csv(out_csv, index=False)
71+
# add manual zero structure score column if it exists
72+
if len(zero_scores) > 0:
73+
zero_scores_df = pd.read_csv(zero_scores)
74+
zero_scores_df = zero_scores_df.drop(columns=["Unnamed: 0"])
75+
zero_scores_df = zero_scores_df.rename(
76+
columns={
77+
"fov_id": "FOVId",
78+
"cell_label_value": "napariCell_ObjectNumber",
79+
"score": "no_structure",
80+
}
81+
)
82+
merged_scores = pd.merge(
83+
zero_scores_df,
84+
fish_classifier_manifest,
85+
on=["FOVId", "napariCell_ObjectNumber"],
86+
how="outer",
87+
)
88+
89+
merged_scores.to_csv(out_csv)
90+
91+
else:
92+
fish_classifier_manifest.to_csv(out_csv)
7093

7194

7295
if __name__ == "__main__":

fish_morphology_code/processing/merge_features/cp_processing_utils.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,11 +382,24 @@ def add_cell_structure_scores(cell_feature_df, structure_scores_csv):
382382

383383
# rename columns to match cell feature columns
384384
structure_score_df = pd.read_csv(structure_scores_csv, index_col=0)
385+
386+
# drop columns we don't need
387+
structure_score_df = structure_score_df.drop(
388+
columns=[
389+
"rescaled_2D_fov_tiff_path",
390+
"original_fov_location",
391+
"rescaled_2D_single_cell_tiff_path",
392+
"single_cell_id",
393+
]
394+
)
385395
structure_score_df = structure_score_df.rename(
386396
columns={
387397
"cell_num": "napariCell_ObjectNumber",
398+
"cell_label_value": "napariCell_ObjectNumber",
388399
"mh score": "mh_structure_org_score",
389400
"kg score": "kg_structure_org_score",
401+
"score": "no_structure",
402+
"fov_id": "FOVId",
390403
}
391404
)
392405

0 commit comments

Comments
 (0)