Skip to content

Commit 5de7db0

Browse files
authored
Update Example Data (#244)
* fix(fpkm): update imports for zFPKM calculation improvements Signed-off-by: Josh Loecker <joshloecker@icloud.com> * fix(fpkm): use Salmon quantification instead of STAR quantification Signed-off-by: Josh Loecker <joshloecker@icloud.com> * chore: ruff formatting Signed-off-by: Josh Loecker <joshloecker@icloud.com> * chore: fill with integers for faster processing Signed-off-by: Josh Loecker <joshloecker@icloud.com> * chore: remove unnecessary async function usage Signed-off-by: Josh Loecker <joshloecker@icloud.com> * fix: remove non existant genes from conversion Signed-off-by: Josh Loecker <joshloecker@icloud.com> * refactor: use more explicit (albeit longer) code to create gene_info dataframe object Signed-off-by: Josh Loecker <joshloecker@icloud.com> * chore: import required modules Signed-off-by: Josh Loecker <joshloecker@icloud.com> * refactor: optional argument for fragment data Signed-off-by: Josh Loecker <joshloecker@icloud.com> * refactor: improve handling for single cell data Signed-off-by: Josh Loecker <joshloecker@icloud.com> * chore: generalize data type input Signed-off-by: Josh Loecker <joshloecker@icloud.com> * chore: ruff formatting Signed-off-by: Josh Loecker <joshloecker@icloud.com> * chore: simplify FPKM/RPKM calculations; properly compute per-gene FPKM scores Signed-off-by: Josh Loecker <joshloecker@icloud.com> * refactor: move zfpkm calculation to external package Signed-off-by: Josh Loecker <joshloecker@icloud.com> * chore: use np.bool for boolean array Signed-off-by: Josh Loecker <joshloecker@icloud.com> * chore: ruff formatting Signed-off-by: Josh Loecker <joshloecker@icloud.com> * feat: allow setting negative zFPKM results to 0 Signed-off-by: Josh Loecker <joshloecker@icloud.com> * feat: simplification to use external zfpkm package Signed-off-by: Josh Loecker <joshloecker@icloud.com> * feat: allow providing the fragment size filepath (from rnaseq preprocessing) Signed-off-by: Josh Loecker <joshloecker@icloud.com> * chore(ruff): reduce max line length Signed-off-by: Josh Loecker <joshloecker@icloud.com> * chore(ruff): mark unsorted imports as fixable Signed-off-by: Josh Loecker <joshloecker@icloud.com> * chore(uv): lock pyproject file Signed-off-by: Josh Loecker <joshloecker@icloud.com> * fix: rename count to quant in testing files Signed-off-by: Josh Loecker <joshloecker@icloud.com> * feat: add single cell normalization using scanpy defaults Signed-off-by: Josh Loecker <joshloecker@icloud.com> * fix: test new quant information Signed-off-by: Josh Loecker <joshloecker@icloud.com> * fix: test new quant information Signed-off-by: Josh Loecker <joshloecker@icloud.com> * chore: use quant files instead of strand files Signed-off-by: Josh Loecker <joshloecker@icloud.com> * chore: use quant files instead of strand files Signed-off-by: Josh Loecker <joshloecker@icloud.com> * chore: updated COMO_input files for naiveB to use updated FastqToGeneCounts information Signed-off-by: Josh Loecker <joshloecker@icloud.com> * feat: added Salmon quantification data for naive B Signed-off-by: Josh Loecker <joshloecker@icloud.com> * chore: use `_read_file` function to read data Signed-off-by: Josh Loecker <joshloecker@icloud.com> * fix(tests): remove 1 from expected gene names to fix header Signed-off-by: Josh Loecker <joshloecker@icloud.com> * fix(tests): use `endswith` instead of `is in` Signed-off-by: Josh Loecker <joshloecker@icloud.com> * fix(tests): Use missing file appropriately Signed-off-by: Josh Loecker <joshloecker@icloud.com> * chore(uv): Use dependency groups Signed-off-by: Josh Loecker <joshloecker@icloud.com> * revert: use synchronous programming for more deterministic usage Signed-off-by: Josh Loecker <joshloecker@icloud.com> * chore(type): fix pyrefly type errors Signed-off-by: Josh Loecker <joshloecker@icloud.com> * chore(type): fix ruff & pyrefly issues Signed-off-by: Josh Loecker <joshloecker@icloud.com> * refactor: rename `_log_and_raise_error` to `log_and_raise_error` Signed-off-by: Josh Loecker <joshloecker@icloud.com> * refactor: rename `_read_file` to `read_file` Signed-off-by: Josh Loecker <joshloecker@icloud.com> --------- Signed-off-by: Josh Loecker <joshloecker@icloud.com>
1 parent 6e632c1 commit 5de7db0

10 files changed

Lines changed: 499 additions & 488 deletions

main/como/cluster_rnaseq.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import numpy as np
99

1010
from como.data_types import LogLevel
11-
from como.utils import _log_and_raise_error, stringlist_to_list
11+
from como.utils import log_and_raise_error, stringlist_to_list
1212

1313

1414
@dataclass
@@ -35,35 +35,35 @@ def __post_init__(self): # noqa: C901, ignore too complex
3535
self.seed = np.random.randint(0, 100_000)
3636

3737
if (isdigit(self.min_active_count) and int(self.min_active_count) < 0) or self.min_active_count != "default":
38-
_log_and_raise_error(
38+
log_and_raise_error(
3939
"min_active_count must be either 'default' or an integer > 0",
4040
error=ValueError,
4141
level=LogLevel.ERROR,
4242
)
4343

4444
if (isdigit(self.quantile) and 0 > int(self.quantile) > 100) or self.quantile != "default":
45-
_log_and_raise_error(
45+
log_and_raise_error(
4646
"quantile must be either 'default' or an integer between 0 and 100",
4747
error=ValueError,
4848
level=LogLevel.ERROR,
4949
)
5050

5151
if (isdigit(self.replicate_ratio) and 0 > self.replicate_ratio > 1.0) or self.replicate_ratio != "default":
52-
_log_and_raise_error(
52+
log_and_raise_error(
5353
"--rep-ratio must be either 'default' or a float between 0 and 1",
5454
error=ValueError,
5555
level=LogLevel.ERROR,
5656
)
5757

5858
if (isdigit(self.batch_ratio) and 0 > self.batch_ratio > 1.0) or self.batch_ratio != "default":
59-
_log_and_raise_error(
59+
log_and_raise_error(
6060
"--batch-ratio must be either 'default' or a float between 0 and 1",
6161
error=ValueError,
6262
level=LogLevel.ERROR,
6363
)
6464

6565
if self.filtering_technique.lower() not in {"quantile", "tpm", "cpm", "zfpkm"}:
66-
_log_and_raise_error(
66+
log_and_raise_error(
6767
"--technique must be either 'quantile', 'tpm', 'cpm', 'zfpkm'",
6868
error=ValueError,
6969
level=LogLevel.ERROR,
@@ -73,35 +73,35 @@ def __post_init__(self): # noqa: C901, ignore too complex
7373
self.filtering_technique = "quantile"
7474

7575
if self.cluster_algorithm.lower() not in {"mca", "umap"}:
76-
_log_and_raise_error(
76+
log_and_raise_error(
7777
"--clust_algo must be either 'mca', 'umap'",
7878
error=ValueError,
7979
level=LogLevel.ERROR,
8080
)
8181

8282
if 0 > self.min_distance > 1.0:
83-
_log_and_raise_error(
83+
log_and_raise_error(
8484
"--min_dist must be a float between 0 and 1",
8585
error=ValueError,
8686
level=LogLevel.ERROR,
8787
)
8888

8989
if (isdigit(self.num_replicate_neighbors) and self.num_replicate_neighbors < 1) or self.num_replicate_neighbors != "default":
90-
_log_and_raise_error(
90+
log_and_raise_error(
9191
"--n-neighbors-rep must be either 'default' or an integer > 1",
9292
error=ValueError,
9393
level=LogLevel.ERROR,
9494
)
9595

9696
if (isdigit(self.num_batch_neighbors) and self.num_batch_neighbors < 1) or self.num_batch_neighbors != "default":
97-
_log_and_raise_error(
97+
log_and_raise_error(
9898
"--n-neighbors-batch must be either 'default' or an integer > 1",
9999
error=ValueError,
100100
level=LogLevel.ERROR,
101101
)
102102

103103
if (isdigit(self.num_context_neighbors) and self.num_context_neighbors < 1) or self.num_context_neighbors != "default":
104-
_log_and_raise_error(
104+
log_and_raise_error(
105105
"--n-neighbors-context must be either 'default' or an integer > 1",
106106
error=ValueError,
107107
level=LogLevel.ERROR,

main/como/combine_distributions.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
_OutputCombinedSourceFilepath,
1919
_SourceWeights,
2020
)
21-
from como.utils import LogLevel, _log_and_raise_error, _num_columns
21+
from como.utils import LogLevel, log_and_raise_error, _num_columns, get_missing_gene_data
2222

2323

2424
def _combine_z_distribution_for_batch(
@@ -186,7 +186,7 @@ def _combine_z_distribution_for_context(
186186
for res in zscore_results:
187187
matrix = res.z_score_matrix.copy()
188188
if len(matrix.columns) > 1:
189-
_log_and_raise_error(
189+
log_and_raise_error(
190190
f"Expected a single column for combined z-score dataframe for data '{res.type.value.lower()}'. Got '{len(matrix.columns)}' columns",
191191
error=ValueError,
192192
level=LogLevel.ERROR,
@@ -302,7 +302,7 @@ async def _begin_combining_distributions(
302302
else ""
303303
)
304304
if not index_name:
305-
_log_and_raise_error(
305+
log_and_raise_error(
306306
f"Unable to find common gene identifier across batches for source '{source.value}' in context '{context_name}'",
307307
error=ValueError,
308308
level=LogLevel.ERROR,

0 commit comments

Comments
 (0)