Skip to content
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

Error in METAFlux Single-Cell Data Tutorial: Error in validObject(.Object): Duplicate rownames not allowed #5

Open
FLD-123 opened this issue Dec 27, 2023 · 9 comments

Comments

@FLD-123
Copy link

FLD-123 commented Dec 27, 2023

Hi METAFlux Developers,

Thank you so much for developing this wonderful tool.

I am currently exploring the METAFlux single-cell data tutorial, utilizing the single-cell data and other information provided by you. However, I encountered an error during the "mean_exp=calculate_avg_exp(myseurat = sc_test_example, myident = 'Cell_type', n_bootstrap=3, seed=1)" step.

The error message is as follows: "Error in validObject(.Object) : Duplicate rownames not allowed." Despite carefully inspecting the data, I couldn't identify any duplicated row names. If possible, could you kindly offer some solutions or guidance on how to address this issue?

Your assistance in resolving this matter would be greatly appreciated.

Thank you in advance.

Best regards,
Fulan Deng

@goterm
Copy link

goterm commented Jan 17, 2024

bumping into the same problem. It might be related to the package Matrix satijalab/seurat#7986
Tried with ‘Matrix’ 1.6-1.1 but >= 1.6.3 is required for METAFlux.
Any help would be appreciated,
Thanks

@Isaacyz
Copy link

Isaacyz commented Jan 18, 2024

Same Error, I referred to this one satijalab/seurat/issues/8164
Still have this Error:
Screenshot 2024-01-18 at 11 55 43 am

And my packages' versions:
Screenshot 2024-01-18 at 11 51 54 am

Thanks

@beata-malachowska
Copy link

Hi,
same issue here. I tried reinstalling Matrix package but it didn't help.
image

image and I'm using "Matrix_1.6-1.1". Please help if you could! Thanks in advance!

@snersesian
Copy link

I am running into the same issue after running previously with no issues. Looking for a solution as well- thanks so much!

@Fir-mahmud
Copy link

I am having the same issue, checked my Seurat object and all the features and there were no duplicate rows but still getting the error "> mean_exp=calculate_avg_exp(myseurat = patient_data,myident = 'celltype_by_marker',n_bootstrap=3,seed=1)
Error in validObject(.Object) :
invalid class ?LogMap? object: Duplicate rownames not allowed" Please suggest!!

@chloe-shard
Copy link

I have the same issue as well!

@osemarieRy
Copy link

It works with Seuat V4.

@yechanYS
Copy link

yechanYS commented Apr 13, 2024

I had the same issue as well and followed source code of calculate_avg_exp() function.
I found the same error message in line

SeuratObject<-suppressWarnings(
    CreateSeuratObject(count=sample, meta.data = meta.data))

which is included in get_ave_exp() function.

This error is caused by duplicated cell ids, generated from random sampling with replacement in the process of bootstrap.
Therefore, I added codes to edit cell ids to avoid duplication before creating seurat object and the function operated well without any error messages.

Below are the codes I used. If there are any issues or concerns, leave additional comment plsease.
Thanks.

generate_boots <- function(celltype, n) {
  dt <- data.frame(cluster = celltype, id = 1:length(celltype))
  index <- do.call(cbind, sapply(1:n, function(x) {
    splits <- dt %>%
      group_by(cluster) %>%
      sample_n(dplyr::n(), replace = TRUE) %>%
      ungroup() %>%
      dplyr::select("id")
  }))
  return(index)
}

get_ave_exp <- function(i, myseurat, samples,myident) {
  [email protected][samples[,i],]
  sample <-myseurat@assays$RNA@counts[,samples[,i]]
  name <- colnames(sample)
  for (j in 1:length(name)) {
    name[j] <- paste0(name[j], "_", j)
  }
  colnames(sample) <- name
  rownames(meta.data) <- name
  SeuratObject<-suppressWarnings(
    CreateSeuratObject(count=sample, meta.data = meta.data))
  SeuratObject<-NormalizeData(SeuratObject,verbose = TRUE)
  ave<-GetAssayData(AverageExpression(SeuratObject,group.by = myident,return.seurat = T), assay = "RNA") %>% as.data.frame()
  return(ave)
}

edit_calculate_avg_exp <- function(myseurat,myident,n_bootstrap,seed) {
  set.seed(seed)
  samples=generate_boots([email protected][,myident],n_bootstrap)
  exp <- lapply(1:n_bootstrap,get_ave_exp,myseurat,samples,myident)
  exp <- do.call(cbind, exp)
  return(exp)
}

mean_exp = edit_calculate_avg_exp(myseurat = sc, myident = 'celltype', n_bootstrap = 50, seed = 1)

@MOSAIFENG
Copy link

It works with Seuat V4.

yes! Seurat v4 works
remove.packages("Seurat")
remotes::install_version("Seurat", "4.4.0", repos = c("https://satijalab.r-universe.dev", getOption("repos")))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants