Skip to content

Commit

Permalink
dev sync
Browse files Browse the repository at this point in the history
  • Loading branch information
tanghaibao committed Apr 29, 2024
1 parent fca4a39 commit f279ccf
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
11 changes: 5 additions & 6 deletions jcvi/assembly/geneticmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from ..graphics.base import (
Rectangle,
draw_cmap,
normalize_axes,
plt,
plot_heatmap,
savefig,
Expand Down Expand Up @@ -384,14 +385,14 @@ def draw_geneticmap_heatmap(root, ax, mstmap: str, subsample: int):
M, markerbedfile, nmarkers = read_subsampled_matrix(mstmap, subsample)

# Plot chromosomes breaks
bed = Bed(markerbedfile)
xsize = len(bed)
b = Bed(markerbedfile)
xsize = len(b)
extent = (0, nmarkers)
chr_labels = []
ignore_size = 20

breaks = []
for seqid, beg, end in bed.get_breaks():
for seqid, beg, end in b.get_breaks():
ignore = abs(end - beg) < ignore_size
pos = (beg + end) / 2
chr_labels.append((seqid, pos, ignore))
Expand Down Expand Up @@ -422,9 +423,7 @@ def draw_geneticmap_heatmap(root, ax, mstmap: str, subsample: int):
m = mstmap.split(".")[0]
root.text(0.5, 0.06, f"Linkage Disequilibrium between {m} markers", ha="center")

root.set_xlim(0, 1)
root.set_ylim(0, 1)
root.set_axis_off()
normalize_axes(root)


def heatmap(args):
Expand Down
21 changes: 14 additions & 7 deletions jcvi/projects/jcvi.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
Functions in this script produce figures in the JCVI manuscript.
"""

import sys

from ..apps.base import ActionDispatcher, OptionParser, logger
from ..assembly.geneticmap import draw_geneticmap_heatmap
from ..graphics.base import normalize_axes, panel_labels, plt, savefig


Expand All @@ -19,31 +22,35 @@ def genomebuild(args):
C. Hi-C contact map concordance
"""
p = OptionParser(genomebuild.__doc__)
_, args, iopts = p.set_image_options(args, figsize="15x5")
_, args, iopts = p.set_image_options(args, figsize="21x7")

if len(args) != 4:
sys.exit(not p.print_help())

reads_histo, geneticmap_matrix, hic_matrix, hic_json = args
reads_histo, mstmap, hic_matrix, hic_json = args

fig = plt.figure(1, (iopts.w, iopts.h))
root = fig.add_axes((0, 0, 1, 1))
ax1 = fig.add_axes((0.1, 0.1, 0.32, 0.8))
ax2 = fig.add_axes((0.1, 0.1, 0.34, 0.8))
ax3 = fig.add_axes((0.1, 0.1, 0.34, 0.8))
ax1_root = fig.add_axes((0, 0, 0.32, 1))
ax2_root = fig.add_axes((0.32, 0, 0.34, 1))
ax3_root = fig.add_axes((0.66, 0, 0.34, 1))
ax1 = fig.add_axes((0.03, 0.1, 0.23, 0.8))
ax2 = fig.add_axes((0.35, 0.1, 0.27, 0.8))
ax3 = fig.add_axes((0.69, 0.1, 0.27, 0.8))

# Panel A
logger.info("Plotting read kmer histogram")

# Panel B
logger.info("Plotting genetic map concordance")
draw_geneticmap_heatmap(ax2_root, ax2, mstmap, 1000)

# Panel C
logger.info("Plotting Hi-C contact map concordance")

labels = ((0.05, 0.95, "A"), (0.37, 0.95, "B"), (0.71, 0.95, "C"))
labels = ((0.05, 0.95, "A"), (0.35, 0.95, "B"), (0.7, 0.95, "C"))
panel_labels(root, labels)
normalize_axes([root, ax1, ax2, ax3])
normalize_axes([root, ax1_root, ax2_root, ax3_root, ax1, ax2, ax3])

image_name = "genomebuild.pdf"
savefig(image_name, dpi=iopts.dpi, iopts=iopts)
Expand Down

0 comments on commit f279ccf

Please sign in to comment.