troutpy.pl.apply_exrnaH_to_cellular_to_create_cellularW

troutpy.pl.apply_exrnaH_to_cellular_to_create_cellularW#

troutpy.pl.apply_exrnaH_to_cellular_to_create_cellularW(adata_extracellular_with_nmf, adata_annotated_cellular)#

Transfer NMF gene loadings from an extracellular RNA dataset to a cellular dataset.

Computes the cellular W matrix by multiplying the cellular gene expression values with the filtered H matrix (gene loadings) from the extracellular NMF results, restricted to genes shared between both datasets.

Parameters:
  • adata_extracellular_with_nmf (anndata.AnnData) – An AnnData object containing the extracellular RNA data with the NMF results. The H matrix is expected to be stored in adata.uns['H_nmf'].

  • adata_annotated_cellular (anndata.AnnData) – An AnnData object containing the cellular RNA data with annotated gene expression values.

Returns:

anndata.AnnData The input adata_annotated_cellular object with the calculated NMF factors (W matrix) added as a DataFrame to adata.obsm["factors"], and each factor also added as an individual column NMF_factor_1, NMF_factor_2, … in adata.obs.