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 message when running FindTransferAnchors() #355

Closed
chent5 opened this issue Dec 5, 2020 · 8 comments
Closed

Error message when running FindTransferAnchors() #355

chent5 opened this issue Dec 5, 2020 · 8 comments
Labels
bug Something isn't working

Comments

@chent5
Copy link

chent5 commented Dec 5, 2020

Hi,

Thanks a lot for developing this very useful package. I got an error message when running FindTransferAnchors() to transfer the label from one scATAC data to another scATAC data.

Below is my code:

library(Seurat)
library(Signac)
library(S4Vectors)
library(patchwork)

# load reference data: scATAC
ref <- readRDS("scATAC_ref.rds")
DefaultAssay(ref) <- "peaks"

# load signac object
query <- readRDS("scATAC_query.rds")
DefaultAssay(query) <- "peaks"

# find peaks that intersect in both datasets
intersecting.regions <- findOverlaps(query = query, subject = ref)

# find the coordinates of peaks in the sci-ATAC-seq that intersect peaks in the 10x
intersections.tenx <- unique(queryHits(intersecting.regions))

# choose a subset of intersecting peaks
peaks.use <- sort(granges(query)[sample(intersections.tenx, size = 10000, replace = FALSE)])

# count fragments per cell overlapping the set of peaks in the 10x data
query_peaks_ref <- FeatureMatrix(
  fragments = Fragments(ref),
  features = peaks.use,
  cells = colnames(ref)
)

### create a new assay and add it to ref
ref[['qPeaks']] <- CreateChromatinAssay(
  counts = query_peaks_ref,
  min.cells = 1,
  ranges = peaks.use,
  genome = 'hg38'
)

DefaultAssay(ref) <- 'qPeaks'
ref <- RunTFIDF(ref)

### create a new assay in the query dataset containing the common peaks
peaknames <- GRangesToString(grange = peaks.use)

query[['qPeaks']] <- CreateChromatinAssay(
  counts <- GetAssayData(query, assay = "peaks", slot = "counts")[peaknames, ],
  ranges = peaks.use,
  genome = "hg38"
)

DefaultAssay(query) <- "qPeaks"
query <- RunTFIDF(query)

### find transfer anchors
transfer.anchors <- FindTransferAnchors(
  reference = ref,
  query = query,
  reference.assay = 'qPeaks',
  query.assay = 'qPeaks',
  reduction = 'cca',
  features = rownames(ref),
  k.filter = NA
)

Then, I got the error message below:

Binding matrix rows
Error in `rownames<-`(`*tmp*`, value = newmat.names) : 
  attempt to set 'rownames' on an object with no dimensions

I checked rownames for query and ref datasets. Both look fine:
image

Could you please help to solve this problem? Thank you so much!

@chent5 chent5 added the bug Something isn't working label Dec 5, 2020
@timoast
Copy link
Collaborator

timoast commented Dec 15, 2020

Which version of Signac are you using? Can you try updating to the current version on the develop branch and see if you still have the same issue?

@chent5
Copy link
Author

chent5 commented Dec 15, 2020

I am using v1.0.0.9000. Are there any significant changes between v1.0.0.9000 and the most updated version? My concern to update the package is whether the results generated by v1.0.0.9000 can be reproduced exactly the same by the most updated version?

@timoast
Copy link
Collaborator

timoast commented Dec 15, 2020

The differences between package versions are listed in the changelog: https://github.com/timoast/signac/blob/master/NEWS.md

For the purpose of determining if this bug has already been fixed, I'd suggest first trying with the latest version

@chent5
Copy link
Author

chent5 commented Dec 15, 2020

Thanks a lot for the link. I will try the latest version and let you know whether it works.

@chent5
Copy link
Author

chent5 commented Dec 18, 2020

I have updated to v1.1.0. I used the same code and got a similar error as below:

Error in `rownames<-`(`*tmp*`, value = newmat.names) : 
  attempt to set 'rownames' on an object with no dimensions
Calls: FindTransferAnchors ... merge.ChromatinAssay -> MergeOverlappingRows -> rownames<-
Execution halted

@timoast
Copy link
Collaborator

timoast commented Dec 23, 2020

If you're able to share those two objects (ref and query) I can take a look. You can email a download link to tstuart@nygenome.org

@chent5
Copy link
Author

chent5 commented Dec 28, 2020

I have shared the two objects, R script and log file with you by Box. Thank you so much for your help in advance!

@timoast
Copy link
Collaborator

timoast commented Jan 4, 2021

Thanks for sending the objects. This should now be fixed in the current develop version (1.1.9010), see the website for install instructions. If you're still having problems, I'd suggest re-creating the objects from raw data using the latest versions of Signac and Seurat.

@timoast timoast closed this as completed Jan 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants