jbergenstrahle / SpatialCPie

MIT License
7 stars 1 forks source link

error while running the runCPie function #1

Open BhardwajArch opened 2 years ago

BhardwajArch commented 2 years ago

Hello

I would like to use SpatialCPie for the cluster identification for 10X visium spatial transcriptome data. Raw data was analysed in space-ranger pipeline. Next, processed data was stored in seurat object and prepared the count and spot matrix as follows :

data1_C1 <- object.list[1] counts_data <- data1_C1$C1@assays$SCT@counts head(counts_data) ## structure of count data 6 x XXX sparse Matrix of class "dgCMatrix" [[ suppressing XXXX column names ‘AAACAGAGCGACTCCT-1’, ‘AAACCGGGTAGGTACC-1’, ‘AAACCGTTCGTCCAGG-1’ ... ]]

AL627309.5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . LINC01409 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . LINC01128 . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 . . . . . . LINC00115 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . LINC02593 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . SAMD11 . . . . . . . . . . . 1 . . . . . . . . . . . . . . . . . . . . . .

get_xy_cord <- GetTissueCoordinates(data1_C1$C1) get_xy_cord # structure of tissue ordinates imagerow imagecol AAACAGAGCGACTCCT-1 140.30567 411.9432 AAACCGGGTAGGTACC-1 321.15719 167.4236 AAACCGTTCGTCCAGG-1 385.67684 219.4323 AAACGAAGAACATACC-1 88.82096 300.6550 AAACGGGCGTACGGGT-1 469.32312 401.2009 AAACTCGGTTCGCAAT-1 475.87334 323.3188

names(get_xy_cord) <- c("x","y") counts <- counts_data spots <- get_xy_cord

counts <- counts[, which(colnames(counts) %in% rownames(spots))]

repeat { d <- dim(counts) counts <- counts[rowSums(counts) >= 20, colSums(counts) >= 20] if (all(dim(counts) == d)) { break } }

Until the pre-processing step, everything works fine. But I am getting error at final step of the analysis.

runCPie( counts, resolutions = c(2, 5), assignmentFunction = function(k, x) cluster::pam(x, k = k)$clustering )

Error: invalid %<-% right-hand side, incorrect number of values

I would appreciate all the suggestions.

royfrancis commented 2 years ago

I got the same error and it went away after providing the argument spotCoordinates. Also counts needs to be a matrix and not dgCMatrix; as.matrix(counts).