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

How to display differences from Variant Calling File? #53

Closed bioinfornatics closed 3 years ago

bioinfornatics commented 3 years ago

Dear,

I would like to use your awesome library with pysam in order to display the difference between two sequences. I see they are GeneBlock for this purpose. So how to create a such instance from a list of variations ?

Thanks

best regards

bioinfornatics commented 3 years ago

Using pysam.VariantFile I am am able to convert variation to a collection of Bio.SeqFeature which are translated (BiopythonTranslator) to a collection of dna_features_viewer.GraphicRecord.GraphicRecord The result is quite good, I stuck currently to display a coord label for each tick of those features on the ruler. Did you know how to do this ?

test

veghp commented 3 years ago

Hi, thanks for the question & answer, that looks great! I personally didn't know, so if you don't mind sending the script, then we can include it here and as one of the Examples. To answer the original question, if you can produce the variants as Biopython records, then you can use Geneblocks or CUBA compare-two-sequences.

Zulko commented 3 years ago

+1 for @veghp 's answer above, please share the script if you can! Btw @veghp did you guess what famous sequence this is?

display a coord label for each tick of those features on the ruler. Did you know how to do this ?

One way is to use Matplotlib's ax.set_xticks([list of indices]), but this may create collisions if your indices are too close from one another. Another way is to add the index to the feature label, for instance "535\nReplaced G->T". This way Dna Features Viewer should detect close labels and display them under one another. Cosmetic pro tip: you can use ax2.invert_yaxis() on the bottom ax so that the Replaced G->T annotations will appear below the ax rather than above.

veghp commented 3 years ago

No I didn't look at it closely, but I see now that this is Covid-19! Nice.

bioinfornatics commented 3 years ago

Thanks. The script will be released freely soon :-)