Ejemplo n.º 1
0
# Now we can perform a multiple sequence alignment of the binding site
# sequences. Here we use Clustal Omega to perform this task.
# Since we have up to 200 sequences we visualize only a small portion of
# the alignment.

alignment = clustalo.ClustalOmegaApp.align(binding_sites)
fig = plt.figure(figsize=(4.5, 4.0))
ax = fig.add_subplot(111)
graphics.plot_alignment_similarity_based(
    ax, alignment[:,:20], labels=sources[:20], symbols_per_line=len(alignment)
)
# Source names in italic
ax.set_yticklabels(ax.get_yticklabels(), fontdict={"fontstyle":"italic"})
fig.tight_layout()

########################################################################
# Finally we can generate our sequence logo.

fig = plt.figure(figsize=(8.0, 3.0))
ax = fig.add_subplot(111)
graphics.plot_sequence_logo(ax, alignment)
ax.set_xticks([5,10,15,20])
ax.set_xlabel("Residue position")
ax.set_ylabel("Bits")
# Only show left and bottom spine
ax.spines["right"].set_visible(False)
ax.spines["top"].set_visible(False)
fig.tight_layout()
# sphinx_gallery_thumbnail_number = 2

plt.show()
Ejemplo n.º 2
0
@ticker.FuncFormatter
def sequence_loc_formatter(x, pos):
    x = normalize_seq_pos(x)
    return f"{x:+}"


COLOR_SCHEME = [
    biotite.colors["lightgreen"],  # A
    biotite.colors["orange"],  # C
    biotite.colors["dimgreen"],  # G
    biotite.colors["brightorange"],  # T
]

fig, ax = plt.subplots(figsize=(8.0, 3.0))
graphics.plot_sequence_logo(ax, profile, COLOR_SCHEME)

normalized_pos = np.array(
    [normalize_seq_pos(x) for x in range(len(profile.symbols))])
tick_locs = np.where(np.isin(normalized_pos, [-15, -10, -5, -1, 1]))[0]
ax.set_xticks(tick_locs)
ax.xaxis.set_major_formatter(ticker.FuncFormatter(sequence_loc_formatter))

ax.set_xlabel("Residue position")
ax.set_ylabel("Conservation (Bits)")
ax.spines["right"].set_visible(False)
ax.spines["top"].set_visible(False)
ax.legend(loc="upper left",
          handles=[
              Patch(color=biotite.colors["green"], label="Purine"),
              Patch(color=biotite.colors["lightorange"], label="Pyrimidine"),
Ejemplo n.º 3
0
fig = plt.figure(figsize=(4.5, 4.0))
ax = fig.add_subplot(111)
graphics.plot_alignment_similarity_based(ax,
                                         alignment[:, :20],
                                         labels=sources[:20],
                                         symbols_per_line=len(alignment))
# Source names in italic
ax.set_yticklabels(ax.get_yticklabels(), fontdict={"fontstyle": "italic"})
fig.tight_layout()

########################################################################
# Finally we can generate our sequence logo and the consensus sequence.

profile = seq.SequenceProfile.from_alignment(alignment)

print("Consensus sequence:")
print(profile.to_consensus())

fig = plt.figure(figsize=(8.0, 3.0))
ax = fig.add_subplot(111)
graphics.plot_sequence_logo(ax, profile, scheme="flower")
ax.set_xticks([5, 10, 15, 20])
ax.set_xlabel("Residue position")
ax.set_ylabel("Bits")
# Only show left and bottom spine
ax.spines["right"].set_visible(False)
ax.spines["top"].set_visible(False)
fig.tight_layout()
# sphinx_gallery_thumbnail_number = 2

plt.show()
Ejemplo n.º 4
0
    seq.NucleotideSequence("ttgacggctagctcagtcctaggtatagtgctagc"),
    seq.NucleotideSequence("ctgatagctagctcagtcctagggattatgctagc"),
    seq.NucleotideSequence("ctgatggctagctcagtcctagggattatgctagc"),
    seq.NucleotideSequence("tttatggctagctcagtcctaggtacaatgctagc"),
    seq.NucleotideSequence("tttatagctagctcagcccttggtacaatgctagc"),
    seq.NucleotideSequence("ttgacagctagctcagtcctagggactatgctagc"),
    seq.NucleotideSequence("ttgacagctagctcagtcctagggattgtgctagc"),
    seq.NucleotideSequence("ttgacggctagctcagtcctaggtattgtgctagc")
]
# Sequences do not need to be aligned
# -> Create alignment with trivial trace
# [[0 0 0 ...]
#  [1 1 1 ...]
#  [2 2 2 ...]
#     ...     ]
alignment = align.Alignment(
    sequences = seqs,
    trace     = np.tile(np.arange(len(seqs[0])), len(seqs)) \
                .reshape(len(seqs), len(seqs[0])) \
                .transpose(),
    score     = 0
)
# Create sequence logo from alignment
fig = plt.figure(figsize=(8.0, 1.5))
ax = fig.add_subplot(111)
profile = seq.SequenceProfile.from_alignment(alignment)
graphics.plot_sequence_logo(ax, profile)
# Remove the entire frame
ax.axis("off")
fig.tight_layout()
plt.show()