Closed mortonjt closed 4 years ago
To zoom in, use .crop(). See the examples in the Readme
On Fri, 14 Feb 2020, 17:08 Jamie Morton, notifications@github.com wrote:
This is an amazing library - I love how tightly it is integrated with matplotlib.
I've got a genome that I'm trying to perform more in depth analysis (example code is below using the ncov2019 genome https://www.ncbi.nlm.nih.gov/nuccore/MN908947)
from dna_features_viewer import BiopythonTranslatorfrom Bio import SeqIOimport matplotlib.pyplot as plt
fig, (ax1, ax2, ax3, ax4, ax5) = plt.subplots( 5, 1, figsize=(15, 10), sharex=True, gridspec_kw={"height_ratios": [5, 1, 1, 1, 1]} ) record = SeqIO.read("sequence.gb", "genbank") graphic_record = BiopythonTranslator().translate_record(record) graphic_record.plot(ax=ax1, with_ruler=False, strand_in_label_threshold=4)
gc = lambda s: 100.0 * len([c for c in s if c in "GC"]) / 50 xx = np.arange(len(record.seq) - 50) yy = [gc(record.seq[x : x + 50]) for x in xx] ax2.fill_between(xx + 25, yy, alpha=0.3) ax2.set_ylim(bottom=0) ax2.set_ylabel("GC(%)")
ax3.plot(filtY[:, 0]) ax3.set_ylabel('(R/Y)') ax4.plot(filtY[:, 1]) ax4.set_ylabel('(A/G)') ax5.plot(filtY[:, 2]) ax5.set_ylabel('(C/T)')
So far, I'm able to generate a beautiful genome plot [image: Screenshot 2020-02-14 12 04 18] https://user-images.githubusercontent.com/4184797/74551947-33841d00-4f22-11ea-866e-ab00e810d73f.png
But when I try to zoom in with
for ax in [ax1, ax2, ax3, ax4, ax5]: ax.set_xlim([24000, 25000])
The plot seems to implode
[image: Screenshot 2020-02-14 12 04 26] https://user-images.githubusercontent.com/4184797/74551941-2f57ff80-4f22-11ea-93bd-56f9fe3802ab.png
Not sure what is going on here (may require a closer look at the internals) - but these sorts of features would be incredibly useful to have ready out-of-the-box for genome wide analysis.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Edinburgh-Genome-Foundry/DnaFeaturesViewer/issues/30?email_source=notifications&email_token=AAMR4KRI2X2IYNLZRTAVJGDRC3FYXA5CNFSM4KVMFGM2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4INUDNBQ, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAMR4KUYQMIZOE2DX7PFP23RC3FYXANCNFSM4KVMFGMQ .
Ok, that fixed it. Thanks!
This is an amazing library - I love how tightly it is integrated with matplotlib.
I've got a genome that I'm trying to perform more in depth analysis (example code is below using the ncov2019 genome)
So far, I'm able to generate a beautiful genome plot
But when I try to zoom in with
The plot seems to implode
Not sure what is going on here (may require a closer look at the internals) - but these sorts of features would be incredibly useful to have ready out-of-the-box for genome wide analysis.
EDIT: the problem seems to be arising due to Jupyter. When I save these plots to a file, it seems to be ok
Although, this is still problematic - if I zoom in to a 50bp region, I get