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

Split up map to reference by samples for SeuratMap2Ref #61

Closed
pwwang opened this issue May 9, 2024 · 0 comments
Closed

Split up map to reference by samples for SeuratMap2Ref #61

pwwang opened this issue May 9, 2024 · 0 comments

Comments

@pwwang
Copy link
Owner

pwwang commented May 9, 2024

Seurat vignette (bottom of the page): https://satijalab.org/seurat/articles/multimodal_reference_mapping

query.batches <- SplitObject(query, split.by = "sampleid")
 
#query.batches <- lapply(X = query.batches, FUN = SCTransform, verbose = FALSE)              # from Seurat vignette
#modified version
for (i in 1:length(query.batches)) {
  print(i)
  query.batches[[i]] <- SCTransform(query.batches[[i]],
              assay="RNA",
              residual.features = rownames(x = reference),
              method = 'glmGamPoi',
              ncells = 4000,
              n_genes = 5000,
              vars.to.regress = "percent.mt",
              do.correct.umi = FALSE,
              do.scale = FALSE,
              do.center = TRUE,
                      verbose = FALSE)
}
 
anchors <- list()
for (i in 1:length(query.batches)) {
  anchors[[i]] <- FindTransferAnchors(
    reference = reference,
    query = query.batches[[i]],
    normalization.method = "SCT",
    #  recompute.residuals=FALSE,
    reference.reduction = "spca",
    k.filter = NA,
    dims = 1:15
    )
}
 
for (i in 1:length(query.batches)) {
  query.batches[[i]] <- MapQuery(
    anchorset = anchors[[i]],
    query = query.batches[[i]],
    reference = reference,
    refdata = list(
      celltype = "celltype.l2",
      predicted_ADT = "ADT"),
    reference.reduction = "spca",
    reduction.model = "wnn.umap"
  )
}
 
for (i in 1:length(query.batches)) {
  query.batches[[i]] <- AddMetaData(
    object = query.batches[[i]],
    metadata = MappingScore(anchors = anchors[[i]]),
    col.name = "mapping.score"
  )
}
 
# Merge the batches
query <- merge(query.batches[[1]], query.batches[2:length(query.batches)], merge.dr = "ref.umap")
query
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

1 participant