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

when runnning st.align.morpho_align_ref : NameError: name 'BA_align' is not defined #271

Open
forrwill opened this issue Sep 29, 2024 · 9 comments

Comments

@forrwill
Copy link

forrwill commented Sep 29, 2024

The other day, I upgraded the latest version of github software,

when running 'st.align.morpho_align_ref'. for "Alignment of 3D models of two stages",

I met the error: NameError. Traceback (most recent call last) NameError: name 'BA_align' is not defined
, I don't know what the problem is, Please help me with this. thank you

@Xiaojieqiu
Copy link
Contributor

@YifanLu2000 can you please address @forrwill 's question?

@YifanLu2000
Copy link
Contributor

Hi, thanks for raising the issue. We have fixed this bug, and after testing, the function st.align.morpho_align_ref should now work as expected. Here is our test result
image
Additionally, another suggestion is that you might want to use the st.align.morpho_align function directly, as it may provide more accurate results. The st.align.morpho_align_ref function performs downsampling. If your dataset is large, we recommend enabling sparse computation by passing the following parameters:

sparse_calculation_mode=True,
use_chunk=True,
chunk_capacity=2,  # please adjust this parameter based on your GPU memory

Furthermore, you can also choose to downsample your input data before using st.align.morpho_align. I hope this helps!

@forrwill
Copy link
Author

Thank you very much for your suggestion. and. I will use it again.

@yuling999666
Copy link

Hi Yifan, I used st.align.morpho_align and got a mapping matrix (pis), but the dimension is (1,1742, 19939). Originally, I have 17425 spots for the reference slice and 19939 spots for the second slice. I'm confused about what does mapping matrix stand for since it doesn't look like what I have done using PASTE. How could the spot number has such a huge reduction? Thanks.

@YifanLu2000
Copy link
Contributor

Hi @yuling999666, thank you for raising this issue. In Spateo, we typically use SVI (Stochastic Variational Inference) for optimization. This means that parameter updates are computed using subsets of the data to reduce computational time.

For the final output, we provide an option to return the complete mapping matrix by setting return_mapping=True. This will generate an NxM mapping matrix but may take slightly more time. Since the mapping matrix is generally not commonly used in alignment tasks, the default setting is return_mapping=False. You can try setting return_mapping=True to obtain the mapping matrix.

Another possible approach is to set SVI=False, which will also return the NxM mapping matrix. However, this is not recommended as it will consume significantly more time and computational resources

@yuling999666
Copy link

Hi @yuling999666, thank you for raising this issue. In Spateo, we typically use SVI (Stochastic Variational Inference) for optimization. This means that parameter updates are computed using subsets of the data to reduce computational time.

For the final output, we provide an option to return the complete mapping matrix by setting return_mapping=True. This will generate an NxM mapping matrix but may take slightly more time. Since the mapping matrix is generally not commonly used in alignment tasks, the default setting is return_mapping=False. You can try setting return_mapping=True to obtain the mapping matrix.

Another possible approach is to set SVI=False, which will also return the NxM mapping matrix. However, this is not recommended as it will consume significantly more time and computational resources

Thanks for clarification. It really helps. I appreciate it.

@yuling999666
Copy link

Hi @YifanLu2000 , It seems that your method (Stochastic Variational Inference) including randomness. However, I can generate the same result for .obsm["align_spatial"] without setting seed... Did I do something wrong or you have done other process. Thanks.

@YifanLu2000
Copy link
Contributor

Hi @yuling999666, are the results exactly the same? We didn’t apply any other processing, so this seems strange. Can you give more information, for example the cell number

@yuling999666
Copy link

Hi @yuling999666, are the results exactly the same? We didn’t apply any other processing, so this seems strange. Can you give more information, for example the cell number

Hi @YifanLu2000 Previously, I just checked the first few lines of my saved results, but later I recognized it is the reference and for the next slice, the coordinates changed. The reference will not change after computed by pipeline. Sorry for the misunderstanding. I also set seed using np.random.seed(2024) before applying st.align.morph_align() and the result stayed the same so that I can replicate the results. Thanks for your response.

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

No branches or pull requests

4 participants