Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding function for mode="nmf" #67

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

anupriyatripathi
Copy link

@anupriyatripathi anupriyatripathi commented Jul 10, 2022

This implements option 1 i.e. mapping NMF W*H on spatial data.
@hejinhuang could you please review it?

cluster_label (String): field in `adata.obs` used for aggregating values
nmf_coeffs (pd.DataFrame): NMF `H` matrix (factor by sample)
sample_name (String): name of the sample to be mapped as labeled in `nmf_coeffs`
scale (bool): Optional. Whether weight input single cell by # of cells in cluster. Default is True.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

scale is unused. remove.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, good catch! 👍

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed!

@@ -210,6 +258,10 @@ def map_cells_to_space(
adata_sc = adata_to_cluster_expression(
adata_sc, cluster_label, scale, add_density=True
)
if mode == "nmf":
adata_sc = adata_to_nmf_factor_expression(
adata_sc, cluster_label, nmf_coeffs, sample_name, add_density=True

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense to assume that you have an "adata_sc"? For NMF mapping, you're just starting with nmf_factors and nmf_coeffs. I would recommend passing both of those, and building the adata in the new function.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One usually runs tg.pp_adatas() before tg.map_cells_to_space() (which calls adata_to_nmf_factor_expression()). So, I think we can assume that we have adata_sc. Is that what you were wondering about?

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