bioneuralnet.downstream_task.subject_representation

Functions

accuracy_score(y_true, y_pred, *[, ...])

Accuracy classification score.

generate_hidden_dims(init_dim[, min_dim])

Generates a list of hidden dimensions by halving the initial dimension until the minimum is reached.

get_activation(activation)

Maps a string to a PyTorch activation module.

get_logger(name)

Retrieves a global logger configured to write to 'bioneuralnet.log'.

mean_squared_error(y_true, y_pred, *[, ...])

Mean squared error regression loss.

r2_score(y_true, y_pred, *[, sample_weight, ...])

\(R^2\) (coefficient of determination) regression score function.

train_test_split(*arrays[, test_size, ...])

Split arrays or matrices into random train and test subsets.

Classes

ASHAScheduler

alias of AsyncHyperBandScheduler

AutoEncoder(*args, **kwargs)

Generic Autoencoder for configurable reduction.

CLIReporter(*[, metric_columns, ...])

Command-line reporter

PCA([n_components, copy, whiten, ...])

Principal component analysis (PCA).

Path(*args, **kwargs)

PurePath subclass that can make system calls.

RandomForestClassifier([n_estimators, ...])

A random forest classifier.

RandomForestRegressor([n_estimators, ...])

A random forest regressor.

SubjectRepresentation(omics_data, embeddings)

SubjectRepresentation Class for Integrating Network Embeddings into Omics Data.

datetime(year, month, day[, hour[, minute[, ...)

The year, month and day arguments are required.

Exceptions

TuneError

General error class raised by ray.tune.

class bioneuralnet.downstream_task.subject_representation.AutoEncoder(*args: Any, **kwargs: Any)[source]

Bases: Module

Generic Autoencoder for configurable reduction. Builds encoder and decoder layers based on a list of hidden dimensions. Allows tuning of dropout, activation, and network architecture.

forward(x)[source]
class bioneuralnet.downstream_task.subject_representation.SubjectRepresentation(omics_data: DataFrame, embeddings: DataFrame, phenotype_data: DataFrame | None = None, phenotype_col: str = 'phenotype', reduce_method: str = 'AE', seed: int | None = None, tune: bool | None = False, output_dir: str | Path | None = None)[source]

Bases: object

SubjectRepresentation Class for Integrating Network Embeddings into Omics Data.

This class integrates network-derived embeddings with raw omics data to create enriched subject-level profiles. It supports dimensionality reduction of embeddings (via Autoencoders or other methods) and subsequent fusion with original omics features.

omics_data

DataFrame of omics features (columns).

Type:

pd.DataFrame

embeddings

DataFrame with embeddings (indexed by feature names).

Type:

pd.DataFrame

phenotype_data

Optional DataFrame with phenotype labels.

Type:

Optional[pd.DataFrame]

phenotype_col

Name of the phenotype column.

Type:

str

reduce_method

Method used for dimensionality reduction (e.g., “AE”).

Type:

str

seed

Random seed for reproducibility.

Type:

Optional[int]

tune

Whether to run hyperparameter tuning.

Type:

bool

output_dir

Directory where results are written.

Type:

Path

run() DataFrame[source]

Executes the Subject Representation workflow.

If tuning is enabled, runs hyperparameter tuning and uses the best config to reduce embeddings. Otherwise, uses the default reduction method.

Returns:

Enhanced omics data as a DataFrame.

Return type:

pd.DataFrame

bioneuralnet.downstream_task.subject_representation.generate_hidden_dims(init_dim: int, min_dim: int = 2) List[int][source]

Generates a list of hidden dimensions by halving the initial dimension until the minimum is reached. For example, if init_dim is 64, this returns [64, 32, 16, 8, 4, 2].

bioneuralnet.downstream_task.subject_representation.get_activation(activation: str)[source]

Maps a string to a PyTorch activation module.