gain.gene_scores package

Subpackages

Submodules

gain.gene_scores.gene_scores module

class gain.gene_scores.gene_scores.GeneScore(resource: GenomicResource)[source]

Bases: ScoreResource[GeneScoreDef]

Class used to represent gene scores.

property files: set[str]
get_gene_value(score_id: str, gene_symbol: str) float | None[source]

Return the value for a given gene symbol.

get_genes(score_id: str, score_min: float | None = None, score_max: float | None = None, values: list[str] | None = None) set[str][source]

Return set of genes for a score between a min and max value or genes with certain gene score values.

get_max(score_id: str) float[source]

Return maximal score value.

get_min(score_id: str) float[source]

Return minimal score value.

static get_schema() dict[str, Any][source]

Return schema to be used for config validation.

get_score_df(score_id: str) DataFrame[source]
get_values(score_id: str) list[Any][source]

Return a list of score values.

A numeric score yields floats; a categorical string score yields the raw string categories, so the element type is not narrowed to float.

get_x_scale(score_id: str) str | None[source]

Return the scale type of the X axis.

get_y_scale(score_id: str) str | None[source]

Return the scale type of the Y axis.

to_dict(score_id: str) dict[str, float][source]

Return {gene_symbol: value} for a score, with NaN rows dropped.

to_tsv(score_id: str | None = None) list[str][source]

Return a TSV version of the gene score data.

class gain.gene_scores.gene_scores.GeneScoreDef(score_id: str, value_type: str, desc: str, small_values_desc: str | None, large_values_desc: str | None, hist_conf: HistogramConfig | None, column_name: str)[source]

Bases: ScoreDef

A gene score definition.

Extends the shared ScoreDef with the one loading detail a gene score needs: the name of the source column the score is read from (the df column, later renamed to score_id).

column_name: str
class gain.gene_scores.gene_scores.GeneScoresDb(gene_scores: list[GeneScore])[source]

Bases: object

Helper class used to load all defined gene scores.

Used by Web interface.

static build_descs_from_score(gene_score: GeneScore) list[ScoreDesc][source]

Build score descriptions from score.

get_gene_score(score_id: str) GeneScore | None[source]

Return a given gene score.

get_gene_score_ids() list[str][source]

Return a list of the IDs of all the gene scores contained.

get_gene_scores() list[GeneScore][source]

Return a list of all the gene scores contained in the DB.

get_score_desc(score_id: str) ScoreDesc | None[source]
get_score_ids() list[str][source]

Return a list of the IDs of all the gene scores contained.

get_scores() list[ScoreDesc][source]
class gain.gene_scores.gene_scores.ScoreDesc(resource_id: str, score_id: str, column_name: str, value_type: str, hist: NullHistogram | CategoricalHistogram | NumberHistogram, description: str, help: str, small_values_desc: str | None, large_values_desc: str | None)[source]

Bases: object

Class used to represent a score description.

column_name: str
description: str
help: str
hist: NullHistogram | CategoricalHistogram | NumberHistogram
large_values_desc: str | None
resource_id: str
score_id: str
small_values_desc: str | None
value_type: str
gain.gene_scores.gene_scores.build_gene_score_from_resource(resource: GenomicResource) GeneScore[source]

Load gene score from a genomic resource.

gain.gene_scores.gene_scores.build_gene_score_from_resource_id(resource_id: str, grr: GenomicResourceRepo | None = None) GeneScore[source]

Module contents