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

Should not perform any direct filtering on da_result before executing groupNhoods #353

Open
isaamael opened this issue Nov 14, 2024 · 1 comment

Comments

@isaamael
Copy link

Hi !

Thank you for your outstanding software. While following the tutorial for analysis, I filtered da_result to remove some irrelevant cell types in plotDAbeeswarm

>packageVersion("miloR")
[1] ‘1.8.1’
>da_result= da_result[!da_result$celltype %in% c("UN1","UN2","UN3","UN4","UN5","UN6","Mixed"),]

As a consequence, groupNhoods throws the error:

Error in .group_nhoods_from_adjacency(nhoods(x), nhood.adj = nhoodAdjacency(x), :
Subsetting is.da vector length is not the same dimension as adjacency

The reason is that groupNhoods checks for equality between

>length(colnames(nhoods(da)))
[1] 5113
>length(colnames(nhoodAdjacency(da)))
[1] 5113
>length(da_result$SpatialFDR)
[1] 4267

filtering in advance causes this error. I am reporting this here in hopes it helps others.

Additionally, I have a question~

Within the same cluster, some Nhoods have increased/decreased after treatment, while others show no significant change.
I am particularly interested in which genes lead to the different changes in Nhoods within the same cluster. Once I obtain the Nhoods and their corresponding clusters, can I manually annotate them instead of using groupNhoods for reclassification? For example, can I assign Nhoods within the same cluster, like C1, that have increased/unchanged/decreased to different NhoodGroups (1/2/3), and then execute findNhoodGroupMarkers among them? Is this approach reasonable?

Any advice from you would be helpful!

@MikeDMorgan
Copy link
Member

If you have a single-cell level annotation in a column of colData() then you can use annotateNhoods to assign a label to each nhood in your DA results data frame. It does this by a majority voting scheme and reports the fraction of cells in the Nhoods with that specific label.

If you want to create a beeswarm or any other nhood plots on a subset of nhoods you need to use the subset.hoods argument for the relevant plotting function.

It sounds like you want to DE testing within a group of Nhoods? That is what the testDiffExp function is for. You can essentially use the same variable as you did for the DA testing to get this.

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

2 participants