gpsea.view package

class gpsea.view.CohortVariantViewer(tx_id: str)[source]

Bases: object

CohortVariantViewer creates an HTML report with the cohort variants.

The report can be either written into an HTML file or displayed in a Jupyter notebook.

See :ref:show-cohort-variants: for an example usage.

process(cohort: Cohort, only_hgvs: bool = True) str[source]

Create an HTML that should be shown with display(HTML(..)) of the ipython package.

Parameters:
  • cohort (Cohort) – The cohort being analyzed in the current notebook.

  • only_hgvs (bool) – Do not show the transcript ID part of the HGVS annotation, just the annotation.

Returns:

an HTML string with parameterized template for rendering

Return type:

str

class gpsea.view.CohortViewable(hpo: MinimalOntology, top_phenotype_count: int = 10, top_variant_count: int = 10)[source]

Bases: object

Class to create a viewable object that is uses a Jinja2 template to create an HTML element for display in the Jupyter notebook.

process(cohort: Cohort, transcript_id: str | None = None) str[source]

Create an HTML that should be shown with display(HTML(..)) of the ipython package.

Parameters:
  • cohort (Cohort) – The cohort being analyzed in the current Notebook

  • transcript_id (str) – the transcript that we map variants onto

Returns:

an HTML string with parameterized template for rendering

Return type:

str

class gpsea.view.ProteinVisualizer(random_seed: int = 42)[source]

Bases: object

Draw a schema of a protein with variants of the cohort.

draw_protein_diagram(tx_coordinates: TranscriptCoordinates, protein_metadata: ProteinMetadata, cohort: Cohort, ax: Axes | None = None, labeling_method: Literal['abbreviate', 'enumerate'] = 'abbreviate') Axes | None[source]
draw_fig(pvis: ProteinVisualizable, ax: Axes | None = None, labeling_method: Literal['abbreviate', 'enumerate'] = 'abbreviate') Axes | None[source]

Visualize the cohort variants on a protein diagram.

By default, the legend is drawn to the right of the figure to avoid overlap between the variant markers and the legend.

Parameters:
  • pvisProteinVisualizable with information about the transcript coordinates, protein metadata, and the cohort for plotting

  • ax – a Matplotlib plt.Axes to plot on or None if a new Axes should be created

  • labeling_method – the strategy for generating labels. Valid values of labeling_method are {‘abbreviate’, ‘enumerate’}

Returns:

None if an plt.Axes was provided via ax argument or an Axes created by the visualizer if ax was None.

class gpsea.view.ProteinVisualizable(tx_coordinates: TranscriptCoordinates, protein_meta: ProteinMetadata, cohort: Cohort)[source]

Bases: object

property transcript_coordinates: TranscriptCoordinates
property transcript_id: str
property protein_id: str
property protein_metadata: ProteinMetadata
property protein_feature_starts: Sequence[int]
property protein_feature_ends: Sequence[int]
property protein_feature_types: Sequence[str]
property protein_length: int
property protein_feature_names: Sequence[str]
property variant_effects: Sequence[VariantEffect]
property variant_locations_counted_absolute: ndarray
property marker_counts
property variant_locations: ndarray

Get an array with 0-based start coordinates of aminoacids that overlap with the variant regions.

Returns

a 1D array with ints containing a coordinate for each variant

class gpsea.view.ProteinViewable[source]

Bases: object

Class to create a pretty HTML table to display the protein information in the Jupyter notebook.

process(cohort: Cohort, pvis: ProteinVisualizable) str[source]

Summarize the data regarding the protein into a HTML table.

Parameters:
  • cohort (Cohort) – the cohort of patients being analyzed

  • pvis (ProteinVisualizable) – The class that collects data from the UniProt API for a given protein ID

Returns:

an HTML document for showing in Jupyter notebook

Return type:

str

class gpsea.view.DiseaseViewable(hpo: MinimalOntology, transcript_id: str = None)[source]

Bases: object

TODO

process(cohort) str[source]
class gpsea.view.MtcStatsViewer[source]

Bases: object

MtcStatsViewer uses a Jinja2 template to create an HTML element for showing in the Jupyter notebook or for writing into a standalone HTML file.

process(result: HpoTermAnalysisResult) str[source]

Create an HTML to present MTC part of the HpoTermAnalysisResult.

Use the display(HTML(..)) functions of the IPython package.

Parameters:

result (HpoTermAnalysisResult) – the result to show

Returns:

an HTML string with parameterized template for rendering or writing into a standalone HTML file.

Return type:

str

gpsea.view.summarize_hpo_analysis(hpo: MinimalOntology, result: HpoTermAnalysisResult) DataFrame[source]

Create a dataframe with counts, frequencies, and p values for the tested HPO terms.

The HPO terms that were not tested will not be included in the frame.

Parameters:
  • hpo – HPO data.

  • result – the HPO term analysis results to show.

class gpsea.view.VariantTranscriptVisualizer[source]

Bases: object

VariantTranscriptProteinArtist creates a graphic to show distributions of variants across a provided transcript and its protein product.

draw_variants(variants: Iterable[Variant], tx: TranscriptCoordinates, protein: ProteinMetadata)[source]
class gpsea.view.VariantFormatter(tx_id: str | None = None)[source]

Bases: Formatter[Variant]

A class that can be used to format a Variant to a human readable string

format_as_string(item: Variant) str[source]
Parameters:

item (Variant) – An object of class Variant representing a variant.

Returns:

A human readable string for the variant.

Return type:

str