Abstract
While neural networks can be trained to map from one specific dataset to another, they usually do not learn a generalized transformation that can extrapolate accurately outside the space of training. For instance, a generative adversarial network (GAN) exclusively trained to transform images of black-haired men to blond-haired men might not have the same effect on images of black-haired women. This is because neural networks are good at generation within the manifold of the data that they are trained on. However, generating new samples outside of the manifold or extrapolating "out-of-sample" is a much harder problem that has been less well studied. To address this, we introduce a technique called neuron editing that learns how neurons encode an edit for a particular transformation in a latent space. We use an autoencoder to decompose the variation within the dataset into activations of different neurons and generate transformed data by defining an editing transformation on those neurons. By performing the transformation in a latent trained space, we encode fairly complex and non-linear transformations to the data with much simpler distribution shifts to the neuron's activations. We motivate our technique on an image domain and then move to our two main biological applications: removal of batch artifacts representing unwanted noise and modeling the effect of drug treatments to predict synergy between drugs.
Introduction
Deep learning models, particularly Generative Adversarial Networks (GANs), have demonstrated remarkable capabilities in data interpolation—the generation of samples that reside within the distribution of the training set. However, these models frequently falter when tasked with extrapolation. In the context of image processing, a model trained to modify the hair color of men may fail to generalize to women, either by failing to apply the change or by erroneously altering the subject's gender to match the training manifold.
This limitation is particularly acute in biological research. For example, researchers may understand the effect of a therapeutic agent on one specific cell type but struggle to predict its impact on a different, unmeasured cell type. This "out-of-sample" problem requires the model to learn a generalizable "edit rule" rather than a simple mapping between two static distributions. To solve this, we propose Neuron Editing, a method that leverages the latent space of autoencoders to apply transformations that preserve the underlying context of the input data.
Methodology: Latent Space Neuron Editing
The Neuron Editing framework operates on the principle that complex, non-linear transformations in high-dimensional data space can be represented as simpler distribution shifts within a well-structured latent space. The process consists of three primary phases:
- Latent Space Mapping: A standard autoencoder is trained on the entire population of data, including both "pre-transformation" and "post-transformation" samples. This process forces the network to learn a compressed representation where complex features are decomposed into individual neuron activations.
- Defining the Edit: Rather than training a generator, we define a piecewise linear transformation based on the percentiles of neuron activations. By comparing the activation distributions of the source and target groups for each neuron in the latent layer, we can define a deterministic shift that captures the essence of the transformation.
- Inference-Time Editing: During inference, a new, out-of-sample sample is passed through the encoder. The learned percentile-based edit is applied to the latent neurons, and the modified activations are then passed through the decoder to reconstruct the transformed data.
Experimental Evaluation
We evaluated Neuron Editing across three distinct domains to test its robustness in extrapolation and biological modeling.
Image Extrapolation (CelebA)
Using the CelebA face dataset, we tested the model's ability to apply a hair color transformation (black to blond) learned on male faces to female faces. Unlike traditional GANs and CycleGANs, which often introduced artifacts or blurred the subject's identity, Neuron Editing successfully performed the transformation while maintaining semantic consistency and identity.
Biological Batch Correction
In mass cytometry data from Dengue Virus patients, technical noise (batch artifacts) often obscures real biological signals. While GANs often "over-correct" by removing both noise and biological variation (such as CCR6 protein levels), Neuron Editing successfully isolated and removed the technical shift in specific proteins like IFNg while preserving the natural variation in others.
Predicting Drug Synergy
We applied the method to a single-cell dataset of leukemia cells treated with drugs like BEZ-235 and Dasatinib. By applying the "Dasatinib edit" to cells already treated with BEZ-235, the model accurately predicted the synergistic effect of the combination therapy. Notably, it correctly identified a specific shift in the p4EBP1 protein, a detail missed by competing models.
Discussion and Key Insights
The success of Neuron Editing stems from reframing the problem from generation to editing. By treating the transformation as a delta applied to an existing sample, the model naturally preserves the "context" of the out-of-sample input. This approach assumes that neurons represent consistent features across the data manifold—for instance, if a neuron encodes "hair color intensity," editing it should remain valid regardless of other features like gender.
Furthermore, Neuron Editing offers superior stability compared to GANs. Because it relies on standard autoencoder training and deterministic latent shifts, it avoids common pitfalls like mode collapse and training instability.
Conclusion
Neuron Editing provides a powerful tool for out-of-sample extrapolation by performing piecewise linear edits in a learned latent space. While the method's performance is dependent on the quality of the underlying autoencoder, it demonstrates significant advantages in preserving biological variation and maintaining semantic consistency in image tasks. Future work will explore more complex, context-dependent edit functions and conditional generation strategies to further enhance the model's flexibility.
Summary updated