dae.pheno package

Subpackages

Submodules

dae.pheno.common module

class dae.pheno.common.MeasureType(value)[source]

Bases: Enum

Definition of measure types.

categorical = 3
continuous = 1
static from_str(measure_type: str) MeasureType[source]
static is_numeric(measure_type: MeasureType) bool[source]
static is_text(measure_type: MeasureType) bool[source]
ordinal = 2
other = 100
raw = 5
skipped = 1000
text = 4
dae.pheno.common.check_phenotype_data_config(config: Box) bool[source]

Check phenotype database preparation config for consistency.

dae.pheno.common.default_config() Box[source]

Construct phenotype database preparation configuration.

dae.pheno.common.dump_config(config: Box) None[source]

Print phenotype database preparation configuration.

dae.pheno.db module

class dae.pheno.db.PhenoDb(dbfile: str, read_only: bool = True)[source]

Bases: object

Class that manages access to phenotype databases.

STREAMING_CHUNK_SIZE = 25
build(create: bool = False) None[source]

Construct all needed table connections.

build_browser() None[source]
build_instrument_values_tables() None[source]

Create instrument values tables.

Each row is basically a list of every measure value in the instrument for a certain person.

build_instruments_and_measures_table() None[source]

Create tables for instruments and measures.

clear_instrument_values_tables(drop: bool = False) None[source]

Clear all instrument values tables.

clear_instruments_table(drop: bool = False) None[source]

Clear the instruments table.

clear_measures_table(drop: bool = False) None[source]

Clear the measures table.

create_all_tables() None[source]
get_browser_measure(measure_id: str) dict | None[source]

Get measrue description from phenotype browser database.

get_families() dict[source]

Return families in the phenotype database.

get_instrument_column_names() dict[str, list[str]][source]

Return a map of instruments and their measure column names.

get_measure_column_names(measure_ids: list[str] | None = None) dict[str, str][source]

Return measure column names mapped to their measure IDs.

get_measure_column_names_reverse(measure_ids: list[str] | None = None) dict[str, str][source]

Return measure column names mapped to their measure IDs.

get_measures() dict[source]

Return measures in the phenotype database.

get_persons() dict[source]

Return individuals in the phenotype database.

get_regression(regression_id: str) Any[source]

Return regressions.

get_regression_values(measure_id: str) list[box.box.Box][source]
property has_descriptions: bool

Check if the database has a description data.

property regression_display_names: Dict[str, str]

Return regressions display name.

property regression_display_names_with_ids: dict[str, Any]

Return regression display names with measure IDs.

property regression_ids: list[str]
save(v: Dict[str, str | None]) None[source]

Save measure values into the database.

save_regression(reg: Dict[str, str]) None[source]

Save regressions into the database.

save_regression_values(reg: Dict[str, str]) None[source]

Save regression values into the databases.

search_measures(instrument_name: str | None = None, keyword: str | None = None) Iterator[dict[str, Any]][source]

Find measert by keyword search.

search_measures_df(instrument_name: str | None = None, keyword: str | None = None) DataFrame[source]

Find measures and return a dataframe with values.

static verify_pheno_folder(folder: Path) None[source]

Verify integrity of a pheno db folder.

dae.pheno.db.generate_instrument_table_name(instrument_name: str) str[source]
dae.pheno.db.safe_db_name(name: str) str[source]

dae.pheno.graphs module

class dae.pheno.graphs.GraphColumn(name, roles, status, df)[source]

Bases: object

Build a colum to produce a graph from it.

all_count()[source]
static build(df, role_name, role_subroles, status)[source]

Construct a graph column object.

females_count()[source]
property label
males_count()[source]
dae.pheno.graphs.column_counts(column)[source]

Collect counts for a graph column.

dae.pheno.graphs.draw_categorical_violin_distribution(df, measure_id, roles_definition=None, ax=None, numerical_categories=False, max_categories=12)[source]

Draw violin distribution for categorical measures.

dae.pheno.graphs.draw_distribution(df, measure_id, ax=None)[source]

Draw measure distribution.

dae.pheno.graphs.draw_linregres(df, col1, col2, jitter: int | None = None, ax=None)[source]

Draw a graph display linear regression between two columns.

dae.pheno.graphs.draw_measure_violinplot(df, measure_id, roles_definition=None, ax=None)[source]

Draw a violin plot for a measure.

dae.pheno.graphs.draw_ordinal_violin_distribution(df, measure_id, ax=None)[source]
dae.pheno.graphs.gender_palette()[source]
dae.pheno.graphs.gender_palette_light()[source]
dae.pheno.graphs.get_columns_to_draw(roles, df)[source]

Collect columns needed for graphs.

dae.pheno.graphs.male_female_colors()[source]
dae.pheno.graphs.male_female_legend(color_male, color_female, ax=None)[source]

Consturct a legend for female graph.

dae.pheno.graphs.names(col1, col2)[source]
dae.pheno.graphs.role_labels(ordered_columns)[source]
dae.pheno.graphs.set_figure_size(figure, x_count)[source]

dae.pheno.husl module

dae.pheno.palletes module

dae.pheno.pheno_db module

dae.pheno.plots module

dae.pheno.prepare_data module

class dae.pheno.prepare_data.PreparePhenoBrowserBase(pheno_name: str, phenotype_data: PhenotypeStudy, output_dir: str, pheno_regressions: Box | None = None, images_dir: str | None = None)[source]

Bases: object

Prepares phenotype data for the phenotype browser.

LARGE_DPI = 150
SMALL_DPI = 16
browsable_figure_path(measure: Measure, suffix: str) str[source]

Construct file path for storing a measure figures.

build_regression(dependent_measure: Measure, independent_measure: Measure, jitter: float) dict[str, Union[str, float]][source]

Build measure regressiongs.

build_values_categorical_distribution(measure: Measure) dict[str, Any][source]

Build a categorical value distribution fiugre.

build_values_ordinal_distribution(measure: Measure) dict[str, Any][source]

Build an ordinal value distribution figure.

build_values_other_distribution(measure: Measure) dict[str, Any][source]

Build an other value distribution figure.

build_values_violinplot(measure: Measure) dict[str, Any][source]

Build a violin plot figure for the measure.

dump_browser_variable(var: dict[str, Any]) None[source]

Print browser measure description.

figure_filepath(measure: Measure, suffix: str) str[source]

Construct file path for storing a measure figures.

handle_measure(measure: Measure) dict[str, Any][source]

Build appropriate figures for a measure.

handle_regressions(measure: Measure) Iterator[dict[str, Any]][source]

Build appropriate regressions and regression figures.

load_measure(measure: Measure) DataFrame[source]
run() None[source]

Run browser preparations for all measures in a phenotype data.

save_fig(measure: Measure, suffix: str) tuple[Optional[str], Optional[str]][source]

Save measure figures.

Module contents