dynverse / dyno

Inferring, interpreting and visualising trajectories using a streamlined set of packages 🦕
https://dynverse.github.io/dyno
Other
163 stars 32 forks source link

dynwrap: cell_ids swapped with feature_ids #70

Open emH-20 opened 4 years ago

emH-20 commented 4 years ago

I created the dynwrap using the wrap_expression and the counts and expression matrix.

object_counts<- as(as.matrix(object@assays$RNA@counts), 'sparseMatrix')
object_expression<- as(as.matrix(object@assays$RNA@data), 'sparseMatrix')
object_dyn<- wrap_expression(counts = object_counts, 
                                              expression = object_expression)

However, I found that the cell_ids and feature_ids were swapped. All of the cell_ids were in the feature_ids column and vice-versa. I swapped them manually. However, when I created the model, everything went back again to how they were, all the labels were mixed up. Not sure if the model is now accurate or not, and how to fix this. image

rcannood commented 4 years ago

Hello emH-20!

This is because in Seurat the columns represent cells, whereas in dyno the rows represent cells. To solve your problem, you need to transpose your input matrix:

object_counts <- Matrix::t(as(as.matrix(object@assays$RNA@counts), 'sparseMatrix'))
object_expression <- Matrix::t(as(as.matrix(object@assays$RNA@data), 'sparseMatrix'))
object_dyn<- wrap_expression(
  counts = object_counts, 
  expression = object_expression
)

We'll work on adding a Seurat wrapper to dyno in the future.

Robrecht

wfma commented 2 years ago

Hi Robrecht!

Just to follow up on this issue, this has worked great for smaller number of cells. I have a bigger patch of data that contains 48000 cells. Unfortunately as.matrix doesnt work with such a big matrix and gives the 'problem too large' error.

> as(as.matrix(seuratobj@assays$RNA@counts), 'sparseMatrix')
Error in asMethod(object) : 
  Cholmod error 'problem too large' at file ../Core/cholmod_dense.c, line 102

However I was able to transpose the count matrices, etc. with t_sp() from Baynorm package. I then run into a 'Error: !is.null(feature_ids) is not TRUE' error. I am still working on this and will update if I solve. In the meantime lmk if you have any new suggestions on this!