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 dealing with multiple samples in RDS, should we opt for reduced dimensionality using 'HARMONY' or stick with PCA? #285

Closed
hai178912522 opened this issue Jun 26, 2023 · 3 comments

Comments

@hai178912522
Copy link

sce <- as.SingleCellExperiment(data)
class: SingleCellExperiment
dim: 15341 79286
metadata(0):
assays(2): counts logcounts
rownames(15341): SAMD11 NOC2L ... PPAN-P2RY11 CEACAM19
rowData names(0):
colnames(79286): P30.post.1_P30.tr.1.AAACCTGAGATCCGAG-1
P30.post.1_P30.tr.1.AAACCTGAGCCGATTT-1 ...
P28.pre_P28.ut.TTTGTCAGTGACCAAG-1 P28.pre_P28.ut.TTTGTCATCGAATGCT-1
colData names(13): orig.ident nCount_RNA ... seurat_cluster ident
reducedDimNames(4): UMAP TSNE HARMONY PCA
mainExpName: RNA
altExpNames(0):
milo <- Milo(sce)
milo <- buildGraph(milo, k = 30, d = 30, reduced.dim = "HARMONY")
milo <- makeNhoods(milo, prop = 0.05, k = 30, d = 30, refined = TRUE, reduced_dims = "HARMONY")
p.NhSize = plotNhoodSizeHist(milo)
image
milo <- countCells(milo, meta.data = as.data.frame(colData(milo)), sample="sample")
6 x 30 sparse Matrix of class "dgCMatrix"

1 2 1 3 2 2 1 1 7 2 . . 2 2 1 1 11 3 8 . 6 5 8 5 . 2 1 1 . 1 1
2 2 3 . 1 1 . 2 1 1 1 . . . 1 . 8 . 4 . 3 6 4 11 . . . . . . .
3 3 1 3 2 . 1 1 2 1 1 . . 1 4 3 14 . 6 2 5 6 10 16 1 1 1 1 . 3 .
4 . 12 5 3 . 5 7 4 2 . . 4 6 1 2 20 4 11 2 6 5 6 10 . 4 2 8 . 1 1
5 4 3 3 1 1 1 2 7 . 3 . 2 3 1 3 14 1 8 3 9 14 7 6 . 4 . 2 . . .
6 1 7 1 1 1 2 5 6 1 1 . . 6 2 3 20 3 8 . 4 5 7 16 1 4 4 1 . 2 .

Design

design <- data.frame(colData(milo))[,c("sample", "group")]
design <- distinct(design)
rownames(design) <- design$sample

Compute neighbourhood connectivity

milo <- calcNhoodDistance(milo, d=30, reduced.dim = "HARMONY")

Differential abundance testing

da_results <- testNhoods(milo, design = ~ group, design.df = design)
ggplot(da_results, aes(PValue)) + geom_histogram(bins=50)
image

ggplot(da_results, aes(logFC, -log10(SpatialFDR))) +
geom_point() +
geom_hline(yintercept = 1) ## Ma
image

Is there any issue with my analysis? Will it result in lack of significance?

@emdann
Copy link
Member

emdann commented Jun 26, 2023

Hi @hai178912522,
It makes perfect sense to use the Harmony dimensionality reduction for constructing the KNN graph, if this is the integration methods you have been using for other graph based analyses on your dataset (e.g. clustering, UMAP). This looks like a fairly standard case where no significant differences in abundance are detected, probably because of a small number of replicates per condition (3 replicates as far as I can tell).

One caveat with using Harmony is that it tends to overcorrect differences between samples, as opposed to other integration methods, so it might be that differences between conditions are lost after integration.

@hai178912522
Copy link
Author

This is the situation with my design. It is a comparison of 8 vs 22 in total。
A data.frame: 30 × 2
sample group

P30.post.1 P30.post.1 Post-treatment
P2.pre P2.pre Treatment naive
P29.pre P29.pre Treatment naive
P29.post.1 P29.post.1 Post-treatment
P37.post.1 P37.post.1 Post-treatment
P8.pre P8.pre Treatment naive
P38.post.1 P38.post.1 Post-treatment
P26.pre P26.pre Treatment naive
P14.pre P14.pre Treatment naive
P9.pre P9.pre Treatment naive
P7.pre P7.pre Treatment naive
P4.pre P4.pre Treatment naive
P15.pre P15.pre Treatment naive
P27.pre P27.pre Treatment naive
P22.pre P22.pre Treatment naive
P1.post.3 P1.post.3 Post-treatment
P33.post.1 P33.post.1 Post-treatment
P12.pre P12.pre Treatment naive
P36.post.1 P36.post.1 Post-treatment
P34.pre P34.pre Treatment naive
P6.pre P6.pre Treatment naive
P23.pre P23.pre Treatment naive
P33.pre P33.pre Treatment naive
P20.pre P20.pre Treatment naive
P35.post.1 P35.post.1 Post-treatment
P17.pre P17.pre Treatment naive
P30.pre P30.pre Treatment naive
P18.pre P18.pre Treatment naive
P35.pre P35.pre Treatment naive
P28.pre P28.pre Treatment naive
Is there any good method to help adjust the results?

@MikeDMorgan
Copy link
Member

Closing due to inactivity

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