Skip to content
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: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 23.7.0 # This should be kept in sync with the version in requirements-dev.in
rev: 24.3.0 # This should be kept in sync with the version in requirements-dev.in
hooks:
- id: black
language_version: python3
Expand Down
16 changes: 4 additions & 12 deletions gnomad/resources/grch37/gnomad_ld.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ def _ld_matrix_path(
CURRENT_EXOME_RELEASE if data_type == "exomes" else CURRENT_GENOME_RELEASE
)
subdir = "sv/" if data_type == "genomes_snv_sv" else ""
return (
f'gs://gnomad-public-requester-pays/release/{version}/ld/{subdir}gnomad.{data_type}.r{version}.{pop}.{"common." if common_only else ""}{"adj." if adj else ""}ld.bm'
)
return f'gs://gnomad-public-requester-pays/release/{version}/ld/{subdir}gnomad.{data_type}.r{version}.{pop}.{"common." if common_only else ""}{"adj." if adj else ""}ld.bm'


def _ld_index_path(
Expand All @@ -38,9 +36,7 @@ def _ld_index_path(
CURRENT_EXOME_RELEASE if data_type == "exomes" else CURRENT_GENOME_RELEASE
)
subdir = "sv/" if data_type == "genomes_snv_sv" else ""
return (
f'gs://gnomad-public-requester-pays/release/{version}/ld/{subdir}gnomad.{data_type}.r{version}.{pop}.{"common." if common_only else ""}{"adj." if adj else ""}ld.variant_indices.ht'
)
return f'gs://gnomad-public-requester-pays/release/{version}/ld/{subdir}gnomad.{data_type}.r{version}.{pop}.{"common." if common_only else ""}{"adj." if adj else ""}ld.variant_indices.ht'


def _ld_snv_sv_path(pop):
Expand All @@ -62,9 +58,7 @@ def _cross_pop_ld_scores_path(
version = (
CURRENT_EXOME_RELEASE if data_type == "exomes" else CURRENT_GENOME_RELEASE
)
return (
f'gs://gnomad-public-requester-pays/release/{version}/ld/scores/gnomad.{data_type}.r{version}.{pop1}.{pop2}.{"adj." if adj else ""}ld_scores.ht'
)
return f'gs://gnomad-public-requester-pays/release/{version}/ld/scores/gnomad.{data_type}.r{version}.{pop1}.{pop2}.{"adj." if adj else ""}ld_scores.ht'


def _ld_scores_path(
Expand All @@ -74,9 +68,7 @@ def _ld_scores_path(
version = (
CURRENT_EXOME_RELEASE if data_type == "exomes" else CURRENT_GENOME_RELEASE
)
return (
f'gs://gnomad-public-requester-pays/release/{version}/ld/scores/gnomad.{data_type}.r{version}.{pop}.{"adj." if adj else ""}ld_scores.ht'
)
return f'gs://gnomad-public-requester-pays/release/{version}/ld/scores/gnomad.{data_type}.r{version}.{pop}.{"adj." if adj else ""}ld_scores.ht'


def ld_matrix(pop: str) -> GnomadPublicBlockMatrixResource:
Expand Down
3 changes: 2 additions & 1 deletion gnomad/sample_qc/filtering.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,8 @@ def compute_stratified_metrics_filter(
**{
f"fail_{metric}": (
ht._qc_metrics[metric] <= metrics_stats_expr[metric].lower
) | (ht._qc_metrics[metric] >= metrics_stats_expr[metric].upper)
)
| (ht._qc_metrics[metric] >= metrics_stats_expr[metric].upper)
for metric in qc_metrics
}
)
Expand Down
2 changes: 1 addition & 1 deletion gnomad/sample_qc/relatedness.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ def infer_families(
"""

def group_parent_child_pairs_by_fam(
parent_child_pairs: Iterable[Tuple[str, str]]
parent_child_pairs: Iterable[Tuple[str, str]],
) -> List[List[Tuple[str, str]]]:
"""
Group parent-child pairs into a list of families.
Expand Down
4 changes: 2 additions & 2 deletions gnomad/utils/constraint.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ def annotate_mutation_type(


def trimer_from_heptamer(
t: Union[hl.MatrixTable, hl.Table]
t: Union[hl.MatrixTable, hl.Table],
) -> Union[hl.MatrixTable, hl.Table]:
"""
Trim heptamer context to create trimer context.
Expand All @@ -426,7 +426,7 @@ def trimer_from_heptamer(


def collapse_strand(
t: Union[hl.Table, hl.MatrixTable]
t: Union[hl.Table, hl.MatrixTable],
) -> Union[hl.Table, hl.MatrixTable]:
"""
Return the deduplicated context by collapsing DNA strands.
Expand Down
6 changes: 3 additions & 3 deletions gnomad/utils/filtering.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def filter_low_conf_regions(


def filter_to_autosomes(
t: Union[hl.MatrixTable, hl.Table]
t: Union[hl.MatrixTable, hl.Table],
) -> Union[hl.MatrixTable, hl.Table]:
"""
Filter the Table or MatrixTable to autosomes only.
Expand Down Expand Up @@ -470,7 +470,7 @@ def remove_fields_from_constant(


def filter_x_nonpar(
t: Union[hl.Table, hl.MatrixTable]
t: Union[hl.Table, hl.MatrixTable],
) -> Union[hl.Table, hl.MatrixTable]:
"""
Filter to loci that are in non-PAR regions on chromosome X.
Expand All @@ -496,7 +496,7 @@ def filter_x_nonpar(


def filter_y_nonpar(
t: Union[hl.Table, hl.MatrixTable]
t: Union[hl.Table, hl.MatrixTable],
) -> Union[hl.Table, hl.MatrixTable]:
"""
Filter to loci that are in non-PAR regions on chromosome Y.
Expand Down
2 changes: 1 addition & 1 deletion gnomad/utils/liftover.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@


def get_liftover_genome(
t: Union[hl.MatrixTable, hl.Table]
t: Union[hl.MatrixTable, hl.Table],
) -> Tuple[hl.genetics.ReferenceGenome, hl.genetics.ReferenceGenome]:
"""
Infer reference genome build of input data and assume destination reference genome build.
Expand Down
15 changes: 7 additions & 8 deletions gnomad/utils/sparse_mt.py
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,8 @@ def get_chr_dp_ann(chrom: str) -> hl.Table:
f"{chrom}_mean_dp": hl.agg.filter(
chr_mt.LGT.is_non_ref(),
hl.agg.sum(chr_mt.DP),
) / hl.agg.filter(chr_mt.LGT.is_non_ref(), hl.agg.count())
)
/ hl.agg.filter(chr_mt.LGT.is_non_ref(), hl.agg.count())
}
).cols()
else:
Expand Down Expand Up @@ -899,12 +900,10 @@ def get_chr_dp_ann(chrom: str) -> hl.Table:

return ht.annotate(
**{
f"{chr_x}_ploidy": ht[f"{chr_x}_mean_dp"] / (
ht[f"{normalization_contig}_mean_dp"] / 2
),
f"{chr_y}_ploidy": ht[f"{chr_y}_mean_dp"] / (
ht[f"{normalization_contig}_mean_dp"] / 2
),
f"{chr_x}_ploidy": ht[f"{chr_x}_mean_dp"]
/ (ht[f"{normalization_contig}_mean_dp"] / 2),
f"{chr_y}_ploidy": ht[f"{chr_y}_mean_dp"]
/ (ht[f"{normalization_contig}_mean_dp"] / 2),
}
)

Expand Down Expand Up @@ -1390,7 +1389,7 @@ def compute_allele_number_per_ref_site(


def filter_ref_blocks(
t: Union[hl.MatrixTable, hl.Table]
t: Union[hl.MatrixTable, hl.Table],
) -> Union[hl.MatrixTable, hl.Table]:
"""
Filter ref blocks out of the Table or MatrixTable.
Expand Down
1 change: 1 addition & 0 deletions gnomad/utils/transcript_annotation.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Utils module containing generic functions that are useful for adding transcript expression-aware annotations."""

import logging
from typing import Callable, List, Optional, Tuple, Union

Expand Down
9 changes: 6 additions & 3 deletions gnomad/utils/vep.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,18 +544,21 @@ def get_csq_from_struct(
"gene": element.gene_id,
"symbol": element.gene_symbol,
"symbol_source": element.gene_symbol_source,
"cdna_position": hl.str(element.cdna_start) + hl.if_else(
"cdna_position": hl.str(element.cdna_start)
+ hl.if_else(
element.cdna_start == element.cdna_end,
"",
"-" + hl.str(element.cdna_end),
),
"cds_position": hl.str(element.cds_start) + hl.if_else(
"cds_position": hl.str(element.cds_start)
+ hl.if_else(
element.cds_start == element.cds_end,
"",
"-" + hl.str(element.cds_end),
),
"mirna": hl.delimit(element.mirna, "&") if "mirna" in element else None,
"protein_position": hl.str(element.protein_start) + hl.if_else(
"protein_position": hl.str(element.protein_start)
+ hl.if_else(
element.protein_start == element.protein_end,
"",
"-" + hl.str(element.protein_end),
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Used to create the requirements-dev.txt file
# Note: `pip-compile requirements-dev.in` needs to be run before changes in requirements-dev.in are reflected in
# requirements-dev.txt, which is used for GitHub Actions
black==23.7.0 # This should be kept in sync with the version in .pre-commit-config.yaml
black==24.3.0 # This should be kept in sync with the version in .pre-commit-config.yaml
isort==5.12.0 # This should be kept in sync with the version in .pre-commit-config.yaml
autopep8==2.0.2 # This should be kept in sync with the version in .pre-commit-config.yaml
pre-commit
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ astroid==3.0.1
# via pylint
autopep8==2.0.2
# via -r requirements-dev.in
black==23.7.0
black==24.3.0
# via -r requirements-dev.in
cfgv==3.4.0
# via pre-commit
Expand Down