welch-lab / liger

R package for integrating and analyzing multiple single-cell datasets
GNU General Public License v3.0
391 stars 78 forks source link

Loading a dataset generated with 'liger' using 'rliger' #318

Closed yesitsjess closed 1 month ago

yesitsjess commented 4 months ago

Hello,

I've downloaded a dataset published here 10.1038/s41590-023-01558-2

I installed rliger using install.packages("rliger") and observed the following message:

readLiger() is provided for reading an RDS file storing an old object and it converts the object to the up-to-date structure.

So I've attempted to load the dataset but I'm getting an error due to the change in package name:

> dolan <- readLiger(paste0(dolan_dir, "FinMg_Cellbender_annot_revision.rds"))
Loading required package: liger
Error in .requirePackage(package) : 
  unable to find required package ‘liger’
In addition: Warning message:
In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE,  :
  there is no package called ‘liger’

For now I've installed an old version of liger from the CRAN archive. Any advise, please?

theAeon commented 4 months ago

It should let you load it if you use dolan <- readRDS(paste0(dolan_dir, "FinMg_Cellbender_annot_revision.rds")) and then call convertOldLiger(dolan).

If the conversion fails, it should give you some relevant modifications to make w/ an old version.

mvfki commented 4 months ago

Hi,

So basically there's a namespace issue caused by that we changed the package name from liger to rliger at some point. And old archive from CRAN is not supposed to work because the reason we renamed it was that there was another totally unrelated package literally called liger and we couldn't conflict with it when we first released our package to CRAN years ago.

However, if you simply do obj <- readRDS(path) like what Andrew said above, you'll able to load the original object into your environment without conversion, even if it shows you error messages.

I had a look at the data you referred to but unfortunately there are quite a bit issues with the original object that block an automatic conversion from smoothly working. So you might really need some manual operation.

# load the original copy
dolan <- readRDS(paste0(dolan_dir, "FinMg_Cellbender_annot_revision.rds"))
# Here it should prompt some error about namespace, but don't worry, it loads

# Then you can just extract the raw count data, returned as a list
raw.data.list <- dolan@raw.data

# If you do want to work with the latest version of rliger, you can create an new object with the raw data
dolan.new <- createLiger(raw.data.list)

# If you just need the annotation or any other metadata
meta.data.frame <- dolan@cell.data

The main issue with the original object is about gene subsetting through each preprocessing stage, but the computation is really fast so you can just simply run those functions using the innocent raw data, namingly normalize(), selectGenes() and scaleNotCenter().

Hope this would be helpful.

yesitsjess commented 4 months ago

Hi,

So basically there's a namespace issue caused by that we changed the package name from liger to rliger at some point. And old archive from CRAN is not supposed to work because the reason we renamed it was that there was another totally unrelated package literally called liger and we couldn't conflict with it when we first released our package to CRAN years ago.

However, if you simply do obj <- readRDS(path) like what Andrew said above, you'll able to load the original object into your environment without conversion, even if it shows you error messages.

I had a look at the data you referred to but unfortunately there are quite a bit issues with the original object that block an automatic conversion from smoothly working. So you might really need some manual operation.

# load the original copy
dolan <- readRDS(paste0(dolan_dir, "FinMg_Cellbender_annot_revision.rds"))
# Here it should prompt some error about namespace, but don't worry, it loads

# Then you can just extract the raw count data, returned as a list
raw.data.list <- dolan@raw.data

# If you do want to work with the latest version of rliger, you can create an new object with the raw data
dolan.new <- createLiger(raw.data.list)

# If you just need the annotation or any other metadata
meta.data.frame <- dolan@cell.data

The main issue with the original object is about gene subsetting through each preprocessing stage, but the computation is really fast so you can just simply run those functions using the innocent raw data, namingly normalize(), selectGenes() and scaleNotCenter().

Hope this would be helpful.

This is really helpful thank you, I did get it loaded with the old version and working ok but I would quite like to try using new rliger. I'll try ASAP. Thanks again

mvfki commented 3 months ago

@yesitsjess Just worked on this a bit and the updated functionality is available in dev version now. You can install it with

if (requireNamespace("devtools", quietly = TRUE)
    install.packages("devtools")
devtools::install_github("mvfki/liger")

And then

library(rliger)
obj <- readLiger("path/to/data.rds", dimredName = "UMAP")