gpsea.view package
- class gpsea.view.GpseaReport[source]
Bases:
object
GpseaReport summarizes an aspect of an analysis for the user.
- class gpsea.view.CohortVariantViewer(tx_id: str)[source]
Bases:
BaseViewer
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:
- Returns:
- a report that can be stored to a path or displayed in
interactive environment such as Jupyter notebook.
- Return type:
- 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) GpseaReport [source]
Generate the report for a given cohort.
The variant effects will be reported with respect to the provided transcript.
- Parameters:
- Returns:
- a report that can be stored to a path or displayed in
interactive environment such as Jupyter notebook.
- Return type:
- class gpsea.view.BaseProteinVisualizer[source]
Bases:
object
The visualizer for plotting cohort variants on a protein diagram.
- abstract draw_protein(cohort: Cohort, protein_metadata: ProteinMetadata, ax, **kwargs)[source]
Draw the locations of the cohort variants on the provided axes.
- Keyword Arguments:
(kwargs) (The function can take multiple keyword arguments)
labeling_method (*) – Valid values of labeling_method are
{'abbreviate', 'enumerate'}
:keyword : :kwtype : param cohort: the cohort to plot. :keyword : :kwtype : param protein_metadata: information for the protein of interest. :keyword : :kwtype : param ax: a Matplotlib
Axes
to plot on
- gpsea.view.configure_default_protein_visualizer(random_seed: int = 42) BaseProteinVisualizer [source]
- class gpsea.view.CohortArtist(protein_visualizer: BaseProteinVisualizer, protein_metadata_service: ProteinMetadataService)[source]
Bases:
object
CohortArtist draws all types of figures to visualize the salient aspects of the
Cohort
of interest.- draw_protein(cohort: Cohort, protein_id: str, ax, **kwargs)[source]
Draw the locations of the cohort variants on the provided axes.
See the
draw_protein()
for more info about the arguments.
- gpsea.view.configure_default_cohort_artist(protein_source: Literal['UNIPROT'] = 'UNIPROT', cache_dir: str | None = None, timeout: float | int = 30.0, random_seed: int = 42) CohortArtist [source]
Get the default
CohortArtist
.- Parameters:
protein_source – a str with the code of the protein data sources (currently accepting just UNIPROT).
cache_dir – path to the folder where we will cache the results fetched from the remote APIs or None if the data should be cached as described by
get_cache_dir_path()
function. In any case, the directory will be created if it does not exist (including any non-existing parents).timeout – a float or an int for the timeout in seconds for the REST APIs.
- class gpsea.view.ProteinVisualizer(random_seed: int = 42)[source]
Bases:
BaseProteinVisualizer
Draw a schema of a protein with variants of the cohort.
- draw_protein(cohort: Cohort, protein_metadata: ProteinMetadata, ax, **kwargs)[source]
Draw the locations of the cohort variants on the provided axes.
- Keyword Arguments:
(kwargs) (The function can take multiple keyword arguments)
labeling_method (*) – Valid values of labeling_method are
{'abbreviate', 'enumerate'}
:keyword : :kwtype : param cohort: the cohort to plot. :keyword : :kwtype : param protein_metadata: information for the protein of interest. :keyword : :kwtype : param ax: a Matplotlib
Axes
to plot on
- 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:
pvis –
ProteinVisualizable
with information about the transcript coordinates, protein metadata, and the cohort for plottingax – a Matplotlib
plt.Axes
to plot on or None if a new Axes should be createdlabeling_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 | None, protein_meta: ProteinMetadata, cohort: Cohort)[source]
Bases:
object
- property protein_metadata: ProteinMetadata
- property variant_effects: Sequence[VariantEffect]
- property marker_counts
- class gpsea.view.ProteinVariantViewer(protein_metadata: ProteinMetadata, tx_id: str)[source]
Bases:
BaseViewer
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:
- class gpsea.view.DiseaseViewer(hpo: MinimalOntology, transcript_id: str | None = None)[source]
Bases:
BaseViewer
TODO
- process(cohort: Cohort) GpseaReport [source]
- class gpsea.view.MtcStatsViewer[source]
Bases:
BaseViewer
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
.- 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:
- 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]