cellgeni / sceasy

A package to help convert different single-cell data formats to each other
GNU General Public License v3.0
363 stars 53 forks source link

SCE to AnnData #9

Closed twfs closed 3 years ago

twfs commented 4 years ago

Hi, thanks for SCEasy! I'm trying to convert from a single cell experiment to AnnData and get:

Error in dn[[2L]] : subscript out of bounds Calls: ... .local -> lapply -> lapply -> FUN -> colnames -> colnames In addition: Warning message: In .regularise_df(as.data.frame(SummarizedExperiment::colData(obj))) : Dropping single category variables:orig.ident Execution halted

Example SCE RDS file attached: EC_sce.zip

Thanks for any help,

Tim

nh3 commented 4 years ago

Hi Tim,

Sorry for the late reply. It appears that the error is caused by irregularities in your object:

> str(rowData(rds))
Formal class 'DataFrame' [package "S4Vectors"] with 6 slots
  ..@ rownames       : chr [1:18620] "TSPAN6" "TNMD" "DPM1" "SCYL3" ...
  ..@ nrows          : int 18620
  ..@ listData       :List of 4
  .. ..$ gene                  : chr [1:18620] "TSPAN6" "TNMD" "DPM1" "SCYL3" ...
  .. ..$ gene.mean             : num [1:18620] NA NA NA NA NA NA NA NA NA NA ...
  .. ..$ gene.dispersion       : num [1:18620] NA NA NA NA NA NA NA NA NA NA ...
  .. ..$ gene.dispersion.scaled: num [1:18620(1d)] NA NA NA NA NA NA NA NA NA NA ...
  .. .. ..- attr(*, "dimnames")=List of 1
  .. .. .. ..$ : chr [1:18620] NA NA NA NA ...
  ..@ elementType    : chr "ANY"
  ..@ elementMetadata: NULL
  ..@ metadata       : list()

Notice that "$ gene.dispersion.scaled: num [1:18620(1d)] NA NA NA NA NA NA NA NA NA NA ..." is not a vector but a 1d array.

Make sure you install the latest sceasy code, and do

rds@rowRanges@elementMetadata@listData$gene.dispersion.scaled <- as.vector(rds@rowRanges@elementMetadata@listData$gene.dispersion.scaled)

before converting, and it should work.

twfs commented 4 years ago

Thanks for the fix. These objects were constructed using the SCE conversion methods in a previous Seurat package version. This may have been a bug in Seurat that has now been fixed, will try some more recent objects and see if that works.

Thanks again,

Tim