-
Notifications
You must be signed in to change notification settings - Fork 22
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
merging Nhood with logFC of opposite sign #270
Comments
Hi @gianfilippo as stated on the github repo landing page please report the output of your sessionInfo() when reporting issues. |
sorry about it. Here it is Matrix products: default locale: attached base packages: other attached packages: loaded via a namespace (and not attached): |
Please up date Milo the current Bioc release first. |
Hi, da_results = groupNhoods(miloOBJ, da_results, da.fdr=0.05) logFC PValue FDR Nhood SpatialFDR NhoodGroup What do you think ? Thanks |
Have you previously run |
Hi, I start from a Seurat integrated object, scdata. Then |
Ok - either don't run |
I will give a try to both options Thanks |
Hi, I tried both suggestions. Here are the results:
What do you think ? What am I doing wrong ? |
Hi, did you have time to look into this issue ? Thanks |
I seems that if I define subset.nhoods (= to the DA Nhoods in my case), the logFC are concordant within each group, although the logFC difference can be larger than the max.lfc.delta. |
Any update on this @MikeDMorgan |
my present solution is to use a combination of cell cluster and logFC sign to define groups. I am not sure about "mixed" nhoods, should I include them in marker analysis or filter them out ? |
hoping for an update on this, thank you! |
I notice that this problematic phenomenon is still happening in version 2.2.0. |
Do you have a minimally reproducible example so I can investigate please. |
Step 1: Download library(Seurat)
library(SingleCellExperiment)
load("GSE188737_hnscc_seu.RData") # Adapt to your location. Then, simply run all commands below without modification. Do you see a mixed NhoodGroup 2 (red and blue)? GSE188737counts <- GetAssayData(object = hnscc_seu, assay = "RNA", layer = "counts")
smoker <- rep("Yes", ncol(GSE188737counts))
smoker[hnscc_seu[[]]$patientID %in% c("HN263", "HN237", "HN272")] <- "No"
smoker <- factor(smoker)
GSE188737 <- SingleCellExperiment(assays = list(counts = GSE188737counts),
colData = DataFrame(patientID = hnscc_seu[[]]$patientID,
sampleID = hnscc_seu[[]]$origin,
cellType = hnscc_seu[[]]$cell_type,
smoker = smoker))
library(scran)
GSE188737 <- logNormCounts(GSE188737)
library(scater)
GSE188737 <- runPCA(GSE188737)
GSE188737 <- runUMAP(GSE188737, dimred = "PCA")
plotUMAP(GSE188737, colour_by = "cellType")
fibroblastsOnly <- GSE188737[, GSE188737$cellType %in% c("CAFs", "Myofib")]
set.seed(4567)
library(miloR)
milo <- Milo(fibroblastsOnly)
reducedDim(milo, "UMAP") <- reducedDim(fibroblastsOnly, "UMAP")
milo <- buildGraph(milo)
milo <- makeNhoods(milo, refinement_scheme = "graph")
design <- data.frame(colData(milo))[, c("sampleID", "smoker")]
IDs <- unique(design$sampleID)
design <- design[!duplicated(design), "smoker", drop = FALSE]
rownames(design) <- IDs
milo <- countCells(milo, meta.data = colData(milo), samples = "sampleID")
## Reorder rownames to match columns of nhoodCounts(milo).
design <- design[colnames(nhoodCounts(milo)), , drop = FALSE]
smokerResults <- testNhoods(milo, design = ~ smoker, design.df = design, fdr.weighting = "graph-overlap")
smokerResults <- groupNhoods(milo, smokerResults, da.fdr = 0.05)
plotDAbeeswarm(smokerResults, "NhoodGroup") |
One thing to note is that the default setting for @DarioS You should also note that in this dataset there is almost perfect separation of more than half of the nhoods between the smokers and non-smokers, hence it is not appropriate to use as-is for Milo. You can see this by using the
Milo assumes the cells are mixed across samples - without knowing the experimental design, this could be down to strong confounding between batch and the variable of interest. Now to the apparent bug - this is a quirk of how the nhoods adjacency is treated for discordant sign nhoods. The implementation only considers DA nhoods as noted above, and so can yield groups that have discordant signs because there are DA nhoods connected to non-DA nhoods with different LFC signs. The intuition is that no nhood groups should contain different LFC signs. The difference is subtle but important. The short story is - this is not a bug per se, but a subtlety in how the nhood adjacency matrix is modified. The adjustments won't propagate through to Bioconductor until the next release in April. However, it is possible to re-install Milo from the devel branch: The default behaviour of groupNhoods is retained. However, to get the intuitive, i.e. no nhood groups with discordant LFCs then use
|
Hi,
I am running the groupNhoods function on the da_results data.frame.
The da_results shows the following
logFC logCPM F PValue FDR Nhood SpatialFDR
946 6.555608 7.725746 20.33434 3.864789e-04 0.2744 946 0.2281628
1221 -2.679248 8.772024 26.29051 9.286647e-05 0.2744 1221 0.2281628
2178 -3.034338 8.446574 20.82294 3.465521e-04 0.2744 2178 0.2281628
2248 -2.549574 8.700925 20.51058 3.239712e-04 0.2744 2248 0.2281628
2291 -3.060969 8.536979 22.01882 2.303425e-04 0.2744 2291 0.2281628
da_results = groupNhoods(miloobj, da_results, da.fdr=FDR)
logFC logCPM F PValue FDR Nhood SpatialFDR. NhoodGroup
946 6.555608 7.725746 20.33434 3.864789e-04 0.2744 946 0.2281628. 9
1221 -2.679248 8.772024 26.29051 9.286647e-05 0.2744 1221 0.2281628. 14
2178 -3.034338 8.446574 20.82294 3.465521e-04 0.2744 2178 0.2281628. 9
2248 -2.549574 8.700925 20.51058 3.239712e-04 0.2744 2248 0.2281628. 1
2291 -3.060969 8.536979 22.01882 2.303425e-04 0.2744 2291 0.2281628. 1
It looks like the Nhoods 946 and 2178 are placed in teh same group, even though the logFC is of opposite sign.
Note: I am using a FDR cut-off of 0.25, because in this run I only had N=2
I am running miloR version 1.5.0
Am I missing something ?
Thanks
The text was updated successfully, but these errors were encountered: