welch-lab / liger

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

Issue with loading old liger object via convertOldLiger function #307

Open ellenbouchard opened 5 months ago

ellenbouchard commented 5 months ago

Dear Welch lab/liger team,

I'm hoping for some help with figuring out how to load in an old liger object that is giving me issues.

The object is from a previously published dataset from early 2023. I'm happy to include a link to the dataset here, if necessary.

When I first attempt to load in the object using readRDS I get the following error:

Error in .checkObjVersion(): ! Old version of liger object is detected. Please run: object <- convertOldLiger(object)

When I then try to run the indicated convertOldLiger function, I get the following error:

! Skipped slot U which is not available. ✖ Inconsistent row ID in slot normData. Error in validObject(.Object) : invalid class “ligerDataset” object: Features in scaleData not found from dataset: [features]

and the object fails to load.

The problem is, because I can't get the object loaded in any form, I can't try and troubleshoot any individual steps of the object conversion function.

Any tips, advice, or feedback would be greatly appreciated! Thank you very much for your time.

mvfki commented 5 months ago

Hi,

Thanks for trying out our new version. Two things I can think of:

  1. By readRDS(), to my experience, the object is indeed loaded into the environment but just not shown in the "environment" panel of your RStudio. If you try operators like:
obj <- readRDS("oldfile.rds")
obj@norm.data

It should show you a list of normalized matrices. and similar for the obj@scale.data

  1. However, force doing those above should probably keep spamming error messages on your screen. You can downgrade the package back to version 1.0.1 and normally load it, and have checks on the colnames and rownames of the matrices. In rliger2.0.0, we added strict checkpoints for cell and feature consistency to prevent potentially erroneous operations. What you will want to look at is, regard the row/colnames of the obj@raw.data as the baseline, see if those in norm.data are identical. scale.data should be feature subset and transposed (cell x gene) in the old version, and you can see if the features are available in rownames(obj@raw.data[["datasetName"]]).

Above is kind of the overall idea of what should be taken care of, please feel free to reach out if you still see a problem.

Here's a figure on the new documentation website that roughly shows how the structure of a liger object is refactored:

ligerObjDemo

Let's keep this Issue open for people coming for rliger2 structure issues.

Appreciate it! Yichen

ellenbouchard commented 5 months ago

Thank you very much for the quick response and helpful resources! I will try that and add an update here with the outcome.

UDPATE: I was able to easily generate the new liger object by first reading in the old liger object as before and then manually working through the steps in the convertOldLiger function. (However, upon further inspection of the original object, I discovered that it does not include some critical metadata for my intended analysis, so I will have to stop at this point).

mvfki commented 5 months ago

Nice to hear that! By metadata did you mean some variables in obj@cell.data? You can use cellMeta<- method to manually insert any variable since you've already constructed an object of the new version. If a variable is named, the names will also be checked. Note that a prefix like "{datasetName}_" might have been added to the object colnames so that might creat some barriers.