Nanostring-Biostats / InSituCor

InSituCor An R package for discovering modules of spatially correlated genes in spatial transcriptomics data.
Other
0 stars 0 forks source link

check mismatched rownames #5

Closed dan11mcguire closed 10 months ago

dan11mcguire commented 10 months ago

I was able to run through sparc where the cell_IDs in counts and the cell_IDs in conditionon were mismatched.

I think there should be a requirement to check this if the rownames are provided.

Its an easy mistake to make, especially if your 'conditionon' dataframe is reordered after a merge.

use_cells <- met[grep("neuron|L", cell_type),cell_ID]
resmismatch_cell_ID <- 
SPARC::sparc(counts = Matrix::t(normed)[sample(use_cells),] ## counts have out of order cell ids
             ,conditionon = data.frame(met[match(use_cells,cell_ID)
                                           ,.(cell_type = as.character(cell_type)
                                              ,nCount_falsecode
                                              ,nCount_negprobes
                                              ,nCount_RNA)]
                                       ,row.names = use_cells
                                       )
             ,celltype = as.character(met[match(use_cells,cell_ID)][["cell_type"]])
             ,neighbors = NULL
             ,radius = 0.1
             ,xy=as.matrix(met[match(use_cells,cell_ID)][,.(sdimx,sdimy)]
                           ,rownames = use_cells)
             )
patrickjdanaher commented 10 months ago

warning added