Skip to content

Commit

Permalink
Merge pull request #58 from dpavam/create-phenopackets-without-phenot…
Browse files Browse the repository at this point in the history
…ypic-features

Create phenopackets without phenotypic features
  • Loading branch information
dpavam authored Feb 27, 2025
2 parents b37d3b4 + 18fb93e commit 219220c
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ To convert all OMIM diseases in a phenotype annotation file to disease phenopack
p2p convert --phenotype-annotation /path/to/phenotype.hpoa --output-dir /path/to/output-dir
```

To convert all OMIM diseases in a phenotype annotation file to lightweight disease phenopackets (without phenotypic features):
```shell
p2p convert --phenotype-annotation /path/to/phenotype.hpoa --output-dir /path/to/output-dir --skip-phenotypic-features
```

To create synthetic patient disease phenopackets, where the dataset is more variable and frequencies are taken
into account and constrained noise is applied :

Expand Down
17 changes: 16 additions & 1 deletion src/phenotype2phenopacket/cli_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,22 @@
default=None,
type=Path,
)
@click.option(
"--skip-phenotypic-features",
"-s",
is_flag=True,
default=False,
required=False,
help="Boolean flag to skip writing phenotypic features to phenopacket.",
)
def convert_to_phenopackets_command(
phenotype_annotation: Path,
num_disease: int,
omim_id: str,
omim_id_list: Path,
output_dir: Path,
local_ontology_cache: Path,
skip_phenotypic_features: bool,
):
"""
Convert a phenotype annotation file to a set of disease phenopackets.
Expand All @@ -84,5 +93,11 @@ def convert_to_phenopackets_command(
"""
output_dir.mkdir(exist_ok=True)
convert_to_phenopackets(
phenotype_annotation, num_disease, omim_id, omim_id_list, output_dir, local_ontology_cache
phenotype_annotation,
num_disease,
omim_id,
omim_id_list,
output_dir,
local_ontology_cache,
skip_phenotypic_features,
)
5 changes: 4 additions & 1 deletion src/phenotype2phenopacket/convert/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def convert_to_phenopackets(
omim_id_list: Path,
output_dir: Path,
local_cached_ontology: Path,
skip_phenotypic_features: bool,
):
"""
Convert a phenotype annotation file to a set of disease-specific phenopackets.
Expand Down Expand Up @@ -47,7 +48,9 @@ def convert_to_phenopackets(
continue
phenopacket_file = PhenotypeAnnotationToPhenopacketConverter(
human_phenotype_ontology
).create_phenopacket(omim_disease, phenotype_annotation_data.version, None)
).create_phenopacket(
omim_disease, phenotype_annotation_data.version, None, skip_phenotypic_features
)
write_phenopacket(
phenopacket_file.phenopacket, output_dir.joinpath(phenopacket_file.phenopacket_path)
)
5 changes: 4 additions & 1 deletion src/phenotype2phenopacket/utils/phenopacket_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,7 @@ def create_phenopacket(
omim_disease_df: pl.DataFrame,
hpoa_version: str,
pt_id: str,
skip_phenotypic_features: bool,
onset: OnsetTerm = None,
) -> PhenopacketFile:
"""
Expand All @@ -853,7 +854,9 @@ def create_phenopacket(
PhenopacketFile: A class instance containing the phenopacket file name and
the generated Phenopacket.
"""
phenotypic_features = self.create_phenotypic_features(omim_disease_df)
phenotypic_features = (
[] if skip_phenotypic_features else self.create_phenotypic_features(omim_disease_df)
)
phenotype_annotation_entry = omim_disease_df.to_dicts()[0]
return PhenopacketFile(
phenopacket=Phenopacket(
Expand Down

0 comments on commit 219220c

Please sign in to comment.