This is a test version of Biostars. For the public version, visit https://www.biostars.org.
IntegrateData Seurat

Hi,

I wanted to ask if this approach is correctly performed.

seurat_st <- merge(
  x = TS1,
  y = list(TS2, TS3, TS4),
  add.cell.ids = paste0("TS", 1:4),
  project = "SpatialProject"
)

split_spatial <- SplitObject(seurat_st, split.by = "genotype")

split_spatial <- lapply(seurat_st, SCTransform, assay = "Spatial", vst.flavor = "v2", conserve.memory = TRUE)

or is it better to do SCTransform individually?

split_spatial <- lapply(split_spatial, SCTransform, assay = "Spatial", vst.flavor = "v2", conserve.memory = TRUE)
samples <- paste0("TS", 1:4)
split_spatial  <- mget(samples)
spatial_features <- SelectIntegrationFeatures(split_spatial, verbose = FALSE)

split_spatial <- PrepSCTIntegration(object.list = split_spatial, anchor.features = spatial_features,
                              verbose = FALSE)

Also, I wanted to avoid the error in IntegrateData function

Error en .M2C(newTMat(i = c(ij1[, 1], ij2[, 1]), j = c(ij1[, 2], ij2[, : 
  'R_Calloc' could not allocate memory (22989229 of 4 bytes)

spatial_anchors <- FindIntegrationAnchors(object.list = split_spatial, normalization.method = "SCT",
                                      verbose = FALSE, anchor.features = spatial_features)

So, I perform rpca function to avoid this error.

spatial_anchors <- FindIntegrationAnchors(
    object.list = split_spatial,
    normalization.method = "SCT",
    dims = 1:30,
    reduction = "rpca", anchor.features = spatial_features
)

spatial_integrated <- IntegrateData(anchorset = spatial_anchors, normalization.method = "SCT",
                                    verbose = FALSE)

But I get the error: std::bad_alloc

sctransform seurat integration st

Both errors are related to memory issues. Increase your RAM.

Hi, how it would be done in R?

If it is R raising the issue try :

memory.limit(size= X)
options(future.globals.maxSize = X)

If it is a physical issue... well, buy more RAM for your computer or HPC.

1 answer

Run SCTransform individually on each sample, and for 4 spatial samples, Harmony is the better choice — it won't blow your RAM.

Log in to answer this question.