visualize.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:wasabiplot 作者: olgabot 项目源码 文件源码
def wasabiplot(bam_filename, chrom, start, stop, strand, log_base=10,
               color='steelblue', bad_cigar=INSERTION_DELETIONS,
               coverage_cigar=COVERAGE_CIGAR, junction_cigar=JUNCTION_CIGAR,
               ax=None, coverage_kws=None, curve_height_multiplier=0.2,
               text_kws=TEXT_KWS, patch_kws=PATCH_KWS, warn_skipped=True,
               annotate=True, **kwargs):
    """Get the number of reads that matched to the reference sequence

    Parameters
    ----------
    bam_filename : str
        Name of the bam filename for logging purposes
    chrom : str
        Name of the reference chromosome
    start, stop : int
        Genome-based locations of the start and stop regions
    strand : '+' | '-'
        Strand to query
    log_base : number or None, optional
        The base to use for log-scaling the data. e.g. 10 would have log10 data
        If None, the data is not log-scaled. (default=10)
    color : valid matplotlib color
        Color to use for both the coverage and junction plotting

    allowed_cigar : tuple of str, optional
        Which CIGAR string flags are allowed. (default=('M') aka match)
    bad_cigar : tuple of str, optional
        Which CIGAR string flags are not allowed. (default=('I', 'D') aka
        insertion and deletion)

    """
    if isinstance(bam_filename, pd.Series):
        bam_filename = bam_filename.iloc[0]

    plotter = WasabiPlotter(bam_filename, chrom, start, stop, strand, log_base,
                            color, bad_cigar, coverage_cigar, junction_cigar,
                            warn_skipped)

    if ax is None:
        ax = plt.gca()

    coverage_kws = {} if coverage_kws is None else coverage_kws
    coverage_kws.update(kwargs)

    plotter.plot_coverage(color, ax, **coverage_kws)
    plotter.plot_junctions(ax, curve_height_multiplier=curve_height_multiplier,
                           text_kws=text_kws, patch_kws=patch_kws,
                           annotate=annotate)

    # Remove bottom spine
    sns.despine(ax=ax, bottom=True)

    # Add a zero-axis line
    ax.hlines(0, 0, plotter.length, linewidth=0.5, zorder=-1)

    if ax.is_last_row():
        xticks = [int(x + start) for x in ax.get_xticks()]
        ax.set(xticklabels=xticks)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号