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

Converting conos object to Seurat fails #34

Open
vtosevski opened this issue Apr 6, 2020 · 4 comments
Open

Converting conos object to Seurat fails #34

vtosevski opened this issue Apr 6, 2020 · 4 comments

Comments

@vtosevski
Copy link

Hi,
I am trying to use conos to integrate 18 samples and the workflow fails at the conversion step from conos to Seurat:

seurat.merged <- as.Seurat(seurats.con)
Merging 18 samples
Adding pairwise alignments to 'conos.pairs' in miscellaneous data
Adding graph as 'RNA_mnn'
Error in intI(i, n = d[1], dn[[1]], give.dn = FALSE) : 
  invalid character indexing
In addition: Warning message:
In CheckDuplicateCellNames(object.list = objects) :
  Some cell names are duplicated across objects provided. Renaming to enforce unique cell names.

The example code from SeuratWrappers conos vignette works fine.

Directly merging the same 18 seurat objects (same list from which the conos workflow starts) works fine as well.

seurat.merged <- merge(seurats[[1]], seurats[2:18], merge.data = F, project = "Merged")
Warning message:
In CheckDuplicateCellNames(object.list = objects) :
  Some cell names are duplicated across objects provided. Renaming to enforce unique cell names.

Any suggestions as to why conos workflow fails on my data?

Thanks,
Vinko

@akramdi
Copy link

akramdi commented Feb 4, 2021

Hi,

I have the same issue:

sobj <- as.Seurat(con)
Merging 10 samples
Adding pairwise alignments to 'conos.pairs' in miscellaneous data
Adding graph as 'SCT_mnn'
Error in intI(i, n = d[1], dn[[1]], give.dn = FALSE) : 
  invalid character indexing
In addition: Warning message:
In CheckDuplicateCellNames(object.list = objects) :
  Some cell names are duplicated across objects provided. Renaming to enforce unique cell names.

Were you finally able to convert from Conos to Seurat ?
Thanks,

@akramdi
Copy link

akramdi commented Feb 8, 2021

Well, I was able to spot the code that causes the error in as.Seurat function:

# Add graph
if (!is.null(x = x$graph)) {
graph <- paste(DefaultAssay(object = object), method, sep = '_')
message("Adding graph as '", graph, "'")
object[[graph]] <- as.Graph(x = get.adjacency(graph = x$graph)[colnames(x = object), colnames(x = object)])
}

Precisely in line 79:

object[[graph]] <- as.Graph(x = get.adjacency(graph = x$graph)[colnames(x = object), colnames(x = object)])
Error in intI(i, n = d[1], dn[[1]], give.dn = FALSE) :
invalid character indexing

Cell names retrieved bycolnames(object) do not match cell names present in the matrix returned by get.adjacency(graph = x$graph).

> colnames(object) %>% head()
[1] "AAACCCAAGGCGTCCT_1" "AAACCCACAACAGCCC_1" "AAACGAAAGCTTGTTG_1"
[4] "AAACGAACAGACACCC_1" "AAACGAAGTAACTTCG_1" "AAACGCTAGCGATGCA_1"

> head(get.adjacency(graph = con$graph))
6 x 20199 sparse Matrix of class "dgCMatrix"
   [[ suppressing 34 column names ‘ACCCTTGCAGCAGATG’, ‘AAACCCATCTAGACAC’, ‘CTGGTCTGTACACGCC’ ... ]]

I'm not sure at which level this can be efficiency fixed. Can one of the developers give some advice ?

Thanks,

@akramdi
Copy link

akramdi commented Feb 9, 2021

I actually forgot to check/fix duplicated cell names across samples before Conos integration...
For anyone with the same issue, here's how I fixed it (I used CheckDuplicateCellNames from Seurat):

## Check if we have duplicated cell names. If yes, fix it
if ( any(duplicated(unlist(lapply(objectList,colnames)))) ){
  objectList <- Seurat:::CheckDuplicateCellNames(objectList)
}

After running Conos integration, the conversion to Seurat works perfectly.

@vtosevski
Copy link
Author

Hi Amira,

I had not followed it further back then. I will keep this in mind next time I come around to it, it would be a very simple fix. Thanks for checking it more carefully.

Vinko

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

2 participants