Skip to content

Commit

Permalink
Merge pull request #4 from czbiohub-sf/v0.0.5-metrics
Browse files Browse the repository at this point in the history
v0.0.7 update
  • Loading branch information
mwlkhoo authored Mar 7, 2024
2 parents 17a866a + a72a342 commit 92745ca
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 19 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def get_data_files(parent_dir):

setup(
name="stats_utils",
version="0.0.5",
version="0.0.7",
description="Statistics utilities for remoscope and corresponding paper",
long_description=readme(),
url="https://github.com/czbiohub-sf/remo-stats-utils",
Expand Down
52 changes: 34 additions & 18 deletions stats_utils/compensator.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@


class CountCompensator(CountCorrector):
def __init__(self, model_name: str, clinical=True, heatmaps=False):
def __init__(
self,
model_name: str,
clinical: bool = True,
heatmaps: bool = False,
skip: bool = False,
):
"""
Initialize count compensator
Expand All @@ -39,28 +45,38 @@ def __init__(self, model_name: str, clinical=True, heatmaps=False):
- heatmaps (optional):
True for heatmap nuked data
False otherwise (default)
- skip (optional):
True to skip compensation (will ignore previous clinical and heatmap args in)
False to proceed with normal compensation, according to other args in(default)
"""

# Generate directory for compensation metrics csv
if clinical:
suffix1 = CLINICAL_COMPENSATION_SUFFIX1
else:
suffix1 = CULTURED_COMPENSATION_SUFFIX1
if heatmaps:
suffix2 = W_HEATMAPS_SUFFIX2
if skip:
m = 1.0
b = 0.0
cov_m = 0.0
cov_b = 0.0
else:
suffix2 = NO_HEATMAPS_SUFFIX2
compensation_csv_dir = str(
DATA_DIR / model_name / (model_name + suffix1 + suffix2)
)

# Check that compensation metrics csv exists
if not Path(compensation_csv_dir).is_file():
raise FileNotFoundError(
f"Could not find compensation metrics for {model_name} ({compensation_csv_dir})"
# Generate directory for compensation metrics csv
if clinical:
suffix1 = CLINICAL_COMPENSATION_SUFFIX1
else:
suffix1 = CULTURED_COMPENSATION_SUFFIX1
if heatmaps:
suffix2 = W_HEATMAPS_SUFFIX2
else:
suffix2 = NO_HEATMAPS_SUFFIX2
compensation_csv_dir = str(
DATA_DIR / model_name / (model_name + suffix1 + suffix2)
)

m, b, cov_m, cov_b = self._get_fit_metrics(compensation_csv_dir)
# Check that compensation metrics csv exists
if not Path(compensation_csv_dir).is_file():
raise FileNotFoundError(
f"Could not find compensation metrics for {model_name} ({compensation_csv_dir})"
)

m, b, cov_m, cov_b = self._get_fit_metrics(compensation_csv_dir)

inv_cmatrix = self._get_matrix(m, b)
inv_cmatrix_std = self._get_matrix_std(cov_m, cov_b)

Expand Down

0 comments on commit 92745ca

Please sign in to comment.