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:
objectConfiguration 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()andread_yaml().Fields (all keyword-argument constructors with defaults):
input_data(str) — path to the input AnnData.h5adfile. 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 whenTrue. DefaultTrue.penalize_error(bool) — include reconstruction-error penalty. DefaultTrue.adata_filename(str) — filename for the saved GRN AnnData insideoutput_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. Default0.1.print_every(int) — log training every N epochs. Default100.optimizer(str) — PyTorch optimiser name. Default'Adam'.learning_rate(float) — optimiser learning rate. Default0.005.epochs(int) — maximum training epochs per model. Default10000.n_models(int) — ensemble size. Default20.validation_size(float) — early-stopping validation fraction. Default0.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')¶
- classmethod read_yaml(yaml_file)[source]¶
Construct a
NetmapConfigfrom a YAML file.Reads the YAML file at
yaml_file, prints the parsed dictionary for debugging, and returns a newNetmapConfiginstance populated with the values found in the file. Keys in the YAML must match the field names ofNetmapConfigexactly.- Parameters:
yaml_file (str) – Path to the YAML configuration file to read.
- Returns:
A new instance initialised from the YAML contents.
- Return type:
- write_yaml(yaml_file)[source]¶
Serialise this configuration to a YAML file.
Writes all fields of the current instance to
yaml_filein YAML format, preserving field order (sort_keys=False). The resulting file can be loaded back withread_yaml().- Parameters:
yaml_file (str) – Destination path for the YAML file. The file is created or overwritten if it already exists.
- Returns:
None