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

Odd cell neighbourhood preservation scores after manually creating SinglecellExperiment from Seurat V5 assay #4

Open
ondina-draia opened this issue Jul 18, 2024 · 0 comments

Comments

@ondina-draia
Copy link

Hello,

I encounter a problem with latest version of the Seurat object (V5 Assays) which is also SCTransformed, when I try to convert in SingleCellExperiment format, I get the following error.

P30.N.sce <- as.SingleCellExperiment(obj$P30.N)

Error in `GetAssayData()`:
! GetAssayData doesn't work for multiple layers in v5 assay

I tried to find a workaround to this trouble by manually creating the SingleCellExperiment object manually:

# Convert to V3/4 assay
obj$P30.N <- NormalizeData(obj$P30.N, assay = "RNA")
obj$P30.N[["RNA3"]] <- as(object = obj$P30.N[["RNA"]], Class = "Assay")

# Raw data stored in RNA3 as counts
counts <- GetAssayData(obj$P30.N, assay = "RNA3", slot = "counts")

# Extract normalized counts
#normalized_counts <- GetAssayData(obj$P30.N, assay = "RNA3", slot = "data")

# MetaData
meta_data <- obj$P30.N@meta.data

# Create SingleCellExperiment object
P30.N.sce <- SingleCellExperiment(
  assays = list(counts = counts, logcounts = normalized_counts),
  colData = meta_data
)

# Extract PCA data
pca_coords <- Embeddings(obj$P30.N, reduction = "pca")

# Add PCA coordinates to the SingleCellExperiment object
reducedDim(P30.N.sce, "PCA") <- pca_coords

# If thereés UMAP embeddings, extract them:
if ("umap" %in% names(obj$P30.N@reductions)) {
  umap_coords <- Embeddings(obj$P30.N, reduction = "umap")
  reducedDim(P30.N.sce, "UMAP") <- umap_coords
}

It seems to work until I check the cell neighborhood preservation scores:

ex2

I don't have this error or this kind of behaviour with the V3 assays.

What should I do? What is the cause of this strange behaviour?

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