Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --noprune opt to retain small features in microsynteny plots. #624

Merged
merged 1 commit into from
Feb 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions jcvi/graphics/synteny.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,7 @@ def __init__(
glyphstyle: str = "arrow",
glyphcolor: BasePalette = OrientationPalette(),
seed: Optional[int] = None,
prune_features=True,
):
_, h = fig.get_figwidth(), fig.get_figheight()
bed = Bed(bedfile)
Expand All @@ -465,13 +466,15 @@ def __init__(
start, end, _, _, chrom, _, span = ext
start, end = start.start, end.end # start, end coordinates
ef = list(extra_features.extract(chrom, start, end))

# Pruning removes minor features with < 0.1% of the region
ef_pruned = [x for x in ef if x.span >= span / 1000]
logger.info(
"Extracted %d features (%d after pruning)", len(ef), len(ef_pruned)
)
extras.append(ef_pruned)
if prune_features:
ef_pruned = [x for x in ef if x.span >= span / 1000]
logger.info(f'Extracted {len(ef)} features ({len(ef_pruned)} after pruning)')
extras.append(ef_pruned)
else:
ef_all = [x for x in ef]
extras.append(ef_all)

maxspan = max(exts, key=lambda x: x[-1])[-1]
scale = maxspan / CANVAS_SIZE
Expand Down Expand Up @@ -672,6 +675,12 @@ def main():
default="",
help="Prefix for the output file",
)
p.add_option(
"--noprune",
default=True,
action="store_false",
help="If set, do not exclude small features from annotation track. ",
)
opts, args, iopts = p.set_image_options(figsize="8x7")

if len(args) != 3:
Expand Down Expand Up @@ -702,6 +711,7 @@ def main():
glyphstyle=opts.glyphstyle,
glyphcolor=opts.glyphcolor,
seed=iopts.seed,
prune_features=opts.noprune,
)

root.set_xlim(0, 1)
Expand Down
Loading