from dataclasses import dataclass import os @dataclass class CascadedFlowConfig: # === Base (same as scDFM FlowConfig) === model_type: str = "cascaded" batch_size: int = 48 ntoken: int = 512 d_model: int = 128 nhead: int = 8 nlayers: int = 4 lr: float = 5e-5 steps: int = 200000 eta_min: float = 1e-6 devices: str = "1" test_only: bool = False data_name: str = "norman" perturbation_function: str = "crisper" noise_type: str = "Gaussian" poisson_alpha: float = 0.8 poisson_target_sum: int = -1 print_every: int = 5000 mode: str = "predict_y" result_path: str = "./result_online" fusion_method: str = "differential_perceiver" infer_top_gene: int = 1000 n_top_genes: int = 5000 checkpoint_path: str = "" gamma: float = 0.5 split_method: str = "additive" use_mmd_loss: bool = True fold: int = 1 use_negative_edge: bool = True topk: int = 30 # === Cascaded / Latent specific === scgpt_dim: int = 512 bottleneck_dim: int = 128 latent_weight: float = 1.0 choose_latent_p: float = 0.4 target_std: float = 1.0 dh_depth: int = 2 warmup_batches: int = 200 # batches to collect running stats # === EMA === ema_decay: float = 0.9999 # === Logit-normal time-step sampling === t_sample_mode: str = "logit_normal" # "uniform" or "logit_normal" t_expr_mean: float = 0.0 # expression flow logit-normal mu t_expr_std: float = 1.0 # expression flow logit-normal sigma t_latent_mean: float = 0.0 # latent flow logit-normal mu t_latent_std: float = 1.0 # latent flow logit-normal sigma # === LR warmup === warmup_steps: int = 2000 # === scGPT paths === scgpt_model_dir: str = "transfer/data/scGPT_pretrained" scgpt_max_seq_len: int = 1200 scgpt_cache_path: str = "" # Pre-extracted HDF5 path. Empty = online extraction (default) # === Inference === latent_steps: int = 20 expr_steps: int = 20 ode_method: str = "rk4" # "euler" or "rk4" def __post_init__(self): if self.data_name == "norman_umi_go_filtered": self.n_top_genes = 5054 if self.data_name == "norman": self.n_top_genes = 5000 def make_path(self): scgpt_mode = "cached" if self.scgpt_cache_path else "online" t_mode = "ln" if self.t_sample_mode == "logit_normal" else "uni" exp_name = ( f"ccfm-{self.data_name}-f{self.fold}" f"-topk{self.topk}-neg{self.use_negative_edge}" f"-d{self.d_model}-lr{self.lr}" f"-lw{self.latent_weight}-lp{self.choose_latent_p}" f"-ema{self.ema_decay}-{t_mode}-wu{self.warmup_steps}" f"-{self.ode_method}-{scgpt_mode}" ) return os.path.join(self.result_path, exp_name)