Entering edit mode
14 months ago
Chris
▴
340
Hi Biostars friends,
I try to run this tutorial on my multiome data. The error I got mean my for loop tried to reach an index seem doesn't exist but don't know how to troubleshoot. Would you please have a suggestion? Thank you so much!
for (i in c("distal","promoter")) {
# Create GRanges
peaks.granges <- feature_metadata.atac_0 %>%
.[peak_type==i] %>%
.[,c("chr","start","end","peak")] %>%
makeGRangesFromDataFrame(keep.extra.columns = TRUE, ignore.strand = TRUE)
# Scan motifs throughout the DNA sequence of each peak and create a binary matrix of motif-peak presence.
motif.matrix <- CreateMotifMatrix(
features = peaks.granges,
pwm = pfm,
genome = 'hg38',
use.counts = FALSE
) %>% as.matrix
# AddChromatinAssay to the Seurat object
seurat@assays[[paste0("ATAC_",i)]] <- CreateChromatinAssay(
seurat@assays$ATAC@counts[peaks.granges$peak,],
ranges = peaks.granges,
motifs = CreateMotifObject(motif.matrix, pfm)
)
}
Error in .subscript.2ary(x, i, , drop = TRUE) : subscript out of bounds.
https://raw.githack.com/bioFAM/MOFA2_tutorials/master/R_tutorials/10x_scRNA_scATAC.html
The error is because of this: seurat@assays$ATAC@counts[peaks.granges$peak,]
but I still don't know what to do.