netmap.utils.netmap_config.NetmapConfig

class netmap.utils.netmap_config.NetmapConfig(input_data='data.h5ad', layer='X', output_directory='netmap', transcription_factors='', tf_only=True, penalize_error=True, adata_filename='grn_lrp.h5ad', grn='grn_lrp.tsv', masking_percentage=0.1, print_every=100, optimizer='Adam', learning_rate=0.005, epochs=10000, n_models=20, validation_size=0.2, model='NegativeBinomialAutoencoder', xai_method='GradientShap', aggregation_strategy='mean')[source]

Bases: object

Configuration dataclass for the NETMAP pipeline.

Holds all parameters required to run the NETMAP pipeline stages (model training, GRN inference, masking, and downstream analysis). Instances can be serialised to / deserialised from YAML via write_yaml() and read_yaml().

Fields (all keyword-argument constructors with defaults):

  • input_data (str) — path to the input AnnData .h5ad file. Default "data.h5ad".

  • layer (str) — AnnData layer used as model input; 'X' for the main expression matrix. Default 'X'.

  • output_directory (str) — root directory for pipeline outputs. Default "netmap".

  • transcription_factors (str) — path to a one-TF-per-line file. Default "".

  • tf_only (bool) — restrict sources to TFs when True. Default True.

  • penalize_error (bool) — include reconstruction-error penalty. Default True.

  • adata_filename (str) — filename for the saved GRN AnnData inside output_directory. Default "grn_lrp.h5ad".

  • grn (str) — filename for the exported GRN TSV. Default "grn_lrp.tsv".

  • masking_percentage (float) — fraction of cells for masking. Default 0.1.

  • print_every (int) — log training every N epochs. Default 100.

  • optimizer (str) — PyTorch optimiser name. Default 'Adam'.

  • learning_rate (float) — optimiser learning rate. Default 0.005.

  • epochs (int) — maximum training epochs per model. Default 10000.

  • n_models (int) — ensemble size. Default 20.

  • validation_size (float) — early-stopping validation fraction. Default 0.2.

  • model (str) — autoencoder class name ('NegativeBinomialAutoencoder' or 'ZINBAutoencoder'). Default "NegativeBinomialAutoencoder".

  • xai_method (str) — Captum attribution method ('GradientShap', 'GuidedBackprop', 'Deconvolution'). Default "GradientShap".

  • aggregation_strategy (str) — attribution aggregation strategy. Default 'mean'.

__init__(input_data='data.h5ad', layer='X', output_directory='netmap', transcription_factors='', tf_only=True, penalize_error=True, adata_filename='grn_lrp.h5ad', grn='grn_lrp.tsv', masking_percentage=0.1, print_every=100, optimizer='Adam', learning_rate=0.005, epochs=10000, n_models=20, validation_size=0.2, model='NegativeBinomialAutoencoder', xai_method='GradientShap', aggregation_strategy='mean')
adata_filename: str = 'grn_lrp.h5ad'
aggregation_strategy: str = 'mean'
epochs: int = 10000
grn: str = 'grn_lrp.tsv'
input_data: str = 'data.h5ad'
layer: str = 'X'
learning_rate: float = 0.005
masking_percentage: float = 0.1
model: str = 'NegativeBinomialAutoencoder'
n_models: int = 20
optimizer: str = 'Adam'
output_directory: str = 'netmap'
penalize_error: bool = True
print_every: int = 100
classmethod read_yaml(yaml_file)[source]

Construct a NetmapConfig from a YAML file.

Reads the YAML file at yaml_file, prints the parsed dictionary for debugging, and returns a new NetmapConfig instance populated with the values found in the file. Keys in the YAML must match the field names of NetmapConfig exactly.

Parameters:

yaml_file (str) – Path to the YAML configuration file to read.

Returns:

A new instance initialised from the YAML contents.

Return type:

NetmapConfig

tf_only: bool = True
transcription_factors: str = ''
validation_size: float = 0.2
write_yaml(yaml_file)[source]

Serialise this configuration to a YAML file.

Writes all fields of the current instance to yaml_file in YAML format, preserving field order (sort_keys=False). The resulting file can be loaded back with read_yaml().

Parameters:

yaml_file (str) – Destination path for the YAML file. The file is created or overwritten if it already exists.

Returns:

None

xai_method: str = 'GradientShap'