I’m using miloR and observing unexpected behavior.
When I run the analysis on multiple clusters together, I get this:
When I subset to just one cluster (same samples, cells, I use the same PCA dims, same parameters d, k, similar cells per NH, alpha=0.05). I just generate the Umap, but the results look very different:
For that specific cluster the number of NH DA looks lower compared to the the one where all the clusters are together, (the pvalue distribution looks similar between the two analysis).
here the code I use:
k=40
d=29
complete.milo <- buildGraph(complete.milo, k = k, d = d)
complete.milo <- makeNhoods(complete.milo, prop = 0.1, k = k, d=d, refined = TRUE)
plotNhoodSizeHist(complete.milo)
complete.milo <- countCells(complete.milo, meta.data = data.frame(colData(complete.milo)), sample="Unique_ID")
design <- data.frame(colData(complete.milo))[,c("Unique_ID", "Macro.Condition")]
design <- distinct(design)
rownames(design) <- design$Unique_ID
## Reorder rownames to match columns of nhoodCounts(milo)
nhoodCounts(complete.milo)
design2 <- design[colnames(nhoodCounts(complete.milo)), , drop=FALSE]
rownames(design2) <- design2$Unique_ID
levels(design2$Macro.Condition)
design2$Macro.Condition <- as.factor(design2$Macro.Condition)
levels(design2$Macro.Condition)
contrast.all <- c("Macro.ConditionRemission - Macro.ConditionActive", "Macro.ConditionHealthy - Macro.ConditionRemission","Macro.ConditionHealthy - Macro.ConditionActive")
# this is the edgeR code called by `testNhoods`
model <- model.matrix(~ 0 + Macro.Condition, data=design2)
mod.constrast <- makeContrasts(contrasts=contrast.all, levels=model)
mod.constrast
da_results <- testNhoods(complete.milo, design = ~0+Macro.Condition, design.df = design2 ,model.contrasts=c("Macro.ConditionHealthy - Macro.ConditionRemission"), fdr.weighting="graph-overlap")
da_results %>% arrange(- SpatialFDR) %>% head()
da_results %>% arrange(- SpatialFDR) %>% tail()
complete.milo <- buildNhoodGraph(complete.milo)
plotNhoodGraphDA(complete.milo, da_results, alpha=0.05) + plot_layout(guides="collect")
Has anyone encountered this before? Am I doing anything wrong?
I’m using miloR and observing unexpected behavior.
When I run the analysis on multiple clusters together, I get this:
When I subset to just one cluster (same samples, cells, I use the same PCA dims, same parameters d, k, similar cells per NH, alpha=0.05). I just generate the Umap, but the results look very different:
For that specific cluster the number of NH DA looks lower compared to the the one where all the clusters are together, (the pvalue distribution looks similar between the two analysis).
here the code I use:
Has anyone encountered this before? Am I doing anything wrong?