Edinburgh-Genome-Foundry / DnaFeaturesViewer

:eye: Python library to plot DNA sequence features (e.g. from Genbank files)
https://edinburgh-genome-foundry.github.io/DnaFeaturesViewer/
MIT License
584 stars 90 forks source link

Add an example which plots sequence features not starting from 0 #69

Closed alexlenail closed 2 years ago

alexlenail commented 2 years ago

I have a few sequence features I want to look at in the middle of a human chromosome. I can subtract an offset from each feature, but that's a little roundabout. Is there a way of plotting some tightly-spaced features in the middle of large genomes?

veghp commented 2 years ago

Hi, can you please clarify your question a bit? Do you want to plot only a subset of features? In that case the best approach is to create a graphic record that contains only the features you want to display. One way is to delete all other features, or use a custom biopython translator and filter based on feature location.

Zulko commented 2 years ago

If the goal is to "zoom" on the middle of a chromosome, then the best way is the cropping feature (see this section of the readme):

cropped_record = record.crop((400, 423))
cropped_record.plot_sequence()

image

alexlenail commented 2 years ago

Alas that didn't work, which caused me to raise the issue.

I got an error from

https://github.com/Edinburgh-Genome-Foundry/DnaFeaturesViewer/blob/1833d9e428713e02cb9c25c1d867d020ad50aec9/examples/overview_and_detail.py#L18

saying the numbers were out of bounds, despite the fact my features clearly overlapped them.

Zulko commented 2 years ago

This example works on my machine :thinking: . Are you running it on a different record? If yes could you provide the record and minimal code reproducing the issue?

alexlenail commented 2 years ago

Forgive me, I hadn't properly set sequence_length