Skip to content

Instantly share code, notes, and snippets.

@gpratt
Last active August 29, 2015 14:08
Show Gist options
  • Save gpratt/2497ac6b553dfe3dd119 to your computer and use it in GitHub Desktop.
Save gpratt/2497ac6b553dfe3dd119 to your computer and use it in GitHub Desktop.
plot_denovo_motifs
from clipper.src import CLIP_analysis
import os
viz = CLIP_analysis_display.ClipVisualization()
def plot_denovo_motifs(bedtool, fig=None):
root = "/Users/gpratt/bioinformatics/yeolab/iPython_Notebook/fox2/"
out_dir = os.path.join(root, "assigned/")
fasta_dir = os.path.join(root, "fasta/")
cluster_name = os.path.basename(bedtool.fn)
cluster_out = os.path.join(root, bedtool.fn + "_homer")
cluster_regions = CLIP_analysis.assign_to_regions(tool=bedtool,
clusters=cluster_name,
regions=regions,
assigned_dir = out_dir)
CLIP_analysis.make_fasta_files_from_regions(cluster_regions, cluster_name, fasta_dir, "/Users/gpratt/bioinformatics/genomes/hg19/chromosomes/all.fa")
CLIP_analysis.calculate_homer_motifs([5,6,7], regions, cluster_name, fasta_dir, cluster_out)
if fig is None:
fig = plt.figure(figsize=(20, 20))
full_grid = gridspec.GridSpec(6, 4)
motif_grid = gridspec.GridSpecFromSubplotSpec(1, 6,
subplot_spec=full_grid[4:6, :],
hspace=0,
wspace=0)
viz.build_common_motifs(motif_grid, cluster_out)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment