Plot TFBS in genome view
We will first plot the TFBS sites from ChIP-seq of GM12878 as loaded previously:
[1]:
import tfcomb
C = tfcomb.CombObj().from_pickle("../data/GM12878.pkl")
This object already contains TFBS to show:
[2]:
C.TFBS[:10]
[2]:
[chr4 11875 11876 ZBTB33 1000 .,
chr4 116639 116640 JUNB 974 .,
chr4 116678 116679 RUNX3 1000 .,
chr4 121620 121621 RUNX3 1000 .,
chr4 124050 124051 ZNF217 948 .,
chr4 124052 124053 SMARCA5 802 .,
chr4 124169 124170 NR2F1 634 .,
chr4 124289 124290 CBX5 906 .,
chr4 124363 124364 E4F1 1000 .,
chr4 124365 124366 PKNOX1 1000 .]
Now, using .plot_TFBS, we can show the TFBS in a certain window:
[3]:
C.plot_TFBS(window_chrom = "chr4",
window_start = 2441831,
window_end = 2441885)
The function can also take fasta and bigwigs to show additional tracks below the TFBS:
[4]:
C.plot_TFBS(window_chrom = "chr4",
window_start = 2441831,
window_end = 2441885,
fasta="../data/hg38_chr4.fa.gz",
bigwigs = ["../data/GM12878_corrected.bw",
"../data/GM12878_footprints.bw"])
Plot TFBS from motifs
For TFBS with strand information, e.g. from motifs, .plot_TFBS will show the direction of the TFBS as arrows:
[5]:
C = tfcomb.CombObj(verbosity=0)
C.TFBS_from_motifs(regions="../data/GM12878_hg38_chr4_ATAC_peaks.bed",
motifs="../data/HOCOMOCOv11_HUMAN_motifs.txt",
genome="../data/hg38_chr4_masked.fa.gz",
threads=8)
[6]:
C.plot_TFBS(window_chrom = "chr4",
window_start = 41709878,
window_end = 41710236,
bigwigs = ["../data/GM12878_corrected.bw",
"../data/GM12878_footprints.bw"])
Set figsize to control size of plot (the default is to estimate it from the number of tracks)
[7]:
C.plot_TFBS(window_chrom = "chr4",
window_start = 41709878,
window_end = 41710236,
bigwigs = ["../data/GM12878_corrected.bw",
"../data/GM12878_footprints.bw"],
figsize=(4,5))