Skip to content

Commit

Permalink
Add diversity()
Browse files Browse the repository at this point in the history
  • Loading branch information
tanghaibao committed Apr 29, 2024
1 parent a844acb commit 9388f91
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
14 changes: 6 additions & 8 deletions jcvi/compara/pedigree.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import networkx as nx
import numpy as np

from ..apps.base import OptionParser, ActionDispatcher, logger, sh
from ..apps.base import OptionParser, ActionDispatcher, logger
from ..formats.base import BaseFile
from ..graphics.base import set3_n

Expand Down Expand Up @@ -241,7 +241,7 @@ def pedigree(args):
p.add_option("--ploidy", default=2, type="int", help="Ploidy")
p.add_option("--N", default=10000, type="int", help="Number of samples")
p.add_option("--title", default="", help="Title of the graph")
opts, args = p.parse_args(args)
opts, args, iopts = p.set_image_options(args)

if len(args) != 1:
sys.exit(not p.print_help())
Expand All @@ -254,12 +254,10 @@ def pedigree(args):
print(v)

G = ped.to_graph(inb, title=opts.title)
dotfile = f"{pedfile}.dot"
nx.nx_agraph.write_dot(G, dotfile)
pdf_file = dotfile + ".pdf"
file_format = pdf_file.split(".")[-1]
sh(f"dot -T{file_format} {dotfile} -o {pdf_file}")
logger.info("Pedigree graph written to `%s`", pdf_file)
A = nx.nx_agraph.to_agraph(G)
image_file = f"{pedfile}.{iopts.format}"
A.draw(image_file, prog="dot")
logger.info("Pedigree graph written to `%s`", image_file)


def main():
Expand Down
12 changes: 12 additions & 0 deletions jcvi/projects/jcvi.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,18 @@ def genomebuild(args):
savefig(image_name, dpi=iopts.dpi, iopts=iopts)


def diversity(args):
"""
%prog diversity pedigree.ped VAR?_srtd.wgs.regions.bed.gz
Plot diversity composite figure, including:
A. Pedigree
B. Depth distribution across genomes
"""
p = OptionParser(diversity.__doc__)
_, args, iopts = p.set_image_options(args, figsize="14x7")


def main():

actions = (
Expand Down

0 comments on commit 9388f91

Please sign in to comment.