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

Plotting specific coordinates from a gff3 file #44

Closed soungalo closed 3 years ago

soungalo commented 3 years ago

Suppose I have a gff3 file and I want to plot everything on chr1 positions 1000-2000. Can you please provide some example code? Should I use the BiopythonTranslator class? How exactly? (maybe there should be an example in the documentation). Thanks!

veghp commented 3 years ago

Hi, thanks for trying this package out. I think your question has been answered in https://github.com/Edinburgh-Genome-Foundry/DnaFeaturesViewer/issues/34#issuecomment-618324166.

Specifically, you can plot only a section of the record (from start to end):

start = 1000
end = 2000
record = BiopythonTranslator().translate_record(gff_records[0][start:end])
ax, _ = record.plot(figure_width=10, strand_in_label_threshold=7)

see the other thread for details, and please let me know if that solves the problem.

APengs494 commented 2 years ago

How to use GraphicFeature to change gene color from gff3 files.

veghp commented 2 years ago

Define your biopython translator with a custom set of colours, as described in the documentation: https://github.com/Edinburgh-Genome-Foundry/DnaFeaturesViewer#custom-biopython-translators

then you can use it to read your gff file and plot it.