Skip to content

Commit

Permalink
Better documentation and debug error in plotting allele stats for 0 a…
Browse files Browse the repository at this point in the history
…lleles
  • Loading branch information
jykr committed May 6, 2024
1 parent 9024cae commit f20315d
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions bean/framework/ReporterScreen.py
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,7 @@ def get_normalized_allele_counts(self, allele_count_df=None, norm_thres=10):
norm_counts = self._get_allele_norm(
allele_count_df=allele_count_df, thres=norm_thres
)
alleles_norm.loc[:, count_columns] = alleles_norm.loc[:, count_columns].astype(float)
alleles_norm.loc[:, count_columns] = (
alleles_norm.loc[:, count_columns] / norm_counts
)
Expand Down
2 changes: 1 addition & 1 deletion bean/model/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def parse_args(parser=None):
"--control-condition",
default="bulk",
type=str,
help="Value in `bdata.samples[condition_col]` that indicates control experimental condition whose editing patterns will be used.",
help="Value in `bdata.samples[condition_col]` that indicates control experimental condition whose editing patterns will be used. Select this as the condition with the least selection- For the sorting screen, use presort (bulk). For the survival screens, use the closest one with T=0.",
)
parser.add_argument(
"--exclude-control-condition-for-inference",
Expand Down
2 changes: 1 addition & 1 deletion bean/model/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def check_args(args, bdata):
)
if args.control_condition not in bdata.samples[args.condition_col].tolist():
raise ValueError(
f"No sample has control label `{args.control_condition}` (set by `--control-condition`) in ReporterScreen.samples[{args.condition_col}]: {bdata.samples[args.condition_col]}. Check your input."
f"No sample has control label `{args.control_condition}` (set by `--control-condition`) in ReporterScreen.samples[{args.condition_col}]: {bdata.samples[args.condition_col]}. Check your input. For the selection of this argument, see more in `--condition-col` under `bean run --help`."
)
if args.replicate_col not in bdata.samples.columns:
raise ValueError(
Expand Down
3 changes: 2 additions & 1 deletion bean/plotting/allele_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ def plot_n_guides_per_edit(
n_guides = edits_df.groupby("edits")["guide"].count()
if ax is None:
fig, ax = plt.subplots()
ax.hist(n_guides, bins=np.arange(min(n_guides) - 0.5, max(n_guides) + 0.5))
if len(n_guides) > 0:
ax.hist(n_guides, bins=np.arange(min(n_guides) - 0.5, max(n_guides) + 0.5))
ax.set_xlabel("# guides per variant")
ax.set_title(f"n_variants={len(edits_df)}")
ax.set_ylabel("# edits")
Expand Down

0 comments on commit f20315d

Please sign in to comment.