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

Issue with clustering - Leiden #150

Open
juan-quintana2020 opened this issue Oct 31, 2021 · 5 comments
Open

Issue with clustering - Leiden #150

juan-quintana2020 opened this issue Oct 31, 2021 · 5 comments

Comments

@juan-quintana2020
Copy link

I am having trouble adjusting my Giotto matix. I have inputted the following code:
d45 <- calculateHVG(gobject = d45, save_param = list(save_name = '3_a_HVGplot'))
d45 <- runPCA(gobject = d45, center = TRUE, scale_unit = TRUE)
d45 <- runUMAP(d45, dimensions_to_use = 1:30)
d45 <- doLeidenCluster(my_giotto_object, name = 'leiden_clus')

I expected that my matrix would be appropriately adjusted, but I got the following error:
Error in igraph::as_data_frame(x = igraph_object, what = "edges") :
Not a graph object

For more context, I am running R version 4.0.4 and Giotto version 1.0.4

the script was working beautifully until a couple of days ago. Any help much appreciated!

@RubD
Copy link
Collaborator

RubD commented Oct 31, 2021

Hi,

I believe you are missing the step where you create a sNN network. That step is necessary to perform the Leiden clustering and is typically performed right before any graph-based clustering algorithms like Leiden.

Something like this should resolve the issue. I'll see if I can add a more informative error message.

d45 <- createNearestNetwork(gobject = d45, dimensions_to_use = 1:30, k = 5)

Let me know if it works!

@juan-quintana2020
Copy link
Author

Hi there,

It seems to have worked! Thanks a lot for your help.

I'm going to take this opportunity to ask if there is a more straightforward way to define the parameters when aupdating the Giotto image:
d45 = updateGiottoImage(d45, image_name = 'image', xmax_adj = 420, xmin_adj = 400, ymax_adj = 420, ymin_adj = 400)

I can't seem to find the right values to completely overlay the two images.

Thanks a lot,

Juan

@RubD
Copy link
Collaborator

RubD commented Nov 2, 2021

Hi Juan, Is this from a Visium dataset or how was the data generated?
@jiajic might be able to help you with this issue.
Best,
Ruben

@jiajic
Copy link
Member

jiajic commented Nov 2, 2021

Hi Juan!

Just adding on here, we're currently working on some more automated methods for this issue for an update.

For now, I'd like to explain a bit more about the image alignment:
It works by stretching your image to cover your spatial locations' x and y minmax values by default as a sort of anchor for the adjustments. You can find what is being used as these anchor values by viewing your giotto image object.
For example:
Screen Shot 2021-11-02 at 11 24 35 AM

The additional adjustment values you add on top of that are additional distance away from those spatloc minmax values that you want to stretch the image. (see diagram below)
Screen Shot 2021-11-02 at 11 30 13 AM

If your image is at the same scale as your spatial locations (one unit distance in spatlocs = 1 pixel) then you can just find the distance from your spatloc minmax values to the corresponding following values:
img_xmin = 0
img_xmax = img width
img_ymin = -img height
img_ymax = 0

The resulting values should be the exact adjustment values you need.

*If the scale is different, you would need the additional step of first scaling your img width and height to that of your spatial locations before finding the distances.

@juan-quintana2020
Copy link
Author

Hi @jiajic - that is really useful, I will give this a go and see if I can get a better alignment.

I'm sorry for keep posting here but we had a follow-up question. For the spot enrichment tool, is there any way to run the spot deconvolution with the SCTransformed seurat scRNAseq object? I'm trying to follow the RANK Enrichment tool but can't seem to understand how or where to get this file "raw_exp_small.txt" or what the equivalent would be on my own data?

Thanks a lot for helping!

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

3 participants