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

Difficult error message - bug or documentation issue? or problem on my object? #332

Closed
skilpinen opened this issue Nov 19, 2020 · 9 comments
Labels
question Further information is requested

Comments

@skilpinen
Copy link

Hi,

I wonder is there bug in the Signac code or in data objects, but I get following error:

peaks.to.genes <- LinkPeaks(seurat.object, peak.assay = "peaks", expression.assay = "RNA", n_sample=10, genes.use = G.a[1:10])
Testing 3 genes and 196807 peaks
Error in if (sum(x = links.keep) == 0) { :
missing value where TRUE/FALSE needed
In addition: Warning message:
In cor(x = as.matrix(x = bg.access), y = as.matrix(x = gene.expression), :
the standard deviation is zero

This is really hard to traceback why this error happens? Where exactly it finds Na where logical is needed? That seurat.object is otherwise working fine. And error is not dependent on that gene amount, I just dropped it to very small to quickly confirm repeat of this problem.

@skilpinen skilpinen added the question Further information is requested label Nov 19, 2020
@timoast
Copy link
Collaborator

timoast commented Nov 19, 2020

Does this still happen if you increase n_sample? It looks like the standard deviation for the background peak set is zero. To compute the z-score we divide by the sd, which would result in a division by zero in this case and give Inf.

I wouldn't recommend running this function with a very low n_sample value, I'd suggest 50 at a minimum.

@skilpinen
Copy link
Author

skilpinen commented Nov 19, 2020

Yes, it does happen. I just dropped n_sample to run it quick. However, I have here a seurat object with which this this function works and another with which it doesn't. Difference is that the one that does not work is subset of the one that works.

Works:
peaks.to.genes <- LinkPeaks(seurat.object, peak.assay = "peaks", expression.assay = "RNA", n_sample=10, genes.use = G.a[1:10])

Doesn't work:
P3GABA<-subset(seurat.object, idents=c("P3 GABAergic neurons","P3 GABAergic precursors","GABA/Ach", "FB GABA"))
peaks.to.genes <- LinkPeaks(P3GABA, peak.assay = "peaks", expression.assay = "RNA", n_sample=10, genes.use = G.a[1:10])

@timoast
Copy link
Collaborator

timoast commented Nov 19, 2020

How many cells are in the subset data?

@skilpinen
Copy link
Author

869 in subset, 3577 in original

@timoast
Copy link
Collaborator

timoast commented Nov 20, 2020

If you're able to share the subset object that recreates this error I can look into it further. You can email a download link to the object to tstuart@nygenome.org

@skilpinen
Copy link
Author

Yes, done.

@skilpinen
Copy link
Author

You can also directly email to Sami.Kilpinen@helsinki.fi

@timoast
Copy link
Collaborator

timoast commented Nov 24, 2020

This error was due to incorrect feature metadata being stored, which could happen if you run FindTopFeatures and then subset the object. This would cause the total counts for each peak to change, since cells are removed. Since LinkPeaks decides which peaks to use based on total accessibility, this cause problems where it was choosing peaks that actually had zero total counts in the dataset. I've pushed a fix to the develop branch that solves this issue by re-computing the feature metadata when an object is subset. You should be able to run:

devtools::install_github("timoast/signac", ref = "develop")
library(Signac)

obj <- FindTopFeatures(obj, min.cutoff = NA) # re-compute feature metadata
obj <- LinkPeaks(obj, ...)

@skilpinen
Copy link
Author

Yes, I confirm that this solved the issue. Thanks.

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

No branches or pull requests

2 participants