Skip to content

02_EBD_preprocessing_and_vanilla_colab.ipynb used deprecated MIOFlow (not 2.0) architecture. Updated and tested it. Works now.#28

Open
GiuGiglio wants to merge 1 commit into
KrishnaswamyLab:mainfrom
GiuGiglio:fix-ebd-tutorial-and-device-bugs
Open

02_EBD_preprocessing_and_vanilla_colab.ipynb used deprecated MIOFlow (not 2.0) architecture. Updated and tested it. Works now.#28
GiuGiglio wants to merge 1 commit into
KrishnaswamyLab:mainfrom
GiuGiglio:fix-ebd-tutorial-and-device-bugs

Conversation

@GiuGiglio

Copy link
Copy Markdown

Fix device mismatch in MIOFlow core and upgrade EBD tutorial to GAGA autoencoder pipeline

This commit fixes a critical GPU device mismatch in the MIOFlow core and massively overhauls the EBD tutorial notebook to use the modern Geometric Autoencoder (GAGA) pipeline instead of the older, manual PHATE DataFrame approach.

Core Changes (mioflow/mioflow.py):

  • Fixed GPU Device Mismatch Bug: When running on CUDA, _encode() and decode_to_gene_space() previously crashed with a device mismatch (cuda:0 vs cpu). The internal torch.tensor(X_scaled) and torch.tensor(traj_flat) calls were defaulting to the CPU, while the gaga_autoencoder model sat on the GPU. Added device=self.device to these tensor instantiations to ensure device synchronization. ### Tutorial Notebook Changes (tutorials/02_EBD_preprocessing_and_vanilla_colab.ipynb):
  • Removed legacy PHATE DataFrame logic and instead set discrete_time directly via pd.factorize.
  • Integrated GAGA Autoencoder Training: Added the missing cell to explicitly train the GAGA autoencoder (fit_gaga) using X_pca and X_phate.
  • Corrected MIOFlow Initialization: Replaced the deprecated input_df and obsm_key parameters with the modernized Autoencoder configuration (gaga_model=gaga_model and gaga_input_key='X_pca').
  • Overhauled Loss Visualization: Replaced the generic plot_losses() function call with a detailed, custom matplotlib block.
  • Modernized Trajectory Visualization (Step 11): Re-wrote the visualization block to natively evaluate background cells through the trained gaga_model.encode() pipeline, plotting the trajectories directly on the GAGA latent embedding instead of PHATE.
  • Fixed Scanpy Namespace Collision: Added import scanpy as sc directly before running highly_variable_genes. The previous scatterplot assignment (sc = ax.scatter) overwrote the scanpy as sc module.
  • Updated Single-Trajectory Selection: Swapped the background scatter data from true_data (PHATE) to gaga_embedding (GAGA).

…autoencoder pipeline

This commit fixes a critical GPU device mismatch in the MIOFlow core and massively overhauls the EBD tutorial notebook to use the modern Geometric Autoencoder (GAGA) pipeline instead of the older, manual PHATE DataFrame approach.
### Core Changes (mioflow/mioflow.py):
* Fixed GPU Device Mismatch Bug: When running on CUDA, _encode() and decode_to_gene_space() previously crashed with a device mismatch (cuda:0 vs cpu). The internal torch.tensor(X_scaled) and torch.tensor(traj_flat) calls were defaulting to the CPU, while the gaga_autoencoder model sat on the GPU. Added device=self.device to these tensor instantiations to ensure device synchronization.
### Tutorial Notebook Changes (tutorials/02_EBD_preprocessing_and_vanilla_colab.ipynb):
* Removed legacy PHATE DataFrame logic and instead set discrete_time directly via pd.factorize.
* Integrated GAGA Autoencoder Training: Added the missing cell to explicitly train the GAGA autoencoder (fit_gaga) using X_pca and X_phate.
* Corrected MIOFlow Initialization: Replaced the deprecated input_df and obsm_key parameters with the modernized Autoencoder configuration (gaga_model=gaga_model and gaga_input_key='X_pca').
* Overhauled Loss Visualization: Replaced the generic plot_losses() function call with a detailed, custom matplotlib block.
* Modernized Trajectory Visualization (Step 11): Re-wrote the visualization block to natively evaluate background cells through the trained gaga_model.encode() pipeline, plotting the trajectories directly on the GAGA latent embedding instead of PHATE.
* Fixed Scanpy Namespace Collision: Added import scanpy as sc directly before running highly_variable_genes. The previous scatterplot assignment (sc = ax.scatter) overwrote the scanpy as sc module.
* Updated Single-Trajectory Selection: Swapped the background scatter data from true_data (PHATE) to gaga_embedding (GAGA).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants