Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Command fixes #879

Merged
merged 5 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docker/Dockerfile → Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ RUN pip3 install cnvkit==0.9.10 --no-cache
# Let matplotlib build its font cache
RUN cnvkit.py version

COPY scripts/* /opt/conda/bin

## USER CONFIGURATION, containers should not run as root
RUN adduser --disabled-password --gecos '' ubuntu && chsh -s /bin/bash && mkdir -p /home/ubuntu
USER ubuntu
Expand Down
4 changes: 2 additions & 2 deletions cnvlib/cnary.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,11 +307,11 @@ def shift_xx(self, is_haploid_x_reference=False, is_xx=None, diploid_parx_genome
is_xx = self.guess_xx(is_haploid_x_reference=is_haploid_x_reference, diploid_parx_genome=diploid_parx_genome)
if is_xx and is_haploid_x_reference:
# Female: divide X coverages by 2 (in log2: subtract 1)
outprobes[outprobes.chromosome == self._chr_x_label, "log2"] -= 1.0
outprobes[outprobes.chromosome == self.chr_x_label, "log2"] -= 1.0
# Male: no change
elif not is_xx and not is_haploid_x_reference:
# Male: multiply X coverages by 2 (in log2: add 1)
outprobes[outprobes.chromosome == self._chr_x_label, "log2"] += 1.0
outprobes[outprobes.chromosome == self.chr_x_label, "log2"] += 1.0
# Female: no change
return outprobes

Expand Down
6 changes: 4 additions & 2 deletions cnvlib/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ def _cmd_batch(args):
procs_per_bam,
args.cluster,
args.fasta,
args.diploid_parx_genome,
)
else:
logging.info(
Expand Down Expand Up @@ -1195,8 +1194,8 @@ def _cmd_call(args):
args.ploidy,
args.purity,
args.male_reference,
args.diploid_parx_genome,
is_sample_female,
args.diploid_parx_genome,
args.filters,
args.thresholds,
)
Expand Down Expand Up @@ -1449,6 +1448,7 @@ def _cmd_diagram(args):
action="store_false",
help="""Disable gene_name labels on plot (useful when a lot of CNV were called).""",
)
add_diploid_parx_genome(P_diagram)
P_diagram.set_defaults(func=_cmd_diagram)


Expand Down Expand Up @@ -1747,6 +1747,7 @@ def _cmd_heatmap(args):
P_heatmap_aes.add_argument(
"-t", "--title", help="Plot title. [Default: Range if provided, otherwise none]"
)
add_diploid_parx_genome(P_heatmap)
P_heatmap.set_defaults(func=_cmd_heatmap)


Expand Down Expand Up @@ -2646,6 +2647,7 @@ def _cmd_export_bed(args):
P_export_bed.add_argument(
"-o", "--output", metavar="FILENAME", help="Output file name."
)
add_diploid_parx_genome(P_export_bed)
P_export_bed.set_defaults(func=_cmd_export_bed)


Expand Down
13 changes: 12 additions & 1 deletion test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,30 @@ picard_targets= build/reference-picard.cnn $(picard_cnrs) $(picard_segs) \
# ------------------------------------------------------------------------------
# Action!

all: $(picard_targets) p2-5_5-metrics.tsv p2-9_2-metrics.tsv p2-20-metrics.tsv
all: mini $(picard_targets) p2-5_5-metrics.tsv p2-9_2-metrics.tsv p2-20-metrics.tsv


.PHONY: clean
clean:
# Picard
rm -rf build/p*targetcoverage.cnn $(picard_targets) p*-scatter.pdf p*-diagram.pdf
rm -rf build/na12878-chrM-Y-trunc* build/chrM-Y-trunc*

.PHONY: test
test:
pytest


# ------------------------------------------------------------------------------
# Minimal 'batch' command

.PHONY: mini
mini: build/na12878-chrM-Y-trunc.bintest.cns

build/na12878-chrM-Y-trunc.bintest.cns: formats/na12878-chrM-Y-trunc.bam formats/chrM-Y-trunc.hg19.fa
$(cnvkit) batch -n -f formats/chrM-Y-trunc.hg19.fa -m wgs formats/na12878-chrM-Y-trunc.bam -d build


# ------------------------------------------------------------------------------
# Standard workflow

Expand Down