cellink.tl.external.compute_joint_nmf_programs#
- cellink.tl.external.compute_joint_nmf_programs(adata_healthy, adata_disease, *, n_shared=10, n_healthy_specific=5, n_disease_specific=5, gamma=1.0, layer=None, random_state=0, prefix='joint_nmf', out_dir=None, save=True)#
Compute joint NMF programs across healthy and disease tissue.
Decomposes healthy (H) and disease (D) matrices jointly:
H ≈ [L_shared_H | L_unique_H] x F_H D ≈ [L_shared_D | L_unique_D] x F_D
with a coupling term y/2 ||L_shared_H - L_shared_D||² that forces the shared programs to be similar.
- Parameters:
adata_healthy (
AnnData) – AnnData for healthy tissue.adata_disease (
AnnData) – AnnData for disease tissue. Must share var_names withadata_healthy.n_shared (
int(default:10)) – Number of shared programs between healthy and disease.n_healthy_specific (
int(default:5)) – Number of healthy-specific programs.n_disease_specific (
int(default:5)) – Number of disease-specific programs.gamma (
float(default:1.0)) – Coupling strength (higher → shared programs more similar).layer (
str|None(default:None)) – Layer to use as expression matrix. If None, usesadata.X.random_state (
int(default:0)) – Random seed for NMF initialisation.prefix (
str(default:'joint_nmf')) – File name prefix for output CSVs.out_dir (
str|Path|None(default:None)) – Directory for output CSVs.save (
bool(default:True)) – Whether to save CSVs.
- Return type:
- Returns:
dict with keys:
"Wh": healthy cell x factor loadings (shared + healthy-specific)"Wd": disease cell x factor loadings (shared + disease-specific)"Hh": gene x factor weights (healthy)"Hd": gene x factor weights (disease)"shared_Wh": healthy cell x shared-factor loadings"shared_Wd": disease cell x shared-factor loadings"unique_Hh": gene x healthy-specific-factor weights"unique_Hd": gene x disease-specific-factor weights