-
Notifications
You must be signed in to change notification settings - Fork 20
strvctvre #1032
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
Draft
bpblanken
wants to merge
7
commits into
main
Choose a base branch
from
benb/strvctvre
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
strvctvre #1032
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5a32dbb
First pass
bpblanken d30d2f8
Finish test
bpblanken 524de9d
do it correctly :/
bpblanken d095e9c
ruff
bpblanken 116bb9b
correct feature flag
bpblanken 8ff45f9
strvctvre
bpblanken 2b6ab30
updates for directory structure
bpblanken File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Run locally with: | ||
# | ||
# gcloud builds submit --quiet --config .cloudbuild/strvctvre-docker.cloudbuild.yaml v03_pipeline/deploy | ||
steps: | ||
- name: 'gcr.io/kaniko-project/executor:v1.3.0' | ||
args: | ||
- --destination=gcr.io/seqr-project/strvctvre-docker-image | ||
- --dockerfile=Dockerfile.strvctvre | ||
- --cache=true | ||
- --cache-ttl=168h | ||
|
||
timeout: 1800s |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -eux | ||
|
||
REFERENCE_GENOME=$1 | ||
STRVCTVRE_REFERENCE_DATASETS_DIR=${STRVCTVRE_REFERENCE_DATASETS_DIR:-/var/seqr/strvctvre-reference-data} | ||
|
||
case $REFERENCE_GENOME in | ||
GRCh38) | ||
STRVCTVRE_REFERENCE_DATA_FILES=( | ||
'gs://seqr-reference-data/strvctvre_data/hg38.phyloP100way.bw' | ||
) | ||
;; | ||
*) | ||
echo "Invalid reference genome $REFERENCE_GENOME, should be GRCh38" | ||
exit 1 | ||
esac | ||
|
||
if [ -f "$STRVCTVRE_REFERENCE_DATASETS_DIR"/"$REFERENCE_GENOME"/_SUCCESS ]; then | ||
echo "Skipping download because already successful" | ||
exit 0; | ||
fi | ||
|
||
mkdir -p "$STRVCTVRE_REFERENCE_DATASETS_DIR"/"$REFERENCE_GENOME"; | ||
rm -rf "${STRVCTVRE_REFERENCE_DATASETS_DIR:?}"/"${REFERENCE_GENOME:?}"/*; | ||
|
||
for reference_data_file in "${STRVCTVRE_REFERENCE_DATA_FILES[@]}"; do | ||
echo "Downloading" "$reference_data_file"; | ||
gsutil cp "$reference_data_file" "$STRVCTVRE_REFERENCE_DATASETS_DIR"/"$REFERENCE_GENOME"/ & | ||
done; | ||
wait | ||
touch "$STRVCTVRE_REFERENCE_DATASETS_DIR"/"$REFERENCE_GENOME"/_SUCCESS |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash | ||
|
||
set -eux | ||
|
||
STRVCTVRE_REFERENCE_DATASETS_DIR=${STRVCTVRE_REFERENCE_DATASETS_DIR:-/var/seqr/strvctvre-reference-data} | ||
STRVCTVRE_DOCKER_IMAGE="gcr.io/seqr-project/strvctvre-docker-image" | ||
docker run --platform linux/amd64 -i -v $STRVCTVRE_DOCKER_IMAGE:$STRVCTVRE_DOCKER_IMAGE:ro $STRVCTVRE_DOCKER_IMAGE -p $WORKDIR "$@" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
FROM python:3.11-bullseye as build | ||
LABEL maintainer="Broad TGG" | ||
|
||
# Sourced from https://stackoverflow.com/a/58269633 | ||
ENV PATH="/root/miniconda3/bin:${PATH}" | ||
RUN apt-get update && \ | ||
apt-get install -y wget && \ | ||
apt-get clean && \ | ||
rm -rf /var/lib/apt/lists/* | ||
RUN wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh && \ | ||
mkdir -p /root/.conda && \ | ||
bash miniconda.sh -b -p /root/miniconda3 && \ | ||
rm -f miniconda.sh | ||
|
||
RUN git clone --depth 1 https://github.com/andrewSharo/StrVCTVRE | ||
WORKDIR /StrVCTVRE | ||
RUN conda env create -f environment_py3.yml | ||
ENTRYPOINT ["conda", "run", "-n", "StrVCTVRE_py_3", "python3", "StrVCTVRE.py"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import hail as hl | ||
|
||
from v03_pipeline.lib.annotations import sv | ||
from v03_pipeline.lib.misc.pedigree import Family | ||
from v03_pipeline.lib.model import ReferenceGenome, Sex | ||
|
||
|
||
def overwrite_male_non_par_calls( | ||
mt: hl.MatrixTable, | ||
families: set[Family], | ||
) -> hl.MatrixTable: | ||
male_sample_ids = { | ||
s.sample_id for f in families for s in f.samples.values() if s.sex == Sex.MALE | ||
} | ||
male_sample_ids = ( | ||
hl.set(male_sample_ids) if male_sample_ids else hl.empty_set(hl.str) | ||
) | ||
par_intervals = hl.array( | ||
[ | ||
i | ||
for i in hl.get_reference(ReferenceGenome.GRCh38).par | ||
if i.start.contig == ReferenceGenome.GRCh38.x_contig | ||
], | ||
) | ||
non_par_interval = hl.interval( | ||
par_intervals[0].end, | ||
par_intervals[1].start, | ||
) | ||
# NB: making use of existing formatting_annotation_fns. | ||
# We choose to annotate & drop here as the sample level | ||
# fields are dropped by the time we format variants. | ||
mt = mt.annotate_rows( | ||
start_locus=sv.start_locus(mt), | ||
end_locus=sv.end_locus(mt), | ||
) | ||
mt = mt.annotate_entries( | ||
GT=hl.if_else( | ||
( | ||
male_sample_ids.contains(mt.s) | ||
& non_par_interval.overlaps( | ||
hl.interval( | ||
mt.start_locus, | ||
mt.end_locus, | ||
), | ||
) | ||
), | ||
hl.Call([1, 1], phased=False), | ||
mt.GT, | ||
), | ||
) | ||
return mt.drop('start_locus', 'end_locus') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import unittest | ||
|
||
import hail as hl | ||
|
||
from v03_pipeline.lib.misc.io import import_callset, select_relevant_fields | ||
from v03_pipeline.lib.misc.pedigree import Family, Sample | ||
from v03_pipeline.lib.misc.sample_ids import subset_samples | ||
from v03_pipeline.lib.misc.sv import overwrite_male_non_par_calls | ||
from v03_pipeline.lib.model import DatasetType, ReferenceGenome, Sex | ||
|
||
TEST_SV_VCF = 'v03_pipeline/var/test/callsets/sv_1.vcf' | ||
|
||
|
||
class SVTest(unittest.TestCase): | ||
def test_overwrite_male_non_par_calls(self) -> None: | ||
mt = import_callset(TEST_SV_VCF, ReferenceGenome.GRCh38, DatasetType.SV) | ||
mt = select_relevant_fields( | ||
mt, | ||
DatasetType.SV, | ||
) | ||
mt = subset_samples( | ||
mt, | ||
hl.Table.parallelize( | ||
[{'s': sample_id} for sample_id in ['RGP_164_1', 'RGP_164_2']], | ||
hl.tstruct(s=hl.dtype('str')), | ||
key='s', | ||
), | ||
) | ||
mt = overwrite_male_non_par_calls( | ||
mt, | ||
{ | ||
Family( | ||
family_guid='family_1', | ||
samples={ | ||
'RGP_164_1': Sample(sample_id='RGP_164_1', sex=Sex.FEMALE), | ||
'RGP_164_2': Sample(sample_id='RGP_164_2', sex=Sex.MALE), | ||
}, | ||
), | ||
}, | ||
) | ||
mt = mt.filter_rows(mt.locus.contig == 'chrX') | ||
self.assertEqual( | ||
[ | ||
hl.Locus(contig='chrX', position=3, reference_genome='GRCh38'), | ||
hl.Locus(contig='chrX', position=2781700, reference_genome='GRCh38'), | ||
], | ||
mt.locus.collect(), | ||
) | ||
self.assertEqual( | ||
[ | ||
hl.Call(alleles=[0, 0], phased=False), | ||
# END of this variant < start of the non-par region. | ||
hl.Call(alleles=[0, 1], phased=False), | ||
hl.Call(alleles=[0, 0], phased=False), | ||
hl.Call(alleles=[1, 1], phased=False), | ||
], | ||
mt.GT.collect(), | ||
) | ||
self.assertFalse( | ||
hasattr(mt, 'start_locus'), | ||
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this worked! Verified the
StrVCTVRE
annotation is present in the VCF in the right format.