DNN

pipeline.code.dnn.analyzer.calculate_rank(params=None, model=None, epoch=0, model_dir=None)[source]

Calculate cross-species embedding correlation ranks between human and mouse regions.

This function extracts embeddings for human and mouse transcriptional data using a trained neural network model, computes the correlation matrix between region-level embeddings, and calculates the average rank of prior homologous human regions for each mouse region.

Parameters:
  • params (object) – Configuration object containing paths to human/mouse transcriptional data and homology mapping file, typically accessed via params.data_files.

  • model (torch.nn.Module) – Trained deep learning model used to extract embeddings from the input data.

  • epoch (int, optional) – Epoch index used.

  • model_dir (str, optional) – Directory path to save the embedding results.

Returns:

The average rank of prior homologous human regions for each mouse region in terms of correlation with the extracted embeddings. Lower values indicate better cross-species alignment.

Return type:

float

pipeline.code.dnn.analyzer.transform_human_mouse(params)[source]

Transform human and mouse data using trained embedding models.

This function loads trained neural network models for a number of repeated experiments, transforms human and mouse transcriptional data into embeddings, and saves them as CSV files.

Parameters:

params (object) –

Configuration object containing:
  • data_files: dictionary with paths to human/mouse data and model save directories

  • repeat_n: number of repeated models

  • model hyperparameters: input_units, hidden_units1/2/3, output_units

  • use_bestrank / use_bestvalid: flags for model selection

Returns:

Saves the generated embedding CSV files.

Return type:

None

pipeline.code.dnn.analyzer.independent_test(params)[source]

Evaluate the trained model on an independent test dataset.

Loads the saved models from repeated training runs, runs inference on the test data, saves predictions and confusion matrix to CSV files.

Parameters:

params (object) –

Configuration object with the following attributes:

  • data_filesdict

    Paths to independent test data and saved model weights. Expected keys include ‘independent_test_path’, ‘independent_data_path’, ‘independent_s_path’.

  • repeat_nint

    Number of repeated training runs/models to evaluate.

  • input_units, hidden_units1, hidden_units2, hidden_units3, output_unitsint

    Model architecture hyperparameters.

  • use_bestrank, use_bestvalidbool

    Flags to select which checkpoint to load for evaluation.

Returns:

Saves prediction results and confusion matrices as CSV files.

Return type:

None


class pipeline.code.dnn.pipeline.DnnPipeline(config)[source]

Bases: object

Deep Neural Network (DNN) model training and evaluation pipeline.

This class implements a full pipeline for training, cross-species transformation, and independent test of DNN models on transcriptional data.

Parameters:

config (object) – Configuration object containing paths, parameters, and flags to control the pipeline.

cfg

Configuration object.

Type:

object

logger

Logger instance for tracking pipeline progress and information.

Type:

logging.Logger

execute()[source]

Execute the pipeline based on configuration flags: training, transformation, or testing.

train()[source]

Run training procedure.

trans()[source]

Perform cross-species transformation of transcriptional data.

test()[source]

Runs independent training and test.

_process_single_dataset(data_path)[source]

Preprocess and train model on independent dataset.

_train_single_model(train_data, valid_data, iteration, data_path)[source]

Train a model with given data split.