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

Error in readVizgen #2

Open
pakiessling opened this issue Nov 5, 2023 · 0 comments
Open

Error in readVizgen #2

pakiessling opened this issue Nov 5, 2023 · 0 comments

Comments

@pakiessling
Copy link

Hi,

i had to make the following modifications to get readVizgen to load correctly:

exprsMat <- data.table::fread(file.path(data_dir, "cell_by_gene.csv"),colClasses = c(cell = 'character') )
cell_idx <- exprsMat[, 1]
exprsMat <- exprsMat[, -1]
exprsMat <- as(as.matrix(t(exprsMat)), "dgCMatrix")
colnames(exprsMat) <- paste("Cell", unlist(cell_idx), sep = "_")
exprsMat <- exprsMat[!grepl("Blank", rownames(exprsMat)), ]
metadata <- read.csv(file.path(data_dir, "cell_metadata.csv"),colClasses = c(EntityID = 'character'))
metadata$cell_id <- metadata$EntityID
rownames(metadata) <- paste("Cell", metadata$cell_id, sep = "_")
metadata <- metadata[colnames(exprsMat), ]
metadata$cell_id <- metadata$EntityID
rownames(metadata) <- paste("Cell", metadata$cell_id, sep = "_")
metadata <- metadata[colnames(exprsMat), ]
spe <- SpatialExperiment::SpatialExperiment(assay = list(counts = exprsMat),
                                                colData = DataFrame(metadata),
                                                spatialCoordsNames = c("center_x",
                                                                       "center_y"))
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