MACS3.Signal.ScoreTrack module

Scoring utilities for MACS3 signal tracks and peak callers.

This code is free software; you can redistribute it and/or modify it under the terms of the BSD License (see the file LICENSE included with the distribution).

class MACS3.Signal.ScoreTrack.ScoreTrackII

Bases: object

Container for treatment/control pileups and derived score tracks.

add(chromosome, endpos, chip, control)

Append treatment/control pileup ending at endpos for chromosome.

add_chromosome(chrom, chrom_max_len)

Allocate arrays for chrom with capacity chrom_max_len.

call_broadpeaks(lvl1_cutoff=5.0, lvl2_cutoff=1.0, min_length=200, lvl1_max_gap=50, lvl2_max_gap=400)

Return broad peaks constructed from high- and low-cutoff segments.

Parameters:
  • lvl1_cutoff (cython.float) – Threshold for core enriched segments.

  • lvl2_cutoff (cython.float) – Threshold for linking segments.

  • min_length (cython.int) – Minimum peak length to report.

  • lvl1_max_gap (cython.int) – Maximum gap when merging level-1 segments.

  • lvl2_max_gap (cython.int) – Maximum allowed length for linking segments.

call_peaks(cutoff=5.0, min_length=200, max_gap=50, call_summits=False)

Return peaks where scores remain above cutoff.

Parameters:
  • cutoff (cython.float) – Minimum score threshold (e.g., -log10 p).

  • min_length (cython.int) – Minimum peak length in bases.

  • max_gap (cython.int) – Maximum distance between merged segments.

  • call_summits (bool) – Whether to report all local maxima within peaks.

change_normalization_method(normalization_method)

Change/set normalization method. However, I do not recommend change this back and forward, since some precision issue will happen – I only keep two digits.

normalization_method: T: scale to depth of treatment;

C: scale to depth of control; M: scale to depth of 1 million; N: not set/ raw pileup

change_score_method(scoring_method)
scoring_method: p: -log10 pvalue;

q: -log10 qvalue; l: log10 likelihood ratio (minus for depletion) s: symmetric log10 likelihood ratio (for comparing two

ChIPs)

f: log10 fold enrichment F: linear fold enrichment d: subtraction M: maximum m: fragment pileup per million reads

cutoff_analysis(max_gap=50, min_length=200, steps=100, min_score=0.0, max_score=1000.0)

Summarise peak metrics across a range of score thresholds.

Parameters:
  • max_gap (cython.int) – Maximum distance between merged regions.

  • min_length (cython.int) – Minimum peak length to keep.

  • steps (cython.int) – Number of cutoff increments between the observed minimum and maximum scores.

  • min_score (cython.float) – Lower bound for the cutoff sweep.

  • max_score (cython.float) – Upper bound for the cutoff sweep.

Returns:

Tab-delimited report of peak counts and lengths per cutoff.

Return type:

str

enable_trackline()

Enable UCSC track line output when exporting bedGraphs.

finalize()

Trim per-chromosome arrays to their populated length.

get_chr_names()

Return all the chromosome names stored.

get_data_by_chr(chromosome)

Return (positions, treatment, control, score) arrays for chromosome.

make_pq_table()

Make pvalue-qvalue table.

Step1: get all pvalue and length of block with this pvalue Step2: Sort them Step3: Apply AFDR method to adjust pvalue and get qvalue for

each pvalue

Return a dictionary of {-log10pvalue:(-log10qvalue,rank,basepairs)} relationships.

set_pseudocount(pseudocount)

Update the pseudocount used when computing score metrics.

write_bedGraph(fhd, name, description, column=3)

Write all data to fhd in bedGraph Format.

fhd: a filehandler to save bedGraph.

name/description: the name and description in track line.

colname: can be 1: chip, 2: control, 3: score

class MACS3.Signal.ScoreTrack.TwoConditionScores

Bases: object

Class for saving two condition comparison scores.

build()

Compute scores from 3 types of comparisons and store them in self.data.

call_peaks(cutoff=3.0, min_length=200, max_gap=100, call_summits=False)

This function try to find regions within which, scores are continuously higher than a given cutoff.

For bdgdiff.

This function is NOT using sliding-windows. Instead, any regions in bedGraph above certain cutoff will be detected, then merged if the gap between nearby two regions are below max_gap. After this, peak is reported if its length is above min_length.

cutoff: cutoff of value, default 3. For log10 LR, it means 1000 or -1000. min_length : minimum peak length, default 200. max_gap : maximum gap to merge nearby peaks, default 100. ptrack: an optional track for pileup heights. If it’s not None, use it to find summits. Otherwise, use self/scoreTrack.

finalize()

Adjust array size of each chromosome.

get_chr_names()

Return all the chromosome names stored.

get_data_by_chr(chromosome)

Return array of counts by chromosome.

The return value is a tuple: ([end pos],[value])

set_pseudocount(pseudocount)

Update the pseudocount used for differential scoring.

write_bedGraph(fhd, name, description, column=3)

Write all data to fhd in bedGraph Format.

fhd: a filehandler to save bedGraph.

name/description: the name and description in track line.

colname: can be 1: cond1 chip vs cond1 ctrl, 2: cond2 chip vs cond2 ctrl, 3: cond1 chip vs cond2 chip

write_matrix(fhd, name, description)

Write all data to fhd into five columns Format:

col1: chr_start_end col2: t1 vs c1 col3: t2 vs c2 col4: t1 vs t2

fhd: a filehandler to save the matrix.