You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi there, thanks for building and maintaining such a great package. Running into strange behavior of TSSEnrichment(): have a Seurat object built from 4 10X multiome samples (points to 4 different fragment files). When I call TSSEnrichment() on the object, the TSS enrichment score for all cells of the first 3 samples are zero, and there's a reasonable distribution of scores for the 4th and last sample.
I don't think this is a problem with annotation because it appears the score is being calculated for at least some of the cells and the same annotation is used for all samples.
Code used to generate the object:
### find input files, build object ###
matrix_path <- "my_path/"
count_files <- list.files(path = matrix_path, pattern = "filtered_feature_bc_matrix.h5$")
frag_files <- list.files(path = matrix_path, pattern = "atac_fragments.tsv.gz$")
sample_names <- gsub("_filtered_feature_bc_matrix.h5","",count_files)
counts <- lapply(paste0(matrix_path,count_files), Read10X_h5)
seu_list <- pblapply(seq_along(1:length(counts)), FUN = function(x) {
pbmc <- CreateSeuratObject(
counts = counts[[x]]$`Gene Expression`,
assay = "RNA"
)
pbmc[["ATAC"]] <- CreateChromatinAssay(
counts = counts[[x]]$Peaks,
sep = c(":", "-"),
fragments = paste0(matrix_path,frag_files[x]),
annotation = annotation
)
return(pbmc)
})
### call peaks on fragment files (a topic for another post perhaps) ###
peaks <- CallPeaks(paste0(matrix_path,frag_files), macs2.path = "macs2_path")
peaks <- keepStandardChromosomes(peaks, pruning.mode = "coarse")
peaks <- subsetByOverlaps(x = peaks, ranges = blacklist_hg38_unified, invert = TRUE)
### re-quantify with new peak set and merge ###
seu_list <- pblapply(seq_along(1:length(seu_list)), FUN = function(x) {
soi <- seu_list[[x]]
#create fragment object
frag_object <- CreateFragmentObject(path = paste0(matrix_path,frag_files[x]),
cells = colnames(soi))
#quantify counts in each peak
macs2_counts <- FeatureMatrix(frag_object,
features = peaks,
cells = colnames(soi))
soi[["ATAC"]] <- CreateChromatinAssay(macs2_counts,
fragments = frag_object,
annotation = annotation)
return(soi)
})
seu_combined <- merge(x = new_seu_list[[1]], y = new_seu_list[2:length(new_seu_list)],
add.cell.ids = sample_names)
The output of the TSSEnrichment call:
DefaultAssay(seu_combined) <- "ATAC"
seu_combined <- TSSEnrichment(seu_combined)
Extracting TSS positions
Extracting fragments at TSSs
|++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=03m 51snger object length is not a multiple of shorter object lengthnumber of items to replace is not a multiple of replacement lengthlonger object length is not a multiple of shorter object lengthnumber of items to replace is not a multiple of replacement length
|++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=03m 35snger object length is not a multiple of shorter object lengthnumber of items to replace is not a multiple of replacement lengthlonger object length is not a multiple of shorter object lengthnumber of items to replace is not a multiple of replacement length
|++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=02m 59snger object length is not a multiple of shorter object lengthnumber of items to replace is not a multiple of replacement lengthlonger object length is not a multiple of shorter object lengthnumber of items to replace is not a multiple of replacement length
|++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=03m 21snger object length is not a multiple of shorter object lengthnumber of items to replace is not a multiple of replacement lengthlonger object length is not a multiple of shorter object lengthnumber of items to replace is not a multiple of replacement length
Computing TSS enrichment score
I'm guessing the warning above points to the source of the problem. And as described above the only non-zero TSS enrichment scores appear in the last sample.
aggregate(seu_combined$TSS.enrichment, by = list(seu_combined$dataset), mean)
Group.1 x
1 VWT064_15A 0.00000
2 VWT064_15C 0.00000
3 VWT064_15F 0.00000
4 VWT064_16 5.02145
Would love to hear your thoughts! Hopefully I haven't made some mistake in the generation of the object that's causing this. Let me know if any other info would be helpful and I'm willing to share the object in case that's helpful.
Update
Calling TSSEnrichment() on each individual object before merging leads to the expected non-zero values for all samples
seu_list <- pblapply(seq_along(1:length(seu_list)), FUN = function(x) {
soi <- seu_list[[x]]
#create fragment object
frag_object <- CreateFragmentObject(path = paste0(matrix_path,frag_files[x]),
cells = colnames(soi))
#quantify counts in each peak
macs2_counts <- FeatureMatrix(frag_object,
features = peaks,
cells = colnames(soi))
soi[["ATAC"]] <- CreateChromatinAssay(macs2_counts,
fragments = frag_object,
annotation = annotation)
DefaultAssay(soi) <- "ATAC"
soi <- NucleosomeSignal(soi)
soi <- TSSEnrichment(soi)
return(soi)
})
seu_combined <- merge(x = seu_list[[1]], y = seu_list[2:length(seu_list)],
add.cell.ids = sample_names)
aggregate(seu_combined$TSS.enrichment, by = list(seu_combined$dataset), mean)
Group.1 x
1 VWT064_15A 5.110414
2 VWT064_15C 4.969871
3 VWT064_15F 5.121808
4 VWT064_16 5.021383
Hi there, thanks for building and maintaining such a great package. Running into strange behavior of
TSSEnrichment()
: have a Seurat object built from 4 10X multiome samples (points to 4 different fragment files). When I callTSSEnrichment()
on the object, the TSS enrichment score for all cells of the first 3 samples are zero, and there's a reasonable distribution of scores for the 4th and last sample.I don't think this is a problem with annotation because it appears the score is being calculated for at least some of the cells and the same annotation is used for all samples.
Code used to generate the object:
The output of the TSSEnrichment call:
I'm guessing the warning above points to the source of the problem. And as described above the only non-zero TSS enrichment scores appear in the last sample.
Would love to hear your thoughts! Hopefully I haven't made some mistake in the generation of the object that's causing this. Let me know if any other info would be helpful and I'm willing to share the object in case that's helpful.
Update
Calling TSSEnrichment() on each individual object before merging leads to the expected non-zero values for all samples
Sessioninfo
The text was updated successfully, but these errors were encountered: