gpsea.view package

class gpsea.view.GpseaReport[source]

Bases: object

GpseaReport summarizes an aspect of an analysis for the user.

abstract write(fh: IOBase | str)[source]

Write the report into the provided path or file handle.

Parameters:

fh – a str with path or io.IOBase with the file-like object for writing the report into.

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) GpseaReport[source]

Generate the variant report.

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:

a report that can be stored to a path or displayed in

interactive environment such as Jupyter notebook.

Return type:

GpseaReport

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

Bases: BaseViewer

CohortViewer summarizes the most salient Cohort aspects into an HTML report.

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

Generate the report for a given cohort.

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

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

Returns:

a report that can be stored to a path or displayed in

interactive environment such as Jupyter notebook.

Return type:

GpseaReport

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.ProteinVariantViewer(protein_metadata: ProteinMetadata, tx_id: str)[source]

Bases: object

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

process(cohort: Cohort) GpseaReport[source]

Summarize the data regarding the protein into a HTML table.

Parameters:

cohort (Cohort) – the cohort of patients being analyzed

Returns:

a report that can be stored to a path or displayed in

interactive environment such as Jupyter notebook.

Return type:

GpseaReport

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

Bases: object

TODO

process(cohort: Cohort) GpseaReport[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) GpseaReport[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:

a report that can be stored to a path or displayed in

interactive environment such as Jupyter notebook.

Return type:

GpseaReport

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.Formatter[source]

Bases: Generic[T]

abstract format_as_string(item: T) str[source]

Inputs an item and outputs a human readable string that can be used to more easily read the item in tables or other visualizers.

Parameters:

item (T) – an element to be formatted

Returns:

a human readable string

Return type:

str

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