Skip to content

Error message when running FindTransferAnchors() #355

@chent5

Description

@chent5

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions