SydneyBioX / CellSPA

Cell Segmentation Performance Assessment
https://sydneybiox.github.io/CellSPA/
4 stars 1 forks source link

Error in readVizgen #2

Open pakiessling opened 1 year ago

pakiessling commented 1 year ago

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"))