-
Notifications
You must be signed in to change notification settings - Fork 51
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
base: master
Are you sure you want to change the base?
adding function for mode="nmf" #67
Conversation
tangram/mapping_utils.py
Outdated
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
scale is unused. remove.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, good catch! 👍
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
This implements
option 1
i.e. mapping NMF W*H on spatial data.@hejinhuang could you please review it?