plot_browser

plot_browser(fileNames, sampleNames, region, basemod, outDir, threshA=129, threshC=129, bedFileFeatures=None, smooth=1000, min_periods=100, colorA='#053C5E', colorC='#BB4430', dotsize=4, static=False, cores=None)
fileNames

list of names of bam files with Mm and Ml tags; indexed; or single file name as string

sampleNames

list of names of samples for output plot name labelling; or single sample name as string; valid names contain [a-zA-Z0-9_].

region

formatted as for example: “chr1:1-100000”

basemod

One of the following:

  • 'A' - extract mA only

  • 'CG' - extract mCpG only

  • 'A+CG' - extract mA and mCpG

outDir

directory to output plot

threshA

threshold for calling mA; default 129

threshC

threshold for calling mCG; default 129

bedFileFeatures

bedFile specifying regions to display in browser (optional); default None

smooth

window over which to smooth aggregate curve; default of 1000 bp

min_periods

minimum number of bases to consider for smoothing: default of 100 bp

colorA

color in hex for mA; default #053C5E

colorC

color in hex for mCG; default #BB4430

dotsize

size of points; default 4

static

One of the following:

  • 'True' - pdf output

  • 'False' - interactive html output; default is False

cores

number of cores over which to parallelize; default is all available

Example

>>> dm.plot_browser("dimelo/test/data/mod_mappings_subset.bam", "test", "chr1:2907273-2909473", "A+CG", "dimelo/dimelo_test", static=False)
>>> dm.plot_browser(["dimelo/test/data/mod_mappings_subset.bam", "dimelo/test/data/mod_mappings_subset.bam"], ["test1", "test2"], "chr1:2907273-2909473", "A+CG", "dimelo/dimelo_test", static=False)

Return

  • PDF or HTML file with single molecules displayed over region of interest. Modified bases are colored according to colorA and colorC.

  • PDFs of aggregate coverage and fraction of bases modified over region of interest.

  • A summary bed file is also produced to support visualizing aggregate data with any genome browser tool. The columns of this bed file are chr, start, end, methylated_bases, total_bases. For example, to take a summary output bed and create a file with fraction of modified bases with a window size of 100 bp for visualization with the WashU browser, you could run the below commands in terminal:

    • bedtools makewindows -g ref_genome.chromsizes.txt -w 100 > ref_genome_windows.100.bp.bed

    • bedtools map -a ref_genome_windows.100.bp.bed -b outDir/fileName_sampleName_chr_start_end_A.bed -c 4,5 -o sum,sum -null 0 | awk -v "OFS=\t" '{if($5>0){print $1,$2,$3,$4/$5}else{print $1,$2,$3,$5}}' > outDir/fileName_sampleName_chr_start_end_A.100.bed

    • bgzip outDir/fileName_sampleName_chr_start_end_A.100.bed

    • tabix -f -p bed outDir/fileName_sampleName_chr_start_end_A.100.bed.gz

Example Plots

Single-Molecule Browser Plot

dimelo-plot-browser - CLI interface

DiMeLo plot browser

dimelo-plot-browser [-h] -f FILENAMES [FILENAMES ...] -s SAMPLENAMES [SAMPLENAMES ...] -r
                    REGION -m {A,CG,A+CG} -o OUTDIR [-t SMOOTH] [-n MIN_PERIODS]
                    [--colorA COLORA] [--colorC COLORC] [-d DOTSIZE] [-A THRESHA]
                    [-C THRESHC] [-b BEDFILEFEATURES] [--static] [-p CORES]

dimelo-plot-browser optional arguments

  • -h, --help - show this help message and exit

  • -A THRESHA, --threshA THRESHA - threshold above which to call an A base methylated (default: 129)

  • -C THRESHC, --threshC THRESHC - threshold above which to call a C base methylated (default: 129)

  • -b BEDFILEFEATURES, --bedFileFeatures BEDFILEFEATURES - bed file specifying annotation to display in browser (default: None)

  • --static - output as PDF instead of interactive HTML

  • -p CORES, --cores CORES - number of cores over which to parallelize (default: None)

dimelo-plot-browser required arguments

  • -f FILENAMES, --fileNames FILENAMES - bam file name(s) (default: None)

  • -s SAMPLENAMES, --sampleNames SAMPLENAMES - sample name(s) for output file labelling (default: None)

  • -r REGION, --region REGION - single region over which to extract base mods, e.g. "chr1:1-100000" (default: None)

  • -m BASEMOD, --basemod BASEMOD - which base modification to extract (default: None)

  • -o OUTDIR, --outDir OUTDIR - directory to output plot (default: None)

dimelo-plot-browser smoothing options

  • -t SMOOTH, --smooth SMOOTH - window over which to smooth aggregate curve (default: 1000)

  • -n MIN_PERIODS, --min_periods MIN_PERIODS - minimum number of bases to consider for smoothing (default: 100)

dimelo-plot-browser plotting options

  • --colorA COLORA - color in hex (e.g. "#BB4430") for mA (default: #053C5E)

  • --colorC COLORC - color in hex (e.g. "#BB4430") for mCG (default: #BB4430)

  • -d DOTSIZE, --dotsize DOTSIZE - size of points (default: 4)