Skip to content

Commit

Permalink
Update utils.R
Browse files Browse the repository at this point in the history
#40
compatible with Seurat 5
  • Loading branch information
multitalk committed Jun 14, 2024
1 parent df5b507 commit 8ee1042
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,17 @@
.normalize_data <- function(rawdata) {
rawdata <- Seurat::CreateSeuratObject(rawdata)
rawdata <- Seurat::NormalizeData(rawdata, verbose = F)
rawdata <- rawdata[["RNA"]]@data
ver <- packageVersion("Seurat")
ver <- substr(ver,1,1)
if (ver >= 5) {
genenames <- rownames(rawdata)
cellnames <- colnames(rawdata)
rawdata <- rawdata[["RNA"]]@layers$data
rownames(rawdata) <- genenames
colnames(rawdata) <- cellnames
} else {
rawdata <- rawdata[["RNA"]]@data
}
return(rawdata)
}

Expand Down

0 comments on commit 8ee1042

Please sign in to comment.