satijalab / seurat

R toolkit for single cell genomics
http://www.satijalab.org/seurat
Other
2.28k stars 910 forks source link

is seurat(v5.0.3) does not support a correlation Matrix data as input?? #8861

Closed adesalegn closed 5 months ago

adesalegn commented 5 months ago

Hi,

I've been using Seurat (v4.0.0) along with PCAtools to analyze correlation networks derived from gene expression data. Previously, I had success with the following code snippet:

library(PCAtools)
library(Seurat)

#  gene expression data
set.seed(123) 
num_genes <- 100  # number of genes
num_samples <- 50  # number of samples

# Generate random gene expression data
gene_expr <- matrix(rnorm(num_genes * num_samples), nrow = num_genes, ncol = num_samples)

# Correlation matrix
coreg <- cor(t(gene_expr), use = 'pairwise.complete.obs', method = 'pearson')
coreg_seurat <- CreateSeuratObject(counts = coreg)
coreg_seurat <- ScaleData(coreg_seurat)
coreg_seurat <- RunPCA(coreg_seurat)

# ElbowPlot(coreg_seurat, ndims = 50)
pca_std <- Stdev(object = coreg_seurat, reduction = 'pca')
chosen <- findElbowPoint(pca_std)
coreg_seurat <- RunUMAP(coreg_seurat, dims = 1:8, n.neighbors = k, min.dist = l)

However, after updating to the latest version of Seurat, I encountered issues when running this code. Specifically, I received the following errors:

Warning: Data is of class matrix. Coercing to dgCMatrix.
Warning: No layers found matching search pattern provided
Error in `ScaleData()`:
! No layer matching pattern 'data' found. Please run NormalizeData and retry
Run `rlang::last_trace()` to see where the error occurred.
Warning: No layers found matching search pattern provided
Error in `PrepDR5()`:
! No layer matching pattern 'scale.data' not found. Please run ScaleData and retry
Run `rlang::last_trace()` to see where the error occurred.

thank you AD

adesalegn commented 5 months ago

I got the answer. Thank you!!