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

FindIntegrationAnchors error: Error in idx[i, ] <- res[[i]][[1]] #4803

Closed
ksaunders73 opened this issue Jul 18, 2021 · 7 comments
Closed

FindIntegrationAnchors error: Error in idx[i, ] <- res[[i]][[1]] #4803

ksaunders73 opened this issue Jul 18, 2021 · 7 comments

Comments

@ksaunders73
Copy link

I'm piggy-backing off of #3930. I got the error they got, except when running FindIntegrationAnchors().

combo <- merge(sobj_tnbc, y = c(sobj_ER, sobj_her, sobj_lumb), add.cell.ids = c("TNBC", "ER", "HER","ERHER"))
head(combo@meta.data)

combo.split <- SplitObject(combo, split.by = "Patient")

combo.split <- lapply(X = combo.split, FUN = function(x) {
  x <- FindVariableFeatures(x, selection.method = "vst", nfeatures = 2000)
})

features <- SelectIntegrationFeatures(object.list = combo.split)
combo.split <- lapply(X = combo.split, FUN = function(x) {
  x <- ScaleData(x, features = features, verbose = FALSE)
  x <- RunPCA(x, features = features, npcs = 10, verbose = FALSE)
})

immune.anchors <- FindIntegrationAnchors(object.list = combo.split, anchor.features = features, 
                                         reduction = "cca", dims = 1:10)

> Error in idx[i, ] <- res[[i]][[1]] : 
  number of items to replace is not a multiple of replacement length
In addition: Warning message:
In FilterAnchors(object = object.pair, assay = assay, slot = slot,  :
  Number of anchor cells is less than k.filter. Retaining all anchors.

My dataset is very small (549 cells) and also TPM normalized, so I have a feeling that has something to do with it:

image

image

I tried setting the k.anchor and k.filter to 10 (smaller than the smallest sample of 11), and the warning goes away, but the error remains

immune.anchors <- FindIntegrationAnchors(object.list = combo.split, anchor.features = features, 
                                         reduction = "cca", dims = 1:10, k.anchor = 10, k.filter = 10)
> Error in idx[i, ] <- res[[i]][[1]] : 
  number of items to replace is not a multiple of replacement length

Thanks for reading!

@ksaunders73
Copy link
Author

ksaunders73 commented Jul 21, 2021

I also want to add that I tried integrating this tiny dataset with five other much larger datasets (the next smallest of the five has around 1500 cells, and the largest has around 47k cells), and I think it is definitely the size of the dataset that is the issue and not the normalization, because when I removed this tiny 549 cell dataset, I was able to integrate the other 5 together (despite one of the 5 being FPKM normalized, but being larger at around 1700 cells). When I kept the tiny 549 cell dataset in, I still get the same error as mentioned above.

@yuhanH
Copy link
Collaborator

yuhanH commented Jul 23, 2021

hi @ksaunders73
Could you have a try that k.filter = NA and leave k.anchor to default setting?

@yuhanH yuhanH added the more-information-needed We need more information before this can be addressed label Jul 23, 2021
@ksaunders73
Copy link
Author

ksaunders73 commented Jul 24, 2021

Hello @yuhanH! This worked to get the FindIntegrationAnchors() working, but I get the error from #3930 with IntegrateData(), and it seems lowering the k.filter method doesn't work anymore. I did since my question increase the sample size cutoff to no less than 50 cells (whereas before there were samples between 30-50 cells in them). I haven't been getting the error since making the no less than 50 cutoff, so maybe the error was occurring because some samples only had like 30 cells or 11 cells?

@no-response no-response bot removed the more-information-needed We need more information before this can be addressed label Jul 24, 2021
@yuhanH
Copy link
Collaborator

yuhanH commented Jul 30, 2021

Hi @ksaunders73
You are right. In the IntegrateData function, we built a weight matrix between anchor cells and all other cells (k.weight).
If the object has too few cells, it may end up with an error. Also, when the object with few cells, it will violate many assumptions in our integration framework.

@yuhanH yuhanH closed this as completed Jul 30, 2021
@ksaunders73
Copy link
Author

Thank you very much for your help @yuhanH !

@BridgeLeeH
Copy link

Hi @ksaunders73
You are right. In the IntegrateData function, we built a weight matrix between anchor cells and all other cells (k.weight).
If the object has too few cells, it may end up with an error. Also, when the object with few cells, it will violate many assumptions in our integration framework.

Hi, a further question can be: although i know the object has too few cells, and it violates many assumptions in integration framework, then how should i address it?
I could not fix my bug when doing integrating analysis----''Error in idx[i, ] <- res[[i]][[1]] : number of items to replace is not a multiple of replacement length''. which scripts and where should i add in my current script?
Current scripts looks like:
immune.anchors <- FindIntegrationAnchors(object.list = c(E1, E2, C1, C2), anchor.features = 10000,
dims = 1:50, verbose = FALSE)
immune.integrated <- IntegrateData(anchorset = immune.anchors,dims=1:50, verbose = FALSE)

Step 1 has been finished, but step 2 runs into Error like mentioned above.

Thanks for your time.

@yuhanH
Copy link
Collaborator

yuhanH commented Sep 1, 2021

Hi, @BridgeLeeH
Maybe you can merge the small objects into the bigger one.

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

3 participants