-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Creating a H5Seurat object error #172
Comments
Validating h5Seurat file And I'm sure I have this info in my dataset... |
Maybe you can try
|
Validating h5Seurat file did not work :/ |
They have changed the structure of the Seurat object with sc@assays$RNA@layers$counts rather than sc@assays$RNA@counts, so the save isn't recognising this difference when saving. Is it possible to have a version with the 'layers' bit added to the save and load Seurat Object? |
oh! Thank you!
can I assign like this:
sc["count"]<-as(object[["RNA"]],Class="Assay"
…On Wed, Jan 3, 2024 at 4:26 PM KerryAM-R ***@***.***> wrote:
They have changed the structure of the Seurat object with ***@***.***
***@***.***$counts rather than ***@***.******@***.***, so the save isn't
recognising this difference when saving.
Is it possible to have a version with the 'layers' bit added to the save
and load Seurat Object?
—
Reply to this email directly, view it on GitHub
<#172 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BEZNLDMKJ7GARFCTAYQJIB3YMV2B3AVCNFSM6AAAAABA26PPN6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNZVGU2DONZWHE>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
--
*Cecilia Pessoa Rodrigues PhD*
|
It is possible to "patch" each of Here it is for #' Patch of SeuratDisk::SaveH5Seurat function
#'
#' The "Assay5" class attribute "RNA" needs to be converted to a standard "Assay"
#' class for compatibility with SeuratDisk. It requires to make a temporary copy
#' so the size of the object grows bigger.
#'
#' @param object the Seurat object
#' @param filename the file path where to save the Seurat object
#' @param verbose SaveH5Seurat verbosity
#' @param overwrite whether to overwrite an existing file
#'
#' @return NULL
SaveH5SeuratObject <- function(
object,
filename,
verbose = TRUE,
overwrite = TRUE
) {
# add copy of "RNA"
object[["RNA-tmp"]] <- CreateAssayObject(counts = object[["RNA"]]$counts)
# remove original
object[["RNA"]] <- NULL
# export
SaveH5Seurat(object, filename = filename, overwrite, verbose)
return(NULL)
} And for #' Patch of SeuratDisk::LoadH5Seurat function
#'
#' The "Assay" class attribute "RNA" needs to be converted to the new "Assay5"
#' class. It requires to make a temporary copy so the size of the object grows
#' bigger.
#'
#' @param filename the file path where to save the Seurat object
#' @param verbose LoadH5Seurat verbosity
#'
#' @return NULL
LoadH5SeuratObject <- function(
filename,
verbose = TRUE
) {
# load h5 data
object <- LoadH5Seurat(filename)
# create "Assay5" class from old "Assay" class
keys <- Key(object)
slotID <- names(keys)[startsWith(keys, "rna")]
object[["RNA"]] <- CreateAssay5Object(counts = object[[slotID]]$counts)
# delete "Assay" class
object[[slotID]] <- NULL
# reorder assays list
object@assays <- object@assays[sort(names(object@assays))]
return(object)
} The biggest caveat is that it requires to make a copy of the RNA assay at each pass (saving or loading). A direct conversion would be preferable, but I have not found such a function in the SeuratObject package. EDIT: A better function would iterate over all assays and do what I did for RNA for each "Assay5" class assay. |
I have an object saved as h5Seurat and get the same error. What can I do to load it into R under Seurat5? I need to open it in order to save it with the function mentioned before... Any suggestions? sample.tumor <- LoadH5Seurat("/home/jovyan/sampletumor.h5Seurat") |
Dear all,
I'm trying to create a h5Seurat object, however, the data that comes out is corrupt.
I updated my datset:
sc <- UpdateSeuratObject(sc)
Validating object structure
Updating object slots
Ensuring keys are in the proper structure
Updating matrix keys for DimReduc ‘pca’
Updating matrix keys for DimReduc ‘umap’
Ensuring keys are in the proper structure
Ensuring feature names don't have underscores or pipes
Updating slots in RNA
Updating slots in RNA_nn
Setting default assay of RNA_nn to RNA
Updating slots in RNA_snn
Setting default assay of RNA_snn to RNA
Updating slots in pca
Updating slots in umap
Setting umap DimReduc to global
Setting assay used for NormalizeData.RNA to RNA
Setting assay used for FindVariableFeatures.RNA to RNA
Setting assay used for ScaleData.RNA to RNA
Setting assay used for RunPCA.RNA to RNA
Setting assay used for FindNeighbors.RNA.pca to RNA
No assay information could be found for FindClusters
Setting assay used for RunUMAP.RNA.pca to RNA
Validating object structure for Assay5 ‘RNA’
Validating object structure for Graph ‘RNA_nn’
Validating object structure for Graph ‘RNA_snn’
Validating object structure for DimReduc ‘pca’
Validating object structure for DimReduc ‘umap’
Object representation is consistent with the most current Seurat version
Warning message:
Adding a command log without an assay associated with it
An object of class Seurat
25567 features across 88261 samples within 1 assay
Active assay: RNA (25567 features, 2000 variable features)
3 layers present: counts, data, scale.data
2 dimensional reductions calculated: pca, umap
Seems right.
then:
SaveH5Seurat(sc, overwrite = TRUE)
Creating h5Seurat file for version 3.1.5.9900
Adding cell embeddings for pca
Adding loadings for pca
No projected loadings for pca
Adding standard deviations for pca
No JackStraw data for pca
Adding cell embeddings for umap
No loadings for umap
No projected loadings for umap
No standard deviations for umap
No JackStraw data for umap
But when I try to load my h5Seurat data I get this message:
Validating h5Seurat file
Error: Call assays must have either a 'counts' or 'data' slot, missing for RNA
What does it mean? Can you help me on that?
The text was updated successfully, but these errors were encountered: