immunogenomics / symphony

Efficient and precise single-cell reference atlas mapping with Symphony
GNU General Public License v3.0
95 stars 22 forks source link

Reproducing a UMAP embedding with Symphony #31

Open yannk-lm opened 2 years ago

yannk-lm commented 2 years ago

Hello,

I wanted to use the mapQuery function on a UMAP generated from Harmony spaces by my regular pipeline. Then I saw in #15 that it wasn't implemented, so I thought about a different approach.

If I could generate a Symphony reference (using harmony::HarmonyMatrix() into symphony::buildReferenceFromHarmonyObj()) where the input (embeddings, parameters, seeds) are strictly identical to the one I use in my regular pipeline, it should produce (I think) the same result.

However, I am using a wrapper function that use SingleCellExperiment object as input to generate and to store my PCA. Since I have some trouble understanding your processing of the irlba::irlba() output in your vignette, I was wondering if there was a way to extract from my SCE object : 1) the input needed for the data_mat argument in harmony::HarmonyMatrix() 2) the loadings for symphony::buildReferenceFromHarmonyObj()

FYI this is my regular pipeline : dec<-scran::modelGeneVar(sce) top.hvgs <- scran::getTopHVGs(dec, n=hvgs) set.seed(0) sce<-scran::fixedPCA(sce, subset.row=top.hvgs, assay.type = "logcounts", BSPARAM = BiocSingular::IrlbaParam()) set.seed(0) sce <- harmony::RunHarmony(sce, "sample) set.seed(0) sce <- scater::runUMAP(sce, dimred="HARMONY", n_dimred = 30)

Thank you very much for your help and please let me know if some point are not clear enough.

Regards, Yannick

joycekang commented 1 year ago

Hi Yannick,

Apologies for the delay in getting back to you.

If you are still interested in tackling this, (1) the input to harmony::HarmonyMatrix() should be the uncorrected PCA matrix (PCs x cells). (2) the loadings should be the PCA loadings used to project the cells into the lower-dimensional space (dimensions cells x PCs), which should be retrievable from irlba (but I am not sure about the scran function).

You'll also need the Harmony object that is returned by the call to harmony::RunHarmony