Skip to content

Commit

Permalink
debug errors in calculating edits
Browse files Browse the repository at this point in the history
  • Loading branch information
jykr committed Aug 26, 2024
1 parent e5b3a90 commit 3b40968
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
1 change: 1 addition & 0 deletions bean/cli/count.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def main(args):
counter.screen.uns["allele_counts"] = counter.screen.uns["allele_counts"].loc[
counter.screen.uns["allele_counts"].allele.map(str) != "", :
]
counter.screen.get_edit_from_allele("allele_counts", "allele")
if match_target_pos:
counter.screen.get_edit_mat_from_uns(target_base_edits, match_target_pos)
else:
Expand Down
4 changes: 3 additions & 1 deletion bean/cli/count_samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ def count_sample(R1: str, R2: str, sample_id: str, args: argparse.Namespace):
except KeyError as e:
raise KeyError(args_dict["edited_base"]) from e

match_target_pos = args_dict["match_target_pos"]
match_target_pos = (
args_dict["match_target_pos"] if not args_dict["tiling"] else False
)
if (
"guide_start_seqs_tbl" in args_dict
and args_dict["guide_start_seqs_tbl"] is not None
Expand Down
2 changes: 1 addition & 1 deletion bean/framework/ReporterScreen.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ def get_edit_mat_from_uns(
edits["guide_start_pos"] = (
reporter_length
- reporter_right_flank_length
- guide_len[edits.guide_idx].reset_index(drop=True)
- guide_len.iloc[edits.guide_idx].reset_index(drop=True)
)
if not match_target_position:
edits["rel_pos"] = edits.edit.map(lambda e: e.rel_pos)
Expand Down
8 changes: 3 additions & 5 deletions bean/preprocessing/data_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,10 @@ def transform_data(self, X, n_bins=None):
.T.reshape((self.n_reps, n_bins, self.n_guides))
.float()
)
except RuntimeError:
except RuntimeError as e:
print((self.n_reps, n_bins, self.n_guides))
print(X.shape)
exit(1)
raise e
if self.device is not None:
x = x.cuda()
return x
Expand Down Expand Up @@ -347,9 +347,7 @@ def _post_init(
]
edited_control = self.transform_data(screen_t.layers["edits"], n_bins=1)
nonedited_control = (
self.transform_data(
screen_t.layers["X_bcmatch"], len(self.control_condition)
)
self.transform_data(screen_t.layers["X_bcmatch"], n_bins=1)
- edited_control
)
nonedited_control[nonedited_control < 0] = 0
Expand Down
4 changes: 2 additions & 2 deletions tests/test_count.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def test_barcode_start_idx():

@pytest.mark.order(108)
def test_count_samples_tiling():
cmd = "bean count-samples -i tests/data/sample_list_tiling.csv -b A -f tests/data/test_guide_info_tiling_chrom.csv -o tests/test_res/tiling/ -r"
cmd = "bean count-samples -i tests/data/sample_list_tiling.csv -b A -f tests/data/test_guide_info_tiling_chrom.csv -o tests/test_res/tiling/ -r --tiling"
try:
subprocess.check_output(
cmd,
Expand All @@ -123,7 +123,7 @@ def test_count_samples_tiling():

@pytest.mark.order(109)
def test_count_chroms():
cmd = "bean count --R1 tests/data/test_tiling_R1.fastq --R2 tests/data/test_tiling_R2.fastq -b A -f tests/data/test_guide_info_tiling_chrom.csv -o tests/test_res/tiling_chrom/ -r"
cmd = "bean count --R1 tests/data/test_tiling_R1.fastq --R2 tests/data/test_tiling_R2.fastq -b A -f tests/data/test_guide_info_tiling_chrom.csv -o tests/test_res/tiling_chrom/ -r --tiling"
try:
subprocess.check_output(
cmd,
Expand Down

0 comments on commit 3b40968

Please sign in to comment.